<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
$pageName = "laporan";
$pageTitle = "Report All";
$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");
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;
$fil_stgl = strtotime($stgl);
$fil_etgl = strtotime($etgl);
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>');

	cout('<nav class="navbar navbar-default">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">Filter</a>
			</div>');
			cout('<!-- Collect the nav links, forms, and other content for toggling -->');
			cout('<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">');
				cout('<form class="navbar-form navbar-left" role="search" method="post" target="filter_iframe" action="/'.adminFolder.'/_ajax/ajax_teachers.php?a=section_main">');
					
							cout('<div class="form-group">');
								cout('<div class="controls"><label for="fil_stgl">From</label>');
									cout('<div class="input-group">');
										cout('<input id="fil_stgl" type="text" size="10" class="fil_stgl form-control" placeholder="Start Date" value="'.date('d-m-Y', $fil_stgl).'" />');
										cout('<label for="fil_stgl" class="input-group-addon btn">');
											cout('<span class="glyphicon glyphicon-calendar"></span>');
										cout('</label>');
									cout('</div>');
								cout('</div>');
							cout('</div>');
							cout('<div class="form-group">');
								cout('<div class="controls"><label for="fil_etgl">To</label>');
									cout('<div class="input-group">');
										cout('<input id="fil_etgl" type="text" size="10" class="fil_etgl form-control" placeholder="End Date" value="'.date('d-m-Y', $fil_etgl).'" />');
										cout('<label for="fil_etgl" class="input-group-addon btn">');
											cout('<span class="glyphicon glyphicon-calendar"></span>');
										cout('</label>');
									cout('</div>');
								cout('</div>');
							cout('</div>');
						
							cout('<div class="form-group">
								<label for="fil_kdgame">Games</label>
								<select name="fil_kdgame" id="fil_kdgame" class="form-control">
									<option value="">- Filter Game -</option>');
									$rsb=array();$qb="SELECT * FROM games WHERE isactive=1";
									callRS($rsb, $qb);
									for ($i=0;$i<count($rsb);$i++) {
										cout('<option value="'.$rsb[$i]["kdgame"].'">'.$rsb[$i]["nama"].'</option>');
									}
								cout('
								</select>
							</div>');
						
							cout('<div class="form-group">');
								cout('<label for="fil_username">UserName</label>');
								cout('<input type="text" name="fil_username" id="fil_username" class="form-control" placeholder="% UserName %">');
							cout('</div>');
						
							cout('<div class="form-group">');
								cout('<label for="fil_kdbank">Bank</label>');
								$rsc=array();$qc = "SELECT * FROM banks";
								callRS($rsc, $qc);
								cout('<select name="fil_kdbank" id="fil_kdbank" class="form-control">');
									cout('<option value="">All</option>');
									for ($j=0;$j<count($rsc);$j++) {
										cout('<option value="'.$rsc[$j]["kdbank"].'" '.$sel.'>'.$rsc[$j]["inisial"].'</option>');
									}
								cout('</select>');
							cout('</div>');
						
							cout('<div class="form-group">');
								cout('<label for="fil_norek">No. Rek.</label>');
								cout('<input type="text" name="fil_norek" id="fil_norek" class="form-control" placeholder="% Nomor Rekening %">');
							cout('</div>');
						
							cout('<div class="form-group">');
								cout('<label for="fil_namarek">Nama Rek.</label>');
								cout('<input type="text" name="fil_namarek" id="fil_namarek" class="form-control" placeholder="% Nama Pemilik Rek. %">');
							cout('</div>');
						
					cout('<button type="button" class="btn btn-primary" onclick="filterReload(\''.$pageName.'\', 1);return false;">Search</button>');
					
				cout('</form>');
				cout('<script>
					$(".fil_stgl, .fil_etgl").datepicker({
						inline: true,
						autosize: true,
						yearRange: "'.(date('Y', time())-5).':'.(date('Y', time())+1).'",
						changeMonth: true,
						changeYear: true,
						dateFormat: "dd-mm-yy"
					});
					$("#fil_username, #fil_norek, #fil_namarek, #fil_telp, #fil_email").keypress(function (e) {
						if(e.which == 13) {
							filterReload(\''.$pageName.'\', 1);
							return false;
						}
					});
				</script>');
			cout('</div><!-- /.navbar-collapse -->');
		cout('</div><!-- /.container-fluid -->');
	cout('</nav>');
	cout('<div class="container-fluid">');
		
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>filterReload(\''.$pageName.'\', 1);</script>');




/* 





*/
/*
$q_stgl = strtotime($stgl);
$q_ytgl = strtotime($stgl)-86400;
## ytday's quick report
cout('<div class="row">');
	$rsnm=array();
	$qnm="SELECT COUNT(kdmember) AS tmem FROM members
		WHERE 1=1
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal_daftar))>=UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_ytgl.")) 
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal_daftar))< UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_stgl.")) 
		AND isdeleted=0 AND isactive=1";
	callRS($rsnm, $qnm);
	cout('<div class="col-sm-3">');
		cout('<div class="home-mini-box">');
			cout('<div class="title title-member"><div class="icon"></div><div class="text">Yesterday\'s Members</div></div>');
			cout('<div class="data">'.$rsnm[0]["tmem"].'</div>');
		cout('</div>');
	cout('</div>');
	
	$rsnd=array();
	$qnd="SELECT SUM(jumlah) AS tjum, COUNT(kddeposit) AS tdp FROM deposits
		WHERE 1=1
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))>=UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_ytgl.")) 
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))< UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_stgl.")) 
		AND isclear = 1";
	callRS($rsnd, $qnd);
	$tj_ytday = $rsnd[0]["tjum"];
	$tt_ytday = $rsnd[0]["tdp"];
	cout('<div class="col-sm-3">');
		cout('<div class="home-mini-box">');
			cout('<div class="title title-deposit"><div class="icon"></div><div class="text">Yesterday\'s Deposits</div></div>');
			cout('<div class="data">Rp. '.number_format($rsnd[0]["tjum"],0).'</div>');
			cout('<div class="data" style="margin:5px 0;">'.number_format($rsnd[0]["tdp"],0).' transaction(s)</div>');
		cout('</div>');
	cout('</div>');
	
	$rsnw=array();
	$qnw="SELECT SUM(jumlah) AS tjum, COUNT(kdwithdraw) AS twd FROM withdraws
		WHERE 1=1
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))>=UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_ytgl.")) 
		AND UNIX_TIMESTAMP(FROM_UNIXTIME(tanggal))< UNIX_TIMESTAMP(FROM_UNIXTIME(".$q_stgl.")) 
		AND isclear = 1";
	callRS($rsnw, $qnw);
	$tj_ytday = $tj_ytday - $rsnw[0]["tjum"];
	$tt_ytday = $tt_ytday + $rsnw[0]["twd"];
	cout('<div class="col-sm-3">');
		cout('<div class="home-mini-box">');
			cout('<div class="title title-withdraw"><div class="icon"></div><div class="text">Yesterday\'s Withdrawals</div></div>');
			cout('<div class="data" style="color:#ff7669;">Rp. -'.number_format($rsnw[0]["tjum"],0).'</div>');
			cout('<div class="data" style="margin:5px 0;">'.number_format($rsnw[0]["twd"],0).' transaction(s)</div>');
		cout('</div>');
	cout('</div>');
	$color_style = $tj_ytday<0?'color:#ff7669;':'';
	cout('<div class="col-sm-3">');
		cout('<div class="home-mini-box">');
			cout('<div class="title title-total"><div class="icon"></div><div class="text">Yesterday\'s Total</div></div>');
			cout('<div class="data" style="'.$color_style.'">Rp. '.number_format($tj_ytday,0).'</div>');
			cout('<div class="data" style="margin:5px 0;">'.number_format($tt_ytday,0).' transaction(s)</div>');
		cout('</div>');
	cout('</div>');
cout('</div>');
## end ytday's quick report
*/
#$rs=array();$q="SELECT * FROM _admin_mods ORDER BY kdpage, kdmod";
#callRS($rs, $q);
#for ($i=0;$i<count($rs);$i++) {
#	echo "UPDATE _admin_mods SET kdmod = '".$rs[$i]["kdpage"].(substr($rs[$i]["kdmod"], 2))."' WHERE kdmod='".$rs[$i]["kdmod"]."';<br/>";
#}
$act_ket = "Index: Dashboard";
updateUserActivities($act_ket);
require(root."/".adminFolder."/_tpl/footer.php");
require(root."/".adminFolder."/_tpl/tag_html_b.php");
?>