/**
  * Additional message in global message
  *
  * @param $msg text to display
  **/
 function displayMessage($msg)
 {
     global $LANG;
     $fin = time();
     $tps = timestampToString($fin - $this->deb);
     echo "<script type='text/javascript'>document.getElementById('migration_message_" . $this->version . "').innerHTML=\"<p class='center'>{$msg} ({$tps})</p>\";</script>\n";
     glpi_flush();
 }
 function getDatasForTemplate($event, $options = array())
 {
     global $LANG;
     if ($options['diff'] > 1000000000) {
         $tmp = $LANG['install'][35];
     } else {
         $tmp = timestampToString($options['diff'], true);
     }
     $this->datas['##dbconnection.delay##'] = $tmp . " (" . $options['name'] . ")";
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 function showStats()
 {
     global $LANG;
     if (!haveRight('observe_ticket', 1) || !isset($this->fields['id'])) {
         return false;
     }
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . $LANG['common'][99] . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . $LANG['reports'][60] . "&nbsp;:</td>";
     echo "<td>" . convDateTime($this->fields['date']) . "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . $LANG['sla'][5] . "&nbsp;:</td>";
     echo "<td>" . convDateTime($this->fields['due_date']) . "</td></tr>";
     if ($this->fields['status'] == 'solved' || $this->fields['status'] == 'closed') {
         echo "<tr class='tab_bg_2'><td>" . $LANG['reports'][64] . "&nbsp;:</td>";
         echo "<td>" . convDateTime($this->fields['solvedate']) . "</td></tr>";
     }
     if ($this->fields['status'] == 'closed') {
         echo "<tr class='tab_bg_2'><td>" . $LANG['reports'][61] . "&nbsp;:</td>";
         echo "<td>" . convDateTime($this->fields['closedate']) . "</td></tr>";
     }
     echo "<tr><th colspan='2'>" . $LANG['common'][100] . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . $LANG['stats'][12] . "&nbsp;:</td><td>";
     if ($this->fields['takeintoaccount_delay_stat'] > 0) {
         echo timestampToString($this->fields['takeintoaccount_delay_stat'], 0);
     } else {
         echo '&nbsp;';
     }
     echo "</td></tr>";
     if ($this->fields['status'] == 'solved' || $this->fields['status'] == 'closed') {
         echo "<tr class='tab_bg_2'><td>" . $LANG['stats'][9] . "&nbsp;:</td><td>";
         if ($this->fields['solve_delay_stat'] > 0) {
             echo timestampToString($this->fields['solve_delay_stat'], 0);
         } else {
             echo '&nbsp;';
         }
         echo "</td></tr>";
     }
     if ($this->fields['status'] == 'closed') {
         echo "<tr class='tab_bg_2'><td>" . $LANG['stats'][10] . "&nbsp;:</td><td>";
         if ($this->fields['close_delay_stat'] > 0) {
             echo timestampToString($this->fields['close_delay_stat']);
         } else {
             echo '&nbsp;';
         }
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_2'><td>" . $LANG['joblist'][26] . "&nbsp;:</td><td>";
     if ($this->fields['ticket_waiting_duration'] > 0) {
         echo timestampToString($this->fields['ticket_waiting_duration'], 0);
     } else {
         echo '&nbsp;';
     }
     echo "</td></tr>";
     echo "</table>";
     echo "</div>";
 }
            if (!isset($_GET['offset'])) {
                // First run
                $offset = $rulecollection->replayRulesOnExistingDB(0, $max, array(), $_POST);
                $manufacturer = isset($_POST["manufacturer"]) ? $_POST["manufacturer"] : 0;
            } else {
                // Next run
                $offset = $rulecollection->replayRulesOnExistingDB($_GET['offset'], $max, array(), $_GET);
                $manufacturer = $_GET["manufacturer"];
                // global start for stat
                $start = $_GET["start"];
            }
            if ($offset < 0) {
                // Work ended
                $end = explode(" ", microtime());
                $duree = round($end[0] + $end[1] - $start);
                changeProgressBarMessage($LANG['rulesengine'][91] . " (" . timestampToString($duree) . ")");
                echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . $LANG['buttons'][13] . "</a>";
            } else {
                // Need more work
                glpi_header($_SERVER['PHP_SELF'] . "?start={$start}&replay_rule=1&offset={$offset}&manufacturer=" . "{$manufacturer}");
            }
            commonFooter(true);
            exit;
        }
    }
}
commonHeader($LANG['rulesengine'][17], $_SERVER['PHP_SELF'], "admin", $rulecollection->menu_type, $rulecollection->menu_option);
if ($rulecollection->showInheritedTab()) {
    $tabs[0] = array('title' => $LANG['rulesengine'][20] . ' : ' . Dropdown::getDropdownName('glpi_entities', $_SESSION['glpiactive_entity']), 'url' => $CFG_GLPI['root_doc'] . "/ajax/rules.tabs.php", 'params' => "target=" . $_SERVER['PHP_SELF'] . "&glpi_tab=1&inherited=1&itemtype=" . get_class($rulecollection));
}
$title = $LANG['rulesengine'][17];
 function showForSLA(SLA $sla)
 {
     global $DB, $CFG_GLPI, $LANG;
     $ID = $sla->getField('id');
     if (!$sla->can($ID, 'r')) {
         return false;
     }
     $canedit = $sla->can($ID, 'w');
     $rand = mt_rand();
     echo "<form name='slalevel_form{$rand}' id='slalevel_form{$rand}' method='post' action='";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     if ($canedit) {
         echo "<div class='center first-bloc'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['sla'][4] . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . $LANG['common'][16] . "&nbsp;: ";
         echo "<input type='hidden' name='slas_id' value='{$ID}'>";
         echo "<input type='hidden' name='entities_id' value='" . $sla->getEntityID() . "'>";
         echo "<input type='hidden' name='is_recursive' value='" . $sla->isRecursive() . "'>";
         echo "<input  name='name' value=''>";
         echo "</td><td class='center'>" . $LANG['sla'][3] . "&nbsp;: ";
         self::dropdownExecutionTime('execution_time', array('max_time' => $sla->fields['resolution_time'], 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id'])));
         echo "</td><td class='center'>" . $LANG['common'][60] . "&nbsp;: ";
         Dropdown::showYesNo("is_active", array('value' => 1));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
         $query = "SELECT *\n                  FROM `glpi_slalevels`\n                  WHERE `slas_id` = '{$ID}'\n                  ORDER BY `execution_time`";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             echo "<div class='center'><table class='tab_cadre_fixehov'>";
             echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>";
             echo "<th>" . $LANG['sla'][3] . "</th>";
             echo "<th>" . $LANG['common'][60] . "</th>";
             echo "</tr>";
             initNavigateListItems('SlaLevel', $LANG['sla'][1] . " - " . $sla->getName());
             while ($data = $DB->fetch_array($result)) {
                 addToNavigateListItems('SlaLevel', $data["id"]);
                 echo "<tr class='tab_bg_2'>";
                 echo "<td width='10'>";
                 if ($canedit) {
                     echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 echo "<td>";
                 if ($canedit) {
                     echo "<a href='" . getItemTypeFormURL('SlaLevel') . "?id=" . $data["id"] . "'>";
                 }
                 echo $data["name"];
                 if (empty($data["name"])) {
                     echo "(" . $data['id'] . ")";
                 }
                 if ($canedit) {
                     echo "</a>";
                 }
                 echo "</td>";
                 echo "<td>" . ($data["execution_time"] != 0 ? timestampToString($data["execution_time"], false) : $LANG['sla'][5]) . "</td>";
                 echo "<td>" . Dropdown::getYesNo($data["is_active"]) . "</td>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'><td colspan='4'>";
                 $this->getRuleWithCriteriasAndActions($data['id'], 0, 1);
                 $this->showActionsList($data["id"], array('readonly' => true));
                 echo "</td></tr>";
             }
             openArrowMassive("slalevel_form{$rand}", true);
             closeArrowMassive('delete', $LANG['buttons'][6]);
             echo "</table></div>";
         }
     }
     echo "</form>";
 }
 function displayValues($services_id, $period, $tooltip = 0)
 {
     $a_times = $this->parseEvents($services_id, $period);
     $displaytime = '';
     if ($a_times[0] > 0) {
         echo "<td style='background-color: rgb(255, 120, 0);-moz-border-radius: 4px;-webkit-border-radius: 4px;-o-border-radius: 4px;padding: 2px;' align='center'>";
         if ($tooltip == '1') {
             $displaytime = '&nbsp;' . showToolTip(timestampToString($a_times[0]), array('display' => false));
         } else {
             $displaytime = '<br/>' . timestampToString($a_times[0]);
         }
     } else {
         echo "<td align='center'>";
     }
     echo round(($a_times[1] - $a_times[0]) / $a_times[1] * 100, 3) . "%" . $displaytime;
     echo "</td>";
 }
Beispiel #7
0
 /**
  * Retrieve last history Data for an item
  *
  * @param $item CommonDBTM object
  * @param $start interger first line to retrieve
  * @param $limit interfer max number of line to retrive (0 for all)
  * @param $sqlfilter string to add an SQL filter
  *
  * @return array of localized log entry (TEXT only, no HTML)
  **/
 static function getHistoryData(CommonDBTM $item, $start = 0, $limit = 0, $sqlfilter = '')
 {
     global $DB, $LANG;
     $itemtype = $item->getType();
     $items_id = $item->getField('id');
     $SEARCHOPTION = Search::getOptions($itemtype);
     $query = "SELECT *\n                FROM `glpi_logs`\n                WHERE `items_id` = '{$items_id}'\n                      AND `itemtype` = '{$itemtype}' ";
     if ($sqlfilter) {
         $query .= "AND ({$sqlfilter}) ";
     }
     $query .= "ORDER BY `id` DESC";
     if ($limit) {
         $query .= " LIMIT " . intval($start) . "," . intval($limit);
     }
     $changes = array();
     foreach ($DB->request($query) as $data) {
         $tmp = array();
         $tmp['display_history'] = true;
         $tmp['id'] = $data["id"];
         $tmp['date_mod'] = convDateTime($data["date_mod"]);
         $tmp['user_name'] = $data["user_name"];
         $tmp['field'] = "";
         $tmp['change'] = "";
         $tmp['datatype'] = "";
         // This is an internal device ?
         if ($data["linked_action"]) {
             // Yes it is an internal device
             switch ($data["linked_action"]) {
                 case HISTORY_CREATE_ITEM:
                     $tmp['change'] = $LANG['log'][20];
                     break;
                 case HISTORY_DELETE_ITEM:
                     $tmp['change'] = $LANG['log'][22];
                     break;
                 case HISTORY_RESTORE_ITEM:
                     $tmp['change'] = $LANG['log'][23];
                     break;
                 case HISTORY_ADD_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['devices'][25] . " : " . "\"" . $data["new_value"] . "\"";
                     break;
                 case HISTORY_UPDATE_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     $change = '';
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                         $specif_fields = $item->getSpecifityLabel();
                         $tmp['change'] = $specif_fields['specificity'] . " : ";
                     }
                     $tmp['change'] .= $data["old_value"] . " --> " . "\"" . $data["new_value"] . "\"";
                     break;
                 case HISTORY_DELETE_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['devices'][26] . " : " . "\"" . $data["old_value"] . "\"";
                     break;
                 case HISTORY_INSTALL_SOFTWARE:
                     $tmp['field'] = $LANG['help'][31];
                     $tmp['change'] = $LANG['software'][44] . " : " . "\"" . $data["new_value"] . "\"";
                     break;
                 case HISTORY_UNINSTALL_SOFTWARE:
                     $tmp['field'] = $LANG['help'][31];
                     $tmp['change'] = $LANG['software'][45] . " : " . "\"" . $data["old_value"] . "\"";
                     break;
                 case HISTORY_DISCONNECT_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][26] . " : " . "\"" . $data["old_value"] . "\"";
                     break;
                 case HISTORY_CONNECT_DEVICE:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][27] . " : " . "\"" . $data["new_value"] . "\"";
                     break;
                 case HISTORY_OCS_IMPORT:
                     if (haveRight("view_ocsng", "r")) {
                         $tmp['field'] = "";
                         $tmp['change'] = $LANG['ocsng'][7] . " " . $LANG['ocsng'][45] . " :";
                         $tmp['change'] .= " " . "\"" . $data["new_value"] . "\"";
                     } else {
                         $tmp['display_history'] = false;
                     }
                     break;
                 case HISTORY_OCS_DELETE:
                     if (haveRight("view_ocsng", "r")) {
                         $tmp['field'] = "";
                         $tmp['change'] = $LANG['ocsng'][46] . " " . $LANG['ocsng'][45] . " :";
                         $tmp['change'] .= " " . "\"" . $data["old_value"] . "\"";
                     } else {
                         $tmp['display_history'] = false;
                     }
                     break;
                 case HISTORY_OCS_LINK:
                     if (haveRight("view_ocsng", "r")) {
                         $tmp['field'] = NOT_AVAILABLE;
                         if (class_exists($data["itemtype_link"])) {
                             $item = new $data["itemtype_link"]();
                             $tmp['field'] = $item->getTypeName();
                         }
                         $tmp['change'] = $LANG['ocsng'][47] . " " . $LANG['ocsng'][45] . " :";
                         $tmp['change'] .= " " . "\"" . $data["new_value"] . "\"";
                     } else {
                         $tmp['display_history'] = false;
                     }
                     break;
                 case HISTORY_OCS_IDCHANGED:
                     if (haveRight("view_ocsng", "r")) {
                         $tmp['field'] = "";
                         $tmp['change'] = $LANG['ocsng'][48] . " " . " : " . "\"" . $data["old_value"] . "\" -->  : " . "\"" . $data["new_value"] . "\"";
                     } else {
                         $tmp['display_history'] = false;
                     }
                     break;
                 case HISTORY_LOG_SIMPLE_MESSAGE:
                     $tmp['field'] = "";
                     $tmp['change'] = $data["new_value"];
                     break;
                 case HISTORY_ADD_RELATION:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][32] . " : " . "\"" . $data["new_value"] . "\"";
                     break;
                 case HISTORY_DEL_RELATION:
                     $tmp['field'] = NOT_AVAILABLE;
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][33] . " : " . "\"" . $data["old_value"] . "\"";
                     break;
                 case HISTORY_ADD_SUBITEM:
                     $tmp['field'] = '';
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][98] . " : " . $tmp['field'] . " (" . $data["new_value"] . ")";
                     break;
                 case HISTORY_UPDATE_SUBITEM:
                     $tmp['field'] = '';
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][99] . " : " . $tmp['field'] . " (" . $data["new_value"] . ")";
                     break;
                 case HISTORY_DELETE_SUBITEM:
                     $tmp['field'] = '';
                     if (class_exists($data["itemtype_link"])) {
                         $item = new $data["itemtype_link"]();
                         $tmp['field'] = $item->getTypeName();
                     }
                     $tmp['change'] = $LANG['log'][100] . " : " . $tmp['field'] . " (" . $data["old_value"] . ")";
                     break;
             }
         } else {
             $fieldname = "";
             // It's not an internal device
             foreach ($SEARCHOPTION as $key2 => $val2) {
                 if ($key2 == $data["id_search_option"]) {
                     $tmp['field'] = $val2["name"];
                     $fieldname = $val2["field"];
                     if (isset($val2['datatype'])) {
                         $tmp['datatype'] = $val2["datatype"];
                     }
                 }
             }
             switch ($tmp['datatype']) {
                 case "bool":
                     $data["old_value"] = Dropdown::getYesNo($data["old_value"]);
                     $data["new_value"] = Dropdown::getYesNo($data["new_value"]);
                     break;
                 case "datetime":
                     $data["old_value"] = convDateTime($data["old_value"]);
                     $data["new_value"] = convDateTime($data["new_value"]);
                     break;
                 case "date":
                     $data["old_value"] = convDate($data["old_value"]);
                     $data["new_value"] = convDate($data["new_value"]);
                     break;
                 case "timestamp":
                     $data["old_value"] = timestampToString($data["old_value"]);
                     $data["new_value"] = timestampToString($data["new_value"]);
                     break;
                 case "actiontime":
                     $data["old_value"] = Ticket::getActionTime($data["old_value"]);
                     $data["new_value"] = Ticket::getActionTime($data["new_value"]);
                     break;
                 case "number":
                     $data["old_value"] = formatNumber($data["old_value"], false, 0);
                     $data["new_value"] = formatNumber($data["new_value"], false, 0);
                     break;
                 case "decimal":
                     $data["old_value"] = formatNumber($data["old_value"]);
                     $data["new_value"] = formatNumber($data["new_value"]);
                     break;
                 case "right":
                     $data["old_value"] = Profile::getRightValue($data["old_value"]);
                     $data["new_value"] = Profile::getRightValue($data["new_value"]);
                     break;
                 case "text":
                     $tmp['change'] = $LANG['log'][64];
                     break;
             }
             if (empty($tmp['change'])) {
                 $tmp['change'] = "\"" . $data["old_value"] . "\" --> \"" . $data["new_value"] . "\"";
             }
         }
         $changes[] = $tmp;
     }
     return $changes;
 }
 function ShowProcesses()
 {
     global $DB, $LANG;
     $ci = new commonitem();
     echo "<table class='tab_cadre' cellpadding='5' width='1150'>";
     $this->ShowHeader();
     $i = 0;
     $query = "SELECT * FROM `" . $this->table . "`\n         ORDER BY `process_number` DESC";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $i++;
             if ($i == '8') {
                 echo "<tr class='tab_bg_2'>";
                 echo "<td colspan='14' height='5'></td>";
                 echo "</tr>";
                 $this->ShowHeader();
                 $i = 0;
             }
             echo "<tr class='tab_bg_2'>";
             echo "<td colspan='14' height='5'></td>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td rowspan='2'>";
             echo $data['process_number'];
             echo "</td>";
             echo "<td rowspan='2'>";
             $ci->getFromDB(PLUGIN_FUSIONINVENTORY_SNMP_AGENTS, $data['FK_agent']);
             echo $ci->getLink(1);
             echo "</td>";
             echo "<td rowspan='2'>";
             switch ($data['status']) {
                 case 3:
                     echo "<img src='../pics/export.png' />";
                     break;
                 case 2:
                     echo "<img src='../pics/wait.png' />";
                     break;
                 case 1:
                     echo "<img src='../pics/ok2.png' />";
                     break;
             }
             echo "</td>";
             echo "<td rowspan='2'>";
             echo convDateTime($data['start_time']);
             echo "</td>";
             echo "<td rowspan='2'>";
             if ($data['start_time'] != '0000-00-00 00:00:00' and $data['end_time'] != '0000-00-00 00:00:00') {
                 $duree_timestamp = strtotime($data['end_time']) - strtotime($data['start_time']);
                 echo timestampToString($duree_timestamp);
             } else {
                 echo '-';
             }
             echo "</td>";
             echo "<td height='28'>";
             if ($data['start_time_discovery'] != '0000-00-00 00:00:00') {
                 if ($data['end_time_discovery'] != '0000-00-00 00:00:00') {
                     echo "<img src='../pics/export.png' />";
                 } else {
                     echo "<img src='../pics/wait.png' />";
                 }
             } else {
                 if ($data['discovery_core'] != '0') {
                     echo "<img src='../pics/ok2.png' />";
                 }
             }
             echo "</td>";
             echo "<td>";
             if ($data['start_time_discovery'] != '0000-00-00 00:00:00') {
                 echo convDateTime($data['start_time_discovery']);
             } else {
                 echo '-';
             }
             echo "</td>";
             echo "<td>";
             if ($data['start_time_discovery'] != '0000-00-00 00:00:00' and $data['end_time_discovery'] != '0000-00-00 00:00:00') {
                 $duree_timestamp = strtotime($data['end_time_discovery']) - strtotime($data['start_time_discovery']);
                 echo timestampToString($duree_timestamp);
             } else {
                 echo '-';
             }
             echo "</td>";
             echo "<td>";
             echo $data['discovery_core'];
             echo "</td>";
             echo "<td>";
             echo $data['discovery_threads'];
             echo "</td>";
             echo "<td>";
             echo $data['discovery_nb_ip'];
             echo "</td>";
             echo "<td>";
             echo $data['discovery_nb_found'];
             if ($data['discovery_nb_error'] > 0) {
                 echo " / <a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?process_number=" . $data['process_number'] . "&agent_type=NETDISCOVERY'>\n                  <font color='#ff0000'>" . $data['discovery_nb_error'] . "</font></a>";
             } else {
                 echo " / " . $data['discovery_nb_error'];
             }
             echo "</td>";
             echo "<td>";
             echo $data['discovery_nb_exists'];
             echo "</td>";
             echo "<td>";
             echo $data['discovery_nb_import'];
             echo "</td>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td height='28'>";
             if ($data['start_time_query'] != '0000-00-00 00:00:00') {
                 if ($data['end_time_query'] != '0000-00-00 00:00:00') {
                     echo "<img src='../pics/export.png' />";
                 } else {
                     echo "<img src='../pics/wait.png' />";
                 }
             } else {
                 if ($data['query_core'] != '0') {
                     echo "<img src='../pics/ok2.png' />";
                 }
             }
             echo "</td>";
             echo "<td>";
             if ($data['start_time_query'] != '0000-00-00 00:00:00') {
                 echo convDateTime($data['start_time_query']);
             } else {
                 echo '-';
             }
             echo "</td>";
             echo "<td>";
             if ($data['start_time_query'] != '0000-00-00 00:00:00' and $data['end_time_query'] != '0000-00-00 00:00:00') {
                 $duree_timestamp = strtotime($data['end_time_query']) - strtotime($data['start_time_query']);
                 echo timestampToString($duree_timestamp);
             } else {
                 echo '-';
             }
             echo "</td>";
             echo "<td>";
             echo $data['query_core'];
             echo "</td>";
             echo "<td>";
             echo $data['query_threads'];
             echo "</td>";
             echo "<td>";
             echo $data['query_nb_query'];
             echo "</td>";
             echo "<td>";
             if ($data['query_nb_error'] > 0) {
                 echo "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?process_number=" . $data['process_number'] . "&agent_type=SNMPQUERY'>\n                  <font color='#ff0000'>" . $data['query_nb_error'] . "</font></a>";
             } else {
                 echo $data['query_nb_error'];
             }
             echo "</td>";
             echo "<td>";
             if ($data['query_nb_connections_created'] > 0) {
                 echo "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?process_number=" . $data['process_number'] . "&amp;created=1'>\n                  " . $data['query_nb_connections_created'] . "</a>";
             } else {
                 echo $data['query_nb_connections_created'];
             }
             echo "</td>";
             echo "<td>";
             if ($data['query_nb_connections_deleted'] > 0) {
                 echo "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?process_number=" . $data['process_number'] . "&amp;created=0'>\n                  " . $data['query_nb_connections_deleted'] . "</a>";
             } else {
                 echo $data['query_nb_connections_deleted'];
             }
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='14' height='5'></td>";
     echo "</tr>";
     echo "</table>";
 }
 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;
 }
Beispiel #10
0
 static function show($type, $date1, $date2, $start, $value, $value2 = "")
 {
     global $LANG, $CFG_GLPI;
     // Set display type for export if define
     $output_type = HTML_OUTPUT;
     if (isset($_GET["display_type"])) {
         $output_type = $_GET["display_type"];
     }
     if ($output_type == HTML_OUTPUT) {
         // HTML display
         echo "<div class ='center'>";
     }
     if (is_array($value)) {
         $end_display = $start + $_SESSION['glpilist_limit'];
         $numrows = count($value);
         if (isset($_GET['export_all'])) {
             $start = 0;
             $end_display = $numrows;
         }
         $nbcols = 8;
         if ($output_type != HTML_OUTPUT) {
             // not HTML display
             $nbcols--;
         }
         echo Search::showHeader($output_type, $end_display - $start + 1, $nbcols);
         if ($output_type == HTML_OUTPUT) {
             // HTML display
             echo Search::showNewLine($output_type);
             $header_num = 1;
             echo Search::showHeaderItem($output_type, "&nbsp;", $header_num);
             echo Search::showHeaderItem($output_type, "", $header_num);
             echo Search::showHeaderItem($output_type, $LANG['stats'][13], $header_num, '', 0, '', "colspan=4");
             echo Search::showHeaderItem($output_type, $LANG['satisfaction'][0], $header_num, '', 0, '', "colspan=3");
             echo Search::showHeaderItem($output_type, $LANG['stats'][8], $header_num, '', 0, '', "colspan=3");
             echo Search::showHeaderItem($output_type, $LANG['stats'][26], $header_num, '', 0, '', "colspan=2");
         }
         echo Search::showNewLine($output_type);
         $header_num = 1;
         $header_to_add = '';
         echo Search::showHeaderItem($output_type, "&nbsp;", $header_num);
         if ($output_type == HTML_OUTPUT) {
             // HTML display
             echo Search::showHeaderItem($output_type, "", $header_num);
         }
         if ($output_type != HTML_OUTPUT) {
             $header_to_add = $LANG['stats'][13] . ' - ';
         }
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['job'][14], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['job'][15], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['job'][17], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['job'][16], $header_num);
         if ($output_type != HTML_OUTPUT) {
             $header_to_add = $LANG['satisfaction'][0] . ' - ';
         }
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['satisfaction'][13], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['satisfaction'][14], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['common'][107], $header_num);
         if ($output_type != HTML_OUTPUT) {
             $header_to_add = $LANG['stats'][8] . ' - ';
         }
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['stats'][12], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['stats'][9], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['stats'][10], $header_num);
         if ($output_type != HTML_OUTPUT) {
             $header_to_add = $LANG['stats'][26] . ' - ';
         }
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['common'][107], $header_num);
         echo Search::showHeaderItem($output_type, $header_to_add . $LANG['common'][33], $header_num);
         // End Line for column headers
         echo Search::showEndLine($output_type);
         $row_num = 1;
         for ($i = $start; $i < $numrows && $i < $end_display; $i++) {
             $row_num++;
             $item_num = 1;
             echo Search::showNewLine($output_type, $i % 2);
             echo Search::showItem($output_type, $value[$i]['link'], $item_num, $row_num);
             if ($output_type == HTML_OUTPUT) {
                 // HTML display
                 $link = "";
                 if ($value[$i]['id'] > 0) {
                     $link = "<a href='stat.graph.php?id=" . $value[$i]['id'] . "&amp;date1={$date1}&amp;date2={$date2}&amp;type={$type}" . (!empty($value2) ? "&amp;champ={$value2}" : "") . "'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/stats_item.png' alt='' title=''>" . "</a>";
                 }
                 echo Search::showItem($output_type, $link, $item_num, $row_num);
             }
             //le nombre d'intervention - the number of intervention
             $opened = self::constructEntryValues("inter_total", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_opened = array_sum($opened);
             echo Search::showItem($output_type, $nb_opened, $item_num, $row_num);
             //le nombre d'intervention resolues - the number of resolved intervention
             $solved = self::constructEntryValues("inter_solved", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_solved = array_sum($solved);
             if ($nb_opened > 0 && $nb_solved > 0) {
                 $nb_solved .= ' (' . round($nb_solved * 100 / $nb_opened) . '%)';
             }
             echo Search::showItem($output_type, $nb_solved, $item_num, $row_num);
             //le nombre d'intervention resolues - the number of resolved intervention
             $solved_late = self::constructEntryValues("inter_solved_late", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_solved_late = array_sum($solved_late);
             if ($nb_solved > 0 && $nb_solved_late > 0) {
                 $nb_solved_late .= ' (' . round($nb_solved_late * 100 / $nb_solved) . '%)';
             }
             echo Search::showItem($output_type, $nb_solved_late, $item_num, $row_num);
             //le nombre d'intervention closes - the number of closed intervention
             $closed = self::constructEntryValues("inter_closed", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_closed = array_sum($closed);
             if ($nb_opened > 0 && $nb_closed > 0) {
                 $nb_closed .= ' (' . round($nb_closed * 100 / $nb_opened) . '%)';
             }
             echo Search::showItem($output_type, $nb_closed, $item_num, $row_num);
             //Satisfaction open
             $opensatisfaction = self::constructEntryValues("inter_opensatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_opensatisfaction = array_sum($opensatisfaction);
             if ($nb_opensatisfaction > 0) {
                 $nb_opensatisfaction .= ' (' . round($nb_opensatisfaction * 100 / $nb_closed) . '%)';
             }
             echo Search::showItem($output_type, $nb_opensatisfaction, $item_num, $row_num);
             //Satisfaction answer
             $answersatisfaction = self::constructEntryValues("inter_answersatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2);
             $nb_answersatisfaction = array_sum($answersatisfaction);
             if ($nb_answersatisfaction > 0) {
                 $nb_answersatisfaction .= ' (' . round($nb_answersatisfaction * 100 / $nb_opensatisfaction) . '%)';
             }
             echo Search::showItem($output_type, $nb_answersatisfaction, $item_num, $row_num);
             //Satisfaction rate
             $satisfaction = self::constructEntryValues("inter_avgsatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2);
             foreach ($satisfaction as $key2 => $val2) {
                 $satisfaction[$key2] *= $answersatisfaction[$key2];
             }
             if ($nb_answersatisfaction > 0) {
                 $avgsatisfaction = round(array_sum($satisfaction) / $nb_answersatisfaction, 1);
                 $avgsatisfaction = TicketSatisfaction::displaySatisfaction($avgsatisfaction);
             } else {
                 $avgsatisfaction = '&nbsp;';
             }
             echo Search::showItem($output_type, $avgsatisfaction, $item_num, $row_num);
             //Le temps moyen de prise en compte du ticket - The average time to take a ticket into account
             $data = self::constructEntryValues("inter_avgtakeaccount", $date1, $date2, $type, $value[$i]["id"], $value2);
             foreach ($data as $key2 => $val2) {
                 $data[$key2] *= $solved[$key2];
             }
             if ($nb_solved > 0) {
                 $timedisplay = array_sum($data) / $nb_solved;
             } else {
                 $timedisplay = 0;
             }
             if ($output_type == HTML_OUTPUT || $output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 $timedisplay = timestampToString($timedisplay, 0);
             }
             echo Search::showItem($output_type, $timedisplay, $item_num, $row_num);
             //Le temps moyen de resolution - The average time to resolv
             $data = self::constructEntryValues("inter_avgsolvedtime", $date1, $date2, $type, $value[$i]["id"], $value2);
             foreach ($data as $key2 => $val2) {
                 $data[$key2] = round($data[$key2] * $solved[$key2]);
             }
             if ($nb_solved > 0) {
                 $timedisplay = array_sum($data) / $nb_solved;
             } else {
                 $timedisplay = 0;
             }
             if ($output_type == HTML_OUTPUT || $output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 $timedisplay = timestampToString($timedisplay, 0);
             }
             echo Search::showItem($output_type, $timedisplay, $item_num, $row_num);
             //Le temps moyen de cloture - The average time to close
             $data = self::constructEntryValues("inter_avgclosedtime", $date1, $date2, $type, $value[$i]["id"], $value2);
             foreach ($data as $key2 => $val2) {
                 $data[$key2] = round($data[$key2] * $solved[$key2]);
             }
             if ($nb_closed > 0) {
                 $timedisplay = array_sum($data) / $nb_closed;
             } else {
                 $timedisplay = 0;
             }
             if ($output_type == HTML_OUTPUT || $output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 $timedisplay = timestampToString($timedisplay, 0);
             }
             echo Search::showItem($output_type, $timedisplay, $item_num, $row_num);
             //Le temps moyen de l'intervention reelle - The average actiontime to resolv
             $data = self::constructEntryValues("inter_avgactiontime", $date1, $date2, $type, $value[$i]["id"], $value2);
             foreach ($data as $key2 => $val2) {
                 if (isset($solved[$key2])) {
                     $data[$key2] *= $solved[$key2];
                 } else {
                     $data[$key2] *= 0;
                 }
             }
             $total_actiontime = array_sum($data);
             if ($nb_solved > 0) {
                 $timedisplay = $total_actiontime / $nb_solved;
             } else {
                 $timedisplay = 0;
             }
             if ($output_type == HTML_OUTPUT || $output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 $timedisplay = timestampToString($timedisplay, 0);
             }
             echo Search::showItem($output_type, $timedisplay, $item_num, $row_num);
             //Le temps total de l'intervention reelle - The total actiontime to resolv
             $timedisplay = $total_actiontime;
             if ($output_type == HTML_OUTPUT || $output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 $timedisplay = timestampToString($timedisplay, 0);
             }
             echo Search::showItem($output_type, $timedisplay, $item_num, $row_num);
             echo Search::showEndLine($output_type);
         }
         // Display footer
         echo Search::showFooter($output_type);
     } else {
         echo $LANG['stats'][23];
     }
     if ($output_type == HTML_OUTPUT) {
         // HTML display
         echo "</div>";
     }
 }
 /**
  * Display in HTML, delay between master and slave
  * 1 line per slave is multiple
  **/
 static function showAllReplicateDelay()
 {
     global $LANG;
     $DBSlave = self::getDBSlaveConf();
     if (is_array($DBSlave->dbhost)) {
         $hosts = $DBSlave->dbhost;
     } else {
         $hosts = array($DBslave->dbhost);
     }
     foreach ($hosts as $num => $name) {
         $diff = self::getReplicateDelay($num);
         echo $LANG['install'][30] . "&nbsp;: '{$name}', ";
         if ($diff > 1000000000) {
             echo $LANG['install'][35] . "<br>";
         } else {
             if ($diff) {
                 echo $LANG['setup'][803] . "&nbsp;: " . timestampToString($diff, 1) . "<br>";
             } else {
                 echo $LANG['setup'][803] . "&nbsp;: " . $LANG['common'][49] . "<br>";
             }
         }
     }
 }
 /**
  * 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;
 }
Beispiel #13
0
/**
 * To be conserved to migrations before 0.80
 * since 0.80, migration is a new class
**/
function displayMigrationMessage($id, $msg = "")
{
    global $LANG;
    static $created = 0;
    static $deb;
    if ($created != $id) {
        if (empty($msg)) {
            $msg = $LANG['rulesengine'][90];
        }
        echo "<div id='migration_message_{$id}'><p class='center'>{$msg}</p></div>";
        $created = $id;
        $deb = time();
    } else {
        if (empty($msg)) {
            $msg = $LANG['rulesengine'][91];
        }
        $fin = time();
        $tps = timestampToString($fin - $deb);
        echo "<script type='text/javascript'>document.getElementById('migration_message_{$id}').innerHTML =\n             '<p class=\"center\">{$msg} ({$tps})</p>';</script>\n";
    }
    glpi_flush();
}