/** * @throws EquipmentTypeIDMissingException */ public static function add_organisation_unit() { if ($_GET['id']) { if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['ou'])) { $equipment_type = new EquipmentType($_GET['id']); if ($equipment_type->is_organisation_unit($_POST['ou']) == true) { $page_1_passed = false; $error = "The organisation units is already connected with this equipment."; } else { $page_1_passed = true; } } else { $page_1_passed = false; $error = "You must select an organisation unit."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("equipment/admin/equipment_type/add_organisation_unit.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); $organisation_unit_array = OrganisationUnit::list_entries(); $result = array(); $counter = 0; foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $organisation_unit->get_name(); $counter++; } $template->set_var("option", $result); $template->output(); } else { $equipment_type = new EquipmentType($_GET['id']); $paramquery = $_GET; $paramquery['action'] = "detail"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($equipment_type->add_organisation_unit($_POST['ou'])) { Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Failed", null); } } } else { throw new EquipmentTypeIDMissingException(); } }