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}
25 if (User::canPermission('updateRecord'))
28 $template .= ' {delete}';
30 array_push($columns, [ 'attribute' => 'invent',
31 'value' => function ($data)
33 return showUrlUpdate($data->invent, $data);
39 array_push($columns, [ 'attribute' => 'serial',
40 'value' => function ($data)
42 return showUrlUpdate($data->serial, $data);
48 array_push($columns, [ 'attribute' => 'modelName',
49 'value' => function ($data)
51 if ($data->name == '')
53 return showUrlUpdate($data->modelName, $data);
57 return showUrlUpdate($data->modelName . ' (' . $data->name . ')', $data);
63 /* // Идентификатор записи
64 array_push($columns, [ 'attribute' => 'id',
65 'value' => function ($data)
67 return showUrlUpdate($data->id, $data);
73 array_push($columns, [ 'attribute' => 'name',
74 'value' => function ($data)
76 return showUrlUpdate($data->name, $data);
81 // Название подразделения
82 array_push($columns, [ 'attribute' => 'regionName',
83 'value' => function ($data)
85 return showUrlUpdate($data->regionName . ' (' . $data->locationName . ')', $data);
91 array_push($columns, [ 'attribute' => 'statusName',
92 'filter' => Html::activeDropDownList(
96 [ '' => Yii::t('app', 'All statuses'), ],
97 ArrayHelper::map(Status::find()->orderBy('name')->all(), 'name', 'name')
99 [ 'class' => 'form-control', ],
101 'value' => function ($data)
103 return showUrlUpdate($data->statusName, $data);
108 /* // Операционная система
109 array_push($columns, [ 'attribute' => 'os',
110 'value' => function ($data)
112 return showUrlUpdate($data->os, $data);
118 array_push($columns, [ 'attribute' => 'mac',
119 'value' => function ($data)
121 return showUrlUpdate($data->mac, $data);
127 array_push($columns, [ 'attribute' => 'comment',
128 'value' => function ($data)
130 return showUrlUpdate($data->comment, $data);
139 array_push($columns, 'invent');
140 array_push($columns, 'serial');
141 array_push($columns, 'modelName');
142 //array_push($columns, 'id');
143 //array_push($columns, 'name');
144 array_push($columns, [ 'attribute' => 'regionName',
145 'value' => function($data)
147 return $data->regionName . ' (' . $data->locationName . ')';
150 array_push($columns, [ 'attribute' => 'statusName',
151 'filter' => Html::activeDropDownList(
155 [ '' => Yii::t('app', 'All statuses') ],
156 ArrayHelper::map(Status::find()->orderBy('name')->all(), 'name', 'name')),
157 [ 'class' => 'form-control' ],
159 'value' => 'statusName',
161 //array_push($columns, 'os');
162 //array_push($columns, 'mac');
163 //array_push($columns, 'product');
164 //array_push($columns, 'modelnumber');
165 //array_push($columns, 'comment');
168 if (User::canPermission('takingInventory'))
171 $template .= ' {print}';
173 'print' => function ($url, $model, $key)
175 return Html::a('<span class="glyphicon glyphicon-print"></span>',
176 Url::to([ 'print', 'id[]' => $model->id ], 'http'),
177 [ 'target' => '_blank',
178 'onclick' => 'markToPrint($(this));',
179 'title' => Yii::t('items', 'Print selected labels'),
183 // Чекбоксы для выбора предметов/оборудования для печати QR меток
185 [ 'class' => 'yii\grid\CheckboxColumn',
186 'checkboxOptions' => function($model, $key, $index, $column)
188 return [ 'value' => $model->id, ];
194 array_push($columns, [
195 'class' => 'yii\grid\ActionColumn',
196 'template' => $template,
197 'buttons' => $buttons,
200 <div class="items-index">
202 <h1><?= Html::encode($this->title) ?></h1>
204 <script language="JavaScript">
205 function markToPrint(href)
207 url = href.attr("href");
208 var ids = $("input[name='selection[]']");
210 for ( var i = 0; i < ids.length; i++)
212 if (ids[ i ][ "checked" ] == true)
214 res += "&id[]=" + ids[ i ][ "value" ];
217 href.attr("href", url + res);
223 <?php // Кнопки на форме
224 if (User::canPermission('createRecord'))
227 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Create Items'),
229 [ 'class' => 'btn btn-success' ]) ?></div>
232 if (User::canPermission('updateRecord'))
235 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Import'),
237 [ 'class' => 'btn btn-success',
238 'style' => 'width: 100%;',
240 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Print Items'),
241 Url::to([ 'print' ], 'http'),
242 [ 'class' => 'btn btn-warning',
243 'style' => 'width: 100%;',
244 'target' => '_blank',
248 if (User::canPermission('takingInventory'))
251 <div class="col-md-2"><?= Html::a(Yii::t('items', 'Start checking'),
252 [ 'start_checking' ],
253 [ 'class' => 'btn btn-info',
260 <?= GridView::widget([
261 'id' => 'ItemsTable',
262 'dataProvider' => $dataProvider, // Источник данных
263 'filterModel' => $searchModel, // Модель поиска
264 'rowOptions' => function($model) // Функция окраски неинвентаризированных предметов/оборудования
266 if ($model->checked == false) // Критерий проверки планируется
268 return [ 'class' => 'danger' ]; // Отметка неинвентаризированной строки
270 if ($model->statusName == 'Списано')
272 return [ 'class' => 'info' ];
275 'columns' => $columns,