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 canView() { if (plugin_resources_haveRight('dropdown_public', 'r')) { return true; } return false; }
static function canView() { if (plugin_resources_haveRight('employment', 'r')) { return true; } return false; }
static function canView() { return plugin_resources_haveRight('budget', 'r'); }
static function canView() { return plugin_resources_haveRight('checklist', 'r'); }
/** * Show for PDF an resources - asociated devices * * @param $pdf object for the output * @param $ID of the resources */ static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli) { global $DB, $CFG_GLPI; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_resources_haveRight("resources", "r")) { return false; } $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . _n('Associated item', 'Associated items', 2) . '</b>'); $query = "SELECT DISTINCT `itemtype` \n FROM `glpi_plugin_resources_resources_items` \n WHERE `plugin_resources_resources_id` = '{$ID}' \n ORDER BY `itemtype` "; $result = $DB->query($query); $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(12, 27, 25, 18, 18); $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Entity'), __('Serial Number'), __('Inventory number') . '</i></b>'); } else { $pdf->setColumnsSize(25, 31, 22, 22); $pdf->displayTitle('<b><i>' . __('Type'), __('Name'), __('Serial Number'), __('Inventory number') . '</i></b>'); } if (!$number) { $pdf->displayLine(__('No item found')); } else { for ($i = 0; $i < $number; $i++) { $type = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($type))) { continue; } if ($item->canView()) { $column = "name"; $table = getTableForItemType($type); $items = new $type(); $query = "SELECT `" . $table . "`.*, `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_resources_resources_items`, `" . $table . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table . "`.`entities_id`) " . " WHERE `" . $table . "`.`id` = `glpi_plugin_resources_resources_items`.`items_id` \n AND `glpi_plugin_resources_resources_items`.`itemtype` = '{$type}' \n AND `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` = '{$ID}' "; if ($type != 'User') { $query .= getEntitiesRestrictRequest(" AND ", $table, '', '', $items->maybeRecursive()); } if ($items->maybeTemplate()) { $query .= " AND `" . $table . "`.`is_template` = '0'"; } $query .= " ORDER BY `glpi_entities`.`completename`, `" . $table . "`.`{$column}`"; if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { if (!$items->getFromDB($data["id"])) { continue; } $items_id_display = ""; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $items_id_display = " (" . $data["id"] . ")"; } if ($type == 'User') { $name = Html::clean(getUserName($data["id"])) . $items_id_display; } else { $name = $data["name"] . $items_id_display; } if ($type != 'User') { $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entity'])); } else { $entity = "-"; } if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(12, 27, 25, 18, 18); $pdf->displayLine($items->getTypeName(), $name, $entity, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-"); } else { $pdf->setColumnsSize(25, 31, 22, 22); $pdf->displayTitle($items->getTypeName(), $name, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-"); } } // Each device } } // numrows device } // type right } // each type } // numrows type }
/** * Show for PDF an resources : employee informations * * @param $pdf object for the output * @param $appli PluginResourcesResource Class */ static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli) { global $DB; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_resources_haveRight("resources", "r")) { return false; } $query = "SELECT * \n FROM `glpi_plugin_resources_employees` \n WHERE `plugin_resources_resources_id` = '{$ID}'"; $result = $DB->query($query); $number = $DB->numrows($result); $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . self::getTypeName(1) . '</b>'); $pdf->setColumnsSize(33, 33, 34); $pdf->displayTitle('<b><i>' . PluginResourcesEmployer::getTypeName(1), PluginResourcesClient::getTypeName(1) . '</i></b>'); if (!$number) { $pdf->displayLine(__('No item found')); } else { for ($i = 0; $i < $number; $i++) { $employer = $DB->result($result, $i, "plugin_resources_employers_id"); $client = $DB->result($result, $i, "plugin_resources_clients_id"); $pdf->displayLine(Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_employers", $employer)), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_clients", $client))); } } $pdf->displaySpace(); }
function plugin_resources_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB; $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; } switch ($type) { case 'PluginResourcesResource': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["ITEM_" . $num . "_2"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResource'); $out = ""; if ($output_type == Search::HTML_OUTPUT) { $out = "<a href=\"" . $link . "?id=" . $data["ITEM_" . $num . "_2"] . "\">"; } $out .= $data["META_{$num}"]; if ($output_type == Search::HTML_OUTPUT) { if ($_SESSION["glpiis_ids_visible"] || empty($data["META_{$num}"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } if (plugin_resources_haveRight("task", "r") && $output_type == Search::HTML_OUTPUT) { $query_tasks = "SELECT COUNT(`id`) AS nb_tasks,SUM(`is_finished`) AS is_finished\n FROM `glpi_plugin_resources_tasks`\n WHERE `plugin_resources_resources_id` = '" . $data['id'] . "'\n AND `is_deleted` = '0'"; $result_tasks = $DB->query($query_tasks); $nb_tasks = $DB->result($result_tasks, 0, "nb_tasks"); $is_finished = $DB->result($result_tasks, 0, "is_finished"); $out .= " (<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?plugin_resources_resources_id=" . $data["id"] . "\">"; if ($nb_tasks - $is_finished > 0) { $out .= "<span class='plugin_resources_date_over_color'>"; $out .= $nb_tasks - $is_finished . "</span></a>)"; } else { $out .= "<span class='plugin_resources_date_day_color'>"; $out .= $nb_tasks . "</span></a>)"; } } } return $out; break; case "glpi_plugin_resources_resources.date_end": if ($data["ITEM_{$num}"] <= date('Y-m-d') && !empty($data["ITEM_{$num}"])) { $out = "<span class='plugin_resources_date_color'>" . Html::convDate($data["ITEM_{$num}"]) . "</span>"; } else { if (empty($data["ITEM_{$num}"])) { $out = __('Not defined', 'resources'); } else { $out = Html::convDate($data["ITEM_{$num}"]); } } return $out; break; case "glpi_plugin_resources_resources_items.items_id": $restrict = "`plugin_resources_resources_id` = '" . $data['id'] . "'\n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { if (!class_exists($device["itemtype"])) { continue; } $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - "; if ($device["itemtype"] == 'User') { if ($output_type == Search::HTML_OUTPUT) { $link = Toolbox::getItemTypeFormURL('User'); $out .= "<a href=\"" . $link . "?id=" . $device["items_id"] . "\">"; } $out .= getUserName($device["items_id"]); if ($output_type == Search::HTML_OUTPUT) { $out .= "</a>"; } } else { $out .= $item->getLink(); } $out .= "<br>"; } } else { $out = ' '; } return $out; break; case "glpi_plugin_resources_resources.quota": if (!empty($data["ITEM_{$num}"])) { $out = floatval($data["ITEM_{$num}"]); } return $out; break; } return ""; break; case 'PluginResourcesTask': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $user = PluginResourcesResource::getResourceName($data["ITEM_" . $num . "_2"], 2); $out = "<a href='" . $user['link'] . "'>"; $out .= $user["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($user["name"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } return $out; break; case 'glpi_plugin_resources_tasks.is_finished': $status = PluginResourcesTask::getStatus($data["ITEM_{$num}"]); return "<img src=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/" . $data["ITEM_{$num}"] . ".png\"\n alt='{$status}' title='{$status}'> {$status}"; break; case "glpi_plugin_resources_tasks_items.items_id": $restrict = "`plugin_resources_tasks_id` = '" . $data['id'] . "'\n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_resources_tasks_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - " . $item->getLink() . "<br>"; } } return $out; break; case "glpi_plugin_resources_taskplannings.id": if (!empty($data["ITEM_{$num}"])) { $plan = new PluginResourcesTaskPlanning(); $plan->getFromDB($data["ITEM_{$num}"]); $out = Html::convDateTime($plan->fields["begin"]) . "<br> -> " . Html::convDateTime($plan->fields["end"]); } else { $out = __('None'); } return $out; break; } return ""; break; case 'User': switch ($table . '.' . $field) { case "glpi_plugin_resources_recipients.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; case "glpi_plugin_resources_recipients_leaving.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; case "glpi_plugin_resources_managers.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; } return ""; break; case 'PluginResourcesResourceResting': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["id"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResourceResting'); $out = "<a href=\"" . $link . "?id=" . $data["id"] . "\">"; $out .= $data["ITEM_{$num}"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["id"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; case 'PluginResourcesResourceHoliday': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["id"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResourceHoliday'); $out = "<a href=\"" . $link . "?id=" . $data["id"] . "\">"; $out .= $data["ITEM_{$num}"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["id"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; case 'PluginResourcesDirectory': switch ($table . '.' . $field) { case "glpi_plugin_resources_managers.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $out = getUserName($data["ITEM_" . $num . "_2"]); } return $out; break; } return ""; break; case 'PluginResourcesEmployment': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $user = PluginResourcesResource::getResourceName($data["ITEM_" . $num . "_2"], 2); $out = "<a href='" . $user['link'] . "'>"; $out .= $user["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($user["name"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; } return ""; }
function showChildrensTab() { return plugin_resources_haveRight('resources', 'w') && count($_SESSION['glpiactiveentities']) > 1; }
static function showReports($ID, $withtemplate = '') { global $DB, $CFG_GLPI; $rand = mt_rand(); $resource = new PluginResourcesResource(); $resource->getFromDB($ID); $canedit = $resource->can($ID, 'w'); Session::initNavigateListItems("PluginResourcesReportConfig", PluginResourcesResource::getTypeName(1) . " = " . $resource->fields["name"]); $query = "SELECT `glpi_plugin_resources_reportconfigs`.`id`,\n `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id`,\n `glpi_plugin_resources_reportconfigs`.`information`, \n `glpi_plugin_resources_reportconfigs`.`comment`\n FROM `glpi_plugin_resources_reportconfigs` "; $query .= " LEFT JOIN `glpi_plugin_resources_resources` ON (`glpi_plugin_resources_resources`.`id` = `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id`)"; $query .= " WHERE `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id` = '{$ID}'"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; $row_num = 1; if ($number != "0") { if ($withtemplate < 2) { echo "<form method='post' name='form_reports{$rand}' id='form_reports{$rand}' action=\"./reportconfig.form.php\">"; } echo "<div align='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='5'>" . self::getTypeName(1) . "</th></tr>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<tr>"; if (plugin_resources_haveRight('resources', 'w') && $canedit && $withtemplate < 2) { echo "<th> </th>"; } echo "<th>" . __('Comments') . "</th>"; echo "<th>" . __('Information', 'Informations', 2) . "</th>"; if ($withtemplate < 2) { echo "<th> </th>"; } echo "</tr>"; while ($data = $DB->fetch_array($result)) { Session::addToNavigateListItems("PluginResourcesReportConfig", $data['id']); $i++; $row_num++; echo "<tr class='tab_bg_1 center'>"; if (plugin_resources_haveRight('resources', 'w') && $canedit && $withtemplate < 2) { echo "<td width='10'>"; echo "<input type='checkbox' name='check[" . $data["id"] . "]'"; if (isset($_POST['check']) && $_POST['check'] == 'all') { echo " checked "; } echo ">"; echo "</td>"; } echo "<td class='left'>" . nl2br($data["comment"]) . "</td>"; echo "<td class='left'>" . nl2br($data["information"]) . "</td>"; if ($withtemplate < 2) { echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/reportconfig.form.php?id=" . $data["id"] . "&plugin_resources_resources_id=" . $data["plugin_resources_resources_id"] . "'>"; _e('Update'); if ($_SESSION["glpiis_ids_visible"]) { echo " (" . $data["id"] . ")"; } echo "</a></td>"; } echo "</tr>"; } echo "</table></div>"; if ($number && $canedit && $withtemplate < 2) { if (plugin_resources_haveRight('resources', 'w')) { Html::openArrowMassives("form_reports{$rand}", true); Html::closeArrowMassives(array('delete_report' => _sx('button', 'Delete permanently'))); } } if ($withtemplate < 2) { Html::closeForm(); } } }
static function canView() { return plugin_resources_haveRight('resources', 'w'); }
static function canView() { return plugin_resources_haveRight('employment', 'r'); }
/** * Show for PDF an resources : checklists informations * * @param $pdf object for the output * @param $ID of the resources */ static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli, $checklist_type) { global $DB; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_resources_haveRight("resources", "r")) { return false; } $query = "SELECT * \n FROM `glpi_plugin_resources_checklists` \n WHERE `plugin_resources_resources_id` = '{$ID}' \n AND `checklist_type` = '{$checklist_type}' \n ORDER BY `rank` "; $result = $DB->query($query); $number = $DB->numrows($result); $i = $j = 0; $pdf->setColumnsSize(100); if ($number > 0) { $pdf->displayTitle('<b>' . self::getChecklistType($checklist_type) . '</b>'); $pdf->setColumnsSize(85, 10, 5); $pdf->displayTitle('<b><i>' . __('Name'), __('Linked task', 'resources'), __('Checked', 'resources') . '</i></b>'); $i++; while ($j < $number) { $checkedID = $DB->result($result, $j, "is_checked"); $name = $DB->result($result, $j, "name"); $task_id = $DB->result($result, $j, "plugin_resources_tasks_id"); if ($checkedID == 1) { $checked = __('Yes'); } else { $checked = __('No'); } $pdf->displayLine($name, Dropdown::getYesNo($task_id), $checked); $j++; } } else { $pdf->displayLine(__('No checklist found', 'resources')); } $pdf->displaySpace(); }
/** * Display menu */ function showMenu() { global $CFG_GLPI; echo "<div align='center'><table class='tab_cadre' width='30%' cellpadding='5'>"; echo "<tr><th colspan='4'>" . __('Menu', 'resources') . "</th></tr>"; $canresting = plugin_resources_haveRight('resting', 'w'); $canholiday = plugin_resources_haveRight('holiday', 'w'); $canemployment = plugin_resources_haveRight('employment', 'w'); $canseeemployment = plugin_resources_haveRight('employment', 'r'); $canseebudget = plugin_resources_haveRight('budget', 'r'); $colspan = "1"; $colspan2 = "1"; if (!$this->canCreate()) { $colspan += 3; } if (!$canresting || !$canholiday) { $colspan2 += 1; } echo "<tr><th colspan='4'>" . __('Resources management', 'resources') . "</th></tr>"; echo "<tr class='tab_bg_1'>"; if ($this->canCreate()) { //Add a resource echo "<td class='center'>"; echo "<a href=\"./wizard.form.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/newresource.png' alt='" . __('Declare an arrival', 'resources') . "'>"; echo "<br>" . __('Declare an arrival', 'resources') . "</a>"; echo "</td>"; //See resources echo "<td class='center'>"; echo "<a href=\"./resource.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/resourcelist.png' alt='" . __('Search resources', 'resources') . "'>"; echo "<br>" . __('Search resources', 'resources') . "</a>"; echo "</td>"; //Remove resources echo "<td class='center'>"; echo "<a href=\"./resource.remove.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/removeresource.png' alt='" . __('Declare a departure', 'resources') . "'>"; echo "<br>" . __('Declare a departure', 'resources') . "</a>"; echo "</td>"; } echo "<td colspan='{$colspan}' class='center'>"; echo "<a href=\"./directory.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/directory.png' alt='" . PluginResourcesDirectory::getTypeName(1) . "'>"; echo "<br>" . PluginResourcesDirectory::getTypeName(1) . "</a>"; echo "</td>"; echo "</tr>"; if ($canresting || $canholiday) { echo "<tr><th colspan='4'>" . __('Others declarations', 'resources') . "</th></tr>"; echo "<tr class='tab_bg_1'>"; if ($canresting) { //Add resting resource echo "<td colspan='{$colspan2}' class='center'>"; echo "<a href=\"./resourceresting.form.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/newresting.png' alt='" . __('Declare a non contract period', 'resources') . "'>"; echo "<br>" . __('Declare a non contract period', 'resources') . "</a>"; echo "</td>"; //List resting resource echo "<td colspan='{$colspan2}' class='center'>"; echo "<a href=\"./resourceresting.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/restinglist.png' alt='" . __('List of non contract periods', 'resources') . "'>"; echo "<br>" . __('List of non contract periods', 'resources') . "</a>"; echo "</td>"; } if ($canholiday) { echo "<td colspan='{$colspan2}' class='center'>"; echo "<a href=\"./resourceholiday.form.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/holidayresource.png' alt='" . __('Declare a forced holiday', 'resources') . "'>"; echo "<br>" . __('Declare a forced holiday', 'resources') . "</a>"; echo "</td>"; echo "<td colspan='{$colspan2}' class='center'>"; echo "<a href=\"./resourceholiday.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/holidaylist.png' alt='" . __('List of forced holidays', 'resources') . "'>"; echo "<br>" . __('List of forced holidays', 'resources') . "</a>"; echo "</td>"; } echo "</tr>"; } if ($canseeemployment || $canseebudget) { echo "<tr><th colspan='4'>" . __('Employments / budgets management', 'resources') . "</th></tr>"; echo "<tr class='tab_bg_1'>"; if ($canseeemployment) { if ($canemployment) { //Add an employment echo "<td class='center'>"; echo "<a href=\"./employment.form.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/employment.png' alt='" . __('Declare an employment', 'resources') . "'>"; echo "<br>" . __('Declare an employment', 'resources') . "</a>"; echo "</td>"; } //See managment employments echo "<td class='center'>"; echo "<a href=\"./employment.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/employmentlist.png' alt='" . __('Employment management', 'resources') . "'>"; echo "<br>" . __('Employment management', 'resources') . "</a>"; echo "</td>"; } if ($canseebudget) { //See managment budgets echo "<td class='center'>"; echo "<a href=\"./budget.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/budgetlist.png' alt='" . __('Budget management', 'resources') . "'>"; echo "<br>" . __('Budget management', 'resources') . "</a>"; echo "</td>"; } if ($canseeemployment) { //See recap ressource / employment echo "<td class='center'>"; echo "<a href=\"./recap.php\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/recap.png' alt='" . __('List Employments / Resources', 'resources') . "'>"; echo "<br>" . __('List Employments / Resources', 'resources') . "</a>"; echo "</td>"; } echo "</tr>"; } echo " </table></div>"; }
function getActions() { $actions = array(); $actions['requiredfields_name']['name'] = __('Name'); $actions['requiredfields_name']['type'] = "yesonly"; $actions['requiredfields_name']['force_actions'] = array('assign'); $actions['requiredfields_name']['type'] = "yesonly"; $actions['requiredfields_firstname']['name'] = __('First name'); $actions['requiredfields_firstname']['type'] = "yesonly"; $actions['requiredfields_firstname']['force_actions'] = array('assign'); $actions['requiredfields_locations_id']['name'] = __('Location'); $actions['requiredfields_locations_id']['type'] = "yesonly"; $actions['requiredfields_locations_id']['force_actions'] = array('assign'); $actions['requiredfields_users_id']['name'] = __('Resource manager', 'resources'); $actions['requiredfields_users_id']['type'] = "yesonly"; $actions['requiredfields_users_id']['force_actions'] = array('assign'); $actions['requiredfields_plugin_resources_departments_id']['name'] = PluginResourcesDepartment::getTypeName(1); $actions['requiredfields_plugin_resources_departments_id']['type'] = "yesonly"; $actions['requiredfields_plugin_resources_departments_id']['force_actions'] = array('assign'); $actions['requiredfields_date_begin']['name'] = __('Arrival date', 'resources'); $actions['requiredfields_date_begin']['type'] = "yesonly"; $actions['requiredfields_date_begin']['force_actions'] = array('assign'); $actions['requiredfields_date_end']['name'] = __('Departure date', 'resources'); $actions['requiredfields_date_end']['type'] = "yesonly"; $actions['requiredfields_date_end']['force_actions'] = array('assign'); $actions['requiredfields_quota']['name'] = __('Quota', 'resources'); $actions['requiredfields_quota']['type'] = "yesonly"; $actions['requiredfields_quota']['force_actions'] = array('assign'); if (plugin_resources_haveRight('dropdown_public', 'w')) { $actions['requiredfields_plugin_resources_resourcesituations_id']['name'] = PluginResourcesResourceSituation::getTypeName(1); $actions['requiredfields_plugin_resources_resourcesituations_id']['type'] = "yesonly"; $actions['requiredfields_plugin_resources_resourcesituations_id']['force_actions'] = array('assign'); $actions['requiredfields_plugin_resources_ranks_id']['name'] = PluginResourcesRank::getTypeName(1); $actions['requiredfields_plugin_resources_ranks_id']['type'] = "yesonly"; $actions['requiredfields_plugin_resources_ranks_id']['force_actions'] = array('assign'); } return $actions; }
/** * Show for PDF an resources : tasks informations * * @param $pdf object for the output * @param $ID of the resources */ static function pdfForResource(PluginPdfSimplePDF $pdf, PluginResourcesResource $appli) { global $DB; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_resources_haveRight("resources", "r")) { return false; } $query = "SELECT * \n FROM `glpi_plugin_resources_tasks` \n WHERE `plugin_resources_resources_id` = '{$ID}'\n AND `is_deleted` ='0'"; $result = $DB->query($query); $number = $DB->numrows($result); $i = $j = 0; $pdf->setColumnsSize(100); if ($number > 0) { $pdf->displayTitle('<b>' . self::getTypeName(2) . '</b>'); $pdf->setColumnsSize(14, 14, 14, 14, 16, 14, 14); $pdf->displayTitle('<b><i>' . __('Name'), __('Type'), __('Comments'), __('Duration'), __('Planning'), __('Resource manager', 'resources'), __('Group') . '</i></b>'); $i++; while ($j < $number) { $tID = $DB->result($result, $j, "id"); $actiontime_ID = $DB->result($result, $j, "actiontime"); $actiontime = ''; $units = Toolbox::getTimestampTimeUnits($actiontime_ID); $hour = $units['hour']; $minute = $units['minute']; if ($hour) { $actiontime = $hour . __('Hour', 'Hours', 2); } if ($minute || !$hour) { $actiontime .= $minute . __('Minute', 'Minutes', 2); } $restrict = " `plugin_resources_tasks_id` = '" . $tID . "' "; $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict); if (!empty($plans)) { foreach ($plans as $plan) { $planification = Html::convDateTime($plan["begin"]) . " -> " . Html::convDateTime($plan["end"]); } } else { $planification = __('None'); } $users_id = $DB->result($result, $j, "users_id"); $managers = Html::clean(getUserName($users_id)); $name = $DB->result($result, $j, "name"); $task_type = $DB->result($result, $j, "plugin_resources_tasktypes_id"); $comment = $DB->result($result, $j, "comment"); $groups_id = $DB->result($result, $j, "groups_id"); $pdf->displayLine(Html::clean($name), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_tasktypes", $task_type)), $comment, $actiontime, Html::clean($planification), $managers, Html::clean(Dropdown::getDropdownName("glpi_groups", $groups_id))); $j++; } } else { $pdf->displayLine(__('No item found')); } $pdf->displaySpace(); }
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; //central or helpdesk access if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); } else { Html::helpHeader(PluginResourcesResource::getTypeName(2)); } $resource = new PluginResourcesResource(); if ($resource->canView() || Session::haveRight("config", "w")) { if (plugin_resources_haveRight("all", "w")) { //Have right to see all resources //Have not right to see all resources echo "<div align='center'><script type='text/javascript'>"; echo "cleanhide('modal_resource_content');"; echo "var account_window=new Ext.Window({\n layout:'fit',\n width:800,\n height:400,\n closeAction:'hide',\n modal: true,\n autoScroll: true,\n title: \"" . __('View by contract type', 'resources') . "\",\n autoLoad: '" . $CFG_GLPI['root_doc'] . "/plugins/resources/ajax/resourcetree.php'\n });"; echo "</script>"; echo "<a onclick='account_window.show();' href='#modal_resource_content' title='" . __('View by contract type', 'resources') . "'>" . __('View by contract type', 'resources') . "</a>"; echo "</div>"; } Search::show("PluginResourcesResource", $_GET); } else { Html::displayRightError(); } if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::footer();
function plugin_init_resources() { global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['resources'] = true; $PLUGIN_HOOKS['change_profile']['resources'] = array('PluginResourcesProfile', 'changeProfile'); $PLUGIN_HOOKS['assign_to_ticket']['resources'] = true; if (Session::getLoginUserID()) { $noupdate = false; if (isset($_SESSION['glpiactiveprofile']['interface']) && $_SESSION['glpiactiveprofile']['interface'] != 'central') { $noupdate = true; } Plugin::registerClass('PluginResourcesResource', array('linkuser_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'notificationtemplates_types' => true, 'unicity_types' => true, 'massiveaction_nodelete_types' => $noupdate, 'massiveaction_noupdate_types' => $noupdate)); Plugin::registerClass('PluginResourcesDirectory', array('massiveaction_nodelete_types' => true, 'massiveaction_noupdate_types' => true)); Plugin::registerClass('PluginResourcesRecap', array('massiveaction_nodelete_types' => true, 'massiveaction_noupdate_types' => true)); Plugin::registerClass('PluginResourcesTaskPlanning', array('planning_types' => true)); Plugin::registerClass('PluginResourcesRuleChecklistCollection', array('rulecollections_types' => true)); Plugin::registerClass('PluginResourcesRuleContracttypeCollection', array('rulecollections_types' => true)); Plugin::registerClass('PluginResourcesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginResourcesEmployment', array('massiveaction_nodelete_types' => true)); if (class_exists('PluginPositionsPosition')) { PluginPositionsPosition::registerType('PluginResourcesResource'); //$PLUGIN_HOOKS['plugin_positions']['PluginResourcesResource']='plugin_resources_positions_pics'; } if (class_exists('PluginBehaviorsCommon')) { PluginBehaviorsCommon::addCloneType('PluginResourcesRuleChecklist', 'PluginBehaviorsRule'); PluginBehaviorsCommon::addCloneType('PluginResourcesRuleContracttype', 'PluginBehaviorsRule'); } if (class_exists('PluginTreeviewConfig')) { PluginTreeviewConfig::registerType('PluginResourcesResource'); $PLUGIN_HOOKS['treeview']['PluginResourcesResource'] = '../resources/pics/miniresources.png'; $PLUGIN_HOOKS['treeview_params']['resources'] = array('PluginResourcesResource', 'showResourceTreeview'); } if (plugin_resources_haveRight("resources", "r") || plugin_resources_haveRight("employer", "w")) { $PLUGIN_HOOKS['menu_entry']['resources'] = 'front/menu.php'; $PLUGIN_HOOKS['helpdesk_menu_entry']['resources'] = '/front/menu.php'; $PLUGIN_HOOKS['submenu_entry']['resources']['search'] = 'front/resource.php'; $PLUGIN_HOOKS['redirect_page']['resources'] = "front/resource.form.php"; $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/directory18.png' title='" . __('Directory', 'resources') . "' alt='" . __('Directory', 'resources') . "'>"] = 'front/directory.php'; } if (plugin_resources_haveRight("resting", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/restinglist18.png' title='" . __('List of non contract periods', 'resources') . "' alt='" . __('List of non contract periods', 'resources') . "'>"] = 'front/resourceresting.php'; } if (plugin_resources_haveRight("holiday", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/holidaylist18.png' title='" . __('List of forced holidays', 'resources') . "' alt='" . __('List of forced holidays', 'resources') . "'>"] = 'front/resourceholiday.php'; } if (plugin_resources_haveRight("employment", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/employmentlist18.png' title='" . __('Employment management', 'resources') . "' alt='" . __('Employment management', 'resources') . "'>"] = 'front/employment.php'; $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/recap18.png' title='" . __('List Employments / Resources', 'resources') . "' alt='" . __('List Employments / Resources', 'resources') . "'>"] = 'front/recap.php'; } if (plugin_resources_haveRight("budget", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/budgetlist18.png' title='" . __('Budget management', 'resources') . "' alt='" . __('Budget management', 'resources') . "'>"] = 'front/budget.php'; } if (plugin_resources_haveRight("resources", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['add'] = 'front/wizard.form.php'; $PLUGIN_HOOKS['submenu_entry']['resources']['template'] = 'front/setup.templates.php?add=0'; if (plugin_resources_haveRight("task", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __('Tasks list', 'resources') . "' alt='" . __('Tasks list', 'resources') . "'>"] = 'front/task.php'; } if (plugin_resources_haveRight("checklist", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']["<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png' title='" . _n('Checklist', 'Checklists', 2, 'resources') . "' alt='" . _n('Checklist', 'Checklists', 2, 'resources') . "'>"] = 'front/checklistconfig.php'; } if (plugin_resources_haveRight("checklist", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['title'] = __('Checklists', 'resources'); $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['page'] = '/plugins/resources/front/checklistconfig.php'; $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['search'] = '/plugins/resources/front/checklistconfig.php'; } if (plugin_resources_haveRight("checklist", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['add'] = '/plugins/resources/front/checklistconfig.form.php?new=1'; } if (plugin_resources_haveRight("employment", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['title'] = __('Employments', 'resources'); $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['page'] = '/plugins/resources/front/employment.php'; $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['links']['search'] = '/plugins/resources/front/employment.php'; } if (plugin_resources_haveRight("employment", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['employment']['links']['add'] = '/plugins/resources/front/employment.form.php'; } if (plugin_resources_haveRight("budget", "r")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['title'] = _n('Budget', 'Budgets', 2); $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['page'] = '/plugins/resources/front/budget.php'; $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['links']['search'] = '/plugins/resources/front/budget.php'; } if (plugin_resources_haveRight("budget", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['budget']['links']['add'] = '/plugins/resources/front/budget.form.php'; } if (Session::haveRight("config", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['options']['checklist']['links']['config'] = '/plugins/resources/front/config.form.php'; } $PLUGIN_HOOKS['use_massive_action']['resources'] = 1; } // Add specific files to add to the header : javascript or css $PLUGIN_HOOKS['add_javascript']['resources'] = "resources.js"; $PLUGIN_HOOKS['add_css']['resources'] = "resources.css"; //TODO : Check $PLUGIN_HOOKS['plugin_pdf']['PluginResourcesResource'] = 'PluginResourcesResourcePDF'; //Clean Plugin on Profile delete if (class_exists('PluginResourcesResource_Item')) { // only if plugin activated $PLUGIN_HOOKS['pre_item_purge']['resources'] = array('Profile' => array('PluginResourcesProfile', 'purgeProfiles')); $PLUGIN_HOOKS['plugin_datainjection_populate']['resources'] = 'plugin_datainjection_populate_resources'; } //planning action $PLUGIN_HOOKS['planning_populate']['resources'] = array('PluginResourcesTaskPlanning', 'populatePlanning'); $PLUGIN_HOOKS['display_planning']['resources'] = array('PluginResourcesTaskPlanning', 'displayPlanningItem'); $PLUGIN_HOOKS['migratetypes']['resources'] = 'plugin_datainjection_migratetypes_resources'; // Config page if (Session::haveRight("config", "w")) { $PLUGIN_HOOKS['submenu_entry']['resources']['config'] = 'front/config.form.php'; $PLUGIN_HOOKS['config_page']['resources'] = 'front/config.form.php'; } } // End init, when all types are registered $PLUGIN_HOOKS['post_init']['resources'] = 'plugin_resources_postinit'; }