Relation between Changes and Tickets
Inheritance: extends CommonDBRelation
Beispiel #1
0
 function post_addItem()
 {
     global $CFG_GLPI;
     parent::post_addItem();
     if (isset($this->input['_tickets_id'])) {
         $ticket = new Ticket();
         if ($ticket->getFromDB($this->input['_tickets_id'])) {
             $pt = new Change_Ticket();
             $pt->add(array('tickets_id' => $this->input['_tickets_id'], 'changes_id' => $this->fields['id']));
             if (!empty($ticket->fields['itemtype']) && $ticket->fields['items_id'] > 0) {
                 $it = new Change_Item();
                 $it->add(array('changes_id' => $this->fields['id'], 'itemtype' => $ticket->fields['itemtype'], 'items_id' => $ticket->fields['items_id']));
             }
         }
     }
     if (isset($this->input['_problems_id'])) {
         $problem = new Problem();
         if ($problem->getFromDB($this->input['_problems_id'])) {
             $cp = new Change_Problem();
             $cp->add(array('problems_id' => $this->input['_problems_id'], 'changes_id' => $this->fields['id']));
         }
     }
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the change
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && in_array($this->input["status"], $this->getSolvedStatusArray())) {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
 }
Beispiel #2
0
 function cleanDBonPurge()
 {
     global $DB;
     $query1 = "DELETE\n                 FROM `glpi_tickettasks`\n                 WHERE `tickets_id` = '" . $this->fields['id'] . "'";
     $DB->query($query1);
     $query1 = "DELETE\n                 FROM `glpi_ticketfollowups`\n                 WHERE `tickets_id` = '" . $this->fields['id'] . "'";
     $DB->query($query1);
     $ts = new TicketValidation();
     $ts->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     $query1 = "DELETE\n                 FROM `glpi_ticketsatisfactions`\n                 WHERE `tickets_id` = '" . $this->fields['id'] . "'";
     $DB->query($query1);
     $pt = new Problem_Ticket();
     $pt->cleanDBonItemDelete('Ticket', $this->fields['id']);
     $ts = new TicketCost();
     $ts->cleanDBonItemDelete($this->getType(), $this->fields['id']);
     $slaLevel_ticket = new SlaLevel_Ticket();
     $slaLevel_ticket->deleteForTicket($this->getID(), SLT::TTO);
     $slaLevel_ticket->deleteForTicket($this->getID(), SLT::TTR);
     $query1 = "DELETE\n                 FROM `glpi_tickets_tickets`\n                 WHERE `tickets_id_1` = '" . $this->fields['id'] . "'\n                       OR `tickets_id_2` = '" . $this->fields['id'] . "'";
     $DB->query($query1);
     $ct = new Change_Ticket();
     $ct->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     $ip = new Item_Ticket();
     $ip->cleanDBonItemDelete('Ticket', $this->fields['id']);
     parent::cleanDBonPurge();
 }
Beispiel #3
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     switch ($item->getType()) {
         case 'Change':
             Change_Ticket::showForChange($item);
             break;
         case 'Problem':
             Problem_Ticket::showForProblem($item);
             break;
         case __CLASS__:
             switch ($tabnum) {
                 case 2:
                     if (!isset($_POST['load_kb_sol'])) {
                         $_POST['load_kb_sol'] = 0;
                     }
                     $item->showSolutionForm($_POST['load_kb_sol']);
                     if ($item->canApprove()) {
                         $fup = new TicketFollowup();
                         $fup->showApprobationForm($item);
                     }
                     break;
                 case 3:
                     $satisfaction = new TicketSatisfaction();
                     if ($item->fields['status'] == self::CLOSED && $satisfaction->getFromDB($_POST["id"])) {
                         $satisfaction->showSatisfactionForm($item);
                     } else {
                         echo "<p class='center b'>" . __('No generated survey') . "</p>";
                     }
                     break;
                 case 4:
                     $item->showStats();
                     break;
             }
             break;
         case 'Group':
         case 'SLA':
         default:
             self::showListForItem($item);
     }
     return true;
 }
Beispiel #4
0
 function post_addItem()
 {
     global $CFG_GLPI;
     parent::post_addItem();
     if (isset($this->input['_tickets_id'])) {
         $ticket = new Ticket();
         if ($ticket->getFromDB($this->input['_tickets_id'])) {
             $pt = new Change_Ticket();
             $pt->add(array('tickets_id' => $this->input['_tickets_id'], 'changes_id' => $this->fields['id']));
             if (!empty($ticket->fields['itemtype']) && $ticket->fields['items_id'] > 0) {
                 $it = new Change_Item();
                 $it->add(array('changes_id' => $this->fields['id'], 'itemtype' => $ticket->fields['itemtype'], 'items_id' => $ticket->fields['items_id']));
             }
         }
     }
     if (isset($this->input['_problems_id'])) {
         $problem = new Problem();
         if ($problem->getFromDB($this->input['_problems_id'])) {
             $cp = new Change_Problem();
             $cp->add(array('problems_id' => $this->input['_problems_id'], 'changes_id' => $this->fields['id']));
             /// TODO add linked tickets and linked hardware (to problem and tickets)
             /// create standard function
         }
     }
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the change
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
 }
Beispiel #5
0
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::checkLoginUser();
$item = new Change_Ticket();
if (isset($_POST["add"])) {
    $item->check(-1, CREATE, $_POST);
    if ($newID = $item->add($_POST)) {
        Event::log($_POST["changes_id"], "change", 4, "maintain", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"]));
    }
    Html::back();
}
Html::displayErrorAndDie("lost");
Beispiel #6
0
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::checkLoginUser();
$item = new Change_Ticket();
if (isset($_POST["add"])) {
    $item->check(-1, 'w', $_POST);
    if ($item->add($_POST)) {
        Event::log($_POST["changes_id"], "change", 4, "maintain", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"]));
    }
    Html::back();
}
Html::displayErrorAndDie("lost");