<?
session_start();
include('includes/config.php');
include "defs.php";
$user_id = $_GET['user_id'];
  
// Database connection
$con = mysqli_connect("localhost", "apmmwfdg_apmmauser", "asgharali2007", "apmmwfdg_glakb");
  
if ($user_id !== "") {
      
    // Get corresponding first name and 
    // last name for that user id    
    $query = mysqli_query($con, "SELECT * FROM s_details WHERE Inv_No='$user_id'");
  
     $row = mysqli_fetch_array($query);
     $idate = $row["Inv_Date"];
     $cust = $row["Customer"];
     $idet = $row["Inv_Det"]; 
     $tpe = $row["Inv_Type"];
     $tot = $row["N_Total"];
     $sman = $row["Salesman"];
     $city = $row["City"];
     $ware = $row["Warehouse"];
     $invn = $row["Inv_N"];
     $prov = $row["Province"];
  
     $strDate = strtotime($idate);
    $idate = date("d-m-Y",$strDate);
             
}
  

$idd=$invn."-".$user_id;
  ?>
  
  <!DOCTYPE html>
  
  <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<body style="background-color:POWDERBLUE;">

<style>
#customers {
  font-family: Times-Roman;
  border-collapse: collapse;
  width: 100%;
}

#customers td, #customers th {
  border: 0px solid #111;
  padding: 2px;
}

#customers tr:nth-child(even){background-color:gainsboro ;}


#customers th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: center;
  background-color: cornflowerblue;
  color: whitesmoke;
}
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}

input[type=text], input[type=password] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

button {
  background-color: #04AA6D;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  cursor: pointer;
  width: 100%;
}

button:hover {
  opacity: 0.8;
}

.cancelbtn {
  width: auto;
  padding: 10px 18px;
  background-color: #f44336;
}

.imgcontainer {
  text-align: center;
  margin: 24px 0 12px 0;
}

img.avatar {
  width:50%;
 
}

.container {
  padding: 16px;
}

span.psw {
  float: right;
  padding-top: 16px;
}

/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
  span.psw {
     display: block;
     float: none;
  }
  .cancelbtn {
     width: 100%;
  }
}
</style>
</head>
<body>

<script>
let myWindow;

function openWin() {
  myWindow = window.open("", "", "width=200,height=100");
}

function closeWin() {
  myWindow.close();
}
</script>


<form action="" method="post">
     
  <div class="imgcontainer">
    
    <img src="images/logo.png" alt="Avatar" class="avatar">
  </div>
<HR>
<div style="background-color:#f1f1f1;text-align:center;padding:10px;margin-top:0px;font-size:11px;">
    <b>The INVOICE just Scanned contains following information on GLAKB.</b>

</div><HR>
  <div class="container">
    <label for="uname"><b>Invoice No.</b></label>
    <input type="text" name="uname" value="<?php echo $idet ?>" readonly>

    <label for="uname"><b>Invoice Date</b></label>
    <input type="text" name="uname" value="<?php echo $idate ?>" readonly>

 <label for="uname"><b>Customer</b></label>
    <input type="text" name="uname" value="<?php echo $cust ?>" readonly>
 
    <label for="uname"><b>Province</b></label>
    <input type="text" name="uname" value="<?php echo $prov ?>" readonly>

    <label for="uname"><b>City</b></label>
    <input type="text" name="uname" value="<?php echo $city ?>" readonly>


    <label for="psw"><b>Salesman</b></label>
    <input type="text" name="psw" value="<?php echo $sman ?>" readonly>

  <label for="psw"><b>Target Warehouse</b></label>
    <input type="text" name="psw" value="<?php echo $ware ?>" readonly>

  <label for="psw"><b>Invoice Total Amount</b></label>
    <input type="text" name="psw" value="<?php echo $tot ?>" readonly>

    
      
   
    <table align="center" id="customers">
     
<tr>
     <th colspan="3"><FONT SIZE=2>PRODUCT  DETAILS</th>

  </tr>
       <?


$result = mysqli_query($con, "select * from cust_sales where Inv_No='$user_id' order by Id");

           echo "        <td align=center>";
        echo "                <b><font size=2 color=black> PRODUCT </b>";
        echo "        </td>";
         echo "        <td align=center>";
        echo "                <b><font size=2 color=black> CTNS </b>";
        echo "        </td>";

        echo "        <td align=center>";
        echo "                <b><font size=2 color=black> LITERS </b>";
        echo "        </td>";
        



        
        echo "</tr>";
       

                                        while($row = mysqli_fetch_object($result))
                                        {
                                      
echo "<td align=center><font size=2>$row->Name</td>";
echo "<td align=center><font size=2>$row->Carton</td>";

echo "<td align=center><font size=2>$row->Qty</td>";
                                        echo "<tr>";
                                                                                }

 echo "</center>";

    ?>
    
    
    </table>
    
    <br>

  <HR>
<div style="background-color:#f1f1f1;text-align:justify;padding:10px;margin-top:0px;font-size:12px;">
    All Rights Reserved to GULF Lube Ahmad Ullah Khan Brothers.

</div>
  <HR>
    
    
   <button type="submit">REFRESH</button>
   
</form>

</body>
</html>