Example #1
1
    public static function syncListing($data)
    {
        // if listing is not from OneHome, skip it
        // if listing is not created by OneHome Agent, skip it
        if (strcasecmp($data['comp_lis'], 'L3010619I') != 0 || !$data['user_id']) {
            return -1;
            //			$data['user_id'] = 627;	// arthur zang
        }
        if (LhListing::model()->exists('property_name_or_address LIKE :s 
			AND display_address LIKE :a', array(':s' => $data['property_name_or_address'], ':a' => $data['display_address']))) {
            return -2;
        }
        // save listing
        $model = new LhListing('sync');
        $model->attributes = $data;
        $model->save();
        // save photo
        $notDef = false;
        foreach ($data['photos'] as $url) {
            $ext = pathinfo($url, PATHINFO_EXTENSION);
            if (!in_array($ext, array('jpg', 'png', 'gif'))) {
                continue;
            }
            $photo = new ProListingPhotos();
            $photo->display_order = 0;
            $photo->default = $notDef ? 0 : 1;
            $notDef = true;
            $photo->listing_id = $model->id;
            $photo->image = basename($url);
            $photo->created_date = date('Y-m-d H:i:s');
            $photo->save();
            // get image from remote server and save to disk
            $file = $photo->generateImagePath();
            if (!file_exists(dirname($file))) {
                mkdir(dirname($file));
            }
            file_put_contents($file, static::getContent($url));
        }
        return 1;
    }
Example #2
0
                 $aBody = array('{NAME}' => $model->name, '{EMAIL}' => $model->email, '{PHONE}' => $model->phone, '{POSITION}' => $model->position, '{MESSAGE}' => nl2br(strip_tags($model->comment)));
                 $aSubject = array('{POSITION}' => $model->position);
                 $sTo = Yii::app()->params['adminEmail'];
                 CmsEmail::sendmail(MAIL_RESUME_USER, $aSubject, $aBody, $sTo);
                 $sTo = $model->email;
                 CmsEmail::sendmail(MAIL_RESUME_USER, $aSubject, $aBody, $sTo);
             }
         }
     }
     $this->render('career/resume', array('model' => $model, 'flag' => $flag));
 }
 public function actionListingDetail($draft = 0)
 {
     $model = $draft == 1 ? LhListing::model()->findByAttributes(array('slug' => $_GET['slug'])) : LhListing::model()->findBySlug($_GET['slug']);
     if (is_null($model)) {
         throw new Exception('Invalid request');
     }
     $view = empty($m) ? 'listing_detail' : 'listing_map';
     $model->view_count++;
     $model->update('view_count');
     // build breadscrumb
     $searchParams = array('index');
     $breadcrumbs = array();
     // property type (child)
     $searchParams['property_type_code[]'] = $model->property_type_1;
     $breadcrumbs[$model->rPropertyType->name] = $searchParams;
     // district
     $searchParams['location[]'] = $model->location_id;
     $breadcrumbs[$model->rLocationDistrict->name] = $searchParams;
     // buidling name
     if ($model->building_name) {
         $searchParams['building'] = $model->building_name;
         $breadcrumbs[$model->building_name] = $searchParams;
     }
     // listing type: sale/rent
     $searchParams['listing_for'] = $model->listing_type == 1 ? 'for_rent' : 'for_sale';
     $typeText = $model->listing_type == 1 ? "For Rent" : "For Sale";
Example #3
0
 /**
  * Change telemarketer of listings when submit form
  * @author Lam Huynh
  */
 public static function massUpdateTelemarketer($items)
 {
     foreach ($items as $id => $data) {
         if (!array_key_exists('user_id', $data)) {
             continue;
         }
         $listing = LhListing::model()->findByPk($id);
         if (!$listing) {
             continue;
         }
         $listing->scenario = 'change-telemarketer';
         $listing->user_id = $data['user_id'];
         $listing->save();
     }
     return true;
 }