public function actionUpdateVoucher($id) { $model = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); $cmsFormater = new CmsFormatter(); if ($model) { if (!FiPaymentVoucher::CanUpdate($model)) { $this->redirect(array('index')); } $model->scenario = 'update_voucher'; $dataTmp = ''; if (isset($_POST['FiPaymentVoucher'])) { $model->attributes = $_POST['FiPaymentVoucher']; if ($model->validate()) { $statusTmp = MyFormat::loadModelByClass($id, 'FiPaymentVoucher'); if ($statusTmp->status != STATUS_ACTIVE && $model->status == STATUS_ACTIVE && empty($model->date_paid)) { $model->date_paid = date('Y-m-d'); } if ($model->save()) { //save detail FiPaymentVoucherDetail::saveDetailWithVoucherID($model->id, $_POST['FiPaymentVoucherDetail']); } $this->redirect(Yii::app()->createAbsoluteUrl('admin/fiInvoice/viewvoucher', array('id' => $id))); } } else { $model->created_date = date('d-m-Y', strtotime($model->created_date)); // $model->date_paid = ($model->date_paid !='' && $model->date_paid !='0000-00-00') ? date('d-m-Y',strtotime($model->date_paid)) : date('d-m-Y'); $model->date_paid = $cmsFormater->formatDatePickerInput($model->date_paid); $dataTmp = FiPaymentVoucherDetail::getDataWithWithVoucherID($id); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } $this->render('payment_voucher', array('actions' => $this->listActionsCanAccess, 'model' => $model, 'dataTmp' => $dataTmp)); }
/** * @Author: ANH DUNG Sep 12, 2014 * @Todo: calc report yearly * @Param: $model model * @Param: $aRes var return * @Param: $date_from 2014-05-25 * @Param: $date_to model 2014-09-25 */ public static function ReporYearly($model, &$aRes, $date_from, $date_to) { $criteria = new CDbCriteria(); $criteria->addBetweenCondition("t.date_paid", $date_from, $date_to); $criteria->compare('t.status', FiInvoice::PAID); $criteria->select = "sum(total_amount_due) as total_amount_due, " . "year(t.date_paid) as year_paid, count(t.id) as count_record"; $criteria->group = "year(t.date_paid)"; $criteria->order = "t.date_paid"; $models = self::model()->findAll($criteria); foreach ($models as $item) { $aRes['TOTAL_AMOUNT_INVOICE'][$item->year_paid] = $item->total_amount_due; $aRes['COUNT_TRANS'][$item->year_paid] = $item->count_record; $aRes['LOOP_VAR'][$item->year_paid] = 1; } $criteria->select = "sum(total_amount) as total_amount," . "year(t.date_paid) as year_paid, count(t.id) as count_record"; $mVoucher = FiPaymentVoucher::model()->findAll($criteria); foreach ($mVoucher as $item) { $aRes['TOTAL_AMOUNT_VOUCHER'][$item->year_paid] = $item->total_amount; $aRes['LOOP_VAR'][$item->year_paid] = 1; } }
<?php $this->breadcrumbs = array('Payment Vouchers Management' => array('paymentvouchers'), 'View Voucher'); $menus = array(array('label' => 'Payment Vouchers Management', 'url' => array('paymentvouchers')), array('label' => 'Create Voucher', 'url' => array('createvoucher')), array('label' => 'Update Voucher', 'url' => array('updateVoucher', 'id' => $model->id)), array('label' => 'Delete Voucher', 'url' => array('DeleteVoucher'), 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?'))); $this->menu = ControllerActionsName::createMenusRoles($menus, $actions); $cmsFormater = new CmsFormatter(); ?> <h1>View Voucher: <?php echo $model->voucher_no; ?> </h1> <?php $this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'pay_to', 'value' => FiPaymentVoucher::getStatus($model->pay_to)), 'voucher_no', 'user_name', 'nric', 'user_billing_address', 'user_postal_code', 'total_amount:Price', array('name' => 'payment_mode', 'type' => 'VoucherPaymentMode', 'value' => $model), 'cheque_number', 'bank_reference_no', 'date_paid:date'))); $this->renderPartial('payment_vouchers/view_from_voucher', array('model' => $model, 'dataTmp' => $dataTmp));