<?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();
$pageSubOf = "settings";
$pageName = "user_authorization";
$pageTitle = "User Authorization/Management";
$thisUrl = "users/authorization";
$pageUrl = "/".adminFolder."/$thisUrl";
$coutSpecs = array('nl'=>"n");
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");
require(root."/".adminFolder."/_lib/auth.php");
$a = cekpost(cleanQuery($_GET["a"]), "");
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>');
# MAIN
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="" || $a=="main") {
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
		cout('</ul>');
	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>
			<!-- 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">');
					if (authorizedModule("user_authorization_filter", $ses_kduser)) {
						if (authorizedModule("user_authorization_element_username", $ses_kduser)) {
							cout('<div class="form-group">');
								cout('<label for="fil_username">Title</label>');
								cout('<input type="text" name="fil_username" id="fil_username" class="form-control" placeholder="% Bank Name %">');
							cout('</div>');
						}
						if (authorizedModule("user_authorization_element_initial", $ses_kduser)) {
							cout('<div class="form-group">');
								cout('<label for="fil_inisial">Initial</label>');
								cout('<input type="text" name="fil_inisial" id="fil_inisial" class="form-control" placeholder="% Initial %">');
							cout('</div>');
						}
						if (authorizedModule("user_authorization_element_active", $ses_kduser)) {
							cout('<div class="form-group">');
								cout('<label for="fil_isactive">Active?</label>');
								cout('<select name="fil_isactive" id="fil_isactive" class="form-control">');
									cout('<option value="">All</option>');
									cout('<option value="1">Active</option>');
									cout('<option value="0">Non-Active</option>');
								cout('</select>');
							cout('</div>');
						}
					}
					cout('<button type="button" class="btn btn-primary" onclick="filterReload(\''.$pageName.'\', 1);return false;">Search</button>');
				cout('</form>');
				cout('<script>
					$("#fil_username, #fil_inisial").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="ajax_resp"></div>');
	cout('<script>filterReload(\''.$pageName.'\', 1);</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# VIEW
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="view") {
	$id = cekpost(cleanQuery($_GET["id"]), "0");
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
			if (authorizedModule("user_authorization_view", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/view/'.$id.'/" title="View"><span class="glyphicon glyphicon-file"></span> <span class="hidden-xs hidden-sm">View</span></a></li>');
			}
			if (authorizedModule("user_authorization_edit", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/edit/'.$id.'/" title="Edit"><span class="glyphicon glyphicon-edit"></span> <span class="hidden-xs hidden-sm">Edit</span></a></li>');
			}
			if (authorizedModule("user_authorization_change_password", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/chpass/'.$id.'/" title="Change Password"><span class="glyphicon glyphicon-lock"></span> <span class="hidden-xs hidden-sm">Change Password</span></a></li>');
			}
			if (authorizedModule("user_authorization_authorization", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/auth/'.$id.'/" title="Authorization"><span class="glyphicon glyphicon-eye-open"></span> <span class="hidden-xs hidden-sm">Authorization</span></a></li>');
			}
			if (authorizedModule("user_authorization_delete", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/delete/'.$id.'/" title="Delete"><span class="glyphicon glyphicon-trash"></span> <span class="hidden-xs hidden-sm">Delete</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>call_section("'.$pageName.'", "section_view", '.$id.');</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# DELETE
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="delete") {
	$id = cekpost(cleanQuery($_GET["id"]), "0");
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
			if (authorizedModule("user_authorization_view", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/view/'.$id.'/" title="View"><span class="glyphicon glyphicon-file"></span> <span class="hidden-xs hidden-sm">View</span></a></li>');
			}
			if (authorizedModule("user_authorization_edit", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/edit/'.$id.'/" title="Edit"><span class="glyphicon glyphicon-edit"></span> <span class="hidden-xs hidden-sm">Edit</span></a></li>');
			}
			if (authorizedModule("user_authorization_change_password", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/chpass/'.$id.'/" title="Change Password"><span class="glyphicon glyphicon-lock"></span> <span class="hidden-xs hidden-sm">Change Password</span></a></li>');
			}
			if (authorizedModule("user_authorization_authorization", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/auth/'.$id.'/" title="Authorization"><span class="glyphicon glyphicon-eye-open"></span> <span class="hidden-xs hidden-sm">Authorization</span></a></li>');
			}
			if (authorizedModule("user_authorization_delete", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/delete/'.$id.'/" title="Delete"><span class="glyphicon glyphicon-trash"></span> <span class="hidden-xs hidden-sm">Delete</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>call_section("'.$pageName.'", "section_delete", '.$id.');</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# EDIT
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="edit") {
	$id = cekpost(cleanQuery($_GET["id"]), "0");
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
			if (authorizedModule("user_authorization_view", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/view/'.$id.'/" title="View"><span class="glyphicon glyphicon-file"></span> <span class="hidden-xs hidden-sm">View</span></a></li>');
			}
			if (authorizedModule("user_authorization_edit", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/edit/'.$id.'/" title="Edit"><span class="glyphicon glyphicon-edit"></span> <span class="hidden-xs hidden-sm">Edit</span></a></li>');
			}
			if (authorizedModule("user_authorization_change_password", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/chpass/'.$id.'/" title="Change Password"><span class="glyphicon glyphicon-lock"></span> <span class="hidden-xs hidden-sm">Change Password</span></a></li>');
			}
			if (authorizedModule("user_authorization_authorization", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/auth/'.$id.'/" title="Authorization"><span class="glyphicon glyphicon-eye-open"></span> <span class="hidden-xs hidden-sm">Authorization</span></a></li>');
			}
			if (authorizedModule("user_authorization_delete", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/delete/'.$id.'/" title="Delete"><span class="glyphicon glyphicon-trash"></span> <span class="hidden-xs hidden-sm">Delete</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>call_section("'.$pageName.'", "section_edit", '.$id.');</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# CHANGE PASSWORD
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="chpass") {
	$id = cekpost(cleanQuery($_GET["id"]), "0");
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
			if (authorizedModule("user_authorization_view", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/view/'.$id.'/" title="View"><span class="glyphicon glyphicon-file"></span> <span class="hidden-xs hidden-sm">View</span></a></li>');
			}
			if (authorizedModule("user_authorization_edit", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/edit/'.$id.'/" title="Edit"><span class="glyphicon glyphicon-edit"></span> <span class="hidden-xs hidden-sm">Edit</span></a></li>');
			}
			if (authorizedModule("user_authorization_change_password", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/chpass/'.$id.'/" title="Change Password"><span class="glyphicon glyphicon-lock"></span> <span class="hidden-xs hidden-sm">Change Password</span></a></li>');
			}
			if (authorizedModule("user_authorization_authorization", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/auth/'.$id.'/" title="Authorization"><span class="glyphicon glyphicon-eye-open"></span> <span class="hidden-xs hidden-sm">Authorization</span></a></li>');
			}
			if (authorizedModule("user_authorization_delete", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/delete/'.$id.'/" title="Delete"><span class="glyphicon glyphicon-trash"></span> <span class="hidden-xs hidden-sm">Delete</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>call_section("'.$pageName.'", "section_chpass", '.$id.');</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# Authorization
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="auth") {
	$id = cekpost(cleanQuery($_GET["id"]), "0");
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
			if (authorizedModule("user_authorization_view", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/view/'.$id.'/" title="View"><span class="glyphicon glyphicon-file"></span> <span class="hidden-xs hidden-sm">View</span></a></li>');
			}
			if (authorizedModule("user_authorization_edit", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/edit/'.$id.'/" title="Edit"><span class="glyphicon glyphicon-edit"></span> <span class="hidden-xs hidden-sm">Edit</span></a></li>');
			}
			if (authorizedModule("user_authorization_change_password", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/chpass/'.$id.'/" title="Change Password"><span class="glyphicon glyphicon-lock"></span> <span class="hidden-xs hidden-sm">Change Password</span></a></li>');
			}
			if (authorizedModule("user_authorization_authorization", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/auth/'.$id.'/" title="Authorization"><span class="glyphicon glyphicon-eye-open"></span> <span class="hidden-xs hidden-sm">Authorization</span></a></li>');
			}
			if (authorizedModule("user_authorization_delete", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/delete/'.$id.'/" title="Delete"><span class="glyphicon glyphicon-trash"></span> <span class="hidden-xs hidden-sm">Delete</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>
		function selectAll(parTargetClass, $parThis) {
			if ($parThis.is(":checked")) {
				$("."+ parTargetClass +"").prop("checked", true);
			} else {
				$("."+ parTargetClass +"").prop("checked", false);
			}
		}
	</script>');
	cout('<script>call_section("'.$pageName.'", "section_auth", '.$id.');</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# ADD
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="add") {
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("user_authorization_main", $ses_kduser)) {
				cout('<li role="presentation"><a href="'.$pageUrl.'/" title="Main List"><span class="glyphicon glyphicon-list"></span> <span class="hidden-xs hidden-sm">Main</span></a></li>');
			}
			if (authorizedModule("user_authorization_add", $ses_kduser)) {
				cout('<li role="presentation" class="active"><a href="'.$pageUrl.'/add/" title="Add New"><span class="glyphicon glyphicon-plus"></span> <span class="hidden-xs hidden-sm">Add</span></a></li>');
			}
		cout('</ul>');
	cout('</div>');
	cout('<div class="ajax_resp"></div>');
	cout('<script>call_section("'.$pageName.'", "section_add", "");</script>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

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.';
?>