index.php
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use backend\models\Label;
use yii\bootstrap\Modal;
$this->title = 'Заказы';
$this->params['breadcrumbs'][] = $this->title;
?>
<h1>Заказы</h1>
<?php \yii\widgets\Pjax::begin(   [
]); ?>
<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
		[
                'attribute' => 'id',
                'format' => 'raw',
                'options' => ['class' => 'btn btn-warning'],
                'value' => function($model){
                    return Html::button($model->id, ['id'=>$model->id, 'class' => 'btn btn-warning']);
                }
            ],
		[
		'attribute' => 'date_time',
		'value'=>'date_time',
		],
		[
		'attribute' => 'name',
		'value'=>'name',
                'format'=>'raw',
		],
		[
		'attribute' => 'phone',
		'value'=>'phone',
		],
		[
		'attribute' => 'total',
		'value'=>'total',
		],
		[
			'filter'    => yii\helpers\ArrayHelper::map(Label::find()->orderBy('id')->asArray()->all(), 'id', 'label'),
			'attribute' => 'label',
			'value' => function ($model, $key, $index, $column) {
					return Html::activeDropDownList($model, 'label',
						yii\helpers\ArrayHelper::map(Label::find()->orderBy('id')->asArray()->all(), 'id', 'label'),
						[
							'prompt' => 'Нет',
							'onchange' => "$.ajax({
								 url: \"/admin/orders/labelupdate\",
								 type: \"post\",
								 data: { order_id:  $model->id, label_id : this.value},
								});"
						]
					);
				},
			'format' => 'raw',
		],
        [
            'attribute' => 'pay',
			'filter'    => [
				0 => 'Нет',1=>'Да'
			],
			'value' => function ($model, $key, $index, $column) {
                return Html::activeDropDownList($model, 'pay',[0 => 'Нет',1=>'Да'],
                    [
                        'onchange' => "$.ajax({
                                     url: \"/admin/orders/payupdate\",
                                     type: \"post\",
                                     data: { order_id:  $model->id, pay_id : this.value},
                                    });"
                    ]
                );
            },
            'format' => 'raw',
        ],
		 [
		 'attribute' => 'status',
		 'value'=>'status',
		 'contentOptions'=>['style'=>'width: 5px;']
		 ],
        [
            'class'    => 'yii\grid\ActionColumn',
            'template' => '{delete}',
            'contentOptions'=>['style'=>'width: 70px;']
        ],		
    ],
]) ?>
<?php \yii\widgets\Pjax::end(); ?>