

<!-- 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 - Karyawan</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-2">
							<label class="label">NIK</label>
							
								<label class="input"> 
									<input id="nik" type="text" name="nik"  value="<?php echo @$nik; ?>" autocomplete="off" />									
								</label>
								
						</section>	
					
						<section class="col col-3">
							<label class="label">Nama Karyawan</label>
							<label class="input"> 
								<input id="id" type="hidden" name ="id" value="<?php echo @$id; ?>" />
								<input id="nama_karyawan" type="text" name="nama_karyawan"  value="<?php echo @$nama_karyawan; ?>" autocomplete="off" />
							</label>
						</section>
						
						<section class="col col-2">
							<label class="label">Jabatan</label>
							<label class="input"> 
								<?php echo $jabatan; ?>
							</label>
						</section>

						<section class="col col-2">
							<label class="label">Bidang Studi</label>
							<label class="input"> 
								<input id="bidang_studi" type="text" name="bidang_studi"  value="<?php echo @$bidang_studi; ?>" autocomplete="off" />
							</label>
						</section>			
					</div>
					
					<div class="row">
						
						
						<section class="col col-2">
							<label class="label">Jenis Kelamin</label>
							<?php echo $jenis_kelamin; ?>
						</section>
						
						<section class="col col-2">
							<label class="label">Agama</label>
							<label class="input"> 
								<input id="agama" type="text" name="agama"  value="<?php echo @$agama; ?>" autocomplete="off" />
							</label>
						</section>
						
						<section class="col col-3">
							<label class="label">Pendidikan</label>
								<?php echo $pendidikan; ?>
						</section>
						
					</div>
					
					<div class="row">
						<section class="col col-2">
							<label class="label">Tempat Lahir</label>
							<label class="input"> 
								<input id="tempat_lahir" type="text" name="tempat_lahir"  value="<?php echo @$tempat_lahir; ?>" autocomplete="off" />
							</label>
						</section>
						
						<section class="col col-2">
							<label class="label">Tanggal Lahir</label>
							<label class="input"> 
								<div id="datetimepicker" class="input-group">
									<input id="tanggal_lahir" type="text" name="tanggal_lahir"  value="<?php echo @$tanggal_lahir; ?>" autocomplete="off" />
								<span class="input-group-addon">
								<span class="glyphicon glyphicon-calendar"></span>
								</span>
							</div>
							
								
							</label>
						</section>					
						
					</div>
					
					<div class="row">
						
						<section class="col col-4">
							<label class="label">Unit Kerja</label>
							<label class="input"> 
								<input id="unit_kerja" type="text" name="unit_kerja"  value="<?php echo @$unit_kerja; ?>" autocomplete="off" />
							</label>
						</section>
						
						<section class="col col-1">
							<label class="label">Masa Kerja</label>
							<label class="input"> 
								<input id="masa_kerja" type="text" name="masa_kerja"  value="<?php echo @$masa_kerja; ?>" autocomplete="off" />
							</label>
						</section>
						
						<section class="col col-2">
							<label class="label">Tanggal Masuk</label>
							<label class="input"> 
								<div id="datetimepicker" class="input-group">
									<input id="tanggal_masuk" type="text" name="tanggal_masuk"  value="<?php echo @$tanggal_masuk; ?>" autocomplete="off" />
								<span class="input-group-addon">
								<span class="glyphicon glyphicon-calendar"></span>
								</span>
							</label>
						</section>
						
					
					</div>
					
					<div class="row">
							
						<section class="col col-6">
							<label class="label">Alamat</label>
							
							<label class="textarea">
								<textarea class="custom-scroll" name="alamat" rows="3"><?php echo @$alamat; ?></textarea>
							</label>
							
						</section>
						
						<section class="col col-2">
							<label class="label">Telepon</label>
							<label class="input"> 
								<input id="telepon" type="text" name="telepon"  value="<?php echo @$telepon; ?>" autocomplete="off" />
							</label>
						</section>	
						
					</div>
					
					
				</fieldset>

				<footer>
					<button type="submit" name="submit" class="btn btn-primary" value="<?php echo $submit; ?>">
						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() {
	
		$('#tanggal_lahir').datetimepicker({
			format: 'YYYY-MM-DD'
		});
		
		$('#tanggal_masuk').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
		$("#crud-form").validate({
			// Rules for form validation
			rules : {
				nama_karyawan : {
					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'		
				},
				nik : {
					required : true,
					remote	 : {
						url		: "<?php echo base_url();?>index.php/ref_karyawan/cek_nik",
						type	: "POST",
						data: {
							nik: function() {
								return $("#nik").val();
							},
							id : $("#id").val()
						}
					}
				},
				jabatan : {
					required : true
				},
				jenis_kelamin : {
					required : true
				},
				agama : {
					required : true
				},
				pendidikan : {
					required : true
				},
				unit_kerja : {
					required : true
				},
				telepon : {
					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_karyawan : {
					required : 'Kolom Nama Karyawan Tidak Boleh Kosong'
						
				},
				nik : {
					required : 'Kolom NIK Tidak Boleh Kosong',
					remote	 : 'NIK Sudah Di Pakai'
						
				},
				jabatan : {
					required : 'Pilih Jabatan'
						
				},
				pendidikan : {
					required : 'Pilih Pendidikan'
						
				},
				jenis_kelamin : {
					required : 'Pilih Jenis Kelamin'
						
				},
				unit_kerja : {
					required : 'Kolom Unit Kerja Tidak Boleh Kosong'
						
				},
				agama : {
					required : 'Kolom Agama Tidak Boleh Kosong'
						
				},
				telepon : {
					number : 'Telepon Harus Angka'
				}
			},

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