function showReport($params)
 {
     global $CFG_GLPI;
     $PluginAddressingReport = new PluginAddressingReport();
     // Default values of parameters
     $default_values["start"] = $start = 0;
     $default_values["id"] = $id = 0;
     $default_values["export"] = $export = false;
     foreach ($default_values as $key => $val) {
         if (isset($params[$key])) {
             ${$key} = $params[$key];
         }
     }
     if ($this->getFromDB($id)) {
         $result = $this->compute($start);
         $nbipf = 0;
         // ip libres
         $nbipr = 0;
         // ip reservees
         $nbipt = 0;
         // ip trouvees
         $nbipd = 0;
         // doublons
         foreach ($result as $ip => $lines) {
             if (count($lines)) {
                 if (count($lines) > 1) {
                     $nbipd++;
                 }
                 if (isset($lines[0]['pname']) && strstr($lines[0]['pname'], "reserv")) {
                     $nbipr++;
                 }
                 $nbipt++;
             } else {
                 $nbipf++;
             }
         }
         ////title
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 left'>";
         echo "<td>";
         if ($this->fields['free_ip']) {
             echo __('Number of free ip', 'addressing') . " " . $nbipf . "<br>";
         }
         if ($this->fields['reserved_ip']) {
             echo __('Number of reserved ip', 'addressing') . " " . $nbipr . "<br>";
         }
         if ($this->fields['alloted_ip']) {
             echo __('Number of assigned ip (no doubles)', 'addressing') . " " . $nbipt . "<br>";
         }
         if ($this->fields['double_ip']) {
             echo __('Doubles', 'addressing') . " " . $nbipd . "<br>";
         }
         echo "</td>";
         echo "<td>";
         if ($this->fields['double_ip']) {
             echo "<span class='plugin_addressing_ip_double'>" . __('Red row', 'addressing') . "</span> - " . __('Same Ip', 'addressing') . "<br>";
         }
         if (isset($this->fields['use_ping']) && $this->fields['use_ping']) {
             echo __('Ping free Ip', 'addressing') . "<br>";
             echo "<span class='plugin_addressing_ping_off'>" . __('Ping: got a response - used Ip', 'addressing') . "</span><br>";
             echo "<span class='plugin_addressing_ping_on'>" . __('Ping: no response - free Ip', 'addressing') . "</span>";
         } else {
             echo "<span class='plugin_addressing_ip_free'>" . __('Blue row', 'addressing') . "</span> - " . __('Free Ip', 'addressing') . "<br>";
         }
         echo "</td></tr>";
         echo "<tr><td colspan='2' align='center'>";
         echo "<a href='./report.form.php?id=" . $this->getID() . "&export=true'>" . __('Export') . "</a>";
         echo "</td></tr>";
         echo "</table>";
         echo "</div>";
         $numrows = 1 + ip2long($this->fields['end_ip']) - ip2long($this->fields['begin_ip']);
         if (strpos($_SERVER['PHP_SELF'], "report.form.php")) {
             Html::printPager($start, $numrows, $_SERVER['PHP_SELF'], "start={$start}&amp;id=" . $id, 'PluginAddressingReport');
         } else {
             Html::printAjaxPager("", $start, $numrows);
         }
         //////////////////////////liste ips////////////////////////////////////////////////////////////
         $ping_response = $PluginAddressingReport->displayReport($result, $this);
         if ($this->fields['use_ping']) {
             $total_realfreeip = $nbipf - $ping_response;
             echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2 center'>";
             echo "<td>";
             echo __('Real free Ip (Ping=KO)', 'addressing') . " " . $total_realfreeip;
             echo "</td></tr>";
             echo "</table>";
         }
         echo "</div>";
     } else {
         echo "<div class='center'>" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='warning'><br><br><b>" . __('Problem detected with the IP Range', 'addressing') . "</b></div>";
     }
 }
Esempio n. 2
0
function plugin_addressing_dynamicReport($parm)
{
    $PluginAddressingAddressing = new PluginAddressingAddressing();
    $PluginAddressingReport = new PluginAddressingReport();
    if ($parm["item_type"] == 'PluginAddressingReport' && isset($parm["id"]) && isset($parm["display_type"]) && $PluginAddressingAddressing->getFromDB($parm["id"])) {
        $result = $PluginAddressingAddressing->compute($parm["start"]);
        $PluginAddressingReport->display($result, $PluginAddressingAddressing);
        return true;
    }
    // Return false if no specific display is done, then use standard display
    return false;
}