7 use yii\widgets\DetailView;
8 use yii\helpers\ArrayHelper;
11 /* @var $this yii\web\View */
12 /* @var $searchModel app\models\ItemsSearch */
13 /* @var $dataProvider yii\data\ActiveDataProvider */
15 $this->title = Yii::t('items', 'Items');
16 $this->params[ 'breadcrumbs' ][] = $this->title;
19 <div class="items-index">
21 <h1><?= Html::encode($this->title) ?></h1>
23 <script language="JavaScript">
24 function markToPrint(href)
26 url = href.attr("href");
27 var ids = $("input[name='selection[]']");
29 for ( var i = 0; i < ids.length; i++)
31 if (ids[ i ][ "checked" ] == true)
33 res += "&id[]=" + ids[ i ][ "value" ];
36 href.attr("href", url + res);
42 <?php // Кнопки на форме ?>
43 <?= Html::a(Yii::t('items', 'Create Items'),
45 [ 'class' => 'btn btn-success' ]) ?>
46 <?= Html::a(Yii::t('items', 'Print Items'),
47 Url::to([ 'print' ], 'http'),
48 [ 'class' => 'btn btn-warning',
51 <?= Html::a(Yii::t('items', 'Start checking'),
53 [ 'class' => 'btn btn-info',
57 <?= GridView::widget([
58 'dataProvider' => $dataProvider, // Источник данных
59 'filterModel' => $searchModel, // Модель поиска
60 'rowOptions' => function($model) // Функция окраски неинвентаризированных предметов/оборудования
62 if ($model->checked == false) // Критерий проверки планируется
64 return [ 'class' => 'danger' ]; // Отметка неинвентаризированной строки
66 if ($model->statusName == 'Списано')
68 return [ 'class' => 'info' ];
73 [ 'class' => 'yii\grid\SerialColumn' ],
76 [ 'attribute' => 'invent',
77 'value' => function ($data)
79 return showUrlUpdate($data->invent, $data);
85 [ 'attribute' => 'serial',
86 'value' => function ($data)
88 return showUrlUpdate($data->serial, $data);
94 [ 'attribute' => 'model',
95 'value' => function ($data)
97 return showUrlUpdate($data->model, $data);
102 /* // Идентификатор записи
103 [ 'attribute' => 'id',
104 'value' => function ($data)
106 return showUrlUpdate($data->id, $data);
112 [ 'attribute' => 'name',
113 'value' => function ($data)
115 return showUrlUpdate($data->name, $data);
120 // Название подразделения
121 [ 'attribute' =>'regionName',
122 'value' => function($data)
124 return showUrlUpdate($data->regionName . ' (' . $data->locationName . ')', $data);
130 [ 'attribute' => 'statusName',
131 'filter' => Html::activeDropDownList(
135 [ '' => Yii::t('app', 'All statuses') ],
136 ArrayHelper::map(Status::find()->orderBy('name')->all(), 'name', 'name')),
137 [ 'class' => 'form-control' ],
139 'value' => function ($data)
141 return showUrlUpdate($data->statusName, $data);
146 /* // Операционная система
147 [ 'attribute' => 'os',
148 'value' => function ($data)
150 return showUrlUpdate($data->os, $data->id);
156 [ 'attribute' => 'mac',
157 'value' => function ($data)
159 return showUrlUpdate($data->mac, $data);
165 [ 'attribute' => 'product',
166 'value' => function ($data)
168 return showUrlUpdate($data->product, $data);
174 [ 'attribute' => 'modelnumber',
175 'value' => function ($data)
177 return showUrlUpdate($data->modelnumber, $data);
183 [ 'attribute' => 'comment',
184 'value' => function ($data)
186 return showUrlUpdate($data->comment, $data);
191 // Чекбоксы для выбора предметов/оборудования для печати QR меток
192 [ 'class' => 'yii\grid\CheckboxColumn',
193 'checkboxOptions' => function($model, $key, $index, $column)
195 return [ 'value' => $model->id, ];
199 // Кнопки действий {view} {update} {delete} {print}
200 [ 'class' => 'yii\grid\ActionColumn',
201 'template' => '{delete} {print}',
203 'print' => function ($url, $model, $key)
205 return Html::a('<span class="glyphicon glyphicon-print"></span>',
206 Url::to([ 'print', 'id[]' => $model->id ], 'http'),
207 [ 'target' => '_blank',
208 'onclick' => 'markToPrint($(this));',
209 'title' => Yii::t('items', 'Print selected labels'),