Blame view

backend/views/orders/index.php 3.45 KB
8df8067a   Administrator   basket
1
2
3
4
5
6
7
  <?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;
8df8067a   Administrator   basket
8
9
10
11
12
13
14
15
  
  
  $this->title = 'Заказы';
  $this->params['breadcrumbs'][] = $this->title;
  ?>
  <h1>Заказы</h1>
  
  	<?php $form = ActiveForm::begin(['id' => 'label-form','method'=>'get','action'=>['/admin/orders/index']]); ?>
94984376   Administrator   add active menu
16
  
8df8067a   Administrator   basket
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
  
      <?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;']
  		],
  		[
94984376   Administrator   add active menu
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  			'filter'    => yii\helpers\ArrayHelper::map(Label::find()->orderBy('id')->asArray()->all(), 'id', 'label'),
  			'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},
  								});"
  						]
8df8067a   Administrator   basket
80
  
94984376   Administrator   add active menu
81
82
83
  					);
  				},
  			'format' => 'raw',
8df8067a   Administrator   basket
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
  		],
          [
              '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;']
          ],		
      ],
  ]) ?>