<?php $__env->startSection('extended_css'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
	<section class="content-header">
		<h1>
			<?php echo e($title); ?>

			<?php if(!empty($smallTitle)): ?>
			<small><?php echo e($smallTitle); ?></small>
			<?php endif; ?>
		</h1>
		<ol class="breadcrumb">
			<li><a href="<?php echo e(route('home')); ?>"><i class="fa fa-dashboard"></i> Home</a></li>
			<li class="active"><?php echo e($title); ?></li>
		</ol>
	</section>

	<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
		<div class="loading" align="center" style="display: none;">
			<img src="<?php echo url('dist/img/loading.gif'); ?>" width="60%">
		</div>
	</div>

	<section class="content">
		<div class="row">
			<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
				<div class="box box-success main-layer b-t-non">
					<h4 class="labelGreen">
						<i class="fa fa-heartbeat m-r-15"></i> Cari Ibu Hamil
					</h4>
					<hr class="m-t-0">
					<div class="box-body">
						<form id='formSearchBumil'>
							<div class="col-lg-6 col-md-6 col-sm-8 col-xs-12 form-group main-layer p-5 m-0">
								<label class='control-label col-lg-2 col-md-3 col-sm-4 col-xs-12 p-0 p-t-5'>NIK Ibu Hamil</label>
								<div class="col-lg-10 col-md-9 col-sm-8 col-xs-12 p-0">
									<input type="number" name="nikBumil" id='nikBumil' autocomplete='off' class="form-control input-sm customInput">
								</div>
							</div>
							<button class="col-lg-2 col-md-2 col-sm-4 col-xs-12 btn btn-success btn-sm m-t-5" id='cariBumil'><i class="fa fa-search"></i> Cari Ibu Hamil</button>
						</form>
						<div class="clearfix m-b-5"></div>
					</div>
					<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
						<div class="loadingResult" align="center" style="display: none;">
							<img src="<?php echo url('dist/img/loading.gif'); ?>" width="60%">
						</div>
					</div>
					<div class="result-page p-0"></div>
					<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 noResult" style="display: none;">
						<h4 class="labelGreen m-b-10 t-a-justify">
							<i class="fa fa-puzzle-piece m-r-15"></i> Hasil Pencarian
						</h4>
						<img src="<?php echo url('dist/img/transparant.png'); ?>" class='notFound'>
					</div>
					<div class='clearfix'></div>
				</div>
				<div class="other-page"></div>
				<div class="modal-dialog"></div>
			</div>
		</div>
	</section>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
	<script type="text/javascript">
		$('#cariBumil').click(function(e){
    		e.preventDefault();
    		reloadResult();
    	});

    	function reloadResult() {
			$('.loadingResult').show();
			var nik = $('#nikBumil').val();
			var level_user = <?php echo e(Sentinel::getUser()->level_user); ?>;
			$.post("<?php echo route('searchBumil'); ?>", {nik:nik}).done(function(data){
				if(data.status == 'success'){
					var searchResult = '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 p-0">';
					searchResult += '<h4 class="labelGreen m-b-10">';
					searchResult += '<i class="fa fa-puzzle-piece m-r-15"></i> Hasil Pencarian';
					searchResult += '</h4>';
					searchResult += '<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 lineRight">';
					searchResult += '<div class="panelResurt" align="center">';
					searchResult += '<div class="col-lg-12 p-0">';
					if (data.bumil.foto != "") {
						var linkDepan = '<?php echo url(Session::get("url_server1")."/dist/img/ibuHamil/"); ?>';
	        			var link = linkDepan+'/'+data.bumil.foto;
					}else{
						var link = '<?php echo url("dist/img/default_image.jpg"); ?>';
					}
					searchResult += '<img id="preview-photo" src="'+link+'" class="img-polaroid" height="250">';
					searchResult += '</div>';
					searchResult += '<a href="javascript:void(0)" onclick="detailBumil('+data.bumil.id_bumil+')" class="col-lg-6 col-md-6 col-sm-8 col-xs-10 col-lg-offset-3 col-md-offset-3 col-sm-offset-2 col-xs-offset-1 TblBumil TblBumilYellow m-t-20">';
					searchResult += 'Biodata Ibu Hamil';
					searchResult += '<span class="btn-circleYellow btn-circle"><i class="fa fa-external-link"></i></span>';
					searchResult += '</a>';
					searchResult += '</div>';
					searchResult += '</div>';
					searchResult += '<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 box-periode">';
					if(data.periode.length > 0){
						$.each(data.periode, function(k,v){
							searchResult += '<div class="panelPeriode">';
							searchResult += '<h4>Kelahiran '+v.kehamilan+'</h4>';
							searchResult += '<span class="panelTblPerod">';
							searchResult += '<a href="javascript:void(0)" onclick="detailKelahiran('+v.id_periode+')" class="btn btn-info btn-sm tblPeriode" data-toggle="tooltip" data-placement="left" title="Detail Periode"><i class="fa fa-external-link"></i></a>';
							searchResult += '</span>';
							searchResult += '</div>';
							searchResult += '<div class="clearfix"></div>';
						});
					}else{
						searchResult += '<label class="labelNoResult"><i> - = Kelahiran Tidak Ditemukan = - </i></label>';
					}
					searchResult += '</div>';
					searchResult += '<div class="clearfix m-b-10"></div>';
					searchResult += '</div>';

					$('.loadingResult').hide();
					$('.noResult').hide();
					$('.result-page').html(searchResult);
				} else {
					$('.loadingResult').hide();
					$('.result-page').empty();
					$('.noResult').show();
				}
			});
		}

		function detailBumil(id) {
			$.post("<?php echo route('detailBumil'); ?>", {id:id}).done(function(data){
				if(data.status == 'success'){
					$('.modal-dialog').html(data.content);
				}
			});
		}

		function detailKelahiran(id_periode) {
			$('.loading').show();
			// $('#mainKunjungan').hide();
			$('.main-layer').hide();
			// var status = $('#sttKehamilan').val();
			// if (status == "Hamil") {
			// 	swal("Maaf !", "Fitur 1000 HPK hanya digunakan untuk Ibu dengan status Melahirkan", "error");
			// 	$('.loading').hide();
			// 	$('#mainKunjungan').show();
			// }else{
				
				$.post("<?php echo route('cek1000hpk'); ?>", {id:id_periode}).done(function(data){
					if(data.status == 'notfound'){
						$.post("<?php echo route('formJumlahAnak'); ?>", {id:id_periode}).done(function(data){
							if(data.status == 'success'){
								// $('.modal-kunjungan').html(data.content);
								$('.modal-dialog').html(data.content);
								$('.loading').hide();
								// $('#mainKunjungan').show();
								$('.main-layer').show();
							}
						});
					} else {
						// $('#mainKunjungan').show();
						$.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();
							}
						});
					}
				});
			// }


		}
	</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('master.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>