<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<div class="row">
	<?php if ($w_cos): ?>
	<?php foreach ($w_cos as $data): ?>
	<?php $widget = trim($data['isi']);
	if ($data["jenis_widget"] == 1) ?>
	
	<?php if ($data["isi"] == "komentar.php"): ?>
	<div class="col-12 col-lg-4 col-md-4">
		<?php include("$this->theme_folder/$this->theme/widgets/".$widget); ?>
	</div>
	<?php endif; ?>
	<?php if ($data["isi"] == "peta_lokasi_kantor.php"): ?>
	<div class="col-12 col-lg-4 col-md-4">
		<?php include("$this->theme_folder/$this->theme/widgets/".$widget); ?>
	</div>
	<?php endif; ?>
	<?php if ($data["isi"] == "peta_wilayah_desa.php"): ?>
	<div class="col-12 col-lg-4 col-md-4">
		<?php include("$this->theme_folder/$this->theme/widgets/".$widget); ?>
	</div>
	<?php endif; ?>
	<?php if ($data["isi"] == "statistik.php"): ?>
	<div class="col-12 col-md-12 mb-2">
		<section id="section-penduduk" class="rounded pink-gradient p-4">
			<div class="container overflow-hidden">
				<div class="row justify-content-between">
					<div class="col-12 text-center mb-2 text-light align-items-center">
						<div>
							<h4 class="my-title-mini text-center">DATA PENDUDUK</h4>
						</div>
					</div>              
					<div id="mandiri" class="col-12 text-center">
						<div class="row">
							<?php $i=0; ?>
							<?php foreach ($stat_widget as $data): ?>
							<?php if ($data['jumlah'] != "-" AND $data['nama']!= "JUMLAH"): ?>
							<div class="col-4">
								<i class="fa <?php if($i==0){ echo "fa-male"; } elseif($i==1){ echo "fa-female"; } elseif($i==2) { echo "fa-users"; } ?> fa-2x"></i>
								<h3 class="font-weight-bold mt-1 text-dark-me"><span id="count-<?= $i ?>"><?= $data['jumlah']?></span></h3>
								<p class="text-gray text-hide-xs"><?= $data['nama']?></p>
							</div>
							<?php $i++; ?>
							<?php endif; ?>
							<?php endforeach; ?>
						</div>
					</div>
				</div>
			</div>
		</section>
	</div>
	<?php endif; ?>
	<?php if ($data["isi"] == "layanan_mandiri.php"): ?>
	<div class="container mt-0 main-container z-index-1">
		<div class="row no-gutters box-shadow-large mb-2 bg-white rounded has-background-img mt-0">
			<div class="col-12 col-md-6 col-lg-7 has-background-img min-height-300 text-hide-xs">
				<div class="background-img pink-gradient">
					<div class="align-self-center text-center mt-4">
						<div class="logo-img-loader">
							<img src="<?= gambar_desa($desa['logo']);?>" alt="" class="logo-image">
						</div>
						<h2 class="mt-3 font-weight-light text-white">Layanan Mandiri</h2>
						<p class="mt-0 text-white">Silakan login untuk mengakses modul Layanan Mandiri.<br>
						Warga dapat membuat Permohonan Surat Keterangan melalui Website Desa.</p>
					</div>
				</div>
			</div>
			<div class="col-12 col-md-6 col-lg-5 card mb-0 fullscreen">
				<?php if(!isset($_SESSION['mandiri']) OR $_SESSION['mandiri']<>1){ ?>
				<div class="container mt-3 main-container">
					<div class="media">
						<div class="media-body">
							<h4 class="content-color-primary mb-0">Layanan Mandiri</h4><hr>
						</div>
					</div>
					<div class="row">
						<div class="col-12 col-md-12">
							<div class="card mb-3">
								<div class="card-body">
									<div class="tab-pane fade show active" id="tablogin" role="tabpanel" aria-labelledby="tablogin-tab">
										<?php if($_SESSION['mandiri_wait']==1) { ?>
										<div id="note" class="alert alert-danger mt-2 text-center" role="alert">
											Gagal 3 kali, NIK atau PIN yang Anda masukkan salah!
										</div>
										<div id="note" class="alert alert-warning mt-1 text-center" role="alert">
											Coba dalam <?= waktu_ind((time()- $_SESSION['mandiri_timeout'])*(-1));?> lagi.
										</div>
										<?php } else { ?>
										<form class="contact_form" action="<?= site_url('first/auth#mandiri')?>" method="post">
											<input style="margin-bottom:8px;" autocomplete="cc-csc" name="nik" type="text" placeholder="Ketik Nomor KTP" maxlength="16" class="form-control" value="" required>
											<input style="margin-bottom:8px;" autocomplete="cc-number" name="pin" type="password" placeholder="Ketik Kode PIN" value="" maxlength="6" class="form-control" required>
											<button type="submit" id="but" class="btn btn-primary btn-block">Masuk</button>
										</form>
										<?php if($_SESSION['mandiri_try'] AND isset($_SESSION['mandiri']) AND $_SESSION['mandiri']==-1){ ?>
										<div id="note" class="alert alert-danger mt-2 text-center" role="alert">
											Kesempatan mencoba <?= ($_SESSION['mandiri_try']-1); ?> kali lagi
										</div>
										<div id="note" class="alert alert-warning mt-0 text-center" role="alert">
											Login Gagal. NIK/PIN yang Anda masukkan salah!
										</div>
										<?php }
										} ?>
										<a class="btn btn-success success-gradient btn-block mt-2" data-toggle="modal" data-target="#pin_mandiri">
											Klik untuk bantuan Kode PIN
										</a>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<?php
				}
				else {
				?>
				<div class="card-header border-bottom">
					<div class="media">
						<div class="media-body">
							<h4 class="content-color-primary mb-0">Menu Layanan</h4>
						</div>    
					</div>
				</div>
				<div class="card-body text-center">
					<div class="font-weight-bold mb-1"><?= $_SESSION['nama'];?></div>
					<div class="mb-1">NIK : <?= $_SESSION['nik'];?></div>
					<div class="mb-1">No. KK : <?= $_SESSION['no_kk']?></div>
					<a href="<?= site_url();?>first/mandiri/1/1"><button type="button" class="btn btn-primary btn-block mb-2">PROFIL</button></a>
					<a href="<?= site_url();?>first/mandiri/1/3"><button type="button" class="btn btn-primary btn-block mb-2">KOTAK PESAN</button></a>
					<a href="<?= site_url();?>first/mandiri_surat"><button type="button" class="btn btn-primary btn-block mb-2">PERMOHONAN SURAT</button></a>
					<a href="<?= site_url();?>first/logout"><button type="button" class="btn btn-danger btn-block mb-2">KELUAR</button></a>
				</div>
				<?php } ?>
			</div>
		</div>
	</div>
	<?php endif; ?>
	<?php endforeach; ?>
	<?php endif; ?>
</div>
