public function actionGetRoomRef($build_id) { $rooms = room::find()->where(['building_id' => $build_id])->orderBy('value ASC')->all(); foreach ($rooms as $room) { if ($room->active) { printf('<option value = %s>%s</option>', $room->id, $room->value); } else { printf('<option value = %s>%s (неактивен)</option>', $room->id, $room->value); } } }
?> <table class="table table-responsive"> <thead> <tr class = "active"> <td>Подразделение<?php echo Html::dropDownList('', $dep, ArrayHelper::map(department::find()->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'department_filter', 'prompt' => 'Выберите подразделение']); ?> </td> <td>Здание<?php echo Html::dropDownList('building_filter', $build, ArrayHelper::map(building::find()->where(['department_id' => $dep])->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'building_filter', 'prompt' => 'Выберите здание']); ?> </td> <td>Кабинет<?php echo Html::dropDownList('room_filter', $room, ArrayHelper::map(room::find()->where(['building_id' => $build])->asArray()->all(), 'id', 'value'), ['class' => 'form-control', 'id' => 'room_filter', 'prompt' => 'Выберите кабинет']); ?> </td> <td>Внешний номер<br> <input type = "text" class = "form-control" id ="long-number_filter"></input> </td> <td>Внутренний номер<br> <input type = "text" class = "form-control" id ="short-number_filter"></input> </td> <td>Управление<br> <button type="button" class="btn btn-default" id = "add_phone_button"> <span class="glyphicon glyphicon-plus"></span> </button> </td> </tr> </thead>
public function actionGetStat($dep_id) { //if ( $dep_id >= 0 || count($dep_id)) { if ($dep_id >= 0) { //echo 'asdasdasda'; $stat = []; $conditions = conditions::find()->all(); if ($dep_id === 'all') { $buildings = building::find()->select(['id'])->where(['active' => '1'])->all(); } else { $buildings = building::find()->select(['id'])->where(['department_id' => $dep_id, 'active' => '1'])->all(); } foreach ($buildings as $build) { $rooms = room::find()->select(['id'])->where(['building_id' => $build->id])->all(); foreach ($rooms as $room) { if (isset($room->id)) { $sets = sets::find()->select(['id'])->where(['room_id' => $room->id])->all(); foreach ($sets as $set) { if (isset($set->id)) { $devices = device::find()->select(['id', 'model_id', 'condition_id'])->where(['set_id' => $set->id, 'active' => '1'])->all(); foreach ($devices as $device) { if (isset($device->id)) { $model = model::findOne($device->model_id); if (isset($model->type_id)) { $type = deviceType::findOne($model->type_id); //echo '<br>' . $type -> value; if (isset($stat[$type->id])) { $stat[$type->id]['all']++; //$stat[ $type -> id ][ 'value' ] = $type -> value; foreach ($conditions as $condition) { //switch ( $device -> condition_id ){ if ($condition->id == $device->condition_id) { $stat[$type->id][$device->condition_id]++; } } } else { $stat[$type->id] = []; $stat[$type->id]['value'] = $type->value; $stat[$type->id]['all'] = 1; foreach ($conditions as $condition) { if ($condition->id == $device->condition_id) { $stat[$type->id][$device->condition_id] = 1; } else { $stat[$type->id][$condition->id] = 0; } } } } } } } } } } } //echo '<br>'; //print_r($stat); echo "<table class = 'table table-responsive'>\n\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Тип устройства</td>\n\t\t\t\t\t\t\t<td>Всего</td>"; $tmp = []; // id шники состояний foreach ($conditions as $condition) { $tmp[] = $condition->id; echo "<td>" . $condition->value . "</td>"; } echo "</tr></thead><tbody>"; foreach ($stat as $sta) { echo "<tr>\n\t\t\t\t\t\t\t<td>" . $sta['value'] . "</td>\n\t\t\t\t\t\t\t<td>" . $sta['all'] . "</td>"; foreach ($tmp as $tm) { echo "<td>" . $sta[$tm] . "</td>"; } echo "</tr>"; } echo "</table>"; } }
public function actionGetRooms($build) { $rooms = room::find()->where(['building_id' => $build])->orderBy('value ASC')->all(); foreach ($rooms as $room) { echo '<option value = ' . $room->id . '>' . $room->value . '</option>'; } }