/
var
/
www
/
barefootlaw.org
/
bios2
/
manager
/
Upload File
HOME
<?php require_once('../Connections/fleetMan.php'); ?> <?php require_once("functions.php"); $api = new fleet(); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } //Report Content mysql_select_db($database_fleetMan, $fleetMan); $report_tables = $api->report_list(); $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if(isset($_POST['reportType'])) { $json = json_decode($api->get_record("report_template","query","where id = '".$_POST['reportType']."'"), true); $table = array(); $query = "select "; foreach($json as $item) { $t = substr($item,0,strpos($item,".")); if(!in_array($t,$table)) { $table[] = $t; } $query .= $item.", "; } $report = mysql_query(substr($query,0,-2)." from ".$table[0]." where _when_added between '".date("Y-m-d", strtotime($_POST['from']))."' and '".date("Y-m-d", strtotime($_POST['to']))."'"); $data = mysql_fetch_assoc($report); header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=Report_'.$api->get_record("report_template","report_name","where id = '".$_POST['reportType']."'").'_'.date("Y-m-d", strtotime($_POST['from'])).'_'.date("Y-m-d", strtotime($_POST['to'])).'.csv'); // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); //fputcsv($output, $data); while ($data = mysql_fetch_assoc($report)) fputcsv($output, $data); exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!--<link rel="shortcut icon" href="../images/favicon.png" type="image/png">--> <title>Download Reports</title> <link rel="stylesheet" href="../lib/jquery-ui/jquery-ui.css"> <link rel="stylesheet" href="../lib/select2/select2.css"> <link rel="stylesheet" href="../lib/dropzone/dropzone.css"> <link rel="stylesheet" href="../lib/jquery-toggles/toggles-full.css"> <link rel="stylesheet" href="../lib/fontawesome/css/font-awesome.css"> <link rel="stylesheet" href="../lib/timepicker/jquery.timepicker.css"> <link rel="stylesheet" href="../lib/bootstrapcolorpicker/css/bootstrap-colorpicker.css"> <link rel="stylesheet" href="../css/quirk.css"> <script src="../lib/modernizr/modernizr.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="../lib/html5shiv/html5shiv.js"></script> <script src="../lib/respond/respond.src.js"></script> <![endif]--> </head> <body> <section><!-- leftpanel --> <div class="mainpanel"> <div class="contentpanel"> <form name="report_template" method="post" action=""> <div class="row"> <div class="col-sm-6"><!-- panel --> <div class="panel"> <div class="panel-heading"> <?php if(isset($status)) echo '<p>'.$status.'</p>'; ?> <h4 class="panel-title">DATA STORE</h4> <p>Select data stores and associated columns (constraints) from which to generate the report template. </p> </div> <div class="panel-body"> <h4 class="panel-title mb10">Select Report Parameters:</h4> <div class="form-group"> <select id="select6" class="form-control" style="width: 100%" data-placeholder="Select Report Type ..." name="reportType"> <?php foreach($report_tables as $item) { ?> <option value="<?php echo $item['id']; ?>"><?php echo $item['name']; ?></option> <?php } ?> </select> </div> <div class="form-group"> <input type="date" placeholder="Enter Start Date" class="form-control" required name="from" value="<?php echo date("Y-m-d") ?>" /> </div> <div class="form-group"> <input type="date" placeholder="Enter End Date" class="form-control" required name="to" value="<?php echo date("Y-m-d") ?>" /> </div> </div> </div><!-- panel --><!-- panel --><!-- panel --> </div><!-- col-sm-6 --> <!-- ####################################################### --><!-- col-sm-6 --> </div><!-- row --> <div class="form-group"> <button class="btn btn-info" type="submit" name="submit">Download</button> </div> </form> </div><!-- contentpanel --> </div><!-- mainpanel --> </section> <script src="../lib/jquery/jquery.js"></script> <script src="../lib/jquery-ui/jquery-ui.js"></script> <script src="../lib/bootstrap/js/bootstrap.js"></script> <script src="../lib/jquery-autosize/autosize.js"></script> <script src="../lib/select2/select2.js"></script> <script src="../lib/jquery-toggles/toggles.js"></script> <script src="../lib/jquery-maskedinput/jquery.maskedinput.js"></script> <script src="../lib/timepicker/jquery.timepicker.js"></script> <script src="../lib/dropzone/dropzone.js"></script> <script src="../lib/bootstrapcolorpicker/js/bootstrap-colorpicker.js"></script> <script src="../js/quirk.js"></script> <script> $(function() { // Textarea Auto Resize autosize($('#autosize')); // Select2 Box $('#select1, #select2, #select3').select2(); $("#select4").select2({ maximumSelectionLength: 2 }); $("#select5").select2({ minimumResultsForSearch: Infinity }); $("#select6").select2({ tags: true }); // Toggles $('.toggle').toggles({ on: true, height: 26 }); // Input Masks $("#date").mask("99/99/9999"); $("#phone").mask("(999) 999-9999"); $("#ssn").mask("999-99-9999"); // Date Picker $('#datepicker').datepicker(); $('#datepicker-inline').datepicker(); $('#datepicker-multiple').datepicker({ numberOfMonths: 2 }); // Time Picker $('#tpBasic').timepicker(); $('#tp2').timepicker({'scrollDefault': 'now'}); $('#tp3').timepicker(); $('#setTimeButton').on('click', function (){ $('#tp3').timepicker('setTime', new Date()); }); // Colorpicker $('#colorpicker1').colorpicker(); $('#colorpicker2').colorpicker({ customClass: 'colorpicker-lg', sliders: { saturation: { maxLeft: 200, maxTop: 200 }, hue: { maxTop: 200 }, alpha: { maxTop: 200 } } }); }); </script> <script type="text/javascript"> function load_cols() { var result = ""; $('#select6 > :selected').each(function() { result += $(this).val()+","; }); var i=0; $("#column_list").html(""); $.getJSON("json_async.php?action=load_cols&entities="+result, function(result){ if(result.status == "1") { //$("#row"+pk).css("visibility","hidden"); for(i=0;i<result.fields.length;i++) { $("#column_list").append('<label class="ckbox ckbox-info"><input type="checkbox" checked value="'+result.fields[i]['col']+'" name='+result.fields[i]['col']+'><span>'+result.fields[i]['name']+'</span></label>'); } } else { //alert("Failed to load data columns."); } }); } </script> </body> </html>