Commit a1604eb28839cd631a95c4f73829d787385676d0
1 parent
0cc44709
-In order's view upgraded products grid
Showing
2 changed files
with
88 additions
and
6 deletions
Show diff stats
views/order/_form.php
views/order/view.php
1 | 1 | <?php |
2 | 2 | |
3 | 3 | use artweb\artbox\ecommerce\models\Order; |
4 | + use artweb\artbox\ecommerce\models\OrderProduct; | |
4 | 5 | use common\components\CreditHelper; |
5 | 6 | use kartik\grid\GridView; |
6 | 7 | use yii\data\ActiveDataProvider; |
7 | 8 | use yii\grid\SerialColumn; |
8 | 9 | use yii\helpers\Html; |
10 | + use yii\helpers\StringHelper; | |
9 | 11 | use yii\web\View; |
10 | 12 | use yii\widgets\DetailView; |
11 | 13 | use yii\widgets\ListView; |
... | ... | @@ -63,6 +65,11 @@ |
63 | 65 | $payment = $model->orderPayment->lang->title; |
64 | 66 | } |
65 | 67 | |
68 | + $js = <<< JS | |
69 | + $('[data-toggle="popover"]').popover(); | |
70 | +JS; | |
71 | + $this->registerJs($js, View::POS_READY); | |
72 | + | |
66 | 73 | ?> |
67 | 74 | <div class="order-view"> |
68 | 75 | |
... | ... | @@ -155,12 +162,91 @@ |
155 | 162 | [ |
156 | 163 | 'class' => SerialColumn::className(), |
157 | 164 | ], |
158 | - 'product_name', | |
159 | - 'name', | |
160 | 165 | 'sku', |
166 | + [ | |
167 | + 'attribute' => 'product_name', | |
168 | + 'content' => function (OrderProduct $model) { | |
169 | + if (!empty( $model->product_name )) { | |
170 | + | |
171 | + if (empty( $model->productVariant )) { | |
172 | + return ''; | |
173 | + } | |
174 | + | |
175 | + return Html::a( | |
176 | + StringHelper::truncate($model->product_name, 10, '...'), | |
177 | + '#', | |
178 | + [ | |
179 | + 'onclick' => 'event.preventDefault();', | |
180 | + 'data-toggle' => 'popover', | |
181 | + 'data-placement' => 'right', | |
182 | + 'data-html' => 'true', | |
183 | + 'data-content' => Html::img( | |
184 | + $model->productVariant->imageUrl, | |
185 | + [ | |
186 | + 'class' => 'img-rounded', | |
187 | + ] | |
188 | + ) . Html::tag('p', $model->product_name), | |
189 | + ] | |
190 | + ); | |
191 | + } else { | |
192 | + return ''; | |
193 | + } | |
194 | + }, | |
195 | + ], | |
196 | + [ | |
197 | + 'attribute' => 'productVariant.product.brand.lang.title', | |
198 | + 'label' => 'Брэнд', | |
199 | + ], | |
200 | + [ | |
201 | + 'attribute' => 'productVariant.lang.title', | |
202 | + 'label' => \Yii::t('app', 'Цвет'), | |
203 | + 'content' => function (OrderProduct $model) { | |
204 | + | |
205 | + if (empty( $model->productVariant )) { | |
206 | + return ''; | |
207 | + } | |
208 | + | |
209 | + if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
210 | + return ''; | |
211 | + } else { | |
212 | + return $model->productVariant->lang->title; | |
213 | + } | |
214 | + }, | |
215 | + ], | |
216 | + [ | |
217 | + 'attribute' => 'productVariant.size', | |
218 | + 'label' => 'Размер', | |
219 | + ], | |
161 | 220 | 'price', |
162 | 221 | 'count', |
163 | 222 | 'sum_cost', |
223 | + 'booking', | |
224 | + 'status', | |
225 | + 'return', | |
226 | + [ | |
227 | + 'content' => function (OrderProduct $model) { | |
228 | + | |
229 | + if (empty( $model->productVariant )) { | |
230 | + return '<i class="glyphicon glyphicon-remove"></i>'; | |
231 | + } | |
232 | + | |
233 | + $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
234 | + foreach ($model->productVariant->variantStocks as $stock) { | |
235 | + $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
236 | + } | |
237 | + return Html::a( | |
238 | + '<i class="glyphicon glyphicon-home"></i>', | |
239 | + '#', | |
240 | + [ | |
241 | + 'onclick' => 'event.preventDefault();', | |
242 | + 'data-toggle' => 'popover', | |
243 | + 'data-placement' => 'left', | |
244 | + 'data-html' => 'true', | |
245 | + 'data-content' => $content . '</tbody></table>', | |
246 | + ] | |
247 | + ); | |
248 | + }, | |
249 | + ], | |
164 | 250 | ], |
165 | 251 | ] |
166 | 252 | ); | ... | ... |