<?php 
include("header.php");
 include("side.php");
 include("../db.php");

?> 
<style >
	.badge-statuss {
    color: #fff;
    background-color:red!important;
}
</style>
            <div id="layoutSidenav_content">
                <main>
                    <div class="container-fluid">
                        <h2 class="mt-30 page-title">Offers</h2>
                        <ol class="breadcrumb mb-30">
                            <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                            <li class="breadcrumb-item active">Offers</li>
                        </ol>
                        <div class="row justify-content-between">
							<div class="col-lg-12">
								<a href="add_offer.php?main=8&cat=2" class="add-btn hover-btn">Add New</a>
							</div>
							
						
							<div class="col-lg-12 col-md-12">
								<div class="card card-static-2 mt-30 mb-30">
									<div class="card-title-2">
										<h4>All Offers</h4>
									</div>
									<div class="card-body-table">
										<div class="table-responsive">
											<table class="table ucp-table table-hover " id="table_id">
												<thead>
													<tr>
														<th >S.No.</th>
														<th style="width:130px">Image</th>
														<th>Title</th>
														<th>Offer</th>
														<th>Offer expire</th>
														<th>Update</th>
														<th>Status</th>
														<th>Action</th>
													</tr>
												</thead>
												<tbody>
													<?php 
													$sql=mysqli_query($conn,"SELECT * FROM `offer` WHERE 1 ORDER BY id DESC");
													$sn='1';
													while ($row=mysqli_fetch_object($sql)) {
													?>
													<tr>
														<td><?=$sn++;?></td>
														<td>
															<div class="offer-img">
																<img src="../uploads/<?=$row->image;?>" class="im" alt="">
															</div>
														</td>
														<td>📢 <?=$row->title;?></td>
														<td><?=$row->offer;?></td>
														<td><?=$row->expiry;?></td>
														<td><?php echo get_time_ago( strtotime($row->date) );?></td>
														<td>
															<?php if($row->status == '1'){ echo '<a href="update.php?id='.$row->id.'&opo=deactive" class="edit-btn" title="Deactive"><span class="badge-item badge-status"> Active</span></a>'; } else { echo '<a href="update.php?id='.$row->id.'&opo=active" class="edit-btn" title="Active"><span class="badge-item badge-statuss"> Deactive</span></a>'; }?></span></td>
														<td class="action-btns">
															<?php if($row->status == '1'){ echo '<a href="update.php?id='.$row->id.'&opo=deactive" class="edit-btn" title="Deactive"><i class="fa fa-power-off" aria-hidden="true"></i></a>'; } else { echo '
																<a href="update.php?id='.$row->id.'&opo=active" class="edit-btn" title="Active"><i class="fa fa-check-circle" aria-hidden="true" ></i></a>'; }?>
															<a href="offer_view.php?id=<?=$row->id; ?>" class="edit-btn"><i class="fa fa-eye" aria-hidden="true"></i><a href="delete.php?offer_id=<?=$row->id;?>" class="edit-btn"><i class="fas fa-trash-alt"></i></a>
														</td>
													</tr>
												<?php } ?>
													
												</tbody>
											</table>
										</div>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </main>
              
              <?php 
              include("footer.php");
               ?>