generateLinkSatisfaction() static public method

Generate link for ticket satisfaction
static public generateLinkSatisfaction ( $ticket ) : url
$ticket ticket object
return url contents
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket)
 {
     $survey = new TicketSatisfaction();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . __('Satisfaction survey') . "</b>");
     if (!$survey->getFromDB($ticket->getID())) {
         $pdf->displayLine(__('No generated survey'));
     } else {
         if ($survey->getField('type') == 2) {
             $url = Entity::generateLinkSatisfaction($ticket);
             $pdf->displayLine(sprintf(__('%1$s (%2$s)'), __('External survey'), $url));
         } else {
             if ($survey->getField('date_answered')) {
                 $sat = $survey->getField('satisfaction');
                 $tabsat = array(0 => __('None'), 1 => __('1 star', 'pdf'), 2 => __('2 stars', 'pdf'), 3 => __('3 stars', 'pdf'), 4 => __('4 stars', 'pdf'), 5 => __('5 stars', 'pdf'));
                 if (isset($tabsat[$sat])) {
                     $sat = $tabsat[$sat] . "  ({$sat}/5)";
                 }
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Response date to the satisfaction survey') . '</b>', Html::convDateTime($survey->getField('date_answered'))));
                 $pdf->displayLine('<b>' . sprintf(__('%1$s: %2$s'), __('Satisfaction with the resolution of the ticket') . '</b>', $sat));
                 $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Comments') . '</b>', $survey->getField('comment')));
             } else {
                 // No answer
                 $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Creation date of the satisfaction survey'), Html::convDateTime($survey->getField('date_begin'))));
                 $pdf->displayLine(__('No answer', 'pdf'));
             }
         }
     }
     $pdf->displaySpace();
 }
 /**
  * @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;
 }
 /**
  * form for satisfaction
  *
  * @param $ticket Object : the ticket
  **/
 function showForm($ticket)
 {
     $tid = $ticket->fields['id'];
     $options = array();
     $options['colspan'] = 1;
     // for external inquest => link
     if ($this->fields["type"] == 2) {
         $url = Entity::generateLinkSatisfaction($ticket);
         echo "<div class='center spaced'>" . "<a href='{$url}'>" . __('External survey') . "</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>" . __('Satisfaction with the resolution of the ticket') . "</td>";
         echo "<td>";
         echo "<input type='hidden' name='tickets_id' value='{$tid}'>";
         echo "<select id='satisfaction_data' name='satisfaction'>";
         for ($i = 0; $i <= 5; $i++) {
             echo "<option value='{$i}' " . ($i == $this->fields["satisfaction"] ? 'selected' : '') . ">{$i}</option>";
         }
         echo "</select>";
         echo "<div class='rateit' id='stars'></div>";
         echo "<script type='text/javascript'>\n";
         echo "\$('#stars').rateit({value: " . $this->fields["satisfaction"] . ",\n                                   min : 0,\n                                   max : 5,\n                                   step: 1,\n                                   backingfld: '#satisfaction_data',\n                                   ispreset: true,\n                                   resetable: false});";
         echo "</script>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td rowspan='1'>" . __('Comments') . "</td>";
         echo "<td rowspan='1' class='middle'>";
         echo "<textarea cols='45' rows='7' name='comment' class='form-control'>" . $this->fields["comment"] . "</textarea>";
         echo "</td></tr>\n";
         if ($this->fields["date_answered"] > 0) {
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . __('Response date to the satisfaction survey') . "</td><td>";
             echo Html::convDateTime($this->fields["date_answered"]) . "</td></tr>\n";
         }
         $options['candel'] = false;
         $this->showFormButtons($options);
     }
 }
Exemplo n.º 4
0
 /**
  * form for satisfaction
  *
  * @param $ticket Object : the ticket
  **/
 function showSatisfactionForm($ticket)
 {
     $tid = $ticket->fields['id'];
     $options = array();
     $options['colspan'] = 1;
     // for external inquest => link
     if ($this->fields["type"] == 2) {
         $url = Entity::generateLinkSatisfaction($ticket);
         echo "<div class='center spaced'>" . "<a href='{$url}'>" . __('External survey') . "</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>" . __('Satisfaction with the resolution of the ticket') . "</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'>" . __('Comments') . "</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>" . __('Response date to the satisfaction survey') . "</td><td>";
             echo Html::convDateTime($this->fields["date_answered"]) . "</td></tr>\n";
         }
         $options['candel'] = false;
         $this->showFormButtons($options);
     }
 }