<?php include'header.php';?>
<?php
if(!isset($_SESSION['id'])){ ?>
<script type = "text/javascript">window.location = "index.php";</script>
<?php } ?>
<style>
    .login-card{max-width:100% !important;}
</style>

<div class="container">
     <?php
    if(isset($_POST['pay_now'])){
    $phone_number= $_POST['phone_number'];
    $vehicle_number= $_POST['vehicle_number'];
    $state= $_POST['state'];
    $category= $_POST['category'];
    $sub_category= $_POST['sub_category'];
    $start_date= $_POST['start_date'];
    $end_date= $_POST['end_date'];
    $time= $_POST['time'];
    $payment_mode= $_POST['payment_mode'];
    
    $file_name = $_FILES['t_id']['name'];
    $tmp_name = $_FILES['t_id']['tmp_name'];
    $new_file = time().'_'.$file_name;

    move_uploaded_file($tmp_name, "assets/ss/".$new_file);
    $amount= $_POST['amount'];
    $status= 'Pending';
    $obj->insert('payments', [
        'phone_number' => $phone_number,
        'vehicle_number' => $vehicle_number,
        'state' => $state,
         'category' => $category,
         'sub_category' => $sub_category,
        'start_date' => $start_date,
        'end_date' => $end_date,
         'time' => $time,
        'payment_mode' => $payment_mode,
        't_id' => $new_file,
        'amount' => $amount,
        'status' => $status,
    ]);

    if($obj->getResult()){
       echo'<script>location.replace("payment_done.php")</script>'; 
    }
} 
?>
<div class="row">
    <div class="col-md-9">
        <div class="card login-card">
            
            <div class="card-header">
                Payment Mode
            </div>
        
            <div class="card-body p-4"> 
            <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item">
              <a class="nav-link active" data-bs-toggle="tab" href="#home">QR Code</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" data-bs-toggle="tab" href="#menu1">UPI Id</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" data-bs-toggle="tab" href="#menu2">Bank Transfer</a>
            </li>
          </ul>
            <div class="tab-content">
            <div id="home" class="container tab-pane active"><br>
              <h3>QR Code</h3>
              <p><?php
                $obj->sql("SELECT * FROM bank_details ");
                $result = $obj->getResult();
                foreach ($result as $row){ ?> 
                    <img src="assets/qrcode/<?php echo $row['qr_code']; ?>" style="width:250px;">
                <?php } ?>
            </p>

            </div>
            <div id="menu1" class="container tab-pane fade"><br>
              <h5>UPI Id</h5>
              <p><?php
                $obj->sql("SELECT * FROM bank_details ");
                $result = $obj->getResult();
                foreach ($result as $row){ 
                    echo $row['upi_id'];
                }
                ?> 
            </p>
            </div>
            <div id="menu2" class="container tab-pane fade"><br>
              <h5>Bank Transfer</h5>
              <p><?php
                $obj->sql("SELECT * FROM bank_details ");
                $result = $obj->getResult();
                foreach ($result as $row){ 
                    echo "Bank Name : ".$row['bank_name']."<br/>";
                    echo "Account Number : ".$row['account_number']."<br/>";
                    echo "IFSC Code : ".$row['ifsc_code']."<br/>";
                }
                ?>
            </p>

            </div>
          </div>
            </div>
        
        </div>
    </div>
    <div class="col-md-3">
        <div class="card login-card">
    
    <div class="card-header">
        Checkout 
    </div>

    <div class="card-body p-4"> 
 
        <form action="tax.php" method="POST" enctype="multipart/form-data">
                <input type="hidden" name="phone_number" class="form-control" placeholder="Enter phone number" value="<?php echo $_POST['phone_number']; ?>" required>
                <input type="hidden" name="vehicle_number" class="form-control" placeholder="Enter vehicle" value="<?php echo $_POST['vehicle_number']; ?>" required>
                <input type="hidden" name="state" class="form-control" placeholder="Enter state"value="<?php echo $_POST['state']; ?>" required>
                <input type="hidden" name="category" class="form-control" placeholder="Enter state"value="<?php echo $_POST['category']; ?>" required>
                <input type="hidden" name="sub_category" class="form-control" placeholder="Enter state"value="<?php echo $_POST['sub_category']; ?>" required>
                <input type="hidden" name="start_date" class="form-control" placeholder="Enter start date" value="<?php echo $_POST['start_date']; ?>" required>
                <input type="hidden" name="end_date" class="form-control" placeholder="Enter end date" value="<?php echo $_POST['start_date']; ?>" required>
                <input type="hidden" name="time" class="form-control" placeholder="Enter state"value="" required>
                <input type="hidden" name="amount" class="form-control" placeholder="Enter end date" value="200" required>
            <div class="mb-3" >
               <h5>Tax : 200</h5>
                <h5>Fees : 50</h5>
                <h5>Total : 250</h5>
            </div>
            <div class="mb-3">
                <label for="payment_mode">Payment Mode:</label>
                <select id="payment_mode" name="payment_mode"class="form-control" required>
                    <option value="">-- Select --</option>
                    <option value="QR CODE">QR CODE</option>
                    <option value="UPI">UPI</option>
                    <option value="BANK TRANSFER">BANK TRANSFER</option>
                </select>
            </div>

            <div class="mb-3">
                <label>Transection Id :</label>
                <input type="file" name="t_id" class="form-control" placeholder="Transection Id"  required>
            </div>
 
            <div class="d-grid">
                <button type="submit" name="pay_now" class="btn btn-login">
                    Pay Now
                </button>
            </div>

        </form>
    </div>

</div>
    </div>
</div>
</div>
<?php include'footer.php';?>