public function actionAemployee($type_id) { $dev = DeviceType::findOne(['id' => $type_id]); $title = $dev->title; // $query1 = (new Query())->select('workplace_id')->from('devices')->where(['type_id' => $type_id])->groupBy('workplace_id'); // $query = (new Query())->select('employees.branch_id, workplace_id, workplaces_title, snp, job_title, date')->from('wp_owners, employees, workplaces')->where(['workplace_id' => $query1])->andWhere('employees.id = wp_owners.employee_id')->andWhere('workplaces.id = workplace_id'); $dp = new ActiveDataProvider(['query' => $query]); return $this->render('a_employee', ['dp' => $dp, 'title' => $title, 'type_id' => $type_id]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DeviceType::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['title' => SORT_ASC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'comp' => $this->comp]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'synonyms', $this->synonyms]); return $dataProvider; }
public function getDeviceType() { return $this->hasOne(DeviceType::className(), ['id' => 'type_id']); }
if ($id_wp > 0) { $model->workplace_id = $id_wp; } ?> <?php echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', function ($model_wp) { $snp = ''; if ($model_wp->owner) { $snp = $model_wp->owner[0]['snp']; } return '"' . $model_wp->workplaces_title . '" ' . $snp; }), ['prompt' => 'Выберите рабочее место...']); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(DeviceType::find()->orderBy('title')->all(), 'id', 'title'), ['prompt' => 'Выберите тип устройства...']); ?> <?php echo $form->field($model, 'brand')->textInput(['maxlength' => true])->widget(AutoComplete::className(), ['clientOptions' => ['source' => $model::arrayBrands()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'model')->textInput(['maxlength' => true])->widget(AutoComplete::className(), ['clientOptions' => ['source' => $model::arrayModels()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'sn')->textInput(['maxlength' => true])->widget(AutoComplete::className(), ['clientOptions' => ['source' => $model::arraySns()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'imei1')->textInput(['maxlength' => true])->widget(AutoComplete::className(), ['clientOptions' => ['source' => $model::arrayImei1()], 'options' => ['class' => 'form-control']]); ?>
/** * Finds the DeviceType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DeviceType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DeviceType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo Html::a('Добавить устройство', ['create', 'param' => $query], ['class' => 'btn btn-success']); ?> <?php echo Html::a('Комплектующие автоматом', ['autocomp'], ['class' => 'btn btn-success', 'data' => ['confirm' => "Произвести автоматическую установку комплектуюдщих \r\n для одиноких системников?"]]); ?> <?php echo Html::a(Html::img('/admin/img/search.png', ['width' => '16px']) . 'Общий склад', ['index?' . $query . '&DevicesSearch%5Bworkplace_id%5D=1'], ['class' => 'btn btn-default']); ?> <?php echo Html::a(Html::img('/admin/img/cross.png', ['style' => 'height: 14px; margin: 0px 1px 3px 0px;']) . ' Сбросить фильтр', ['index?' . $query], ['class' => 'btn btn-default', 'style' => 'float:right;']); ?> </p> <?php $cols = ['id', ['attribute' => 'dt_title', 'filter' => ArrayHelper::map(DeviceType::find()->all(), 'title', 'title')], ['attribute' => 'dev_comp', 'value' => function ($model) { return $model->dev_comp ? 'Да' : 'Нет'; }, 'filter' => ['Нет', 'Да']], 'brand', 'model', 'sn', 'specification', 'imei1', ['attribute' => 'parent_device_id', 'value' => function ($model) { return Html::a($model->parent_device_id, ['devices/view', 'id' => $model->parent_device_id]); }, 'format' => 'raw'], 'device_note', ['class' => Column::className(), 'content' => function ($model) use($mode) { //if ($model->workplace) { //if($model->employee) $snp = $model->employee->snp; if ($model->workplace_id == 1 || $model->workplace_id == null) { return ''; } if ($mode != 'def') { return Html::img('/admin/img/man.png', ['style' => 'height:24px;', 'title' => $model->workplace_id . ' ' . $model->wp_title]); } else { if ($mode == 'def') { return Html::a(Html::img('/admin/img/man.png', ['style' => 'height:24px;']), ['workplaces/view', 'id' => $model->workplace_id], ['title' => $model->workplace_id . ' ' . $model->wp_title . "\n" . $model->snp]); }
} else { if ($t) { echo '</table></div></td></tr>'; $t = false; } $n++; if (in_array($model['id'], $parentsId)) { //если устройство в текущей строке относится к родительским то //указываем что эта строка управляет видимостью скрытой таблицы echo '<tr class = "accordion-toggle success" data-toggle="collapse" data-target=".rows' . $n . '">'; } else { echo '<tr>'; } foreach ($model as $key => $item) { if ($key == 'type_id') { echo '<td>' . DeviceType::findOne($item)->title . '</td>'; } else { echo '<td>' . $item . '</td>'; } } echo "</tr>"; $cn = $n; } $oldParent = $parent; } ?> </tbody> </table>