index.php 3.48 KB
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use kartik\date\DatePicker;
use \yii\widgets\Pjax;
use \yii\bootstrap\Modal;

/* @var $this yii\web\View */
/* @var $searchModel common\models\CartBillsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Заказы');
$this->params['breadcrumbs'][] = $this->title;

$safe_bill_img0 = '/storage/checkbox0.gif';
$safe_bill_img1 = '/storage/checkbox1.gif';

\backend\assets\CartAsset::register($this);
Pjax::begin(['id' => 'gridViewContent']);
?>

<div class="cart-bills-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            ['content' => function ($model) {
                $url = \yii\helpers\Url::to(['view', 'id' => $model->id]);
                return Html::a('<span class="glyphicon glyphicon-eye-open">  </span>', '#', [
                    'class' => 'cartModalViewButton',
                    'value' => $url,
                ]);
            },
            ],
            'id',
            'account_id',
            ['label' =>'Информация',
               'format' => 'raw',
                'value' =>function( $model ) use ($safe_bill_img0, $safe_bill_img1) {
                    $info  = '<b> Код 1С:</b>' . ' ' . $model->scode . '<br>';
                    $info .= '<b> Имя:</b>' . ' ' .$model->name . '<br>';
                    $info .= '<b> Тел.:</b>' . ' ' .$model->phone . '<br>';
                    $info .= '<b> Email:</b>' . ' ' .$model->email . '<br>';
                    $info .= '<b> Доставка:</b>' . ' ' .$model->delivery . '<br>';
                    $info .= '<b> Комментарий:</b>' . ' ' .$model->message . '<br>';
                    $info .= '<b> Страховка:</b>';
                    if ($model->safe_bill == '1') {
                        $info .= " <img src=$safe_bill_img1>";
                    }
                    else {
                        $info .= " <img src=$safe_bill_img0>";
                    }
                    return $info;
                },
            ],
            'sum',
            [
                'label' =>'Статус',
                'attribute' => 'status',
                'filter' => \yii\helpers\ArrayHelper::map( \common\models\DicStatuses::find()->where(['active' =>1])->all(), 'id','name' ),
            ],
            'manager_name',
            [
                'label' =>'Дата',
                'value' =>function ($data) {
                    return date('Y-m-d', $data->dt);
                },
                'attribute' => 'dt',
                'filter' => DatePicker::widget([
                    'model' =>$searchModel,
                    'language' =>'ru',
                    'size' =>'xs',
                    'separator' =>'по',
                    'attribute' => 'dt',
                    'type' => DatePicker::TYPE_RANGE,
                    'attribute2' => 'date_to',
                ]),
            ],

        ],
    ]); ?>

    <?php
    // сюда будем всавлять контент модального окна
    Modal::begin([
        //     'header'=>'<h4>Прайс</h4>',
        'id' => 'modal',
        'size' => 'modal-lg',
    ]);

    echo "<div class='modalContent'></div>";
    Modal::end();
    Pjax::end();
    ?>
</div>