Exemplo n.º 1
0
 public function getParentText()
 {
     $category = FCategory::findOne($this->id);
     if (isset($category->parent)) {
         return $category->parent->name;
     } else {
         return 'Выбрать';
     }
 }
Exemplo n.º 2
0
 public function setQuery($query)
 {
     $geo = new Geo();
     $geo->reset();
     $geo->installGeo($this->id_okrug, $this->id_region, $this->id_city);
     if ($geo->arrayCity) {
         $where["id_city"] = $geo->arrayCity;
     }
     if ($this->id_cat) {
         $cat = FCategory::findOne($this->id_cat);
         $arrayUsers = $cat->arrayUsers;
         $where["id"] = $arrayUsers;
     }
     if (isset($where)) {
         $query = $query->where($where);
     }
     if ($this->search != "") {
         $query = $query->andWhere(["or like", $this->search_field, $this->search]);
     }
     return $query;
 }
Exemplo n.º 3
0
 public function actionItems()
 {
     $get = Yii::$app->request->get();
     $parent_cat = false;
     $params = "";
     if (isset($get["cat"])) {
         $cat_id = $get["cat"];
         $parent_cat = FCategory::findOne($cat_id);
         $brandChumbs = $parent_cat->brandChumbs;
         $cat_name = $parent_cat->name;
         if (count($brandChumbs) > 0) {
             foreach ($brandChumbs as $val) {
                 $params['breadcrumbs'][] = ['label' => $val["name"], 'url' => [$val["url"], "cat" => $val["id"]]];
             }
         }
     } else {
         $cat_id = 0;
     }
     $get = Yii::$app->request->get();
     $session = Yii::$app->session;
     $field_value = "";
     if (isset($get["id_field"])) {
         $id_field = $get["id_field"];
         $value = $get["value"];
         $field_value[$id_field] = $value;
         $query = RItems::find()->joinWith('fields')->where(['r_fields.id_field' => $id_field, 'r_fields.value' => $value]);
     } else {
         $query = RItems::find()->where(['id_parent' => $cat_id]);
     }
     $query = $query->isActive();
     if (isset($session["GEO"])) {
         $query = $query->city($this->geo);
     }
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 10]);
     $items = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('items', ['parent_cat' => $parent_cat, 'params' => $params, 'items' => $items, 'pages' => $pages, 'field_value' => $field_value]);
 }
Exemplo n.º 4
0
 public function getBrandChumbs()
 {
     $parent_id = $this->parent_id;
     $res = array();
     while ($parent = FCategory::findOne($parent_id)) {
         $res[] = array("name" => $parent->name, "url" => $parent->getUrl(true), "id" => $parent->id);
         $parent_id = $parent->parent_id;
     }
     if (count($res) > 0) {
         $res = array_reverse($res);
     }
     return $res;
 }
Exemplo n.º 5
0
 public function actionEditFilter()
 {
     $post = Yii::$app->request->post();
     $get = Yii::$app->request->get();
     $id_category = $get["id"];
     $id_field = $post["id_field"];
     $cat = FCategory::findOne($id_category);
     $cat->installFilter($id_field);
 }
Exemplo n.º 6
0
 public function actionEditRecord($id)
 {
     $RItems = RItems::findOne($id);
     $model = new RItemsForm();
     $model->loadForm($RItems);
     $user = Yii::$app->user->identity;
     $cat = FCategory::findOne($model->id_category);
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post();
         $model->load($post);
         $model->image = UploadedFile::getInstances($model, 'image');
         if ($model->validate()) {
             $model->save();
             $this->redirect(['user/index']);
         }
     }
     return $this->render('editRecord', ['user' => $user, 'model' => $model, 'cat' => $cat]);
 }