/**
  * @param string $type
  */
 public function actionIndex($type = 'sales')
 {
     $model = new Deal('search');
     $model->property = new Property('search');
     $criteria = new CDbCriteria();
     $criteria->scopes = ['publicAvailable'];
     $_GET['Deal']['sort'] = isset($_GET['Deal']['sort']) && $_GET['Deal']['sort'] ? $_GET['Deal']['sort'] : 'price DESC';
     if (isset($_GET['studio'])) {
         $_GET['Deal']['min_bedrooms'] = 0;
         $_GET['Deal']['max_bedrooms'] = 0;
         $_GET['Deal']['dea_ptype'] = 2;
     }
     if (isset($_GET['Deal'])) {
         $model->attributes = $_GET['Deal'];
         // =================================================================================
         // <<< Reconsider that part of code
         if (isset($_GET['Deal']['priceMode']) && $_GET['Deal']['priceMode'] == 'pcm') {
             $criteria->compare('dea_marketprice * 4.3 * 1.1', '>=' . (isset($_GET['Deal']['min_price']) ? $_GET['Deal']['min_price'] : ""));
             $criteria->compare('dea_marketprice * 4.3 * 0.9', '<=' . (isset($_GET['Deal']['max_price']) ? $_GET['Deal']['max_price'] : ""));
         } else {
             $criteria->compare('dea_marketprice * 1.1', '>=' . (isset($_GET['Deal']['min_price']) ? $_GET['Deal']['min_price'] : ""));
             $criteria->compare('dea_marketprice * 0.9', '<=' . (isset($_GET['Deal']['max_price']) ? $_GET['Deal']['max_price'] : ""));
         }
         $criteria->compare('dea_bedroom', '>=' . (isset($_GET['Deal']['min_bedrooms']) ? $_GET['Deal']['min_bedrooms'] : ""));
         $criteria->compare('dea_bedroom', '<=' . (isset($_GET['Deal']['max_bedrooms']) ? $_GET['Deal']['max_bedrooms'] : ""));
         $criteria->compare('dea_ptype', isset($_GET['Deal']['dea_ptype']) ? $_GET['Deal']['dea_ptype'] : "");
         $criteria->compare('dea_psubtype', isset($_GET['Deal']['dea_ptype']) ? $_GET['Deal']['dea_ptype'] : "", false, 'OR');
         $criteria->compare('dea_branch', isset($_GET['Deal']['dea_branch']) ? $_GET['Deal']['dea_branch'] : "");
         list($field, $order) = explode(" ", $_GET['Deal']['sort']);
         $order = $order == 'ASC' ? $order : 'DESC';
         $field = in_array($field, ['price', 'date']) ? $field : 'price';
         $orderArray = ['price' => 'dea_marketprice', 'date' => 'dea_launchdate'];
         // Reconsider that part of code >>>
         // =================================================================================
         $criteria->order = $orderArray[$field] . ' ' . $order;
         if (isset($_GET['Deal']['showMode']) && $_GET['Deal']['showMode'] == 'available') {
             $criteria->scopes = ['available'];
         }
     }
     if (isset($_GET['Property']['fullAddressString'])) {
         $criteria->with = ['property', 'property.address', 'property.area'];
         if (isset($model->property->fullAddressString)) {
             $model->property->fullAddressString = $_GET['Property']['fullAddressString'];
         } else {
             $model->property->setFullAddressString($_GET['Property']['fullAddressString']);
         }
         $addressParts = explode(' ', str_replace(",", "", $_GET['Property']['fullAddressString']));
         $addressCriteria = $areaCriteria = [];
         foreach ($addressParts as $key => $part) {
             $addressCriteria[] = "concat_ws(' ',address.line1,address.line2,address.line3,address.line4,address.line5, address.postcode) LIKE :part" . $key;
             $areaCriteria[] = "area.are_title LIKE :part" . $key . "";
             $criteria->params[':part' . $key] = '%' . $part . '%';
         }
         $criteria->addCondition('((' . implode(') AND (', $addressCriteria) . ')) OR ((' . implode(') AND (', $areaCriteria) . '))');
     }
     $criteria->compare('dea_type', $type);
     array_push($criteria->scopes, "notUnderTheRadar");
     $dataProvider = $model->publicSearch($criteria);
     $this->render('index', ['dataProvider' => $dataProvider, 'type' => $type, 'model' => $model, 'isMobile' => Yii::app()->device->isDevice('mobile')]);
 }