Пример #1
0
 public function actionIndex()
 {
     $tickets = tickets::find()->all();
     $cartridge_types = cartridgeType::find()->orderBy('used DESC')->all();
     $departments = department::find()->where(['active' => 1])->orderBy('value ASC')->all();
     $carts = cartridgeHistory::find()->where(['add_date' => date('Y-m-d')])->orderBy('id DESC')->all();
     return $this->render('index', ['tickets' => $tickets, 'cartridge_types' => $cartridge_types, 'departments' => $departments, 'carts' => $carts]);
 }
Пример #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $std = student::where('regNo', '=', $id)->first();
     $dep = department::where('student_regNo', '=', $id)->first();
     $caf = cafeteria::where('student_regNo', '=', '78699')->first();
     $lib = library::where('student_regNo', '=', '78699')->first();
     $ext = extraactiv::where('student_regNo', '=', '78699')->first();
     $fa = fa::where('student_regNo', '=', '78699')->first();
     $fin = finance::where('student_regNo', '=', '78699')->first();
     $gam = games::where('student_regNo', '=', '78699')->first();
     $html = PDF::make($std, $dep, $caf, $lib, $ext, $fa, $fin, $gam);
     $mpdf = new mpdf();
     $mpdf->WriteHTML($html);
     $mpdf->Output();
     // $allpeople = student::where('regNo','=',$id)->first();
     // echo $allpeople->stdFname;
 }
Пример #3
0
 public function actionEditMolUser($table, $action, $id, $value)
 {
     switch ($table) {
         case 'po_name':
             switch ($action) {
                 case 'add':
                     $po_name = new po_name();
                     $po_name->po_name = $value;
                     $po_name->po_type_id = $id;
                     if ($po_name->save()) {
                         $result = 'ПО добавлено';
                     }
                     break;
                 case 'delete':
                     $po_name = po_name::findOne($id);
                     if ($po_name->active == '1') {
                         $po_name->active = '0';
                     } else {
                         $po_name->active = '1';
                     }
                     if ($po_name->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $po_name = po_name::findOne($id);
                         $po_name->po_name = $value;
                         if ($po_name->save()) {
                             $result = 'ПО переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'po_type':
             switch ($action) {
                 case 'add':
                     $po_type = new po_type();
                     $po_type->po_type = $value;
                     if ($po_type->save()) {
                         $result = 'Тип ПО добавлен';
                     }
                     break;
                 case 'delete':
                     $po_type = po_type::findOne($id);
                     if ($po_type->active == '1') {
                         $po_type->active = '0';
                     } else {
                         $po_type->active = '1';
                     }
                     if ($po_type->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $po_type = po_type::findOne($id);
                         $po_type->po_type = $value;
                         if ($po_type->save()) {
                             $result = 'Тип ПО переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'mol':
             switch ($action) {
                 case 'add':
                     $mol = new mol();
                     $mol->value = $value;
                     if ($mol->save()) {
                         $result = 'МОЛ добавлено';
                     }
                     break;
                 case 'delete':
                     $mol = mol::findOne($id);
                     if ($mol->active == '1') {
                         $mol->active = '0';
                     } else {
                         $mol->active = '1';
                     }
                     if ($mol->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $mol = mol::findOne($id);
                         $mol->value = $value;
                         if ($mol->save()) {
                             $result = 'МОЛ переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'cpu':
             switch ($action) {
                 case 'add':
                     $cpu = new cpu();
                     $cpu->name = $value;
                     if ($cpu->save()) {
                         $result = 'Процессор добавлен';
                     }
                     break;
                 case 'delete':
                     $cpu = cpu::findOne($id);
                     if ($cpu->active == '1') {
                         $cpu->active = '0';
                     } else {
                         $cpu->active = '1';
                     }
                     if ($cpu->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $cpu = cpu::findOne($id);
                         $cpu->name = $value;
                         if ($cpu->save()) {
                             $result = 'Процессор переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'cartridge_type':
             switch ($action) {
                 case 'add':
                     $type = new CartridgeType();
                     $type->type = $value;
                     if ($type->save()) {
                         $result = 'Тип картриджа добавлен';
                     }
                     break;
                 case 'delete':
                     $type = CartridgeType::find()->where(['type' => $id])->One();
                     if ($type->delete()) {
                         $result = 'Тип картриджа удален';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $type = CartridgeType::find()->where(['type' => $id])->One();
                         $type->type = $value;
                         if ($type->update()) {
                             $result = 'Картридж переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'consignment':
             switch ($action) {
                 case 'add':
                     $consignment = new consignment();
                     $consignment->name = $value;
                     if ($consignment->save()) {
                         $result = 'Партия добавлена';
                     } else {
                         $result = 'Партия НЕ добавлена';
                     }
                     break;
                 case 'delete':
                     // $query_str = 'UPDATE consignment SET active = NOT active WHERE id = "'.$id.'"';
                     //$consignment = consignment::findOne($id);
                     //if ($consignment -> active == '1') $consignment -> active = '0'; else $consignment -> active = '1';
                     //$consignment -> save();
                     //$result = 'Статус изменен';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $consignment = consignment::findOne($id);
                         $consignment->name = $value;
                         if ($consignment->save()) {
                             $result = 'Партия переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'type':
             switch ($action) {
                 case 'add':
                     $device_type = new deviceType();
                     $device_type->value = $value;
                     if ($device_type->save()) {
                         $result = 'Тип добавлен';
                     }
                     break;
                 case 'delete':
                     $device_type = deviceType::findOne($id);
                     if ($device_type->active == '1') {
                         $device_type->active = '0';
                     } else {
                         $device_type->active = '1';
                     }
                     if ($device_type->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $device_type = deviceType::findOne($id);
                         $device_type->value = $value;
                         if ($device_type->save()) {
                             $result = 'Тип переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'mark':
             switch ($action) {
                 case 'add':
                     $mark = new trademarks();
                     $mark->value = $value;
                     if ($mark->save()) {
                         $result = 'Марка добавлена';
                     }
                     break;
                 case 'delete':
                     $mark = mark::findOne($id);
                     if ($mark->active == '1') {
                         $mark->active = '0';
                     } else {
                         $mark->active = '1';
                     }
                     if ($mark->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     if ($value != '') {
                         $mark = mark::findOne($id);
                         $mark->value = $value;
                         if ($mark->save()) {
                             $result = 'Марка переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'user':
             switch ($action) {
                 case 'add':
                     $user = new user();
                     $user->name = $value;
                     $user->password = sha1('1');
                     if ($user->save()) {
                         $result = 'Сотрудник добавлен';
                     }
                     break;
                 case 'delete':
                     if ($value != '') {
                         $user = user::findOne($id);
                         if ($user->active == '1') {
                             $user->active = '0';
                         } else {
                             $user->active = '1';
                         }
                         if ($user->save()) {
                             $result = 'Статус изменен';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'edit':
                     $user = user::findOne($id);
                     $user->name = $value;
                     if ($user->save()) {
                         $result = 'Сотрудник переименован';
                     }
                     break;
             }
             break;
         case 'room':
             switch ($action) {
                 case 'add':
                     $room = new room();
                     $room->value = $value;
                     $room->building_id = $id;
                     if ($room->save()) {
                         $result = 'Кабинет добавлен';
                     } else {
                         $result = print_r($room->getErrors());
                     }
                     break;
                 case 'delete':
                     $room = room::findOne($id);
                     if ($room->active == '1') {
                         $room->active = '0';
                     } else {
                         $room->active = '1';
                     }
                     $room->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $room = room::findOne($id);
                         $room->value = $value;
                         if ($room->save()) {
                             $result = 'Кабинет переименован';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'device':
             switch ($action) {
                 case 'add':
                     switch (substr($id, 0, 3)) {
                         case 'mrk':
                             $result = 'Марка не добавлена! Выберите тип устройства для добавления!';
                             break;
                         case 'typ':
                             $type_id = intval(substr($id, 4));
                             $trademark = new trademark();
                             $trademark->value = $value;
                             $TypeLinkMark = new TypeLinkMark();
                             $TypeLinkMark->type_id = $type_id;
                             $TypeLinkMark->mark_id = Yii::app()->db->getLastInsertID();
                             if ($TypeLinkMark->save() && $trademark->save()) {
                                 $result = 'Марка добавлена';
                             }
                             break;
                     }
                     break;
                 case 'delete':
                     $device = new device();
                     $device->value = $value;
                     if ($device->save()) {
                         $result = 'Статус изменен';
                     }
                     break;
                 case 'edit':
                     $query_str = 'UPDATE user SET value = "' . $value . '" WHERE id = "' . $id . '"';
                     $result = 'Сотрудник переименован';
                     break;
             }
             break;
         case 'model':
             switch ($action) {
                 case 'add':
                     $model = new model();
                     $model->value = $value;
                     $model->save();
                     $result = 'Модель добавлена';
                     break;
                 case 'delete':
                     $model = model::findOne($id);
                     if ($model->active == '1') {
                         $model->active = '0';
                     } else {
                         $model->active = '1';
                     }
                     $model->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $model = model::findOne($id);
                         $model->value = $value;
                         if ($model->save()) {
                             $result = 'Модель переименована';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
             }
             break;
         case 'department':
             switch ($action) {
                 case 'delete':
                     //$result = 'Статус изменен';
                     $department = department::findOne($id);
                     if ($department->active == '1') {
                         $department->active = '0';
                     } else {
                         $department->active = '1';
                     }
                     $department->save();
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $department = department::findOne($id);
                         $department->value = $value;
                         if ($department->save()) {
                             $result = 'Подразделение переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'add':
                     $department = new Department();
                     $department->value = $value;
                     if ($department->save()) {
                         $result = 'Подразделение добавлено';
                     }
                     break;
             }
             break;
         case 'building':
             switch ($action) {
                 case 'delete':
                     $building = building::findOne($id);
                     if ($building->active == '1') {
                         $building->active = '0';
                     } else {
                         $building->active = '1';
                     }
                     $building->save();
                     //$result = 'Статус изменен';
                     $result = '';
                     break;
                 case 'edit':
                     if ($value != '') {
                         $building = building::findOne($id);
                         $building->value = $value;
                         if ($building->save()) {
                             $result = 'Здание переименовано';
                         }
                     } else {
                         $result = 'Введите новое наименование!';
                     }
                     break;
                 case 'add':
                     $building = new Building();
                     $building->value = $value;
                     $building->department_id = $id;
                     if ($building->save()) {
                         $result = 'Здание добавлено';
                     }
                     break;
             }
             break;
     }
     echo $result;
 }
Пример #4
0
			<td>Внешний номер</td>
			<td>Внутренний номер</td>
			<td>Управление</td>
		</thead>
		<tbody id ="phonebook_table">
		<?php 
//$phonebooks = Phonebook::find()->limit(10)->all();
//$departments = department::findAll(['active'=>'1']);
foreach ($phonebook as $phone) {
    //echo '=============|'.$phone->longNumber;
    //echo '<option value = '.$department->id.'>'.$department->value.'</option>';
    if (isset($phone->room_id) && room::findOne($phone->room_id)) {
        //echo 'есть рум ид';
        $room = room::findOne($phone->room_id);
        $build = building::findOne($room->building_id);
        $dep = department::findOne($build->department_id);
        //echo $room->value;
        echo '
					<tr id = "row_' . $phone->id . '">
						<td>' . $dep->value . '</td>
						<td>' . $build->value . '</td>
						<td>' . $room->value . '</td>
						<td>' . $phone->longNumber . '</td>
						<td>' . $phone->shortNumber . '</td>
						<td>
							<div class="edit_element_controls btn-group">
								<button type="button" class="btn btn-default" onClick = "edit_room(' . $phone->id . ')">
									<span class="glyphicon glyphicon-pencil"></span>
								</button>
							</div>
						</td>
Пример #5
0
    public function actionGetCartridgeStat($from_date, $till_date)
    {
        $cart_types = CartridgeType::find()->orderBy('used DESC')->all();
        $departments = department::find()->where(['active' => 1])->orderBy('value ASC')->all();
        if ($from_date && $till_date) {
            $cart_history = CartridgeHistory::find()->where(['>=', 'add_date', $from_date])->andWhere(['<=', 'add_date', $till_date])->all();
        } else {
            $cart_history = CartridgeHistory::find()->all();
        }
        echo '<table class = "table table-hover table-condensed"><tr><td>Подразделение / Картридж</td>';
        foreach ($cart_types as $type) {
            echo '<td>' . $type->type . '</td>';
        }
        echo '<td>Все</td>';
        echo '</tr>';
        foreach ($departments as $dep) {
            echo '<tr>
					<td>' . $dep->value . '</td>';
            $all_type_count = 0;
            foreach ($cart_types as $type) {
                $type_count = 0;
                foreach ($cart_history as $cart) {
                    // if ( $cart -> room_id != null ){
                    // $cart_build = building::findOne($cart -> room_id);
                    // // $cart_build_id = $cart_build -> id;
                    // $cart_dep = department::findOne($cart_build['id']);
                    // $cart_dep_id = $cart_dep['id'];
                    // }
                    // else{
                    // if( $cart -> building_id != null ){
                    // $cart_dep = department::findOne( $cart -> building_id );
                    // $cart_dep_id = $cart_dep -> id;
                    // }
                    // else{
                    // if($cart -> department_id != null ){
                    // $cart_dep_id = $cart -> department_id;
                    // }
                    // }
                    // }
                    if ($cart->department_id == $dep->id && $cart->cartridge_type == $type->type) {
                        // if ( $cart_dep_id == $dep -> id && $cart -> cartridge_type == $type -> type ){
                        $type_count++;
                        $all_type_count++;
                    }
                }
                echo $type_count ? '<td style = "color : red"><strong>' . $type_count . '</strong></td>' : '<td>' . $type_count . '</td>';
            }
            echo $all_type_count ? '<td style = "color : red"><strong>' . $all_type_count . '</strong></td>' : '<td>' . $all_type_count . '</td>';
            echo '</tr>';
        }
        echo '<tr><td>Все</td>';
        foreach ($cart_types as $type) {
            $type_count = 0;
            foreach ($cart_history as $cart) {
                if ($cart->cartridge_type == $type->type) {
                    $type_count++;
                }
            }
            echo $type_count ? '<td style = "color : red"><strong>' . $type_count . '</strong></td>' : '<td>' . $type_count . '</td>';
        }
        echo '<td style = "color : red"><strong>' . count($cart_history) . '</strong></td>';
        '</tr>';
        echo '</table>';
    }
Пример #6
0
 public function actionGetDevicesJson($room_id, $set_id = 11, $is_history)
 {
     if ($is_history === 'true') {
         $is_history = true;
     } else {
         $is_history = false;
     }
     $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;
     // адрес комплекта
     $addr_set = sets::findOne($set_id);
     //$addr_dep = department::findOne($addr_set ->department_id);
     //$addr_build = building::findOne($addr_set -> building_id);
     //$addr_room = room::findOne($addr_set -> room_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);
     $ggg['area'] = array("department" => $addr_dep->value, "building" => $addr_build->value, "room" => $addr_room->value, "set" => $addr_set->name);
     // устройства
     // актуальные или из истории
     if ($is_history) {
         //$history_sets = sets::find($set_id) -> asArray() -> all();
         //$history_sets = ArrayHelper::getColumn($history_sets, 'id');
         //$history_sets = array_unique($history_sets);
         //$devices_in_history = deviceHistory::find( ['set_id' => $history_sets] ) -> asArray() -> all();
         $devices_in_history = deviceHistory::find()->where(['set_id' => $set_id, 'room_id' => $room_id])->all();
         foreach ($devices_in_history as $device_in_history) {
             $device = device::findOne($device_in_history->device_id);
             // -------------------------------------------------------------------------------------------------------------------------------------
             //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
             if (user::findOne($device_in_history->user_id)) {
                 $dev_add_usr = user::findOne($device_in_history->user_id);
                 $dev_add_user_name = $dev_add_usr->name;
             } else {
                 $dev_add_user_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);
             array_push($ggg['devices'], array("add_date" => $device_in_history->date, "add_user" => $dev_add_user_name, "device_id" => $device_in_history->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));
             // если тип устройства - системный блок.
             $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;
             }
             // --------------------------------------------------------------------------------------------------------------------------------------------------
         }
         //$set_devices = device::findAll(['id' => ArrayHelper::getColumn($devices_in_history, 'device_id')]);
     } else {
         $set_devices = device::findAll(['set_id' => $set_id, 'active' => true]);
         foreach ($set_devices as $device) {
             //$dev_add_usr = user::find(['id' => $device -> add_username_id])-> one();
             if ($dev_add_usr = user::findOne($device->add_username_id)) {
                 $dev_add_user_name = $dev_add_usr->name;
             } else {
                 $dev_add_user_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);
             array_push($ggg['devices'], array("add_date" => $device->add_date, "add_user" => $dev_add_user_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));
             // если тип устройства - системный блок.
             $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);
 }
Пример #7
0
    public function actionEditRoom($phone_id)
    {
        $phone = phonebook::findOne($phone_id);
        $departments = department::findAll(['active' => '1']);
        echo '<td>
				<select id="dep_sel_' . $phone_id . '" class="form-control" onChange="change_navigation_dep(' . "\$('#dep_sel_" . $phone_id . ' option:selected' . "'" . ').val()' . ', ' . "'build_sel_" . $phone_id . "')" . '"' . ">";
        foreach ($departments as $department) {
            echo '<option value = "' . $department->id . '">' . $department->value . '</option>';
        }
        echo '</select>
			</td>
			<td>
				<select id="build_sel_' . $phone_id . '" class="form-control" onChange="change_navigation_build(' . "\$('#build_sel_" . $phone_id . ' option:selected' . "'" . ').val()' . ', ' . "'room_sel_" . $phone_id . "')" . '"' . ">";
        echo '</select>
			</td>
			<td>
				<select id="room_sel_' . $phone_id . '" class="form-control" >
					<option value="">кабинет 1</option>
					<option value="">кабинет 2</option>
					<option value="">кабинет 3</option>
				</select>
			</td>
			<td>' . $phone->longNumber . '</td>
			<td>' . $phone->shortNumber . '</td>
			<td>
				<div class="edit_element_controls btn-group">
					<button type="button" class="btn btn-default" onClick = "set_room(' . "\$('#room_sel_" . $phone_id . ' option:selected' . "'" . ').val()' . ", '" . $phone_id . "')" . '"' . '>
						<span class="glyphicon glyphicon-ok"></span>
					</button>
					<button type="button" class="btn btn-default" onClick = "reload_phonebook()">
						<span class="glyphicon glyphicon-remove"></span>
					</button>
				</div>
			</td>';
    }
Пример #8
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);
 }
Пример #9
0
 public function getDepartment()
 {
     return $this->hasOne(department::className(), ['id' => 'department_id'])->via('building');
 }