<style type='text/css'>
#th1{
background-color:blue;    
color:white;
font-weight:bold;
padding:5px;
font-size:8px;
}   

#td1{
background-color:black;    
color:white;
font-weight:bold;
padding:5px;
font-size:8px;
}   
   
#td2{
color:black;
padding:5px;
font-size:8px;
}   

#tdh{
color:black;
font-weight:bold;
font-size:8px; 
} 
</style>

<?php
 
include 'dbconfig.php';
 
// Create connection

$nopos=$_GET['nopos'];
//echo $notrans;
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}
 
$sql3="select * from toko_profile";
$res3 = mysqli_query($conn, $sql3);
$row3 = mysqli_fetch_row($res3);

$sql = "SELECT item_code,item_desc,harga_jual,qty,disc_val,custname FROM Trans1ret where return_no='".$nopos."'"." order by idno desc" ;

$sql2 = "SELECT sum(harga_jual*qty)-sum(disc_val) as totrp,sum(disc_val) as discount FROM Trans1ret where return_no='".$nopos."'"." order by idno desc" ;

$res2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_row($res2);
//customer from transaksi
$cust=mysqli_query($conn,"select custname,custid from Trans1ret where return_no='".$nopos."'");
$rowcust = mysqli_fetch_row($cust);
//customer from tbcustomer
$cust2=mysqli_query($conn,"select nohp,alamat from TbCustomer where custid='".$rowcust[1]."'");
$rowcust2 = mysqli_fetch_row($cust2);



$res = mysqli_query($conn, $sql);
echo "<table>";
echo "<tr><td id='tdh'>".$row3[2]."</td></tr>";
echo "<tr><td id='tdh'>".$row3[3]."</td></tr>";
echo "<tr><td id='tdh'>Contact Phone : ".$row3[4]."</td></tr>";
echo "</table>";
echo "<br>";
echo "<table border='1'>";
echo "<tr><th id='th1' colspan='5' align='center'>NO :".$nopos."</th></tr>";
echo "<tr><th id='th1' colspan='5' align='center'>".$rowcust[0]."/".$rowcust2[0]."</th></tr>";
echo "<tr><th id='th1'>Item Code</th><th id='th1'>Product</th><th id='th1'>Harga</th><th id='th1'>Qty</th><th id='th1'>Disc</th></tr>";

if($res === false) {
  echo "error while executing mysql: " . mysqli_error($conn);
}
 
 while($row = mysqli_fetch_row($res))
 
 {

echo "<tr><td id='td2'>".$row[0]."</td><td id='td2'>".$row[1]."</td><td align='right' id='td2'>".number_format($row[2],2)."</td><td align='right' id='td2'>".number_format($row[3],2)."</td><td align='right' id='td2'>".number_format($row[4],2)."</td></tr>";  
     
 }
 echo "<tr><td colspan='5' align='right' id='td1' >Total (IDR) : ".number_format($row2[0],2)." / Disc. : ".number_format($row2[1],2)."  </td></tr>";
 echo "<tr><td colspan='5' style='font-size:10px;'>Printing Date : ".date('d-M-Y')."</td></tr>";
 
   
   
 
 

 
mysqli_close($conn);
 
?>
