<?php
session_start();
require_once ('class.admin.php');
include_once ('session.php');

$reg_user = new USER();

if(!isset($_SESSION['email'])){
	
header("Location: login.php");

exit(); 
}

$stmt = $reg_user->runQuery("SELECT * FROM account");
$stmt->execute();

if(isset($_POST['set']))
{
	
	$uname = trim($_POST['uname']);
	$uname = strip_tags($uname);
	$uname = htmlspecialchars($uname);
	
	$billing_code = trim($_POST['billing_code']);
	$billing_code = strip_tags($billing_code);
	$billing_code = htmlspecialchars($billing_code);
	
			$set= $reg_user->runQuery("UPDATE account SET uname = '$uname', billing_code = '$billing_code' WHERE uname = '$uname'");
			$set->execute();
			
			$id = $reg_user->lasdID();		
			
			
			$msg= "<div class='alert alert-info'>
				<button class='close' data-dismiss='alert'>&times;</button>
					<strong>Settings Saved Successfully to <b>$billing_code</b>!</strong> 
			  </div>";	

}

?>

 <?php include 'headeradmin.php'; ?>
 

 <!---begin of Mobile View Here   only from Digital Forest Team-->
 
       <?php include 'menu.php'; ?>
  
  <!---End of Mobile View Here   only from Digital Forest Team-->
  
 
      <script type="text/javascript" src="paginator.js"></script>
        <script type="text/javascript" src="table.js"></script>
     
      <br><br><br><br><br><br><br>
  
    <div class="container-fluid mt--7">
     <!-- Table -->
      <div class="row">
        <div class="col">
          <div class="card shadow" >
            <div class="card-header border-0">
              <h3 class="mb-0"><a href=""   class="btn btn-danger">CHANGE USER TRANSFER</a></h3>
            </div>
          
           <div class="card-body">
               
               <?php if(isset($msg)) echo $msg;  ?> 
              
            
              <form method="POST">
               
                 <div class="col-lg-6">
                      <div class="form-group">
				 
						<label>Select Client & Current Transfer mode</label>
						<select name="uname" class="form-control input-sm validate[required]">
						<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)){?>
							<option value="<?php echo $row['uname']; ?>"><?php echo $row['fname']; ?> <?php echo $row['mname']; ?> <?php echo $row['lname']; ?> (<?php

if ($row['billing_code'] == 1) {

    echo "Allow Transfer(OTP Only)";

} elseif ($row['billing_code'] == 2) {

    echo "Multiple Transfer Codes";

} elseif ($row['billing_code'] == 5) {

    echo "Suspend Transfer";

} else {

    echo "Set billing code";

}

?>)</option>
						<?php } ?>
					   </select>
				 
			 </div></div>
			
			  <div class="col-lg-6">
                      <div class="form-group">
						<label>=====>> <span style="color:red;">Code Meanings are below</span></label>
						<select  name="billing_code" class="form-control input-sm validate[required]">
							<option value="1">ALLOW TRANSFER(Only OTP Required)</option>
							<option value="2">REQUEST Transfer Code</option>
						<!----	<option value="3">REQUEST TAX CODE</option> 
								<option value="4">REQUEST IMF CODE</option> ---->
							<option value="5">SUSPEND TRANSFER</option>  
						</select>
				 
                </div></div>
                <br/>
					<button type="submit" name="set" class="btn btn-success ">Set Transfer</button>
				</form>
               
               <hr>
               	<article>
                <p>Allow Transfer means that client will peform transaction without any of the billing codes</p>
                <p>Request Transfer Code means client will enter  required Transfer Code before completing transactions</p>
                <strong>Required Codes</strong>
                <ol>

  <li>Transfer Code</li>

  <li>Deposit Certificate serial number</li>

  <li>Zip code number</li>
  <li>confirmation number</li>

</ol>
<p>Suspend transfer means transfer has been suspended and no code will show.</p>
				</article>

                </br>
               
               
               
               
          </div>
     
        </div>
      </div>
     </div>
 
    
       <?php include 'foot.php'; ?>