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

?>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.css">
  
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.js">
</script>

<style >
	.badge-statuss {
    color: #fff;
    background-color:red!important;

}
.badge-status {
    background-color: #0ab20d!important;
}
</style>

            <div id="layoutSidenav_content">
                <main>
                    <div class="container-fluid">
                        <h2 class="mt-30 page-title">Products</h2>
                        <ol class="breadcrumb mb-30">
                            <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                            <li class="breadcrumb-item active">Products</li>
                        </ol>
                        <div class="row justify-content-between">
							<div class="col-lg-12">
								<a href="add_product.php?main=7&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 Categories</h4>
									</div>
									<div class="card-body-table">
										<div class="table-responsive">
											<table class="table ucp-table table-hover display" id="table_id">
												<thead>
													<tr>
														<!-- <th ><input type="checkbox" class="check-all"></th> -->
														<th >ID</th>
														<th >Image</th>
														<th>Product Name</th>
														<th>Sell Price</th>
														<th>MRP</th>
														
														<th>(mrp % sell) Discount</th>
														<th>Created</th>
														<th>Status</th>
														</tr>
												</thead>
												<tbody>
													<?php 
													$sql=mysqli_query($conn,"SELECT * FROM `product` WHERE (status='1' or status='2') ORDER BY id DESC");
													$sn='1';
													while ($row=mysqli_fetch_object($sql)) {
														$x = $row->price; 
										                $total = $row->mrp; 
										                $percentage = ($x*100)/$total;
										                $percentag=100-$percentage; 
													?>													
													<tr>
														<!-- td><input type="checkbox" class="check-item" name="ids[]" value="11"></td> -->
														<td><?=$sn++;?></td>
														<td>
															<div class="cate-img">
																<img src="../uploads/<?=$row->image1;?>" class="im" alt="">
															</div>
														</td>
														
														<td><?=$row->product_name;?></td>
														<!-- <td>&#8377;<?=number_format($row->buyprice);?></td> -->
														<td>&#8377;<?=number_format($row->price);?></td>
														<td>&#8377;<?=number_format($row->mrp);?></td>
														<td><?=number_format($percentag);?>% OFF</td>
														<td><?php echo get_time_ago( strtotime($row->date) );?></td>
														
														<td>
															<?php if($row->status == '2'){ echo '<a href="update.php?id='.$row->id.'&opp=deactive" class="edit-btn" title="Deactive"><span class="badge-item badge-status"> Selected</span></a>'; } else { echo '<a href="update.php?id='.$row->id.'&opp=active" class="edit-btn" title="Active" ><span class="badge-item badge-statuss"> Unselect</span></a>'; }?></span></td>
															
													</tr>
													
												<?php } ?>
													
												</tbody>
											</table>
										</div>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </main>
               <?php include("footer.php"); ?>
<!-- href="update.php?id='.$row->id.'&op=active" -->
<!-- Button trigger modal -->
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
  Launch demo modal
</button> -->

<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
													  <div class="modal-dialog modal-dialog-centered" role="document">
													    <div class="modal-content">
													      <div class="modal-header">
													        <h5 class="modal-title" id="exampleModalLongTitle">Active proccess..</h5>
													        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
													          <span aria-hidden="true">&times;</span>
													        </button>
													      </div>
													      <div class="modal-body">
													      	Price
													       <input type="text" name="pvprice" value="<?=$pp2;?>" class="form-control">
													       PV Price
													       <input type="text" name="pv" value="2" class="form-control">
													      </div>
													      <div class="modal-footer">
													        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
													        <button type="button" class="btn btn-primary">Save changes</button>
													      </div>
													    </div>
													  </div>
													</div>