protected function beforeDelete() { FiInvoiceDetail::DeleteByInvoiceId($this->id); FiInvoiceReceipt::DeleteByInvoiceId($this->id); return parent::beforeDelete(); }
/** * @Author: ANH DUNG Sep 12, 2014 * @Todo: GenerateReceipt * @Param: $invoice_id */ public function actionGenerateReceipt($invoice_id) { try { $mInvoice = $this->loadModel($invoice_id); $this->layout = 'ajax'; $model = new FiInvoiceReceipt('GenerateReceipt'); $model->receipt_date_paid = date('d/m/Y'); $model->invoice_id = $mInvoice->id; if (isset($_POST['FiInvoiceReceipt'])) { $model->attributes = $_POST['FiInvoiceReceipt']; if ($model->save()) { FiInvoice::UpdateStatusInvoice($mInvoice, FiInvoice::PAID); die('<script type="text/javascript">parent.$.fn.colorbox.close(); parent.$.fn.yiiGridView.update("fi-invoice-grid");</script>'); } } $this->render('GenerateReceipt', array('model' => $model, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }