/**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     try {
         $model = ProAirconService::model()->findByPk($id);
         if (is_null($model)) {
             throw new Exception('id not valid');
         }
         $old_upload_service_documents = $model->upload_service_documents;
         $model->scenario = 'updateTelemarketer';
         $model->schedule_date = MyFormat::dateConverYmdToDmy($model->schedule_date, "d/m/Y");
         $this->layout = 'ajax';
         if (isset($_POST['ProAirconService'])) {
             $model->attributes = $_POST['ProAirconService'];
             $model->upload_service_documents = CUploadedFile::getInstance($model, 'upload_service_documents');
             if (is_null($model->upload_service_documents)) {
                 $model->upload_service_documents = $old_upload_service_documents;
             } else {
                 $model->validate();
                 if (!$model->hasErrors()) {
                     $mOld = ProAirconService::model()->findByPk($model->id);
                     ProAirconService::removeFile($mOld, 'upload_service_documents', ProAirconService::$folderUpload);
                     $model->upload_service_documents = ProAirconService::save_photo($model);
                 }
             }
             if ($model->save()) {
                 die('<script type="text/javascript">parent.$.fn.colorbox.close(); parent.$.fn.yiiGridView.update("pro-defect-grid");</script>');
             }
         }
         $this->render('update', 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));
     }
 }
Exemple #2
0
 /**
  * @Author: ANH DUNG Feb 10, 2015
  * @Todo: format ListedDate of listing
  * Re-listed on OR Listed on
  * Re-listed on Feb 08, 2015
  * @Param: $model model listing
  */
 public static function FormatListedDate($model)
 {
     $date = $model->date_listed;
     $text = "Listed on ";
     if ($model->re_listed_count) {
         $date = $model->re_listed_date;
         $text = "Re-listed on ";
     }
     $res = $text . MyFormat::dateConverYmdToDmy($date, MyFormat::$sDateIndexListing);
     return $res;
 }
Exemple #3
0
            <h3><a href="<?php 
echo Yii::app()->createAbsoluteUrl('site/listingdetail', array('slug' => $data->slug));
?>
">
                    <?php 
echo $data->property_name_or_address;
?>
                </a>
            </h3>
            <p><?php 
echo $data->rPropertyType ? $data->rPropertyType->name : '';
?>
</p>
            <!--<p>376 Thomson Road</p>-->
            <p class="type">Listed on <?php 
echo MyFormat::dateConverYmdToDmy($data->date_listed, MyFormat::$sDateIndexListing);
?>
</p>
            <p class="price"><?php 
echo $cmsFormater->formatPrice($data->price);
?>
</p>
            <p><?php 
echo $cmsFormater->formatPrice($data->office_bkank_valuation);
?>
</p>
            <p><?php 
echo $data->floor_area;
?>
 sqft</p>
            <div class="ico-group clearfix">
 public function actionUpdate($id)
 {
     try {
         $model = $this->loadModel($id);
         $model->scenario = 'update_tenant';
         $old_image = $model->avatar;
         $oldFile = $model->upload_employment_pass_passport;
         $oldScannedPassport = $model->scanned_passport;
         $oldPass = $model->password_hash;
         $model->pass_expiry_date = MyFormat::dateConverYmdToDmy($model->pass_expiry_date, 'd/m/Y');
         $model->expiration_date = MyFormat::dateConverYmdToDmy($model->expiration_date, 'd/m/Y');
         if (isset($_POST['Users'])) {
             $model->attributes = $_POST['Users'];
             $model->upload_employment_pass_passport = CUploadedFile::getInstance($model, 'upload_employment_pass_passport');
             $model->scanned_passport = CUploadedFile::getInstance($model, 'scanned_passport');
             $model->avatar = CUploadedFile::getInstance($model, 'avatar');
             $model->validate();
             if (!$model->hasErrors()) {
                 $model->role_id = ROLE_TENANT;
                 if (!empty($model->password_hash)) {
                     $model->temp_password = $model->password_hash;
                     $model->password_hash = md5($model->password_hash);
                 } else {
                     $model->password_hash = $oldPass;
                 }
                 if (!is_null($model->upload_employment_pass_passport)) {
                     Users::deleteOldFile($model, 'upload_employment_pass_passport', Users::$folderUpload);
                     $model->upload_employment_pass_passport = Users::save_upload_employment_pass_passport($model);
                 } else {
                     $model->upload_employment_pass_passport = $oldFile;
                 }
                 if (!is_null($model->scanned_passport)) {
                     Users::deleteOldFile($model, 'scanned_passport', Users::$folderUpload);
                     $model->scanned_passport = Users::save_scanned_passport($model);
                 } else {
                     $model->scanned_passport = $oldScannedPassport;
                 }
                 if (!is_null($model->avatar)) {
                     Users::deleteImage($model);
                     $model->avatar = Users::saveImage($model, 'avatar');
                     Users::resizeImage($model, 'avatar', Users::$aSize);
                 } else {
                     $model->avatar = $old_image;
                 }
                 if (isset($_POST['delete_current_image']) && $_POST['delete_current_image']) {
                     Users::deleteImage($model, 'avatar', Users::$aSize);
                     $model->avatar = '';
                 }
                 if (isset($_POST['delete_current_pass_passport']) && $_POST['delete_current_pass_passport']) {
                     Users::deleteOldFile($model, 'upload_employment_pass_passport', Users::$folderUpload);
                     $model->upload_employment_pass_passport = '';
                 }
                 if (isset($_POST['delete_scanned_passport']) && $_POST['delete_scanned_passport']) {
                     Users::deleteOldFile($model, 'scanned_passport', Users::$folderUpload);
                     $model->scanned_passport = '';
                 }
                 $model->update();
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
         $model->upload_employment_pass_passport = $oldFile;
         $model->scanned_passport = $oldScannedPassport;
         $this->render('update', 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));
     }
 }
Exemple #5
0
 } else {
     $model->scanned_employment_pass = $oldscanned_employment_pass;
 }
 if (!is_null($model->scanned_passport)) {
     ProTransactionsVendorPurchaserDetail::deleteOldFile($model, 'scanned_passport');
     $model->scanned_passport = ProTransactionsVendorPurchaserDetail::saveSomeFile($model, 'scanned_passport');
 } else {
     $model->scanned_passport = $oldscanned_passport;
 }
 $model->pass_expiry_date = MyFormat::dateConverDmyToYmd($model->pass_expiry_date);
Exemple #6
0
         $link = Yii::app()->createAbsoluteUrl('member/landlord/tenancies_detail', array('transaction_id' => $mTransaction->id));
         if ($item->type == ProTransactions::CLIENT_TYPE_TENANT) {
             $link = Yii::app()->createAbsoluteUrl('member/tenant/tenancies_detail', array('transaction_id' => $mTransaction->id));
         }
         $href = "<a href='{$link}' target='_blank'>Tenancy link</a>";
         $FullName = $item->name;
         $aBody = array('{FULL_NAME}' => $FullName, '{PROPERTY_NAME}' => $PropertyName, '{EXPIRING_DATE}' => $ExpiringDate, '{TENANCY_LINK}' => $href);
         $aSubject = array('{PROPERTY_NAME}' => $PropertyName);
         CmsEmail::sendmail(MAIL_TENANCY_EXPIRING, $aSubject, $aBody, $item->email);
     }
 }
Exemple #7
0
 public static function ReportTrans()
 {
     Yii::import('application.extensions.vendors.PHPExcel', true);
     $objPHPExcel = new PHPExcel();
     // Set properties
     $objPHPExcel->getProperties()->setCreator("ANHDUNG")->setLastModifiedBy("ANHDUNG")->setTitle('Report Financial')->setSubject("Office 2007 XLSX Document")->setDescription("Report Transaction")->setKeywords("office 2007 openxml php")->setCategory("Report Transaction");
     $row = 1;
     $i = 1;
     //        $dataAll = $_SESSION['data-excel']->data;
     $HeadTitle = 'Report Transaction';
     $TOTAL_AMOUNT_INVOICE = isset($_SESSION['REPORT_TRANSACTION']['TOTAL_AMOUNT_INVOICE']) ? $_SESSION['REPORT_TRANSACTION']['TOTAL_AMOUNT_INVOICE'] : array();
     $TOTAL_AMOUNT_VOUCHER = isset($_SESSION['REPORT_TRANSACTION']['TOTAL_AMOUNT_VOUCHER']) ? $_SESSION['REPORT_TRANSACTION']['TOTAL_AMOUNT_VOUCHER'] : array();
     $COUNT_TRANS = isset($_SESSION['REPORT_TRANSACTION']['COUNT_TRANS']) ? $_SESSION['REPORT_TRANSACTION']['COUNT_TRANS'] : array();
     $LOOP_VAR = isset($_SESSION['REPORT_TRANSACTION']['LOOP_VAR']) ? $_SESSION['REPORT_TRANSACTION']['LOOP_VAR'] : array();
     $total_trans = 0;
     $total_revenue = 0;
     $cmsFormater = new CmsFormatter();
     $REPORT_TYPE = $_SESSION['REPORT_TYPE'];
     // 1.sheet 1
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Times New Roman');
     $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setSize(12);
     $objPHPExcel->getActiveSheet()->setTitle($HeadTitle);
     $objPHPExcel->getActiveSheet()->setCellValue("A{$row}", FiInvoice::$STA_REPORT_TYPE[$REPORT_TYPE]);
     $objPHPExcel->getActiveSheet()->getStyle("A{$row}")->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->mergeCells("A{$row}:c{$row}");
     $row++;
     $index = 1;
     $beginBorder = $row;
     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", 'Date');
     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", 'Number of Transactions');
     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", 'Revenue');
     $index--;
     $objPHPExcel->getActiveSheet()->getStyle("A{$row}:" . MyFormat::columnName($index) . $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle("A{$row}:" . MyFormat::columnName($index) . $row)->getFont()->setBold(true);
     $row++;
     if ($REPORT_TYPE == FiInvoice::REPORT_DAILY) {
         foreach ($LOOP_VAR as $value) {
             $amount_invoice = isset($TOTAL_AMOUNT_INVOICE[$value]) ? $TOTAL_AMOUNT_INVOICE[$value] : 0;
             $amount_voucher = isset($TOTAL_AMOUNT_VOUCHER[$value]) ? $TOTAL_AMOUNT_VOUCHER[$value] : 0;
             $revenue = $amount_invoice - $amount_voucher;
             $total_trans += isset($COUNT_TRANS[$value]) ? $COUNT_TRANS[$value] : 0;
             $total_revenue += $revenue;
             if ($revenue != 0 || $amount_invoice != 0 || $amount_voucher != 0) {
                 $index = 1;
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", MyFormat::dateConverYmdToDmy($value, "d/m/Y"));
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", $COUNT_TRANS[$value]);
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", MyFormat::formatPrice($revenue));
                 $row++;
                 $i++;
             }
         }
         // end foreach($LOOP_VAR
     } elseif ($REPORT_TYPE == FiInvoice::REPORT_MONTHLY) {
         foreach ($LOOP_VAR as $year => $arrMonth) {
             foreach ($arrMonth as $month => $temp) {
                 $amount_invoice = isset($TOTAL_AMOUNT_INVOICE[$year][$month]) ? $TOTAL_AMOUNT_INVOICE[$year][$month] : 0;
                 $amount_voucher = isset($TOTAL_AMOUNT_VOUCHER[$year][$month]) ? $TOTAL_AMOUNT_VOUCHER[$year][$month] : 0;
                 $revenue = $amount_invoice - $amount_voucher;
                 $total_trans += isset($COUNT_TRANS[$year][$month]) ? $COUNT_TRANS[$year][$month] : 0;
                 $total_revenue += $revenue;
                 if ($revenue != 0 || $amount_invoice != 0 || $amount_voucher != 0) {
                     $index = 1;
                     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", "{$month}/{$year}");
                     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", $COUNT_TRANS[$year][$month]);
                     $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", MyFormat::formatPrice($revenue));
                     $row++;
                     $i++;
                 }
             }
             // foreach($arrMonth as $month=>$temp):
         }
         // end foreach($LOOP_VAR
     } elseif ($REPORT_TYPE == FiInvoice::REPORT_YEARLY) {
         foreach ($LOOP_VAR as $year => $tmp) {
             $amount_invoice = isset($TOTAL_AMOUNT_INVOICE[$year]) ? $TOTAL_AMOUNT_INVOICE[$year] : 0;
             $amount_voucher = isset($TOTAL_AMOUNT_VOUCHER[$year]) ? $TOTAL_AMOUNT_VOUCHER[$year] : 0;
             $revenue = $amount_invoice - $amount_voucher;
             $total_trans += isset($COUNT_TRANS[$year]) ? $COUNT_TRANS[$year] : 0;
             $total_revenue += $revenue;
             if ($revenue != 0 || $amount_invoice != 0 || $amount_voucher != 0) {
                 $index = 1;
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", $year);
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", $COUNT_TRANS[$year]);
                 $objPHPExcel->getActiveSheet()->setCellValue(MyFormat::columnName($index++) . "{$row}", MyFormat::formatPrice($revenue));
                 $row++;
                 $i++;
             }
         }
         // end foreach($LOOP_VAR
     }
     //        $objPHPExcel->getActiveSheet()->getStyle("B$beginBorder:".MyFormat::columnName($index).($row))
     //            ->getAlignment()->setWrapText(true);
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
     $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
     $row--;
     $index--;
     $objPHPExcel->getActiveSheet()->getStyle("A{$beginBorder}:A" . $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle("B{$beginBorder}:B" . $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
     $objPHPExcel->getActiveSheet()->getStyle("C{$beginBorder}:C" . $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
     $objPHPExcel->getActiveSheet()->getStyle("A{$beginBorder}" . ':' . MyFormat::columnName($index) . $row)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
     $objPHPExcel->getActiveSheet()->getStyle("A{$beginBorder}:" . MyFormat::columnName($index) . $row)->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
     //save file
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     for ($level = ob_get_level(); $level > 0; --$level) {
         @ob_end_clean();
     }
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-type: ' . 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment; filename="' . 'Report Transaction.' . 'xlsx' . '"');
     header('Cache-Control: max-age=0');
     $objWriter->save('php://output');
     Yii::app()->end();
 }
Exemple #8
0
 /**
  * @Author: ANH DUNG Apr 01, 2014
  * @Todo: convert some field db date to user interface date
  * @Param: $model model transaction
  */
 public static function convertToUserDate($model)
 {
     if (is_null($model)) {
         return;
     }
     $model->otp_contract_date = MyFormat::dateConverYmdToDmy($model->otp_contract_date, 'd/m/Y');
     $model->commencement_date = MyFormat::dateConverYmdToDmy($model->commencement_date, 'd/m/Y');
     $model->expiring_date = MyFormat::dateConverYmdToDmy($model->expiring_date, 'd/m/Y');
     $model->appointment_date_hdb_only = MyFormat::dateConverYmdToDmy($model->appointment_date_hdb_only, 'd/m/Y');
     $model->tenancy_agreement_date = MyFormat::dateConverYmdToDmy($model->tenancy_agreement_date, 'd/m/Y');
 }
 {
     $this->pageTitle = "Engage Us - " . Yii::app()->params['title'];
     $this->layout = 'application.views.layouts.layout_user';
     $this->render('Engageus');
 }
 /**
  * @Author: ANH DUNG Nov 28, 2014
  * @Todo: On the Salesperson’s list of tenancy page, 
  * there is a new button called “ Record existing tenancy ” for 
  * creating a tenancy that does not require creating a transaction before it:
  * @param: $add_property: 1: ADD_EXISTING, 2: ADD_UNLISTED
  */
 public function actionRecord_existing_tenancy($add_property)
 {
     /** 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 3: Landlord, 4: Tenant Purchaser’s Details
      */
     MyFormat::validateUserAccess(ROLE_AGENT);
     $this->pageTitle = "Record existing tenancy - " . Yii::app()->params['title'];
     try {
         $mUser = Users::model()->findByPk(Yii::app()->user->id);
         $type = ProTransactions::FOR_RENT;
         $listing_id = 0;
         if (isset($_GET['listing_id'])) {
             $listing_id = $_GET['listing_id'];
         }
         // handle create new
         if (!isset($_GET['id'])) {
             $mTransactions = ProTransactions::CreateNewRecordTransaction($type, $listing_id);
Exemple #10
0
 ?>
         <?php 
 $amount_invoice = isset($TOTAL_AMOUNT_INVOICE[$value]) ? $TOTAL_AMOUNT_INVOICE[$value] : 0;
 $amount_voucher = isset($TOTAL_AMOUNT_VOUCHER[$value]) ? $TOTAL_AMOUNT_VOUCHER[$value] : 0;
 //                $revenue = ($amount_invoice-$amount_voucher>0) ? $amount_invoice-$amount_voucher : 0;
 $revenue = $amount_invoice - $amount_voucher;
 $total_trans += isset($COUNT_TRANS[$value]) ? $COUNT_TRANS[$value] : 0;
 $total_revenue += $revenue;
 ?>
         <?php 
 if ($revenue != 0 || $amount_invoice != 0 || $amount_voucher != 0) {
     ?>
         <tr class="materials_row ">
             <td class="item_c">
                 <?php 
     echo MyFormat::dateConverYmdToDmy($value, "d/m/Y");
     ?>
             </td>
             <td class="item_r">
                 <?php 
     echo $COUNT_TRANS[$value];
     ?>
             </td>
             <td class=" item_r">
                 <?php 
     echo MyFormat::formatPrice($revenue);
     ?>
             </td>
         </tr>
         <?php 
 }