<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title> Login | ACP - <?php echo site_name(); ?></title>

<?php $this->load->view('admin/login_top'); ?>
<?php $this->load->helpers('common'); ?>

<script type="text/javascript">

    $(document).ready(function(){
	$(document).on('click', "#goto_forgot", function() {
		clrErr();
 		 $('#login_panel').hide();
 		 $('#loginFrm').trigger('reset');
 		 
		 reloadCaptcha('captchaForgotImg');
		 $('#forgot_panel').fadeIn();
 		 return false;	 
 	});
	$(document).on('click', "#goto_login", function() {
		clrErr();
 		 $('#forgot_panel').hide();
 		 $('#forgotFrm').trigger('reset');
		 reloadCaptcha('captchaImg');
		 $('#login_panel').fadeIn();
 		 return false;	 
 	});
	$(document).on('click', ".changeCaptcha_login", function() {
 		reloadCaptcha_login($(this).attr('id').replace('id_',''));
		 return false;	 
 	}); 
	 $(document).on('click', ".changeCaptcha", function() {
 		reloadCaptcha($(this).attr('id').replace('id_',''));
		 return false;	 
 	}); 
});

function reloadCaptcha_login(captcha_id){
	$('#'+captcha_id).fadeOut();
		$.ajax({ url :"<?php echo base_url(); ?>admin/ajax/loadCaptchaImgLogin",
			success : function (resData) { 
  				$('#'+captcha_id).html(resData);
				$('#'+captcha_id).append('<a style="margin:10px 2px; position:absolute;" href="#" class="changeCaptcha_login" id="'+captcha_id+'" ><?php echo img('assets/ap_assets/img/reload_captcha.png', TRUE);?> </a>');
				// console.log(resData);
				$('#'+captcha_id).fadeIn("slow");
			}
		 });	
}
function reloadCaptcha(captcha_id){
	$('#'+captcha_id).fadeOut();
		$.ajax({ url :"<?php echo base_url(); ?>admin/ajax/loadCaptchaImg",
			success : function (resData) { 
  				$('#'+captcha_id).html(resData);
				$('#'+captcha_id).append('<a style="margin:10px 2px; position:absolute;" href="#" class="changeCaptcha" id="'+captcha_id+'" ><?php echo img('assets/ap_assets/img/reload_captcha.png', TRUE);?> </a>');
				// console.log(resData);
				$('#'+captcha_id).fadeIn("slow");
			}
		 });	
}

    function validateForm(){
	clrErr();
	$errStaus = false; 
   	if(validateFormFields('adminLoginName','Please enter your user name.',''))$errStaus=true;
	if(validateFormFields('adminLoginPass','Please enter your password.',''))$errStaus=true;
	if(validateFormFields('adminLoginCode','Please enter the verify code.',''))$errStaus=true;
	if($errStaus) {
		return false;
	} else {
	return true;
	}
 }
    function validateForgotForm(){
 	clrErr();
	$errStaus = false; 
   	if(validateFormFields('adminForgotEmail','Please enter your user name.',''))$errStaus=true;
	if(validateFormFields('adminForgotCode','Please enter the verify code.',''))$errStaus=true;
	if($errStaus) {
		return false;
	} else {
	return true;		
	}
}

</script>

</head>


<body>
    <div class="limiter">
		<div class="container-login100" >
		    <!--style="background-image:url(login_assets/images/bg.jpg)"-->
			<div class="wrap-login100 pr-5 pl-5 pt-5 pb-4" id="login_panel" >
				<!--<form class="login100-form validate-form" action="server.php" method="POST">-->
				    <?php
        			    $actUrl = 'admin/login/setLogin';	 
         		        echo form_open($actUrl,array('name' => 'loginFrm','class'=>'login100-form validate-form', 'id' => 'loginFrm' ,'onsubmit'=>'return validateForm();'));
        			?>
			
					<span class="login100-form-title pb-4" style="font-size:24px;color:#212529;">
					    <!--<img src="login_assets/header_logo.jpg" heigth="70px" width="200px">-->
					    <?php echo site_name(); ?>
					</span>
					
					<!--<span class="login100-form-title pb-3" style="font-size:22px;color:#212529;" >-->
					<!--	     Admin Panel -->
					<!--</span>-->
					
					<span class="login100-form-title pb-4" style="font-size:19px;color:#d33f8d;" >
						     Login
					</span>
					     <div class="wrap-input100 mb-3">
        			       <div class="" id="messageRow">
                              <?php 
                          		$errMsg = validation_errors('* ');
                        		if(empty($errMsg)){ $errMsg = $this->session->flashdata('errMsg');  }
                        		$warningMsg = $this->session->flashdata('warningMsg');
                        		$successMsg = $this->session->flashdata('successMsg');
                        		if(isset($errMsg) && !empty($errMsg)){ echo showMessage($errMsg,'error',true); }  
                        		if(isset($warningMsg) && !empty($warningMsg)){ echo showMessage($warningMsg,'warning',true); }
                        		if(isset($successMsg) && !empty($successMsg)){ echo showMessage($successMsg,'success',true); }
                         	    ?>
                            </div>
    			        </div>

					<div class="wrap-input100 validate-input " id="div_adminLoginName" >
						<?php   echo form_input(array( 'name' => 'adminLoginName',  'id' => 'adminLoginName',  'placeholder'   => 'Username', 'class' => 'input100', ));  ?>
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<span class="lnr lnr-user"></span>
						</span>
					</div>
					<p class="text-danger err_msg" id="err_adminLoginName"></p>
					<div class="wrap-input100 validate-input mt-3" id="div_adminLoginPass" >
						<?php   echo form_input(array( 'type'=>"password" , 'name' => 'adminLoginPass',  'id' => 'adminLoginPass',  'placeholder'   => 'Password', 'class' => 'input100', ));  ?>
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<span class="lnr lnr-lock"></span>
						</span>
					</div>
					<p class="text-danger err_msg" id="err_adminLoginPass"></p>

                    <div class="wrap-input100 validate-input mt-3" >
                        <div class="row">
                          <div class="col-md-5 ">
                            <div class="cap-img" id="captchaImg" style="width:100% !important" >
                              <?php   
                              	$this->session->unset_userdata('S4A_CAPTCHA_login');
                              	// var_dump(create_captcha(captcha_config())); exit();
            					$captcha = create_captcha(captcha_config());
            					$this->session->set_userdata('S4A_CAPTCHA_login', $captcha['word']);
            				// 	$sessionCaptcha = $this->session->userdata('S4A_CAPTCHA_login');
            				// 	var_dump($captcha['word']);
            				//  	var_dump($sessionCaptcha);
            					echo  $captcha['image'];
            					?>
            							
                              <a style="margin:10px 2px; position:absolute" href="#" class="changeCaptcha_login" id="id_captchaImg" ><?php echo img('assets/ap_assets/img/reload_captcha.png', TRUE);?> </a>
                          	</div>
                          </div>
                          
                          <?php  //echo form_input(array( 'type'=>"hidden" , 'name' => 'adminLoginCodepsw', 'style'=>'padding: 0 30px 0 20px;', 'id' => 'adminLoginCodepsw',    'class' => 'input100', 'value'=> $sessionCaptcha )); ?>
                        
                           <div class="col-md-7 " id="div_adminLoginCode">
                            <?php  echo form_input(array( 'type'=>"text" , 'value' => set_value('adminForgotCode',$captcha['word'])  , 'name' => 'adminLoginCode', 'style'=>'padding: 0 30px 0 20px;', 'id' => 'adminLoginCode',    'class' => 'input100',   )); ?>
                            <p class="text-danger err_msg" id="err_adminLoginCode"></p>
                          </div>
                        </div>
                  </div>
				
					<div class="container-login100-form-btn pt-3">
					    <?php   echo form_button(array( 'name' => 'loginBtn','value' => 'true', 'id' => 'loginBtn',  'type' => 'submit','content' => 'Submit', 'class' => 'login100-form-btn', )); ?>
					</div>
                        
					<div class="text-center w-full pt-3" >
						<span class="txt1">
							<a id="goto_forgot" href="#">Forgot Passoword</a>
						</span>
					</div>
				<!--</form>-->
				<?php echo form_close();?> 
			</div>
			
			
			<div class="wrap-login100 pr-5 pl-5 pt-4 pb-4" id="forgot_panel" style="display:none;">
				<!--<form class="login100-form validate-form" action="server.php" method="POST">-->
				    <?php
			            $actUrl = 'admin/login/forgot';	 
 		                echo form_open($actUrl,array('name' => 'forgotFrm', 'id' => 'forgotFrm' ,'onsubmit'=>'return validateForgotForm();'));
		            ?>
					<span class="login100-form-title pb-4" style="font-size:24px;color:#212529;">
					    <!--<img src="login_assets/header_logo.jpg" heigth="70px" width="200px">-->
					   <?php echo site_name(); ?>
					</span>
					
					<!--<span class="login100-form-title pb-3" style="font-size:22px;color:#212529;" >-->
					<!--	     Admin Panel -->
					<!--</span>-->
					
					<span class="login100-form-title pb-4" style="font-size:19px;color:#d33f8d;" >
						     Forgot Password
					</span>
					     <div class="wrap-input100 mb-3">
        			       <div class="" id="messageRow">
                              <?php 
                          		$errMsg = validation_errors('* ');
                        		if(empty($errMsg)){ $errMsg = $this->session->flashdata('errMsg');  }
                        		$warningMsg = $this->session->flashdata('warningMsg');
                        		$successMsg = $this->session->flashdata('successMsg');
                        		if(isset($errMsg) && !empty($errMsg)){ echo showMessage($errMsg,'error',true); }  
                        		if(isset($warningMsg) && !empty($warningMsg)){ echo showMessage($warningMsg,'warning',true); }
                        		if(isset($successMsg) && !empty($successMsg)){ echo showMessage($successMsg,'success',true); }
                         	    ?>
                            </div>
    			        </div>
					<div class="wrap-input100 validate-input " id="div_adminForgotEmail" data-validate = "Valid username is required">
						<!--<input class="input100" type="text" name="username" placeholder="Username">-->
						<?php   echo form_input(array( 'name' => 'adminForgotEmail',  'id' => 'adminForgotEmail',  'placeholder'   => 'Username', 'class' => 'input100', ));  ?>
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<span class="lnr lnr-user"></span>
						</span>
					</div>
					<p class="text-danger err_msg" id="err_adminForgotEmail"></p>
                    
                     <div class="wrap-input100 validate-input mt-3" >
                        <div class="row">
                          <div class="col-md-5 ">
                            <div class="cap-img" id="captchaForgotImg" style="width:100% !important" >
                              <?php   $this->session->unset_userdata('S4A_CAPTCHA');
            							$captcha = create_captcha(captcha_config());
            							$this->session->set_userdata('S4A_CAPTCHA', $captcha['word']);
            							echo  $captcha['image']; ?>
                              <a style="margin:10px 2px; position:absolute" href="#" class="changeCaptcha" id="id_captchaForgotImg" ><?php echo img('assets/ap_assets/img/reload_captcha.png', TRUE);?> </a> </div>
                          </div>
                          <div class="col-md-7 " id="div_adminForgotCode">
                            <?php  echo form_input(array( 'type'=>"text"  , 'style'=>'padding: 0 30px 0 20px;', 'name' => 'adminForgotCode',  'id' => 'adminForgotCode',  'class' => 'input100', )); ?><p class="text-danger err_msg" id="err_adminForgotCode"></p>
                          </div>
                        </div>
                      </div>
				
					<div class="container-login100-form-btn pt-3">
					    <?php   echo form_button(array( 'name' => 'loginBtn_2','value' => 'true', 'id' => 'loginBtn_2',  'type' => 'submit','content' => 'Submit', 'class' => 'login100-form-btn', )); ?>
					</div>
                        
					<div class="text-center w-full pt-3" >
						<span class="txt1">
							<a id="goto_login" href="#">Go to Login</a>
						</span>
					</div>
				<!--</form>-->
				<?php echo form_close();?> 
			</div>
			
		</div>
	</div>
</body>

</html>