Esempio n. 1
0
 public function actionAddModel($table, $action, $name, $type_id, $mark_id)
 {
     // проверка на существование марки такого типа устройств в базе
     $tmp = model::find()->where(['type_id' => $type_id, 'mark_id' => $mark_id, 'value' => $name])->one();
     if (!$tmp) {
         $model = new model();
         $model->type_id = $type_id;
         $model->mark_id = $mark_id;
         $model->value = $name;
         $model->save();
         echo 'Модель добавлена';
     } else {
         echo 'Ошибка добавления модели. Такая модель уже есть в базе';
     }
 }
Esempio n. 2
0
 public function getModel()
 {
     return $this->hasOne(model::className(), ['id' => 'model_id']);
 }
Esempio n. 3
0
 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>";
     }
 }
Esempio n. 4
0
 public function getModel()
 {
     return $this->hasMany(model::className(), ['mark_id' => 'id']);
 }
Esempio n. 5
0
 public function actionGetModels($type_id, $mark_id)
 {
     $models = model::find()->where(['active' => '1', 'type_id' => $type_id, 'mark_id' => $mark_id])->orderBy('value ASC')->all();
     foreach ($models as $mod) {
         echo '<option value = ' . $mod->id . '>' . $mod->value . '</option>';
     }
     //echo $type_id . $mark_id;
 }
Esempio n. 6
0
 public function actionGetDevicesJson($consignment_id = 0, $search_str = '')
 {
     $search_str = trim($search_str);
     $ggg = array();
     $cond_array = array();
     $ggg['devices'] = array();
     // справочник типов устройств
     $types = deviceType::find(['id', 'value'])->all();
     foreach ($types as $type) {
         $types_array[] = ['id' => $type['id'], 'value' => $type['value']];
     }
     $ggg['device_types'] = $types_array;
     // справочник состояний
     $conditions = conditions::find()->all();
     foreach ($conditions as $condition) {
         $cond_array[$condition['id']] = $condition['value'];
     }
     $ggg['conditions'] = $cond_array;
     // справочник партий
     $consignments = consignment::find()->all();
     $consignments_array = [];
     foreach ($consignments as $consignment) {
         $consignments_array[$consignment['id']] = $consignment['name'];
     }
     $ggg['consignments'] = $consignments_array;
     // устройства
     if ($consignment_id == 0) {
         $set_devices = device::find()->filterWhere(['like', 'inv_no', $search_str])->all();
     } else {
         $set_devices = device::findAll(['consignment_id' => $consignment_id]);
     }
     foreach ($set_devices as $device) {
         //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
         $dev_add_usr = user::findOne($device->add_username_id);
         if ($dev_add_usr) {
             $dev_add_usr_name = $dev_add_usr->name;
         } else {
             $dev_add_usr_name = '';
         }
         //print_r($dev_add_usr);
         $dev_model = model::findOne($device->model_id);
         //print_r($dev_model);
         $dev_type = deviceType::findOne($dev_model->type_id);
         $dev_mark = trademarks::findOne($dev_model->mark_id);
         // адрес устройства
         $dev_set_id = $device->set_id;
         $addr_set = sets::findOne($dev_set_id);
         $addr_room = room::findOne($addr_set->room_id);
         $addr_build = building::findOne($addr_room->building_id);
         $addr_dep = department::findOne($addr_build->department_id);
         $dev_addr_str = $addr_dep->value . ' -> ' . $addr_build->value . ' -> ' . $addr_room->value . ' -> ' . $addr_set->name;
         array_push($ggg['devices'], array("add_date" => $device->add_date, "add_user" => $dev_add_usr_name, "device_id" => $device->id, "device_model" => $dev_model->value, "device_type" => $dev_type->value, "device_trademark" => $dev_mark->value, "device_inv_no" => $device->inv_no, "device_ser_no" => $device->serial_no, "device_condition_id" => $device->condition_id, "device_consignment_id" => $device->consignment_id, "device_comment" => $device->comment, "device_address" => $dev_addr_str));
         // если тип устройства - системный блок.
         $sys_unit = sysUnitSpec::find(['device_id' => $device->id])->one();
         $set_have_sys_unit = 0;
         if ($dev_type->id == 3) {
             if ($set_have_sys_unit == 0) {
                 $ggg['sys_unit_spec'] = array();
                 $ggg['sys_unit_po'] = array();
             }
             $set_have_sys_unit = 1;
             array_push($ggg['sys_unit_spec'], array("device_id" => $device->id, "cpu_id" => $sys_unit->cpu_id, "ram" => $sys_unit->RAM, "hdd" => $sys_unit->HDD));
             $sys_unit_po = po::find(['device_id' => $device->id])->one();
             array_push($ggg['sys_unit_po'], array("device_id" => $device->id, "type_id" => $sys_unit_po->type_id, "name_id" => $sys_unit_po->name_id, "licensed" => $sys_unit_po->licensed));
         }
         if ($set_have_sys_unit) {
             // справочник процессоров
             $cpus = cpu::findAll(['active' => '1']);
             foreach ($cpus as $cpu) {
                 $cpu_ref_array[$cpu['id']] = $cpu['name'];
             }
             $ggg['cpu'] = $cpu_ref_array;
             // справочник операционок
             $po_os = po_name::findAll(['active' => '1', 'po_type_id' => '1']);
             foreach ($po_os as $po) {
                 $po_os_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_os'] = $po_os_ref_array;
             //  справочник офисных пакетов
             $po_office = po_name::findAll(['active' => '1', 'po_type_id' => '2']);
             foreach ($po_office as $po) {
                 $po_office_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_office'] = $po_office_ref_array;
             // справочник антивирусов
             $po_antivirus = po_name::findAll(['active' => '1', 'po_type_id' => '3']);
             foreach ($po_antivirus as $po) {
                 $po_antivirus_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_antivirus'] = $po_antivirus_ref_array;
             // справочник Специального ПО
             $po_special = po_name::findAll(['active' => '1', 'po_type_id' => '4']);
             foreach ($po_special as $po) {
                 $po_special_ref_array[$po['id']] = $po['po_name'];
             }
             $ggg['po_special'] = $po_special_ref_array;
         }
     }
     echo json_encode($ggg);
 }