<div class="box box-success b-t-non" id='panel-addKunjungan'>
	@if($statusForm == 'Tambah')
	<h4 class="labelGreen">
		<i class="fa fa-plus-square m-r-15"></i> 
	@else
	<h4 class="labelYellow">
		<i class="fa fa-pencil m-r-15"></i> 
	@endif
		Form Pemeriksaan
	</h4>
	<hr class="m-t-0">
	<form id='formTambahKunjungan'>
		{{ csrf_field() }}
		<div class="box-body">
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Kunjungan </label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<input type="hidden" name="statusForm" value="{{ $statusForm }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
						<input type="hidden" name="id_pemeriksaan" value="{{ $kunjungan->id_pemeriksaan }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
						<input type="text" name="nama_kunjungan" value="Kunjungan ke {{ $kunjungan->kunjungan }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12" readonly>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Nama Ibu</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<input type="hidden" name="bumil_id" value="{{ $kunjungan->bumil_id }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
						<input type="text" name="nama_bumil" value="{{ $kunjungan->bumil->nama_bumil }}" autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12" readonly>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group m-b-0">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Tanggal Berkunjung</label>
					<div class="col-lg-8 col-md-8 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_kunjungan' value="<?php if($statusForm == 'Tambah'){echo $tglNow;}else{echo date('d-m-Y', strtotime($kunjungan->tgl_kunjungan));} ?>" autocomplete='off' placeholder='dd-mm-yyyy' class="form-control pull-right"  id='form_datetime_pemeriksaan' data-date-format="dd-mm-yyyy" required='required' readonly>
					</div>
				</div>
			</div>
			<div class='clearfix p-b-5'></div>
			<hr class="lineTopGreen">
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Berat Badan</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="berat_badan" value="{{ $kunjungan->berat_badan }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5">Kg</label>
						</div>
						<i style="font-size: 12px">Gunakan Tanda Titik untuk mengganti Tanda Koma</i>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Tinggi Badan</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="tinggi_badan" value="{{ $kunjungan->tinggi_badan }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5">Cm</label>
						</div>
						<i style="font-size: 12px">Gunakan Tanda Titik untuk mengganti Tanda Koma</i>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>LILA (Lingkar Lengan Atas )</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="lila" value="{{ $kunjungan->lila }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5">Cm</label>
						</div>
						<i style="font-size: 12px">Gunakan Tanda Titik untuk mengganti Tanda Koma</i>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>HB</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="hb" value="{{ $kunjungan->hb }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5">g/dl</label>
						</div>
						<i style="font-size: 12px">Gunakan Tanda Titik untuk mengganti Tanda Koma</i>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Tekanan Darah (mmHG)</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 p-0">
							<label class="control-label col-lg-4 col-md-4 col-sm-6 col-xs-6 p-0" id='label-input'>Sistole</label>
							<div class="col-lg-7 col-md-7 col-sm-5 col-xs-5 p-0">
								<input type="number" name="sistole" value="{{ $kunjungan->sistole }}" min='0' autocomplete='off' class="form-control input-sm customInput">
							</div>
						</div>
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 p-0">
							<label class="control-label col-lg-4 col-md-4 col-sm-6 col-xs-6 p-0" id='label-input'>Diastole</label>
							<div class="col-lg-7 col-md-7 col-sm-5 col-xs-5 p-0">
								<input type="number" name="diastole" value="{{ $kunjungan->diastole }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Faktor Risiko</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="faktor_resiko" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='0' <?php if($kunjungan->faktor_resiko == '0'){echo "selected";} ?>> .:: Pilih Faktor ::. </option>
							<option value='1' <?php if($kunjungan->faktor_resiko == '1'){echo "selected";} ?>>KEK</option>
							<option value='2' <?php if($kunjungan->faktor_resiko == '2'){echo "selected";} ?>>Diabetes</option>
							<option value='3' <?php if($kunjungan->faktor_resiko == '3'){echo "selected";} ?>>Eklampsi</option>
							<option value='4' <?php if($kunjungan->faktor_resiko == '4'){echo "selected";} ?>>Anemia</option>
							<option value='5' <?php if($kunjungan->faktor_resiko == '5'){echo "selected";} ?>>Tidak Ada</option>
						</select>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Letak Janin</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="letak_janin" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='0' <?php if($kunjungan->letak_janin == '0'){echo "selected";} ?>> .:: Pilih Letak ::. </option>
							<option value='1' <?php if($kunjungan->letak_janin == '1'){echo "selected";} ?>>Ke</option>
							<option value='2' <?php if($kunjungan->letak_janin == '2'){echo "selected";} ?>>Su</option>
							<option value='3' <?php if($kunjungan->letak_janin == '3'){echo "selected";} ?>>Li</option>
						</select>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Denyut Jantung Janin</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="denyut_jantung_janin" value="{{ $kunjungan->denyut_jantung_janin }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5"> / Menit</label>
						</div>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Tinggi Fundus</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 p-0">
							<input type="number" name="tinggi_fundus" value="{{ $kunjungan->tinggi_fundus }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 p-0">
							<label class="m-t-5 m-l-5"> Cm</label>
						</div>
						<i style="font-size: 12px">Gunakan Tanda Titik untuk mengganti Tanda Koma</i>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Kaki Bengkak</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="kaki_bengkak" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='0' <?php if($kunjungan->kaki_bengkak == '0'){echo "selected";} ?>> .:: Pilih Keadaan Kaki ::. </option>
							<option value='1' <?php if($kunjungan->kaki_bengkak == '1'){echo "selected";} ?>>Ya</option>
							<option value='2' <?php if($kunjungan->kaki_bengkak == '2'){echo "selected";} ?>>Tidak</option>
						</select>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Imunisasi TT</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="imunisasi_tt" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='0' <?php if($kunjungan->imunisasi_tt == '0'){echo "selected";} ?>> .:: Pilih Tindakan ::. </option>
							<option value='1' <?php if($kunjungan->imunisasi_tt == '1'){echo "selected";} ?>>Ya</option>
							<option value='2' <?php if($kunjungan->imunisasi_tt == '2'){echo "selected";} ?>>Tidak</option>
						</select>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Konsumsi Suplemen Fe</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="suplemen_fe" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='0' <?php if($kunjungan->suplemen_fe == '0'){echo "selected";} ?>> .:: Pilih Tindakan ::. </option>
							<option value='1' <?php if($kunjungan->suplemen_fe == '1'){echo "selected";} ?>>Ya</option>
							<option value='2' <?php if($kunjungan->suplemen_fe == '2'){echo "selected";} ?>>Tidak</option>
						</select>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<!-- <div class='clearfix p-b-5'></div> -->
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Konsumsi Protein Hewani per Hari</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 p-0">
							<select name="protein_hewani" id='proteinHewani' class="form-control input-sm customInput col-md-7 col-xs-12">
								<option value='0' <?php if($kunjungan->protein_hewani == '0'){echo "selected";} ?>> .:: Pilih Jumlah ::. </option>
								<option value='1' <?php if($kunjungan->protein_hewani == '1'){echo "selected";} ?>>1 Kali</option>
								<option value='2' <?php if($kunjungan->protein_hewani == '2'){echo "selected";} ?>>2 Kali</option>
								<option value='3' <?php if($kunjungan->protein_hewani == '3'){echo "selected";} ?>>3 Kali</option>
								<option value='4' <?php if($kunjungan->protein_hewani == '4'){echo "selected";} ?>>4 Kali</option>
								<option value='5' <?php if($kunjungan->protein_hewani == '5'){echo "selected";} ?>>Lainnya</option>
							</select>
						</div>
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 p-0 p-l-5" id='proteinHewaniLain' <?php if($kunjungan->protein_hewani != '5'){ echo 'style="display: none;"';} ?>>
							<div class="col-lg-8 col-md-8 col-sm-6 col-xs-6 p-0">
								<input type="number" name="protein_hewani_lain" value="{{ $kunjungan->protein_hewani_lain }}" min='0' autocomplete='off' class="form-control input-sm customInput col-md-7 col-xs-12">
							</div>
							<div class="col-lg-4 col-md-4 col-sm-6 col-xs-6 p-0">
								<label class="m-t-5 m-l-5"> Kali</label>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class='col-lg-6 col-md-6 col-sm-12 col-xs-12 p-0 p-b-5'>
				<div class="form-group">
					<label class="control-label col-lg-4 col-md-4 col-sm-12 col-xs-12" id='label-input'>Status Kehamilan</label>
					<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
						<select name="status" required="required" class="form-control input-sm customInput col-md-7 col-xs-12">
							<option value='' disabled selected> .:: Pilih Status ::. </option>
							<option value='Hamil' <?php if($kunjungan->status == 'Hamil'){echo "selected";} ?>>Hamil</option>
							<option value='Melahirkan' <?php if($kunjungan->status == 'Melahirkan'){echo "selected";} ?>>Melahirkan</option>
							<option value='Anak Meninggal' <?php if($kunjungan->status == 'Anak Meninggal'){echo "selected";} ?>>Anak Meninggal</option>
							<option value='Abortus' <?php if($kunjungan->status == 'Abortus'){echo "selected";} ?>>Abortus</option>
						</select>
					</div>
				</div>
				<div class='clearfix p-b-5'></div>
			</div>
			<div class='clearfix p-b-10'></div>
		</div>
		<div class="box-footer">
			<button type="submit" id='btn-simpan' 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-addKunjungan').animateCss('bounceInUp');
	})();

	$('.btn-cancel').click(function(e){
    	e.preventDefault();
    	$('#panel-addKunjungan').animateCss('bounceOutDown');
    	$('.other-kunjungan').fadeOut(function(){
    		$('.other-kunjungan').empty();
            $('#mainKunjungan').fadeIn();
        });
    });

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

    $('#proteinHewani').change(function(){
    	var proteinHewani= $('#proteinHewani').val();
    	if (proteinHewani != '5') {
    		$('#proteinHewaniLain').hide();
    	}else{
    		$('#proteinHewaniLain').show();
    	}
    });
    
    // $('#statusKehamilan').change(function(){
    // 	var statusKehamilan= $('#statusKehamilan').val();
    // 	if (statusKehamilan != 'Hamil') {
    // 		$('#ketKehamilan').show();
    // 	}else{
    // 		$('#ketKehamilan').hide();
    // 	}
    // });

    $('#btn-simpan').click(function(e){
    	e.preventDefault();
    	var data  = new FormData($('#formTambahKunjungan')[0]);
    	data.append('statusSimpan','1');
    	var sttForm = "{{ $statusForm }}";
    	if(sttForm == 'Tambah'){
    		var textPop = "Data Pemeriksaan Ibu akan di Simpan dan hanya bisa di edit selama 3 hari sejak tanggal penyimpanan!";
    	}else{
    		var textPop = "Data Pemeriksaan Ibu akan di Simpan dan hanya bisa di edit selama 3 hari sejak tanggal pertama penyimpanan!";
    	}
    	swal(
			{
				title: "Apa anda yakin dengan informasi data Pemeriksaan Ibu Ini?",
				text: textPop,
				type: "warning",
				showCancelButton: true,
				confirmButtonColor: "#DD6B55",
				confirmButtonText: "Saya yakin!",
				cancelButtonText: "Batal!",
				closeOnConfirm: false
			},
			function(){
			    $.ajax({
			        url: "{{ route('updateKunjungan') }}",
			        type: 'POST',
			        data: data,
			        enctype: 'multipart/form-data',
			        async: true,
			        cache: false,
			        contentType: false,
			        processData: false
			     }).done(function(data){
			     	$('#formTambahKunjungan').validate(data, 'has-error');
		    		if(data.status == 'success'){
		    			swal("Berhasil !", "Pemeriksaan Berhasil di Simpan !", "success");
				        e.preventDefault();
				    	$('#panel-addKunjungan').animateCss('bounceOutDown');
				    	$('.other-kunjungan').fadeOut(function(){
				    		$('.other-kunjungan').empty();
				            $('#mainKunjungan').fadeIn();
				        });
				        reloadKunjungan();
		    		} else if(data.status == 'failed'){
		    			swal("Maaf !!!", "Pemeriksaan Gagal di Simpan !", "warning");
		    		} else {
		    			swal("Maaf !!!", "Silahkan periksa inputan Anda !!", "warning");
		    			$('#btn-save').animateCss('shake', function(){
		    				swal('Perhatian', 'Mohon periksa inputan anda', 'warning');
		    			});
		    		}
		    	});
			}
		);
    });
</script>