Ejemplo n.º 1
0
 /**
  * @Author: ANH DUNG Jan 02, 2015
  * @Todo: Create Tenancy 
  * @param: $add_property: 1: ADD_EXISTING, 2: ADD_UNLISTED
  */
 public function actionCreateTenancy($add_property)
 {
     $this->pageTitle = "Record existing tenancy - " . Yii::app()->params['title'];
     try {
         //            $mUser = Users::model()->findByPk(Yii::app()->user->id);
         //            $mUser = new Users();
         $mTransactions = new ProTransactions();
         if (isset($_GET['user_id'])) {
             // Jan 02, 2014 For backend
             $type = ProTransactions::FOR_RENT;
             $listing_id = 0;
             if (isset($_GET['listing_id'])) {
                 $listing_id = $_GET['listing_id'];
             }
             // handle create new
             if (!isset($_GET['id'])) {
                 $needMore = array('user_id' => $_GET['user_id']);
                 $mTransactions = ProTransactions::CreateNewRecordTransaction($type, $listing_id, $needMore);
                 $this->redirect(array('createTenancy', 'add_property' => $add_property, 'id' => $mTransactions->id, 'type' => $type, 'listing_id' => $listing_id, 'user_id' => $mTransactions->user_id));
             } else {
                 $mTransactions = ProTransactions::getByPk($_GET['id']);
             }
             //                $this->ValidateLinkRecord($add_property, $listing_id); // OPEN IT
             ProTransactions::GetSomeInfoRecord($mTransactions, $add_property);
             ProTransactions::HandlePost($mTransactions);
         }
         $this->render('record/record_existing_tenancy', array('mTransactions' => $mTransactions, 'actions' => $this->listActionsCanAccess));
     } catch (Exception $exc) {
         //            echo $exc->getMessage();
         throw new CHttpException(404, 'Invalid Request');
     }
 }