*/ 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); } } Html::back(); } else {
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"] = ""; } if (!isset($_GET["plugin_resources_resources_id"])) { $_GET["plugin_resources_resources_id"] = 0; } $task = new PluginResourcesTask(); $task_item = new PluginResourcesTask_Item(); //add tasks if (isset($_POST['add'])) { $task->check(-1, 'w', $_POST); $newID = $task->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $task->check($_POST['id'], 'w'); $task->update($_POST); //no sending mail here : see post_updateItem of PluginResourcesTask Html::back(); } else { if (isset($_POST["delete"])) { $task->check($_POST['id'], 'w');
/** * Display a Planning Item * * @param $val Array of the item to display * * @return Already planned information **/ static function getAlreadyPlannedInformation($val) { global $CFG_GLPI; $out = ""; $out .= PluginResourcesResource::getTypeName() . " - " . PluginResourcesTask::getTypeName() . ' : ' . Html::convDateTime($val["begin"]) . ' -> ' . Html::convDateTime($val["end"]) . ' : '; $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.form.php?id=" . $val["plugin_resources_tasks_id"] . "'>"; $out .= Html::resume_text($val["name"], 80) . '</a>'; return $out; }
Resources is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Resources is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Resources. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; Html::header(PluginResourcesResource::getTypeName(2), '', "plugins", "resources"); $task = new PluginResourcesTask(); if ($task->canView() || Session::haveRight("config", "w")) { Search::manageGetValues("PluginResourcesTask"); //if $_GET["plugin_resources_resources_id"] exist this show list of tasks from a resource //else show all resources if (isset($_GET["plugin_resources_resources_id"]) && !empty($_GET["plugin_resources_resources_id"])) { $_GET["field"] = array(0 => "13"); $_GET["contains"] = array(0 => $_GET["plugin_resources_resources_id"]); } Search::showGenericSearch("PluginResourcesTask", $_GET); Search::showList("PluginResourcesTask", $_GET); } else { Html::displayRightError(); } Html::footer();
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 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 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_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB; $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; } switch ($type) { case 'PluginResourcesResource': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["ITEM_" . $num . "_2"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResource'); $out = ""; if ($output_type == Search::HTML_OUTPUT) { $out = "<a href=\"" . $link . "?id=" . $data["ITEM_" . $num . "_2"] . "\">"; } $out .= $data["META_{$num}"]; if ($output_type == Search::HTML_OUTPUT) { if ($_SESSION["glpiis_ids_visible"] || empty($data["META_{$num}"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } if (plugin_resources_haveRight("task", "r") && $output_type == Search::HTML_OUTPUT) { $query_tasks = "SELECT COUNT(`id`) AS nb_tasks,SUM(`is_finished`) AS is_finished\n FROM `glpi_plugin_resources_tasks`\n WHERE `plugin_resources_resources_id` = '" . $data['id'] . "'\n AND `is_deleted` = '0'"; $result_tasks = $DB->query($query_tasks); $nb_tasks = $DB->result($result_tasks, 0, "nb_tasks"); $is_finished = $DB->result($result_tasks, 0, "is_finished"); $out .= " (<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?plugin_resources_resources_id=" . $data["id"] . "\">"; if ($nb_tasks - $is_finished > 0) { $out .= "<span class='plugin_resources_date_over_color'>"; $out .= $nb_tasks - $is_finished . "</span></a>)"; } else { $out .= "<span class='plugin_resources_date_day_color'>"; $out .= $nb_tasks . "</span></a>)"; } } } return $out; break; case "glpi_plugin_resources_resources.date_end": if ($data["ITEM_{$num}"] <= date('Y-m-d') && !empty($data["ITEM_{$num}"])) { $out = "<span class='plugin_resources_date_color'>" . Html::convDate($data["ITEM_{$num}"]) . "</span>"; } else { if (empty($data["ITEM_{$num}"])) { $out = __('Not defined', 'resources'); } else { $out = Html::convDate($data["ITEM_{$num}"]); } } return $out; break; case "glpi_plugin_resources_resources_items.items_id": $restrict = "`plugin_resources_resources_id` = '" . $data['id'] . "'\n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { if (!class_exists($device["itemtype"])) { continue; } $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - "; if ($device["itemtype"] == 'User') { if ($output_type == Search::HTML_OUTPUT) { $link = Toolbox::getItemTypeFormURL('User'); $out .= "<a href=\"" . $link . "?id=" . $device["items_id"] . "\">"; } $out .= getUserName($device["items_id"]); if ($output_type == Search::HTML_OUTPUT) { $out .= "</a>"; } } else { $out .= $item->getLink(); } $out .= "<br>"; } } else { $out = ' '; } return $out; break; case "glpi_plugin_resources_resources.quota": if (!empty($data["ITEM_{$num}"])) { $out = floatval($data["ITEM_{$num}"]); } return $out; break; } return ""; break; case 'PluginResourcesTask': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $user = PluginResourcesResource::getResourceName($data["ITEM_" . $num . "_2"], 2); $out = "<a href='" . $user['link'] . "'>"; $out .= $user["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($user["name"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } return $out; break; case 'glpi_plugin_resources_tasks.is_finished': $status = PluginResourcesTask::getStatus($data["ITEM_{$num}"]); return "<img src=\"" . $CFG_GLPI["root_doc"] . "/plugins/resources/pics/" . $data["ITEM_{$num}"] . ".png\"\n alt='{$status}' title='{$status}'> {$status}"; break; case "glpi_plugin_resources_tasks_items.items_id": $restrict = "`plugin_resources_tasks_id` = '" . $data['id'] . "'\n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_resources_tasks_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - " . $item->getLink() . "<br>"; } } return $out; break; case "glpi_plugin_resources_taskplannings.id": if (!empty($data["ITEM_{$num}"])) { $plan = new PluginResourcesTaskPlanning(); $plan->getFromDB($data["ITEM_{$num}"]); $out = Html::convDateTime($plan->fields["begin"]) . "<br> -> " . Html::convDateTime($plan->fields["end"]); } else { $out = __('None'); } return $out; break; } return ""; break; case 'User': switch ($table . '.' . $field) { case "glpi_plugin_resources_recipients.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; case "glpi_plugin_resources_recipients_leaving.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; case "glpi_plugin_resources_managers.name": $out = getUserName($data["ITEM_" . $num . "_2"]); return $out; break; } return ""; break; case 'PluginResourcesResourceResting': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["id"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResourceResting'); $out = "<a href=\"" . $link . "?id=" . $data["id"] . "\">"; $out .= $data["ITEM_{$num}"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["id"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; case 'PluginResourcesResourceHoliday': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": if (!empty($data["id"])) { $link = Toolbox::getItemTypeFormURL('PluginResourcesResourceHoliday'); $out = "<a href=\"" . $link . "?id=" . $data["id"] . "\">"; $out .= $data["ITEM_{$num}"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["id"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; case 'PluginResourcesDirectory': switch ($table . '.' . $field) { case "glpi_plugin_resources_managers.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $out = getUserName($data["ITEM_" . $num . "_2"]); } return $out; break; } return ""; break; case 'PluginResourcesEmployment': switch ($table . '.' . $field) { case "glpi_plugin_resources_resources.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $user = PluginResourcesResource::getResourceName($data["ITEM_" . $num . "_2"], 2); $out = "<a href='" . $user['link'] . "'>"; $out .= $user["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($user["name"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } return $out; break; } return ""; break; } return ""; }