/** * Creates data provider instance with search query applied * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = AdminWorkplaces::find()->select(['branch_title' => 'branches.branch_title', 'id' => 'workplaces.id', 'status' => 'wp_owners.status', 'room_title' => 'rooms.room_title', 'workplaces_title' => 'workplaces.workplaces_title', 'voip_number' => 'voip_numbers.voip_number', 'snp' => 'employees.snp', 'cellnumber' => 'cell_numbers.cell_number', 'email' => 'emails.email_address', 'jobtitle' => 'employees.job_title'])->from('workplaces')->leftJoin('branches', 'branches.id = workplaces.branch_id')->leftJoin('rooms', 'rooms.id = workplaces.room_id')->leftJoin('wp_owners', 'wp_owners.workplace_id = workplaces.id')->leftJoin('devices', 'devices.workplace_id = workplaces.id')->leftJoin(['sub_devices' => 'devices'], 'sub_devices.parent_device_id = devices.id')->leftJoin('netints', 'netints.device_id = devices.id OR netints.device_id = sub_devices.id')->leftJoin('voip_numbers', 'voip_numbers.workplace_id = workplaces.id AND voip_numbers.status = 1')->leftJoin('employees', 'employees.id = wp_owners.employee_id')->leftJoin('cell_numbers', 'cell_numbers.employee_id = employees.id AND cell_numbers.status = 1')->leftJoin('emails', 'emails.employee_id = employees.id AND emails.status = 1')->where('workplaces.id <> 119'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]); $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(['workplaces.id' => $this->id, 'netints.ipaddr' => $this->ip, 'netints.mac' => $this->mac, 'voip_numbers.voip_number' => $this->voip_number])->andFilterWhere(['like', 'netints.domain_name', $this->domain_name]); return $dataProvider; }
<?php $form = ActiveForm::begin(['layout' => 'horizontal', 'action' => ['site/admin_workplace?tab=1'], 'method' => 'get']); ?> <?php echo $form->field($model, 'voip_number', ['horizontalCssClasses' => ['wrapper' => 'col-xs-9']])->widget(AutoComplete::className(), ['clientOptions' => ['source' => AdminWorkplaces::arrayVoips()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'mac', ['horizontalCssClasses' => ['wrapper' => 'col-xs-9']])->widget(AutoComplete::className(), ['clientOptions' => ['source' => AdminWorkplaces::arrayMacs()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'domain_name', ['horizontalCssClasses' => ['wrapper' => 'col-xs-9']])->widget(AutoComplete::className(), ['clientOptions' => ['source' => AdminWorkplaces::arrayDomains()], 'options' => ['class' => 'form-control']]); ?> <?php echo $form->field($model, 'ip', ['horizontalCssClasses' => ['wrapper' => 'col-xs-9']])->widget(AutoComplete::className(), ['clientOptions' => ['source' => AdminWorkplaces::arrayIps()], 'options' => ['class' => 'form-control']]); ?> <div style="float: right"> <?php echo Html::submitButton('Поиск', ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Сбрсить', ['site/admin_workplace'], ['class' => 'btn btn-default']); ?> </div> <?php ActiveForm::end();
} ?> </div> <?php } ?> </div> <?php if ($tab == 1) { ?> <div id = "list-devices" class="row"> <h3> Список устройств </h3> <?php $deviceProvider = AdminWorkplaces::devicesProvider($model->id); $s = 0; if ($deviceProvider) { echo GridView::widget(['dataProvider' => $deviceProvider, 'columns' => [['class' => \yii\grid\SerialColumn::className()], ['attribute' => 'device_type_title', 'header' => 'Тип', 'value' => function ($device) { if ($device['parent_devices_id']) { return '[' . $device['parent_devices_id'] . '] ' . $device['device_type_title']; } else { return $device['device_type_title']; } }], ['attribute' => 'devices_brand', 'header' => 'Бренд'], ['attribute' => 'devices_model', 'header' => 'Модель'], ['attribute' => 'devices_sn', 'header' => 'SN'], ['attribute' => 'devices_id', 'header' => 'ID'], ['attribute' => 'devices_specification', 'header' => 'Спецификация'], ['attribute' => 'devices_device_note', 'header' => 'Заметка']]]); } ?> </div> <?php } elseif ($tab == 2) { ?>