<div class="row no-gutters vh-100 proh bg-template">
	<div class="col align-self-center px-3 text-center">
		<form id="form" class="form-signin shadow">
			<input type="hidden" name="<?= csrf_token(); ?>" value="<?= csrf_hash(); ?>" style="display: none">
			Masukkan alamat email Anda untuk mengatur ulang password.
			<p id="error" style="color:#cc0000;display:none;"><small>alamat email tidak ditemukan, mohon cek kembali.</small></p>
			<p id="sukses" style="color:#00cc00;display:none;"><small>berhasil menyetel ulang password, silahkan cek email anda untuk langkah selanjutnya.</small></p>
			<div class="form-group float-label">
				<input class="form-control" type="email" name="email">
				<label for="email" class="form-control-label">Alamat Email</label>
			</div>
			<div id="prosesmail" style="display:none;">
				<h5 class="cl1"><i class="fa fa-circle-o-notch fa-spin"></i> Memproses...</h5>
			</div>
			<button id="submitmail" type="submit" class="btn btn-sm btn-default btn-rounded shadow">
				reset password
			</button>
		</form>
	</div>
</div>

<script type="text/javascript">
	var csfrData = {};
	csfrData['<?= csrf_token(); ?>'] = '<?= csrf_hash(); ?>';
	$.ajaxSetup({
		data: csfrData
	});
	$(function() {
		$("#form").on("submit", function(e) {
			e.preventDefault();

			$(".form").prop("readonly", true);
			$("#submitmail").hide();
			$("#prosesmail").show();
			$.post("<?= site_url("home/signin/pwreset"); ?>", $(this).serialize(), function(data) {
				$("#submitmail").show();
				$("#prosesmail").hide();
				if (data.success == true) {
					$(".form").val("");
					$(".form").prop("readonly", false);
					swal("Berhasil!", "Berhasil mengirimkan password baru, silahkan cek inbox email Anda.", "success").then((value) => {
						window.location.href = "<?= site_url("home/signin"); ?>";
					});
				} else {
					swal("Gagal!", "Alamat email tidak ditemukan, pastikan alamat email sudah benar.", "error");
				}
			});
		});
	});
</script>
