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

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

#tdh{
color:black;
font-weight:bold;
 
} 

#tdh2{
color:black;
font-weight:bold;
font-size:12; 
} 
</style>

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

// $date1=date('Y-m-d',strtotime($_GET['date1']));
// $date2=date('Y-m-d',strtotime($_GET['date2']));
$date1=$_GET['date1'];
$date2=$_GET['date2'];
//$kodecab=$_GET['kodecab'];
// echo date('Y-m-d',strtotime($_GET['date1']))."<br>";
// echo date('Y-m-d',strtotime($_GET['date2']));

 

//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);
$dateok=date('d-m-Y',strtotime(tgl_rec));
 
 
$sql = "SELECT a.tgl_rec,a.item_code,a.item_desc,sum(a.qty) as qty,sum((a.harga_jual*a.qty)-a.disc_val) as value,a.custname,a.notrans_link,a.return_no FROM Trans1ret a  where date(a.tgl_rec)>='".date('Y-m-d',strtotime($date1))."' and date(a.tgl_rec)<='".date('Y-m-d',strtotime($date2))."'    group by a.tgl_rec,a.custname " ; 

$sql2 = "SELECT sum(a.qty) as totqty,sum((a.harga_jual*a.qty)-a.disc_val) as omzet FROM Trans1ret a  where date(a.tgl_rec)>='".date('Y-m-d',strtotime($date1))."' and date(a.tgl_rec)<='".date('Y-m-d',strtotime($date2))."'      " ; 

$res2 = mysqli_query($conn, $sql2);
$row2 = mysqli_fetch_row($res2);

$res = mysqli_query($conn, $sql);
$resx = mysqli_query($conn, $sql);
$resx2=mysqli_fetch_row($resx);
 

echo "<table>";
echo "<tr><td id='tdh'>Return By Date</td></tr>";
echo "<tr><td id='tdh'>Date : ".date('d-M-Y',strtotime($date1))." To ".date('d-M-Y',strtotime($date2))."</td></tr>";
echo "</table>";
echo "<br>";
echo "<table border='1'>";
echo "<th id='th1'>Tanggal</th><th id='th1'>Product</th><th id='th1'>Qty</th><th id='th1'>Value</th><th id='th1'>Customer</th>";

if($res === false) {
  echo "error while executing mysql: " . mysqli_error($conn);
}
 
 while($row = mysqli_fetch_row($res))
 
 {
echo "<tr><td id='tdh2' colspan='5' align='center'>".$row[6]." - ".$row[7]."</td></tr>";
echo "<tr><td id='td2'>".date('d-m-Y',strtotime($row[0]))."</td><td id='td2'>".$row[2]."</td><td align='right' id='td2'>".$row[3]."</td><td align='right' id='td2'>".number_format($row[4],2)."</td><td align='right' id='td2'>".$row[5]."</td></tr>";  
     
 }
 echo "<tr><td colspan='2'>Total </td><td align='right' id='td1'> ".number_format($row2[0],2)."</td><td align='right' id='td1'> ".number_format($row2[1],2)."</td></tr>";
 
   
   
 
 

 
mysqli_close($conn);
 
?>
