function getPaymentSerialNo($id = null) { App::import("Model", "UploadPayment"); $upload = new UploadPayment(); $status = $upload->find("first", array("conditions" => array("UploadPayment.ref_id" => $id))); if (empty($status)) { $serial_no = 01; } else { $status = $upload->find("first", array("conditions" => array("UploadPayment.ref_id" => $id), 'order' => array('UploadPayment.serial_no' => 'DESC'))); $serial_no = $status['UploadPayment']['serial_no'] + 1; } return $serial_no; }
function download_single_file_payment($id) { App::import("Model", "UploadPayment"); $upload_model = new UploadPayment(); if (!$id) { $this->Session->setFlash(__('Invalid id for upload', true)); $this->redirect(array('action' => 'index')); } $upload = $upload_model->find('first', array('conditions' => array('UploadPayment.id' => $id))); if (!$upload) { $this->Session->setFlash(__('Invalid id for upload', true)); $this->redirect(array('action' => 'index')); } $this->viewClass = 'Media'; $filename = $upload['UploadPayment']['filename']; $this->set(array('id' => $upload['UploadPayment']['id'], 'name' => substr($filename, 0, strrpos($filename, '.')), 'extension' => substr(strrchr($filename, '.'), 1), 'path' => APP . 'uploads' . DS . $upload['UploadPayment']['ref_model'] . DS . $upload['UploadPayment']['ref_id'] . DS, 'download' => true)); }
function delete_single_file_payment($work_order_id, $id) { App::import("Model", "UploadPayment"); @($upload_model = new UploadPayment()); if (!$id) { $this->Session->setFlash(__('Invalid id for delete', true)); $this->redirect(array('action' => 'index')); } @$upload_model->delete($id); $this->redirect("http://{$_SERVER['SERVER_NAME']}{$this->webroot}work_order_manager/work_orders/detail/{$work_order_id}#payment-info"); }