<?php include("header.php");
 include("side.php");
 include("../db.php");
 if(isset($_GET['id'])){
  $_SESSION['salim']=$_GET['id'];
}
  $is=$_SESSION['salim'];
  extract($_REQUEST);
  if(isset($update)){
$sql=mysqli_query($conn,"UPDATE `order_products` SET `status`='$status' WHERE place_id='$is'");
	$alert='<div class="alert alert-success alert-dismissible">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Order is '.$status.'!</strong> .
  </div>';
	}

?>
           <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css">
           <style>
           	body{
  font-family: "Open Sans";
  font-size:16px;
}
select{
  padding:8px 5px;
  border-radius:5px;
  color:#333;
  width:250px;
}
.font-awesome .fa{
  font-family: "Font Awesome 5 Free", Open Sans;
  font-weight:501;
}
           </style>
            <div id="layoutSidenav_content">
                <main>
                    <div class="container-fluid">
                        <h2 class="mt-30 page-title">Orders</h2>
                        <ol class="breadcrumb mb-30">
                            <li class="breadcrumb-item"><a href="index.php">Dashboard</a></li>
                            <li class="breadcrumb-item"><a href="orders.php">Orders</a></li>
                            <li class="breadcrumb-item active">Order View</li>
                        </ol>
                        <div class="row">
							<div class="col-xl-12 col-md-12">
								<?php if(isset($alert)){ echo $alert; } ?>
								<div class="card card-static-2 mb-30">
									<div class="card-title-2">

										<h2 class="title1458">Invoice</h2>
										<span class="order-id">Order - #ORDER<?=$is;?></span> 
									</div>
									<div class="invoice-content">
										<div class="row">
											<div class="col-lg-6 col-sm-6">
												<div class="ordr-date">
													<b>Order Date :</b> <?=$_SESSION['e'];?>
												</div>
											</div>
											<div class="col-lg-6 col-sm-6">

												<div class="ordr-date right-text">
													<b>Order Date :</b><br>
													#0, <?=$_SESSION['a'];?>, <?=$_SESSION['b'];?> - <?=$_SESSION['c'];?>
												</div>
											</div>
											<div class="col-lg-12">
												<div class="card card-static-2 mb-30 mt-30">
													<div class="card-title-2">
														<h4>Recent Orders</h4>
													</div>
													<div class="card-body-table">
														<div class="table-responsive">
															<table class="table ucp-table table-hover">
																<thead>
																	<tr>
																		<th style="width:130px">#</th>
																		<th>Item</th>
																		<th style="width:150px" class="text-center">Price</th>
																		<th style="width:150px" class="text-center">Qty</th>
																		<th style="width:100px" class="text-center">Total</th>
																	</tr>
																</thead>
																<tbody>
																		<?php 
															 $sql=mysqli_query($conn,"SELECT o.product_name,o.place_id,o.date,p.address,p.city,p.pin,o.status,o.subtotal,o.price,o.qty,o.total FROM place p INNER JOIN order_products o ON p.id = o.place_id WHERE o.place_id='$is'" );
																		$sn='1';
																		  while($row=mysqli_fetch_object($sql)) {
																		  	$_SESSION['a']=$row->address;
																		  	$_SESSION['b']=$row->city;
																		  	$_SESSION['c']=$row->pin;
																		  	$_SESSION['d']=$row->place_id;
																		  	$_SESSION['e']=$row->date;
																		  	$_SESSION['total']=$row->total;
														
																		   ?>
												
																	<tr>
																		<td><?=$sn++;?></td>
																		<td>
																			<a href="#" target="_blank"><?=$row->product_name;?></a>
																		</td>
																		<td class="text-center"><?=$row->price;?></td>
																		<td class="text-center"><?=$row->qty;?></td>
																		<td class="text-center"><?=$row->subtotal;?></td>
																	</tr>
																<?php } ?>
																	
																</tbody>
															</table>
														</div>
													</div>
												</div>
											</div>
											<div class="col-lg-7"></div>
											<div class="col-lg-5">
												<div class="order-total-dt">
													<div class="order-total-left-text">
														Service Tax
													</div>
													<div class="order-total-right-text">
														&#8377;50
													</div>
												</div>
												<div class="order-total-dt">
													<div class="order-total-left-text">
														Delivery Fees
													</div>
													<div class="order-total-right-text">
														&#8377;50
													</div>
												</div>
												<div class="order-total-dt">
													<div class="order-total-left-text fsz-18">
														Total Amount
													</div>
													<div class="order-total-right-text fsz-18">
														&#8377;<?=number_format($_SESSION['total'],2);?>
													</div>
												</div>
											</div>
											<div class="col-lg-7">
												<div class="select-status">
													<label for="status">Status*</label>
													<div class="status-active">
														<?php 
																		 $sqlw=mysqli_query($conn,"SELECT distinct status  FROM  order_products WHERE place_id='$is'" );
																		$sn='1';
																		  while($row=mysqli_fetch_object($sqlw)) { echo $row->status; }?>
													</div>
												</div>
											</div>
											<div class="col-lg-5">
												<form action="" method="post">
												<div class="select-status">
													<label for="status">Status*</label>
													<div class="input-group">
														<select id="status" name="status" class="custom-select">
															<option selected="">Pending</option>
															<option>Cancel</option>
															<option>Progress</option>
															<option>Completed</option>
														</select>


														<div class="input-group-append">
															<button class="status-btn hover-btn" name="update" value="Done" type="submit">Submit</button>
														</div>
													</div>
												</div>
												</form>
											</div>
										</div>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </main>
            <?php include("footer.php"); ?>

    