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 checkWizardSetup($ID, $field) { global $DB; if ($ID > 0) { $resource = new PluginResourcesResource(); $self = new self(); if ($resource->getFromDB($ID)) { if ($self->getFromDB($resource->fields["plugin_resources_contracttypes_id"])) { if ($self->fields[$field] > 0) { return true; } } } } return false; }
function plugin_init_badges() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['badges'] = true; $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true; $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'initProfile'); if (Session::getLoginUserID()) { Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask')); if (class_exists('PluginResourcesResource')) { PluginResourcesResource::registerType('PluginBadgesBadge'); } $plugin = new Plugin(); if (!$plugin->isActivated('environment') && Session::haveRight("plugin_badges", READ)) { $PLUGIN_HOOKS['menu_toadd']['badges'] = array('assets' => 'PluginBadgesMenu'); } if (Session::haveRight("plugin_badges", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['badges'] = 1; } if (class_exists('PluginBadgesBadge')) { // only if plugin activated $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges'; } // Import from Data_Injection plugin $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges'; } }
function plugin_init_badges() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['badges'] = true; $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'changeProfile'); $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true; if (Session::getLoginUserID()) { Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask')); if (class_exists('PluginResourcesResource')) { PluginResourcesResource::registerType('PluginBadgesBadge'); } if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) { $_SESSION["glpi_plugin_environment_badges"] = 1; if (plugin_badges_haveRight("badges", "r")) { $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['title'] = PluginBadgesBadge::getTypeName(2); $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['page'] = '/plugins/badges/front/badge.php'; $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['search'] = '/plugins/badges/front/badge.php'; } if (plugin_badges_haveRight("badges", "w")) { $PLUGIN_HOOKS['submenu_entry']['environment']['options']['badges']['links']['add'] = '/plugins/badges/front/badge.form.php'; } } else { if (plugin_badges_haveRight("badges", "r")) { $PLUGIN_HOOKS['menu_entry']['badges'] = 'front/badge.php'; $PLUGIN_HOOKS['submenu_entry']['badges']['search'] = 'front/badge.php'; } if (plugin_badges_haveRight("badges", "w")) { $PLUGIN_HOOKS['submenu_entry']['badges']['add'] = 'front/badge.form.php?new=1'; } } if (class_exists('PluginBadgesBadge')) { // only if plugin activated //Clean Plugin on Profile delete $PLUGIN_HOOKS['pre_item_purge']['badges'] = array('Profile ' => array('PluginBadgesProfile', 'purgeProfiles')); $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges'; } // Import from Data_Injection plugin $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges'; } }
Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; $resource = new PluginResourcesResource(); $employee = new PluginResourcesEmployee(); $choice = new PluginResourcesChoice(); $resource->checkGlobal("r"); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { //from central Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); } else { //from helpdesk Html::helpHeader(PluginResourcesResource::getTypeName(2)); } if (isset($_POST["first_step"]) || isset($_GET["first_step"])) { if (!isset($_POST["template"])) { $_POST["template"] = $_GET["template"]; } if (!isset($_POST["withtemplate"])) {
/** * 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(); }
/** * 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(); }
/** * 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(); }
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); } } }
This file is part of Resources. Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources", "employment"); $employment = new PluginResourcesEmployment(); if ($employment->canView() || Session::haveRight("config", "w")) { Search::manageGetValues("PluginResourcesEmployment"); if (isset($_GET["plugin_resources_resources_id"]) && !empty($_GET["plugin_resources_resources_id"])) { $_GET["field"] = array(0 => "13"); $_GET["contains"] = array(0 => $_GET["plugin_resources_resources_id"]); } Search::showGenericSearch("PluginResourcesEmployment", $_GET); Search::showList("PluginResourcesEmployment", $_GET); } else { Html::displayRightError(); } Html::footer();
------------------------------------------------------------------------- Resources plugin for GLPI Copyright (C) 2006-2012 by the Resources Development Team. https://forge.indepnet.net/projects/resources ------------------------------------------------------------------------- LICENSE This file is part of Resources. Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; if (isset($_GET["file"])) { PluginResourcesResource::sendFile(GLPI_PLUGIN_DOC_DIR . "/resources/" . $_GET["file"], $_GET["file"]); } else { Html::displayRightError(); }
// Send UTF8 Headers header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); if (isset($_REQUEST["table"]) && isset($_REQUEST["value"])) { // Security if (!TableExists($_REQUEST['table'])) { exit; } switch ($_REQUEST["table"]) { case "glpi_plugin_resources_resources": if ($_REQUEST['value'] == 0) { $tmpname['link'] = $CFG_GLPI['root_doc'] . "/plugins/resources/front/resource.php"; $tmpname['comment'] = ""; } else { $tmpname = PluginResourcesResource::getResourceName($_REQUEST["value"], 2); } echo $tmpname["comment"]; if (isset($_REQUEST['withlink'])) { echo "<script type='text/javascript' >\n"; echo "Ext.get('" . $_REQUEST['withlink'] . "').dom.href='" . $tmpname['link'] . "';"; echo "</script>\n"; } break; default: if ($_REQUEST["value"] > 0) { $tmpname = Dropdown::getDropdownName($_REQUEST["table"], $_REQUEST["value"], 1); echo $tmpname["comment"]; } } }
(at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; //from helpdesk Html::helpHeader(PluginResourcesResource::getTypeName(2)); $choice = new PluginResourcesChoice(); $resource = new PluginResourcesResource(); //add items needs from helpdesk if (isset($_POST["addhelpdeskitem"])) { if ($_POST['plugin_resources_choiceitems_id'] > 0 && $_POST['plugin_resources_resources_id'] > 0) { if ($resource->canCreate()) { $choice->addHelpdeskItem($_POST); } } Html::back(); } else { if (isset($_POST["deletehelpdeskitem"])) { if ($resource->canCreate()) { $choice->delete(array('id' => $_POST["id"])); } Html::back(); //next step : email and finish resource creation
/** * Display the cost's form * * @param $ID * @param array $options * @return bool */ function showForm($ID, $options = array("")) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showTabs($options); $this->showFormHeader($options); $fields = $this->getAdditionalFields(); $nb = count($fields); echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>"; echo __('Comments') . "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>\n <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Profession', 'resources') . "</td>"; echo "<td>"; $params = array('name' => 'plugin_resources_professions_id', 'value' => $this->fields['plugin_resources_professions_id'], 'entity' => $this->fields["entities_id"], 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownRank.php", 'span' => 'span_rank', 'sort' => false); PluginResourcesResource::showGenericDropdown('PluginResourcesProfession', $params); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Rank', 'resources') . "</td><td>"; echo "<span id='span_rank' name='span_rank'>"; if ($this->fields["plugin_resources_ranks_id"] > 0) { echo Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->fields["plugin_resources_ranks_id"]); } else { _e('None'); } echo "</span></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Begin date') . "</td>"; echo "<td>"; Html::showDateFormItem("begin_date", $this->fields["begin_date"], true, true); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('End date') . "</td>"; echo "<td>"; Html::showDateFormItem("end_date", $this->fields["end_date"], true, true); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Budget cost', 'resources') . "</td>"; echo "<td>"; echo "<input type='text' name='cost' value='" . Html::formatNumber($this->fields["cost"], true) . "' size='14'></td></tr>"; if (isset($this->fields['is_protected']) && $this->fields['is_protected']) { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * Display a Planning Item * * @param $parm Array of the item to display * @return Nothing (display function) **/ static function displayPlanningItem(array $val, $who, $type = "", $complete = 0) { global $CFG_GLPI; $rand = mt_rand(); echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.form.php?id=" . $val["id"] . "'"; echo " onmouseout=\"cleanhide('content_task_" . $val["id"] . $rand . "')\" \n onmouseover=\"cleandisplay('content_task_" . $val["id"] . $rand . "')\""; echo ">"; switch ($type) { case "in": //TRANS: %1$s is the start time of a planned item, %2$s is the end $beginend = sprintf(__('From %1$s to %2$s :'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"]))); printf(__('%1$s %2$s'), $beginend, Html::resume_text($val["name"], 80)); break; case "begin": $start = sprintf(__('Start at %s'), date("H:i", strtotime($val["begin"]))); printf(__('%1$s: %2$s'), $start, Html::resume_text($val["name"], 80)); break; case "end": $end = sprintf(__('End at %s'), date("H:i", strtotime($val["end"]))); printf(__('%1$s: %2$s'), $end, Html::resume_text($val["name"], 80)); break; } if ($val["users_id"] && $who == 0) { echo " - " . __('User') . " " . getUserName($val["users_id"]); } echo "</a><br>"; echo PluginResourcesResource::getTypeName(1) . " : <a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php?id=" . $val["plugin_resources_resources_id"] . "'"; echo ">" . $val["resource"] . "</a>"; echo "<div class='over_link' id='content_task_" . $val["id"] . $rand . "'>"; if ($val["end"]) { echo "<strong>" . __('End date') . "</strong> : " . Html::convdatetime($val["end"]) . "<br>"; } if ($val["type"]) { echo "<strong>" . PluginResourcesTaskType::getTypeName(1) . "</strong> : " . $val["type"] . "<br>"; } if ($val["content"]) { echo "<strong>" . __('Description') . "</strong> : " . $val["content"]; } echo "</div>"; }
This file is part of Resources. Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; $resource = new PluginResourcesResource(); if ($resource->canView() || Session::haveRight("config", "w")) { if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); } else { Html::helpHeader(PluginResourcesResource::getTypeName(2)); } $resource->listOfTemplates($CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php", $_GET["add"]); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::footer(); } else { Html::helpFooter(); } }
function showForm($ID, $options = array()) { if (!Session::haveRight("profile", "r")) { return false; } $prof = new Profile(); if ($ID) { $this->getFromDBByProfile($ID); $prof->getFromDB($ID); } $this->showFormHeader($options); echo "<tr class='tab_bg_2'>"; echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'resources'), $prof->fields["name"]) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesResource::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("resources", $this->fields["resources"], 1, 1, 1); echo "</td>"; echo "<td>" . PluginResourcesTask::getTypeName(2) . "</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("task", $this->fields["task"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesChecklist::getTypeName(2) . "</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("checklist", $this->fields["checklist"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "<td>" . PluginResourcesEmployee::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("employee", $this->fields["employee"], 1, 1, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('All resources access', 'resources') . "</td><td>"; Profile::dropdownNoneReadWrite("all", $this->fields["all"], 1, 0, 1); echo "</td>"; echo "<td>" . __('Associable items to a ticket') . " - " . PluginResourcesResource::getTypeName(2) . "</td><td>"; if ($prof->fields['create_ticket']) { Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]); } else { echo Dropdown::getYesNo(0); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<th colspan='4' class='center b'>" . __('Service company management', 'resources') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesResourceResting::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("resting", $this->fields["resting"], 1, 0, 1); echo "</td>"; echo "<td>" . PluginResourcesResourceHoliday::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("holiday", $this->fields["holiday"], 1, 0, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<th colspan='4' class='center b'>" . __('Public service management', 'resources') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesEmployment::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("employment", $this->fields["employment"], 1, 1, 1); echo "</td>"; echo "<td>" . PluginResourcesBudget::getTypeName(2) . ":</td><td>"; Profile::dropdownNoneReadWrite("budget", $this->fields["budget"], 1, 1, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Dropdown management', 'resources') . "</td><td>"; Profile::dropdownNoneReadWrite("dropdown_public", $this->fields["dropdown_public"], 1, 1, 1); echo "</td><td></td><td></td>"; echo "</tr>"; echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">"; $options['candel'] = false; $this->showFormButtons($options); }
Html::back(); } else { if (isset($_POST["update"])) { $budget->check($_POST["id"], 'w'); $budget->update($_POST); Html::back(); } else { if (isset($_POST["delete"])) { $budget->check($_POST["id"], 'w'); $budget->delete($_POST); $budget->redirectToList(); } else { if (isset($_POST["purge"])) { $budget->check($_POST['id'], 'w'); $budget->delete($_POST, 1); $budget->redirectToList(); } else { if (isset($_POST["restore"])) { $budget->check($_POST["id"], 'w'); $budget->restore($_POST); $budget->redirectToList(); } else { $budget->checkGlobal("r"); Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources", "budget"); $budget->showForm($_GET["id"]); Html::footer(); } } } } }
function getTitle() { return PluginResourcesResource::getTypeName(2) . " " . PluginResourcesChecklist::getTypeName(1); }
function showItemFromPlugin($instID, $withtemplate = '') { global $DB, $CFG_GLPI; if (empty($withtemplate)) { $withtemplate = 0; } $PluginResourcesTask = new PluginResourcesTask(); if ($PluginResourcesTask->getFromDB($instID)) { $plugin_resources_resources_id = $PluginResourcesTask->fields["plugin_resources_resources_id"]; $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->getFromDB($plugin_resources_resources_id); $canedit = $PluginResourcesResource->can($plugin_resources_resources_id, 'w'); $query = "SELECT `items_id`, `itemtype` \n FROM `" . $this->getTable() . "` \n WHERE `plugin_resources_tasks_id` = '{$instID}' \n ORDER BY `itemtype` "; $result = $DB->query($query); $number = $DB->numrows($result); echo "<form method='post' name='addtaskitem' action=\"./task.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='" . ($canedit ? 3 : 2) . "'>" . _n('Associated item', 'Associated items', 2); echo "</th></tr>"; echo "<tr><th>" . _n('Type', 'Types', 2) . "</th>"; echo "<th>" . __('Name') . "</th>"; if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<th> </th>"; } echo "</tr>"; $used = array(); if ($number != "0") { for ($i = 0; $i < $number; $i++) { $type = $DB->result($result, $i, "itemtype"); $items_id = $DB->result($result, $i, "items_id"); if (!class_exists($type)) { continue; } $item = new $type(); if ($item->canView()) { $table = getTableForItemType($type); $query = "SELECT `" . $table . "`.*, `" . $this->getTable() . "`.`id` as items_id \n FROM `" . $this->getTable() . "` \n INNER JOIN `" . $table . "` ON (`" . $table . "`.`id` = `" . $this->getTable() . "`.`items_id`) \n WHERE `" . $this->getTable() . "`.`itemtype` = '" . $type . "' \n AND `" . $this->getTable() . "`.`items_id` = '" . $items_id . "' \n AND `" . $this->getTable() . "`.`plugin_resources_tasks_id` = '{$instID}' "; $query .= "ORDER BY `" . $table . "`.`name` "; $result_linked = $DB->query($query); if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { $ID = ""; $itemID = $data["id"]; $used[] = $itemID; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $ID = " (" . $data["id"] . ")"; } $itemname = $data["name"]; if ($type == 'User') { $itemname = getUserName($itemID); } $link = Toolbox::getItemTypeFormURL($type); $name = "<a href=\"" . $link . "\">" . $itemname . "{$ID}</a>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . $item->getTypeName() . "</td>"; echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] == '1' ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<td class='center' class='tab_bg_2'>"; Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/resources/front/task.form.php', 'deletetaskitem', _x('button', 'Delete permanently'), array('id' => $data["items_id"])); echo "</td>"; } echo "</tr>"; } } } } } if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<tr class='tab_bg_1'><td colspan='2' class='right'>"; echo "<input type='hidden' name='plugin_resources_tasks_id' value='{$instID}'>"; $PluginResourcesResource_Item = new PluginResourcesResource_Item(); $PluginResourcesResource_Item->dropdownItems($plugin_resources_resources_id, $used); echo "</td>"; echo "<td class='center' colspan='2' class='tab_bg_2'>"; echo "<input type='submit' name='addtaskitem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div>"; } else { echo "</table></div>"; } Html::closeForm(); echo "<br>"; } }
/** * show for PDF the resources associated with a device * * @param $ID of the device * @param $itemtype : type of the device * */ static function PdfFromItems($pdf, $item) { global $DB, $CFG_GLPI; $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . __('Associated Human Resource', 'resources') . '</b>'); $ID = $item->getField('id'); $itemtype = get_Class($item); $canread = $item->can($ID, 'r'); $canedit = $item->can($ID, 'w'); $PluginResourcesResource = new PluginResourcesResource(); $query = "SELECT `glpi_plugin_resources_resources`.* " . " FROM `glpi_plugin_resources_resources_items`,`glpi_plugin_resources_resources` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_resources_resources`.`entities_id`) " . " WHERE `glpi_plugin_resources_resources_items`.`items_id` = '" . $ID . "' \n AND `glpi_plugin_resources_resources_items`.`itemtype` = '" . $itemtype . "' \n AND `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` = `glpi_plugin_resources_resources`.`id` " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_resources_resources", '', '', $PluginResourcesResource->maybeRecursive()); $result = $DB->query($query); $number = $DB->numrows($result); if (!$number) { $pdf->displayLine(__('No item found')); } else { if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16); $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Location'), PluginResourcesContractType::getTypeName(1), PluginResourcesDepartment::getTypeName(1), __('Arrival date', 'resources'), __('Departure date', 'resources') . '</i></b>'); } else { $pdf->setColumnsSize(17, 17, 17, 17, 17, 17); $pdf->displayTitle('<b><i>' . __('Name'), __('Location'), PluginResourcesContractType::getTypeName(1), PluginResourcesDepartment::getTypeName(1), __('Arrival date', 'resources'), __('Departure date', 'resources') . '</i></b>'); } while ($data = $DB->fetch_array($result)) { $resourcesID = $data["id"]; if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16); $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])), Html::clean(Dropdown::getDropdownName("glpi_locations", $data["locations_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"])), Html::convDate($data["date_begin"]), Html::convDate($data["date_end"])); } else { $pdf->setColumnsSize(17, 17, 17, 17, 17, 17); $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_locations", $data["locations_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"])), Html::clean(Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"])), Html::convDate($data["date_begin"]), Html::convDate($data["date_end"])); } } } }
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(); } } }
} else { if (isset($_POST["delete"])) { $checklistconfig->check($_POST['id'], 'w'); $checklistconfig->delete($_POST); $checklistconfig->redirectToList(); } else { if (isset($_POST["restore"])) { $checklistconfig->check($_POST['id'], 'w'); $checklistconfig->restore($_POST); $checklistconfig->redirectToList(); } else { if (isset($_POST["purge"])) { $checklistconfig->check($_POST['id'], 'w'); $checklistconfig->delete($_POST, 1); $checklistconfig->redirectToList(); } else { if (isset($_POST["update"])) { $checklistconfig->check($_POST['id'], 'w'); $checklistconfig->update($_POST); Html::back(); } else { $checklistconfig->checkGlobal("r"); Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources", "checklist"); $options = array(); $checklistconfig->showForm($_GET["id"], $options); Html::footer(); } } } } }
-------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (isset($_GET["users_id"])) { //si plugin ressource active $plugin = new Plugin(); if ($plugin->isActivated("resources")) { //recherche de la ressource lie a ce user $condition = "`items_id`= '" . $_GET["users_id"] . "' and `itemtype` = 'User'"; $infos = getAllDatasFromTable('glpi_plugin_resources_resources_items', $condition); if (!empty($infos)) { foreach ($infos as $info) { $ressource = new PluginResourcesResource(); $ressource->getFromDB($info['plugin_resources_resources_id']); $restrict = "`items_id` = '" . $ressource->fields['id'] . "'\n AND `is_deleted` = '0' \n AND `entities_id` = '" . $ressource->fields['entities_id'] . "'\n AND `itemtype` = '" . $ressource->getType() . "'"; $datas = getAllDatasFromTable('glpi_plugin_positions_positions', $restrict); if (!empty($datas)) { foreach ($datas as $data) { if (isset($data['id'])) { if (isset($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) { $id = $data['id']; $locations_id = $ressource->fields['locations_id']; $itemtype = 'User'; $menuoff = 1; $download = 1; } } }
This file is part of Resources. Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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'; //from helpdesk Html::helpHeader(PluginResourcesResource::getTypeName(2)); $employee = new PluginResourcesEmployee(); //add employee informations from helpdesk //next step : show list needs of the new ressource if (isset($_POST["add_helpdesk_employee"])) { $newID = $employee->add($_POST); Html::redirect("./resource_item.list.php?id=" . $_POST["plugin_resources_resources_id"] . "&exist=0"); } else { //show form employee informations from helpdesk $employee->showFormHelpdesk($_GET["id"], 0); } Html::helpFooter();
/** * Display the budget form * * @param $ID integer ID of the item * @param $options array * - target filename : where to go when done. * - withtemplate boolean : template or basic item * *@return boolean item found **/ function showForm($ID, $options = array("")) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name", array('value' => $this->fields["name"])); echo "</td>"; echo "<td>" . __('Budget volume', 'resources') . "</td>"; echo "<td>"; Dropdown::show('PluginResourcesBudgetType', array('value' => $this->fields["plugin_resources_budgettypes_id"], 'entity' => $this->fields["entities_id"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Profession', 'resources') . "</td>"; echo "<td>"; $params = array('name' => 'plugin_resources_professions_id', 'value' => $this->fields['plugin_resources_professions_id'], 'entityt' => $this->fields["entities_id"], 'action' => $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/dropdownRank.php", 'span' => 'span_rank', 'sort' => true); PluginResourcesResource::showGenericDropdown('PluginResourcesProfession', $params); echo "</td>"; echo "<td>" . __('Rank', 'resources') . "</td><td>"; echo "<span id='span_rank' name='span_rank'>"; if ($this->fields["plugin_resources_ranks_id"] > 0) { echo Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->fields["plugin_resources_ranks_id"]); } else { _e('None'); } echo "</span></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Budget volume', 'resources') . "</td>"; echo "<td>"; $options = array('value' => 0); Html::autocompletionTextField($this, 'volume', $options); echo "</td><td>" . __('Type of budget volume', 'resources') . "</td><td>"; Dropdown::show('PluginResourcesBudgetVolume', array('value' => $this->fields["plugin_resources_budgetvolumes_id"], 'entity' => $this->fields["entities_id"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Begin date') . "</td>"; echo "<td>"; Html::showDateFormItem("begin_date", $this->fields["begin_date"], true, true); echo "</td>"; echo "<td>" . __('End date') . "</td>"; echo "<td>"; Html::showDateFormItem("end_date", $this->fields["end_date"], true, true); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center' colspan='6'>"; printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); echo "</td>"; echo "</tr>"; if ($_SESSION['glpiactiveprofile']['interface'] != 'central') { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return 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 { $name .= $data["name"]; } $name .= "</a>";
static function showGeolocLink($itemtype, $id, $positions_id = 0) { global $CFG_GLPI; if ($itemtype != 'User' && $itemtype != 'PluginResourcesResource') { $item = new $itemtype(); $item->getFromDB($id); $documents_id = self::getDocument($item->fields['locations_id']); $locations_id = $item->fields['locations_id']; } else { //si plugin ressource active $plugin = new Plugin(); if ($plugin->isActivated("resources")) { //recherche de la ressource lie a ce user if ($itemtype != 'PluginResourcesResource') { $condition = "`items_id`= '" . $id . "' AND `itemtype` = 'User'"; $infos = getAllDatasFromTable('glpi_plugin_resources_resources_items', $condition); if (!empty($infos)) { foreach ($infos as $info) { $ressource = new PluginResourcesResource(); $ressource->getFromDB($info['plugin_resources_resources_id']); $restrict = "`items_id` = '" . $ressource->getID() . "'\n AND `is_deleted` = '0' \n AND `entities_id` = '" . $ressource->fields['entities_id'] . "'\n AND `itemtype` = 'PluginResourcesResource'"; $datas = getAllDatasFromTable('glpi_plugin_positions_positions', $restrict); if (!empty($datas)) { foreach ($datas as $data) { if (isset($data['id'])) { if (isset($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) { $documents_id = self::getDocument($ressource->fields['locations_id']); $positions_id = $data['id']; $locations_id = $ressource->fields['locations_id']; } } } } } } } else { $ressource = new PluginResourcesResource(); if ($ressource->getFromDB($id)) { $restrict = "`items_id` = '" . $ressource->fields['id'] . "'\n AND `is_deleted` = '0' \n AND `entities_id` = '" . $ressource->fields['entities_id'] . "'\n AND `itemtype` = '" . $ressource->getType() . "'"; $datas = getAllDatasFromTable('glpi_plugin_positions_positions', $restrict); if (!empty($datas)) { foreach ($datas as $data) { if (isset($data['id'])) { if (isset($ressource->fields['locations_id']) && $ressource->fields['locations_id'] > 0) { $documents_id = self::getDocument($ressource->fields['locations_id']); $positions_id = $data['id']; $locations_id = $ressource->fields['locations_id']; } } } } } } } } $out = ""; $Doc = new Document(); if (isset($documents_id) && $Doc->getFromDB($documents_id)) { $out .= " <a href='#' onClick=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/plugins/positions/front/geoloc.php?positions_id=" . $positions_id . "&download=1&locations_id=" . $locations_id . "' ,'glpipopup', \n 'height=650, width=1400, top=100, left=100, scrollbars=yes' );\n w.focus();\" ><img src='" . $CFG_GLPI["root_doc"] . "/plugins/positions/pics/sm_globe.png'></a> "; } return $out; }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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(); }
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'; if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); } else { Html::helpHeader(PluginResourcesResource::getTypeName(2)); } if (empty($_POST["date_end"])) { $_POST["date_end"] = date("Y-m-d"); } $resource = new PluginResourcesResource(); $checklistconfig = new PluginResourcesChecklistconfig(); if (isset($_POST["removeresources"]) && $_POST["plugin_resources_resources_id"] != 0) { $date = date("Y-m-d H:i:s"); $CronTask = new CronTask(); $CronTask->getFromDBbyName("PluginResourcesEmployment", "ResourcesLeaving"); $input["id"] = $_POST["plugin_resources_resources_id"]; $input["date_end"] = $_POST["date_end"]; if ($_POST["date_end"] < $date || $CronTask->fields["state"] == CronTask::STATE_DISABLE) { $input["is_leaving"] = "1"; } else { $input["is_leaving"] = "0"; } $input["plugin_resources_leavingreasons_id"] = $_POST["plugin_resources_leavingreasons_id"]; $input["withtemplate"] = "0"; $input["users_id_recipient_leaving"] = Session::getLoginUserID();