<?php 
require('includes/header.php');  
?>	

<!--begin::Content-->
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
	<!--begin::Subheader-->
	<div class="subheader py-2 py-lg-4 subheader-solid" id="kt_subheader">
		<div class="container-fluid d-flex align-items-center justify-content-between flex-wrap flex-sm-nowrap">
			<!--begin::Info-->
			<div class="d-flex align-items-center flex-wrap mr-2">
				<!--begin::Page Title-->
				<h5 class="text-dark font-weight-bold mt-2 mb-2 mr-5">Pengurusan Pemohon Selain Aktif</h5>
				<!--end::Page Title-->
				<!--begin::Actions-->
				<div class="subheader-separator subheader-separator-ver mt-2 mb-2 mr-4 bg-gray-200"></div>
			</div>
			<!--end::Info-->
		</div>
	</div>
	<!--end::Subheader-->
	<!--begin::Entry-->
	<div class="d-flex flex-column-fluid">
		<!--begin::Container-->
		<div class="container">
			<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accordionExample8">
				<div class="card">
					<div class="card-header" id="headingThree8">
						<div class="card-title collapsed" data-toggle="collapse" data-target="#collapseThree8">
							<div class="card-label">													
								<span class="svg-icon svg-icon-primary menu-icon">
									<?=$Tapisanhome_svg?>
								</span>Tapisan</div>
							<span class="svg-icon">
								<?=$Tapisan_svg?>
							</span>
						</div>
					</div>
					<div id="collapseThree8" class="collapse" data-parent="#accordionExample8">
						<div class="card-body"><br>
							<?php
								createDropDown($PDO, 'DUN', 'i_dun', 'dun_sc', $my_details->user_dun, 'Semua DUN', 6, 2, 12, $readonly);
								createDropDown($PDO, 'Parlimen', 'i_parlimen', 'parlimen_sc', $my_details->user_parlimen, 'Semua Parlimen', 6, 2, 12, $readonly);
								createDropDown($PDO, 'Daerah', 'i_daerah', 'daerah_sc', $my_details->user_daerah, 'Semua Daerah', 6, 2, 12, $readonly);
								$mySQL = "SELECT id_bangsa AS id, desk_bangsa as name FROM i_bangsa WHERE id_bangsa IN (1,2,3,5) ORDER BY susunan";										
								createDropDown_sql($PDO, 'Bangsa', $mySQL, 'bangsa_sc', 0, 'Semua Bangsa', 6, 2, 12, $readonly,'');
								
								if($my_details->user_level == 8 || $my_details->user_level == 9 || $my_details->user_level == 13)
								{
									$mySQL = "SELECT id_program AS id, desk_program as name
											FROM i_program 
											WHERE id_program = 4
											ORDER BY id_program";									
									createDropDown_sql($PDO, 'Program', $mySQL, 'program_sc', 4, '', 6, 2, 12, $readonly);									
								}
								else
								{
									createDropDown($PDO, 'Program', 'i_program', 'program_sc', $indicator_List['id_program'], 'Semua Program', 6, 2, 12, $readonly);
								}
								
								$mySQL = "SELECT id_aktifmohon AS id, desk_aktifmohon as name
										FROM i_aktifmohon 
										WHERE id_aktifmohon != 1
										ORDER BY susunan";									
								createDropDown_sql($PDO, 'Status Aktif', $mySQL, 'aktifmohon_sc', 0, 'Semua Status', 6, 2, 12, $readonly);	
								createDropDown($PDO, 'Status Mohon', 'i_statusmohon', 'statusmohon_sc', $indicator_List['id_statusmohon'], 'Semua Status', 6, 2, 12, $readonly);
							?>
						</div>
					</div>
				</div>
			</div>
			<!--begin::Row-->
			<div class="row">
				<?php
					$tbColumn = array();
					$tbColumn[] = array('Bil', 5);
					$tbColumn[] = array('Tarikh Daftar', 15);
					$tbColumn[] = array('Nama Pemohon', 20);
					$tbColumn[] = array('No KP', 15);
					$tbColumn[] = array('Program', 15);
					$tbColumn[] = array('Status Permohonan', 15);
					$tbColumn[] = array('Status Aktif', 15);
					$tbColumn[] = array('Tindakan', 0);
					
					$userBtn = '';
					createTable('indicator_table', $tbColumn, 'Pengurusan Pemohon Selain Aktif', '', 1, $userBtn, 'ajax-modal', 12);
				?>
				
			</div>
			<!--end::Row-->
		</div>
		<!--end::Container-->
	</div>
	<!--end::Entry-->
</div>
<!--end::Content-->
					
<?php 
require('includes/footer.php');
?>


<script>
var ajaxUrl = $('#script_base_name').val() + "-ajax.php";
function getData()
{
	return {
		sqlOnly: 0,
		dun_sc: $('#dun_sc').val(),
		parlimen_sc: $('#parlimen_sc').val(),
		daerah_sc: $('#daerah_sc').val(),
		bangsa_sc: $('#bangsa_sc').val(),
		program: $('#program_sc').val(),
		aktifmohon_sc: $('#aktifmohon_sc').val(),
		statusmohon_sc: $('#statusmohon_sc').val(),
	};
}

function reloadTable()
{
	reinitTable($('#table_name').val(), this.ajaxUrl, this.getData(), 1, 0);
}

$(document).ready(function(){  

	$('#ajax-modal').on('shown.bs.modal', function () {  // this is to clear modal cache each time modal load
	 $(this).removeData('bs.modal');
	}); 
	
	initTable($('#table_name').val(), ajaxUrl, getData(), 1, 0);
	
	//print function
	$('#printExcel, #printPdf').click(function() {
		printFunc($('#table_name').val(), $(this).attr("value"), "normalPrint.php", $('#script_base_name').val(), $('#table_title').val(), $('#table_header').val(), getData(), $('#table_printonly_header').val(), 'L');
	});
	
	$('#dun_sc,#parlimen_sc,#daerah_sc,#bangsa_sc,#program_sc,#aktifmohon_sc,#statusmohon_sc').change(function(){
		reloadTable();
	});
});
</script>