<div class="modal fade" id="detail-dialog" tabindex="-1" role="dialog" aria-labelledby="product-detail-dialog">
	<div class="modal-dialog modal-lg" >
		<div class="modal-content">
			<div class="modal-header" style="border-bottom:none;">
				<button type="button" class="close" data-dismiss="modal" id='custom-close' aria-label="Close"><span aria-hidden="true">&times;</span></button>
			</div>
			<div class="modal-body">
				<form id='formAnak'>
					<label class="control-label col-lg-12 col-md-12 col-sm-12 col-xs-12 t-a-center" id='label-input' style="font-size: 22px;margin-bottom: 0px;">Jumlah Anak</label>
					<label class="control-label col-lg-12 col-md-12 col-sm-12 col-xs-12 t-a-center" id='label-input' style="font-size: 18px;font-weight: 500;">yang dilahirkan</label>
					<div class="form-group">
						<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
							<input type="hidden" name="periode_id" value="<?php echo e($periode->id_periode); ?>" id="periodeId">
							<input type="number" name="jumlah_anak" min='0' autocomplete='off' required="required" class="form-control input-sm customInput col-md-7 col-xs-12" style="font-size: 28px;height: 50px;border-radius: 5px;text-align: center;">
						</div>
					</div>
				</form>
				<div class="clearfix"></div>
			</div>
			<div class="modal-footer t-a-center" style="border-bottom:solid 20px #ff86ff">
				<button type="button" id='btn-simpan' class="btn btn-lg btn-info" style="width: 100px;font-weight: 800;font-size: 18px;">OK</button>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var onLoad = (function() {
		$('#detail-dialog').find('.modal-dialog').css({
			'width'     : '50%'
		});
		$('#detail-dialog').modal('show');
	})();
	$('#detail-dialog').on('hidden.bs.modal', function () {
		$('.modal-dialog').html('');
	})

	$('#btn-simpan').click(function(e){
		var id_periode = <?php echo e($periode->id_periode); ?>;
    	e.preventDefault();
    	var data  = new FormData($('#formAnak')[0]);
    	swal(
			{
				title: "Apa anda yakin dengan informasi jumlah anak yang di lahirkan?",
				text: "Jumlah anak akan di Simpan dan tidak dapat di tambah ataupun dikurangi!",
				type: "warning",
				showCancelButton: true,
				confirmButtonColor: "#DD6B55",
				confirmButtonText: "Saya yakin!",
				cancelButtonText: "Batal!",
				closeOnConfirm: false
			},
			function(){
			    $.ajax({
			        url: "<?php echo e(route('addAnak')); ?>",
			        type: 'POST',
			        data: data,
			        enctype: 'multipart/form-data',
			        async: true,
			        cache: false,
			        contentType: false,
			        processData: false
			     }).done(function(data){
		    		if(data.status == 'success'){
		    			$('#detail-dialog').modal('hide');
		    			$('.loading').show();
						// $('#mainKunjungan').hide();
						$('.main-layer').hide();
						swal({
							title : "Berhasil",
							text : "Jumlah Anak Berhasil Dibuat !",
							type : "success",
							timer: 2000,
							showConfirmButton: false
						});
				        e.preventDefault();
				        $.post("<?php echo route('main1000hpk'); ?>", {id:id_periode}).done(function(data){
							if(data.status == 'success'){
								$('.loading').hide();
								// $('.other-kunjungan').html(data.content).fadeIn();
								$('.other-page').html(data.content).fadeIn();
							} else {
								// $('#mainKunjungan').show();
								$('.main-layer').show();
							}
						});
				        // reloadKunjungan();
		    		} else if(data.status == 'failed'){
		    			swal("Maaf !!!", "Kunjungan Pemeriksaan Gagal ditambahkan !", "warning");
		    		} else {
		    			swal("Maaf !!!", "Silahkan periksa inputan Anda !!", "warning");
		    			$('#btn-simpan').animateCss('shake', function(){
		    				swal('Perhatian', 'Mohon periksa inputan anda', 'warning');
		    			});
		    		}
		    	});
			}
		);
    });
</script>