Exemple #1
0
 function getReport($obj, $pagenum = 1)
 {
     $reportInfo = $this->getReportInfo($obj);
     return getReportData($reportInfo, $pagenum = 1);
 }
function processReportUpload()
{
    // Build filepath
    $uploadfile = getcwd() . '/tmp/' . basename($_FILES['file']['name']);
    // If move from temp PHP directory == success, then true
    if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
        // Check to see if this is a duplicate report
        $isDuplicate = getReportData(NULL, gps('report_name'));
        if ($isDuplicate) {
            unlink($uploadfile);
            // Put result in a encoded JSON return
            $out = array("result" => 'duplicate', "report_name" => $isDuplicate['report_name'], "description" => $isDuplicate['short_description'], "report_id" => $out['report_id']);
            return json_encode($out);
        }
        //// Start building query
        // Get the file as binary
        $report_data = file_get_contents($uploadfile);
        // Report Name - Used to check for duplicates
        $report_name = gps('report_name');
        // Report Short Description
        $short_description = gps('short_description');
        // New Report?
        $reportStatus = gps('reportNew');
        // Author ID
        $aud = gps('report_author_id');
        $report_owner_author_id = $aud;
        $report_the_user_id = $aud;
        // Scope of Data
        $report_type_id = gps('report_type_id');
        // Scope of Data
        $report_scope_id = gps('report_scope_id');
        // Publication Number
        $pid = gps('report_number');
        // Filename
        $report_file_name = basename($_FILES['file']['name']);
        // Publication Date. Tenatively date of import.
        $report_publication_date = date("m-d-y");
        // xx-xx-xxxx
        // report filesize
        $report_file_size = filesize($uploadfile);
        // set report ID to null if it is a new report, otherwise, use $stored_report_id
        //$report_id = ($reportStatus == 0) ? NULL : $reportStatus;
        // Build Parameters
        $spParams = array(array(NULL, 1), array(NULL, 1), array($report_owner_author_id, 1), array($report_id, 1), array($report_name, 1), array($short_description, 1), array($pid, 1), array($report_publication_date, 1), array(1, 1), array($report_type_id, 1), array('http://', 1), array(1, 1), array($report_file_size, 1), array($report_file_name, 1), array($report_file_name, 1), array('pdf', 1), array('application/pdf', 1), array(1, 1), array($report_data, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)), array(1, 1), array($report_scope_id, 1), array($report_the_user_id, 1));
        // call the procedure
        $result = callStoredProcedure(sqlsrvConnect(), 'Report_WyomingTobaccoEdit_SP', $spParams);
        // if JSON result TRUE
        if ($result['success']) {
            unlink($uploadfile);
            // Delete uploaded file as its now in DB
            // prepare JSON data pairs in to array
            $out = array("result" => 'success', "post_ID" => gps('post_ID'), "description" => gps('short_description'), "category" => gps('category'), "scope" => gps('sod'), "publication_number" => gps('pid'), "report_id" => $result['report_id'], "report_name" => $result['report_name']);
            // return array as json
            return json_encode($out);
        } else {
            $error = print_r($result, TRUE);
            // if anything else, return error
            $out = array("result" => "error" . $error);
            return json_encode($out);
        }
    }
}
Exemple #3
0
$section = null;
$pageTitle = "Pagination";
include "inc/functions.php";
include "inc/variables.php";
include "inc/connection.php";
$division = $_SESSION['division'];
$report = $_SESSION['report'];
$colNames = $sqlSelectReport;
$fileDate = (new \DateTime())->format('Y-m-d H.i.s');
$reportData = "Select * from reportTemp";
if (isset($_POST["ExportType"])) {
    if (isset($_POST["report"])) {
        $report = $_POST['report'];
    }
    $data = getReportData();
    switch ($_POST["ExportType"]) {
        case "export-to-excel":
            // Submission from
            $filename = "{$report}._{$division}.{$fileDate}.xls";
            header("Content-Type: application/vnd.ms-excel");
            header("Content-Disposition: attachment; filename=\"{$filename}\"");
            ExportFile($data);
            exit;
        case "export-to-csv":
            // Submission from
            $filename = "{$report}._{$division}.{$fileDate}.csv";
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Content-type: text/csv");
            header("Content-Disposition: attachment; filename=\"{$filename}\"");
            header("Expires: 0");