Beispiel #1
0
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.

-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI 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.

GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::haveRightsOr('change', array(Change::READALL, Change::READMY));
Html::header(Change::getTypeName(Session::getPluralNumber()), '', "helpdesk", "change");
Search::show('Change');
Html::footer();
Beispiel #2
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         $nb = 0;
         switch ($item->getType()) {
             case 'Change':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countElementsInTable('glpi_changes_items', "`changes_id` = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(_n('Item', 'Items', Session::getPluralNumber()), $nb);
             case 'User':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countDistinctElementsInTable('glpi_changes_users', 'changes_id', "`users_id` = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(Change::getTypeName(Session::getPluralNumber()), $nb);
             case 'Group':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countDistinctElementsInTable('glpi_changes_groups', 'changes_id', "`groups_id` = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(Change::getTypeName(Session::getPluralNumber()), $nb);
             case 'Supplier':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countDistinctElementsInTable('glpi_changes_suppliers', 'changes_id', "`suppliers_id` = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(Change::getTypeName(Session::getPluralNumber()), $nb);
             default:
                 if (Session::haveRight("change", Change::READALL)) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         // Direct one
                         $nb = countElementsInTable('glpi_changes_items', " `itemtype` = '" . $item->getType() . "'\n                                                   AND `items_id` = '" . $item->getID() . "'");
                         // Linked items
                         $linkeditems = $item->getLinkedItems();
                         if (count($linkeditems)) {
                             foreach ($linkeditems as $type => $tab) {
                                 foreach ($tab as $ID) {
                                     $nb += countElementsInTable('glpi_changes_items', " `itemtype` = '{$type}'\n                                                            AND `items_id` = '{$ID}'");
                                 }
                             }
                         }
                     }
                     return self::createTabEntry(Change::getTypeName(Session::getPluralNumber()), $nb);
                 }
         }
     }
     return '';
 }
 /**
  * Show changes for a ticket
  *
  * @param $ticket Ticket object
  **/
 static function showForTicket(Ticket $ticket)
 {
     global $DB, $CFG_GLPI;
     $ID = $ticket->getField('id');
     if (!$ticket->can($ID, READ)) {
         return false;
     }
     $canedit = $ticket->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n                                `glpi_changes`.*\n                FROM `glpi_changes_tickets`\n                LEFT JOIN `glpi_changes`\n                     ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n                WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n                ORDER BY `glpi_changes`.`name`";
     $result = $DB->query($query);
     $changes = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $changes[$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='3'>" . __('Add a change') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
         Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID()));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td><td>";
         if (Session::haveRight('change', CREATE)) {
             echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>";
             _e('Create a change from this ticket');
             echo "</a>";
         }
         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'>";
     echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>";
     echo "</tr>";
     if ($numrows) {
         Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
         Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
         $i = 0;
         foreach ($changes as $data) {
             Session::addToNavigateListItems('Change', $data["id"]);
             Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
             $i++;
         }
         Change::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>";
 }
Beispiel #5
0
                        $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"]));
                        Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST['changes_id']);
                    } 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"]));
                            Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST['changes_id']);
                        } else {
                            if (isset($_POST['delete_supplier'])) {
                                $change_supplier = new Change_Supplier();
                                $change_supplier->check($_POST['id'], 'd');
                                $change_supplier->delete($_POST);
                                Event::log($_POST['changes_id'], "change", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"]));
                                Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST['changes_id']);
                            } else {
                                Html::header(Change::getTypeName(2), $_SERVER['PHP_SELF'], "maintain", "change");
                                $change->showForm($_GET["id"], $_GET);
                                Html::footer();
                            }
                        }
                    }
                }
            }
        }
    }
}
            $change->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $change->check($_POST["id"], PURGE);
                $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"], UPDATE);
                    $change->update($_POST);
                    Event::log($_POST["id"], "change", 4, "maintain", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    Html::back();
                } else {
                    if (isset($_POST['addme_assign'])) {
                        $change_user = new Change_User();
                        $change->check($_POST['changes_id'], READ);
                        $input = array('changes_id' => $_POST['changes_id'], 'users_id' => Session::getLoginUserID(), 'use_notification' => 1, 'type' => CommonITILActor::ASSIGN);
                        $change_user->add($input);
                        Event::log($_POST['changes_id'], "change", 4, "maintain", sprintf(__('%s adds an actor'), $_SESSION["glpiname"]));
                        Html::redirect($CFG_GLPI["root_doc"] . "/front/change.form.php?id=" . $_POST['changes_id']);
                    } else {
                        Html::header(Change::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "helpdesk", "change");
                        $change->display($_GET);
                        Html::footer();
                    }
                }
            }
        }
    }
}
Beispiel #7
0
Copyright (C) 2003-2014 by the INDEPNET Development Team.

http://indepnet.net/   http://glpi-project.org
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI 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.

GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkSeveralRightsOr(array('show_all_change' => '1', 'show_my_change' => '1'));
Html::header(Change::getTypeName(2), '', "maintain", "change");
Search::show('Change');
Html::footer();