public function actionSavePayment() { $data = $this->sessionInfo(); if (Yii::app()->user->checkAccess('payment.index')) { if (isset($_POST['ReceivingPayment'])) { $data['model']->attributes = $_POST['ReceivingPayment']; if ($data['model']->validate()) { $paid_amount = $_POST['ReceivingPayment']['payment_amount']; $paid_date = Date('Y-m-d H:i:s'); $note = $_POST['ReceivingPayment']['note']; if ($paid_amount <= $data['balance']) { $data['payment_id'] = ReceivingPayment::model()->batchPayment($data['supplier_id'], $data['employee_id'], $data['account'], $paid_amount, $paid_date, $note); if (substr($data['payment_id'], 0, 2) == '-1') { $data['warning'] = $data['payment_id']; } else { $data = $this->sessionInfo(); $data['warning'] = $data['fullname'] . ' Successfully paid '; $this->renderPartial('_payment_success', $data); exit; } } else { $data['model']->addError('payment_amount', Yii::t('app', 'Total amount to paid is only') . ' <strong>' . number_format($data['balance'], Yii::app()->shoppingCart->getDecimalPlace()) . '</strong>'); } } } } else { throw new CHttpException(403, 'You are not authorized to perform this action'); } if (Yii::app()->request->isAjaxRequest) { Yii::app()->clientScript->scriptMap['*.js'] = false; Yii::app()->clientScript->scriptMap['jquery-ui.css'] = false; Yii::app()->clientScript->scriptMap['box.css'] = false; $this->renderPartial('_payment', $data, false, true); } else { $this->render('_payment', $data); } }
protected function saveReceivePayment($receive_id, $payment_id, $payment_amount, $paid_date, $note, $payment_type = 'Cash') { $receive_payment = new ReceivingPayment(); $receive_payment->receive_id = $receive_id; $receive_payment->payment_id = $payment_id; $receive_payment->payment_type = $payment_type; $receive_payment->payment_amount = $payment_amount; $receive_payment->date_paid = $paid_date; $receive_payment->note = $note; $receive_payment->save(); }