示例#1
0
/**
 * @var $this  InstructionController
 * @var $model Deal
 * @var $form  AdminFilterForm
 * @var $title String
 */
$types = PropertyType::model()->getTypes();
$subtypes = array();
foreach ($types as $key => $value) {
    $subtypes[$value->pty_id] = PropertyType::model()->getTypes($value->pty_id);
}
$offices = Office::model()->enabledClientMatching()->findAll();
$matchingPostcodes = [];
foreach ($offices as $value) {
    $matchingPostcodes[$value->id] = LinkOfficeToPostcode::model()->getPostcodeList($value->id);
}
$form = $this->beginWidget('AdminFilterForm', array('action' => Yii::app()->getBaseUrl() . '/' . Yii::app()->request->getPathInfo(), 'id' => 'instruction-filter-form', 'enableAjaxValidation' => false, 'model' => [$model], 'ajaxFilterGrid' => 'instruction-list', 'storeInSession' => false, 'focus' => [$model, 'searchString']));
?>
<fieldset>
	<div class="block-header">Preference</div>
	<div class="control-group">
		<label class="control-label"></label>

		<div class="controls">
			<?php 
echo $title;
?>
			<br>
			<span class="hint">Client will receive email alert for following properties</span>
		</div>
示例#2
0
 protected function afterSave()
 {
     $tableName = LinkOfficeToPostcode::model()->tableName();
     $sql = 'DELETE FROM ' . $tableName . ' WHERE officeId = ' . $this->id . '';
     Yii::app()->db->createCommand($sql)->execute();
     if (!$this->newPostcodes) {
         return parent::afterSave();
     }
     $sql = [];
     foreach ($this->newPostcodes as $value) {
         $sql[] = '(' . $this->id . ', "' . $value . '")';
     }
     $sql = 'REPLACE INTO ' . $tableName . ' (officeId, postcode) VALUES ' . implode(', ', $sql);
     Yii::app()->db->createCommand($sql)->execute();
     parent::afterSave();
     $this->refresh();
 }
 public function actionDetailSearch($instructionId = 0)
 {
     $model = new Client('search');
     $model->cli_created = '';
     $model->searchNoBudget = true;
     $model->searchNoMinimumBeds = true;
     $model->cli_saleemail = Client::EMAIL_SALES_YES;
     $model->telephones = array(new Telephone('search'));
     $clientAttributes = isset($_GET['Client']) && $_GET['Client'] ? $_GET['Client'] : [];
     $minPrices = Util::getPropertyPrices("minimum");
     $maxPrices = Util::getPropertyPrices("maximum");
     $title = '';
     if (!$clientAttributes && $instructionId) {
         /** @var Deal $instructionModel */
         $instructionModel = Deal::model()->with('address')->findByPk($instructionId);
         if ($address = $instructionModel->address) {
             $title = $address->getFullAddressString(', ') . " (" . Locale::formatCurrency($instructionModel->getPrice()) . ")";
             if ($address->postcode) {
                 $thisPostcodeFirst = $address->getPostcodePart();
                 $postcodeList = LinkOfficeToPostcode::model()->getPostcodeList();
                 if (in_array($thisPostcodeFirst, $postcodeList)) {
                     $model->searchPostcodes[] = $thisPostcodeFirst;
                 }
             }
         }
         $model->PropertyTypesIds = [$instructionModel->dea_ptype, $instructionModel->dea_psubtype];
         $model->cli_salebed = $instructionModel->dea_bedroom ? $instructionModel->dea_bedroom : '';
         $categories = [];
         foreach ($instructionModel->propertyCategories as $category) {
             $categories = $category->id;
         }
         $model->setPropertyCategoryIds($categories);
         /**
          * round is required because numbers with floating point cannot be used as array keys
          */
         $model->minPrice = (int) round($instructionModel->dea_marketprice - $instructionModel->dea_marketprice * Yii::app()->params['mailshot']['price_margin_min']);
         $model->maxPrice = (int) round($instructionModel->dea_marketprice + $instructionModel->dea_marketprice * Yii::app()->params['mailshot']['price_margin_max']);
         $minPrices[$model->minPrice] = Locale::formatCurrency($model->minPrice, true, false);
         $maxPrices[$model->maxPrice] = Locale::formatCurrency($model->maxPrice, true, false);
         ksort($minPrices);
         ksort($maxPrices);
     }
     if ($clientAttributes) {
         $model->attributes = $clientAttributes;
     }
     $this->render('detailSearch', compact('model', 'title', 'minPrices', 'maxPrices'));
 }