<?php
$timexx = microtime();
$timexx = explode(' ', $timexx);
$timexx = $timexx[1] + $timexx[0];
$start = $timexx;
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
$pageName = "index";
$pageTitle = "Dashboard";
$coutSpecs = array('nl'=>"n");
$act_ket = "Main Page of Index";
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");
require(root."/".adminFolder."/_lib/auth.php");
if (!isset($_SESSION["user"])) {
	header("Location: /".adminFolder."/login/");
	exit;
}
$stgl = cekpost(cleanQuery($_REQUEST["fil_stgl"]), date('d-m-Y', time()));
$etgl = cekpost(cleanQuery($_REQUEST["fil_etgl"]), date('d-m-Y', time()));
$q_stgl = strtotime($stgl);
$q_etgl = strtotime($etgl)+86400;
$q_ytgl = strtotime($stgl)-86400;
require(root."/".adminFolder."/_tpl/tag_html_a.php");
cout('
<style type="text/css">
	
</style>
');
require(root."/".adminFolder."/_tpl/openbody.php");
require(root."/".adminFolder."/_tpl/header.php");
cout('<div class="page-header">');
	cout('<h1>'.$pageTitle.'</h1>');
cout('</div>');
if (!authorizedModule("members_main", $ses_kduser)) {
	unAuthorizedAccess("members_main");
} else {
	cout('<div class="container-fluid today-reports">a</div><!--/.container-fluid today-reports-->');
	cout('<div class="container-fluid this-month-reports">b</div><!--/.container-fluid this-month-reports-->');
	cout('<div class="container-fluid last-month-reports">c</div><!--/.container-fluid last-month-reports-->');
	cout('<script>');
		cout('
		function callIndexRep(parType) {
			var aURL = "/'.adminFolder.'/_ajax/ajax_index.php";
			var aData = "time='.time().'";
			if (parType=="today") {
				$(".today-reports").html("<img src=\"/img/ajax-loader.gif\" />");
				aData += "&a=today";
			}
			if (parType=="this-month") {
				$(".this-month-reports").html("<img src=\"/img/ajax-loader.gif\" />");
				aData += "&a=this-month";
			}
			if (parType=="last-month") {
				$(".last-month-reports").html("<img src=\"/img/ajax-loader.gif\" />");
				aData += "&a=last-month";
			}
			$.ajax({
				type: "GET",
				url: aURL,
				data: aData,
				success: function(resp) {
					if (parType=="today") {
						$(".today-reports").html(resp);
					}
					if (parType=="this-month") {
						$(".this-month-reports").html(resp);
						$(".this-month-reports").fadeOut(1).fadeIn(100, function(){
							$(".this-month-reports").fadeOut(1).fadeIn(100, function(){
								if ($(".this-month-reports #chartContainer").length) {
									slideThis($("#chartContainer").parent().find("a.btn"));
								}
							});
						});
					}
					if (parType=="last-month") {
						$(".last-month-reports").html(resp);
						$(".last-month-reports").fadeOut(1).fadeIn(100, function(){
							if ($(".last-month-reports #chartContainer2").length) {
								slideThis($("#chartContainer2").parent().find("a.btn"));
							}
						});
					}
				}
			});
		}
		function slideThis(parEl) {
			var $el = parEl;
			if ($el.parent().parent().hasClass("muncul")) {
				$el.parent().parent().find(".chart").slideUp(1000, function(){
					$el.parent().parent().removeClass("muncul").addClass("sembunyi");
				});
			} else {
				$el.parent().parent().find(".chart").slideDown(1000, function(){
					$el.parent().parent().removeClass("sembunyi").addClass("muncul");
				});
			}
		}
		$(window).load(function(){
			callIndexRep(\'today\');
			callIndexRep(\'this-month\');
			callIndexRep(\'last-month\');
		});
		');
	cout('</script>');
}

$act_ket = "Index: Dashboard";
updateUserActivities($act_ket);
require(root."/".adminFolder."/_tpl/footer.php");
require(root."/".adminFolder."/_tpl/tag_html_b.php");
$timexx = microtime();
$timexx = explode(' ', $timexx);
$timexx = $timexx[1] + $timexx[0];
$finish = $timexx;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>