Example #1
0
 public static function unityItem($row)
 {
     if (!is_array($row)) {
         $id = $row;
         $item = Union::find($id);
         if (is_null($item)) {
             return '';
         }
         $row = $item->getFields();
     }
     $header = isset($row['header']) ? $row['header'] : $row['name'];
     // Заголовок
     $html[] = Html::tag('div', Html::tag('h3', $header), ['class' => 'header']);
     // подзаголовок
     if (ArrayHelper::keyExists('sub_header', $row)) {
         $html[] = Html::tag('p', $row['sub_header']);
     }
     // картинка с ссылкой
     $html[] = Html::tag('p', Html::a(Html::img($row['img'], ['width' => '100%', 'class' => 'thumbnail']), self::getUnionUrl($row)));
     // Описание
     $content = $row['description'];
     $content = self::getMiniText($content);
     $html[] = Html::tag('p', $content);
     return Html::tag('div', join('', $html), ['class' => 'col-lg-4 unityItem']);
 }
Example #2
0
 public function search($params)
 {
     $query = \app\models\Union::query(['in', 'moderation_status', [0, 1]])->orderBy(['date_insert' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     // load the search form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // adjust the query by adding the filters
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Example #3
0
 private function doAction($id, $callback)
 {
     $item = \app\models\Union::find($id);
     if (is_null($item)) {
         return self::jsonErrorId(101, 'Не найдено объединение');
     }
     $callback($item);
     return self::jsonSuccess();
 }
Example #4
0
 public function actionUnion_item($category, $id)
 {
     $item = Union::find($id);
     if (is_null($item)) {
         throw new Exception('Нет такого объединения');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     if (is_null($categoryObject)) {
         throw new Exception('Не найдена категория');
     }
     return $this->render(['item' => $item, 'officeList' => $item->getOfficeList(['id', 'point_lat as lat', 'point_lng as lng', 'concat("<h5>",name,"</h5><div>",ifnull(content,""),"</div><p>",point_address,"</p>") as html']), 'breadcrumbs' => $categoryObject->getBreadCrumbs([$item->getField('name')]), 'category' => $categoryObject]);
 }
Example #5
0
 /**
  * @return array gs_unions.*
  */
 public function getUnions()
 {
     return Union::query(['tree_node_id' => $this->getId(), 'moderation_status' => 1])->orderBy(['sort_index' => SORT_ASC])->orderBy(['if(sort_index is NULL, 1, 0)' => SORT_ASC, 'sort_index' => SORT_ASC])->all();
 }
 public function actionIndex()
 {
     return $this->render(['items' => Union::query(['moderation_status' => null])->all()]);
 }
 /**
  * Продукт
  *
  * @param $category string id_string
  * @param $union_id int идентификатор объединения
  * @param $id int идентификатор продукта gs_unions_shop_product.id
  *
  * @return string
  * @throws \cs\web\Exception
  */
 public function actionProduct($category, $union_id, $id)
 {
     $item = Union::find($union_id);
     if (is_null($item)) {
         throw new Exception('Нет такого объединения');
     }
     $categoryObject = UnionCategory::find(['id_string' => $category]);
     if (is_null($categoryObject)) {
         throw new Exception('Не найдена категория');
     }
     $product = Product::find($id);
     if (is_null($product)) {
         throw new Exception('Не найден товар');
     }
     $treeNode = TreeNode::find($product->getField('tree_node_id'));
     $breadcrumbs = $categoryObject->getBreadCrumbs();
     $breadcrumbs = ArrayHelper::merge($breadcrumbs, [['url' => ['page/union_item', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => $item->getName()], ['url' => ['union_shop/index', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => 'Магазин'], ['url' => ['union_shop/category', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string'), 'shop_category' => $product->getField('tree_node_id')], 'label' => $treeNode->getField('name')], $product->getField('name')]);
     return $this->render(['union' => $item, 'shop' => $item->getShop(), 'breadcrumbs' => $breadcrumbs, 'category' => $categoryObject, 'treeNode' => $treeNode, 'product' => $product]);
 }
Example #8
0
 private function clearCache()
 {
     \app\models\Union::deleteCacheOfficeList($this->union_id);
 }