/** * @param string $get_array * @param string $type_array * @param string $category_array * @return string */ public static function add_as_item_window($get_array, $type_array, $category_array) { if ($get_array) { $_GET = unserialize($get_array); } if ($type_array) { $type_array = unserialize($type_array); } if ($category_array) { $category_array = unserialize($category_array); } $template = new HTMLTemplate("equipment/add_item_window.html"); $equipment_array = EquipmentType::list_entries(); $result = array(); $hit_array = array(); $counter = 0; if (is_array($type_array) and count($type_array) >= 1) { if (is_array($equipment_array) and count($equipment_array) >= 1) { foreach ($equipment_array as $key => $value) { if (in_array($value, $type_array) or $value <= 3) { $equipment_type = new EquipmentType($value); $result[$counter]['value'] = $value; $result[$counter]['disabled'] = ""; $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")"; $counter++; array_push($hit_array, $value); } } } if (is_array($category_array) and count($category_array) >= 1) { foreach ($category_array as $key => $value) { $equipment_cat_array = EquipmentType::list_entries_by_cat_id($value); if (is_array($equipment_cat_array) and count($equipment_cat_array) >= 1) { foreach ($equipment_cat_array as $key => $value) { if (!in_array($value, $hit_array)) { $equipment_type = new EquipmentType($value); $result[$counter]['value'] = $value; $result[$counter]['disabled'] = ""; $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")"; $counter++; array_push($hit_array, $value); } } } } } } else { if (is_array($category_array) and count($category_array) >= 1) { foreach ($category_array as $key => $value) { $equipment_cat_array = EquipmentType::list_entries_by_cat_id($value); if (is_array($equipment_cat_array) and count($equipment_cat_array) >= 1) { if (!in_array(1, $equipment_cat_array)) { $equipment_cat_array[] = 1; } if (!in_array(2, $equipment_cat_array)) { $equipment_cat_array[] = 2; } if (!in_array(3, $equipment_cat_array)) { $equipment_cat_array[] = 3; } foreach ($equipment_cat_array as $key => $value) { if (!in_array($value, $hit_array)) { $equipment_type = new EquipmentType($value); $result[$counter]['value'] = $value; $result[$counter]['disabled'] = ""; $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")"; $counter++; array_push($hit_array, $value); } } } } } else { if (is_array($equipment_array) and count($equipment_array) >= 1) { foreach ($equipment_array as $key => $value) { $equipment_type = new EquipmentType($value); $result[$counter]['value'] = $value; $result[$counter]['disabled'] = ""; $result[$counter]['content'] = $equipment_type->get_name() . " (" . $equipment_type->get_cat_name() . ")"; $counter++; } } } } if ($counter == 0) { $result[0]['value'] = "0"; $result[0]['disabled'] = "disabled='disabled'"; $result[0]['content'] = "NO EQUIPMENT FOUND!"; } $template->set_var("select", $result); if ($_GET['parent'] and is_numeric($_GET['parent_id'])) { $array['container'] = "#EquipmentItemAddWindow" . $_GET['parent_key'] . "-" . $_GET['parent_id'] . "-" . $_GET['key']; $container_value_select = "EquipmentItemAddValueField" . $_GET['parent_key'] . "-" . $_GET['parent_id'] . "-" . $_GET['key']; } else { $array['container'] = "#EquipmentItemAddWindow" . $_GET['key']; $container_value_select = "EquipmentItemAddValueField" . $_GET['key']; } $template->set_var("container_value_select_id", $container_value_select); $array['continue_caption'] = "Add"; $array['cancel_caption'] = "Cancel"; $array['content_caption'] = "Add Equipment"; $array['height'] = 350; $array['width'] = 400; $array['content'] = $template->get_string(); $continue_handler_template = new JSTemplate("equipment/js/add_item_window.js"); $continue_handler_template->set_var("session_id", $_GET['session_id']); $continue_handler_template->set_var("get_array", $get_array); $continue_handler_template->set_var("container_id", $array['container']); $continue_handler_template->set_var("container_value_select_id", $container_value_select); $array['continue_handler'] = $continue_handler_template->get_string(); return json_encode($array); }
private static function detail_home() { $equipment_type = new EquipmentType($_GET['id']); $template = new HTMLTemplate("equipment/admin/equipment_type/detail.html"); $paramquery = $_GET; $paramquery['action'] = "rename"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $template->set_var("rename_params", $params); $template->set_var("name", $equipment_type->get_name()); $template->set_var("category", $equipment_type->get_cat_name()); $paramquery = $_GET; $paramquery['action'] = "change_location"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); $template->set_var("change_location_params", $params); if ($equipment_type->get_location_id() == null) { $template->set_var("location", "<span class='italic'>none</span>"); } else { $location = new Location($equipment_type->get_location_id()); $template->set_var("location", $location->get_name(true)); } if ($equipment_type->get_description()) { $template->set_var("description", $equipment_type->get_description()); } else { $template->set_var("description", "<span class='italic'>none</span>"); } $template->output(); }
/** * @throws EquipmentTypeIDMissingException */ public static function type_detail($type_id, $owner_id) { if (is_numeric($type_id)) { $equipment_type = new EquipmentType($type_id); $equipment_owner = new User($owner_id); $template = new HTMLTemplate("equipment/detail.html"); $template->set_var("name", $equipment_type->get_name()); $template->set_var("category", $equipment_type->get_cat_name()); if ($equipment_type->get_location_id() == null) { $template->set_var("location", "<span class='italic'>none</span>"); } else { $location = new Location($equipment_type->get_location_id()); $template->set_var("location", $location->get_name(true)); } $template->set_var("owner", $equipment_owner->get_full_name(false)); if ($equipment_type->get_description()) { $template->set_var("description", $equipment_type->get_description()); } else { $template->set_var("description", "<span class='italic'>none</span>"); } $user_array = $equipment_type->list_users(); $user_content_array = array(); $counter = 0; if (is_array($user_array) and count($user_array) >= 1) { foreach ($user_array as $key => $value) { $user = new User($value); $user_content_array[$counter]['username'] = $user->get_username(); $user_content_array[$counter]['fullname'] = $user->get_full_name(false); $counter++; } $template->set_var("no_user", false); } else { $template->set_var("no_user", true); } $template->set_var("user", $user_content_array); $ou_array = $equipment_type->list_organisation_units(); $ou_content_array = array(); $counter = 0; if (is_array($ou_array) and count($ou_array) >= 1) { foreach ($ou_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $ou_content_array[$counter]['name'] = $organisation_unit->get_name(); $counter++; } $template->set_var("no_ou", false); } else { $template->set_var("no_ou", true); } $template->set_var("ou", $ou_content_array); $template->output(); } else { throw new EquipmentTypeIDMissingException(); } }