getDatasForObject() публичный Метод

public getDatasForObject ( CommonDBTM $item, array $options, $simple = false )
$item CommonDBTM CommonDBTM object
$options array array
$simple (false by default)
 /**
  * @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;
 }
 /**
  * @see NotificationTargetCommonITILObject::getDatasForObject()
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI;
     // Common ITIL datas
     $datas = parent::getDatasForObject($item, $options, $simple);
     $datas["##problem.impacts##"] = $item->getField('impactcontent');
     $datas["##problem.causes##"] = $item->getField('causecontent');
     $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
     // Complex mode
     if (!$simple) {
         $restrict = "`problems_id`='" . $item->getField('id') . "'";
         $tickets = getAllDatasFromTable('glpi_problems_tickets', $restrict);
         $datas['tickets'] = array();
         if (count($tickets)) {
             $ticket = new Ticket();
             foreach ($tickets as $data) {
                 if ($ticket->getFromDB($data['tickets_id'])) {
                     $tmp = array();
                     $tmp['##ticket.id##'] = $data['tickets_id'];
                     $tmp['##ticket.date##'] = $ticket->getField('date');
                     $tmp['##ticket.title##'] = $ticket->getField('name');
                     $tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
                     $tmp['##ticket.content##'] = $ticket->getField('content');
                     $datas['tickets'][] = $tmp;
                 }
             }
         }
         $datas['##problem.numberoftickets##'] = count($datas['tickets']);
         $restrict = "`problems_id`='" . $item->getField('id') . "'";
         $changes = getAllDatasFromTable('glpi_changes_problems', $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['##problem.numberofchanges##'] = count($datas['changes']);
         $restrict = "`problems_id` = '" . $item->getField('id') . "'";
         $items = getAllDatasFromTable('glpi_items_problems', $restrict);
         $datas['items'] = array();
         if (count($items)) {
             foreach ($items as $data) {
                 if ($item2 = getItemForItemtype($data['itemtype'])) {
                     if ($item2->getFromDB($data['items_id'])) {
                         $tmp = array();
                         $tmp['##item.itemtype##'] = $item2->getTypeName();
                         $tmp['##item.name##'] = $item2->getField('name');
                         $tmp['##item.serial##'] = $item2->getField('serial');
                         $tmp['##item.otherserial##'] = $item2->getField('otherserial');
                         $tmp['##item.contact##'] = $item2->getField('contact');
                         $tmp['##item.contactnum##'] = $item2->getField('contactnum');
                         $tmp['##item.location##'] = '';
                         $tmp['##item.user##'] = '';
                         $tmp['##item.group##'] = '';
                         $tmp['##item.model##'] = '';
                         //Object location
                         if ($item2->getField('locations_id') != NOT_AVAILABLE) {
                             $tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
                         }
                         //Object user
                         if ($item2->getField('users_id')) {
                             $user_tmp = new User();
                             if ($user_tmp->getFromDB($item2->getField('users_id'))) {
                                 $tmp['##item.user##'] = $user_tmp->getName();
                             }
                         }
                         //Object group
                         if ($item2->getField('groups_id')) {
                             $tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
                         }
                         $modeltable = getSingular($item2->getTable()) . "models";
                         $modelfield = getForeignKeyFieldForTable($modeltable);
                         if ($item2->isField($modelfield)) {
                             $tmp['##item.model##'] = $item2->getField($modelfield);
                         }
                         $datas['items'][] = $tmp;
                     }
                 }
             }
         }
         $datas['##problem.numberofitems##'] = count($datas['items']);
     }
     return $datas;
 }
 /**
  * @see NotificationTargetCommonITILObject::getDatasForObject()
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI;
     // Common ITIL datas
     $datas = parent::getDatasForObject($item, $options, $simple);
     // Specific datas
     $datas['##change.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $item->getField("id") . "_ChangeValidation\$1");
     $datas['##change.globalvalidation##'] = ChangeValidation::getStatus($item->getField('global_validation'));
     //       $datas["##problem.impacts##"]  = $item->getField('impactcontent');
     //       $datas["##problem.causes##"]   = $item->getField('causecontent');
     //       $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
     // Complex mode
     if (!$simple) {
         $restrict = "`changes_id`='" . $item->getField('id') . "'";
         $tickets = getAllDatasFromTable('glpi_changes_tickets', $restrict);
         $datas['tickets'] = array();
         if (count($tickets)) {
             $ticket = new Ticket();
             foreach ($tickets as $data) {
                 if ($ticket->getFromDB($data['tickets_id'])) {
                     $tmp = array();
                     $tmp['##ticket.id##'] = $data['tickets_id'];
                     $tmp['##ticket.date##'] = $ticket->getField('date');
                     $tmp['##ticket.title##'] = $ticket->getField('name');
                     $tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']);
                     $tmp['##ticket.content##'] = $ticket->getField('content');
                     $datas['tickets'][] = $tmp;
                 }
             }
         }
         $datas['##change.numberoftickets##'] = count($datas['tickets']);
         $restrict = "`changes_id`='" . $item->getField('id') . "'";
         $problems = getAllDatasFromTable('glpi_changes_problems', $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['##change.numberofproblems##'] = count($datas['problems']);
         $restrict = "`changes_id` = '" . $item->getField('id') . "'";
         $items = getAllDatasFromTable('glpi_changes_items', $restrict);
         $datas['items'] = array();
         if (count($items)) {
             foreach ($items as $data) {
                 if ($item2 = getItemForItemtype($data['itemtype'])) {
                     if ($item2->getFromDB($data['items_id'])) {
                         $tmp = array();
                         $tmp['##item.itemtype##'] = $item2->getTypeName();
                         $tmp['##item.name##'] = $item2->getField('name');
                         $tmp['##item.serial##'] = $item2->getField('serial');
                         $tmp['##item.otherserial##'] = $item2->getField('otherserial');
                         $tmp['##item.contact##'] = $item2->getField('contact');
                         $tmp['##item.contactnum##'] = $item2->getField('contactnum');
                         $tmp['##item.location##'] = '';
                         $tmp['##item.user##'] = '';
                         $tmp['##item.group##'] = '';
                         $tmp['##item.model##'] = '';
                         //Object location
                         if ($item2->getField('locations_id') != NOT_AVAILABLE) {
                             $tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
                         }
                         //Object user
                         if ($item2->getField('users_id')) {
                             $user_tmp = new User();
                             if ($user_tmp->getFromDB($item2->getField('users_id'))) {
                                 $tmp['##item.user##'] = $user_tmp->getName();
                             }
                         }
                         //Object group
                         if ($item2->getField('groups_id')) {
                             $tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
                         }
                         $modeltable = getSingular($item2->getTable()) . "models";
                         $modelfield = getForeignKeyFieldForTable($modeltable);
                         if ($item2->isField($modelfield)) {
                             $tmp['##item.model##'] = $item2->getField($modelfield);
                         }
                         $datas['items'][] = $tmp;
                     }
                 }
             }
         }
         $datas['##change.numberofitems##'] = count($datas['items']);
         //Validation infos
         $restrict = "`changes_id`='" . $item->getField('id') . "'";
         if (isset($options['validation_id']) && $options['validation_id']) {
             $restrict .= " AND `glpi_changevalidations`.`id` = '" . $options['validation_id'] . "'";
         }
         $restrict .= " ORDER BY `submission_date` DESC, `id` ASC";
         $validations = getAllDatasFromTable('glpi_changevalidations', $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;
         }
     }
     return $datas;
 }
 /**
  * @see NotificationTargetCommonITILObject::getDatasForObject()
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI;
     // Common ITIL datas
     $datas = parent::getDatasForObject($item, $options, $simple);
     $datas["##problem.impacts##"] = $item->getField('impactcontent');
     $datas["##problem.causes##"] = $item->getField('causecontent');
     $datas["##problem.symptoms##"] = $item->getField('symptomcontent');
     // Complex mode : get tasks
     if (!$simple) {
         $restrict = "`problems_id`='" . $item->getField('id') . "'";
         $tickets = getAllDatasFromTable('glpi_problems_tickets', $restrict);
         $datas['tickets'] = array();
         if (count($tickets)) {
             $ticket = new Ticket();
             foreach ($tickets as $data) {
                 if ($ticket->getFromDB($data['tickets_id'])) {
                     $tmp = array();
                     $tmp['##ticket.id##'] = $data['tickets_id'];
                     $tmp['##ticket.date##'] = $ticket->getField('date');
                     $tmp['##ticket.title##'] = $ticket->getField('name');
                     $tmp['##ticket.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php" . "?redirect=ticket_" . $data['tickets_id']);
                     $tmp['##ticket.content##'] = $ticket->getField('content');
                     $datas['tickets'][] = $tmp;
                 }
             }
         }
         $datas['##problem.numberoftickets##'] = 0;
         if (!empty($datas['tickets'])) {
             $datas['##problem.numberoftickets##'] = count($datas['tickets']);
         }
         $restrict = "`problems_id` = '" . $item->getField('id') . "'\n                       ORDER BY `date` DESC,\n                                `id` ASC";
         //Task infos
         $tasks = getAllDatasFromTable('glpi_problemtasks', $restrict);
         foreach ($tasks as $task) {
             $tmp = array();
             $tmp['##task.author##'] = Html::clean(getUserName($task['users_id']));
             $tmp['##task.category##'] = Dropdown::getDropdownName('glpi_taskcategories', $task['taskcategories_id']);
             $tmp['##task.date##'] = Html::convDateTime($task['date']);
             $tmp['##task.description##'] = $task['content'];
             $tmp['##task.time##'] = Problem::getActionTime($task['actiontime']);
             $tmp['##task.status##'] = Planning::getState($task['state']);
             $tmp['##task.user##'] = "";
             $tmp['##task.begin##'] = "";
             $tmp['##task.end##'] = "";
             if (!is_null($task['begin'])) {
                 $tmp['##task.user##'] = Html::clean(getUserName($task['users_id_tech']));
                 $tmp['##task.begin##'] = Html::convDateTime($task['begin']);
                 $tmp['##task.end##'] = Html::convDateTime($task['end']);
             }
             $datas['tasks'][] = $tmp;
         }
         $datas['##problem.numberoftasks##'] = 0;
         if (!empty($datas['tasks'])) {
             $datas['##problem.numberoftasks##'] = count($datas['tasks']);
         }
         $restrict = "`problems_id` = '" . $item->getField('id') . "'";
         $items = getAllDatasFromTable('glpi_items_problems', $restrict);
         $datas['items'] = array();
         if (count($tickets)) {
             foreach ($items as $data) {
                 if ($item2 = getItemForItemtype($data['itemtype'])) {
                     if ($item2->getFromDB($data['items_id'])) {
                         $tmp = array();
                         $tmp['##item.itemtype##'] = $item2->getTypeName();
                         $tmp['##item.name##'] = $item2->getField('name');
                         $tmp['##item.serial##'] = $item2->getField('serial');
                         $tmp['##item.otherserial##'] = $item2->getField('otherserial');
                         $tmp['##item.contact##'] = $item2->getField('contact');
                         $tmp['##item.contactnum##'] = $item2->getField('contactnum');
                         $tmp['##item.location##'] = '';
                         $tmp['##item.user##'] = '';
                         $tmp['##item.group##'] = '';
                         $tmp['##item.model##'] = '';
                         //Object location
                         if ($item2->getField('locations_id') != NOT_AVAILABLE) {
                             $tmp['##item.location##'] = Dropdown::getDropdownName('glpi_locations', $item2->getField('locations_id'));
                         }
                         //Object user
                         if ($item2->getField('users_id')) {
                             $user_tmp = new User();
                             if ($user_tmp->getFromDB($item2->getField('users_id'))) {
                                 $tmp['##item.user##'] = $user_tmp->getName();
                             }
                         }
                         //Object group
                         if ($item2->getField('groups_id')) {
                             $tmp['##item.group##'] = Dropdown::getDropdownName('glpi_groups', $item2->getField('groups_id'));
                         }
                         $modeltable = getSingular($item2->getTable()) . "models";
                         $modelfield = getForeignKeyFieldForTable($modeltable);
                         if ($item2->isField($modelfield)) {
                             $tmp['##item.model##'] = $item2->getField($modelfield);
                         }
                         $datas['items'][] = $tmp;
                     }
                 }
             }
         }
         $datas['##problem.numberofitems##'] = 0;
         if (!empty($datas['items'])) {
             $datas['##problem.numberofitems##'] = count($datas['items']);
         }
     }
     return $datas;
 }