<?php  
 include("includes/db_config.php");
 
$id=$_GET['id'];
$sql="select user_payment.* from user_payment  where user_payment.id='".$id."'";
$res_data= mysqli_query($conn, $sql);
$resid= mysqli_fetch_array($res_data);
/*$country=$resid['country'];
$state=$resid['state'];
$city=$resid['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); */ ?>
 <!DOCTYPE html>
<html lang="en-IN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <title>Orange Groceries</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <?php include("includes/css.php")?>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
  <div class="wrapper">

  <?php include("includes/header.php");?>
    <?php include("includes/sidebar.php");?>
<div class="content-wrapper">
      <section class="content">
        <div class="row">

          <div class="col-xs-12">
            <div class="box box-danger">
<div style="width:100%;margin:0 auto">
  <table style="width:100%;border:solid 1px #fff;padding:0px" cellspacing="0" id="divToPrint">
    <tbody>
      <tr> 
        <td>
          <table style="width:800px;border:solid 1px #fff;padding:0px" cellspacing="0">
            <tbody>
              <tr>
                <td style="padding:0px; background-color: #e96125" width="633px" height="51px"><a style="margin:0 0 0 10px;display:inline-block" href="#">
                    <img src="img/logo.png" alt="orangegroceries.com">
                  </a>
                </td>
              </tr>
              <tr style="background:#e96125;width:100%;border-bottom:1px solid #ccc;padding:0px">
                <td style="padding:0px">
                  <table style="width:800px;margin:0 auto;background:#fff;margin:0 10px 10px" 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:800px;background-color: #fff;" cellspacing="0" cellpadding="0" border="0">
                                    <tbody>
                                      <tr>
                                        <td style="height:20px;color:#000000;width:80px; font-size:12px;"><strong>Order No:</strong>
                                          <?php echo $resid['order_id']; ?>
                                        </td>
                                      </tr>
                                      <tr>
                                       <td class="col-sm-4 invoice-col">
          From
          <address>
            <strong>Orange Groceries</strong><br>
            Hyderabad, Telangana - <br>India
        
            Phone: +91-9876543210<br>
            Email: support@orangegroceries.com
          </address>
       </td>
     
        <td class="invoice-col">
          To
          <?php $id=$resid['user_id'];
           $query="select * from user_profile where id='$id'";
           $result= mysqli_query($conn, $query);
           $row= mysqli_fetch_array($result); 
               $country=$resid['country'];
                $state=$resid['state'];
                $city=$resid['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);

                $shp_country=$row['country'];

$shp_state=$row['state'];
$shp_city=$row['city'];
$sql_country = mysqli_query($conn,"select * from countries where id = '$shp_country'");
$s_country = mysqli_fetch_array($sql_country);
$sql_state = mysqli_query($conn,"select * from states where id = '$shp_state'");
$s_state = mysqli_fetch_array($sql_state);
$sql_city = mysqli_query($conn,"select * from cities where id = '$shp_city'");
$s_city = mysqli_fetch_array($sql_city);?>
          <address>
            <strong><?php //echo $row['addr']; ?></strong><br>
          <!--   <?php echo $row_city['name'].", ".$row_state['name'].", ".$row_country['name']; ?><br>
            Phone: <?php echo $row['mob_no']; ?><br>
            Email: <?php echo $row['email']; ?> -->

                                               Name: <?php echo $resid['name']; ?><br>
                                          Phone: <?php echo $resid['phone']; ?><br>
                                          Email: <?php echo $row['email']; ?><br>
                                          <?php if(!empty($resid['address'])){echo $resid['address'];}else{
                                            echo $row['addr'];
                                          } ?>,<br>
                                          <?php if(!empty($row_city['name'])){ echo $row_city['name']."-".$resid['pincode'];} else{
                                            echo $s_city['name']."-".$resid['shp_pincode'];
                                          } ?>,<br>
                                          <?php if(!empty($row_state['name'])){ echo $row_state['name'];} else{
                                            echo $s_state['name'];
                                          } ?>,<br>
                                          <?php if(!empty($row_country['name'])){ echo $row_country['name'];} else{
                                            echo $s_country['name'];
                                          } ?>,<br>
                                          Phone Number: <?php echo $resid['phone']; ?>
          </address>
 </td>

                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              <tr>
                                <td style="background-color:#d2d3d5;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="color:#000000;vertical-align:top"></td>
                                        <td style="font-weight:bold;vertical-align:top;width:145px;padding-right:30px"><br/><br/></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>
                                        <td style="background-color:#d2d3d5;width:20px">&nbsp;</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;font-weight:bold;width:35px">
                                          Sl 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;font-weight:bold;width:240px">
                                          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;font-weight:bold;width:30px">
                                          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;width:70px">
                                         Product Quantity 
                                        </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">
                                          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:70px">
                                          Sub Total
                                        </td>

                                        <td style="background-color:#d2d3d5;width:20px">&nbsp;</td>
                                      </tr>
                                      <?php $cart_id=$resid['cart_id'];
                                       $rid = explode(",",$cart_id);
                                            $j=1;
                                           foreach($rid as $in_id){
                       $query="select * from addto_cart where id='".$in_id."'";
                            $res_datas= mysqli_query($conn, $query);
                                     while($res= mysqli_fetch_array($res_datas)){                             $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="width:20px">&nbsp;</td>
                                        <td style="text-align:center;padding:3px 0 3px 3px">
                                          <?php echo $j; $j++; ?>
                                        </td>
                                        <td style="width:240px;padding:3px 0 3px 3px">
                                          <label style="line-height:18px">
                                            <a style="text-decoration:none;text-transform: capitalize;">
                                              <?php echo $res['prod_name']; ?></a>
                                          </label>
                                        </td>
										  <td style="text-align:center;width:70px;padding:3px 0 3px 3px">
                                          <label>
                                            <?php echo $res['price']; ?>
                                          </label>
                                        </td>
										  <td style="text-align:center;width:70px;padding:3px 0 3px 3px">
                                          <label>
                                          <?php echo $prd_dt=$res['prod_size']; ?>
                                          </label>
                                        </td>
                                        <td style="text-align:center;padding:3px 0 3px 3px;width:30px">
                                          <label><?php echo $res['quantity']; ?></label>
                                        </td>
                                        
                                        <td style="text-align:center;padding:3px 0 3px 3px;width:70px">
                                          <label>Rs.
                                            <?php if(!empty($res['quantity'])){
										  $price=($res['price'] * $res['quantity']); echo $price;
									  }else{
										  echo $res['price'];
									  }?></label>
                                        </td>
                                        <!-- <td style="text-align:center;padding:3px 0 3px 3px;width:75px">
                                          <label>Rs. 47.75 </label>
                                        </td> -->
                                        <td></td>
                                      </tr>
                                    <?php } } ?>
                                      <tr>
                                        <td colspan="8" style="background:#ededed;color:#000000;padding:5px 20px;text-transform:uppercase" width="250"> </td>
                                      </tr>
                                        <?php 
                                        $totalp=$resid['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" colspan="6" >
                                          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">
                                          <?php echo "100"; ?> </td>
                                        <td style="background-color:#d2d3d5;width:20px">&nbsp;</td>

                                      </tr><?php } ?>


                                     <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" colspan="6" >
                                          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">
                                          <?php echo $resid['total_price']; 
                                    ?>
                                        </td>

                                        <td style="background-color:#d2d3d5;width:20px">&nbsp;</td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                              
                            

                            </tbody>
                          </table>
                        </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
                 +91-9876543210 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" style="height: 50px; padding: 5px10px; color: white; background-color: green; border: 0px;" onClick="PrintDiv();" >Print</button>
                  </div>
</div>

</div>
  <?php include("includes/js.php");?>
<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>
</body>
</html>