<?php 
include_once ("includes/setup.inc.php");

$script_base = 'pht_listjanji';
$myID = fetch_postget_val('appointment',$_POST, $_GET);

?>
<div class="modal-header">
	<h5 class="modal-title">Start Checking</h5>
	<button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeBtn" name="closeBtn" ></button>
</div>
<div class="modal-body">
	<form action="javascript:;" class="form-horizontal" name="indicator_form" id="indicator_form">
		<div class="form-body">
			<div class="row">
				<?php
					include_once ("general-appointment_detail.php");
				?>
				<div class="col-md-12" style="text-align:center">
					<button type="button" class="btn btn-primary" id="confirmBtn">Start Checking</button>
				</div>
			</div>
			
		</div>
	</form>
</div>
<div class="modal-footer">
	<?php
		//echo '<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>';
		if($readonly == 0)
		{
			//echo '<button type="button" class="btn btn-primary" id="appointment_simpanBtn">Simpan</button>';
		}
	?>
</div>

<script>
$(document).ready(function(){  

	$('.select2').select2({ width: '100%' }); 
	
	$('.numonly').keypress(function(evt){
		evt = (evt) ? evt : window.event;
		var charCode = (evt.which) ? evt.which : evt.keyCode;
		if ((charCode >= 48 && charCode <= 57)) {
			return true;
		}
		return false;
	});
	
	$('#confirmBtn').click(function() {
		/*
		var indicator_list = [[]];
		indicator_list.push(['klinik_vat', 'Klinik Vaterinar', 'dd']);
		indicator_list.push(['id_pet', 'Haiwan Peliharaan', 'dd']);
		indicator_list.push(['tkh_appointment', 'Tarikh Temu Janji', 'tb']);
		indicator_list.push(['timeslot', 'Masa Temu Janji', 'dd']);
		*/
		//if (checkInput(indicator_list))
		{
			$(this).prop("disabled",true);
			//var param = $('#indicator_form').serialize();
			$.ajax({
				type: "POST", 
				url: "pht_listjanji-start_checking_insert.php", 
				data: 'id=' + "<?=$myID?>",

				success: function(res){
					
					$(this).prop("disabled",false);
					if(res > 0)
					{
						swal.fire({
							text: "Confirmed Start Checking",
							icon: "success",
							buttonsStyling: false,
							confirmButtonText: "OK!",
							customClass: {
								confirmButton: "btn font-weight-bold btn-light-primary"
							}
						}).then(function() {
							window.parent.reloadTable();
							$("#closeBtn").click();
						});
					}
					else
					{
						swal.fire({
							text: "Error. " + res,
							icon: "error",
							buttonsStyling: false,
							confirmButtonText: "OK!",
							customClass: {
								confirmButton: "btn font-weight-bold btn-light-primary"
							}
						}).then(function() {
							$(this).prop("disabled",false);										
						});
					}
					
				} 
			});  //end ajax
		}
	});		
});		
</script>