<!DOCTYPE HTML>
<?php 
include('config.php');

$ven_autoid = $_POST['ven_autoid'];
$pagename = "Lap Pembelian";

$fdate = dtosql($_POST['fdate']);
$tdate = dtosql($_POST['tdate']);

	$filter_q = "";
    foreach($ven_autoid as $value)
    {
		if($value){
			$txt = " a.outlet_autoid = '$value' or";	
			$filter_q = $filter_q.$txt;
		}
		
    }


	if($filter_q){
		$filter_query = " AND ( ".substr_replace($filter_q ,"", -2)." )";
	}
?>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo $pagename?></title>
    <?php include('../../common/script_css.php');?>

</head>
<body class="print_body">
<?php include('../../sys/navprint.php')?>
<div style="padding:5px">
    <table class="table" width="1600" border="1" bordercolor="#CCCCCC" style="font-size:12px">
    <thead>
    	<tr class="bold">
        	<td colspan="12">
            Laporan Pembelian - Outlet
            <br>
            <?php echo iddate($fdate)?> -  <?php echo iddate($tdate)?> 
            </td>
        </tr>
    	<tr class="bold">
        	<td style="width:30px;">No</td>
        	<td style="width:120px;">No Pembelian</td>
        	<td style="width:120px;">Tanggal</td>            
        	<td style="width:220px;">Nama Outlet</td>
            <td style="width:300px;">Catatan</td>
            <td style="width:150px;">Total</td>
	</tr>
	</thead>

<?php
$i = 1;
$gtotal_qty = 0;
$gtotal_amount = 0;

  $sql = " SELECT * FROM poheader_outlet a, mst_outlet b
  			WHERE a.outlet_autoid = b.outlet_autoid AND a.po_status = 1 AND 
			(a.po_transdate BETWEEN '$fdate' AND '$tdate') $filter_query ORDER BY a.po_transdate";
  $dcon = $conn->query($sql) or die($sql);
  while($rs = $dcon->fetch_assoc()){
		


?> 
	<tr>
    	<td><?php echo $i?></td>
        <td><?php echo $rs['po_transno']?></td>
        <td><?php echo dtostr($rs['po_transdate'])?></td>
        <td><?php echo $rs['outlet_name']?></td>
        <td><?php echo $rs['po_notes']?></td>
        <td class="tr"><?php echo number_format($rs['po_amount'])?></td>
	</tr>
<?php 
$i = $i + 1;
$gtotal_amount 	= $gtotal_amount + $rs['po_amount'];
} ?>
	<tr class="bold">
    	<td colspan="5" class="tr">Jumlah</td>
        <td class="tr"><?php echo number_format($gtotal_amount)?></td>
	</tr>
</table>
</div>
</body>

</html>