function write($file, $text, $type, $ID_Device, $debug = 0)
 {
     global $CFG_GLPI;
     $config = new PluginFusioninventoryConfigSNMPScript();
     if ($config->getValue("logs") == '1' and $debug == '0') {
         error_log("[" . convDateTime(date("Y-m-d H:i:s")) . "][" . $type . "][" . $ID_Device . "] " . $text . "\n", 3, GLPI_LOG_DIR . "/" . $file . ".log");
     } else {
         if ($config->getValue("logs") == '2') {
             error_log("[" . convDateTime(date("Y-m-d H:i:s")) . "][" . $type . "][" . $ID_Device . "] " . $text . "\n", 3, GLPI_LOG_DIR . "/" . $file . ".log");
         }
     }
 }
 function getEntries($ID, $begin, $limit)
 {
     global $DB;
     $datas = array();
     $query = "SELECT *\n                FROM " . $this->table . "\n\t\t\t\t    WHERE `FK_printers` = '" . $ID . "'\n                LIMIT " . $begin . ", " . $limit . ";";
     if ($result = $DB->query($query)) {
         $i = 0;
         while ($data = $DB->fetch_assoc($result)) {
             $data['date'] = convDateTime($data['date']);
             $datas["{$i}"] = $data;
             $i++;
         }
         return $datas;
     }
     return false;
 }
 /**
  * Get all data needed for template processing
  **/
 function getDatasForTemplate($event, $options = array())
 {
     global $LANG;
     //User who tries to add or update an item in DB
     $action = $options['action_user'] ? $LANG['log'][20] : $LANG['log'][21];
     $this->datas['##unicity.action_type##'] = $action;
     $this->datas['##unicity.action_user##'] = $options['action_user'];
     $this->datas['##unicity.message##'] = $options['message'];
     $this->datas['##unicity.date##'] = convDateTime($options['date']);
     $item = new $options['itemtype']();
     $this->datas['##unicity.itemtype##'] = $item->getTypeName();
     $this->datas['##unicity.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
     if ($options['refuse']) {
         $this->datas['##unicity.action##'] = $LANG['setup'][821];
     } else {
         $this->datas['##unicity.action##'] = $LANG['setup'][823];
     }
     $this->getTags();
     foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
         if (!isset($this->datas[$tag])) {
             $this->datas[$tag] = $values['label'];
         }
     }
 }
 static function displayLastAlert($itemtype, $items_id)
 {
     global $DB, $LANG;
     if ($items_id) {
         $query = "SELECT `date`\n                   FROM `glpi_alerts`\n                   WHERE `itemtype` = '{$itemtype}'\n                         AND `items_id` = '{$items_id}'\n                   ORDER BY `date` DESC\n                   LIMIT 1";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             echo " " . $LANG['mailing'][52] . ' ' . convDateTime($DB->result($result, 0, 'date'));
         }
     }
 }
 /**
  * Print the contact form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - withtemplate : template or basic item
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!haveRight("budget", "r")) {
         return false;
     }
     $use_cache = true;
     $rowspan = 4;
     if ($ID > 0) {
         $rowspan++;
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;: </td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='{$rowspan}' class='middle right'>" . $LANG['common'][25] . "&nbsp;: </td>";
     echo "<td class='center middle' rowspan='{$rowspan}'><textarea cols='45' rows='4'\n             name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['financial'][21] . "&nbsp;:</td>";
     echo "<td><input type='text' name='value' size='14'\n             value='" . formatNumber($this->fields["value"], true) . "'></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['search'][8] . "&nbsp;: </td>";
     echo "<td>";
     showDateFormItem("begin_date", $this->fields["begin_date"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['search'][9] . "&nbsp;: </td>";
     echo "<td>";
     showDateFormItem("end_date", $this->fields["end_date"]);
     echo "</td></tr>";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][26] . "&nbsp;: </td>";
         echo "<td>";
         echo $this->fields["date_mod"] ? convDateTime($this->fields["date_mod"]) : $LANG['setup'][307];
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /** Show LDAP users to add or synchronise
  *
  * @return  nothing
  **/
 static function showLdapUsers()
 {
     global $CFG_GLPI, $LANG;
     $values['order'] = 'DESC';
     $values['start'] = 0;
     foreach ($_SESSION['ldap_import'] as $option => $value) {
         $values[$option] = $value;
     }
     $results = array();
     $limitexceeded = false;
     $ldap_users = self::getAllUsers($values, $results, $limitexceeded);
     if (is_array($ldap_users)) {
         $numrows = count($ldap_users);
         $action = "toprocess";
         $form_action = "process_ok";
         if ($numrows > 0) {
             if ($limitexceeded) {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th class='red'>";
                 echo "<img class='center' src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png'\n                      alt='warning'>&nbsp;" . $LANG['ldap'][8];
                 echo "</th></tr></table><br>";
             }
             printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
             // delete end
             array_splice($ldap_users, $values['start'] + $_SESSION['glpilist_limit']);
             // delete begin
             if ($values['start'] > 0) {
                 array_splice($ldap_users, 0, $values['start']);
             }
             echo "<form method='post' id='ldap_form' name='ldap_form' action='" . $_SERVER['PHP_SELF'] . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . (!$_SESSION['ldap_import']['mode'] ? $LANG['buttons'][37] : $LANG['ldap'][15]) . "</th>";
             $num = 0;
             echo Search::showHeaderItem(HTML_OUTPUT, $LANG['Menu'][14], $num, $_SERVER['PHP_SELF'] . "?order=" . ($values['order'] == "DESC" ? "ASC" : "DESC"));
             echo "<th>" . $LANG['common'][26] . " " . $LANG['ldap'][13] . "</th>";
             if ($_SESSION['ldap_import']['mode']) {
                 echo "<th>" . $LANG['common'][26] . " " . $LANG['ldap'][14] . "</th>";
             }
             echo "</tr>";
             foreach ($ldap_users as $userinfos) {
                 $link = $user = $userinfos["user"];
                 if (isset($userinfos['id']) && haveRight('user', 'r')) {
                     $link = "<a href='" . getItemTypeFormURL('User') . '?id=' . $userinfos['id'] . "'>{$user}</a>";
                 }
                 if (isset($userinfos["timestamp"])) {
                     $stamp = $userinfos["timestamp"];
                 } else {
                     $stamp = '';
                 }
                 if (isset($userinfos["date_sync"])) {
                     $date_sync = $userinfos["date_sync"];
                 } else {
                     $date_sync = '';
                 }
                 echo "<tr class='tab_bg_2 center'>";
                 //Need to use " instead of ' because it doesn't work with names with ' inside !
                 echo "<td><input type='checkbox' name=\"" . $action . "[" . $user . "]\"></td>";
                 echo "<td>" . $link . "</td>";
                 if ($stamp != '') {
                     echo "<td>" . convDateTime(date("Y-m-d H:i:s", $stamp)) . "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($_SESSION['ldap_import']['mode']) {
                     if ($date_sync != '') {
                         echo "<td>" . convDateTime($date_sync) . "</td>";
                     } else {
                         echo "<td>&nbsp;</td>";
                     }
                 }
                 echo "</tr>";
             }
             if ($_SESSION['ldap_import']['mode']) {
                 $colspan = 6;
             } else {
                 $colspan = 5;
             }
             echo "</table>";
             openArrowMassive("ldap_form", true);
             closeArrowMassive($form_action, $_SESSION['ldap_import']['mode'] ? $LANG['ldap'][15] : $LANG['buttons'][37]);
             echo "</form>";
             printPager($values['start'], $numrows, $_SERVER['PHP_SELF'], '');
         } else {
             echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? $LANG['ldap'][43] : $LANG['ldap'][3]) . "</div>";
         }
     } else {
         echo "<div class='center b'>" . ($_SESSION['ldap_import']['mode'] ? $LANG['ldap'][43] : $LANG['ldap'][3]) . "</div>";
     }
 }
 function showForm($input = '')
 {
     global $DB, $LANG, $CFG_GLPI, $INFOFORM_PAGES;
     $CommonItem = new CommonItem();
     $np = new Netport();
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo $LANG['plugin_fusioninventory']["processes"][1];
     echo " <a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php'>(" . $LANG['common'][66] . ")</a>";
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][27];
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][1];
     echo "</th>";
     echo "<th>";
     echo $LANG['joblist'][0];
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][1];
     echo "</th>";
     echo "</tr>";
     if (!isset($input['process_number'])) {
         $condition = '';
     } else {
         $condition = "WHERE `process_number`='" . $input['process_number'] . "'";
         if (isset($input['created'])) {
             $condition .= " AND `creation`='" . $input['created'] . "' ";
         }
     }
     $query = "SELECT * FROM `" . $this->table . "`\n         " . $condition . "\n         ORDER BY `date`DESC , `process_number` DESC";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             echo "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?h_process_number=" . $data['process_number'] . "'>" . $data['process_number'] . "</a>";
             echo "</td>";
             echo "<td>";
             echo convDateTime($data['date']);
             echo "</td>";
             echo "<td>";
             $np->getFromDB($data['FK_port_source']);
             $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]);
             $link1 = $CommonItem->getLink(1);
             $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">";
             if (rtrim($np->fields["name"]) != "") {
                 $link .= $np->fields["name"];
             } else {
                 $link .= $LANG['common'][0];
             }
             $link .= "</a>";
             echo $link . " " . $LANG['networking'][25] . " " . $link1;
             echo "</td>";
             echo "<td>";
             if ($data['creation'] == '1') {
                 echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_ok.png'/>";
             } else {
                 echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_notok.png'/>";
             }
             echo "</td>";
             echo "<td>";
             $np->getFromDB($data['FK_port_destination']);
             $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]);
             $link1 = $CommonItem->getLink(1);
             $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">";
             if (rtrim($np->fields["name"]) != "") {
                 $link .= $np->fields["name"];
             } else {
                 $link .= $LANG['common'][0];
             }
             $link .= "</a>";
             echo $link . " " . $LANG['networking'][25] . " " . $link1;
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
 }
 function computerState($target, $ID)
 {
     global $DB, $LANG;
     $np = new Netport();
     $pta = new PluginFusioninventoryAgents();
     echo "<br/>";
     echo "<div align='center'>";
     echo "<form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo $LANG['plugin_fusioninventory']["agents"][15];
     echo "</th>";
     echo "</tr>";
     $a_datas = $this->find("`device_id`='" . $ID . "'", "", "1");
     if (empty($a_datas)) {
         // Ajouter une entrée
         $this->fields['device_id'] = $ID;
         $this->fields['date_mod'] = date("Y-m-d H:i:s");
         $data['ID'] = $this->addToDB();
         $data['date_mod'] = $this->fields['date_mod'];
         $data['state'] = 0;
     } else {
         // Afficher l'état
         foreach ($a_datas as $device_id => $values) {
             $data = $a_datas[$device_id];
         }
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo convDateTime($data['date_mod']);
     echo " : </td>";
     echo "<td align='center'>";
     switch ($data['state']) {
         case 0:
             echo $LANG['plugin_fusioninventory']["agents"][16];
             break;
         case 1:
             echo $LANG['plugin_fusioninventory']["agents"][22];
             break;
         case 2:
             echo $LANG['plugin_fusioninventory']["agents"][17];
             break;
         case 3:
             echo $LANG['plugin_fusioninventory']["agents"][18];
             break;
         case 4:
             echo $LANG['plugin_fusioninventory']["agents"][19];
             break;
         case 5:
             echo $LANG['plugin_fusioninventory']["agents"][20];
             break;
         case 6:
             echo $LANG['plugin_fusioninventory']["agents"][21];
             break;
         default:
             break;
     }
     echo "</td>";
     echo "</tr>";
     $ip = "";
     if ($data['state'] == 0 or $data['state'] == 6) {
         $a_data = $np->find("`on_device`='" . $ID . "' AND `device_type`='1'");
         foreach ($a_data as $port_id => $port) {
             echo "<tr class='tab_bg_1'>";
             echo "<td align='center'>";
             if (!($fp = fsockopen($port['ifaddr'], 62354, $errno, $errstr, 1))) {
                 echo $port['ifaddr'] . " : </td><td align='center'><b>" . $LANG['plugin_fusioninventory']["task"][9] . "</b>";
             } else {
                 echo $port['ifaddr'] . " : </td><td align='center'><b>" . $LANG['plugin_fusioninventory']["task"][8] . "</b>";
                 $ip = $port['ifaddr'];
                 fclose($fp);
             }
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td align='center' colspan='2'>";
     $a_datasagent = $pta->find("`on_device`='" . $ID . "' AND `device_type`='1' ", "", "1");
     if (!empty($a_datasagent)) {
         foreach ($a_datasagent as $agent_id => $dataagent) {
             echo "<input type='hidden' name='agentID' value='" . $agent_id . "'/>";
         }
     }
     echo "<input type='hidden' name='ID' value='" . $ID . "'/>";
     echo "<input type='hidden' name='ip' value='" . $ip . "'/>";
     echo "<input type='submit' name='startagent' value=\"" . $LANG['plugin_fusioninventory']["task"][12] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</form>";
     echo "</div>";
     $glpiroot = GLPI_ROOT . "/plugins/fusioninventory/front/";
     if (strstr($_SERVER["PHP_SELF"], "fusioninventory")) {
         $glpiroot = '../plugins/fusioninventory/front/';
     }
     if ($data['state'] > 0 and $data['state'] < 6) {
         echo "<script type='text/javascript'>\nExt.getCmp('fusioninventory_1').getUpdater().startAutoRefresh(3,'" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.state.php?ID=" . $ID . "');\n      \n      </script>";
     } else {
         echo "<script type='text/javascript'>\nExt.getCmp('fusioninventory_1').getUpdater().stopAutoRefresh();\n\n      </script>";
     }
 }
 /**
  * Print a nice tab for last event
  *
  * Print a great tab to present lasts events occured on glpi
  *
  * @param $target where to go when complete
  * @param $order order by clause occurences (eg: )
  * @param $sort order by clause occurences (eg: date)
  * @param $start
  **/
 static function showList($target, $order = 'DESC', $sort = 'date', $start = 0)
 {
     global $DB, $CFG_GLPI, $LANG;
     // Show events from $result in table form
     list($logItemtype, $logService) = self::logArray();
     // Columns of the Table
     $items = array("items_id" => array($LANG['event'][0], "colspan='2'"), "date" => array($LANG['common'][27], ""), "service" => array($LANG['event'][2], "width='8%'"), "level" => array($LANG['event'][3], "width='8%'"), "message" => array($LANG['event'][4], "width='50%'"));
     // define default sorting
     if (!isset($items[$sort])) {
         $sort = "date";
     }
     if ($order != "ASC") {
         $order = "DESC";
     }
     // Query Database
     $query_limit = "SELECT *\n                      FROM `glpi_events`\n                      ORDER BY `{$sort}` {$order}\n                      LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     // Number of results
     $numrows = countElementsInTable("glpi_events");
     // Get results
     $result = $DB->query($query_limit);
     $number = $DB->numrows($result);
     // No Events in database
     if ($number < 1) {
         echo "<div class='center b'>" . $LANG['central'][4] . "</div>";
         return;
     }
     // Output events
     $i = 0;
     echo "<div class='center'>";
     $parameters = "sort={$sort}&amp;order={$order}";
     printPager($start, $numrows, $target, $parameters);
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     foreach ($items as $field => $args) {
         echo "<th " . $args[1] . ">";
         if ($sort == $field) {
             if ($order == "DESC") {
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png\" alt='' title=''>";
             } else {
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png\" alt='' title=''>";
             }
         }
         echo "<a href='{$target}?sort={$field}&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "'>" . $args[0] . "</a></th>";
     }
     echo "</tr>";
     while ($i < $number) {
         $ID = $DB->result($result, $i, "id");
         $items_id = $DB->result($result, $i, "items_id");
         $type = $DB->result($result, $i, "type");
         $date = $DB->result($result, $i, "date");
         $service = $DB->result($result, $i, "service");
         $level = $DB->result($result, $i, "level");
         $message = $DB->result($result, $i, "message");
         $itemtype = "&nbsp;";
         if (isset($logItemtype[$type])) {
             $itemtype = $logItemtype[$type];
         } else {
             $type = getSingular($type);
             if (class_exists($type)) {
                 $item = new $type();
                 $itemtype = $item->getTypeName();
             }
         }
         echo "<tr class='tab_bg_2'>";
         echo "<td>{$itemtype} :</td>";
         echo "<td class='center b'>";
         self::displayItemLogID($type, $items_id);
         echo "</td><td>" . convDateTime($date) . "</td>";
         echo "<td class='center'>" . (isset($logService[$service]) ? $logService[$service] : $service);
         echo "</td><td class='center'>{$level}</td><td>{$message}</td></tr>";
         $i++;
     }
     echo "</table></div><br>";
 }
Exemple #10
0
arsort($files);
if (count($files)) {
    foreach ($files as $file => $date) {
        $taille_fic = filesize($path . "/" . $file) / 1024;
        $taille_fic = (int) $taille_fic;
        echo "<tr class='tab_bg_2'><td>{$file}&nbsp;</td>" . "<td class='right'>&nbsp;" . $taille_fic . " kB &nbsp;</td>" . "<td>&nbsp;" . convDateTime(date("Y-m-d H:i", $date)) . "</td>" . "<td>&nbsp;" . "<a href=\"javascript:confirmAction('" . addslashes($file . " - " . $LANG['backup'][17]) . "',\n                                               'backup.php?delfile={$file}')\">" . $LANG['buttons'][6] . "</a>&nbsp;</td>" . "<td>&nbsp;" . "<a href=\"javascript:confirmAction('" . addslashes($file . " - " . $LANG['backup'][16]) . "',\n                                               'backup.php?file={$file}&amp;donotcheckversion=1')\">" . $LANG['buttons'][21] . "</a>&nbsp;</td>" . "<td>&nbsp;<a href=\"document.send.php?file=_dumps/{$file}\">" . $LANG['backup'][13] . "</a>" . "</td></tr>";
    }
}
closedir($dir);
$dir = opendir($path);
unset($files);
$files = array();
while ($file = readdir($dir)) {
    if ($file != "." && $file != ".." && preg_match("/\\.xml\$/i", $file)) {
        $files[$file] = filemtime($path . "/" . $file);
    }
}
arsort($files);
if (count($files)) {
    foreach ($files as $file => $date) {
        $taille_fic = filesize($path . "/" . $file) / 1024;
        $taille_fic = (int) $taille_fic;
        echo "<tr class='tab_bg_1'><td colspan='6'><hr noshade></td></tr>" . "<tr class='tab_bg_2'><td>{$file}&nbsp;</td>" . "<td class='right'>&nbsp;" . $taille_fic . " kB &nbsp;</td>" . "<td>&nbsp;" . convDateTime(date("Y-m-d H:i", $date)) . "</td>" . "<td>&nbsp;" . "<a href=\"javascript:confirmAction('" . addslashes($file . " - " . $LANG['backup'][17]) . "',\n                                                 'backup.php?delfile={$file}')\">" . $LANG['buttons'][6] . "</a>&nbsp;</td>" . "<td>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;</td>" . "<td>&nbsp;<a href=\"document.send.php?file=_dumps/{$file}\">" . $LANG['backup'][13] . "</a>" . "</td></tr>";
    }
}
closedir($dir);
?>
</table>
</div>
<?php 
commonFooter();
 static function showShortForTicket($ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     // Print Followups for a job
     $showprivate = haveRight("show_full_ticket", "1");
     $RESTRICT = "";
     if (!$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                           OR `users_id` ='" . getLoginUserID() . "') ";
     }
     // Get Number of Followups
     $query = "SELECT *\n               FROM `glpi_ticketfollowups`\n               WHERE `tickets_id` = '{$ID}'\n                     {$RESTRICT}\n               ORDER BY `date` DESC";
     $result = $DB->query($query);
     $out = "";
     if ($DB->numrows($result) > 0) {
         $out .= "<div class='center'><table class='tab_cadre' width='100%'>\n\n                  <tr><th>" . $LANG['common'][27] . "</th><th>" . $LANG['job'][4] . "</th>\n                  <th>" . $LANG['joblist'][6] . "</th></tr>\n";
         while ($data = $DB->fetch_array($result)) {
             $out .= "<tr class='tab_bg_3'>\n                     <td class='center'>" . convDateTime($data["date"]) . "</td>\n                     <td class='center'>" . getUserName($data["users_id"], 1) . "</td>\n                     <td width='70%' class='b'>" . resume_text($data["content"], $CFG_GLPI["cut"]) . "\n                     </td></tr>";
         }
         $out .= "</table></div>";
     }
     return $out;
 }
 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>";
 }
 /**
  * Print the document form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     if (!haveRight("document", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $options['formoptions'] = " enctype='multipart/form-data'";
     $this->showFormHeader($options);
     if ($ID > 0) {
         echo "<tr><th colspan='2'>";
         if ($this->fields["users_id"] > 0) {
             echo $LANG['document'][42] . " " . getUserName($this->fields["users_id"], 1);
         } else {
             echo "&nbsp;";
         }
         echo "</th>";
         echo "<th colspan='2'>" . $LANG['common'][26] . "&nbsp;: " . convDateTime($this->fields["date_mod"]) . "</th>";
         echo "</tr>\n";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='6' class='middle right'>" . $LANG['common'][25] . "&nbsp;: </td>";
     echo "<td class='center middle' rowspan='6'>";
     echo "<textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['document'][22] . "&nbsp;:</td>";
         echo "<td>" . $this->getDownloadLink('', 45);
         echo "<input type='hidden' name='current_filepath' value='" . $this->fields["filepath"] . "'>";
         echo "<input type='hidden' name='current_filename' value='" . $this->fields["filename"] . "'>";
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['document'][2] . " (" . self::getMaxUploadSize() . ")&nbsp;:</td>";
     echo "<td><input type='file' name='filename' value='" . $this->fields["filename"] . "' size='39'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['document'][36] . "&nbsp;:</td>";
     echo "<td>";
     $this->showUploadedFilesDropdown("upload_file");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['document'][33] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "link");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['document'][3] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('DocumentCategory', array('value' => $this->fields["documentcategories_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['document'][4] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "mime");
     if ($ID > 0) {
         echo "</td><td>" . $LANG['document'][1] . "&nbsp;:</td>";
         echo "<td>" . $this->fields["sha1sum"];
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 function getEntries($type, $ID, $begin, $limit)
 {
     global $DB;
     $datas = array();
     $query = "SELECT *\n                FROM " . $this->table . " ";
     if ($type == COMPUTER_TYPE) {
         $query .= "WHERE `device_type` = '" . COMPUTER_TYPE . "' ";
     } else {
         if ($type == NETWORKING_TYPE) {
             $query .= "WHERE `device_type` = '" . NETWORKING_TYPE . "' ";
         } else {
             // $type == PRINTER_TYPE
             $query .= "WHERE `device_type` = '" . PRINTER_TYPE . "' ";
         }
     }
     $query .= "AND `device_id` = '" . $ID . "' " . "LIMIT " . $begin . ", " . $limit . ";";
     if ($result = $DB->query($query)) {
         $i = 0;
         while ($data = $DB->fetch_assoc($result)) {
             $data['first_pb_date'] = convDateTime($data['first_pb_date']);
             $data['last_pb_date'] = convDateTime($data['last_pb_date']);
             $datas["{$i}"] = $data;
             $i++;
         }
         return $datas;
     }
     return false;
 }
 /**
  * Print the computer form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  *
  **/
 function showForm($ID, $options = array())
 {
     global $LANG, $CFG_GLPI, $DB;
     if (!haveRight("computer", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . " : ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . " : ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . ": ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['state'][0] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][17] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('ComputerType', array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;: </td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][5] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][21] . "&nbsp;: </td>";
     echo "<td >";
     autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . $LANG['common'][22] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('ComputerModel', array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][18] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][34] . "&nbsp;: </td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][88] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Network', array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][89] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('Domain', array('value' => $this->fields["domains_id"]));
     echo "</td>";
     echo "<td rowspan='8'>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td rowspan='8' class='middle'>";
     echo "<textarea cols='45' rows='11' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][9] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('OperatingSystem', array('value' => $this->fields["operatingsystems_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][53] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('OperatingSystemServicePack', array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][52] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('OperatingSystemVersion', array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][11] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][10] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'os_license_number');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][58] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'uuid');
     echo "</td></tr>\n";
     // Get OCS Datas :
     $dataocs = array();
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r")) {
         $query = "SELECT *\n                   FROM `glpi_ocslinks`\n                   WHERE `computers_id` = '{$ID}'";
         $result = $DB->query($query);
         if ($DB->numrows($result) == 1) {
             $dataocs = $DB->fetch_array($result);
         }
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>" . $datestring . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && count($dataocs)) {
         echo "<br>";
         echo $LANG['ocsng'][14] . "&nbsp;: " . convDateTime($dataocs["last_ocs_update"]);
         echo "<br>";
         echo $LANG['ocsng'][13] . "&nbsp;: " . convDateTime($dataocs["last_update"]);
         echo "<br>";
         if (haveRight("ocsng", "r")) {
             echo $LANG['common'][52] . " <a href='" . $CFG_GLPI["root_doc"] . "/front/ocsserver.form.php?id=" . OcsServer::getByMachineID($ID) . "'>" . OcsServer::getServerNameByID($ID) . "</a>";
             $query = "SELECT `ocs_agent_version`, `ocsid`\n                      FROM `glpi_ocslinks`\n                      WHERE `computers_id` = '{$ID}'";
             $result_agent_version = $DB->query($query);
             $data_version = $DB->fetch_array($result_agent_version);
             $ocs_config = OcsServer::getConfig(OcsServer::getByMachineID($ID));
             //If have write right on OCS and ocsreports url is not empty in OCS config
             if (haveRight("ocsng", "w") && $ocs_config["ocs_url"] != '') {
                 echo ", " . OcsServer::getComputerLinkToOcsConsole(OcsServer::getByMachineID($ID), $data_version["ocsid"], $LANG['ocsng'][57]);
             }
             if ($data_version["ocs_agent_version"] != NULL) {
                 echo " , " . $LANG['ocsng'][49] . "&nbsp;: " . $data_version["ocs_agent_version"];
             }
         } else {
             echo $LANG['common'][52] . " " . OcsServer::getServerNameByID($ID);
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && haveRight("sync_ocsng", "w") && count($dataocs)) {
         echo "<td >" . $LANG['ocsng'][6] . " " . $LANG['Menu'][33] . "&nbsp;:</td>";
         echo "<td >";
         Dropdown::showYesNo("_auto_update_ocs", $dataocs["use_auto_update"]);
         echo "</td>";
     } else {
         echo "<td colspan=2></td>";
     }
     echo "<td>" . $LANG['computers'][51] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('AutoUpdateSystem', array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Exemple #16
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;
 }
 /**
  * Print the Software / license form
  *
  * @param $ID Integer : Id of the version or the template to print
  * @param $options array
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if (!haveRight("software", "w")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['help'][31] . "&nbsp;:</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
     } else {
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
     }
     echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     echo "</td>";
     echo "<td>" . $LANG['common'][17] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('SoftwareLicenseType', array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['software'][1] . "&nbsp;:</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][20] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "otherserial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['software'][2] . "&nbsp;:</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td>";
     echo "<td rowspan='" . ($ID > 0 ? '4' : '3') . "' class='middle'>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td class='center middle' rowspan='" . ($ID > 0 ? '4' : '3') . "'>";
     echo "<textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['tracking'][29] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showInteger("number", $this->fields["number"], 1, 1000, 1, array(-1 => $LANG['software'][4]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['software'][32] . "&nbsp;:</td>";
     echo "<td>";
     showDateFormItem('expire', $this->fields["expire"]);
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td></tr>\n";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][26] . "&nbsp;: </td>";
         echo "<td>" . ($this->fields["date_mod"] ? convDateTime($this->fields["date_mod"]) : $LANG['setup'][307]);
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /**
  * Print the group form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $LANG;
     if (!haveRight("group", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='3' class='middle right'>" . $LANG['common'][25] . "&nbsp;:&nbsp;</td>";
     echo "<td class='center middle' rowspan='3'>";
     echo "<textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][64] . "&nbsp;:&nbsp;</td>";
     echo "<td>";
     // Manager must be in the same entity
     User::dropdown(array('value' => $this->fields["users_id"], 'right' => 'all', 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     if (!$ID) {
         $template = "newtemplate";
         echo "<td>" . $LANG['computers'][14] . "&nbsp;:&nbsp;</td>";
         echo "<td>";
         echo convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         echo "<td>" . $LANG['common'][26] . "&nbsp;:&nbsp;</td>";
         echo "<td>";
         echo convDateTime($this->fields["date_mod"]);
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 function showForm($target, $ID = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     PluginFusioninventoryAuth::checkRight("snmp_networking", "r");
     $CommonItem = new CommonItem();
     if ($ID != '') {
         $this->getFromDB($ID);
     } else {
         $this->getEmpty();
     }
     echo "<div align='center'><form method='post' name='' id=''  action=\"" . $target . "\">";
     echo "<table  class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>";
     echo $LANG['plugin_fusioninventory']["menu"][4] . " ( " . $LANG['plugin_fusioninventory']["unknown"][3] . " ";
     $CommonItem->getFromDB(PLUGIN_FUSIONINVENTORY_SNMP_AGENTS, $this->fields["FK_agent"]);
     echo $CommonItem->getLink(1);
     echo ") :</th></tr>";
     $datestring = $LANG["common"][26] . ": ";
     $date = convDateTime($this->fields["date_mod"]);
     echo "<tr>";
     echo "<th align='center' width='450' colspan='2'>";
     echo $LANG["common"][2] . " " . $this->fields["ID"];
     echo "</th>";
     echo "<th align='center' colspan='2' width='50'>";
     echo $datestring . $date;
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG["common"][16] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='35'/>";
     echo "</td>";
     if (isMultiEntitiesMode()) {
         echo "<td align='center'>" . $LANG['entity'][0] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("Entity", array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"]));
         echo "</td>";
         echo "</tr>";
         echo "</tr>";
     } else {
         echo "<td align='center'></td>";
         echo "</td>";
         echo "<td align='center'></td>";
         echo "</tr>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][0] . " :</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='dnsname' value='" . $this->fields["dnsname"] . "' size='35'/>";
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][18] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='contact' value='" . $this->fields["contact"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][17] . " :</td>";
     echo "<td align='center'>";
     $type_list[] = COMPUTER_TYPE;
     $type_list[] = NETWORKING_TYPE;
     $type_list[] = PRINTER_TYPE;
     $type_list[] = PERIPHERAL_TYPE;
     $type_list[] = PHONE_TYPE;
     // GENERIC OBJECT : Search types in generic object
     $plugin = new Plugin();
     if ($plugin->isActivated('genericobject')) {
         if (TableExists("glpi_plugin_genericobject_types")) {
             $query = "SELECT * FROM `glpi_plugin_genericobject_types`\n                  WHERE `status`='1' ";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_array($result)) {
                     $type_list[] = $data['device_type'];
                 }
             }
         }
     }
     // END GENERIC OBJECT
     Device::dropdownTypes('type', $this->fields["type"], $type_list);
     echo "</td>";
     echo "<td align='center'>" . $LANG['setup'][89] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     Dropdown::show("Domain", array('name' => "domain", 'value' => $this->fields["domain"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['common'][15] . " :</td>";
     echo "<td align='center'>";
     Dropdown::show("Location", array('name' => "location", 'value' => $this->fields["location"]));
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][19] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='serial' value='" . $this->fields["serial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][2] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("accepted", $this->fields["accepted"]);
     echo "</td>";
     echo "<td align='center'>" . $LANG['common'][20] . " : </td>";
     echo "</td>";
     echo "<td align='center'>";
     echo "<input type='text' name='otherserial' value='" . $this->fields["otherserial"] . "' size='35'/>";
     echo "</td>";
     echo "</tr>";
     if (!empty($this->fields["ifaddr"]) or !empty($this->fields["ifmac"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['networking'][14] . " :</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifaddr"] . "' size='35'/>";
         echo "</td>";
         echo "<td align='center'>" . $LANG['networking'][15] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         echo "<input type='text' name='otherserial' value='" . $this->fields["ifmac"] . "' size='35'/>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][3] . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("snmp", $this->fields["snmp"]);
     echo "</td>";
     if ($this->fields["snmp"] == "1") {
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][4] . " : </td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "FK_model_infos", 'value' => $this->fields["FK_model_infos"]));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][3] . " :</td>";
         echo "<td align='center'>";
         Dropdown::show("PluginFusioninventorySnmpauth", array('name' => "FK_snmp_connection", 'value' => $this->fields["FK_snmp_connection"]));
         echo "</td>";
     }
     echo "<td align='center'>" . $LANG['common'][25] . " : </td>";
     echo "</td>";
     echo "<td align='middle'>";
     echo "<textarea  cols='50' rows='5' name='comments' >" . $this->fields["comments"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][4] . " :</td>";
     echo "<td align='center'>";
     echo Dropdown::getYesNo($this->fields["hub"]);
     echo "</td>";
     echo "<td align='center' colspan='2'></td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td class='tab_bg_2' align='center' colspan='4'>\n";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='import' value=\"" . $LANG['buttons'][37] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>";
     echo "</td>";
     echo "<td width='33%' align='center'>";
     echo "<input type='hidden' name='ID' value={$ID}>";
     echo "<div class='center'>";
     if (PluginFusioninventory::haveRight("unknowndevices", "w")) {
         if (!$this->fields["deleted"]) {
             echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\" class='submit'>";
         } else {
             echo "<input type='submit' name='restore' value=\"" . $LANG['buttons'][21] . "\" class='submit'>";
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>";
         }
     }
     echo "</div>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "</table></form></div>";
 }
 function generateConfig($weathermaps_id)
 {
     global $DB, $CFG_GLPI;
     if ($weathermaps_id < 1) {
         return;
     }
     $conf = "\n";
     $pmWeathermapnode = new PluginMonitoringWeathermapnode();
     $pmComponent = new PluginMonitoringComponent();
     $pmService = new PluginMonitoringService();
     $this->getFromDB($weathermaps_id);
     if ($this->fields['background'] != '') {
         $conf .= "BACKGROUND " . GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermapbg/" . $this->fields['background'] . "\n";
         //$conf .= "BACKGROUND http://192.168.20.194".$CFG_GLPI['root_doc']."/plugins/monitoring/front/send.php?file=weathermapbg/".$this->fields['background']."\n";
     }
     // image file to generate
     $conf .= "IMAGEOUTPUTFILE " . GLPI_PLUGIN_DOC_DIR . "/monitoring/weathermap-" . $weathermaps_id . ".png\n";
     $conf .= "\n";
     $conf .= "WIDTH " . $this->fields["width"] . "\nHEIGHT " . $this->fields["height"] . "\nHTMLSTYLE overlib\nTITLE " . $this->fields["name"] . "\nTIMEPOS 10 20 Cree le : " . convDateTime(date("Y-m-d H:i:s")) . "\n\nKEYPOS DEFAULT 10 " . ($this->fields["height"] - $this->fields["width"] / 16) . "\nKEYSTYLE  DEFAULT horizontal " . $this->fields["width"] / 4 . "\nKEYTEXTCOLOR 0 0 0\nKEYOUTLINECOLOR 0 0 0\nKEYBGCOLOR 255 255 255\nBGCOLOR 255 255 255\nTITLECOLOR 0 0 0\nTIMECOLOR 0 0 0\nSCALE DEFAULT 0.0001 0.1   255 255 255   255 255 255  \nSCALE DEFAULT 0.1 50   0 255 0   255 215 0  \nSCALE DEFAULT 50 100   255 215 0   255 0 0  \n\nSET key_hidezero_DEFAULT 1\n\n# End of global section\n\n# TEMPLATE-only NODEs:\nNODE DEFAULT\n\tMAXVALUE 100\n\n# TEMPLATE-only LINKs:\nLINK DEFAULT\n\tWIDTH 4\n\tBANDWIDTH 100M\n\n# regular NODEs:\n";
     $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n         WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n         ORDER BY `name`";
     $result = $DB->query($query);
     $link = '';
     while ($data = $DB->fetch_array($result)) {
         $name = $data['name'];
         if ($name == '') {
             $itemtype = $data['itemtype'];
             $item = new $itemtype();
             $item->getFromDB($data['items_id']);
             $name = $item->getName();
             $link = $item->getLinkURL();
         }
         $conf .= "NODE " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . "\n" . "   LABEL " . $name . "\n" . "   POSITION " . $data['x'] . " " . $data['y'] . "\n";
         if ($link != '') {
             $conf .= "   INFOURL " . $link . "\n";
         }
         $conf .= "\n";
     }
     $conf .= "\n\n# regular LINKs:\n";
     $bwlabelpos = array();
     $bwlabelpos[0] = "BWLABELPOS 81 39";
     $bwlabelpos[1] = "BWLABELPOS 71 29";
     $i = 0;
     $doublelink = array();
     $doublelinkbegin = array();
     $doublelinkdiff = array();
     $doublelinknumber = array();
     $query = "SELECT `" . getTableForItemType("PluginMonitoringWeathermaplink") . "`.*, \n            count(`" . getTableForItemType("PluginMonitoringWeathermaplink") . "`.`id`) as `cnt` \n            FROM `" . getTableForItemType("PluginMonitoringWeathermaplink") . "` \n         LEFT JOIN `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n            ON `plugin_monitoring_weathermapnodes_id_1` = `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`.`id`\n\n         WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n         group by `plugin_monitoring_weathermapnodes_id_1`, `plugin_monitoring_weathermapnodes_id_2`\n         HAVING cnt >1";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $tlink = $data['plugin_monitoring_weathermapnodes_id_1'] . "-" . $data['plugin_monitoring_weathermapnodes_id_2'];
         $doublelink[$tlink] = $data['cnt'];
         $doublelinknumber[$tlink] = 0;
         $beg = 0;
         $diff = 0;
         switch ($data['cnt']) {
             case 2:
                 $beg = -22;
                 $diff = 44;
                 break;
             case 3:
                 $beg = -33;
                 $diff = 33;
                 break;
             case 4:
                 $beg = -39;
                 $diff = 26;
                 break;
             case 5:
                 $beg = -60;
                 $diff = 30;
                 break;
         }
         $doublelinkbegin[$tlink] = $beg;
         $doublelinkdiff[$tlink] = $diff;
     }
     $query = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermapnode") . "`\n         WHERE `plugin_monitoring_weathermaps_id`='" . $weathermaps_id . "'\n         ORDER BY `name`";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $queryl = "SELECT * FROM `" . getTableForItemType("PluginMonitoringWeathermaplink") . "`\n            WHERE `plugin_monitoring_weathermapnodes_id_1`='" . $data['id'] . "'";
         $resultl = $DB->query($queryl);
         while ($datal = $DB->fetch_array($resultl)) {
             $bandwidth = $datal['bandwidth_in'] . " " . $datal['bandwidth_out'];
             if ($datal['bandwidth_in'] == $datal['bandwidth_out']) {
                 $bandwidth = $datal['bandwidth_in'];
             }
             $pmWeathermapnode->getFromDB($datal['plugin_monitoring_weathermapnodes_id_2']);
             $queryevent = "SELECT * FROM `glpi_plugin_monitoring_serviceevents`\n               WHERE `plugin_monitoring_services_id`='" . $datal['plugin_monitoring_services_id'] . "'\n                  ORDER BY `id` DESC\n                  LIMIT 1";
             $resultevent = $DB->query($queryevent);
             $in = '';
             $out = '';
             while ($dataevent = $DB->fetch_array($resultevent)) {
                 $pmService->getFromDB($datal['plugin_monitoring_services_id']);
                 $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']);
                 $matches1 = array();
                 preg_match("/" . $pmComponent->fields['weathermap_regex_in'] . "/m", $dataevent['perf_data'], $matches1);
                 if (isset($matches1[1])) {
                     $in = $matches1[1];
                 }
                 $matches1 = array();
                 preg_match("/" . $pmComponent->fields['weathermap_regex_out'] . "/m", $dataevent['perf_data'], $matches1);
                 if (isset($matches1[1])) {
                     $out = $matches1[1];
                 }
             }
             $in = $this->checkBandwidth("in", $in, $bandwidth);
             $out = $this->checkBandwidth("out", $out, $bandwidth);
             $nodesuffix = '';
             $tlink = $datal['plugin_monitoring_weathermapnodes_id_1'] . "-" . $datal['plugin_monitoring_weathermapnodes_id_2'];
             if (isset($doublelink[$tlink])) {
                 $nodesuffix = ":" . ($doublelinkbegin[$tlink] + $doublelinknumber[$tlink] * $doublelinkdiff[$tlink]) . ":0";
                 $doublelinknumber[$tlink]++;
             }
             $conf .= "LINK " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . "-" . preg_replace("/[^A-Za-z0-9_]/", "", $pmWeathermapnode->fields['name']) . "_" . $pmWeathermapnode->fields['id'] . $nodesuffix . "\n";
             $timezone = '0';
             if (isset($_SESSION['plugin_monitoring_timezone'])) {
                 $timezone = $_SESSION['plugin_monitoring_timezone'];
             }
             $timezone_file = str_replace("+", ".", $timezone);
             //            if (file_exists(GLPI_ROOT."/files/_plugins/monitoring/PluginMonitoringService-".$datal['plugin_monitoring_services_id']."-2h".$timezone_file.".gif")) {
             $conf .= "   INFOURL " . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $datal['plugin_monitoring_services_id'] . "\n" . "   OVERLIBGRAPH " . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/send.php?file=PluginMonitoringService-" . $datal['plugin_monitoring_services_id'] . "-2h" . $timezone_file . ".png\n";
             //            }
             $conf .= "   " . $bwlabelpos[$i] . "\n";
             $conf .= "   TARGET static:" . $in . ":" . $out . "\n";
             $conf .= "   NODES " . preg_replace("/[^A-Za-z0-9_]/", "", $data['name']) . "_" . $data['id'] . $nodesuffix . " " . preg_replace("/[^A-Za-z0-9_]/", "", $pmWeathermapnode->fields['name']) . "_" . $pmWeathermapnode->fields['id'] . $nodesuffix . "\n";
             $conf .= "   BANDWIDTH " . $bandwidth . "\n\n";
             $i++;
             if ($i == '2') {
                 $i = 0;
             }
         }
     }
     return $conf;
 }
 /**
  * Print the mailgate form
  *
  * @param $ID Integer : Id of the item to print
  * @param $options array
  *     - target filename : where to go when done.
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     if (!haveRight("config", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $options['colspan'] = 1;
     $this->showTabs($options);
     $this->showFormHeader($options);
     if (!function_exists('mb_list_encodings') || !function_exists('mb_convert_encoding')) {
         echo "<tr class='tab_bg_1'><td colspan='2'>" . $LANG['mailgate'][4] . "</td></tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . " (" . $LANG['mailing'][111] . ")&nbsp;:</td><td>";
     autocompletionTextField($this, "name");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][60] . "&nbsp;:</td><td>";
     Dropdown::showYesNo("is_active", $this->fields["is_active"]);
     echo "</td></tr>";
     showMailServerConfig($this->fields["host"]);
     echo "<tr class='tab_bg_1'><td>" . $LANG['login'][6] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "login");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['login'][7] . "&nbsp;:</td>";
     echo "<td><input type='password' name='passwd' value='' size='20' autocomplete='off'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td width='200px'> " . $LANG['mailgate'][7] . "&nbsp;:</td><td>";
     self::showMaxFilesize('filesize_max', $this->fields["filesize_max"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td><textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     if ($ID > 0) {
         echo "<br>" . $LANG['common'][26] . "&nbsp;: " . convDateTime($this->fields["date_mod"]);
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /**
  * Print the phone form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     $target = $this->getFormURL();
     $withtemplate = '';
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (isset($options['withtemplate'])) {
         $withtemplate = $options['withtemplate'];
     }
     if (!haveRight("phone", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . "&nbsp;: ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . "&nbsp;: ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . "&nbsp;: ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['state'][0] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][17] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhoneType', array('value' => $this->fields["phonetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;:</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][5] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][21] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . $LANG['common'][22] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhoneModel', array('value' => $this->fields["phonemodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][18] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][34] . "&nbsp;:</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['peripherals'][33] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["phones_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['peripherals'][18] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "brand");
     echo "</td>";
     echo "<td rowspan='6'>";
     echo $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td rowspan='6'>\n            <textarea cols='45' rows='9' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['phones'][36] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhonePowerSupply', array('value' => $this->fields["phonepowersupplies_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][71] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "firmware");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['phones'][40] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "number_line");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['monitors'][18] . "&nbsp;:</td>";
     echo "<td>";
     // micro?
     echo "\n<table><tr><td>" . $LANG['phones'][38] . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_headset", $this->fields["have_headset"]);
     echo "</td></tr>";
     // hp?
     echo "<tr><td>" . $LANG['phones'][39] . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_hp", $this->fields["have_hp"]);
     echo "</td></tr></table>\n";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center' height='30'>" . $datestring . "&nbsp;" . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         echo "(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /**
  * Print the validation list into ticket
  *
  * @param $ticket class
  **/
 function showSummary($ticket)
 {
     global $DB, $LANG, $CFG_GLPI;
     if (!haveRight('validate_ticket', 1) && !haveRight('create_validation', 1)) {
         return false;
     }
     $tID = $ticket->fields['id'];
     //$canadd = haveRight("create_validation", "1");
     $tmp = array('tickets_id' => $tID);
     $canadd = $this->can(-1, 'w', $tmp);
     $rand = mt_rand();
     echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddValidation" . $tID . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'tickets_id' => $tID, 'id' => -1);
         ajaxUpdateItemJsCode("viewfollowup" . $tID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewfollowup.php", $params, false);
         echo "};";
         echo "</script>\n";
         if ($ticket->fields["status"] != 'solved' && $ticket->fields["status"] != 'closed') {
             echo "<div class='center'><a href='javascript:viewAddValidation" . $tID . "{$rand}();'>";
             echo $LANG['validation'][1] . "</a></div><br>\n";
         }
     }
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `tickets_id` = '" . $ticket->getField('id') . "'";
     if (!$canadd) {
         $query .= " AND `users_id_validate` = '" . getLoginUserID() . "' ";
     }
     $query .= " ORDER BY submission_date DESC";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($number) {
         $colonnes = array($LANG['validation'][2], $LANG['validation'][3], $LANG['validation'][18], $LANG['validation'][5], $LANG['validation'][4], $LANG['validation'][21], $LANG['validation'][6]);
         $nb_colonnes = count($colonnes);
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th colspan='" . $nb_colonnes . "'>" . $LANG['validation'][7] . "</th></tr>";
         echo "<tr>";
         foreach ($colonnes as $colonne) {
             echo "<th>" . $colonne . "</th>";
         }
         echo "</tr>";
         initNavigateListItems('TicketValidation', $LANG['validation'][26] . " = " . $ticket->fields['name']);
         while ($row = $DB->fetch_assoc($result)) {
             $canedit = $this->can($row["id"], 'w');
             addToNavigateListItems('TicketValidation', $row["id"]);
             $bgcolor = $this->getStatusColor($row['status']);
             $status = $this->getStatus($row['status']);
             echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditValidation" . $ticket->fields['id'] . $row["id"] . "{$rand}();\"" : '') . " id='viewfollowup" . $this->fields['tickets_id'] . $row["id"] . "{$rand}'>";
             echo "<td>";
             if ($canedit) {
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditValidation" . $ticket->fields['id'] . $row["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'tickets_id' => $this->fields["tickets_id"], 'id' => $row["id"]);
                 ajaxUpdateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewfollowup.php", $params, false);
                 echo "};";
                 echo "</script>\n";
             }
             echo "<div style='background-color:" . $bgcolor . ";'>" . $status . "</div></td>";
             if ($ticket->can($ticket->fields['id'], 'r') && !strstr($ticket->fields["status"], "solved") && !strstr($ticket->fields["status"], "closed")) {
                 $link_validation = getItemTypeFormURL('TicketValidation');
                 echo "<td>" . convDateTime($row["submission_date"]) . "</td>";
             } else {
                 echo "<td>" . convDateTime($row["submission_date"]) . "</a></td>";
             }
             echo "<td>" . getUserName($row["users_id"]) . "</td>";
             echo "<td>" . $row["comment_submission"] . "</td>";
             echo "<td>" . convDateTime($row["validation_date"]) . "</td>";
             echo "<td>" . getUserName($row["users_id_validate"]) . "</td>";
             echo "<td>" . $row["comment_validation"] . "</td>";
             echo "</tr>";
         }
         echo "</table>";
     } else {
         echo "<div class='center b'>" . $LANG['search'][15] . "</div>";
     }
 }
 /** form for Task
  *
  * @param $ID Integer : Id of the task
  * @param $options array
  *     -  ticket Object : the ticket
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $LANG, $CFG_GLPI;
     if (isset($options['ticket']) && !empty($options['ticket'])) {
         $ticket = $options['ticket'];
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $input = array('tickets_id' => $ticket->getField('id'));
         $this->check(-1, 'w', $input);
     }
     $canplan = haveRight("show_planning", "1");
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='5' class='middle right'>" . $LANG['joblist'][6] . "&nbsp;:</td>";
     echo "<td class='center middle' rowspan='5'>" . "<textarea name='content' cols='50' rows='6'>" . $this->fields["content"] . "</textarea></td>";
     if ($this->fields["date"]) {
         echo "<td>" . $LANG['common'][27] . "&nbsp;:</td>";
         echo "<td>" . convDateTime($this->fields["date"]);
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='tickets_id' value='" . $this->fields["tickets_id"] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][36] . "&nbsp;:</td><td>";
     Dropdown::show('TaskCategory', array('value' => $this->fields["taskcategories_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][77] . "&nbsp;:</td>";
     echo "<td><select name='is_private'>";
     echo "<option value='0' " . (!$this->fields["is_private"] ? " selected" : "") . ">" . $LANG['choice'][0] . "</option>";
     echo "<option value='1' " . ($this->fields["is_private"] ? " selected" : "") . ">" . $LANG['choice'][1] . "</option>";
     echo "</select></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['job'][31] . "&nbsp;:</td><td>";
     $units = getTimestampTimeUnits($this->fields["actiontime"]);
     $hour = $units['hour'] + 24 * $units['day'];
     $minute = $units['minute'];
     Dropdown::showInteger('hour', $hour, 0, 100, 1, array($hour));
     echo "&nbsp;" . $LANG['job'][21] . "&nbsp;&nbsp;";
     Dropdown::showInteger('minute', $minute, 0, 59);
     echo "&nbsp;" . $LANG['job'][22];
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['job'][35] . "</td>";
     echo "<td>";
     $plan = new TicketPlanning();
     $plan->showFormForTask($ticket, $this);
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
 function ShowErrors($input = '')
 {
     global $DB, $LANG;
     $ci = new commonitem();
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>";
     echo $LANG['plugin_fusioninventory']["processes"][1];
     echo " <a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php'>(" . $LANG['common'][66] . ")</a>";
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][27];
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][17];
     echo "</th>";
     echo "<th>";
     echo $LANG['common'][1];
     echo "</th>";
     echo "<th>";
     echo $LANG['plugin_fusioninventory']["errors"][104];
     echo "</th>";
     echo "</tr>";
     $condition = "";
     if (isset($input['process_number'])) {
         $condition = "WHERE `process_number`='" . $input['process_number'] . "'";
         if (isset($input['agent_type'])) {
             $condition .= " AND agent_type='" . $input['agent_type'] . "' ";
         }
     }
     $query = "SELECT * FROM `" . $this->table . "`\n         " . $condition . "\n         ORDER BY `process_number` DESC";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             echo $data['process_number'];
             echo "</td>";
             echo "<td>";
             echo convDateTime($data['date']);
             echo "</td>";
             echo "<td>";
             if ($data['agent_type'] == "SNMPQUERY") {
                 echo $LANG['plugin_fusioninventory']["processes"][27];
             } else {
                 if ($data['agent_type'] == "NETDISCOVERY") {
                     echo $LANG['plugin_fusioninventory']["processes"][26];
                 }
             }
             echo "</td>";
             echo "<td>";
             $ci->getFromDB($data['device_type'], $data['on_device']);
             echo $ci->getLink(1);
             echo "</td>";
             echo "<td>";
             echo $data['error_message'];
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
 }
 static function showHistory($ID_port)
 {
     global $DB, $LANG, $INFOFORM_PAGES, $CFG_GLPI;
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $CommonItem = new CommonItem();
     $np = new Netport();
     $query = "\n         SELECT * FROM(\n            SELECT * FROM (\n               SELECT ID, date as date, process_number as process_number,\n               FK_port_source, FK_port_destination,\n               creation as Field, NULL as old_value, NULL as new_value\n\n               FROM glpi_plugin_fusioninventory_snmphistoryconnections\n               WHERE `FK_port_source`='" . $ID_port . "'\n                  OR `FK_port_destination`='" . $ID_port . "'\n               ORDER BY date DESC\n               LIMIT 0,30\n               )\n            AS DerivedTable1\n            UNION ALL\n            SELECT * FROM (\n               SELECT ID, date_mod as date, FK_process as process_number,\n               FK_ports AS FK_port_source, NULL as FK_port_destination,\n               Field, old_value, new_value\n\n               FROM glpi_plugin_fusioninventory_snmphistories\n               WHERE `FK_ports`='" . $ID_port . "'\n               ORDER BY date DESC\n               LIMIT 0,30\n               )\n            AS DerivedTable2)\n         AS MainTable\n         ORDER BY date DESC, ID DESC\n         LIMIT 0,30";
     //echo $query."<br/>";
     $text = "<table class='tab_cadre' cellpadding='5' width='950'>";
     $text .= "<tr class='tab_bg_1'>";
     $text .= "<th colspan='8'>";
     $text .= "Historique";
     $text .= "</th>";
     $text .= "</tr>";
     $text .= "<tr class='tab_bg_1'>";
     $text .= "<th>" . $LANG['plugin_fusioninventory']["snmp"][50] . "</th>";
     $text .= "<th>" . $LANG["common"][1] . "</th>";
     $text .= "<th>" . $LANG["event"][18] . "</th>";
     $text .= "<th></th>";
     $text .= "<th></th>";
     $text .= "<th></th>";
     $text .= "<th>" . $LANG["common"][27] . "</th>";
     $text .= "</tr>";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             $text .= "<tr class='tab_bg_1'>";
             if (!empty($data["FK_port_destination"])) {
                 // Connections and disconnections
                 if ($data['Field'] == '1') {
                     $text .= "<td align='center'><img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_ok.png'/></td>";
                 } else {
                     $text .= "<td align='center'><img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_notok.png'/></td>";
                 }
                 if ($ID_port == $data["FK_port_source"]) {
                     $np->getFromDB($data["FK_port_destination"]);
                     if (isset($np->fields["on_device"])) {
                         $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]);
                         $link1 = $CommonItem->getLink(1);
                         $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">";
                         if (rtrim($np->fields["name"]) != "") {
                             $link .= $np->fields["name"];
                         } else {
                             $link .= $LANG['common'][0];
                         }
                         $link .= "</a>";
                         $text .= "<td align='center'>" . $link . " " . $LANG['networking'][25] . " " . $link1 . "</td>";
                     } else {
                         $text .= "<td align='center'><font color='#ff0000'>" . $LANG['common'][28] . "</font></td>";
                     }
                 } else {
                     if ($ID_port == $data["FK_port_destination"]) {
                         $np->getFromDB($data["FK_port_source"]);
                         if (isset($np->fields["on_device"])) {
                             $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]);
                             $link1 = $CommonItem->getLink(1);
                             $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">";
                             if (rtrim($np->fields["name"]) != "") {
                                 $link .= $np->fields["name"];
                             } else {
                                 $link .= $LANG['common'][0];
                             }
                             $link .= "</a>";
                             $text .= "<td align='center'>" . $link . " " . $LANG['networking'][25] . " " . $link1 . "</td>";
                         } else {
                             $text .= "<td align='center'><font color='#ff0000'>" . $LANG['common'][28] . "</font></td>";
                         }
                     }
                 }
                 $text .= "<td align='center' colspan='4'></td>";
                 $text .= "<td align='center'>" . convDateTime($data["date"]) . "</td>";
             } else {
                 // Changes values
                 $text .= "<td align='center' colspan='2'></td>";
                 $text .= "<td align='center'>" . $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data["Field"]]['name'] . "</td>";
                 $text .= "<td align='center'>" . $data["old_value"] . "</td>";
                 $text .= "<td align='center'>-></td>";
                 $text .= "<td align='center'>" . $data["new_value"] . "</td>";
                 $text .= "<td align='center'>" . convDateTime($data["date"]) . "</td>";
             }
             $text .= "</tr>";
         }
     }
     /*
       $pthc = new PluginFusioninventorySnmphistoryconnection;
     
       $data_connections = $pthc->find('`FK_port_source`="'.$ID_port.'"
                                           OR `FK_port_destination `="'.$ID_port.'"',
                                        '`date` DESC',
                                        '0,30');
       $query = "SELECT *
                 FROM `glpi_plugin_fusioninventory_snmphistories`
                 WHERE `FK_ports`='".$ID_port."'
                 ORDER BY `date_mod` DESC
                 LIMIT 0,30;";
     
     
       $text = "<table class='tab_cadre' cellpadding='5' width='950'>";
     
       $text .= "<tr class='tab_bg_1'>";
       $text .= "<th colspan='8'>";
       $text .= "Historique";
       $text .= "</th>";
       $text .= "</tr>";
     
       $text .= "<tr class='tab_bg_1'>";
       $text .= "<th>".$LANG['plugin_fusioninventory']["snmp"][50]."</th>";
       $text .= "<th>".$LANG["common"][1]."</th>";
       $text .= "<th>".$LANG["networking"][15]."</th>";
       $text .= "<th>".$LANG["event"][18]."</th>";
       $text .= "<th></th>";
       $text .= "<th></th>";
       $text .= "<th></th>";
       $text .= "<th>".$LANG["common"][27]."</th>";
       $text .= "</tr>";
     
       if ($result=$DB->query($query)) {
          while ($data=$DB->fetch_array($result)) {
             $text .= "<tr class='tab_bg_1'>";
     
             if (($data["old_device_ID"] != "0") OR ($data["new_device_ID"] != "0")) {
                // Connections and disconnections
                if ($data["old_device_ID"] != "0") {
                   $text .= "<td align='center'>".$LANG['plugin_fusioninventory']["history"][2]."</td>";
                   $CommonItem->getFromDB($data["old_device_type"],$data["old_device_ID"]);
                   $text .= "<td align='center'>".$CommonItem->getLink(1)."</td>";
                   $text .= "<td align='center'>".$data["old_value"]."</td>";
                } else if ($data["new_device_ID"] != "0") {
                   $text .= "<td align='center'>".$LANG['plugin_fusioninventory']["history"][3]."</td>";
                   $CommonItem->getFromDB($data["new_device_type"],$data["new_device_ID"]);
                   $text .= "<td align='center'>".$CommonItem->getLink(1)."</td>";
                   $text .= "<td align='center'>".$data["new_value"]."</td>";
                }
                $text .= "<td align='center' colspan='4'></td>";
                $text .= "<td align='center'>".convDateTime($data["date_mod"])."</td>";
     
             } else if (($data["old_device_ID"] == "0") AND ($data["new_device_ID"] == "0") AND ($data["Field"] == "0")) {
                // Unknown Mac address
                if (!empty($data["old_value"])) {
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$LANG['plugin_fusioninventory']["history"][2]."</td>";
                   $CommonItem->getFromDB($data["old_device_type"],$data["old_device_ID"]);
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$CommonItem->getLink(1)."</td>";
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$data["old_value"]."</td>";
                } else if (!empty($data["new_value"])) {
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$LANG['plugin_fusioninventory']["history"][3]."</td>";
                   $CommonItem->getFromDB($data["new_device_type"],$data["new_device_ID"]);
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$CommonItem->getLink(1)."</td>";
                   $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$data["new_value"]."</td>";
                }
                $text .= "<td align='center' colspan='4' background='#cf9b9b' class='tab_bg_1_2'></td>";
                $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".convDateTime($data["date_mod"])."</td>";
             } else {
                // Changes values
                $text .= "<td align='center' colspan='3'></td>";
                $text .= "<td align='center'>".$data["Field"]."</td>";
                $text .= "<td align='center'>".$data["old_value"]."</td>";
                $text .= "<td align='center'>-></td>";
                $text .= "<td align='center'>".$data["new_value"]."</td>";
                $text .= "<td align='center'>".convDateTime($data["date_mod"])."</td>";
             }
             $text .= "</tr>";
          }
       }
     */
     $text .= "<tr class='tab_bg_1'>";
     $text .= "<th colspan='8'>";
     $text .= "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/report/switch_ports.history.php?FK_networking_ports=" . $ID_port . "'>Voir l'historique complet</a>";
     $text .= "</th>";
     $text .= "</tr>";
     $text .= "</table>";
     return $text;
 }
 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>";
 }
 /**
  * Print the Software form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     // Show Software or blank form
     if (!haveRight("software", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $canedit = $this->can($ID, 'w');
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . "&nbsp;: ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . "&nbsp;: ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . "&nbsp;: ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . $LANG['common'][5] . " / " . $LANG['software'][6] . "&nbsp;:</td><td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;:</td><td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][36] . "&nbsp;:</td><td>";
     Dropdown::show('SoftwareCategory', array('value' => $this->fields["softwarecategories_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;:</td><td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['software'][46] . "&nbsp;:</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . $LANG['common'][34] . "&nbsp;:</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td><td colspan='2'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td><td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td rowspan='3' class='middle'>" . $LANG['common'][25] . "&nbsp;: </td>";
     echo "<td class='center middle' rowspan='3'>";
     echo "<textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center' height='30'>" . $datestring . "&nbsp;" . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         echo "(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td></tr>\n";
     // UPDATE
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['software'][29] . "&nbsp;:</td><td colspan='3'>";
     Dropdown::showYesNo("is_update", $this->fields['is_update']);
     echo "&nbsp;" . $LANG['pager'][2] . "&nbsp;";
     Dropdown::show('Software', array('value' => $this->fields["softwares_id"]));
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /**
  * Print the transfer form
  *
  * @param $ID Integer : Id of the contact to print
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     if (!haveRight("transfer", "r")) {
         return false;
     }
     $edit_form = true;
     if (!strpos($_SERVER['PHP_SELF'], "transfer.form.php")) {
         $edit_form = false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $params = array();
     if (!haveRight("transfer", "w")) {
         $params['readonly'] = true;
     }
     if ($edit_form) {
         $this->showTabs($options);
         $this->showFormHeader($options);
     } else {
         echo "<form method='post' name=form action='" . $options['target'] . "'>";
         echo "<div class='center' id='tabsbody' >";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='tab_bg_2 top' colspan='4'>";
         echo "<div class='center'>";
         Dropdown::show('Entity', array('name' => 'to_entity'));
         echo "&nbsp;<input type='submit' name='transfer' value=\"" . $LANG['buttons'][48] . "\"\n                      class='submit'></div>";
         echo "</td></tr>";
     }
     if ($edit_form) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][16] . "&nbsp;:</td><td>";
         autocompletionTextField($this, "name");
         echo "</td>";
         echo "<td rowspan='3' class='middle right'>" . $LANG['common'][25] . "&nbsp;: </td>";
         echo "<td class='center middle' rowspan='3'>\n               <textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][26] . "&nbsp;: </td>";
         echo "<td>" . ($this->fields["date_mod"] ? convDateTime($this->fields["date_mod"]) : $LANG['setup'][307]);
         echo "</td></tr>";
     }
     $keep = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49]);
     $clean = array(0 => $LANG['buttons'][49], 1 => $LANG['buttons'][6], 2 => $LANG['buttons'][22]);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['title'][38] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_history'];
     Dropdown::showFromArray('keep_history', $keep, $params);
     echo "</td>";
     if (!$edit_form) {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG['Menu'][38] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['networking'][6] . "&nbsp;:</td><td>";
     $options = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49] . " - " . $LANG['buttons'][10], 2 => $LANG['buttons'][49] . " - " . $LANG['buttons'][9]);
     $params['value'] = $this->fields['keep_networklink'];
     Dropdown::showFromArray('keep_networklink', $options, $params);
     echo "</td>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['title'][28] . "&nbsp;:</td><td>";
     $options = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49] . " - " . $LANG['buttons'][10], 2 => $LANG['buttons'][49] . " - " . $LANG['buttons'][48]);
     $params['value'] = $this->fields['keep_ticket'];
     Dropdown::showFromArray('keep_ticket', $options, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG["Menu"][4] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_software'];
     Dropdown::showFromArray('keep_software', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][4] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_software'];
     Dropdown::showFromArray('clean_software', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['Menu'][17] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_reservation'];
     Dropdown::showFromArray('keep_reservation', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG['title'][30] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_device'];
     Dropdown::showFromArray('keep_device', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][2] . " -> " . $LANG["Menu"][21] . " / " . $LANG['cartridges'][12] . "&nbsp;:" . "</td><td>";
     $params['value'] = $this->fields['keep_cartridgeitem'];
     Dropdown::showFromArray('keep_cartridgeitem', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG['cartridges'][12] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_cartridgeitem'];
     Dropdown::showFromArray('clean_cartridgeitem', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['cartridges'][12] . " -> " . $LANG["Menu"][21] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_cartridge'];
     Dropdown::showFromArray('keep_cartridge', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['financial'][3] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_infocom'];
     Dropdown::showFromArray('keep_infocom', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][92] . " -> " . $LANG["Menu"][32] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_consumable'];
     Dropdown::showFromArray('keep_consumable', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG['computers'][8] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_disk'];
     Dropdown::showFromArray('keep_disk', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG['connect'][0] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][3] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_monitor'];
     Dropdown::showFromArray('keep_dc_monitor', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][3] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_monitor'];
     Dropdown::showFromArray('clean_dc_monitor', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][2] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_printer'];
     Dropdown::showFromArray('keep_dc_printer', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][2] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_printer'];
     Dropdown::showFromArray('clean_dc_printer', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][16] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_peripheral'];
     Dropdown::showFromArray('keep_dc_peripheral', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][16] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_peripheral'];
     Dropdown::showFromArray('clean_dc_peripheral', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][34] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_phone'];
     Dropdown::showFromArray('keep_dc_phone', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][34] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_phone'];
     Dropdown::showFromArray('clean_dc_phone', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG["Menu"][26] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][23] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_supplier'];
     Dropdown::showFromArray('keep_supplier', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][23] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_supplier'];
     Dropdown::showFromArray('clean_supplier', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][23] . " -> " . $LANG["Menu"][22] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_contact'];
     Dropdown::showFromArray('keep_contact', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][22] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_contact'];
     Dropdown::showFromArray('clean_contact', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][27] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_document'];
     Dropdown::showFromArray('keep_document', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][27] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_document'];
     Dropdown::showFromArray('clean_document', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][25] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_contract'];
     Dropdown::showFromArray('keep_contract', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][25] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_contract'];
     Dropdown::showFromArray('clean_contract', $clean, $params);
     echo "</td></tr>";
     if (haveRight("transfer", "w")) {
         if ($edit_form) {
             $this->showFormButtons($options);
             $this->addDivForTabs();
         } else {
             echo "</table></div></form>";
         }
     }
 }
/**
 * Log a message in log file
 *
 * @param $name string: name of the log file
 * @param $text string: text to log
 * @param $force boolean: force log in file not seeing use_log_in_files config
**/
function logInFile($name, $text, $force = false)
{
    global $CFG_GLPI;
    $user = '';
    if (function_exists('getLoginUserID')) {
        $user = "******" . getLoginUserID() . '@' . php_uname('n') . "]";
    }
    if (isset($CFG_GLPI["use_log_in_files"]) && $CFG_GLPI["use_log_in_files"] || $force) {
        error_log(convDateTime(date("Y-m-d H:i:s")) . "{$user}\n" . $text, 3, GLPI_LOG_DIR . "/" . $name . ".log");
    }
}