You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: David DURIEUX
// Purpose of file:
// ----------------------------------------------------------------------
$NEEDED_ITEMS = array("printer");
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
PluginFusioninventoryAuth::checkRight("snmp_printers", "r");
if (isset($_POST['update']) && isset($_POST['ID'])) {
    PluginFusioninventoryAuth::checkRight("snmp_printers", "w");
    $plugin_fusioninventory_printers = new PluginFusioninventoryPrinters();
    $_POST['FK_printers'] = $_POST['ID'];
    unset($_POST['ID']);
    $query = "SELECT * \n             FROM `glpi_plugin_fusioninventory_printers`\n             WHERE `FK_printers`='" . $_POST['FK_printers'] . "' ";
    $result = $DB->query($query);
    $data = $DB->fetch_assoc($result);
    $_POST['ID'] = $data['ID'];
    $plugin_fusioninventory_printers->update($_POST);
} else {
    if (isset($_POST["GetRightModel"]) && isset($_POST['ID'])) {
        $plugin_fusioninventory_model_infos = new PluginFusioninventoryModelInfos();
        $plugin_fusioninventory_model_infos->getrightmodel($_POST['ID'], PRINTER_TYPE);
    }
}
if (isset($_POST['update_cartridges']) && isset($_POST['ID'])) {
    PluginFusioninventoryAuth::checkRight("snmp_printers", "w");
 function showFormPrinter_pagescounter($target, $ID)
 {
     global $DB, $CFG_GLPI, $LANG, $FUSIONINVENTORY_MAPPING;
     $plugin_fusioninventory_printers = new PluginFusioninventoryPrinters();
     $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP();
     $this->ID = $ID;
     $query = "SELECT * \n                FROM `glpi_plugin_fusioninventory_printers`\n                WHERE `FK_printers`=" . $ID . " ";
     $result = $DB->query($query);
     $data = $DB->fetch_assoc($result);
     switch ($data['frequence_days']) {
         case 1:
             $frequence = "day";
             break;
         case 7:
             $frequence = "week";
             break;
         case 30:
             $frequence = "month";
             break;
         case 365:
             $frequence = "year";
             break;
     }
     // get infos to get visible or not the counters
     $snmp_model_ID = $plugin_fusioninventory_snmp->GetSNMPModel($ID, PRINTER_TYPE);
     // ** Get link OID fields
     $Array_Object_TypeNameConstant = $plugin_fusioninventory_snmp->GetLinkOidToFields($ID, PRINTER_TYPE);
     $mapping_name = array();
     foreach ($Array_Object_TypeNameConstant as $object => $mapping_type_name) {
         //$explode = explode("||", $mapping_type_name);
         $mapping_name[$mapping_type_name] = "1";
     }
     // Form pages counter
     //		echo "<br>";
     echo "<div align='center'><form method='post' name='snmp_form' id='snmp_form'\n                 action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG["cartridges"][39];
     echo "</th>";
     echo "</tr>";
     if (isset($mapping_name['pagecountertotalpages']) and $mapping_name['pagecountertotalpages'] == "1") {
         // Total page counter
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $LANG['plugin_fusioninventory']["mapping"][128];
         echo "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         // calendrier
         if (!isset($_SESSION["datetotalpages"])) {
             $_SESSION["datetotalpages"] = "";
         }
         PluginFusioninventory::printer_calendar($_SESSION["datetotalpages"], "datetotalpages", $target);
         // fin calendrier
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         $Array = $plugin_fusioninventory_printers->getPagesCount($ID, $frequence, $_SESSION["datetotalpages"], 'pages_total');
         echo "<table class='tab_cadre' cellpadding='5' width='900'>";
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["common"][27], $Array['dates'], 1);
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["printers"][31], $Array['count']);
         $ecart = $plugin_fusioninventory_printers->counter_page_arrayLine_display_difference("ecart", $Array['count'], $Array['dates']);
         echo "</table>";
         $plugin_fusioninventory_printers->graphBy($ecart, $LANG['plugin_fusioninventory']["mapping"][128], $LANG['plugin_fusioninventory']["printer"][0], 1, $frequence);
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['pagecounterblackpages']) and $mapping_name['pagecounterblackpages'] == "1") {
         // ** Black & white page counter
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $LANG['plugin_fusioninventory']["mapping"][129];
         echo "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         if (!isset($_SESSION["dateblackpages"])) {
             $_SESSION["dateblackpages"] = "";
         }
         PluginFusioninventory::printer_calendar($_SESSION["dateblackpages"], "dateblackpages", $target);
         // fin calendrier
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         $Array = $plugin_fusioninventory_printers->getPagesCount($ID, $frequence, $_SESSION["dateblackpages"], 'pages_n_b');
         echo "<table class='tab_cadre' cellpadding='5' width='900'>";
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["common"][27], $Array['dates'], 1);
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["printers"][31], $Array['count']);
         $ecart = $plugin_fusioninventory_printers->counter_page_arrayLine_display_difference("ecart", $Array['count'], $Array['dates']);
         echo "</table>";
         $plugin_fusioninventory_printers->graphBy($ecart, $LANG['plugin_fusioninventory']["mapping"][129], $LANG['plugin_fusioninventory']["printer"][0], 1, $frequence);
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['pagecountercolorpages']) and $mapping_name['pagecountercolorpages'] == "1") {
         // ** Color page counter
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $LANG['plugin_fusioninventory']["mapping"][130];
         echo "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         if (!isset($_SESSION["datecolorpages"])) {
             $_SESSION["datecolorpages"] = "";
         }
         PluginFusioninventory::printer_calendar($_SESSION["datecolorpages"], "datecolorpages", $target);
         // fin calendrier
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         $Array = $plugin_fusioninventory_printers->getPagesCount($ID, $frequence, $_SESSION["datecolorpages"], 'pages_color');
         echo "<table class='tab_cadre' cellpadding='5' width='900'>";
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["common"][27], $Array['dates'], 1);
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["printers"][31], $Array['count']);
         $ecart = $plugin_fusioninventory_printers->counter_page_arrayLine_display_difference("ecart", $Array['count'], $Array['dates']);
         echo "</table>";
         $plugin_fusioninventory_printers->graphBy($ecart, $LANG['plugin_fusioninventory']["mapping"][130], $LANG['plugin_fusioninventory']["printer"][0], 1, $frequence);
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['pagecounterrectoversopages']) and $mapping_name['pagecounterrectoversopages'] == "1") {
         // ** Recto/Verso page counter
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $LANG['plugin_fusioninventory']["mapping"][154];
         echo "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         if (!isset($_SESSION["daterectoversopages"])) {
             $_SESSION["daterectoversopages"] = "";
         }
         PluginFusioninventory::printer_calendar($_SESSION["daterectoversopages"], "daterectoversopages", $target);
         // fin calendrier
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         $Array = $plugin_fusioninventory_printers->getPagesCount($ID, $frequence, $_SESSION["daterectoversopages"], 'pages_recto_verso');
         echo "<table class='tab_cadre' cellpadding='5' width='900'>";
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["common"][27], $Array['dates'], 1);
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["printers"][31], $Array['count']);
         $ecart = $plugin_fusioninventory_printers->counter_page_arrayLine_display_difference("ecart", $Array['count'], $Array['dates']);
         echo "</table>";
         $plugin_fusioninventory_printers->graphBy($ecart, $LANG['plugin_fusioninventory']["mapping"][154], $LANG['plugin_fusioninventory']["printer"][0], 1, $frequence);
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['pagecounterscannedpages']) and $mapping_name['pagecounterscannedpages'] == "1") {
         // ** Scanned page counter
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $LANG['plugin_fusioninventory']["mapping"][155];
         echo "</th>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         if (!isset($_SESSION["datescannedpages"])) {
             $_SESSION["datescannedpages"] = "";
         }
         PluginFusioninventory::printer_calendar($_SESSION["datescannedpages"], "datescannedpages", $target);
         // fin calendrier
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='3'>";
         $Array = $plugin_fusioninventory_printers->getPagesCount($ID, $frequence, $_SESSION["datescannedpages"], 'scanned');
         echo "<table class='tab_cadre' cellpadding='5' width='900'>";
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["common"][27], $Array['dates'], 1);
         $plugin_fusioninventory_printers->counter_page_arrayLine_display($LANG["printers"][31], $Array['count']);
         $ecart = $plugin_fusioninventory_printers->counter_page_arrayLine_display_difference("ecart", $Array['count'], $Array['dates']);
         echo "</table>";
         $plugin_fusioninventory_printers->graphBy($ecart, $LANG['plugin_fusioninventory']["mapping"][155], $LANG['plugin_fusioninventory']["printer"][0], 1, $frequence);
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
 }
 static function clean_db()
 {
     global $DB;
     $ptp = new PluginFusioninventoryPort();
     $pti = new PluginFusioninventoryIfaddr();
     $ptn = new PluginFusioninventoryNetworking2();
     $ptpr = new PluginFusioninventoryPrinters();
     $ptpc = new PluginFusioninventoryPrintersCartridges();
     $ptph = new PluginFusioninventoryPrintersHistory();
     // * Clean glpi_plugin_fusioninventory_networking_ports
     $query_select = "SELECT `glpi_plugin_fusioninventory_networking_ports`.`ID`\n                       FROM `glpi_plugin_fusioninventory_networking_ports`\n                             LEFT JOIN `glpi_networking_ports`\n                                       ON `glpi_networking_ports`.`ID` = `FK_networking_ports`\n                             LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `on_device`\n                       WHERE `glpi_networking`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $ptp->deleteFromDB($data["ID"], 1);
     }
     // * Clean glpi_plugin_fusioninventory_networking_ifaddr
     $query_select = "SELECT `glpi_plugin_fusioninventory_networking_ifaddr`.`ID`\n                       FROM `glpi_plugin_fusioninventory_networking_ifaddr`\n                             LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `FK_networking`\n                       WHERE `glpi_networking`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $pti->deleteFromDB($data["ID"], 1);
     }
     // * Clean glpi_plugin_fusioninventory_networking
     $query_select = "SELECT `glpi_plugin_fusioninventory_networking`.`ID`\n                       FROM `glpi_plugin_fusioninventory_networking`\n                             LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `FK_networking`\n                       WHERE `glpi_networking`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $ptn->deleteFromDB($data["ID"], 1);
     }
     // * Clean glpi_plugin_fusioninventory_printers
     $query_select = "SELECT `glpi_plugin_fusioninventory_printers`.`ID`\n                       FROM `glpi_plugin_fusioninventory_printers`\n                             LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n                       WHERE `glpi_printers`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $ptpr->deleteFromDB($data["ID"], 1);
     }
     // * Clean glpi_plugin_fusioninventory_printers_cartridges
     $query_select = "SELECT `glpi_plugin_fusioninventory_printers_cartridges`.`ID`\n                       FROM `glpi_plugin_fusioninventory_printers_cartridges`\n                             LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n                       WHERE `glpi_printers`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $ptpc->deleteFromDB($data["ID"], 1);
     }
     // * Clean glpi_plugin_fusioninventory_printers_history
     $query_select = "SELECT `glpi_plugin_fusioninventory_printers_history`.`ID`\n                       FROM `glpi_plugin_fusioninventory_printers_history`\n                             LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n                       WHERE `glpi_printers`.`ID` IS NULL";
     $result = $DB->query($query_select);
     while ($data = $DB->fetch_array($result)) {
         $ptph->deleteFromDB($data["ID"], 1);
     }
 }
Esempio n. 4
0
function plugin_headings_fusioninventory_printerInfo($type, $ID)
{
    include_once GLPI_ROOT . "/inc/stat.function.php";
    $plugin_fusioninventory_printers = new PluginFusioninventoryPrinters();
    $plugin_fusioninventory_printers->showFormPrinter(GLPI_ROOT . '/plugins/fusioninventory/front/printer_info.form.php', $ID);
    //	$plugin_fusioninventory_printers->showFormPrinter_pagescounter(GLPI_ROOT . '/plugins/fusioninventory/front/printer_info.form.php', $ID);
    echo '<div id="overDivYFix" STYLE="visibility:hidden">fusioninventory_1</div>';
    $plugin_fusioninventory_printers->showFormPrinter_graph(GLPI_ROOT . '/plugins/fusioninventory/front/printer_info.form.php', $ID);
}