index.php
4.18 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?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->registerJsFile('/app/modules/admin/assets/js/jquery-1.11.3.min.js');
$this->registerJsFile('/app/modules/admin/assets/js/site.js');
$this->title = 'Заказы';
$this->params['breadcrumbs'][] = $this->title;
?>
<h1>Заказы</h1>
<?php $form = ActiveForm::begin(['id' => 'label-form','method'=>'get','action'=>['/admin/orders/index']]); ?>
<?php
$arr = [];
foreach(Label::find()->orderBy('id')->all() as $item)
{
$arr[] = ['id'=>$item->id,'label'=>$item->label.'-'.$item->name];
}
echo $form->field($searchModel, 'labels')->inline(true)->checkboxList(ArrayHelper::map($arr, 'id', 'label'),['onClick'=>'$("#label-form").submit()']);
?>
<?php ActiveForm::end(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'id',
'format' => 'raw',
'options' => ['class' => 'btn btn-warning'],
'value' => function($model){
return Html::button($model->id, ['id'=>$model->id, 'class' => 'btn btn-warning']); '/admin/orders/show?id=47';
//return Html::a($model->id, ['/admin/orders/show', 'id'=>$model->id], ['class'=>'btn btn-warning'] );
// return Html::a($data->name, ['/admin/orders/show','id'=>$data->id]);
}
],
/*[
'attribute' =>'username',
'value'=>function($data){
if(!empty($data->user->username))return Html::a($data->user->username, ['/admin/users/show','id'=>$data->user->id]);
},
'format'=>'raw',
//'contentOptions'=>['style'=>'width: 160px;']
], */
[
'attribute' => 'date_time',
'value'=>'date_time',
],
[
'attribute' => 'name',
'value'=>'name',
'format'=>'raw',
],
[
'attribute' => 'phone',
'value'=>'phone',
//'contentOptions'=>['style'=>'max-width: 300px;']
],
[
'attribute' => 'total',
'value'=>'total',
//'contentOptions'=>['style'=>'max-width: 300px;']
],
[
'attribute' => 'label',
'value' => function ($model, $key, $index, $column) {
// var_dump($model); var_dump($key); exit;
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',
'value' => function ($model, $key, $index, $column) {
// var_dump($model); var_dump($key); exit;
return Html::activeDropDownList($model, 'pay',[0 => 'Нет',1=>'Да'],
[
// 'prompt' => 'Нет',
'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;']
],
],
]) ?>