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; }
static function showMinimalList($params = array()) { global $DB, $CFG_GLPI; $item = new self(); $itemtype = $item->getType(); $itemtable = $item->getTable(); // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['id'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['withtemplate'] = 0; foreach ($params as $key => $val) { $p[$key] = $val; } $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->getFromDB($p['id']); $canedit = $PluginResourcesResource->can($p['id'], 'w'); if (isset($_POST["start"])) { $p['start'] = $_POST["start"]; } else { $p['start'] = 0; } if (isset($_POST["sort"])) { $p['sort'] = $_POST["sort"]; } else { $p['sort'] = 1; } if (isset($_POST["order"]) && $_POST["order"] == "DESC") { $p['order'] = "DESC"; } else { $p['order'] = "ASC"; } // Manage defautll seachtype value : for bookmark compatibility if (count($p['contains'])) { foreach ($p['contains'] as $key => $val) { if (!isset($p['searchtype'][$key])) { $p['searchtype'][$key] = 'contains'; } } } if (is_array($p['contains2']) && count($p['contains2'])) { foreach ($p['contains2'] as $key => $val) { if (!isset($p['searchtype2'][$key])) { $p['searchtype2'][$key] = 'contains'; } } } $target = Toolbox::getItemTypeSearchURL($itemtype); $limitsearchopt = Search::getCleanedOptions($itemtype); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $entity_restrict = $item->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView($itemtype); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID()); if (count($displaypref)) { foreach ($displaypref as $val) { array_push($toview, $val); } } // Add searched items if (count($p['field']) > 0) { foreach ($p['field'] as $key => $val) { if (!in_array($val, $toview) && $val != 'all' && $val != 'view') { array_push($toview, $val); } } } // Add order item if (!in_array($p['sort'], $toview)) { array_push($toview, $p['sort']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect($itemtype); // Add select for all toview item foreach ($toview as $key => $val) { $query .= Search::addSelect($itemtype, $val, $key, 0); } $query .= "`" . $itemtable . "`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " FROM `" . $itemtable . "`"; // Init already linked tables array in order not to link a table several times $already_link_tables = array(); // Put reference table array_push($already_link_tables, $itemtable); // Add default join $COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt[$itemtype] =& Search::getOptions($itemtype); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]); } // Search all case : if (in_array("all", $p['field'])) { foreach ($searchopt[$itemtype] as $key => $val) { // Do not search on Group Name if (is_array($val)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]); } } } $query .= " WHERE `" . $itemtable . "`.`plugin_resources_resources_id` = '" . $p['id'] . "'"; $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' "; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (in_array('all', $p['field'])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } if (empty($GROUPBY)) { foreach ($toview as $key2 => $val2) { if (!empty($GROUPBY)) { break; } if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $item->getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) { echo "<div align='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=13&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>"; echo "</div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; if ($item->canCreate() && $canedit) { $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\""; $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config .= $tmp . ">"; } //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']); } // Pager if ($output_type == Search::HTML_OUTPUT) { Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows, $search_config); echo "<br>"; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { Html::openMassiveActionsForm('massform' . $itemtype); $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => true, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions($itemtype, $massiveactionparams); } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols, 1); $header_num = 1; // Display column Headers for toview items $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; echo Search::showNewLine($output_type); if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) { // HTML display - massive modif $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); } // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers $headers_line .= Search::showEndLine($output_type); $headers_line_top .= $headers_line; $headers_line_bottom .= $headers_line; echo $headers_line_top; $DB->data_seek($result, $p['start']); // Define begin and end var for loop // Search case $i = $begin_display; // Init list of items displayed if ($output_type == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype, PluginResourcesResource::getTypeName(2) . " = " . (empty($PluginResourcesResource->fields['name']) ? "(" . $p['id'] . ")" : $PluginResourcesResource->fields['name'])); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); $tmpcheck = ""; if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $sel = ""; $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; } echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'"); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= __('Tasks list', 'resources'); } // Display footer echo Search::showFooter($output_type, $title); //massive action if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($itemtype, $massiveactionparams); Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows); } } else { echo Search::showError($output_type); } } }
/** * Show resource associated to an item * * @since version 0.84 * * @param $item CommonDBTM object for which associated resource must be displayed * @param $withtemplate (default '') **/ static function showForItem(CommonDBTM $item, $withtemplate = '') { global $DB, $CFG_GLPI; $ID = $item->getField('id'); if ($item->isNewID($ID)) { return false; } if (!plugin_resources_haveRight('resources', 'r')) { return false; } if (!$item->can($item->fields['id'], 'r')) { return false; } if (empty($withtemplate)) { $withtemplate = 0; } $canedit = $item->canadditem('PluginResourcesResource'); $rand = mt_rand(); $is_recursive = $item->isRecursive(); $query = "SELECT `glpi_plugin_resources_resources_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_resources_resources`.`name` AS assocName,\n `glpi_plugin_resources_resources`.*\n FROM `glpi_plugin_resources_resources_items`\n LEFT JOIN `glpi_plugin_resources_resources`\n ON (`glpi_plugin_resources_resources_items`.`plugin_resources_resources_id`=`glpi_plugin_resources_resources`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_resources_resources`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_resources_resources_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_resources_resources_items`.`itemtype` = '" . $item->getType() . "' "; $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_resources_resources", '', '', true); $query .= " ORDER BY `assocName`"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; $resources = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $resources[$data['assocID']] = $data; $used[$data['id']] = $data['id']; } } $resource = new PluginResourcesResource(); $more = true; if ($item->getType() == "User" && $number != 0) { $more = false; } if ($canedit && $withtemplate < 2 && $more) { // Restrict entity for knowbase $entities = ""; $entity = $_SESSION["glpiactive_entity"]; if ($item->isEntityAssign()) { /// Case of personal items : entity = -1 : create on active entity (Reminder case)) if ($item->getEntityID() >= 0) { $entity = $item->getEntityID(); } if ($item->isRecursive()) { $entities = getSonsOf('glpi_entities', $entity); } else { $entities = $entity; } } $limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_resources_resources", '', $entities, true); $q = "SELECT COUNT(*)\n FROM `glpi_plugin_resources_resources`\n WHERE `is_deleted` = '0'\n AND `is_template` = '0' "; if ($item->getType() != 'User') { $q .= " {$limit}"; } $result = $DB->query($q); $nb = $DB->result($result, 0, 0); echo "<div class='firstbloc'>"; if (plugin_resources_haveRight('resources', 'r') && $nb > count($used)) { echo "<form name='resource_form{$rand}' id='resource_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginResourcesResource') . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='4' class='center'>"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; echo "<input type='hidden' name='items_id' value='{$ID}'>"; if ($item->getType() == 'Ticket') { echo "<input type='hidden' name='tickets_id' value='{$ID}'>"; } PluginResourcesResource::dropdown(array('entity' => $entities, 'used' => $used)); echo "</td><td class='center' width='20%'>"; echo "<input type='submit' name='additem' value=\"" . __s('Associate a resource', 'resources') . "\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); } echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number && $withtemplate < 2) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; if (Session::isMultiEntitiesMode()) { $colsup = 1; } else { $colsup = 0; } echo "<tr>"; if ($canedit && $number && $withtemplate < 2) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('First name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . __('Location') . "</th>"; echo "<th>" . PluginResourcesContractType::getTypeName(1) . "</th>"; echo "<th>" . PluginResourcesDepartment::getTypeName(1) . "</th>"; echo "<th>" . __('Arrival date', 'resources') . "</th>"; echo "<th>" . __('Departure date', 'resources') . "</th>"; echo "</tr>"; $used = array(); $resourceID = 0; if ($number) { Session::initNavigateListItems('PluginResourcesResource', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); foreach ($resources as $data) { $resourceID = $data["id"]; $link = NOT_AVAILABLE; if ($resource->getFromDB($resourceID)) { $link = $resource->getLink(); } Session::addToNavigateListItems('PluginResourcesResource', $resourceID); $used[$resourceID] = $resourceID; $assocID = $data["assocID"]; echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>"; if ($canedit && $withtemplate < 2) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); echo "</td>"; } echo "<td class='center'>{$link}</td>"; echo "<td class='center'>" . $data['firstname'] . "</td>"; if (Session::isMultiEntitiesMode()) { echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>"; } echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_locations", $data["locations_id"]); echo "</td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"]); echo "</td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"]); echo "</td>"; echo "<td class='center'>" . Html::convDate($data["date_begin"]) . "</td>"; if ($data["date_end"] <= date('Y-m-d') && !empty($data["date_end"])) { echo "<td class='center'>"; echo "<span class='plugin_resources_date_color'>"; echo Html::convDate($data["date_end"]); echo "</span>"; echo "</td>"; } else { if (empty($data["date_end"])) { echo "<td class='center'>" . __('Not defined', 'resources') . "</td>"; } else { echo "<td class='center'>" . Html::convDate($data["date_end"]) . "</td>"; } } echo "</tr>"; $i++; } } echo "</table>"; if ($canedit && $number && $withtemplate < 2) { $massiveactionparams['ontop'] = false; Html::showMassiveActions(__CLASS__, $massiveactionparams); Html::closeForm(); } echo "</div>"; if ($item->getType() == "User") { $PluginResourcesEmployee = new PluginResourcesEmployee(); $PluginResourcesEmployee->showForm($resourceID, $ID, 0); } }
function pre_deleteItem() { global $CFG_GLPI; if ($CFG_GLPI["use_mailing"]) { $PluginResourcesResource = new PluginResourcesResource(); $options = array('resting_id' => $this->fields["id"]); if ($PluginResourcesResource->getFromDB($this->fields["plugin_resources_resources_id"])) { NotificationEvent::raiseEvent("deleteresting", $PluginResourcesResource, $options); } } return true; }
function showFormHelpdesk($plugin_resources_resources_id, $exist) { global $CFG_GLPI; if (!$this->canView()) { return false; } $employee_spotted = false; $resource = new PluginResourcesResource(); $resource->getFromDB($plugin_resources_resources_id); $restrict = "`plugin_resources_resources_id` = '{$plugin_resources_resources_id}'"; $employees = getAllDatasFromTable($this->getTable(), $restrict); $ID = 0; if (!empty($employees)) { foreach ($employees as $employer) { $ID = $employer["id"]; } } if (empty($ID)) { if ($this->getEmpty()) { $employee_spotted = true; } } else { if ($this->getfromDB($ID)) { $employee_spotted = true; } } if ($employee_spotted) { echo "<div align='center'><br>"; if ($exist == 0 || empty($ID)) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/employee.form.php\">"; } else { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php\">"; } $entity = $resource->fields["entities_id"]; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . self::getTypeName(1) . "</th></tr>"; echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; echo "<input type='hidden' name='plugin_resources_resources_id' value='{$plugin_resources_resources_id}'>"; echo PluginResourcesEmployer::getTypeName(1) . "</td>"; echo "<td colspan='2'>"; Dropdown::show('PluginResourcesEmployer', array('name' => "plugin_resources_employers_id", 'value' => $this->fields["plugin_resources_employers_id"], 'entity' => $entity)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td colspan='2' class='center'>"; echo PluginResourcesClient::getTypeName(1) . "</td>"; echo "<td colspan='2'>"; Dropdown::show('PluginResourcesClient', array('name' => "plugin_resources_clients_id", 'value' => $this->fields["plugin_resources_clients_id"], 'entity' => $entity)); echo "</td></tr>"; if ($this->canCreate()) { if ($exist == 0) { echo "<tr><td class='tab_bg_2 top' colspan='4'>"; echo "<input type='hidden' name='plugin_resources_resources_id' value=\"" . $plugin_resources_resources_id . "\">"; echo "<div align='center'><input type='submit' name='add_helpdesk_employee' value=\"" . _sx('button', 'Next step', 'resources') . "\" class='submit'>"; echo "</td></tr>"; } else { if (empty($ID)) { echo "<tr><td class='tab_bg_2 top' colspan='4'>"; echo "<input type='hidden' name='plugin_resources_resources_id' value=\"" . $plugin_resources_resources_id . "\">"; echo "<div align='center'><input type='submit' name='add_helpdesk_employee' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; } else { if ($resource->fields["is_leaving"] != 1) { echo "<tr><td class='tab_bg_2 top' colspan='4'>"; echo "<input type='hidden' name='id' value=\"{$ID}\">"; echo "<input type='hidden' name='plugin_resources_resources_id' value=\"" . $plugin_resources_resources_id . "\">"; echo "<div align='center'><input type='submit' name='updateemployee' value=\"" . _sx('button', 'Update') . "\" class='submit' >"; echo "</div>"; echo "</td></tr>"; } } } } echo "</table>"; Html::closeForm(); echo "</div>"; } }
$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(); $input['send_notification'] = 1; $resource->update($input); //test it $resource->getFromDB($_POST["plugin_resources_resources_id"]); $resources_checklist = PluginResourcesChecklist::checkIfChecklistExist($_POST["plugin_resources_resources_id"]); if (!$resources_checklist) { $checklistconfig->addChecklistsFromRules($resource, PluginResourcesChecklist::RESOURCES_CHECKLIST_OUT); } Session::addMessageAfterRedirect(__('Declaration of resource leaving OK', 'resources')); Html::back(); } else { if ($resource->canView() || Session::haveRight("config", "w")) { //show remove resource form $resource->showResourcesToRemove(); } } if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { Html::footer(); } else {
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; }
*/ 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; } } } }
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(); } } }
$_POST["firstname"] = $User->fields["firstname"]; $_POST["entities_id"] = $_SESSION["glpiactive_entity"]; $_POST["plugin_resources_contracttypes_id"] = 0; $_POST["users_id"] = 0; $_POST["date_end"] = ""; $_POST["departments_id"] = 0; $_POST["is_leaving"] = 0; $_POST["users_id_recipient_leaving"] = 0; $_POST["comment"] = ""; $_POST["notes"] = ""; $_POST["is_template"] = 0; $_POST["template_name"] = ""; $_POST["is_deleted"] = 0; $_POST["withtemplate"] = 0; if ($_POST["templates_id"] > 0) { $resource->getFromDB($_POST["templates_id"]); unset($resource->fields["is_template"]); unset($resource->fields["date_mod"]); $fields = array(); foreach ($resource->fields as $key => $value) { if ($value != '' && (!isset($fields[$key]) || $fields[$key] == '' || $fields[$key] == 0)) { $_POST[$key] = $value; } } $_POST["withtemplate"] = 1; } //for not create employee informations with template $_POST["add_from_helpdesk"] = 1; $_POST["comment"] = addslashes($_POST["comment"]); $_POST["locations_id"] = $User->fields["locations_id"]; $_POST["date_begin"] = $_SESSION["glpi_currenttime"];
function showFormForTask($resources, PluginResourcesTask $task) { global $CFG_GLPI; $PluginResourcesResource = new PluginResourcesResource(); $PluginResourcesResource->getFromDB($resources); $taskid = $task->getField('id'); if ($taskid > 0 && $this->getFromDBbyTask($taskid)) { if ($this->canCreate()) { echo "<script type='text/javascript' >\n"; echo "function showPlan" . $taskid . "(){\n"; echo "Ext.get('plan').setDisplayed('none');"; $params = array('form' => 'followups', 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'entity' => $PluginResourcesResource->fields["entities_id"]); Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/planning.php", $params); echo "}"; echo "</script>\n"; echo "<div id='plan' onClick='showPlan" . $taskid . "()'>\n"; echo "<span class='showplan'>"; } if ($this->fields["begin"] && $this->fields["end"]) { echo Html::convDateTime($this->fields["begin"]) . " -> " . Html::convDateTime($this->fields["end"]); } else { _e('Plan this task'); } if ($this->canCreate()) { echo "</span>"; echo "</div>\n"; echo "<div id='viewplan'></div>\n"; } } else { if ($this->canCreate()) { echo "<script type='text/javascript' >\n"; echo "function showPlanUpdate(){\n"; echo "Ext.get('plan').setDisplayed('none');"; $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"]); Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/planning.php", $params); echo "};"; echo "</script>"; echo "<div id='plan' onClick='showPlanUpdate()'>\n"; echo "<span class='showplan'>" . __('Plan this task') . "</span>"; echo "</div>\n"; echo "<div id='viewplan'></div>\n"; } else { _e('None'); } } }
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>"; } }
static function showFromResources($plugin_resources_resources_id, $checklist_type, $withtemplate = '') { global $CFG_GLPI; if (!plugin_resources_haveRight('checklist', 'r')) { return false; } $target = "./resource.form.php"; $targetchecklist = "./checklist.form.php"; $targettask = "./task.form.php"; $resource = new PluginResourcesResource(); $resource->getFromDB($plugin_resources_resources_id); $canedit = $resource->can($plugin_resources_resources_id, 'w'); $entities_id = $resource->fields["entities_id"]; $plugin_resources_contracttypes_id = $resource->fields["plugin_resources_contracttypes_id"]; $rand = mt_rand(); $restrict = "`entities_id` = '" . $entities_id . "' \n AND `plugin_resources_resources_id` = '{$plugin_resources_resources_id}' \n AND `checklist_type` = '{$checklist_type}' \n ORDER BY `rank`"; $checklists = getAllDatasFromTable("glpi_plugin_resources_checklists", $restrict); $numrows = countElementsInTable("glpi_plugin_resources_checklists", $restrict); if (!empty($checklists)) { $values = array(); $values["checklist_type"] = $checklist_type; $values["plugin_resources_resources_id"] = $plugin_resources_resources_id; $isfinished = self::checkifChecklistFinished($values); if (!$isfinished) { echo "<ul><li><div align='left' id='menu_navigate'>"; if ($checklist_type == self::RESOURCES_CHECKLIST_IN) { echo "<a href=\"javascript:showHideDiv('checklist_view_in_mode',\n 'checklistimg{$rand}','" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png',\n '" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png');\">"; } else { echo "<a href=\"javascript:showHideDiv('checklist_view_out_mode',\n 'checklistimg{$rand}','" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png',\n '" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png');\">"; } echo "<img name='checklistimg{$rand}' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">"; echo "</a>"; echo "</li></ul></div>"; echo "<div align='center' "; if ($checklist_type == self::RESOURCES_CHECKLIST_IN) { echo "id='checklist_view_in_mode'>"; } else { if ($checklist_type == self::RESOURCES_CHECKLIST_OUT) { echo "id='checklist_view_out_mode'>"; } } } echo "<form method='post' name='massiveaction_form{$checklist_type}.{$rand}' id='massiveaction_form{$checklist_type}.{$rand}' action='" . $target . "'>"; echo "<table width='950' class='tab_cadre_fixe' cellpadding='2'>"; echo "<tr><th colspan='7'>" . self::getChecklistType($checklist_type) . "</th></tr>"; if (!$isfinished) { echo "<tr>"; echo "<th> </th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Important', 'resources') . "</th>"; if (plugin_resources_haveRight("task", "w") && $canedit) { echo "<th>" . __('Linked task', 'resources') . "</th>"; } echo "<th>" . __('State') . "</th>"; echo "<th> </th>"; echo "<th> </th>"; echo "</tr>"; Session::initNavigateListItems("PluginResourcesChecklist", PluginResourcesResource::getTypeName(1) . " = " . $resource->fields['name']); $i = 0; foreach ($checklists as $checklist) { $ID = $checklist["id"]; Session::addToNavigateListItems("PluginResourcesChecklist", $ID); echo "<tr class='tab_bg_1'>"; echo "<td width='10'>"; echo "<input type='checkbox' name='item[{$ID}]' "; $is_finished = 0; $PluginResourcesTask = new PluginResourcesTask(); if ($PluginResourcesTask->GetfromDB($checklist["plugin_resources_tasks_id"])) { if ($PluginResourcesTask->fields["is_finished"] == 1) { $is_finished = 1; } } if ($checklist["plugin_resources_tasks_id"] && $is_finished == 0) { echo " disabled='true' "; } echo " value='1'>"; echo "</td>"; echo "<td width='30%'>"; echo "<a href='" . $targetchecklist . "?id=" . $ID . "&plugin_resources_resources_id=" . $plugin_resources_resources_id . "&plugin_resources_contracttypes_id=" . $plugin_resources_contracttypes_id . "&checklist_type=" . $checklist_type . "' >"; echo $checklist["name"]; echo "</a> "; if (!empty($checklist["address"])) { echo " "; $link = str_replace("&", "&", $checklist["address"]); Html::showToolTip($checklist["address"], array('link' => $link, 'linktarget' => '_blank')); } echo "</td>"; echo "<td>"; if ($checklist["tag"]) { echo "<span class='plugin_resources_date_over_color'>"; } echo nl2br($checklist["comment"]); if ($checklist["tag"]) { echo "</span>"; } echo "</td>"; if (plugin_resources_haveRight("task", "w") && $canedit) { echo "<td class='center'>"; if (!empty($checklist["plugin_resources_tasks_id"])) { echo "<a href='" . $targettask . "?id=" . $checklist["plugin_resources_tasks_id"] . "&plugin_resources_resources_id=" . $plugin_resources_resources_id . "&central=1'>"; } echo Dropdown::getYesNo($checklist["plugin_resources_tasks_id"]); if (!empty($checklist["plugin_resources_tasks_id"])) { echo "</a>"; } echo "</td>"; } echo "<td class='center'>"; echo "<input type='checkbox' disabled='true' name='is_checked' "; if ($checklist["is_checked"]) { echo "checked"; } echo " >"; if ($checklist["is_checked"] > 0) { echo "<input type='hidden' value='0' name='is_checked{$ID}'>"; } else { echo "<input type='hidden' value='1' name='is_checked{$ID}'>"; } echo "</td>"; if ($i != 0 && plugin_resources_haveRight('checklist', 'w') && $canedit) { echo "<td>"; Html::showSimpleForm($target, 'move', __('Bring up'), array('action' => 'up', 'id' => $ID, 'plugin_resources_resources_id' => $plugin_resources_resources_id, 'checklist_type' => $checklist_type), $CFG_GLPI["root_doc"] . "/pics/deplier_up.png"); echo "</td>"; } else { echo "<td> </td>"; } if ($i != $numrows - 1 && plugin_resources_haveRight('checklist', 'w') && $canedit) { echo "<td>"; Html::showSimpleForm($target, 'move', __('Bring down'), array('action' => 'down', 'id' => $ID, 'plugin_resources_resources_id' => $plugin_resources_resources_id, 'checklist_type' => $checklist_type), $CFG_GLPI["root_doc"] . "/pics/deplier_down.png"); echo "</td>"; } else { echo "<td> </td>"; } echo "<input type='hidden' name='plugin_resources_resources_id' value='{$plugin_resources_resources_id}'>"; echo "<input type='hidden' name='checklist_type' value='{$checklist_type}'>"; echo "<input type='hidden' name='plugin_resources_contracttypes_id' value='{$plugin_resources_contracttypes_id}'>"; echo "<input type='hidden' value='" . $checklist["comment"] . "' name='comment'>"; echo "</tr>"; $i++; } } if (plugin_resources_haveRight('checklist', 'w') && $canedit) { $values = array(); $values["checklist_type"] = $checklist_type; $values["plugin_resources_resources_id"] = $plugin_resources_resources_id; $values["plugin_resources_contracttypes_id"] = $plugin_resources_contracttypes_id; $values["entities_id"] = $entities_id; $isfinished = self::checkifChecklistFinished($values); echo "<tr class='tab_bg_2'>"; echo "<td colspan='7' class='left'>"; if (!$isfinished) { echo "<a onclick= \"if ( plugin_resources_markCheckboxes('massiveaction_form{$checklist_type}.{$rand}') ) return false;\" href='#'>" . __('Select all') . "</a>"; echo " - <a onclick= \"if ( plugin_resources_unMarkCheckboxes('massiveaction_form{$checklist_type}.{$rand}') ) return false;\" href='#'>" . __('Deselect all') . "</a> "; } self::dropdownChecklistActions($values); echo "</td>"; echo "</tr>"; } echo "</table>"; Html::closeForm(); } if (plugin_resources_haveRight('checklist', 'w') && $canedit) { $rand = mt_rand(); echo "<div id='viewchecklisttask" . "{$rand}'></div>\n"; echo "<script type='text/javascript' >\n"; echo "function viewAddChecklistTask" . "{$rand}(){\n"; $params = array('type' => __CLASS__, 'target' => $targetchecklist, 'plugin_resources_contracttypes_id' => $plugin_resources_contracttypes_id, 'plugin_resources_resources_id' => $plugin_resources_resources_id, 'checklist_type' => $checklist_type, 'id' => -1); Ajax::updateItemJsCode("viewchecklisttask" . "{$rand}", $CFG_GLPI["root_doc"] . "/plugins/resources/ajax/viewchecklisttask.php", $params, false); echo "};"; echo "</script>\n"; echo "<p align='center' ><a href='javascript:viewAddChecklistTask" . "{$rand}();'>"; if ($checklist_type == self::RESOURCES_CHECKLIST_IN) { _e('Add a task at the arriving checklist', 'resources'); } else { if ($checklist_type == self::RESOURCES_CHECKLIST_OUT) { _e('Add a task at the leaving checklist', 'resources'); } } echo "</a></p><br>\n"; } echo "</div>"; }
function plugin_resources_install() { global $DB; foreach (glob(GLPI_ROOT . '/plugins/resources/inc/*.php') as $file) { if (!preg_match('/resourceinjection/', $file) && !preg_match('/clientinjection/', $file) && !preg_match('/resourcepdf/', $file) && !preg_match('/datecriteria/', $file)) { include_once $file; } } $update = false; $update78 = false; $update80 = false; $update804 = false; $update83 = false; $install = false; if (!TableExists("glpi_plugin_resources_resources") && !TableExists("glpi_plugin_resources_employments")) { $install = true; // $DB->runFile(GLPI_ROOT ."/plugins/resources/sql/empty-1.9.0.sql"); // $DB->runFile(GLPI_ROOT ."/plugins/resources/sql/update-1.9.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/empty-1.9.1.sql"); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (1, '" . __('Long term contract', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (2, '" . __('Fixed term contract', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); $query = "INSERT INTO `glpi_plugin_resources_contracttypes` ( `id`, `name`,`comment`)\n VALUES (3, '" . __('Trainee', 'resources') . "', '')"; $DB->query($query) or die($DB->error()); } else { if (TableExists("glpi_plugin_resources") && !TableExists("glpi_plugin_resources_employee")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.4.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources_profiles") && FieldExists("glpi_plugin_resources_profiles", "interface")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources") && !FieldExists("glpi_plugin_resources", "helpdesk_visible")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.5.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_contracttypes")) { $update = true; $update78 = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (TableExists("glpi_plugin_resources_contracttypes") && !FieldExists("glpi_plugin_resources_resources", "plugin_resources_resourcestates_id")) { $update = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_reportconfigs")) { $update = true; $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.6.2.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_checklistconfigs")) { $update80 = true; $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_choiceitems")) { $update804 = true; $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.7.1.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } else { if (!TableExists("glpi_plugin_resources_employments")) { $update83 = true; $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.0.sql"); $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); $query = "SELECT *\n FROM `glpi_plugin_resources_employers`"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_array($result)) { $queryUpdate = "UPDATE `glpi_plugin_resources_employers`\n SET `completename`= '" . $data["name"] . "'\n WHERE `id`= '" . $data["id"] . "'"; $DB->query($queryUpdate) or die($DB->error()); } } } else { if (TableExists("glpi_plugin_resources_ranks") && !FieldExists("glpi_plugin_resources_ranks", "begin_date")) { $DB->runFile(GLPI_ROOT . "/plugins/resources/sql/update-1.9.1.sql"); } } } } } } } } } } } if ($update78 || $install) { //Do One time on 0.78 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resources'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.url## : ##resource.url##\n\n ##lang.resource.entity## : ##resource.entity##\n ##IFresource.name####lang.resource.name## : ##resource.name##\n ##ENDIFresource.name## ##IFresource.firstname####lang.resource.firstname## : ##resource.firstname##\n ##ENDIFresource.firstname## ##IFresource.type####lang.resource.type## : ##resource.type##\n ##ENDIFresource.type## ##IFresource.users####lang.resource.users## : ##resource.users##\n ##ENDIFresource.users## ##IFresource.usersrecipient####lang.resource.usersrecipient## : ##resource.usersrecipient##\n ##ENDIFresource.usersrecipient## ##IFresource.datedeclaration####lang.resource.datedeclaration## : ##resource.datedeclaration##\n ##ENDIFresource.datedeclaration## ##IFresource.datebegin####lang.resource.datebegin## : ##resource.datebegin##\n ##ENDIFresource.datebegin## ##IFresource.dateend####lang.resource.dateend## : ##resource.dateend##\n ##ENDIFresource.dateend## ##IFresource.department####lang.resource.department## : ##resource.department##\n ##ENDIFresource.department## ##IFresource.status####lang.resource.status## : ##resource.status##\n ##ENDIFresource.status## ##IFresource.location####lang.resource.location## : ##resource.location##\n ##ENDIFresource.location## ##IFresource.comment####lang.resource.comment## : ##resource.comment##\n ##ENDIFresource.comment## ##IFresource.usersleaving####lang.resource.usersleaving## : ##resource.usersleaving##\n ##ENDIFresource.usersleaving## ##IFresource.leaving####lang.resource.leaving## : ##resource.leaving##\n ##ENDIFresource.leaving## ##IFresource.helpdesk####lang.resource.helpdesk## : ##resource.helpdesk##\n ##ENDIFresource.helpdesk## ##FOREACHupdates##----------\n ##lang.update.title## :\n ##IFupdate.name####lang.resource.name## : ##update.name##\n ##ENDIFupdate.name## ##IFupdate.firstname####lang.resource.firstname## : ##update.firstname##\n ##ENDIFupdate.firstname## ##IFupdate.type####lang.resource.type## : ##update.type##\n ##ENDIFupdate.type## ##IFupdate.users####lang.resource.users## : ##update.users##\n ##ENDIFupdate.users## ##IFupdate.usersrecipient####lang.resource.usersrecipient## : ##update.usersrecipient##\n ##ENDIFupdate.usersrecipient## ##IFupdate.datedeclaration####lang.resource.datedeclaration## : ##update.datedeclaration##\n ##ENDIFupdate.datedeclaration## ##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin##\n ##ENDIFupdate.datebegin## ##IFupdate.dateend####lang.resource.dateend## : ##update.dateend##\n ##ENDIFupdate.dateend## ##IFupdate.department####lang.resource.department## : ##update.department##\n ##ENDIFupdate.department## ##IFupdate.status####lang.resource.status## : ##update.status##\n ##ENDIFupdate.status## ##IFupdate.location####lang.resource.location## : ##update.location##\n ##ENDIFupdate.location## ##IFupdate.comment####lang.resource.comment## : ##update.comment##\n ##ENDIFupdate.comment## ##IFupdate.usersleaving####lang.resource.usersleaving## : ##update.usersleaving##\n ##ENDIFupdate.usersleaving## ##IFupdate.leaving####lang.resource.leaving## : ##update.leaving##\n ##ENDIFupdate.leaving## ##IFupdate.helpdesk####lang.resource.helpdesk## : ##update.helpdesk##\n ##ENDIFupdate.helpdesk## ----------##ENDFOREACHupdates##\n ##FOREACHtasks####lang.task.title## :\n ##IFtask.name####lang.task.name## : ##task.name##\n ##ENDIFtask.name## ##IFtask.type####lang.task.type## : ##task.type##\n ##ENDIFtask.type## ##IFtask.users####lang.task.users## : ##task.users##\n ##ENDIFtask.users## ##IFtask.groups####lang.task.groups## : ##task.groups##\n ##ENDIFtask.groups## ##IFtask.datebegin####lang.task.datebegin## : ##task.datebegin##\n ##ENDIFtask.datebegin## ##IFtask.dateend####lang.task.dateend## : ##task.dateend##\n ##ENDIFtask.dateend## ##IFtask.comment####lang.task.comment## : ##task.comment##\n ##ENDIFtask.comment## ##IFtask.finished####lang.task.finished## : ##task.finished##\n ##ENDIFtask.finished## ##IFtask.realtime####lang.task.realtime## : ##task.realtime##\n ##ENDIFtask.realtime## ----------##ENDFOREACHtasks## ',\n '<p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.url##\n </strong> :\n <a href=\"##resource.url##\">##resource.url##\n </a></span> <br /><br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.entity##</strong> : ##resource.entity##\n </span> <br /> ##IFresource.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##resource.name##\n <br /></span>##ENDIFresource.name## ##IFresource.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##resource.firstname##\n <br /></span>##ENDIFresource.firstname## ##IFresource.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.type##</strong> : ##resource.type##<br />\n </span>##ENDIFresource.type## ##IFresource.status##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.status##</strong> : ##resource.status##<br />\n </span>##ENDIFresource.status## ##IFresource.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.users##</strong> : ##resource.users##<br />\n </span>##ENDIFresource.users## ##IFresource.usersrecipient##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersrecipient##\n </strong> : ##resource.usersrecipient##<br />\n </span>##ENDIFresource.usersrecipient## ##IFresource.datedeclaration##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datedeclaration##\n </strong> : ##resource.datedeclaration##<br />\n </span>##ENDIFresource.datedeclaration## ##IFresource.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datebegin##</strong> : ##resource.datebegin##\n <br /></span>##ENDIFresource.datebegin## ##IFresource.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.dateend##</strong> : ##resource.dateend##\n <br /></span>##ENDIFresource.dateend## ##IFresource.department##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.department##</strong> : ##resource.department##\n <br /></span>##ENDIFresource.department## ##IFresource.location##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.location##</strong> : ##resource.location##\n <br /></span>##ENDIFresource.location## ##IFresource.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.comment##</strong> : ##resource.comment##\n <br /></span>##ENDIFresource.comment## ##IFresource.usersleaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersleaving##</strong> : ##resource.usersleaving##\n <br /></span>##ENDIFresource.usersleaving## ##IFresource.leaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.leaving##</strong> : ##resource.leaving##\n <br /></span>##ENDIFresource.leaving## ##IFresource.helpdesk##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.helpdesk##</strong> : ##resource.helpdesk##\n <br /></span>##ENDIFresource.helpdesk## ##FOREACHupdates##----------\n <br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.update.title## :</strong></span>\n <br /> ##IFupdate.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##update.name##<br />\n </span>##ENDIFupdate.name## ##IFupdate.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##update.firstname##\n <br /></span>##ENDIFupdate.firstname## ##IFupdate.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.type##</strong> : ##update.type##<br />\n </span>##ENDIFupdate.type## ##IFupdate.status##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.status##</strong> : ##update.status##<br />\n </span>##ENDIFupdate.status## ##IFupdate.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.users##</strong> : ##update.users##<br />\n </span>##ENDIFupdate.users## ##IFupdate.usersrecipient##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersrecipient##</strong> : ##update.usersrecipient##\n <br /></span>##ENDIFupdate.usersrecipient## ##IFupdate.datedeclaration##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datedeclaration##\n </strong> : ##update.datedeclaration##<br />\n </span>##ENDIFupdate.datedeclaration## ##IFupdate.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.datebegin##</strong> : ##update.datebegin##\n <br /></span>##ENDIFupdate.datebegin## ##IFupdate.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.dateend##</strong> : ##update.dateend##\n <br /></span>##ENDIFupdate.dateend## ##IFupdate.department##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.department##</strong> : ##update.department##\n <br /></span>##ENDIFupdate.department## ##IFupdate.location##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.location##</strong> : ##update.location##\n <br /></span>##ENDIFupdate.location## ##IFupdate.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.comment##</strong> : ##update.comment##\n <br /></span>##ENDIFupdate.comment## ##IFupdate.usersleaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.usersleaving##\n </strong> : ##update.usersleaving##<br />\n </span>##ENDIFupdate.usersleaving## ##IFupdate.leaving##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.leaving##</strong> : ##update.leaving##\n <br /></span>##ENDIFupdate.leaving## ##IFupdate.helpdesk##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.helpdesk##</strong> : ##update.helpdesk##\n <br /></span>##ENDIFupdate.helpdesk####ENDFOREACHupdates## ##FOREACHtasks##----------\n <br /><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.title## :</strong></span> <br /> ##IFtask.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.name##</strong> : ##task.name##<br />\n </span>##ENDIFtask.name## ##IFtask.type##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.type##</strong> : ##task.type##<br />\n </span>##ENDIFtask.type## ##IFtask.users##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.users##</strong> : ##task.users##<br />\n </span>##ENDIFtask.users## ##IFtask.groups##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.groups##</strong> : ##task.groups##<br />\n </span>##ENDIFtask.groups## ##IFtask.datebegin##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.datebegin##</strong> : ##task.datebegin##<br />\n </span>##ENDIFtask.datebegin## ##IFtask.dateend##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.dateend##</strong> : ##task.dateend##<br />\n </span>##ENDIFtask.dateend## ##IFtask.comment##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.comment##</strong> : ##task.comment##<br />\n </span>##ENDIFtask.comment## ##IFtask.finished##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.finished##</strong> : ##task.finished##<br />\n </span>##ENDIFtask.finished## ##IFtask.realtime##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.task.realtime##</strong> : ##task.realtime##\n </span>##ENDIFtask.realtime##<br />----------##ENDFOREACHtasks##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource', 0, 'PluginResourcesResource', 'new',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource', 0, 'PluginResourcesResource', 'update',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource', 0, 'PluginResourcesResource', 'delete',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Task', 0, 'PluginResourcesResource', 'newtask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Task', 0, 'PluginResourcesResource', 'updatetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Task', 0, 'PluginResourcesResource', 'deletetask',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Resources Tasks'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##resource.action## : ##resource.entity##',\n '##FOREACHtasks##\n ##lang.task.name## : ##task.name##\n ##lang.task.type## : ##task.type##\n ##lang.task.users## : ##task.users##\n ##lang.task.groups## : ##task.groups##\n ##lang.task.datebegin## : ##task.datebegin##\n ##lang.task.dateend## : ##task.dateend##\n ##lang.task.comment## : ##task.comment##\n ##lang.task.resource## : ##task.resource##\n ##ENDFOREACHtasks##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.users##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.groups##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.datebegin##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.dateend##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.comment##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.task.resource##</span></td>\n </tr>\n ##FOREACHtasks##\n <tr>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.name##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.users##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.groups##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.datebegin##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.dateend##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.comment##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##task.resource##</span></td>\n </tr>\n ##ENDFOREACHtasks##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Expired Resources Tasks', 0, 'PluginResourcesResource', 'AlertExpiredTasks',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Leaving Resources'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##resource.action## : ##resource.entity##',\n '##FOREACHresources##\n ##lang.resource.name## : ##resource.name##\n ##lang.resource.firstname## : ##resource.firstname##\n ##lang.resource.type## : ##resource.type##\n ##lang.resource.location## : ##resource.location##\n ##lang.resource.users## : ##resource.users##\n ##lang.resource.dateend## : ##resource.dateend##\n ##ENDFOREACHresources##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n </tr>\n ##FOREACHresources##\n <tr>\n <td><a href=\"##resource.url##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n </tr>\n ##ENDFOREACHresources##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Leaving Resources', 0, 'PluginResourcesResource', 'AlertLeavingResources',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Alert Resources Checklists'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##checklist.action## : ##checklist.entity##',\n '##lang.checklist.title##\n\n ##FOREACHchecklists##\n ##lang.checklist.name## ##lang.checklist.firstname## : ##checklist.name## ##checklist.firstname##\n ##lang.checklist.datebegin## : ##checklist.datebegin##\n ##lang.checklist.dateend## : ##checklist.dateend##\n ##lang.checklist.entity## : ##checklist.entity##\n ##lang.checklist.location## : ##checklist.location##\n ##lang.checklist.type## : ##checklist.type##\n\n ##lang.checklist.title2## :\n ##tasklist.name##\n ##ENDFOREACHchecklists##',\n '<table class=\"tab_cadre\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\">\n <tbody>\n <tr bgcolor=\"#d9c4b8\">\n <th colspan=\"7\"><span style=\"font-family: Verdana; font-size: 11px; text-align: center;\">##lang.checklist.title##</span></th>\n </tr>\n <tr>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.name## ##lang.checklist.firstname##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.datebegin##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.dateend##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.entity##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.location##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.type##</span></td>\n <td style=\"text-align: left;\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.checklist.title2##</span></td>\n </tr>\n ##FOREACHchecklists##\n <tr>\n <td><a href=\"##checklist.url##\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.name## ##checklist.firstname##</span></a></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.datebegin##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.dateend##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.entity##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.location##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##checklist.type##</span></td>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <table width=\"100%\">\n <tbody>\n <tr>\n <td><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"> ##tasklist.name## </span></td>\n </tr>\n </tbody>\n </table>\n </span></td>\n </tr>\n ##ENDFOREACHchecklists##\n </tbody>\n </table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Arrival Checklists', 0, 'PluginResourcesResource', 'AlertArrivalChecklists',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Alert Leaving Checklists', 0, 'PluginResourcesResource', 'AlertLeavingChecklists',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-02-17 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Leaving Resource'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.title2##\n\n ##lang.resource.url## : ##resource.url##\n\n ##lang.resource.entity## : ##resource.entity##\n ##IFresource.name## ##lang.resource.name## : ##resource.name##\n ##ENDIFresource.name##\n ##IFresource.firstname## ##lang.resource.firstname## : ##resource.firstname##\n ##ENDIFresource.firstname##\n\n ##lang.resource.badge##',\n '<p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.resource.title2##</strong>\n <p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.url##</strong> :\n <a href=\"##resource.url##\">##resource.url##</a>\n </span> <br /><br />\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.entity##</strong> : ##resource.entity##</span>\n <br /> ##IFresource.name##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.name##</strong> : ##resource.name##<br />\n </span>##ENDIFresource.name## ##IFresource.firstname##\n <span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n <strong>##lang.resource.firstname##</strong> : ##resource.firstname##\n <br /></span>##ENDIFresource.firstname##</p>\n <p><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\"><strong>##lang.resource.badge##</strong></span></p>\n </span></p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Leaving Resource', 0, 'PluginResourcesResource', 'LeavingResource',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); } if ($update78) { $profiles = getAllDatasFromTable("glpi_plugin_resources_profiles"); if (!empty($profiles)) { foreach ($profiles as $profile) { $query = "UPDATE `glpi_plugin_resources_profiles`\n SET `profiles_id` = '" . $resource["id"] . "'\n WHERE `id` = '" . $resource["id"] . "';"; $result = $DB->query($query); } } $query = "ALTER TABLE `glpi_plugin_resources_profiles`\n DROP `name` ;"; $result = $DB->query($query); $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets"); foreach ($tables as $table) { $query = "DELETE FROM `{$table}` WHERE (`itemtype` = '4302' ) "; $DB->query($query); } Plugin::migrateItemType(array(4300 => 'PluginResourcesResource', 4301 => 'PluginResourcesTask', 4303 => 'PluginResourcesDirectory'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_resources_resources_items", "glpi_plugin_resources_choices", "glpi_plugin_resources_tasks_items")); Plugin::migrateItemType(array(1600 => "PluginBadgesBadge"), array("glpi_plugin_resources_resources_items", "glpi_plugin_resources_choices", "glpi_plugin_resources_tasks_items")); } if ($update || $install) { //Do One time on 0.78 for 1.6.2 $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Report Creation'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.creationtitle##\n\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n##lang.resource.department## : ##resource.department##\n##lang.resource.location## : ##resource.location##\n##lang.resource.users## : ##resource.users##\n##lang.resource.usersrecipient## : ##resource.usersrecipient##\n##lang.resource.datedeclaration## : ##resource.datedeclaration##\n##lang.resource.datebegin## : ##resource.datebegin##\n\n##lang.resource.creation##\n\n##lang.resource.datecreation## : ##resource.datecreation##\n##lang.resource.login## : ##resource.login##\n##lang.resource.email## : ##resource.email##\n\n##lang.resource.informationtitle##\n\n##IFresource.commentaires####lang.resource.commentaires## : ##resource.commentaires####ENDIFresource.commentaires##\n\n##IFresource.informations####lang.resource.informations## : ##resource.informations####ENDIFresource.informations##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.creationtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" colspan=\"2\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" colspan=\"2\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.usersrecipient##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.usersrecipient##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datedeclaration##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datedeclaration##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.creation##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datecreation##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datecreation##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.login##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.login##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.email##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.email##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.informationtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFresource.commentaires##\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n##ENDIFresource.commentaires## ##IFresource.informations##\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.informations##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.informations##</span></td>\n</tr>\n##ENDIFresource.informations##\n</tbody>\n</table>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Resource Report Creation', 0, 'PluginResourcesResource', 'report',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-11-16 11:36:46');"; $result = $DB->query($query); } if ($update80) { $restrict = "`plugin_resources_resources_id` ='-1'"; $checklists = getAllDatasFromTable("glpi_plugin_resources_checklists", $restrict); $PluginResourcesChecklistconfig = new PluginResourcesChecklistconfig(); if (!empty($checklists)) { foreach ($checklists as $checklist) { $values["name"] = addslashes($checklist["name"]); $values["address"] = addslashes($checklist["address"]); $values["comment"] = addslashes($checklist["comment"]); $values["tag"] = $checklist["tag"]; $values["entities_id"] = $checklist["entities_id"]; $PluginResourcesChecklistconfig->add($values); } } $query = "DELETE FROM `glpi_plugin_resources_checklists`\n WHERE `plugin_resources_resources_id` ='-1'\n OR `plugin_resources_resources_id` ='0';"; $DB->query($query); // Put realtime in seconds if (FieldExists('glpi_plugin_resources_tasks', 'realtime')) { $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n ADD `actiontime` INT( 11 ) NOT NULL DEFAULT 0 ;"; $DB->queryOrDie($query, $this->version . " 0.80 Add actiontime in glpi_plugin_resources_tasks"); $query = "UPDATE `glpi_plugin_resources_tasks`\n SET `actiontime` = ROUND(realtime * 3600)"; $DB->queryOrDie($query, $this->version . " 0.80 Compute actiontime value in glpi_plugin_resources_tasks"); $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n DROP `realtime` ;"; $DB->queryOrDie($query, $this->version . " 0.80 DROP realtime in glpi_plugin_resources_tasks"); } // ADD plannings for tasks $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks"); if (!empty($tasks)) { foreach ($tasks as $task) { $query = "INSERT INTO `glpi_plugin_resources_taskplannings`\n ( `id` , `plugin_resources_tasks_id` , `begin` , `end` )\n VALUES (NULL , '" . $task["id"] . "', '" . $task["date_begin"] . "', '" . $task["date_end"] . "') ;"; $DB->query($query); } } unset($input); $query = "ALTER TABLE `glpi_plugin_resources_tasks`\n DROP `date_begin`, DROP `date_end` ;"; $DB->queryOrDie($query, $this->version . " 0.80 Drop date_begin and date_end in glpi_plugin_resources_tasks"); // ADD tasks $PluginResourcesResource = new PluginResourcesResource(); $taches = getAllDatasFromTable("glpi_plugin_resources_tasks"); if (!empty($taches)) { foreach ($taches as $tache) { $PluginResourcesResource->getFromDB($tache["plugin_resources_resources_id"]); $input["entities_id"] = $PluginResourcesResource->fields["entities_id"]; $query = "UPDATE `glpi_plugin_resources_tasks`\n SET `entities_id` = '" . $PluginResourcesResource->fields["entities_id"] . "' WHERE `id` = '" . $tache["id"] . "' ;"; $DB->query($query); } } } if ($install || $update80) { $restrict = "`itemtype` = 'PluginResourcesResource'"; $unicities = getAllDatasFromTable("glpi_fieldunicities", $restrict); if (empty($unicities)) { $query = "INSERT INTO `glpi_fieldunicities`\n VALUES (NULL, 'Resources creation', 1, 'PluginResourcesResource', '0',\n 'name,firstname','1',\n '1', '1', '');"; $DB->queryOrDie($query, " 0.80 Create fieldunicities check"); } $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Resting'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.restingtitle##\n##lang.resource.openby## : ##resource.openby##\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n\n##lang.resource.department## : ##resource.department##\n##lang.resource.users## : ##resource.users##\n\n##lang.resource.resting##\n\n##lang.resource.location## : ##resource.location##\n##lang.resource.home## : ##resource.home##\n##lang.resource.datebegin## : ##resource.datebegin##\n##lang.resource.dateend## : ##resource.dateend##\n\n##lang.resource.commentaires## : ##resource.commentaires##\n\n##FOREACHupdates##\n##lang.update.title##\n\n##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin####ENDIFupdate.datebegin##\n##IFupdate.dateend####lang.resource.dateend## : ##update.dateend####ENDIFupdate.dateend##\n##IFupdate.location####lang.resource.location## : ##update.location###ENDIFupdate.location##\n##IFupdate.home####lang.resource.home## : ##update.home####ENDIFupdate.home##\n##IFupdate.comment####lang.resource.comment## : ##update.comment####ENDIFupdate.comment##\n##ENDFOREACHupdates##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.restingtitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.openby##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.openby##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.resting##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.location##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.home##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.home##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n</tbody>\n</table>\n<p>##FOREACHupdates##</p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.update.title##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFupdate.datebegin##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin## : ##update.datebegin##\n</span></span></td>\n</tr>\n##ENDIFupdate.datebegin## ##IFupdate.dateend##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend## : ##update.dateend##\n</span></span></td>\n</tr>\n##ENDIFupdate.dateend## ##IFupdate.location##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.location## : ##update.location##\n</span></span></td>\n</tr>\n##ENDIFupdate.location## ##IFupdate.home##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.home## : ##update.home##\n</span></span></td>\n</tr>\n##ENDIFupdate.home## ##IFupdate.comment##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.comment## : ##update.comment##\n</span></span></td>\n</tr>\n##ENDIFupdate.comment##\n</tbody>\n</table>\n<p>##ENDFOREACHupdates##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Resting', 0, 'PluginResourcesResource', 'newresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Resting', 0, 'PluginResourcesResource', 'updateresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Resting', 0, 'PluginResourcesResource', 'deleteresting',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginResourcesResource' AND `name` = 'Resource Holiday'"; $result = $DB->query($query_id) or die($DB->error()); $itemtype = $DB->result($result, 0, 'id'); $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n VALUES(NULL, " . $itemtype . ", '','##lang.resource.title## - ##resource.firstname## ##resource.name##',\n '##lang.resource.holidaytitle##\n##lang.resource.openby## : ##resource.openby##\n##lang.resource.entity## : ##resource.entity##\n\n##lang.resource.name## : ##resource.name##\n##lang.resource.firstname## : ##resource.firstname##\n\n##lang.resource.department## : ##resource.department##\n##lang.resource.users## : ##resource.users##\n\n##lang.resource.holiday##\n\n##lang.resource.datebegin## : ##resource.datebegin##\n##lang.resource.dateend## : ##resource.dateend##\n\n##lang.resource.commentaires## : ##resource.commentaires##\n\n##FOREACHupdates##\n##lang.update.title##\n\n##IFupdate.datebegin####lang.resource.datebegin## : ##update.datebegin####ENDIFupdate.datebegin##\n##IFupdate.dateend####lang.resource.dateend## : ##update.dateend####ENDIFupdate.dateend##\n##IFupdate.comment####lang.resource.comment## : ##update.comment####ENDIFupdate.comment##\n##ENDFOREACHupdates##',\n '<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.holidaytitle##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.entity##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.openby##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.openby##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.name##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.firstname##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.firstname##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.department##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.users##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.users##</span></td>\n</tr>\n</tbody>\n</table>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.resource.holiday##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.datebegin##</span></td>\n<td style=\"text-align: left;\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend##</span></td>\n<td style=\"text-align: left;\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.dateend##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\" bgcolor=\"#cccccc\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.commentaires##</span></td>\n</tr>\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\"><span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##resource.commentaires##</span></td>\n</tr>\n</tbody>\n</table>\n<p>##FOREACHupdates##</p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; font-family: verdana;\">##lang.update.title##</span></p>\n<table border=\"1\" cellspacing=\"2\" cellpadding=\"3\" width=\"590px\" align=\"center\">\n<tbody>\n##IFupdate.datebegin##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.datebegin## : ##update.datebegin##\n</span></span></td>\n</tr>\n##ENDIFupdate.datebegin## ##IFupdate.dateend##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.dateend## : ##update.dateend##\n</span></span></td>\n</tr>\n##ENDIFupdate.dateend## ##IFupdate.comment##\n<tr>\n<td style=\"text-align: left;\" colspan=\"4\" width=\"auto\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">\n<span style=\"font-family: Verdana; font-size: 11px; text-align: left;\">##lang.resource.comment## : ##update.comment##\n</span></span></td>\n</tr>\n##ENDIFupdate.comment##\n</tbody>\n</table>\n<p>##ENDFOREACHupdates##</p>');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'New Resource Holiday', 0, 'PluginResourcesResource', 'newholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Update Resource Holiday', 0, 'PluginResourcesResource', 'updateholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); $query = "INSERT INTO `glpi_notifications`\n VALUES (NULL, 'Delete Resource Holiday', 0, 'PluginResourcesResource', 'deleteholiday',\n 'mail'," . $itemtype . ",\n '', 1, 1, '2010-05-16 22:36:46');"; $result = $DB->query($query); } if ($update804) { $query = "SELECT * FROM `glpi_plugin_resources_choices`\n WHERE `itemtype`!= ''\n GROUP BY `comment`,`itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); $affectedchoices = array(); if (!empty($number)) { while ($data = $DB->fetch_assoc($result)) { $restrictaffected = "`itemtype` = '" . $data["itemtype"] . "'\n AND `comment` = '" . addslashes($data["comment"]) . "'"; $affected = getAllDatasFromTable("glpi_plugin_resources_choices", $restrictaffected); if (!empty($affected)) { foreach ($affected as $affect) { if ($affect["itemtype"] == $data["itemtype"] && $affect["comment"] == $data["comment"]) { $affectedchoices[$data["id"]][] = $affect["plugin_resources_resources_id"]; } } } } } $i = 0; if (!empty($affectedchoices)) { foreach ($affectedchoices as $key => $ressources) { $i++; $choice = new PluginResourcesChoice(); $choice_item = new PluginResourcesChoiceItem(); $types = array(__('Computer') => 'Computer', __('Monitor') => 'Monitor', __('Software') => 'Software', __('Network device') => 'NetworkEquipment', __('Printer') => 'Printer', __('Peripheral') => 'Peripheral', __('Phone') => 'Phone', __('Consumable model') => 'ConsumableItem', __('Specific network rights', 'resources') => '4303', __('Access to the applications', 'resources') => '4304', __('Specific securities groups', 'resources') => '4305', __('Specific distribution lists', 'resources') => '4306', __('Others needs', 'resources') => '4307', 'PluginBadgesBadge' => 'PluginBadgesBadge'); if ($choice->getFromDB($key)) { $key = array_search($choice->fields["itemtype"], $types); if ($key) { $name = $key; } else { $name = $choice->fields["itemtype"]; } $valuesparent["name"] = $i . "." . $name; $valuesparent["entities_id"] = 0; $valuesparent["is_recursive"] = 1; $newidparent = $choice_item->add($valuesparent); $comment = "N/A"; if (!empty($choice->fields["comment"])) { $comment = $choice->fields["comment"]; } $valueschild["name"] = addslashes(Html::resume_text($comment, 50)); $valueschild["comment"] = addslashes($comment); $valueschild["entities_id"] = 0; $valueschild["is_recursive"] = 1; $valueschild["plugin_resources_choiceitems_id"] = $newidparent; $newidchild = $choice_item->add($valueschild); foreach ($ressources as $id => $val) { $query = "UPDATE `glpi_plugin_resources_choices`\n SET `plugin_resources_choiceitems_id` = '" . $newidchild . "'\n WHERE `plugin_resources_resources_id` = '" . $val . "'\n AND `itemtype` = '" . $choice->fields["itemtype"] . "'\n AND `comment` = '" . addslashes($choice->fields["comment"]) . "';"; $result = $DB->query($query); } } } } $query = "ALTER TABLE `glpi_plugin_resources_choices`\n DROP `itemtype`,\n DROP `comment`,\n ADD UNIQUE KEY `unicity` (`plugin_resources_resources_id`,`plugin_resources_choiceitems_id`);"; $result = $DB->query($query); $query = "ALTER TABLE `glpi_plugin_resources_choices`\n ADD `comment` text collate utf8_unicode_ci;"; $result = $DB->query($query); } //0.83 - Drop Matricule if (TableExists("glpi_plugin_resources_employees") && FieldExists("glpi_plugin_resources_employees", "matricule")) { $query = "SELECT * FROM `glpi_users`"; $result = $DB->query($query); $number = $DB->numrows($result); if (!empty($number)) { while ($data = $DB->fetch_assoc($result)) { $restrict = "`items_id` = '" . $data["id"] . "'\n AND `itemtype` = 'User'"; $links = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); if (!empty($links)) { foreach ($links as $link) { $employee = new PluginResourcesEmployee(); if ($employee->getFromDBbyResources($link["plugin_resources_resources_id"])) { $matricule = $employee->fields["matricule"]; if (isset($matricule) && !empty($matricule)) { $query = "UPDATE `glpi_users`\n SET `registration_number` = '" . $matricule . "'\n WHERE `id` ='" . $link["items_id"] . "'"; $DB->query($query); } } } } } } $query = "ALTER TABLE `glpi_plugin_resources_employees`\n DROP `matricule` ;"; $result = $DB->query($query); } $rep_files_resources = GLPI_PLUGIN_DOC_DIR . "/resources"; if (!is_dir($rep_files_resources)) { mkdir($rep_files_resources); } CronTask::Register('PluginResourcesResource', 'Resources', DAY_TIMESTAMP); CronTask::Register('PluginResourcesTask', 'ResourcesTask', DAY_TIMESTAMP); CronTask::Register('PluginResourcesChecklist', 'ResourcesChecklist', DAY_TIMESTAMP); CronTask::Register('PluginResourcesEmployment', 'ResourcesLeaving', DAY_TIMESTAMP, array('state' => CronTask::STATE_DISABLE)); PluginResourcesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); return true; }
function showItemHelpdesk($plugin_resources_resources_id, $exist, $withtemplate = '') { global $CFG_GLPI; $restrict = "`plugin_resources_resources_id` = '{$plugin_resources_resources_id}'"; $choices = getAllDatasFromTable($this->getTable(), $restrict); $resource = new PluginResourcesResource(); $resource->getFromDB($plugin_resources_resources_id); $canedit = $resource->can($plugin_resources_resources_id, 'w') && $withtemplate < 2 && $resource->fields["is_leaving"] != 1; if ($exist == 0) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource_item.list.php\">"; } else { if ($exist == 1) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/resource.form.php\">"; } } echo "<div align='center'><table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='4'>" . __('Element(s) to be affected', 'resources') . "</th>"; echo "</tr>"; echo "<tr>"; echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Description') . "</th>"; echo "<th>" . __('Comments') . "</th>"; if ($canedit) { echo "<th> </th>"; } echo "</tr>"; $used = array(); if (!empty($choices)) { foreach ($choices as $choice) { $used[] = $choice["plugin_resources_choiceitems_id"]; echo "<tr class='tab_bg_1'>"; $items = Dropdown::getDropdownName("glpi_plugin_resources_choiceitems", $choice["plugin_resources_choiceitems_id"], 1); echo "<td class='left'>"; echo $items['name']; echo "</td>"; echo "<td class='left'>"; echo nl2br($items["comment"]); echo "</td>"; echo "<td class='center'>"; $rand = mt_rand(); if (!empty($choice["comment"])) { self::showModifyCommentFrom($choice, $rand); } else { self::showAddCommentForm($choice, $rand); } echo "</td>"; if ($canedit) { echo "<td class='center' class='tab_bg_2'>"; Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/resources/front/resource_item.list.php', 'deletehelpdeskitem', _x('button', 'Delete permanently'), array('id' => $choice["id"])); echo "</td>"; } echo "</tr>"; } } if ($canedit) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='4'>" . __('Add a need', 'resources') . " :</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='4' class='center'>"; echo "<input type='hidden' name='plugin_resources_resources_id' value='{$plugin_resources_resources_id}'>"; $condition = ""; if ($_SESSION['glpiactiveprofile']['interface'] != 'central') { $condition = '`is_helpdesk_visible` = 1'; } Dropdown::show('PluginResourcesChoiceItem', array('name' => 'plugin_resources_choiceitems_id', 'entity' => $_SESSION['glpiactive_entity'], 'condition' => $condition, 'used' => $used)); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center' colspan='4'>"; echo "<input type='submit' name='addhelpdeskitem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='id' value=\"{$plugin_resources_resources_id}\">"; echo " "; if ($_SESSION['glpiactiveprofile']['interface'] != 'central') { if ($exist != 1) { echo "<input type='submit' name='finish' value=\"" . __('Terminate the declaration', 'resources') . "\" class='submit'>"; } else { echo "<input type='submit' name='resend' value=\"" . __('Resend the declaration', 'resources') . "\" class='submit'>"; } } echo "</td>"; echo "</tr>"; } echo "</table></div>"; Html::closeForm(); echo "<br>"; }