/** * 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); } }
This file is part of Resources. Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; //from helpdesk Html::helpHeader(PluginResourcesResource::getTypeName(2)); $employee = new PluginResourcesEmployee(); //add employee informations from helpdesk //next step : show list needs of the new ressource if (isset($_POST["add_helpdesk_employee"])) { $newID = $employee->add($_POST); Html::redirect("./resource_item.list.php?id=" . $_POST["plugin_resources_resources_id"] . "&exist=0"); } else { //show form employee informations from helpdesk $employee->showFormHelpdesk($_GET["id"], 0); } Html::helpFooter();
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $resource = new PluginResourcesResource(); $employee = new PluginResourcesEmployee(); $choice = new PluginResourcesChoice(); $resource->checkGlobal("r"); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { //from central Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); } else { //from helpdesk Html::helpHeader(PluginResourcesResource::getTypeName(2)); } if (isset($_POST["first_step"]) || isset($_GET["first_step"])) { if (!isset($_POST["template"])) { $_POST["template"] = $_GET["template"]; } if (!isset($_POST["withtemplate"])) { $_POST["withtemplate"] = $_GET["withtemplate"];
You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } $resource = new PluginResourcesResource(); $checklist = new PluginResourcesChecklist(); $checklistconfig = new PluginResourcesChecklistconfig(); $employee = new PluginResourcesEmployee(); $choice = new PluginResourcesChoice(); $resource_item = new PluginResourcesResource_Item(); $cat = new PluginResourcesTicketCategory(); $task = new PluginResourcesTask(); /////////////////////////////////resource from helpdesk/////////////////////////////// if (isset($_POST["resend"])) { $resource->reSendResourceCreation($_POST); $resource->redirectToList(); //from helpdesk //add items needs of a resource } else { if (isset($_POST["addhelpdeskitem"])) { if ($_POST['plugin_resources_choiceitems_id'] > 0 && $_POST['plugin_resources_resources_id'] > 0) { if ($resource->canCreate()) { $choice->addHelpdeskItem($_POST);
function showForm($ID, $options = array()) { if (!Session::haveRight("profile", "r")) { return false; } $prof = new Profile(); if ($ID) { $this->getFromDBByProfile($ID); $prof->getFromDB($ID); } $this->showFormHeader($options); echo "<tr class='tab_bg_2'>"; echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'resources'), $prof->fields["name"]) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesResource::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("resources", $this->fields["resources"], 1, 1, 1); echo "</td>"; echo "<td>" . PluginResourcesTask::getTypeName(2) . "</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("task", $this->fields["task"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesChecklist::getTypeName(2) . "</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("checklist", $this->fields["checklist"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "<td>" . PluginResourcesEmployee::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("employee", $this->fields["employee"], 1, 1, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('All resources access', 'resources') . "</td><td>"; Profile::dropdownNoneReadWrite("all", $this->fields["all"], 1, 0, 1); echo "</td>"; echo "<td>" . __('Associable items to a ticket') . " - " . PluginResourcesResource::getTypeName(2) . "</td><td>"; if ($prof->fields['create_ticket']) { Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]); } else { echo Dropdown::getYesNo(0); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<th colspan='4' class='center b'>" . __('Service company management', 'resources') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesResourceResting::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("resting", $this->fields["resting"], 1, 0, 1); echo "</td>"; echo "<td>" . PluginResourcesResourceHoliday::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("holiday", $this->fields["holiday"], 1, 0, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<th colspan='4' class='center b'>" . __('Public service management', 'resources') . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginResourcesEmployment::getTypeName(2) . "</td><td>"; Profile::dropdownNoneReadWrite("employment", $this->fields["employment"], 1, 1, 1); echo "</td>"; echo "<td>" . PluginResourcesBudget::getTypeName(2) . ":</td><td>"; Profile::dropdownNoneReadWrite("budget", $this->fields["budget"], 1, 1, 1); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Dropdown management', 'resources') . "</td><td>"; Profile::dropdownNoneReadWrite("dropdown_public", $this->fields["dropdown_public"], 1, 1, 1); echo "</td><td></td><td></td>"; echo "</tr>"; echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">"; $options['candel'] = false; $this->showFormButtons($options); }
function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); $resource_item = new PluginResourcesResource_Item(); switch ($input['action']) { case "Transfert": if ($input['itemtype'] == 'PluginResourcesResource') { foreach ($input["item"] as $key => $val) { if ($val == 1) { $this->getFromDB($key); $contracttype = PluginResourcesContractType::transfer($PluginResourcesResource->fields["plugin_resources_contracttypes_id"], $input['entities_id']); if ($contracttype > 0) { $values["id"] = $key; $values["plugin_resources_contracttypes_id"] = $contracttype; $this->update($values); } unset($values); $resourcestate = PluginResourcesResourceState::transfer($PluginResourcesResource->fields["plugin_resources_resourcestates_id"], $input['entities_id']); if ($resourcestate > 0) { $values["id"] = $key; $values["plugin_resources_resourcestates_id"] = $resourcestate; $this->update($values); } unset($values); $department = PluginResourcesDepartment::transfer($PluginResourcesResource->fields["plugin_resources_departments_id"], $input['entities_id']); if ($department > 0) { $values["id"] = $key; $values["plugin_resources_departments_id"] = $department; $this->update($values); } unset($values); $situation = PluginResourcesResourceSituation::transfer($PluginResourcesResource->fields["plugin_resources_resourcesituations_id"], $input['entities_id']); if ($situation > 0) { $values["id"] = $key; $values["plugin_resources_resourcesituations_id"] = $situation; $this->update($values); } unset($values); $contractnature = PluginResourcesContractNature::transfer($PluginResourcesResource->fields["plugin_resources_contractnatures_id"], $input['entities_id']); if ($contractnature > 0) { $values["id"] = $key; $values["plugin_resources_contractnatures_id"] = $contractnature; $this->update($values); } unset($values); $rank = PluginResourcesRank::transfer($PluginResourcesResource->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $key; $values["plugin_resources_ranks_id"] = $rank; $this->update($values); } unset($values); $speciality = PluginResourcesResourceSpeciality::transfer($PluginResourcesResource->fields["plugin_resources_resourcespecialities_id"], $input['entities_id']); if ($speciality > 0) { $values["id"] = $key; $values["plugin_resources_resourcespecialities_id"] = $speciality; $this->update($values); } unset($values); $PluginResourcesTask = new PluginResourcesTask(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $tasks = getAllDatasFromTable("glpi_plugin_resources_tasks", $restrict); if (!empty($tasks)) { foreach ($tasks as $task) { $PluginResourcesTask->getFromDB($task["id"]); $tasktype = PluginResourcesTaskType::transfer($PluginResourcesTask->fields["plugin_resources_tasktypes_id"], $input['entities_id']); if ($tasktype > 0) { $values["id"] = $task["id"]; $values["plugin_resources_tasktypes_id"] = $tasktype; $PluginResourcesTask->update($values); } $values["id"] = $task["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesTask->update($values); } } unset($values); $PluginResourcesEmployment = new PluginResourcesEmployment(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employments = getAllDatasFromTable("glpi_plugin_resources_employments", $restrict); if (!empty($employments)) { foreach ($employments as $employment) { $PluginResourcesEmployment->getFromDB($employment["id"]); $rank = PluginResourcesRank::transfer($PluginResourcesEmployment->fields["plugin_resources_ranks_id"], $input['entities_id']); if ($rank > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_ranks_id"] = $rank; $PluginResourcesEmployment->update($values); } $PluginResourcesEmployment->getFromDB($employment["id"]); $profession = PluginResourcesProfession::transfer($PluginResourcesEmployment->fields["plugin_resources_professions_id"], $input['entities_id']); if ($profession > 0) { $values["id"] = $employment["id"]; $values["plugin_resources_professions_id"] = $profession; $PluginResourcesEmployment->update($values); } $values["id"] = $employment["id"]; $values["entities_id"] = $input['entities_id']; $PluginResourcesEmployment->update($values); } } unset($values); $PluginResourcesEmployee = new PluginResourcesEmployee(); $restrict = "`plugin_resources_resources_id` = '" . $key . "'"; $employees = getAllDatasFromTable("glpi_plugin_resources_employees", $restrict); if (!empty($employees)) { foreach ($employees as $employee) { $employer = PluginResourcesEmployer::transfer($employee["plugin_resources_employers_id"], $input['entities_id']); if ($employer > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_employers_id"] = $employer; $PluginResourcesEmployee->update($values); } $client = PluginResourcesClient::transfer($employee["plugin_resources_clients_id"], $input['entities_id']); if ($client > 0) { $values["id"] = $employee["id"]; $values["plugin_resources_clients_id"] = $client; $PluginResourcesEmployee->update($values); } } } unset($values); $query = "UPDATE `glpi_plugin_resources_checklists`\n SET `entities_id` = '" . $input['entities_id'] . "'\n WHERE `plugin_resources_resources_id` ='{$key}'"; $DB->query($query); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($this->update($values)) { $res['ok']++; } else { $res['ko']++; } } } } break; case "Install": foreach ($input["item"] as $key => $val) { if ($val == 1) { $values = array('plugin_resources_resources_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']); if ($resource_item->add($values)) { $res['ok']++; } else { $res['ko']++; } } } break; case "Desinstall": foreach ($input["item"] as $key => $val) { if ($val == 1) { if ($resource_item->deleteItemByResourcesAndItem($key, $input['item_item'], $input['typeitem'])) { $res['ok']++; } else { $res['ko']++; } } } break; case "Send": if ($this->sendEmail($input)) { $res['ok']++; } else { $res['ko']++; } break; default: return parent::doSpecificMassiveActions($input); break; } return $res; }
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; }