Compare View
Commits (5)
Showing
11 changed files
Show diff stats
backend/views/parser/index.php
| ... | ... | @@ -12,8 +12,8 @@ if ( $model->mode ) { |
| 12 | 12 | $mode = 0; |
| 13 | 13 | $button_label = 'Прочитать'; |
| 14 | 14 | } |
| 15 | - | |
| 16 | 15 | ?> |
| 16 | + | |
| 17 | 17 | <div class="row"> |
| 18 | 18 | <div class="col-lg-5"> |
| 19 | 19 | <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data',],'action'=>['parser/results', 'mode' => $mode]]); | ... | ... |
common/models/GoodsView.php
| ... | ... | @@ -21,7 +21,7 @@ use Yii; |
| 21 | 21 | * @property string $ID |
| 22 | 22 | * @property string $image |
| 23 | 23 | * @property string $tecdoc_id |
| 24 | - * @property double $price | |
| 24 | + * @property double $price - цена в гривнях | |
| 25 | 25 | * @property string $brand_id |
| 26 | 26 | |
| 27 | 27 | */ |
| ... | ... | @@ -29,8 +29,9 @@ class GoodsView extends \backend\components\base\BaseActiveRecord |
| 29 | 29 | { |
| 30 | 30 | /** |
| 31 | 31 | * @inheritdoc |
| 32 | + * служебный аттрибут для определения отдельного вывода кроссов и оригинальных деталей | |
| 32 | 33 | */ |
| 33 | - | |
| 34 | + public $crosses; | |
| 34 | 35 | |
| 35 | 36 | public static function tableName() |
| 36 | 37 | { |
| ... | ... | @@ -55,7 +56,7 @@ class GoodsView extends \backend\components\base\BaseActiveRecord |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | /** |
| 58 | - * @return string | |
| 59 | + * @return float - price in custom margin_id and currency | |
| 59 | 60 | */ |
| 60 | 61 | public function getOutputPrice() |
| 61 | 62 | { |
| ... | ... | @@ -73,7 +74,61 @@ class GoodsView extends \backend\components\base\BaseActiveRecord |
| 73 | 74 | if(!$rate) |
| 74 | 75 | $rate = 1; // если 0, то 1 |
| 75 | 76 | |
| 76 | - return round($this->price * ($this->rate/$rate) * $koef, 2); | |
| 77 | + return round(( $this->price / $rate) * $koef, 2); | |
| 78 | + } | |
| 79 | + /** | |
| 80 | + * @return float - price in custom margin_id and in USD | |
| 81 | + */ | |
| 82 | + public function getOutputPriceUSD() | |
| 83 | + { | |
| 84 | + $price_margin_id = Yii::$app->session->getFlash('price_margin_id',1); | |
| 85 | + | |
| 86 | + $koef = Margins::getDb()->cache( function ($db) use ($price_margin_id) { | |
| 87 | + return (float) Margins::findOne($price_margin_id)->koef; | |
| 88 | + }); | |
| 89 | + | |
| 90 | + $rate = Currency::getDb()->cache( function ($db) { | |
| 91 | + return (float) Currency::findOne(2)->rate; | |
| 92 | + }); | |
| 93 | + | |
| 94 | + if(!$rate) | |
| 95 | + $rate = 1; // если 0, то 1 | |
| 96 | + | |
| 97 | + return round( ($this->price / $rate) * $koef, 2); | |
| 98 | + } | |
| 99 | + | |
| 100 | + /** | |
| 101 | + * @return float - price in custom margin_id in EUR | |
| 102 | + */ | |
| 103 | + public function getOutputPriceEUR() | |
| 104 | + { | |
| 105 | + $price_margin_id = Yii::$app->session->getFlash('price_margin_id',1); | |
| 106 | + | |
| 107 | + $koef = Margins::getDb()->cache( function ($db) use ($price_margin_id) { | |
| 108 | + return (float) Margins::findOne($price_margin_id)->koef; | |
| 109 | + }); | |
| 110 | + | |
| 111 | + $rate = Currency::getDb()->cache( function ($db) { | |
| 112 | + return (float) Currency::findOne(3)->rate; | |
| 113 | + }); | |
| 114 | + | |
| 115 | + if(!$rate) | |
| 116 | + $rate = 1; // если 0, то 1 | |
| 117 | + | |
| 118 | + return round( ($this->price/$rate) * $koef, 2); | |
| 119 | + } | |
| 120 | + /** | |
| 121 | + * @return float - price in custom margin_id and in UAH | |
| 122 | + */ | |
| 123 | + public function getOutputPriceUAH() | |
| 124 | + { | |
| 125 | + $price_margin_id = Yii::$app->session->getFlash('price_margin_id',1); | |
| 126 | + | |
| 127 | + $koef = Margins::getDb()->cache( function ($db) use ($price_margin_id) { | |
| 128 | + return (float) Margins::findOne($price_margin_id)->koef; | |
| 129 | + }); | |
| 130 | + | |
| 131 | + return round($this->price * $koef, 2); | |
| 77 | 132 | } |
| 78 | 133 | |
| 79 | 134 | public static function primaryKey() | ... | ... |
common/models/GoodsViewSearch.php
| ... | ... | @@ -38,15 +38,10 @@ class GoodsViewSearch extends GoodsView |
| 38 | 38 | * |
| 39 | 39 | * @return ActiveDataProvider |
| 40 | 40 | */ |
| 41 | - public function search($params) | |
| 41 | + public function search( $params, $sort ) | |
| 42 | 42 | { |
| 43 | 43 | $query = GoodsView::find(); |
| 44 | 44 | |
| 45 | -// $pagination = [ | |
| 46 | -// 'pageSize' => 20, | |
| 47 | -// ]; | |
| 48 | - | |
| 49 | - | |
| 50 | 45 | $this->load($params); |
| 51 | 46 | |
| 52 | 47 | if ( !$this->validate() ) { |
| ... | ... | @@ -58,51 +53,19 @@ class GoodsViewSearch extends GoodsView |
| 58 | 53 | 'brand' => $this->brand, |
| 59 | 54 | ]); |
| 60 | 55 | |
| 61 | - $query->andWhere(['or', 'box > 0', 'add_box > 0']); | |
| 56 | + | |
| 57 | + $query->andWhere(['or', 'box > 0', 'add_box > 0'])->orderBy( $sort ); | |
| 62 | 58 | |
| 63 | 59 | $dataProvider = new ActiveDataProvider([ |
| 64 | 60 | 'query' => $query, |
| 65 | 61 | 'key' => 'name', |
| 66 | - 'sort' => [ | |
| 67 | - 'attributes' => [ | |
| 68 | - 'box', | |
| 69 | - 'delivery', | |
| 70 | - 'price' | |
| 71 | - ], | |
| 72 | - ], | |
| 73 | - | |
| 74 | 62 | ]); |
| 75 | 63 | |
| 76 | 64 | return $dataProvider; |
| 77 | 65 | } |
| 78 | - public function searchCrosses($params) | |
| 66 | + public function searchCrosses( $params, $sort ) | |
| 79 | 67 | { |
| 80 | - $query = GoodsView::find()->innerJoin('w_details_crosses', '`w_details_crosses`.`CROSS_ARTICLE` = `name` and `w_details_crosses`.`CROSS_BRAND` = w_goods_view.`brand`'); | |
| 81 | - | |
| 82 | - | |
| 83 | -// ->select([ | |
| 84 | -// 'name' => 'Name', | |
| 85 | -// 'brand' => 'w_details_crosses.CROSS_BRAND', | |
| 86 | -// 'box' => 'Box', | |
| 87 | -// 'add_box' => 'add_box', | |
| 88 | -// 'importer_id' => 'importer_id', | |
| 89 | -// 'importer_name' => 'importer_name', | |
| 90 | -// 'rate' => 'Rate', | |
| 91 | -// 'currency_id' => 'currency_id', | |
| 92 | -// 'delivery' => 'Delivery', | |
| 93 | -// 'description' => 'Description', | |
| 94 | -// 'article' => 'w_details_crosses.CROSS_ARTICLE', | |
| 95 | -// 'ID' => 'w_goods_view.ID', | |
| 96 | -// 'image' => 'Image', | |
| 97 | -// 'tecdoc_id' => 'tecdoc_id', | |
| 98 | -// 'price' => 'Price', | |
| 99 | -// 'brand_id' => 'brand_id', | |
| 100 | -// ]); | |
| 101 | - | |
| 102 | -// $pagination = [ | |
| 103 | -// 'pageSize' => 20, | |
| 104 | -// ]; | |
| 105 | - | |
| 68 | + $query = GoodsView::find()->innerJoin('w_details_crosses', '`w_details_crosses`.`ARTICLE` = `name` and `w_details_crosses`.`BRAND` = w_goods_view.`brand`')->select('w_goods_view.*, w_details_crosses.CROSS_BRAND as crosses' ); | |
| 106 | 69 | |
| 107 | 70 | $this->load($params); |
| 108 | 71 | |
| ... | ... | @@ -111,23 +74,15 @@ class GoodsViewSearch extends GoodsView |
| 111 | 74 | } |
| 112 | 75 | |
| 113 | 76 | $query->andFilterWhere([ |
| 114 | - 'w_details_crosses.ARTICLE' => $this->name, | |
| 115 | - 'w_details_crosses.BRAND' => $this->brand, | |
| 77 | + 'w_details_crosses.CROSS_ARTICLE' => $this->name, | |
| 78 | + 'w_details_crosses.CROSS_BRAND' => $this->brand, | |
| 116 | 79 | ]); |
| 117 | 80 | |
| 118 | - $query->andWhere(['or', 'box > 0', 'add_box > 0']); | |
| 81 | + $query->andWhere(['or', 'box > 0', 'add_box > 0'])->orderBy( $sort ); | |
| 119 | 82 | |
| 120 | 83 | $dataProvider = new ActiveDataProvider([ |
| 121 | 84 | 'query' => $query, |
| 122 | 85 | 'key' => 'name', |
| 123 | - 'sort' => [ | |
| 124 | - 'attributes' => [ | |
| 125 | - 'box', | |
| 126 | - 'delivery', | |
| 127 | - 'price' | |
| 128 | - ], | |
| 129 | - ], | |
| 130 | - | |
| 131 | 86 | ]); |
| 132 | 87 | |
| 133 | 88 | return $dataProvider; | ... | ... |
console/migrations/m151219_103804_goods_view.php
| ... | ... | @@ -40,9 +40,9 @@ class m151219_103804_goods_view extends Migration |
| 40 | 40 | if (`w_details_description`.`image` = '', |
| 41 | 41 | if (`w_details_description`.`tecdoc_image` = '', |
| 42 | 42 | '', |
| 43 | - concat('ital_origin/images/tecdoc/big/',`w_details_description`.`tecdoc_image`) | |
| 43 | + concat('/storage/images/tecdoc/big/',`w_details_description`.`tecdoc_image`) | |
| 44 | 44 | ), |
| 45 | - concat('ital_origin/images/goods/big/',`w_details_description`.`image`) | |
| 45 | + concat('/storage/images/goods/big/',`w_details_description`.`image`) | |
| 46 | 46 | ) as `image`, |
| 47 | 47 | `w_details_description`.`tecdoc_id`, |
| 48 | 48 | ... | ... |
frontend/controllers/GoodsController.php
| ... | ... | @@ -16,20 +16,26 @@ use Yii; |
| 16 | 16 | use yii\web\Controller; |
| 17 | 17 | use common\models\Details; |
| 18 | 18 | |
| 19 | -class GoodsController extends Controller { | |
| 19 | +class GoodsController extends Controller | |
| 20 | +{ | |
| 20 | 21 | public $layout = '/internal'; |
| 21 | 22 | |
| 22 | - public function actionIndex( $name , $id ) | |
| 23 | + public function actionIndex($name, $id) | |
| 23 | 24 | { |
| 24 | 25 | |
| 25 | - | |
| 26 | - $arr_name = explode('_',$name); | |
| 26 | + $arr_name = explode('_', $name); | |
| 27 | 27 | $brand = $arr_name[0]; |
| 28 | 28 | $article = $arr_name[1]; |
| 29 | 29 | |
| 30 | 30 | |
| 31 | + $params = Yii::$app->request->getQueryParams(); | |
| 32 | + | |
| 33 | + // получим параметры сортировки из гет запроса | |
| 34 | + $sort_params_or = $this->getSortParams($params, 'or'); | |
| 35 | + $sort_params_cross = $this->getSortParams($params, 'cross'); | |
| 36 | + | |
| 31 | 37 | $arr_values = ['name' => $article, |
| 32 | - 'brand' => $brand]; | |
| 38 | + 'brand' => $brand]; | |
| 33 | 39 | $arr = ['GoodsViewSearch' => $arr_values]; |
| 34 | 40 | |
| 35 | 41 | if(empty( Yii::$app->user->identity )){ |
| ... | ... | @@ -41,24 +47,70 @@ class GoodsController extends Controller { |
| 41 | 47 | // $arr = ['GoodsViewSearch' => ['name' => '0092S40090', |
| 42 | 48 | // 'brand' => 'BOSCH']]; |
| 43 | 49 | |
| 50 | + if (empty(Yii::$app->user->identity)) { | |
| 51 | + $margin_id = 1; | |
| 52 | + } else { | |
| 53 | + $margin_id = Yii::$app->user->identity->margin_id; | |
| 54 | + } | |
| 44 | 55 | |
| 45 | 56 | Yii::$app->session->setFlash('price_currency_id', 1); |
| 46 | 57 | Yii::$app->session->setFlash('price_margin_id', $margin_id); |
| 47 | 58 | |
| 48 | 59 | $searchModel = new GoodsViewSearch(); |
| 49 | - $goods_provider = $searchModel->search($arr); | |
| 60 | + $goods_provider = $searchModel->search($arr, $sort_params_or); | |
| 50 | 61 | |
| 51 | - $crosses_provider = $searchModel->searchCrosses($arr); | |
| 62 | + $crosses_provider = $searchModel->searchCrosses($arr, $sort_params_cross); | |
| 52 | 63 | |
| 53 | 64 | // для заголовка таблицы (карточка товара) |
| 54 | 65 | $detailsModel = GoodsView::findOne($arr_values); |
| 55 | 66 | |
| 56 | - return $this->render('index',[ | |
| 67 | + return $this->render('index', [ | |
| 57 | 68 | 'goods_data_provider' => $goods_provider, |
| 58 | 69 | 'crosses_data_provider' => $crosses_provider, |
| 59 | 70 | 'detailsModel' => $detailsModel, |
| 60 | 71 | ]); |
| 61 | 72 | } |
| 62 | 73 | |
| 74 | + /** | |
| 75 | + * @param $params - массив параметров для сортировки | |
| 76 | + * @param $prefix - строка, перфикс таблицы сортировки (_or / _cross ) | |
| 77 | + * @return массив - итоговый массив с параемтрами для сортировки который подставляется в запрос | |
| 78 | + */ | |
| 79 | + protected function getSortParams($params, $prefix) | |
| 80 | + { | |
| 81 | + $default_sort_params = ['price' => SORT_DESC]; | |
| 82 | + $sort_params = []; | |
| 83 | + | |
| 84 | + if ( empty( $params['sort'] ) ) { | |
| 85 | + // нет параметров - сортируем по цене по убыванию | |
| 86 | + $sort_params = $default_sort_params; | |
| 87 | + | |
| 88 | + } else { | |
| 89 | + // разбираем парметры | |
| 90 | + $sort_arr = explode('_', $params['sort']); | |
| 91 | + if ($sort_arr[1] === $prefix) { | |
| 92 | + if ($sort_arr[0][0] === '-') { | |
| 93 | + // если первый символ "-", то по убыванию | |
| 94 | + $sort_arr[0] = str_replace('-', '', $sort_arr[0]); | |
| 95 | + $sort_params[$sort_arr[0]] = SORT_ASC; | |
| 96 | + } else { | |
| 97 | + $sort_params[$sort_arr[0]] = SORT_DESC; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + if ( empty( $sort_params ) ) { | |
| 101 | + // если так и ненашли подходящих параметров, значит сортируем другую таблицу | |
| 102 | + // а для этой вытащим из кеша или дефолтная сортировка | |
| 103 | + if ( Yii::$app->cache->exists( "sort_{$prefix}" ) ) { | |
| 104 | + $sort_params = Yii::$app->cache->get( "sort_{$prefix}" ); | |
| 105 | + } else { | |
| 106 | + $sort_params = $default_sort_params; | |
| 107 | + } | |
| 108 | + } else { | |
| 109 | + Yii::$app->cache->set( "sort_{$prefix}", $sort_params, 300 ); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + return $sort_params; | |
| 114 | + } | |
| 63 | 115 | |
| 64 | 116 | } |
| 65 | 117 | \ No newline at end of file | ... | ... |
frontend/views/goods/index.php
| 1 | 1 | <?php |
| 2 | 2 | use yii\data\Sort; |
| 3 | 3 | use \yii\helpers\Html; |
| 4 | +use \yii\widgets\Pjax; | |
| 4 | 5 | |
| 5 | 6 | $sort = new Sort([ |
| 6 | 7 | 'attributes' => [ |
| 7 | - 'box' => ['label' => 'Наличие'], | |
| 8 | - 'delivery' => ['label' => 'Срок'], | |
| 9 | - 'price' => ['label' => 'Цена'], | |
| 8 | + 'box_or' => ['label' => 'Наличие'], | |
| 9 | + 'delivery_or' => ['label' => 'Срок'], | |
| 10 | + 'price_or' => [ | |
| 11 | + 'label' => 'Цена'], | |
| 12 | + 'box_cross' => ['label' => 'Наличие'], | |
| 13 | + 'delivery_cross' => ['label' => 'Срок'], | |
| 14 | + 'price_cross' => [ | |
| 15 | + 'label' => 'Цена'], | |
| 10 | 16 | ], |
| 11 | 17 | ]); |
| 12 | 18 | $this->registerCssFile('/css/BC2_catalog_zapchasti.css'); |
| 13 | 19 | $this->registerJsFile('/js/jquery.tablesorter.min.js'); |
| 20 | +$this->registerJsFile('/js/goods.js'); | |
| 21 | + | |
| 14 | 22 | $this->params['breadcrumbs'][] = $this->title; |
| 15 | -\yii\widgets\Pjax::begin(); | |
| 23 | +Pjax::begin(); | |
| 16 | 24 | ?> |
| 17 | 25 | |
| 18 | 26 | |
| ... | ... | @@ -25,9 +33,9 @@ $this->params['breadcrumbs'][] = $this->title; |
| 25 | 33 | <img src="/images/arrow_dots.png"> |
| 26 | 34 | <a href="" class='navigation'>Акамуляторы(АКБ)</a> |
| 27 | 35 | <img src="/images/arrow_dots.png"> |
| 28 | - <span>Аккумулятор<span class='detail_name'> 0 092 S30 120: BOSCH</span></span> | |
| 36 | + <span>Аккумулятор<span class='detail_name'> <?= "{$detailsModel->name}: {$detailsModel->brand}"?></span></span> | |
| 29 | 37 | |
| 30 | - <p class="vin_article">Аккумулятор 0 092 S30 120: BOSCH</p> | |
| 38 | + <p class="vin_article"><?= "{$detailsModel->name}: {$detailsModel->brand}"?></p> | |
| 31 | 39 | <div class="tovar_card"> |
| 32 | 40 | <div class="search_span zapchasti"> |
| 33 | 41 | |
| ... | ... | @@ -62,20 +70,25 @@ $this->params['breadcrumbs'][] = $this->title; |
| 62 | 70 | <table class='detail'> |
| 63 | 71 | <tr> |
| 64 | 72 | <td> |
| 65 | - <img src="/images/acamulator_big.png"> | |
| 66 | - <img src="/images/small_plus.png"> | |
| 73 | + <?php | |
| 74 | +// <img src="/images/acamulator_big.png"> | |
| 75 | +// <img src="/images/small_plus.png"> | |
| 76 | + ?> | |
| 67 | 77 | </td> |
| 68 | 78 | |
| 69 | 79 | |
| 70 | 80 | <td> |
| 71 | - <p class='bold_line'>0 092 S30 120: BOSCH</p> | |
| 72 | - <p class="thin_line">12V 88Ah 740A</p> | |
| 73 | - <p class='bold_line space'>Емкость, А/Ч:<span class='thin_line'> 88</span></p> | |
| 74 | - <p class="bold_line">Полярность: Правая (-/+)</p> | |
| 81 | + | |
| 82 | + <p class='bold_line'><?= "{$detailsModel->name}: {$detailsModel->brand}"?></p> | |
| 83 | + <p class="thin_line"><?= "{$detailsModel->description}"?></p> | |
| 84 | + | |
| 75 | 85 | </td> |
| 76 | 86 | </tr> |
| 77 | 87 | <tr class="galery"> |
| 78 | - <td><img src="/images/acamulator_small_gallery.png"><img src="/images/acamulator_small_gallery.png"></td> | |
| 88 | + <?php | |
| 89 | + // <td><img src="/images/acamulator_small_gallery.png"><img src="/images/acamulator_small_gallery.png"></td> | |
| 90 | + ?> | |
| 91 | + | |
| 79 | 92 | </tr> |
| 80 | 93 | </table> |
| 81 | 94 | <img src="/images/arrow_rounded.png" class='arrow_rounded'> |
| ... | ... | @@ -89,19 +102,19 @@ $this->params['breadcrumbs'][] = $this->title; |
| 89 | 102 | <div class="vin tables"> |
| 90 | 103 | |
| 91 | 104 | <div class="first_section"> |
| 92 | - <p class="bold_line">12V 88Ah 740A Bosch 0092s30120</p> | |
| 93 | - <p class="currency opposite" id="dollars">грн</p> | |
| 94 | - <p class="currency active_button_purple1" id="grivna">$</p> | |
| 105 | + <p class="bold_line"><?= "{$detailsModel->description} {$detailsModel->brand} {$detailsModel->name}"?></p> | |
| 106 | + <p class="currency opposite" id="grivna">UAH</p> | |
| 107 | + <p class="currency active_button_purple1" id="dollars">USD</p> | |
| 108 | + <p class="currency opposite" id="euro">EUR</p> | |
| 95 | 109 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> |
| 96 | 110 | <tbody><tr class="name"> |
| 97 | 111 | <td class="small_width row_name">Фирма</td> |
| 98 | 112 | <td class="medium_width row_name">Номер детали</td> |
| 99 | 113 | <td class="large_width row_name">Описание</td> |
| 100 | 114 | <td class="row_select1 row_name"></td> |
| 101 | - <td class="right_large row_name link_sort arrow_up"><?= $sort->link('box') ?></td> | |
| 102 | - <td class="right_small row_name link_sort arrow_up"><?= $sort->link('delivery') ?></td> | |
| 103 | - <td class="right_medium row_name link_sort arrow_up"><?= $sort->link('price') ?></td> | |
| 104 | - | |
| 115 | + <td class="right_large row_name link_sort arrow_up"><?= $sort->link('box_or') ?></td> | |
| 116 | + <td class="right_small row_name link_sort arrow_up"><?= $sort->link('delivery_or') ?></td> | |
| 117 | + <td class="right_medium row_name link_sort arrow_up"><?= $sort->link('price_or') ?></td> | |
| 105 | 118 | </tr> |
| 106 | 119 | <?php |
| 107 | 120 | echo \yii\widgets\ListView::widget([ |
| ... | ... | @@ -118,8 +131,7 @@ $this->params['breadcrumbs'][] = $this->title; |
| 118 | 131 | </div> |
| 119 | 132 | <div class="second_section"> |
| 120 | 133 | <p class="bold_line">Замены искомого производителя</p> |
| 121 | - <p class="currency1 opposite1" id="dollars">грн</p> | |
| 122 | - <p class="currency1 active_button_purple11" id="grivna">$</p> | |
| 134 | + <p </p> | |
| 123 | 135 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> |
| 124 | 136 | <tbody> |
| 125 | 137 | <tr class="name"> |
| ... | ... | @@ -127,10 +139,9 @@ $this->params['breadcrumbs'][] = $this->title; |
| 127 | 139 | <td class="medium_width row_name">Номер детали</td> |
| 128 | 140 | <td class="large_width row_name">Описание</td> |
| 129 | 141 | <td class="row_select1 row_name"></td> |
| 130 | - <td class="right_large row_name link_sort arrow_up">Наличие</td> | |
| 131 | - <td class="right_small row_name link_sort arrow_up">Срок</td> | |
| 132 | - <td class="right_medium row_name link_sort arrow_up">Цена</td> | |
| 133 | - | |
| 142 | + <td class="right_large row_name link_sort arrow_up"><?= $sort->link('box_cross') ?></td> | |
| 143 | + <td class="right_small row_name link_sort arrow_up"><?= $sort->link('delivery_cross') ?></td> | |
| 144 | + <td class="right_medium row_name link_sort arrow_up"><?= $sort->link('price_cross') ?></td> | |
| 134 | 145 | </tr> |
| 135 | 146 | <?php |
| 136 | 147 | echo \yii\widgets\ListView::widget([ |
| ... | ... | @@ -149,7 +160,9 @@ $this->params['breadcrumbs'][] = $this->title; |
| 149 | 160 | </div> |
| 150 | 161 | |
| 151 | 162 | </div> |
| 152 | - | |
| 163 | +<?php | |
| 164 | +Pjax::end(); | |
| 165 | +?> | |
| 153 | 166 | <script type="text/javascript"> |
| 154 | 167 | function changeText() { |
| 155 | 168 | e = document.getElementById('button_grey_card'); |
| ... | ... | @@ -168,12 +181,8 @@ $this->params['breadcrumbs'][] = $this->title; |
| 168 | 181 | }) |
| 169 | 182 | </script> |
| 170 | 183 | |
| 171 | -<?php | |
| 172 | -\yii\widgets\Pjax::end(); | |
| 173 | -?> | |
| 174 | - | |
| 175 | 184 | <div class="modal fade" id="details_content_block" > |
| 176 | - <div class="modal-dialog"> | |
| 185 | + <div class="modal-dialog table_details"> | |
| 177 | 186 | <div class="modal-content"> |
| 178 | 187 | <div class="modal-header"> |
| 179 | 188 | <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ... | ... |
frontend/views/goods/one_item.php
| 1 | 1 | <?php |
| 2 | 2 | use \yii\helpers\Html; |
| 3 | - | |
| 4 | -$this->registerCssFile('/css/BC2_catalog_zapchasti.css'); | |
| 5 | 3 | // если товар один и тот же то выводим только цену и кол-во |
| 6 | 4 | // иначе всю информацию |
| 7 | 5 | $new_good = false; |
| ... | ... | @@ -10,9 +8,10 @@ $article_arr = $widget->dataProvider->getKeys(); |
| 10 | 8 | if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) |
| 11 | 9 | // если предыдущий артикул равен текущему, то это тот же товар |
| 12 | 10 | $new_good = true; |
| 13 | -?> | |
| 11 | +// определим это вызов основной таблицы или кросс таблицы | |
| 12 | +$cross_prefix = ( empty($model->crosses) )? '': '_cross'; | |
| 14 | 13 | |
| 15 | -<?php $this->beginBlock('item_details'); | |
| 14 | + $this->beginBlock('item_details'); | |
| 16 | 15 | // выделим отдельно детали товара в блок, для опционального его вывода |
| 17 | 16 | ?> |
| 18 | 17 | <tr style="border-bottom: 0"> |
| ... | ... | @@ -25,9 +24,9 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) |
| 25 | 24 | <a class="tecdoc_id_info" data-toggle="modal" data-target="#details_content_block" data-id="<?= $model->tecdoc_id ?>" href=""><img src="/images/gear.png"></a> |
| 26 | 25 | <a href="" id="go_photo"><img src="/images/icon_cam.png"></a> |
| 27 | 26 | </td> |
| 28 | -<?php $this->endBlock(); ?> | |
| 29 | - | |
| 30 | - <?php $this->beginBlock('empty_details'); | |
| 27 | +<?php | |
| 28 | + $this->endBlock(); | |
| 29 | + $this->beginBlock('empty_details'); | |
| 31 | 30 | // иначе пустой блок |
| 32 | 31 | ?> |
| 33 | 32 | <tr style="border-bottom: 0;border-top: 0;"> |
| ... | ... | @@ -76,8 +75,16 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) |
| 76 | 75 | <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= $model->delivery?> дн.</td></tr> |
| 77 | 76 | |
| 78 | 77 | </table></td> |
| 79 | - <td class="right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 80 | - <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= $model->outputPrice?></td></tr> | |
| 78 | + <td class="usd right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 79 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= \Yii::$app->formatter->asDecimal( $model->outputPriceUSD )?></td></tr> | |
| 80 | + | |
| 81 | + </table></td> | |
| 82 | + <td class="hidden uah right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 83 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= \Yii::$app->formatter->asDecimal( $model->outputPriceUAH )?></td></tr> | |
| 84 | + | |
| 85 | + </table></td> | |
| 86 | + <td class="hidden eur right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 87 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= \Yii::$app->formatter->asDecimal( $model->outputPriceEUR )?></td></tr> | |
| 81 | 88 | |
| 82 | 89 | </table></td> |
| 83 | 90 | </tr> | ... | ... |
| 1 | +<?php | |
| 2 | +use \yii\helpers\Html; | |
| 3 | + | |
| 4 | +$this->registerCssFile('/css/BC2_catalog_zapchasti.css'); | |
| 5 | +// если товар один и тот же то выводим только цену и кол-во | |
| 6 | +// иначе всю информацию | |
| 7 | +$new_good = false; | |
| 8 | +//в провайдере в качестве ключей установлен - артикул | |
| 9 | +$article_arr = $widget->dataProvider->getKeys(); | |
| 10 | +if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | |
| 11 | + // если предыдущий артикул равен текущему, то это тот же товар | |
| 12 | + $new_good = true; | |
| 13 | +?> | |
| 14 | + | |
| 15 | +<?php $this->beginBlock('item_details'); | |
| 16 | +// выделим отдельно детали товара в блок, для опционального его вывода | |
| 17 | +?> | |
| 18 | + <tr style="border-bottom: 0"> | |
| 19 | + <td style="border-bottom: 0" class="small_width"><?= $model->brand?></td> | |
| 20 | + <td style="border-bottom: 0" class="medium_width"><?= $model->article?> | |
| 21 | + <img src="/images/favourite_notactive.png" class="favourite"> | |
| 22 | + <img src="/images/favourite.png" class="pose"> | |
| 23 | + </td> | |
| 24 | + <td style="border-bottom: 0" class="large_width"><?= $model->description?> | |
| 25 | + <a class="tecdoc_id_info" data-toggle="modal" data-target="#details_content_block" data-id="<?= $model->tecdoc_id ?>" href=""><img src="/images/gear.png"></a> | |
| 26 | + <a href="" id="go_photo"><img src="/images/icon_cam.png"></a> | |
| 27 | + </td> | |
| 28 | +<?php $this->endBlock(); ?> | |
| 29 | + | |
| 30 | + <?php $this->beginBlock('empty_details'); | |
| 31 | + // иначе пустой блок | |
| 32 | + ?> | |
| 33 | + <tr style="border-bottom: 0;border-top: 0;"> | |
| 34 | + <td style="border-bottom: 0;border-top: 0;"></td> | |
| 35 | + <td style="border-bottom: 0;border-top: 0;"></td> | |
| 36 | + <td style="border-bottom: 0;border-top: 0;"></td> | |
| 37 | + | |
| 38 | + <?php $this->endBlock(); ?> | |
| 39 | + | |
| 40 | + <?php | |
| 41 | + if($new_good){ | |
| 42 | + echo $this->blocks['item_details']; | |
| 43 | + }else{ | |
| 44 | + echo $this->blocks['empty_details']; | |
| 45 | + } | |
| 46 | + | |
| 47 | + ?> | |
| 48 | + <td class="right"> | |
| 49 | + <table class="tovar_table right" cellspacing="0" cellpadding="0" border="0" style="border: 0;"> | |
| 50 | + <tbody> | |
| 51 | + <tr class="one" style="border-bottom: 0; | |
| 52 | + border-top: 0;"> | |
| 53 | + <td class="row_select" style="border-bottom: 0; | |
| 54 | + border-top: 0;"> | |
| 55 | + <div class="lend-tovar-cart-left"> | |
| 56 | + <input type="text" class="lend-tovar-cart-number" value="1"> | |
| 57 | + <div class="arrow-cart-lend-wr"> | |
| 58 | + <img class="arrow-cart-lend-1" src="/images/arrow-cart-up.png" width="9" height="6" alt=""> | |
| 59 | + <img class="arrow-cart-lend-2" src="/images/arrow-cart-down1.png" width="9" height="6" alt=""> | |
| 60 | + </div> | |
| 61 | + </div> | |
| 62 | + <button class="purple">В корзину</button> | |
| 63 | + </td> | |
| 64 | + | |
| 65 | + </tr> | |
| 66 | + </tbody></table> | |
| 67 | + | |
| 68 | + </td> | |
| 69 | + <td class="right_large"> | |
| 70 | + <table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 71 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= $model->box ?></td></tr> | |
| 72 | + | |
| 73 | + </table> | |
| 74 | + </td> | |
| 75 | + <td class="right_small"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 76 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= $model->delivery?> дн.</td></tr> | |
| 77 | + | |
| 78 | + </table></td> | |
| 79 | + <td class="right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | |
| 80 | + <tr border='0' style='border-top:0; border-left:0'><td border='0' style='border-top:0; border-left:0'><?= $model->outputPrice?></td></tr> | |
| 81 | + | |
| 82 | + </table></td> | |
| 83 | + </tr> | |
| 84 | + | |
| 85 | + | |
| 86 | + <div id="modal_form_photo"> | |
| 87 | + <span id="modal_close"><img src="/images/close_form.png"></span> | |
| 88 | + <img src="<?= $model->image ?>"> | |
| 89 | + </div> | |
| 0 | 90 | \ No newline at end of file | ... | ... |
frontend/web/css/BC2_catalog_zapchasti.css
| 1 | +$( document ).ready(function() { | |
| 2 | + // для таблицы кроссов, классы обозначаются через cross_ | |
| 3 | + var cross_prefix = ''; | |
| 4 | + | |
| 5 | + // по умолчанию - цены в долларах, остальные скрываем | |
| 6 | + var show_currency = ['usd']; | |
| 7 | + var hidden_currency = ['uah','eur']; | |
| 8 | + | |
| 9 | + $( document ).on( "click", ".currency", changeCurrency ); | |
| 10 | + | |
| 11 | + function changeCurrency(){ | |
| 12 | + | |
| 13 | + if( $(this).attr('id') === 'grivna' ){ | |
| 14 | + show_currency = ['uah']; | |
| 15 | + hidden_currency = ['eur','usd']; | |
| 16 | + }else if( $(this).attr('id') === 'euro' ) { | |
| 17 | + show_currency = ['eur']; | |
| 18 | + hidden_currency = ['uah','usd']; | |
| 19 | + }else if( $(this).attr('id') === 'dollars' ) { | |
| 20 | + show_currency = ['usd']; | |
| 21 | + hidden_currency = ['uah','eur']; | |
| 22 | + } | |
| 23 | + $('.currency').removeClass('active_button_purple1'); | |
| 24 | + $(this).addClass('active_button_purple1'); | |
| 25 | + | |
| 26 | + setVisiblePrice(); | |
| 27 | + } | |
| 28 | + | |
| 29 | + function setVisiblePrice(){ | |
| 30 | + // элементы с классами из show_currency отобразим | |
| 31 | + for( var i = 0; i < show_currency.length; i++ ){ | |
| 32 | + var arr_elements = document.getElementsByClassName(show_currency[i] + cross_prefix); | |
| 33 | + | |
| 34 | + for(var j = 0; j < arr_elements.length; j++ ){ | |
| 35 | + if( arr_elements[j].classList.contains('hidden') ) | |
| 36 | + arr_elements[j].classList.remove('hidden'); | |
| 37 | + } | |
| 38 | + } | |
| 39 | + | |
| 40 | + // элементы с классами из hidden_currency спрячем | |
| 41 | + for( var i = 0; i < hidden_currency.length; i++ ){ | |
| 42 | + var arr_elements = document.getElementsByClassName(hidden_currency[i] + cross_prefix); | |
| 43 | + for(var j = 0; j < arr_elements.length; j++ ){ | |
| 44 | + if( !arr_elements[j].classList.contains('hidden') ) | |
| 45 | + arr_elements[j].classList.add('hidden'); | |
| 46 | + } | |
| 47 | + } | |
| 48 | + } | |
| 49 | + | |
| 50 | +}) | ... | ... |
frontend/web/js/script.js
| ... | ... | @@ -578,13 +578,8 @@ $('.menu_block_center2 .by_articul .menu_search_down').hover(function(){ |
| 578 | 578 | function(){ |
| 579 | 579 | $(this).find('a:first-child').css({'color':'#6b84b5'}); |
| 580 | 580 | } |
| 581 | -); | |
| 582 | -$('.currency').click(function(){ | |
| 583 | - $('.currency').removeClass('active_button_purple1'); | |
| 584 | - $(this).addClass('active_button_purple1'); | |
| 585 | - | |
| 586 | -} | |
| 587 | 581 | ); |
| 582 | + | |
| 588 | 583 | $('.menu_block_center .menu_item').hover(function(){ |
| 589 | 584 | $(this).find('p').addClass('pcolor')}, |
| 590 | 585 | function(){ | ... | ... |