Commit b13c67c36638d2db440622bc2f4f40d8804cd7de
output price in goods controller
Showing
14 changed files
with
426 additions
and
83 deletions
Show diff stats
common/models/Details.php
@@ -6,7 +6,7 @@ use backend\models\Importers; | @@ -6,7 +6,7 @@ use backend\models\Importers; | ||
6 | use common\components\CustomVarDamp; | 6 | use common\components\CustomVarDamp; |
7 | use Yii; | 7 | use Yii; |
8 | use backend\components\base\BaseActiveRecord; | 8 | use backend\components\base\BaseActiveRecord; |
9 | - | 9 | +use yii\db\Query; |
10 | /** | 10 | /** |
11 | * This is the model class for table "{{%details}}". | 11 | * This is the model class for table "{{%details}}". |
12 | * | 12 | * |
@@ -166,4 +166,65 @@ class Details extends BaseActiveRecord | @@ -166,4 +166,65 @@ class Details extends BaseActiveRecord | ||
166 | return true; | 166 | return true; |
167 | } | 167 | } |
168 | 168 | ||
169 | + public function getTehdocData($id){ | ||
170 | + | ||
171 | + $sql = $this->createTehdocQuery(); | ||
172 | + | ||
173 | + | ||
174 | + $connection = \Yii::$app->db; | ||
175 | + $data = $connection | ||
176 | + | ||
177 | + ->createCommand($sql); | ||
178 | + | ||
179 | + $data->bindValues([':ART_ID'=>$id,':LANG_ID'=>16]); | ||
180 | + | ||
181 | + return $data->queryAll(); | ||
182 | + | ||
183 | + } | ||
184 | + | ||
185 | + public function createTehdocQuery(){ | ||
186 | + $sql = "SELECT | ||
187 | + TYP_ID , | ||
188 | + MFA_BRAND, | ||
189 | + MFA_ID, | ||
190 | + DES_TEXTS7.TEX_TEXT AS MOD_CDS_TEXT, | ||
191 | + TYP_MOD_ID as `mod_id`, | ||
192 | + DES_TEXTS.TEX_TEXT AS TYP_CDS_TEXT, | ||
193 | + TYP_PCON_START, | ||
194 | + TYP_PCON_END, | ||
195 | + TYP_CCM, | ||
196 | + TYP_KW_FROM,TYP_KW_UPTO, | ||
197 | + TYP_HP_FROM,TYP_HP_UPTO, | ||
198 | + GROUP_CONCAT(distinct ENGINES.ENG_CODE SEPARATOR ' / ') as ENG_CODE, | ||
199 | + DES_TEXTS3.TEX_TEXT AS TYP_ENGINE_DES_TEXT | ||
200 | + FROM | ||
201 | + LINK_ART | ||
202 | + INNER JOIN LINK_LA_TYP ON LAT_LA_ID = LA_ID | ||
203 | + INNER JOIN TYPES ON TYP_ID = LAT_TYP_ID | ||
204 | + INNER JOIN COUNTRY_DESIGNATIONS ON COUNTRY_DESIGNATIONS.CDS_ID = TYP_CDS_ID AND COUNTRY_DESIGNATIONS.CDS_LNG_ID = :LANG_ID | ||
205 | + INNER JOIN DES_TEXTS ON DES_TEXTS.TEX_ID = COUNTRY_DESIGNATIONS.CDS_TEX_ID | ||
206 | + | ||
207 | + INNER JOIN MODELS ON MOD_ID = TYP_MOD_ID and | ||
208 | + MOD_PCON_START >= 198001 | ||
209 | + INNER JOIN COUNTRY_DESIGNATIONS AS COUNTRY_DESIGNATIONS2 ON COUNTRY_DESIGNATIONS2.CDS_ID = MOD_CDS_ID and | ||
210 | + COUNTRY_DESIGNATIONS2.CDS_LNG_ID = :LANG_ID | ||
211 | + INNER JOIN DES_TEXTS AS DES_TEXTS7 ON DES_TEXTS7.TEX_ID = COUNTRY_DESIGNATIONS2.CDS_TEX_ID | ||
212 | + | ||
213 | + INNER JOIN w_manufacturers ON MFA_ID = MOD_MFA_ID and MY_ACTIVE = 1 | ||
214 | + LEFT JOIN LINK_TYP_ENG ON LTE_TYP_ID = TYP_ID | ||
215 | + LEFT JOIN ENGINES ON ENG_ID = LTE_ENG_ID | ||
216 | + LEFT JOIN DESIGNATIONS AS DESIGNATIONS3 ON DESIGNATIONS3.DES_ID = TYP_KV_BODY_DES_ID AND DESIGNATIONS3.DES_LNG_ID = :LANG_ID | ||
217 | + LEFT JOIN DES_TEXTS AS DES_TEXTS4 ON DES_TEXTS4.TEX_ID = DESIGNATIONS3.DES_TEX_ID | ||
218 | + LEFT JOIN DESIGNATIONS AS DESIGNATIONS4 ON DESIGNATIONS4.DES_ID = TYP_KV_MODEL_DES_ID AND DESIGNATIONS4.DES_LNG_ID = :LANG_ID | ||
219 | + LEFT JOIN DES_TEXTS AS DES_TEXTS5 ON DES_TEXTS5.TEX_ID = DESIGNATIONS4.DES_TEX_ID | ||
220 | + LEFT JOIN DESIGNATIONS AS DESIGNATIONS6 ON DESIGNATIONS6.DES_ID = TYP_KV_DRIVE_DES_ID AND DESIGNATIONS6.DES_LNG_ID = :LANG_ID | ||
221 | + LEFT JOIN DES_TEXTS AS DES_TEXTS6 ON DES_TEXTS6.TEX_ID = DESIGNATIONS6.DES_TEX_ID | ||
222 | + LEFT JOIN DESIGNATIONS AS DESIGNATIONS2 ON DESIGNATIONS2.DES_ID = TYP_KV_FUEL_DES_ID AND DESIGNATIONS2.DES_LNG_ID = :LANG_ID | ||
223 | + LEFT JOIN DES_TEXTS AS DES_TEXTS3 ON DES_TEXTS3.TEX_ID = DESIGNATIONS2.DES_TEX_ID | ||
224 | + WHERE LA_ART_ID = :ART_ID | ||
225 | + group by `TYP_ID` | ||
226 | + order by MFA_BRAND,MOD_CDS_TEXT,TYP_CDS_TEXT"; | ||
227 | + return $sql; | ||
228 | + } | ||
229 | + | ||
169 | } | 230 | } |
common/models/GoodsView.php
@@ -21,7 +21,7 @@ use Yii; | @@ -21,7 +21,7 @@ use Yii; | ||
21 | * @property string $ID | 21 | * @property string $ID |
22 | * @property string $image | 22 | * @property string $image |
23 | * @property string $tecdoc_id | 23 | * @property string $tecdoc_id |
24 | - * @property double $price | 24 | + * @property double $price - цена в гривнях |
25 | * @property string $brand_id | 25 | * @property string $brand_id |
26 | 26 | ||
27 | */ | 27 | */ |
@@ -29,8 +29,9 @@ class GoodsView extends \backend\components\base\BaseActiveRecord | @@ -29,8 +29,9 @@ class GoodsView extends \backend\components\base\BaseActiveRecord | ||
29 | { | 29 | { |
30 | /** | 30 | /** |
31 | * @inheritdoc | 31 | * @inheritdoc |
32 | + * служебный аттрибут для определения отдельного вывода кроссов и оригинальных деталей | ||
32 | */ | 33 | */ |
33 | - | 34 | + public $crosses; |
34 | 35 | ||
35 | public static function tableName() | 36 | public static function tableName() |
36 | { | 37 | { |
@@ -55,7 +56,7 @@ class GoodsView extends \backend\components\base\BaseActiveRecord | @@ -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 | public function getOutputPrice() | 61 | public function getOutputPrice() |
61 | { | 62 | { |
@@ -73,7 +74,61 @@ class GoodsView extends \backend\components\base\BaseActiveRecord | @@ -73,7 +74,61 @@ class GoodsView extends \backend\components\base\BaseActiveRecord | ||
73 | if(!$rate) | 74 | if(!$rate) |
74 | $rate = 1; // если 0, то 1 | 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 | public static function primaryKey() | 134 | public static function primaryKey() |
common/models/GoodsViewSearch.php
@@ -42,11 +42,6 @@ class GoodsViewSearch extends GoodsView | @@ -42,11 +42,6 @@ class GoodsViewSearch extends GoodsView | ||
42 | { | 42 | { |
43 | $query = GoodsView::find(); | 43 | $query = GoodsView::find(); |
44 | 44 | ||
45 | -// $pagination = [ | ||
46 | -// 'pageSize' => 20, | ||
47 | -// ]; | ||
48 | - | ||
49 | - | ||
50 | $this->load($params); | 45 | $this->load($params); |
51 | 46 | ||
52 | if ( !$this->validate() ) { | 47 | if ( !$this->validate() ) { |
@@ -58,51 +53,18 @@ class GoodsViewSearch extends GoodsView | @@ -58,51 +53,18 @@ class GoodsViewSearch extends GoodsView | ||
58 | 'brand' => $this->brand, | 53 | 'brand' => $this->brand, |
59 | ]); | 54 | ]); |
60 | 55 | ||
61 | - $query->andWhere(['or', 'box > 0', 'add_box > 0']); | 56 | + $query->andWhere(['or', 'box > 0', 'add_box > 0'])->orderBy(['price' => SORT_DESC]); |
62 | 57 | ||
63 | $dataProvider = new ActiveDataProvider([ | 58 | $dataProvider = new ActiveDataProvider([ |
64 | 'query' => $query, | 59 | 'query' => $query, |
65 | 'key' => 'name', | 60 | 'key' => 'name', |
66 | - 'sort' => [ | ||
67 | - 'attributes' => [ | ||
68 | - 'box', | ||
69 | - 'delivery', | ||
70 | - 'price' | ||
71 | - ], | ||
72 | - ], | ||
73 | - | ||
74 | ]); | 61 | ]); |
75 | 62 | ||
76 | return $dataProvider; | 63 | return $dataProvider; |
77 | } | 64 | } |
78 | public function searchCrosses($params) | 65 | public function searchCrosses($params) |
79 | { | 66 | { |
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 | - | 67 | + $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 | 68 | ||
107 | $this->load($params); | 69 | $this->load($params); |
108 | 70 | ||
@@ -111,23 +73,15 @@ class GoodsViewSearch extends GoodsView | @@ -111,23 +73,15 @@ class GoodsViewSearch extends GoodsView | ||
111 | } | 73 | } |
112 | 74 | ||
113 | $query->andFilterWhere([ | 75 | $query->andFilterWhere([ |
114 | - 'w_details_crosses.ARTICLE' => $this->name, | ||
115 | - 'w_details_crosses.BRAND' => $this->brand, | 76 | + 'w_details_crosses.CROSS_ARTICLE' => $this->name, |
77 | + 'w_details_crosses.CROSS_BRAND' => $this->brand, | ||
116 | ]); | 78 | ]); |
117 | 79 | ||
118 | - $query->andWhere(['or', 'box > 0', 'add_box > 0']); | 80 | + $query->andWhere(['or', 'box > 0', 'add_box > 0'])->orderBy(['price' => SORT_DESC]); |
119 | 81 | ||
120 | $dataProvider = new ActiveDataProvider([ | 82 | $dataProvider = new ActiveDataProvider([ |
121 | 'query' => $query, | 83 | 'query' => $query, |
122 | 'key' => 'name', | 84 | 'key' => 'name', |
123 | - 'sort' => [ | ||
124 | - 'attributes' => [ | ||
125 | - 'box', | ||
126 | - 'delivery', | ||
127 | - 'price' | ||
128 | - ], | ||
129 | - ], | ||
130 | - | ||
131 | ]); | 85 | ]); |
132 | 86 | ||
133 | return $dataProvider; | 87 | return $dataProvider; |
console/migrations/m151219_103804_goods_view.php
@@ -46,7 +46,7 @@ class m151219_103804_goods_view extends Migration | @@ -46,7 +46,7 @@ class m151219_103804_goods_view extends Migration | ||
46 | ) as `image`, | 46 | ) as `image`, |
47 | `w_details_description`.`tecdoc_id`, | 47 | `w_details_description`.`tecdoc_id`, |
48 | 48 | ||
49 | - `w_details`.`PRICE`as `price`, | 49 | + `w_details`.`PRICE` * rate as `price`, |
50 | `w_brands`.`ID` as `brand_id` | 50 | `w_brands`.`ID` as `brand_id` |
51 | from `w_details` | 51 | from `w_details` |
52 | inner join `w_brands` on `w_brands`.`BRAND` = `w_details`.`BRAND` | 52 | inner join `w_brands` on `w_brands`.`BRAND` = `w_details`.`BRAND` |
1 | +<?php | ||
2 | + | ||
3 | +namespace frontend\controllers; | ||
4 | + | ||
5 | +use common\models\Details; | ||
6 | +use yii\data\ArrayDataProvider; | ||
7 | +use yii\web\Controller; | ||
8 | + | ||
9 | +class DetailController extends Controller { | ||
10 | + | ||
11 | + public function actionIndex() | ||
12 | + { | ||
13 | + | ||
14 | + return $this->render('index'); | ||
15 | + } | ||
16 | + | ||
17 | + public function actionGetDetailsForItem() | ||
18 | + { | ||
19 | + | ||
20 | + $data = (new Details)->getTehdocData('1204403'); | ||
21 | + | ||
22 | + | ||
23 | + return $this->renderPartial('details_view',[ | ||
24 | + 'data' => $data | ||
25 | + | ||
26 | + ]); | ||
27 | + } | ||
28 | + | ||
29 | + | ||
30 | +} | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |
frontend/controllers/GoodsController.php
@@ -10,9 +10,11 @@ namespace frontend\controllers; | @@ -10,9 +10,11 @@ namespace frontend\controllers; | ||
10 | 10 | ||
11 | use common\components\CustomVarDamp; | 11 | use common\components\CustomVarDamp; |
12 | use common\models\DetailsCrosses; | 12 | use common\models\DetailsCrosses; |
13 | +use common\models\GoodsView; | ||
13 | use common\models\GoodsViewSearch; | 14 | use common\models\GoodsViewSearch; |
14 | use Yii; | 15 | use Yii; |
15 | use yii\web\Controller; | 16 | use yii\web\Controller; |
17 | +use common\models\Details; | ||
16 | 18 | ||
17 | class GoodsController extends Controller { | 19 | class GoodsController extends Controller { |
18 | public $layout = '/internal'; | 20 | public $layout = '/internal'; |
@@ -20,18 +22,26 @@ class GoodsController extends Controller { | @@ -20,18 +22,26 @@ class GoodsController extends Controller { | ||
20 | public function actionIndex( $name , $id ) | 22 | public function actionIndex( $name , $id ) |
21 | { | 23 | { |
22 | 24 | ||
25 | + | ||
23 | $arr_name = explode('_',$name); | 26 | $arr_name = explode('_',$name); |
24 | $brand = $arr_name[0]; | 27 | $brand = $arr_name[0]; |
25 | $article = $arr_name[1]; | 28 | $article = $arr_name[1]; |
26 | 29 | ||
27 | - $arr = ['GoodsViewSearch' => ['name' => $article, | ||
28 | - 'brand' => $brand]]; | 30 | + |
31 | + $arr_values = ['name' => $article, | ||
32 | + 'brand' => $brand]; | ||
33 | + $arr = ['GoodsViewSearch' => $arr_values]; | ||
34 | + | ||
29 | if(empty( Yii::$app->user->identity )){ | 35 | if(empty( Yii::$app->user->identity )){ |
30 | $margin_id = 1; | 36 | $margin_id = 1; |
31 | }else{ | 37 | }else{ |
32 | $margin_id = Yii::$app->user->identity->margin_id; | 38 | $margin_id = Yii::$app->user->identity->margin_id; |
33 | } | 39 | } |
34 | 40 | ||
41 | +// $arr = ['GoodsViewSearch' => ['name' => '0092S40090', | ||
42 | +// 'brand' => 'BOSCH']]; | ||
43 | + | ||
44 | + | ||
35 | Yii::$app->session->setFlash('price_currency_id', 1); | 45 | Yii::$app->session->setFlash('price_currency_id', 1); |
36 | Yii::$app->session->setFlash('price_margin_id', $margin_id); | 46 | Yii::$app->session->setFlash('price_margin_id', $margin_id); |
37 | 47 | ||
@@ -40,9 +50,13 @@ class GoodsController extends Controller { | @@ -40,9 +50,13 @@ class GoodsController extends Controller { | ||
40 | 50 | ||
41 | $crosses_provider = $searchModel->searchCrosses($arr); | 51 | $crosses_provider = $searchModel->searchCrosses($arr); |
42 | 52 | ||
53 | + // для заголовка таблицы (карточка товара) | ||
54 | + $detailsModel = GoodsView::findOne($arr_values); | ||
55 | + | ||
43 | return $this->render('index',[ | 56 | return $this->render('index',[ |
44 | 'goods_data_provider' => $goods_provider, | 57 | 'goods_data_provider' => $goods_provider, |
45 | 'crosses_data_provider' => $crosses_provider, | 58 | 'crosses_data_provider' => $crosses_provider, |
59 | + 'detailsModel' => $detailsModel, | ||
46 | ]); | 60 | ]); |
47 | } | 61 | } |
48 | 62 |
1 | +<table class="details-list" width="100%" id="isset_cars"> | ||
2 | + <thead> | ||
3 | + <tr> | ||
4 | + <th class="header1 headerSortDown">Марка</th> | ||
5 | + <th class="header1">Модель</th> | ||
6 | + <th class="header1">Модификация</th> | ||
7 | + <th class="header1">Год выпуска</th> | ||
8 | + <th class="header1">Объем двигателя, литров</th> | ||
9 | + <th class="header1">kW</th> | ||
10 | + <th class="header1">Л.силы</th> | ||
11 | + <th class="header1">Код двигателя</th> | ||
12 | + </tr> | ||
13 | + </thead> | ||
14 | + <tbody> | ||
15 | + <?php $i=0; ?> | ||
16 | + <?php foreach($data as $name=>$item):?> | ||
17 | + <?php $i++;?> | ||
18 | + <tr> | ||
19 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['MFA_BRAND']?></td> | ||
20 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['MOD_CDS_TEXT']?></td> | ||
21 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['TYP_CDS_TEXT']?></td> | ||
22 | + <td class="<?=($i%2)?'cell':''?>"> | ||
23 | + <?=substr($item['TYP_PCON_START'],0,4)?>.<?=substr($item['TYP_PCON_START'],4,6)?> | ||
24 | + <?php if ($item['TYP_PCON_END']):?>-<?=substr($item['TYP_PCON_END'],0,4)?>.<?=substr($item['TYP_PCON_END'],4,6)?><?php endif; ?> | ||
25 | + </td> | ||
26 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['TYP_CCM']?></td> | ||
27 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['TYP_KW_FROM']?><?=($item['TYP_KW_UPTO'])?'-'.$item['TYP_KW_UPTO']:''?></td> | ||
28 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['TYP_HP_FROM']?><?=($item['TYP_HP_UPTO'])?'-'.$item['TYP_HP_UPTO']:''?></td> | ||
29 | + <td class="<?=($i%2)?'cell':''?>"><?=$item['ENG_CODE']?>, <?=$item['TYP_ENGINE_DES_TEXT']?></td> | ||
30 | + </tr> | ||
31 | + <?php endforeach; ?> | ||
32 | + </tbody> | ||
33 | +</table> | ||
34 | + | ||
35 | +<script type="text/javascript"> | ||
36 | + $(document).ready(function(){ | ||
37 | + $(".details-list").tablesorter(); | ||
38 | + }); | ||
39 | +</script> | ||
0 | \ No newline at end of file | 40 | \ No newline at end of file |
frontend/views/goods/index.php
@@ -6,10 +6,16 @@ $sort = new Sort([ | @@ -6,10 +6,16 @@ $sort = new Sort([ | ||
6 | 'attributes' => [ | 6 | 'attributes' => [ |
7 | 'box' => ['label' => 'Наличие'], | 7 | 'box' => ['label' => 'Наличие'], |
8 | 'delivery' => ['label' => 'Срок'], | 8 | 'delivery' => ['label' => 'Срок'], |
9 | - 'price' => ['label' => 'Цена'], | 9 | + 'price' => [ |
10 | + 'asc' => ['price' => SORT_ASC ], | ||
11 | + 'desc' => ['price' => SORT_DESC], | ||
12 | + 'default' => SORT_DESC, | ||
13 | + 'label' => 'Цена'], | ||
10 | ], | 14 | ], |
11 | ]); | 15 | ]); |
12 | $this->registerCssFile('/css/BC2_catalog_zapchasti.css'); | 16 | $this->registerCssFile('/css/BC2_catalog_zapchasti.css'); |
17 | +$this->registerJsFile('/js/jquery.tablesorter.min.js'); | ||
18 | +$this->registerJsFile('/js/goods.js'); | ||
13 | $this->params['breadcrumbs'][] = $this->title; | 19 | $this->params['breadcrumbs'][] = $this->title; |
14 | \yii\widgets\Pjax::begin(); | 20 | \yii\widgets\Pjax::begin(); |
15 | ?> | 21 | ?> |
@@ -23,9 +29,9 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -23,9 +29,9 @@ $this->params['breadcrumbs'][] = $this->title; | ||
23 | <img src="/images/arrow_dots.png"> | 29 | <img src="/images/arrow_dots.png"> |
24 | <a href="" class='navigation'>Акамуляторы(АКБ)</a> | 30 | <a href="" class='navigation'>Акамуляторы(АКБ)</a> |
25 | <img src="/images/arrow_dots.png"> | 31 | <img src="/images/arrow_dots.png"> |
26 | - <span>Аккумулятор<span class='detail_name'> 0 092 S30 120: BOSCH</span></span> | 32 | + <span>Аккумулятор<span class='detail_name'> <?= "{$detailsModel->name}: {$detailsModel->brand}"?></span></span> |
27 | 33 | ||
28 | - <p class="vin_article">Аккумулятор 0 092 S30 120: BOSCH</p> | 34 | + <p class="vin_article"><?= "{$detailsModel->name}: {$detailsModel->brand}"?></p> |
29 | <div class="tovar_card"> | 35 | <div class="tovar_card"> |
30 | <div class="search_span zapchasti"> | 36 | <div class="search_span zapchasti"> |
31 | 37 | ||
@@ -60,20 +66,25 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -60,20 +66,25 @@ $this->params['breadcrumbs'][] = $this->title; | ||
60 | <table class='detail'> | 66 | <table class='detail'> |
61 | <tr> | 67 | <tr> |
62 | <td> | 68 | <td> |
63 | - <img src="/images/acamulator_big.png"> | ||
64 | - <img src="/images/small_plus.png"> | 69 | + <?php |
70 | +// <img src="/images/acamulator_big.png"> | ||
71 | +// <img src="/images/small_plus.png"> | ||
72 | + ?> | ||
65 | </td> | 73 | </td> |
66 | 74 | ||
67 | 75 | ||
68 | <td> | 76 | <td> |
69 | - <p class='bold_line'>0 092 S30 120: BOSCH</p> | ||
70 | - <p class="thin_line">12V 88Ah 740A</p> | ||
71 | - <p class='bold_line space'>Емкость, А/Ч:<span class='thin_line'> 88</span></p> | ||
72 | - <p class="bold_line">Полярность: Правая (-/+)</p> | 77 | + |
78 | + <p class='bold_line'><?= "{$detailsModel->name}: {$detailsModel->brand}"?></p> | ||
79 | + <p class="thin_line"><?= "{$detailsModel->description}"?></p> | ||
80 | + | ||
73 | </td> | 81 | </td> |
74 | </tr> | 82 | </tr> |
75 | <tr class="galery"> | 83 | <tr class="galery"> |
76 | - <td><img src="/images/acamulator_small_gallery.png"><img src="/images/acamulator_small_gallery.png"></td> | 84 | + <?php |
85 | + // <td><img src="/images/acamulator_small_gallery.png"><img src="/images/acamulator_small_gallery.png"></td> | ||
86 | + ?> | ||
87 | + | ||
77 | </tr> | 88 | </tr> |
78 | </table> | 89 | </table> |
79 | <img src="/images/arrow_rounded.png" class='arrow_rounded'> | 90 | <img src="/images/arrow_rounded.png" class='arrow_rounded'> |
@@ -87,9 +98,10 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -87,9 +98,10 @@ $this->params['breadcrumbs'][] = $this->title; | ||
87 | <div class="vin tables"> | 98 | <div class="vin tables"> |
88 | 99 | ||
89 | <div class="first_section"> | 100 | <div class="first_section"> |
90 | - <p class="bold_line">12V 88Ah 740A Bosch 0092s30120</p> | ||
91 | - <p class="currency opposite" id="dollars">грн</p> | ||
92 | - <p class="currency active_button_purple1" id="grivna">$</p> | 101 | + <p class="bold_line"><?= "{$detailsModel->description} {$detailsModel->brand} {$detailsModel->name}"?></p> |
102 | + <p class="currency opposite" id="grivna">UAH</p> | ||
103 | + <p class="currency active_button_purple1" id="dollars">USD</p> | ||
104 | + <p class="currency opposite" id="euro">EUR</p> | ||
93 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> | 105 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> |
94 | <tbody><tr class="name"> | 106 | <tbody><tr class="name"> |
95 | <td class="small_width row_name">Фирма</td> | 107 | <td class="small_width row_name">Фирма</td> |
@@ -116,8 +128,9 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -116,8 +128,9 @@ $this->params['breadcrumbs'][] = $this->title; | ||
116 | </div> | 128 | </div> |
117 | <div class="second_section"> | 129 | <div class="second_section"> |
118 | <p class="bold_line">Замены искомого производителя</p> | 130 | <p class="bold_line">Замены искомого производителя</p> |
119 | - <p class="currency1 opposite1" id="dollars">грн</p> | ||
120 | - <p class="currency1 active_button_purple11" id="grivna">$</p> | 131 | + <p class="cross_currency opposite" id="cross_grivna">UAH</p> |
132 | + <p class="cross_currency active_button_purple1" id="cross_dollars">USD</p> | ||
133 | + <p class="cross_currency opposite" id="cross_euro">EUR</p> | ||
121 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> | 134 | <table class="tovar_table" cellspacing="0" cellpadding="0" border="0"> |
122 | <tbody> | 135 | <tbody> |
123 | <tr class="name"> | 136 | <tr class="name"> |
@@ -147,6 +160,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -147,6 +160,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
147 | </div> | 160 | </div> |
148 | 161 | ||
149 | </div> | 162 | </div> |
163 | + | ||
150 | <script type="text/javascript"> | 164 | <script type="text/javascript"> |
151 | function changeText() { | 165 | function changeText() { |
152 | e = document.getElementById('button_grey_card'); | 166 | e = document.getElementById('button_grey_card'); |
@@ -160,11 +174,24 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -160,11 +174,24 @@ $this->params['breadcrumbs'][] = $this->title; | ||
160 | }); | 174 | }); |
161 | $('.link_sort').click(function(){ | 175 | $('.link_sort').click(function(){ |
162 | 176 | ||
163 | - $(this).find('.desc).toggleClass('arrow_downA'); | 177 | + $(this).find('.desc').toggleClass('arrow_downA'); |
164 | 178 | ||
165 | }) | 179 | }) |
166 | </script> | 180 | </script> |
167 | 181 | ||
168 | <?php | 182 | <?php |
169 | \yii\widgets\Pjax::end(); | 183 | \yii\widgets\Pjax::end(); |
170 | -?> | ||
171 | \ No newline at end of file | 184 | \ No newline at end of file |
185 | +?> | ||
186 | + | ||
187 | +<div class="modal fade" id="details_content_block" > | ||
188 | + <div class="modal-dialog"> | ||
189 | + <div class="modal-content"> | ||
190 | + <div class="modal-header"> | ||
191 | + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ||
192 | + </div> | ||
193 | + <div id="details_content"> | ||
194 | + | ||
195 | + </div> | ||
196 | + </div> | ||
197 | + </div> | ||
198 | +</div> | ||
172 | \ No newline at end of file | 199 | \ No newline at end of file |
frontend/views/goods/one_item.php
1 | <?php | 1 | <?php |
2 | use \yii\helpers\Html; | 2 | use \yii\helpers\Html; |
3 | 3 | ||
4 | -$this->registerCssFile('/css/BC2_catalog_zapchasti.css'); | ||
5 | // если товар один и тот же то выводим только цену и кол-во | 4 | // если товар один и тот же то выводим только цену и кол-во |
6 | // иначе всю информацию | 5 | // иначе всю информацию |
7 | $new_good = false; | 6 | $new_good = false; |
@@ -10,9 +9,10 @@ $article_arr = $widget->dataProvider->getKeys(); | @@ -10,9 +9,10 @@ $article_arr = $widget->dataProvider->getKeys(); | ||
10 | if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | 9 | if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) |
11 | // если предыдущий артикул равен текущему, то это тот же товар | 10 | // если предыдущий артикул равен текущему, то это тот же товар |
12 | $new_good = true; | 11 | $new_good = true; |
13 | -?> | 12 | +// определим это вызов основной таблицы или кросс таблицы |
13 | +$cross_prefix = ( empty($model->crosses) )? '': '_cross'; | ||
14 | 14 | ||
15 | -<?php $this->beginBlock('item_details'); | 15 | + $this->beginBlock('item_details'); |
16 | // выделим отдельно детали товара в блок, для опционального его вывода | 16 | // выделим отдельно детали товара в блок, для опционального его вывода |
17 | ?> | 17 | ?> |
18 | <tr style="border-bottom: 0"> | 18 | <tr style="border-bottom: 0"> |
@@ -22,7 +22,7 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | @@ -22,7 +22,7 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | ||
22 | <img src="/images/favourite.png" class="pose"> | 22 | <img src="/images/favourite.png" class="pose"> |
23 | </td> | 23 | </td> |
24 | <td style="border-bottom: 0" class="large_width"><?= $model->description?> | 24 | <td style="border-bottom: 0" class="large_width"><?= $model->description?> |
25 | - <a href=""><img src="/images/gear.png"></a> | 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> | 26 | <a href="" id="go_photo"><img src="/images/icon_cam.png"></a> |
27 | </td> | 27 | </td> |
28 | <?php $this->endBlock(); ?> | 28 | <?php $this->endBlock(); ?> |
@@ -76,8 +76,22 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | @@ -76,8 +76,22 @@ if ( empty($article_arr[$index - 1]) || $article_arr[$index - 1] != $key ) | ||
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> | 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 | 77 | ||
78 | </table></td> | 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> | 79 | + <td class="usd<?=$cross_prefix?> 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'><?= \Yii::$app->formatter->asDecimal( $model->outputPriceUSD )?></td></tr> | ||
81 | + | ||
82 | + </table></td> | ||
83 | + <td class="hidden uah<?=$cross_prefix?> right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | ||
84 | + <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> | ||
85 | + | ||
86 | + </table></td> | ||
87 | + <td class="hidden eur<?=$cross_prefix?> right_medium"><table class="inner" border='0' style='border-top:0; border-left:0'> | ||
88 | + <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 | 89 | ||
82 | </table></td> | 90 | </table></td> |
83 | </tr> | 91 | </tr> |
92 | + | ||
93 | + | ||
94 | + <div id="modal_form_photo"> | ||
95 | + <span id="modal_close"><img src="/images/close_form.png"></span> | ||
96 | + <img src="<?= $model->image ?>"> | ||
97 | + </div> | ||
84 | \ No newline at end of file | 98 | \ No newline at end of file |
frontend/web/css/BC2_catalog_zapchasti.css
@@ -124,6 +124,22 @@ | @@ -124,6 +124,22 @@ | ||
124 | position: relative; | 124 | position: relative; |
125 | text-align: center; | 125 | text-align: center; |
126 | } | 126 | } |
127 | +.cross_currency{ | ||
128 | + display:inline-block; | ||
129 | + | ||
130 | + font-weight: normal; | ||
131 | + color: #6c83b5; | ||
132 | + height: 21px; | ||
133 | + width: 36px; | ||
134 | + border-radius: 4px 0 0 4px; | ||
135 | + border: 1px solid #efeff0; | ||
136 | + background-color: #efeff0; | ||
137 | + cursor: pointer; | ||
138 | + float:right; | ||
139 | + display: inline-block; | ||
140 | + position: relative; | ||
141 | + text-align: center; | ||
142 | +} | ||
127 | 143 | ||
128 | .currency1{ | 144 | .currency1{ |
129 | display:inline-block; | 145 | display:inline-block; |
@@ -531,4 +547,8 @@ td .purple { | @@ -531,4 +547,8 @@ td .purple { | ||
531 | border: 1px solid #dfdfdf; | 547 | border: 1px solid #dfdfdf; |
532 | width: 180px; | 548 | width: 180px; |
533 | margin-left: 20px; | 549 | margin-left: 20px; |
534 | -} | ||
535 | \ No newline at end of file | 550 | \ No newline at end of file |
551 | +} | ||
552 | +/*for prices column*/ | ||
553 | +.hidden{ | ||
554 | + display: none; | ||
555 | +} |
1 | +$( document ).ready(function() { | ||
2 | + // кнопки с переключателями валюты с основной таблицы | ||
3 | + var btn_eur = document.getElementById('euro'); | ||
4 | + var btn_uah = document.getElementById('grivna'); | ||
5 | + var btn_usd = document.getElementById('dollars'); | ||
6 | + // кнопки с переключателями валюты таблицы с кроссами | ||
7 | + var cross_btn_eur = document.getElementById('cross_euro'); | ||
8 | + var cross_btn_uah = document.getElementById('cross_grivna'); | ||
9 | + var cross_btn_usd = document.getElementById('cross_dollars'); | ||
10 | + | ||
11 | + // для таблицы кроссов, классы обозначаются через cross_ | ||
12 | + var cross_prefix = ''; | ||
13 | + | ||
14 | + // по умолчанию - цены в долларах, остальные скрываем | ||
15 | + var show_currency = ['usd']; | ||
16 | + var hidden_currency = ['uah','eur']; | ||
17 | + | ||
18 | + // назначим события кнопкам переключателей валюты | ||
19 | + if(btn_eur) | ||
20 | + btn_eur.onclick = changeEUR; | ||
21 | + if(btn_uah) | ||
22 | + btn_uah.onclick = changeUAH; | ||
23 | + if(btn_usd) | ||
24 | + btn_usd.onclick = changeUSD; | ||
25 | + if(cross_btn_eur) | ||
26 | + cross_btn_eur.onclick = changeEUR; | ||
27 | + if(cross_btn_uah) | ||
28 | + cross_btn_uah.onclick = changeUAH; | ||
29 | + if(cross_btn_usd) | ||
30 | + cross_btn_usd.onclick = changeUSD; | ||
31 | + | ||
32 | + | ||
33 | + function changeEUR(){ | ||
34 | + if( $(this).hasClass('cross_currency') ){ | ||
35 | + cross_prefix = '_cross'; | ||
36 | + }else{ | ||
37 | + cross_prefix = ''; | ||
38 | + } | ||
39 | + | ||
40 | + show_currency = ['eur']; | ||
41 | + hidden_currency = ['uah','usd']; | ||
42 | + setVisiblePrice(); | ||
43 | + } | ||
44 | + function changeUAH(){ | ||
45 | + if( $(this).hasClass('cross_currency') ){ | ||
46 | + cross_prefix = '_cross'; | ||
47 | + }else{ | ||
48 | + cross_prefix = ''; | ||
49 | + } | ||
50 | + | ||
51 | + show_currency = ['uah']; | ||
52 | + hidden_currency = ['eur','usd']; | ||
53 | + setVisiblePrice(); | ||
54 | + } | ||
55 | + function changeUSD(){ | ||
56 | + if( $(this).hasClass('cross_currency') ){ | ||
57 | + cross_prefix = '_cross'; | ||
58 | + }else{ | ||
59 | + cross_prefix = ''; | ||
60 | + } | ||
61 | + | ||
62 | + show_currency = ['usd']; | ||
63 | + hidden_currency = ['uah','eur']; | ||
64 | + setVisiblePrice(); | ||
65 | + } | ||
66 | + | ||
67 | + function setVisiblePrice(){ | ||
68 | + // элементы с классами из show_currency отобразим | ||
69 | + for( var i = 0; i < show_currency.length; i++ ){ | ||
70 | + var arr_elements = document.getElementsByClassName(show_currency[i] + cross_prefix); | ||
71 | + for(var j = 0; j < arr_elements.length; j++ ){ | ||
72 | + | ||
73 | + if( arr_elements[j].classList.contains('hidden') ) | ||
74 | + arr_elements[j].classList.remove('hidden'); | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + // элементы с классами из hidden_currency спрячем | ||
79 | + for( var i = 0; i < hidden_currency.length; i++ ){ | ||
80 | + var arr_elements = document.getElementsByClassName(hidden_currency[i] + cross_prefix); | ||
81 | + for(var j = 0; j < arr_elements.length; j++ ){ | ||
82 | + if( !arr_elements[j].classList.contains('hidden') ) | ||
83 | + arr_elements[j].classList.add('hidden'); | ||
84 | + } | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | +}) |
1 | + | ||
2 | +(function($){$.extend({tablesorter:new | ||
3 | +function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,rows,-1,i);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,rows,rowIndex,cellIndex){var l=parsers.length,node=false,nodeValue=false,keepLooking=true;while(nodeValue==''&&keepLooking){rowIndex++;if(rows[rowIndex]){node=getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex);nodeValue=trimAndGetNodeText(table.config,node);if(table.config.debug){log('Checking if value was empty on row:'+rowIndex);}}else{keepLooking=false;}}for(var i=1;i<l;i++){if(parsers[i].is(nodeValue,table,node)){return parsers[i];}}return parsers[0];}function getNodeFromRowAndCellIndex(rows,rowIndex,cellIndex){return rows[rowIndex].cells[cellIndex];}function trimAndGetNodeText(config,node){return $.trim(getElementText(config,node));}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=$(table.tBodies[0].rows[i]),cols=[];if(c.hasClass(table.config.cssChildRow)){cache.row[cache.row.length-1]=cache.row[cache.row.length-1].add(c);continue;}cache.row.push(c);for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c[0].cells[j]),table,c[0].cells[j]));}cols.push(cache.normalized.length);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){var text="";if(!node)return"";if(!config.supportsTextContent)config.supportsTextContent=node.textContent||false;if(config.textExtraction=="simple"){if(config.supportsTextContent){text=node.textContent;}else{if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){text=node.childNodes[0].innerHTML;}else{text=node.innerHTML;}}}else{if(typeof(config.textExtraction)=="function"){text=config.textExtraction(node);}else{text=$(node).text();}}return text;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){var pos=n[i][checkCell];rows.push(r[pos]);if(!table.config.appender){var l=r[pos].length;for(var j=0;j<l;j++){tableBody[0].appendChild(r[pos][j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false;var header_index=computeTableHeaderCellIndexes(table);$tableHeaders=$(table.config.selectorHeaders,table).each(function(index){this.column=header_index[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(table.config.sortInitialOrder);this.count=this.order;if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(checkHeaderOptionsSortingLocked(table,index))this.order=this.lockedOrder=checkHeaderOptionsSortingLocked(table,index);if(!this.sortDisabled){var $th=$(this).addClass(table.config.cssHeader);if(table.config.onRenderHeader)table.config.onRenderHeader.apply($th);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function computeTableHeaderCellIndexes(t){var matrix=[];var lookup={};var thead=t.getElementsByTagName('THEAD')[0];var trs=thead.getElementsByTagName('TR');for(var i=0;i<trs.length;i++){var cells=trs[i].cells;for(var j=0;j<cells.length;j++){var c=cells[j];var rowIndex=c.parentNode.rowIndex;var cellId=rowIndex+"-"+c.cellIndex;var rowSpan=c.rowSpan||1;var colSpan=c.colSpan||1 | ||
4 | +var firstAvailCol;if(typeof(matrix[rowIndex])=="undefined"){matrix[rowIndex]=[];}for(var k=0;k<matrix[rowIndex].length+1;k++){if(typeof(matrix[rowIndex][k])=="undefined"){firstAvailCol=k;break;}}lookup[cellId]=firstAvailCol;for(var k=rowIndex;k<rowIndex+rowSpan;k++){if(typeof(matrix[k])=="undefined"){matrix[k]=[];}var matrixrow=matrix[k];for(var l=firstAvailCol;l<firstAvailCol+colSpan;l++){matrixrow[l]="x";}}}}return lookup;}function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){return(v.toLowerCase()=="desc")?1:0;}else{return(v==1)?1:0;}}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(table.config.parsers[c].type=="text")?((order==0)?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c)):((order==0)?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c));var e="e"+i;dynamicExp+="var "+e+" = "+s;dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";if(table.config.debug){benchmark("Evaling expression:"+dynamicExp,new Date());}eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function makeSortFunction(type,direction,index){var a="a["+index+"]",b="b["+index+"]";if(type=='text'&&direction=='asc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+a+" < "+b+") ? -1 : 1 )));";}else if(type=='text'&&direction=='desc'){return"("+a+" == "+b+" ? 0 : ("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : ("+b+" < "+a+") ? -1 : 1 )));";}else if(type=='numeric'&&direction=='asc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+a+" - "+b+"));";}else if(type=='numeric'&&direction=='desc'){return"("+a+" === null && "+b+" === null) ? 0 :("+a+" === null ? Number.POSITIVE_INFINITY : ("+b+" === null ? Number.NEGATIVE_INFINITY : "+b+" - "+a+"));";}};function makeSortText(i){return"((a["+i+"] < b["+i+"]) ? -1 : ((a["+i+"] > b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$.data(this,"tablesorter",config);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){var me=this;setTimeout(function(){me.config.parsers=buildParserCache(me,$headers);cache=buildCache(me);},1);}).bind("updateCell",function(e,cell){var config=this.config;var pos=[(cell.parentNode.rowIndex-1),cell.cellIndex];cache.normalized[pos[0]][pos[1]]=config.parsers[pos[1]].format(getElementText(config,cell),cell);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){return/^[-+]?\d*$/.test($.trim(s.replace(/[,.']/g,'')));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLocaleLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}var $tr,row=-1,odd;$("tr:visible",table.tBodies[0]).each(function(i){$tr=$(this);if(!$tr.hasClass(table.config.cssChildRow))row++;odd=(row%2==0);$tr.removeClass(table.config.widgetZebra.css[odd?0:1]).addClass(table.config.widgetZebra.css[odd?1:0])});if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery); | ||
0 | \ No newline at end of file | 5 | \ No newline at end of file |
frontend/web/js/main.js
1 | /** | 1 | /** |
2 | * Created by vitaliy on 23.11.15. | 2 | * Created by vitaliy on 23.11.15. |
3 | */ | 3 | */ |
4 | +function clearFixedMenuPAdding(item_id){ | ||
5 | + $(item_id).on('show.bs.modal', function(){ | ||
6 | + $('.another_menu').css({transition: 'none'}); | ||
7 | + $('.another_menu').css({paddingRight: '15px'}); | ||
8 | + | ||
9 | + }); | ||
10 | + | ||
11 | + $(item_id).on('hidden.bs.modal', function(){ | ||
12 | + | ||
13 | + $('.another_menu').css({paddingRight: '0px'}); | ||
14 | + | ||
15 | + }) | ||
16 | +} | ||
17 | + | ||
4 | $(document).ready(function(){ | 18 | $(document).ready(function(){ |
19 | + | ||
20 | + clearFixedMenuPAdding('#details_content_block'); | ||
21 | + | ||
5 | $('#accountsform-country').change(function(){ | 22 | $('#accountsform-country').change(function(){ |
6 | var region_id = $(this).val(); | 23 | var region_id = $(this).val(); |
7 | if(region_id){ | 24 | if(region_id){ |
@@ -35,4 +52,18 @@ $(document).ready(function(){ | @@ -35,4 +52,18 @@ $(document).ready(function(){ | ||
35 | 52 | ||
36 | }); | 53 | }); |
37 | 54 | ||
55 | + $('.tecdoc_id_info').click(function(e){ | ||
56 | + var tecdoc_id = $(this).data('id'); | ||
57 | + $.post( "/detail/get-details-for-item", {tecdoc_id:tecdoc_id},function( data ) { | ||
58 | + $('#details_content').empty(); | ||
59 | + $('#details_content').html(data); | ||
60 | + | ||
61 | + | ||
62 | + }); | ||
63 | + | ||
64 | + }); | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | ||
38 | }); | 69 | }); |
frontend/web/js/script.js
@@ -557,6 +557,12 @@ $('.currency').click(function(){ | @@ -557,6 +557,12 @@ $('.currency').click(function(){ | ||
557 | 557 | ||
558 | } | 558 | } |
559 | ); | 559 | ); |
560 | + $('.cross_currency').click(function(){ | ||
561 | + $('.cross_currency').removeClass('active_button_purple1'); | ||
562 | + $(this).addClass('active_button_purple1'); | ||
563 | + | ||
564 | +} | ||
565 | +); | ||
560 | $('.menu_block_center .menu_item').hover(function(){ | 566 | $('.menu_block_center .menu_item').hover(function(){ |
561 | $(this).find('p').addClass('pcolor')}, | 567 | $(this).find('p').addClass('pcolor')}, |
562 | function(){ | 568 | function(){ |