<?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 Borang Item</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
								$my_sql = 'SELECT id_borangdiv AS id, title as name 
										   FROM u_borangdiv 
										   ORDER BY susunan';
								createDropDown_sql($PDO, 'Div', $my_sql, 'div_sc', $indicator_List['id_borangdiv'], 'Sila Pilih', 7, 3, 12, $readonly);
							?>
						</div>
					</div>
				</div>
			</div>  
			<!--begin::Row-->
			<div class="row">
				<?php
					$tbColumn = array();
					$tbColumn[] = array('Bil', 15);
					$tbColumn[] = array('Borang Div', 30);
					$tbColumn[] = array('Jenis Input', 15);
					$tbColumn[] = array('Label', 30);
					$tbColumn[] = array('Susunan', 30);
					$tbColumn[] = array('Tindakan', 0);
					
					//$userBtn = '<a class="btn btn-primary font-weight-bolder" onclick="loadMyModal(\''.$base_name.'-tambah.php?id=0\', \'#ajax-modal\')"><span class="svg-icon svg-icon-md">'.$tambahBtnSvg.'</span>Tambah</a>';
					createTable('indikator_table', $tbColumn, 'Pengurusan Borang Item', 'Pengurusan Maklumat Borang Item', 0, $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,
		div: $('#div_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());
	});
	
	$('#div_sc').change(function(){
		reloadTable();
	});
});
</script>