Esempio n. 1
0
 public function run()
 {
     $model = new ProGlobalEnquiry('create');
     $model->country_id = ActiveRecord::getDefaultAreaCode();
     if (isset(Yii::app()->user->id)) {
         $model->name = Yii::app()->user->title . ' ' . Yii::app()->user->first_name . ' ' . Yii::app()->user->last_name;
         $model->email = Yii::app()->user->email;
         if (Yii::app()->user->role_id != ROLE_REGISTER_MEMBER) {
             $model->email = Yii::app()->user->email_not_login;
         }
         $model->phone = Yii::app()->user->phone;
         $model->country_id = Yii::app()->user->country;
     }
     if (isset(Yii::app()->user->id)) {
         $cmsFormater = new CmsFormatter();
         $mUser = Users::model()->findByPk(Yii::app()->user->id);
         $model->name = $cmsFormater->formatFullNameRegisteredUsers($mUser);
         $model->email = $mUser->email;
         $model->nric = $mUser->nric_passportno_roc;
         $model->phone = $mUser->phone;
         if (Yii::app()->user->role_id == ROLE_LANDLORD || Yii::app()->user->role_id == ROLE_TENANT) {
             $model->phone = $mUser->contact_no;
             $model->email = $mUser->email_not_login;
         }
         if (Yii::app()->user->role_id == ROLE_AGENT) {
             $model->email = $mUser->email_not_login;
         }
     }
     //        $model->type_selling= 'Tenancy';
     $box = Pages::getPageById(PAGE_ENGAGE_US_BOX);
     $this->render("global_enquiry", array('model' => $model, 'box' => $box));
 }
Esempio n. 2
0
 public function run()
 {
     $box = Pages::getPageById(PAGE_PROPERTY_BOX);
     $model = new ProEnquiryProperty();
     $mListing = Listing::model()->findByPk($this->property_id);
     //        echo $mListing->property_name_or_address;die;
     Listing::ReplaceContentCmsPage($box, $mListing);
     $model->country_id = ActiveRecord::getDefaultAreaCode();
     if (isset(Yii::app()->user->id)) {
         $model->name = Yii::app()->user->title . ' ' . Yii::app()->user->first_name . ' ' . Yii::app()->user->last_name;
         $model->email = Yii::app()->user->email;
         if (Yii::app()->user->role_id != ROLE_REGISTER_MEMBER) {
             $model->email = Yii::app()->user->email_not_login;
         }
         $model->phone = Yii::app()->user->phone;
         $model->country_id = Yii::app()->user->country;
     }
     $this->dir = Yii::getPathOfAlias('application.components.views') . '/_agent_detail.php';
     $model->description = trim(strip_tags($box->content));
     if ($this->position == "bottom") {
         $this->render("enquiry_bottom", array('model' => $model, 'box' => $box, 'property_id' => $this->property_id, 'agent_id' => $this->agent_id, 'dir' => $this->dir, 'position' => 'bottom'));
     } else {
         $this->render("enquiry_right", array('model' => $model, 'box' => $box, 'property_id' => $this->property_id, 'agent_id' => $this->agent_id, 'dir' => $this->dir, 'position' => 'right'));
     }
 }
Esempio n. 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     try {
         $model = new Users('create_agent');
         $model->area_code_id = ActiveRecord::getDefaultAreaCode();
         $model->country_id = ActiveRecord::getDefaultAreaCode();
         $model->license = Yii::app()->params['company_license'];
         $model->agent_company_name = Yii::app()->params['company_name'];
         $this->ajaxGetFirstTier($model);
         if (isset($_POST['Users'])) {
             $model->attributes = $_POST['Users'];
             $model->role_id = ROLE_AGENT;
             $model->temp_password = $_POST['Users']['password_hash'];
             $model->application_id = FE;
             $model->avatar = CUploadedFile::getInstance($model, 'avatar');
             $model->agent_company_logo = CUploadedFile::getInstance($model, 'agent_company_logo');
             $model->validate();
             if (!$model->hasErrors()) {
                 $model->save();
                 $model->password_hash = md5($_POST['Users']['password_hash']);
                 $model->scenario = NULL;
                 $model->update(array('password_hash'));
                 $model->save();
                 if (!is_null($model->avatar)) {
                     $model->avatar = Users::saveImage($model, 'avatar');
                     Users::resizeImage($model, 'avatar', Users::$aSize);
                     $model->update(array('avatar'));
                 }
                 if (!is_null($model->agent_company_logo)) {
                     $model->agent_company_logo = Users::saveImage($model, 'agent_company_logo');
                     Users::resizeImage($model, 'agent_company_logo', Users::$aSizeLogo);
                     $model->update(array('agent_company_logo'));
                 }
                 ProAgentTierManager::saveAgentTier($model, isset($_POST['tier_id']) ? $_POST['tier_id'] : array());
                 ProAgentDistrict::saveAgentDistict($model, $model->ProAgentDistrict);
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
         $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }