Commit 894d945a1b996af2ccb02a1ee459843c7b058fa6
1 parent
4c64240a
-Logs bu fix and Slava's task
Showing
7 changed files
with
331 additions
and
71 deletions
Show diff stats
components/OrderProductLogger.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | namespace artweb\artbox\ecommerce\components; | 2 | namespace artweb\artbox\ecommerce\components; |
| 3 | 3 | ||
| 4 | use artweb\artbox\ecommerce\models\OrderProductLog; | 4 | use artweb\artbox\ecommerce\models\OrderProductLog; |
| 5 | + use common\models\User; | ||
| 5 | use yii\base\Object; | 6 | use yii\base\Object; |
| 6 | use yii\helpers\Json; | 7 | use yii\helpers\Json; |
| 7 | 8 | ||
| @@ -40,9 +41,14 @@ | @@ -40,9 +41,14 @@ | ||
| 40 | $log = new OrderProductLog(); | 41 | $log = new OrderProductLog(); |
| 41 | $log->order_product_id = (integer) $identityId; | 42 | $log->order_product_id = (integer) $identityId; |
| 42 | $log->order_id = $params['order_id']; | 43 | $log->order_id = $params['order_id']; |
| 43 | - $log->user_id = (integer) \Yii::$app->user->identity->id; | ||
| 44 | $log->data = Json::encode($data); | 44 | $log->data = Json::encode($data); |
| 45 | 45 | ||
| 46 | + if (\Yii::$app->user instanceof User) { | ||
| 47 | + $log->user_id = (integer) \Yii::$app->user->identity->id; | ||
| 48 | + } else { | ||
| 49 | + $log->user_id = NULL; | ||
| 50 | + } | ||
| 51 | + | ||
| 46 | $log->save(); | 52 | $log->save(); |
| 47 | } | 53 | } |
| 48 | } | 54 | } |
controllers/StatisticsController.php
| @@ -8,7 +8,6 @@ | @@ -8,7 +8,6 @@ | ||
| 8 | use yii\data\ActiveDataProvider; | 8 | use yii\data\ActiveDataProvider; |
| 9 | use yii\helpers\ArrayHelper; | 9 | use yii\helpers\ArrayHelper; |
| 10 | use yii\helpers\Html; | 10 | use yii\helpers\Html; |
| 11 | - use yii\helpers\VarDumper; | ||
| 12 | use yii\web\Controller; | 11 | use yii\web\Controller; |
| 13 | use yii\web\Response; | 12 | use yii\web\Response; |
| 14 | 13 | ||
| @@ -185,6 +184,56 @@ | @@ -185,6 +184,56 @@ | ||
| 185 | ); | 184 | ); |
| 186 | } | 185 | } |
| 187 | 186 | ||
| 187 | + public function actionView($id = NULL, $manager = NULL, $date = NULL) | ||
| 188 | + { | ||
| 189 | + /** | ||
| 190 | + * Get a dates range | ||
| 191 | + */ | ||
| 192 | + if (!empty($date)) { | ||
| 193 | + $arr = []; | ||
| 194 | + preg_match('@(.*)\s:\s(.*)@', $date, $arr); | ||
| 195 | + $dateFilter = [ | ||
| 196 | + 'between', | ||
| 197 | + 'created_at', | ||
| 198 | + strtotime($arr[ 1 ]), | ||
| 199 | + strtotime($arr[ 2 ]), | ||
| 200 | + ]; | ||
| 201 | + } else { | ||
| 202 | + $dateFilter = []; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + if (!empty($id)) { | ||
| 206 | + $labelFilter = [ 'label' => $id ]; | ||
| 207 | + } else { | ||
| 208 | + $labelFilter = []; | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + if (!empty($manager)) { | ||
| 212 | + $managerFilter = [ 'manager_id' => $manager ]; | ||
| 213 | + } else { | ||
| 214 | + $managerFilter = []; | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + $dataProvider = new ActiveDataProvider( | ||
| 218 | + [ | ||
| 219 | + 'query' => Order::find() | ||
| 220 | + ->filterWhere($labelFilter) | ||
| 221 | + ->andFilterWhere($dateFilter) | ||
| 222 | + ->andFilterWhere($managerFilter), | ||
| 223 | + ] | ||
| 224 | + ); | ||
| 225 | + | ||
| 226 | + $label = Label::find()->with('lang')->where(['id' => $id])->one(); | ||
| 227 | + | ||
| 228 | + return $this->render( | ||
| 229 | + 'view', | ||
| 230 | + [ | ||
| 231 | + 'dataProvider' => $dataProvider, | ||
| 232 | + 'label' => $label, | ||
| 233 | + ] | ||
| 234 | + ); | ||
| 235 | + } | ||
| 236 | + | ||
| 188 | public function actionExport($date_range = NULL, $label = NULL, $manager = NULL) | 237 | public function actionExport($date_range = NULL, $label = NULL, $manager = NULL) |
| 189 | { | 238 | { |
| 190 | \Yii::$app->response->format = Response::FORMAT_JSON; | 239 | \Yii::$app->response->format = Response::FORMAT_JSON; |
| @@ -246,7 +295,7 @@ | @@ -246,7 +295,7 @@ | ||
| 246 | $i = 0; | 295 | $i = 0; |
| 247 | $products = ''; | 296 | $products = ''; |
| 248 | foreach ($order->products as $product) { | 297 | foreach ($order->products as $product) { |
| 249 | - $i ++; | 298 | + $i++; |
| 250 | $products .= $product->sku; | 299 | $products .= $product->sku; |
| 251 | if (count($order->products) != $i) { | 300 | if (count($order->products) != $i) { |
| 252 | $products .= ' ,'; | 301 | $products .= ' ,'; |
| @@ -267,12 +316,19 @@ | @@ -267,12 +316,19 @@ | ||
| 267 | 316 | ||
| 268 | return [ | 317 | return [ |
| 269 | 'message' => 'Файл успешно сгенерирован', | 318 | 'message' => 'Файл успешно сгенерирован', |
| 270 | - 'button' => Html::a( | ||
| 271 | - Html::tag('i', '', [ | ||
| 272 | - 'class' => 'glyphicon glyphicon-download-alt' | ||
| 273 | - ]) . ' Скачать', '/storage/statistics_export.csv', [ | ||
| 274 | - 'class' => 'btn bg-olive', | ||
| 275 | - ]) | 319 | + 'button' => Html::a( |
| 320 | + Html::tag( | ||
| 321 | + 'i', | ||
| 322 | + '', | ||
| 323 | + [ | ||
| 324 | + 'class' => 'glyphicon glyphicon-download-alt', | ||
| 325 | + ] | ||
| 326 | + ) . ' Скачать', | ||
| 327 | + '/storage/statistics_export.csv', | ||
| 328 | + [ | ||
| 329 | + 'class' => 'btn bg-olive', | ||
| 330 | + ] | ||
| 331 | + ), | ||
| 276 | ]; | 332 | ]; |
| 277 | } | 333 | } |
| 278 | } | 334 | } |
models/Label.php
| @@ -69,6 +69,7 @@ | @@ -69,6 +69,7 @@ | ||
| 69 | { | 69 | { |
| 70 | $query = ( new Query() )->select( | 70 | $query = ( new Query() )->select( |
| 71 | [ | 71 | [ |
| 72 | + 'label', | ||
| 72 | 'sum' => 'SUM(total)', | 73 | 'sum' => 'SUM(total)', |
| 73 | 'count' => 'COUNT(*)', | 74 | 'count' => 'COUNT(*)', |
| 74 | 'unique' => ( new Query() )->select('COUNT(*)') | 75 | 'unique' => ( new Query() )->select('COUNT(*)') |
| @@ -96,6 +97,7 @@ | @@ -96,6 +97,7 @@ | ||
| 96 | ] | 97 | ] |
| 97 | ) | 98 | ) |
| 98 | ->from('order') | 99 | ->from('order') |
| 100 | + ->groupBy('label') | ||
| 99 | ->where([ 'label' => $this->id ]) | 101 | ->where([ 'label' => $this->id ]) |
| 100 | ->andFilterWhere( | 102 | ->andFilterWhere( |
| 101 | $date | 103 | $date |
models/OrderProduct.php
| @@ -37,8 +37,8 @@ | @@ -37,8 +37,8 @@ | ||
| 37 | 37 | ||
| 38 | public function afterSave($insert, $changedAttributes) | 38 | public function afterSave($insert, $changedAttributes) |
| 39 | { | 39 | { |
| 40 | -// $data = OrderProductLogger::generateData($changedAttributes, $this->oldAttributes, $insert); | ||
| 41 | -// OrderProductLogger::saveData($data, $this->id, [ 'order_id' => $this->order_id ]); | 40 | + $data = OrderProductLogger::generateData($changedAttributes, $this->oldAttributes, $insert); |
| 41 | + OrderProductLogger::saveData($data, $this->id, [ 'order_id' => $this->order_id ]); | ||
| 42 | 42 | ||
| 43 | parent::afterSave($insert, $changedAttributes); | 43 | parent::afterSave($insert, $changedAttributes); |
| 44 | } | 44 | } |
views/order/log.php
| @@ -70,26 +70,26 @@ | @@ -70,26 +70,26 @@ | ||
| 70 | </div><!-- /.box --> | 70 | </div><!-- /.box --> |
| 71 | 71 | ||
| 72 | <?php | 72 | <?php |
| 73 | -// echo ListView::widget( | ||
| 74 | -// [ | ||
| 75 | -// 'dataProvider' => $productLogData, | ||
| 76 | -// 'layout' => '{items}', | ||
| 77 | -// 'itemView' => '_log_product_item', | ||
| 78 | -// 'itemOptions' => [ | ||
| 79 | -// 'tag' => false, | ||
| 80 | -// ], | ||
| 81 | -// 'viewParams' => [ | ||
| 82 | -// 'order' => $model, | ||
| 83 | -// ], | ||
| 84 | -// 'options' => [ | ||
| 85 | -// 'class' => 'list-view', | ||
| 86 | -// ], | ||
| 87 | -// 'emptyText' => 'У этого заказа нет товаров', | ||
| 88 | -// 'emptyTextOptions' => [ | ||
| 89 | -// 'class' => 'callout callout-info', | ||
| 90 | -// ], | ||
| 91 | -// ] | ||
| 92 | -// ); | 73 | + echo ListView::widget( |
| 74 | + [ | ||
| 75 | + 'dataProvider' => $productLogData, | ||
| 76 | + 'layout' => '{items}', | ||
| 77 | + 'itemView' => '_log_product_item', | ||
| 78 | + 'itemOptions' => [ | ||
| 79 | + 'tag' => false, | ||
| 80 | + ], | ||
| 81 | + 'viewParams' => [ | ||
| 82 | + 'order' => $model, | ||
| 83 | + ], | ||
| 84 | + 'options' => [ | ||
| 85 | + 'class' => 'list-view', | ||
| 86 | + ], | ||
| 87 | + 'emptyText' => 'У этого заказа нет товаров', | ||
| 88 | + 'emptyTextOptions' => [ | ||
| 89 | + 'class' => 'callout callout-info', | ||
| 90 | + ], | ||
| 91 | + ] | ||
| 92 | + ); | ||
| 93 | ?> | 93 | ?> |
| 94 | 94 | ||
| 95 | </div> | 95 | </div> |
views/statistics/index.php
| @@ -30,11 +30,18 @@ | @@ -30,11 +30,18 @@ | ||
| 30 | * @var int | boolean $dataLabel | 30 | * @var int | boolean $dataLabel |
| 31 | * @var int | boolean $dataManager | 31 | * @var int | boolean $dataManager |
| 32 | */ | 32 | */ |
| 33 | - | ||
| 34 | - $this->registerJsFile('/admin/js/statistics.js', [ | ||
| 35 | - 'position' => View::POS_END, | ||
| 36 | - 'depends' => 'yii\web\JqueryAsset' | ||
| 37 | - ]); | 33 | + |
| 34 | + $this->registerJsFile( | ||
| 35 | + '/admin/js/statistics.js', | ||
| 36 | + [ | ||
| 37 | + 'position' => View::POS_END, | ||
| 38 | + 'depends' => 'yii\web\JqueryAsset', | ||
| 39 | + ] | ||
| 40 | + ); | ||
| 41 | + | ||
| 42 | + $this->title = 'Статистика заказов'; | ||
| 43 | + | ||
| 44 | + $this->params['breadcrumbs'][] = $this->title; | ||
| 38 | 45 | ||
| 39 | ?> | 46 | ?> |
| 40 | 47 | ||
| @@ -141,30 +148,49 @@ | @@ -141,30 +148,49 @@ | ||
| 141 | <td><b>Уникальных товаров, шт.</b></td> | 148 | <td><b>Уникальных товаров, шт.</b></td> |
| 142 | </tr> | 149 | </tr> |
| 143 | <?php | 150 | <?php |
| 144 | - $total_count = 0; | ||
| 145 | - $total_sum = 0; | ||
| 146 | - $total_products = 0; | ||
| 147 | - $total_unique = 0; | 151 | + $total_count = 0; |
| 152 | + $total_sum = 0; | ||
| 153 | + $total_products = 0; | ||
| 154 | + $total_unique = 0; | ||
| 148 | foreach ($labelStatistics as $name => $statistic) { | 155 | foreach ($labelStatistics as $name => $statistic) { |
| 156 | + if ($statistic) { | ||
| 157 | + $link = Html::a( | ||
| 158 | + $name, | ||
| 159 | + [ | ||
| 160 | + 'view', | ||
| 161 | + 'id' => $statistic[ 'label' ], | ||
| 162 | + 'manager' => $dataManager, | ||
| 163 | + 'date' => $dateValue, | ||
| 164 | + ], | ||
| 165 | + [ | ||
| 166 | + 'target' => '_blank', | ||
| 167 | + ] | ||
| 168 | + ); | ||
| 169 | + } else { | ||
| 170 | + $link = $name; | ||
| 171 | + } | ||
| 149 | $total_count += $statistic[ 'count' ]; | 172 | $total_count += $statistic[ 'count' ]; |
| 150 | $total_sum += $statistic[ 'sum' ]; | 173 | $total_sum += $statistic[ 'sum' ]; |
| 151 | $total_products += $statistic[ 'products' ]; | 174 | $total_products += $statistic[ 'products' ]; |
| 152 | $total_unique += $statistic[ 'unique' ]; | 175 | $total_unique += $statistic[ 'unique' ]; |
| 153 | echo Html::tag( | 176 | echo Html::tag( |
| 154 | 'tr', | 177 | 'tr', |
| 155 | - Html::tag('td', $name) . Html::tag('td', $statistic[ 'count' ]) . Html::tag( | 178 | + Html::tag( |
| 179 | + 'td', | ||
| 180 | + $link | ||
| 181 | + ) . Html::tag('td', $statistic[ 'count' ]) . Html::tag( | ||
| 156 | 'td', | 182 | 'td', |
| 157 | $statistic[ 'sum' ] | 183 | $statistic[ 'sum' ] |
| 158 | ) . Html::tag('td', $statistic[ 'products' ]) . Html::tag('td', $statistic[ 'unique' ]) | 184 | ) . Html::tag('td', $statistic[ 'products' ]) . Html::tag('td', $statistic[ 'unique' ]) |
| 159 | ); | 185 | ); |
| 160 | } | 186 | } |
| 161 | - ?> | 187 | + ?> |
| 162 | <tr> | 188 | <tr> |
| 163 | <td><b>Всего</b></td> | 189 | <td><b>Всего</b></td> |
| 164 | - <td><b><?=$total_count?></b></td> | ||
| 165 | - <td><b><?=$total_sum?></b></td> | ||
| 166 | - <td><b><?=$total_products?></b></td> | ||
| 167 | - <td><b><?=$total_unique?></b></td> | 190 | + <td><b><?= $total_count ?></b></td> |
| 191 | + <td><b><?= $total_sum ?></b></td> | ||
| 192 | + <td><b><?= $total_products ?></b></td> | ||
| 193 | + <td><b><?= $total_unique ?></b></td> | ||
| 168 | </tr> | 194 | </tr> |
| 169 | </table> | 195 | </table> |
| 170 | </div><!-- /.box-body --> | 196 | </div><!-- /.box-body --> |
| @@ -362,25 +388,34 @@ | @@ -362,25 +388,34 @@ | ||
| 362 | </div><!-- /.box --> | 388 | </div><!-- /.box --> |
| 363 | 389 | ||
| 364 | <p> | 390 | <p> |
| 365 | -<?php | ||
| 366 | - echo Html::button(Html::tag('i', '', [ | ||
| 367 | - 'class' => 'glyphicon glyphicon-cog', | ||
| 368 | - ]) . ' Создать выгрузку', [ | ||
| 369 | - 'class' => 'btn bg-navy', | ||
| 370 | - 'id' => 'generate-button', | ||
| 371 | - 'data-link' => Url::to([ | ||
| 372 | - 'export', | ||
| 373 | - 'date_range' => $dateValue, | ||
| 374 | - 'label' => $dataLabel, | ||
| 375 | - 'manager' => $dataManager, | ||
| 376 | - ]) | ||
| 377 | - ]) | ||
| 378 | -?> | 391 | + <?php |
| 392 | + echo Html::button( | ||
| 393 | + Html::tag( | ||
| 394 | + 'i', | ||
| 395 | + '', | ||
| 396 | + [ | ||
| 397 | + 'class' => 'glyphicon glyphicon-cog', | ||
| 398 | + ] | ||
| 399 | + ) . ' Создать выгрузку', | ||
| 400 | + [ | ||
| 401 | + 'class' => 'btn bg-navy', | ||
| 402 | + 'id' => 'generate-button', | ||
| 403 | + 'data-link' => Url::to( | ||
| 404 | + [ | ||
| 405 | + 'export', | ||
| 406 | + 'date_range' => $dateValue, | ||
| 407 | + 'label' => $dataLabel, | ||
| 408 | + 'manager' => $dataManager, | ||
| 409 | + ] | ||
| 410 | + ), | ||
| 411 | + ] | ||
| 412 | + ) | ||
| 413 | + ?> | ||
| 379 | </p> | 414 | </p> |
| 380 | <div class="box box-default"> | 415 | <div class="box box-default"> |
| 381 | <div class="box-header with-border"> | 416 | <div class="box-header with-border"> |
| 382 | <h3 class="box-title">Заказы</h3> | 417 | <h3 class="box-title">Заказы</h3> |
| 383 | - | 418 | + |
| 384 | <div class="box-tools pull-right"> | 419 | <div class="box-tools pull-right"> |
| 385 | <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button> | 420 | <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button> |
| 386 | </div><!-- /.box-tools --> | 421 | </div><!-- /.box-tools --> |
| @@ -392,11 +427,12 @@ | @@ -392,11 +427,12 @@ | ||
| 392 | 'columns' => [ | 427 | 'columns' => [ |
| 393 | 'id', | 428 | 'id', |
| 394 | [ | 429 | [ |
| 395 | - 'label' => 'Дата добавления', | ||
| 396 | - 'content' => function(Order $model) { | ||
| 397 | - return \Yii::$app->formatter->asDate($model->created_at) . | ||
| 398 | - '<br>' . \Yii::$app->formatter->asTime($model->created_at); | ||
| 399 | - }, | 430 | + 'label' => 'Дата добавления', |
| 431 | + 'content' => function(Order $model) { | ||
| 432 | + return \Yii::$app->formatter->asDate( | ||
| 433 | + $model->created_at | ||
| 434 | + ) . '<br>' . \Yii::$app->formatter->asTime($model->created_at); | ||
| 435 | + }, | ||
| 400 | ], | 436 | ], |
| 401 | 'name', | 437 | 'name', |
| 402 | [ | 438 | [ |
| @@ -408,11 +444,11 @@ | @@ -408,11 +444,11 @@ | ||
| 408 | $content = ''; | 444 | $content = ''; |
| 409 | $i = 0; | 445 | $i = 0; |
| 410 | foreach ($model->products as $product) { | 446 | foreach ($model->products as $product) { |
| 411 | - if(empty($product->productVariant)){ | ||
| 412 | - $image = ''; | ||
| 413 | - } else { | ||
| 414 | - $image = $product->productVariant->imageUrl; | ||
| 415 | - } | 447 | + if (empty($product->productVariant)) { |
| 448 | + $image = ''; | ||
| 449 | + } else { | ||
| 450 | + $image = $product->productVariant->imageUrl; | ||
| 451 | + } | ||
| 416 | $i++; | 452 | $i++; |
| 417 | $content .= Html::a( | 453 | $content .= Html::a( |
| 418 | $product->sku, | 454 | $product->sku, |
| 1 | +<?php | ||
| 2 | + use artweb\artbox\ecommerce\models\Label; | ||
| 3 | + use artweb\artbox\ecommerce\models\Order; | ||
| 4 | + use kartik\grid\GridView; | ||
| 5 | + use yii\data\ActiveDataProvider; | ||
| 6 | + use yii\helpers\Html; | ||
| 7 | + use yii\helpers\StringHelper; | ||
| 8 | + use yii\web\View; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * @var ActiveDataProvider $dataProvider | ||
| 12 | + * @var View $this | ||
| 13 | + * @var Label $label | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + $this->title = 'Статистика по метке: ' . $label->lang->title; | ||
| 17 | + | ||
| 18 | + $this->params['breadcrumbs'][] = [ | ||
| 19 | + 'url' => ['index'], | ||
| 20 | + 'label' => 'Статистика заказов', | ||
| 21 | + ]; | ||
| 22 | + $this->params['breadcrumbs'][] = $this->title; | ||
| 23 | + | ||
| 24 | + $js = <<< JS | ||
| 25 | + $('[data-toggle="popover"]').popover(); | ||
| 26 | +JS; | ||
| 27 | +$this->registerJs($js, View::POS_READY); | ||
| 28 | + | ||
| 29 | +?> | ||
| 30 | + | ||
| 31 | +<div class="box box-default"> | ||
| 32 | + <div class="box-header with-border"> | ||
| 33 | + <h3 class="box-title"><?=$this->title?></h3> | ||
| 34 | + </div><!-- /.box-header --> | ||
| 35 | + <div class="box-body"> | ||
| 36 | + | ||
| 37 | + <?= GridView::widget( | ||
| 38 | + [ | ||
| 39 | + 'dataProvider' => $dataProvider, | ||
| 40 | + 'columns' => [ | ||
| 41 | + 'id', | ||
| 42 | + [ | ||
| 43 | + 'label' => 'Дата добавления', | ||
| 44 | + 'content' => function(Order $model) { | ||
| 45 | + return \Yii::$app->formatter->asDate( | ||
| 46 | + $model->created_at | ||
| 47 | + ) . '<br>' . \Yii::$app->formatter->asTime($model->created_at); | ||
| 48 | + }, | ||
| 49 | + ], | ||
| 50 | + 'name', | ||
| 51 | + [ | ||
| 52 | + 'label' => 'Товары', | ||
| 53 | + 'content' => function(Order $model) { | ||
| 54 | + if (empty($model->products)) { | ||
| 55 | + return ''; | ||
| 56 | + } else { | ||
| 57 | + $content = ''; | ||
| 58 | + $i = 0; | ||
| 59 | + foreach ($model->products as $product) { | ||
| 60 | + if (empty($product->productVariant)) { | ||
| 61 | + $image = ''; | ||
| 62 | + } else { | ||
| 63 | + $image = $product->productVariant->imageUrl; | ||
| 64 | + } | ||
| 65 | + $i++; | ||
| 66 | + $content .= Html::a( | ||
| 67 | + $product->sku, | ||
| 68 | + '#', | ||
| 69 | + [ | ||
| 70 | + 'onclick' => 'event.preventDefault();', | ||
| 71 | + 'data-toggle' => 'popover', | ||
| 72 | + 'data-placement' => 'right', | ||
| 73 | + 'data-html' => 'true', | ||
| 74 | + 'data-content' => Html::img( | ||
| 75 | + $image, | ||
| 76 | + [ | ||
| 77 | + 'class' => 'img-rounded', | ||
| 78 | + ] | ||
| 79 | + ) . Html::tag('p', $product->product_name), | ||
| 80 | + ] | ||
| 81 | + ); | ||
| 82 | + if ($i != count($model->products)) { | ||
| 83 | + $content .= ', '; | ||
| 84 | + } | ||
| 85 | + if ($i % 2 == 0) { | ||
| 86 | + $content .= '<br>'; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + return $content; | ||
| 90 | + } | ||
| 91 | + }, | ||
| 92 | + ], | ||
| 93 | + 'city', | ||
| 94 | + [ | ||
| 95 | + 'attribute' => 'orderLabel.label', | ||
| 96 | + 'label' => 'Метка', | ||
| 97 | + ], | ||
| 98 | + 'total', | ||
| 99 | + [ | ||
| 100 | + 'attribute' => 'reason', | ||
| 101 | + 'content' => function($model) { | ||
| 102 | + /** | ||
| 103 | + * @var Order $model | ||
| 104 | + */ | ||
| 105 | + if (empty($model->reason)) { | ||
| 106 | + return ''; | ||
| 107 | + } else { | ||
| 108 | + return Order::REASONS[ $model->reason ]; | ||
| 109 | + } | ||
| 110 | + }, | ||
| 111 | + ], | ||
| 112 | + [ | ||
| 113 | + 'attribute' => 'manager.username', | ||
| 114 | + 'label' => 'Менеджер', | ||
| 115 | + ], | ||
| 116 | + [ | ||
| 117 | + 'attribute' => 'body', | ||
| 118 | + 'content' => function($model) { | ||
| 119 | + /** | ||
| 120 | + * @var Order $model | ||
| 121 | + */ | ||
| 122 | + if (empty($model->body)) { | ||
| 123 | + return ''; | ||
| 124 | + } else { | ||
| 125 | + return Html::a( | ||
| 126 | + StringHelper::truncate($model->body, 10, '...'), | ||
| 127 | + '#', | ||
| 128 | + [ | ||
| 129 | + 'data-toggle' => 'tooltip', | ||
| 130 | + 'title' => $model->body, | ||
| 131 | + 'onclick' => 'event.preventDefault();', | ||
| 132 | + ] | ||
| 133 | + ); | ||
| 134 | + } | ||
| 135 | + }, | ||
| 136 | + ], | ||
| 137 | + [ | ||
| 138 | + 'content' => function($model) { | ||
| 139 | + /** | ||
| 140 | + * @var Order $model | ||
| 141 | + */ | ||
| 142 | + return Html::a( | ||
| 143 | + Html::tag('i', '', [ 'class' => 'glyphicon glyphicon-eye-open' ]), | ||
| 144 | + [ | ||
| 145 | + '/ecommerce/order/view', | ||
| 146 | + 'id' => $model->id, | ||
| 147 | + ], | ||
| 148 | + [ | ||
| 149 | + 'target' => '_blank', | ||
| 150 | + 'data-pjax' => '0', | ||
| 151 | + ] | ||
| 152 | + ); | ||
| 153 | + }, | ||
| 154 | + ], | ||
| 155 | + ], | ||
| 156 | + ] | ||
| 157 | + ) ?> | ||
| 158 | + | ||
| 159 | + </div> | ||
| 160 | +</div> |