/** * Display a line for an object * * @since version 0.85 (befor in each object with differents parameters) * * @param $id Integer ID of the object * @param $options array of options * output_type : Default output type (see Search class / default Search::HTML_OUTPUT) * row_num : row num used for display * type_for_massiveaction : itemtype for massive action * id_for_massaction : default 0 means no massive action * followups : only for Tickets : show followup columns */ static function showShort($id, $options = array()) { global $CFG_GLPI, $DB; $p['output_type'] = Search::HTML_OUTPUT; $p['row_num'] = 0; $p['type_for_massiveaction'] = 0; $p['id_for_massiveaction'] = 0; $p['followups'] = false; if (count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } $rand = mt_rand(); /// TODO to be cleaned. Get datas and clean display links // Prints a job in short form // Should be called in a <table>-segment // Print links or not in case of user view // Make new job object and fill it from database, if success, print it $item = new static(); $candelete = static::canDelete(); $canupdate = Session::haveRight(static::$rightname, UPDATE); $showprivate = Session::haveRight('followup', TicketFollowup::SEEPRIVATE); $align = "class='center"; $align_desc = "class='left"; if ($p['followups']) { $align .= " top'"; $align_desc .= " top'"; } else { $align .= "'"; $align_desc .= "'"; } if ($item->getFromDB($id)) { $item_num = 1; $bgcolor = $_SESSION["glpipriority_" . $item->fields["priority"]]; echo Search::showNewLine($p['output_type'], $p['row_num'] % 2); $check_col = ''; if (($candelete || $canupdate) && $p['output_type'] == Search::HTML_OUTPUT && $p['id_for_massiveaction']) { $check_col = Html::getMassiveActionCheckBox($p['type_for_massiveaction'], $p['id_for_massiveaction']); } echo Search::showItem($p['output_type'], $check_col, $item_num, $p['row_num'], $align); // First column $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $item->fields["id"]); if ($p['output_type'] == Search::HTML_OUTPUT) { $first_col .= "<br><img src='" . static::getStatusIconURL($item->fields["status"]) . "'\n alt=\"" . static::getStatus($item->fields["status"]) . "\" title=\"" . static::getStatus($item->fields["status"]) . "\">"; } else { $first_col = sprintf(__('%1$s - %2$s'), $first_col, static::getStatus($item->fields["status"])); } echo Search::showItem($p['output_type'], $first_col, $item_num, $p['row_num'], $align); // Second column if ($item->fields['status'] == static::CLOSED) { $second_col = sprintf(__('Closed on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['closedate'])); } else { if ($item->fields['status'] == static::SOLVED) { $second_col = sprintf(__('Solved on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['solvedate'])); } else { if ($item->fields['begin_waiting_date']) { $second_col = sprintf(__('Put on hold on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['begin_waiting_date'])); } else { if ($item->fields['due_date']) { $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['due_date'])); } else { $second_col = sprintf(__('Opened on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['date'])); } } } } echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=130"); // Second BIS column $second_col = Html::convDateTime($item->fields["date_mod"]); echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=90"); // Second TER column if (count($_SESSION["glpiactiveentities"]) > 1) { $second_col = Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=100"); } // Third Column echo Search::showItem($p['output_type'], "<span class='b'>" . static::getPriorityName($item->fields["priority"]) . "</span>", $item_num, $p['row_num'], "{$align} bgcolor='{$bgcolor}'"); // Fourth Column $fourth_col = ""; foreach ($item->getUsers(CommonITILActor::REQUESTER) as $d) { $userdata = getUserName($d["users_id"], 2); $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false))); $fourth_col .= "<br>"; } foreach ($item->getGroups(CommonITILActor::REQUESTER) as $d) { $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]); $fourth_col .= "<br>"; } echo Search::showItem($p['output_type'], $fourth_col, $item_num, $p['row_num'], $align); // Fifth column $fifth_col = ""; foreach ($item->getUsers(CommonITILActor::ASSIGN) as $d) { $userdata = getUserName($d["users_id"], 2); $fifth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false))); $fifth_col .= "<br>"; } foreach ($item->getGroups(CommonITILActor::ASSIGN) as $d) { $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]); $fifth_col .= "<br>"; } foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $d) { $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]); $fifth_col .= "<br>"; } echo Search::showItem($p['output_type'], $fifth_col, $item_num, $p['row_num'], $align); // Sixth Colum // Ticket : simple link to item $sixth_col = ""; $is_deleted = false; $item_ticket = new Item_Ticket(); $data = $item_ticket->find("`tickets_id` = " . $item->fields['id']); if ($item->getType() == 'Ticket') { if (!empty($data)) { foreach ($data as $val) { if (!empty($val["itemtype"]) && $val["items_id"] > 0) { if ($object = getItemForItemtype($val["itemtype"])) { if ($object->getFromDB($val["items_id"])) { $is_deleted = $object->isDeleted(); $sixth_col .= $object->getTypeName(); $sixth_col .= " - <span class='b'>"; if ($item->canView()) { $sixth_col .= $object->getLink(); } else { $sixth_col .= $object->getNameID(); } $sixth_col .= "</span><br>"; } } } } } else { $sixth_col = __('General'); } echo Search::showItem($p['output_type'], $sixth_col, $item_num, $p['row_num'], $is_deleted ? " class='center deleted' " : $align); } // Seventh column echo Search::showItem($p['output_type'], "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $item->fields["itilcategories_id"]) . "</span>", $item_num, $p['row_num'], $align); // Eigth column $eigth_column = "<span class='b'>" . $item->getName() . "</span> "; // Add link if ($item->canViewItem()) { $eigth_column = "<a id='" . $item->getType() . $item->fields["id"] . "{$rand}' href=\"" . $item->getLinkURL() . "\">{$eigth_column}</a>"; if ($p['followups'] && $p['output_type'] == Search::HTML_OUTPUT) { $eigth_column .= TicketFollowup::showShortForTicket($item->fields["id"]); } else { if (method_exists($item, 'numberOfFollowups')) { $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, sprintf(__('%1$s - %2$s'), $item->numberOfFollowups($showprivate), $item->numberOfTasks($showprivate))); } else { $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, $item->numberOfTasks($showprivate)); } } } if ($p['output_type'] == Search::HTML_OUTPUT) { $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip(Html::clean(Html::entity_decode_deep($item->fields["content"])), array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . $rand))); } echo Search::showItem($p['output_type'], $eigth_column, $item_num, $p['row_num'], $align_desc . " width='200'"); //tenth column $tenth_column = ''; $planned_infos = ''; $tasktype = $item->getType() . "Task"; $plan = new $tasktype(); $items = array(); foreach ($DB->request($plan->getTable(), array($item->getForeignKeyField() => $item->fields['id'])) as $plan) { if (isset($plan['begin']) && $plan['begin']) { $items[$plan['id']] = $plan['id']; $planned_infos .= sprintf(__('From %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['begin'])); $planned_infos .= sprintf(__('To %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['end'])); if ($plan['users_id_tech']) { $planned_infos .= sprintf(__('By %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), getUserName($plan['users_id_tech'])); } $planned_infos .= "<br>"; } } unset($i, $j); $tenth_column = count($items); if ($tenth_column) { $tenth_column = "<span class='pointer'\n id='" . $item->getType() . $item->fields["id"] . "planning{$rand}'>" . $tenth_column . '</span>'; $tenth_column = sprintf(__('%1$s %2$s'), $tenth_column, Html::showToolTip($planned_infos, array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . "planning" . $rand))); } echo Search::showItem($p['output_type'], $tenth_column, $item_num, $p['row_num'], $align_desc . " width='150'"); // Finish Line echo Search::showEndLine($p['output_type']); } else { echo "<tr class='tab_bg_2'>"; echo "<td colspan='6' ><i>" . __('No item in progress.') . "</i></td></tr>"; } }
/** * @see NotificationTargetCommonITILObject::getDatasForObject() **/ function getDatasForObject(CommonDBTM $item, array $options, $simple = false) { global $CFG_GLPI; // Common ITIL datas $datas = parent::getDatasForObject($item, $options, $simple); $datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']); $datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item); $datas['##ticket.content##'] = $datas['##ticket.description##']; // Specific datas $datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1"); $datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation')); $datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type')); $datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id')); $autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER); $datas['##ticket.autoclose##'] = __('Never'); $datas['##lang.ticket.autoclosewarning##'] = ""; if ($autoclose_value > 0) { $datas['##ticket.autoclose##'] = $autoclose_value; $datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value); } $datas['##ticket.sla##'] = ''; if ($item->getField('slas_id')) { $datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id')); } $datas['##ticket.location##'] = ''; if ($item->getField('locations_id')) { $datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id')); } // is ticket deleted $datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted')); //Tags associated with the object linked to the ticket $datas['##ticket.itemtype##'] = ''; $datas['##ticket.item.name##'] = ''; $datas['##ticket.item.serial##'] = ''; $datas['##ticket.item.otherserial##'] = ''; $datas['##ticket.item.location##'] = ''; $datas['##ticket.item.contact##'] = ''; $datas['##ticket.item.contactnumber##'] = ''; $datas['##ticket.item.user##'] = ''; $datas['##ticket.item.group##'] = ''; $datas['##ticket.item.model##'] = ''; $item_ticket = new Item_Ticket(); $items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'"); $datas['items'] = array(); if (count($items)) { foreach ($items as $val) { if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) { $tmp = array(); //Object type $tmp['##ticket.itemtype##'] = $hardware->getTypeName(); //Object name $tmp['##ticket.item.name##'] = $hardware->getField('name'); //Object serial if ($hardware->isField('serial')) { $tmp['##ticket.item.serial##'] = $hardware->getField('serial'); } //Object contact if ($hardware->isField('contact')) { $tmp['##ticket.item.contact##'] = $hardware->getField('contact'); } //Object contact num if ($hardware->isField('contact_num')) { $tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num'); } //Object otherserial if ($hardware->isField('otherserial')) { $tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial'); } //Object location if ($hardware->isField('locations_id')) { $tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id')); } //Object user if ($hardware->getField('users_id')) { $user_tmp = new User(); if ($user_tmp->getFromDB($hardware->getField('users_id'))) { $tmp['##ticket.item.user##'] = $user_tmp->getName(); } } //Object group if ($hardware->getField('groups_id')) { $tmp['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $hardware->getField('groups_id')); } $modeltable = getSingular($hardware->getTable()) . "models"; $modelfield = getForeignKeyFieldForTable($modeltable); if ($hardware->isField($modelfield)) { $tmp['##ticket.item.model##'] = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield)); } $datas['items'][] = $tmp; } } } $datas['##ticket.numberofitems##'] = count($datas['items']); // Get followups, log, validation, satisfaction, linked tickets if (!$simple) { // Linked tickets $linked_tickets = Ticket_Ticket::getLinkedTicketsTo($item->getField('id')); $datas['linkedtickets'] = array(); if (count($linked_tickets)) { $linkedticket = new Ticket(); foreach ($linked_tickets as $data) { if ($linkedticket->getFromDB($data['tickets_id'])) { $tmp = array(); $tmp['##linkedticket.id##'] = $data['tickets_id']; $tmp['##linkedticket.link##'] = Ticket_Ticket::getLinkName($data['link']); $tmp['##linkedticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $data['tickets_id']); $tmp['##linkedticket.title##'] = $linkedticket->getField('name'); $tmp['##linkedticket.content##'] = $linkedticket->getField('content'); $datas['linkedtickets'][] = $tmp; } } } $datas['##ticket.numberoflinkedtickets##'] = count($datas['linkedtickets']); $restrict = "`tickets_id`='" . $item->getField('id') . "'"; $problems = getAllDatasFromTable('glpi_problems_tickets', $restrict); $datas['problems'] = array(); if (count($problems)) { $problem = new Problem(); foreach ($problems as $data) { if ($problem->getFromDB($data['problems_id'])) { $tmp = array(); $tmp['##problem.id##'] = $data['problems_id']; $tmp['##problem.date##'] = $problem->getField('date'); $tmp['##problem.title##'] = $problem->getField('name'); $tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "problem_" . $data['problems_id']); $tmp['##problem.content##'] = $problem->getField('content'); $datas['problems'][] = $tmp; } } } $datas['##ticket.numberofproblems##'] = count($datas['problems']); $restrict = "`tickets_id`='" . $item->getField('id') . "'"; $changes = getAllDatasFromTable('glpi_changes_tickets', $restrict); $datas['changes'] = array(); if (count($changes)) { $change = new Change(); foreach ($changes as $data) { if ($change->getFromDB($data['changes_id'])) { $tmp = array(); $tmp['##change.id##'] = $data['changes_id']; $tmp['##change.date##'] = $change->getField('date'); $tmp['##change.title##'] = $change->getField('name'); $tmp['##change.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $data['changes_id']); $tmp['##change.content##'] = $change->getField('content'); $datas['changes'][] = $tmp; } } } $datas['##ticket.numberofchanges##'] = count($datas['changes']); if (!isset($options['additionnaloption']['show_private']) || !$options['additionnaloption']['show_private']) { $restrict .= " AND `is_private` = '0'"; } $restrict .= " ORDER BY `date` DESC, `id` ASC"; //Followup infos $followups = getAllDatasFromTable('glpi_ticketfollowups', $restrict); $datas['followups'] = array(); foreach ($followups as $followup) { $tmp = array(); $tmp['##followup.isprivate##'] = Dropdown::getYesNo($followup['is_private']); $tmp['##followup.author##'] = Html::clean(getUserName($followup['users_id'])); $tmp['##followup.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $followup['requesttypes_id']); $tmp['##followup.date##'] = Html::convDateTime($followup['date']); $tmp['##followup.description##'] = $followup['content']; $datas['followups'][] = $tmp; } $datas['##ticket.numberoffollowups##'] = count($datas['followups']); // Approbation of solution $restrict .= " LIMIT 1"; $replysolved = getAllDatasFromTable('glpi_ticketfollowups', $restrict); $data = current($replysolved); $datas['##ticket.solution.approval.description##'] = $data['content']; $datas['##ticket.solution.approval.date##'] = Html::convDateTime($data['date']); $datas['##ticket.solution.approval.author##'] = Html::clean(getUserName($data['users_id'])); //Validation infos $restrict = "`tickets_id`='" . $item->getField('id') . "'"; if (isset($options['validation_id']) && $options['validation_id']) { $restrict .= " AND `glpi_ticketvalidations`.`id` = '" . $options['validation_id'] . "'"; } $restrict .= " ORDER BY `submission_date` DESC, `id` ASC"; $validations = getAllDatasFromTable('glpi_ticketvalidations', $restrict); $datas['validations'] = array(); foreach ($validations as $validation) { $tmp = array(); $tmp['##validation.submission.title##'] = sprintf(__('An approval request has been submitted by %s'), Html::clean(getUserName($validation['users_id']))); $tmp['##validation.answer.title##'] = sprintf(__('An answer to an an approval request was produced by %s'), Html::clean(getUserName($validation['users_id_validate']))); $tmp['##validation.author##'] = Html::clean(getUserName($validation['users_id'])); $tmp['##validation.status##'] = TicketValidation::getStatus($validation['status']); $tmp['##validation.storestatus##'] = $validation['status']; $tmp['##validation.submissiondate##'] = Html::convDateTime($validation['submission_date']); $tmp['##validation.commentsubmission##'] = $validation['comment_submission']; $tmp['##validation.validationdate##'] = Html::convDateTime($validation['validation_date']); $tmp['##validation.validator##'] = Html::clean(getUserName($validation['users_id_validate'])); $tmp['##validation.commentvalidation##'] = $validation['comment_validation']; $datas['validations'][] = $tmp; } // Ticket Satisfaction $inquest = new TicketSatisfaction(); $datas['##satisfaction.type##'] = ''; $datas['##satisfaction.datebegin##'] = ''; $datas['##satisfaction.dateanswered##'] = ''; $datas['##satisfaction.satisfaction##'] = ''; $datas['##satisfaction.description##'] = ''; if ($inquest->getFromDB($item->getField('id'))) { // internal inquest if ($inquest->fields['type'] == 1) { $datas['##ticket.urlsatisfaction##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . '_Ticket$3'); // external inquest } else { if ($inquest->fields['type'] == 2) { $datas['##ticket.urlsatisfaction##'] = Entity::generateLinkSatisfaction($item); } } $datas['##satisfaction.type##'] = $inquest->getTypeInquestName($inquest->getfield('type')); $datas['##satisfaction.datebegin##'] = Html::convDateTime($inquest->fields['date_begin']); $datas['##satisfaction.dateanswered##'] = Html::convDateTime($inquest->fields['date_answered']); $datas['##satisfaction.satisfaction##'] = $inquest->fields['satisfaction']; $datas['##satisfaction.description##'] = $inquest->fields['comment']; } } return $datas; }
function post_updateItem($history = 1) { global $CFG_GLPI; $donotif = count($this->updates); if (isset($this->input['_forcenotif'])) { $donotif = true; } // Manage SLT Level : add actions foreach (array(SLT::TTR, SLT::TTO) as $sltType) { list($dateField, $sltField) = SLT::getSltFieldNames($sltType); if (in_array($sltField, $this->updates) && $this->fields[$sltField] > 0) { $this->manageSltLevel($this->fields[$sltField]); } } $this->updates[] = "actiontime"; if (count($this->updates)) { // Update Ticket Tco if (in_array("actiontime", $this->updates) || in_array("cost_time", $this->updates) || in_array("cost_fixed", $this->updates) || in_array("cost_material", $this->updates)) { $item_ticket = new Item_Ticket(); $linked_items = $item_ticket->find("`tickets_id` = " . $this->fields['id']); if (!empty($this->input["items_id"])) { foreach ($this->input["items_id"] as $itemtype => $items) { foreach ($items as $items_id) { if ($itemtype && ($item = getItemForItemtype($itemtype))) { if ($item->getFromDB($items_id)) { $newinput = array(); $newinput['id'] = $items_id; $newinput['ticket_tco'] = self::computeTco($item); $item->update($newinput); } } } } } } 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)); } } } // Setting a solution type means the ticket is solved if ((in_array("solutiontypes_id", $this->updates) || in_array("solution", $this->updates)) && (isset($this->input["status"]) && (in_array($this->input["status"], $this->getSolvedStatusArray()) || in_array($this->input["status"], $this->getClosedStatusArray())))) { // auto close case Ticket_Ticket::manageLinkedTicketsOnSolved($this->fields['id']); } // Clean content to mail //$this->fields["content"] = stripslashes($this->fields["content"]); $donotif = true; } if (isset($this->input['_disablenotif'])) { $donotif = false; } if ($donotif && $CFG_GLPI["use_mailing"]) { $mailtype = "update"; if (isset($this->input["status"]) && $this->input["status"] && in_array("status", $this->updates) && in_array($this->input["status"], $this->getSolvedStatusArray())) { $mailtype = "solved"; } if (isset($this->input["status"]) && $this->input["status"] && in_array("status", $this->updates) && in_array($this->input["status"], $this->getClosedStatusArray())) { $mailtype = "closed"; } // to know if a solution is approved or not if (isset($this->input['solvedate']) && $this->input['solvedate'] == 'NULL' && isset($this->oldvalues['solvedate']) && $this->oldvalues['solvedate'] && (isset($this->input['status']) && $this->input['status'] != $this->oldvalues['status'] && $this->oldvalues['status'] == self::SOLVED)) { $mailtype = "rejectsolution"; } // Read again ticket to be sure that all data are up to date $this->getFromDB($this->fields['id']); NotificationEvent::raiseEvent($mailtype, $this); } // inquest created immediatly if delay = O $inquest = new TicketSatisfaction(); $rate = Entity::getUsedConfig('inquest_config', $this->fields['entities_id'], 'inquest_rate'); $delay = Entity::getUsedConfig('inquest_config', $this->fields['entities_id'], 'inquest_delay'); $duration = Entity::getUsedConfig('inquest_duration', $this->fields['entities_id'], 'inquest_duration'); $type = Entity::getUsedConfig('inquest_config', $this->fields['entities_id']); $max_closedate = $this->fields['closedate']; if (in_array("status", $this->updates) && in_array($this->input["status"], $this->getClosedStatusArray()) && $delay == 0 && $rate > 0 && mt_rand(1, 100) <= $rate) { $inquest->add(array('tickets_id' => $this->fields['id'], 'date_begin' => $_SESSION["glpi_currenttime"], 'entities_id' => $this->fields['entities_id'], 'type' => $type, 'max_closedate' => $max_closedate)); } }
function post_updateItem($history = 1) { global $CFG_GLPI; $donotif = count($this->updates); if (isset($this->input['_forcenotif'])) { $donotif = true; } if (!empty($this->input['itemtype']) && !empty($this->input['items_id'])) { $item_ticket = new Item_Ticket(); $item_ticket->add(array('items_id' => $this->input['items_id'], 'itemtype' => $this->input['itemtype'], 'tickets_id' => $this->fields['id'])); } // Manage SLA Level : add actions if (in_array("slas_id", $this->updates) && $this->fields["slas_id"] > 0) { // Add First Level $calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']); $sla = new SLA(); if ($sla->getFromDB($this->fields["slas_id"])) { $sla->setTicketCalendar($calendars_id); // Add first level in working table if ($this->fields["slalevels_id"] > 0) { $sla->addLevelToDo($this); } } SlaLevel_Ticket::replayForTicket($this->getID()); } $this->updates[] = "actiontime"; if (count($this->updates)) { // Update Ticket Tco if (in_array("actiontime", $this->updates) || in_array("cost_time", $this->updates) || in_array("cost_fixed", $this->updates) || in_array("cost_material", $this->updates)) { $item_ticket = new Item_Ticket(); $linked_items = $item_ticket->find("`tickets_id` = " . $this->fields['id']); if (!empty($linked_items)) { foreach ($linked_items as $data) { if ($data["itemtype"] && ($item = getItemForItemtype($data["itemtype"]))) { if ($item->getFromDB($data["items_id"])) { $newinput = array(); $newinput['id'] = $data["items_id"]; $newinput['ticket_tco'] = self::computeTco($item); $item->update($newinput); } } } } } // Setting a solution type means the ticket is solved if ((in_array("solutiontypes_id", $this->updates) || in_array("solution", $this->updates)) && (in_array($this->input["status"], $this->getSolvedStatusArray()) || in_array($this->input["status"], $this->getClosedStatusArray()))) { // auto close case Ticket_Ticket::manageLinkedTicketsOnSolved($this->fields['id']); } // Clean content to mail //$this->fields["content"] = stripslashes($this->fields["content"]); $donotif = true; } if (isset($this->input['_disablenotif'])) { $donotif = false; } if ($donotif && $CFG_GLPI["use_mailing"]) { $mailtype = "update"; if (isset($this->input["status"]) && $this->input["status"] && in_array("status", $this->updates) && in_array($this->input["status"], $this->getSolvedStatusArray())) { $mailtype = "solved"; } if (isset($this->input["status"]) && $this->input["status"] && in_array("status", $this->updates) && in_array($this->input["status"], $this->getClosedStatusArray())) { $mailtype = "closed"; } // Read again ticket to be sure that all data are up to date $this->getFromDB($this->fields['id']); NotificationEvent::raiseEvent($mailtype, $this); } // inquest created immediatly if delay = O $inquest = new TicketSatisfaction(); $rate = Entity::getUsedConfig('inquest_config', $this->fields['entities_id'], 'inquest_rate'); $delay = Entity::getUsedConfig('inquest_config', $this->fields['entities_id'], 'inquest_delay'); $type = Entity::getUsedConfig('inquest_config', $this->fields['entities_id']); $max_closedate = $this->fields['closedate']; if (in_array("status", $this->updates) && in_array($this->input["status"], $this->getClosedStatusArray()) && $delay == 0 && $rate > 0 && mt_rand(1, 100) <= $rate) { $inquest->add(array('tickets_id' => $this->fields['id'], 'date_begin' => $_SESSION["glpi_currenttime"], 'entities_id' => $this->fields['entities_id'], 'type' => $type, 'max_closedate' => $max_closedate)); } }