<?php
/**
 * File			: login.php
 * Description  : View untuk halaman login admin
 * Created By	: Hendi
 * Created Date : 15 Mar 2021
 * Last Update  : 24 Mar 2021
**/	

# agar jika ada perubahan css/js tidak perlu lg diclear data browser
# karena browser sudah dipaksa ambil css/js yang baru
$rand = rand();
/**
=========================================================
Material Dashboard - v2.1.2
=========================================================

Product Page: https://www.creative-tim.com/product/material-dashboard
Copyright 2020 Creative Tim (https://www.creative-tim.com)
Coded by Creative Tim

=========================================================
The above copyright notice and this permission notice 
shall be included in all copies or substantial portions 
of the Software. 
**/
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="apple-touch-icon" sizes="76x76" href="<?=base_url('public/favicon.ico')?>">
	<link rel="icon" type="image/png" href="<?=base_url('public/favicon.ico')?>">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<?php # untuk csrf token saat ajax?>
	<?= csrf_meta() ?>
	<title>
		Admin Panel - <?= $title ?>
	</title>
	<meta content='width=device-width, initial-scale=1.0, shrink-to-fit=no' name='viewport' />
	<!-- Fonts and icons -->
	<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
	<!-- CSS Files -->
	<link href="<?=base_url('public/assets/css/material-dashboard.css?v=2.1.2')?>" rel="stylesheet" />
	<!-- My CSS -->
	<link href="<?=base_url('public/assets/css/mystyle.css?v='.$rand)?>" rel="stylesheet" />
	<!-- Google Recaptcha -->
	<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body class="">
	<div class="wrapper loginna">
		<div class="main-panel">
			<div class="content">
				<div class="container-fluid">
					<div class="row">
						<div class="col-md-7 login-desc">
							<h1 class="card-title">Admin Panel</h1>
							<p class="card-description">
								Silahkan masukan username dan password Anda dengan benar.
							</p>
						</div>
						<div class="col-md-5 login-form">
							<div class="card card-profile">
								<div class="card-avatar">
									<a href="javascript:;">
										<img class="img" src="<?=base_url('public/assets/img/logo/logo_250.png')?>" />
									</a>
								</div>
								<div class="card-body">
									<?php 
										# cek validasi 
										$inputs = session()->getFlashdata('inputs');
										$errors = session()->getFlashdata('errors');
										$success = session()->getFlashdata('success');
										
										if (!empty($errors))
										{ 
											echo '<div class="alert alert-danger" role="alert">
													<button type="button" class="close" data-dismiss="alert" aria-label="Close">
														<i class="material-icons">close</i>
													</button>
													<ul>';
											 
											foreach ($errors as $error) 
											{ 
												echo '<li>'.esc($error).'</li>';
											} 
											
											echo '	</ul>
												  </div>';
										}
										
										if (!empty($success))
										{ 
											echo '<div class="alert alert-success" role="alert">
													<button type="button" class="close" data-dismiss="alert" aria-label="Close">
														<i class="material-icons">close</i>
													</button>
													<span>'.$success.'<span>
												  </div>';
										}
										
										# jika menggunakan form_open(), maka csrf token otomatis sudah dibuat.
										# esc() berfungsi menjaga serangan xss (cross site scripting)
									?>
									<?= form_open('do-login') ?>
										<div class="row">
											<div class="col-md-12">
												<div class="form-group bmd-form-group">
													<label class="bmd-label-floating">Username</label>
													<input type="text" name="user_id" class="form-control" value="<?= esc($inputs['user_id'] ?? '') ?>">
												</div>
											</div>
											<div class="col-md-12">
												<div class="form-group bmd-form-group">
													<label class="bmd-label-floating">Password</label>
													<input type="password" name="password" class="form-control" value="<?= esc($inputs['password'] ?? '') ?>">
												</div>
											</div>
										</div>
										<button type="submit" class="btn btn-hejo" style="width: 100%;">Login<div class="ripple-container"></div><div class="ripple-container"></div></button>
										<div class="clearfix"></div>
									<?= form_close() ?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<footer class="footer">
				<div class="container-fluid">
					<div class="copyright float-left">
						&copy;
						<script>
							document.write(new Date().getFullYear())
						</script><!-- <a href="https://titasictech.com">titasictech.com</a>-->. template <!-- with <i class="material-icons">favorite</i> -->by
						<a href="https://www.creative-tim.com" target="_blank">Creative Tim</a>.
					</div>
				</div>
			</footer>
		</div>
	</div>
	<!-- Core JS Files -->
	<script src="<?=base_url('public/assets/js/core/jquery.min.js')?>"></script>
	<script src="<?=base_url('public/assets/js/core/popper.min.js')?>"></script>
	<script src="<?=base_url('public/assets/js/core/bootstrap-material-design.min.js')?>"></script>
	<script src="<?=base_url('public/assets/js/plugins/perfect-scrollbar.jquery.min.js')?>"></script>
	<!-- Plugin for the momentJs  -->
	<!--<script src="<?=base_url('public/assets/js/plugins/moment.min.js')?>"></script>-->
	<!-- Plugin for Sweet Alert -->
	<!--<script src="<?=base_url('public/assets/js/plugins/sweetalert2.js')?>"></script>-->
	<!-- Forms Validations Plugin -->
	<!--<script src="<?=base_url('public/assets/js/plugins/jquery.validate.min.js')?>"></script>-->
	<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support SweetAlert -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
	<!-- Notifications Plugin -->
	<!--<script src="<?=base_url('public/assets/js/plugins/bootstrap-notify.js')?>"></script>-->
	<!-- Control Center for Material Dashboard: parallax effects, scripts for the example pages etc -->
	<script src="<?=base_url('public/assets/js/material-dashboard.js?v=2.1.2')?>" type="text/javascript"></script>
	<!-- Material Dashboard DEMO methods, don't include it in your project! -->
	<!--<script src="<?=base_url('public/assets/demo/demo.js')?>"></script>-->
	
</body>
</html>