예제 #1
0
        return array('captcha' => array('class' => 'CCaptchaAction', 'backColor' => 0xffffff), 'page' => array('class' => 'CViewAction'));
    }
    /*
	 * @author Lam Huynh
	 */
    public function actionIndex()
    {
        if (empty($_GET)) {
            $this->redirect(Yii::app()->createAbsoluteUrl('site/home'));
        }
        // build breadscrumb
        $searchParams = array('index');
        $breadcrumbs = array();
        // property type (child)
        if (isset($_GET['property_type_code'])) {
            $typeIds = $_GET['property_type_code'];
            if ($typeIds && ($type = ProPropertyType::model()->findByPk(current($typeIds)))) {
                $searchParams['property_type_code[]'] = $type->id;
                $breadcrumbs[$type->name] = $searchParams;
            }
        }
        // district
        if (isset($_GET['location'])) {
            $locationIds = $_GET['location'];
            if ($locationIds && ($location = ProLocation::model()->findByPk(current($locationIds)))) {
                $searchParams['location[]'] = $location->id;
                $breadcrumbs[$location->name] = $searchParams;
            }
        }
        // buidling name
        if (isset($_GET['building']) && ($building = $_GET['building'])) {
            $searchParams['building'] = $building;
            $breadcrumbs[$building] = $searchParams;
        }
        // listing type: sale/rent
        if (isset($_GET['listing_for']) && ($listingFor = $_GET['listing_for'])) {
            $typeText = $listingFor == 'for_rent' ? "For Rent" : "For Sale";
            $searchParams['listing_for'] = $listingFor;
            $breadcrumbs[$typeText] = $searchParams;
        }
        $this->breadcrumbs = $breadcrumbs;
        Yii::app()->theme = 'onehome';
        Yii::app()->clientScript->coreScriptPosition = CClientScript::POS_BEGIN;
예제 #2
0
 public static function GetInfoMapAd($model)
 {
     /* ---------------------------------------------------
      * DTOAN
      * ADD LOCATION
      * lay 2 so dau
      * --------------------------------------------------
      */
     if (!empty($model->postal_code)) {
         $postaCode = substr($model->postal_code, 0, 2);
         $checkLocation = ProLocation::model()->find("t.postal_code like '%{$postaCode}%'");
         if ($checkLocation && isset($checkLocation->id)) {
             $model->location_id = $checkLocation->id;
         }
     }
     //        if ($model->map_config_distance != Yii::app()->params['distance']) {
     $position = explode('-', $model->postal_code_xy);
     if (count($position) == 2) {
         $dist = Yii::app()->params['distance'];
         $limit = Yii::app()->params['limit_result'];
         $long = $position[0];
         $lat = $position[1];
         $mrt_distance = array();
         $mrt = ApiNearRmt::model()->findAll();
         foreach ($mrt as $item) {
             $tmp = Listing::findDistance($long, $item->long_street, $lat, $item->lat_street);
             if ($tmp <= $dist) {
                 $mrt_distance[$item->id]['v'] = $item->name . "({$tmp} Km)";
                 $mrt_distance[$item->id]['x'] = $item->long_street;
                 $mrt_distance[$item->id]['y'] = $item->lat_street;
             }
         }
         //near school
         $school_distance = array();
         $school = ApiNearSchool::model()->findAll();
         foreach ($school as $school_item) {
             $tmp = Listing::findDistance($long, $school_item->long_street, $lat, $school_item->lat_street);
             if ($tmp <= $dist) {
                 $school_distance[$school_item->id]['v'] = $school_item->name . "({$tmp} Km)";
                 $school_distance[$school_item->id]['x'] = $school_item->long_street;
                 $school_distance[$school_item->id]['y'] = $school_item->lat_street;
             }
         }
         //building nam
         $building_distance = array();
         $allBuilding = ApiBuilding::model()->findAll();
         foreach ($allBuilding as $building) {
             $tmp = Listing::findDistance($long, $building->long_street, $lat, $building->lat_street);
             if ($tmp <= $dist) {
                 $name = substr($building->building, 6, 45);
                 $building_distance[$building->id]['v'] = $name . "({$tmp} Km)";
                 $building_distance[$building->id]['x'] = $building->long_street;
                 $building_distance[$building->id]['y'] = $building->lat_street;
             }
         }
         /*  
             51 => 'Nearest MRT Stations',
             23 => 'Nearest Schools'
             1093 => 'Nearest Building',
             'car' => 'Nearest bus stop',
         */
         //$nearBy = @file_get_contents('http://www.streetdirectory.com/api/?mode=tips&act=nearby&output=json&x=' . trim($position[0]) . '&y=' . trim($position[1]) . '&dist=' . $dist . '&start=0&limit=' . $limit . '&country=sg');
         /*            $link = 'http://www.streetdirectory.com/api/?mode=tips&act=nearby&output=json&x=' . trim($position[0]) . '&y=' . trim($position[1]) . '&dist=' . $dist . '&start=0&limit=' . $limit . '&country=sg';
                     $ch = curl_init();
                     $domain = $_SERVER["HTTP_HOST"];
                     curl_setopt($ch, CURLOPT_URL, "$link");
                     curl_setopt($ch, CURLOPT_POST, 1);
                     curl_setopt($ch, CURLOPT_POSTFIELDS, "domain=$domain");
                     curl_setopt($ch, CURLOPT_HEADER, 0);
                     $nearBy = curl_exec($ch);
         
                     $arrCat = Listing::$nearBy;
                     $data   = json_decode($nearBy, true);
                     $dataCat = array();
                     if (is_array($data) && count($data) > 0) {
                         foreach ($data as $item) {
                             if (isset($item['cat']) && isset($arrCat[$item['cat']])) {
                                 $dataCat[$item['cat']][] = $item;
                             }
                         }
                     }*/
         $dataCat[51] = $mrt_distance;
         $dataCat[23] = $school_distance;
         $dataCat[1093] = $building_distance;
         $dataCat['car'] = array();
         // ANH DUNG Oct 27, 2014 tinh property_house_blk_no
         // 1. co postal code
         // 2.  House/blk no = building Number (trong table walkup ) +
         $model->property_house_blk_no = self::getHouseBlkNo($model->postal_code);
         $model->property_street_name = self::getStreetName($model->postal_code);
         $model->map_config_distance = $dist;
         $model->map_config_result = $limit;
         $model->json_map = json_encode($dataCat);
     }
 }
예제 #3
0
 protected static function parseLocation($dom)
 {
     $a = $dom->find('.summarytitle a', 0);
     if (!$a) {
         return null;
     }
     $matches = null;
     preg_match('/\\(D(\\d+)\\)/', $a->plaintext, $matches);
     if (!isset($matches[1])) {
         return null;
     }
     $district = (int) $matches[1];
     $model = ProLocation::model()->findByAttributes(array('district' => $district));
     if (!$model) {
         return null;
     }
     return $model->id;
 }
예제 #4
0
         if ($model->user_id == Yii::app()->user->id) {
             $model->delete();
         }
     }
 }
 /**
  * @Author: ANH DUNG Jul 25, 2014
  * @Todo: build li photo for inventory photo
  * @Param: $model model 
  * @Return: string li
  */
 public function builLiPhoto($model)
 {
     $file_path = ImageProcessing::bindImageByModel($model, 160, 160);
     $pathPhotoBig = ImageProcessing::bindImageByModel($model, -1, -1);
     $link_remove = Yii::app()->createAbsoluteUrl('enquiry/ajaxRemoveFileAll', array('id' => $model->id));
     if (isset($_GET['admin'])) {
         $link_remove = Yii::app()->createAbsoluteUrl('admin/tenancy/inventoryPhoto', array('id' => $model->transaction_id, 'InventoryPhotoId' => $model->id));
     }
     $res = "";
     $res .= "<li>";
     $res .= "<a href='{$pathPhotoBig}' class='FancyPhoto' rel='group'>";
예제 #5
0
 /**
  * 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 = ProLocation::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));
     }
 }