Example #1
0
  */
 protected function beforeAction($action)
 {
     $this->CheckLogin();
     return parent::beforeAction($action);
 }
 /**
  * <Jason>
  * <To added a document into gridview in tenancy details page>
  */
 public function actionUploadDocument()
 {
     try {
         $model = new ProTransactionsPropertyDocument('upload');
         if (isset($_POST['ProTransactionsPropertyDocument'])) {
             $model->attributes = $_POST['ProTransactionsPropertyDocument'];
             $model->transactions_id = $_GET['transaction_id'];
             $model->user_id = Yii::app()->user->id;
             $model->file_name = CUploadedFile::getInstance($model, 'file_name');
             if ($model->validate()) {
                 if (!$model->getErrors()) {
                     if ($model->save()) {
                         if (!is_null($model->file_name)) {
                             $model->file_name = ProTransactionsPropertyDocument::saveFile($model, 'file_name', ProTransactionsPropertyDocument::$folderUpload, $model->order_no);
                             $model->update(array('file_name'));
                         }
                         Yii::app()->user->setFlash('success', "Your report defect has been insert successfully!");
                         $model->title = '';
                         die('<script type="text/javascript">parent.$.fancybox.close(); parent.fnUpdateGridView("#document-grid");   </script>');
 public static function SaveFileDocument($mFile, $title, $key, $id_transaction)
 {
     $mFile->transactions_id = $id_transaction;
     $mFile->title = InputHelper::removeScriptTag($title);
     $mFile->order_no = $key;
     $mFile->file_name = CUploadedFile::getInstance($mFile, 'file_name[' . $key . ']');
     if (!is_null($mFile->file_name)) {
         $mFile->file_name = ProTransactionsPropertyDocument::saveFile($mFile, 'file_name', ProTransactionsPropertyDocument::$folderUpload, $key);
     }
     if (!empty($mFile->title)) {
         $mFile->save();
         $response['code'] = true;
         $response['message'] = 'successfully';
     }
 }
             $link = Yii::app()->createAbsoluteUrl('member/agent/view', array('tenancy' => $mTransactions->id));
             $this->redirect($link);
             // may be redirect to view
         }
     }
 }
 // Dec 01, 2014 xử lý bắt biến post và gọi validate cho các model, tách ra cho dễ nhìn
 public function GetPostAndValidateTenancy($mTransactions)
 {
     $this->GetPostOnly($mTransactions);
     $mTransactions->validate();
     $mTransactions->mPropertyDetail->validate();
     if ($mTransactions->type == ProTransactions::FOR_RENT) {
         // it alway for rent
         if (!empty($mTransactions->mTenatDefault->user_id)) {
             $mTransactions->mTenatDefault->scenario = 'AgentAddTenantExitUid';
         }
         $mTransactions->mTenatDefault->validate();
         Users::validateDefaultTenant($mTransactions->mTenatDefault);
     }
     // chưa xử lý gì phần validate này ProTransactionsPropertyDocument
     ProTransactionsPropertyDocument::validateFile($mTransactions);
     if ($mTransactions->type == ProTransactions::FOR_RENT) {
         ProTransactions::validateLandlordTenant($mTransactions);
     } else {
         // for sale - validate for vendor and purcharser
         ProTransactions::validateVendorPurchaser($mTransactions);
     }
 }
 /**
  * @Author: ANH DUNG Jan 13, 2015
  * @Todo: get attribute from post
  */
 public function GetPostOnly(&$mTransactions)
 {
     $mTransactions->attributes = $_POST['ProTransactions'];
     $mTransactions->mPropertyDetail->attributes = $_POST['ProTransactionsPropertyDetail'];
     $mTransactions->mPropertyDocument = new ProTransactionsPropertyDocument();
     $mTransactions->mPropertyDocument->attributes = $_POST['ProTransactionsPropertyDocument'];
     $mTransactions->mTenatDefault->attributes = isset($_POST['ProTransactionsVendorPurchaserDetail']) ? $_POST['ProTransactionsVendorPurchaserDetail'] : array();
     $mTransactions->mTenatDefault->scanned_employment_pass = CUploadedFile::getInstance($mTransactions->mTenatDefault, 'scanned_employment_pass');
     $mTransactions->mTenatDefault->scanned_passport = CUploadedFile::getInstance($mTransactions->mTenatDefault, 'scanned_passport');
 }
 /**
  * @Author: ANH DUNG Jan 13, 2015
  * @Todo: Handle SaveAsDraft
  */
 public function HandleSaveAsDraft($mTransactions)
 {
     if (isset($_POST['SaveAsDraft']) && $_POST['SaveAsDraft'] == 1) {
         $this->GetPostOnly($mTransactions);
         $this->HandleSaveAsDraftOnlySave($mTransactions);
         $link = Yii::app()->createAbsoluteUrl('member/agent/tenancy', array('status' => STATUS_TENANCY_DRAFT));
         $this->redirect($link);
         // may be redirect to view
     }
 }
 /**
  * @Author: ANH DUNG Jan 13, 2015
  * @Todo: Save Draft Only
  * @Param: $mTransactions
  */
 public function HandleSaveAsDraftOnlySave(&$mTransactions)
 {
     ProTransactions::convertToDbDate($mTransactions);
     $prefix_code = "T" . date('Y') . date('m');
     if (!isset($_GET['update_transactions'])) {
         $mTransactions->transactions_no = MyFormat::getNextId('ProTransactions', $prefix_code, 'transactions_no', ProTransactions::LENGTH_TRANS_NO);
     }
     $mTransactions->status = STATUS_TENANCY_DRAFT;
     $mTransactions->update();
     // update transaction
     // save  mPropertyDetail
     $mTransactions->mPropertyDetail->transactions_id = $mTransactions->id;
     $mTransactions->mPropertyDetail->listing_id = $mTransactions->listing_id;
     $mTransactions->mPropertyDetail->scenario = null;
     $mTransactions->mPropertyDetail->save();
     // save tenant
     if ($mTransactions->type == ProTransactions::FOR_RENT) {