static function afterAdd(Group_Ticket $item) { global $DB; //Toolbox::logDebug(__METHOD__, $item); $config = PluginBehaviorsConfig::getInstance(); if ($config->getField('add_notif')) { if ($item->getField('type') == CommonITILActor::ASSIGN) { $ticket = new Ticket(); if ($ticket->getFromDB($item->getField('tickets_id'))) { NotificationEvent::raiseEvent('plugin_behaviors_ticketnewgrp', $ticket); } } } // Check is the connected user is a tech if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('own_ticket', 1)) { return false; // No check } $config = PluginBehaviorsConfig::getInstance(); if ($config->getField('single_tech_mode') != 0 && $item->input['type'] == CommonITILActor::ASSIGN) { $crit = array('tickets_id' => $item->input['tickets_id'], 'type' => CommonITILActor::ASSIGN); foreach ($DB->request('glpi_groups_tickets', $crit) as $data) { if ($data['id'] != $item->getID()) { $gu = new Group_Ticket(); $gu->delete($data); } } if ($config->getField('single_tech_mode') == 2) { foreach ($DB->request('glpi_tickets_users', $crit) as $data) { $gu = new Ticket_User(); $gu->delete($data); } } } }
static function afterUpdate(TicketSatisfaction $ticketsatisfaction) { $config = PluginBehaviorsConfig::getInstance(); $ticket = new Ticket(); if ($config->getField('add_notif') && $ticket->getFromDB($ticketsatisfaction->getField('tickets_id')) && $ticketsatisfaction->input["date_answered"]) { NotificationEvent::raiseEvent('plugin_behaviors_replysurvey', $ticket); } }
static function afterPurge(Document_Item $document_item) { $config = PluginBehaviorsConfig::getInstance(); if ($config->getField('add_notif') && $document_item->fields['itemtype'] == 'Ticket' && isset($_POST['item'])) { // prevent not use in case of purge ticket $ticket = new Ticket(); $ticket->getFromDB($document_item->fields['items_id']); NotificationEvent::raiseEvent('plugin_behaviors_document_itemdel', $ticket); } }
function getGroups($ticket_id, $removeAlreadyAssigned = true) { $groups = $user_groups = $ticket_groups = array(); // get groups for user connected $tmp_user_groups = Group_User::getUserGroups($_SESSION['glpiID']); foreach ($tmp_user_groups as $current_group) { $user_groups[$current_group['id']] = $current_group['id']; $groups[$current_group['id']] = $current_group['id']; } // get groups already assigned in the ticket if ($ticket_id > 0) { $ticket = new Ticket(); $ticket->getFromDB($ticket_id); foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $current_group) { $ticket_groups[$current_group['groups_id']] = $current_group['groups_id']; } } // To do an escalation, the user must be in a group currently assigned to the ticket // or no group is assigned to the ticket // TODO : matching with "view all tickets (yes/no) option in profile user" if (!empty($ticket_groups) && count(array_intersect($ticket_groups, $user_groups)) == 0) { return array(); } //get all group which we can climb if (count($groups) > 0) { $group_group = $this->find("groups_id_source IN (" . implode(", ", $groups) . ")"); foreach ($group_group as $current_group) { $groups[$current_group['groups_id_destination']] = $current_group['groups_id_destination']; } } //remove already assigned groups if (!empty($ticket_groups) && $removeAlreadyAssigned) { $groups = array_diff_assoc($groups, $ticket_groups); } //add name to returned groups and remove non assignable groups $group_obj = new Group(); foreach ($groups as $groups_id => &$groupname) { $group_obj->getFromDB($groups_id); //check if we can assign this group if ($group_obj->fields['is_assign'] == 0) { unset($groups[$groups_id]); continue; } //add name $groupname = $group_obj->fields['name']; } //sort by group name (and keep associative index) asort($groups); return $groups; }
function canCreateItem() { // From Ticket Document Tab => check right to add followup. if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) { $ticket = new Ticket(); if ($ticket->getFromDB($this->fields['tickets_id'])) { return $ticket->canAddFollowups(); } } if (Session::haveRight('document', 'w')) { return parent::canCreateItem(); } return false; }
/** * @since version 0.85 **/ function canCreateItem() { if ($this->canChildItem('canViewItem', 'canView')) { $ticket = new Ticket(); if ($ticket->getFromDB($this->fields['tickets_id'])) { if ($ticket->fields['type'] == Ticket::INCIDENT_TYPE) { return Session::haveRight(self::$rightname, self::CREATEINCIDENT); } if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) { return Session::haveRight(self::$rightname, self::CREATEREQUEST); } } } }
function plugin_init_escalation() { global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['change_profile']['escalation'] = array('PluginEscalationProfile', 'changeprofile'); $PLUGIN_HOOKS['csrf_compliant']['escalation'] = true; // After escalation, if user can't see the ticket (dan't see all ticket right), it redirect to ticket list if (isset($_SERVER['HTTP_REFERER']) and strstr($_SERVER['HTTP_REFERER'], "escalation/front/group_group.form.php")) { if (isset($_GET['id'])) { $ticket = new Ticket(); $ticket->getFromDB($_GET['id']); if (!$ticket->canViewItem()) { // Can't see ticket, go in ticket list $ticket->redirectToList(); } } } if (isset($_SESSION["glpiID"])) { $plugin = new Plugin(); if ($plugin->isActivated('escalation')) { Plugin::registerClass('PluginEscalationProfile', array('addtabon' => array('Profile'))); Plugin::registerClass('PluginEscalationTicketCopy', array('addtabon' => array('Ticket'))); Plugin::registerClass('PluginEscalationConfig', array('addtabon' => array('Entity'))); Plugin::registerClass('PluginEscalationGroup_Group', array('addtabon' => array('Ticket', 'Group'))); $PLUGIN_HOOKS['menu_entry']['escalation'] = false; PluginEscalationGroup_Group::convertNewTicket(); // limit group $peConfig = new PluginEscalationConfig(); if ($peConfig->getValue('limitgroup', $_SESSION['glpidefault_entity']) == '1') { if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id'])) { $group = new Group(); $a_groups = array(); $a_groups[0] = Dropdown::EMPTY_VALUE; foreach ($_SESSION['glpigroups'] as $groups_id) { $group->getFromDB($groups_id); $a_groups[$groups_id] = $group->getName(); } $_SESSION['plugin_escalation_requestergroups'] = $a_groups; register_shutdown_function('plugin_escalation_on_exit'); ob_start(); } } // end limit group } $PLUGIN_HOOKS['pre_item_add']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'selectGroupOnAdd')); $PLUGIN_HOOKS['item_add']['escalation'] = array('Ticket' => array('PluginEscalationTicketCopy', 'finishAdd')); // $PLUGIN_HOOKS['pre_item_update']['escalation'] = array('Ticket' => array('PluginEscalationGroup_Group', 'notMultiple')); } }
/** * @since version 0.85 **/ function canCreateItem() { if ($this->canChildItem('canViewItem', 'canView')) { $ticket = new Ticket(); if ($ticket->getFromDB($this->fields['tickets_id'])) { // No validation for closed tickets if (in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) { return false; } if ($ticket->fields['type'] == Ticket::INCIDENT_TYPE) { return Session::haveRight(self::$rightname, self::CREATEINCIDENT); } if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) { return Session::haveRight(self::$rightname, self::CREATEREQUEST); } } } }
function post_deleteFromDB() { global $CFG_GLPI; $donotif = $CFG_GLPI["use_mailing"]; if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) { $donotif = false; } $t = new Ticket(); if ($t->getFromDB($this->fields['tickets_id'])) { if ($t->fields["suppliers_id_assign"] == 0 && $t->countUsers(Ticket::ASSIGN) == 0 && $t->countGroups(Ticket::ASSIGN) == 0) { $t->update(array('id' => $this->fields['tickets_id'], 'status' => 'new')); } else { $t->updateDateMod($this->fields['tickets_id']); if ($donotif) { NotificationEvent::raiseEvent("update", $t); } } } parent::post_deleteFromDB(); }
function canCreateItem() { if (isset($this->input['itemtype']) && isset($this->input['items_id'])) { if ($item = getItemForItemtype($this->input['itemtype'])) { if ($item->canAddItem('Document')) { return true; } } } // From Ticket Document Tab => check right to add followup. if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) { $ticket = new Ticket(); if ($ticket->getFromDB($this->fields['tickets_id'])) { return $ticket->canAddFollowups(); } } if (Session::haveRight('document', 'w')) { return parent::canCreateItem(); } return false; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'add_task': if (!($task = getItemForItemtype('TicketTask'))) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); break; } $ticket = new Ticket(); $field = $ticket->getForeignKeyField(); $input = $ma->getInput(); foreach ($ids as $id) { if ($item->can($id, READ)) { if ($ticket->getFromDB($item->fields['tickets_id'])) { $input2 = array($field => $item->fields['tickets_id'], 'taskcategories_id' => $input['taskcategories_id'], 'actiontime' => $input['actiontime'], 'content' => $input['content']); if ($task->can(-1, CREATE, $input2)) { if ($task->add($input2)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } } return; case 'solveticket': $input = $ma->getInput(); $ticket = new Ticket(); foreach ($ids as $id) { if ($item->can($id, READ)) { if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) { $toupdate = array(); $toupdate['id'] = $ticket->getID(); $toupdate['solutiontypes_id'] = $input['solutiontypes_id']; $toupdate['solution'] = $input['solution']; if ($ticket->update($toupdate)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT)); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * get SQL condition for filtered dropdown assign groups * @param int $tickets_id * @param int $itilcategories_id * @return string */ static function getSQLCondition($tickets_id, $itilcategories_id) { $ticket = new Ticket(); $group = new Group(); $params = array('entities_id' => $_SESSION['glpiactive_entity'], 'is_recursive' => 1); if (!empty($tickets_id) && $ticket->getFromDB($tickets_id)) { // == UPDATE EXISTING TICKET == $params['entities_id'] = $ticket->fields['entities_id']; $params['condition'] = " AND " . ($ticket->fields['type'] == Ticket::DEMAND_TYPE ? "`is_request`='1'" : "`is_incident`='1'"); } $found_groups = self::getGroupsForCategory($itilcategories_id, $params); $groups_id_toshow = array(); //init if (!empty($found_groups)) { for ($lvl = 1; $lvl <= 4; $lvl++) { if (isset($found_groups['groups_id_level' . $lvl])) { if ($found_groups['groups_id_level' . $lvl] === "all") { foreach (PluginItilcategorygroupsGroup_Level::getAllGroupForALevel($lvl, $params['entities_id']) as $groups_id) { if ($group->getFromDB($groups_id)) { $groups_id_toshow[] = $group->getID(); } } } else { foreach ($found_groups['groups_id_level' . $lvl] as $groups_id) { if (countElementsInTableForEntity("glpi_groups", $ticket->getEntityID(), "`id`='{$groups_id}'") > 0) { $group->getFromDB($groups_id); $groups_id_toshow[] = $group->getID(); } } } } } } $condition = ""; if (count($groups_id_toshow) > 0) { // transform found groups (2 dimensions) in a flat array $groups_id_toshow_flat = array(); array_walk_recursive($groups_id_toshow, function ($v, $k) use(&$groups_id_toshow_flat) { array_push($groups_id_toshow_flat, $v); }); $newarray = implode(", ", $groups_id_toshow_flat); $condition = " id IN ({$newarray})"; } return $condition; }
*/ /** @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"])); Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id')); } else { if (isset($_POST["purge"])) { $fup->check($_POST['id'], PURGE); $fup->delete($_POST, 1); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s purges a followup'), $_SESSION["glpiname"]));
/** * Init cost for creation based on previous cost **/ function initBasedOnPrevious() { $ticket = new Ticket(); if (!isset($this->fields['contracts_id']) || !$ticket->getFromDB($this->fields['contracts_id'])) { return false; } $lastdata = $this->getLastCostForContract($this->fields['contracts_id']); if (isset($lastdata['end_date'])) { $this->fields['begin_date'] = $lastdata['end_date']; } if (isset($lastdata['cost'])) { $this->fields['cost'] = $lastdata['cost']; } if (isset($lastdata['name'])) { $this->fields['name'] = $lastdata['name']; } if (isset($lastdata['budgets_id'])) { $this->fields['budgets_id'] = $lastdata['budgets_id']; } }
/** function buildTicket - Builds,and returns, the major structure of the ticket to be entered. * * @param $i mail ID * @param $options array of possible options * * @return ticket fields array */ function buildTicket($i, $options = array()) { global $CFG_GLPI; $play_rules = isset($options['play_rules']) && $options['play_rules']; $head = $this->getHeaders($i); // Get Header Info Return Array Of Headers // **Key Are (subject,to,toOth,toNameOth,from,fromName) $tkt = array(); $tkt['_blacklisted'] = false; // For RuleTickets $tkt['_mailgate'] = $options['mailgates_id']; // Use mail date if it's defined if ($this->fields['use_mail_date']) { $tkt['date'] = $head['date']; } // Detect if it is a mail reply $glpi_message_match = "/GLPI-([0-9]+)\\.[0-9]+\\.[0-9]+@\\w*/"; // Check if email not send by GLPI : if yes -> blacklist if (!isset($head['message_id']) || preg_match($glpi_message_match, $head['message_id'], $match)) { $tkt['_blacklisted'] = true; return $tkt; } // manage blacklist $blacklisted_emails = Blacklist::getEmails(); // Add name of the mailcollector as blacklisted $blacklisted_emails[] = $this->fields['name']; if (Toolbox::inArrayCaseCompare($head['from'], $blacklisted_emails)) { $tkt['_blacklisted'] = true; return $tkt; } // max size = 0 : no import attachments if ($this->fields['filesize_max'] > 0) { if (is_writable(GLPI_TMP_DIR)) { $tkt['_filename'] = $this->getAttached($i, GLPI_TMP_DIR . "/", $this->fields['filesize_max']); $tkt['_tag'] = $this->tags; } else { //TRANS: %s is a directory Toolbox::logInFile('mailgate', sprintf(__('%s is not writable'), GLPI_TMP_DIR . "/")); } } // Who is the user ? $tkt['_users_id_requester'] = User::getOrImportByEmail($head['from']); $tkt["_users_id_requester_notif"]['use_notification'] = 1; // Set alternative email if user not found / used if anonymous mail creation is enable if (!$tkt['_users_id_requester']) { $tkt["_users_id_requester_notif"]['alternative_email'] = $head['from']; } // Add to and cc as additional observer if user found if (count($head['ccs'])) { foreach ($head['ccs'] as $cc) { if ($cc != $head['from'] && !Toolbox::inArrayCaseCompare($cc, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($cc)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } if (count($head['tos'])) { foreach ($head['tos'] as $to) { if ($to != $head['from'] && !Toolbox::inArrayCaseCompare($to, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($to)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } // Auto_import $tkt['_auto_import'] = 1; // For followup : do not check users_id = login user $tkt['_do_not_check_users_id'] = 1; $body = $this->getBody($i); // Do it before using charset variable $head['subject'] = $this->decodeMimeString($head['subject']); $tkt['_head'] = $head; if (!empty($this->charset) && !$this->body_converted) { $body = Toolbox::encodeInUtf8($body, $this->charset); $this->body_converted = true; } if (!Toolbox::seems_utf8($body)) { $tkt['content'] = Toolbox::encodeInUtf8($body); } else { $tkt['content'] = $body; } // See In-Reply-To field if (isset($head['in_reply_to'])) { if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in References if (!isset($tkt['tickets_id']) && isset($head['references'])) { if (preg_match($glpi_message_match, $head['references'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in title if (!isset($tkt['tickets_id']) && preg_match('/\\[.+#(\\d+)\\]/', $head['subject'], $match)) { $tkt['tickets_id'] = intval($match[1]); } $is_html = false; //If files are present and content is html if (isset($this->files) && count($this->files) && $tkt['content'] != strip_tags($tkt['content']) && !isset($tkt['tickets_id'])) { $is_html = true; $tkt['content'] = Ticket::convertContentForTicket($tkt['content'], array_merge($this->files, $this->altfiles), $this->tags); } $tkt['content'] = $this->cleanMailContent($tkt['content']); if ($is_html && !isset($tkt['tickets_id'])) { $tkt['content'] = nl2br($tkt['content']); } $tkt['_supplier_email'] = false; // Found ticket link if (isset($tkt['tickets_id'])) { // it's a reply to a previous ticket $job = new Ticket(); $tu = new Ticket_User(); $st = new Supplier_Ticket(); // Check if ticket exists and users_id exists in GLPI /// TODO check if users_id have right to add a followup to the ticket if ($job->getFromDB($tkt['tickets_id']) && $job->fields['status'] != CommonITILObject::CLOSED && ($CFG_GLPI['use_anonymous_followups'] || $tkt['_users_id_requester'] > 0 || $tu->isAlternateEmailForITILObject($tkt['tickets_id'], $head['from']) || ($tkt['_supplier_email'] = $st->isSupplierEmail($tkt['tickets_id'], $head['from'])))) { if ($tkt['_supplier_email']) { $tkt['content'] = sprintf(__('From %s'), $head['from']) . "\n\n" . $tkt['content']; } $content = explode("\n", $tkt['content']); $tkt['content'] = ""; $to_keep = array(); // Move requester to author of followup : $tkt['users_id'] = $tkt['_users_id_requester']; $begin_strip = -1; $end_strip = -1; $begin_match = "/" . NotificationTargetTicket::HEADERTAG . ".*" . NotificationTargetTicket::HEADERTAG . "/"; $end_match = "/" . NotificationTargetTicket::FOOTERTAG . ".*" . NotificationTargetTicket::FOOTERTAG . "/"; foreach ($content as $ID => $val) { // Get first tag for begin if ($begin_strip < 0) { if (preg_match($begin_match, $val)) { $begin_strip = $ID; } } // Get last tag for end if ($begin_strip >= 0) { if (preg_match($end_match, $val)) { $end_strip = $ID; continue; } } } if ($begin_strip >= 0) { // Clean first and last lines $content[$begin_strip] = preg_replace($begin_match, '', $content[$begin_strip]); } if ($end_strip >= 0) { // Clean first and last lines $content[$end_strip] = preg_replace($end_match, '', $content[$end_strip]); } if ($begin_strip >= 0) { $length = count($content); // Use end strip if set if ($end_strip >= 0 && $end_strip < $length) { $length = $end_strip; } for ($i = $begin_strip + 1; $i < $length; $i++) { unset($content[$i]); } } $to_keep = array(); // Aditional clean for thunderbird foreach ($content as $ID => $val) { if (!isset($val[0]) || $val[0] != '>') { $to_keep[$ID] = $ID; } } $tkt['content'] = ""; foreach ($to_keep as $ID) { $tkt['content'] .= $content[$ID] . "\n"; } // Do not play rules for followups : WRONG : play rules only for refuse options //$play_rules = false; } else { // => to handle link in Ticket->post_addItem() $tkt['_linkedto'] = $tkt['tickets_id']; unset($tkt['tickets_id']); } } // Add message from getAttached if ($this->addtobody) { $tkt['content'] .= $this->addtobody; } $tkt['name'] = $this->textCleaner($head['subject']); if (!isset($tkt['tickets_id'])) { // Which entity ? //$tkt['entities_id']=$this->fields['entities_id']; //$tkt['Subject']= $head['subject']; // not use for the moment // Medium $tkt['urgency'] = "3"; // No hardware associated $tkt['itemtype'] = ""; // Mail request type } else { // Reopen if needed $tkt['add_reopen'] = 1; } $tkt['requesttypes_id'] = RequestType::getDefault('mail'); if ($play_rules) { $rule_options['ticket'] = $tkt; $rule_options['headers'] = $head; $rule_options['mailcollector'] = $options['mailgates_id']; $rule_options['_users_id_requester'] = $tkt['_users_id_requester']; $rulecollection = new RuleMailCollectorCollection(); $output = $rulecollection->processAllRules(array(), array(), $rule_options); // New ticket : compute all if (!isset($tkt['tickets_id'])) { foreach ($output as $key => $value) { $tkt[$key] = $value; } } else { // Followup only copy refuse data $tobecopied = array('_refuse_email_no_response', '_refuse_email_with_response'); foreach ($tobecopied as $val) { if (isset($output[$val])) { $tkt[$val] = $output[$val]; } } } } $tkt = Toolbox::addslashes_deep($tkt); return $tkt; }
/** * Is the current user have right to create the current task ? * * @return boolean **/ function canCreateItem() { if (!parent::canReadITILItem()) { return false; } $ticket = new Ticket(); if ($ticket->getFromDB($this->fields['tickets_id'])) { return Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']); } return false; }
/** function buildTicket - Builds,and returns, the major structure of the ticket to be entered. * * @param $i mail ID * @param $options array options * * @return ticket fields array */ function buildTicket($i, $options = array()) { $play_rules = isset($options['play_rules']) && $options['play_rules']; $head = $this->getHeaders($i); // Get Header Info Return Array Of Headers // **Key Are (subject,to,toOth,toNameOth,from,fromName) $tkt = array(); $tkt['_blacklisted'] = false; // Detect if it is a mail reply $glpi_message_match = "/GLPI-([0-9]+)\\.[0-9]+\\.[0-9]+@\\w*/"; // Check if email not send by GLPI : if yes -> blacklist if (preg_match($glpi_message_match, $head['message_id'], $match)) { $tkt['_blacklisted'] = true; return $tkt; } // max size = 0 : no import attachments if ($this->fields['filesize_max'] > 0) { if (is_writable(GLPI_DOC_DIR . "/_tmp/")) { $_FILES = $this->getAttached($i, GLPI_DOC_DIR . "/_tmp/", $this->fields['filesize_max']); } else { logInFile('mailgate', GLPI_DOC_DIR . "/_tmp/ is not writable"); } } // Who is the user ? $tkt['_users_id_requester'] = User::getOrImportByEmail($head['from']); $tkt["_users_id_requester_notif"]['use_notification'] = 1; if (!$tkt['_users_id_requester']) { $tkt["_users_id_requester_notif"]['alternative_email'] = $head['from']; } // Add to and cc as additional observer if user found if (count($head['ccs'])) { foreach ($head['ccs'] as $cc) { if ($cc != $head['from'] && strcasecmp($cc, $this->fields['name']) && ($tmp = User::getOrImportByEmail($cc)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } if (count($head['tos'])) { foreach ($head['tos'] as $to) { if ($to != $head['from'] && strcasecmp($to, $this->fields['name']) && ($tmp = User::getOrImportByEmail($to, false)) > 0) { $tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1); } } } // Auto_import $tkt['_auto_import'] = 1; // For followup : do not check users_id = login user $tkt['_do_not_check_users_id'] = 1; $body = $this->getBody($i); // Do it before using charset variable $head['subject'] = $this->decodeMimeString($head['subject']); $tkt['_head'] = $head; if (!empty($this->charset) && !$this->body_converted) { $body = encodeInUtf8($body, $this->charset); $this->body_converted = true; } if (!seems_utf8($body)) { $tkt['content'] = encodeInUtf8($body); } else { $tkt['content'] = $body; } // Add message from getAttached if ($this->addtobody) { $tkt['content'] .= $this->addtobody; } // See In-Reply-To field if (isset($head['in_reply_to'])) { if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in References if (!isset($tkt['tickets_id']) && isset($head['references'])) { if (preg_match($glpi_message_match, $head['references'], $match)) { $tkt['tickets_id'] = intval($match[1]); } } // See in title if (!isset($tkt['tickets_id']) && preg_match('/\\[GLPI #(\\d+)\\]/', $head['subject'], $match)) { $tkt['tickets_id'] = intval($match[1]); } // Found ticket link if (isset($tkt['tickets_id'])) { // it's a reply to a previous ticket $job = new Ticket(); // Check if ticket exists and users_id exists in GLPI /// TODO check if users_id have right to add a followup to the ticket if ($job->getFromDB($tkt['tickets_id']) && $job->fields['status'] != 'closed' && ($tkt['_users_id_requester'] > 0 || Ticket_User::isAlternateEmailForTicket($tkt['tickets_id'], $head['from']))) { $content = explode("\n", $tkt['content']); $tkt['content'] = ""; $first_comment = true; $to_keep = array(); foreach ($content as $ID => $val) { if (isset($val[0]) && $val[0] == '>') { // Delete line at the top of the first comment if ($first_comment) { $first_comment = false; if (isset($to_keep[$ID - 1])) { unset($to_keep[$ID - 1]); } } } else { $to_keep[$ID] = $ID; } } foreach ($to_keep as $ID) { $tkt['content'] .= $content[$ID] . "\n"; } // Do not play rules for followups : WRONG : play rules only for refuse options //$play_rules = false; } else { // => to handle link in Ticket->post_addItem() $tkt['_linkedto'] = $tkt['tickets_id']; unset($tkt['tickets_id']); } } $tkt['name'] = $this->textCleaner($head['subject']); if (!isset($tkt['tickets_id'])) { // Which entity ? //$tkt['entities_id']=$this->fields['entities_id']; //$tkt['Subject']= $head['subject']; // not use for the moment // Medium $tkt['urgency'] = "3"; // No hardware associated $tkt['itemtype'] = ""; // Mail request type } else { // Reopen if needed $tkt['add_reopen'] = 1; } $tkt['requesttypes_id'] = RequestType::getDefault('mail'); $tkt['content'] = clean_cross_side_scripting_deep(html_clean($tkt['content'])); if ($play_rules) { $rule_options['ticket'] = $tkt; $rule_options['headers'] = $head; $rule_options['mailcollector'] = $options['mailgates_id']; $rule_options['_users_id_requester'] = $tkt['_users_id_requester']; $rulecollection = new RuleMailCollectorCollection(); $output = $rulecollection->processAllRules(array(), array(), $rule_options); // New ticket : compute all if (!isset($tkt['tickets_id'])) { foreach ($output as $key => $value) { $tkt[$key] = $value; } } else { // Followup only copy refuse data $tobecopied = array('_refuse_email_no_response', '_refuse_email_with_response'); foreach ($tobecopied as $val) { if (isset($output[$val])) { $tkt[$val] = $output[$val]; } } } } $tkt = addslashes_deep($tkt); return $tkt; }
function post_addItem() { global $CFG_GLPI; $t = new Ticket(); $t->updateDateMod($this->fields['tickets_id_1']); $t->updateDateMod($this->fields['tickets_id_2']); parent::post_addItem(); $donotif = $CFG_GLPI["use_mailing"]; if ($donotif) { $t->getFromDB($this->fields['tickets_id_1']); NotificationEvent::raiseEvent("update", $t); $t->getFromDB($this->fields['tickets_id_2']); NotificationEvent::raiseEvent("update", $t); } }
/** * @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; }
/** * Print the validation form * * @param $ID integer ID of the item * @param $options array options used * **/ function showForm($ID, $options = array()) { global $LANG; $this->check($ID, 'w'); if ($ID > 0) { $tickets_id = $this->fields["tickets_id"]; } else { $tickets_id = $options['ticket']->fields["id"]; } $ticket = new Ticket(); if (!$ticket->getFromDB($tickets_id)) { return false; } // No update validation is answer set $validation_admin = $this->fields["users_id"] == getLoginUserID() && $this->canCreate() && $this->fields['status'] == 'waiting'; $validator = $this->fields["users_id_validate"] == getLoginUserID(); $options['colspan'] = 1; $this->showFormHeader($options); if ($validation_admin) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][18] . " : </td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='" . $ticket->fields['id'] . "'>"; echo "<input type='hidden' name='entities_id' value='" . $ticket->fields['entities_id'] . "'>"; echo getUserName($this->fields["users_id"]); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['validation'][21] . " : </td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='" . $ticket->fields['id'] . "'>"; echo "<input type='hidden' name='entities_id' value='" . $ticket->fields['entities_id'] . "'>"; User::dropdown(array('name' => "users_id_validate", 'entity' => $ticket->fields['entities_id'], 'right' => 'validate_ticket', 'value' => $this->fields["users_id_validate"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td><textarea cols='60' rows='3' name='comment_submission'>" . $this->fields["comment_submission"] . "</textarea></td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][18] . " : </td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['validation'][21] . " : </td>"; echo "<td>" . getUserName($this->fields["users_id_validate"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td>" . $this->fields["comment_submission"] . "</td></tr>"; } if ($ID > 0) { echo "<tr class='tab_bg_2'><td colspan='2'> </td></tr>"; if ($validator) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][28] . " : </td>"; echo "<td>"; self::dropdownStatus("status", array('value' => $this->fields["status"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][6] . " (" . $LANG['validation'][16] . ") : </td>"; echo "<td><textarea cols='60' rows='3' name='comment_validation'>" . $this->fields["comment_validation"] . "</textarea>"; echo "</td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][28] . " : </td>"; echo "<td>" . self::getStatus($this->fields["status"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td>" . $this->fields["comment_validation"] . "</td></tr>"; } } $this->showFormButtons($options); return true; }
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item, $tree = false) { global $DB, $CFG_GLPI; $ID = $item->getField('id'); $type = $item->getType(); if (!Session::haveRight("show_all_ticket", "1")) { return; } switch ($item->getType()) { case 'User': $restrict = "(`glpi_tickets_users`.`users_id` = '" . $item->getID() . "'\n AND `glpi_tickets_users`.`type` = " . CommonITILActor::REQUESTER . ")"; $order = '`glpi_tickets`.`date_mod` DESC'; break; case 'SLA': $restrict = "(`slas_id` = '" . $item->getID() . "')"; $order = '`glpi_tickets`.`due_date` DESC'; break; case 'Supplier': $restrict = "(`glpi_suppliers_tickets`.`suppliers_id` = '" . $item->getID() . "'\n AND `glpi_suppliers_tickets`.`type` = " . CommonITILActor::ASSIGN . ")"; $order = '`glpi_tickets`.`date_mod` DESC'; break; case 'Group': if ($tree) { $restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")"; } else { $restrict = "='" . $item->getID() . "'"; } $restrict = "(`glpi_groups_tickets`.`groups_id` {$restrict}\n AND `glpi_groups_tickets`.`type` = " . CommonITILActor::REQUESTER . ")"; $order = '`glpi_tickets`.`date_mod` DESC'; break; default: $restrict = "(`items_id` = '" . $item->getID() . "' AND `itemtype` = '{$type}')"; $order = '`glpi_tickets`.`date_mod` DESC'; } $query = "SELECT " . Ticket::getCommonSelect() . "\n FROM glpi_tickets " . Ticket::getCommonLeftJoin() . "\n WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n ORDER BY {$order}\n LIMIT " . intval($_SESSION['glpilist_limit']); $result = $DB->query($query); $number = $DB->numrows($result); $pdf->setColumnsSize(100); if (!$number) { $pdf->displayTitle('<b>' . __('Last tickets') . '</b>'); } else { $pdf->displayTitle("<b>" . sprintf(__('Last %d ticket') . "</b>", $number)); $job = new Ticket(); while ($data = $DB->fetch_assoc($result)) { if (!$job->getFromDB($data["id"])) { continue; } $pdf->setColumnsAlign('center'); $col = '<b><i>ID ' . $job->fields["id"] . '</i></b>, ' . sprintf(__('%1$s: %2$s'), __('Status'), Ticket::getStatus($job->fields["status"])); if (count($_SESSION["glpiactiveentities"]) > 1) { if ($job->fields['entities_id'] == 0) { $col = sprintf(__('%1$s (%2$s)'), $col, __('Root entity')); } else { $col = sprintf(__('%1$s (%2$s)'), $col, Dropdown::getDropdownName("glpi_entities", $job->fields['entities_id'])); } } $pdf->displayLine($col); $pdf->setColumnsAlign('left'); $col = '<b><i>' . sprintf(__('Opened on %s') . '</i></b>', Html::convDateTime($job->fields['date'])); if ($job->fields['begin_waiting_date']) { $col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Put on hold on %s') . '</i></b>', Html::convDateTime($job->fields['begin_waiting_date']))); } if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) { $col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Solved on %s') . '</i></b>', Html::convDateTime($job->fields['solvedate']))); } if (in_array($job->fields["status"], $job->getClosedStatusArray())) { $col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('Closed on %s') . '</i></b>', Html::convDateTime($job->fields['closedate']))); } if ($job->fields['due_date']) { $col = sprintf(__('%1$s, %2$s'), $col, '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', __('Due date'), Html::convDateTime($job->fields['due_date']))); } $pdf->displayLine($col); $col = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Priority') . '</i></b>', Ticket::getPriorityName($job->fields["priority"])); if ($job->fields["itilcategories_id"]) { $col = sprintf(__('%1$s - %2$s'), $col, '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', __('Category'), Dropdown::getDropdownName('glpi_itilcategories', $job->fields["itilcategories_id"]))); } $pdf->displayLine($col); $col = ''; $users = $job->getUsers(CommonITILActor::REQUESTER); if (count($users)) { foreach ($users as $d) { if (empty($col)) { $col = getUserName($d['users_id']); } else { $col = sprintf(__('%1$s, %2$s'), $col, getUserName($d['users_id'])); } } } $grps = $job->getGroups(CommonITILActor::REQUESTER); if (count($grps)) { if (empty($col)) { $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>'); } else { $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>'); } $first = true; foreach ($grps as $d) { if ($first) { $col = sprintf(__('%1$s %2$s'), $col, Dropdown::getDropdownName("glpi_groups", $d['groups_id'])); } else { $col = sprintf(__('%1$s, %2$s'), $col, Dropdown::getDropdownName("glpi_groups", $d['groups_id'])); } $first = false; } } if ($col) { $texte = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Requester') . '</i></b>', ''); $pdf->displayText($texte, $col, 1); } $col = ''; $users = $job->getUsers(CommonITILActor::ASSIGN); if (count($users)) { foreach ($users as $d) { if (empty($col)) { $col = getUserName($d['users_id']); } else { $col = sprintf(__('%1$s, %2$s'), $col, getUserName($d['users_id'])); } } } $grps = $job->getGroups(CommonITILActor::ASSIGN); if (count($grps)) { if (empty($col)) { $col = sprintf(__('%1$s %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>'); } else { $col = sprintf(__('%1$s - %2$s'), $col, _n('Group', 'Groups', 2) . ' </i></b>'); } $first = true; foreach ($grps as $d) { if ($first) { $col = sprintf(__('%1$s %2$s'), $col, Dropdown::getDropdownName("glpi_groups", $d['groups_id'])); } else { $col = sprintf(__('%1$s, %2$s'), $col, Dropdown::getDropdownName("glpi_groups", $d['groups_id'])); } $first = false; } } if ($col) { $texte = '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', 'Assigned to', ''); $pdf->displayText($texte, $col, 1); } $texte = '<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', 'Title', ''); $pdf->displayText($texte, $job->fields["name"], 1); } } $pdf->displaySpace(); }
// ---------------------------------------------------------------------- // Original Author of file: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_POST["id"])) { exit; } if (!isset($_REQUEST['glpi_tab'])) { exit; } $ticket = new Ticket(); if ($_POST["id"] > 0 && $ticket->getFromDB($_POST["id"])) { switch ($_REQUEST['glpi_tab']) { case -1: $fup = new TicketFollowup(); $fup->showSummary($ticket); $validation = new Ticketvalidation(); $validation->showSummary($ticket); $task = new TicketTask(); $task->showSummary($ticket); $ticket->showSolutionForm(); if ($ticket->canApprove()) { $fup->showApprobationForm($ticket); } $ticket->showCost($_POST['target']); $ticket->showStats(); Document::showAssociated($ticket);
/** * Print the validation form * * @param $ID integer ID of the item * @param $options array options used * **/ function showForm($ID, $options = array()) { if ($ID > 0) { $this->check($ID, 'w'); } else { $options['tickets_id'] = $options['parent']->fields["id"]; $this->check(-1, 'w', $options); } // No update validation is answer set $validation_admin = $this->fields["users_id"] == Session::getLoginUserID() && static::canCreate() && $this->fields['status'] == 'waiting'; $validator = $this->fields["users_id_validate"] == Session::getLoginUserID(); $options['colspan'] = 1; $this->showFormHeader($options); if ($validation_admin) { $ticket = new Ticket(); $ticket->getFromDB($this->fields['tickets_id']); $validation_right = ''; if ($ticket->fields['type'] == Ticket::DEMAND_TYPE) { $validation_right = 'validate_request'; } else { $validation_right = 'validate_incident'; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Approval requester') . "</td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='" . $this->fields['tickets_id'] . "'>"; echo getUserName($this->fields["users_id"]); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Approver') . "</td>"; echo "<td>"; User::dropdown(array('name' => "users_id_validate", 'entity' => $this->getEntityID(), 'right' => $validation_right, 'value' => $this->fields["users_id_validate"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Comments') . "</td>"; echo "<td><textarea cols='60' rows='3' name='comment_submission'>" . $this->fields["comment_submission"] . "</textarea></td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Approval requester') . "</td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Approver') . "</td>"; echo "<td>" . getUserName($this->fields["users_id_validate"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Comments') . "</td>"; echo "<td>" . $this->fields["comment_submission"] . "</td></tr>"; } if ($ID > 0) { echo "<tr class='tab_bg_2'><td colspan='2'> </td></tr>"; if ($validator) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Status of the approval request') . "</td>"; echo "<td>"; self::dropdownStatus("status", array('value' => $this->fields["status"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Approval comments') . "<br>(" . __('Optional when approved') . ")</td>"; echo "<td><textarea cols='60' rows='3' name='comment_validation'>" . $this->fields["comment_validation"] . "</textarea>"; echo "</td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Status of the approval request') . "</td>"; echo "<td>" . self::getStatus($this->fields["status"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Comments') . "</td>"; echo "<td>" . $this->fields["comment_validation"] . "</td></tr>"; } } $this->showFormButtons($options); return true; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'solveticket': $input = $ma->getInput(); $ticket = new Ticket(); foreach ($ids as $id) { if ($item->can($id, READ)) { if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) { $toupdate = array(); $toupdate['id'] = $ticket->getID(); $toupdate['solutiontypes_id'] = $input['solutiontypes_id']; $toupdate['solution'] = $input['solution']; if ($ticket->update($toupdate)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT)); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
function post_updateItem($history = 1) { global $CFG_GLPI; $job = new Ticket(); $mailsend = false; if ($job->getFromDB($this->fields["tickets_id"])) { $job->updateDateMod($this->fields["tickets_id"]); if (count($this->updates)) { if ($CFG_GLPI["use_mailing"] && (in_array("content", $this->updates) || isset($this->input['_need_send_mail']))) { $options = array('followup_id' => $this->fields["id"], 'is_private' => $this->fields['is_private']); NotificationEvent::raiseEvent("update_followup", $job, $options); } } // Add log entry in the ticket $changes[0] = 0; $changes[1] = ''; $changes[2] = $this->fields['id']; Log::history($this->getField('tickets_id'), 'Ticket', $changes, $this->getType(), Log::HISTORY_UPDATE_SUBITEM); } }
/** * Do a specific SLAlevel for a ticket * * @param $data array data of an entry of slalevels_tickets * * @return nothing **/ static function doLevelForTicket(array $data) { $ticket = new Ticket(); $slalevelticket = new self(); // existing ticket and not deleted if ($ticket->getFromDB($data['tickets_id']) && !$ticket->isDeleted()) { // search all actors of a ticket foreach ($ticket->getUsers(CommonITILActor::REQUESTER) as $user) { $ticket->fields['_users_id_requester'][] = $user['users_id']; } foreach ($ticket->getUsers(CommonITILActor::ASSIGN) as $user) { $ticket->fields['_users_id_assign'][] = $user['users_id']; } foreach ($ticket->getUsers(CommonITILActor::OBSERVER) as $user) { $ticket->fields['_users_id_observer'][] = $user['users_id']; } foreach ($ticket->getGroups(CommonITILActor::REQUESTER) as $group) { $ticket->fields['_groups_id_requester'][] = $group['groups_id']; } foreach ($ticket->getGroups(CommonITILActor::ASSIGN) as $group) { $ticket->fields['_groups_id_assign'][] = $group['groups_id']; } foreach ($ticket->getGroups(CommonITILActor::OBSERVER) as $groups) { $ticket->fields['_groups_id_observer'][] = $group['groups_id']; } foreach ($ticket->getSuppliers(CommonITILActor::ASSIGN) as $supplier) { $ticket->fields['_suppliers_id_assign'][] = $supplier['suppliers_id']; } $slalevel = new SlaLevel(); $sla = new SLA(); // Check if sla datas are OK if ($ticket->fields['slas_id'] > 0 && $ticket->fields['slalevels_id'] == $data['slalevels_id']) { if ($ticket->fields['status'] == CommonITILObject::CLOSED) { // Drop line when status is closed $slalevelticket->delete(array('id' => $data['id'])); } else { if ($ticket->fields['status'] != CommonITILObject::SOLVED) { // If status = solved : keep the line in case of solution not validated $input['id'] = $ticket->getID(); $input['_auto_update'] = true; if ($slalevel->getRuleWithCriteriasAndActions($data['slalevels_id'], 1, 1) && $sla->getFromDB($ticket->fields['slas_id'])) { $doit = true; if (count($slalevel->criterias)) { $doit = $slalevel->checkCriterias($ticket->fields); } // Process rules if ($doit) { $input = $slalevel->executeActions($input, array()); } } // Put next level in todo list $next = $slalevel->getNextSlaLevel($ticket->fields['slas_id'], $ticket->fields['slalevels_id']); $input['slalevels_id'] = $next; $ticket->update($input); $sla->addLevelToDo($ticket); // Action done : drop the line $slalevelticket->delete(array('id' => $data['id'])); } } } else { // Drop line $slalevelticket->delete(array('id' => $data['id'])); } } else { // Drop line $slalevelticket->delete(array('id' => $data['id'])); } }
function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; if (!static::canView()) { return false; } // In percent $colsize1 = '13'; $colsize2 = '37'; $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1); // Set default options if (!$ID) { $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0); foreach ($values as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } if (isset($options['tickets_id'])) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $options['content'] = $ticket->getField('content'); $options['name'] = $ticket->getField('name'); $options['impact'] = $ticket->getField('impact'); $options['urgency'] = $ticket->getField('urgency'); $options['priority'] = $ticket->getField('priority'); $options['itilcategories_id'] = $ticket->getField('itilcategories_id'); $options['due_date'] = $ticket->getField('due_date'); } } if (isset($options['problems_id'])) { $problem = new Problem(); if ($problem->getFromDB($options['problems_id'])) { $options['content'] = $problem->getField('content'); $options['name'] = $problem->getField('name'); $options['impact'] = $problem->getField('impact'); $options['urgency'] = $problem->getField('urgency'); $options['priority'] = $problem->getField('priority'); $options['itilcategories_id'] = $problem->getField('itilcategories_id'); $options['due_date'] = $problem->getField('due_date'); } } } if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE, $options); } $showuserlink = 0; if (User::canView()) { $showuserlink = 1; } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>"; echo "<td class='left' width='{$colsize2}%'>"; if (isset($options['tickets_id'])) { echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>"; } if (isset($options['problems_id'])) { echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>"; } $date = $this->fields["date"]; if (!$ID) { $date = date("Y-m-d H:i:s"); } Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>"; echo "<td width='{$colsize2}%' class='left'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1)); echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>"; User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<th>" . __('Last update') . "</th>"; echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n"; if ($this->fields['users_id_lastupdater'] > 0) { printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td></tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Date of solving') . "</th>"; echo "<td>"; Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th>" . __('Closing date') . "</th>"; echo "<td>"; Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Status') . "</th>"; echo "<td width='{$colsize2}%'>"; self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); ChangeValidation::alertValidation($this, 'status'); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>"; echo "<td width='{$colsize2}%'>"; // Only change during creation OR when allowed to change priority OR when user is the creator $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Category') . "</th>"; echo "<td >"; $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_change`='1'"); ITILCategory::dropdown($opt); echo "</td>"; echo "<th>" . __('Impact') . "</th>"; echo "<td>"; $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Total duration') . "</th>"; echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>"; echo "<th class='left'>" . __('Priority') . "</th>"; echo "<td>"; $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idajax = 'change_priority_' . mt_rand(); echo " <span id='{$idajax}' style='display:none'></span>"; $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => 'dropdown_priority' . $idpriority); Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); echo "</td>"; echo "</tr>"; echo "</table>"; $this->showActorsPartForm($ID, $options); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Title') . "</th>"; echo "<td colspan='3'>"; echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Description') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<textarea id='content{$rand}' name='content' cols='90' rows='6'>" . Html::clean(Html::entity_decode_deep($this->fields["content"])) . "</textarea>"; echo "</td>"; echo "</tr>"; $options['colspan'] = 3; $this->showFormButtons($options); return true; }
/** * @param $ID * @param $options array **/ function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; if (!static::canView()) { return false; } // In percent $colsize1 = '13'; $colsize2 = '37'; // Set default options if (!$ID) { $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'name' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'itilcategories_id' => 0); foreach ($values as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } if (isset($options['tickets_id'])) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $options['content'] = $ticket->getField('content'); $options['name'] = $ticket->getField('name'); $options['impact'] = $ticket->getField('impact'); $options['urgency'] = $ticket->getField('urgency'); $options['priority'] = $ticket->getField('priority'); $options['itilcategories_id'] = $ticket->getField('itilcategories_id'); } } } $this->initForm($ID, $options); $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>"; echo "<td class='left' width='{$colsize2}%'>"; if (isset($options['tickets_id'])) { echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>"; } $date = $this->fields["date"]; if (!$ID) { $date = date("Y-m-d H:i:s"); } Html::showDateTimeFormItem("date", $date, 1, false); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>"; echo "<td width='{$colsize2}%' class='left'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true); echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>"; User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<th>" . __('Last update') . "</th>"; echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n"; if ($this->fields['users_id_lastupdater'] > 0) { printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td></tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Date of solving') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th>" . __('Closing date') . "</th>"; echo "<td>"; Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Status') . "</th>"; echo "<td width='{$colsize2}%'>"; self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>"; echo "<td width='{$colsize2}%'>"; // Only change during creation OR when allowed to change priority OR when user is the creator $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Category') . "</th>"; echo "<td >"; $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_problem`='1'"); ITILCategory::dropdown($opt); echo "</td>"; echo "<th>" . __('Impact') . "</th>"; echo "<td>"; $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Total duration') . "</th>"; echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>"; echo "<th class='left'>" . __('Priority') . "</th>"; echo "<td>"; $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idajax = 'change_priority_' . mt_rand(); echo " <span id='{$idajax}' style='display:none'></span>"; $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); echo "</td>"; echo "</tr>"; echo "</table>"; $this->showActorsPartForm($ID, $options); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Title') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 110, 'name' => 'name', 'data' => rawurlencode($this->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Description') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 110, 'name' => 'content', 'data' => rawurlencode($this->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($this->fields["content"])) { echo nl2br($this->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th colspan='2' width='" . ($colsize1 + $colsize2) . "%'>"; $docnb = Document_Item::countForItem($this); echo "<a href=\"" . $this->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; echo "<td colspan='2'></td>"; echo "</tr>"; } $options['colspan'] = 2; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * @param $output * @param $params **/ function executeActions($output, $params) { if (count($this->actions)) { foreach ($this->actions as $action) { switch ($action->fields["action_type"]) { case "send": $ticket = new Ticket(); if ($ticket->getFromDB($output['id'])) { NotificationEvent::raiseEvent('recall', $ticket); } break; case "add_validation": if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) { $output['_add_validation'] = array($output['_add_validation']); } switch ($action->fields['field']) { case 'users_id_validate_requester_supervisor': $output['_add_validation'][] = 'requester_supervisor'; break; case 'users_id_validate_assign_supervisor': $output['_add_validation'][] = 'assign_supervisor'; break; case 'groups_id_validate': $output['_add_validation']['group'][] = $action->fields["value"]; break; case 'users_id_validate': $output['_add_validation'][] = $action->fields["value"]; break; case 'validation_percent': $output[$action->fields["field"]] = $action->fields["value"]; break; default: $output['_add_validation'][] = $action->fields["value"]; break; } break; case "assign": $output[$action->fields["field"]] = $action->fields["value"]; // Special case of users_id_requester if ($action->fields["field"] === '_users_id_requester') { // Add groups of requester if (!isset($output['_groups_id_of_requester'])) { $output['_groups_id_of_requester'] = array(); } foreach (Group_User::getUserGroups($action->fields["value"]) as $g) { $output['_groups_id_of_requester'][$g['id']] = $g['id']; } } break; case "append": $actions = $this->getActions(); $value = $action->fields["value"]; if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) { $value = $actions[$action->fields["field"]]["appendtoarray"]; $value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"]; } $output[$actions[$action->fields["field"]]["appendto"]][] = $value; // Special case of users_id_requester if ($action->fields["field"] === '_users_id_requester') { // Add groups of requester if (!isset($output['_groups_id_of_requester'])) { $output['_groups_id_of_requester'] = array(); } foreach (Group_User::getUserGroups($action->fields["value"]) as $g) { $output['_groups_id_of_requester'][$g['id']] = $g['id']; } } break; case 'fromuser': if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) { $output['locations_id'] = $output['users_locations']; } break; case 'fromitem': if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) { $output['locations_id'] = $output['items_locations']; } if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) { $output['groups_id'] = $output['items_groups']; } break; case 'compute': // Value could be not set (from test) $urgency = isset($output['urgency']) ? $output['urgency'] : 3; $impact = isset($output['impact']) ? $output['impact'] : 3; // Apply priority_matrix from config $output['priority'] = Ticket::computePriority($urgency, $impact); break; case "affectbyip": case "affectbyfqdn": case "affectbymac": if (!isset($output["entities_id"])) { $output["entities_id"] = $params["entities_id"]; } if (isset($this->regex_results[0])) { $regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]); } else { $regexvalue = $action->fields["value"]; } switch ($action->fields["action_type"]) { case "affectbyip": $result = IPAddress::getUniqueItemByIPAddress($regexvalue, $output["entities_id"]); break; case "affectbyfqdn": $result = FQDNLabel::getUniqueItemByFQDN($regexvalue, $output["entities_id"]); break; case "affectbymac": $result = NetworkPortInstantiation::getUniqueItemByMac($regexvalue, $output["entities_id"]); break; default: $result = array(); } if (!empty($result)) { $output["items_id"][$result["itemtype"]][] = $result["id"]; } break; } } } return $output; }
<?php $AJAX_INCLUDE = 1; include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); $ticket_id = isset($_REQUEST['ticket_id']) ? $_REQUEST['ticket_id'] : 0; $PluginEscaladeGroup_Group = new PluginEscaladeGroup_Group(); $groups_id_filtred = $PluginEscaladeGroup_Group->getGroups($ticket_id); if (count($groups_id_filtred) > 0) { $myarray = array(); foreach ($groups_id_filtred as $groups_id => $groups_name) { $myarray[] = $groups_id; } $newarray = implode(", ", $myarray); $condition = " id IN ({$newarray})"; } else { $condition = "1=0"; } $rand = mt_rand(); $_SESSION['glpicondition'][$rand] = $condition; $_GET["condition"] = $rand; if (!isset($_GET["entity_restrict"]) && $ticket_id) { $ticket = new Ticket(); $ticket->getFromDB($ticket_id); $_GET["entity_restrict"] = $ticket->fields['entities_id']; } require "../../../ajax/getDropdownValue.php";