Exemple #1
0
 foreach ($_POST['tables'] as $table) {
     if ($table) {
         $tables[] = $table;
     }
 }
 $entities = array();
 foreach ($_POST['entities'] as $uuid) {
     if ($uuid) {
         $entities[] = $uuid;
     }
 }
 if (empty($items)) {
     new NotifyWidgetFailure(_T("Select some data to include in the report.", "report"));
     redirectTo(urlStrRedirect("report/report/index"));
 }
 $result = generate_report($periods, $sections, $tables, $items, $entities, $_SESSION['lang']);
 // display sections
 foreach ($result['sections'] as $section) {
     // Section Title
     $f->push(new Div());
     $title = new TitleElement($section['title']);
     $f->add($title);
     $f->pop();
     // Display tables and graphs for this section
     $report_objects = array();
     $report_types = array();
     foreach ($section['content'] as $content) {
         $table = False;
         $svg = False;
         if ($content['type'] == 'table') {
             $title = new SpanElement(sprintf('<h3>%s</h3>', $content['title']));
</table>
</aside>

<section id="admin-results" style='padding-left: 0%;'>
<?php 
if (isset($_POST['export'])) {
    $result = report_to_csv($dbc, $_POST['export']);
    if ($result === 1) {
        echo "Report successfully generated.";
    } else {
        echo "Unable to generate Report.";
    }
    $_POST['submit'] = $_POST['export'];
}
if (isset($_POST['submit'])) {
    $result = generate_report($dbc, $_POST['submit']);
    if ($result != false && $result->num_rows != 0) {
        echo "<h3>" . get_report_name($_POST['submit']) . "</h3>";
        echo "<form method='post' action='./save-generated-report.php' target='_blank'>\r\n\t\t\t\t\t\t\t<button class='btn btn-primary' id='admin-report-button' name='export' value='" . $_POST['submit'] . "'>\r\n\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-download-alt'></span> Download\r\n\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t</form>";
        echo "<table class='table table-striped table-hover' id='admin-search' align='center'>";
        if ($_POST['submit'] < 4) {
            ?>
					<tr>
						<th id="admin-th">NetID</th>
						<th id="admin-th">Serial Number</th>
						<th id="admin-th">Make</th>
						<th id="admin-th">Model/Type</th>
						<th id="admin-th">Missing</th>
					</tr>
<?php 
            while ($row = mysqli_fetch_assoc($result)) {
Exemple #3
0
list($micro, $seconds) = explode(" ", microtime());
$start = $seconds + $micro;
/* let's give this script lot of time to run for ever */
ini_set("max_execution_time", "0");
$t = time();
$number_sent = 0;
# fetch all enabled reports that have a stratime in the past
if (!$force) {
    $reports = db_fetch_assoc("SELECT * FROM reports WHERE mailtime<{$t} AND enabled='on'");
} else {
    $reports = db_fetch_assoc("SELECT * FROM reports WHERE enabled='on'");
}
reports_log("Cacti Reports reports found: " . sizeof($reports), true, "REPORTS", POLLER_VERBOSITY_MEDIUM);
# execute each of those reports
if (sizeof($reports)) {
    foreach ($reports as $report) {
        reports_log("Reports processing report: " . $report["name"], true, "REPORTS", POLLER_VERBOSITY_MEDIUM);
        $current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $report["user_id"]);
        if (isset($report['email'])) {
            generate_report($report, false, "poller");
            $number_sent++;
        }
    }
    /* record the end time */
    list($micro, $seconds) = explode(" ", microtime());
    $end = $seconds + $micro;
    /* log statistics */
    $reports_stats = sprintf("Time:%01.4f Reports:%s", $end - $start, $number_sent);
    reports_log('Reports STATS: ' . $reports_stats, true, "REPORTS", POLLER_VERBOSITY_LOW);
    db_execute("REPLACE INTO settings (name, value) VALUES ('stats_reports', '{$reports_stats}')");
}
Exemple #4
0
function report_to_csv($dbc, $report_type, $attachment = True, $headers = True)
{
    $filename = generate_report_filename($report_type);
    $query = generate_report($dbc, $report_type);
    if ($filename === 0 || $query === 0) {
        return 0;
    }
    if ($attachment) {
        // send response headers to the browser
        header('Content-Type: text/csv');
        header('Content-Disposition: attachment;filename=' . $filename);
        $fp = fopen('php://output', 'w');
    } else {
        $fp = fopen($filename, 'w');
    }
    if ($headers) {
        // output header row (if at least one row exists)
        $row = $query->fetch_assoc();
        if ($row) {
            fputcsv($fp, array_keys($row));
            // reset pointer back to beginning
            $query->data_seek(0);
        }
    }
    while ($row = $query->fetch_assoc()) {
        if ($report_type < 3) {
            $row['Missing'] = $row['Missing'] == 0 ? "No" : "Yes";
        } else {
            if ($report_type > 3 && $report_type < 7) {
                $row['ReturnLocation'] = $row['ReturnLocation'] == 0 ? "----" : $row['ReturnLocation'];
            } else {
                if ($report_type > 6) {
                    $row['Phone'] = $row['Phone'] == Null ? "----" : $row['Phone'];
                    $row['Admin'] = $row['Admin'] == 0 ? "No" : "Yes";
                }
            }
        }
        fputcsv($fp, $row);
    }
    fclose($fp);
    return 1;
}
Exemple #5
0
function reports_send($id)
{
    global $config;
    /* ================= input validation ================= */
    input_validate_input_number($id);
    /* ==================================================== */
    include_once $config['base_path'] . '/lib/reports.php';
    $report = db_fetch_row('SELECT * FROM reports WHERE id=' . $id);
    if (!sizeof($report)) {
        /* set error condition */
    } elseif ($report['user_id'] == $_SESSION['sess_user_id']) {
        reports_log(__FUNCTION__ . ', send now, report_id: ' . $id, false, 'REPORTS TRACE', POLLER_VERBOSITY_MEDIUM);
        /* use report name as default EMail title */
        if (!strlen($report['subject'])) {
            $report['subject'] = $report['name'];
        }
        if (!strlen($report['email'])) {
            $_SESSION['reports_error'] = "Unable to send Report '" . $report['name'] . "'.  Please set destination e-mail addresses";
            if (!isset($_POST['selected_items'])) {
                raise_message('reports_error');
            }
        } elseif (!strlen($report['subject'])) {
            $_SESSION['reports_error'] = "Unable to send Report '" . $report['name'] . "'.  Please set an e-mail subject";
            if (!isset($_POST['selected_items'])) {
                raise_message('reports_error');
            }
        } elseif (!strlen($report['from_name'])) {
            $_SESSION['reports_error'] = "Unable to send Report '" . $report['name'] . "'.  Please set an e-mail From Name";
            if (!isset($_POST['selected_items'])) {
                raise_message('reports_error');
            }
        } elseif (!strlen($report['from_email'])) {
            $_SESSION['reports_error'] = "Unable to send Report '" . $report['name'] . "'.  Please set an e-mail from address";
            if (!isset($_POST['selected_items'])) {
                raise_message('reports_error');
            }
        } else {
            generate_report($report, true);
        }
    }
}