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

<div id="mandiri" class="card mb-2">
	<?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"><i class="material-icons icon-sm">person</i> Layanan Mandiri</h4><hr>
				</div>
			</div>
			<div class="row">
				<div class="col-12 col-md-12">
					<div class="card mb-3">
						<div class="card-header p-0">
							<ul class="nav nav-tabs wizard-1" role="tablist">
								<li class="nav-item">
									<a class="nav-link active" id="tablogin-tab" data-toggle="tab" href="#tablogin" role="tab" aria-controls="tablogin" aria-selected="true">
										<span>Login</span>
									</a>
								</li>
								<li class="nav-item">
									<a class="nav-link" id="tabdaftar-tab" data-toggle="tab" href="#tabdaftar" role="tab" aria-controls="tabdaftar" aria-selected="false">
										<span>Daftar Kode PIN</span>
									</a>
								</li>
							</ul>
						</div>
						<div class="card-body">
							<div class="tab-content">
								<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')?>" 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-1 text-center" role="alert">
												Login Gagal. NIK/PIN yang Anda masukkan salah!
											</div>
										<?php }
									} ?>
								</div>
								<div class="tab-pane fade" id="tabdaftar" role="tabpanel" aria-labelledby="tabdaftar-tab">
									<a data-toggle="modal" data-target="#pin_mandiri">
										<div class="card mb-4 success-gradient">
											<div class="card-body">
												<div class="media">
													<div class="media-body">
														<p class="text-white mb-0">Pendaftaran Kode PIN</p>
														<h4 class="mb">Layanan Mandiri</h4>
														<p class="text-white mb-0">Klik Disini</p>
													</div>
													<div class="icon-circle icon-50 bg-light-white">
														<i class="material-icons">send</i>
													</div>
												</div>
											</div>
										</div>
									</a>
								</div>
							</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"><i class="material-icons icon-sm">person</i> 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();?>mandiri_web/mandiri/1/1"><button type="button" class="btn btn-primary btn-block mb-2">PROFIL</button></a>
			<a href="<?= site_url();?>mandiri_web/mandiri/1/3"><button type="button" class="btn btn-primary btn-block mb-2">KOTAK PESAN</button></a>
			<a href="<?= site_url();?>mandiri_web/mandiri_surat"><button type="button" class="btn btn-primary btn-block mb-2">PERMOHONAN SURAT</button></a>
			<a href="<?= site_url();?>mandiri_web/mandiri/1/2"><button type="button" class="btn btn-primary btn-block mb-2">RIWAYAT LAYANAN</button></a>
			<a href="<?= site_url();?>mandiri_web/mandiri/1/4"><button type="button" class="btn btn-primary btn-block mb-2">PROGRAM BANTUAN</button></a>
			<a href="<?= site_url();?>mandiri_web/logout"><button type="button" class="btn btn-danger btn-block mb-2">KELUAR</button></a>
		</div>
	<?php } ?>
</div>
<?php $this->load->view('head_tags_front') ?>
