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(); $fup = new TicketFollowup(); if (isset($_POST["add"])) { $fup->check(-1, CREATE, $_POST); $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a followup'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST['add_close']) || isset($_POST['add_reopen'])) { $ticket = new Ticket(); if ($ticket->getFromDB($_POST["tickets_id"]) && $ticket->canApprove()) { $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s approves or refuses a solution'), $_SESSION["glpiname"])); Html::back(); } } else { if (isset($_POST["update"])) { $fup->check($_POST['id'], UPDATE); $fup->update($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s updates a followup'), $_SESSION["glpiname"]));
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>"))); } }
/** * Constructor * * @param $mailgateID ID of the mailgate * @param $display display messages in MessageAfterRedirect or just return error (default 0=) * * @return if $display = false return messages result string **/ function collect($mailgateID, $display = 0) { global $CFG_GLPI; if ($this->getFromDB($mailgateID)) { $this->mid = -1; $this->fetch_emails = 0; //Connect to the Mail Box $this->connect(); $rejected = new NotImportedEmail(); // Clean from previous collect (from GUI, cron already truncate the table) $rejected->deleteByCriteria(array('mailcollectors_id' => $this->fields['id'])); if ($this->marubox) { // Get Total Number of Unread Email in mail box $tot = $this->getTotalMails(); //Total Mails in Inbox Return integer value $error = 0; $refused = 0; $blacklisted = 0; for ($i = 1; $i <= $tot && $this->fetch_emails < $this->maxfetch_emails; $i++) { $tkt = $this->buildTicket($i, array('mailgates_id' => $mailgateID, 'play_rules' => true)); toolbox::logdebug("tkt", $tkt); //Indicates that the mail must be deleted from the mailbox $delete_mail = false; //If entity assigned, or email refused by rule, or no user and no supplier associated with the email $user_condition = $CFG_GLPI["use_anonymous_helpdesk"] || isset($tkt['_users_id_requester']) && $tkt['_users_id_requester'] > 0 || isset($tkt['_supplier_email']) && $tkt['_supplier_email']; $rejinput = array(); $rejinput['mailcollectors_id'] = $mailgateID; if (!$tkt['_blacklisted']) { $rejinput['from'] = $tkt['_head']['from']; $rejinput['to'] = $tkt['_head']['to']; $rejinput['users_id'] = $tkt['_users_id_requester']; $rejinput['subject'] = $this->textCleaner($tkt['_head']['subject']); $rejinput['messageid'] = $tkt['_head']['message_id']; } $rejinput['date'] = $_SESSION["glpi_currenttime"]; // Manage blacklisted emails if (isset($tkt['_blacklisted']) && $tkt['_blacklisted']) { $this->deleteMails($i, self::REFUSED_FOLDER); $blacklisted++; // entities_id set when new ticket / tickets_id when new followup } else { if ((isset($tkt['entities_id']) || isset($tkt['tickets_id'])) && $user_condition || isset($tkt['_refuse_email_no_response']) || isset($tkt['_refuse_email_with_response'])) { if (isset($tkt['_refuse_email_with_response'])) { $this->sendMailRefusedResponse($tkt['_head']['from'], $tkt['name']); $delete_mail = self::REFUSED_FOLDER; $refused++; } else { if (isset($tkt['_refuse_email_no_response'])) { $delete_mail = self::REFUSED_FOLDER; $refused++; } else { if (isset($tkt['entities_id']) || isset($tkt['tickets_id'])) { // Is a mail responding of an already existing ticket ? if (isset($tkt['tickets_id'])) { $fup = new TicketFollowup(); if ($fup->add($tkt)) { $delete_mail = self::ACCEPTED_FOLDER; } else { $error++; $rejinput['reason'] = NotImportedEmail::FAILED_INSERT; $rejected->add($rejinput); } } else { // New ticket $track = new Ticket(); if ($track->add($tkt)) { $delete_mail = self::ACCEPTED_FOLDER; } else { $error++; $rejinput['reason'] = NotImportedEmail::FAILED_INSERT; $rejected->add($rejinput); } } } else { // Case never raise $delete_mail = self::REFUSED_FOLDER; $refused++; } } } //Delete Mail from Mail box if ticket is added successfully if ($delete_mail) { $this->deleteMails($i, $delete_mail); } } else { if (!$tkt['_users_id_requester']) { $rejinput['reason'] = NotImportedEmail::USER_UNKNOWN; } else { $rejinput['reason'] = NotImportedEmail::MATCH_NO_RULE; } $rejected->add($rejinput); } } $this->fetch_emails++; } imap_expunge($this->marubox); $this->close_mailbox(); //Close Mail Box //TRANS: %1$d, %2$d, %3$d, %4$d and %5$d are number of messages $msg = sprintf(__('Number of messages: available=%1$d, retrieved=%2$d, refused=%3$d, errors=%4$d, blacklisted=%5$d'), $tot, $this->fetch_emails, $refused, $error, $blacklisted); if ($display) { Session::addMessageAfterRedirect($msg, false, $error ? ERROR : INFO); } else { return $msg; } } else { $msg = __('Could not connect to mailgate server'); if ($display) { Session::addMessageAfterRedirect($msg, false, ERROR); } else { return $msg; } } } else { //TRANS: %s is the ID of the mailgate $msg = sprintf(__('Could not find mailgate %d'), $mailgateID); if ($display) { Session::addMessageAfterRedirect($msg, false, ERROR); } else { return $msg; } } }
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] . " " . "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>)"); } }
/** * @see CommonDBTM::doSpecificMassiveActions() **/ function doSpecificMassiveActions($input = array()) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); switch ($input['action']) { case "link_ticket": if (isset($input['link']) && isset($input['tickets_id_1'])) { if ($this->getFromDB($input['tickets_id_1'])) { foreach ($input["item"] as $key => $val) { if ($val == 1) { $input2 = array(); $input2['id'] = $input['tickets_id_1']; $input2['_link']['tickets_id_1'] = $input['tickets_id_1']; $input2['_link']['link'] = $input['link']; $input2['_link']['tickets_id_2'] = $key; if ($this->can($input['tickets_id_1'], 'w')) { if ($this->update($input2)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } } } break; case "submit_validation": $valid = new TicketValidation(); foreach ($input["item"] as $key => $val) { if ($val == 1) { $input2 = array('tickets_id' => $key, 'users_id_validate' => $input['users_id_validate'], 'comment_submission' => $input['comment_submission']); if ($valid->can(-1, 'w', $input2)) { if ($valid->add($input2)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } break; case "add_followup": $fup = new TicketFollowup(); foreach ($input["item"] as $key => $val) { if ($val == 1) { $input2 = array('tickets_id' => $key, 'is_private' => $input['is_private'], 'requesttypes_id' => $input['requesttypes_id'], 'content' => $input['content']); if ($fup->can(-1, 'w', $input2)) { if ($fup->add($input2)) { $res['ok']++; } else { $res['ko']++; } } else { $res['noright']++; } } } break; default: return parent::doSpecificMassiveActions($input); } return $res; }
/** * Constructor * * @param $mailgateID ID of the mailgate * @param $display display messages in MessageAfterRedirect or just return error * * @return if $display = false return messages result string **/ function collect($mailgateID, $display = 0) { global $LANG, $CFG_GLPI; if ($this->getFromDB($mailgateID)) { $this->mid = -1; $this->fetch_emails = 0; //Connect to the Mail Box $this->connect(); $rejected = new NotImportedEmail(); // Clean from previous collect (from GUI, cron already truncate the table) $rejected->deleteByCriteria(array('mailcollectors_id' => $this->fields['id'])); if ($this->marubox) { // Get Total Number of Unread Email in mail box $tot = $this->getTotalMails(); //Total Mails in Inbox Return integer value $error = 0; $refused = 0; for ($i = 1; $i <= $tot && $this->fetch_emails < $this->maxfetch_emails; $i++) { $tkt = $this->buildTicket($i, array('mailgates_id' => $mailgateID, 'play_rules' => true)); //Indicates that the mail must be deleted from the mailbox $delete_mail = false; //If entity assigned, or email refused by rule, or no user associated with the email $user_condition = $CFG_GLPI["use_anonymous_helpdesk"] || isset($tkt['_users_id_requester']) && $tkt['_users_id_requester'] > 0; // Manage blacklisted emails if (isset($tkt['_blacklisted']) && $tkt['_blacklisted']) { $this->deleteMails($i); // entities_id set when new ticket / tickets_id when new followup } else { if ((isset($tkt['entities_id']) || isset($tkt['tickets_id'])) && $user_condition || isset($tkt['_refuse_email_no_response']) || isset($tkt['_refuse_email_with_response'])) { if (isset($tkt['_refuse_email_with_response'])) { $this->sendMailRefusedResponse($tkt['_head']['from'], $tkt['name']); $delete_mail = true; $refused++; } else { if (isset($tkt['_refuse_email_no_response'])) { $delete_mail = true; $refused++; } else { if (isset($tkt['entities_id']) || isset($tkt['tickets_id'])) { $tkt['_mailgate'] = $mailgateID; $result = imap_fetchheader($this->marubox, $i); // Is a mail responding of an already existgin ticket ? if (isset($tkt['tickets_id'])) { // Deletion of message with sucess if (false === is_array($result)) { $fup = new TicketFollowup(); if ($fup->add($tkt)) { $delete_mail = true; } } else { $error++; } } else { // New ticket // Deletion of message with sucess if (false === is_array($result)) { $track = new Ticket(); if ($track->add($tkt)) { $delete_mail = true; } } else { $error++; } } } else { // Case never raise $delete_mail = true; $refused++; } } } //Delete Mail from Mail box if ticket is added successfully if ($delete_mail) { $this->deleteMails($i); } } else { $input = array(); $input['mailcollectors_id'] = $mailgateID; $input['from'] = $tkt['_head']['from']; $input['to'] = $tkt['_head']['to']; if (!$tkt['_users_id_requester']) { $input['reason'] = NotImportedEmail::USER_UNKNOWN; } else { $input['reason'] = NotImportedEmail::MATCH_NO_RULE; } $input['users_id'] = $tkt['_users_id_requester']; $input['subject'] = $this->textCleaner($tkt['_head']['subject']); $input['messageid'] = $tkt['_head']['message_id']; $input['date'] = $_SESSION["glpi_currenttime"]; $rejected->add($input); } } $this->fetch_emails++; } imap_expunge($this->marubox); $this->close_mailbox(); //Close Mail Box if ($display) { if ($error == 0) { addMessageAfterRedirect($LANG['mailgate'][3] . " : " . $this->fetch_emails); } else { addMessageAfterRedirect($LANG['mailgate'][3] . " : " . $this->fetch_emails . " ({$error} " . $LANG['common'][63] . ")", false, ERROR); } } else { return "Number of messages: available={$tot}, collected=" . $this->fetch_emails . ($error > 0 ? " ({$error} error(s))" : "" . ($refused > 0 ? " ({$refused} refused)" : "")); } } else { if ($display) { addMessageAfterRedirect($LANG['log'][41], false, ERROR); } else { return "Could not connect to mailgate server"; } } } else { if ($display) { addMessageAfterRedirect($LANG['common'][54] . " : mailgate " . $mailgateID, false, ERROR); } else { return 'Could find mailgate ' . $mailgateID; } } }
/** 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"))); } } }
/** * Add a followup to a existing ticket * for an authenticated user * * @param $params array of options (ticket, content) * @param $protocol * * @return array of hashtable **/ static function methodAddTicketFollowup($params, $protocol) { if (isset($params['help'])) { return array('ticket' => 'integer,mandatory', 'content' => 'string,mandatory', 'users_login' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional'); } if (!Session::getLoginUserID()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED); } $ticket = new Ticket(); if (isset($params['users_login']) && is_numeric($params['users_login'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'users_login should be a string'); } if (isset($params['users_login']) && is_string($params['users_login'])) { $user = new User(); if (!($users_id = $user->getIdByName($params['users_login']))) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'unable to get users_id with the users_login'); } } if (!isset($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket'); } if (!is_numeric($params['ticket'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket'); } if (!$ticket->can($params['ticket'], 'r')) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND); } if (!$ticket->canAddFollowups()) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) && !$ticket->canApprove()) { // Logged user not allowed if (isset($users_id)) { // If we get the users id $approbationSolution = self::checkApprobationSolution($users_id, $ticket); if (!$approbationSolution) { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } } else { return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED); } } if (!isset($params['content'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'content'); } // Source of the ticket, dynamically created if (isset($params['source'])) { if (empty($params['content'])) { return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'source'); } $source = Dropdown::importExternal('RequestType', $params['source']); } else { $source = Dropdown::importExternal('RequestType', 'WebServices'); } $private = isset($params['private']) && $params['private'] ? 1 : 0; $followup = new TicketFollowup(); $user = 0; if (isset($users_id)) { $user = $users_id; } $data = array('tickets_id' => $params['ticket'], 'requesttypes_id' => $source, 'is_private' => $private, 'users_id' => $user, 'content' => addslashes(Toolbox::clean_cross_side_scripting_deep($params["content"]))); if (isset($params['close'])) { if (isset($params['reopen'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'can\'t use both reopen and close options'); } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray())) { $data['add_close'] = 1; if (isset($users_id)) { $data['users_id'] = $users_id; } } else { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'close for not solved ticket'); } } if (isset($params['reopen'])) { if (in_array($ticket->fields['status'], array(Ticket::SOLVED, Ticket::WAITING))) { $data['add_reopen'] = 1; if (isset($users_id)) { $data['users_id'] = $users_id; } } else { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'reopen for not solved or waiting ticket'); } } if (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) && !isset($params['close']) && !isset($params['reopen'])) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'missing reopen/close option for solved ticket'); } if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) { return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'cannot add to a closed ticket'); } if ($followup->add($data)) { return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol); } return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError()); }
$_SESSION['glpitransfer_list'][$_POST["itemtype"]] = array(); } foreach ($_POST["item"] as $key => $val) { if ($val == 1) { $_SESSION['glpitransfer_list'][$_POST["itemtype"]][$key] = $key; } } $REDIRECT = $CFG_GLPI['root_doc'] . '/front/transfer.action.php'; break; case "add_followup": $fup = new TicketFollowup(); foreach ($_POST["item"] as $key => $val) { if ($val == 1) { $input = array('tickets_id' => $key, 'is_private' => $_POST['is_private'], 'requesttypes_id' => $_POST['requesttypes_id'], 'content' => $_POST['content']); if ($fup->can(-1, 'w', $input)) { $fup->add($input); } } } break; case "submit_validation": $valid = new TicketValidation(); 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;
/** * CLone a ticket and his relations * @param integer $tickets_id id of the ticket to clone * @return print a json response (return nothing) */ static function cloneAndLink($tickets_id) { global $DB; //get old ticket $ticket = new Ticket(); if (!$ticket->getFromDB($tickets_id)) { echo "{\"success\":false, \"message\":\"" . __("Error : get old ticket", "escalade") . "\"}"; exit; } //set fields $fields = $ticket->fields; $fields = array_map(array('Toolbox', 'addslashes_deep'), $fields); $fields['id'] = 0; $fields['_users_id_requester'] = 0; $fields['status'] = CommonITILObject::INCOMING; /*var_dump($fields); exit;*/ //create new ticket (duplicate from previous) if (!($newID = $ticket->add($fields))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding new ticket", "escalade") . "\"}"; exit; } //add link between them $ticket_ticket = new Ticket_Ticket(); if (!$ticket_ticket->add(array('tickets_id_1' => $tickets_id, 'tickets_id_2' => $newID, 'link' => Ticket_Ticket::LINK_TO))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding link between the two tickets", "escalade") . "\"}"; exit; } //add a followup to indicate duplication $followup = new TicketFollowup(); if (!$followup->add(array('tickets_id' => $newID, 'users_id' => Session::getLoginUserID(), 'content' => __("This ticket has been from the ticket num", "escalade") . " " . $tickets_id, 'is_private' => true, 'requesttypes_id' => 6))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding followups", "escalade") . "\"}"; exit; } //add actors to the new ticket (without assign) //users $query_users = "INSERT INTO glpi_tickets_users\n SELECT '' AS id, {$newID} as tickets_id, users_id, type, use_notification, alternative_email\n FROM glpi_tickets_users\n WHERE tickets_id = {$tickets_id} AND type != 2"; if (!($res = $DB->query($query_users))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding actors (user)", "escalade") . "\"}"; exit; } //groups $query_groups = "INSERT INTO glpi_groups_tickets\n SELECT '' AS id, {$newID} as tickets_id, groups_id, type\n FROM glpi_groups_tickets\n WHERE tickets_id = {$tickets_id} AND type != 2"; if (!($res = $DB->query($query_groups))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding actors (group)", "escalade") . "\"}"; exit; } //add documents $query_docs = "INSERT INTO glpi_documents_items (documents_id, items_id, itemtype, entities_id, is_recursive, date_mod)\n SELECT documents_id, {$newID}, 'Ticket', entities_id, is_recursive, date_mod\n FROM glpi_documents_items\n WHERE items_id = {$tickets_id} AND itemtype = 'Ticket'"; if (!($res = $DB->query($query_docs))) { echo "{\"success\":false, \"message\":\"" . __("Error : adding documents", "escalade") . "\"}"; exit; } //add history to the new ticket $changes[0] = '0'; $changes[1] = __("This ticket has been from the ticket num", "escalade") . " " . $tickets_id; $changes[2] = ""; Log::history($newID, 'Ticket', $changes, 'Ticket'); //add message (ticket cloned) after redirect Session::addMessageAfterRedirect(__("This ticket has been from the ticket num", "escalade") . " " . $tickets_id); //all ok echo "{\"success\":true, \"newID\":{$newID}}"; }
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']); } }
private function manageTicket($closed = true) { global $DB, $CFG_GLPI; $DB->connect(); $_SESSION['glpiactive_entity'] = 0; $CFG_GLPI['root_doc'] = "http://127.0.0.1/fusion0.83/"; $plugin = new Plugin(); $plugin->getFromDBbyDir("timelineticket"); $plugin->activate($plugin->fields['id']); Plugin::load("timelineticket"); Session::loadLanguage("en_GB"); $ticket = new Ticket(); $group = new Group(); $group_ticket = new Group_Ticket(); $GLPIlog = new GLPIlogs(); $ticket_User = new Ticket_User(); $_SESSION['plugin_timelineticket_date'] = array(); $group->add(array('name' => 'grtech1')); $group->add(array('name' => 'grtech2')); // * 01/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate = array('1' => $_SESSION["glpi_currenttime"]); $input = array(); $input['name'] = 'Pb with the ticket'; $input['content'] = 'I have a problem with the ticket'; $tickets_id = $ticket->add($input); $GLPIlog->testSQLlogs('01/'); $GLPIlog->testPHPlogs('01/'); // * 02/ sleep(2); // * 03/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[3] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['_itil_assign']['_type'] = 'group'; $input['_itil_assign']['groups_id'] = 1; $ticket->update($input); $input['_itil_assign']['_type'] = 'user'; $input['_itil_assign']['users_id'] = 2; $ticket->update($input); $GLPIlog->testSQLlogs('03/'); $GLPIlog->testPHPlogs('03/'); $a_db = getAllDatasFromTable('glpi_groups_tickets'); $a_ref = array(); $a_ref[1] = array('id' => '1', 'tickets_id' => '1', 'groups_id' => '1', 'type' => '2'); $this->assertEquals($a_ref, $a_db, 'May have ticket assigned to group1'); $a_db = getAllDatasFromTable('glpi_tickets_users'); $a_ref = array(); $a_ref[1] = array('id' => '1', 'tickets_id' => '1', 'users_id' => '2', 'type' => '1', 'use_notification' => '1', 'alternative_email' => ''); $a_ref[2] = array('id' => '2', 'tickets_id' => '1', 'users_id' => '2', 'type' => '2', 'use_notification' => '1', 'alternative_email' => ''); $this->assertEquals($a_ref, $a_db, 'May have ticket assigned to user 2 (glpi)'); // * 04/ sleep(2); // * 05/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[5] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['status'] = Ticket::WAITING; $ticket->update($input); $GLPIlog->testSQLlogs('05/'); $GLPIlog->testPHPlogs('05/'); $ticket->getFromDB(1); $this->assertEquals('waiting', $ticket->fields['status'], 'May have status waiting'); // * 06/ sleep(1); // * 07/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[7] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = 2; $input['itickets_id'] = $tickets_id; $ticket_User->check($input['id'], 'w'); $ticket_User->delete($input); $input = array(); $input['id'] = 1; $input['itickets_id'] = $tickets_id; $group_ticket->check($input['id'], 'w'); $group_ticket->delete($input); $GLPIlog->testSQLlogs('07/'); $GLPIlog->testPHPlogs('07/'); $a_db = getAllDatasFromTable('glpi_groups_tickets'); $this->assertEquals(array(), $a_db, 'May have no group assigned'); // * 08/ sleep(1); // * 09/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[9] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['_itil_assign']['_type'] = 'group'; $input['_itil_assign']['groups_id'] = 2; $ticket->update($input); $GLPIlog->testSQLlogs('09/'); $GLPIlog->testPHPlogs('09/'); $a_db = getAllDatasFromTable('glpi_groups_tickets'); $a_ref = array(); $a_ref[2] = array('id' => '2', 'tickets_id' => '1', 'groups_id' => '2', 'type' => '2'); $this->assertEquals($a_ref, $a_db, 'May have ticket assigned to group2'); $ticket->getFromDB(1); $this->assertEquals('assign', $ticket->fields['status'], '(09/) Status is assign'); // * 10/ sleep(1); // * 11/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[11] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['status'] = Ticket::WAITING; $ticket->update($input); $input = array(); $input['id'] = $tickets_id; $input['_itil_assign']['_type'] = 'user'; $input['_itil_assign']['users_id'] = 4; $ticket->update($input); $GLPIlog->testSQLlogs('11/'); $GLPIlog->testPHPlogs('11/'); // * 12/ sleep(1); // * 13/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[13] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['_itil_assign']['_type'] = 'group'; $input['_itil_assign']['groups_id'] = 1; $ticket->update($input); $input['_itil_assign']['_type'] = 'user'; $input['_itil_assign']['users_id'] = 2; $ticket->update($input); $GLPIlog->testSQLlogs('13/'); $GLPIlog->testPHPlogs('13/'); $ticket->getFromDB(1); $this->assertEquals('waiting', $ticket->fields['status'], '(13/)May have always status waiting'); // * 14/ $input = array(); $input['id'] = 2; $input['itickets_id'] = $tickets_id; $group_ticket->check($input['id'], 'w'); $group_ticket->delete($input); $GLPIlog->testSQLlogs('14/'); $GLPIlog->testPHPlogs('14/'); $a_db = getAllDatasFromTable('glpi_groups_tickets'); $a_ref = array(); $a_ref[3] = array('id' => '3', 'tickets_id' => '1', 'groups_id' => '1', 'type' => '2'); $this->assertEquals($a_ref, $a_db, '(14/) May have ticket assigned to group1'); $ticket->getFromDB(1); $this->assertEquals('waiting', $ticket->fields['status'], '(14/) Status is waiting'); // * 15/ sleep(2); // * 16/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[16] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['status'] = Ticket::ASSIGNED; $ticket->update($input); $GLPIlog->testSQLlogs('16/'); $GLPIlog->testPHPlogs('16/'); // * 17/ sleep(1); // * 18/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[18] = $_SESSION["glpi_currenttime"]; $input = array(); $input['id'] = $tickets_id; $input['solution'] = "solution"; $ticket->update($input); $GLPIlog->testSQLlogs('18/'); $GLPIlog->testPHPlogs('18/'); $ticket->getFromDB(1); $this->assertEquals('solved', $ticket->fields['status'], '(18/) Status is solved'); if ($closed) { // * 19/ sleep(1); // * 20/ $_SESSION["glpi_currenttime"] = date("Y-m-d H:i:s"); $a_storedate[20] = $_SESSION["glpi_currenttime"]; $fup = new TicketFollowup(); $input = array(); $input['tickets_id'] = $tickets_id; $input['add_close'] = 'add_close'; $fup->add($input); $GLPIlog->testSQLlogs('20/'); $GLPIlog->testPHPlogs('20/'); $ticket->getFromDB(1); $this->assertEquals('closed', $ticket->fields['status'], '(19/) Status is closed'); } self::$storedate = $a_storedate; }