Ejemplo n.º 1
0
function RunNowReportInDB($report_id = null, $report_arr = array())
{
    if (!$report_id && !count($report_arr)) {
        return;
    }
    global $pearDB, $oreon;
    $hosts = array();
    $reportinfo = array();
    $hosts = getHostReport($report_id);
    $reportinfo = getReportInfo($report_id);
    $services = getServiceGroupReport($report_id);
    $dates = getPeriodToReportFork($reportinfo['period']);
    $start_date = $dates[0];
    $end_date = $dates[1];
    $reportingTimePeriod = getreportingTimePeriod();
    if (isset($_SERVER['DOCUMENT_ROOT'])) {
        $nb_folders = count(explode("/", $_SERVER['DOCUMENT_ROOT']));
        $path_www = "/" . implode("/", array_fill(0, intval($nb_folders) - 1, '..'));
        //echo $_SERVER['DOCUMENT_ROOT'] . "  " . intval($nb_folders) -1 . "  " .  $path_www . "<br />";
    }
    if (isset($hosts) && count($hosts) > 0) {
        foreach ($hosts['report_hgs'] as $hgs_id) {
            $stats = array();
            $stats = getLogInDbForHostGroup($hgs_id, $start_date, $end_date, $reportingTimePeriod);
            $Allfiles[] = pdfGen($report_id, getMyHostGroupName($hgs_id), 'hgs', $start_date, $end_date, $stats, "", $reportinfo["report_title"], $path_www);
            // "/../.."
            //print_r($Allfiles);
        }
    }
    if (isset($services) && count($services) > 0) {
        foreach ($services['report_sg'] as $sg_id) {
            $sg_stats = array();
            $sg_stats = getLogInDbForServicesGroup($sg_id, $start_date, $end_date, $reportingTimePeriod);
            $Allfiles[] = pdfGen($report_id, getMyServiceGroupName($sg_id), 'sgs', $start_date, $end_date, $sg_stats, $l, $reportinfo["report_title"], $path_www);
        }
    }
    $emails = getReportContactEmail($report_id);
    $files = array();
    foreach ($Allfiles as $file) {
        $files[basename($file)]["url"] = $file;
    }
    mailer(getGeneralOptInfo("pdfreports_report_author"), getGeneralOptInfo("pdfreports_email_sender"), $emails, $reportinfo['subject'], $reportinfo['mail_body'], getGeneralOptInfo("pdfreports_smtp_server_address"), $files, $reportinfo['name']);
    $files = null;
    $Allfiles = null;
    $emails = null;
    $services = null;
    $hosts = null;
}
         $stats = getLogInDbForHostGroup($hgs_id, $start_date, $end_date, $reportingTimePeriod);
         //print_r($stats);
         //tableau contenant la liste des pdf générés
         $Allfiles[] = pdfGen(getMyHostGroupName($hgs_id), 'hgs', $start_date, $end_date, $stats, $l, $reportinfo["report_title"], "");
         //$Allfiles[] = pdfGen( getMyHostGroupName($hgs_id), 'hgs', $start_date, $end_date, $stats, $l, getGeneralOptInfo("pdfreports_report_header_logo") , $reportinfo["report_title"]  );
         //print_r($Allfiles);
     }
 }
 // Generate servicegroup reports
 if (isset($services) && count($services) > 0) {
     foreach ($services['report_sg'] as $sg_id) {
         $sg_stats = array();
         $sg_stats = getLogInDbForServicesGroup($sg_id, $start_date, $end_date, $reportingTimePeriod);
         //print_r($stats);
         //tableau contenant la liste des pdf générés
         $Allfiles[] = pdfGen(getMyServiceGroupName($sg_id), 'sgs', $start_date, $end_date, $sg_stats, $l, $reportinfo["report_title"], "");
         //$Allfiles[] = pdfGen( getMyServiceGroupName($sg_id), 'sgs', $start_date, $end_date, $sg_stats, $l, getGeneralOptInfo("pdfreports_report_header_logo") , $reportinfo["report_title"]  );
         //print_r($Allfiles);
     }
 }
 $emails = getReportContactEmail($report_id);
 //print_r( $emails );
 $files = array();
 foreach ($Allfiles as $file) {
     $files[basename($file)]["url"] = $file;
 }
 //print_r($files);
 mailer(getGeneralOptInfo("pdfreports_report_author"), getGeneralOptInfo("pdfreports_email_sender"), $emails, $reportinfo['subject'], $reportinfo['mail_body'], getGeneralOptInfo("pdfreports_smtp_server_address"), $files, $reportinfo['name']);
 $files = null;
 $Allfiles = null;
 $emails = null;