From f0a8acb530ca6c4825cf2c68f83cfad634be9b8c Mon Sep 17 00:00:00 2001 From: Mihail Date: Fri, 18 Dec 2015 13:17:02 +0200 Subject: [PATCH] add sort function to goods index page --- frontend/config/main.php | 1 + frontend/controllers/GoodsController.php | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- frontend/views/goods/index.php | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------ frontend/views/goods/index_old.php | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/goods/one_item.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/goods/test.php | 21 +++++++++++++++++++++ 6 files changed, 525 insertions(+), 134 deletions(-) create mode 100644 frontend/views/goods/index_old.php create mode 100644 frontend/views/goods/one_item.php create mode 100644 frontend/views/goods/test.php diff --git a/frontend/config/main.php b/frontend/config/main.php index 151622a..86bc0ec 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -60,6 +60,7 @@ return [ 'events/view/'=>'events/view', 'standard-services/view/'=>'standard-services/view', 'f/'=>'stone/ajax-filter', + 'goods/'=>'goods/index', // переделать 'search'=>'site/search', 'contact'=>'site/contact', 'about'=>'site/about', diff --git a/frontend/controllers/GoodsController.php b/frontend/controllers/GoodsController.php index d4044af..d0fe9c5 100644 --- a/frontend/controllers/GoodsController.php +++ b/frontend/controllers/GoodsController.php @@ -8,19 +8,125 @@ namespace frontend\controllers; +use common\components\CustomVarDamp; use Yii; +use yii\data\SqlDataProvider; use yii\web\Controller; class GoodsController extends Controller { public $layout = '/internal'; - public function actionIndex() + public function actionIndex($name = '') { - return $this->render('index'); + $query = $this->getQuery(); + + $provider = new SqlDataProvider([ + 'sql' => $query, + 'pagination' => false, + // 'params' => [':status' => 1], + 'sort' => [ + 'attributes' => [ + 'box', + 'delivery', + 'price' + ], + ], + ]); + + + return $this->render('index',[ + 'dataProvider' => $provider + ]); } + private function getQuery(){ + $query = <<< MySQL + select straight_join `w_details`.`ARTICLE` as `name`, + `w_details`.`BRAND` as `brand`, + `w_details`.`BOX` as `box`, + `w_details`.`ADD_BOX` as `add_box`, + `w_details`.`IMPORT_ID` as `importer_id`, + `w_importers`.`name` as `importer_name`, + `w_importers`.`delivery`, + if (`w_details_description`.`description` = '', + if (`w_details_description`.`tecdoc_description` = '', + `w_details_description`.`supplier_description`, + `w_details_description`.`tecdoc_description` + ), + `w_details_description`.`description` + ) as `description`, + + if (`w_details_description`.`tecdoc_article` = '', + if (`w_details_description`.`article` = '', + if (`w_details`.`FULL_ARTICLE` = '', + `w_details`.`ARTICLE`, + `w_details`.`FULL_ARTICLE` + ), + `w_details_description`.`article` + ), + `w_details_description`.`tecdoc_article` + ) as `article`, + `w_details`.`ID`, + if (`w_details_description`.`image` = '', + if (`w_details_description`.`tecdoc_image` = '', + '', + concat('ital_origin/images/tecdoc/big/',`w_details_description`.`tecdoc_image`) + ), + concat('ital_origin/images/goods/big/',`w_details_description`.`image`) + ) as `image`, + `w_details_description`.`tecdoc_id`, + round(if(`w_margins_groups`.`koef` is not null, + `w_details`.`PRICE`*`w_margins_groups`.`koef`, + if (`w_margins_importers`.`koef` is not null, + `w_details`.`PRICE`*`w_margins_importers`.`koef`, + `w_details`.`PRICE`*`w_margins`.`koef` + ) + )*`t`.`rate`/`w_currency`.`rate`,2) as `price`, + + round(if(`input_groups`.`koef` is not null, + `w_details`.`PRICE`*`input_groups`.`koef`, + `w_details`.`PRICE` + )*`t`.`rate`/`w_currency`.`rate`,2) as `input_price`, + + round(if(`input_groups`.`koef` is not null, + `w_details`.`PRICE`*`input_groups`.`koef`, + `w_details`.`PRICE` + )*`t`.`rate`/`default`.`rate`,2) as `input_price_default`, + + round(if(`w_margins_groups`.`koef` is not null, + `w_details`.`PRICE`*`w_margins_groups`.`koef`, + if (`w_margins_importers`.`koef` is not null, + `w_details`.`PRICE`*`w_margins_importers`.`koef`, + `w_details`.`PRICE`*`w_margins`.`koef` + ) + )*`t`.`rate`/`default`.`rate`,2) as `price_default`, + + `w_brands`.`ID` as `brand_id` +from `w_details` + inner join `w_brands` on `w_brands`.`BRAND` = `w_details`.`BRAND` + left join `w_details_description` on `w_details_description`.`name` = `w_details`.`ARTICLE` and + `w_details_description`.`brand` = `w_details`.`BRAND` + inner join `w_importers` on `w_importers`.`id` = `w_details`.`IMPORT_ID` and + `w_importers`.`active` = 1 + inner join `w_margins` on `w_margins`.`id` = 1 + left join `w_margins_importers` on `w_margins_importers`.`importer_id` = `w_details`.`IMPORT_ID` and + `w_margins_importers`.`margin_id` = 1 + left join `w_margins_groups` on `w_margins_groups`.`importer_id` = `w_details`.`IMPORT_ID` and + `w_margins_groups`.`margin_id` = 1 and + `w_margins_groups`.`group` = `w_details`.`group` + inner join `w_currency` on `w_currency`.`id` = 1 + inner join `w_currency` as `t` on `t`.`id` = `w_importers`.`currency_id` + inner join `w_currency` as `default` on `default`.`is_default` = 1 + left join `w_margins_groups` as `input_groups` on `input_groups`.`importer_id` = `w_details`.`IMPORT_ID` and + `input_groups`.`margin_id` = 8 and + `input_groups`.`group` = `w_details`.`group` +where `w_details`.`ARTICLE` = '0092S40090' and `w_details`.`BRAND` = 'BOSCH' and (`w_details`.`BOX` > 0 or `w_details`.`ADD_BOX`) +MySQL; + + return $query; +} } \ No newline at end of file diff --git a/frontend/views/goods/index.php b/frontend/views/goods/index.php index 6bdd1b6..1bc5768 100644 --- a/frontend/views/goods/index.php +++ b/frontend/views/goods/index.php @@ -15,67 +15,65 @@ $this->params['breadcrumbs'][] = $this->title; Акамуляторы(АКБ) Аккумулятор 0 092 S30 120: BOSCH -

Аккумулятор 0 092 S30 120: BOSCH

- -
+

Аккумулятор 0 092 S30 120: BOSCH

+
+
- -

Укажите свой автомобиль - и мы предложим вам - еще Аккумуляторы (АКБ)

-
+ +

Укажите свой автомобиль + и мы предложим вам + еще Аккумуляторы (АКБ)

+
- + +
+ +
+
+ +

+ У нас есть еще
+ 45 Аккумуляторы (АКБ)
+ Возможно что-то вам
+ подойдет +

- -
-
- -

- У нас есть еще
- 45 Аккумуляторы (АКБ)
- Возможно что-то вам
- подойдет -

-
- - - - +
- - -
+ + - - - - - -
+ + + -

0 092 S30 120: BOSCH

-

12V 88Ah 740A

-

Емкость, А/Ч: 88

-

Полярность: Правая (-/+)

-
- + +

0 092 S30 120: BOSCH

+

12V 88Ah 740A

+

Емкость, А/Ч: 88

+

Полярность: Правая (-/+)

+ + + + + + + +
-

Скрыть карточку товара

+

Скрыть карточку товара

@@ -176,7 +174,7 @@ $this->params['breadcrumbs'][] = $this->title;
-

12V 88Ah 740A Bosch 0092s30120

+

Замены искомого производителя

грн

$

@@ -274,9 +272,46 @@ $this->params['breadcrumbs'][] = $this->title;
- 3 - 1 дн. - 103.75 + + + + + + + + + + +
3
3
+ + + + + + + + + + + + +
1 дн.
1 дн.
+ + + + + + + + + + + +
103.75
103.75
+ BOSH @@ -401,9 +436,46 @@ $this->params['breadcrumbs'][] = $this->title; - 3 - 1 дн. - 103.75 + + + + + + + + + + +
3
3
+ + + + + + + + + + + + +
1 дн.
1 дн.
+ + + + + + + + + + + +
103.75
103.75
+ @@ -412,81 +484,17 @@ $this->params['breadcrumbs'][] = $this->title;
-
-
-

Наши проекты

- - 1/ - 5 - -
- - - - - -
- -
- lr.italauto.com.ua -
-
    -

    Запчасти на Land Rover
    и Range Rover

    -
  • Оригинальные запчасти
  • -
  • Сертифицированый продавец
  • -
  • Более 300 000 товаров
  • -
-
- - - - -
- -
- lr.italauto.com.ua -
-
    -

    Запчасти на
    Mercedes Benz

    -
  • Оригинальные запчасти
  • -
  • Сертифицированый продавец
  • -
  • Более 300 000 товаров
  • -
-
- - - - -
- -
- lr.italauto.com.ua -
-
    -

    Запчасти на FIAT

    -
  • Оригинальные запчасти
  • -
  • Сертифицированый продавец
  • -
  • Более 300 000 товаров
  • -
-
- - - - -
- -
- lr.italauto.com.ua -
-
    -

    Запчасти на Land Rover
    и Range Rover

    -
  • Оригинальные запчасти
  • -
  • Сертифицированый продавец
  • -
  • Более 300 000 товаров
  • -
-
- -
-
-
\ No newline at end of file + + \ No newline at end of file diff --git a/frontend/views/goods/index_old.php b/frontend/views/goods/index_old.php new file mode 100644 index 0000000..cdcc0ea --- /dev/null +++ b/frontend/views/goods/index_old.php @@ -0,0 +1,201 @@ + [ + 'box' => ['label' => 'Наличие'], + 'delivery' => ['label' => 'Срок'], + 'price' => ['label' => 'Цена'], + ], +]); +$this->registerCssFile('/css/BC2_catalog_zapchasti.css'); +$this->params['breadcrumbs'][] = $this->title; +\yii\widgets\Pjax::begin(); +?> + +
+ Италавто + + Расходные материалы + + Электрооборудование + + Акамуляторы(АКБ) + + Аккумулятор 0 092 S30 120: BOSCH +

Аккумулятор 0 092 S30 120: BOSCH

+ + +
+ + +

Укажите свой автомобиль + и мы предложим вам + еще Аккумуляторы (АКБ)

+
+ + + + +
+ +
+
+ +

+ У нас есть еще
+ 45 Аккумуляторы (АКБ)
+ Возможно что-то вам
+ подойдет +

+
+ + + + + + + + + + + +
+ + + +

0 092 S30 120: BOSCH

+

12V 88Ah 740A

+

Емкость, А/Ч: 88

+

Полярность: Правая (-/+)

+
+ + + + +
+
+

Скрыть карточку товара

+
+
+ +
+

12V 88Ah 740A Bosch 0092s30120

+

грн

+

$

+ + + + + + + + + + + + $dataProvider, + 'itemView'=>'one_item', + 'summary'=>'', + ] ); + ?> + + +
ФирмаНомер деталиОписаниеlink('box')?>link('delivery')?>link('price')?>
+ + +
+ +
+
+
+

Наши проекты

+ + 1/ + 5 + +
+ + + + + +
+ +
+ lr.italauto.com.ua +
+
    +

    Запчасти на Land Rover
    и Range Rover

    +
  • Оригинальные запчасти
  • +
  • Сертифицированый продавец
  • +
  • Более 300 000 товаров
  • +
+
+ + + + +
+ +
+ lr.italauto.com.ua +
+
    +

    Запчасти на
    Mercedes Benz

    +
  • Оригинальные запчасти
  • +
  • Сертифицированый продавец
  • +
  • Более 300 000 товаров
  • +
+
+ + + + +
+ +
+ lr.italauto.com.ua +
+
    +

    Запчасти на FIAT

    +
  • Оригинальные запчасти
  • +
  • Сертифицированый продавец
  • +
  • Более 300 000 товаров
  • +
+
+ + + + +
+ +
+ lr.italauto.com.ua +
+
    +

    Запчасти на Land Rover
    и Range Rover

    +
  • Оригинальные запчасти
  • +
  • Сертифицированый продавец
  • +
  • Более 300 000 товаров
  • +
+
+ +
+ +
+
+ \ No newline at end of file diff --git a/frontend/views/goods/one_item.php b/frontend/views/goods/one_item.php new file mode 100644 index 0000000..f492d31 --- /dev/null +++ b/frontend/views/goods/one_item.php @@ -0,0 +1,54 @@ +registerCssFile('/css/BC2_catalog_zapchasti.css'); +?> + + + + + $model->brand + 0$model->article + + + + $model->description + + + + + + + + + + +
+
+ +
+ + +
+
+ +
+ + + + + + +
+ + + + +
дн.
+ + + +
+ diff --git a/frontend/views/goods/test.php b/frontend/views/goods/test.php new file mode 100644 index 0000000..565109b --- /dev/null +++ b/frontend/views/goods/test.php @@ -0,0 +1,21 @@ +title = 'Test'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + $dataProvider, + ]); ?> + +
-- libgit2 0.21.4