$model->property_id = $enquiry; $model->get_update = 1; if ($model->save()) { /* * ----------------- * dtoan : send mail * ----------------- */ SendEmail::sendEmailShortList($model); } } $thankYouEnquiry = Pages::getPageById(PAGE_THANK_ENQUIRY_PROPERTY); Yii::app()->user->setFlash('success', $thankYouEnquiry->content); // $this->redirect(Yii::app()->createAbsoluteUrl('site/thankyou')); $this->redirect(Yii::app()->createAbsoluteUrl('page/index', array('slug' => 'thank-you-message-for-sending-global-enquiry'))); } } $this->render('normal_user/sendEnquiry', array('model' => $model, 'listing' => $listing)); } else { throw new CHttpException(404, 'Invalid request. Please do not repeat this request again.'); } } /** * @Author: ANH DUNG Mar 27, 2014 * @Todo: dùng để tạo mới và update transaction - khá là rối logic - be careful * @param: $type: 1: for sale, 2: for rent * @param: $listing_id: listing_id */ // public function actionCreateTransaction($type, $listing_id){ public function actionCreateTransaction($type) { /** 1. get thông tin user login * 2. createnew tạo mới 1 transaction với status tạm =0, sau đó get thông tin liên quan * 3. get thông tin của listing đưa vào model của $mTransactionsPropertyDetail * 4. get thông tin của ,1: vendor,2: purchaser, 3: Landlord, 4: Tenant Purchaser’s Details, External Co-broke details * */ MyFormat::validateUserAccess(ROLE_AGENT); $this->pageTitle = "Create Transaction - " . Yii::app()->params['title']; // try { $mUser = Users::model()->findByPk(Yii::app()->user->id); $listing_id = 0; if (isset($_GET['listing_id'])) { $listing_id = $_GET['listing_id']; } // Dec 02, 2014 $add_property = ProTransactions::ADD_EXISTING; if (isset($_GET['add_property']) && in_array($_GET['add_property'], ProTransactions::$LIST_ADD_PROPERTY)) { $add_property = $_GET['add_property']; } // Dec 02, 2014 if (!isset($_GET['id'])) { $mTransactions = ProTransactions::CreateNewRecordTransaction($type, $listing_id); $this->redirect(array('createTransaction', 'id' => $mTransactions->id, 'type' => $type, 'listing_id' => $listing_id, 'add_property' => $add_property, 'list' => $_GET['list'])); } else { $mTransactions = ProTransactions::getByPk($_GET['id']); } $this->validateLink($type, $listing_id, $add_property); // OPEN IT $this->GetSomeInfo($mTransactions, $type, $add_property); if (isset($_POST['ProTransactionsPropertyDetail'])) { $this->GetPostAndValidate($mTransactions); if (!$mTransactions->hasErrors() && !$mTransactions->mPropertyDetail->hasErrors() && !$mTransactions->mBillTo->hasErrors() && !$mTransactions->mTenatDefault->hasErrors() && !$mTransactions->mLandlord->hasErrors() && !$mTransactions->mTenant->hasErrors() && !$mTransactions->mVendor->hasErrors() && !$mTransactions->mPurchaser->hasErrors() && !$mTransactions->mPropertyDocument->hasErrors()) { $mTransactions->invoice_bill_to = $mTransactions->mBillTo->bill_to_id; ProTransactions::convertToDbDate($mTransactions); $prefix_code = 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_ACTIVE; $mTransactions->update(); // update transaction // save mPropertyDetail $mTransactions->mPropertyDetail->transactions_id = $mTransactions->id; $mTransactions->mPropertyDetail->listing_id = $mTransactions->listing_id; $mTransactions->mPropertyDetail->save(); //save mBillTo $mTransactions->mBillTo->transactions_id = $mTransactions->id; $mTransactions->mBillTo->client_type_id = $mTransactions->client_type_id; $mTransactions->mBillTo->type = ProTransactionsBillTo::TYPE_VENDOR_PURCHASER; $mUserBillTo = Users::saveUserExternalCoBroke($mTransactions->mBillTo, ROLE_EXTERNAL_CO_BROKE); $mTransactions->mBillTo->user_id = $mUserBillTo->id; $mTransactions->mBillTo->save(); // save mBillTo // save tenant if ($mTransactions->type == ProTransactions::FOR_RENT) { $mTransactions->mTenatDefault->transactions_id = $mTransactions->id; ProTransactionsVendorPurchaserDetail::saveOneTenant($mTransactions->mTenatDefault, 1); // update new expiration date for tenant to check login ProTransactionsVendorPurchaserDetail::updateExpirationTenant($mTransactions); } // end save tenant //save ProTransactionsPropertyDocument /* Closed by HTram, because it were uploaded by ajax at the form