<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
$pageSubOf = "pages";
$pageName = "announcements";
$pageTitle = "Announcements";
$thisUrl = "announcements";
$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("announcements_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("announcements_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>');
			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">');
					if (authorizedModule("announcements_filter", $ses_kduser)) {
						if (authorizedModule("announcements_element_title", $ses_kduser)) {
							cout('<div class="form-group">');
								cout('<label for="fil_judul">Title</label>');
								cout('<input type="text" name="fil_judul" id="fil_judul" class="form-control" placeholder="% Title %">');
							cout('</div>');
						}
						if (authorizedModule("announcements_element_content", $ses_kduser)) {
							cout('<div class="form-group">');
								cout('<label for="fil_isi">Content</label>');
								cout('<input type="text" name="fil_isi" id="fil_isi" class="form-control" placeholder="% Content %">');
							cout('</div>');
						}
						if (authorizedModule("announcements_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_judul, #fil_isi").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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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("announcements_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>');
}
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######

# ADD
###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ###### ######
if ($a=="add") {
	cout('<div class="section_submenus">');
		cout('<ul class="nav nav-tabs" role="tablist">');
			if (authorizedModule("announcements_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("announcements_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");
?>