<?php
include('db_con.php');
include('db_coni.php');
if (isset($_SESSION['user_id'])) {
        $user_type = $_SESSION['user_type'];
        $user_id = $_SESSION['user_id'];
        $user_name = $_SESSION['user_name'];
        $branch_id = $_SESSION['branch_id'];
        $branch_name = $_SESSION['branch_name'];
        $store_id = $_SESSION['store_id'];
        $store_name = $_SESSION['store_name'];
}else{
    header('Location: login');
    die();
}
if($user_type=='user')
	
{
	session_destroy();



header("location:login");	
}


?>
<!DOCTYPE html>
<html>
<head>
  <title>System Setup</title>
	<?php include('include/head.php'); ?>
	
</head>
<body>
	<?php include('include/header.php'); ?>
	
<div class="main-container">
<?php include('include/sidebar.php'); ?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark"></h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Settings</a></li>
              <li class="breadcrumb-item active">Setup</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->

     <span id="alert_action"></span>
    <div class="row">
        <div class="col-12">
          <div class="card">
            <div class="card-header">
            	<div class="row">
                          <div class="col-lg-10 col-md-10 col-sm-8 col-xs-6">
                              <h3 class="panel-title">Settings -> Setup</h3>
                            </div>
                           
                </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
           <br />
           <br />
           <br />
           <div class="col-sm-6">
           <span id="msg">It Will Update Last Purchase Rate (All Items)<br /></span>
        		
        				<button name="btn_action" id="btn_action" /></button>
        			
        				<button id="action" class="form-control action btn btn-primary">Start</button>
        				<input type="hidden" id="alert_status" />
        			</div>
        			</div>
        		</div>
       
                        
                   		  
			            </div>
			        </div>
			    </div>
			</div>
			       
        
        
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
 
  <!-- /.content-wrapper -->
 <?php include('include/footer.php'); ?>
		</div>
		</div>
	<?php include('include/script.php'); ?>
	
</body>
</html>
      
       
 <script>
 
  $(document).ready(function(){
    $(window).keydown(function(event){
    if(event.keyCode == 13) {
    
      event.preventDefault();
    }
  });
    });
  </script>
<script>
$(document).ready(function(){

	$(document).on('click', '#action', function(){
	$('#alert_action').fadeIn().html('<div class="alert alert-warning"><img src="images/loader.gif" style="width:24px; height:24px" /> &nbsp;Updating LP Rate...Do Not close This Tab</div>');

		var btn_action = 'lp_rate';
		$('#action').attr('disabled','disabled');
    $(this).val('Pleaes wait...');
		$.ajax({
			url:"system_setup_action.php",
			method:"POST",
			data:{btn_action:btn_action},
			
			success:function(data)
			{
				$('#alert_action').fadeIn().html('<div class="alert alert-success">'+data+'</div>');
				$('#alert_status').val(data);
				 window.location = "dashboard";

			}
		
		
		})
	});
});
	  
</script>