Print generic new line
static public showNewLine ( $type, $odd = false, $is_deleted = false ) : string | ||
$type | display type (0=HTML, 1=Sylk,2=PDF,3=CSV) | |
$odd | is it a new odd line ? (false by default) | |
$is_deleted | is it a deleted search ? (false by default) | |
return | string | to display |
public function showResult($output_type, $limit = 0) { global $DB; $arrayRet = $this->execQuery($_POST); $result = $arrayRet['query_result']; $query = $arrayRet['query']; $nbtot = $result ? $DB->numrows($result) : 0; if ($limit) { $start = isset($_GET["start"]) ? $_GET["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $result = $DB->query($query . " LIMIT {$start},{$limit}"); } } else { $start = 0; } $nbCols = $DB->num_fields($result); $nbrows = $DB->numrows($result); $groupByRackName = true; if (isset($_POST['groupByRackName']) && $_POST['groupByRackName'] == "on") { $groupByRackName = false; } $title = date("d/m/Y H:i"); if ($nbtot == 0) { echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>"; Html::footer(); } else { if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php"; } else { if ($output_type == Search::HTML_OUTPUT) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>{$title}</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}' target='_blank'>\n"; $param = ""; foreach ($_POST as $key => $val) { if (is_array($val)) { foreach ($val as $k => $v) { echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >"; if (!empty($param)) { $param .= "&"; } $param .= $key . "[" . $k . "]=" . urlencode($v); } } else { echo "<input type='hidden' name='{$key}' value='{$val}' >"; if (!empty($param)) { $param .= "&"; } $param .= "{$key}=" . urlencode($val); } } echo "<input type='hidden' name='result_search_reports' value='searchdone' >"; $param .= "&result_search_reports=searchdone&target=_blank"; Dropdown::showOutputFormat(); Html::closeForm(); echo "</td></tr>"; echo "</table></div>"; Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param); } } } if ($nbtot > 0) { if ($output_type == Search::HTML_OUTPUT) { echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; } echo Search::showHeader($output_type, $nbrows, $nbCols, true); $showAllFieds = true; $listFields = array(); $cptField = 0; $showAllFieds = (!isset($_POST['cb_object_name']) || $_POST['cb_object_name'] != "on") && (!isset($_POST['cb_object_location']) || $_POST['cb_object_location'] != "on") && (!isset($_POST['cb_group']) || $_POST['cb_group'] != "on") && (!isset($_POST['cb_manufacturer']) || $_POST['cb_manufacturer'] != "on") && (!isset($_POST['cb_model']) || $_POST['cb_model'] != "on") && (!isset($_POST['cb_serial_number']) || $_POST['cb_serial_number'] != "on"); $num = 1; $cptRow = 1; if (!$showAllFieds) { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false); $cptField++; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'location', false); $cptField++; $this->showTitle($output_type, $num, _n("Location", "Locations", 1, "racks"), 'roomlocation', false); $cptField++; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false); $cptField++; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false); $cptField++; if (isset($_POST['cb_object_name']) && $_POST['cb_object_name'] == "on") { $listFields['object_name'] = $_POST['cb_object_name']; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false); $cptField++; } // Lieu if (isset($_POST['cb_object_location']) && $_POST['cb_object_location'] == "on") { $listFields['object_location'] = $_POST['cb_object_location']; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false); $cptField++; } // Groupe if (isset($_POST['cb_group']) && $_POST['cb_group'] == "on") { $listFields['group'] = $_POST['cb_group']; $this->showTitle($output_type, $num, __("Group"), 'roomlocation', false); $cptField++; } // Fabricant if (isset($_POST['cb_manufacturer']) && $_POST['cb_manufacturer'] == "on") { $listFields['manufacturer'] = $_POST['cb_manufacturer']; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false); $cptField++; } // Modèle if (isset($_POST['cb_model']) && $_POST['cb_model'] == "on") { $listFields['model'] = $_POST['cb_model']; $this->showTitle($output_type, $num, __("Model"), 'model', false); $cptField++; } // Numéro de série if (isset($_POST['cb_serial_number']) && $_POST['cb_serial_number'] == "on") { $listFields['serial_number'] = $_POST['cb_serial_number']; $this->showTitle($output_type, $num, __("Serial number", "racks"), 'group', false); $cptField++; } } else { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false); $listFields['rack_name'] = true; $this->showTitle($output_type, $num, __("Place", "racks"), 'location', false); $listFields['location'] = true; $this->showTitle($output_type, $num, __("Location", "racks"), 'roomlocation', false); $listFields['roomlocation'] = true; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false); $listFields['u'] = true; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false); $listFields['front_rear'] = true; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false); $listFields['object_name'] = true; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false); $listFields['object_location'] = true; $this->showTitle($output_type, $num, __("Group"), false); $listFields['group'] = true; $this->showTitle($output_type, $num, __("Type"), 'type', false); $listFields['type'] = true; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false); $listFields['manufacturer'] = true; $this->showTitle($output_type, $num, __("Model"), 'model', false); $listFields['model'] = true; $this->showTitle($output_type, $num, __("Serial number", "racks"), 'serial_number', false); $listFields['serial_number'] = true; $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false); $listFields['other_serial'] = true; $cptField = 13; } echo Search::showEndLine($output_type); $num = 1; $currentRack = -1; while ($row = $DB->fetch_array($result)) { // itemtype $itemtype = $row['itemtype']; $num = 1; $cptRow++; echo Search::showNewLine($output_type); if (isset($row['itemtype']) && $row['itemtype'] != "") { $class = substr($itemtype, 0, -5); $item = new $class(); $table = getTableForItemType($class); $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' "); $device = $DB->fetch_array($r); } // nom $link = Toolbox::getItemTypeFormURL("PluginRacksRack"); if ($groupByRackName || $currentRack != $row['id']) { if ($output_type == Search::HTML_OUTPUT) { echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow); } else { echo Search::showItem($output_type, $row["name"], $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // lieu if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['locations_id']; $tmpObj = new Location(); $tmpObj->getFromDB($tmpId); if (isset($tmpObj->fields['name'])) { echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow); } else { echo Search::showItem($output_type, " ", $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // Emplacement if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['plugin_racks_roomlocations_id']; $tmpObj = new PluginRacksRoomLocation(); $tmpObj->getFromDB($tmpId); if (isset($tmpObj->fields['name'])) { echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow); } else { echo Search::showItem($output_type, ' ', $num, $cptRow); } } else { echo Search::showItem($output_type, " ", $num, $cptRow); } if (isset($row['itemtype']) && $row['itemtype'] != "") { // U if (isset($row['position']) && $row['position'] != "") { echo Search::showItem($output_type, $row['position'], $num, $cptRow); } else { echo Search::showItem($output_type, " ", $num, $cptRow); } // avant / arrière if ($row['faces_id'] == 1) { echo Search::showItem($output_type, __("Front", "racks"), $num, $cptRow); } else { echo Search::showItem($output_type, __("Back", "racks"), $num, $cptRow); } // Nom de l'objet if (array_key_exists("object_name", $listFields)) { $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5)); if ($itemtype != 'PluginRacksOtherModel') { if ($output_type == Search::HTML_OUTPUT) { echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow); } else { echo Search::showItem($output_type, $device["name"], $num, $cptRow); } } else { echo Search::showItem($output_type, $device["name"], $num, $cptRow); } } // Lieu de l'objet if (array_key_exists("object_location", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // Groupe if (array_key_exists("group", $listFields)) { // Groupe if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // type if (array_key_exists("type", $listFields)) { echo Search::showItem($output_type, $item->getTypeName(), $num, $cptRow); } // fabricant if (array_key_exists("manufacturer", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // modèle //TODO = model du rack => model des objets if (array_key_exists("model", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { $model_table = getTableForItemType($itemtype); $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype)); echo Search::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // numéro de série if (array_key_exists("serial_number", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, $device['serial'], $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } // numéro d'inventaire if (array_key_exists("other_serial", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo Search::showItem($output_type, $device['otherserial'], $num, $cptRow); } else { echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow); } } $currentRack = $row['id']; } else { for ($k = 0; $k < $cptField - 3; $k++) { echo Search::showItem($output_type, " ", $num, $cptRow, ""); } } echo Search::showEndLine($output_type); } if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } echo Search::showFooter($output_type, $title); } }
function showMinimalList($params) { global $DB, $CFG_GLPI; // Instanciate an object to access method $item = NULL; $itemtype = $this->getType(); $itemtable = $this->getTable(); if (class_exists($itemtype)) { $item = new $itemtype(); } // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; foreach ($params as $key => $val) { $p[$key] = $val; } if ($p['export_all']) { $p['start'] = 0; } // Manage defautlt seachtype value : for bookmark compatibility if (count($p['contains'])) { foreach ($p['contains'] as $key => $val) { if (!isset($p['searchtype'][$key])) { $p['searchtype'][$key] = 'contains'; } } } if (is_array($p['contains2']) && count($p['contains2'])) { foreach ($p['contains2'] as $key => $val) { if (!isset($p['searchtype2'][$key])) { $p['searchtype2'][$key] = 'contains'; } } } //$target = Toolbox::getItemTypeSearchURL($itemtype); $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/resourceresting.php"; $limitsearchopt = Search::getCleanedOptions("PluginResourcesResourceResting"); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $PluginResourcesResource = new PluginResourcesResource(); $entity_restrict = $PluginResourcesResource->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView($itemtype); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser("PluginResourcesResourceResting", Session::getLoginUserID()); if (count($displaypref)) { foreach ($displaypref as $val) { array_push($toview, $val); } } // Add searched items if (count($p['field']) > 0) { foreach ($p['field'] as $key => $val) { if (!in_array($val, $toview) && $val != 'all' && $val != 'view') { array_push($toview, $val); } } } // Add order item if (!in_array($p['sort'], $toview)) { array_push($toview, $p['sort']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect($itemtype); // Add select for all toview item foreach ($toview as $key => $val) { $query .= Search::addSelect($itemtype, $val, $key, 0); } $query .= "`" . $itemtable . "`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " FROM `" . $itemtable . "`"; // Init already linked tables array in order not to link a table several times $already_link_tables = array(); // Put reference table array_push($already_link_tables, $itemtable); // Add default join $COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt[$itemtype] =& Search::getOptions($itemtype); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"]); } // Search all case : if (in_array("all", $p['field'])) { foreach ($searchopt[$itemtype] as $key => $val) { // Do not search on Group Name if (is_array($val)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"]); } } } //// 3 - WHERE // default string $COMMONWHERE = Search::addDefaultWhere($itemtype); $first = empty($COMMONWHERE); // Add deleted if item have it if ($item && $item->maybeDeleted()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_deleted` = '" . $p['is_deleted'] . "' "; } // Remove template items if ($item && $item->maybeTemplate()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`{$itemtable}`.`is_template` = '0' "; } // Add Restrict to current entities if ($entity_restrict) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } if ($itemtype == 'Entity') { $COMMONWHERE .= getEntitiesRestrictRequest($LINK, $itemtable, 'id', '', true); } else { if (isset($CFG_GLPI["union_search_type"]["PluginResourcesResource"])) { // Will be replace below in Union/Recursivity Hack $COMMONWHERE .= $LINK . " ENTITYRESTRICT "; } else { $COMMONWHERE .= getEntitiesRestrictRequest($LINK, "glpi_plugin_resources_resources", '', '', $PluginResourcesResource->maybeRecursive()); } } } ///R�cup�ration des groupes de l'utilisateur connect� $who = Session::getLoginUserID(); if (!plugin_resources_haveRight("all", "r")) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "(`glpi_plugin_resources_resources`.`users_id_recipient` = '{$who}' OR `glpi_plugin_resources_resources`.`users_id` = '{$who}') "; } $WHERE = ""; $HAVING = ""; // Add search conditions // If there is search items if ($_SESSION["glpisearchcount"][$itemtype] > 0 && count($p['contains']) > 0) { for ($key = 0; $key < $_SESSION["glpisearchcount"][$itemtype]; $key++) { // if real search (strlen >0) and not all and view search if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) { // common search if ($p['field'][$key] != "all" && $p['field'][$key] != "view") { $LINK = " "; $NOT = 0; $tmplink = ""; if (is_array($p['link']) && isset($p['link'][$key])) { if (strstr($p['link'][$key], "NOT")) { $tmplink = " " . str_replace(" NOT", "", $p['link'][$key]); $NOT = 1; } else { $tmplink = " " . $p['link'][$key]; } } else { $tmplink = " AND "; } if (isset($searchopt[$itemtype][$p['field'][$key]]["usehaving"])) { // Manage Link if not first item if (!empty($HAVING)) { $LINK = $tmplink; } // Find key $item_num = array_search($p['field'][$key], $toview); $HAVING .= Search::addHaving($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num); } else { // Manage Link if not first item if (!empty($WHERE)) { $LINK = $tmplink; } $WHERE .= Search::addWhere($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]); } // view and all search } else { $LINK = " OR "; $NOT = 0; $globallink = " AND "; if (is_array($p['link']) && isset($p['link'][$key])) { switch ($p['link'][$key]) { case "AND": $LINK = " OR "; $globallink = " AND "; break; case "AND NOT": $LINK = " AND "; $NOT = 1; $globallink = " AND "; break; case "OR": $LINK = " OR "; $globallink = " OR "; break; case "OR NOT": $LINK = " AND "; $NOT = 1; $globallink = " OR "; break; } } else { $tmplink = " AND "; } // Manage Link if not first item if (!empty($WHERE)) { $WHERE .= $globallink; } $WHERE .= " ( "; $first2 = true; $items = array(); if ($p['field'][$key] == "all") { $items = $searchopt[$itemtype]; } else { // toview case : populate toview foreach ($toview as $key2 => $val2) { $items[$val2] = $searchopt[$itemtype][$val2]; } } foreach ($items as $key2 => $val2) { if (is_array($val2)) { // Add Where clause if not to be done in HAVING CLAUSE if (!isset($val2["usehaving"])) { $tmplink = $LINK; if ($first2) { $tmplink = " "; $first2 = false; } $WHERE .= Search::addWhere($tmplink, $NOT, $itemtype, $key2, $p['searchtype'][$key], $p['contains'][$key]); } } } $WHERE .= " ) "; } } } } if (!empty($WHERE) || !empty($COMMONWHERE)) { if (!empty($COMMONWHERE)) { $WHERE = ' WHERE ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : ''); } else { $WHERE = ' WHERE ' . $WHERE . ' '; } $first = false; } $query .= $WHERE; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (in_array('all', $p['field'])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } if (empty($GROUPBY)) { foreach ($toview as $key2 => $val2) { if (!empty($GROUPBY)) { break; } if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $this->getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { // Pager if ($output_type == Search::HTML_OUTPUT) { Html::printPager($p['start'], $numrows, $target, $parameters, $itemtype); } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols); $header_num = 1; // Display column Headers for toview items echo Search::showNewLine($output_type); // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) { $linkto = "{$target}?itemtype={$itemtype}&sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto; } echo Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers echo Search::showEndLine($output_type); $DB->data_seek($result, $p['start']); // Define begin and end var for loop // Search case $i = $begin_display; // Init list of items displayed if ($output_type == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= __('List of non contract periods', 'resources'); } // Display footer echo Search::showFooter($output_type, $title); // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printPager($p['start'], $numrows, $target, $parameters); } } else { echo Search::showError($output_type); } } }
static function commonListHeader($output_type = HTML_OUTPUT, $canedit) { // New Line for Header Items Line echo Search::showNewLine($output_type); // $show_sort if $header_num = 1; $items = array(); $items[__('Name')] = "glpi_plugin_projet_projets.name"; if (Session::isMultiEntitiesMode()) { $items[__('Entity')] = "glpi_entities.completename"; } $items[__('Description')] = "glpi_plugin_projet_projets.description"; $items[__('Progress')] = "glpi_plugin_projet_projets.advance"; $items[__('Start date')] = "glpi_plugin_projet_projets.date_begin"; $items[__('End date')] = "glpi_plugin_projet_projets.date_end"; foreach ($items as $key => $val) { $issort = 0; $link = ""; echo Search::showHeaderItem($output_type, $key, $header_num, $link); } if ($canedit) { echo "<th> </th>"; } // End Line for column headers echo Search::showEndLine($output_type); }
/** * show hardware to be identified, or identified and imported, or just the hardware with agents installed on them * @param type $hardware array * @param type $lim integer * @param int|type $start integer * @param type $ipAdress string * @param type $status string * @param $subnet * @param $action * @global type $CFG_GLPI */ static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action) { global $CFG_GLPI, $DB; $output_type = Search::HTML_OUTPUT; //0 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php"; $return = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $returnargs = "subnetsChoice={$subnet}&action={$action}"; $reload = "ip={$ipAdress}&status={$status}&action={$action}"; $backValues = "?b[]={$ipAdress}&b[]={$status}"; if ($status == "inventoried") { $status_name = __('Inventoried', 'ocsinventoryng'); } elseif ($status == "imported") { $status_name = __('Imported / Linked', 'ocsinventoryng'); } elseif ($status == "noninventoried") { $status_name = __('Non Inventoried', 'ocsinventoryng'); } else { $status_name = __('Identified', 'ocsinventoryng'); } $subnet_name = self::getSubnetNamebyIP($ipAdress); echo "<div class='center'>"; echo "<h2>" . __('Subnet', 'ocsinventoryng') . " " . $subnet_name . " (" . $ipAdress . ") - " . $status_name; echo " "; $refresh = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php?" . $reload; Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), array(), $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png"); echo "</h2>"; echo "</div>"; if ($subnet >= 0) { $back = __('Back'); echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>"; } echo Html::printPager($start, count($hardware), $link, $reload); echo Search::showNewLine($output_type, true); if (empty($hardware)) { echo "<div class='center b'><br>" . __('No new IPDiscover device to import', 'ocsinventoryng') . "</div>"; Html::displayBackLink(); } else { $header_num = 1; switch ($status) { case "inventoried": echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('User'), $header_num); echo Search::showHeaderItem($output_type, __('Name'), $header_num); echo Search::showHeaderItem($output_type, __('System'), $header_num); echo Search::showHeaderItem($output_type, __('Version of the operating system'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Last OCSNG inventory date', 'ocsinventoryng'), $header_num); echo Search::showEndLine($output_type); $row_num = 1; for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $row_num % 2); echo Search::showItem($output_type, $hardware[$i]["userid"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["name"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["osname"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["osversion"], $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["ipaddr"], $item_num, $row_num); echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["lastdate"]), $item_num, $row_num); echo Search::showEndLine($output_type); } } echo "</table>\n"; break; case "imported": $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; echo "<input type='submit' class='submit' name='deletelink' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('Item'), $header_num); echo Search::showHeaderItem($output_type, __('Item type'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Location'), $header_num); echo Search::showHeaderItem($output_type, __('Import date in GLPI', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Subnet'), $header_num); echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $row_num % 2); $class = getItemForItemtype($hardware[$i]["itemtype"]); $class->getFromDB($hardware[$i]["items_id"]); $iplist = ""; $ip = new IPAddress(); // Update IPAddress foreach ($DB->request('glpi_networkports', array('itemtype' => $hardware[$i]["itemtype"], 'items_id' => $hardware[$i]["items_id"])) as $netname) { foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', 'items_id' => $netname['id'])) as $dataname) { foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $dataname['id'])) as $data) { $ip->getFromDB($data['id']); $iplist .= $ip->getName() . "<br>"; } } } echo Search::showItem($output_type, $class->getLink(), $item_num, $row_num); echo Search::showItem($output_type, $class->getTypeName(), $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["macaddress"], $item_num, $row_num); echo Search::showItem($output_type, $iplist, $item_num, $row_num); echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $class->fields["locations_id"]), $item_num, $row_num); echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["last_update"]), $item_num, $row_num); echo Search::showItem($output_type, $hardware[$i]["subnet"], $item_num, $row_num); echo self::showItem($hardware[$i]["id"], "", "", "", true, "", $i); echo Search::showEndLine($output_type); } } echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>"; echo "</tbody>"; echo "</table>\n"; echo "<div class='center' style=\"width=100%\">"; echo "<input type='submit' class='submit' name='deletelink' value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; case "noninventoried": $ocsTypes = array("id" => array(Dropdown::EMPTY_VALUE), "name" => array(Dropdown::EMPTY_VALUE)); $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; $macConstructor = ""; self::getOCSTypes($ocsTypes); self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='IdentifyAndImport' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='IdentifyAndLink' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>\n"; echo Search::showHeaderItem($output_type, __('Date'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Subnet mask'), $header_num); echo Search::showHeaderItem($output_type, __('DNS', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Description') . "<span class='red'>*</span>", $header_num); echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); if ($action == "import") { echo Search::showHeaderItem($output_type, __('Name'), $header_num); if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); } else { echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); } echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; $ocstypes = array(); foreach ($ocsTypes["name"] as $items) { $ocstypes[$items] = $items; } $itemstypes = array(Dropdown::EMPTY_VALUE); foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); } for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; echo Search::showNewLine($output_type, $row_num % 2); echo self::showItem(Html::convDateTime($hardware[$i]["date"])); if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) { $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]); if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) { $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))]; } else { $macConstructor = __("unknow"); } } $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>"; echo self::showItem($mac); echo self::showItem($ip = $hardware[$i]["ip"]); echo self::showItem($hardware[$i]["mask"]); echo self::showItem($hardware[$i]["DNS"]); echo "<td><input type=\"text\" name='itemsdescription[" . $i . "]' value=\"\" ></td>"; echo "<td>"; Dropdown::showFromArray("ocsitemstype[{$i}]", $ocstypes); echo "</td>"; if ($action == "import") { echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>"; if (Session::isMultiEntitiesMode()) { echo "<td>"; Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"])); echo "</td>"; } echo "<td>"; Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes); echo "</td>"; } else { echo "<td width='10'>"; $mtrand = mt_rand(); $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname); //print_r($p); Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "<span id='results_{$mynamei}{$rand}'>\n"; echo "</span>\n"; //} echo "</td>"; } echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i); echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >\n <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>"; echo "</tbody>"; } } echo "</table>\n"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='IdentifyAndImport' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='IdentifyAndLink' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; default: $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php"; $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues; $macConstructor = ""; self::checkBox($target); echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='Import' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='Link' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; echo "<table width='100%'class='tab_cadrehov'>"; echo Search::showHeaderItem($output_type, __('Date'), $header_num); echo Search::showHeaderItem($output_type, __('Description'), $header_num); echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('MAC address'), $header_num); if ($action == "import") { if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Name'), $header_num); echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num); } else { echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); } echo Search::showHeaderItem($output_type, __(' '), $header_num); echo Search::showEndLine($output_type); $row_num = 1; $itemstypes = array(Dropdown::EMPTY_VALUE); foreach (self::$hardwareItemTypes as $items) { $class = getItemForItemtype($items); $itemstypes[$items] = $class->getTypeName(); } for ($i = $start; $i < $lim + $start; $i++) { if (isset($hardware[$i])) { $row_num++; echo Search::showNewLine($output_type, $row_num % 2); echo self::showItem(Html::convDateTime($hardware[$i]["date"])); echo self::showItem($description = $hardware[$i]["description"]); echo self::showItem($hardware[$i]["type"]); echo self::showItem($ip = $hardware[$i]["ip"]); if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) { $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]); if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) { $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))]; } else { $macConstructor = __("unknow"); } } $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>"; echo self::showItem($mac); if ($action == "import") { if (Session::isMultiEntitiesMode()) { echo "<td>"; Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"])); echo "</td>"; } echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>"; echo "<td>"; Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes); echo "</td>"; } else { echo "<td width='10'>"; $mtrand = mt_rand(); $mynamei = "itemtype"; $myname = "tolink_items[" . $i . "]"; $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand)); $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname); Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "<span id='results_{$mynamei}{$rand}'>\n"; echo "</span>\n"; echo "</td>"; } echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i); echo "<tbody style=\"display:none\">"; echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >"; echo "<input type=\"hidden\" name='itemsdescription[" . $i . "]' value=\"{$description}\" >\n <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></tr>"; echo "</td></tr></tbody>"; } } echo "</table>"; echo "<div class='center' style=\"width=100%\">"; if ($action == "import") { echo "<input type='submit' class='submit' name='Import' value=\"" . _sx('button', 'Import') . "\">"; echo " "; } else { echo "<input type='submit' class='submit' name='Link' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; echo " "; } echo "<input type='submit' class='submit' name='delete' value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>"; Html::closeForm(); self::checkBox($target); break; } } if ($subnet >= 0) { $back = __('Back'); echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>"; } }
static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand) { global $CFG_GLPI; $pfDeployPackage = new PluginFusioninventoryDeployPackage(); $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']); $o_file = new self(); // compute short shas to find the corresponding entries in database $short_shas = array(); foreach ($datas['jobs']['associatedFiles'] as $sha512) { $short_shas[] = "'" . substr($sha512, 0, 6) . "'"; } // find corresponding file entries $files = $o_file->find("shortsha512 IN (" . implode(",", $short_shas) . ")"); // do a quick mapping between database id and short shas $files_mapping = array(); foreach ($files as $f) { $files_mapping[$f['shortsha512']] = $f['id']; } echo "<table class='tab_cadrehov package_item_list' id='table_file_{$rand}'>"; $i = 0; foreach ($datas['jobs']['associatedFiles'] as $sha512) { $short_sha = substr($sha512, 0, 6); $fileregistry_error = 0; // check if the files is registered in database if (!array_key_exists($short_sha, $files_mapping)) { $fileregistry_error |= self::REGISTRY_NO_DB_ENTRY; } if (!$o_file->checkPresenceManifest($sha512)) { $fileregistry_error |= self::REGISTRY_NO_MANIFEST; } // get database entries if (!$fileregistry_error) { $file_id = $files_mapping[$short_sha]; // get file's name $file_name = $files[$file_id]['name']; // get file's size $file_size = $files[$file_id]['filesize']; //mimetype icon if (isset($files[$file_id]['mimetype'])) { $file_mimetype = str_replace('/', '__', $files[$file_id]['mimetype']); } else { $file_mimetype = NULL; } } else { // get file's name from what has been saved in json $file_name = $datas['associatedFiles'][$sha512]['name']; $file_size = NULL; $file_mimetype = NULL; } $file_uncompress = $datas['associatedFiles'][$sha512]['uncompress']; $file_p2p = $datas['associatedFiles'][$sha512]['p2p']; $file_p2p_retention_duration = $datas['associatedFiles'][$sha512]['p2p-retention-duration']; // start new line $pics_path = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/"; echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2); if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='control'>"; Html::showCheckbox(array('name' => 'file_entries[]', 'value' => 0)); echo "</td>"; } echo "<td class='filename'>"; if (!empty($file_mimetype) && file_exists(GLPI_ROOT . "/plugins/fusioninventory/pics/ext/extensions/{$file_mimetype}.png")) { echo "<img src='" . $pics_path . "ext/extensions/{$file_mimetype}.png' />"; } else { echo "<img src='" . $pics_path . "ext/extensions/documents.png' />"; } //filename echo " " . "<a class='edit' " . " onclick=\"edit_subtype(" . " 'file', {$order->fields['id']}, {$rand}, this " . " )\"" . ">{$file_name}</a>"; //p2p icon if (isset($file_p2p) && $file_p2p != 0) { echo "<a title='" . __('p2p', 'fusioninventory') . ", " . __("retention", 'fusioninventory') . " : " . $file_p2p_retention_duration . " " . __("days", 'fusioninventory') . "' class='more'>"; echo "<img src='" . $pics_path . "p2p.png' />"; echo "<sup>" . $file_p2p_retention_duration . "</sup>"; echo "</a>"; } //uncompress icon if (isset($file_uncompress) && $file_uncompress != 0) { echo "<a title='" . __('uncompress', 'fusioninventory') . "' class='more'><img src='" . $pics_path . "uncompress.png' /></a>"; } //sha fingerprint $sha_status = "good"; if ($fileregistry_error != 0) { $sha_status = "bad"; } echo "<div class='fingerprint'>"; echo "<div class='fingerprint_" . $sha_status . "'>" . $sha512; if ($fileregistry_error & self::REGISTRY_NO_DB_ENTRY) { echo "<div class='fingerprint_badmsg'>" . __("This file is not correctly registered in database.") . "<br/>" . __("You can fix it by uploading or selecting the good one."); echo "</div>"; } if ($fileregistry_error & self::REGISTRY_NO_MANIFEST) { echo "<div class='fingerprint_badmsg'>" . __("This file doesn't have any manifest file associated.") . "<br/>" . __("You must upload the file."); echo "</div>"; } echo "</div>"; echo "</div>"; //filesize if (!$fileregistry_error) { echo "<div class='size'>"; echo __('Size') . ": " . self::processFilesize($file_size); echo "</div>"; } echo "</td>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>"; } $i++; } if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<tr><th>"; Html::checkAllAsCheckbox("filesList{$rand}", mt_rand()); echo "</th><th colspan='3' class='mark'></th></tr>"; } echo "</table>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>"; echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>"; } }
static function showMinimalList($params = array()) { global $DB, $CFG_GLPI; $item = new self(); $itemtype = $item->getType(); $itemtable = $item->getTable(); // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['id'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['withtemplate'] = 0; foreach ($params as $key => $val) { $p[$key] = $val; } $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->getFromDB($p['id']); $canedit = $PluginResourcesResource->can($p['id'], 'w'); if (isset($_POST["start"])) { $p['start'] = $_POST["start"]; } else { $p['start'] = 0; } if (isset($_POST["sort"])) { $p['sort'] = $_POST["sort"]; } else { $p['sort'] = 1; } if (isset($_POST["order"]) && $_POST["order"] == "DESC") { $p['order'] = "DESC"; } else { $p['order'] = "ASC"; } // Manage defautll seachtype value : for bookmark compatibility if (count($p['contains'])) { foreach ($p['contains'] as $key => $val) { if (!isset($p['searchtype'][$key])) { $p['searchtype'][$key] = 'contains'; } } } if (is_array($p['contains2']) && count($p['contains2'])) { foreach ($p['contains2'] as $key => $val) { if (!isset($p['searchtype2'][$key])) { $p['searchtype2'][$key] = 'contains'; } } } $target = Toolbox::getItemTypeSearchURL($itemtype); $limitsearchopt = Search::getCleanedOptions($itemtype); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $entity_restrict = $item->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView($itemtype); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID()); if (count($displaypref)) { foreach ($displaypref as $val) { array_push($toview, $val); } } // Add searched items if (count($p['field']) > 0) { foreach ($p['field'] as $key => $val) { if (!in_array($val, $toview) && $val != 'all' && $val != 'view') { array_push($toview, $val); } } } // Add order item if (!in_array($p['sort'], $toview)) { array_push($toview, $p['sort']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect($itemtype); // Add select for all toview item foreach ($toview as $key => $val) { $query .= Search::addSelect($itemtype, $val, $key, 0); } $query .= "`" . $itemtable . "`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " FROM `" . $itemtable . "`"; // Init already linked tables array in order not to link a table several times $already_link_tables = array(); // Put reference table array_push($already_link_tables, $itemtable); // Add default join $COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt[$itemtype] =& Search::getOptions($itemtype); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]); } // Search all case : if (in_array("all", $p['field'])) { foreach ($searchopt[$itemtype] as $key => $val) { // Do not search on Group Name if (is_array($val)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]); } } } $query .= " WHERE `" . $itemtable . "`.`plugin_resources_resources_id` = '" . $p['id'] . "'"; $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' "; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (in_array('all', $p['field'])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } if (empty($GROUPBY)) { foreach ($toview as $key2 => $val2) { if (!empty($GROUPBY)) { break; } if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $item->getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) { echo "<div align='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=13&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>"; echo "</div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; if ($item->canCreate() && $canedit) { $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\""; $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config .= $tmp . ">"; } //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']); } // Pager if ($output_type == Search::HTML_OUTPUT) { Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows, $search_config); echo "<br>"; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { Html::openMassiveActionsForm('massform' . $itemtype); $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => true, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions($itemtype, $massiveactionparams); } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols, 1); $header_num = 1; // Display column Headers for toview items $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; echo Search::showNewLine($output_type); if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) { // HTML display - massive modif $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); } // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers $headers_line .= Search::showEndLine($output_type); $headers_line_top .= $headers_line; $headers_line_bottom .= $headers_line; echo $headers_line_top; $DB->data_seek($result, $p['start']); // Define begin and end var for loop // Search case $i = $begin_display; // Init list of items displayed if ($output_type == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype, PluginResourcesResource::getTypeName(2) . " = " . (empty($PluginResourcesResource->fields['name']) ? "(" . $p['id'] . ")" : $PluginResourcesResource->fields['name'])); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); $tmpcheck = ""; if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $sel = ""; $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; } echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'"); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= __('Tasks list', 'resources'); } // Display footer echo Search::showFooter($output_type, $title); //massive action if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($itemtype, $massiveactionparams); Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows); } } else { echo Search::showError($output_type); } } }
/** * Display a line for a ticket * * @param $id Integer ID of the ticket * @param $followups Boolean show followup columns * @param $output_type Integer type of output (default Search::HTML_OUTPUT) * @param $row_num Integer row number (default 0) * @param $id_for_massaction Integer default 0 means no massive action (default 0) * */ static function showShort($id, $followups, $output_type = Search::HTML_OUTPUT, $row_num = 0, $id_for_massaction = 0) { global $CFG_GLPI; $rand = mt_rand(); /// TODO to be cleaned. Get datas and clean display links // Prints a job in short form // Should be called in a <table>-segment // Print links or not in case of user view // Make new job object and fill it from database, if success, print it $job = new self(); $candelete = Session::haveRight("delete_ticket", "1"); $canupdate = Session::haveRight("update_ticket", "1"); $showprivate = Session::haveRight("show_full_ticket", "1"); $align = "class='center"; $align_desc = "class='left"; if ($followups) { $align .= " top'"; $align_desc .= " top'"; } else { $align .= "'"; $align_desc .= "'"; } if ($job->getFromDB($id)) { $item_num = 1; $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]]; echo Search::showNewLine($output_type, $row_num % 2); $check_col = ''; if (($candelete || $canupdate) && $output_type == Search::HTML_OUTPUT && $id_for_massaction) { $check_col = Html::getMassiveActionCheckBox(__CLASS__, $id_for_massaction); } echo Search::showItem($output_type, $check_col, $item_num, $row_num, $align); // First column $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $job->fields["id"]); if ($output_type == Search::HTML_OUTPUT) { $first_col .= "<br><img src='" . self::getStatusIconURL($job->fields["status"]) . "'\n alt=\"" . self::getStatus($job->fields["status"]) . "\" title=\"" . self::getStatus($job->fields["status"]) . "\">"; } else { $first_col = sprintf(__('%1$s - %2$s'), $first_col, self::getStatus($job->fields["status"])); } echo Search::showItem($output_type, $first_col, $item_num, $row_num, $align); // Second column if ($job->fields['status'] == self::CLOSED) { $second_col = sprintf(__('Closed on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['closedate'])); } else { if ($job->fields['status'] == self::SOLVED) { $second_col = sprintf(__('Solved on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['solvedate'])); } else { if ($job->fields['begin_waiting_date']) { $second_col = sprintf(__('Put on hold on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['begin_waiting_date'])); } else { if ($job->fields['due_date']) { $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['due_date'])); } else { $second_col = sprintf(__('Opened on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['date'])); } } } } echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=130"); // Second BIS column $second_col = Html::convDateTime($job->fields["date_mod"]); echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=90"); // Second TER column if (count($_SESSION["glpiactiveentities"]) > 1) { $second_col = Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']); echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=100"); } // Third Column echo Search::showItem($output_type, "<span class='b'>" . parent::getPriorityName($job->fields["priority"]) . "</span>", $item_num, $row_num, "{$align} bgcolor='{$bgcolor}'"); // Fourth Column $fourth_col = ""; if (isset($job->users[CommonITILActor::REQUESTER]) && count($job->users[CommonITILActor::REQUESTER])) { foreach ($job->users[CommonITILActor::REQUESTER] as $d) { $userdata = getUserName($d["users_id"], 2); $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false))); $fourth_col .= "<br>"; } } if (isset($job->groups[CommonITILActor::REQUESTER]) && count($job->groups[CommonITILActor::REQUESTER])) { foreach ($job->groups[CommonITILActor::REQUESTER] as $d) { $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]); $fourth_col .= "<br>"; } } echo Search::showItem($output_type, $fourth_col, $item_num, $row_num, $align); // Fifth column $fifth_col = ""; if (isset($job->users[CommonITILActor::ASSIGN]) && count($job->users[CommonITILActor::ASSIGN])) { foreach ($job->users[CommonITILActor::ASSIGN] as $d) { $userdata = getUserName($d["users_id"], 2); $fifth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false))); $fifth_col .= "<br>"; } } if (isset($job->groups[CommonITILActor::ASSIGN]) && count($job->groups[CommonITILActor::ASSIGN])) { foreach ($job->groups[CommonITILActor::ASSIGN] as $d) { $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]); $fifth_col .= "<br>"; } } if (isset($job->suppliers[CommonITILActor::ASSIGN]) && count($job->suppliers[CommonITILActor::ASSIGN])) { foreach ($job->suppliers[CommonITILActor::ASSIGN] as $d) { $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]); $fifth_col .= "<br>"; } } echo Search::showItem($output_type, $fifth_col, $item_num, $row_num, $align); // Sixth Colum $sixth_col = ""; $is_deleted = false; if (!empty($job->fields["itemtype"]) && $job->fields["items_id"] > 0) { if ($item = getItemForItemtype($job->fields["itemtype"])) { if ($item->getFromDB($job->fields["items_id"])) { $is_deleted = $item->isDeleted(); $sixth_col .= $item->getTypeName(); $sixth_col .= "<br><span class='b'>"; if ($item->canView()) { $sixth_col .= $item->getLink(array('linkoption' => $output_type == Search::HTML_OUTPUT)); } else { $sixth_col .= $item->getNameID(); } $sixth_col .= "</span>"; } } } else { if (empty($job->fields["itemtype"])) { $sixth_col = __('General'); } } echo Search::showItem($output_type, $sixth_col, $item_num, $row_num, $is_deleted ? " class='center deleted' " : $align); // Seventh column echo Search::showItem($output_type, "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $job->fields["itilcategories_id"]) . "</span>", $item_num, $row_num, $align); // Eigth column $eigth_column = "<span class='b'>" . $job->fields["name"] . "</span> "; // Add link if ($job->canViewItem()) { $eigth_column = "<a id='ticket" . $job->fields["id"] . "{$rand}' href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $job->fields["id"] . "\">{$eigth_column}</a>"; if ($followups && $output_type == Search::HTML_OUTPUT) { $eigth_column .= TicketFollowup::showShortForTicket($job->fields["id"]); } else { $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, sprintf(__('%1$s - %2$s'), $job->numberOfFollowups($showprivate), $job->numberOfTasks($showprivate))); } } if ($output_type == Search::HTML_OUTPUT) { $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip($job->fields['content'], array('display' => false, 'applyto' => "ticket" . $job->fields["id"] . $rand))); } echo Search::showItem($output_type, $eigth_column, $item_num, $row_num, $align_desc . "width='300'"); // Finish Line echo Search::showEndLine($output_type); } else { echo "<tr class='tab_bg_2'>"; echo "<td colspan='6' ><i>" . __('No ticket in progress.') . "</i></td></tr>"; } }
function showMinimalList($params) { global $DB, $CFG_GLPI; $itemtype = "PluginResourcesDirectory"; $itemtable = $this->table; if (class_exists($itemtype)) { $item = new $itemtype(); } // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['id'] = 0; $p['withtemplate'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; foreach ($params as $key => $val) { $p[$key] = $val; } if ($p['export_all']) { $p['start'] = 0; } $PluginResourcesResource = new PluginResourcesResource(); $canedit = $PluginResourcesResource->can($p['id'], 'w'); // Manage defautlt seachtype value : for bookmark compatibility if (count($p['contains'])) { foreach ($p['contains'] as $key => $val) { if (!isset($p['searchtype'][$key])) { $p['searchtype'][$key] = 'contains'; } } } if (is_array($p['contains2']) && count($p['contains2'])) { foreach ($p['contains2'] as $key => $val) { if (!isset($p['searchtype2'][$key])) { $p['searchtype2'][$key] = 'contains'; } } } $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/directory.php"; $limitsearchopt = Search::getCleanedOptions("PluginResourcesDirectory"); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $entity_restrict = $PluginResourcesResource->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView("User"); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser("PluginResourcesDirectory", Session::getLoginUserID()); if (count($displaypref)) { foreach ($displaypref as $val) { array_push($toview, $val); } } // Add searched items if (count($p['field']) > 0) { foreach ($p['field'] as $key => $val) { if (!in_array($val, $toview) && $val != 'all' && $val != 'view') { array_push($toview, $val); } } } // Add order item if (!in_array($p['sort'], $toview)) { array_push($toview, $p['sort']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect("User"); // Add select for all toview item foreach ($toview as $key => $val) { $query .= self::addSelect("PluginResourcesDirectory", $val, $key, 0); } $query .= "`glpi_plugin_resources_resources`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " FROM `" . $itemtable . "`"; // Init already linked tables array in order not to link a table several times $already_link_tables = array(); // Put reference table array_push($already_link_tables, $itemtable); // Add default join $COMMONLEFTJOIN = Search::addDefaultJoin("PluginResourcesDirectory", $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt["PluginResourcesDirectory"] =& Search::getOptions("PluginResourcesDirectory"); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt["PluginResourcesDirectory"][$val]["table"], $searchopt["PluginResourcesDirectory"][$val]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$val]["joinparams"]); } // Search all case : if (in_array("all", $p['field'])) { foreach ($searchopt[$itemtype] as $key => $val) { // Do not search on Group Name if (is_array($val)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt["PluginResourcesDirectory"][$key]["table"], $searchopt["PluginResourcesDirectory"][$key]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$key]["joinparams"]); } } } $ASSIGN = " `glpi_plugin_resources_resources`.`is_leaving` = 0 AND `glpi_users`.`is_active` = 1 AND "; //// 3 - WHERE // default string $COMMONWHERE = Search::addDefaultWhere($itemtype); $first = empty($COMMONWHERE); // Add deleted if item have it if ($PluginResourcesResource && $PluginResourcesResource->maybeDeleted()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_deleted` = '" . $p['is_deleted'] . "' "; } // Remove template items if ($PluginResourcesResource && $PluginResourcesResource->maybeTemplate()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_template` = '0' "; } // Add Restrict to current entities if ($entity_restrict) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } if (isset($CFG_GLPI["union_search_type"][$itemtype])) { // Will be replace below in Union/Recursivity Hack $COMMONWHERE .= $LINK . " ENTITYRESTRICT "; } else { $COMMONWHERE .= getEntitiesRestrictRequest($LINK, "glpi_plugin_resources_resources", '', '', $PluginResourcesResource->maybeRecursive()); } } $WHERE = ""; $HAVING = ""; // Add search conditions // If there is search items if ($_SESSION["glpisearchcount"]["PluginResourcesDirectory"] > 0 && count($p['contains']) > 0) { for ($key = 0; $key < $_SESSION["glpisearchcount"]["PluginResourcesDirectory"]; $key++) { // if real search (strlen >0) and not all and view search if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) { // common search if ($p['field'][$key] != "all" && $p['field'][$key] != "view") { $LINK = " "; $NOT = 0; $tmplink = ""; if (is_array($p['link']) && isset($p['link'][$key])) { if (strstr($p['link'][$key], "NOT")) { $tmplink = " " . str_replace(" NOT", "", $p['link'][$key]); $NOT = 1; } else { $tmplink = " " . $p['link'][$key]; } } else { $tmplink = " AND "; } if (isset($searchopt["PluginResourcesDirectory"][$p['field'][$key]]["usehaving"])) { // Manage Link if not first item if (!empty($HAVING)) { $LINK = $tmplink; } // Find key $item_num = array_search($p['field'][$key], $toview); $HAVING .= Search::addHaving($LINK, $NOT, "PluginResourcesDirectory", $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num); } else { // Manage Link if not first item if (!empty($WHERE)) { $LINK = $tmplink; } $WHERE .= self::addWhere($LINK, $NOT, "PluginResourcesDirectory", $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]); } // view and all search } else { $LINK = " OR "; $NOT = 0; $globallink = " AND "; if (is_array($p['link']) && isset($p['link'][$key])) { switch ($p['link'][$key]) { case "AND": $LINK = " OR "; $globallink = " AND "; break; case "AND NOT": $LINK = " AND "; $NOT = 1; $globallink = " AND "; break; case "OR": $LINK = " OR "; $globallink = " OR "; break; case "OR NOT": $LINK = " AND "; $NOT = 1; $globallink = " OR "; break; } } else { $tmplink = " AND "; } // Manage Link if not first item if (!empty($WHERE)) { $WHERE .= $globallink; } $WHERE .= " ( "; $first2 = true; $items = array(); if ($p['field'][$key] == "all") { $items = $searchopt["PluginResourcesDirectory"]; } else { // toview case : populate toview foreach ($toview as $key2 => $val2) { $items[$val2] = $searchopt["PluginResourcesDirectory"][$val2]; } } foreach ($items as $key2 => $val2) { if (is_array($val2)) { // Add Where clause if not to be done in HAVING CLAUSE if (!isset($val2["usehaving"])) { $tmplink = $LINK; if ($first2) { $tmplink = " "; $first2 = false; } $WHERE .= self::addWhere($tmplink, $NOT, "PluginResourcesDirectory", $key2, $p['searchtype'][$key], $p['contains'][$key]); } } } $WHERE .= " ) "; } } } } if (!empty($WHERE) || !empty($COMMONWHERE)) { if (!empty($COMMONWHERE)) { $WHERE = ' WHERE ' . $ASSIGN . ' ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : ''); } else { $WHERE = ' WHERE ' . $ASSIGN . ' ' . $WHERE . ' '; } $first = false; } $query .= $WHERE; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (in_array('all', $p['field'])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } if (empty($GROUPBY)) { foreach ($toview as $key2 => $val2) { if (!empty($GROUPBY)) { break; } if (isset($searchopt["PluginResourcesDirectory"][$val2]["forcegroupby"])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("searchtype", $p['searchtype']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("searchtype2", $p['searchtype2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $this->getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { // Pager if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; if ($item->canCreate() && $canedit) { $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\""; $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config .= $tmp . ">"; } //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']); } // Pager if ($output_type == Search::HTML_OUTPUT) { Html::printPager($p['start'], $numrows, $target, $parameters, $itemtype, 0, $search_config); echo "<br>"; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { Html::openMassiveActionsForm('massform' . $itemtype); $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => false, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions("PluginResourcesDirectory", $massiveactionparams); } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols); $header_num = 1; // Display column Headers for toview items $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; echo Search::showNewLine($output_type); if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) { // HTML display - massive modif $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); } // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt["PluginResourcesDirectory"][$val]['nosort']) || !$searchopt["PluginResourcesDirectory"][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt["PluginResourcesDirectory"][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers $headers_line .= Search::showEndLine($output_type); $headers_line_top .= $headers_line; $headers_line_bottom .= $headers_line; echo $headers_line_top; $DB->data_seek($result, $p['start']); // Define begin and end var for loop // Search case $i = $begin_display; // Init list of items displayed if ($output_type == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); $tmpcheck = ""; if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $sel = ""; $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'"); } foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem("PluginResourcesDirectory", $val, $data, $key), $item_num, $row_num, Search::displayConfigItem("PluginResourcesDirectory", $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= self::getTypeName(1); } // Display footer echo Search::showFooter($output_type, $title); //massive action if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $massiveactionparams['ontop'] = false; $massiveactionparams['fixed'] = false; Html::showMassiveActions("PluginResourcesDirectory", $massiveactionparams); Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printPager($p['start'], $numrows, $target, $parameters, "PluginResourcesDirectory", 0, $search_config); } } else { echo Search::showError($output_type); } } }
/** * Print out list kb item * * @param $options $_GET * @param $type string search type : browse / search (default search) **/ static function showList($options, $type = 'search') { global $DB, $CFG_GLPI; // Default values of parameters $params['faq'] = !Session::haveRight("knowbase", "r"); $params["start"] = "0"; $params["knowbaseitemcategories_id"] = "0"; $params["contains"] = ""; $params["target"] = $_SERVER['PHP_SELF']; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $ki = new self(); switch ($type) { case 'myunpublished': if (!Session::haveRight('knowbase', 'w') && !Session::haveRight('faq', 'w')) { return false; } break; case 'allunpublished': if (!Session::haveRight('knowbase_admin', 1)) { return false; } break; default: break; } if (!$params["start"]) { $params["start"] = 0; } $query = self::getListRequest($params, $type); // Get it from database if ($result = $DB->query($query)) { $KbCategory = new KnowbaseItemCategory(); $title = ""; if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) { $title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name']; $title = sprintf(__('%1$s: %2$s'), __('Category'), $title); } Session::initNavigateListItems('KnowbaseItem', $title); $numrows = $DB->numrows($result); $list_limit = $_SESSION['glpilist_limit']; $showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy')); // Limit the result, if no limit applies, use prior result if ($numrows > $list_limit && !isset($_GET['export_all'])) { $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " "; $result_limit = $DB->query($query_limit); $numrows_limit = $DB->numrows($result_limit); } else { $numrows_limit = $numrows; $result_limit = $result; } if ($numrows_limit > 0) { // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } // Pager $parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq=" . $params['faq']; if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $parameters .= "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype']; } if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } $nbcols = 1; // Display List Header echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols); $header_num = 1; echo Search::showHeaderItem($output_type, __('Subject'), $header_num); if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Content'), $header_num); } if ($showwriter) { echo Search::showHeaderItem($output_type, __('Writer'), $header_num); } echo Search::showHeaderItem($output_type, __('Category'), $header_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, ' ', $header_num); } // Num of the row (1=header_line) $row_num = 1; for ($i = 0; $i < $numrows_limit; $i++) { $data = $DB->fetch_assoc($result_limit); Session::addToNavigateListItems('KnowbaseItem', $data["id"]); // Column num $item_num = 1; $row_num++; echo Search::showNewLine($output_type, $i % 2); if ($output_type == Search::HTML_OUTPUT) { if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $href = " href='#' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=show_kb&id=" . $data['id'] . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' );" . "w.focus();\""; } else { $href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" "; } echo Search::showItem($output_type, "<div class='kb'><a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($data["name"], 80) . "</a></div>\n <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($data["answer"])), 600) . "</div>", $item_num, $row_num); } else { echo Search::showItem($output_type, $data["name"], $item_num, $row_num); echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($data["answer"], ENT_QUOTES, "UTF-8"))), $item_num, $row_num); } if ($showwriter) { echo Search::showItem($output_type, getUserName($data["users_id"], 1), $item_num, $row_num); } $categ = $data["category"]; if ($output_type == Search::HTML_OUTPUT) { $cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&forcetab=Knowbase$2'; $categ = "<a href='{$cathref}'>" . $categ . '</a>'; } echo Search::showItem($output_type, $categ, $item_num, $row_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { $content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&id=" . $options['item_items_id'] . "&forcetab=" . $options['item_itemtype'] . "\$2'>" . __('Use as a solution') . "</a>"; echo Search::showItem($output_type, $content, $item_num, $row_num); } // End Line echo Search::showEndLine($output_type); } // Display footer if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id'])); } else { echo Search::showFooter($output_type); } echo "<br>"; if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } } else { echo "<div class='center b'>" . __('No item found') . "</div>"; } } }
static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand) { global $CFG_GLPI; $pfDeployPackage = new PluginFusioninventoryDeployPackage(); $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']); $checks_types = self::getTypes(); echo "<table class='tab_cadrehov package_item_list' id='table_check_{$rand}'>"; $i = 0; foreach ($datas['jobs']['checks'] as $check) { //specific case for filesystem size if (is_numeric($check['value'])) { if ($check['type'] == "freespaceGreater") { $check['value'] = $check['value'] * 1024 * 1024; } $check['value'] = PluginFusioninventoryDeployFile::processFilesize($check['value']); } echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2); if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='control'>"; echo "<input type='checkbox' name='check_entries[]' value='{$i}' />"; echo "</td>"; } echo "<td>"; echo "<a class='edit'" . "onclick=\"edit_subtype('check', {$order->fields['id']}, {$rand} ,this)\">" . $checks_types[$check['type']] . "</a><br />"; echo $check['path']; if (!empty($check['value'])) { echo " <b>"; if (strpos($check['type'], "Greater") !== FALSE) { echo ">"; } else { if (strpos($check['type'], "Lower") !== FALSE) { echo "<"; } else { echo "="; } } echo "</b> "; echo $check['value']; } echo "</td>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>"; } echo "</tr>"; $i++; } if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<tr><th>"; Html::checkAllAsCheckbox("checksList{$rand}", mt_rand()); echo "</th><th colspan='3' class='mark'></th></tr>"; } echo "</table>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt='' />"; echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit' />"; } }
public function showResult($output_type, $limit = 0, $params = array()) { global $DB; $arrayRet = $this->execQuery($_REQUEST); $result = $arrayRet['query_result']; $query = $arrayRet['query']; $nbtot = $result ? $DB->numrows($result) : 0; if ($limit) { $start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $result = $DB->query($query . " LIMIT {$start},{$limit}"); } } else { $start = 0; } $nbCols = $DB->num_fields($result); $nbrows = $DB->numrows($result); $groupByRackName = true; if (isset($_REQUEST['groupByRackName']) && $_REQUEST['groupByRackName'] == "on") { $groupByRackName = false; } $title = date("d/m/Y H:i"); if ($nbtot == 0) { echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>"; Html::footer(); } else { if ($output_type == Search::HTML_OUTPUT) { echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>{$title}</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; $parameters = null; $parameters .= Toolbox::append_params($_REQUEST, '&'); $this->printPager($start, $nbtot, $_SERVER["PHP_SELF"], $parameters, 'PluginRacksRack'); } } if ($nbtot > 0) { if ($output_type == Search::HTML_OUTPUT) { echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; } echo Search::showHeader($output_type, $nbrows, $nbCols, true); echo Search::showNewLine($output_type); $showAllFieds = true; $listFields = array(); $cptField = 0; $showAllFieds = (!isset($_REQUEST['cb_object_name']) || $_REQUEST['cb_object_name'] != "on") && (!isset($_REQUEST['cb_object_location']) || $_REQUEST['cb_object_location'] != "on") && (!isset($_REQUEST['cb_group']) || $_REQUEST['cb_group'] != "on") && (!isset($_REQUEST['cb_manufacturer']) || $_REQUEST['cb_manufacturer'] != "on") && (!isset($_REQUEST['cb_model']) || $_REQUEST['cb_model'] != "on") && (!isset($_REQUEST['cb_serial_number']) || $_REQUEST['cb_serial_number'] != "on"); $num = 1; $cptRow = 1; if (!$showAllFieds) { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false, $params); $cptField++; $this->showTitle($output_type, $num, __("Location"), 'location', false, $params); $cptField++; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params); $cptField++; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params); $cptField++; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params); $cptField++; if (isset($_REQUEST['cb_object_name']) && $_REQUEST['cb_object_name'] == "on") { $listFields['object_name'] = $_REQUEST['cb_object_name']; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params); $cptField++; } // Lieu if (isset($_REQUEST['cb_object_location']) && $_REQUEST['cb_object_location'] == "on") { $listFields['object_location'] = $_REQUEST['cb_object_location']; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params); $cptField++; } // Groupe if (isset($_REQUEST['cb_group']) && $_REQUEST['cb_group'] == "on") { $listFields['group'] = $_REQUEST['cb_group']; $this->showTitle($output_type, $num, __("Group"), 'group', false, $params); $cptField++; } // Fabricant if (isset($_REQUEST['cb_manufacturer']) && $_REQUEST['cb_manufacturer'] == "on") { $listFields['manufacturer'] = $_REQUEST['cb_manufacturer']; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params); $cptField++; } // Modèle if (isset($_REQUEST['cb_model']) && $_REQUEST['cb_model'] == "on") { $listFields['model'] = $_REQUEST['cb_model']; $this->showTitle($output_type, $num, __("Model"), 'model', false, $params); $cptField++; } // Numéro de série if (isset($_REQUEST['cb_serial_number']) && $_REQUEST['cb_serial_number'] == "on") { $listFields['serial_number'] = $_REQUEST['cb_serial_number']; $this->showTitle($output_type, $num, __("Serial number"), 'group', false, $params); $cptField++; } } else { $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false, $params); $listFields['rack_name'] = true; $this->showTitle($output_type, $num, __("Location"), 'location', false, $params); $listFields['location'] = true; $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params); $listFields['roomlocation'] = true; $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params); $listFields['u'] = true; $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params); $listFields['front_rear'] = true; $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params); $listFields['object_name'] = true; $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params); $listFields['object_location'] = true; $this->showTitle($output_type, $num, __("Group"), 'group', false, $params); $listFields['group'] = true; $this->showTitle($output_type, $num, __("Type"), 'type', false, $params); $listFields['type'] = true; $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params); $listFields['manufacturer'] = true; $this->showTitle($output_type, $num, __("Model"), 'model', false, $params); $listFields['model'] = true; $this->showTitle($output_type, $num, __("Serial number"), 'serial_number', false, $params); $listFields['serial_number'] = true; $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false, $params); $listFields['other_serial'] = true; $cptField = 13; } echo self::showEndLine($output_type, $params); $num = 1; $cptRow = 1; $currentRack = -1; while ($row = $DB->fetch_array($result)) { // itemtype $itemtype = $row['itemtype']; $num = 1; $cptRow++; echo Search::showNewLine($output_type); if (isset($row['itemtype']) && $row['itemtype'] != "") { $class = substr($itemtype, 0, -5); $item = new $class(); $table = getTableForItemType($class); $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' "); $device = $DB->fetch_array($r); } // nom $link = Toolbox::getItemTypeFormURL("PluginRacksRack"); if ($groupByRackName || $currentRack != $row['id']) { if ($output_type == Search::HTML_OUTPUT) { echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow, null, $params); } else { echo self::showItem($output_type, $row["name"], $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // lieu if ($groupByRackName || $currentRack != $row['id']) { if (isset($row['locations_id'])) { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $row['locations_id']), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // Emplacement if ($groupByRackName || $currentRack != $row['id']) { $tmpId = $row['plugin_racks_roomlocations_id']; $tmpId = $row['plugin_racks_roomlocations_id']; $tmpObj = new PluginRacksRoomLocation(); $trans_name = ""; if ($tmpObj->getFromDB($tmpId)) { $trans_name = $tmpObj->fields['name']; } $trans = DropdownTranslation::getTranslatedValue($tmpId, "PluginRacksRoomLocation", 'name', $_SESSION['glpilanguage']); if (!empty($trans)) { $trans_name = $trans; } if (isset($tmpId)) { echo self::showItem($output_type, $trans_name, $num, $cptRow, null, $params); } else { echo self::showItem($output_type, ' ', $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } if (isset($row['itemtype']) && $row['itemtype'] != "") { // U if (isset($row['position']) && $row['position'] != "") { echo self::showItem($output_type, $row['position'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } // avant / arrière if ($row['faces_id'] == 1) { echo self::showItem($output_type, __("Front", "racks"), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, _x('Rack enclosure', 'Back', 'racks'), $num, $cptRow, null, $params); } // Nom de l'objet if (array_key_exists("object_name", $listFields)) { $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5)); if ($itemtype != 'PluginRacksOtherModel') { if ($output_type == Search::HTML_OUTPUT) { echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow, null, $params); } else { echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params); } } else { echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params); } } // Lieu de l'objet if (array_key_exists("object_location", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // Groupe if (array_key_exists("group", $listFields)) { // Groupe if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // type if (array_key_exists("type", $listFields)) { echo self::showItem($output_type, $item->getTypeName(), $num, $cptRow, null, $params); } // fabricant if (array_key_exists("manufacturer", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // modèle if (array_key_exists("model", $listFields)) { $model_table = getTableForItemType($itemtype); $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype)); echo self::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow, null, $params); } // numéro de série if (array_key_exists("serial_number", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, $device['serial'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } // numéro d'inventaire if (array_key_exists("other_serial", $listFields)) { if ($itemtype != 'PluginRacksOtherModel') { echo self::showItem($output_type, $device['otherserial'], $num, $cptRow, null, $params); } else { echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params); } } $currentRack = $row['id']; } else { for ($k = 0; $k < $cptField - 3; $k++) { echo self::showItem($output_type, " ", $num, $cptRow, null, $params); } } echo self::showEndLine($output_type, $params); } echo self::showFooter($output_type, $title, $params); if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } } }
function displayList($tasks_id) { global $CFG_GLPI; $rand = mt_rand(); echo "<script type=\"text/javascript\">\nfunction edit_subtype(id,el) {\n\n //remove all border to previous selected item (remove classes)\n// Ext.select('#table_taskjob_'+ _rand +' tr').removeClass('selected');\n\n\n var row = null;\n if (el) {\n // get parent row of the selected element\n row = jQuery(el).parents('tr:first')\n }\n\n if (row) {\n //add border to selected index (add class)\n row.addClass('selected');\n// params['index'] = row.index();\n // change mode to edit\n// params['mode'] = 'edit';\n arg = 'taskjobs_id=' + id;\n } else {\n arg = 'tasks_id=' + id;\n }\n\n //scroll to edit form\n// document.getElementById('th_title_taskjob_' + _rand).scrollIntoView();\n\n //show and load form\n// \$('taskjobs_block' + _rand).setDisplayed('block');\n \$('#taskjobs_block').load('../ajax/taskjob_form.php?' + arg);\n}\n\n/*\n * Create a new subtype element.\n * This method just override *edit_subtype* with a null element.\n */\nfunction new_subtype(id) {\n edit_subtype(id, null);\n}\n</script>"; echo "<table class='tab_cadre_fixe' id='package_order_" . $tasks_id . "'>"; echo "<tr>"; echo "<th id='th_title_taskjob_{$rand}'>"; //echo "<img src='".$CFG_GLPI["root_doc"]."/plugins/fusioninventory/pics/$subtype.png' />"; echo " " . $this->getTypeName(); echo " "; echo "<img id='plus_taskjobs_block{$rand}'"; echo " onclick=\"new_subtype({$tasks_id})\" "; echo " title='" . __('Add') . "' alt='" . __('Add') . "' "; echo " class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' /> "; echo "</th>"; echo "</tr>"; echo "<tr>"; echo "<td style='vertical-align:top'>"; /** * Display subtype form **/ echo "<form name='additiontaskjob' method='post' " . " action='taskjob.form.php'>"; echo "<input type='hidden' name='orders_id' value='{$tasks_id}' />"; echo "<input type='hidden' name='itemtype' value='PluginFusioninventoryDeploy" . ucfirst('taskjob') . "' />"; echo "<div id='taskjobs_block'></div>"; Html::closeForm(); $a_taskjobs = getAllDatasFromTable($this->getTable(), "`plugin_fusioninventory_tasks_id`='" . $tasks_id . "'", FALSE, '`ranking`'); echo "<div id='drag_taskjob_taskjobs'>"; echo "<table class='tab_cadrehov package_item_list' id='table_taskjob_{$rand}' style='width: 950px'>"; $i = 0; foreach ($a_taskjobs as $data) { echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2); echo "<td class='control'>"; Html::showCheckbox(array('name' => 'taskjob_entries[]', 'value' => $i)); echo "</td>"; echo "<td>"; echo "<a class='edit' " . "onclick=\"edit_subtype({$data['id']}, this)\">"; echo $data['name']; echo "</a><br />"; echo "<b>"; echo __('Definition', 'fusioninventory'); echo "</b>"; echo "<ul class='retChecks'>"; $a_definitions = importArrayFromDB($data['definition']); foreach ($a_definitions as $a_definition) { foreach ($a_definition as $itemtype => $items_id) { echo "<li>"; $item = new $itemtype(); $item->getFromDB($items_id); echo $item->getTypeName() . " > "; echo $item->getLink(); echo "</li>"; } } echo "</ul>"; echo "<b>"; echo __('Action', 'fusioninventory'); echo "</b>"; echo "<ul class='retChecks'>"; $a_actions = importArrayFromDB($data['action']); foreach ($a_actions as $a_action) { foreach ($a_action as $itemtype => $items_id) { echo "<li>"; $item = new $itemtype(); $item->getFromDB($items_id); echo $item->getTypeName() . " > "; echo $item->getLink(); echo "</li>"; } } echo "</ul>"; echo "</td>"; echo "</td>"; echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>"; echo "</tr>"; $i++; } echo "<tr><th>"; Html::checkAllAsCheckbox("taskjobsList{$rand}", mt_rand()); echo "</th><th colspan='3' class='mark'></th></tr>"; echo "</table>"; echo "</div>"; echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>"; echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>"; /** * Initialize drag and drop on subtype lists **/ echo "<script type=\"text/javascript\">\n redipsInit('taskjob', 'taskjob', {$tasks_id});\n</script>"; echo "</table>"; }
/** * Prints display pre import * * @param $type the type of device * @param $configID the ID of the supplier config * @param $start for pager display * @param $complete to see all device (already imported and not) * @return nothing (print out a table) * */ static function seePreImport($params) { global $DB, $CFG_GLPI; // Default values of parameters $p['link'] = array(); $p['field'] = array(); $p['contains'] = array(); $p['searchtype'] = array(); $p['sort'] = '1'; $p['order'] = 'ASC'; $p['start'] = 0; $p['export_all'] = 0; $p['link2'] = ''; $p['contains2'] = ''; $p['field2'] = ''; $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['itemtype'] = ''; $p['manufacturers_id'] = ''; $p['imported'] = ''; foreach ($params as $key => $val) { $p[$key] = $val; } $globallinkto = self::getArrayUrlLink("field", $p['field']) . self::getArrayUrlLink("link", $p['link']) . self::getArrayUrlLink("contains", $p['contains']) . self::getArrayUrlLink("searchtype", $p['searchtype']) . self::getArrayUrlLink("field2", $p['field2']) . self::getArrayUrlLink("contains2", $p['contains2']) . self::getArrayUrlLink("searchtype2", $p['searchtype2']) . self::getArrayUrlLink("itemtype2", $p['itemtype2']) . self::getArrayUrlLink("link2", $p['link2']); $modeltable = ""; $target = $CFG_GLPI["root_doc"] . "/plugins/manufacturersimports/front/import.php"; if ($p['itemtype'] && $p['manufacturers_id']) { $config = new PluginManufacturersimportsConfig(); $config->getFromDB($p['manufacturers_id']); $suppliername = $config->fields["name"]; $supplierclass = "PluginManufacturersimports" . $suppliername; $supplier = new $supplierclass(); $infocom = new Infocom(); $canedit = Session::haveRight(static::$rightname, UPDATE) && $infocom->canUpdate(); if (!$p['start']) { $p['start'] = 0; } $modeltable = getTableForItemType($p['itemtype'] . "Model"); $modelfield = getForeignKeyFieldForTable(getTableForItemType($p['itemtype'] . "Model")); $item = new $p['itemtype'](); $itemtable = getTableForItemType($p['itemtype']); $query = "SELECT `" . $itemtable . "`.`id`,\n `" . $itemtable . "`.`name`, \n `" . $itemtable . "`.`serial`,\n `" . $itemtable . "`.`entities_id`,\n `glpi_plugin_manufacturersimports_logs`.`import_status`,\n `glpi_plugin_manufacturersimports_logs`.`items_id`,\n `glpi_plugin_manufacturersimports_logs`.`itemtype`, \n `glpi_plugin_manufacturersimports_logs`.`documents_id`,\n `glpi_plugin_manufacturersimports_logs`.`date_import`, \n '" . $p['itemtype'] . "' AS type,\n `{$modeltable}`.`name` AS model_name\n FROM `" . $itemtable . "` "; //model device left join $query .= "LEFT JOIN `{$modeltable}` ON (`{$modeltable}`.`id` = `" . $itemtable . "`.`" . $modelfield . "`) "; $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemtable . "`.`entities_id`)"; $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_configs` \n ON (`glpi_plugin_manufacturersimports_configs`.`manufacturers_id` = `" . $itemtable . "`.`manufacturers_id`)"; $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_logs` \n ON (`glpi_plugin_manufacturersimports_logs`.`items_id` = `" . $itemtable . "`.`id` \n AND `glpi_plugin_manufacturersimports_logs`.`itemtype` = '" . $p['itemtype'] . "')"; $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_models` \n ON (`glpi_plugin_manufacturersimports_models`.`items_id` = `" . $itemtable . "`.`id` \n AND `glpi_plugin_manufacturersimports_models`.`itemtype` = '" . $p['itemtype'] . "')"; //serial must be not empty $query .= " WHERE `" . $itemtable . "`.`is_deleted` = '0'\n AND `" . $itemtable . "`.`is_template` = '0'\n AND `glpi_plugin_manufacturersimports_configs`.`id` = '" . $p['manufacturers_id'] . "'\n AND `" . $itemtable . "`.`serial` != '' "; //already imported if ($p['imported'] == self::IMPORTED) { $query .= " AND `import_status` != " . self::IMPORTED . ""; //not imported } else { if ($p['imported'] == self::NOT_IMPORTED) { $query .= " AND (`date_import` IS NULL OR `import_status` = " . self::IMPORTED . " "; $query .= ") "; } } $entities = ""; if ($config->isRecursive()) { $entities = getSonsOf('glpi_entities', $config->getEntityID()); } else { $entities = $config->getEntityID(); } $query .= "" . getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()); //// 4 - ORDER $ORDER = " ORDER BY `entities_id`,`" . $itemtable . "`.`name` "; $toview = array("name" => 1); foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = self::addOrderBy($p['itemtype'], $p['sort'], $p['order'], $key); } } $query .= $ORDER; $result = $DB->query($query); $numrows = $DB->numrows($result); if ($p['start'] < $numrows) { // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } $parameters = "itemtype=" . $p['itemtype'] . "&manufacturers_id=" . $p['manufacturers_id'] . "&imported=" . $p['imported']; $total = 0; if ($output_type == Search::HTML_OUTPUT) { self::printPager($p['start'], $numrows, $target, $parameters, $p['itemtype']); } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $_SESSION["glpilist_limit"]; // Export All case if (isset($_GET['export_all'])) { $begin_display = 0; $end_display = $numrows; } if (Session::isMultiEntitiesMode()) { $colsup = 1; } else { $colsup = 0; } //////////////////////HEADER/////////////// if ($output_type == Search::HTML_OUTPUT) { echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"../ajax/massiveaction.php\">"; } //echo Search::displaySearchHeader($output_type,0); //table + div if ($canedit) { $nbcols = 11 + $colsup; } else { $nbcols = 10 + $colsup; } $LIST_LIMIT = $_SESSION['glpilist_limit']; $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt["PluginManufacturersimportsPreImport"][$val]['nosort']) || !$searchopt["PluginManufacturersimportsPreImport"][$val]['nosort']) { $linkto = "{$target}?itemtype=" . $p['itemtype'] . "&manufacturers_id=" . $p['manufacturers_id'] . "&imported=" . $p['imported'] . "&sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto; } } echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols); echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, "", $header_num); echo Search::showHeaderItem($output_type, __('Name'), $header_num, $linkto, $p['sort'] == $val, $p['order']); if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Serial number'), $header_num); echo $supplier->showItemTitle($output_type, $header_num); echo Search::showHeaderItem($output_type, __('Financial and administrative information'), $header_num); echo Search::showHeaderItem($output_type, __('Supplier attached', 'manufacturersimports'), $header_num); echo Search::showHeaderItem($output_type, __('New warranty attached', 'manufacturersimports'), $header_num); echo Search::showHeaderItem($output_type, _n('Link', 'Links', 1), $header_num); echo Search::showHeaderItem($output_type, _n('Status', 'Statuses', 1), $header_num); echo $supplier->showDocTitle($output_type, $header_num); // End Line for column headers echo Search::showEndLine($output_type); $i = $p['start']; if (isset($_GET['export_all'])) { $i = 0; } if ($i > 0) { $DB->data_seek($result, $i); } $row_num = 1; while ($i < $numrows && $i < $end_display) { $i++; $item_num = 1; $line = $DB->fetch_array($result); $compSerial = $line['serial']; $compId = $line['id']; $model = $line["model_name"]; if (!$line["itemtype"]) { $line["itemtype"] = $p['itemtype']; } self::showImport($row_num, $item_num, $line, $output_type, $p['manufacturers_id'], $line["import_status"], $p['imported']); //1.show already imported items && import_status not failed if ($p['imported'] == 1) { $total += 1; } } echo "<tr class='tab_bg_1'><td colspan='" . ($canedit ? 11 + $colsup : 10 + $colsup) . "'>"; echo sprintf(__('Total number of devices to import %s', 'manufacturersimports'), $total); echo "</td></tr>"; // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= PluginManufacturersimportsPreImport::getTypeName(2) . " " . $suppliername; } echo Search::showFooter($output_type, $title); //massive action if ($canedit && $output_type == Search::HTML_OUTPUT) { if ($_SESSION['glpilist_limit'] < Toolbox::get_max_input_vars()) { Html::openArrowMassives("massiveaction_form", false); self::dropdownMassiveAction($compId, $p['itemtype'], $p['manufacturers_id'], $p['start'], $p['imported']); Html::closeArrowMassives(array()); } else { echo "<table class='tab_cadre' width='80%'><tr class='tab_bg_1'>" . "<td><span class='b'>"; echo __('Selection too large, massive action disabled.') . "</span>"; if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { echo "<br>" . __('To increase the limit: change max_input_vars or suhosin.post.max_vars in php configuration.'); } echo "</td></tr></table>"; } Html::closeForm(); } else { echo "</table>"; echo "</div>"; } echo "<br>"; if ($output_type == Search::HTML_OUTPUT) { self::printPager($p['start'], $numrows, $target, $parameters, $p['itemtype']); } } else { echo "<div align='center'><b>" . __('No device finded', 'manufacturersimports') . "</b></div>"; } } }
/** * Execute the report * * @param $options array **/ function execute($options = array()) { global $DB, $CFG_GLPI, $HEADER_LOADED; // Require (for pager) when not called by displayCriteriasForm $this->manageCriteriasValues(); if (isset($_POST['list_limit'])) { $_SESSION['glpilist_limit'] = $_POST['list_limit']; unset($_POST['list_limit']); } $limit = $_SESSION['glpilist_limit']; if (isset($_POST["display_type"])) { $output_type = $_POST["display_type"]; if ($output_type < 0) { $output_type = -$output_type; $limit = 0; } } else { $output_type = Search::HTML_OUTPUT; } $title = $this->title; if ($this->subname) { $title = sprintf(__('%1$s - %2$s'), $title, $this->subname); } $res = $DB->query($this->sql); $nbtot = $res ? $DB->numrows($res) : 0; if ($limit) { $start = isset($_GET["start"]) ? $_GET["start"] : 0; if ($start >= $nbtot) { $start = 0; } if ($start > 0 || $start + $limit < $nbtot) { $res = $DB->query($this->sql . " LIMIT {$start},{$limit}"); } } else { $start = 0; } if ($nbtot == 0) { if (!$HEADER_LOADED) { Html::header($title, $_SERVER['PHP_SELF'], "utils", "report"); Report::title(); } echo "<div class='center'><font class='red b'>" . __('No item found') . "</font></div>"; Html::footer(); } else { if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php"; } else { if ($output_type == Search::HTML_OUTPUT) { if (!$HEADER_LOADED) { Html::header($title, $_SERVER['PHP_SELF'], "utils", "report"); Report::title(); } echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . $title . "</th></tr>\n"; echo "<tr class='tab_bg_2 center'><td class='center'>"; echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n"; $param = ""; foreach ($_POST as $key => $val) { if (is_array($val)) { foreach ($val as $k => $v) { echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >"; if (!empty($param)) { $param .= "&"; } $param .= $key . "[" . $k . "]=" . urlencode($v); } } else { echo "<input type='hidden' name='" . $key . "' value='{$val}' >"; if (!empty($param)) { $param .= "&"; } $param .= "{$key}=" . urlencode($val); } } Dropdown::showOutputFormat(); Html::closeForm(); echo "</td></tr>"; echo "</table></div>"; Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param); } } } if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) { if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) { echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">"; } } plugin_reports_checkRight($this->plug, $this->name, "r"); if ($res && $nbtot > 0) { $nbcols = $DB->num_fields($res); $nbrows = $DB->numrows($res); echo Search::showHeader($output_type, $nbrows, $nbcols, true); echo Search::showNewLine($output_type); $num = 1; // fill $sqlcols with default sql query fields so we can validate $columns $sqlcols = array(); for ($i = 0; $i < $nbcols; $i++) { $colname = $DB->field_name($res, $i); $sqlcols[] = $colname; } $colsname = array(); // if $columns is not empty, display $columns if (count($this->columns) > 0) { foreach ($this->columns as $colname => $column) { // display only $columns that are valid if (in_array($colname, $sqlcols)) { $column->showTitle($output_type, $num); $colsname[$colname] = $column; } } } else { // else display default columns from SQL query foreach ($sqlcols as $colname) { $column = new PluginReportsColumn($colname, $colname); $column->showTitle($output_type, $num); $colsname[$colname] = $column; } } echo Search::showEndLine($output_type); $prev = ""; for ($row_num = 2; $row = $DB->fetch_assoc($res); $row_num++) { $crt = ""; foreach ($this->group_by as $colname) { if (isset($row[$colname])) { $crt .= $row[$colname] . "####"; } } echo Search::showNewLine($output_type); $num = 1; foreach ($colsname as $colname => $column) { //If value needs to be modified on the fly if (isset($this->columns_mapping[$colname]) && isset($this->columns_mapping[$colname][$row[$colname]])) { $new_value = $this->columns_mapping[$colname][$row[$colname]]; $row[$colname] = $new_value; } if (!in_array($colname, $this->group_by)) { $column->showValue($output_type, $row, $num, $row_num); } else { if ($crt == $prev) { $column->showValue($output_type, $output_type == Search::CSV_OUTPUT ? $row : array(), $num, $row_num); } else { $column->showValue($output_type, $row, $num, $row_num, true); } } } // Each column echo Search::showEndLine($output_type); $prev = $crt; } // Each row if (isset($options['withtotal']) && $options['withtotal']) { echo Search::showNewLine($output_type); $num = 1; foreach ($colsname as $colname => $column) { $column->showTotal($output_type, $num, $row_num); } echo Search::showEndLine($output_type); } } echo Search::showFooter($output_type, $title); if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) { if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) { Html::openArrowMassives("massiveaction_form", true); Dropdown::showForMassiveAction($options['withmassiveaction']); $options = array(); Html::closeArrowMassives($options); Html::closeForm(); } Html::footer(); } }
function afficheTableau($date, $display, $output_type, $itemtable, $end_display, $start, $nbcols, $titre, $total, $items, $locations_id) { global $DB, $CFG_GLPI; $first = true; $deleted = 0; $master_total = 0; $master_total += $total; if ($total != 0) { if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; echo Search::showHeader($output_type, $end_display - $start + 1, $nbcols, 1); } else { echo Search::showNewLine($output_type); echo Search::showEndLine($output_type); } echo Search::showNewLine($output_type); //tr if ($output_type == Search::HTML_OUTPUT) { if ($total != -1) { echo "<th>" . $titre . "</th><th><font color='red'>" . Html::formatNumber($total) . " " . _n('Euro', 'Euros', 2, 'financialreports') . "</font></th><th>"; } else { echo "<th>" . $titre . "</th><th></th><th>"; } if ($_SESSION[$display]) { $status = "false"; } else { $status = "true"; } echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/financialreports/front/financialreport.php?" . $display . "=" . $status . "&date=" . $date . "&locations_id=" . $locations_id . "'>"; if ($_SESSION[$display]) { echo __('Hide', 'financialreports'); } else { echo __('Display', 'financialreports'); } echo "</a>"; if ($itemtable != 'disposal') { echo "</th><th colspan='4'><th>"; } else { echo "</th><th colspan='3'><th>"; } } else { echo Search::showHeaderItem($output_type, $titre, $header_num); //th echo Search::showHeaderItem($output_type, __('Total'), $header_num); if ($total != -1) { echo Search::showHeaderItem($output_type, Html::formatNumber($total) . " " . _n('Euro', 'Euros', 2, 'financialreports'), $header_num); } } echo Search::showEndLine($output_type); //tr echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, __('Name'), $header_num); echo Search::showHeaderItem($output_type, __('Inventory number'), $header_num); echo Search::showHeaderItem($output_type, __('Date of purchase'), $header_num); if ($itemtable != 'disposal') { echo Search::showHeaderItem($output_type, __('User / Group', 'financialreports'), $header_num); echo Search::showHeaderItem($output_type, __('Location'), $header_num); } echo Search::showHeaderItem($output_type, __('Model'), $header_num); echo Search::showHeaderItem($output_type, __('Supplier'), $header_num); if ($itemtable == 'disposal') { echo Search::showHeaderItem($output_type, __('Disposal date', 'financialreports'), $header_num); echo Search::showHeaderItem($output_type, __('Comments'), $header_num); } else { echo Search::showHeaderItem($output_type, __('Purchase Price HT in', 'financialreports') . " " . _n('Euro', 'Euros', 2, 'financialreports'), $header_num); } // End Line for column headers echo Search::showEndLine($output_type); $row_num = 1; if ($_SESSION[$display]) { foreach ($items as $data) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $row_num % 2); //name $link = Toolbox::getItemTypeFormURL($data["TYPE"]); $output_iddev = "<a href='" . $link . "?id=" . $data["id"] . "'>" . $data["ITEM_0"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["id"] . ")" : "") . "</a>"; echo Search::showItem($output_type, $output_iddev, $item_num, $row_num); //otherserial echo Search::showItem($output_type, $data["ITEM_2"], $item_num, $row_num); //buy_date echo Search::showItem($output_type, Html::convdate($data["ITEM_3"]), $item_num, $row_num); if ($itemtable != 'disposal') { //user $username_computer = formatUserName($data["ITEM_4_3"], $data["ITEM_4"], $data["ITEM_4_2"], $data["ITEM_4_4"]); $output_iduser = "******" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $data["ITEM_4_3"] . "'>" . $username_computer . "</a>"; if ($data["ITEM_4_3"] && $data["ITEM_5"]) { $output_iduser .= " / <a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["ITEM_5_1"] . "'>" . $data["ITEM_5"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["ITEM_5_1"] . ")" : "") . "</a>"; } else { if (!isset($data["ITEM_4_3"]) && $data["ITEM_5"]) { $output_iduser = "******" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["ITEM_5_1"] . "'>" . $data["ITEM_5"] . ($_SESSION["glpiis_ids_visible"] ? " (" . $data["ITEM_5_1"] . ")" : "") . "</a>"; } else { if (!isset($data["ITEM_4_3"]) && !isset($data["ITEM_5"])) { $output_iduser = __('In stock / available', 'financialreports'); } } } echo Search::showItem($output_type, $output_iduser, $item_num, $row_num); //location echo Search::showItem($output_type, $data["ITEM_9"], $item_num, $row_num); } //model echo Search::showItem($output_type, $data["ITEM_6"], $item_num, $row_num); //manufacturer echo Search::showItem($output_type, $data["ITEM_7"], $item_num, $row_num); if ($itemtable == 'disposal') { //comments echo Search::showItem($output_type, Html::convdate($data["ITEM_10"]), $item_num, $row_num); echo Search::showItem($output_type, nl2br($data["ITEM_9"]), $item_num, $row_num); } else { //value if ($output_type == Search::HTML_OUTPUT) { $ouput_value = "<font color='red'>" . Html::formatNumber($data["ITEM_8"]) . "</font>"; } else { $ouput_value = Html::formatNumber($data["ITEM_8"]); } echo Search::showItem($output_type, $ouput_value, $item_num, $row_num); } echo Search::showEndLine($output_type); } } echo Search::showFooter($output_type); } return $master_total; }
public static function showAccountsList($values, $list) { global $CFG_GLPI; $ID = $values["id"]; $aeskey = $values["aeskey"]; $PluginAccountsHash = new PluginAccountsHash(); $PluginAccountsHash->getFromDB($ID); $hash = $PluginAccountsHash->fields["hash"]; $default_values["start"] = $start = 0; $default_values["id"] = $id = 0; $default_values["export"] = $export = false; foreach ($default_values as $key => $val) { if (isset($values[$key])) { ${$key} = $values[$key]; } } // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($values["display_type"])) { $output_type = $values["display_type"]; } $header_num = 1; $nbcols = 4; $row_num = 1; $numrows = 1; $parameters = "id=" . $ID . "&aeskey=" . $aeskey; if ($output_type == Search::HTML_OUTPUT && !empty($list)) { self::printPager($start, $numrows, $_SERVER['PHP_SELF'], $parameters, "PluginAccountsReport"); } echo Search::showHeader($output_type, 1, $nbcols, 1); echo Search::showNewLine($output_type); echo Search::showHeaderItem($output_type, __('Name'), $header_num); if (Session::isMultiEntitiesMode()) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Type'), $header_num); echo Search::showHeaderItem($output_type, __('Login'), $header_num); echo Search::showHeaderItem($output_type, __('Uncrypted password', 'accounts'), $header_num); echo Search::showEndLine($output_type); if (!empty($list)) { foreach ($list as $user => $field) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type); $IDc = $field["id"]; if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='hash_id' value='" . $ID . "'>"; echo "<input type='hidden' name='id[{$IDc}]' value='" . $IDc . "'>"; } $name = "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/accounts/front/account.form.php?id=" . $IDc . "'>" . $field["name"]; if ($_SESSION["glpiis_ids_visible"]) { $name .= " (" . $IDc . ")"; } $name .= "</a>"; echo Search::showItem($output_type, $name, $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='name[{$IDc}]' value='" . $field["name"] . "'>"; } if (Session::isMultiEntitiesMode()) { echo Search::showItem($output_type, $field['entities_id'], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='entities_id[{$IDc}]' value='" . $field["entities_id"] . "'>"; } } echo Search::showItem($output_type, $field["type"], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='type[{$IDc}]' value='" . $field["type"] . "'>"; } echo Search::showItem($output_type, $field["login"], $item_num, $row_num); if ($output_type == Search::HTML_OUTPUT) { echo "<input type='hidden' name='login[{$IDc}]' value='" . $field["login"] . "'>"; } if ($output_type == Search::HTML_OUTPUT) { $encrypted = $field["password"]; echo "<input type='hidden' name='password[{$IDc}]'>"; $pass = "******"; $pass .= "<script language='javascript'>\n var good_hash=\"{$hash}\";\n var hash=SHA256(SHA256(\"{$aeskey}\"));\n if (hash != good_hash) {\n pass = \"" . __('Wrong encryption key', 'accounts') . "\";\n } else {\n pass = AESDecryptCtr(\"{$encrypted}\",SHA256(\"{$aeskey}\"), 256);\n };\n\n document.getElementsByName(\"password[{$IDc}]\").item(0).value = pass;\n\n document.getElementById(\"show_password\${$IDc}\").innerHTML = pass;\n </script>"; echo Search::showItem($output_type, $pass, $item_num, $row_num); } else { echo Search::showItem($output_type, $field["password"], $item_num, $row_num); } echo Search::showEndLine($output_type); } } if ($output_type == Search::HTML_OUTPUT) { Html::closeForm(); } // Display footer echo Search::showFooter($output_type, __('Linked accounts list', 'accounts')); }
/** * @param $params */ static function showSnmpDeviceToAdd($params) { global $DB, $CFG_GLPI; // Default values of parameters $p['link'] = array(); $p['field'] = array(); $p['contains'] = array(); $p['searchtype'] = array(); $p['sort'] = '1'; $p['order'] = 'ASC'; $p['start'] = 0; $p['export_all'] = 0; $p['link2'] = ''; $p['contains2'] = ''; $p['field2'] = ''; $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['itemtype'] = ''; $p['ip'] = ''; $p['tolinked'] = 0; $p['check'] = 'all'; $p['plugin_ocsinventoryng_ocsservers_id'] = 0; foreach ($params as $key => $val) { $p[$key] = $val; } $tolinked = $p['tolinked']; $start = $p['start']; $plugin_ocsinventoryng_ocsservers_id = $p['plugin_ocsinventoryng_ocsservers_id']; $title = __('Import new SNMP devices', 'ocsinventoryng'); if ($tolinked) { $title = __('Import new SNMP devices into glpi', 'ocsinventoryng'); } $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsngsnmp.import.php'; if ($tolinked) { $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsngsnmp.link.php'; } if (!$start) { $start = 0; } // Get all links between glpi and OCS $query_glpi = "SELECT ocs_id\n FROM `glpi_plugin_ocsinventoryng_snmpocslinks`\n WHERE `plugin_ocsinventoryng_ocsservers_id` = '" . $plugin_ocsinventoryng_ocsservers_id . "'"; $result_glpi = $DB->query($query_glpi); $already_linked = array(); if ($DB->numrows($result_glpi) > 0) { while ($data = $DB->fetch_array($result_glpi)) { $already_linked[] = $data["ocs_id"]; } } $snmpOptions = array('ORDER' => 'LASTDATE', 'FILTER' => array('EXCLUDE_IDS' => $already_linked), 'DISPLAY' => array('CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS), 'ORDER' => 'NAME'); //if ($cfg_ocs["tag_limit"] and $tag_limit = explode("$", trim($cfg_ocs["tag_limit"]))) { // $snmpOptions['FILTER']['TAGS'] = $tag_limit; //} //if ($cfg_ocs["tag_exclude"] and $tag_exclude = explode("$", trim($cfg_ocs["tag_exclude"]))) { // $snmpOptions['FILTER']['EXCLUDE_TAGS'] = $tag_exclude; //} $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($plugin_ocsinventoryng_ocsservers_id); $ocsResult = $ocsClient->getSnmp($snmpOptions); if (isset($ocsResult['SNMP'])) { if (count($ocsResult['SNMP'])) { // Get all hardware from OCS DB $hardware = array(); $snmp = array_slice($ocsResult['SNMP'], $start, $_SESSION['glpilist_limit']); foreach ($snmp as $data) { $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data)); $id = $data['META']['ID']; $hardware[$id]["id"] = $data['META']["ID"]; $hardware[$id]["date"] = $data['META']["LASTDATE"]; $hardware[$id]["name"] = $data['META']["NAME"]; $hardware[$id]["ipaddr"] = $data['META']["IPADDR"]; $hardware[$id]["snmpdeviceid"] = $data['META']["SNMPDEVICEID"]; $hardware[$id]["description"] = $data['META']["DESCRIPTION"]; $hardware[$id]["type"] = $data['META']["TYPE"]; $hardware[$id]["contact"] = $data['META']["CONTACT"]; $hardware[$id]["location"] = $data['META']["LOCATION"]; } foreach ($hardware as $id => $field) { if ($field["type"] == "Network") { $field["type"] = "NetworkEquipment"; } if (!empty($p['itemtype']) && $field['type'] != $p['itemtype']) { unset($hardware[$id]); } if (!empty($p['ip']) && !preg_match("/" . $p['ip'] . "/", $field['ipaddr'])) { unset($hardware[$id]); } } $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } $parameters = "itemtype=" . $p['itemtype'] . "&ip=" . $p['ip']; // Define begin and end var for loop // Search case $begin_display = $start; $end_display = $start + $_SESSION["glpilist_limit"]; $numrows = $ocsResult['TOTAL_COUNT']; // Export All case if (isset($_GET['export_all'])) { $begin_display = 0; $end_display = $numrows; } $nbcols = 10; if ($output_type == Search::HTML_OUTPUT && $tolinked && count($hardware)) { echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>"; } if ($numrows) { $parameters = ""; Html::printPager($start, $numrows, $target, $parameters); //Show preview form only in import even in multi-entity mode because computer import //can be refused by a rule /*if (!$tolinked) { echo "<div class='firstbloc'>"; echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode' action='$target'>\n"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n"; echo "<tr class='tab_bg_1'><td class='center'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; }*/ if ($output_type == Search::HTML_OUTPUT) { echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>"; } if ($output_type == Search::HTML_OUTPUT && !$tolinked) { echo "<div class='center'>"; PluginOcsinventoryngOcsServer::checkBox($target); echo "</div>"; } if ($output_type == Search::HTML_OUTPUT) { echo "<table class='tab_cadrehov'>"; echo "<tr class='tab_bg_1'><td colspan='10' class='center'>"; if (!$tolinked) { echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">"; } else { echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; } echo "</td></tr>\n"; } echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols); echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, __('Name'), $header_num); //, $linkto, $p['sort']==$val, $p['order'] echo Search::showHeaderItem($output_type, __('Description'), $header_num); echo Search::showHeaderItem($output_type, __('IP address'), $header_num); echo Search::showHeaderItem($output_type, __('Date'), $header_num); echo Search::showHeaderItem($output_type, __('Contact SNMP', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Location SNMP', 'ocsinventoryng'), $header_num); echo Search::showHeaderItem($output_type, __('Type SNMP', 'ocsinventoryng'), $header_num); if (!$tolinked) { echo Search::showHeaderItem($output_type, __('Item type to create', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); echo Search::showHeaderItem($output_type, "", $header_num); } else { echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%'); } // End Line for column headers echo Search::showEndLine($output_type); $row_num = 1; foreach ($hardware as $ID => $tab) { $row_num++; $item_num = 1; if ($tab["type"] == "Network") { $tab["type"] = "NetworkEquipment"; } echo Search::showNewLine($output_type, $row_num % 2); echo Search::showItem($output_type, $tab["name"], $item_num, $row_num); echo Search::showItem($output_type, $tab["description"], $item_num, $row_num, 'width=15%'); echo Search::showItem($output_type, $tab["ipaddr"], $item_num, $row_num, 'width=5%'); echo Search::showItem($output_type, Html::convDateTime($tab["date"]), $item_num, $row_num, 'width=15%'); echo Search::showItem($output_type, $tab["contact"], $item_num, $row_num, 'width=5%'); echo Search::showItem($output_type, $tab["location"], $item_num, $row_num, 'width=15%'); echo Search::showItem($output_type, $tab["type"], $item_num, $row_num); if (!$tolinked) { echo "<td width='15%'>"; $value = false; if (getItemForItemtype($tab["type"])) { $value = $tab["type"]; } $type = "toimport_itemtype[" . $tab["id"] . "]"; Dropdown::showItemTypes($type, self::$snmptypes, array('value' => $value)); echo "</td>\n"; } /* if ($p['change_import_mode'] && !$tolinked){ if (!isset ($data['entities_id']) || $data['entities_id'] == -1){ echo "<td class='center'><img src=\"".$CFG_GLPI['root_doc']. "/pics/redbutton.png\"></td>\n"; $data['entities_id'] = -1; } else{ echo "<td class='center'>"; $tmprule = new RuleImportEntity(); if ($tmprule->can($data['_ruleid'],READ)){ echo "<a href='". $tmprule->getLinkURL()."'>".$tmprule->getName()."</a>"; } else{ echo $tmprule->getName(); } echo "</td>\n"; } echo "<td width='30%'>"; $ent = "toimport_entities[".$tab["id"]."]"; Entity::dropdown(array('name' => $ent, 'value' => $data['entities_id'], 'comments' => 0)); echo "</td>\n"; } */ echo "<td width='10'>"; if (!$tolinked) { echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($p['check'] == "all" ? "checked" : "") . ">"; } else { /* $tab['entities_id'] = $p['glpiactiveentities']; $rulelink = new RuleImportComputerCollection(); $rulelink_results = array(); $params = array('entities_id' => $p['glpiactiveentities'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id); $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params); //Look for the computer using automatic link criterias as defined in OCSNG configuration $options = array('name' => "tolink[".$tab["id"]."]"); $show_dropdown = true; //If the computer is not explicitly refused by a rule if (!isset($rulelink_results['action']) || $rulelink_results['action'] != PluginOcsinventoryngOcsServer::LINK_RESULT_NO_IMPORT){ if (!empty($rulelink_results['found_computers'])){ $options['value'] = $rulelink_results['found_computers'][0]; $options['entity'] = $p['glpiactiveentities']; } */ /* } else{ echo "<img src='".$CFG_GLPI['root_doc']. "/pics/redbutton.png'>"; } */ $value = false; if (getItemForItemtype($tab["type"])) { $type = $tab["type"]; $options['name'] = "tolink_items[" . $tab["id"] . "]"; $self = new self(); if ($item = $self->getFromDBbyName($tab["type"], $tab["name"])) { $options['value'] = isset($item->fields['id']) ? $item->fields['id'] : false; } $type::dropdown($options); echo "<input type='hidden' name='tolink_itemtype[" . $tab["id"] . "]' value='" . $tab["type"] . "'>"; } else { $mtrand = mt_rand(); $mynamei = "itemtype"; $myname = "tolink_items[" . $tab["id"] . "]"; $rand = Dropdown::showItemTypes($mynamei, self::$snmptypes, array('rand' => $mtrand)); $p = array('itemtype' => '__VALUE__', 'id' => $tab["id"], 'rand' => $rand, 'myname' => $myname); //print_r($p); Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p); echo "<span id='results_{$mynamei}{$rand}'>\n"; echo "</span>\n"; } } echo "</td></tr>\n"; } echo "<tr class='tab_bg_1'><td colspan='10' class='center'>"; if (!$tolinked) { echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">"; } else { echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">"; } echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='" . $plugin_ocsinventoryng_ocsservers_id . "'>"; echo "</td></tr>"; echo "</table>\n"; Html::closeForm(); if (!$tolinked) { echo "<div class='center'>"; PluginOcsinventoryngOcsServer::checkBox($target); echo "</div>"; } Html::printPager($start, $numrows, $target, $parameters); } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . $title . "</th></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n"; echo "</table>"; } echo "</div>"; } else { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . $title . "</th></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n"; echo "</table></div>"; } } else { echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . $title . "</th></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n"; echo "</table></div>"; } }
/** * Print out list kb item * * @param $options $_GET * @param $type string search type : browse / search (default search) **/ static function showList($options, $type = 'search') { global $DB, $CFG_GLPI; // Default values of parameters $params['faq'] = !Session::haveRight(self::$rightname, READ); $params["start"] = "0"; $params["knowbaseitemcategories_id"] = "0"; $params["contains"] = ""; $params["target"] = $_SERVER['PHP_SELF']; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $ki = new self(); switch ($type) { case 'myunpublished': if (!Session::haveRightsOr(self::$rightname, array(UPDATE, self::PUBLISHFAQ))) { return false; } break; case 'allunpublished': if (!Session::haveRight(self::$rightname, self::KNOWBASEADMIN)) { return false; } break; default: break; } if (!$params["start"]) { $params["start"] = 0; } $query = self::getListRequest($params, $type); // Get it from database if ($result = $DB->query($query)) { $KbCategory = new KnowbaseItemCategory(); $title = ""; if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) { $title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name']; $title = sprintf(__('%1$s: %2$s'), __('Category'), $title); } Session::initNavigateListItems('KnowbaseItem', $title); $numrows = $DB->numrows($result); $list_limit = $_SESSION['glpilist_limit']; $showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy')); // Limit the result, if no limit applies, use prior result if ($numrows > $list_limit && !isset($_GET['export_all'])) { $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " "; $result_limit = $DB->query($query_limit); $numrows_limit = $DB->numrows($result_limit); } else { $numrows_limit = $numrows; $result_limit = $result; } if ($numrows_limit > 0) { // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } // Pager $parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq=" . $params['faq']; if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $parameters .= "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype']; } if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } $nbcols = 1; // Display List Header echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols); echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, __('Subject'), $header_num); if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Content'), $header_num); } if ($showwriter) { echo Search::showHeaderItem($output_type, __('Writer'), $header_num); } echo Search::showHeaderItem($output_type, __('Category'), $header_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, ' ', $header_num); } // Num of the row (1=header_line) $row_num = 1; for ($i = 0; $i < $numrows_limit; $i++) { $data = $DB->fetch_assoc($result_limit); Session::addToNavigateListItems('KnowbaseItem', $data["id"]); // Column num $item_num = 1; $row_num++; echo Search::showNewLine($output_type, $i % 2); $item = new self(); $item->getFromDB($data["id"]); $name = $data["name"]; $answer = $data["answer"]; // Manage translations if (isset($data['transname']) && !empty($data['transname'])) { $name = $data["transname"]; } if (isset($data['transanswer']) && !empty($data['transanswer'])) { $answer = $data["transanswer"]; } if ($output_type == Search::HTML_OUTPUT) { $toadd = ''; if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $href = " href='#' onClick=\"" . Html::jsGetElementbyID('kbshow' . $data["id"]) . ".dialog('open');\""; $toadd = Ajax::createIframeModalWindow('kbshow' . $data["id"], $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"], array('display' => false)); } else { $href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" "; } echo Search::showItem($output_type, "<div class='kb'>{$toadd}<a " . ($data['is_faq'] ? " class='pubfaq' title='" . __("This item is part of the FAQ") . "' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($name, 80) . "</a></div>\n <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($answer)), 600) . "</div>", $item_num, $row_num); } else { echo Search::showItem($output_type, $name, $item_num, $row_num); echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($answer, ENT_QUOTES, "UTF-8"))), $item_num, $row_num); } $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($showwriter) { echo Search::showItem($output_type, getUserName($data["users_id"], $showuserlink), $item_num, $row_num); } $categ = $data["category"]; if ($output_type == Search::HTML_OUTPUT) { $cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&forcetab=Knowbase$2'; $categ = "<a href='{$cathref}'>" . $categ . '</a>'; } echo Search::showItem($output_type, $categ, $item_num, $row_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { $forcetab = $options['item_itemtype']; if (!$_SESSION['glpiticket_timeline'] || $_SESSION['glpiticket_timeline_keep_replaced_tabs']) { $forcetab .= '$2'; //Solution tab } else { $forcetab .= '$1'; //Timeline tab } $content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&id=" . $options['item_items_id'] . "&forcetab=" . $forcetab . "'>" . __('Use as a solution') . "</a>"; echo Search::showItem($output_type, $content, $item_num, $row_num); } // End Line echo Search::showEndLine($output_type); } // Display footer if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id'])); } else { echo Search::showFooter($output_type); } echo "<br>"; if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } } else { echo "<div class='center b'>" . __('No item found') . "</div>"; } } }
function show($itemtype, $type, $date1, $date2, $start, array $value, $value2 = "") { global $LANG, $CFG_GLPI; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } //printCleanArray($value); if (is_array($value)) { $end_display = $start + $_SESSION['plugin_mobile']['rows_limit']; $numrows = count($value); if (isset($_GET['export_all'])) { $start = 0; $end_display = $numrows; } $nbcols = 8; if ($output_type != Search::HTML_OUTPUT) { // not HTML display $nbcols--; } echo PluginMobileSearch::showHeader($output_type, $end_display - $start + 1, $nbcols); Search::showNewLine($output_type); $header_num = 1; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; echo PluginMobileSearch::showHeaderItem($output_type, $search_config, $header_num, "", 0, array()); } echo "<div data-type='horizontal' data-role='controlgroup' class='mobile_list_header'>"; $header_num = 1; echo PluginMobileSearch::showHeaderItem($output_type, " ", $header_num, '#', 0, '', 3); /*if ($output_type==Search::HTML_OUTPUT) { // HTML display echo PluginMobileSearch::showHeaderItem($output_type," ",$header_num, '#', 0, '', 7); }*/ //stevenes echo PluginMobileSearch::showHeaderItem($output_type, $LANG['stats'][13], $header_num, '#', 0, '', 3); echo PluginMobileSearch::showHeaderItem($output_type, $LANG['stats'][11], $header_num, '#', 0, '', 3); // echo PluginMobileSearch::showHeaderItem($output_type,$LANG['stats'][11],$header_num, '#', 0, '', 7); /* echo PluginMobileSearch::showHeaderItem($output_type,$LANG['stats'][15],$header_num, '#', 0, '', 7); echo PluginMobileSearch::showHeaderItem($output_type,$LANG['stats'][25],$header_num, '#', 0, '', 7); echo PluginMobileSearch::showHeaderItem($output_type,$LANG['stats'][27],$header_num, '#', 0, '', 7); echo PluginMobileSearch::showHeaderItem($output_type,$LANG['stats'][30],$header_num, '#', 0, '', 7); */ echo "</div>"; // End Line for column headers echo PluginMobileSearch::showEndLine($output_type); $itemtype = "Ticket"; //echo $start; //echo $value[0]['id']; //echo $value[0]['link']; $row_num = 1; for ($i = $start; $i < $numrows && $i < $end_display; $i++) { $value[$i]['link'] = preg_replace('#<a.*>(.*)</a>#isU', '$1', $value[$i]['link']); $value[$i]['link'] = "<a href='stat.graph.php?id=" . $value[$i + 1]['id'] . "&date1={$date1}&date2=" . "{$date2}&type={$type}" . (!empty($value2) ? "&champ={$value2}" : "") . "'>" . $value[$i]['link'] . "</a>"; $row_num++; $item_num = 1; echo PluginMobileSearch::showNewLine($output_type, $i % 2); echo PluginMobileSearch::showItem($output_type, $value[$i]['link'], $item_num, $row_num, '', 3); //echo PluginMobileSearch::showItem($output_type,$link,$item_num,$row_num, '', 7); /*if ($output_type==Search::HTML_OUTPUT) { // HTML display $link=""; if ($value[$i]['id']>0) { $link="<a href='stat.graph.php?id=".$value[$i]['id']."&date1=$date1&date2=". "$date2&type=$type".(!empty($value2)?"&champ=$value2":"")."'>". "<img src=\"".$CFG_GLPI["root_doc"]."/pics/stats_item.png\" alt='' title=''>". "</a>"; } echo PluginMobileSearch::showItem($output_type,$link,$item_num,$row_num, '', 7); }*/ //le nombre d'intervention - the number of intervention $opened = Stat::constructEntryValues($itemtype, "inter_total", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_opened = array_sum($opened); echo PluginMobileSearch::showItem($output_type, $nb_opened, $item_num, $row_num, '', 3); $export_data['opened'][$value[$i]['link']] = $nb_opened; //le nombre d'intervention resolues - the number of resolved intervention $solved = Stat::constructEntryValues($itemtype, "inter_solved", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_solved = array_sum($solved); echo PluginMobileSearch::showItem($output_type, $nb_solved, $item_num, $row_num, '', 3); $export_data['solved'][$value[$i]['link']] = $nb_solved; //dados chamados //Le temps moyen de resolution - The average time to resolv /* $data=Stat::constructEntryValues($itemtype,"inter_avgsolvedtime",$date1,$date2,$type,$value[$i]["id"],$value2); foreach ($data as $key2 => $val2) { $data[$key2]*=$solved[$key2]; } if ($nb_solved>0) { $nb=array_sum($data)/$nb_solved; } else { $nb=0; } $timedisplay = $nb*HOUR_TIMESTAMP; if ($output_type==Search::HTML_OUTPUT || $output_type==Search::PDF_OUTPUT_LANDSCAPE || $output_type==Search::PDF_OUTPUT_PORTRAIT) { $timedisplay=mobileTimestampToString($timedisplay,0); } echo PluginMobileSearch::showItem($output_type,$timedisplay,$item_num,$row_num, '', 7); //Le temps moyen de l'intervention reelle - The average realtime to resolv $data=Stat::constructEntryValues($itemtype,"inter_avgrealtime",$date1,$date2,$type,$value[$i]["id"],$value2); foreach ($data as $key2 => $val2) { if (isset($solved[$key2])) { $data[$key2]*=$solved[$key2]; } else { $data[$key2]*=0; } } $total_realtime=array_sum($data); if ($nb_solved>0) { $nb=$total_realtime/$nb_solved; } else { $nb=0; } $timedisplay=$nb*MINUTE_TIMESTAMP; if ($output_type==Search::HTML_OUTPUT || $output_type==Search::PDF_OUTPUT_LANDSCAPE || $output_type==Search::PDF_OUTPUT_PORTRAIT) { $timedisplay=mobileTimestampToString($timedisplay,0); } echo PluginMobileSearch::showItem($output_type,$timedisplay,$item_num,$row_num, '', 7); //Le temps total de l'intervention reelle - The total realtime to resolv $timedisplay=$total_realtime*MINUTE_TIMESTAMP; if ($output_type==Search::HTML_OUTPUT || $output_type==Search::PDF_OUTPUT_LANDSCAPE || $output_type==Search::PDF_OUTPUT_PORTRAIT) { $timedisplay=mobileTimestampToString($timedisplay,0); } echo PluginMobileSearch::showItem($output_type,$timedisplay,$item_num,$row_num, '', 7); //Le temps moyen de prise en compte du ticket - The average time to take a ticket into account $data=Stat::constructEntryValues($itemtype,"inter_avgtakeaccount",$date1,$date2,$type,$value[$i]["id"], $value2); foreach ($data as $key2 => $val2) { $data[$key2]*=$solved[$key2]; } if ($nb_solved>0) { $nb=array_sum($data)/$nb_solved; } else { $nb=0; } $timedisplay=$nb*HOUR_TIMESTAMP; if ($output_type==Search::HTML_OUTPUT || $output_type==Search::PDF_OUTPUT_LANDSCAPE || $output_type==Search::PDF_OUTPUT_PORTRAIT) { $timedisplay=mobileTimestampToString($timedisplay,0); } echo PluginMobileSearch::showItem($output_type,$timedisplay,$item_num,$row_num, '', 7); echo PluginMobileSearch::showEndLine($output_type); } */ echo PluginMobileSearch::showEndLine($output_type); } // Display footer echo PluginMobileSearch::showFooter($output_type); } else { echo $LANG['stats'][23]; } }
static function showShort($id, $followups, $output_type = HTML_OUTPUT, $row_num = 0) { global $CFG_GLPI, $LANG; $rand = mt_rand(); /// TODO to be cleaned. Get datas and clean display links // Prints a job in short form // Should be called in a <table>-segment // Print links or not in case of user view // Make new job object and fill it from database, if success, print it $job = new self(); $candelete = haveRight("delete_ticket", "1"); $canupdate = haveRight("update_ticket", "1"); $showprivate = haveRight("show_full_ticket", "1"); $align = "class='center"; $align_desc = "class='left"; if ($followups) { $align .= " top'"; $align_desc .= " top'"; } else { $align .= "'"; $align_desc .= "'"; } if ($job->getFromDB($id)) { $item_num = 1; $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]]; echo Search::showNewLine($output_type, $row_num % 2); // First column $first_col = "ID : " . $job->fields["id"]; if ($output_type == HTML_OUTPUT) { $first_col .= "<br><img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $job->fields["status"] . ".png'\n alt=\"" . self::getStatus($job->fields["status"]) . "\" title=\"" . self::getStatus($job->fields["status"]) . "\">"; } else { $first_col .= " - " . self::getStatus($job->fields["status"]); } if (($candelete || $canupdate) && $output_type == HTML_OUTPUT) { $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if (isset($_SESSION['glpimassiveactionselected'][$job->fields["id"]])) { $sel = "checked"; } $first_col .= " <input type='checkbox' name='item[" . $job->fields["id"] . "]'\n value='1' {$sel}>"; } echo Search::showItem($output_type, $first_col, $item_num, $row_num, $align); // Second column if ($job->fields['status'] == 'closed') { $second_col = $LANG['joblist'][12]; if ($output_type == HTML_OUTPUT) { $second_col .= " :<br>"; } else { $second_col .= " : "; } $second_col .= convDateTime($job->fields['closedate']); } else { if ($job->fields['status'] == 'solved') { $second_col = $LANG['joblist'][14]; if ($output_type == HTML_OUTPUT) { $second_col .= " :<br>"; } else { $second_col .= " : "; } $second_col .= convDateTime($job->fields['solvedate']); } else { if ($job->fields['begin_waiting_date']) { $second_col = $LANG['joblist'][26]; if ($output_type == HTML_OUTPUT) { $second_col .= " :<br>"; } else { $second_col .= " : "; } $second_col .= convDateTime($job->fields['begin_waiting_date']); } else { if ($job->fields['due_date']) { $second_col = $LANG['sla'][5]; if ($output_type == HTML_OUTPUT) { $second_col .= " :<br>"; } else { $second_col .= " : "; } $second_col .= convDateTime($job->fields['due_date']); } else { $second_col = $LANG['joblist'][11]; if ($output_type == HTML_OUTPUT) { $second_col .= " :<br>"; } else { $second_col .= " : "; } $second_col .= convDateTime($job->fields['date']); } } } } echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=130"); // Second BIS column $second_col = convDateTime($job->fields["date_mod"]); echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=90"); // Second TER column if (count($_SESSION["glpiactiveentities"]) > 1) { if ($job->fields['entities_id'] == 0) { $second_col = $LANG['entity'][2]; } else { $second_col = Dropdown::getDropdownName("glpi_entities", $job->fields['entities_id']); } echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=100"); } // Third Column echo Search::showItem($output_type, "<strong>" . self::getPriorityName($job->fields["priority"]) . "</strong>", $item_num, $row_num, "{$align} bgcolor='{$bgcolor}'"); // Fourth Column $fourth_col = ""; if (isset($job->users[self::REQUESTER]) && count($job->users[self::REQUESTER])) { foreach ($job->users[self::REQUESTER] as $k => $d) { $userdata = getUserName($k, 2); $fourth_col .= "<strong>" . $userdata['name'] . "</strong> "; $fourth_col .= showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); $fourth_col .= "<br>"; } } if (isset($job->groups[self::REQUESTER]) && count($job->groups[self::REQUESTER])) { foreach ($job->groups[self::REQUESTER] as $k => $d) { $fourth_col .= Dropdown::getDropdownName("glpi_groups", $k); $fourth_col .= "<br>"; } } echo Search::showItem($output_type, $fourth_col, $item_num, $row_num, $align); // Fifth column $fifth_col = ""; if (isset($job->users[self::ASSIGN]) && count($job->users[self::ASSIGN])) { foreach ($job->users[self::ASSIGN] as $k => $d) { $userdata = getUserName($k, 2); $fifth_col .= "<strong>" . $userdata['name'] . "</strong> "; $fifth_col .= showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); $fifth_col .= "<br>"; } } if (isset($job->groups[self::ASSIGN]) && count($job->groups[self::ASSIGN])) { foreach ($job->groups[self::ASSIGN] as $k => $d) { $fourth_col .= Dropdown::getDropdownName("glpi_groups", $k); $fourth_col .= "<br>"; } } if ($job->fields["suppliers_id_assign"] > 0) { if (!empty($fifth_col)) { $fifth_col .= "<br>"; } $fifth_col .= self::getAssignName($job->fields["suppliers_id_assign"], 'Supplier', 1); } echo Search::showItem($output_type, $fifth_col, $item_num, $row_num, $align); // Sixth Colum $sixth_col = ""; $is_deleted = false; if (!empty($job->fields["itemtype"]) && $job->fields["items_id"] > 0) { if (class_exists($job->fields["itemtype"])) { $item = new $job->fields["itemtype"](); if ($item->getFromDB($job->fields["items_id"])) { $is_deleted = $item->isDeleted(); $sixth_col .= $item->getTypeName(); $sixth_col .= "<br><strong>"; if ($item->canView()) { $sixth_col .= $item->getLink($output_type == HTML_OUTPUT); } else { $sixth_col .= $item->getNameID(); } $sixth_col .= "</strong>"; } } } else { if (empty($job->fields["itemtype"])) { $sixth_col = $LANG['help'][30]; } } echo Search::showItem($output_type, $sixth_col, $item_num, $row_num, $is_deleted ? " class='center deleted' " : $align); // Seventh column echo Search::showItem($output_type, "<strong>" . Dropdown::getDropdownName('glpi_ticketcategories', $job->fields["ticketcategories_id"]) . "</strong>", $item_num, $row_num, $align); // ninth column $ninth_column = "<strong>" . $job->fields["name"] . "</strong> "; // Add link if ($job->canViewItem()) { $ninth_column = "<a id='ticket" . $job->fields["id"] . "{$rand}' href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $job->fields["id"] . "\">{$ninth_column}</a>"; if ($followups && $output_type == HTML_OUTPUT) { $ninth_column .= TicketFollowup::showShortForTicket($job->fields["id"]); } else { $ninth_column .= " (" . $job->numberOfFollowups($showprivate) . "-" . $job->numberOfTasks($showprivate) . ")"; } } if ($output_type == HTML_OUTPUT) { $ninth_column .= " " . showToolTip($job->fields['content'], array('display' => false, 'applyto' => "ticket" . $job->fields["id"] . $rand)); } echo Search::showItem($output_type, $ninth_column, $item_num, $row_num, $align_desc . "width='300'"); // Finish Line echo Search::showEndLine($output_type); } else { echo "<tr class='tab_bg_2'><td colspan='6' ><i>" . $LANG['joblist'][16] . "</i></td></tr>"; } }
$buy = $result[$itemtype]['buy']; if ($ref == 'buy' || $buy == 0 || $val == 0) { $tmp = ''; } else { $tmp = round($val * 100 / $buy, 0) . "%"; } echo Search::showItem($display_type, $tmp, $numcol, $row_num, "class='right'"); } echo Search::showEndLine($display_type); $row_num++; } if ($display_type == Search::HTML_OUTPUT) { $row = array_pop($result); // Last line : total or single type unset($row['buy']); Stat::showGraph(array($title => $row), array('type' => 'pie')); } } else { $nbrows = 1; $nbcols = 1; echo Search::showHeader($display_type, $nbrows, $nbcols, true); echo Search::showNewLine($display_type); $num = 1; echo Search::showHeaderItem($display_type, __('No item found'), $num); echo Search::showEndLine($display_type); } echo Search::showFooter($display_type, $title); } if ($display_type == Search::HTML_OUTPUT) { Html::footer(); }
showTitle($output_type, $num, __('Type'), 'type'); showTitle($output_type, $num, __('Name'), 'name', true); showTitle($output_type, $num, __('First name'), 'firstname', true); showTitle($output_type, $num, __('Administrative number'), 'registration_number', true); showTitle($output_type, $num, PluginResourcesProfession::getTypeName(1), 'profession', true); showTitle($output_type, $num, __('Arrival date', 'resources'), 'date_begin', true); showTitle($output_type, $num, __('Departure date', 'resources'), 'date_end', true); showTitle($output_type, $num, PluginResourcesProfession::getTypeName(1) . " - " . __('Begin date'), 'begin_date', true); showTitle($output_type, $num, PluginResourcesProfession::getTypeName(1) . " - " . __('End date'), 'end_date', true); echo Search::showEndLine($output_type); if ($limit) { $dataAll = array_slice($dataAll, $start, $limit); } foreach ($dataAll as $key => $data) { $num = 1; echo Search::showNewLine($output_type); echo Search::showItem($output_type, Dropdown::getDropdownName('glpi_entities', $data['entity']), $num, $key); if ($data['typeName'] == 'Resource') { $type = PluginResourcesResource::getTypeName(0); $link = Toolbox::getItemTypeFormURL("PluginResourcesResource"); } else { if ($data['typeName'] == 'Employment') { $type = PluginResourcesEmployment::getTypeName(0); $link = Toolbox::getItemTypeFormURL("PluginResourcesEmployment"); } } echo Search::showItem($output_type, $type, $num, $key); $name = "<a href='" . $link . "?id=" . $data["ID"] . "' target='_blank'>"; if ($data["name"] == NULL) { $name .= "(" . $data["ID"] . ")"; } else {
static function displayList(PluginFusioninventoryDeployOrder $order, $datas, $rand) { global $CFG_GLPI; $pfDeployPackage = new PluginFusioninventoryDeployPackage(); $pfDeployPackage->getFromDB($order->fields['plugin_fusioninventory_deploypackages_id']); echo "<table class='tab_cadrehov package_item_list' id='table_action_{$rand}'>"; $i = 0; foreach ($datas['jobs']['actions'] as $action) { echo Search::showNewLine(Search::HTML_OUTPUT, $i % 2); if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='control'>"; Html::showCheckbox(array('name' => 'action_entries[]')); echo "</td>"; } $keys = array_keys($action); $action_type = array_shift($keys); echo "<td>"; echo "<a class='edit' " . "onclick=\"edit_subtype('action', {$order->fields['id']}, {$rand}, this)\">"; echo PluginFusioninventoryDeployAction::getType($action_type); echo "</a><br />"; foreach ($action[$action_type] as $key => $value) { if (is_array($value)) { if ($key === "list") { foreach ($value as $list) { echo $list; echo " "; } } } else { echo "<b>"; if ($key == 'exec') { echo __('Command to execute', 'fusioninventory'); } else { echo $key; } echo "</b>"; if ($key === "exec") { echo "<pre style='border-left:solid lightgrey 3px;margin-left: 5px;" . "padding-left:2px'>{$value}</pre>"; } else { echo " {$value} "; } } } if (isset($action[$action_type]['retChecks'])) { echo "<br><b>" . __("return codes saved for this command", 'fusioninventory') . "</b> : <ul class='retChecks'>"; foreach ($action[$action_type]['retChecks'] as $retCheck) { echo "<li>"; $retchecks_entries = self::retchecks_entries(); echo $retchecks_entries[$retCheck['type']] . " " . array_shift($retCheck['values']); echo "</li>"; } echo "</ul>"; } echo "</td>"; echo "</td>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<td class='rowhandler control' title='" . __('drag', 'fusioninventory') . "'><div class='drag row'></div></td>"; } echo "</tr>"; $i++; } if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo "<tr><th>"; Html::checkAllAsCheckbox("actionsList{$rand}", mt_rand()); echo "</th><th colspan='3' class='mark'></th></tr>"; } echo "</table>"; if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) { echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png' alt=''>"; echo "<input type='submit' name='delete' value=\"" . __('Delete', 'fusioninventory') . "\" class='submit'>"; } }
/** * @param $output_type (default 'Search::HTML_OUTPUT') * @param $mass_id id of the form to check all (default '') */ static function commonListHeader($output_type = Search::HTML_OUTPUT, $mass_id = '') { // New Line for Header Items Line echo Search::showNewLine($output_type); // $show_sort if $header_num = 1; $items = array(); $items[empty($mass_id) ? ' ' : Html::getCheckAllAsCheckbox($mass_id)] = ''; $items[__('Status')] = "status"; $items[__('Date')] = "date"; $items[__('Last update')] = "date_mod"; if (count($_SESSION["glpiactiveentities"]) > 1) { $items[_n('Entity', 'Entities', Session::getPluralNumber())] = "glpi_entities.completename"; } $items[__('Priority')] = "priority"; $items[__('Requester')] = "users_id"; $items[__('Assigned')] = "users_id_assign"; if (static::getType() == 'Ticket') { $items[_n('Associated element', 'Associated elements', Session::getPluralNumber())] = ""; } $items[__('Category')] = "glpi_itilcategories.completename"; $items[__('Title')] = "name"; $items[__('Planification')] = "glpi_tickettasks.begin"; foreach ($items as $key => $val) { $issort = 0; $link = ""; echo Search::showHeaderItem($output_type, $key, $header_num, $link); } // End Line for column headers echo Search::showEndLine($output_type); }
/** * Display a line for an object * * @since version 0.85 (befor in each object with differents parameters) * * @param $id Integer ID of the object * @param $options array of options * output_type : Default output type (see Search class / default Search::HTML_OUTPUT) * row_num : row num used for display * type_for_massiveaction : itemtype for massive action * id_for_massaction : default 0 means no massive action * followups : only for Tickets : show followup columns */ static function showShort($id, $options = array()) { global $CFG_GLPI, $DB; $p['output_type'] = Search::HTML_OUTPUT; $p['row_num'] = 0; $p['type_for_massiveaction'] = 0; $p['id_for_massiveaction'] = 0; if (count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } $rand = mt_rand(); // Prints a job in short form // Should be called in a <table>-segment // Print links or not in case of user view // Make new job object and fill it from database, if success, print it $item = new static(); $candelete = static::canDelete(); $canupdate = Session::haveRight(static::$rightname, UPDATE); $align = "class='center"; $align_desc = "class='left"; $align .= "'"; $align_desc .= "'"; if ($item->getFromDB($id)) { $item_num = 1; $bgcolor = $_SESSION["glpipriority_" . $item->fields["priority"]]; echo Search::showNewLine($p['output_type'], $p['row_num'] % 2); $check_col = ''; if (($candelete || $canupdate) && $p['output_type'] == Search::HTML_OUTPUT && $p['id_for_massiveaction']) { $check_col = Html::getMassiveActionCheckBox($p['type_for_massiveaction'], $p['id_for_massiveaction']); } echo Search::showItem($p['output_type'], $check_col, $item_num, $p['row_num'], $align); $id_col = $item->fields["id"]; echo Search::showItem($p['output_type'], $id_col, $item_num, $p['row_num'], $align); // First column $first_col = ''; $color = ''; if ($item->fields["projectstates_id"]) { $query = "SELECT `color`\n FROM `glpi_projectstates`\n WHERE `id` = '" . $item->fields["projectstates_id"] . "'"; foreach ($DB->request($query) as $color) { $color = $color['color']; } $first_col = Dropdown::getDropdownName('glpi_projectstates', $item->fields["projectstates_id"]); } echo Search::showItem($p['output_type'], $first_col, $item_num, $p['row_num'], "{$align} bgcolor='{$color}'"); // Second column $second_col = sprintf(__('Opened on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['date'])); echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=130"); // Second BIS column $second_col = Html::convDateTime($item->fields["date_mod"]); echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=90"); // Second TER column if (count($_SESSION["glpiactiveentities"]) > 1) { $second_col = Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=100"); } // Third Column echo Search::showItem($p['output_type'], "<span class='b'>" . CommonITILObject::getPriorityName($item->fields["priority"]) . "</span>", $item_num, $p['row_num'], "{$align} bgcolor='{$bgcolor}'"); // Fourth Column $fourth_col = ""; if ($item->fields["users_id"]) { $userdata = getUserName($item->fields["users_id"], 2); $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false))); } echo Search::showItem($p['output_type'], $fourth_col, $item_num, $p['row_num'], $align); // Fifth column $fifth_col = ""; if ($item->fields["groups_id"]) { $fifth_col .= Dropdown::getDropdownName("glpi_groups", $item->fields["groups_id"]); $fifth_col .= "<br>"; } echo Search::showItem($p['output_type'], $fifth_col, $item_num, $p['row_num'], $align); // Eigth column $eigth_column = "<span class='b'>" . $item->fields["name"] . "</span> "; // Add link if ($item->canViewItem()) { $eigth_column = "<a id='" . $item->getType() . $item->fields["id"] . "{$rand}' href=\"" . $item->getLinkURL() . "&forcetab=Project\$\">{$eigth_column}</a>"; } if ($p['output_type'] == Search::HTML_OUTPUT) { $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip($item->fields['content'], array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . $rand))); } echo Search::showItem($p['output_type'], $eigth_column, $item_num, $p['row_num'], $align_desc . "width='200'"); // Finish Line echo Search::showEndLine($p['output_type']); } else { echo "<tr class='tab_bg_2'>"; echo "<td colspan='6' ><i>" . __('No item in progress.') . "</i></td></tr>"; } }
/** * @param $target * @param $date1 * @param $date2 * @param $start **/ static function showItems($target, $date1, $date2, $start) { global $DB, $CFG_GLPI; $view_entities = Session::isMultiEntitiesMode(); if ($view_entities) { $entities = getAllDatasFromTable('glpi_entities'); } $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } if (empty($date2)) { $date2 = date("Y-m-d"); } $date2 .= " 23:59:59"; // 1 an par defaut if (empty($date1)) { $date1 = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y") - 1)); } $date1 .= " 00:00:00"; $query = "SELECT `glpi_items_tickets`.`itemtype`,\n `glpi_items_tickets`.`items_id`,\n COUNT(*) AS NB\n FROM `glpi_tickets`\n LEFT JOIN `glpi_items_tickets`\n ON (`glpi_tickets`.`id` = `glpi_items_tickets`.`tickets_id`)\n WHERE `date` <= '{$date2}'\n AND `glpi_tickets`.`date` >= '{$date1}' " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n AND `glpi_items_tickets`.`itemtype` <> ''\n AND `glpi_items_tickets`.`items_id` > 0\n GROUP BY `glpi_items_tickets`.`itemtype`, `glpi_items_tickets`.`items_id`\n ORDER BY NB DESC"; $result = $DB->query($query); $numrows = $DB->numrows($result); if ($numrows > 0) { if ($output_type == Search::HTML_OUTPUT) { Html::printPager($start, $numrows, $target, "date1=" . $date1 . "&date2=" . $date2 . "&type=hardwares&start={$start}", 'Stat'); echo "<div class='center'>"; } $end_display = $start + $_SESSION['glpilist_limit']; if (isset($_GET['export_all'])) { $end_display = $numrows; } echo Search::showHeader($output_type, $end_display - $start + 1, 2, 1); $header_num = 1; echo Search::showNewLine($output_type); echo Search::showHeaderItem($output_type, _n('Associated element', 'Associated elements', 2), $header_num); if ($view_entities) { echo Search::showHeaderItem($output_type, __('Entity'), $header_num); } echo Search::showHeaderItem($output_type, __('Number of tickets'), $header_num); echo Search::showEndLine($output_type); $DB->data_seek($result, $start); $i = $start; if (isset($_GET['export_all'])) { $start = 0; } for ($i = $start; $i < $numrows && $i < $end_display; $i++) { $item_num = 1; // Get data and increment loop variables $data = $DB->fetch_assoc($result); if (!($item = getItemForItemtype($data["itemtype"]))) { continue; } if ($item->getFromDB($data["items_id"])) { echo Search::showNewLine($output_type, $i % 2); echo Search::showItem($output_type, sprintf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink()), $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : "")); if ($view_entities) { $ent = $item->getEntityID(); $ent = $entities[$ent]['completename']; echo Search::showItem($output_type, $ent, $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : "")); } echo Search::showItem($output_type, $data["NB"], $item_num, $i - $start + 1, "class='center'" . " " . ($item->isDeleted() ? " class='deleted' " : "")); } } echo Search::showFooter($output_type); if ($output_type == Search::HTML_OUTPUT) { echo "</div>"; } } }
/** *Print out list kb item * * @param $options : $_GET * @param $faq display on faq ? **/ static function showList($options, $faq = 0) { global $DB, $LANG, $CFG_GLPI; // Default values of parameters $params["start"] = "0"; $params["knowbaseitemcategories_id"] = "0"; $params["contains"] = ""; $params["target"] = $_SERVER['PHP_SELF']; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } // Lists kb Items $where = ""; $order = ""; $score = ""; // Build query if (getLoginUserID()) { $where = getEntitiesRestrictRequest("", "glpi_knowbaseitems", "", "", true) . " AND "; } else { // Anonymous access if (isMultiEntitiesMode()) { $where = " (`glpi_knowbaseitems`.`entities_id` = '0'\n AND `glpi_knowbaseitems`.`is_recursive` = '1')\n AND "; } } if ($faq) { // helpdesk $where .= " (`glpi_knowbaseitems`.`is_faq` = '1')\n AND "; } // a search with $contains if (strlen($params["contains"]) > 0) { $search = unclean_cross_side_scripting_deep($params["contains"]); $score = " ,MATCH(glpi_knowbaseitems.question, glpi_knowbaseitems.answer)\n AGAINST('{$search}' IN BOOLEAN MODE) AS SCORE "; $where_1 = $where . " MATCH(glpi_knowbaseitems.question, glpi_knowbaseitems.answer)\n AGAINST('{$search}' IN BOOLEAN MODE) "; $order = "ORDER BY `SCORE` DESC"; // preliminar query to allow alternate search if no result with fulltext $query_1 = "SELECT COUNT(`id`)\n FROM `glpi_knowbaseitems`\n WHERE {$where_1}"; $result_1 = $DB->query($query_1); $numrows_1 = $DB->result($result_1, 0, 0); if ($numrows_1 <= 0) { // not result this fulltext try with alternate search $search1 = array('/\\\\"/', "/\\+/", "/\\*/", "/~/", "/</", "/>/", "/\\(/", "/\\)/", "/\\-/"); $contains = preg_replace($search1, "", $params["contains"]); $where .= " (`glpi_knowbaseitems`.`question` " . makeTextSearch($contains) . "\n OR `glpi_knowbaseitems`.`answer` " . makeTextSearch($contains) . ")"; } else { $where = $where_1; } } else { // no search -> browse by category $where .= " (`glpi_knowbaseitems`.`knowbaseitemcategories_id`\n = '" . $params["knowbaseitemcategories_id"] . "')"; $order = " ORDER BY `glpi_knowbaseitems`.`question` ASC"; } if (!$params["start"]) { $params["start"] = 0; } $query = "SELECT `glpi_knowbaseitems`.*,\n `glpi_knowbaseitemcategories`.`completename` AS category\n {$score}\n FROM `glpi_knowbaseitems`\n LEFT JOIN `glpi_knowbaseitemcategories`\n ON (`glpi_knowbaseitemcategories`.`id`\n = `glpi_knowbaseitems`.`knowbaseitemcategories_id`)\n WHERE {$where}\n {$order}"; // Get it from database if ($result = $DB->query($query)) { $KbCategory = new KnowbaseItemCategory(); $title = ""; if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) { $title = $LANG['common'][36] . " = " . (empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name']); } initNavigateListItems('KnowbaseItem', $title); $numrows = $DB->numrows($result); $list_limit = $_SESSION['glpilist_limit']; // Limit the result, if no limit applies, use prior result if ($numrows > $list_limit && !isset($_GET['export_all'])) { $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " "; $result_limit = $DB->query($query_limit); $numrows_limit = $DB->numrows($result_limit); } else { $numrows_limit = $numrows; $result_limit = $result; } if ($numrows_limit > 0) { // Set display type for export if define $output_type = HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } // Pager $parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq={$faq}"; if (isset($options['tickets_id'])) { $parameters .= "&tickets_id=" . $options['tickets_id']; } if ($output_type == HTML_OUTPUT) { printPager($params['start'], $numrows, getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } $nbcols = 1; // Display List Header echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols); $header_num = 1; echo Search::showHeaderItem($output_type, $LANG['knowbase'][14], $header_num); if ($output_type != HTML_OUTPUT) { echo Search::showHeaderItem($output_type, $LANG['knowbase'][15], $header_num); } echo Search::showHeaderItem($output_type, $LANG['common'][36], $header_num); if (isset($options['tickets_id']) && $output_type == HTML_OUTPUT) { echo Search::showHeaderItem($output_type, ' ', $header_num); } // Num of the row (1=header_line) $row_num = 1; for ($i = 0; $i < $numrows_limit; $i++) { $data = $DB->fetch_array($result_limit); addToNavigateListItems('KnowbaseItem', $data["id"]); // Column num $item_num = 1; $row_num++; echo Search::showNewLine($output_type, $i % 2); if ($output_type == HTML_OUTPUT) { if (isset($options['tickets_id'])) { $href = " href='#' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=show_kb&id=" . $data['id'] . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' );w.focus();\""; } else { $href = " href=\"" . $params['target'] . "?id=" . $data["id"] . "\" "; } echo Search::showItem($output_type, "<div class='kb'><a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " {$href}>" . resume_text($data["question"], 80) . "</a></div>\n <div class='kb_resume'>" . resume_text(html_clean(unclean_cross_side_scripting_deep($data["answer"])), 600) . "</div>", $item_num, $row_num); } else { echo Search::showItem($output_type, $data["question"], $item_num, $row_num); echo Search::showItem($output_type, html_clean(unclean_cross_side_scripting_deep(html_entity_decode($data["answer"], ENT_QUOTES, "UTF-8"))), $item_num, $row_num); } echo Search::showItem($output_type, $data["category"], $item_num, $row_num); if (isset($options['tickets_id']) && $output_type == HTML_OUTPUT) { $content = "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?load_kb_sol=" . $data['id'] . "&id=" . $options['tickets_id'] . "&forcetab=4'>" . $LANG['job'][24] . "</a>"; echo Search::showItem($output_type, $content, $item_num, $row_num); } // End Line echo Search::showEndLine($output_type); } // Display footer if ($output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) { echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id'])); } else { echo Search::showFooter($output_type); } echo "<br>"; if ($output_type == HTML_OUTPUT) { printPager($params['start'], $numrows, getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } } else { if ($params["knowbaseitemcategories_id"] != 0) { echo "<div class='center b'>" . $LANG['search'][15] . "</div>"; } } } }