getAmortTypeName() static public method

Get amortissement type name for infocoms
static public getAmortTypeName ( $value )
$value status ID
コード例 #1
0
ファイル: infocom.class.php プロジェクト: geldarr/hack-space
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $CFG_GLPI;
     $ID = $item->getField('id');
     if (!Session::haveRight("infocom", "r")) {
         return false;
     }
     $ic = new Infocom();
     $pdf->setColumnsSize(100);
     if ($ic->getFromDBforDevice(get_class($item), $ID)) {
         $pdf->displayTitle("<b>" . __('Financial and administrative information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Supplier') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Budget') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_budgets", $ic->fields["budgets_id"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Order number') . "</i></b>", $ic->fields["order_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Order date') . "</i></b>", Html::convDate($ic->fields["order_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Immobilization number') . "</i></b>", $ic->fields["immo_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Date of purchase') . "</i></b>", Html::convDate($ic->fields["buy_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Invoice number') . "</i></b>", $ic->fields["bill"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery date') . "</i></b>", Html::convDate($ic->fields["delivery_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery form') . "</i></b>", $ic->fields["delivery_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Startup date') . "</i></b>", Html::convDate($ic->fields["use_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), _('Date of last physical inventory') . "</i></b>", Html::convDate($ic->fields["inventory_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty extension value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["warranty_value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization duration') . "</i></b>", sprintf(__('%1$s (%2$s)'), sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]), Infocom::getAmortTypeName($ic->fields["sink_type"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Account net value') . "</i></b>", Infocom::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $CFG_GLPI['date_tax'], "n")), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization coefficient') . "</i></b>", $ic->fields["sink_coeff"]));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('TCO (value + tracking cost)') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Monthly TCO') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]))));
         PluginPdfCommon::mainLine($pdf, $ic, 'comment');
         $pdf->setColumnsSize(100);
         $pdf->displayTitle("<b>" . __('Warranty information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Start date of warranty') . "</i></b>", Html::convDate($ic->fields["warranty_date"])), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty duration') . "</i></b>", sprintf(__('%1$s - %2$s'), sprintf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]), sprintf(__('Valid to %s'), Infocom::getWarrantyExpir($ic->fields["buy_date"], $ic->fields["warranty_duration"])))));
         $col1 = "<b><i>" . __('Alarms on financial and administrative information') . "</i></b>";
         if ($ic->fields["alert"] == 0) {
             $col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
         } else {
             if ($ic->fields["alert"] == 4) {
                 $col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
             }
         }
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty information') . "</i></b>", $ic->fields["warranty_info"]), $col1);
     } else {
         $pdf->displayTitle("<b>" . __('No financial information', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
コード例 #2
0
 /**
  * Generic Function to display Items
  *
  * @param $itemtype              item type
  * @param $ID                    ID of the SEARCH_OPTION item
  * @param $data            array containing data results
  * @param $num                   item num in the request
  * @param $meta                  is a meta item ? (default 0)
  * @param $addobjectparams array added parameters for union search
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array())
 {
     global $CFG_GLPI;
     $showuserlink = 0;
     if (Session::haveRight('user', READ)) {
         $showuserlink = 1;
     }
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) {
             return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']);
         }
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     if (count($addobjectparams)) {
         $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     if ($meta) {
         $NAME = "META_";
     }
     $table = $searchopt[$ID]["table"];
     $field = $searchopt[$ID]["field"];
     $linkfield = $searchopt[$ID]["linkfield"];
     /// TODO try to clean all specific cases using SpecificToDisplay
     switch ($table . '.' . $field) {
         case "glpi_users.name":
             // USER search case
             if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if ($split[$k] > 0) {
                         if ($count_display) {
                             $out .= "<br>";
                         }
                         $count_display++;
                         if ($itemtype == 'Ticket') {
                             $userdata = getUserName($split[$k], 2);
                             $tooltip = "";
                             if (Session::haveRight('user', READ)) {
                                 $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                             }
                             $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip);
                         } else {
                             $out .= getUserName($split[$k], $showuserlink);
                         }
                     }
                 }
                 // Manage alternative_email for tickets_users
                 if ($itemtype == 'Ticket' && isset($data[$NAME . $num . '_2'])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . '_2']);
                     for ($k = 0; $k < count($split); $k++) {
                         $split2 = explode(" ", $split[$k]);
                         if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                         }
                     }
                 }
                 return $out;
             }
             if ($itemtype != 'User') {
                 $toadd = '';
                 if ($itemtype == 'Ticket' && $data[$NAME . $num . "_3"] > 0) {
                     $userdata = getUserName($data[$NAME . $num . "_3"], 2);
                     $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                 }
                 if (Session::haveRight('user', READ)) {
                     $usernameformat = formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 1);
                 } else {
                     $usernameformat = formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 0);
                 }
                 return sprintf(__('%1$s %2$s'), $usernameformat, $toadd);
             }
             break;
         case "glpi_profiles.interface":
             return Profile::getInterfaceName($data[$NAME . $num]);
         case "glpi_profiles.name":
             if ($itemtype == 'User' && $ID == 20) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $split4 = explode("\$\$\$\$", $data[$NAME . $num . "_4"]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = sprintf(__('%1$s - %2$s'), $split[$k], Dropdown::getDropdownName('glpi_entities', $split2[$k]));
                         $comp = '';
                         if ($split3[$k]) {
                             $comp = __(READ);
                             if ($split4[$k]) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                             }
                         }
                         if ($split4[$k]) {
                             $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                         }
                         if (!empty($comp)) {
                             $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_entities.completename":
             if ($itemtype == 'User') {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $split4 = explode("\$\$\$\$", $data[$NAME . $num . "_4"]);
                 $added = array();
                 $count_display = 0;
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = sprintf(__('%1$s - %2$s'), $split[$k], Dropdown::getDropdownName('glpi_profiles', $split2[$k]));
                         $comp = '';
                         if ($split3[$k]) {
                             $comp = __(READ);
                             if ($split4[$k]) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                             }
                         }
                         if ($split4[$k]) {
                             $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                         }
                         if (!empty($comp)) {
                             $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_documenttypes.icon":
             if (!empty($data[$NAME . $num])) {
                 return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
             }
             return "&nbsp;";
         case "glpi_documents.filename":
             $doc = new Document();
             if ($doc->getFromDB($data['id'])) {
                 return $doc->getDownloadLink();
             }
             return NOT_AVAILABLE;
         case "glpi_deviceharddrives.specificity":
         case "glpi_devicememories.specificity":
         case "glpi_deviceprocessors.specificity":
             return $data[$NAME . $num];
         case "glpi_networkports.mac":
             $out = "";
             if ($itemtype == 'Computer') {
                 $displayed = array();
                 if (!empty($data[$NAME . $num . "_2"])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = Toolbox::strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                     if (!empty($data[$NAME . $num])) {
                         $out .= "<br>";
                     }
                 }
                 if (!empty($data[$NAME . $num])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = Toolbox::strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_contracts.duration":
         case "glpi_contracts.notice":
         case "glpi_contracts.periodicity":
         case "glpi_contracts.billing":
             if (!empty($data[$NAME . $num])) {
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $output = "";
                 foreach ($split as $duration) {
                     $output .= (empty($output) ? '' : '<br>') . sprintf(_n('%d month', '%d months', $duration), $duration);
                 }
                 return $output;
             }
             return "&nbsp;";
         case "glpi_contracts.renewal":
             return Contract::getContractRenewalName($data[$NAME . $num]);
             //          case "glpi_infocoms.sink_time" :
             //             if (!empty($data[$NAME.$num])) {
             //                $split = explode("$$$$", $data[$NAME.$num]);
             //                $out   = '';
             //                foreach ($split as $val) {
             //                   $out .= (empty($out)?'':'<br>');
             //                   if ($val > 0) {
             //                      //TRANS: %d is a number of years
             //                      $out .= sprintf(_n('%d year', '%d years', $val), $val);
             //                   }
             //                }
             //                return $out;
             //             }
             //             return "&nbsp;";
             //
             //          case "glpi_infocoms.warranty_duration" :
             //             if (!empty($data[$NAME.$num])) {
             //                $split = explode("$$$$", $data[$NAME.$num]);
             //                $out   = '';
             //                foreach ($split as $val) {
             //                   $out .= (empty($out)?'':'<br>');
             //                   if ($val > 0) {
             //                      $out .= sprintf(_n('%d month', '%d months', $val), $val);
             //                   }
             //                   if ($val < 0) {
             //                      $out .= __('Lifelong');
             //                   }
             //                }
             //                return $out;
             //             }
             //             return "&nbsp;";
         //          case "glpi_infocoms.sink_time" :
         //             if (!empty($data[$NAME.$num])) {
         //                $split = explode("$$$$", $data[$NAME.$num]);
         //                $out   = '';
         //                foreach ($split as $val) {
         //                   $out .= (empty($out)?'':'<br>');
         //                   if ($val > 0) {
         //                      //TRANS: %d is a number of years
         //                      $out .= sprintf(_n('%d year', '%d years', $val), $val);
         //                   }
         //                }
         //                return $out;
         //             }
         //             return "&nbsp;";
         //
         //          case "glpi_infocoms.warranty_duration" :
         //             if (!empty($data[$NAME.$num])) {
         //                $split = explode("$$$$", $data[$NAME.$num]);
         //                $out   = '';
         //                foreach ($split as $val) {
         //                   $out .= (empty($out)?'':'<br>');
         //                   if ($val > 0) {
         //                      $out .= sprintf(_n('%d month', '%d months', $val), $val);
         //                   }
         //                   if ($val < 0) {
         //                      $out .= __('Lifelong');
         //                   }
         //                }
         //                return $out;
         //             }
         //             return "&nbsp;";
         case "glpi_infocoms.sink_type":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $out .= (empty($out) ? '' : '<br>') . Infocom::getAmortTypeName($val);
             }
             return $out;
         case "glpi_infocoms.alert":
             if ($data[$NAME . $num] == pow(2, Alert::END)) {
                 return __s('Warranty expiration date');
             }
             return "";
         case "glpi_contracts.alert":
             switch ($data[$NAME . $num]) {
                 case pow(2, Alert::END):
                     return __('End');
                 case pow(2, Alert::NOTICE):
                     return __('Notice');
                 case pow(2, Alert::END) + pow(2, Alert::NOTICE):
                     return __('End + Notice');
             }
             return "";
         case "glpi_tickets_tickets.tickets_id_1":
             $out = "";
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
             $displayed = array();
             for ($k = 0; $k < count($split); $k++) {
                 $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split[$k];
                 if ($linkid > 0 && !isset($displayed[$linkid])) {
                     $text = "<a ";
                     $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
                     $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
                     if (count($displayed)) {
                         $out .= "<br>";
                     }
                     $displayed[$linkid] = $linkid;
                     $out .= $text;
                 }
             }
             return $out;
         case "glpi_problems.count":
             if ($data[$NAME . $num] > 0 && Session::haveRight("problem", Problem::READALL)) {
                 if ($itemtype == 'ITILCategory') {
                     $options['field'][0] = 7;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = $data['id'];
                     $options['link'][0] = 'AND';
                 }
                 $options['reset'] = 'reset';
                 $out = "<a id='problem{$itemtype}" . $data['id'] . "' ";
                 $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                 $out .= $data[$NAME . $num] . "</a>";
             } else {
                 $out = $data[$NAME . $num];
             }
             return $out;
         case "glpi_tickets.count":
             if ($data[$NAME . $num] > 0 && Session::haveRight("ticket", Ticket::READALL)) {
                 if ($itemtype == 'User') {
                     $options['field'][0] = 4;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = $data['id'];
                     $options['link'][0] = 'AND';
                     $options['field'][1] = 22;
                     $options['searchtype'][1] = 'equals';
                     $options['contains'][1] = $data['id'];
                     $options['link'][1] = 'OR';
                     $options['field'][2] = 5;
                     $options['searchtype'][2] = 'equals';
                     $options['contains'][2] = $data['id'];
                     $options['link'][2] = 'OR';
                 } else {
                     if ($itemtype == 'ITILCategory') {
                         $options['field'][0] = 7;
                         $options['searchtype'][0] = 'equals';
                         $options['contains'][0] = $data['id'];
                         $options['link'][0] = 'AND';
                     } else {
                         $options['field'][0] = 12;
                         $options['searchtype'][0] = 'equals';
                         $options['contains'][0] = 'all';
                         $options['link'][0] = 'AND';
                         $options['itemtype2'][0] = $itemtype;
                         $options['field2'][0] = self::getOptionNumber($itemtype, 'name');
                         $options['searchtype2'][0] = 'equals';
                         $options['contains2'][0] = $data['id'];
                         $options['link2'][0] = 'AND';
                     }
                 }
                 $options['reset'] = 'reset';
                 $out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
                 $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                 $out .= $data[$NAME . $num] . "</a>";
             } else {
                 $out = $data[$NAME . $num];
             }
             return $out;
         case "glpi_tickets.due_date":
             // Due date + progress
             if ($ID == 151) {
                 $out = Html::convDate($data[$NAME . $num]);
                 // No due date in waiting status
                 if ($data[$NAME . $num . '_2'] == CommonITILObject::WAITING) {
                     return '';
                 }
                 if (empty($data[$NAME . $num])) {
                     return '';
                 }
                 if ($data[$NAME . $num . '_2'] == Ticket::SOLVED || $data[$NAME . $num . '_2'] == Ticket::CLOSED) {
                     return $data[$NAME . $num];
                 }
                 $ticket = new Ticket();
                 $ticket->getFromDB($data['ITEM_0']);
                 $percentage = 0;
                 $totaltime = 0;
                 $currenttime = 0;
                 if ($ticket->fields['slas_id'] != 0) {
                     // Have SLA
                     $sla = new SLA();
                     $sla->getFromDB($ticket->fields['slas_id']);
                     $currenttime = $sla->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
                     $totaltime = $sla->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]);
                 } else {
                     $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
                     if ($calendars_id != 0) {
                         // Ticket entity have calendar
                         $calendar = new Calendar();
                         $calendar->getFromDB($calendars_id);
                         $currenttime = $calendar->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
                         $totaltime = $calendar->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]);
                     } else {
                         // No calendar
                         $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['date']);
                         $totaltime = strtotime($data[$NAME . $num]) - strtotime($ticket->fields['date']);
                     }
                 }
                 if ($totaltime != 0) {
                     $percentage = round(100 * $currenttime / $totaltime);
                 } else {
                     // Total time is null : no active time
                     $percentage = 100;
                 }
                 if ($percentage > 100) {
                     $percentage = 100;
                 }
                 $percentage_text = $percentage;
                 if ($_SESSION['glpiduedatewarning_unit'] == '%') {
                     $less_warn_limit = $_SESSION['glpiduedatewarning_less'];
                     $less_warn = 100 - $percentage;
                 } else {
                     if ($_SESSION['glpiduedatewarning_unit'] == 'hours') {
                         $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP;
                         $less_warn = $totaltime - $currenttime;
                     } else {
                         if ($_SESSION['glpiduedatewarning_unit'] == 'days') {
                             $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP;
                             $less_warn = $totaltime - $currenttime;
                         }
                     }
                 }
                 if ($_SESSION['glpiduedatecritical_unit'] == '%') {
                     $less_crit_limit = $_SESSION['glpiduedatecritical_less'];
                     $less_crit = 100 - $percentage;
                 } else {
                     if ($_SESSION['glpiduedatecritical_unit'] == 'hours') {
                         $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP;
                         $less_crit = $totaltime - $currenttime;
                     } else {
                         if ($_SESSION['glpiduedatecritical_unit'] == 'days') {
                             $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP;
                             $less_crit = $totaltime - $currenttime;
                         }
                     }
                 }
                 $color = $_SESSION['glpiduedateok_color'];
                 if ($less_crit < $less_crit_limit) {
                     $color = $_SESSION['glpiduedatecritical_color'];
                 } else {
                     if ($less_warn < $less_warn_limit) {
                         $color = $_SESSION['glpiduedatewarning_color'];
                     }
                 }
                 //Calculate bar progress
                 $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n                         border: 1px solid #9BA563;' >";
                 $out .= "<div style='position:absolute;'>&nbsp;" . $percentage_text . "%</div>";
                 $out .= "<div class='center' style='background-color: " . $color . ";\n                         width: " . $percentage . "%; height: 12px' ></div>";
                 $out .= "</div>";
                 return $out;
             }
             break;
         case "glpi_softwarelicenses.number":
             if ($data[$NAME . $num . "_2"] == -1) {
                 return __('Unlimited');
             }
             if (empty($data[$NAME . $num])) {
                 return 0;
             }
             return $data[$NAME . $num];
         case "glpi_auth_tables.name":
             return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
         case "glpi_reservationitems.comment":
             if (empty($data[$NAME . $num])) {
                 return "<a title=\"" . __s('Modify the comment') . "\"\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>";
             }
             return "<a title=\"" . __s('Modify the comment') . "\"\n                     href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$NAME . $num]) . "</a>";
         case 'glpi_notifications.mode':
             return Notification::getMode($data[$NAME . $num]);
         case 'glpi_notifications.event':
             $item = NotificationTarget::getInstanceByType($data['itemtype']);
             if ($item) {
                 $events = $item->getAllEvents();
                 if (isset($events[$data[$NAME . $num]])) {
                     return $events[$data[$NAME . $num]];
                 }
             }
             return '';
         case 'glpi_reminders.state':
             return Planning::getState($data[$NAME . $num]);
         case 'glpi_crontasks.description':
             $tmp = new CronTask();
             return $tmp->getDescription($data['id']);
         case 'glpi_crontasks.state':
             return CronTask::getStateName($data[$NAME . $num]);
         case 'glpi_crontasks.mode':
             return CronTask::getModeName($data[$NAME . $num]);
         case 'glpi_crontasks.itemtype':
             if ($plug = isPluginItemType($data[$NAME . $num])) {
                 return $plug['plugin'];
             }
             return '';
         case 'glpi_changes.status':
             $status = Change::getStatus($data[$NAME . $num]);
             return "<img src=\"" . Change::getStatusIconURL($data[$NAME . $num]) . "\"\n                     alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
         case 'glpi_problems.status':
             $status = Problem::getStatus($data[$NAME . $num]);
             return "<img src=\"" . Problem::getStatusIconURL($data[$NAME . $num]) . "\"\n                     alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
         case 'glpi_tickets.status':
             $status = Ticket::getStatus($data[$NAME . $num]);
             return "<img src=\"" . Ticket::getStatusIconURL($data[$NAME . $num]) . "\"\n                     alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
         case 'glpi_tickets.items_id':
             if (!empty($data[$NAME . $num . "_2"]) && ($item = getItemForItemtype($data[$NAME . $num . "_2"]))) {
                 if ($item->getFromDB($data[$NAME . $num])) {
                     return $item->getLink(array('comments' => true));
                 }
             }
             return '&nbsp;';
         case 'glpi_tickets.name':
             if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 $link = Toolbox::getItemTypeFormURL('Ticket');
                 foreach ($split as $val) {
                     if (!empty($val)) {
                         $split2 = self::explodeWithID("\$\$", $val);
                         $out .= "<a id='ticket" . $split2[1] . "' href=\"" . $link;
                         $out .= strstr($link, '?') ? '&amp;' : '?';
                         $out .= 'id=' . $split2[1];
                         $out .= "\">";
                         $name = $split2[0];
                         if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                             $name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]);
                         }
                         $out .= $name . "</a><br>";
                     }
                 }
                 return $out;
             }
             $link = Toolbox::getItemTypeFormURL('Ticket');
             $out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
             $out .= strstr($link, '?') ? '&amp;' : '?';
             $out .= 'id=' . $data[$NAME . $num . "_2"];
             // Force solution tab if solved
             if ($data[$NAME . $num . "_4"] == CommonITILObject::SOLVED) {
                 $out .= "&amp;forcetab=Ticket\$2";
             }
             $out .= "\">";
             $name = $data[$NAME . $num];
             if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, $data[$NAME . $num . "_2"]);
             }
             $out .= $name . "</a>";
             $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br($data[$NAME . $num . "_3"]), array('applyto' => 'ticket' . $data[$NAME . $num . "_2"], 'display' => false)));
             return $out;
         case 'glpi_ticketvalidations.status':
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 if (!empty($val)) {
                     $split2 = self::explodeWithID("\$\$", $val);
                     $status = TicketValidation::getStatus($split2[0]);
                     $bgcolor = TicketValidation::getStatusColor($split2[0]);
                     $out .= (empty($out) ? '' : '<br>') . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
                 }
             }
             return $out;
         case 'glpi_ticketsatisfactions.type':
             return TicketSatisfaction::getTypeInquestName($data[$NAME . $num]);
         case 'glpi_ticketsatisfactions.satisfaction':
             return TicketSatisfaction::displaySatisfaction($data[$NAME . $num]);
         case 'glpi_notimportedemails.reason':
             return NotImportedEmail::getReason($data[$NAME . $num]);
         case 'glpi_notimportedemails.messageid':
             $clean = array('<' => '', '>' => '');
             return strtr($data[$NAME . $num], $clean);
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
         if (count($matches) == 2) {
             $plug = $matches[1];
             $function = 'plugin_' . $plug . '_giveItem';
             if (function_exists($function)) {
                 $out = $function($itemtype, $ID, $data, $num);
                 if (!empty($out)) {
                     return $out;
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     /// TODO try to use getvalueToDisplay instead of redefine display system
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]);
                 if (isset($data[$NAME . $num . "_2"]) && strlen($data[$NAME . $num . "_2"])) {
                     $link = Toolbox::getItemTypeFormURL($linkitemtype);
                     $out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$NAME . $num . "_2"];
                     if (isset($searchopt[$ID]['forcetab'])) {
                         $out .= "&amp;forcetab=" . $searchopt[$ID]['forcetab'];
                     }
                     $out .= "\">";
                     $name = Dropdown::getValueWithUnit($data[$NAME . $num], $unit);
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                         $name = sprintf(__('%1$s (%2$s)'), $name, $data[$NAME . $num . "_2"]);
                     }
                     $out .= $name . "</a>";
                     return $out;
                 }
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $count_display = 0;
                 $separate = '<br>';
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = '<hr>';
                 }
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $split2 = self::explodeWithID("\$\$", $split[$k]);
                         if (isset($split2[1]) && $split2[1] > 0) {
                             if ($count_display) {
                                 $out .= $separate;
                             }
                             $count_display++;
                             $page = Toolbox::getItemTypeFormURL($linkitemtype);
                             $page .= strpos($page, '?') ? '&id' : '?id';
                             $name = Dropdown::getValueWithUnit($split2[0], $unit);
                             if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                                 $name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]);
                             }
                             $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $split2[1] . "' href='{$page}=" . $split2[1] . "'>" . $name . "</a>";
                         }
                     }
                 }
                 return $out;
             case "text":
                 $separate = '<br>';
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = '<hr>';
                 }
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 $count_display = 0;
                 foreach ($split as $val) {
                     if (strlen(trim($val)) > 0) {
                         $split2 = self::explodeWithID("\$\$", $val);
                         if ($count_display) {
                             $out .= $separate;
                         }
                         $count_display++;
                         if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
                             $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($split2[0])));
                         } else {
                             $text = nl2br($split2[0]);
                         }
                         if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) {
                             $rand = mt_rand();
                             $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false)));
                         } else {
                             $out .= $text;
                         }
                     }
                 }
                 return $out;
             case "date":
             case "date_delay":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . Html::convDate($val);
                 }
                 return $out;
             case "datetime":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . Html::convDateTime($val);
                 }
                 return $out;
             case "timestamp":
                 $withseconds = false;
                 if (isset($searchopt[$ID]['withseconds'])) {
                     $withseconds = $searchopt[$ID]['withseconds'];
                 }
                 $withdays = true;
                 if (isset($searchopt[$ID]['withdays'])) {
                     $withdays = $searchopt[$ID]['withdays'];
                 }
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($val, $withseconds, $withdays);
                 }
                 return $out;
             case "email":
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $out = '';
                 $count_display = 0;
                 foreach ($split as $val) {
                     $split2 = self::explodeWithID("\$\$", $val);
                     if ($count_display) {
                         $out .= "<br>";
                     }
                     $count_display++;
                     if (!empty($val)) {
                         $out .= empty($out) ? '' : '<br>';
                         $out .= "<a href='mailto:{$split2['0']}'>{$split2['0']}</a>";
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "weblink":
                 $orig_link = trim($data[$NAME . $num]);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) {
                         $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "...";
                     }
                     return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>";
                 }
                 return "&nbsp;";
             case "number":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             $split2 = self::explodeWithID("\$\$", $split[$k]);
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split2[0]])) {
                                 $out .= $searchopt[$ID]['toadd'][$split2[0]];
                             } else {
                                 $number = str_replace(' ', '&nbsp;', Html::formatNumber($split2[0], false, 0));
                                 $out .= Dropdown::getValueWithUnit($number, $unit);
                             }
                         }
                     }
                     return $out;
                 }
                 if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$NAME . $num]])) {
                     return $searchopt[$ID]['toadd'][$data[$NAME . $num]];
                 } else {
                     $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$NAME . $num], false, 0));
                     return Dropdown::getValueWithUnit($number, $unit);
                 }
             case "decimal":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             $split2 = self::explodeWithID("\$\$", $split[$k]);
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split2[0]])) {
                                 $out .= $searchopt[$ID]['toadd'][$split2[0]];
                             } else {
                                 $number = str_replace(' ', '&nbsp;', Html::formatNumber($split2[0]));
                                 $out .= Dropdown::getValueWithUnit($number, $unit);
                             }
                         }
                     }
                     return $out;
                 }
                 $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$NAME . $num]));
                 return Dropdown::getValueWithUnit($number, $unit);
             case "bool":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             $split2 = self::explodeWithID("\$\$", $split[$k]);
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($split2[0]), $unit);
                         }
                     }
                     return $out;
                 }
                 return Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$NAME . $num]), $unit);
             case "right":
                 return Profile::getRightValue($data[$NAME . $num]);
             case "itemtypename":
                 if ($obj = getItemForItemtype($data[$NAME . $num])) {
                     return $obj->getTypeName();
                 }
                 return "";
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$NAME . $num]])) {
                     return $CFG_GLPI['languages'][$data[$NAME . $num]][0];
                 }
                 return __('Default value');
         }
     }
     // Manage items with need group by / group_concat
     if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
         $out = "";
         $split = explode("\$\$\$\$", $data[$NAME . $num]);
         $count_display = 0;
         $separate = '<br>';
         if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
             $separate = '<hr>';
         }
         for ($k = 0; $k < count($split); $k++) {
             if (strlen(trim($split[$k])) > 0) {
                 if ($count_display) {
                     $out .= $separate;
                 }
                 $withoutid = self::explodeWithID("\$\$", $split[$k]);
                 $count_display++;
                 // Get specific display if available
                 $itemtype = getItemTypeForTable($table);
                 if ($item = getItemForItemtype($itemtype)) {
                     $tmpdata = array($field => $withoutid[0]);
                     $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true));
                 }
                 if (!empty($specific)) {
                     $out .= $specific;
                 } else {
                     $out .= Dropdown::getValueWithUnit($withoutid[0], $unit);
                 }
             }
         }
         return $out;
     }
     // Get specific display if available
     $itemtype = getItemTypeForTable($table);
     if ($item = getItemForItemtype($itemtype)) {
         $tmpdata = array($field => $data[$NAME . $num]);
         if (isset($searchopt[$ID]['additionalfields']) && count($searchopt[$ID]['additionalfields'])) {
             foreach ($searchopt[$ID]['additionalfields'] as $key) {
                 $tmpdata[$key] = $data[$NAME . $num . '_' . $key];
             }
         }
         $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true));
         if (!empty($specific)) {
             return $specific;
         }
     }
     // Manage auto CONCAT id
     $split = self::explodeWithID('$$', $data[$NAME . $num]);
     $split[0] = trim($split[0]);
     if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split[0]])) {
         return $searchopt[$ID]['toadd'][$split[0]];
     }
     // Empty is 0 or empty
     if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) {
         return $searchopt[$ID]['emptylabel'];
     }
     return Dropdown::getValueWithUnit($split[0], $unit);
 }
コード例 #3
0
ファイル: item.class.php プロジェクト: geldarr/hack-space
 function generatePdf($itemtype, $data, $saveas)
 {
     global $CFG_GLPI, $PDF, $DB;
     $ID = $data["id"];
     //name
     if (!empty($data["name"])) {
         $name_item = Toolbox::decodeFromUtf8($data["name"]);
     } else {
         $name_item = "";
     }
     //user
     if (!empty($data["users_id"])) {
         $user_item = Toolbox::decodeFromUtf8(Html::clean(getUserName($data["users_id"])));
     } else {
         if (!empty($data["groups_id"])) {
             $user_item = Toolbox::decodeFromUtf8(Dropdown::getDropdownName("glpi_groups", $data["groups_id"]));
         } else {
             $user_item = "";
         }
     }
     //fabricant
     if (!empty($data["manufacturers_id"])) {
         $fabricant_item = Toolbox::decodeFromUtf8(Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]));
     } else {
         $fabricant_item = "";
     }
     //serial
     if (!empty($data["serial"])) {
         $serial_item = Toolbox::decodeFromUtf8($data["serial"]);
     } else {
         $serial_item = "";
     }
     $class = $itemtype . "Type";
     $item = new $class();
     $typefield = getForeignKeyFieldForTable(getTableForItemType($itemtype . "Type"));
     $item->getFromDB($data[$typefield]);
     if (!empty($typefield) && !empty($item->fields["name"])) {
         $type_item = Toolbox::decodeFromUtf8($item->fields["name"]);
     } else {
         $type_item = "";
     }
     //infocoms
     $ic = new Infocom();
     if ($ic->getfromDBforDevice($itemtype, $ID)) {
         //immobilizationsheets_item
         if (!empty($ic->fields["immo_number"])) {
             $immobilizationsheets_item = Toolbox::decodeFromUtf8($ic->fields["immo_number"]);
         } else {
             $immobilizationsheets_item = "";
         }
         //buy_date
         if (!empty($ic->fields["buy_date"])) {
             $buy_date_item = Toolbox::decodeFromUtf8(Html::convdate($ic->fields["buy_date"]));
         } else {
             $buy_date_item = "";
         }
         //use_date
         if (!empty($ic->fields["use_date"])) {
             $use_date_item = Toolbox::decodeFromUtf8(Html::convdate($ic->fields["use_date"]));
         } else {
             $use_date_item = "";
         }
         //order_number
         if (!empty($ic->fields["order_number"])) {
             $order_number_item = Toolbox::decodeFromUtf8($ic->fields["order_number"]);
         } else {
             $order_number_item = "";
         }
         //value_item
         if (!empty($ic->fields["value"])) {
             $value_item = Toolbox::decodeFromUtf8(Html::clean(Html::formatNumber($ic->fields["value"])));
         } else {
             $value_item = "";
         }
         //sink_time
         if (!empty($ic->fields["sink_time"])) {
             $sink_time_item = Toolbox::decodeFromUtf8(sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]));
         } else {
             $sink_time_item = "";
         }
         //sink_type
         if (!empty($ic->fields["sink_type"])) {
             $sink_type_item = Toolbox::decodeFromUtf8(Infocom::getAmortTypeName($ic->fields["sink_type"]));
         } else {
             $sink_type_item = "";
         }
     } else {
         $immobilizationsheets_item = "";
         $buy_date_item = "";
         $use_date_item = "";
         $order_number_item = "";
         $value_item = "";
         $sink_time_item = "";
         $sink_type_item = "";
     }
     //composants
     $devtypes = self::getDeviceTypes();
     if ($itemtype == 'Computer') {
         $device2 = new $devtypes[2]();
         $query2 = "SELECT `deviceprocessors_id`\n                  FROM `" . getTableForItemType('items_' . $devtypes[2]) . "`\n                  WHERE `items_id` = '{$ID}'";
         $result2 = $DB->query($query2);
         $number2 = $DB->numrows($result2);
         $device3 = new $devtypes[3]();
         $query3 = "SELECT SUM(`size`) AS total\n                  FROM `" . getTableForItemType('items_' . $devtypes[3]) . "`\n                  WHERE `items_id` = '{$ID}'";
         $result3 = $DB->query($query3);
         $number3 = $DB->numrows($result3);
         $query3b = "SELECT `devicememories_id`\n                  FROM `" . getTableForItemType('items_' . $devtypes[3]) . "`\n                  WHERE `items_id` = '{$ID}'";
         $result3b = $DB->query($query3b);
         $number3b = $DB->numrows($result3b);
         $device4 = new $devtypes[4]();
         $query4 = "SELECT `deviceharddrives_id`,`capacity`\n                  FROM `" . getTableForItemType('items_' . $devtypes[4]) . "`\n                  WHERE `items_id` = '{$ID}'";
         $result4 = $DB->query($query4);
         $number4 = $DB->numrows($result4);
         $device5 = new $devtypes[6]();
         $query5 = "SELECT `devicedrives_id`\n                  FROM `" . getTableForItemType('items_' . $devtypes[6]) . "`\n                  WHERE `items_id` = '{$ID}'";
         $result5 = $DB->query($query5);
         $number5 = $DB->numrows($result5);
         if ($number2 != 0) {
             while ($data2 = $DB->fetch_array($result2)) {
                 //proc_item
                 if (!empty($data2["deviceprocessors_id"])) {
                     $query_proc = "SELECT `designation`\n                              FROM `glpi_deviceprocessors`\n                              WHERE `id` = '" . $data2["deviceprocessors_id"] . "'";
                     $result_proc = $DB->query($query_proc);
                     $number_proc = $DB->numrows($result_proc);
                     if ($number_proc != 0) {
                         while ($data_proc = $DB->fetch_array($result_proc)) {
                             $proc_item = Toolbox::decodeFromUtf8($data_proc["designation"]);
                         }
                     }
                 }
             }
         } else {
             $proc_item = "";
         }
         if ($number3 != 0) {
             while ($data3 = $DB->fetch_array($result3)) {
                 //ram_item
                 $ram_item = $data3["total"];
             }
         } else {
             $ram_item = "";
         }
         $ram_type_item = "";
         if ($number3b != 0) {
             while ($data3b = $DB->fetch_array($result3b)) {
                 //ram_type_item
                 if (!empty($data3b["devicememories_id"])) {
                     $query_ram = "SELECT `glpi_devicememorytypes`.`name`\n                              FROM `glpi_devicememories`,`glpi_devicememorytypes`\n                              WHERE `glpi_devicememories`.`id` = '" . $data3b["devicememories_id"] . "'\n                              AND `glpi_devicememorytypes`.`id` = `glpi_devicememories`.`devicememorytypes_id` ";
                     $result_ram = $DB->query($query_ram);
                     $number_ram = $DB->numrows($result_ram);
                     if ($number_ram != 0) {
                         while ($data_ram = $DB->fetch_array($result_ram)) {
                             $ram_type_item = Toolbox::decodeFromUtf8($data_ram["name"]);
                         }
                     } else {
                         $ram_type_item = "";
                     }
                 }
             }
         } else {
             $ram_type_item = "";
         }
         $hdd_item = "";
         $hdd_designation_item = "";
         $hdd_interface_item = "";
         if ($number4 != 0) {
             while ($data4 = $DB->fetch_array($result4)) {
                 //hdd_item
                 $hdd_size_item = Toolbox::decodeFromUtf8($data4["capacity"]);
                 if (!empty($data4["deviceharddrives_id"])) {
                     $query_hdd = "SELECT `designation`\n                              FROM `glpi_deviceharddrives`\n                              WHERE `id` = '" . $data4["deviceharddrives_id"] . "'";
                     $result_hdd = $DB->query($query_hdd);
                     $number_hdd = $DB->numrows($result_hdd);
                     if ($number_hdd != 0) {
                         while ($data_hdd = $DB->fetch_array($result_hdd)) {
                             $hdd_designation_item = Toolbox::decodeFromUtf8($data_hdd["designation"]);
                         }
                     } else {
                         $hdd_designation_item = "";
                     }
                     $query_hdd1 = "SELECT `glpi_interfacetypes`.`name`\n                              FROM `glpi_deviceharddrives`,`glpi_interfacetypes`\n                              WHERE `glpi_deviceharddrives`.`id` = '" . $data4["deviceharddrives_id"] . "'\n                              AND `glpi_interfacetypes`.`id` = `glpi_deviceharddrives`.`interfacetypes_id` ";
                     //replace interface by FK_interface 0.72.1
                     $result_hdd1 = $DB->query($query_hdd1);
                     $number_hdd1 = $DB->numrows($result_hdd1);
                     if ($number_hdd1 != 0) {
                         while ($data_hdd1 = $DB->fetch_array($result_hdd1)) {
                             $hdd_interface_item = Toolbox::decodeFromUtf8($data_hdd1["name"]);
                         }
                     }
                 } else {
                     $hdd_interface_item = "";
                 }
                 $hdd_item .= $hdd_designation_item . " " . $hdd_interface_item . " (" . $hdd_size_item . " Mo)";
                 if ($number4 > 1) {
                     $hdd_item .= " - ";
                 }
             }
         } else {
             $hdd_item = "";
         }
         $lecteur_item = "";
         if ($number5 != 0) {
             while ($data5 = $DB->fetch_array($result5)) {
                 //lecteur_item
                 if (!empty($data5["items_id"])) {
                     $query_lecteur = "SELECT `designation`\n                                 FROM `glpi_devicedrives`\n                                 WHERE `id` = '" . $data5["interfacetypes_id"] . "'";
                     $result_lecteur = $DB->query($query_lecteur);
                     $number_lecteur = $DB->numrows($result_lecteur);
                     if ($number_lecteur != 0) {
                         while ($data_lecteur = $DB->fetch_array($result_lecteur)) {
                             $lecteur_item .= Toolbox::decodeFromUtf8($data_lecteur["designation"]);
                             if ($number5 > 1) {
                                 $lecteur_item .= " - ";
                             }
                         }
                     }
                 }
             }
         } else {
             $lecteur_item = "";
         }
         //softwares
         $query6 = "SELECT `glpi_softwares`.`name`,`glpi_softwarelicenses`.`softwareversions_id_buy`,`glpi_softwarelicenses`.`serial`\n                  FROM `glpi_softwarelicenses`\n                  INNER JOIN `glpi_computers_softwarelicenses` ON (`glpi_softwarelicenses`.`id` = `glpi_computers_softwarelicenses`.`softwarelicenses_id` AND `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}') \n                  INNER JOIN `glpi_softwares` ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`) ";
         $result6 = $DB->query($query6);
         $number6 = $DB->numrows($result6);
     }
     //Affichage
     //$PDF->addJpegFromFile('../pics/immobilizationsheets.jpg',285,785,32,32);
     //title
     $PDF->ezSetDy(-20);
     $title = array(array('' => Toolbox::decodeFromUtf8(__('IDENTIFICATION IMMOBILIZATION SHEET', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'center'));
     $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $PDF->ezSetDy(-10);
     //partie 1
     $PDF->ezSetDy(-20);
     $title1 = array(array('' => Toolbox::decodeFromUtf8(__('I - PART TO BE FILLED BY THE PERSON IN CHARGE FOR THE PURCHASES', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(transfer the original to the administrator network so computer equipement, the assistant of management in the other cases)', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $PDF->ezSetDy(-10);
     //Date mise en service
     $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Startup date')) . "</u> : " . $buy_date_item, 8, array("justification" => "left"));
     $PDF->ezSetDy(-10);
     //ligne1 (entreprise / fournisseur)
     $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('MY ENTERPRISE', 'immobilizationsheets')), '1' => Toolbox::decodeFromUtf8(strtoupper(__('Supplier')))));
     $cols1 = array('0' => array('width' => 265, 'justification' => 'center'), '1' => array('width' => 265, 'justification' => 'center'));
     $PDF->ezTable($data1, '', __('COMPUTER IDENTIFICATION', 'immobilizationsheets'), array('showHeadings' => 0, 'cols' => $cols1));
     //ligne2 (4 / 9)
     $data2 = array(array('0' => Toolbox::decodeFromUtf8(__('Assignment number (si non informatique)', 'immobilizationsheets')), '1' => '', '2' => Toolbox::decodeFromUtf8(__('Brand')), '3' => $fabricant_item));
     $cols2 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left'));
     $PDF->ezTable($data2, '', '', array('showHeadings' => 0, 'cols' => $cols2, 'fontSize' => 8));
     //ligne3 (5 / 10)
     $data3 = array(array('0' => Toolbox::decodeFromUtf8(__('Invoice number')), '1' => $order_number_item, '2' => Toolbox::decodeFromUtf8(__('Type')), '3' => $type_item));
     $cols3 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left'));
     $PDF->ezTable($data3, '', '', array('showHeadings' => 0, 'cols' => $cols3, 'fontSize' => 8));
     //ligne4 (6 / 11)
     $data4 = array(array('0' => Toolbox::decodeFromUtf8(__('Value')), '1' => $value_item, '2' => Toolbox::decodeFromUtf8(__('Serial Number')), '3' => $serial_item));
     $cols4 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left'));
     $PDF->ezTable($data4, '', '', array('showHeadings' => 0, 'cols' => $cols4, 'fontSize' => 8));
     //ligne5 (7 / 12)
     $data5 = array(array('0' => Toolbox::decodeFromUtf8(__('Assignment (client / inv. …)', 'immobilizationsheets')), '1' => '', '2' => Toolbox::decodeFromUtf8(__('Permanent number', 'immobilizationsheets')), '3' => $immobilizationsheets_item));
     $cols5 = array('0' => array('width' => 132.5, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 132.5, 'justification' => 'left'), '2' => array('width' => 132.5, 'justification' => 'left'), '3' => array('width' => 132.5, 'justification' => 'left'));
     $PDF->ezTable($data5, '', '', array('showHeadings' => 0, 'cols' => $cols5, 'fontSize' => 8));
     $PDF->ezSetDy(-10);
     //trigramme
     $data6 = array(array('0' => Toolbox::decodeFromUtf8(__('Trigram and visa of the person in charge', 'immobilizationsheets')), '1' => ''));
     $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left'));
     $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8));
     //partie 2
     $PDF->ezSetDy(-20);
     $title1 = array(array('' => Toolbox::decodeFromUtf8(__('II - PART TO BE FILLED BY THE NETWORK ADMINISTRATOR', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(transfer to the assistant of management)', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $PDF->ezSetDy(-10);
     //ligne1 (name  / user)
     $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('User name / sector', 'immobilizationsheets')), '1' => $user_item, '2' => Toolbox::decodeFromUtf8(__('Name')), '3' => $name_item));
     $cols1 = array('0' => array('width' => 132.5, 'justification' => 'center'), '1' => array('width' => 132.5, 'justification' => 'center'), '2' => array('width' => 132.5, 'justification' => 'center'), '3' => array('width' => 132.5, 'justification' => 'center'));
     $PDF->ezTable($data1, '', __('PRINCIPAL ASSIGNMENT', 'immobilizationsheets'), array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1));
     $PDF->ezSetDy(-10);
     if ($itemtype == 'Computer') {
         //title config mat?ielle
         $title = array(array('' => Toolbox::decodeFromUtf8(__('HARDWARE CONFIGURATION', 'immobilizationsheets'))));
         $cols = array('' => array('width' => 530, 'justification' => 'center'));
         $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1));
         $PDF->ezSetDy(-10);
         //ligne1 (processeur  / ram quantit?/ ram type)
         $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('Processor')), '1' => $proc_item, '2' => Toolbox::decodeFromUtf8(__('Memory')), '3' => Toolbox::decodeFromUtf8(__('Quantity', 'immobilizationsheets')), '4' => $ram_item, '5' => Toolbox::decodeFromUtf8(__('Type')), '6' => $ram_type_item));
         $cols1 = array('0' => array('width' => 55, 'justification' => 'center'), '1' => array('width' => 200, 'justification' => 'left'), '2' => array('width' => 55, 'justification' => 'center'), '3' => array('width' => 55, 'justification' => 'center'), '4' => array('width' => 55, 'justification' => 'center'), '5' => array('width' => 55, 'justification' => 'center'), '6' => array('width' => 55, 'justification' => 'center'));
         $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1));
         //ligne2 (Disque dur / Lecteur)
         $data1 = array(array('0' => Toolbox::decodeFromUtf8(__('Hard drive')), '1' => $hdd_item, '2' => Toolbox::decodeFromUtf8(__('Drive')), '3' => $lecteur_item));
         $cols1 = array('0' => array('width' => 55, 'justification' => 'center'), '1' => array('width' => 200, 'justification' => 'left'), '2' => array('width' => 55, 'justification' => 'center'), '3' => array('width' => 220, 'justification' => 'center'));
         $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1));
         $PDF->ezSetDy(-10);
         //titre suppl?ent
         $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Additional cards or peripherals', 'immobilizationsheets')) . "</u> : ", 8, array("justification" => "left"));
         $PDF->ezSetDy(-10);
         if ($number6 > 0) {
             //title config logicielle
             $title = array(array('' => Toolbox::decodeFromUtf8(__('SOFTWARE CONFIGURATION', 'immobilizationsheets'))));
             $cols = array('' => array('width' => 530, 'justification' => 'center'));
             $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1));
             $PDF->ezSetDy(-10);
             //titre logiciels
             $PDF->ezText("<u>" . Toolbox::decodeFromUtf8(__('Oem/Delivered software', 'immobilizationsheets')) . "</u> : ", 8, array("justification" => "left"));
             $PDF->ezSetDy(-10);
             //ligne1 (name  / version / licence)
             $data0 = array(array('0' => Toolbox::decodeFromUtf8(__('Name')), '1' => Toolbox::decodeFromUtf8(__('Version')), '2' => Toolbox::decodeFromUtf8(__('License number'))));
             $cols1 = array('0' => array('width' => 240, 'justification' => 'left'), '1' => array('width' => 50, 'justification' => 'center'), '2' => array('width' => 240, 'justification' => 'center'));
             $PDF->ezTable($data0, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1));
             while ($data6 = $DB->fetch_array($result6)) {
                 $soft_name_item = $data6["name"];
                 $soft_version_item = Dropdown::getDropdownName("glpi_softwareversions", $data6["softwareversions_id_buy"]);
                 $soft_license_item = $data6["serial"];
                 $data1 = array(array('0' => $soft_name_item, '1' => $soft_version_item, '2' => $soft_license_item));
                 $cols1 = array('0' => array('width' => 240, 'justification' => 'left'), '1' => array('width' => 50, 'justification' => 'center'), '2' => array('width' => 240, 'justification' => 'center'));
                 $PDF->ezTable($data1, '', '', array('fontSize' => 8, 'showHeadings' => 0, 'cols' => $cols1));
             }
             $PDF->ezSetDy(-10);
         }
     }
     //trigramme
     $data6 = array(array('0' => Toolbox::decodeFromUtf8(__('Trigram and visa of the person in charge', 'immobilizationsheets')), '1' => ''));
     $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left'));
     $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8));
     //partie 3
     $PDF->ezSetDy(-20);
     $title1 = array(array('' => Toolbox::decodeFromUtf8(__('III - PART TO BE FILLED BY THE MANAGEMENT ASSISTANT', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title1, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 10, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $title2 = array(array('' => Toolbox::decodeFromUtf8(__('(for checking, visa and classification)', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'left'));
     $PDF->ezTable($title2, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 8, 'showLines' => 0, 'shaded' => 2, 'shadeCol' => array(0.8, 0.8, 0.8), 'shadeCol2' => array(0.8, 0.8, 0.8)));
     $PDF->ezSetDy(-20);
     //title
     $title = array(array('' => Toolbox::decodeFromUtf8(__('CALCULATION OF AMORTIZATION', 'immobilizationsheets'))));
     $cols = array('' => array('width' => 530, 'justification' => 'center'));
     $PDF->ezTable($title, '', '', array('cols' => $cols, 'showHeadings' => 0, 'fontSize' => 12, 'showLines' => 1));
     $PDF->ezSetDy(-10);
     //Base d'amortissement
     $amort0 = array(array('0' => Toolbox::decodeFromUtf8(__('Base amortization', 'immobilizationsheets')), '1' => $sink_type_item));
     $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left'));
     $PDF->ezTable($amort0, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0));
     $PDF->ezSetDy(-10);
     //Duree d'amortissement
     $amort1 = array(array('0' => Toolbox::decodeFromUtf8(__('Amortization duration')), '1' => $sink_time_item));
     $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left'));
     $PDF->ezTable($amort1, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0));
     $PDF->ezSetDy(-10);
     //Date de debut d'amortissement
     $amort2 = array(array('0' => Toolbox::decodeFromUtf8(__('Date of beginning of amortization', 'immobilizationsheets')), '1' => $use_date_item));
     $cols1 = array('0' => array('width' => 130, 'fontSize' => 8, 'justification' => 'left'), '1' => array('width' => 400, 'justification' => 'left'));
     $PDF->ezTable($amort2, '', '', array('showHeadings' => 0, 'cols' => $cols1, 'fontSize' => 8, 'showLines' => 0));
     $PDF->ezSetDy(-10);
     //visa
     $amort1 = array(array('0' => Toolbox::decodeFromUtf8(__('VISA A.G.', 'immobilizationsheets')), '1' => ""));
     $cols6 = array('0' => array('width' => 430, 'fontSize' => 8, 'justification' => 'right'), '1' => array('width' => 100, 'justification' => 'left'));
     $PDF->ezTable($data6, '', '', array('showHeadings' => 0, 'cols' => $cols6, 'xPos' => 'center', 'xOreintation' => 'right', 'fontSize' => 8));
     //end
     $PDF->addInfo('Author', Toolbox::decodeFromUtf8(Html::clean(getUserName(Session::getLoginUserID()))));
     $config = new PluginImmobilizationsheetsConfig();
     if ($config->getFromDB(1)) {
         if ($saveas == 1) {
             if ($config->fields["use_backup"] == 1) {
                 $path = GLPI_DOC_DIR . "/_uploads/";
                 $time_file = date("Y-m-d-H-i-s");
                 $filename = "immo_" . $time_file . "_" . $data["name"] . ".pdf";
                 $filepath = $path . $filename;
                 $fp = fopen($filepath, 'wb');
                 fwrite($fp, $PDF->output());
                 fclose($fp);
                 $doc = new document();
                 $input = array();
                 $input["entities_id"] = $data["entities_id"];
                 $input["name"] = addslashes(self::getTypeName(1) . " " . $data["name"] . " " . $time_file);
                 $input["upload_file"] = $filename;
                 $input["documentcategories_id"] = $config->fields["documentcategories_id"];
                 $input["type"] = "application/pdf";
                 $input["date_mod"] = date("Y-m-d H:i:s");
                 $input["users_id"] = Session::getLoginUserID();
                 $newdoc = $doc->add($input);
                 $docitem = new Document_Item();
                 $docitem->add(array('documents_id' => $newdoc, 'itemtype' => $itemtype, 'items_id' => $ID, 'entities_id' => $input["entities_id"]));
             }
         }
     }
 }
コード例 #4
0
 static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array())
 {
     global $CFG_GLPI, $LANG, $PLUGIN_HOOKS;
     $searchopt =& Search::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         return PluginMobileSearch::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     if ($meta) {
         $NAME = "META_";
     }
     $table = $searchopt[$ID]["table"];
     $field = $searchopt[$ID]["field"];
     $linkfield = $searchopt[$ID]["linkfield"];
     switch ($table . '.' . $field) {
         case "glpi_users_validation.name":
         case "glpi_users.name":
             // USER search case
             if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if ($split[$k] > 0) {
                         if ($count_display) {
                             $out .= "<br>";
                         }
                         $count_display++;
                         if ($itemtype == 'Ticket') {
                             $userdata = getUserNameMobile($split[$k], 2);
                             $out .= $userdata['name'] . "&nbsp;";
                         } else {
                             $out .= getUserNameMobile($split[$k], 1);
                         }
                     }
                 }
                 return $out;
             } else {
                 if (!empty($linkfield)) {
                     $toadd = '';
                     if ($itemtype == 'Ticket' && $data[$NAME . $num . "_3"] > 0) {
                         $userdata = getUserNameMobile($data[$NAME . $num . "_3"], 2);
                         $toadd = "&nbsp;";
                     }
                     //Stevenes
                     $name1 = explode("\$\$", $data[$NAME . $num]);
                     //	return $name1['0'].' ('.$name1['1'].')';
                     $link_user = $_SESSION['mobileSearchLastLink'] = "<a href=" . $CFG_GLPI["root_doc"] . "/plugins/mobile/front/item.php?itemtype=user&menu=admin&ssmenu=user&id=" . $name1['1'] . ">" . $name1['0'] . " (" . $name1['1'] . ")</a>";
                     return $link_user;
                     // return formatUserNameMobile($data[$NAME.$num."_3"],$data[$NAME.$num],$data[$NAME.$num."_2"], $data[$NAME.$num."_4"],1).$toadd;
                 }
             }
             break;
         case "glpi_profiles.interface":
             return Profile::getInterfaceName($data[$NAME . $num]);
             break;
         case "glpi_profiles.name":
             if ($itemtype == 'User') {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . $split2[$k];
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_entities.completename":
             if ($itemtype == 'User') {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $added = array();
                 $count_display = 0;
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . $split2[$k];
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             } else {
                 if ($data[$NAME . $num . "_2"] == 0) {
                     // Set name for Root entity
                     $data[$NAME . $num] = $LANG['entity'][2];
                 }
             }
             break;
         case "glpi_documenttypes.icon":
             if (!empty($data[$NAME . $num])) {
                 return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
             }
             return "&nbsp;";
         case "glpi_documents.filename":
             $doc = new Document();
             if ($doc->getFromDB($data['id'])) {
                 return $doc->getDownloadLink();
             }
             return NOT_AVAILABLE;
         case "glpi_deviceharddrives.specificity":
         case "glpi_devicememories.specificity":
         case "glpi_deviceprocessors.specificity":
             return $data[$NAME . $num];
         case "glpi_networkports.mac":
             $out = "";
             if ($itemtype == 'Computer') {
                 $displayed = array();
                 if (!empty($data[$NAME . $num . "_2"])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                     if (!empty($data[$NAME . $num])) {
                         $out .= "<br>";
                     }
                 }
                 if (!empty($data[$NAME . $num])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_contracts.duration":
         case "glpi_contracts.notice":
         case "glpi_contracts.periodicity":
         case "glpi_contracts.billing":
             if (!empty($data[$NAME . $num])) {
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $output = "";
                 foreach ($split as $duration) {
                     $output .= (empty($output) ? '' : '<br>') . $duration . " " . $LANG['financial'][57];
                 }
                 return $output;
             }
             return "&nbsp;";
         case "glpi_contracts.renewal":
             return Contract::getContractRenewalName($data[$NAME . $num]);
         case "glpi_infocoms.sink_time":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][9];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.warranty_duration":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][57];
                     }
                     if ($val < 0) {
                         $out .= $LANG['financial'][2];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.sink_type":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $out .= (empty($out) ? '' : '<br>') . Infocom::getAmortTypeName($val);
             }
             return $out;
         case "glpi_infocoms.alert":
             if ($data[$NAME . $num] == pow(2, Alert::END)) {
                 return $LANG['financial'][80];
             }
             return "";
         case "glpi_contracts.alert":
             switch ($data[$NAME . $num]) {
                 case pow(2, Alert::END):
                     return $LANG['buttons'][32];
                 case pow(2, Alert::NOTICE):
                     return $LANG['financial'][10];
                 case pow(2, Alert::END) + pow(2, Alert::NOTICE):
                     return $LANG['buttons'][32] . " + " . $LANG['financial'][10];
             }
             return "";
         case "glpi_tickets.count":
             if ($data[$NAME . $num] > 0 && Session::haveRight("ticket", Ticket::READALL)) {
                 $options['field'][0] = 12;
                 $options['searchtype'][0] = 'equals';
                 $options['contains'][0] = 'all';
                 $options['link'][0] = 'AND';
                 $options['itemtype2'][0] = $itemtype;
                 $options['field2'][0] = self::getOptionNumber($itemtype, 'name');
                 $options['searchtype2'][0] = 'equals';
                 $options['contains2'][0] = $data['id'];
                 $options['link2'][0] = 'AND';
                 $options['reset'] = 'reset';
                 $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options) . "\" data-back='false'>";
                 $out .= $data[$NAME . $num];
                 $out .= "</a>";
             } else {
                 $out = $data[$NAME . $num];
             }
             return $out;
         case "glpi_softwarelicenses.number":
             if ($data[$NAME . $num . "_2"] == -1) {
                 return $LANG['software'][4];
             }
             if (empty($data[$NAME . $num])) {
                 return 0;
             }
             return $data[$NAME . $num];
         case "glpi_auth_tables.name":
             return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
         case "glpi_reservationitems.comment":
             if (empty($data[$NAME . $num])) {
                 return "<a title='" . $LANG['reservation'][22] . "'\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' data-back='false'>" . $LANG['common'][49] . "</a>";
             }
             return "<a title='" . $LANG['reservation'][22] . "'\n                     href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' data-back='false'>" . resume_text($data[$NAME . $num]) . "</a>";
         case 'glpi_notifications.mode':
             return Notification::getMode($data[$NAME . $num]);
         case 'glpi_notifications.event':
             $item = NotificationTarget::getInstanceByType($data['itemtype']);
             if ($item) {
                 $events = $item->getAllEvents();
                 return $events[$data[$NAME . $num]];
             }
             return '';
         case 'glpi_crontasks.description':
             $tmp = new CronTask();
             return $tmp->getDescription($data['id']);
         case 'glpi_crontasks.state':
             return CronTask::getStateName($data[$NAME . $num]);
         case 'glpi_crontasks.mode':
             return CronTask::getModeName($data[$NAME . $num]);
         case 'glpi_crontasks.itemtype':
             if ($plug = isPluginItemType($data[$NAME . $num])) {
                 return $plug['plugin'];
             }
             return '';
         case 'glpi_tickets.status':
             $status = Ticket::getStatus($data[$NAME . $num]);
             // status Stevenes Donato
             if ($data[$NAME . $num] == "1") {
                 $data[$NAME . $num] = "new";
             }
             if ($data[$NAME . $num] == "2") {
                 $data[$NAME . $num] = "assign";
             }
             if ($data[$NAME . $num] == "3") {
                 $data[$NAME . $num] = "plan";
             }
             if ($data[$NAME . $num] == "4") {
                 $data[$NAME . $num] = "waiting";
             }
             if ($data[$NAME . $num] == "5") {
                 $data[$NAME . $num] = "solved";
             }
             if ($data[$NAME . $num] == "6") {
                 $data[$NAME . $num] = "closed";
             }
             //
             return "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . $data[$NAME . $num] . ".png\"\n                        alt='{$status}' title='{$status}'>&nbsp;{$status}";
         case 'glpi_tickets.priority':
             return Ticket::getPriorityName($data[$NAME . $num]);
         case 'glpi_tickets.urgency':
             return Ticket::getUrgencyName($data[$NAME . $num]);
         case 'glpi_tickets.impact':
             return Ticket::getImpactName($data[$NAME . $num]);
         case 'glpi_tickets.items_id':
             if (!empty($data[$NAME . $num . "_2"]) && class_exists($data[$NAME . $num . "_2"])) {
                 $item = new $data[$NAME . $num . "_2"]();
                 if ($item->getFromDB($data[$NAME . $num])) {
                     return $item->getLink(true);
                 }
             }
             return '&nbsp;';
         case 'glpi_tickets.id':
             $link = getItemTypeFormURLMobile('Ticket');
             $out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
             $out .= strstr($link, '?') ? '&amp;' : '?';
             $out .= 'id=' . $data[$NAME . $num];
             //$out .= 'id='.$data[$NAME.$num."_2"];
             $out .= "\" data-back='false'>" . $data[$NAME . $num];
             if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                 //$out .= " (".$data[$NAME.$num."_2"].")";
                 $out .= $data[$NAME . $num . "_2"];
             }
             $out .= "</a>";
             return $out;
         case 'glpi_ticketvalidations.status':
         case "glpi_tickets.global_validation":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $status = TicketValidation::getStatus($val);
                 $bgcolor = TicketValidation::getStatusColor($val);
                 $out .= (empty($out) ? '' : '<br>') . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
             }
             return $out;
         case 'glpi_notimportedemails.reason':
             return NotImportedEmail::getReason($data[$NAME . $num]);
         case 'glpi_notimportedemails.messageid':
             $clean = array('<' => '', '>' => '');
             return strtr($data[$NAME . $num], $clean);
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
         if (count($matches) == 2) {
             $plug = $matches[1];
             $function = 'plugin_' . $plug . '_giveItem';
             if (function_exists($function)) {
                 $out = $function($itemtype, $ID, $data, $num);
                 if (!empty($out)) {
                     return $out;
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 if (!empty($data[$NAME . $num . "_2"])) {
                     if (isset($searchopt[$ID]["itemlink_type"])) {
                         $link = getItemTypeFormURLMobile($searchopt[$ID]["itemlink_type"]);
                     } else {
                         $link = getItemTypeFormURLMobile($itemtype);
                     }
                     $out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$NAME . $num . "_2"] . "\" data-back='false'>";
                     $out .= $data[$NAME . $num] . $unit;
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                         $out .= " (" . $data[$NAME . $num . "_2"] . ")";
                     }
                     $out .= "</a>";
                     return $out;
                 } else {
                     if (isset($searchopt[$ID]["itemlink_type"])) {
                         $out = "";
                         $split = explode("\$\$\$\$", $data[$NAME . $num]);
                         $count_display = 0;
                         $separate = '<br>';
                         if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                             $separate = '<hr>';
                         }
                         for ($k = 0; $k < count($split); $k++) {
                             if (strlen(trim($split[$k])) > 0) {
                                 $split2 = explode("\$\$", $split[$k]);
                                 if (isset($split2[1]) && $split2[1] > 0) {
                                     if ($count_display) {
                                         $out .= $separate;
                                     }
                                     $count_display++;
                                     $page = getItemTypeFormURLMobile($searchopt[$ID]["itemlink_type"]);
                                     $page .= strpos($page, '?') ? '&id' : '?id';
                                     $out .= "<a id='" . $searchopt[$ID]["itemlink_type"] . "_" . $split2[1] . "'\n                                       href='{$page}=" . $split2[1] . "' data-back='false'>";
                                     $out .= $split2[0] . $unit;
                                     if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                                         $out .= " (" . $split2[1] . ")";
                                     }
                                     $out .= "</a>";
                                 }
                             }
                         }
                         return $out;
                     }
                 }
                 break;
             case "text":
                 $separate = '<br>';
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = '<hr>';
                 }
                 return str_replace('$$$$', $separate, nl2br($data[$NAME . $num]));
             case "date":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . convDate($val);
                 }
                 return $out;
             case "datetime":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . Html::convDateTime($val);
                 }
                 return $out;
             case "timestamp":
                 return timestampToString($data[$NAME . $num]);
             case "realtime":
                 return Ticket::getRealtime($data[$NAME . $num]);
             case "date_delay":
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     if (strpos($val, ',')) {
                         list($dat, $dur) = explode(',', $val);
                         if (!empty($dat)) {
                             $out .= (empty($out) ? '' : '<br>') . getWarrantyExpir($dat, $dur);
                         }
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "email":
                 // Stevenes
                 //               $email=trim($data[$NAME.$num]);
                 $email = explode('$$', $data[$NAME . $num]);
                 if (!empty($email['0'])) {
                     return $email['0'];
                     //return "<a href='mailto:$email'>$email</a>";
                 }
                 return "&nbsp;";
             case "weblink":
                 $orig_link = trim($data[$NAME . $num]);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (utf8_strlen($link) > 30) {
                         $link = Toolbox::substr($link, 0, 30) . "...";
                     }
                     //return "<a href=\"".formatOutputWebLink($orig_link)."\" target='_blank'>$link</a>";
                     return $orig_link;
                 }
                 return "&nbsp;";
             case "number":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', Html::formatNumber($split[$k], false, 0)) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', Html::formatNumber($data[$NAME . $num], false, 0)) . $unit;
             case "decimal":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', Html::formatNumber($split[$k])) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', Html::formatNumber($data[$NAME . $num])) . $unit;
             case "bool":
                 return Dropdown::getYesNo($data[$NAME . $num]) . $unit;
             case "right":
                 return Profile::getRightValue($data[$NAME . $num]);
             case "itemtypename":
                 if (class_exists($data[$NAME . $num])) {
                     $obj = new $data[$NAME . $num]();
                     return $obj->getTypeName();
                 } else {
                     return "";
                 }
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$NAME . $num]])) {
                     return $CFG_GLPI['languages'][$data[$NAME . $num]][0];
                 } else {
                     return $LANG['setup'][46];
                 }
                 break;
         }
     }
     // Manage items with need group by / group_concat
     if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
         $out = "";
         $split = explode("\$\$\$\$", $data[$NAME . $num]);
         $count_display = 0;
         $separate = '<br>';
         if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
             $separate = '<hr>';
         }
         for ($k = 0; $k < count($split); $k++) {
             if (strlen(trim($split[$k])) > 0) {
                 if ($count_display) {
                     $out .= $separate;
                 }
                 $count_display++;
                 $out .= $split[$k] . $unit;
             }
         }
         return $out;
     }
     return $data[$NAME . $num] . $unit;
 }
コード例 #5
0
 /**
  * Generic Function to display Items
  *
  * @param $itemtype item type
  * @param $ID ID of the SEARCH_OPTION item
  * @param $data array containing data results
  * @param $num item num in the request
  * @param $meta is a meta item ?
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, $data, $num, $meta = 0)
 {
     global $CFG_GLPI, $LANG;
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     if ($meta) {
         $NAME = "META_";
     }
     $table = $searchopt[$ID]["table"];
     $field = $searchopt[$ID]["field"];
     $linkfield = $searchopt[$ID]["linkfield"];
     switch ($table . '.' . $field) {
         case "glpi_users.name":
             // USER search case
             if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if ($split[$k] > 0) {
                         if ($count_display) {
                             $out .= "<br>";
                         }
                         $count_display++;
                         if ($itemtype == 'Ticket') {
                             $userdata = getUserName($split[$k], 2);
                             $out .= $userdata['name'] . "&nbsp;" . showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                         } else {
                             $out .= getUserName($split[$k], 1);
                         }
                     }
                 }
                 // Manage alternative_email for tickets_users
                 if ($itemtype == 'Ticket' && isset($data[$NAME . $num . '_2'])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . '_2']);
                     for ($k = 0; $k < count($split); $k++) {
                         $split2 = explode(" ", $split[$k]);
                         if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                         }
                     }
                 }
                 return $out;
             }
             if ($itemtype != 'User') {
                 $toadd = '';
                 if ($itemtype == 'Ticket' && $data[$NAME . $num . "_3"] > 0) {
                     $userdata = getUserName($data[$NAME . $num . "_3"], 2);
                     $toadd = "&nbsp;" . showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                 }
                 return formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 1) . $toadd;
             }
             break;
         case "glpi_profiles.interface":
             return Profile::getInterfaceName($data[$NAME . $num]);
         case "glpi_profiles.name":
             if ($itemtype == 'User' && $ID == 20) {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $count_display = 0;
                 $added = array();
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . Dropdown::getDropdownName('glpi_entities', $split2[$k]);
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_complete_entities.completename":
             if ($itemtype == 'User') {
                 $out = "";
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                 $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]);
                 $added = array();
                 $count_display = 0;
                 for ($k = 0; $k < count($split); $k++) {
                     if (strlen(trim($split[$k])) > 0) {
                         $text = $split[$k] . " - " . Dropdown::getDropdownName('glpi_profiles', $split2[$k]);
                         if ($split3[$k]) {
                             $text .= " (R)";
                         }
                         if (!in_array($text, $added)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $text;
                             $added[] = $text;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_entities.completename":
             if ($data[$NAME . $num . "_2"] == 0) {
                 // Set name for Root entity
                 $data[$NAME . $num] = $LANG['entity'][2];
             }
             break;
         case "glpi_documenttypes.icon":
             if (!empty($data[$NAME . $num])) {
                 return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>";
             }
             return "&nbsp;";
         case "glpi_documents.filename":
             $doc = new Document();
             if ($doc->getFromDB($data['id'])) {
                 return $doc->getDownloadLink();
             }
             return NOT_AVAILABLE;
         case "glpi_deviceharddrives.specificity":
         case "glpi_devicememories.specificity":
         case "glpi_deviceprocessors.specificity":
             return $data[$NAME . $num];
         case "glpi_networkports.mac":
             $out = "";
             if ($itemtype == 'Computer') {
                 $displayed = array();
                 if (!empty($data[$NAME . $num . "_2"])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                     if (!empty($data[$NAME . $num])) {
                         $out .= "<br>";
                     }
                 }
                 if (!empty($data[$NAME . $num])) {
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         $lowstr = utf8_strtolower($split[$k]);
                         if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= $split[$k];
                             $displayed[] = $lowstr;
                         }
                     }
                 }
                 return $out;
             }
             break;
         case "glpi_contracts.duration":
         case "glpi_contracts.notice":
         case "glpi_contracts.periodicity":
         case "glpi_contracts.billing":
             if (!empty($data[$NAME . $num])) {
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $output = "";
                 foreach ($split as $duration) {
                     $output .= (empty($output) ? '' : '<br>') . $duration . " " . $LANG['financial'][57];
                 }
                 return $output;
             }
             return "&nbsp;";
         case "glpi_contracts.renewal":
             return Contract::getContractRenewalName($data[$NAME . $num]);
         case "glpi_infocoms.sink_time":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][9];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.warranty_duration":
             if (!empty($data[$NAME . $num])) {
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= empty($out) ? '' : '<br>';
                     if ($val > 0) {
                         $out .= $val . " " . $LANG['financial'][57];
                     }
                     if ($val < 0) {
                         $out .= $LANG['financial'][2];
                     }
                 }
                 return $out;
             }
             return "&nbsp;";
         case "glpi_infocoms.sink_type":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $out .= (empty($out) ? '' : '<br>') . Infocom::getAmortTypeName($val);
             }
             return $out;
         case "glpi_infocoms.alert":
             if ($data[$NAME . $num] == pow(2, Alert::END)) {
                 return $LANG['financial'][80];
             }
             return "";
         case "glpi_contracts.alert":
             switch ($data[$NAME . $num]) {
                 case pow(2, Alert::END):
                     return $LANG['buttons'][32];
                 case pow(2, Alert::NOTICE):
                     return $LANG['financial'][10];
                 case pow(2, Alert::END) + pow(2, Alert::NOTICE):
                     return $LANG['buttons'][32] . " + " . $LANG['financial'][10];
             }
             return "";
         case "glpi_tickets_tickets.tickets_id_1":
             $out = "";
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]);
             $displayed = array();
             for ($k = 0; $k < count($split); $k++) {
                 $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split[$k];
                 if ($linkid > 0 && !isset($displayed[$linkid])) {
                     $text = $linkid . " - " . Dropdown::getDropdownName('glpi_tickets', $linkid);
                     if (count($displayed)) {
                         $out .= "<br>";
                     }
                     $displayed[$linkid] = $linkid;
                     $out .= $text;
                 }
             }
             return $out;
         case "glpi_tickets.count":
             if ($data[$NAME . $num] > 0 && haveRight("show_all_ticket", "1")) {
                 if ($itemtype == 'User') {
                     $options['field'][0] = 4;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = $data['id'];
                     $options['link'][0] = 'AND';
                     $options['field'][1] = 22;
                     $options['searchtype'][1] = 'equals';
                     $options['contains'][1] = $data['id'];
                     $options['link'][1] = 'OR';
                     $options['field'][2] = 5;
                     $options['searchtype'][2] = 'equals';
                     $options['contains'][2] = $data['id'];
                     $options['link'][2] = 'OR';
                 } else {
                     $options['field'][0] = 12;
                     $options['searchtype'][0] = 'equals';
                     $options['contains'][0] = 'all';
                     $options['link'][0] = 'AND';
                     $options['itemtype2'][0] = $itemtype;
                     $options['field2'][0] = self::getOptionNumber($itemtype, 'name');
                     $options['searchtype2'][0] = 'equals';
                     $options['contains2'][0] = $data['id'];
                     $options['link2'][0] = 'AND';
                 }
                 $options['reset'] = 'reset';
                 $out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
                 $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&amp;') . "\">";
                 $out .= $data[$NAME . $num] . "</a>";
             } else {
                 $out = $data[$NAME . $num];
             }
             return $out;
         case "glpi_softwarelicenses.number":
             if ($data[$NAME . $num . "_2"] == -1) {
                 return $LANG['software'][4];
             }
             if (empty($data[$NAME . $num])) {
                 return 0;
             }
             return $data[$NAME . $num];
         case "glpi_auth_tables.name":
             return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]);
         case "glpi_reservationitems.comment":
             if (empty($data[$NAME . $num])) {
                 return "<a title=\"" . $LANG['reservation'][22] . "\"\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . $LANG['common'][49] . "</a>";
             }
             return "<a title=\"" . $LANG['reservation'][22] . "\"\n                     href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . resume_text($data[$NAME . $num]) . "</a>";
         case 'glpi_notifications.mode':
             return Notification::getMode($data[$NAME . $num]);
         case 'glpi_notifications.event':
             $item = NotificationTarget::getInstanceByType($data['itemtype']);
             if ($item) {
                 $events = $item->getAllEvents();
                 return $events[$data[$NAME . $num]];
             }
             return '';
         case 'glpi_crontasks.description':
             $tmp = new CronTask();
             return $tmp->getDescription($data['id']);
         case 'glpi_crontasks.state':
             return CronTask::getStateName($data[$NAME . $num]);
         case 'glpi_crontasks.mode':
             return CronTask::getModeName($data[$NAME . $num]);
         case 'glpi_crontasks.itemtype':
             if ($plug = isPluginItemType($data[$NAME . $num])) {
                 return $plug['plugin'];
             }
             return '';
         case 'glpi_tickets.status':
             $status = Ticket::getStatus($data[$NAME . $num]);
             return "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . $data[$NAME . $num] . ".png\"\n                     alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
         case 'glpi_tickets.type':
             return Ticket::getTicketTypeName($data[$NAME . $num]);
         case 'glpi_tickets.priority':
             return Ticket::getPriorityName($data[$NAME . $num]);
         case 'glpi_tickets.urgency':
             return Ticket::getUrgencyName($data[$NAME . $num]);
         case 'glpi_tickets.impact':
             return Ticket::getImpactName($data[$NAME . $num]);
         case 'glpi_tickets.items_id':
             if (!empty($data[$NAME . $num . "_2"]) && class_exists($data[$NAME . $num . "_2"])) {
                 $item = new $data[$NAME . $num . "_2"]();
                 if ($item->getFromDB($data[$NAME . $num])) {
                     return $item->getLink(true);
                 }
             }
             return '&nbsp;';
         case 'glpi_tickets.name':
             $link = getItemTypeFormURL('Ticket');
             $out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
             $out .= strstr($link, '?') ? '&amp;' : '?';
             $out .= 'id=' . $data[$NAME . $num . "_2"];
             // Force solution tab if solved
             if ($data[$NAME . $num . "_4"] == 'solved') {
                 $out .= "&amp;forcetab=4";
             }
             $out .= "\">" . $data[$NAME . $num];
             if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                 $out .= " (" . $data[$NAME . $num . "_2"] . ")";
             }
             $out .= "</a>";
             $out .= showToolTip(nl2br($data[$NAME . $num . "_3"]), array('applyto' => 'ticket' . $data[$NAME . $num . "_2"], 'display' => false));
             return $out;
         case "glpi_tickets.due_date":
             // No due date in waiting status
             if ($data[$NAME . $num . '_2'] == 'waiting') {
                 $data[$NAME . $num] = "";
             }
             break;
         case 'glpi_ticketvalidations.status':
         case "glpi_tickets.global_validation":
             $split = explode("\$\$\$\$", $data[$NAME . $num]);
             $out = '';
             foreach ($split as $val) {
                 $status = TicketValidation::getStatus($val);
                 $bgcolor = TicketValidation::getStatusColor($val);
                 $out .= (empty($out) ? '' : '<br>') . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
             }
             return $out;
         case 'glpi_ticketsatisfactions.type':
             return TicketSatisfaction::getTypeInquestName($data[$NAME . $num]);
         case 'glpi_ticketsatisfactions.satisfaction':
             return TicketSatisfaction::displaySatisfaction($data[$NAME . $num]);
         case 'glpi_notimportedemails.reason':
             return NotImportedEmail::getReason($data[$NAME . $num]);
         case 'glpi_notimportedemails.messageid':
             $clean = array('<' => '', '>' => '');
             return strtr($data[$NAME . $num], $clean);
         case 'glpi_fieldunicities.fields':
             $values = explode(',', $data[$NAME . $num]);
             $item = new $data['ITEMTYPE']();
             $message = array();
             foreach ($values as $field) {
                 $table = getTableNameForForeignKeyField($field);
                 if ($table != '') {
                     $searchOption = $item->getSearchOptionByField('field', 'name', $table);
                 } else {
                     $searchOption = $item->getSearchOptionByField('field', $field);
                 }
                 $message[] = $searchOption['name'];
             }
             return implode(',', $message);
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
         if (count($matches) == 2) {
             $plug = $matches[1];
             $function = 'plugin_' . $plug . '_giveItem';
             if (function_exists($function)) {
                 $out = $function($itemtype, $ID, $data, $num);
                 if (!empty($out)) {
                     return $out;
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 if (!empty($data[$NAME . $num . "_2"])) {
                     if (isset($searchopt[$ID]["itemlink_type"])) {
                         $link = getItemTypeFormURL($searchopt[$ID]["itemlink_type"]);
                     } else {
                         $link = getItemTypeFormURL($itemtype);
                     }
                     $out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$NAME . $num . "_2"] . "\">" . $data[$NAME . $num] . $unit;
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
                         $out .= " (" . $data[$NAME . $num . "_2"] . ")";
                     }
                     $out .= "</a>";
                     return $out;
                 }
                 if (isset($searchopt[$ID]["itemlink_type"])) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     $separate = '<br>';
                     if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                         $separate = '<hr>';
                     }
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             $split2 = explode("\$\$", $split[$k]);
                             if (isset($split2[1]) && $split2[1] > 0) {
                                 if ($count_display) {
                                     $out .= $separate;
                                 }
                                 $count_display++;
                                 $page = getItemTypeFormURL($searchopt[$ID]["itemlink_type"]);
                                 $page .= strpos($page, '?') ? '&id' : '?id';
                                 $out .= "<a id='" . $searchopt[$ID]["itemlink_type"] . "_" . $data['id'] . "_" . $split2[1] . "' href='{$page}=" . $split2[1] . "'>" . $split2[0] . $unit;
                                 if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
                                     $out .= " (" . $split2[1] . ")";
                                 }
                                 $out .= "</a>";
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "text":
                 $separate = '<br>';
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = '<hr>';
                 }
                 $text = str_replace('$$$$', $separate, nl2br($data[$NAME . $num]));
                 if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
                     $text = html_clean(unclean_cross_side_scripting_deep($text));
                 }
                 return $text;
             case "date":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . convDate($val);
                 }
                 return $out;
             case "datetime":
                 $split = explode("\$\$\$\$", $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     $out .= (empty($out) ? '' : '<br>') . convDateTime($val);
                 }
                 return $out;
             case "timestamp":
                 $withseconds = false;
                 if (isset($searchopt[$ID]['withseconds'])) {
                     $withseconds = $searchopt[$ID]['withseconds'];
                 }
                 return timestampToString($data[$NAME . $num], $withseconds);
             case "date_delay":
                 $split = explode('$$$$', $data[$NAME . $num]);
                 $out = '';
                 foreach ($split as $val) {
                     if (strpos($val, ',')) {
                         list($dat, $dur) = explode(',', $val);
                         if (!empty($dat)) {
                             $out .= (empty($out) ? '' : '<br>') . getWarrantyExpir($dat, $dur);
                         }
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "email":
                 $email = trim($data[$NAME . $num]);
                 if (!empty($email)) {
                     return "<a href='mailto:{$email}'>{$email}</a>";
                 }
                 return "&nbsp;";
             case "weblink":
                 $orig_link = trim($data[$NAME . $num]);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (utf8_strlen($link) > $CFG_GLPI["url_maxlength"]) {
                         $link = utf8_substr($link, 0, $CFG_GLPI["url_maxlength"]) . "...";
                     }
                     return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>";
                 }
                 return "&nbsp;";
             case "number":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', formatNumber($split[$k], false, 0)) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', formatNumber($data[$NAME . $num], false, 0)) . $unit;
             case "decimal":
                 if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
                     $out = "";
                     $split = explode("\$\$\$\$", $data[$NAME . $num]);
                     $count_display = 0;
                     for ($k = 0; $k < count($split); $k++) {
                         if (strlen(trim($split[$k])) > 0) {
                             if ($count_display) {
                                 $out .= "<br>";
                             }
                             $count_display++;
                             $out .= str_replace(' ', '&nbsp;', formatNumber($split[$k])) . $unit;
                         }
                     }
                     return $out;
                 }
                 return str_replace(' ', '&nbsp;', formatNumber($data[$NAME . $num])) . $unit;
             case "bool":
                 return Dropdown::getYesNo($data[$NAME . $num]) . $unit;
             case "right":
                 return Profile::getRightValue($data[$NAME . $num]);
             case "itemtypename":
                 if (class_exists($data[$NAME . $num])) {
                     $obj = new $data[$NAME . $num]();
                     return $obj->getTypeName();
                 }
                 return "";
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$NAME . $num]])) {
                     return $CFG_GLPI['languages'][$data[$NAME . $num]][0];
                 }
                 return $LANG['setup'][46];
         }
     }
     // Manage items with need group by / group_concat
     if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) {
         $out = "";
         $split = explode("\$\$\$\$", $data[$NAME . $num]);
         $count_display = 0;
         $separate = '<br>';
         if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
             $separate = '<hr>';
         }
         for ($k = 0; $k < count($split); $k++) {
             if (strlen(trim($split[$k])) > 0) {
                 if ($count_display) {
                     $out .= $separate;
                 }
                 $count_display++;
                 $out .= $split[$k] . $unit;
             }
         }
         return $out;
     }
     return $data[$NAME . $num] . $unit;
 }