function showForm(Printer $item, $options = array())
 {
     // ** Get link OID fields
     $mapping_name = array();
     $id = $item->getID();
     $a_cartridges = $this->find("`printers_id`='" . $id . "'");
     echo "<div align='center'><form method='post' name='snmp_form' id='snmp_form'\n                 action=\"" . $options['target'] . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th align='center' colspan='3'>";
     echo __('Cartridge(s)', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     asort($mapping_name);
     $mapping = new PluginFusioninventoryMapping();
     foreach ($a_cartridges as $a_cartridge) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>";
         $mapping->getFromDB($a_cartridge['plugin_fusioninventory_mappings_id']);
         echo $mapping->getTranslation($mapping->fields);
         echo " : ";
         echo "</td>";
         echo "<td align='center'>";
         echo "</td>";
         echo "<td align='center'>";
         if ($a_cartridge['state'] == 100000) {
             echo __('OK');
         } else {
             if ($a_cartridge['state'] < 0) {
                 $a_cartridge['state'] = $a_cartridge['state'] * -1;
                 echo $a_cartridge['state'];
                 echo ' ' . __('remaining pages', 'fusioninventory');
             } else {
                 PluginFusioninventoryDisplay::bar($a_cartridge['state']);
             }
         }
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
예제 #2
0
function pluginFusioninventoryUpdatemapping()
{
    /*
     * Udpate mapping
     */
    $pfMapping = new PluginFusioninventoryMapping();
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'location';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'locations_id';
    $a_input['locale'] = 1;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'firmware';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'networkequipmentfirmwares_id';
    $a_input['locale'] = 2;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'firmware1';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 2;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'firmware2';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 2;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'contact';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'contact';
    $a_input['locale'] = 403;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'comments';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'comment';
    $a_input['locale'] = 404;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'uptime';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkequipments';
    $a_input['tablefield'] = 'uptime';
    $a_input['locale'] = 3;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cpu';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkequipments';
    $a_input['tablefield'] = 'cpu';
    $a_input['locale'] = 12;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cpuuser';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkequipments';
    $a_input['tablefield'] = 'cpu';
    $a_input['locale'] = 401;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cpusystem';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkequipments';
    $a_input['tablefield'] = 'cpu';
    $a_input['locale'] = 402;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'serial';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'serial';
    $a_input['locale'] = 13;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'otherserial';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'otherserial';
    $a_input['locale'] = 419;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'name';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'name';
    $a_input['locale'] = 20;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ram';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'ram';
    $a_input['locale'] = 21;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'memory';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkequipments';
    $a_input['tablefield'] = 'memory';
    $a_input['locale'] = 22;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'vtpVlanName';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 19;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'vmvlan';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 430;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'entPhysicalModelName';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'networkequipmentmodels_id';
    $a_input['locale'] = 17;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'macaddr';
    $a_input['table'] = 'glpi_networkequipments';
    $a_input['tablefield'] = 'ip';
    $a_input['locale'] = 417;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cdpCacheAddress';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 409;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cdpCacheDevicePort';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 410;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cdpCacheVersion';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 435;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cdpCacheDeviceId';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 436;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'cdpCachePlatform';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 437;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpRemChassisId';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 431;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpRemPortId';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 432;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpLocChassisId';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 432;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpRemSysDesc';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 438;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpRemSysName';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 439;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'lldpRemPortDesc';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 440;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'vlanTrunkPortDynamicStatus';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 411;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'dot1dTpFdbAddress';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 412;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ipNetToMediaPhysAddress';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 413;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'dot1dTpFdbPort';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 414;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'dot1dBasePortIfIndex';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 415;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ipAdEntAddr';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 421;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'PortVlanIndex';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 422;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifIndex';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 408;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifmtu';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifmtu';
    $a_input['locale'] = 4;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifspeed';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifspeed';
    $a_input['locale'] = 5;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifinternalstatus';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifinternalstatus';
    $a_input['locale'] = 6;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'iflastchange';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'iflastchange';
    $a_input['locale'] = 7;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifinoctets';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifinoctets';
    $a_input['locale'] = 8;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifoutoctets';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifoutoctets';
    $a_input['locale'] = 9;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifinerrors';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifinerrors';
    $a_input['locale'] = 10;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifouterrors';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifouterrors';
    $a_input['locale'] = 11;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifstatus';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifstatus';
    $a_input['locale'] = 14;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifPhysAddress';
    $a_input['table'] = 'glpi_networkports';
    $a_input['tablefield'] = 'mac';
    $a_input['locale'] = 15;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifName';
    $a_input['table'] = 'glpi_networkports';
    $a_input['tablefield'] = 'name';
    $a_input['locale'] = 16;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifType';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 18;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifdescr';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifdescr';
    $a_input['locale'] = 23;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'portDuplex';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'portduplex';
    $a_input['locale'] = 33;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'NetworkEquipment';
    $a_input['name'] = 'ifalias';
    $a_input['table'] = 'glpi_plugin_fusioninventory_networkports';
    $a_input['tablefield'] = 'ifalias';
    $a_input['locale'] = 120;
    $pfMapping->set($a_input);
    // Printers
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'model';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'printermodels_id';
    $a_input['locale'] = 25;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'enterprise';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'manufacturers_id';
    $a_input['locale'] = 420;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'serial';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'serial';
    $a_input['locale'] = 27;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'contact';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'contact';
    $a_input['locale'] = 405;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'comments';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'comment';
    $a_input['locale'] = 406;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'name';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'comment';
    $a_input['locale'] = 24;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'otherserial';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'otherserial';
    $a_input['locale'] = 418;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'memory';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'memory_size';
    $a_input['locale'] = 26;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'location';
    $a_input['table'] = 'glpi_printers';
    $a_input['tablefield'] = 'locations_id';
    $a_input['locale'] = 56;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'informations';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 165;
    $a_input['shortlocale'] = 165;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblack';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 157;
    $a_input['shortlocale'] = 157;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblackmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 166;
    $a_input['shortlocale'] = 166;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblackused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 167;
    $a_input['shortlocale'] = 167;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblackremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 168;
    $a_input['shortlocale'] = 168;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblack2';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 157;
    $a_input['shortlocale'] = 157;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblack2max';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 166;
    $a_input['shortlocale'] = 166;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblack2used';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 167;
    $a_input['shortlocale'] = 167;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonerblack2remaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 168;
    $a_input['shortlocale'] = 168;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonercyan';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 158;
    $a_input['shortlocale'] = 158;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonercyanmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 169;
    $a_input['shortlocale'] = 169;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonercyanused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 170;
    $a_input['shortlocale'] = 170;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonercyanremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 171;
    $a_input['shortlocale'] = 171;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonermagenta';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 159;
    $a_input['shortlocale'] = 159;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonermagentamax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 172;
    $a_input['shortlocale'] = 172;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonermagentaused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 173;
    $a_input['shortlocale'] = 173;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'tonermagentaremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 174;
    $a_input['shortlocale'] = 174;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'toneryellow';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 160;
    $a_input['shortlocale'] = 160;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'toneryellowmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 175;
    $a_input['shortlocale'] = 175;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'toneryellowused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 176;
    $a_input['shortlocale'] = 176;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'toneryellowused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 177;
    $a_input['shortlocale'] = 177;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'wastetoner';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 151;
    $a_input['shortlocale'] = 151;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'wastetonermax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 190;
    $a_input['shortlocale'] = 190;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'wastetonerused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 191;
    $a_input['shortlocale'] = 191;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'wastetonerremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 192;
    $a_input['shortlocale'] = 192;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgeblack';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 134;
    $a_input['shortlocale'] = 134;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgeblackphoto';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 135;
    $a_input['shortlocale'] = 135;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgecyan';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 136;
    $a_input['shortlocale'] = 136;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgecyanlight';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 139;
    $a_input['shortlocale'] = 139;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgemagenta';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 138;
    $a_input['shortlocale'] = 138;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgemagentalight';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 140;
    $a_input['shortlocale'] = 140;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgeyellow';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 137;
    $a_input['shortlocale'] = 137;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'cartridgegrey';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 196;
    $a_input['shortlocale'] = 196;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'maintenancekit';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 156;
    $a_input['shortlocale'] = 156;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'maintenancekitmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 193;
    $a_input['shortlocale'] = 193;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'maintenancekitused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 194;
    $a_input['shortlocale'] = 194;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'maintenancekitremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 195;
    $a_input['shortlocale'] = 195;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumblack';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 161;
    $a_input['shortlocale'] = 161;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumblackmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 178;
    $a_input['shortlocale'] = 178;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumblackused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 179;
    $a_input['shortlocale'] = 179;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumblackremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 180;
    $a_input['shortlocale'] = 180;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumcyan';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 162;
    $a_input['shortlocale'] = 162;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumcyanmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 181;
    $a_input['shortlocale'] = 181;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumcyanused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 182;
    $a_input['shortlocale'] = 182;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumcyanremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 183;
    $a_input['shortlocale'] = 183;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drummagenta';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 163;
    $a_input['shortlocale'] = 163;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drummagentamax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 184;
    $a_input['shortlocale'] = 184;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drummagentaused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 185;
    $a_input['shortlocale'] = 185;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drummagentaremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 186;
    $a_input['shortlocale'] = 186;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumyellow';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 164;
    $a_input['shortlocale'] = 164;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumyellowmax';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 187;
    $a_input['shortlocale'] = 187;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumyellowused';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 188;
    $a_input['shortlocale'] = 188;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'drumyellowremaining';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 189;
    $a_input['shortlocale'] = 189;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountertotalpages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_total';
    $a_input['locale'] = 28;
    $a_input['shortlocale'] = 128;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterblackpages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_n_b';
    $a_input['locale'] = 29;
    $a_input['shortlocale'] = 129;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountercolorpages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_color';
    $a_input['locale'] = 30;
    $a_input['shortlocale'] = 130;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterrectoversopages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_recto_verso';
    $a_input['locale'] = 54;
    $a_input['shortlocale'] = 154;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterscannedpages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'scanned';
    $a_input['locale'] = 55;
    $a_input['shortlocale'] = 155;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountertotalpages_print';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_total_print';
    $a_input['locale'] = 423;
    $a_input['shortlocale'] = 1423;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterblackpages_print';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_n_b_print';
    $a_input['locale'] = 424;
    $a_input['shortlocale'] = 1424;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountercolorpages_print';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_color_print';
    $a_input['locale'] = 425;
    $a_input['shortlocale'] = 1425;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountertotalpages_copy';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_total_copy';
    $a_input['locale'] = 426;
    $a_input['shortlocale'] = 1426;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterblackpages_copy';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_n_b_copy';
    $a_input['locale'] = 427;
    $a_input['shortlocale'] = 1427;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountercolorpages_copy';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_color_copy';
    $a_input['locale'] = 428;
    $a_input['shortlocale'] = 1428;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecountertotalpages_fax';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_total_fax';
    $a_input['locale'] = 429;
    $a_input['shortlocale'] = 1429;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'pagecounterlargepages';
    $a_input['table'] = 'glpi_plugin_fusioninventory_printerlogs';
    $a_input['tablefield'] = 'pages_total_large';
    $a_input['locale'] = 434;
    $a_input['shortlocale'] = 1434;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'ifPhysAddress';
    $a_input['table'] = 'glpi_networkports';
    $a_input['tablefield'] = 'mac';
    $a_input['locale'] = 48;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'ifName';
    $a_input['table'] = 'glpi_networkports';
    $a_input['tablefield'] = 'name';
    $a_input['locale'] = 57;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'ifaddr';
    $a_input['table'] = 'glpi_networkports';
    $a_input['tablefield'] = 'ip';
    $a_input['locale'] = 407;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'ifType';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 97;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Printer';
    $a_input['name'] = 'ifIndex';
    $a_input['table'] = '';
    $a_input['tablefield'] = '';
    $a_input['locale'] = 416;
    $pfMapping->set($a_input);
    // ** Computer
    $a_input = array();
    $a_input['itemtype'] = 'Computer';
    $a_input['name'] = 'serial';
    $a_input['table'] = '';
    $a_input['tablefield'] = 'serial';
    $a_input['locale'] = 13;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Computer';
    $a_input['name'] = 'ifPhysAddress';
    $a_input['table'] = '';
    $a_input['tablefield'] = 'mac';
    $a_input['locale'] = 15;
    $pfMapping->set($a_input);
    $a_input = array();
    $a_input['itemtype'] = 'Computer';
    $a_input['name'] = 'ifaddr';
    $a_input['table'] = '';
    $a_input['tablefield'] = 'ip';
    $a_input['locale'] = 407;
    $pfMapping->set($a_input);
}
 static function showHistory($ID_port)
 {
     global $DB, $CFG_GLPI;
     $np = new NetworkPort();
     $query = "\n         SELECT * FROM(\n            SELECT * FROM (\n               SELECT `id`, `date_mod`, `plugin_fusioninventory_agentprocesses_id`,\n                  `networkports_id_source`, `networkports_id_destination`,\n                  `creation` as `field`, NULL as `value_old`, NULL as `value_new`\n               FROM `glpi_plugin_fusioninventory_networkportconnectionlogs`\n               WHERE `networkports_id_source`='" . $ID_port . "'\n                  OR `networkports_id_destination`='" . $ID_port . "'\n               ORDER BY `date_mod` DESC\n               )\n            AS `DerivedTable1`\n            UNION ALL\n            SELECT * FROM (\n               SELECT `glpi_plugin_fusioninventory_networkportlogs`.`id`,\n                  `date_mod` as `date_mod`, `plugin_fusioninventory_agentprocesses_id`,\n                  `networkports_id` AS `networkports_id_source`,\n                  NULL as `networkports_id_destination`,\n                  `name` AS `field`, `value_old`, `value_new`\n               FROM `glpi_plugin_fusioninventory_networkportlogs`\n               LEFT JOIN `glpi_plugin_fusioninventory_mappings`\n                  ON `glpi_plugin_fusioninventory_networkportlogs`." . "`plugin_fusioninventory_mappings_id` =\n                     `glpi_plugin_fusioninventory_mappings`.`id`\n               WHERE `networkports_id`='" . $ID_port . "'\n               ORDER BY `date_mod` DESC\n               )\n            AS `DerivedTable2`)\n         AS `MainTable`\n         ORDER BY `date_mod` DESC, `id` DESC";
     $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>" . __('Connection') . "</th>";
     $text .= "<th>" . __('Item') . "</th>";
     $text .= "<th>" . __('Field') . "</th>";
     $text .= "<th></th>";
     $text .= "<th></th>";
     $text .= "<th></th>";
     $text .= "<th>" . __('Date') . "</th>";
     $text .= "</tr>";
     $result = $DB->query($query);
     if ($result) {
         while ($data = $DB->fetch_array($result)) {
             $text .= "<tr class='tab_bg_1'>";
             if (!empty($data["networkports_id_destination"])) {
                 // Connections and disconnections
                 $imgfolder = $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics";
                 if ($data['field'] == '1') {
                     $text .= "<td align='center'><img src='" . $imgfolder . "/connection_ok.png'/></td>";
                 } else {
                     $text .= "<td align='center'><img src='" . $imgfolder . "/connection_notok.png'/></td>";
                 }
                 if ($ID_port == $data["networkports_id_source"]) {
                     if ($np->getFromDB($data["networkports_id_destination"])) {
                         //if (isset($np->fields["items_id"])) {
                         $item = new $np->fields["itemtype"]();
                         $item->getFromDB($np->fields["items_id"]);
                         $link1 = $item->getLink(1);
                         $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $np->fields["id"] . "\">";
                         if (rtrim($np->fields["name"]) != "") {
                             $link .= $np->fields["name"];
                         } else {
                             $link .= __('Without name');
                         }
                         $link .= "</a>";
                         $text .= "<td align='center'>" . $link . " " . __('on', 'fusioninventory') . " " . $link1 . "</td>";
                     } else {
                         $text .= "<td align='center'><font color='#ff0000'>" . __('Deleted') . "</font></td>";
                     }
                 } else {
                     if ($ID_port == $data["networkports_id_destination"]) {
                         $np->getFromDB($data["networkports_id_source"]);
                         if (isset($np->fields["items_id"])) {
                             $item = new $np->fields["itemtype"]();
                             $item->getFromDB($np->fields["items_id"]);
                             $link1 = $item->getLink(1);
                             $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $np->fields["id"] . "\">";
                             if (rtrim($np->fields["name"]) != "") {
                                 $link .= $np->fields["name"];
                             } else {
                                 $link .= __('Without name');
                             }
                             $link .= "</a>";
                             $text .= "<td align='center'>" . $link . " " . __('on', 'fusioninventory') . " " . $link1 . "</td>";
                         } else {
                             $text .= "<td align='center'><font color='#ff0000'>" . __('Deleted') . "</font></td>";
                         }
                     }
                 }
                 $text .= "<td align='center' colspan='4'></td>";
                 $text .= "<td align='center'>" . Html::convDateTime($data["date_mod"]) . "</td>";
             } else {
                 // Changes values
                 $text .= "<td align='center' colspan='2'></td>";
                 //               $text .= "<td align='center'>".
                 //                      $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data["field"]]['name']."</td>";
                 $mapping = new PluginFusioninventoryMapping();
                 $mapfields = $mapping->get('NetworkEquipment', $data["field"]);
                 if ($mapfields != FALSE) {
                     $text .= "<td align='center'>" . $mapping->getTranslation($mapfields) . "</td>";
                 } else {
                     $text .= "<td align='center'></td>";
                 }
                 $text .= "<td align='center'>" . $data["value_old"] . "</td>";
                 $text .= "<td align='center'>-></td>";
                 $text .= "<td align='center'>" . $data["value_new"] . "</td>";
                 $text .= "<td align='center'>" . Html::convDateTime($data["date_mod"]) . "</td>";
             }
             $text .= "</tr>";
         }
     }
     $text .= "</table>";
     return $text;
 }
    /**
     * Show printer graph form
     **/
    function showGraph($id, $options = array())
    {
        global $DB, $CFG_GLPI;
        $printer = new Printer();
        $where = '';
        $begin = '';
        $end = '';
        $timeUnit = 'day';
        $graphField = 'pages_total';
        $pagecounters = array();
        $graphType = 'day';
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_begin'])) {
            $begin = $_SESSION['glpi_plugin_fusioninventory_graph_begin'];
        }
        if ($begin == 'NULL' or $begin == '') {
            $begin = date("Y-m-01");
            // first day of current month
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_end'])) {
            $end = $_SESSION['glpi_plugin_fusioninventory_graph_end'];
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_type'])) {
            $graphType = $_SESSION['glpi_plugin_fusioninventory_graph_type'];
        }
        if ($end == 'NULL' or $end == '') {
            $end = date("Y-m-d");
            // today
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'])) {
            $timeUnit = $_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'];
        }
        if (!isset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
            $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'] = array();
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'])) {
            $printerCompAdd = $_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'];
            if (!key_exists($printerCompAdd, $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
                $oPrinter = new Printer();
                if ($oPrinter->getFromDB($printerCompAdd)) {
                    $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$printerCompAdd] = $oPrinter->getField('name');
                }
            }
        } elseif (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove'])) {
            unset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove']]);
        }
        $oPrinter = new Printer();
        $printers = $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'];
        $printersView = $printers;
        // printers without the current printer
        if (isset($printersView[$id])) {
            unset($printersView[$id]);
        } else {
            if ($oPrinter->getFromDB($id)) {
                $printers[$id] = $oPrinter->getField('name');
            }
        }
        $printersList = '';
        foreach ($printers as $printers_id => $printername) {
            if ($printersList != '') {
                $printersList .= '<br/>';
            }
            if ($printers_id == $id) {
                $printersList .= $printername;
            } else {
                $oPrinter->getFromDB($printers_id);
                $printersList .= $oPrinter->getLink(1);
            }
        }
        $printersIds = "";
        foreach (array_keys($printers) as $printerId) {
            if ($printersIds != '') {
                $printersIds .= ', ';
            }
            $printersIds .= $printerId;
        }
        $where = " WHERE `printers_id` IN(" . $printersIds . ")";
        if ($begin != '' || $end != '') {
            $where .= " AND " . getDateRequest("`date`", $begin, $end);
        }
        $group = '';
        switch ($timeUnit) {
            case 'day':
                $group = "GROUP BY `printers_id`, `year`, `month`, `day`";
                break;
            case 'week':
                $group = "GROUP BY `printers_id`, `year`, `month`, `week`";
                break;
            case 'month':
                $group = "GROUP BY `printers_id`, `year`, `month`";
                break;
            case 'year':
                $group = "GROUP BY `printers_id`, `year`";
                break;
        }
        echo "<form method='post' name='snmp_form' id='snmp_form' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/printer_info.form.php'>";
        echo "<table class='tab_cadre' cellpadding='5' width='950'>";
        $mapping = new PluginFusioninventoryMapping();
        $maps = $mapping->find("`itemtype`='Printer'");
        foreach ($maps as $mapfields) {
            if (!isset($mapfields["shortlocale"])) {
                $mapfields["shortlocale"] = $mapfields["locale"];
            }
            $pagecounters[$mapfields['name']] = $mapping->getTranslation($mapfields);
        }
        echo "<tr class='tab_bg_1'>";
        echo "<th colspan='4'>";
        echo __('Printed page counter', 'fusioninventory');
        echo "</th>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('Start date') . "&nbsp;:</td>";
        echo "<td class='left'>";
        Html::showDateFormItem("graph_begin", $begin);
        echo "</td>";
        echo "<td class='left'>" . __('Time unit', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $elementsTime = array('day' => _n('Day', 'Days', 1), 'week' => __('Week'), 'month' => _n('Month', 'Months', 1), 'year' => __('Year', 'fusioninventory'));
        Dropdown::showFromArray('graph_timeUnit', $elementsTime, array('value' => $timeUnit));
        echo "</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('End date') . "&nbsp;:</td>";
        echo "<td class='left'>";
        Html::showDateFormItem("graph_end", $end);
        echo "</td>";
        echo "<td class='left'>" . __('Display', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $elements = array('total' => __('Total counter', 'fusioninventory'), 'day' => __('pages per day', 'fusioninventory'));
        Dropdown::showFromArray('graph_type', $elements, array('value' => $graphType));
        echo "</td>";
        echo "</tr>";
        echo "<tr class='tab_bg_2'>";
        echo "<td class='center' colspan='4'>\n              <input type='submit' class='submit' name='graph_plugin_fusioninventory_printer_period'\n                      value='" . __('Update') . "'/>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr>";
        echo "<th colspan='4'>" . __('Printers to compare', 'fusioninventory') . "</th>";
        echo "</tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left' rowspan='3'>" . __('Printer') . "&nbsp;:</td>";
        echo "<td class='left' rowspan='3'>";
        echo $printersList;
        echo "</td>";
        echo "<td class='left'>" . __('Add a printer', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $printersused = array();
        foreach ($printersView as $printer_id => $name) {
            $printersused[] = $printer_id;
        }
        $printer->getFromDB($id);
        Dropdown::show('Printer', array('name' => 'graph_printerCompAdd', 'entity' => $printer->fields['entities_id'], 'used' => $printersused));
        echo "&nbsp;<input type='submit' value=\"" . __('Add') . "\" class='submit' " . "name='graph_plugin_fusioninventory_printer_add'>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td class='left'>" . __('Remove a printer', 'fusioninventory') . "&nbsp;:</td>";
        echo "<td class='left'>";
        $printersTmp = $printersView;
        $printersTmp[0] = "-----";
        asort($printersTmp);
        Dropdown::showFromArray('graph_printerCompRemove', $printersTmp);
        echo "&nbsp;<input type='submit' value=\"" . __('Delete', 'fusioninventory') . "\" " . "class='submit' name='graph_plugin_fusioninventory_printer_remove'>";
        echo "</td>";
        echo "</tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td colspan='2'></td>";
        echo "</tr>";
        echo "</table>";
        Html::closeForm();
        $elementsField = array('pages_total' => $pagecounters['pagecountertotalpages'], 'pages_n_b' => $pagecounters['pagecounterblackpages'], 'pages_color' => $pagecounters['pagecountercolorpages'], 'pages_recto_verso' => $pagecounters['pagecounterrectoversopages'], 'scanned' => $pagecounters['pagecounterscannedpages'], 'pages_total_print' => $pagecounters['pagecountertotalpages_print'], 'pages_n_b_print' => $pagecounters['pagecounterblackpages_print'], 'pages_color_print' => $pagecounters['pagecountercolorpages_print'], 'pages_total_copy' => $pagecounters['pagecountertotalpages_copy'], 'pages_n_b_copy' => $pagecounters['pagecounterblackpages_copy'], 'pages_color_copy' => $pagecounters['pagecountercolorpages_copy'], 'pages_total_fax' => $pagecounters['pagecountertotalpages_fax']);
        echo "<br/>";
        $a_graph = array();
        foreach ($elementsField as $graphField => $name) {
            $query = "SELECT `printers_id`, DAY(`date`)-1 AS `day`, WEEK(`date`) AS `week`,\n                    MONTH(`date`) AS `month`, YEAR(`date`) AS `year`, `date`,\n                    `{$graphField}`\n             FROM `glpi_plugin_fusioninventory_printerlogs`" . $where . " AND `" . $graphField . "` > 0 " . $group;
            $result = $DB->query($query);
            if ($DB->numrows($result) == 0) {
                unset($elementsField[$graphField]);
            }
        }
        foreach ($elementsField as $graphField => $name) {
            $query = "SELECT `printers_id`, DAY(`date`)-1 AS `day`, WEEK(`date`) AS `week`,\n                    MONTH(`date`) AS `month`, YEAR(`date`) AS `year`, `date`,\n                    `{$graphField}`\n             FROM `glpi_plugin_fusioninventory_printerlogs`" . $where . $group . "\n             ORDER BY `year`, `month`, `day`, `printers_id`";
            $input = array();
            $result = $DB->query($query);
            if ($result) {
                if ($DB->numrows($result) != 0) {
                    $pages = array();
                    $data = array();
                    $date = '';
                    while ($data = $DB->fetch_assoc($result)) {
                        switch ($timeUnit) {
                            case 'day':
                                $split = explode(" ", $data['date']);
                                $date = $split[0];
                                break;
                            case 'week':
                                $split = explode(" ", $data['date']);
                                $date = $split[0];
                                break;
                            case 'month':
                                $split = explode(" ", $data['date']);
                                $split2 = explode("-", $split[0]);
                                $date = $split2[0] . "-" . $split2[1];
                                break;
                            case 'year':
                                $split = explode(" ", $data['date']);
                                $split2 = explode("-", $split[0]);
                                $date = $split2[0];
                                break;
                        }
                        if ($graphType == 'day') {
                            if (!isset($pages[$data['printers_id']])) {
                                $pages[$data['printers_id']] = $data[$graphField];
                            } else {
                                $y = $data[$graphField] - $pages[$data['printers_id']];
                                if ($y < 0) {
                                    $y = 0;
                                }
                                $input[] = array('x' => $date, 'y' => $y);
                                if ($data[$graphField] > 0) {
                                    $pages[$data['printers_id']] = $data[$graphField];
                                }
                            }
                        } else {
                            $input[] = array('x' => $date, 'y' => $data[$graphField]);
                        }
                    }
                }
            }
            $continue = 1;
            if ($continue == '0' or $continue == '-1') {
                echo "<table class='tab_cadre' cellpadding='5' width='900'>";
                echo "<tr class='tab_bg_1'>";
                echo "<th>";
                echo $name;
                echo "</th>";
                echo "</tr>";
                echo "<tr class='tab_bg_1'>";
                echo "<td align='center'>";
                if ($continue == '0') {
                    echo __('Too datas to display', 'fusioninventory');
                }
                echo "</td>";
                echo "</tr>";
                echo "</table><br/>";
            } else {
                if (count($input > 0)) {
                    $split = explode(' > ', $name);
                    $a_graph[] = array('key' => $split[count($split) - 1], 'values' => $input);
                }
            }
        }
        // Display graph
        echo '<div id="chartPrinter">' . '<svg style="height: 400px; width: 950px;"></svg>' . '</div>';
        echo "<script type='text/javascript'>\n      function drawGraph() {\n         var chart = nv.models.multiBarChart();\n\n         chart.yAxis\n             .tickFormat(d3.format(',0f'));\n\n        d3.select('#chartPrinter svg')\n           .datum(exampleData())\n          .transition().duration(500).call(chart);\n\n        nv.utils.windowResize(chart.update);\n    }\n    ";
        echo '   function exampleData() {
      return ' . json_encode($a_graph) . '
   }

   drawGraph();
</script>';
    }
 static function printerInventoryTransformation($array)
 {
     $a_inventory = array();
     $thisc = new self();
     // * INFO
     $array_tmp = $thisc->addValues($array['INFO'], array('NAME' => 'name', 'SERIAL' => 'serial', 'ID' => 'id', 'MANUFACTURER' => 'manufacturers_id', 'LOCATION' => 'locations_id', 'MODEL' => 'printermodels_id', 'MEMORY' => 'memory_size'));
     $array_tmp['is_dynamic'] = 1;
     $array_tmp['have_ethernet'] = 1;
     $a_inventory['Printer'] = $array_tmp;
     $a_inventory['itemtype'] = 'Printer';
     $array_tmp = $thisc->addValues($array['INFO'], array('COMMENTS' => 'sysdescr'));
     $array_tmp['last_fusioninventory_update'] = date('Y-m-d H:i:s');
     $a_inventory['PluginFusioninventoryPrinter'] = $array_tmp;
     // * PORTS
     $a_inventory['networkport'] = array();
     if (isset($array['PORTS'])) {
         foreach ($array['PORTS']['PORT'] as $a_port) {
             if (!isset($a_port['IFNUMBER'])) {
                 $array_tmp = $thisc->addValues($a_port, array('IFNAME' => 'name', 'IFNUMBER' => 'logical_number', 'MAC' => 'mac', 'IP' => 'ip', 'IFTYPE' => 'iftype'));
                 $a_inventory['networkport'][$a_port['IFNUMBER']] = $array_tmp;
             }
         }
     }
     // CARTRIDGES
     $a_inventory['cartridge'] = array();
     if (isset($array['CARTRIDGES'])) {
         $pfMapping = new PluginFusioninventoryMapping();
         foreach ($array['CARTRIDGES'] as $name => $value) {
             $plugin_fusioninventory_mappings = $pfMapping->get("Printer", strtolower($name));
             if ($plugin_fusioninventory_mappings) {
                 if (strstr($value, 'pages')) {
                     // 30pages
                     $value = str_replace('pages', '', $value);
                     $value = 0 - $value;
                 } else {
                     if ($value == '') {
                         // no info
                         // nothing to do
                     } else {
                         if (is_numeric($value)) {
                             // percentage
                             // nothing to do
                         } else {
                             if ($value == 'OK') {
                                 // state type 'OK'
                                 $value = 100000;
                             } else {
                                 // special cases
                                 $value = '';
                             }
                         }
                     }
                 }
                 if ($value != '') {
                     $a_inventory['cartridge'][$plugin_fusioninventory_mappings['id']] = $value;
                 }
             }
         }
     }
     // * PAGESCOUNTER
     $a_inventory['pagecounters'] = array();
     if (isset($array['PAGECOUNTERS'])) {
         $array_tmp = $thisc->addValues($array['PAGECOUNTERS'], array('TOTAL' => 'pages_total', 'BLACK' => 'pages_n_b', 'COLOR' => 'pages_color', 'RECTOVERSO' => 'pages_recto_verso', 'SCANNED' => 'scanned', 'PRINTTOTAL' => 'pages_total_print', 'PRINTBLACK' => 'pages_n_b_print', 'PRINTCOLOR' => 'pages_color_print', 'COPYTOTAL' => 'pages_total_copy', 'COPYBLACK' => 'pages_n_b_copy', 'COPYCOLOR' => 'pages_color_copy', 'FAXTOTAL' => 'pages_total_fax'));
         $a_inventory['pagecounters'] = $array_tmp;
     }
     return $a_inventory;
 }
 /**
  * @test
  */
 public function PrinterCartridge()
 {
     global $DB;
     $DB->connect();
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $a_printer = array();
     $a_printer['INFO'] = array('ID' => '54', 'NAME' => 'ARC12-B09-N', 'TYPE' => 'PRINTER');
     $a_printer['CARTRIDGES'] = array('CARTRIDGEBLACK' => 90, 'CARTRIDGECYAN' => '', 'CARTRIDGEMAGENTA' => 'OK', 'CARTRIDGEYELLOW' => '30pages');
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $pfMapping = new PluginFusioninventoryMapping();
     $a_return = $pfFormatconvert->printerInventoryTransformation($a_printer);
     $a_reference = array();
     $a_id = $pfMapping->get("Printer", strtolower('CARTRIDGEBLACK'));
     $a_reference[$a_id['id']] = 90;
     $a_id = $pfMapping->get("Printer", strtolower('CARTRIDGEMAGENTA'));
     $a_reference[$a_id['id']] = 100000;
     $a_id = $pfMapping->get("Printer", strtolower('CARTRIDGEYELLOW'));
     $a_reference[$a_id['id']] = -30;
     $this->assertEquals($a_reference, $a_return['cartridge']);
 }
예제 #7
0
function plugin_fusioninventory_addWhere($link, $nott, $type, $id, $val)
{
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$id]["table"];
    $field = $searchopt[$id]["field"];
    switch ($type) {
        case 'PluginFusioninventoryTaskjob':
            /*
             * WARNING: The following is some minor hack in order to select a range of ids.
             *
             * More precisely, when using the ID filter, you can now put IDs separated by commas.
             * This is used by the DeployPackage class when it comes to check running tasks on some
             * packages.
             */
            if ($table == 'glpi_plugin_fusioninventory_tasks') {
                if ($field == 'id') {
                    //check if this range is numeric
                    $ids = explode(',', $val);
                    foreach ($ids as $k => $i) {
                        if (!is_numeric($i)) {
                            unset($ids[$k]);
                        }
                    }
                    if (count($ids) >= 1) {
                        return $link . " `{$table}`.`id` IN (" . implode(',', $ids) . ")";
                    } else {
                        return "";
                    }
                } elseif ($field == 'name') {
                    $val = stripslashes($val);
                    //decode a json query to match task names in taskjobs list
                    $names = json_decode($val);
                    if ($names !== NULL && is_array($names)) {
                        $names = array_map(create_function('$a', 'return "\\"".$a."\\"";'), $names);
                        return $link . " `{$table}`.`name` IN (" . implode(',', $names) . ")";
                    } else {
                        return "";
                    }
                }
            }
            break;
        case 'PluginFusioninventoryAgent':
            $pfAgentmodule = new PluginFusioninventoryAgentmodule();
            $a_modules = $pfAgentmodule->find();
            foreach ($a_modules as $data) {
                if ($table . "." . $field == "glpi_plugin_fusioninventory_agentmodules." . $data['modulename']) {
                    if ($data['exceptions'] != "[]" and $data['exceptions'] != "") {
                        $a_exceptions = importArrayFromDB($data['exceptions']);
                        $current_id = current($a_exceptions);
                        $in = "(";
                        foreach ($a_exceptions as $agent_id) {
                            $in .= $agent_id . ", ";
                        }
                        $in .= ")";
                        $in = str_replace(", )", ")", $in);
                        if ($val != $data['is_active']) {
                            return $link . " (FUSION_" . $data['modulename'] . ".`exceptions` LIKE '%\"" . $current_id . "\"%' ) AND `glpi_plugin_fusioninventory_agents`.`id` IN " . $in . " ";
                        } else {
                            return $link . " `glpi_plugin_fusioninventory_agents`.`id` NOT IN " . $in . " ";
                        }
                    } else {
                        if ($val != $data['is_active']) {
                            return $link . " (FUSION_" . $data['modulename'] . ".`is_active`!='" . $data['is_active'] . "') ";
                        } else {
                            return $link . " (FUSION_" . $data['modulename'] . ".`is_active`='" . $data['is_active'] . "') ";
                        }
                    }
                }
            }
            break;
        case 'PluginFusioninventoryTaskjoblog':
            if ($field == 'uniqid') {
                return $link . " (`" . $table . "`.`uniqid`='" . $val . "') ";
            }
            break;
            // * Computer List (front/computer.php)
        // * Computer List (front/computer.php)
        case 'Computer':
            switch ($table . "." . $field) {
                // ** FusionInventory - switch
                case "glpi_plugin_fusioninventory_networkequipments.name":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR glpi_networkequipments.id IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR glpi_networkequipments.id IS NOT NULL";
                        }
                    }
                    return $link . " (glpi_networkequipments.id  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - switch port
                // ** FusionInventory - switch port
                case "glpi_plugin_fusioninventory_networkports.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR FUSIONINVENTORY_22.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR FUSIONINVENTORY_22.name IS NOT NULL";
                        }
                    }
                    return $link . " (FUSIONINVENTORY_22.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
            }
            $a_agent_modules = PluginFusioninventoryAgentmodule::getModules();
            foreach ($a_agent_modules as $module) {
                if ($table . "." . $field == 'glpi_plugin_fusioninventory_agentmodules.' . $module) {
                    $pfAgentmodule = new PluginFusioninventoryAgentmodule();
                    $a_modules = $pfAgentmodule->find("`modulename`='" . $module . "'");
                    $data = current($a_modules);
                    if ($data['exceptions'] != "[]" and $data['exceptions'] != "") {
                        $a_exceptions = importArrayFromDB($data['exceptions']);
                        $current_id = current($a_exceptions);
                        $in = "(";
                        foreach ($a_exceptions as $agent_id) {
                            $in .= $agent_id . ", ";
                        }
                        $in .= ")";
                        $in = str_replace(", )", ")", $in);
                        if ($val != $data['is_active']) {
                            return $link . " (FUSION_" . $module . ".`exceptions` LIKE '%\"" . $current_id . "\"%' ) AND `agent" . strtolower($module) . "`.`id` IN " . $in . " ";
                        } else {
                            return $link . " `agent" . strtolower($module) . "`.`id` NOT IN " . $in . " ";
                        }
                    } else {
                        if ($val != $data['is_active']) {
                            return $link . " (FUSION_" . $module . ".`is_active`!='" . $data['is_active'] . "') ";
                        } else {
                            return $link . " (FUSION_" . $module . ".`is_active`='" . $data['is_active'] . "') ";
                        }
                    }
                }
            }
            break;
            // * Networking List (front/networking.php)
        // * Networking List (front/networking.php)
        case 'NetworkEquipment':
            switch ($table . "." . $field) {
                // ** FusionInventory - last inventory
                case "glpi_plugin_fusioninventory_networkequipments.networkequipments_id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.last_fusinvsnmp_update IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.last_fusinvsnmp_update IS NOT NULL";
                        }
                    }
                    return $link . " ({$table}.last_fusinvsnmp_update  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - SNMP authentification
                // ** FusionInventory - SNMP authentification
                case "glpi_plugin_fusioninventory_networkequipments.plugin_fusinvsnmp_snmpauths_id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR glpi_plugin_fusioninventory_configsecurities.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR glpi_plugin_fusioninventory_configsecurities.name IS NOT NULL";
                        }
                    }
                    return $link . " (glpi_plugin_fusioninventory_configsecurities.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - CPU
                // ** FusionInventory - CPU
                case "glpi_plugin_fusioninventory_networkequipments.cpu":
                    break;
            }
            break;
            // * Printer List (front/printer.php)
        // * Printer List (front/printer.php)
        case 'Printer':
            switch ($table . "." . $field) {
                // ** FusionInventory - last inventory
                case "glpi_plugin_fusioninventory_printers.printers_id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.last_fusinvsnmp_update IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.last_fusinvsnmp_update IS NOT NULL";
                        }
                    }
                    return $link . " ({$table}.last_fusinvsnmp_update  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - SNMP authentification
                // ** FusionInventory - SNMP authentification
                case "glpi_plugin_fusioninventory_networkequipments.plugin_fusinvsnmp_snmpauths_id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.name IS NOT NULL";
                        }
                    }
                    return $link . " ({$table}.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - switch
                // ** FusionInventory - switch
                case "glpi_plugin_fusioninventory_networkequipments.name":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR glpi_networkequipments.id IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR glpi_networkequipments.id IS NOT NULL";
                        }
                    }
                    return $link . " (glpi_networkequipments.id  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - switch port
                // ** FusionInventory - switch port
                case "glpi_plugin_fusioninventory_networkports.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR FUSIONINVENTORY_22.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR FUSIONINVENTORY_22.name IS NOT NULL";
                        }
                    }
                    return $link . " (FUSIONINVENTORY_22.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
            }
            break;
            // * Unknown mac addresses connectd on switch - report
            // (plugins/fusinvsnmp/report/unknown_mac.php)
        // * Unknown mac addresses connectd on switch - report
        // (plugins/fusinvsnmp/report/unknown_mac.php)
        case 'PluginFusioninventoryUnmanaged':
            switch ($table . "." . $field) {
                // ** FusionInventory - switch
                case "glpi_plugin_fusioninventory_networkequipments.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR FUSIONINVENTORY_12.items_id IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR FUSIONINVENTORY_12.items_id IS NOT NULL";
                        }
                    }
                    return $link . " (FUSIONINVENTORY_13.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
                    // ** FusionInventory - switch port
                // ** FusionInventory - switch port
                case "glpi_plugin_fusioninventory_networkports.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR FUSIONINVENTORY_22.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR FUSIONINVENTORY_22.name IS NOT NULL";
                        }
                    }
                    return $link . " (FUSIONINVENTORY_22.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
            }
            break;
            // * Ports date connection - report (plugins/fusinvsnmp/report/ports_date_connections.php)
        // * Ports date connection - report (plugins/fusinvsnmp/report/ports_date_connections.php)
        case 'PluginFusioninventoryNetworkPort':
            switch ($table . "." . $field) {
                // ** Name and link of networking device (switch)
                case "glpi_plugin_fusioninventory_networkports.id":
                    break;
                    // ** Name and link of port of networking device (port of switch)
                // ** Name and link of port of networking device (port of switch)
                case "glpi_plugin_fusioninventory_networkports.networkports_id":
                    break;
                    // ** Location of switch
                // ** Location of switch
                case "glpi_locations.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR glpi_networkequipments.location IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR glpi_networkequipments.location IS NOT NULL";
                        }
                    }
                    if ($val == "0") {
                        return $link . " (glpi_networkequipments.location >= -1 ) ";
                    }
                    return $link . " (glpi_networkequipments.location = '" . $val . "' {$ADD} ) ";
                    break;
                case "glpi_plugin_fusioninventory_networkports.lastup":
                    $ADD = "";
                    //$val = str_replace("&lt;", ">", $val);
                    //$val = str_replace("\\", "", $val);
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.{$field} IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.{$field} IS NOT NULL";
                        }
                    }
                    return $link . " ({$table}.{$field} {$val} {$ADD} ) ";
                    break;
            }
            break;
            // * range IP list (plugins/fusinvsnmp/front/iprange.php)
        // * range IP list (plugins/fusinvsnmp/front/iprange.php)
        case 'PluginFusioninventoryIPRange':
            switch ($table . "." . $field) {
                // ** Name of range IP and link to form
                case "glpi_plugin_fusioninventory_ipranges.name":
                    break;
                    // ** Agent name associed to IP range and link to agent form
                // ** Agent name associed to IP range and link to agent form
                case "glpi_plugin_fusinvsnmp_agents.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.name IS NOT NULL";
                        }
                    }
                    return $link . " ({$table}.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
            }
            switch ($table . "." . $field) {
                case "glpi_plugin_fusinvsnmp_agents.plugin_fusinvsnmp_agents_id_query":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.name IS NULL";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.name IS NOT NULL";
                        }
                    }
                    return $link . " (gpta.name  LIKE '%" . $val . "%' {$ADD} ) ";
                    break;
            }
            break;
        case 'PluginFusioninventoryNetworkPortLog':
            switch ($table . "." . $field) {
                // ** Display switch and Port
                case "glpi_networkports.id":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.id IS NULL ";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.id IS NOT NULL ";
                        }
                    }
                    return $link . " ({$table}.id = '" . $val . "' {$ADD} ) ";
                    break;
                    // ** Display GLPI field of device
                // ** Display GLPI field of device
                case "glpi_plugin_fusinvsnmp_networkportlogs.field":
                    $ADD = "";
                    if ($nott == "0" && $val == "NULL") {
                        $ADD = " OR {$table}.{$field} IS NULL ";
                    } else {
                        if ($nott == "1" && $val == "NULL") {
                            $ADD = " OR {$table}.{$field} IS NOT NULL ";
                        }
                    }
                    if (!empty($val)) {
                        $map = new PluginFusioninventoryMapping();
                        $mapfields = $map->get('NetworkEquipment', $val);
                        if ($mapfields != FALSE) {
                            $val = $mapfields['tablefields'];
                        } else {
                            $val = '';
                        }
                    }
                    return $link . " ({$table}.{$field} = '" . addslashes($val) . "' {$ADD} ) ";
                    break;
            }
            break;
    }
    return "";
}
 function showForm($options = array())
 {
     global $DB;
     $mapping = new PluginFusioninventoryMapping();
     echo "<form name='form' method='post' action='" . $options['target'] . "'>";
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo __('History configuration', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>";
     echo __('List of fields for which to keep history', 'fusioninventory');
     echo "</th>";
     echo "<th>";
     echo __('Retention in days', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     $days = array();
     $days[-1] = __('Never');
     $days[0] = __('Always');
     for ($i = 1; $i < 366; $i++) {
         $days[$i] = "{$i}";
     }
     $query = "SELECT `" . $this->getTable() . "`.`id`, `locale`, `days`, `itemtype`, `name`\n                FROM `" . $this->getTable() . "`, `glpi_plugin_fusioninventory_mappings`\n                WHERE `" . $this->getTable() . "`.`plugin_fusioninventory_mappings_id`=\n                         `glpi_plugin_fusioninventory_mappings`.`id`\n                ORDER BY `itemtype`, `name`;";
     $result = $DB->query($query);
     if ($result) {
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1'>";
             echo "<td align='left'>";
             echo $mapping->getTranslation($data);
             echo "</td>";
             echo "<td align='center'>";
             Dropdown::showFromArray('field-' . $data['id'], $days, array('value' => $data['days']));
             echo "</td>";
             echo "</tr>";
         }
     }
     if (Session::haveRight('plugin_fusioninventory_configuration', UPDATE)) {
         echo "<tr class='tab_bg_2'><td align='center' colspan='4'>\n               <input type='hidden' name='tabs' value='history'/>\n               <input class='submit' type='submit' name='update'\n                      value='" . __('Update') . "'></td></tr>";
     }
     echo "</table>";
     echo "<br/>";
     echo "<table class='tab_cadre_fixe' cellpadding='2'>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='1' class='center' height='30'>";
     if (Session::haveRight('plugin_fusioninventory_configuration', UPDATE)) {
         echo "<input type='submit' class=\"submit\" name='Clean_history' " . "value='" . __('Clean') . "' >";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table></div>";
     Html::closeForm();
     return TRUE;
 }
 function createModel($xml, $message)
 {
     global $DB;
     $pfMapping = new PluginFusioninventoryMapping();
     $pfModel = new PluginFusioninventorySnmpmodel();
     $type = (string) $xml->type;
     switch ($type) {
         case '1':
             $type = "Computer";
             break;
         case '2':
             $type = "NetworkEquipment";
             break;
         case '3':
             $type = "Printer";
             break;
     }
     $input = array();
     $input['name'] = (string) $xml->name;
     $input['itemtype'] = $type;
     $input['discovery_key'] = (string) $xml->key;
     //$input['comment']       = Toolbox::clean_cross_side_scripting_deep(
     //                            Toolbox::addslashes_deep((string)$xml->comments));
     $plugin_fusioninventory_snmpmodels_id = $pfModel->add($input);
     $a_devices = array();
     if (isset($xml->devices) && isset($xml->devices->sysdescr)) {
         foreach ($xml->devices->sysdescr as $child) {
             $a_devices[] = (string) $child;
         }
     }
     $pfSnmpmodeldevice = new PluginFusioninventorySnmpmodeldevice();
     $pfSnmpmodeldevice->updateDevicesForModel($plugin_fusioninventory_snmpmodels_id, $a_devices);
     foreach ($xml->oidlist->oidobject as $child) {
         $plugin_fusioninventory_snmpmodelmibobjects_id = 0;
         $plugin_fusioninventory_snmpmodelmiboids_id = 0;
         $oid_port_counter = 0;
         $oid_port_dyn = 0;
         $mapping_type = '';
         $mapping_name = '';
         $vlan = 0;
         $is_active = 1;
         $mappings_id = 0;
         if (isset($child->object)) {
             $plugin_fusioninventory_snmpmodelmibobjects_id = Dropdown::importExternal("PluginFusioninventorySnmpmodelMibObject", $child->object);
         }
         if (isset($child->oid)) {
             $plugin_fusioninventory_snmpmodelmiboids_id = Dropdown::importExternal("PluginFusioninventorySnmpmodelMibOid", $child->oid);
         }
         if (isset($child->portcounter)) {
             $oid_port_counter = $child->portcounter;
         }
         if (isset($child->dynamicport)) {
             $oid_port_dyn = $child->dynamicport;
         }
         if (isset($child->mapping_type)) {
             $mapping_type = '';
             switch ($child->mapping_type) {
                 case '1':
                     $mapping_type = "Computer";
                     break;
                 case '2':
                     $mapping_type = "NetworkEquipment";
                     break;
                 case '3':
                     $mapping_type = "Printer";
                     break;
             }
             if ($mapping_type == '') {
                 $mapping_type = $child->mapping_type;
             }
         }
         if (isset($child->mapping_name)) {
             $mapping_name = $child->mapping_name;
         }
         if (isset($child->vlan)) {
             $vlan = $child->vlan;
         }
         if (isset($child->activation)) {
             $is_active = $child->activation;
         }
         if (isset($mapping_type) and isset($mapping_name)) {
             $a_mappings = $pfMapping->get($mapping_type, $mapping_name);
             $mappings_id = $a_mappings['id'];
         }
         if (!isset($mappings_id) or empty($mappings_id)) {
             $mappings_id = '0';
         }
         $query = "INSERT INTO `glpi_plugin_fusioninventory_snmpmodelmibs`\n             (\n                `plugin_fusioninventory_snmpmodels_id`,\n                `plugin_fusioninventory_snmpmodelmiboids_id`,\n                `plugin_fusioninventory_snmpmodelmibobjects_id`,\n                `oid_port_counter`,\n                `oid_port_dyn`,\n                `plugin_fusioninventory_mappings_id`,\n                `vlan`,\n                `is_active`\n             )\n             VALUES(\n                '" . $plugin_fusioninventory_snmpmodels_id . "',\n                '" . $plugin_fusioninventory_snmpmodelmiboids_id . "',\n                '" . $plugin_fusioninventory_snmpmodelmibobjects_id . "',\n                '" . $oid_port_counter . "',\n                '" . $oid_port_dyn . "',\n                '" . $mappings_id . "',\n                '" . $vlan . "',\n                '" . $is_active . "'\n             );";
         $DB->query($query);
     }
 }