<div class="box box-success b-t-non" id='panel-add'>
	<h4 class="labelYellow">
		<i class="fa fa-pencil m-r-15"></i> Form Edit
	</h4>
	<hr class="m-t-0">
	<form method='post' action="<?php echo e(route('editBidan')); ?>" enctype='multipart/form-data'>
		<?php echo e(csrf_field()); ?>

		<div class="box-body">
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0'>
				<div class="form-group" id='gr_mail'>
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Email</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<?php if(!empty($asal)): ?>
							<input type="hidden" name="asal" value='<?php echo e($asal); ?>' required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						<?php endif; ?>
						<input type="hidden" name="id_bidan" value="<?php echo e($bidan->id_bidan); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						<input type="text" name="email" value="<?php echo e($bidan->users->email); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12" readonly>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group" id='gr_nik'>
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>NIK</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="number" name="nik" value="<?php echo e($bidan->users->nik); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12" readonly>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Nama Lengkap</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="text" name="nama" value="<?php echo e($bidan->nama_bidan); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group m-b-0">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Tanggal Lahir</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12 input-group p-t-0 p-b-0 p-l-15 p-r-15">
						<div class="input-group-addon">
							<i class="fa fa-calendar"></i>
						</div>
						<input type="text" name='tgl_lahir' value="<?php echo e(date('d-m-Y', strtotime($bidan->tgl_lahir))); ?>" autocomplete='off' placeholder='dd-mm-yyyy' class="form-control pull-right"  id='form_datetime_today' data-date-format="dd-mm-yyyy" required='required'>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Jenis Kelamin</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<select name="jenis_kelamin" required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='' disabled selected> .:: Pilih Jenis Kelamin ::. </option>
							<option value='Laki-Laki' <?php if($bidan->jenis_kelamin == "Laki-Laki"){echo "selected";} ?>>Laki-Laki</option>
							<option value='Perempuan' <?php if($bidan->jenis_kelamin == "Perempuan"){echo "selected";} ?>>Perempuan</option>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Alamat</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="text" name="alamat" value="<?php echo e($bidan->alamat); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Provinsi</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<select name="provinsi_id" id='provinsi' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='' disabled selected> .:: Pilih Provinsi ::. </option>
							<?php foreach($provinsis as $provinsi): ?>
								<option value='<?php echo e($provinsi->id_provinsi); ?>' <?php if($provinsi->id_provinsi == $bidan->provinsi_id){echo "selected";} ?>><?php echo e($provinsi->nama_provinsi); ?></option>
							<?php endforeach; ?>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Kabupaten</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<select name="kabupaten_id" id='kabupaten' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='' disabled selected> .:: Pilih Kabupaten ::. </option>
							<?php foreach($kabupatens as $kabupaten): ?>
								<option value='<?php echo e($kabupaten->id_kabupaten); ?>' <?php if($kabupaten->id_kabupaten == $bidan->kabupaten_id){echo "selected";} ?>><?php echo e($kabupaten->nama_kabupaten); ?></option>
							<?php endforeach; ?>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Kecamatan</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<select name="kecamatan_id" id='kecamatan' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='' disabled selected> .:: Pilih Kecamatan ::. </option>
							<?php foreach($kecamatans as $kecamatan): ?>
								<option value='<?php echo e($kecamatan->id_kecamatan); ?>' <?php if($kecamatan->id_kecamatan== $bidan->kecamatan_id){echo "selected";} ?>><?php echo e($kecamatan->nama_kecamatan); ?></option>
							<?php endforeach; ?>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
				<div class="form-group">
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>No Telp</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="text" name="no_tlp" value="<?php echo e($bidan->no_tlp); ?>" required="required" autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
					</div>
				</div>
				<?php if(empty($asal)): ?>
					<div class='clearfix p-b-5'></div>
					<div class="form-group">
						<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Sebagai Bikor</label>
						<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
							<input type="checkbox" name='bikor' value='bikor' class="form-check customCheck" id='bikor1' <?php if($bidan->users->level_user == '2'){echo "checked";} ?> <?php if(!empty($asal)){echo "disabled";} ?>><label class="labelRadio" for="bikor1">Ya</label>
						</div>
					</div>
					<div class='clearfix p-b-5'></div>
					<div class="form-group">
						<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Puskesmas / RS</label>
						<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
							<select name="pusat_kesehatan_id" id='pusKes' required="required" class="form-control input-sm customInput col-md-7 col-xs-12" <?php if(!empty($asal)){echo "disabled";} ?>>
								<option value='' disabled selected> .:: Pilih Puskesmas / Rumah Sakit ::. </option>
								<?php foreach($pusKess as $pusKes): ?>
									<option value='<?php echo e($pusKes->id_pusat_kesehatan); ?>' <?php if (Sentinel::getUser()->level_user == 1) { if($pusKes->id_pusat_kesehatan == $bidan->pusat_kesehatan_id){ echo "selected"; } }elseif (Sentinel::getUser()->level_user == 6) { if($pusKes->id_pusat_kesehatan == $infoPus->id_pusat_kesehatan){ echo "selected"; } } ?> ><?php echo e($pusKes->nama); ?></option>
								<?php endforeach; ?>
							</select>
						</div>
					</div>
				<?php endif; ?>
				<div class='clearfix p-b-5'></div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0'>
				<div class="form-group">
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12 col-lg-offset-3 col-md-offset-3">
						<div class="crop-edit">
							<center>
								<?php if($bidan->users->foto != null): ?>
									<img id="preview-photo" src="<?php echo url('dist/img/users/'.$bidan->users->foto); ?>" class="img-polaroid" width="250">
								<?php else: ?>
									<img id="preview-photo" src="<?php echo url('dist/img/default_image.jpg'); ?>" class="img-polaroid" width="250">
								<?php endif; ?>
							</center>
						</div>
					</div>
					<div class='clearfix p-b-5'></div>
					<label class="control-label col-lg-3 col-md-3 col-sm-12 col-xs-12" id='label-input'>Foto</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="file" class="upload" onchange="loadFilePhoto(event)" name="foto" accept="image/*" class="form-control customInput input-sm col-md-7 col-xs-12">
						<i>* Kosongi jika foto tidak ingin dirubah</i>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
			</div>
			<div class='clearfix p-b-5'></div>
		</div>
		<div class="box-footer">
			<span id='tombol'>
			<button type="submit" class="btn btn-primary pull-right m-l-15">Simpan <span class="fa fa-save"></span></button>
			</span>
			<button type="button" class="btn btn-warning btn-cancel pull-right"><span class="fa fa-chevron-left"></span> Kembali</button>
		</div>
	</form>
</div>
<script type="text/javascript">
	var onLoad = (function() {
		$('#panel-add').animateCss('bounceInUp');
	})();

	$('.btn-cancel').click(function(e){
    	e.preventDefault();
    	$('#panel-add').animateCss('bounceOutDown');
    	$('.other-page').fadeOut(function(){
    		$('.other-page').empty();
            $('.main-layer').fadeIn();
        });
    });

    function loadFilePhoto(event) {
        var image = URL.createObjectURL(event.target.files[0]);
        $('#preview-photo').fadeOut(function(){
        	$(this).attr('src', image).fadeIn().css({
        		'-webkit-animation' : 'showSlowlyElement 700ms',
        		'animation'         : 'showSlowlyElement 700ms'
        	});
        });
    };

    $('#form_datetime_today').datetimepicker({
        weekStart: 2,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
    });

	$('#provinsi').chosen();
	$('#kabupaten').chosen();
	$('#kecamatan').chosen();
	$('#kecamatanTgs').chosen();
	$('#pusKes').chosen();
	$('#provinsi').change(function(){
    	var id= $('#provinsi').val();
    	$.post("<?php echo route('getKabupaten'); ?>", {id :id }).done(function(data){
    		var listKab = '<option value="" disabled selected> .:: Pilih Kabupaten ::. </option>';
    		if(data.length > 0){
    			$.each(data, function(k,v){
    				listKab += '<option value="'+v.id_kabupaten+'">'+v.nama_kabupaten+'</option>';
    			});
    		}
    		$('#kabupaten').html(listKab);
    		$('#kabupaten').trigger('chosen:updated');
    	});
    });
	$('#kabupaten').change(function(){
    	var id= $('#kabupaten').val();
    	$.post("<?php echo route('getKecamatan'); ?>", {id :id }).done(function(data){
    		var listKec = '<option value="" disabled selected> .:: Pilih Kecamatan ::. </option>';
    		if(data.length > 0){
    			$.each(data, function(k,v){
    				listKec += '<option value="'+v.id_kecamatan+'">'+v.nama_kecamatan+'</option>';
    			});
    		}
    		$('#kecamatan').html(listKec);
    		$('#kecamatan').trigger('chosen:updated');
    	});
    });
</script>