/** * Print the HTML array for Items linked to a change * * @param $change Change object * * @return Nothing (display) **/ static function showForChange(Change $change) { global $DB, $CFG_GLPI; $instID = $change->fields['id']; if (!$change->can($instID, READ)) { return false; } $canedit = $change->canEdit($instID); $rand = mt_rand(); $query = "SELECT DISTINCT `itemtype`\n FROM `glpi_changes_items`\n WHERE `glpi_changes_items`.`changes_id` = '{$instID}'\n ORDER BY `itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeitem_form{$rand}' id='changeitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; $types = array(); foreach ($change->getAllTypesForHelpdesk() as $key => $val) { $types[] = $key; } Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $change->fields['is_recursive'] ? getSonsOf('glpi_entities', $change->fields['entities_id']) : $change->fields['entities_id'])); echo "</td><td class='center' width='30%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='changes_id' value='{$instID}'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $number) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Serial number') . "</th>"; $header_end .= "<th>" . __('Inventory number') . "</th></tr>"; echo $header_begin . $header_top . $header_end; $totalnb = 0; for ($i = 0; $i < $number; $i++) { $itemtype = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $itemtable = getTableForItemType($itemtype); $query = "SELECT `{$itemtable}`.*,\n `glpi_changes_items`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_changes_items`,\n `{$itemtable}`"; if ($itemtype != 'Entity') { $query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) "; } $query .= " WHERE `{$itemtable}`.`id` = `glpi_changes_items`.`items_id`\n AND `glpi_changes_items`.`itemtype` = '{$itemtype}'\n AND `glpi_changes_items`.`changes_id` = '{$instID}'"; if ($item->maybeTemplate()) { $query .= " AND `{$itemtable}`.`is_template` = '0'"; } $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`"; $result_linked = $DB->query($query); $nb = $DB->numrows($result_linked); for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) { $link = $itemtype::getFormURLWithID($data['id']); $linkname = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]); } $name = "<a href=\"" . $link . "\">" . $linkname . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo "</td>"; } if ($prem) { $itemname = $item->getTypeName($nb); echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $itemname, $nb) : $itemname) . "</td>"; } echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>"; echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'"); echo ">" . $name . "</td>"; echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; echo "</tr>"; } $totalnb += $nb; } } if ($number) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
include '../inc/includes.php'; } $link = new Change_User(); $item = new Change(); Session::checkLoginUser(); Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']); if (isset($_POST["update"])) { $link->check($_POST["id"], UPDATE); $link->update($_POST); echo "<script type='text/javascript' >\n"; echo "window.parent.location.reload();"; echo "</script>"; } else { if (isset($_POST['delete'])) { $link->check($_POST['id'], DELETE); $link->delete($_POST); Event::log($link->fields['changes_id'], "change", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); if ($item->can($link->fields["changes_id"], READ)) { Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $link->fields['changes_id']); } Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR); Html::redirect($CFG_GLPI["root_doc"] . "/front/change.php"); } else { if (isset($_GET["id"])) { $link->showUserNotificationForm($_GET["id"]); } else { Html::displayErrorAndDie('Lost'); } } } Html::popFooter();
/** * Show tickets for a change * * @param $change Change object **/ static function showForChange(Change $change) { global $DB, $CFG_GLPI; $ID = $change->getField('id'); if (!$change->can($ID, READ)) { return false; } $canedit = $change->canEdit($ID); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_tickets`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_tickets`\n ON (`glpi_changes_tickets`.`tickets_id` = `glpi_tickets`.`id`)\n WHERE `glpi_changes_tickets`.`changes_id` = '{$ID}'\n ORDER BY `glpi_tickets`.`name`"; $result = $DB->query($query); $tickets = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $tickets[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a ticket') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='right'>"; echo "<input type='hidden' name='changes_id' value='{$ID}'>"; Ticket::dropdown(array('used' => $used, 'entity' => $change->getEntityID(), 'entity_sons' => $change->isRecursive())); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'specific_actions' => array('purge' => _x('button', 'Delete permanently'), __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'solveticket' => __('Solve tickets')), 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('changes_id' => $change->getID()), 'width' => 1000, 'height' => 500); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr class='noHover'><th colspan='12'>" . Ticket::getTypeName($numrows) . "</th>"; echo "</tr>"; if ($numrows) { Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); Session::initNavigateListItems('Ticket', sprintf(__('%1$s = %2$s'), Change::getTypeName(1), $change->fields["name"])); $i = 0; foreach ($tickets as $data) { Session::addToNavigateListItems('Ticket', $data["id"]); Ticket::showShort($data['id'], array('followups' => false, 'row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID'])); $i++; } Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show problems for a change * * @param $change Change object **/ static function showForChange(Change $change) { global $DB, $CFG_GLPI; $ID = $change->getField('id'); if (!$change->can($ID, 'r')) { return false; } $canedit = $change->can($ID, 'w'); $rand = mt_rand(); $showentities = Session::isMultiEntitiesMode(); $query = "SELECT DISTINCT `glpi_changes_problems`.`id` AS linkID,\n `glpi_problems`.*\n FROM `glpi_changes_problems`\n LEFT JOIN `glpi_problems`\n ON (`glpi_changes_problems`.`problems_id` = `glpi_problems`.`id`)\n WHERE `glpi_changes_problems`.`changes_id` = '{$ID}'\n ORDER BY `glpi_problems`.`name`"; $result = $DB->query($query); $problems = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $problems[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a problem') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>"; echo "<input type='hidden' name='changes_id' value='{$ID}'>"; Problem::dropdown(array('used' => $used, 'entity' => $change->getEntityID())); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr></table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $numrows) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . _n('Problem', 'Problems', 2) . "</th>"; if ($showentities) { echo "<th>" . __('Entity') . "</th>"; } echo "</tr>"; $used = array(); if ($numrows) { Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Change::getTypeName(1), $change->fields["name"])); foreach ($problems as $data) { Session::addToNavigateListItems('Problem', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]); echo "</td>"; } echo "<td><a href='" . Toolbox::getItemTypeFormURL('Problem') . "?id=" . $data['id'] . "'>" . $data["name"] . "</a></td>"; if ($showentities) { echo "<td>" . Dropdown::getDropdownName('glpi_entities', $data["entities_id"]) . "</td>"; } echo "</tr>"; } } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions(__CLASS__, $massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Show projects for a change * * @param $change Change object **/ static function showForChange(Change $change) { global $DB, $CFG_GLPI; $ID = $change->getField('id'); if (!$change->can($ID, READ)) { return false; } $canedit = $change->canEdit($ID); $rand = mt_rand(); $showentities = Session::isMultiEntitiesMode(); $query = "SELECT DISTINCT `glpi_changes_projects`.`id` AS linkID,\n `glpi_projects`.*\n FROM `glpi_changes_projects`\n LEFT JOIN `glpi_projects`\n ON (`glpi_changes_projects`.`projects_id` = `glpi_projects`.`id`)\n WHERE `glpi_changes_projects`.`changes_id` = '{$ID}'\n ORDER BY `glpi_projects`.`name`"; $result = $DB->query($query); $projects = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $projects[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='changeproject_form{$rand}' id='changeproject_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a project') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>"; echo "<input type='hidden' name='changes_id' value='{$ID}'>"; Project::dropdown(array('used' => $used, 'entity' => $change->getEntityID())); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr></table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; echo "<tr class='noHover'><th colspan='12'>" . Project::getTypeName($numrows) . "</th></tr>"; if ($numrows) { Project::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); Session::initNavigateListItems('Project', sprintf(__('%1$s = %2$s'), Change::getTypeName(1), $change->fields["name"])); $i = 0; foreach ($projects as $data) { Session::addToNavigateListItems('Project', $data["id"]); Project::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID'])); $i++; } Project::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
$change->delete($_POST, 1); Event::log($_POST["id"], "change", 4, "maintain", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $change->redirectToList(); } else { if (isset($_POST["update"])) { $change->check($_POST["id"], 'w'); $change->update($_POST); Event::log($_POST["id"], "change", 4, "maintain", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST['delete_user'])) { $change_user = new Change_User(); $change_user->check($_POST['id'], 'd'); $change_user->delete($_POST); Event::log($_POST['changes_id'], "change", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); if ($change->can($_POST["id"], 'r')) { Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST["changes_id"]); } Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR); Html::redirect($CFG_GLPI["root_doc"] . "/front/change.php"); } else { if (isset($_POST['delete_group'])) { $change_group = new Change_Group(); $change_group->check($_POST['id'], 'd'); $change_group->delete($_POST); Event::log($_POST['changes_id'], "change", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); if ($change->can($_POST["id"], 'r')) { Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST["changes_id"]); } Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR); Html::redirect($CFG_GLPI["root_doc"] . "/front/change.php");