function showSyntheseReport($componentscatalogs_id) {
      global $CFG_GLPI;

      if (!isset($_SESSION['glpi_plugin_monitoring']['synthese'])) {
         $_SESSION['glpi_plugin_monitoring']['synthese'] = array();
      }
      if (!isset($_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id])) {
         $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id] = array();
      }
      $sess = $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id];
      $pmComponentscatalog_Component = new PluginMonitoringComponentscatalog_Component();
      $pmComponent = new PluginMonitoringComponent();
      $a_options = array();

      $this->getFromDB($componentscatalogs_id);

      echo "<form name='form' method='post'
         action='".$CFG_GLPI['root_doc']."/plugins/monitoring/front/report_componentscatalog.form.php'>";

      echo "<table class='tab_cadre_fixe'>";
      echo '<tr class="tab_bg_1">';
      echo '<th colspan="5">';
      echo __('Report');
      echo "<input type='hidden' name='componentscatalogs_id' value='".$componentscatalogs_id."' />";
      echo "<input type='hidden' name='reporttype' value='synthese' />";
      $a_options['componentscatalogs_id'] = $componentscatalogs_id;
      echo '</th>';
      echo '</tr>';

      echo '<tr class="tab_bg_1">';
      echo '<td>';
      echo '</td>';
      echo '<td colspan="2">';
      $default_value = 12;
      if (isset($sess['synthesenumber'])) {
         $default_value = $sess['synthesenumber'];
      }
      Dropdown::showNumber("synthesenumber", array(
                'value' => $default_value,
                'min'   => 2,
                'max'   => 30)
      );
      $a_options['synthesenumber'] = $default_value;
      echo "&nbsp;";
      $a_time = array('week' => __('Week'),
                      'month' => __('Month'),
                      'year' => __('Year'));
      $default_value = 'week';
      if (isset($sess['synthesenumber'])) {
         $default_value = $sess['synthesenumber'];
      }
      Dropdown::showFromArray("syntheseperiod", $a_time, array('value' => $default_value));
      $a_options['syntheseperiod'] = $default_value;
      echo '</td>';
      echo "<td>".__('End date')." :</td>";
      echo "<td>";
      $default_value = date('Y-m-d');
      if (isset($sess['synthesedate_end'])) {
         $default_value = $sess['synthesedate_end'];
      }
      Html::showDateFormItem("synthesedate_end", $default_value);
      $a_options['synthesedate_end'] = $default_value;
      echo "</td>";
      echo '</tr>';

      echo "</table>";

      echo "<table class='tab_cadre_fixe'>";
      $a_composants = $pmComponentscatalog_Component->find("`plugin_monitoring_componentscalalog_id`='".$componentscatalogs_id."'");
      foreach ($a_composants as $comp_data) {
         $pmComponent->getFromDB($comp_data['plugin_monitoring_components_id']);

         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         //echo "<input type='checkbox' name='components_id[]' value='".$pmComponent->getID()."' checked />";
         echo "<input type='hidden' name='components_id[]' value='".$pmComponent->getID()."' />";
         $a_options['components_id'][] = $pmComponent->getID();
         echo "</td>";
         echo "<td>";
         echo $pmComponent->getLink();
         echo "</td>";
         echo "</tr>";

         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         echo "</td>";
         echo "<td>";

         PluginMonitoringToolbox::loadPreferences($pmComponent->getID());

         $a_perfnames = PluginMonitoringServicegraph::getperfdataNames($pmComponent->fields['graph_template']);
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_3'>";
         echo "<td rowspan='".count($a_perfnames)."' width='90'>";
         echo __('Use for report', 'monitoring')."&nbsp;:";

         echo "</td>";
         $i = 0;
         $j = 0;
         if (!isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()])) {
            foreach ($a_perfnames as $name) {
               $_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name] = 'checked';
            }
         }

         foreach ($a_perfnames as $name) {
            if ($i > 0) {
               echo "<tr class='tab_bg_3'>";
            }
            echo "<td>";
            $checked = "checked";
            if (isset($sess['perfname'])
                 && isset($sess['perfname'][$pmComponent->getID()])) {

               if (isset($sess['perfname'][$pmComponent->getID()])) {
                  $checked = "";
               }
               if (isset($sess['perfname'][$pmComponent->getID()][$name])) {
                  $checked = "checked";
               }
            } else {
               if (isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()])) {
                  $checked = "";
               }
               if (isset($_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name])) {
                  $checked = $_SESSION['glpi_plugin_monitoring']['perfname'][$pmComponent->getID()][$name];
               }
            }
            echo "<input type='checkbox' name='perfname[".$pmComponent->getID()."][".$name."]' value='".$name."' ".$checked."/> ".$name;
            if ($checked == 'checked') {
               $a_options['perfname'][$pmComponent->getID()][] = $name;
            }
            echo "</td>";
            echo "<td>";
            echo __('Best is high value', 'monitoring').' :';
            echo "</td>";
            echo "<td>";
            $default_value = 1;
            if (isset($sess['perfname_val'])
                 && isset($sess['perfname_val'][$pmComponent->getID()])) {

               if (isset($sess['perfname_val'][$pmComponent->getID()][$name])) {
                  $default_value = $sess['perfname_val'][$pmComponent->getID()][$name];
               }
            }
            Dropdown::showYesNo('perfname_val['.$pmComponent->getID().']['.$name.']', $default_value);
            if ($checked == 'checked') {
               $a_options['perfname_val'][$pmComponent->getID()][$name] = $default_value;
            }
            echo "</td>";
            echo "</tr>";
            $i++;
         }

         echo "</table>";

         echo "</td>";

         echo "</tr>";
      }
      echo "<tr class='tab_bg_1'>";
      echo "<td colspan='2' align='center'>";
      echo "<input type='submit' class='submit' name='update' value='".__('Save')."'/>";
      echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input type='submit' class='submit' name='generatepdf' value='".__('Generate PDF', 'monitoring')."'/>";
      echo "</td>";
      echo "</tr>";
      echo "</table>";

      Html::closeForm();

      if (isset($_SESSION['plugin_monitoring_report'])) {
//         $a_options = $_SESSION['plugin_monitoring_report'];
      }
      $this->generateSyntheseReport(
              $_SESSION['glpi_plugin_monitoring']['synthese'][$componentscatalogs_id],
              FALSE);
   }
  ------------------------------------------------------------------------

  @package   Plugin Monitoring for GLPI
  @author    David Durieux
  @co-author
  @comment
  @copyright Copyright (c) 2011-2014 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2014

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkRight("plugin_monitoring_servicescatalog", READ);
Html::header(__('Monitoring', 'monitoring'), $_SERVER["PHP_SELF"], "plugins", "monitoring", "businessrules");
$pmBusinessrule_component = new PluginMonitoringBusinessrule_component();
$pmComponentscatalog_Component = new PluginMonitoringComponentscatalog_Component();
if (isset($_POST['add'])) {
    if (!isset($_POST['plugin_monitoring_components_id']) || $_POST['plugin_monitoring_components_id'] < 1) {
        Html::back();
    }
    $a_data = current($pmComponentscatalog_Component->find("`plugin_monitoring_componentscalalog_id`='" . $_POST['plugin_monitoring_componentscatalogs_id'] . "'\n            AND `plugin_monitoring_components_id`='" . $_POST['plugin_monitoring_components_id'] . "'", '', 1));
    $_POST['plugin_monitoring_componentscatalogs_components_id'] = $a_data['id'];
    $pmBusinessrule_component->add($_POST);
    $pmBusinessrule_component->replayDynamicServices($_POST['plugin_monitoring_businessrulegroups_id']);
}
Html::back();
Html::footer();
Ejemplo n.º 3
0
 function showReport($componentscatalogs_id)
 {
     global $CFG_GLPI;
     $pmComponentscatalog_Component = new PluginMonitoringComponentscatalog_Component();
     $pmComponent = new PluginMonitoringComponent();
     $this->getFromDB($componentscatalogs_id);
     echo "<form name='form' method='post' \n         action='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/report_componentscatalog.form.php'>";
     echo "<table class='tab_cadre_fixe'>";
     echo '<tr class="tab_bg_1">';
     echo '<th colspan="5">';
     echo __('Report');
     echo "<input type='hidden' name='componentscatalogs_id' value='" . $componentscatalogs_id . "' />";
     echo '</th>';
     echo '</tr>';
     // ** simple report
     echo '<tr class="tab_bg_1">';
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '<input type="radio" name="reporttype" value="simplereport" checked />';
     echo '</td>';
     echo '<td colspan="4">';
     echo '<strong>' . __('Simple report', "monitoring") . '</strong>';
     echo '</td>';
     echo '</tr>';
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '</td>';
     echo "<td>" . __('Start date') . " :</td>";
     echo "<td>";
     Html::showDateFormItem("date_start", date('Y-m-d H:i:s', date('U') - 24 * 3600 * 7));
     echo "</td>";
     echo "<td>" . __('End date') . " :</td>";
     echo "<td>";
     Html::showDateFormItem("date_end", date('Y-m-d'));
     echo "</td>";
     echo "</tr>";
     // ** synthese
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '<input type="radio" name="reporttype" value="synthese" />';
     echo '</td>';
     echo '<td colspan="4">';
     echo '<strong>' . __('Synthese', "monitoring") . '</strong>';
     echo '</td>';
     echo '</tr>';
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '</td>';
     echo '<td colspan="2">';
     Dropdown::showNumber("synthesenumber", array('value' => 12, 'min' => 2, 'max' => 30));
     echo "&nbsp;";
     $a_time = array('week' => __('Week'), 'month' => __('Month'), 'year' => __('Year'));
     Dropdown::showFromArray("syntheseperiod", $a_time);
     echo '</td>';
     echo "<td>" . __('End date') . " :</td>";
     echo "<td>";
     Html::showDateFormItem("synthesedate_end", date('Y-m-d'));
     echo "</td>";
     echo '</tr>';
     // ** synthese ++
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '<input type="radio" name="reporttype" value="syntheseplus" />';
     echo '</td>';
     echo '<td colspan="4">';
     echo '<strong>' . __('Synthese detail', "monitoring") . '</strong>';
     echo '</td>';
     echo '</tr>';
     echo '<tr class="tab_bg_1">';
     echo '<td>';
     echo '</td>';
     echo '<td colspan="2">';
     Dropdown::showNumber("syntheseplusnumber", array('value' => 12, 'min' => 2, 'max' => 30));
     echo "&nbsp;";
     $a_time = array('week' => __('Week'), 'month' => __('Month'), 'year' => __('Year'));
     Dropdown::showFromArray("syntheseplusperiod", $a_time);
     echo '</td>';
     echo "<td>" . __('End date') . " :</td>";
     echo "<td>";
     Html::showDateFormItem("syntheseplusdate_end", date('Y-m-d'));
     echo "</td>";
     echo '</tr>';
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     $a_composants = $pmComponentscatalog_Component->find("`plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'");
     foreach ($a_composants as $comp_data) {
         $pmComponent->getFromDB($comp_data['plugin_monitoring_components_id']);
         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         echo "<input type='checkbox' name='components_id[]' value='" . $pmComponent->getID() . "' checked />";
         echo "</td>";
         echo "<td>";
         echo $pmComponent->getLink();
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td width='10'>";
         echo "</td>";
         echo "<td>";
         PluginMonitoringServicegraph::preferences($pmComponent->getID(), 1, 1);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' align='center'>";
     echo "<input type='submit' class='submit' name='generate' value='" . __('Generate the report', 'monitoring') . "'/>";
     echo "</td>";
     echo "</tr>";
     Html::closeForm();
 }