

<!-- 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>Master - Siswa</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="role-form" class="smart-form">
				<header>
					<?php echo $header; ?>
				</header>

				<fieldset>
					
					<div class="row">
						
						<section class="col col-3">
							<label class="label">NIS</label>
							<label class="input">
								<input id="nis" disabled="disabled" type="text" name="nis"  value="<?php echo @$nis; ?>" autocomplete="off" />
							</label>
						</section>
                        <section class="col col-3">
							<label class="label">Nama Siswa</label>
							<label class="input"> 
								<input id="id_siswa" type="hidden" name ="id_siswa" value="<?php echo @$id_siswa; ?>" />
								<input id="nama" disabled="disabled" type="text" name="nama"  value="<?php echo @$nama; ?>" autocomplete="off" />
							</label>
						</section>
                        </div>
                       
                   <div class="row">
						<section class="col col-3">
							<label class="label">Sekolah</label>
							<?php echo $nama_smk; ?>
						</section>
                            
                    	<section class="col col-3">
							<label class="label">Jurusan</label>
							<?php echo $mappingJur; ?>
						</section>
                    </div>
                    <div class="row">
						<section class="col col-2">
							<label class="label">Kelas</label>							
							<?php echo $kelas; ?>
						</section>	
						<section class="col col-4">
							<label class="label">Wali Kelas</label>							
							<?php echo $mapping; ?>
						</section>
					</div>
						
                     
				</fieldset>
                
                <br />
                <header>
<?php echo "KOMPONEN BIAYA"; ?>
				</header>
                <div>
                    <fieldset>
                        <?php echo $nr. $komponen_biaya; ?>
                    </fieldset>
                </div>
                
                <br />
                <header>
<?php echo "KOMPONEN SPP"; ?>
				</header>
                <div>
                    <fieldset>
                        <?php echo $nr_spp. $komponen_spp; ?>
                    </fieldset>
                </div>
                
                
                
                <br />
                <header>
<?php echo "KOMPONEN Tabsis"; ?>
				</header>
                <div>
                    <fieldset>
                        <?php echo $nr_tabsis. $komponen_tabsis; ?>
                    </fieldset>
                </div>
                
                
                
				<footer>
					<button type="submit" name="submit" id="myBtn" class="btn btn-primary" value="<?php echo $submit; ?>" onclick="buttonDis()">
						Edit
					</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 getTypeSPP(smk) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#id-TypeSPP").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getTypeSPP"; ?>",
			data : "smk="+smk,
			success:function(msg){
				$("#id-TypeSPP").html(msg);
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function getType(id_smk) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#id-MappingType").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getType"; ?>",
			data : "id_smk="+id_smk,
			success:function(msg){
				$("#id-MappingType").html(msg);
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function cekKelas(id_smk, id_jur) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#id-MappingKls").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/cekKelas"; ?>",
			data : "id_jur="+id_jur+"&&id_smk="+id_smk,
			success:function(msg){
				$("#id-MappingKls").html(msg);
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function getJurusan(smk) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#id-MappingJur").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getJurusan"; ?>",
			data : "smk="+smk,
			success:function(msg){
				$("#id-MappingJur").html(msg);
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
	function getWaliKelas(kelas, id_mapping_jur) {
		$.ajax({
			type:"POST",
			dataType: "html",
			beforeSend : function() {
				$("#id-Mapping").html("Populating data, please wait..");
			},
			url : "<?php echo site_url("/") . $controller . "/getWaliKelas"; ?>",
			data : "kelas="+kelas+"&&id_mapping_jur="+id_mapping_jur,
			success:function(msg){
				$("#id-Mapping").html(msg);
			},
			error:function(){
				alert("Load failed");
			}
		});
	}
	
		
	$(function() {
		
		$('#fileupload').filer({
			limit: 4, // setup limit
			maxSize : 25,
            showThumbs: true,
            templates: {
                box: '<ul class="jFiler-item-list"></ul>',
                item: '<li class="jFiler-item">\
                            <div class="jFiler-item-container">\
                                <div class="jFiler-item-inner">\
                                    <div class="jFiler-item-thumb">\
                                        <div class="jFiler-item-status"></div>\
                                        <div class="jFiler-item-info">\
                                            <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        </div>\
                                        {{fi-image}}\
                                    </div>\
                                    <div class="jFiler-item-assets jFiler-row">\
                                        <ul class="list-inline pull-left">\
                                            <li><span class="jFiler-item-others">{{fi-icon}} {{fi-size2}}</span></li>\
                                        </ul>\
                                        <ul class="list-inline pull-right">\
                                            <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                        </ul>\
                                    </div>\
                                </div>\
                            </div>\
                        </li>',
                itemAppend: '<li class="jFiler-item">\
                            <div class="jFiler-item-container">\
                                <div class="jFiler-item-inner">\
                                    <div class="jFiler-item-thumb">\
                                        <div class="jFiler-item-status"></div>\
                                        <div class="jFiler-item-info">\
                                            <span class="jFiler-item-title"><b title="{{fi-name}}">{{fi-name | limitTo: 25}}</b></span>\
                                        </div>\
                                        {{fi-image}}\
                                    </div>\
                                    <div class="jFiler-item-assets jFiler-row">\
                                        <ul class="list-inline pull-left">\
                                            <span class="jFiler-item-others">{{fi-icon}} {{fi-size2}}</span>\
                                        </ul>\
                                        <ul class="list-inline pull-right">\
                                            <li><a class="icon-jfi-trash jFiler-item-trash-action"></a></li>\
                                        </ul>\
                                    </div>\
                                </div>\
                            </div>\
                        </li>',
                progressBar: '<div class="bar"></div>',
                itemAppendToEnd: true,
                removeConfirmation: true,
                _selectors: {
                    list: '.jFiler-item-list',
                    item: '.jFiler-item',
                    progressBar: '.bar',
                    remove: '.jFiler-item-trash-action',
                }
            },
            addMore: true
        });
		
		
		$('#tanggal_lahir').datetimepicker({
			format: 'YYYY-MM-DD'
		});
		
		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
		$("#role-form").validate({
			// Rules for form validation
			rules : {
				nama : {
					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'		
				},
				/*
				nisn : {
					required : true,
					number	: true,
					remote	 : {
						url		: "<?php echo base_url();?>index.php/ref_siswa/cek_nisn",
						type	: "POST",
						data: {
							nisn: function() {
								return $("#nisn").val();
							},
							id_siswa : $("#id_siswa").val()
						}
					}
				},
				*/
				nis : {
					required : true,
					remote	 : {
						url		: "<?php echo base_url();?>index.php/ref_siswa/cek_nis",
						type	: "POST",
						data: {
							nis: function() {
								return $("#nis").val();
							},
							id_siswa : $("#id_siswa").val()
						}
					}
				},
				jenis_kelamin : {
					required : true
				},
				nama_ayah : {
					required : true
				},
				smk : {
					required : true
				},
				id_mapping_jur : {
					required : true
				},
				kelas : {
					required : true
				},
				nama_ibu : {
					required : true
				},
				id_mapping_kelas : {
					required : true
				},
				nama_wali : {
					required : true
				},
				telepon_wali : {
					required : true,
					number : true
				},
				telepon : {
					required : true,
					number : true
				},
				id_type_spp : {
					required : true,
					number : true
				},
				status : {
					required : true,
					number : true
				}
			},
			
			submitHandler : function(form) {
				
				$(form).ajaxSubmit({
					/* beforeSubmit: function() {
						$("#hiddenElement").val("false");
						$("#cancel").attr("disabled","disabled");
						$("#button_id").attr("disabled","disabled");
						//$("button[type=submit]").append('<i class="fa fa-gear fa-1x fa-spin"></i>');
						$("#button_id").append('<i class="fa fa-gear fa-1x fa-spin">');
					}, */
					dataType: 'json',
					success : function(msg) {
						window.location.hash = base_url + 'index.php/<?php echo $controller; ?>/';
						/* if (msg.msg == "noauth") {
							window.location = base_url;
						}
						else if (msg.error == true) {
							write_error_html(msg.field);
							
							//button manipulating
							$("#hiddenElement").val("true");
							$(".fa-spin").remove();
							$("#cancel").removeAttr("disabled");
							$("#button_id").removeAttr("disabled");
						} else {
							window.location.hash = base_url + 'create_agent/';
						} */
					}
				});
				
			},

			// Messages for form validation
			messages : {
				nama : {
					required : 'Nama Siswa Tidak Boleh Kosong'
						
				},
				kelas : {
					required : 'Kelas Tidak Boleh Kosong'
						
				},
				id_mapping_kelas : {
					required : 'Pilih Wali Kelas'
						
				},
				nama_wali : {
					required : 'Nama Wali Tidak Boleh Kosong'
						
				},
				telepon : {
					required : 'Telepon Tidak Boleh Kosong',
					number   : 'Telepon Harus Angka'
						
				},
				telepon_wali : {
					required : 'Telepon Wali Tidak Boleh Kosong',
					number   : 'Telepon Wali Harus Angka'
						
				},
				nisn : {
					required : 'NISN Tidak Boleh Kosong',
					number : 'NISN Hanya diisi angka',
					//remote : 'NISN Sudah Di Gunakan'
				},
				nis : {
					required : 'NIS Tidak Boleh Kosong',
					remote : 'NIS Sudah Di Gunakan'
				},
				jenis_kelamin : {
					required : 'Pilih Jenis Kelamin Siswa'
				},
				nama_ayah : {
					required : 'Nama Ayah Tidak Boleh Kosong'
				},
				nama_ibu : {
					required : 'Nama Ibu Tidak Boleh Kosong'
				},
				smk : {
					required : 'SMK Tidak Boleh Kosong'
				},
				id_mapping_jur : {
					required : 'Jurusan Tidak Boleh Kosong'
				}
			},

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