Exemple #1
0
 /**
  * @Author: ANH DUNG Jan 22, 2015
  * @Todo: update id cua admin tao company listing vao id listing saleperson pick
  * @Param: column company_listing_user_created
  */
 public static function UpdateIdAdminCreateCompanylisting()
 {
     // 1. update table listing
     $criteria = new CDbCriteria();
     $criteria->addCondition('t.company_listing_id IS NOT NULL AND t.company_listing_id<>"" ');
     $models = Listing::model()->findAll($criteria);
     foreach ($models as $model) {
         $mCompanyListing = Listing::model()->findByPk($model->company_listing_id);
         if ($mCompanyListing) {
             $model->company_listing_user_created = $mCompanyListing->user_id;
             $model->update(array('company_listing_user_created'));
             // 2. update table transaction
             $c2 = new CDbCriteria();
             $c2->compare('listing_id', $model->id);
             ProTransactions::model()->updateAll(array('company_listing_user_created' => $model->company_listing_user_created), $c2);
         }
     }
 }
 public function OverideModel($model)
 {
     if (isset(Yii::app()->user->id)) {
         $cmsFormater = new CmsFormatter();
         $mUser = Users::model()->findByPk(Yii::app()->user->id);
         $model->fullname = $cmsFormater->formatFullNameRegisteredUsers($mUser);
         $model->nric = $mUser->nric_passportno_roc;
         $model->contact_no = $mUser->phone;
         $model->email = $mUser->email;
         if (Yii::app()->user->role_id == ROLE_LANDLORD || Yii::app()->user->role_id == ROLE_TENANT) {
             $model->contact_no = $mUser->contact_no;
             $model->email = $mUser->email_not_login;
         }
         if (Yii::app()->user->role_id == ROLE_AGENT) {
             $model->email = $mUser->email_not_login;
         }
     }
     $mTrans = ProTransactions::model()->findByPk($model->transaction_id);
     if (is_null($mTrans)) {
         return;
     }
     $mListing = Listing::model()->findByPk($mTrans->listing_id);
     if (is_null($mListing)) {
         return;
     }
     $model->property_name_or_address = $mListing->property_name_or_address;
     $model->unit_from = $mListing->unit_from;
     $model->unit_to = $mListing->unit_to;
     $model->postal_code = $mListing->postal_code;
     $model->location_id = $mListing->location_id;
     $model->property_type_id = $mListing->property_type_1;
     $model->tenure = $mListing->tenure;
     $model->floor_area = $mListing->floor_area;
     $model->of_bedroom_from = $mListing->of_bedroom;
     $model->of_bathrooms_from = $mListing->of_bathrooms;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     try {
         $model = ProTransactions::model()->findByPk($id);
         if ($model === null) {
             Yii::log("The requested page does not exist.");
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         return $model;
     } catch (Exception $e) {
         Yii::log("Exception " . print_r($e, true), 'error');
         throw new CHttpException("Exception " . print_r($e, true));
     }
 }
Exemple #4
0
  * @Param: $title string need update
  */
 public static function UpdateStringPropertyName($mTrans, &$title)
 {
     $mTransPropertyDetail = $mTrans->rPropertyDetail;
     if (trim($mTransPropertyDetail->building_name) != '') {
         $title[] = $mTransPropertyDetail->building_name;
     }
     if (trim($mTransPropertyDetail->house_blk_no) != '') {
         $title[] = $mTransPropertyDetail->house_blk_no;
     }
     if (trim($mTransPropertyDetail->street_name) != '') {
         $title[] = $mTransPropertyDetail->street_name;
     }
     if (trim($mTransPropertyDetail->postal_code) != '') {
         $title[] = $mTransPropertyDetail->postal_code;
     }
     // Nguyên phần else: ANH DUNG MAY 06, 2015
 }
                <?php 
echo $form->error($model, 'postal_code');
?>
            </div>

            <div class="clearfix output">
                <a href="javascript:void(0)" class="btn-2 iframe_close">Cancel</a>
                <input type="submit" class="btn-3" value="Submit" />
            </div>

<?php 
$this->endWidget();
?>

<?php 
// Feb 03,2015 for calc gst at BE when update trans or tenancy
$sUidGst = 0;
if ($model->transactions_id) {
    $mTransactions = ProTransactions::model()->findByPk($model->transactions_id);
    $sUidGst = $mTransactions->user_id;
}
?>
        
        
<script>
    $(function(){
        $('.iframe_close').on('click', function(){
            parent.$.fancybox.close();
        });
    });
</script>
 protected function beforeSave()
 {
     if (!empty($this->receipt_date_paid) && strpos($this->receipt_date_paid, '/')) {
         $this->receipt_date_paid = MyFormat::dateConverDmyToYmd($this->receipt_date_paid);
     }
     if ($this->transactions_id) {
         $mTrans = ProTransactions::model()->findByPk($this->transactions_id);
         if ($mTrans) {
             $this->listing_id = $mTrans->listing_id;
         }
     }
     return parent::beforeSave();
 }
 /**
  * @Author: ANH DUNG Feb 02 2015
  * @Todo: update old data  for change Feb 02, 2015 Receivable Gross Commission should be rental + 7% GST
  * ProTransactionsSaveCommission::Feb02UpdateOldData();
  */
 public static function Feb02UpdateOldData()
 {
     $AllTrans = ProTransactions::model()->findAll();
     foreach ($AllTrans as $mTransactions) {
         if ($mTransactions->type == ProTransactions::FOR_RENT) {
             $price = 0;
             $receivable_gross_commission = 0;
             self::ForRentCalcSomething($mTransactions, $price, $receivable_gross_commission);
             ProTransactionsSaveCommission::model()->updateAll(array('price' => $price, 'receivable_gross_commission' => $receivable_gross_commission), "`transactions_id`={$mTransactions->id}");
         }
     }
     echo count($AllTrans);
     die;
 }
Exemple #8
0
 public static function deleteTransExpiredAfterDays()
 {
     return;
     // Feb 02, 2015  sẽ không xóa trans vì còn để user view nữa, vì cũng không có yêu cầu xóa nên kệ nó thôi
     $days = 100;
     if ($days < 0 || empty($days)) {
         return;
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("DATE_ADD(t.created_date,INTERVAL {$days} DAY) < CURDATE() AND t.status=0");
     //select * from `pro_pro_transactions` where  DATE_ADD(created_date,INTERVAL 1 DAY) <= CURDATE() AND  status=0
     $models = ProTransactions::model()->findAll($criteria);
     if (count($models) > 0) {
         foreach ($models as $item) {
             $item->delete();
         }
     }
 }