ESH/stock_issue_report_excel.php
2024-10-23 18:28:06 +05:30

62 lines
2.6 KiB
PHP

<?php
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=stock_issue_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<?php
include('includes/config/config.php');
include('includes/functions.php');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
//include('pop_up_top.php');
$from_date = $_REQUEST['startDate2'];
$to_date = $_REQUEST['endDate2'];
?>
<body>
<table width="100%" border="1">
<tr>
<div style="font-size:12px">
<td width="25%" align="left"> Run Date : <?php echo date("d-M-Y"); ?></td>
<td width="50%" align="center" style="font-size:40px"><strong>Stock Issue Report</strong></td>
<td width="25%" align="right"> User : <?php echo $username ?></td>
<?php if(isset($from_date) && isset($to_date)){?>
<td width="25%" align="right"> Range : <?php echo $from_date; ?> to <?php echo $to_date ;?></td>
<?php }?>
</tr>
</table>
<table width="87%" border="1">
<tr>
<th width="2%" align="left">Sr </th>
<th align="left" width="10%">Item</th>
<th align="left" width="30%">Batch</th>
<th align="left" width="10%">Stock Qty</th>
<th width="10%" align="left">Issued qty</th>
</tr>
<?php
$from_date = $_REQUEST['startDate2'];
$to_date = $_REQUEST['endDate2'];
$count = 0;
$sql_stock_issue="SELECT sum(issue_qty) as total_qty,item_id,item_batch_no FROM `stock_issue_items` a inner join stock_issue b on a.stock_issue_id=b.stock_issue_id where b.issue_date between STR_TO_DATE('".$from_date."', '%d-%m-%Y') AND STR_TO_DATE('".$to_date."', '%d-%m-%Y') and a.issue_ohc_type_id='".$_SESSION['current_ohcttype']."' and a.item_id in (SELECT item_id from tbl_items) group by item_id,item_batch_no ";
$results_stock_issue = mysqli_query($conn,$sql_stock_issue);
while ($row_stock_issue = mysqli_fetch_array($results_stock_issue)) {
$item_desc = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row_stock_issue['item_id']);
$stock_qty = getTableFieldValue('item_stock', 'stock_qty', 'item_id', $row_stock_issue['item_id'],'item_batch_no',"'".$row_stock_issue['item_batch_no']."'" );
?><tr>
<td><?php echo ++$count?></td>
<td><?php echo $item_desc?></td>
<td><?php echo $row_stock_issue['item_batch_no'];?></td>
<td><?php echo $stock_qty?></td>
<td><?php echo $row_stock_issue['total_qty']?></td>
</tr><?php
}
?>
</table>