<?php session_start();
include("includes/db_config.php");
$id=$_GET['id'];
$sql_ptm="select * from user_payment where id='".$id."'";
$result_ptm = mysqli_query($conn, $sql_ptm);
$res_ptm= mysqli_fetch_array($result_ptm);
$cart_id=$res_ptm['cart_id']; 
$user_id=$res_ptm['user_id'];
$session_id=$_SESSION['prd_session_id'];
 ?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content=" ">
    <meta name="author" content="">
    <title>Orange Groceries</title>
    <?php include("includes/css.php");?>
</head>

<body>
<!-- <section class="pt-3 pb-3 page-info section-padding border-bottom bg-white">
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <a href="https://orangegroceries.com/index.php"><strong><span class="mdi mdi-home"></span> Home</strong></a> <span class="mdi mdi-chevron-right"></span> <a href="#">My Order</a>
        </div>
    </div>
</div>
</section>
 --><section class="checkout-page section-padding">
<div class="container">
<div class="row">

<?php $sql=mysqli_query($conn,"select * from user_profile where id='".$user_id."'")or die(mysqli_error($conn));
$resid= mysqli_fetch_array($sql); 
$country=$res_ptm['country'];
$state=$res_ptm['state'];
$city=$res_ptm['city'];
$sql_country = mysqli_query($conn,"select * from countries where id = '$country'");
$row_country = mysqli_fetch_array($sql_country);
$sql_state = mysqli_query($conn,"select * from states where id = '$state'");
$row_state = mysqli_fetch_array($sql_state);
$sql_city = mysqli_query($conn,"select * from cities where id = '$city'");
$row_city = mysqli_fetch_array($sql_city);?>    
<div style="width:634px;margin:0 auto">
    <table style="width:612px;border:solid 1px #fff;padding:0px" cellspacing="0" id="divToPrint">
        <tbody>
            <tr>
                <td>
                    <table style="width:612px;border:solid 4px #57b018;padding:0px" cellspacing="0">
                        <tbody>
        <tr align="center">
            <td style="padding:0px; background-color: #fff; border:1px solid #ccc;" width="633px" height="51px"><a style="margin:0 0 0 10px;display:inline-block text-align:center;" href="https://orangegroceries.com/" align="center">
                    <img src="https://orangegroceries.com/img/logo.png" alt="orangegroceries.com" height="80px" align="center" class="text-center">
                </a>
            </td>
        </tr> 
        <tr style="background:#fff;width:100%;border-bottom:1px solid #ccc;padding:0px">
            <td style="padding:0px">
                <table style="width:612px;padding: 2px 5px;background:#fff;margin:0px" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                  <tr>
                    <td>
                     <table style="width:612px" cellspacing="0" cellpadding="0" border="0">
                     <tbody>
                        <tr>
                         <td>
                          <table style="width:612px;background-color: #fff;" cellspacing="0" cellpadding="0" border="0">
                             <tbody>
                             <tr>
                                <td>
                                    <span style="font-family:Arial,Helvetica,sans-serif;color:#444;font-size:16px;font-weight:normal;text-align:left;padding:20px 10px 10px 10px; text-transform:capitalize;"><br /> &nbsp; &nbsp; Dear <?php echo $res_ptm['name']; ?>,</span>
                                </td>
                            </tr>
                            <tr>
                                <td style="font-family:Arial,Helvetica,sans-serif;color:#444;font-size:22px;font-weight:normal;text-align:center;padding:10px 0 25px">Thank you for your order at <span class="il">orangegroceries.com</span>
                                </td>
                            </tr>
                        </tbody>
                         </table>
                          </td>
                            </tr>
                            <tr>
                            <td style="background-color:#f8f8f8;text-align:left;font-family:Arial,Helvetica,sans-serif;padding:10px 20px;border-bottom:2px solid #fff">
                                <table style="width:540px;font-size:10px;color:#000000; font-size:12px;" cellspacing="0" cellpadding="0" border="0">
                                 <tbody>
                                  <tr>
                                 <td style="height:20px;width:240px;color:#000000; font-size:12px;"><strong>Order No: <?php echo $res_ptm['order_id']; ?></strong> <br/><strong> Date :</strong><?php  $date=$res_ptm['created_date'];  echo $Date = date("d M Y , H:i A ", strtotime($date));  ?><br><br> <strong> Phone Number: </strong> <?php echo $res_ptm['phone']; ?>   <br> <br> </td>
                                        <td style="vertical-align:top; width:300px;font-size:12px;">
                                           <p style="margin:0 0 6px; font-size:12px; color:#000000;">Your order will be delivered to this address:</p>
                                           <span style="text-transform:capitalize; color:#000;"><?php echo $res_ptm['name']; ?></span>,<br>
                                            <span style="text-transform:capitalize; color:#000;"><?php echo $res_ptm['address']; ?>,</span><br>
                                                <?php  echo $row_city['name']."&nbsp;-&nbsp;".$res_ptm['pincode']; ?> <?php echo $row_state['name']; ?>  </td>     
                                             </tr>
											  
                                              </tbody>
                                           </table>
                                           </td>
                                            </tr>
                                            <tr>
                                            <td>
                                        <table style="font-size:11px" width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
                                        <tbody><tr style="background-color:#d2d3d5;">   
                                        <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:left;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold; border-top:1px solid #333; border-bottom:1px solid #333;width:35px">Sr. No.</td>   
										<td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:left;background-color:#d2d3d5;line-height:22px;padding-left:3px;border-top:1px solid #333; border-bottom:1px solid #333;font-weight:bold;width:220px">Item Details </td>
                                         <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;border-top:1px solid #333; border-bottom:1px solid #333;font-weight:bold;width:30px"> Qty. 
                                          </td>  
                                          <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:30px; border-top:1px solid #333; border-bottom:1px solid #333;"> Product Size. 
                                          </td>  
                                         <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:70px;border-top:1px solid #333; border-bottom:1px solid #333;"> Unit Price </td>          <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;border-top:1px solid #333; border-bottom:1px solid #333;width:70px">                         Sub Total                   </td>    </tr> 
                                          <?php $rid = explode(",",$cart_id);
                                            $j=1;
                                           foreach($rid as $in_id){
							$query="select * from addto_cart where id='".$in_id."'";
							$res_data= mysqli_query($conn, $query);
						
                            while($res= mysqli_fetch_array($res_data)){
                            $prd_did=$res['prod_details_id'];
                            $sql_prdd="SELECT * from product_detail where id='$prd_did'";
                            $exe_prdd=mysqli_query($conn,$sql_prdd);
                            $res_prdd=mysqli_fetch_array($exe_prdd);	?>
                              <tr style="background-color:#ffffff;font-size:11px;font-family:arial;color:#000000;line-height:18px">
                                 
                              <td style="text-align:center;padding:3px 0 3px 3px; border-bottom:1px dashed #ccc;">
                                   <?php echo $j; $j++; ?>.
                              </td>
                               <td style="width:240px;padding:3px 0 3px 3px;border-bottom:1px dashed #ccc;">    
                                <label style="line-height:18px"> 
                                 <a style="text-decoration:none;text-transform: capitalize; color:#15c;"><?php echo $res['prod_name']; ?></a>              </label>  </td>           
                               <td style="text-align:center;padding:3px 0 3px 3px;border-bottom:1px dashed #ccc;width:30px"> <label><?php echo $res['quantity']; ?></label> </td> 
                               <td style="text-align:center;padding:3px 0 3px 3px;border-bottom:1px dashed #ccc;width:30px"> <label><?php echo $res_prdd['prod_quantity']." ".$res_prdd['prod_quantity_type'];?></label> </td> 
                               
                        <td style="text-align:center;width:70px;padding:3px 0 3px 3px;border-bottom:1px dashed #ccc;">   <label> <?php echo $res['price']; ?>                       </label>  </td>                         
                         <td style="text-align:center;padding:3px 0 3px 3px;width:70px;border-bottom:1px dashed #ccc;"> <label>Rs.  <?php  $price=($res['price'] * $res['quantity']); echo $price; ?></label>   
                        </td> 
                     
                       </tr>   
                              
                                <?php } } ?>   
                              <?php 
                                $totalp=$res_ptm['total_price'];
                                if($totalp < 1800){ ?> 
                                  <tr>
                                 <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:right;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:70px;border-bottom:1px dashed #ccc;" colspan="5">Delivery Charge</td>  
                                   <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:70px;border-bottom:1px dashed #ccc;">₹<?php //$query="select SUM(price * quantity) AS total from addto_cart where order_no='$order_no' and user_id='$id'";
									 echo "100"; 	?> </td> <?php } ?></tr><tr>
                   <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:right;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:70px;border-bottom:1px dashed #ccc;" colspan="5">

                                  Total Price   </td>  
                                   <td style="font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:18px;color:#000000;text-align:center;background-color:#d2d3d5;line-height:22px;padding-left:3px;font-weight:bold;width:70px;border-bottom:1px dashed #ccc;"><?php //$query="select SUM(price * quantity) AS total from addto_cart where order_no='$order_no' and user_id='$id'";
                  //$res_data= mysqli_query($conn, $query);
                  //$res= mysqli_fetch_array($res_data);
                  echo $res_ptm['total_price']; ?> </td> 

                   </tr>
                                      </tbody>
                                       </table>
                                     </td>
                                     </tr>
                                     <tr style="background-color:#fff">
                                    <td>
                                        <p style="color:#000000;margin-bottom:15px;margin-left:20px;margin-right:0;margin-top:15px">Happy shopping!<br>Team <span class="il">orangegroceries.com</span></p>
                                    </td>
                                </tr>
                                <tr style="background-color:#fff">

                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div style="background:#f7f9f8;border:1px solid #dedede;padding:15px 0px;font-family:'Roboto Slab',serif">
                            <div style="margin-left:auto;margin-right:auto;width:85%;text-align:center">
                                <h3 style="font-family:'Roboto Slab',serif;font-weight:normal;margin:0;font-size:18px">Order Your Groceries On The Go!</h3>


                            </div>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </td>
</tr>
<tr style="background:#e0e0e0">
    <td style="color:#000000;font-family:Arial,Helvetica,sans-serif;font-size:12px;padding:16px">
        In case you need any assistance please do not hesitate to call our customer service on
       <a href="tel:09100454581">+91-9876543210</a> 07:00 am to 10:00 pm on all days or email us at
        <a href="mailto:support@orangegroceries.com" style="color:#e96125;font-size:11px;text-decoration:none; font-weight:800" target="_blank">
            support@<span class="il">orangegroceries</span>.com
        </a> All calls to our customer support number will be recorded for internal training and quality purposes.
    </td>
</tr> 
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div>
<!-- <button type="button" class="btn btn-md" style="height: 42px; padding: 5px 25px; float:left;border-radius:5px; color: white; background-color: green;margin:2px 10px; border: 0px;" onclick="PrintDiv();">Print</button>
 -->
</div>
</div>

</div>
</div>
</section>
    <?php include("includes/js.php");?>
</body>
<script type="text/javascript">
function PrintDiv() 
{
  var divToPrint=document.getElementById('divToPrint');
  var newWin=window.open('','Print-Window');
  newWin.document.open();
  newWin.document.write('<html><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
  newWin.document.close();
  setTimeout(function(){newWin.close();},10);
}

</script>
</html>