<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 Periode Kehamilan
	</h4>
	<hr class="m-t-0">
	<form id='form-g'>
		{{ csrf_field() }}
		<div class="box-body">
			<div class='col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-1 col-md-offset-1 p-0'>
				<div class="form-group">
					<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="hidden" name="id_periode" value="{{ $periode->id_periode }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
						<input type="text" name="nik" value="{{ $periode->bumil->nik }}" autocomplete='off' required="required" 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 Ibu Hamil</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="text" name="nama_bumil" value="{{ $periode->bumil->nama_bumil }}" autocomplete='off' required="required" 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'>Usia Ibu (Tahun)</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="number" min="0" name="usia_ibu" value="{{ $periode->usia_ibu }}" autocomplete='off' required="required" 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'>Usia Kehamilan (Minggu)</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="number" min="0" name="usia_kehamilan" value="{{ $periode->usia_kehamilan }}" autocomplete='off' required="required" 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'>Kehamilan Ke</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<input type="number" name="kehamilan" value="{{ $periode->kehamilan }}" autocomplete='off' required="required" 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'>Jarak Kehamilan</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<div class="col-lg-5 col-md-6 col-sm-6 col-xs-6 p-0">
							<label class="control-label col-lg-3 col-md-3 col-sm-4 col-xs-4 p-0" id='label-input'>Tahun</label>
							<div class="col-lg-8 col-md-8 col-sm-4 col-xs-6 p-0">
								<input type="number" name="jarak_tahun" value="{{ $periode-> jarak_tahun }}" min="0" autocomplete='off' required="required" class="form-control input-sm customInput">
							</div>
						</div>
						<div class="col-lg-5 col-md-6 col-sm-6 col-xs-6 p-0">
							<label class="control-label col-lg-3 col-md-3 col-sm-4 col-xs-4 p-0" id='label-input'>Bulan</label>
							<div class="col-lg-8 col-md-8 col-sm-4 col-xs-6 p-0">
								<input type="number" name="jarak_bulan" value="{{ $periode->jarak_bulan }}" min="0" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							</div>
						</div>
					</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'>Golongan Darah</label>
					<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
						<select name="gol_darah" required="required" class="form-control input-sm customInput col-md-7 col-xs-12" id='golDars'>
							<option value=''> .:: Pilih Golongan Darah ::. </option>
							<option value='A' <?php if($periode->gol_darah == 'A'){echo "selected";} ?>>A</option>
							<option value='B' <?php if($periode->gol_darah == 'B'){echo "selected";} ?>>B</option>
							<option value='AB' <?php if($periode->gol_darah == 'AB'){echo "selected";} ?>>AB</option>
							<option value='O' <?php if($periode->gol_darah == 'O'){echo "selected";} ?>>O</option>
							<option value='Rh-' <?php if($periode->gol_darah == 'Rh-'){echo "selected";} ?>>Rh-</option>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
			</div>
			<div class='clearfix p-b-5'></div>
		</div>
		<div class="box-footer">
			<button type="submit" id='btn-save' class="btn btn-primary pull-right m-l-15">Simpan <span class="fa fa-save"></span></button>
			<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-addKunjungan').animateCss('bounceOutDown');
    	$('.other-kunjungan').fadeOut(function(){
    		$('.other-kunjungan').empty();
            $('#mainKunjungan').fadeIn();
        });
    });

    $('#golDars').chosen();

	$('#btn-save').click(function(e){
    	e.preventDefault();
    	var data  = new FormData($('#form-g')[0]);
	    $.ajax({
	        url: "{{ route('editKehamilan') }}",
	        type: 'POST',
	        data: data,
	        enctype: 'multipart/form-data',
	        async: true,
	        cache: false,
	        contentType: false,
	        processData: false
	     }).done(function(data){
	     	$('#form-g').validate(data, 'has-error');
    		if(data.status == 'success'){
    			swal("Berhasil !", "Periode Kehamilan Berhasil Dibuat !", "success");
		        e.preventDefault();
		    	$('#panel-add').animateCss('bounceOutDown');
		    	$('.other-kunjungan').fadeOut(function(){
		    		$('.other-kunjungan').empty();
		            $('#mainKunjungan').fadeIn();
		        });
		        reloadKunjungan();
    		} else if(data.status == 'failed'){
    			swal("Maaf !!!", data.message, "warning");
    		} else {
    			swal("Maaf !!!", "Silahkan periksa inputan Anda !!", "warning");
    			$('#btn-save').animateCss('shake', function(){
    				swal('Perhatian', 'Mohon periksa inputan anda', 'warning');
    			});
    		}
    	});
    });
</script>