Пример #1
0
 function post_addItem()
 {
     global $CFG_GLPI;
     if (isset($this->input['content'])) {
         if (isset($this->input['_stock_image'])) {
             $this->addImagePaste();
         }
     }
     // Log this event
     $username = '******';
     if (isset($_SESSION["glpiname"])) {
         $username = $_SESSION["glpiname"];
     }
     Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s adds the item %2$s'), $username, $this->fields['id']));
     if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
         $fup = new TicketFollowup();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
             $toadd["content"] = $this->input["_followup"]['content'];
         }
         if (isset($this->input["_followup"]['is_private'])) {
             $toadd["is_private"] = $this->input["_followup"]['is_private'];
         }
         // $toadd['_no_notif'] = true;
         $fup->add($toadd);
     }
     if (isset($this->input["plan"]) && count($this->input["plan"]) || isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
         $task = new TicketTask();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id'], "actiontime" => $this->input["actiontime"]);
         if (isset($this->input["plan"]) && count($this->input["plan"])) {
             $toadd["plan"] = $this->input["plan"];
         }
         if (isset($_SESSION['glpitask_private'])) {
             $toadd['is_private'] = $_SESSION['glpitask_private'];
         }
         // $toadd['_no_notif'] = true;
         $task->add($toadd);
     }
     $ticket_ticket = new Ticket_Ticket();
     // From interface
     if (isset($this->input['_link'])) {
         $this->input['_link']['tickets_id_1'] = $this->fields['id'];
         // message if ticket's ID doesn't exist
         if (!empty($this->input['_link']['tickets_id_2'])) {
             if ($ticket_ticket->can(-1, CREATE, $this->input['_link'])) {
                 $ticket_ticket->add($this->input['_link']);
             } else {
                 Session::addMessageAfterRedirect(__('Unknown ticket'), false, ERROR);
             }
         }
     }
     // From mailcollector : do not check rights
     if (isset($this->input["_linkedto"])) {
         $input2['tickets_id_1'] = $this->fields['id'];
         $input2['tickets_id_2'] = $this->input["_linkedto"];
         $input2['link'] = Ticket_Ticket::LINK_TO;
         $ticket_ticket->add($input2);
     }
     // Manage SLT Level : add actions
     foreach (array(SLT::TTR, SLT::TTO) as $sltType) {
         list($dateField, $sltField) = SLT::getSltFieldNames($sltType);
         if (isset($this->input[$sltField]) && $this->input[$sltField] > 0) {
             $this->manageSltLevel($this->input[$sltField]);
         }
     }
     // Add project task link if needed
     if (isset($this->input['_projecttasks_id'])) {
         $projecttask = new ProjectTask();
         if ($projecttask->getFromDB($this->input['_projecttasks_id'])) {
             $pt = new ProjectTask_Ticket();
             $pt->add(array('projecttasks_id' => $this->input['_projecttasks_id'], 'tickets_id' => $this->fields['id']));
         }
     }
     if (!empty($this->input['items_id'])) {
         $item_ticket = new Item_Ticket();
         foreach ($this->input['items_id'] as $itemtype => $items) {
             foreach ($items as $items_id) {
                 $item_ticket->add(array('items_id' => $items_id, 'itemtype' => $itemtype, 'tickets_id' => $this->fields['id'], '_disablenotif' => true));
             }
         }
     }
     parent::post_addItem();
     $this->manageValidationAdd($this->input);
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the ticket
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
     if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) {
         Session::addMessageAfterRedirect(sprintf(__('%1$s (%2$s)'), __('Your ticket has been registered, its treatment is in progress.'), sprintf(__('%1$s: %2$s'), __('Ticket'), "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>")));
     }
 }
Пример #2
0
 function post_addItem()
 {
     global $LANG, $CFG_GLPI;
     // Add document if needed
     $this->addFiles($this->fields['id']);
     if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
         $fup = new TicketFollowup();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
             $toadd["content"] = $this->input["_followup"]['content'];
         }
         if (isset($this->input["_followup"]['is_private'])) {
             $toadd["is_private"] = $this->input["_followup"]['is_private'];
         }
         $toadd['_no_notif'] = true;
         $fup->add($toadd);
     }
     if (isset($this->input["plan"]) || isset($this->input["_hour"]) && isset($this->input["_minute"]) && isset($this->input["realtime"]) && $this->input["realtime"] > 0) {
         $task = new TicketTask();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_hour"])) {
             $toadd["hour"] = $this->input["_hour"];
         }
         if (isset($this->input["_minute"])) {
             $toadd["minute"] = $this->input["_minute"];
         }
         if (isset($this->input["plan"])) {
             $toadd["plan"] = $this->input["plan"];
         }
         $toadd['_no_notif'] = true;
         $task->add($toadd);
     }
     $ticket_ticket = new Ticket_Ticket();
     // From interface
     if (isset($this->input['_link'])) {
         $this->input['_link']['tickets_id_1'] = $this->fields['id'];
         if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
             $ticket_ticket->add($this->input['_link']);
         }
     }
     // From mailcollector : do not check rights
     if (isset($this->input["_linkedto"])) {
         $input2['tickets_id_1'] = $this->fields['id'];
         $input2['tickets_id_2'] = $this->input["_linkedto"];
         $input2['link'] = Ticket_Ticket::LINK_TO;
         $ticket_ticket->add($input2);
     }
     // Manage SLA Level : add actions
     if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) {
         $sla = new SLA();
         if ($sla->getFromDB($this->input["slas_id"])) {
             // Add first level in working table
             if ($this->input["slalevels_id"] > 0) {
                 $sla->addLevelToDo($this);
             }
         }
     }
     // Add user groups linked to tickets
     $ticket_user = new Ticket_User();
     $group_ticket = new Group_Ticket();
     if (isset($this->input["_users_id_requester"]) && ($this->input["_users_id_requester"] > 0 || isset($this->input["_users_id_requester_notif"]['alternative_email']) && !empty($this->input["_users_id_requester_notif"]['alternative_email']))) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_requester"], 'type' => self::REQUESTER);
         if (isset($this->input["_users_id_requester_notif"])) {
             foreach ($this->input["_users_id_requester_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_users_id_observer"]) && ($this->input["_users_id_observer"] > 0 || isset($this->input["_users_id_observer_notif"]['alternative_email']) && !empty($this->input["_users_id_observer_notif"]['alternative_email']))) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_observer"], 'type' => self::OBSERVER);
         if (isset($this->input["_users_id_observer_notif"])) {
             foreach ($this->input["_users_id_observer_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_users_id_assign"]) && $this->input["_users_id_assign"] > 0) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_assign"], 'type' => self::ASSIGN);
         if (isset($this->input["_users_id_assign_notif"])) {
             foreach ($this->input["_users_id_assign_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_groups_id_requester"]) && $this->input["_groups_id_requester"] > 0) {
         $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_requester"], 'type' => self::REQUESTER));
     }
     if (isset($this->input["_groups_id_assign"]) && $this->input["_groups_id_assign"] > 0) {
         $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_assign"], 'type' => self::ASSIGN));
     }
     if (isset($this->input["_groups_id_observer"]) && $this->input["_groups_id_observer"] > 0) {
         $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_observer"], 'type' => self::OBSERVER));
     }
     // Additional actors : using default notification parameters
     // Observers : for mailcollector
     if (isset($this->input["_additional_observers"]) && is_array($this->input["_additional_observers"]) && count($this->input["_additional_observers"])) {
         $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::OBSERVER);
         foreach ($this->input["_additional_observers"] as $tmp) {
             if (isset($tmp['users_id'])) {
                 foreach ($tmp as $key => $val) {
                     $input2[$key] = $val;
                 }
                 $ticket_user->add($input2);
             }
         }
     }
     if (isset($this->input["_additional_assigns"]) && is_array($this->input["_additional_assigns"]) && count($this->input["_additional_assigns"])) {
         $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::ASSIGN);
         foreach ($this->input["_additional_assigns"] as $tmp) {
             if (isset($tmp['users_id'])) {
                 foreach ($tmp as $key => $val) {
                     $input2[$key] = $val;
                 }
                 $ticket_user->add($input2);
             }
         }
     }
     if (isset($this->input["_additional_requesters"]) && is_array($this->input["_additional_requesters"]) && count($this->input["_additional_requesters"])) {
         $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::REQUESTER);
         foreach ($this->input["_additional_requesters"] as $tmp) {
             if (isset($tmp['users_id'])) {
                 foreach ($tmp as $key => $val) {
                     $input2[$key] = $val;
                 }
                 $ticket_user->add($input2);
             }
         }
     }
     //Action for send_validation rule
     if (isset($this->input["_add_validation"]) && $this->input["_add_validation"] > 0) {
         $validation = new Ticketvalidation();
         $values['tickets_id'] = $this->fields['id'];
         $values['users_id_validate'] = $this->input["_add_validation"];
         if ($validation->can(-1, 'w', $values)) {
             $validation->add($values);
             Event::log($this->fields['id'], "ticket", 4, "tracking", $_SESSION["glpiname"] . "  " . $LANG['log'][21]);
         }
     }
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the ticket
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
     if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) {
         addMessageAfterRedirect($LANG['help'][18] . " (" . $LANG['job'][38] . "&nbsp;" . "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>)");
     }
 }
Пример #3
0
 function post_addItem()
 {
     global $CFG_GLPI;
     // Log this event
     $username = '******';
     if (isset($_SESSION["glpiname"])) {
         $username = $_SESSION["glpiname"];
     }
     Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s adds the item %2$s'), $username, $this->fields['id']));
     if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
         $fup = new TicketFollowup();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
             $toadd["content"] = $this->input["_followup"]['content'];
         }
         if (isset($this->input["_followup"]['is_private'])) {
             $toadd["is_private"] = $this->input["_followup"]['is_private'];
         }
         $toadd['_no_notif'] = true;
         $fup->add($toadd);
     }
     if (isset($this->input["plan"]) && count($this->input["plan"]) || isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
         $task = new TicketTask();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id'], "actiontime" => $this->input["actiontime"]);
         if (isset($this->input["plan"]) && count($this->input["plan"])) {
             $toadd["plan"] = $this->input["plan"];
         }
         if (isset($_SESSION['glpitask_private'])) {
             $toadd['is_private'] = $_SESSION['glpitask_private'];
         }
         $toadd['_no_notif'] = true;
         $task->add($toadd);
     }
     $ticket_ticket = new Ticket_Ticket();
     // From interface
     if (isset($this->input['_link'])) {
         $this->input['_link']['tickets_id_1'] = $this->fields['id'];
         // message if ticket's ID doesn't exist
         if (!empty($this->input['_link']['tickets_id_2'])) {
             if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
                 $ticket_ticket->add($this->input['_link']);
             } else {
                 Session::addMessageAfterRedirect(__('Unknown ticket'), false, ERROR);
             }
         }
     }
     // From mailcollector : do not check rights
     if (isset($this->input["_linkedto"])) {
         $input2['tickets_id_1'] = $this->fields['id'];
         $input2['tickets_id_2'] = $this->input["_linkedto"];
         $input2['link'] = Ticket_Ticket::LINK_TO;
         $ticket_ticket->add($input2);
     }
     // Manage SLA Level : add actions
     if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) {
         $calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']);
         $sla = new SLA();
         if ($sla->getFromDB($this->input["slas_id"])) {
             $sla->setTicketCalendar($calendars_id);
             // Add first level in working table
             if ($this->input["slalevels_id"] > 0) {
                 $sla->addLevelToDo($this);
             }
             // Replay action in case of open date is set before now
         }
         SlaLevel_Ticket::replayForTicket($this->getID());
     }
     parent::post_addItem();
     //Action for send_validation rule
     if (isset($this->input["_add_validation"])) {
         $validations_to_send = array();
         if (!is_array($this->input["_add_validation"])) {
             $this->input["_add_validation"] = array($this->input["_add_validation"]);
         }
         foreach ($this->input["_add_validation"] as $validation) {
             switch ($validation) {
                 case 'requester_supervisor':
                     if (isset($this->input['_groups_id_requester']) && $this->input['_groups_id_requester']) {
                         $users = Group_User::getGroupUsers($this->input['_groups_id_requester'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
                 case 'assign_supervisor':
                     if (isset($this->input['_groups_id_assign']) && $this->input['_groups_id_assign']) {
                         $users = Group_User::getGroupUsers($this->input['_groups_id_assign'], "is_manager='1'");
                         foreach ($users as $data) {
                             $validations_to_send[] = $data['id'];
                         }
                     }
                     break;
                 default:
                     $validations_to_send[] = $validation;
             }
         }
         // Keep only one
         $validations_to_send = array_unique($validations_to_send);
         $validation = new TicketValidation();
         foreach ($validations_to_send as $users_id) {
             if ($users_id > 0) {
                 $values = array();
                 $values['tickets_id'] = $this->fields['id'];
                 $values['users_id_validate'] = $users_id;
                 $values['_ticket_add'] = true;
                 // to know update by rules
                 if (isset($this->input["_rule_process"])) {
                     $values['_rule_process'] = $this->input["_rule_process"];
                 }
                 // if auto_import, tranfert it for validation
                 if (isset($this->input['_auto_import'])) {
                     $values['_auto_import'] = $this->input['_auto_import'];
                 }
                 // Cron or rule process of hability to do
                 if (Session::isCron() || isset($this->input["_auto_import"]) || isset($this->input["_rule_process"]) || $validation->can(-1, 'w', $values)) {
                     // cron or allowed user
                     $validation->add($values);
                     Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s updates the item %2$s'), $_SESSION["glpiname"], $this->fields['id']));
                 }
             }
         }
     }
     // Processing Email
     if ($CFG_GLPI["use_mailing"]) {
         // Clean reload of the ticket
         $this->getFromDB($this->fields['id']);
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) {
             $type = "solved";
         }
         NotificationEvent::raiseEvent($type, $this);
     }
     if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) {
         Session::addMessageAfterRedirect(sprintf(__('%1$s (%2$s)'), __('Your ticket has been registered, its treatment is in progress.'), sprintf(__('%1$s: %2$s'), __('Ticket'), "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>")));
     }
 }
Пример #4
0
/** Generate bigdump : add tickets to an item
 *
 * @param $type      item type
 * @param $ID        item ID
 * @param $ID_entity entity ID
**/
function addTracking($type, $ID, $ID_entity) {
   global $percent, $DB, $MAX, $FIRST, $LAST;

   $current_year = date("Y");

   while (mt_rand(0,100)<$percent['tracking_on_item']) {
      // ticket closed ?
      $status    = CommonITILObject::CLOSED;
      $closedate = "";
      $solvedate = "";

      $opendate  = time() - mt_rand(0, 365)*DAY_TIMESTAMP - mt_rand(0, 10)*HOUR_TIMESTAMP
                   - mt_rand(0, 60)*MINUTE_TIMESTAMP - mt_rand(0, 60);

      if (mt_rand(0,100)<$percent['closed_tracking']) {
         $rtype = mt_rand(0, 100);

         if ($rtype<20) {
            $status = CommonITILObject::SOLVED;
         } else {
            $status = CommonITILObject::CLOSED;
         }

      } else {
         $rtype = mt_rand(0, 100);

         if ($rtype<20) {
            $status = CommonITILObject::INCOMING;

         } else if ($rtype<40) {
            $status = CommonITILObject::WAITING;

         } else if ($rtype<80) {
            $status = CommonITILObject::PLANNED;
            $date3  = $opendate+mt_rand(10800, 7776000); // + entre 3 heures et 3 mois
            $date4  = $date3+10800; // + 3 heures

         } else {
            $status = CommonITILObject::ASSIGNED;
         }
      }

      // Author
      $users[0] = mt_rand($FIRST['users_normal'], $LAST['users_postonly']);

      // Assign user
      $users[1] = 0;

      if ($status != CommonITILObject::INCOMING) {
         $users[1] = mt_rand($FIRST['users_sadmin'], $LAST['users_admin']);
      }
      $enterprise = 0;

      if (mt_rand(0,100)<20) {
         $enterprise = mt_rand($FIRST["enterprises"], $LAST['enterprises']);
      }

      $firstactiontime = mt_rand(0, 10)*DAY_TIMESTAMP+mt_rand(0, 10)*HOUR_TIMESTAMP
                         +mt_rand(0, 60)*MINUTE_TIMESTAMP;
      $solvetime       = 0;
      $closetime       = 0;
      $actiontime      = 0;

      $solution        = "";
      $solutiontype    = 0;
      $due_date        = $opendate + $firstactiontime+mt_rand(0, 10)*DAY_TIMESTAMP+
                         mt_rand(0, 10)*HOUR_TIMESTAMP+mt_rand(0, 60)*MINUTE_TIMESTAMP;
      $duedatetoadd    = date("Y-m-d H:i:s", intval($due_date));


      if (($status == CommonITILObject::CLOSED) || ($status == CommonITILObject::SOLVED)) {
         $solvetime = $firstactiontime+mt_rand(0, 10)*DAY_TIMESTAMP+mt_rand(0, 10)*HOUR_TIMESTAMP+
                      mt_rand(0, 60)*MINUTE_TIMESTAMP;
         $solvedate = $opendate+$solvetime;
         $closedate = $opendate+$solvetime;
         $actiontime = mt_rand(0, 10)*HOUR_TIMESTAMP+
                      mt_rand(0, 60)*MINUTE_TIMESTAMP;
         if ($status == CommonITILObject::CLOSED) {
            $closetime = $solvetime+mt_rand(0, 5)*DAY_TIMESTAMP+mt_rand(0, 10)*HOUR_TIMESTAMP+
                         mt_rand(0, 60)*MINUTE_TIMESTAMP;
            $closedate = $opendate+$closetime;
         }
         $solutiontype = mt_rand($FIRST['solutiontypes'], $LAST['solutiontypes']);
         $solution     = "Solution '".Toolbox::getRandomString(20);
      }
      $updatedate = $opendate+max($firstactiontime, $solvetime, $closetime);
      $hour_cost  = 100;

      $closedatetoadd = 'NULL';
      if (!empty($closedate)) {
         $closedatetoadd = date("Y-m-d H:i:s", intval($closedate));
      }

      $solvedatetoadd = 'NULL';
      if (!empty($solvedate)) {
         $solvedatetoadd = date("Y-m-d H:i:s",intval($solvedate));
      }
      $t   = new Ticket();
      $tID = $t->add(toolbox::addslashes_deep(
                     array('entities_id'                 => $ID_entity,
                           'name'                        => "Title '".Toolbox::getRandomString(20),
                           'date'                        => date("Y-m-d H:i:s", intval($opendate)),
                           'closedate'                   => $closedatetoadd,
                           'solvedate'                   => $solvedatetoadd,
                           'date_mod'                    => date("Y-m-d H:i:s", intval($updatedate)),
                           'users_id_lastupdater'        => $users[0],
                           'status'                      => $status,
                           'users_id_recipient'          => $users[0],
                           'requesttypes_id'             => mt_rand(0,6),
                           '_suppliers_id_assign'        => $enterprise,
                           'itemtype'                    => $type,
                           'items_id'                    => $ID,
                           'content'                     => "tracking '".Toolbox::getRandomString(15),
                           'urgency'                     => mt_rand(1,5),
                           'impact'                      => mt_rand(1,5),
                           'priority'                    => mt_rand(1,5),
                           'itilcategories_id'           => mt_rand(0, $MAX['tracking_category']),
                           'type'                        => mt_rand(1,2),
                           'solutiontypes_id'            => $solutiontype,
                           'locations_id'                => mt_rand($FIRST['locations'],
                                                                    $LAST['locations']),
                           'solution'                    => $solution,
                           'actiontime'                  => $actiontime,
                           'due_date'                    => $duedatetoadd,
                           'close_delay_stat'            => $closetime,
                           'solve_delay_stat'            => $solvetime,
                           'takeintoaccount_delay_stat'  => $firstactiontime,
                           '_users_id_requester'         => $users[0],
                           '_users_id_assign'            => $users[1],
                           '_groups_id_assign'           => mt_rand($FIRST["techgroups"],
                                                                    $LAST['techgroups']),
                           '_groups_id_requester'        => mt_rand($FIRST["groups"], $LAST['groups']),
                     )));

      // Add followups
      $i     = 0;
      $fID   = 0;
      $first = true;
      $date  = 0;
      $tf    = new TicketFollowup();
      while (mt_rand(0,100)<$percent['followups']) {
         if ($first) {
            $date = $opendate+$firstactiontime;
            $first = false;

         } else {
            $date += mt_rand(3600, 7776000);
         }
         $tf->add(toolbox::addslashes_deep(
                  array('tickets_id'      => $tID,
                        'date'            => date("Y-m-d H:i:s", $date),
                        'users_id'        => $users[1],
                        'content'         => "followup $i '".Toolbox::getRandomString(15),
                        'requesttypes_id' => mt_rand(0, 3))));
         $i++;
      }
      $tt = new TicketTask();
      while (mt_rand(0,100)<$percent['tasks']) {
         $doplan=false;
         if ($first) {
            $date   = $opendate+$firstactiontime;
            $first  = false;
            $doplan = true;
         } else {
            $date += mt_rand(3600, 7776000);
         }

         $begin       = $end = 'NULL';
         $assign_user = 0;
         $state       = 1;
         if ($status == CommonITILObject::PLANNED && $doplan) {
            $endtask = date("Y-m-d H:i:s", $date4);
            if ($endtask < date("Y-m-d H:i:s")) {
               $state = 2; // done
            }
         }
         $params = toolbox::addslashes_deep(
                   array('tickets_id'        => $tID,
                         'taskcategories_id' => mt_rand($FIRST['taskcategory'], $LAST['taskcategory']),
                         'date'              => date("Y-m-d H:i:s",$date),
                         'users_id'          => $users[1],
                         'content'           => "task $i '".Toolbox::getRandomString(15),
                         'is_private'        => mt_rand(0,1),
                         'state'             => $state,
                         'users_id_tech'    => $users[1]));

         if ($status == CommonITILObject::PLANNED && $doplan) {
            $params['plan'] = array('begin'       => date("Y-m-d H:i:s", $date3),
                                    'end'         => $endtask);
         }
         $tt->add($params);
         $i++;
      }

      $tc = new TicketCost();
      $params = toolbox::addslashes_deep(
                array('tickets_id'        => $tID,
                     'entities_id'       => $ID_entity,
                     'begin_date'        => date("Y-m-d H:i:s", intval($opendate)),
                     'name'              => "C'ost",
                     'cost_time'         => $hour_cost,
                     'actiontime'        => floor($actiontime/2)));

      // Insert satisfaction for stats
      if ($status == CommonITILObject::CLOSED
          && mt_rand(0,100) < $percent['satisfaction']) {

         $answerdate = 'NULL';
         if (mt_rand(0,100) < $percent['answersatisfaction']) {
            $answerdate = $closedatetoadd;
         }
         $ts = new TicketSatisfaction();
         $ts->add(toolbox::addslashes_deep(
                  array('tickets_id'   => $tID,
                        'type'         => mt_rand(1,2),
                        'date_begin'   => $closedatetoadd,
                        'date_answer'  => $answerdate,
                        'satisfaction' => mt_rand(0,5),
                        'comment'      => "comment ' satisfaction $tID")));
      }

   }

}
Пример #5
0
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('tickets_id' => $key, 'users_id_validate' => $_POST['users_id_validate'], 'comment_submission' => $_POST['comment_submission']);
             if ($valid->can(-1, 'w', $input)) {
                 $valid->add($input);
             }
         }
     }
     break;
 case "add_task":
     $task = new TicketTask();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('tickets_id' => $key, 'taskcategories_id' => $_POST['taskcategories_id'], 'content' => $_POST['content']);
             if ($task->can(-1, 'w', $input)) {
                 $task->add($input);
             }
         }
     }
     break;
 case "add_actor":
     $ticket = new Ticket();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $input = array('id' => $key);
             if (isset($_POST['_ticket_requester'])) {
                 $input['_ticket_requester'] = $_POST['_ticket_requester'];
             }
             if (isset($_POST['_ticket_observer'])) {
                 $input['_ticket_observer'] = $_POST['_ticket_observer'];
             }
Пример #6
0
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
checkCentralAccess();
$task = new TicketTask();
if (isset($_POST["add"])) {
    $task->check(-1, 'w', $_POST);
    $task->add($_POST);
    Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . "  " . $LANG['log'][21]);
    glpi_header(getItemTypeFormURL('Ticket') . "?id=" . $task->getField('tickets_id'));
} else {
    if (isset($_POST["delete"])) {
        $task->check($_POST['id'], 'd');
        $task->delete($_POST);
        Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
        glpi_header(getItemTypeFormURL('Ticket') . "?id=" . $task->getField('tickets_id'));
    } else {
        if (isset($_POST["update"])) {
            $task->check($_POST["id"], 'w');
            $task->update($_POST);
            Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
            glpi_header($_SERVER['HTTP_REFERER']);
        }
Пример #7
0
 /**
  *  remove old groups to a ticket when a new group assigned
  *  called by "pre_item_add" hook on Group_Ticket object
  * @param CommonDBTM $item the ticket object
  */
 static function addHistoryOnAddGroup(CommonDBTM $item)
 {
     global $DB;
     if ($_SESSION['plugins']['escalade']['config']['remove_group'] == false) {
         return true;
     }
     //if group sent is not an assign group, return
     if ($item->input['type'] != CommonITILActor::ASSIGN) {
         return;
     }
     $tickets_id = $item->input['tickets_id'];
     $groups_id = $item->input['groups_id'];
     //if group already assigned, return
     $group_ticket = new Group_Ticket();
     $condition = "tickets_id = {$tickets_id} AND groups_id = {$groups_id} AND type = 2";
     if ($group_ticket->find($condition)) {
         unset($_SESSION['plugin_escalade']['keep_users']);
         return;
     }
     $item->fields['status'] = CommonITILObject::ASSIGNED;
     //add line in history table
     $history = new PluginEscaladeHistory();
     $history->add(array('tickets_id' => $tickets_id, 'groups_id' => $groups_id));
     //remove old user(s) (pass if user added by new ticket form)
     $backtrace = debug_backtrace();
     $first_trace = array_pop($backtrace);
     if (strpos($first_trace['file'], 'ticket.form.php') === false || $first_trace['function'] != "add" || !$first_trace['object'] instanceof Ticket) {
         self::removeAssignUsers($tickets_id);
     }
     //add a task to inform the escalation (pass if solution)
     if (isset($_SESSION['plugin_escalade']['solution'])) {
         unset($_SESSION['plugin_escalade']['solution']);
         return $item;
     }
     if ($_SESSION['plugins']['escalade']['config']['task_history']) {
         $group = new Group();
         $group->getFromDB($groups_id);
         $task = new TicketTask();
         $task->add(array('tickets_id' => $tickets_id, 'is_private' => true, 'state' => 0, 'content' => __("escalated to the group", "escalade") . " " . $group->getName()));
     }
     //check if event is not triggered by behaviors plugin
     //to prevent user remove when "add technician group" option is active
     if (strpos($first_trace['file'], 'ticket.form.php') !== false && $first_trace['function'] == "add" && $first_trace['object'] instanceof Ticket) {
         return;
     }
     if ($_SESSION['plugins']['escalade']['config']['ticket_last_status'] != -1) {
         $ticket = new Ticket();
         $ticket->update(array('id' => $tickets_id, 'status' => $_SESSION['plugins']['escalade']['config']['ticket_last_status']));
     }
     return $item;
 }
Пример #8
0
 static function finishAdd($item)
 {
     if (isset($_SESSION['plugin_escalation_ticketcopy']) && count($_SESSION['plugin_escalation_ticketcopy']) > 0) {
         if (isset($_SESSION['plugin_escalation_ticketcopy']['followup'])) {
             $ticketFollowup = new TicketFollowup();
             foreach ($_SESSION['plugin_escalation_ticketcopy']['followup'] as $follows_id) {
                 $a_followups = $ticketFollowup->find("`id`='" . $follows_id . "'");
                 foreach ($a_followups as $data) {
                     unset($data['id']);
                     $data = Toolbox::addslashes_deep($data);
                     $data['tickets_id'] = $item->getID();
                     $ticketFollowup->add($data);
                 }
             }
         }
         if (isset($_SESSION['plugin_escalation_ticketcopy']['task'])) {
             $ticketTask = new TicketTask();
             foreach ($_SESSION['plugin_escalation_ticketcopy']['task'] as $tasks_id) {
                 $a_tasks = $ticketTask->find("`id`='" . $tasks_id . "'", "`id`");
                 foreach ($a_tasks as $data) {
                     unset($data['id']);
                     $data = Toolbox::addslashes_deep($data);
                     $data['tickets_id'] = $item->getID();
                     foreach ($data as $key => $value) {
                         if ($value == '') {
                             unset($data[$key]);
                         }
                     }
                     $ticketTask->add($data);
                 }
             }
         }
         unset($_SESSION['plugin_escalation_ticketcopy']);
     }
 }