<?php 
session_start();
require('../db.php');

include('inc/session.php');
						
$user = $_SESSION['user'];
								
$ins = mysqli_query($conn,"SELECT * FROM users WHERE email='$user' ");
$data = mysqli_fetch_array($ins);
								
$email = $data['email'];
$rowpas = $data['pass'];
$bal = $data['bal'];
							
$deps = "SELECT * FROM deposit  ";
$payment = $conn->query($deps);

include('../inc/logo.php');	

$qrysit = mysqli_query($conn,"SELECT * FROM settings");
$sitnam = mysqli_fetch_array($qrysit);						
								
?> 
<?php include('inc/header.php');?>
<body class="fixed-nav sticky-footer bg-light" id="page-top">



  <!-- Navigation-->
 <?php include('inc/nav.php');?>
        
  <!-- Navigation Ends--> 
      </ul>
    </div>
  </nav>
  <div class="content-wrapper">
  
    <div class="container-fluid">
      <!-- Breadcrumbs-->
     
      <div class="row">
        <div class="col-12">
          
     
     <h1 class="w3-xxxlarge w3-text-green" align="center"><b>Airtime2Cash Configuration</b></h1>
       
<p align="center"><strong>Description:</strong> Configure Airtime2Cash Charges (%)  </p>
      <!-- Example Bar Chart Card-->
       
     <?php 
		   // define variables and set to empty values

	$request_dir = $_SERVER['SERVER_NAME'];	
		
		
		if(isset($_POST['rate'])){


$mtn = $_REQUEST['mtn'];
$airtel = $_REQUEST['airtel'];
$glo = $_REQUEST['glo'];
$mobile = $_REQUEST['mobile'];



		
              
		
	if(!empty($mtn) || !empty($glo) || !empty($airtel) || !empty($mobile) ) {	
		
		
	$sql_store = mysqli_query($conn,
	
	"UPDATE acash_billing SET 
mtn='$mtn',
airtel='$airtel',
9mobile='$mobile',
glo='$glo' ");	
echo "<div class='alert alert-info'>Settings saved</div>";

?> <script>
setTimeout(function(){ window.location.href='a2cash_settings.php' }, 1000);</script>
   <?php
	}else{
		
echo "<div class='alert alert-danger'>Field cannot be empty</div>"; }

}
	
$qrypinBil = mysqli_query($conn,"SELECT * FROM acash_billing");
 $apib = mysqli_fetch_array($qrypinBil);


$qrypin = mysqli_query($conn,"SELECT * FROM acash_billing");
 $apiSet = mysqli_fetch_array($qrypin);




		?> 
       
  <form action="" method="post" autocomplete = 'off' > 
  
     <table class="table  margin-tp-10" id="transTable">
    
<td width="20%"><i class="fa fa-phone"></i> MTN Charges (%)</td>
 <td id="mainService"> <input type="text" name="mtn"  value="<?php echo $apib['mtn'];?>" class="form-control"  placeholder="Enter MTN Charge"> </td>

                        </tr>  
                        
  <td width="20%"><i class="fa fa-phone"></i> GLO Charges (%)</td>
 <td id="mainService"> <input type="text" name="glo"  value="<?php echo $apib['glo'];?>" class="form-control"  placeholder="Enter GLO Charge"> </td>

                        </tr> 

 

<td width="10%"><i class="fa fa-phone"></i> Airtel Charges (%)</td>
 <td id="mainService"> <input type="text" name="airtel"  value="<?php echo $apib['airtel'];?>" class="form-control"  placeholder="Enter Airtel Charge"> </td>

                        </tr> 


<td width="10%"><i class="fa fa-phone"></i> 9Mobile Charges (%)</td>
 <td id="mainService"> <input type="text" name="mobile"  value="<?php echo $apib['9mobile'];?>" class="form-control"  placeholder="Enter 9Mobile Charge"> </td>

                        </tr> 












                                            <tr>
                            <td colspan="2">
                            <button type="submit" id="submit" name="rate" class="btn btn-info">Save Settings</button>
                       </td>
                                                                       
                          <td valign="middle"></td>                                             
                        </tr>
                                    </table> 
  
  </form>

</div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
   <?php include('inc/footer.php');?>