/** * form for satisfaction * * @param $ticket Object : the ticket **/ function showSatisfactionForm($ticket) { global $LANG; $tid = $ticket->fields['id']; $options = array(); $options['colspan'] = 1; // for external inquest => link if ($this->fields["type"] == 2) { $url = EntityData::generateLinkSatisfaction($ticket); echo "<div class='center spaced'>" . "<a href='{$url}'>" . $LANG['satisfaction'][10] . "</a><br>({$url})</div>"; // for internal inquest => form } else { $this->showFormHeader($options); // Set default satisfaction to 3 if not set if (is_null($this->fields["satisfaction"])) { $this->fields["satisfaction"] = 3; } echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['satisfaction'][1] . " : </td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='{$tid}'>"; echo "<input type='hidden' id='satisfaction' name='satisfaction' value='" . $this->fields["satisfaction"] . "'>"; echo "<script type='text/javascript'>\n\n Ext.onReady(function() {\n var md = new Ext.form.StarRate({\n hiddenName: 'satisfaction',\n starConfig: {\n \tminValue: 0,\n \tmaxValue: 5,\n value:" . $this->fields["satisfaction"] . "\n },\n applyTo : 'satisfaction'\n });\n })\n </script>"; echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td rowspan='1'>" . $LANG['common'][25] . " : </td>"; echo "<td rowspan='1' class='middle'>"; echo "<textarea cols='45' rows='7' name='comment' >" . $this->fields["comment"] . "</textarea>"; echo "</td></tr>\n"; if ($this->fields["date_answered"] > 0) { echo "<tr class='tab_bg_2'>"; echo "<td colspan='2'>" . $LANG['satisfaction'][4] . " : "; echo convDateTime($this->fields["date_answered"]) . "</td></tr>\n"; } $options['candel'] = false; $this->showFormButtons($options); } }
/** * Get all data needed for template processing **/ function getDatasForTemplate($event, $options = array()) { global $LANG, $CFG_GLPI; //----------- Ticket infos -------------- // if ($event != 'alertnotclosed') { $fields = array('ticket.title' => 'name', 'ticket.content' => 'content', 'ticket.description' => 'content', 'ticket.costfixed' => 'cost_fixed', 'ticket.costmaterial' => 'cost_material'); foreach ($fields as $tag => $table_field) { $this->datas['##' . $tag . '##'] = $this->obj->getField($table_field); } $this->datas['##ticket.id##'] = sprintf("%07d", $this->obj->getField("id")); $this->datas['##ticket.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id")); $this->datas['##ticket.urlapprove##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id") . "_4"); $this->datas['##ticket.urlvalidation##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id") . "_7"); $this->datas['##ticket.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->getEntity()); $events = $this->getAllEvents(); if ($event == 'validation' && isset($options['validation_status'])) { $this->datas['##ticket.action##'] = $LANG['validation'][0] . ' - ' . TicketValidation::getStatus($options['validation_status']); } else { $this->datas['##ticket.action##'] = $events[$event]; } $this->datas['##ticket.storestatus##'] = $this->obj->getField('status'); $this->datas['##ticket.status##'] = Ticket::getStatus($this->obj->getField('status')); $this->datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($this->obj->getField('global_validation')); $this->datas['##ticket.type##'] = Ticket::getTicketTypeName($this->obj->getField('type')); $this->datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $this->obj->getField('requesttypes_id')); $this->datas['##ticket.urgency##'] = Ticket::getUrgencyName($this->obj->getField('urgency')); $this->datas['##ticket.impact##'] = Ticket::getImpactName($this->obj->getField('impact')); $this->datas['##ticket.priority##'] = Ticket::getPriorityName($this->obj->getField('priority')); $this->datas['##ticket.time##'] = Ticket::getActionTime($this->obj->getField('actiontime')); $this->datas['##ticket.costtime##'] = $this->obj->getField('cost_time'); $this->datas['##ticket.creationdate##'] = convDateTime($this->obj->getField('date')); $this->datas['##ticket.closedate##'] = convDateTime($this->obj->getField('closedate')); $this->datas['##ticket.solvedate##'] = convDateTime($this->obj->getField('solvedate')); $this->datas['##ticket.duedate##'] = convDateTime($this->obj->getField('due_date')); $entitydata = new EntityData(); $autoclose_value = $CFG_GLPI['autoclose_delay']; if ($entitydata->getFromDB($this->getEntity())) { $autoclose_value = $entitydata->getField('autoclose_delay'); // Set global config value if ($autoclose_value == -1) { $autoclose_value = $CFG_GLPI['autoclose_delay']; } } if ($autoclose_value > 0) { $this->datas['##ticket.autoclose##'] = $autoclose_value; $this->datas['##lang.ticket.autoclosewarning##'] = $LANG['job'][54] . " " . $autoclose_value . " " . $LANG['stats'][31]; } else { $this->datas['##ticket.autoclose##'] = $LANG['setup'][307]; $this->datas['##lang.ticket.autoclosewarning##'] = ""; } if ($this->obj->getField('ticketcategories_id')) { $this->datas['##ticket.category##'] = Dropdown::getDropdownName('glpi_ticketcategories', $this->obj->getField('ticketcategories_id')); } else { $this->datas['##ticket.category##'] = ''; } if ($this->obj->getField('slas_id')) { $this->datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $this->obj->getField('slas_id')); } else { $this->datas['##ticket.sla##'] = ''; } if ($this->obj->countUsers(Ticket::REQUESTER)) { $users = array(); foreach ($this->obj->getUsers(Ticket::REQUESTER) as $uid => $tmp) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); $tmp = array(); $tmp['##author.id##'] = $uid; $tmp['##author.name##'] = $user_tmp->getName(); if ($user_tmp->getField('locations_id')) { $tmp['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id')); } else { $tmp['##author.location##'] = ''; } $tmp['##author.phone##'] = $user_tmp->getField('phone'); $tmp['##author.phone2##'] = $user_tmp->getField('phone2'); $this->datas['authors'][] = $tmp; } $this->datas['##ticket.authors##'] = implode(', ', $users); } else { $this->datas['##ticket.authors##'] = ''; } if ($this->obj->getField('users_id_recipient')) { $user_tmp = new User(); $user_tmp->getFromDB($this->obj->getField('users_id_recipient')); $this->datas['##ticket.openbyuser##'] = $user_tmp->getName(); } else { $this->datas['##ticket.openbyuser##'] = ''; } if ($this->obj->countUsers(Ticket::ASSIGN)) { $users = array(); foreach ($this->obj->getUsers(Ticket::ASSIGN) as $uid => $tmp) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); } $this->datas['##ticket.assigntousers##'] = implode(', ', $users); } else { $this->datas['##ticket.assigntousers##'] = ''; } if ($this->obj->countUsers(Ticket::OBSERVER)) { $users = array(); foreach ($this->obj->getUsers(Ticket::OBSERVER) as $uid => $tmp) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); } $this->datas['##ticket.observerusers##'] = implode(', ', $users); } else { $this->datas['##ticket.observerusers##'] = ''; } if ($this->obj->getField('suppliers_id_assign')) { $this->datas['##ticket.assigntosupplier##'] = Dropdown::getDropdownName('glpi_suppliers', $this->obj->getField('suppliers_id_assign')); } else { $this->datas['##ticket.assigntosupplier##'] = ''; } if ($this->obj->countGroups(Ticket::REQUESTER)) { $groups = array(); foreach ($this->obj->getUsers(Ticket::REQUESTER) as $gid => $tmp) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $this->datas['##ticket.groups##'] = implode(', ', $groups); } else { $this->datas['##ticket.groups##'] = ''; } if ($this->obj->countGroups(Ticket::OBSERVER)) { $groups = array(); foreach ($this->obj->getGroups(Ticket::OBSERVER) as $gid => $tmp) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $this->datas['##ticket.observergroups##'] = implode(', ', $groups); } else { $this->datas['##ticket.observergroups##'] = ''; } if ($this->obj->countGroups(Ticket::ASSIGN)) { $groups = array(); foreach ($this->obj->getGroups(Ticket::ASSIGN) as $gid => $tmp) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $this->datas['##ticket.assigntogroups##'] = implode(', ', $groups); } else { $this->datas['##ticket.assigntogroups##'] = ''; } //Tags associated with the object linked to the ticket if ($this->target_object != null) { //Object type $this->datas['##ticket.itemtype##'] = $this->target_object->getTypeName(); //Object name $this->datas['##ticket.item.name##'] = $this->target_object->getField('name'); //Object serial if ($this->target_object->isField('serial')) { $this->datas['##ticket.item.serial##'] = $this->target_object->getField('serial'); } else { $this->datas['##ticket.item.serial##'] = ''; } //Object contact if ($this->target_object->isField('contact')) { $this->datas['##ticket.item.contact##'] = $this->target_object->getField('contact'); } else { $this->datas['##ticket.item.contact##'] = ''; } //Object contact num if ($this->target_object->isField('contact_num')) { $this->datas['##ticket.item.contactnumber##'] = $this->target_object->getField('contact_num'); } else { $this->datas['##ticket.item.contactnumber##'] = ''; } //Object otherserial if ($this->target_object->isField('otherserial')) { $this->datas['##ticket.item.otherserial##'] = $this->target_object->getField('otherserial'); } else { $this->datas['##ticket.item.otherserial##'] = ''; } //Object location if ($this->target_object->isField('locations_id')) { $this->datas['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $this->target_object->getField('locations_id')); } else { $this->datas['##ticket.item.location##'] = ''; } //Object user $this->datas['##ticket.item.user##'] = ''; if ($this->obj->getField('users_id')) { $user_tmp = new User(); if ($user_tmp->getFromDB($this->target_object->getField('users_id'))) { $this->datas['##ticket.item.user##'] = $user_tmp->getName(); } } //Object group if ($this->obj->getField('groups_id')) { $this->datas['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $this->target_object->getField('groups_id')); } else { $this->datas['##ticket.item.group##'] = ''; } $modeltable = getSingular($this->getTable()) . "models"; $modelfield = getForeignKeyFieldForTable($modeltable); if ($this->target_object->isField($modelfield)) { $this->datas['##ticket.item.model##'] = $this->target_object->getField($modelfield); } else { $this->datas['##ticket.item.model##'] = ''; } } else { $this->datas['##ticket.itemtype##'] = ''; $this->datas['##ticket.item.name##'] = ''; $this->datas['##ticket.item.serial##'] = ''; $this->datas['##ticket.item.otherserial##'] = ''; $this->datas['##ticket.item.location##'] = ''; } if ($this->obj->getField('ticketsolutiontypes_id')) { $this->datas['##ticket.solution.type##'] = Dropdown::getDropdownName('glpi_ticketsolutiontypes', $this->obj->getField('ticketsolutiontypes_id')); } else { $this->datas['##ticket.solution.type##'] = ''; } $this->datas['##ticket.solution.description##'] = unclean_cross_side_scripting_deep($this->obj->getField('solution')); // Linked tickets $linked_tickets = Ticket_Ticket::getLinkedTicketsTo($this->obj->getField('id')); 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##'] = urldecode($CFG_GLPI["url_base"] . "/index.php" . "?redirect=ticket_" . $data['tickets_id']); $tmp['##linkedticket.title##'] = $linkedticket->getField('name'); $tmp['##linkedticket.content##'] = $linkedticket->getField('content'); $this->datas['linkedtickets'][] = $tmp; } } } if (!empty($this->datas['linkedtickets'])) { $this->datas['##ticket.numberoflinkedtickets##'] = count($this->datas['linkedtickets']); } else { $this->datas['##ticket.numberoflinkedtickets##'] = 0; } $restrict = "`tickets_id`='" . $this->obj->getField('id') . "'"; if (!isset($options['additionnaloption']) || !$options['additionnaloption']) { $restrict .= " AND `is_private` = '0'"; } $restrict .= " ORDER BY `date` DESC, `id` ASC"; //Task infos $tasks = getAllDatasFromTable('glpi_tickettasks', $restrict); foreach ($tasks as $task) { $tmp = array(); $tmp['##task.isprivate##'] = Dropdown::getYesNo($task['is_private']); $tmp['##task.author##'] = html_clean(getUserName($task['users_id'])); $tmp['##task.category##'] = Dropdown::getDropdownName('glpi_taskcategories', $task['taskcategories_id']); $tmp['##task.date##'] = convDateTime($task['date']); $tmp['##task.description##'] = $task['content']; $tmp['##task.time##'] = Ticket::getActionTime($task['actiontime']); $plan = new TicketPlanning(); if ($plan->getFromDBbyTask($task['id'])) { $tmp['##task.planning.user##'] = html_clean(getUserName($plan->fields['users_id'])); $tmp['##task.planning.begin##'] = convDateTime($plan->fields['begin']); $tmp['##task.planning.end##'] = convDateTime($plan->fields['end']); $tmp['##task.planning.status##'] = Planning::getState($plan->fields['state']); } else { $tmp['##task.planning.user##'] = ""; $tmp['##task.planning.begin##'] = ""; $tmp['##task.planning.end##'] = ""; $tmp['##task.planning.status##'] = ""; } $this->datas['tasks'][] = $tmp; } if (!empty($this->datas['tasks'])) { $this->datas['##ticket.numberoftasks##'] = count($this->datas['tasks']); } else { $this->datas['##ticket.numberoftasks##'] = 0; } //Followup infos $followups = getAllDatasFromTable('glpi_ticketfollowups', $restrict); 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##'] = convDateTime($followup['date']); $tmp['##followup.description##'] = $followup['content']; $this->datas['followups'][] = $tmp; } if (isset($this->datas['followups'])) { $this->datas['##ticket.numberoffollowups##'] = count($this->datas['followups']); } else { $this->datas['##ticket.numberoffollowups##'] = 0; } //Validation infos $restrict = "`tickets_id`='" . $this->obj->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); foreach ($validations as $validation) { $tmp = array(); $tmp['##validation.submission.title##'] = $LANG['validation'][27] . " (" . $LANG['job'][4] . " " . html_clean(getUserName($validation['users_id'])) . ")"; $tmp['##validation.answer.title##'] = $LANG['validation'][32] . " (" . $LANG['validation'][21] . " " . 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##'] = convDateTime($validation['submission_date']); $tmp['##validation.commentsubmission##'] = $validation['comment_submission']; $tmp['##validation.validationdate##'] = convDateTime($validation['validation_date']); $tmp['##validation.validator##'] = html_clean(getUserName($validation['users_id_validate'])); $tmp['##validation.commentvalidation##'] = $validation['comment_validation']; $this->datas['validations'][] = $tmp; } // Ticket Satisfaction $inquest = new TicketSatisfaction(); if ($inquest->getFromDB($this->obj->getField('id'))) { // internal inquest if ($inquest->fields['type'] == 1) { $this->datas['##ticket.urlsatisfaction##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $this->obj->getField("id") . "_10"); // external inquest } else { if ($inquest->fields['type'] == 2) { $this->datas['##ticket.urlsatisfaction##'] = EntityData::generateLinkSatisfaction($this->obj); } } $this->datas['##satisfaction.type##'] = $inquest->getTypeInquestName($inquest->getfield('type')); $this->datas['##satisfaction.datebegin##'] = convDateTime($inquest->fields['date_begin']); $this->datas['##satisfaction.dateanswered##'] = convDateTime($inquest->fields['date_answered']); $this->datas['##satisfaction.satisfaction##'] = $inquest->fields['satisfaction']; $this->datas['##satisfaction.description##'] = $inquest->fields['comment']; } else { $this->datas['##satisfaction.type##'] = ''; $this->datas['##satisfaction.datebegin##'] = ''; $this->datas['##satisfaction.dateanswered##'] = ''; $this->datas['##satisfaction.satisfaction##'] = ''; $this->datas['##satisfaction.description##'] = ''; } // Use list_limit_max or load the full history ? foreach (Log::getHistoryData($this->obj, 0, $CFG_GLPI['list_limit_max']) as $data) { $tmp = array(); $tmp['##ticket.log.date##'] = $data['date_mod']; $tmp['##ticket.log.user##'] = $data['user_name']; $tmp['##ticket.log.field##'] = $data['field']; $tmp['##ticket.log.content##'] = $data['change']; $this->datas['log'][] = $tmp; } if (isset($this->datas['log'])) { $this->datas['##ticket.numberoflogs##'] = count($this->datas['log']); } else { $this->datas['##ticket.numberoflogs##'] = 0; } } else { if (isset($options['entities_id']) && isset($options['tickets'])) { $this->datas['##ticket.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']); $this->datas['##ticket.action##'] = $LANG['crontask'][15]; $t = new Ticket(); foreach ($options['tickets'] as $ticket) { $tmp = array(); $t->getFromDB($ticket['id']); $tmp['##ticket.id##'] = sprintf("%07d", $ticket['id']); $tmp['##ticket.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=ticket_" . $ticket['id']); $tmp['##ticket.title##'] = $ticket['name']; $tmp['##ticket.status##'] = Ticket::getStatus($ticket['status']); $tmp['##ticket.globalvalidation##'] = TicketValidation::getStatus($ticket['global_validation']); $tmp['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $ticket['requesttypes_id']); $tmp['##ticket.urgency##'] = Ticket::getUrgencyName($ticket['urgency']); $tmp['##ticket.impact##'] = Ticket::getImpactName($ticket['impact']); $tmp['##ticket.priority##'] = Ticket::getPriorityName($ticket['priority']); $tmp['##ticket.time##'] = Ticket::getActionTime($ticket['actiontime']); $tmp['##ticket.costtime##'] = $ticket['cost_time']; $tmp['##ticket.creationdate##'] = convDateTime($ticket['date']); $tmp['##ticket.content##'] = $ticket['content']; if ($t->getField('ticketsolutiontypes_id')) { $tmp['##ticket.solution.type##'] = Dropdown::getDropdownName('glpi_ticketsolutiontypes', $t->getField('ticketsolutiontypes_id')); } else { $this->datas['##ticket.solution.type##'] = ''; } $tmp['##ticket.solution.description##'] = unclean_cross_side_scripting_deep($t->getField('solution')); if ($t->countUsers(Ticket::REQUESTER)) { $users = array(); foreach ($t->getUsers(Ticket::REQUESTER) as $uid => $val) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); $tmp2 = array(); $tmp2['##author.id##'] = $uid; $tmp2['##author.name##'] = $user_tmp->getName(); if ($user_tmp->getField('locations_id')) { $tmp2['##author.location##'] = Dropdown::getDropdownName('glpi_locations', $user_tmp->getField('locations_id')); } else { $tmp2['##author.location##'] = ''; } $tmp2['##author.phone##'] = $user_tmp->getField('phone'); $tmp2['##author.phone2##'] = $user_tmp->getField('phone2'); $tmp['authors'][] = $tmp2; } $tmp['##ticket.authors##'] = implode(', ', $users); } else { $tmp['##ticket.authors##'] = ''; } if ($t->countUsers(Ticket::ASSIGN)) { $users = array(); foreach ($t->getUsers(Ticket::ASSIGN) as $uid => $val) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); } $tmp['##ticket.assigntousers##'] = implode(', ', $users); } else { $tmp['##ticket.assigntousers##'] = ''; } if ($t->countGroups(Ticket::ASSIGN)) { $groups = array(); foreach ($t->getGroups(Ticket::ASSIGN) as $gid => $val) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $tmp['##ticket.assigntogroups##'] = implode(', ', $groups); } else { $tmp['##ticket.assigntogroups##'] = ''; } if ($t->countGroups(Ticket::REQUESTER)) { $groups = array(); foreach ($t->getGroups(Ticket::REQUESTER) as $gid => $val) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $tmp['##ticket.groups##'] = implode(', ', $groups); } else { $tmp['##ticket.groups##'] = ''; } if ($t->countUsers(Ticket::OBSERVER)) { $users = array(); foreach ($t->getUsers(Ticket::OBSERVER) as $uid => $tmp) { $user_tmp = new User(); $user_tmp->getFromDB($uid); $users[$uid] = $user_tmp->getName(); } $tmp['##ticket.observerusers##'] = implode(', ', $users); } else { $tmp['##ticket.observerusers##'] = ''; } if ($t->countGroups(Ticket::OBSERVER)) { $groups = array(); foreach ($t->getGroups(Ticket::OBSERVER) as $gid => $tmp) { $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid); } $tmp['##ticket.observergroups##'] = implode(', ', $groups); } else { $tmp['##ticket.observergroups##'] = ''; } if ($ticket['suppliers_id_assign']) { $tmp['##ticket.assigntosupplier##'] = Dropdown::getDropdownName('glpi_suppliers', $ticket['suppliers_id_assign']); } else { $tmp['##ticket.assigntosupplier##'] = ''; } $this->datas['tickets'][] = $tmp; } } } $this->getTags(); foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) { if (!isset($this->datas[$tag])) { $this->datas[$tag] = $values['label']; } } }