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();
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>"; echo Search::showItem($output_type, $name, $num, $key); echo Search::showItem($output_type, $data['firstname'], $num, $key); echo Search::showItem($output_type, $data['registration_number'], $num, $key); $link1 = Toolbox::getItemTypeFormURL("PluginResourcesProfession");
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/>. -------------------------------------------------------------------------- */ //Options for GLPI 0.71 and newer : need slave db to access the report $USEDBREPLICATE = 1; $DBCONNECTION_REQUIRED = 1; include "../../../../inc/includes.php"; // Instantiate Report with Name $titre = $LANG['plugin_resources']['resourceemploymentdiff']; $report = new PluginReportsAutoReport($titre); // Columns title (optional) $report->setColumns(array(new PluginReportsColumn('registration_number', __('Administrative number'), array('sorton' => 'registration_number')), new PluginReportsColumnLink('resource_id', __('Name'), 'PluginResourcesResource', array('sorton' => 'resource_name')), new PluginReportsColumn('firstname', __('First name'), array('sorton' => 'firstname')), new PluginReportsColumnInteger('quota', __('Quota', 'resources'), array('sorton' => 'quota')), new PluginReportsColumn('resource_rank', __('Resource', 'resources') . " - " . PluginResourcesRank::getTypeName(1), array('sorton' => 'resource_rank')), new PluginReportsColumn('resource_profession', __('Resource', 'resources') . " - " . PluginResourcesProfession::getTypeName(1), array('sorton' => 'resource_profession')), new PluginReportsColumn('resource_professionline', __('Resource', 'resources') . " - " . PluginResourcesProfessionLine::getTypeName(1), array('sorton' => 'resource_professionline')), new PluginReportsColumn('resource_professioncategory', __('Resource', 'resources') . " - " . PluginResourcesProfessionCategory::getTypeName(1), array('sorton' => 'resource_professioncategory')), new PluginReportsColumnLink('employment_id', __('Name') . " - " . PluginResourcesEmployment::getTypeName(1), 'PluginResourcesEmployment', array('sorton' => 'employment_name')), new PluginReportsColumnFloat('ratio_employment_budget', __('Ratio Employment / Budget', 'resources'), array('sorton' => 'ratio_employment_budget')), new PluginReportsColumn('employment_rank', PluginResourcesEmployment::getTypeName(1) . " - " . PluginResourcesRank::getTypeName(1), array('sorton' => 'employment_rank')), new PluginReportsColumn('employment_profession', PluginResourcesEmployment::getTypeName(1) . " - " . PluginResourcesProfession::getTypeName(1), array('sorton' => 'employment_profession')), new PluginReportsColumn('employment_professionline', PluginResourcesEmployment::getTypeName(1) . " - " . PluginResourcesProfessionLine::getTypeName(1), array('sorton' => 'employment_professionline')), new PluginReportsColumn('employment_professioncategory', PluginResourcesEmployment::getTypeName(1) . " - " . PluginResourcesProfessionCategory::getTypeName(1), array('sorton' => 'employment_professioncategory')), new PluginReportsColumnDate('begin_date', __('Begin date'), array('sorton' => 'begin_date')), new PluginReportsColumnDate('end_date', __('End date'), array('sorton' => 'end_date')), new PluginReportsColumn('employment_state', PluginResourcesEmploymentState::getTypeName(1), array('sorton' => 'employment_state')), new PluginReportsColumn('employer_name', __('Name') . " - " . PluginResourcesEmployer::getTypeName(1), array('sorton' => 'employer_name')))); // SQL statement $condition = getEntitiesRestrictRequest(' AND ', "glpi_plugin_resources_employments", '', '', false); //display only resource which have rank and profession not equal to employment rank or profession $query = "SELECT `glpi_users`.`registration_number`,\n `glpi_users`.`id` as user_id,\n `glpi_plugin_resources_resources`.`id` as resource_id,\n `glpi_plugin_resources_resources`.`name` as resource_name,\n `glpi_plugin_resources_resources`.`firstname`,\n `glpi_plugin_resources_resources`.`quota`,\n `glpi_plugin_resources_ranks`.`name` AS resource_rank,\n `glpi_plugin_resources_professions`.`name` AS resource_profession,\n `glpi_plugin_resources_professionlines`.`name` AS resource_professionline,\n `glpi_plugin_resources_professioncategories`.`name` AS resource_professioncategory,\n `glpi_plugin_resources_employments`.`name` AS employment_name,\n `glpi_plugin_resources_employments`.`id` AS employment_id,\n `glpi_plugin_resources_employments`.`ratio_employment_budget`,\n `glpi_plugin_resources_employmentranks`.`name` AS employment_rank,\n `glpi_plugin_resources_employmentprofessions`.`name` AS employment_profession,\n `glpi_plugin_resources_employmentprofessionlines`.`name` AS employment_professionline,\n `glpi_plugin_resources_employmentprofessioncategories`.`name` AS employment_professioncategory,\n `glpi_plugin_resources_employments`.`begin_date`,\n `glpi_plugin_resources_employments`.`end_date`,\n `glpi_plugin_resources_employmentstates`.`name` AS employment_state,\n `glpi_plugin_resources_employers`.`name` AS employer_name\n FROM `glpi_users`\n LEFT JOIN `glpi_plugin_resources_resources_items`\n ON (`glpi_users`.`id` = `glpi_plugin_resources_resources_items`.`items_id`\n AND `glpi_plugin_resources_resources_items`.`itemtype`= 'User')\n LEFT JOIN `glpi_plugin_resources_resources`\n ON (`glpi_plugin_resources_resources`.`id` = `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id`)\n LEFT JOIN `glpi_plugin_resources_employments`\n ON (`glpi_plugin_resources_resources`.`id` = `glpi_plugin_resources_employments`.`plugin_resources_resources_id` )\n LEFT JOIN `glpi_plugin_resources_ranks`\n ON (`glpi_plugin_resources_resources`.`plugin_resources_ranks_id` = `glpi_plugin_resources_ranks`.`id`)\n LEFT JOIN `glpi_plugin_resources_professions`\n ON (`glpi_plugin_resources_ranks`.`plugin_resources_professions_id` = `glpi_plugin_resources_professions`.`id`)\n LEFT JOIN `glpi_plugin_resources_professions` AS `glpi_plugin_resources_employmentprofessions`\n ON (`glpi_plugin_resources_employments`.`plugin_resources_professions_id` = `glpi_plugin_resources_employmentprofessions`.`id`)\n LEFT JOIN `glpi_plugin_resources_employers`\n ON (`glpi_plugin_resources_employments`.`plugin_resources_employers_id` = `glpi_plugin_resources_employers`.`id`)\n LEFT JOIN `glpi_plugin_resources_professionlines`\n ON (`glpi_plugin_resources_professions`.`plugin_resources_professionlines_id` = `glpi_plugin_resources_professionlines`.`id`)\n LEFT JOIN `glpi_plugin_resources_professioncategories`\n ON (`glpi_plugin_resources_professions`.`plugin_resources_professioncategories_id` = `glpi_plugin_resources_professioncategories`.`id`)\n LEFT JOIN `glpi_plugin_resources_ranks` AS `glpi_plugin_resources_employmentranks`\n ON (`glpi_plugin_resources_employments`.`plugin_resources_ranks_id` = `glpi_plugin_resources_employmentranks`.`id`)\n LEFT JOIN `glpi_plugin_resources_professionlines` AS `glpi_plugin_resources_employmentprofessionlines`\n ON (`glpi_plugin_resources_employmentprofessions`.`plugin_resources_professionlines_id` = `glpi_plugin_resources_employmentprofessionlines`.`id`)\n LEFT JOIN `glpi_plugin_resources_professioncategories` AS `glpi_plugin_resources_employmentprofessioncategories`\n ON (`glpi_plugin_resources_employmentprofessions`.`plugin_resources_professioncategories_id` = `glpi_plugin_resources_employmentprofessioncategories`.`id`)\n LEFT JOIN `glpi_plugin_resources_employmentstates`\n ON (`glpi_plugin_resources_employments`.`plugin_resources_employmentstates_id` = `glpi_plugin_resources_employmentstates`.`id`)\n WHERE (`glpi_plugin_resources_resources`.`is_leaving` = 0\n AND `glpi_users`.`is_active` = 1\n AND `glpi_plugin_resources_employments`.`plugin_resources_resources_id` <> 0\n AND `glpi_plugin_resources_resources`.`is_deleted` = '0'\n AND `glpi_plugin_resources_resources`.`is_template` = '0'\n " . $condition . " )\n GROUP BY `glpi_plugin_resources_employments`.`id`, `glpi_users`.`id`\n HAVING (resource_profession <> employment_profession\n OR resource_rank <> employment_rank)" . $report->getOrderBy('registration_number'); $report->setSqlRequest($query); $report->execute();
/** * affiche le résultat de la recherche ou toute la liste * * @param $params * @return bool */ function showMinimalList($params) { global $DB, $CFG_GLPI; $itemtype = "PluginResourcesRecap"; $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['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->canUpdate(); $PluginResourcesEmployment = new PluginResourcesEmployment(); // 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/recap.php"; $limitsearchopt = Search::getCleanedOptions("PluginResourcesRecap"); $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 = $PluginResourcesEmployment->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView("PluginResourcesRecap"); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser("PluginResourcesRecap", 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("PluginResourcesRecap", $val, $key, 0); } $query .= "`glpi_plugin_resources_resources`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table // $query.= " FROM `".$itemtable."`"; $query .= " FROM `glpi_plugin_resources_employments`"; // 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("PluginResourcesRecap", $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt["PluginResourcesRecap"] =& Search::getOptions("PluginResourcesRecap"); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt["PluginResourcesRecap"][$val]["table"], $searchopt["PluginResourcesRecap"][$val]["linkfield"], 0, 0, $searchopt["PluginResourcesRecap"][$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["PluginResourcesRecap"][$key]["table"], $searchopt["PluginResourcesRecap"][$key]["linkfield"], 0, 0, $searchopt["PluginResourcesRecap"][$key]["joinparams"]); } } } //display only resource not leaving //with active user //and employment affected to a resource $ASSIGN = ""; // `glpi_plugin_resources_resources`.`is_leaving` = 0 AND ". // " `glpi_users`.`is_active` = 1 AND ". // " `glpi_plugin_resources_employments`.`plugin_resources_resources_id` <> 0 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_employments"); } } $WHERE = ""; $HAVING = ""; // Add search conditions // If there is search items if ($_SESSION["glpisearchcount"]["PluginResourcesRecap"] > 0 && count($p['contains']) > 0) { for ($key = 0; $key < $_SESSION["glpisearchcount"]["PluginResourcesRecap"]; $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["PluginResourcesRecap"][$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, "PluginResourcesRecap", $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, "PluginResourcesRecap", $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["PluginResourcesRecap"]; } else { // toview case : populate toview foreach ($toview as $key2 => $val2) { $items[$val2] = $searchopt["PluginResourcesRecap"][$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, "PluginResourcesRecap", $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["PluginResourcesRecap"][$val2]["forcegroupby"])) { // $GROUPBY = " GROUP BY `glpi_plugin_resources_employments`.`id`"; // } // } // } //display all employment for each resource $query .= " GROUP BY `glpi_plugin_resources_employments`.`id`"; // 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, "PluginResourcesRecap", 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"; } // 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); // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt["PluginResourcesRecap"][$val]['nosort']) || !$searchopt["PluginResourcesRecap"][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt["PluginResourcesRecap"][$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']); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem("PluginResourcesRecap", $val, $data, $key), $item_num, $row_num, Search::displayConfigItem("PluginResourcesRecap", $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); echo "</table></div>"; if ($output_type == Search::HTML_OUTPUT) { // In case of HTML display Html::printPager($p['start'], $numrows, $target, $parameters, "PluginResourcesRecap", 0, $search_config); } } else { echo Search::showError($output_type); } } }
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["id"])) { $_GET["id"] = ""; } if (!isset($_GET["plugin_resources_resources_id"])) { $_GET["plugin_resources_resources_id"] = 0; } $employment = new PluginResourcesEmployment(); if (isset($_POST["add"])) { $employment->check(-1, 'w'); $newID = $employment->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $employment->check($_POST["id"], 'w'); $employment->update($_POST); Html::back(); } else { if (isset($_POST["delete"])) { $employment->check($_POST["id"], 'w'); $employment->delete($_POST); $employment->redirectToList(); } else {
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); }
function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $resource_item = new PluginResourcesResource_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginResourcesResource') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $contracttype = PluginResourcesContractType::transfer($PluginResourcesResource->fields["plugin_resources_contracttypes_id"], $input['entities_id']); if ($contracttype > 0) { $values["id"] = $key; $values["plugin_resources_contracttypes_id"] = $contracttype; $this->update($values); } unset($values); $resourcestate = PluginResourcesResourceState::transfer($PluginResourcesResource->fields["plugin_resources_resourcestates_id"], $input['entities_id']); if ($resourcestate > 0) { $values["id"] = $key; $values["plugin_resources_resourcestates_id"] = $resourcestate; $this->update($values); } unset($values); $department = PluginResourcesDepartment::transfer($PluginResourcesResource->fields["plugin_resources_departments_id"], $input['entities_id']); if ($department > 0) { $values["id"] = $key; $values["plugin_resources_departments_id"] = $department; $this->update($values); } unset($values); $situation = PluginResourcesResourceSituation::transfer($PluginResourcesResource->fields["plugin_resources_resourcesituations_id"], $input['entities_id']); if ($situation > 0) { $values["id"] = $key; $values["plugin_resources_resourcesituations_id"] = $situation; $this->update($values); } unset($values); $contractnature = PluginResourcesContractNature::transfer($PluginResourcesResource->fields["plugin_resources_contractnatures_id"], $input['entities_id']); if ($contractnature > 0) { $values["id"] = $key; $values["plugin_resources_contractnatures_id"] = $contractnature; $this->update($values); } unset($values); $rank = PluginResourcesRank::transfer($PluginResourcesResource->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $key; $values["plugin_resources_ranks_id"] = $rank; $this->update($values); } unset($values); $speciality = PluginResourcesResourceSpeciality::transfer($PluginResourcesResource->fields["plugin_resources_resourcespecialities_id"], $input['entities_id']); if ($speciality > 0) { $values["id"] = $key; $values["plugin_resources_resourcespecialities_id"] = $speciality; $this->update($values); } unset($values); $PluginResourcesTask = new PluginResourcesTask(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks", $restrict); if (!empty($tasks)) { foreach ($tasks as $task) { $PluginResourcesTask->getFromDB($task["id"]); $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $task["id"]; $values["plugin_resources_tasktypes_id"] = $tasktype; $PluginResourcesTask->update($values); } $values["id"] = $task["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesTask->update($values); } } unset($values); $PluginResourcesEmployment = new PluginResourcesEmployment(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employments = getAllDatasFromTable("glpi_plugin_resources_employments", $restrict); if (!empty($employments)) { foreach ($employments as $employment) { $PluginResourcesEmployment->getFromDB($employment["id"]); $rank = PluginResourcesRank::transfer($PluginResourcesEmployment->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_ranks_id"] = $rank; $PluginResourcesEmployment->update($values); } $PluginResourcesEmployment->getFromDB($employment["id"]); $profession = PluginResourcesProfession::transfer($PluginResourcesEmployment->fields["plugin_resources_professions_id"], $input['entities_id']); if ($profession > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_professions_id"] = $profession; $PluginResourcesEmployment->update($values); } $values["id"] = $employment["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesEmployment->update($values); } } unset($values); $PluginResourcesEmployee = new PluginResourcesEmployee(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employees = getAllDatasFromTable("glpi_plugin_resources_employees", $restrict); if (!empty($employees)) { foreach ($employees as $employee) { $employer = PluginResourcesEmployer::transfer($employee["plugin_resources_employers_id"], $input['entities_id']); if ($employer > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_employers_id"] = $employer; $PluginResourcesEmployee->update($values); } $client = PluginResourcesClient::transfer($employee["plugin_resources_clients_id"], $input['entities_id']); if ($client > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_clients_id"] = $client; $PluginResourcesEmployee->update($values); } } } unset($values); $query = "UPDATE `glpi_plugin_resources_checklists`\n SET `entities_id` = '" . $input['entities_id'] . "'\n WHERE `plugin_resources_resources_id` ='{$key}'"; $DB->query($query); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_resources_resources_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($resource_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($resource_item->deleteItemByResourcesAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; case "Send": if ($this->sendEmail($input)) { $res['ok']++; } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }