7 use yii\widgets\DetailView;
8 use yii\helpers\ArrayHelper;
12 /* @var $this yii\web\View */
13 /* @var $searchModel app\models\ItemsSearch */
14 /* @var $dataProvider yii\data\ActiveDataProvider */
16 $this->title = Yii::t('items', 'Items');
17 $this->params[ 'breadcrumbs' ][] = $this->title;
19 // Формирование колонок и кнопок
21 $columns = [[ 'class' => 'yii\grid\SerialColumn' ]];
22 // Кнопки действий {view} {update} {delete} {print}
26 $pageSize = Yii::$app->session['pageSize'] ?? 20;
28 if (User::canPermission('createRecord'))
30 $template .= ' {copy}';
31 $buttons [ 'copy' ] = function ($url, $model, $key)
33 return Html::a('<span class="glyphicon glyphicon-share"></span>',
34 Url::to([ 'addcopy', 'is' => $model->id ]), [ 'title' => Yii::t('items', 'Copy from curren item'), ]);
38 if (User::canPermission('updateRecord'))
41 $template .= ' {delete}';
43 array_push($columns, [ 'attribute' => 'invent',
44 'value' => function ($data)
46 return showUrlUpdate($data->invent, $data);
52 array_push($columns, [ 'attribute' => 'serial',
53 'value' => function ($data)
55 return showUrlUpdate($data->serial, $data);
61 array_push($columns, [ 'attribute' => 'modelName',
62 'value' => function ($data)
64 if ($data->name == '')
66 return showUrlUpdate($data->modelName, $data);
70 return showUrlUpdate($data->modelName . ' (' . $data->name . ')', $data);
76 /* // Идентификатор записи
77 array_push($columns, [ 'attribute' => 'id',
78 'value' => function ($data)
80 return showUrlUpdate($data->id, $data);
86 array_push($columns, [ 'attribute' => 'name',
87 'value' => function ($data)
89 return showUrlUpdate($data->name, $data);
94 // Название подразделения
95 array_push($columns, [ 'attribute' => 'regionName',
96 'value' => function ($data)
98 return showUrlUpdate($data->regionName . ' (' . $data->locationName . ')', $data);
104 array_push($columns, [ 'attribute' => 'statusName',
105 'filter' => Html::activeDropDownList(
109 [ '' => Yii::t('app', 'All statuses'), ],
110 ArrayHelper::map(Status::find()->orderBy('name')->all(), 'name', 'name')
112 [ 'class' => 'form-control', ],
114 'value' => function ($data)
116 return showUrlUpdate($data->statusName, $data);
121 /* // Операционная система
122 array_push($columns, [ 'attribute' => 'os',
123 'value' => function ($data)
125 return showUrlUpdate($data->os, $data);
131 array_push($columns, [ 'attribute' => 'mac',
132 'value' => function ($data)
134 return showUrlUpdate($data->mac, $data);
140 array_push($columns, [ 'attribute' => 'comment',
141 'value' => function ($data)
143 return showUrlUpdate($data->comment, $data);
152 array_push($columns, 'invent');
153 array_push($columns, 'serial');
154 array_push($columns, 'modelName');
155 //array_push($columns, 'id');
156 //array_push($columns, 'name');
157 array_push($columns, [ 'attribute' => 'regionName',
158 'value' => function($data)
160 return $data->regionName . ' (' . $data->locationName . ')';
163 array_push($columns, [ 'attribute' => 'statusName',
164 'filter' => Html::activeDropDownList(
168 [ '' => Yii::t('app', 'All statuses') ],
169 ArrayHelper::map(Status::find()->orderBy('name')->all(), 'name', 'name')),
170 [ 'class' => 'form-control' ],
172 'value' => 'statusName',
174 //array_push($columns, 'os');
175 //array_push($columns, 'mac');
176 //array_push($columns, 'product');
177 //array_push($columns, 'modelnumber');
178 //array_push($columns, 'comment');
181 if (User::canPermission('takingInventory'))
184 $template .= ' {print}';
185 $buttons[ 'print' ] = function ($url, $model, $key)
187 return Html::a('<span class="glyphicon glyphicon-print"></span>',
188 Url::to([ 'print', 'id[]' => $model->id ], 'http'),
189 [ 'target' => '_blank',
190 'onclick' => 'markToPrint($(this));',
192 'title' => Yii::t('items', 'Print selected labels'),
195 // Чекбоксы для выбора предметов/оборудования для печати QR меток
197 [ 'class' => 'yii\grid\CheckboxColumn',
198 'checkboxOptions' => function($model, $key, $index, $column)
200 return [ 'value' => $model->id, ];
206 array_push($columns, [
207 'class' => 'yii\grid\ActionColumn',
208 'template' => $template,
209 'buttons' => $buttons,
210 'header' => Html::dropDownList(
211 'pageSize', $pageSize, [
217 [ 'onChange' => '$.pjax.reload({container: "#ItemsTable", url: $(location).attr("href") + "&pageSize=" + $(this).val()});',
218 'title' => Yii::t('app', 'Lines per page'),
224 <div class="items-index">
226 <h1><?= Html::encode($this->title) ?></h1>
228 <script language="JavaScript">
229 function markToPrint(href)
231 url = href.attr("href");
232 var ids = $("input[name='selection[]']");
234 for ( var i = 0; i < ids.length; i++)
236 if (ids[ i ][ "checked" ] == 1)
238 res += "&id[]=" + ids[ i ][ "value" ];
241 href.attr("href", url + res);
247 <?php // Кнопки на форме
248 if (User::canPermission('createRecord'))
251 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Create Items'),
253 [ 'class' => 'btn btn-success' ]) ?></div>
256 if (User::canPermission('updateRecord'))
259 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Import'),
261 [ 'class' => 'btn btn-success',
262 'style' => 'width: 100%;',
264 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Print Items'),
265 Url::to([ 'print' ], 'http'),
266 [ 'class' => 'btn btn-warning',
267 'style' => 'width: 100%;',
268 'target' => '_blank',
272 if (User::canPermission('takingInventory'))
275 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Start checking'),
276 [ 'start_checking' ],
277 [ 'class' => 'btn btn-info',
284 <?php Pjax::begin(); ?>
285 <?= GridView::widget([
286 'id' => 'ItemsTable',
287 'dataProvider' => $dataProvider, // Источник данных
288 'filterModel' => $searchModel, // Модель поиска
289 'rowOptions' => function($model) // Функция окраски неинвентаризированных предметов/оборудования
291 if ($model->checked == 0) // Критерий проверки планируется
293 return [ 'class' => 'danger' ]; // Отметка неинвентаризированной строки
295 if ($model->checked == 2)
297 return [ 'class' => 'warning' ]; // Отметка непроверенной строки
299 if ($model->statusName == 'Списано')
301 return [ 'class' => 'info' ];
304 'columns' => $columns,
306 <?php Pjax::end(); ?>