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

<div class="app-content content">
    <div class="content-overlay"></div>
    <div class="content-wrapper">
        <div class="content-header row"></div>
        <div class="content-body"> 

                <div class="row">
                    <div class="col-12">
                        <div class="card">

                            <div class="card-header">
                                <h4 class="card-title mb-1">Paymets</h4>
                            </div>

                            <div class="card-content">
                                <div class="card-body">



<!-- CUSTOMER LIST TABLE -->
<div class="table-responsive col-md-12 s-right mt-2">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>phone number</th>
                <th>vehicle number </th>
                <th>state</th>
                 <th>category</th>
                 <th>Sub category</th>
                <th>start date</th>
                <th>end date</th>
                 <th>payment mode</th>
                <th>amount</th>
                <th>status</th>
                 <th>transection id</th>
                 <th></th>
            </tr>
        </thead>

        <tbody>
<?php
$obj->sql("SELECT * FROM payments ORDER BY id DESC");
$result = $obj->getResult();
foreach ($result as $row) { ?>
    <tr>
        <td><?php echo $row['phone_number']; ?></td>
        <td><?php echo $row['vehicle_number']; ?></td>
        <td>
            <?php
            $scode= $row['state'];
            $obj->sql("SELECT * FROM state WHERE code='$scode'");
            $result1 = $obj->getResult();
            foreach ($result1 as $row1) { echo $row1['name']; } ?>
        </td>

        <td>
            <?php
            $ca_id= $row['category'];
            $obj->sql("SELECT * FROM category WHERE id='$ca_id'");
            $result1 = $obj->getResult();
            foreach ($result1 as $row1) { echo $row1['name']; } ?>
        </td>
        <td>
            <?php
            $sc_id= $row['sub_category'];
            $obj->sql("SELECT * FROM sub_category WHERE id='$sc_id'");
            $result1 = $obj->getResult();
            foreach ($result1 as $row1) { echo $row1['name']; } ?>
        </td>
        <td><?php echo $row['start_date']; ?></td>
        <td><?php echo $row['end_date']; ?></td>
        <td><?php echo $row['payment_mode']; ?></td>
        <td><?php echo $row['amount']; ?></td>
        <td><?php echo $row['status']; ?></td>
<!-- Image -->
<td>
    <img src="../assets/ss/<?php echo $row['t_id']; ?>" 
         width="100px"
         style="cursor:pointer;border-radius:5px;"
         data-toggle="modal" 
         data-target="#imgModal<?php echo $row['id']; ?>">
<div class="modal fade" id="imgModal<?php echo $row['id']; ?>" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
        <div class="modal-content bg-transparent border-0">
            
            <button type="button" class="close text-white position-absolute" 
                    style="right:10px;top:10px;z-index:999;"
                    data-dismiss="modal">
                <span style="font-size:40px;">&times;</span>
            </button>

            <img src="../assets/ss/<?php echo $row['t_id']; ?>" 
                 class="img-fluid rounded">
                 
        </div>
    </div>
</div>

</td>

<!-- Image Modal -->
        <td>
            <button type="button" title="Edit" data-toggle="modal" data-target="#edit<?php echo $row['id']; ?>" class="btn btn-icon btn-info"><i class="bx bxs-pencil"></i></button>
            	<div class="modal fade text-left" id="edit<?php echo $row['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel110" style="display: none;" aria-hidden="true">
            		<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
            			<div class="modal-content">
            				<div class="modal-header bg-info">
            					<h5 class="modal-title white" id="myModalLabel110">Edit</h5>
            					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
            						<i class="bx bx-x"></i>
            					</button>
            				</div>
            				<div class="modal-body">									
                                <form class="form" action="" method="POST">
                                    <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                                    <div class="form-body">
                                        <div class="row">
                                
                                            <div class="col-md-4 mt-1">
                                                <div class="form-label-group position-relative has-icon-left">
                                            
                                                    <select class="form-control" name="status" required>
                                                        <option value="">Select Status</option>
                                                        <option value="Pending" <?php if($row['status'] == 'Pending'){ echo 'selected'; } ?>>Pending</option>
                                                        <option value="Completed" <?php if($row['status'] == 'Completed'){ echo 'selected'; } ?>>Completed</option>
                                                        <option value="Reject" <?php if($row['status'] == 'Reject'){ echo 'selected'; } ?>>Reject</option>
                                                    </select>
                                            
                                                    <div class="form-control-position">
                                                        <i class="bx bx-package"></i>
                                                    </div>
                                            
                                                    <label>Status</label>
                                                </div>
                                            </div>

                                            <div class="col-md-12 d-flex justify-content-end">
                                                <button type="submit" class="btn btn-primary mr-1 mb-1" name="edit_payments">Submit</button>
                                                <button type="reset" class="btn btn-light-secondary mr-1 mb-1">Reset</button>
                                            </div>
                                
                                        </div>
                                    </div>
                                </form>
            
                            </div>
            				<div class="modal-footer">
            					NOTE: <i>Fill Details Carefully.</i>
            				</div>
            			</div>
            		</div>
            	</div>              

        </td>
    </tr>
<?php } ?>

        </tbody>
    </table>
</div>


                        </div><!-- card-content -->
                    </div><!-- card -->
                </div>
            </div>
        </section>

    </div>
</div>
</div>
</div>

<div class="sidenav-overlay"></div>
<?php include'footer.php'; ?>
