		<?php
			// Database connection
			include '../../connection.php'; 

			// Retrieve data
			$sql = "SELECT all_drive_package.id, sim_entry.sim_name, district.dist_name, all_drive_package.offer_name,all_drive_package.offer_amount,all_drive_package.offer_meyad,all_drive_package.offer_commision,all_drive_package.offer_type FROM all_drive_package 
					left join sim_entry on all_drive_package.offer_sim = sim_entry.sim_id
					left join district on all_drive_package.offer_area = district.dist_id
					order by all_drive_package.id desc";
			$result = $con->query($sql);
			$sl=0;

			if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['delete_id'])) {
				$delete_id = $_POST['delete_id'];
				$delete_sql = "DELETE FROM all_drive_package WHERE id = ?";
				$stmt = $con->prepare($delete_sql);
				$stmt->bind_param("i", $delete_id);
				$stmt->execute();
				header("Location: offer.php"); 
				exit();
			}
		?>
	
	<?php include 'header-link.php' ?>
	
	<?php include 'nav-bar.php' ?>

	
	<?php include 'header-top-chat.php' ?>
	
	
	
<!-- [ Main Content ] start -->
<section class="pcoded-main-container">
    <div class="pcoded-wrapper">
        <div class="pcoded-content">
            <div class="pcoded-inner-content">
                <div class="main-body">
                    <div class="page-wrapper">
                        <!-- [ breadcrumb ] start -->
                        <div class="page-header">
                            <div class="page-block">
                                <div class="row align-items-center">
                                    <div class="col-md-12">
                                        <div class="page-header-title">
                                            <h5 class="m-b-10"> Drive & Package List</h5>
                                        </div>
                                       
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- [ breadcrumb ] end -->
                        <!-- [ Main Content ] start -->

                      
                        <div class="row">
                           
                            <!-- Default ordering table start -->
                            <div class="col-sm-12">
                                <div class="card">
                                    <div class="card-header">
                                        <h5> <a href="offer-add.php" class="btn btn-primary" ><span class="pcoded-micon"><i	class="feather icon-plus-square"></i></span> Add New </a> </h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="dt-responsive table-responsive">
                                            <table id="order-table" class="table table-striped table-bordered nowrap text-center">
                                                <thead>
                                                    <tr>
                                                        <th> Sl </th>
                                                        <th> Offer Name </th>
                                                        <th>  Amount (Tk)  </th>
                                                        <th>  Validation (Meyad) </th>
                                                        <th> Offer Commission (Tk) </th>
                                                        <th> Offer Type </th>
                                                        <th> Mobile Operator </th>
                                                        <th> Area </th>
                                                        <th> Action </th>
                                                    </tr>
                                                </thead>
                                                 <tbody>
													<?php if ($result->num_rows > 0): ?>
														<?php while($row = $result->fetch_assoc()): ?>
															<tr>
																<th scope="row"><?php  echo ++$sl ?></th>
																<td><?php echo $row['offer_name']; ?></td>
																<td><?php echo $row['offer_amount']; ?></td>
																<td><?php echo $row['offer_meyad']; ?></td>
																<td><?php echo $row['offer_commision']; ?></td>
																<td><?php echo $row['offer_type']; ?></td>
																<td><?php echo $row['sim_name']; ?></td>
																<td><?php echo $row['dist_name']; ?></td>
																<td>
																	<!--<a class="btn-sm btn-success mx-3" href="edit-bal-request.php?id=<?php echo $row['id']; ?>"> <i
                                                                    class="feather icon-edit"></i> </a> --> 
																	<form action="" method="POST" style="display:inline;">
																		<input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
																		<button type="submit" class="btn-sm btn-danger" onclick="return confirm('Do You Want To Delete ?')"> <i
                                                                        class="feather icon-trash-2"></i> </button>
																	</form>
																</td>
															</tr>
														<?php endwhile; ?>
													<?php else: ?>
														<tr><td colspan="6">No records found.</td></tr>
													<?php endif; ?>
												</tbody>
                                                <tfoot>
                                                   <tr>
                                                        <th> Sl </th>
                                                        <th> Offer Name </th>
                                                        <th>  Amount (Tk)  </th>
                                                        <th>  Validation (Meyad) </th>
                                                        <th> Offer Commission (Tk) </th>
                                                        <th> Offer Type </th>
                                                        <th> Mobile Operator </th>
                                                        <th> Area </th>
                                                        <th> Action </th>
                                                    </tr>
                                                </tfoot>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- Default ordering table end -->
                            
                        </div>
                        <!-- [ Main Content ] end -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!-- [ Main Content ] end -->
	
	
	<?php include 'footer.php' ?>

