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'));
 }