/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     try {
         $model = new ProTransactionsInvoice('GenVoucher');
         $model->transactions_id = $id;
         $this->layout = 'ajax';
         $model->receipt_date_paid = date('d/m/Y');
         $mTrans = $model->rTransaction;
         $model->voucher_ma_gross_comm = 0;
         if (isset($_POST['ProTransactionsInvoice'])) {
             $model->attributes = $_POST['ProTransactionsInvoice'];
             $model->validate();
             if (!$model->hasErrors()) {
                 ProTransactionsInvoice::DoGenVoucher($model, $mTrans);
                 die('<script type="text/javascript">parent.$.fn.colorbox.close(); parent.$.fn.yiiGridView.update("pro-transactions-invoice-grid");</script>');
             }
         }
         $this->render('create', array('model' => $model, 'mTrans' => $mTrans, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }
 /**
  * @Author: ANH DUNG Jul 09, 2014
  * @Todo: gen some voucher for transaction
  * @Param: $transactions_id
  */
 public function actionAjaxGenVoucher($transactions_id)
 {
     if (Yii::app()->request->isPostRequest) {
         $model = $this->loadModel($transactions_id);
         if ($model->status == STATUS_GEN_INVOICE) {
             ProTransactionsInvoice::DoGenVoucher($model);
             $model->status = STATUS_GEN_VOUCHER;
             $model->update(array('status'));
         }
     }
     die;
 }