<!DOCTYPE html>
<html lang="en">
<head>
	<!-- header -->
		<?php
			$session = \Config\Services::session();
			// echo "<pre>";
			// print_r($session->getFlashData('error_message'));
			// echo "</pre>";
			// die;
		    echo view('admin/common_header'); 
		 ?>
	<!-- /header -->

	<!-- Bootsrap form validation JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/formValidation.js');?>"></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/bootstrap.js');?>"></script>

	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/notifications/pnotify.min.js');?>"></script>
<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/notifications/noty.min.js');?>"></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/notifications/jgrowl.min.js');?>"></script>

	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/core/app.js');?>"></script>
	<script src='https://www.google.com/recaptcha/api.js'></script>
	<!-- /theme JS files -->

	

</head>

<body class="login-cover">

	<!-- Page container -->
	<div class="page-container login-container">

		<!-- Page content -->
		<div class="page-content">

			<!-- Main content -->
			<div class="content-wrapper">
			<?php
			 $validation =  \Config\Services::validation();
			if(isset($_COOKIE['remember_token'])) 
			{
				$myencrypt = new MyEncrypt;
				$token_value = $myencrypt->decode($this->input->cookie('remember_token'));
				$login_data=explode("|",$token_value);
				$password=$login_data[0];
				
				$username=$login_data[1];
				$rem='1';
			}
			else
			{
				$username='';
				$password='';
				$rem='0';
			}
            $this->db = db_connect();
			$login_check=$this->db->query("select * from site_controls where settings_name='login' and site_key='log_captcha_status'")->getRow();
			$login_load = $login_check->site_value;
			
			$sitekey = $this->db->query("select * from site_controls where site_key='captcha_key'");
			$site_kval=$sitekey->getRow();


			?>

				<!-- Form with validation -->
			<form action="<?= site_url("admin/login");?>" class="form-validate login" method="post">
					<div class="panel panel-body login-form">
						<div class="text-center">
							<div class="icon-object border-slate-300 text-slate-300"><i class="icon-reading"></i></div>
							<h5 class="content-group"><?php echo lang('language_lang.lbl_admin_login_page_title');?> <small class="display-block"><?php echo lang('language_lang.lbl_admin_login_credentials');?></small></h5>
						</div>

						<div class="form-group has-feedback has-feedback-left">
							<input type="text" class="form-control" value="<?php echo $username;?>" placeholder="Username" name="username" required="required">
							<div class="form-control-feedback">
								<i class="icon-user text-muted"></i>
							</div>
							<?php echo $validation->getError('username');?>
						</div>

						<div class="form-group has-feedback has-feedback-left">
							<input type="password" class="form-control" value="<?php echo $password;?>" placeholder="Password" name="password" required="required">
							<div class="form-control-feedback">
								<i class="icon-lock2 text-muted"></i>
							</div>
							<?php echo $validation->getError('password');?>
						</div>

						<!--<?php 
						if($login_load=='on')
						{
						?>
								<div class="form-group has-feedback has-feedback-left">
									<div class="g-recaptcha" data-callback="recaptchaCallback"  data-sitekey="<?php echo $site_kval->site_value;?>"></div>
									<?php echo $validation->getError('g-recaptcha-response');?>
								</div>
							
						<?php 
						}
						?>-->


						<div class="form-group login-options">
							<div class="row">
								<div class="col-sm-6">
									<label class="checkbox-inline">
										<input type="checkbox" <?php if($rem=='1') echo "checked=='checked'";?> name="remember" class="styled">
										<?php echo lang('language_lang.lbl_admin_login_remember');?>
									</label>
								</div>

								<div class="col-sm-6 text-right">
									<a href="<?= site_url("admin/login/reset");?>" ><?php echo lang('language_lang.lbl_admin_login_forgot_password');?></a>
								</div>
							</div>
						</div>

						<div class="form-group">
							<button type="submit" class="btn bg-blue btn-block"><?php echo lang('language_lang.button_Login');?> <i class="icon-arrow-right14 position-right"></i></button>
						</div>
						
					</div>
				</form>
				<!-- /form with validation -->

				

			</div>
			<!-- /main content -->

		</div>
		<!-- /page content -->


		<!-- Footer -->
		<div class="footer text-white">
			<?php echo site_footer();?>
		</div>
		<!-- /footer -->

	</div>
	<!-- /page container -->

	<script type="text/javascript">
	jQuery.noConflict();
	(function( $ ) {
	$(function() {

		$(document).ready(function() {

			 $.jGrowl.defaults.closer = false;


			<?php
			 if($session->getFlashData('error_message')) { ?>

			$('#jgrowl-warning').on('click', function () {
		        $.jGrowl('<?php echo $session->getFlashData('error_message');?>', {
		            header: 'Attention Here!',
		            theme: 'bg-warning'
		        });
		    });

		    <?php } ?>


		    <?php if($session->getFlashData('reset_success_message')) { ?>

			// $('#jgrowl-warning').on('click', function () {
		        $.jGrowl('<?php echo $session->getFlashData('reset_success_message');?>', {
		            header: 'Attention Here!',
		            theme: 'bg-success'
		        });
		    // });

		    <?php } ?>	
				
		    $('.login').formValidation({
		    	framework: 'bootstrap',
		    	excluded: [':disabled'],
		        
		        fields: {
		            username: {
		                message: '<?php echo lang("language_lang.login_username_valid");?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.login_username_empty");?>'
		                    },
		                    stringLength: {
		                        min: 5,
		                        message: '<?php echo lang("language_lang.login_username_min");?>'
		                    }
		                    
		                }
		            },
		            password: {
		                message: '<?php echo lang("language_lang.login_password_valid");?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.login_password_empty");?>'
		                    }
		                }
		            }
		            
		        }
		    })
			
		});
	    
	   

	});
	})(jQuery);

	</script>

</body>
</html>
