Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AdRealEstate::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'property' => $this->property, 'deal_type' => $this->deal_type, 'type_of_property' => $this->type_of_property, 'place_address_id' => $this->place_address_id, 'rooms_in_the_apartment' => $this->rooms_in_the_apartment, 'material_housing' => $this->material_housing, 'floor' => $this->floor, 'floors_in_the_house' => $this->floors_in_the_house, 'area_of_property' => $this->area_of_property, 'measurement_of_property' => $this->measurement_of_property, 'area_of_land' => $this->area_of_land, 'measurement_of_land' => $this->measurement_of_land, 'lease_term' => $this->lease_term, 'price' => $this->price, 'price_for_the_period' => $this->price_for_the_period, 'necessary_furniture' => $this->necessary_furniture, 'internet' => $this->internet, 'pets_allowed' => $this->pets_allowed, 'condition' => $this->condition, 'images_label' => $this->images_label]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Finds the AdRealEstate model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AdRealEstate the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($modelAdRealEstate = AdRealEstate::findOne($id)) !== null) {
         return $modelAdRealEstate;
     } else {
         //throw new NotFoundHttpException('The requested page does not exist.');
         return $this->redirect(['/ad/default/index']);
     }
 }
Exemplo n.º 3
0
 /**
  * @return string
  */
 public function actionDeleteAvatar()
 {
     $imageData = Json::decode(Yii::$app->request->post('imageData'));
     $modelImageForm = new ImageForm();
     $modelImageForm->deleteImage();
     if (Yii::$app->session->get('error')) {
         echo $error = Yii::$app->session->get('error');
     } else {
         $error = false;
     }
     /* @var $model \common\models\AdRealEstate */
     if ($imageData['modelName'] == 'AdRealEstate') {
         $model = AdRealEstate::findOne($imageData['object_id']);
     } elseif ($imageData['modelName'] == 'UserProfile') {
         $model = UserProfile::findOne($imageData['object_id']);
     }
     $imagesObject = $model->imagesOfObjects;
     return $this->render('@common/widgets/ImageLoad/views/_formAutoload', ['modelName' => $imageData['modelName'], 'id' => $imageData['id'], 'object_id' => $imageData['object_id'], 'images_num' => $imageData['images_num'], 'images_label' => $imageData['images_label'], 'images_temp' => $imageData['images_temp'], 'imageSmallWidth' => $imageData['imageSmallWidth'], 'imageSmallHeight' => $imageData['imageSmallHeight'], 'imagesObject' => $imagesObject, 'modelImageForm' => $modelImageForm, 'baseUrl' => $imageData['baseUrl'], 'imagePath' => $imageData['imagePath'], 'noImage' => $imageData['noImage'], 'imageClass' => $imageData['imageClass'], 'buttonDeleteClass' => $imageData['buttonDeleteClass'], 'imageContainerClass' => $imageData['imageContainerClass'], 'formImagesContainerClass' => $imageData['formImagesContainerClass'], 'error' => $error]);
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRealEstate()
 {
     return $this->hasOne(AdRealEstate::className(), ['id' => 'real_estate_id']);
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAdRealEstates10()
 {
     return $this->hasMany(AdRealEstate::className(), ['system_measure' => 'id']);
 }
Exemplo n.º 6
0
 /**
  * Returns the array of possible user status values.
  *
  * @return array
  *
  */
 public function checkForm($scenario, $modelAdRealEstate)
 {
     /* @var $modelAdRealEstate \common\models\AdRealEstate */
     $modelAdRealEstate->setScenario($scenario);
     if (isset(Yii::$app->request->post('AdRealEstate')['appliances'])) {
         $modelAdRealEstate->appliances = Yii::$app->request->post('AdRealEstate')['appliances'];
     }
     /* Проверям заполненные поля для полученного сценария */
     if ($modelAdRealEstate->validate()) {
         /* Находит введенный город */
         $modelAdRealEstate = $this->findCity($modelAdRealEstate);
         /* Находит введенную улицу, если город найден */
         if (!$modelAdRealEstate->errors) {
             /* Сценарии для поиска улицы, с номером дома */
             if ($modelAdRealEstate->scenario == 'sellingRoom' || $modelAdRealEstate->scenario == 'rentARoom' || $modelAdRealEstate->scenario == 'sellingApatrment' || $modelAdRealEstate->scenario == 'rentApatrment' || $modelAdRealEstate->scenario == 'sellingHouse' || $modelAdRealEstate->scenario == 'rentHouse' || $modelAdRealEstate->scenario == 'sellingLand' || $modelAdRealEstate->scenario == 'sellingGarage' || $modelAdRealEstate->scenario == 'rentGarage' || $modelAdRealEstate->scenario == 'sellingComercial' || $modelAdRealEstate->scenario == 'rentComercial') {
                 if ($this->place_street != '' || $this->place_house != '') {
                     $modelAdRealEstate = $this->findAddress($modelAdRealEstate);
                 } else {
                     $modelAdRealEstate->place_address_id = '';
                 }
             }
         }
         if (!$modelAdRealEstate->errors) {
             /* Для определенных сценариев проверяем объявления на дублирование  */
             if ($modelAdRealEstate->scenario == 'buyRoom' || $modelAdRealEstate->scenario == 'rentingARoom' || $modelAdRealEstate->scenario == 'buyApatrment' || $modelAdRealEstate->scenario == 'rentingApatrment' || $modelAdRealEstate->scenario == 'buyHouse' || $modelAdRealEstate->scenario == 'rentingHouse' || $modelAdRealEstate->scenario == 'buyLand' || $modelAdRealEstate->scenario == 'buyGarage' || $modelAdRealEstate->scenario == 'rentingGarage' || $modelAdRealEstate->scenario == 'buyComercial' || $modelAdRealEstate->scenario == 'rentingComercial') {
                 $modelAdRealEstateIs = AdRealEstate::find()->where($this->getAttributesArray($modelAdRealEstate->attributes))->joinWith(['adCategory.adMain' => function ($query) {
                     $query->andWhere(['user_id' => Yii::$app->user->id]);
                     $query->andWhere(['phone_temp_ad' => $this->phone_temp_ad]);
                     $query->andWhere(['place_city_id' => $this->place_city_id]);
                 }])->one();
                 if ($modelAdRealEstateIs) {
                     // Если такаяже запись найдена, направляем на ее редактирование
                     $modelAdRealEstateIs->addError('model_is');
                     return $modelAdRealEstateIs;
                 }
             }
             $modelAdRealEstate = $this->saveAd($modelAdRealEstate);
         }
     }
     //dd($modelAdRealEstate->errors);
     return $modelAdRealEstate;
 }
Exemplo n.º 7
0
 public function getContentList()
 {
     switch ($this->adCategory->category) {
         case 1:
             $modelAdRealEstate = new AdRealEstate();
             $items = '';
             if ($this->adCategory->adRealEstate->type_of_property) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('type_of_property') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->typeOfProperty->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->area_of_property) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('area_of_property') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->area_of_property) . ' ' . Yii::t('references', $this->adCategory->adRealEstate->measurementOfProperty->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->area_of_land) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('area_of_land') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->area_of_land) . ' ' . Yii::t('references', $this->adCategory->adRealEstate->measurementOfLand->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->rooms_in_the_apartment) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('rooms_in_the_apartment') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->roomsInTheApartment->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->material_housing) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('material_housing') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->materialHousing->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->floor) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('floor') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->floor0->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->floors_in_the_house) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('floors_in_the_house') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->floorsInTheHouse->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->lease_term) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('lease_term') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->leaseTerm->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->price) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('price') . ':</strong> ' . Yii::$app->formatter->asCurrency(Yii::t('references', $this->adCategory->adRealEstate->price), $this->adCategory->adRealEstate->user->country->currency) . '</p>';
             }
             if ($this->adCategory->adRealEstate->price_for_the_period) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('price_for_the_period') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->priceForThePeriod->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->necessary_furniture) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('necessary_furniture') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->necessaryFurniture->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->internet) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('internet') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->internet0->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->pets_allowed) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('pets_allowed') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->petsAllowed->reference_name) . '</p>';
             }
             if ($this->adCategory->adRealEstate->adRealEstateAppliances) {
                 $itemsDiv = '';
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('appliances') . ':</strong> ';
                 foreach ($this->adCategory->adRealEstate->adRealEstateAppliances as $one) {
                     $items .= $itemsDiv . Yii::t('references', $one->reference->reference_name);
                     $itemsDiv = ', ';
                 }
             }
             if ($this->adCategory->adRealEstate->condition) {
                 $items .= '<p class="content-elem"><strong>' . $modelAdRealEstate->getAttributeLabel('condition') . ':</strong> ' . Yii::t('references', $this->adCategory->adRealEstate->condition0->reference_name) . '</p>';
             }
             return $items;
             break;
         case 2:
             break;
     }
     return false;
 }