<!-- Widget ID (each widget will need unique ID)-->
<div class="jarviswidget" id="wid-id-6" data-widget-editbutton="false" data-widget-custombutton="false" data-widget-deletebutton="false">
	<!-- widget options:
		usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
		
		data-widget-colorbutton="false"	
		data-widget-editbutton="false"
		data-widget-togglebutton="false"
		data-widget-deletebutton="false"
		data-widget-fullscreenbutton="false"
		data-widget-custombutton="false"
		data-widget-collapsed="true" 
		data-widget-sortable="false"
		
	-->
	<header>
		<span class="widget-icon"> <i class="fa fa-edit"></i> </span>
		<h2>Pembayaran SPP</h2>				
		
	</header>

	<!-- widget div-->
	<div>
		
		<!-- widget edit box -->
		<div class="jarviswidget-editbox">
			<!-- This area used as dropdown edit box -->
			
		</div>
		<!-- end widget edit box -->
		
		<!-- widget content -->
		<div class="widget-body no-padding">
			
			<form action="<?php echo @$action; ?>" method="post" id="crud-form" class="smart-form">
				<header>
					<?php echo $header; ?>
				</header>

				<fieldset>
                <!--
					<div class="row">
						<section class="col col-3">
							<label class="label">Nomor Transaksi</label>
							<label class="input"> 
									<input id="last_id" type="hidden" name="last_id"  value="<?php echo @$last_id; ?>"/>									
									<?php echo $faktur; ?>									
							</label>
						</section>
						
						<section class="col col-2">
							<label class="label">Tanggal Transaksi</label>							
								<label class="input"> 
									<input id="tanggaltransaksi" type="text" name="tanggal_transaksi"  value="<?php echo @$t_trans; ?>" />									
								</label>								
						</section>	
                        
                        </div>
                        -->
                        <div class="row">
                        <section class="col col-3">
							<label class="label">Sekolah</label>
							<?php echo $nama_smk; ?>
						</section>
						<?php echo $id_siswa; ?>	
					</div>
                    <div class="row">
                    	<section class="col col-3">
                        	<label class="label">Tahun Ajaran</label>
							<div id="div-thn">
							
							<?php echo $thn_ajaran; ?></div>
						</section>
                    </div>
					<div class="row">					
						<div id="div-bulan"><?php echo $bulan; ?></div>						
					</div>	
					
					<div class="row">
						
						<section class="col col-6">
							<label class="label">Besarnya</label>
							<label class="input"> 
									<div id="besar-div"><input id="besarnyaShow" type="text" name="besarnyaShow"  value="Rp 0.00" readonly="readonly" /></div>									
							</label>
						</section>		
					</div>
                    <div class="row">
						<section class="col col-6">
							<label class="label">Total Bayar</label>
							<label class="input"> 
									<div id="total-div"><input id="totalBayar" type="text" name="totalBayar"  value="Rp 0.00" readonly="readonly" /></div>									
							</label>
						</section>
					</div>		
					
				</fieldset>
				<!--<header>
					Detail Transaksi
				</header>
				
				<fieldset>
				
					<?php //echo @$trans_detail; ?>
					
					<div class="row">
						<section class="col col-2">
							<label class="label">Total Bayar</label>
							<label class="input"> 
									<div id="total-div"><input id="totalBayar" type="text" name="totalBayar"  value="0" readonly="readonly" /></div>									
							</label>
						</section>
					</div>
				
				</fieldset>	--->
				
				<footer>
					<button type="submit" id="myBtn" name="submit" class="btn btn-primary" value="<?php echo $submit; ?>" onclick="buttonDis()">
						Save
					</button>
					<button type="reset" id="cancel_create" name="cancel" class="btn btn-default" >
						Batal
					</button>
				</footer>

				<div class="message">
					<i class="fa fa-check fa-lg"></i>
					<p>
						Your comment was successfully added!
					</p>
				</div>
			</form>
			

		</div>
		<!-- end widget content -->
		
	</div>
	<!-- end widget div -->
				
</div>
<!-- end widget -->

<script type="text/javascript">
	function buttonDis() {
		document.getElementById("myBtn").style.visibility="hidden";
	}
	
	function getNama(smk) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#b_detail").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getNama"; ?>",
			data : "smk="+smk,
			success:function(msg){
				$("#b_detail").html(msg);
			},
			error:function(){
				alert(smk);
			}
		});
	}
	
	function getThnAj(id) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#div-thn").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getThnAj"; ?>",
			data : "id="+id,
			success:function(msg){
				$("#div-thn").html(msg);
			},
			error:function(){
				alert("error");
			}
		});
	}
	
	function countBulan() {
		var count = $("#bulan :selected").length;
		if (count == 0) {
			countTotal(1);
		} else {
			countTotal(count);
		}	
			
	}
	
	function getBulan(id, thn) {
		
		$.ajax({
			type:"POST",
			dataType: "html",		
			url:"<?php echo site_url("/") . $controller . "/getBulan"; ?>",
			data : "id="+id+"&thn="+thn,
			success:function(msg){
				$("#div-bulan").html(msg);										
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function getBesarnya(id, thn) {
		
		$.ajax({
			type:"POST",
			dataType: "html",		
			url:"<?php echo site_url("/") . $controller . "/getBesarnya"; ?>",
			data : "id="+id+"&thn="+thn,
			success:function(msg){
				$("#besar-div").html(msg);										
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function getTotal(id, thn) {
		
		$.ajax({
			type:"POST",
			dataType: "html",
			url:"<?php echo site_url("/") . $controller . "/getTotal"; ?>",
			data : "id="+id+"&thn="+thn,
			success:function(msg){
				$("#total-div").html(msg);
										
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function countTotal(num) {
		var besarnya = $("#besarnya").val();
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#total-div").html("Count Total, please wait..");			
			},
			url:"<?php echo site_url("/") . $controller . "/countTotal"; ?>",
			data : "num="+num+"&besarnya="+besarnya,
			success:function(msg){
				$("#total-div").html(msg);
										
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
		
	$(function() {
		
		$(".chosen-select").chosen();	
		
		$('#tanggaltransaksi').datetimepicker({
			format: 'DD-MM-YYYY'
		});
		
		alert_cancel = 'Are You Sure to cancel this form ?';
		$('#cancel_create').on('click', function () {
			if (confirm(alert_cancel)) {
				window.location.href = "<?php echo site_url('/').'home#'.$controller; ?>";
			}
		});
		
		// Validation
		$("#crud-form").validate({
			// Rules for form validation
			rules : {
				tanggal_transaksi : {
					required : true
					/*remote	 : {
						url		: "<?php echo base_url();?>index.php/adm_tahun_ajaran/cek_tahun_ajaran",
						type	: "POST",
						data: {
							tahun_ajaran: function() {
								return $("#tahun_ajaran").val();
							}
						}
					}*/	
					//remote : '<?php echo base_url();?>index.php/login/cek_user'		
				},
				id_siswa : {
					required : true
				},
				'bulan[]': {
					required: true
				}
			},
			ignore: [],
			submitHandler : function(form) {
				
				$(form).ajaxSubmit({
					dataType: 'json',
					success : function(msg) {
						window.location.hash = base_url + 'index.php/<?php echo $controller; ?>/successPage';					
					}
				});
				
			},

			// Messages for form validation
			messages : {
				tanggal_transaksi : {
					required : 'Tanggal Transaksi Harus di isi'
						
				},
				id_siswa : {
					required : 'Pilih Nama Siswa'
						
				}
			},

			// Do not change code below
			errorPlacement : function(error, element) {
				error.insertAfter(element.parent());
			}
		});		
		
	});
</script>