/**
  * show tooltip for user notification information
  *
  * @param $type      integer  user type
  * @param $canedit   boolean  can edit ?
  * @param $options   array    options for default values ($options of showForm)
  *
  * @return nothing display
  **/
 function showUsersAssociated($type, $canedit, array $options = array())
 {
     global $CFG_GLPI;
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 2;
     }
     $usericon = self::getActorIcon('user', $type);
     $user = new User();
     $linkuser = new $this->userlinkclass();
     $itemtype = $this->getType();
     $typename = self::getActorFieldNameType($type);
     $candelete = true;
     $mandatory = '';
     // For ticket templates : mandatories
     if ($itemtype == 'Ticket' && isset($options['_tickettemplate'])) {
         $mandatory = $options['_tickettemplate']->getMandatoryMark("_users_id_" . $typename);
         if ($options['_tickettemplate']->isMandatoryField("_users_id_" . $typename) && isset($this->users[$type]) && count($this->users[$type]) == 1) {
             $candelete = false;
         }
     }
     if (isset($this->users[$type]) && count($this->users[$type])) {
         foreach ($this->users[$type] as $d) {
             $k = $d['users_id'];
             echo "{$mandatory}{$usericon} ";
             if ($k) {
                 $userdata = getUserName($k, 2);
             } else {
                 $email = $d['alternative_email'];
                 $userdata = "<a href='mailto:{$email}'>{$email}</a>";
             }
             if ($k) {
                 $param = array('display' => false);
                 if ($showuserlink) {
                     $param['link'] = $userdata["link"];
                 }
                 echo $userdata['name'] . "&nbsp;" . Html::showToolTip($userdata["comment"], $param);
             } else {
                 echo $userdata;
             }
             if ($CFG_GLPI['use_mailing']) {
                 $text = __('Email followup') . "&nbsp;" . Dropdown::getYesNo($d['use_notification']) . '<br>';
                 if ($d['use_notification']) {
                     $uemail = $d['alternative_email'];
                     if (empty($uemail) && $user->getFromDB($d['users_id'])) {
                         $uemail = $user->getDefaultEmail();
                     }
                     $text .= sprintf(__('%1$s: %2$s'), __('Email'), $uemail);
                     if (!NotificationMail::isUserAddressValid($uemail)) {
                         $text .= "&nbsp;<span class='red'>" . __('Invalid email address') . "</span>";
                     }
                 }
                 echo "&nbsp;";
                 if ($canedit || $d['users_id'] == Session::getLoginUserID()) {
                     $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => $linkuser->getFormURL() . "?id=" . $d['id']);
                     Html::showToolTip($text, $opt);
                 }
             }
             if ($canedit && $candelete) {
                 echo "&nbsp;";
                 Html::showSimpleForm($linkuser->getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $d['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
             }
             echo "<br>";
         }
     }
 }
Пример #2
0
 /**
  * Print the object user form for notification
  *
  * @param $ID              integer ID of the item
  * @param $options   array
  *
  * @return Nothing (display)
  **/
 function showUserNotificationForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->check($ID, UPDATE);
     if (!isset($this->fields['users_id'])) {
         return false;
     }
     $item = new static::$itemtype_1();
     echo "<br><form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
     echo "<div class='center'>";
     echo "<table class='tab_cadre' width='80%'>";
     echo "<tr class='tab_bg_2'><td>" . $item->getTypeName(1) . "</td>";
     echo "<td>";
     if ($item->getFromDB($this->fields[static::getItilObjectForeignKey()])) {
         echo $item->getField('name');
     }
     echo "</td></tr>";
     $user = new User();
     $default_email = "";
     $emails = array();
     if ($user->getFromDB($this->fields["users_id"])) {
         $default_email = $user->getDefaultEmail();
         $emails = $user->getAllEmails();
     }
     echo "<tr class='tab_bg_2'><td>" . __('User') . "</td>";
     echo "<td>" . $user->getName() . "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Email Followup') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('use_notification', $this->fields['use_notification']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Email') . "</td>";
     echo "<td>";
     if (count($emails) == 1 && !empty($default_email) && NotificationMail::isUserAddressValid($default_email)) {
         echo $default_email;
     } else {
         if (count($emails) > 1) {
             // Several emails : select in the list
             $emailtab = array();
             foreach ($emails as $new_email) {
                 if ($new_email != $default_email) {
                     $emailtab[$new_email] = $new_email;
                 } else {
                     $emailtab[''] = $new_email;
                 }
             }
             Dropdown::showFromArray("alternative_email", $emailtab, array('value' => $this->fields['alternative_email']));
         } else {
             echo "<input type='text' size='40' name='alternative_email' value='" . $this->fields['alternative_email'] . "'>";
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' colspan='2'>";
     echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</td></tr>";
     echo "</table></div>";
     Html::closeForm();
 }
Пример #3
0
 function post_addItem()
 {
     global $CFG_GLPI;
     $job = new Ticket();
     $mailsend = false;
     if ($job->getFromDB($this->fields["tickets_id"])) {
         // Set global validation to waiting
         if ($job->fields['global_validation'] == 'accepted' || $job->fields['global_validation'] == 'none') {
             $input['id'] = $this->fields["tickets_id"];
             $input['global_validation'] = 'waiting';
             // to fix lastupdater
             if (isset($this->input['_auto_update'])) {
                 $input['_auto_update'] = $this->input['_auto_update'];
             }
             // to know update by rules
             if (isset($this->input["_rule_process"])) {
                 $input['_rule_process'] = $this->input["_rule_process"];
             }
             // No update ticket notif on ticket add
             if (isset($this->input["_ticket_add"])) {
                 $input['_disablenotif'] = true;
             }
             $job->update($input);
         }
         if ($CFG_GLPI["use_mailing"]) {
             $options = array('validation_id' => $this->fields["id"], 'validation_status' => $this->fields["status"]);
             $mailsend = NotificationEvent::raiseEvent('validation', $job, $options);
         }
         if ($mailsend) {
             $user = new User();
             $user->getFromDB($this->fields["users_id_validate"]);
             $email = $user->getDefaultEmail();
             if (!empty($email)) {
                 //TRANS: %s is the user name
                 Session::addMessageAfterRedirect(sprintf(__('Approval request send to %s'), $user->getName()));
             } else {
                 Session::addMessageAfterRedirect(sprintf(__('The selected user (%s) has no valid email address. The request has been created, without email confirmation.'), $user->getName()), false, ERROR);
             }
         }
     }
     parent::post_addItem();
 }
Пример #4
0
 /**
  * show tooltip for user notification information
  *
  * @param $type      integer  user type
  * @param $canedit   boolean  can edit ?
  *
  * @return nothing display
  **/
 function showUsersAssociated($type, $canedit)
 {
     global $CFG_GLPI;
     $showuserlink = 0;
     if (Session::haveRight('user', 'r')) {
         $showuserlink = 2;
     }
     $usericon = self::getActorIcon('user', $type);
     $user = new User();
     if (isset($this->users[$type]) && count($this->users[$type])) {
         foreach ($this->users[$type] as $d) {
             $k = $d['users_id'];
             echo "{$usericon}&nbsp;";
             if ($k) {
                 $userdata = getUserName($k, 2);
             } else {
                 $email = $d['alternative_email'];
                 $userdata = "<a href='mailto:{$email}'>{$email}</a>";
             }
             if ($k) {
                 $param = array('display' => false);
                 if ($showuserlink) {
                     $param['link'] = $userdata["link"];
                 }
                 echo $userdata['name'] . "&nbsp;" . Html::showToolTip($userdata["comment"], $param);
             } else {
                 echo $userdata;
             }
             if ($CFG_GLPI['use_mailing']) {
                 $text = __('Email followup') . "&nbsp;" . Dropdown::getYesNo($d['use_notification']) . '<br>';
                 if ($d['use_notification']) {
                     $uemail = $d['alternative_email'];
                     if (empty($uemail) && $user->getFromDB($d['users_id'])) {
                         $uemail = $user->getDefaultEmail();
                     }
                     $text .= sprintf(__('%1$s: %2$s'), __('Email'), $uemail);
                     if (!NotificationMail::isUserAddressValid($uemail)) {
                         $text .= "&nbsp;<span class='red'>" . __('Invalid email address') . "</span>";
                     }
                 }
                 echo "&nbsp;";
                 if ($canedit || $d['users_id'] == Session::getLoginUserID()) {
                     $opt = array('img' => $CFG_GLPI['root_doc'] . '/pics/edit.png', 'popup' => 'edit_user_notification&amp;itemtype=' . $this->getType() . '&amp;id=' . $d['id']);
                     Html::showToolTip($text, $opt);
                 }
             }
             if ($canedit) {
                 echo "&nbsp;";
                 Html::showSimpleForm($this->getFormURL(), 'delete_user', _x('button', 'Delete permanently'), array('id' => $d['id'], $this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png");
             }
             echo "<br>";
         }
     }
 }
Пример #5
0
Session::checkLoginUser();
if (isset($_POST['field']) && $_POST["value"] > 0 || isset($_POST['allow_email']) && $_POST['allow_email']) {
    if (preg_match('/[^a-z_\\-0-9]/i', $_POST['field'])) {
        throw new \RuntimeException('Invalid field provided!');
    }
    $default_email = "";
    $emails = array();
    if (isset($_POST['typefield']) && $_POST['typefield'] == 'supplier') {
        $supplier = new Supplier();
        if ($supplier->getFromDB($_POST["value"])) {
            $default_email = $supplier->fields['email'];
        }
    } else {
        $user = new User();
        if ($user->getFromDB($_POST["value"])) {
            $default_email = $user->getDefaultEmail();
            $emails = $user->getAllEmails();
        }
    }
    $user_index = 0;
    if (isset($_POST['_user_index'])) {
        $user_index = $_POST['_user_index'];
    }
    echo __('Email followup') . '&nbsp;';
    $default_notif = true;
    if (isset($_POST['use_notification'][$user_index])) {
        $default_notif = $_POST['use_notification'][$user_index];
    }
    if (isset($_POST['alternative_email'][$user_index]) && !empty($_POST['alternative_email'][$user_index]) && empty($default_email)) {
        if (NotificationMail::isUserAddressValid($_POST['alternative_email'][$user_index])) {
            $default_email = $_POST['alternative_email'][$user_index];
Пример #6
0
 function post_addItem()
 {
     global $CFG_GLPI;
     $item = new static::$itemtype();
     $mailsend = false;
     if ($item->getFromDB($this->fields[static::$items_id])) {
         // Set global validation to waiting
         if ($item->fields['global_validation'] == self::ACCEPTED || $item->fields['global_validation'] == self::NONE) {
             $input['id'] = $this->fields[static::$items_id];
             $input['global_validation'] = self::WAITING;
             // to fix lastupdater
             if (isset($this->input['_auto_update'])) {
                 $input['_auto_update'] = $this->input['_auto_update'];
             }
             // to know update by rules
             if (isset($this->input["_rule_process"])) {
                 $input['_rule_process'] = $this->input["_rule_process"];
             }
             // No update ticket notif on ticket add
             if (isset($this->input["_ticket_add"])) {
                 $input['_disablenotif'] = true;
             }
             $item->update($input);
         }
         if ($CFG_GLPI["use_mailing"]) {
             $options = array('validation_id' => $this->fields["id"], 'validation_status' => $this->fields["status"]);
             $mailsend = NotificationEvent::raiseEvent('validation', $item, $options);
         }
         if ($mailsend) {
             $user = new User();
             $user->getFromDB($this->fields["users_id_validate"]);
             $email = $user->getDefaultEmail();
             if (!empty($email)) {
                 $message[] = sprintf(__('Approval request send to %s'), $user->getName());
             } else {
                 $error[] = sprintf(__('The selected user (%s) has no valid email address. The request has been created, without email confirmation.'), $user->getName());
             }
         }
     }
     parent::post_addItem();
 }
 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$1');
     } else {
         $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     }
     $tab = '$2';
     if ($_SESSION['glpiticket_timeline'] == 1) {
         $tab = '$1';
     }
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . $tab);
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $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##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($user_tmp->getFromDB($uid)) {
                 $users[$uid] = $user_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntousers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntosupplier##"] = '';
     if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
         $suppliers = array();
         foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['suppliers_id'];
             $supplier_tmp = new Supplier();
             if ($supplier_tmp->getFromDB($uid)) {
                 $suppliers[$uid] = $supplier_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntosupplier##"] = implode(', ', $suppliers);
     }
     $datas["##{$objettype}.groups##"] = '';
     if ($item->countGroups(CommonITILActor::REQUESTER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::REQUESTER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.groups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observergroups##"] = '';
     if ($item->countGroups(CommonITILActor::OBSERVER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::OBSERVER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.observergroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observerusers##"] = '';
     if ($item->countUsers(CommonITILActor::OBSERVER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::OBSERVER) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
             } else {
                 $users[] = $tmp['alternative_email'];
             }
         }
         $datas["##{$objettype}.observerusers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntogroups##"] = '';
     if ($item->countGroups(CommonITILActor::ASSIGN)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.assigntogroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.solution.type##"] = '';
     if ($item->getField('solutiontypes_id')) {
         $datas["##{$objettype}.solution.type##"] = Dropdown::getDropdownName('glpi_solutiontypes', $item->getField('solutiontypes_id'));
     }
     $datas["##{$objettype}.solution.description##"] = Toolbox::unclean_cross_side_scripting_deep($item->getField('solution'));
     // Complex mode
     if (!$simple) {
         $datas['log'] = array();
         // Use list_limit_max or load the full history ?
         foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
             $tmp = array();
             $tmp["##{$objettype}.log.date##"] = $data['date_mod'];
             $tmp["##{$objettype}.log.user##"] = $data['user_name'];
             $tmp["##{$objettype}.log.field##"] = $data['field'];
             $tmp["##{$objettype}.log.content##"] = $data['change'];
             $datas['log'][] = $tmp;
         }
         $datas["##{$objettype}.numberoflogs##"] = count($datas['log']);
         // Get unresolved items
         $restrict = "`" . $item->getTable() . "`.`status`\n                        NOT IN ('" . implode("', '", array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray())) . "'\n                               )";
         if ($item->maybeDeleted()) {
             $restrict .= " AND `" . $item->getTable() . "`.`is_deleted` = '0' ";
         }
         $datas["##{$objettype}.numberofunresolved##"] = countElementsInTableForEntity($item->getTable(), $this->getEntity(), $restrict);
         // Document
         $query = "SELECT `glpi_documents`.*\n                   FROM `glpi_documents`\n                   LEFT JOIN `glpi_documents_items`\n                     ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n                   WHERE `glpi_documents_items`.`itemtype` =  '" . $item->getType() . "'\n                         AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
         $datas["documents"] = array();
         $addtodownloadurl = '';
         if ($item->getType() == 'Ticket') {
             $addtodownloadurl = "%2526tickets_id=" . $item->fields['id'];
         }
         if ($result = $DB->query($query)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $tmp = array();
                 $tmp['##document.id##'] = $data['id'];
                 $tmp['##document.name##'] = $data['name'];
                 $tmp['##document.weblink##'] = $data['link'];
                 $tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']);
                 $downloadurl = "/front/document.send.php?docid=" . $data['id'];
                 $tmp['##document.downloadurl##'] = $this->formatURL($options['additionnaloption']['usertype'], $downloadurl . $addtodownloadurl);
                 $tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']);
                 $tmp['##document.filename##'] = $data['filename'];
                 $datas['documents'][] = $tmp;
             }
         }
         $datas["##{$objettype}.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . '_Document_Item$1');
         $datas["##{$objettype}.numberofdocuments##"] = count($datas['documents']);
         //costs infos
         $costtype = $item->getType() . 'Cost';
         $costs = $costtype::getCostsSummary($costtype, $item->getField("id"));
         $datas["##{$objettype}.costfixed##"] = $costs['costfixed'];
         $datas["##{$objettype}.costmaterial##"] = $costs['costmaterial'];
         $datas["##{$objettype}.costtime##"] = $costs['costtime'];
         $datas["##{$objettype}.totalcost##"] = $costs['totalcost'];
         $restrict = "`" . $item->getForeignKeyField() . "`='" . $item->getField('id') . "'";
         $restrict .= " ORDER BY `begin_date` DESC, `id` ASC";
         $costs = getAllDatasFromTable(getTableForItemType($costtype), $restrict);
         $datas['costs'] = array();
         foreach ($costs as $cost) {
             $tmp = array();
             $tmp['##cost.name##'] = $cost['name'];
             $tmp['##cost.comment##'] = $cost['comment'];
             $tmp['##cost.datebegin##'] = Html::convDate($cost['begin_date']);
             $tmp['##cost.dateend##'] = Html::convDate($cost['end_date']);
             $tmp['##cost.time##'] = $item->getActionTime($cost['actiontime']);
             $tmp['##cost.costtime##'] = Html::formatNumber($cost['cost_time']);
             $tmp['##cost.costfixed##'] = Html::formatNumber($cost['cost_fixed']);
             $tmp['##cost.costmaterial##'] = Html::formatNumber($cost['cost_material']);
             $tmp['##cost.totalcost##'] = CommonITILCost::computeTotalCost($cost['actiontime'], $cost['cost_time'], $cost['cost_fixed'], $cost['cost_material']);
             $tmp['##cost.budget##'] = Dropdown::getDropdownName('glpi_budgets', $cost['budgets_id']);
             $datas['costs'][] = $tmp;
         }
         $datas["##{$objettype}.numberofcosts##"] = count($datas['costs']);
         //Task infos
         $tasktype = $item->getType() . 'Task';
         $taskobj = new $tasktype();
         $restrict = "`" . $item->getForeignKeyField() . "`='" . $item->getField('id') . "'";
         if ($taskobj->maybePrivate() && (!isset($options['additionnaloption']['show_private']) || !$options['additionnaloption']['show_private'])) {
             $restrict .= " AND `is_private` = '0'";
         }
         $restrict .= " ORDER BY `date` DESC, `id` ASC";
         $tasks = getAllDatasFromTable($taskobj->getTable(), $restrict);
         $datas['tasks'] = array();
         foreach ($tasks as $task) {
             $tmp = array();
             $tmp['##task.id##'] = $task['id'];
             if ($taskobj->maybePrivate()) {
                 $tmp['##task.isprivate##'] = Dropdown::getYesNo($task['is_private']);
             }
             $tmp['##task.author##'] = Html::clean(getUserName($task['users_id']));
             $tmp_taskcatinfo = Dropdown::getDropdownName('glpi_taskcategories', $task['taskcategories_id'], true, true, false);
             $tmp['##task.categoryid##'] = $task['taskcategories_id'];
             $tmp['##task.category##'] = $tmp_taskcatinfo['name'];
             $tmp['##task.categorycomment##'] = $tmp_taskcatinfo['comment'];
             $tmp['##task.date##'] = Html::convDateTime($task['date']);
             $tmp['##task.description##'] = $task['content'];
             $tmp['##task.time##'] = Ticket::getActionTime($task['actiontime']);
             $tmp['##task.status##'] = Planning::getState($task['state']);
             $tmp['##task.user##'] = Html::clean(getUserName($task['users_id_tech']));
             $tmp['##task.group##'] = Html::clean(Toolbox::clean_cross_side_scripting_deep(Dropdown::getDropdownName("glpi_groups", $task['groups_id_tech'])), true, 2, false);
             $tmp['##task.begin##'] = "";
             $tmp['##task.end##'] = "";
             if (!is_null($task['begin'])) {
                 $tmp['##task.begin##'] = Html::convDateTime($task['begin']);
                 $tmp['##task.end##'] = Html::convDateTime($task['end']);
             }
             $datas['tasks'][] = $tmp;
         }
         $datas["##{$objettype}.numberoftasks##"] = count($datas['tasks']);
     }
     return $datas;
 }
 /**
  * @param $item            CommonDBTM object
  * @param $options   array
  * @param $simple          (false by default)
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI, $DB;
     $objettype = strtolower($item->getType());
     $datas["##{$objettype}.title##"] = $item->getField('name');
     $datas["##{$objettype}.content##"] = $item->getField('content');
     $datas["##{$objettype}.description##"] = $item->getField('content');
     $datas["##{$objettype}.id##"] = sprintf("%07d", $item->getField("id"));
     $datas["##{$objettype}.url##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id"));
     $datas["##{$objettype}.urlapprove##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . "_" . $item->getType() . '$2');
     $entity = new Entity();
     if ($entity->getFromDB($this->getEntity())) {
         $datas["##{$objettype}.entity##"] = $entity->getField('completename');
         $datas["##{$objettype}.shortentity##"] = $entity->getField('name');
     }
     $datas["##{$objettype}.storestatus##"] = $item->getField('status');
     $datas["##{$objettype}.status##"] = $item->getStatus($item->getField('status'));
     $datas["##{$objettype}.urgency##"] = $item->getUrgencyName($item->getField('urgency'));
     $datas["##{$objettype}.impact##"] = $item->getImpactName($item->getField('impact'));
     $datas["##{$objettype}.priority##"] = $item->getPriorityName($item->getField('priority'));
     $datas["##{$objettype}.time##"] = $item->getActionTime($item->getField('actiontime'));
     $datas["##{$objettype}.creationdate##"] = Html::convDateTime($item->getField('date'));
     $datas["##{$objettype}.closedate##"] = Html::convDateTime($item->getField('closedate'));
     $datas["##{$objettype}.solvedate##"] = Html::convDateTime($item->getField('solvedate'));
     $datas["##{$objettype}.duedate##"] = Html::convDateTime($item->getField('due_date'));
     $datas["##{$objettype}.category##"] = '';
     if ($item->getField('itilcategories_id')) {
         $datas["##{$objettype}.category##"] = Dropdown::getDropdownName('glpi_itilcategories', $item->getField('itilcategories_id'));
     }
     $datas["##{$objettype}.authors##"] = '';
     $datas['authors'] = array();
     if ($item->countUsers(CommonITILActor::REQUESTER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $tmpusr) {
             $uid = $tmpusr['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $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##'] = '';
                 }
                 if ($user_tmp->getField('usertitles_id')) {
                     $tmp['##author.title##'] = Dropdown::getDropdownName('glpi_usertitles', $user_tmp->getField('usertitles_id'));
                 } else {
                     $tmp['##author.title##'] = '';
                 }
                 if ($user_tmp->getField('usercategories_id')) {
                     $tmp['##author.category##'] = Dropdown::getDropdownName('glpi_usercategories', $user_tmp->getField('usercategories_id'));
                 } else {
                     $tmp['##author.category##'] = '';
                 }
                 $tmp['##author.email##'] = $user_tmp->getDefaultEmail();
                 $tmp['##author.mobile##'] = $user_tmp->getField('mobile');
                 $tmp['##author.phone##'] = $user_tmp->getField('phone');
                 $tmp['##author.phone2##'] = $user_tmp->getField('phone2');
                 $datas['authors'][] = $tmp;
             } else {
                 // Anonymous users only in xxx.authors, not in authors
                 $users[] = $tmpusr['alternative_email'];
             }
         }
         $datas["##{$objettype}.authors##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.openbyuser##"] = '';
     if ($item->getField('users_id_recipient')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_recipient'));
         $datas["##{$objettype}.openbyuser##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.lastupdater##"] = '';
     if ($item->getField('users_id_lastupdater')) {
         $user_tmp = new User();
         $user_tmp->getFromDB($item->getField('users_id_lastupdater'));
         $datas["##{$objettype}.lastupdater##"] = $user_tmp->getName();
     }
     $datas["##{$objettype}.assigntousers##"] = '';
     if ($item->countUsers(CommonITILActor::ASSIGN)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($user_tmp->getFromDB($uid)) {
                 $users[$uid] = $user_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntousers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntosupplier##"] = '';
     if ($item->countSuppliers(CommonITILActor::ASSIGN)) {
         $suppliers = array();
         foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $tmp) {
             $uid = $tmp['suppliers_id'];
             $supplier_tmp = new Supplier();
             if ($supplier_tmp->getFromDB($uid)) {
                 $suppliers[$uid] = $supplier_tmp->getName();
             }
         }
         $datas["##{$objettype}.assigntosupplier##"] = implode(', ', $suppliers);
     }
     $datas["##{$objettype}.groups##"] = '';
     if ($item->countGroups(CommonITILActor::REQUESTER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::REQUESTER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.groups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observergroups##"] = '';
     if ($item->countGroups(CommonITILActor::OBSERVER)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::OBSERVER) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.observergroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.observerusers##"] = '';
     if ($item->countUsers(CommonITILActor::OBSERVER)) {
         $users = array();
         foreach ($item->getUsers(CommonITILActor::OBSERVER) as $tmp) {
             $uid = $tmp['users_id'];
             $user_tmp = new User();
             if ($uid && $user_tmp->getFromDB($uid)) {
                 $users[] = $user_tmp->getName();
             } else {
                 $users[] = $tmp['alternative_email'];
             }
         }
         $datas["##{$objettype}.observerusers##"] = implode(', ', $users);
     }
     $datas["##{$objettype}.assigntogroups##"] = '';
     if ($item->countGroups(CommonITILActor::ASSIGN)) {
         $groups = array();
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
             $gid = $tmp['groups_id'];
             $groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
         }
         $datas["##{$objettype}.assigntogroups##"] = implode(', ', $groups);
     }
     $datas["##{$objettype}.solution.type##"] = '';
     if ($item->getField('solutiontypes_id')) {
         $datas["##{$objettype}.solution.type##"] = Dropdown::getDropdownName('glpi_solutiontypes', $item->getField('solutiontypes_id'));
     }
     $datas["##{$objettype}.solution.description##"] = Toolbox::unclean_cross_side_scripting_deep($item->getField('solution'));
     $datas['log'] = array();
     // Use list_limit_max or load the full history ?
     foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
         $tmp = array();
         $tmp["##{$objettype}.log.date##"] = $data['date_mod'];
         $tmp["##{$objettype}.log.user##"] = $data['user_name'];
         $tmp["##{$objettype}.log.field##"] = $data['field'];
         $tmp["##{$objettype}.log.content##"] = $data['change'];
         $datas['log'][] = $tmp;
     }
     $datas["##{$objettype}.numberoflogs##"] = count($datas['log']);
     // Get unresolved items
     $restrict = "`" . $item->getTable() . "`.`status`\n                     NOT IN ('" . implode("', '", array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray())) . "'\n                             )";
     if ($item->maybeDeleted()) {
         $restrict .= " AND `" . $item->getTable() . "`.`is_deleted` = '0' ";
     }
     $datas["##{$objettype}.numberofunresolved##"] = countElementsInTableForEntity($item->getTable(), $this->getEntity(), $restrict);
     // Document
     $query = "SELECT `glpi_documents`.*\n                 FROM `glpi_documents`\n                 LEFT JOIN `glpi_documents_items`\n                      ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n                 WHERE `glpi_documents_items`.`itemtype` =  '{$objettype}'\n                       AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
     $datas["documents"] = array();
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_assoc($result)) {
             $tmp = array();
             $tmp['##document.id##'] = $data['id'];
             $tmp['##document.name##'] = $data['name'];
             $tmp['##document.weblink##'] = $data['link'];
             $tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']);
             $tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']);
             $tmp['##document.filename##'] = $data['filename'];
             $datas['documents'][] = $tmp;
         }
     }
     $datas["##{$objettype}.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], $objettype . "_" . $item->getField("id") . '_Document_Item$1');
     $datas["##{$objettype}.numberofdocuments##"] = count($datas['documents']);
     return $datas;
 }
Пример #9
0
 function sendEmail($data)
 {
     $users = array();
     foreach ($data["item"] as $key => $val) {
         if ($val == 1) {
             $restrict = "`itemtype` = 'User'\n                     AND `plugin_resources_resources_id` = '" . $key . "'";
             $resources = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict);
             if (!empty($resources)) {
                 foreach ($resources as $resource) {
                     $users[] = $resource["items_id"];
                 }
             }
         }
     }
     $User = new User();
     $mail = "";
     $first = true;
     foreach ($users as $key => $val) {
         if ($User->getFromDB($val)) {
             $email = $User->getDefaultEmail();
             if (!empty($email)) {
                 if (!$first) {
                     $mail .= ";";
                 } else {
                     $first = false;
                 }
                 $mail .= $email;
             }
         }
     }
     $send = "<a href='mailto:{$mail}'>" . __('Click here to send your email', 'resources') . "</a>";
     Session::addMessageAfterRedirect($send);
     return true;
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $CFG_GLPI, $DB;
     if ($event == 'AlertExpiredTasks') {
         $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
         $this->datas['##lang.resource.entity##'] = __('Entity');
         $this->datas['##resource.action##'] = __('List of not finished tasks', 'resources');
         $this->datas['##lang.task.name##'] = __('Name');
         $this->datas['##lang.task.type##'] = __('Type');
         $this->datas['##lang.task.users##'] = __('Technician');
         $this->datas['##lang.task.groups##'] = __('Group');
         $this->datas['##lang.task.datebegin##'] = __('Begin date');
         $this->datas['##lang.task.dateend##'] = __('End date');
         $this->datas['##lang.task.planned##'] = __('Used for planning', 'resources');
         $this->datas['##lang.task.realtime##'] = __('Effective duration', 'resources');
         $this->datas['##lang.task.finished##'] = __('Carried out task', 'resources');
         $this->datas['##lang.task.comment##'] = __('Comments');
         $this->datas['##lang.task.resource##'] = PluginResourcesResource::getTypeName(1);
         foreach ($options['tasks'] as $id => $task) {
             $tmp = array();
             $tmp['##task.name##'] = $task['name'];
             $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_tasktypes', $task['plugin_resources_tasktypes_id']);
             $tmp['##task.users##'] = Html::clean(getUserName($task['users_id']));
             $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']);
             $restrict = " `plugin_resources_tasks_id` = '" . $task['id'] . "' ";
             $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
             if (!empty($plans)) {
                 foreach ($plans as $plan) {
                     $tmp['##task.datebegin##'] = Html::convDateTime($plan["begin"]);
                     $tmp['##task.dateend##'] = Html::convDateTime($plan["end"]);
                 }
             } else {
                 $tmp['##task.datebegin##'] = '';
                 $tmp['##task.dateend##'] = '';
             }
             $tmp['##task.planned##'] = '';
             $tmp['##task.finished##'] = Dropdown::getYesNo($task['is_finished']);
             $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]);
             $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment']));
             $tmp['##task.comment##'] = Html::clean($comment);
             $tmp['##task.resource##'] = Dropdown::getDropdownName('glpi_plugin_resources_resources', $task['plugin_resources_resources_id']);
             $this->datas['tasks'][] = $tmp;
         }
     } else {
         if ($event == 'AlertLeavingResources') {
             $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
             $this->datas['##lang.resource.entity##'] = __('Entity');
             $this->datas['##resource.action##'] = __('These resources have normally left the company', 'resources');
             $this->datas['##lang.resource.id##'] = "ID";
             $this->datas['##lang.resource.name##'] = __('Name');
             $this->datas['##lang.resource.firstname##'] = __('First name');
             $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
             $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
             $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
             $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
             $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
             $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
             $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
             $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
             $this->datas['##lang.resource.location##'] = __('Location');
             $this->datas['##lang.resource.comment##'] = __('Description');
             $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
             $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
             $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
             $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
             $this->datas['##lang.resource.url##'] = __('URL');
             foreach ($options['resources'] as $id => $resource) {
                 $tmp = array();
                 $tmp['##resource.name##'] = $resource['name'];
                 $tmp['##resource.firstname##'] = $resource['firstname'];
                 $tmp['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $resource['plugin_resources_contracttypes_id']);
                 $tmp['##resource.users##'] = Html::clean(getUserName($resource['users_id']));
                 $tmp['##resource.usersrecipient##'] = Html::clean(getUserName($resource['users_id_recipient']));
                 $tmp['##resource.datedeclaration##'] = Html::convDateTime($resource['date_declaration']);
                 $tmp['##resource.datebegin##'] = Html::convDateTime($resource['date_begin']);
                 $tmp['##resource.dateend##'] = Html::convDateTime($resource['date_end']);
                 $tmp['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $resource['plugin_resources_departments_id']);
                 $tmp['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $resource['plugin_resources_resourcestates_id']);
                 $tmp['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $resource['locations_id']);
                 $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $resource['comment']));
                 $tmp['##resource.comment##'] = Html::clean($comment);
                 $tmp['##resource.usersleaving##'] = Html::clean(getUserName($resource['users_id_recipient_leaving']));
                 $tmp['##resource.leaving##'] = Dropdown::getYesNo($resource['is_leaving']);
                 $tmp['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $resource['plugin_resources_leavingreasons_id']);
                 $tmp['##resource.helpdesk##'] = Dropdown::getYesNo($resource['is_helpdesk_visible']);
                 $tmp['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $resource['id']);
                 $this->datas['resources'][] = $tmp;
             }
         } else {
             if ($event == 'AlertArrivalChecklists' || $event == 'AlertLeavingChecklists') {
                 $this->datas['##checklist.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
                 $this->datas['##lang.checklist.entity##'] = __('Entity');
                 if ($event == 'AlertArrivalChecklists') {
                     $checklist_type = PluginResourcesChecklist::RESOURCES_CHECKLIST_IN;
                     $this->datas['##checklist.action##'] = __('Actions to do on these new resources', 'resources');
                     $this->datas['##lang.checklist.title##'] = __('New resource - checklist needs to verificated', 'resources');
                 } else {
                     $checklist_type = PluginResourcesChecklist::RESOURCES_CHECKLIST_OUT;
                     $this->datas['##checklist.action##'] = __('Actions to do on these leaving resources', 'resources');
                     $this->datas['##lang.checklist.title##'] = __('Leaving resource - checklist needs to verificated', 'resources');
                 }
                 $this->datas['##lang.checklist.title2##'] = __('Checklist needs to verificated', 'resources');
                 $this->datas['##lang.checklist.id##'] = "ID";
                 $this->datas['##lang.checklist.name##'] = __('Name');
                 $this->datas['##lang.checklist.firstname##'] = __('First name');
                 $this->datas['##lang.checklist.type##'] = PluginResourcesContractType::getTypeName(1);
                 $this->datas['##lang.checklist.users##'] = __('Resource manager', 'resources');
                 $this->datas['##lang.checklist.usersrecipient##'] = __('Requester');
                 $this->datas['##lang.checklist.datedeclaration##'] = __('Request date');
                 $this->datas['##lang.checklist.datebegin##'] = __('Arrival date', 'resources');
                 $this->datas['##lang.checklist.dateend##'] = __('Departure date', 'resources');
                 $this->datas['##lang.checklist.department##'] = PluginResourcesDepartment::getTypeName(1);
                 $this->datas['##lang.checklist.status##'] = PluginResourcesResourceState::getTypeName(1);
                 $this->datas['##lang.checklist.location##'] = __('Location');
                 $this->datas['##lang.checklist.comment##'] = __('Description');
                 $this->datas['##lang.checklist.usersleaving##'] = __('Informant of leaving', 'resources');
                 $this->datas['##lang.checklist.leaving##'] = __('Declared as leaving', 'resources');
                 //         $this->datas['##lang.checklist.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                 $this->datas['##lang.checklist.helpdesk##'] = __('Associable to a ticket');
                 $this->datas['##lang.checklist.url##'] = "URL";
                 foreach ($options['checklists'] as $id => $checklist) {
                     $tmp = array();
                     $tmp['##checklist.id##'] = $checklist['plugin_resources_resources_id'];
                     $tmp['##checklist.name##'] = $checklist['resource_name'];
                     $tmp['##checklist.firstname##'] = $checklist['resource_firstname'];
                     $tmp['##checklist.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $checklist['plugin_resources_contracttypes_id']);
                     $tmp['##checklist.users##'] = Html::clean(getUserName($checklist['users_id']));
                     $tmp['##checklist.usersrecipient##'] = Html::clean(getUserName($checklist['users_id_recipient']));
                     $tmp['##checklist.datedeclaration##'] = Html::convDateTime($checklist['date_declaration']);
                     $tmp['##checklist.datebegin##'] = Html::convDateTime($checklist['date_begin']);
                     $tmp['##checklist.dateend##'] = Html::convDateTime($checklist['date_end']);
                     $tmp['##checklist.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $checklist['plugin_resources_departments_id']);
                     $tmp['##checklist.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $checklist['plugin_resources_resourcestates_id']);
                     $tmp['##checklist.location##'] = Dropdown::getDropdownName('glpi_locations', $checklist['locations_id']);
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $checklist['comment']));
                     $tmp['##checklist.comment##'] = Html::clean($comment);
                     $tmp['##checklist.usersleaving##'] = Html::clean(getUserName($checklist['users_id_recipient_leaving']));
                     $tmp['##checklist.leaving##'] = Dropdown::getYesNo($checklist['is_leaving']);
                     //            $tmp['##checklist.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons',
                     //                                                   $checklist['plugin_resources_leavingreasons_id']);
                     $tmp['##checklist.helpdesk##'] = Dropdown::getYesNo($checklist['is_helpdesk_visible']);
                     $tmp['##checklist.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $checklist['plugin_resources_resources_id']);
                     $query = PluginResourcesChecklist::queryListChecklists($checklist['plugin_resources_resources_id'], $checklist_type);
                     $tmp['##tasklist.name##'] = '';
                     foreach ($DB->request($query) as $data) {
                         $tmp['##tasklist.name##'] .= $data["name"];
                         if ($_SESSION["glpiis_ids_visible"] == 1) {
                             $tmp['##tasklist.name##'] .= " (" . $data["id"] . ")";
                         }
                         $tmp['##tasklist.name##'] .= "\n";
                     }
                     $this->datas['checklists'][] = $tmp;
                 }
             } else {
                 if ($event == 'LeavingResource') {
                     $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id'));
                     $this->datas['##lang.resource.entity##'] = __('Entity');
                     $this->datas['##lang.resource.title##'] = __('A resource has been declared leaving', 'resources');
                     $this->datas['##lang.resource.title2##'] = __('Please check the leaving checklist of the resource', 'resources');
                     $this->datas['##lang.resource.id##'] = "ID";
                     $this->datas['##resource.id##'] = $this->obj->getField("id");
                     $this->datas['##lang.resource.name##'] = __('Name');
                     $this->datas['##resource.name##'] = $this->obj->getField("name");
                     $this->datas['##lang.resource.firstname##'] = __('First name');
                     $this->datas['##resource.firstname##'] = $this->obj->getField("firstname");
                     $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
                     $this->datas['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->obj->getField('plugin_resources_contracttypes_id'));
                     $this->datas['##lang.resource.situation##'] = PluginResourcesResourceSituation::getTypeName(1);
                     $this->datas['##resource.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->obj->getField('plugin_resources_resourcesituations_id'));
                     $this->datas['##lang.resource.contractnature##'] = PluginResourcesContractNature::getTypeName(1);
                     $this->datas['##resource.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->obj->getField('plugin_resources_contractnatures_id'));
                     $this->datas['##lang.resource.quota##'] = __('Quota', 'resources');
                     $this->datas['##resource.quota##'] = $this->obj->getField('quota');
                     $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
                     $this->datas['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->obj->getField('plugin_resources_departments_id'));
                     $this->datas['##lang.resource.rank##'] = PluginResourcesRank::getTypeName(1);
                     $this->datas['##resource.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->obj->getField('plugin_resources_ranks_id'));
                     $this->datas['##lang.resource.speciality##'] = PluginResourcesResourceSpeciality::getTypeName(1);
                     $this->datas['##resource.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->obj->getField('plugin_resources_resourcespecialities_id'));
                     $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
                     $this->datas['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->obj->getField('plugin_resources_resourcestates_id'));
                     $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
                     $this->datas['##resource.users##'] = Html::clean(getUserName($this->obj->getField("users_id")));
                     $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
                     $this->datas['##resource.usersrecipient##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient")));
                     $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
                     $this->datas['##resource.datedeclaration##'] = Html::convDate($this->obj->getField('date_declaration'));
                     $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
                     $this->datas['##resource.datebegin##'] = Html::convDate($this->obj->getField('date_begin'));
                     $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
                     $this->datas['##resource.dateend##'] = Html::convDate($this->obj->getField('date_end'));
                     $this->datas['##lang.resource.location##'] = __('Location');
                     $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $this->obj->getField('locations_id'));
                     $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
                     $this->datas['##resource.helpdesk##'] = Dropdown::getYesNo($this->obj->getField('is_helpdesk_visible'));
                     $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
                     $this->datas['##resource.leaving##'] = Dropdown::getYesNo($this->obj->getField('is_leaving'));
                     $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                     $this->datas['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->obj->getField('plugin_resources_leavingreasons_id'));
                     $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
                     $this->datas['##resource.usersleaving##'] = Html::clean(getUserName($this->obj->getField('users_id_recipient_leaving')));
                     $this->datas['##lang.resource.comment##'] = __('Description');
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment")));
                     $this->datas['##resource.comment##'] = Html::clean($comment);
                     $this->datas['##lang.resource.url##'] = "URL";
                     $this->datas['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $this->obj->getField("id"));
                     $this->datas['##lang.resource.badge##'] = " ";
                     if (isset($this->target_object->input['checkbadge'])) {
                         if (!empty($this->target_object->input['checkbadge'])) {
                             $this->datas['##lang.resource.badge##'] = __('Thanks to recover his badges', 'resources');
                         } else {
                             $this->datas['##lang.resource.badge##'] = " ";
                         }
                     }
                 } else {
                     $events = $this->getAllEvents();
                     $this->datas['##lang.resource.title##'] = $events[$event];
                     $this->datas['##resource.action_user##'] = getUserName(Session::getLoginUserID());
                     $this->datas['##lang.resource.entity##'] = __('Entity');
                     $this->datas['##resource.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id'));
                     $this->datas['##resource.id##'] = $this->obj->getField("id");
                     $this->datas['##lang.resource.name##'] = __('Name');
                     $this->datas['##resource.name##'] = $this->obj->getField("name");
                     $this->datas['##lang.resource.firstname##'] = __('First name');
                     $this->datas['##resource.firstname##'] = $this->obj->getField("firstname");
                     $this->datas['##lang.resource.type##'] = PluginResourcesContractType::getTypeName(1);
                     $this->datas['##resource.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->obj->getField('plugin_resources_contracttypes_id'));
                     $this->datas['##lang.resource.situation##'] = PluginResourcesResourceSituation::getTypeName(1);
                     $this->datas['##resource.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->obj->getField('plugin_resources_resourcesituations_id'));
                     $this->datas['##lang.resource.contractnature##'] = PluginResourcesContractNature::getTypeName(1);
                     $this->datas['##resource.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->obj->getField('plugin_resources_contractnatures_id'));
                     $this->datas['##lang.resource.quota##'] = __('Quota', 'resources');
                     $this->datas['##resource.quota##'] = $this->obj->getField('quota');
                     $this->datas['##lang.resource.users##'] = __('Resource manager', 'resources');
                     $this->datas['##resource.users##'] = Html::clean(getUserName($this->obj->getField("users_id")));
                     $this->datas['##lang.resource.usersrecipient##'] = __('Requester');
                     $this->datas['##resource.usersrecipient##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient")));
                     $this->datas['##lang.resource.datedeclaration##'] = __('Request date');
                     $this->datas['##resource.datedeclaration##'] = Html::convDate($this->obj->getField('date_declaration'));
                     $this->datas['##lang.resource.datebegin##'] = __('Arrival date', 'resources');
                     $this->datas['##resource.datebegin##'] = Html::convDate($this->obj->getField('date_begin'));
                     $this->datas['##lang.resource.dateend##'] = __('Departure date', 'resources');
                     $this->datas['##resource.dateend##'] = Html::convDate($this->obj->getField('date_end'));
                     $this->datas['##lang.resource.department##'] = PluginResourcesDepartment::getTypeName(1);
                     $this->datas['##resource.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->obj->getField('plugin_resources_departments_id'));
                     $this->datas['##lang.resource.rank##'] = PluginResourcesRank::getTypeName(1);
                     $this->datas['##resource.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->obj->getField('plugin_resources_ranks_id'));
                     $this->datas['##lang.resource.speciality##'] = PluginResourcesResourceSpeciality::getTypeName(1);
                     $this->datas['##resource.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->obj->getField('plugin_resources_resourcespecialities_id'));
                     $this->datas['##lang.resource.status##'] = PluginResourcesResourceState::getTypeName(1);
                     $this->datas['##resource.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->obj->getField('plugin_resources_resourcestates_id'));
                     $this->datas['##lang.resource.location##'] = __('Location');
                     $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $this->obj->getField('locations_id'));
                     $this->datas['##lang.resource.comment##'] = __('Description');
                     $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment")));
                     $this->datas['##resource.comment##'] = Html::clean($comment);
                     $this->datas['##lang.resource.usersleaving##'] = __('Informant of leaving', 'resources');
                     $this->datas['##resource.usersleaving##'] = Html::clean(getUserName($this->obj->getField("users_id_recipient_leaving")));
                     $this->datas['##lang.resource.leaving##'] = __('Declared as leaving', 'resources');
                     $this->datas['##resource.leaving##'] = Dropdown::getYesNo($this->obj->getField('is_leaving'));
                     $this->datas['##lang.resource.leavingreason##'] = PluginResourcesLeavingReason::getTypeName(1);
                     $this->datas['##resource.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->obj->getField('plugin_resources_leavingreasons_id'));
                     $this->datas['##lang.resource.helpdesk##'] = __('Associable to a ticket');
                     $this->datas['##resource.helpdesk##'] = Dropdown::getYesNo($this->obj->getField('is_helpdesk_visible'));
                     $this->datas['##lang.resource.url##'] = "URL";
                     $this->datas['##resource.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_resources_" . $this->obj->getField("id"));
                     if ($event == 'report') {
                         $this->datas['##lang.resource.creationtitle##'] = __('Creation report of the human resource', 'resources');
                         $this->datas['##resource.login##'] = "";
                         $this->datas['##resource.email##'] = "";
                         $restrict = "`itemtype` = 'User' \n                        AND `plugin_resources_resources_id` = '" . $this->obj->getField("id") . "'";
                         $items = getAllDatasFromTable("glpi_plugin_resources_resources_items", $restrict);
                         if (!empty($items)) {
                             foreach ($items as $item) {
                                 $user = new User();
                                 $user->getFromDB($item["items_id"]);
                                 $this->datas['##resource.login##'] = $user->fields["name"];
                                 $this->datas['##resource.email##'] = $user->getDefaultEmail();
                             }
                         }
                         $this->datas['##lang.resource.login##'] = __('Login');
                         $this->datas['##lang.resource.creation##'] = __('Informations of the created user', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation Date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $this->datas['##lang.resource.email##'] = __('Email');
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $PluginResourcesReportConfig = new PluginResourcesReportConfig();
                         $PluginResourcesReportConfig->getFromDB($options['reports_id']);
                         $this->datas['##lang.resource.informations##'] = __('Information', 'Informations', 2);
                         $information = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesReportConfig->fields['information']));
                         $this->datas['##resource.informations##'] = Html::clean(nl2br($information));
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesReportConfig->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                     }
                     if ($event == 'newresting' || $event == 'updateresting' || $event == 'deleteresting') {
                         $this->datas['##lang.resource.restingtitle##'] = __('Non contract period management', 'resources');
                         $this->datas['##lang.resource.resting##'] = __('Detail of non contract period', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $PluginResourcesResourceResting = new PluginResourcesResourceResting();
                         $PluginResourcesResourceResting->getFromDB($options['resting_id']);
                         $this->datas['##lang.resource.location##'] = __('Agency concerned');
                         $this->datas['##resource.location##'] = Dropdown::getDropdownName('glpi_locations', $PluginResourcesResourceResting->fields['locations_id']);
                         $this->datas['##lang.resource.home##'] = __('At home');
                         $this->datas['##resource.home##'] = Dropdown::getYesNo($PluginResourcesResourceResting->fields['at_home']);
                         $this->datas['##lang.resource.datebegin##'] = __('Begin date');
                         $this->datas['##resource.datebegin##'] = Html::convDate($PluginResourcesResourceResting->fields['date_begin']);
                         $this->datas['##lang.resource.dateend##'] = __('End date');
                         $this->datas['##resource.dateend##'] = Html::convDate($PluginResourcesResourceResting->fields['date_end']);
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesResourceResting->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                         $this->datas['##lang.resource.openby##'] = __('Reported by', 'resources');
                         $this->datas['##resource.openby##'] = Html::clean(getUserName(Session::getLoginUserID()));
                         if (isset($options['oldvalues']) && !empty($options['oldvalues'])) {
                             $this->target_object->oldvalues = $options['oldvalues'];
                         }
                     }
                     if ($event == 'newholiday' || $event == 'updateholiday' || $event == 'deleteholiday') {
                         $this->datas['##lang.resource.holidaytitle##'] = __('Forced holiday management', 'resources');
                         $this->datas['##lang.resource.holiday##'] = __('Detail of the forced holiday', 'resources');
                         $this->datas['##lang.resource.datecreation##'] = __('Creation date');
                         $this->datas['##resource.datecreation##'] = Html::convDate(date("Y-m-d"));
                         $PluginResourcesResourceHoliday = new PluginResourcesResourceHoliday();
                         $PluginResourcesResourceHoliday->getFromDB($options['holiday_id']);
                         $this->datas['##lang.resource.datebegin##'] = __('Begin date');
                         $this->datas['##resource.datebegin##'] = Html::convDate($PluginResourcesResourceHoliday->fields['date_begin']);
                         $this->datas['##lang.resource.dateend##'] = __('End date');
                         $this->datas['##resource.dateend##'] = Html::convDate($PluginResourcesResourceHoliday->fields['date_end']);
                         $this->datas['##lang.resource.informationtitle##'] = __('Additional informations', 'resources');
                         $this->datas['##lang.resource.commentaires##'] = __('Comments');
                         $commentaire = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br>", $PluginResourcesResourceHoliday->fields['comment']));
                         $this->datas['##resource.commentaires##'] = Html::clean(nl2br($commentaire));
                         $this->datas['##lang.resource.openby##'] = __('Reported by', 'resources');
                         $this->datas['##resource.openby##'] = Html::clean(getUserName(Session::getLoginUserID()));
                         if (isset($options['oldvalues']) && !empty($options['oldvalues'])) {
                             $this->target_object->oldvalues = $options['oldvalues'];
                         }
                     }
                     //old values infos
                     if (isset($this->target_object->oldvalues) && !empty($this->target_object->oldvalues) && ($event == 'update' || $event == 'updateresting' || $event == 'updateholiday')) {
                         $this->datas['##lang.update.title##'] = __('Modified fields', 'resources');
                         $tmp = array();
                         if (isset($this->target_object->oldvalues['name'])) {
                             if (empty($this->target_object->oldvalues['name'])) {
                                 $tmp['##update.name##'] = "---";
                             } else {
                                 $tmp['##update.name##'] = $this->target_object->oldvalues['name'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['firstname'])) {
                             if (empty($this->target_object->oldvalues['firstname'])) {
                                 $tmp['##update.firstname##'] = "---";
                             } else {
                                 $tmp['##update.firstname##'] = $this->target_object->oldvalues['firstname'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_contracttypes_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_contracttypes_id'])) {
                                 $tmp['##update.type##'] = "---";
                             } else {
                                 $tmp['##update.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_contracttypes', $this->target_object->oldvalues['plugin_resources_contracttypes_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id'])) {
                             if (empty($this->target_object->oldvalues['users_id'])) {
                                 $tmp['##update.users##'] = "---";
                             } else {
                                 $tmp['##update.users##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id_recipient'])) {
                             if (empty($this->target_object->oldvalues['users_id_recipient'])) {
                                 $tmp['##update.usersrecipient##'] = "---";
                             } else {
                                 $tmp['##update.usersrecipient##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id_recipient']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_declaration'])) {
                             if (empty($this->target_object->oldvalues['date_declaration'])) {
                                 $tmp['##update.datedeclaration##'] = "---";
                             } else {
                                 $tmp['##update.datedeclaration##'] = Html::convDate($this->target_object->oldvalues['date_declaration']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_begin'])) {
                             if (empty($this->target_object->oldvalues['date_begin'])) {
                                 $tmp['##update.datebegin##'] = "---";
                             } else {
                                 $tmp['##update.datebegin##'] = Html::convDate($this->target_object->oldvalues['date_begin']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['date_end'])) {
                             if (empty($this->target_object->oldvalues['date_end'])) {
                                 $tmp['##update.dateend##'] = "---";
                             } else {
                                 $tmp['##update.dateend##'] = Html::convDate($this->target_object->oldvalues['date_end']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['quota'])) {
                             if (empty($this->target_object->oldvalues['quota'])) {
                                 $tmp['##update.quota##'] = "---";
                             } else {
                                 $tmp['##update.quota##'] = $this->target_object->oldvalues['quota'];
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_departments_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_departments_id'])) {
                                 $tmp['##update.department##'] = "---";
                             } else {
                                 $tmp['##update.department##'] = Dropdown::getDropdownName('glpi_plugin_resources_departments', $this->target_object->oldvalues['plugin_resources_departments_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcestates_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcestates_id'])) {
                                 $tmp['##update.status##'] = "---";
                             } else {
                                 $tmp['##update.status##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcestates', $this->target_object->oldvalues['plugin_resources_resourcestates_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcesituations_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcesituations_id'])) {
                                 $tmp['##update.situation##'] = "---";
                             } else {
                                 $tmp['##update.situation##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcesituations', $this->target_object->oldvalues['plugin_resources_resourcesituations_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_contractnatures_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_contractnatures_id'])) {
                                 $tmp['##update.contractnature##'] = "---";
                             } else {
                                 $tmp['##update.contractnature##'] = Dropdown::getDropdownName('glpi_plugin_resources_contractnatures', $this->target_object->oldvalues['plugin_resources_contractnatures_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_ranks_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_ranks_id'])) {
                                 $tmp['##update.rank##'] = "---";
                             } else {
                                 $tmp['##update.rank##'] = Dropdown::getDropdownName('glpi_plugin_resources_ranks', $this->target_object->oldvalues['plugin_resources_ranks_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_resourcespecialities_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_resourcespecialities_id'])) {
                                 $tmp['##update.speciality##'] = "---";
                             } else {
                                 $tmp['##update.speciality##'] = Dropdown::getDropdownName('glpi_plugin_resources_resourcespecialities', $this->target_object->oldvalues['plugin_resources_resourcespecialities_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['locations_id'])) {
                             if (empty($this->target_object->oldvalues['locations_id'])) {
                                 $tmp['##update.location##'] = "---";
                             } else {
                                 $tmp['##update.location##'] = Dropdown::getDropdownName('glpi_locations', $this->target_object->oldvalues['locations_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['comment'])) {
                             if (empty($this->target_object->oldvalues['comment'])) {
                                 $tmp['##update.comment##'] = "---";
                             } else {
                                 $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->target_object->oldvalues['comment']));
                                 $tmp['##update.comment##'] = Html::clean($comment);
                             }
                         }
                         if (isset($this->target_object->oldvalues['users_id_recipient_leaving'])) {
                             if (empty($this->target_object->oldvalues['users_id_recipient_leaving'])) {
                                 $tmp['##update.usersleaving##'] = "---";
                             } else {
                                 $tmp['##update.usersleaving##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id_recipient_leaving']));
                             }
                         }
                         if (isset($this->target_object->oldvalues['is_leaving'])) {
                             if (empty($this->target_object->oldvalues['is_leaving'])) {
                                 $tmp['##update.leaving##'] = "---";
                             } else {
                                 $tmp['##update.leaving##'] = Dropdown::getYesNo($this->target_object->oldvalues['is_leaving']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['plugin_resources_leavingreasons_id'])) {
                             if (empty($this->target_object->oldvalues['plugin_resources_leavingreasons_id'])) {
                                 $tmp['##update.leavingreason##'] = "---";
                             } else {
                                 $tmp['##update.leavingreason##'] = Dropdown::getDropdownName('glpi_plugin_resources_leavingreasons', $this->target_object->oldvalues['plugin_resources_leavingreasons_id']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['is_helpdesk_visible'])) {
                             if (empty($this->target_object->oldvalues['is_helpdesk_visible'])) {
                                 $tmp['##update.helpdesk##'] = "---";
                             } else {
                                 $tmp['##update.helpdesk##'] = Dropdown::getYesNo($this->target_object->oldvalues['is_helpdesk_visible']);
                             }
                         }
                         if (isset($this->target_object->oldvalues['at_home'])) {
                             if (empty($this->target_object->oldvalues['at_home'])) {
                                 $tmp['##update.home##'] = "---";
                             } else {
                                 $tmp['##update.home##'] = Dropdown::getYesNo($this->target_object->oldvalues['at_home']);
                             }
                         }
                         $this->datas['updates'][] = $tmp;
                     }
                     //task infos
                     $restrict = "`plugin_resources_resources_id`='" . $this->obj->getField('id') . "' AND `is_deleted` = 0";
                     if (isset($options['tasks_id']) && $options['tasks_id']) {
                         $restrict .= " AND `glpi_plugin_resources_tasks`.`id` = '" . $options['tasks_id'] . "'";
                     }
                     $restrict .= " ORDER BY `name` DESC";
                     $tasks = getAllDatasFromTable('glpi_plugin_resources_tasks', $restrict);
                     $this->datas['##lang.task.title##'] = __('Associated tasks', 'resources');
                     $this->datas['##lang.task.name##'] = __('Name');
                     $this->datas['##lang.task.type##'] = __('Type');
                     $this->datas['##lang.task.users##'] = __('Technician');
                     $this->datas['##lang.task.groups##'] = __('Group');
                     $this->datas['##lang.task.datebegin##'] = __('Begin date');
                     $this->datas['##lang.task.dateend##'] = __('End date');
                     $this->datas['##lang.task.planned##'] = __('Used for planning', 'resources');
                     $this->datas['##lang.task.realtime##'] = __('Effective duration', 'resources');
                     $this->datas['##lang.task.finished##'] = __('Carried out task', 'resources');
                     $this->datas['##lang.task.comment##'] = __('Description');
                     foreach ($tasks as $task) {
                         $tmp = array();
                         $tmp['##task.name##'] = $task['name'];
                         $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_resources_tasktypes', $task['plugin_resources_tasktypes_id']);
                         $tmp['##task.users##'] = Html::clean(getUserName($task['users_id']));
                         $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']);
                         $restrict = " `plugin_resources_tasks_id` = '" . $task['id'] . "' ";
                         $plans = getAllDatasFromTable("glpi_plugin_resources_taskplannings", $restrict);
                         if (!empty($plans)) {
                             foreach ($plans as $plan) {
                                 $tmp['##task.datebegin##'] = Html::convDateTime($plan["begin"]);
                                 $tmp['##task.dateend##'] = Html::convDateTime($plan["end"]);
                             }
                         } else {
                             $tmp['##task.datebegin##'] = '';
                             $tmp['##task.dateend##'] = '';
                         }
                         $tmp['##task.planned##'] = '';
                         $tmp['##task.finished##'] = Dropdown::getYesNo($task['is_finished']);
                         $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]);
                         $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment']));
                         $tmp['##task.comment##'] = Html::clean($comment);
                         $this->datas['tasks'][] = $tmp;
                     }
                 }
             }
         }
     }
 }