<div class="left"> <?php echo $form->field($model, 'city_id')->dropDownList(City::getList(), ['name' => $directPopulating ? 'city_id' : null, 'label' => 'City', 'emptyItem' => Yii::t('app', 'Empty city option')]); ?> <?php echo $form->field($model, 'type', [])->dropDownList(Advert::getTypesDropDownList(), ['name' => $directPopulating ? 'type' : null, 'emptyItem' => Yii::t('app', 'Empty type option')]); ?> <?php echo $form->field($model, 'category')->dropDownList(Category::getDropdownList(), ['name' => $directPopulating ? 'category' : null, 'emptyItem' => Yii::t('app', 'Empty category option')]); ?> <?php echo $form->field($model, 'term', ['template' => '{label}{input}'])->datepicker(['name' => $directPopulating ? 'term' : null, 'datepicker' => ['dateFormat' => Yii::$app->formatter->dateFormat, 'clientOptions' => ['maxDate' => "+1m", 'minDate' => "+1d", 'monthNamesShort' => DatepickerHelper::monthNamesShort()]]]); ?> <div class="range"> <label class="control-label" for="min_price"><?php echo Yii::t('app', 'Price'); ?> </label> <br> <?php Spaceless::begin(); ?> <?php echo $form->field($model, 'min_price', ['template' => "{input}"])->textInput(['name' => $directPopulating ? 'min_price' : null, 'placeholder' => Yii::t('app', 'Price from')]); ?>
/** * * @param type $query * @param type $params */ public function buildQuery($query, $params) { $tableAdvert = self::tableName(); if (!empty($this->category)) { $query->andWhere('category = :category', [':category' => $this->category]); } if (!empty($this->content)) { $ids = []; foreach ((new \yii\sphinx\Query())->from(self::tableName())->match($this->content)->all() as $row) { array_push($ids, $row['id']); } $query->andWhere([self::tableName() . '.id' => $ids]); } if (!empty($this->city_id)) { $query->andWhere('city_id = :city_id', [':city_id' => $this->city_id]); } /*if (!empty($this->city)) { $query->andWhere('city = :city', [':city' => $this->city]); }*/ if (!empty($this->created_at)) { } if (!empty($this->currency)) { $query->andWhere('currency = :currency', [':currency' => $this->currency]); } if (!empty($this->is_foreign) || $this->is_foreign === 0) { $query->andWhere('is_foreign = :is_foreign', [':is_foreign' => $this->is_foreign]); } if (!empty($this->is_templet) || $this->is_templet === 0) { $query->andWhere('is_templet = :is_templet', [':is_templet' => $this->is_templet]); } if (!empty($this->min_date) && ($minDate = DatepickerHelper::convertDateFrom($this->min_date))) { $query->andWhere(self::tableName() . '.created_at >= :minDate', [':minDate' => $minDate]); } if (!empty($this->min_price)) { $query->andWhere('min_price = :min_price', [':min_price' => $this->min_price]); } if (!empty($this->max_price)) { $query->andWhere('max_price = :max_price', [':max_price' => $this->max_price]); } if (!empty($this->max_date) && ($maxDate = DatepickerHelper::convertDateTo($this->max_date))) { $query->andWhere(self::tableName() . '.created_at <= :maxDate', [':maxDate' => $maxDate]); } if (!empty($this->published) || $this->published === 0) { $query->andWhere('published = :published', [':published' => $this->published]); } if (!empty($this->status)) { $query->andWhere('status = :status', [':status' => $this->status]); } if (!empty($this->type)) { $query->andWhere('type = :type', [':type' => $this->type]); } if (!empty($this->updated_at)) { } if (!empty($this->user_id)) { $query->andWhere("{$tableAdvert}.user_id = :user_id", [':user_id' => $this->user_id]); } $query->orderBy(self::tableName() . '.created_at desc'); }
<div class="range"> <label class="control-label" for="min_date"><?php echo Yii::t('app', 'Period'); ?> </label> <br> <?php Spaceless::begin(); ?> <?php echo $form->field($searchModel, 'min_date', ['template' => "{input}"])->datepicker(['name' => $directPopulating ? 'min_date' : null, 'placeholder' => $searchModel->getAttributeLabel('min_date'), 'datepicker' => ['dateFormat' => Yii::$app->formatter->dateFormat, 'clientOptions' => ['maxDate' => "0", 'monthNamesShort' => DatepickerHelper::monthNamesShort()]]]); ?> <?php echo $form->field($searchModel, 'max_date', ['template' => "{input}"])->datepicker(['name' => $directPopulating ? 'max_date' : null, 'class' => 'without-left-border', 'placeholder' => $searchModel->getAttributeLabel('max_date'), 'datepicker' => ['dateFormat' => Yii::$app->formatter->dateFormat, 'clientOptions' => ['maxDate' => "0", 'monthNamesShort' => DatepickerHelper::monthNamesShort()]]]); ?> <?php Spaceless::end(); ?> <div class="clear"></div> </div> <div class="range"> <label class="control-label" for="min_price"><?php echo Yii::t('app', 'Price'); ?> </label> <br> <?php Spaceless::begin();
/** * @return string default advert term (+3 days from current day) */ public function getDefaultTerm() { return DatepickerHelper::unixTimestampToDate(time() + 3600 * 24 * 3); }