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

75 lines
3.2 KiB
PHP

<?php include('pdf_header.php');
//include('includes/config/config.php');
//include('includes/functions.php');
//include('pop_up_top.php');
?><html>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<body>
<table width="100%" >
<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"><strong>STOCK LEVEL</strong></td>
<td width="25%" align="left"> User : <?php echo $username ?></td>
</tr>
</table>
<table border="1">
<?php
//$item_id=$_REQUEST['flex_item_id']; where item_id='".$_REQUEST['flex_item_id']."'
$sql=base64_decode($filterkey);
$result = mysqli_query($conn,$sql);
$count=0;
?><tr bgcolor='#eeeeee'><th width=5%>Sr.</th><th width=25%>Item</th><th width=15%>Total Stock</th><th width=10%>Total Hold</th><th width=10%>Total Avl.</th><th width=30%>Details</th></tr><?php
while($row1=mysqli_fetch_array($result)){
extract($row1);
$total_stock=0;
$total_hold=0;
$item_id=$row1['item_id'];
$item_desc = getItemWithFormName ( $item_id );
$unit_id = getTableFieldValue ( 'tbl_items', 'unit_id', 'item_id', $item_id );
$unit_name = getTableFieldValue ( 'unit_master', 'unit_name', 'unit_id', $unit_id );
$sql_details = "select distinct item_id from item_stock ";
$sql_details = "select item_stock_id,item_id,item_batch_no,expiry_date,stock_qty from item_stock where item_id='".$row1 ['item_id']."' and stock_qty>0";
$result_details = mysqli_query($conn,$sql_details );
$detailed_info='';
while ( $row_details = mysqli_fetch_assoc ( $result_details ) ) {
extract ( $row_details );
$item_stock = $stock_qty;
$sql_item_stock1 = "select sum(issue_qty),item_batch_no from stock_issue_items where stock_issue_id in (select stock_issue_id from stock_issue where STATUS='N' ) and item_id=$item_id and item_batch_no='" . $item_batch_no . "' group by item_batch_no,item_id ";
$result_item_stock1 = mysqli_query($conn,$sql_item_stock1 );
$row_item_stock1 = mysqli_fetch_array ( $result_item_stock1 );
if ($row_item_stock1 [0] != "" && $row_item_stock1 [0] != null) {
$hold_qty = $row_item_stock1 [0];
} else {
$hold_qty = 0.0;
}
$total_hold+=$hold_qty;
$total_stock+=$item_stock;
$available_qty = floatval ( $item_stock ) - floatval ( $hold_qty );
$detailed_info.="&nbsp;<br><br><p><b>Batch</b>:".$item_batch_no;
$detailed_info.=", <b>Expiry</b>:";
$detailed_info.=(isset($row_details ['expiry_date']))?date_format ( date_create ( $row_details ['expiry_date'] ), "M-Y " ):"";
$detailed_info.=", <b>Stock</b>: ".$item_stock . " " . $unit_name;
$detailed_info.=", <b>Hold</b>: ".$hold_qty . " " . $unit_name;
$detailed_info.=", <b>Available</b>: ".$available_qty . " " . $unit_name."</p>";
}
//$links = $edit_link1;
$total_available=floatval ( $total_stock ) - floatval ( $total_hold );
$count=$count+1;
?><tr><td><?php echo $count;?></td><td> <?php echo $item_desc ; ?></td><td> <?php echo $total_stock." ".$unit_name ?></td><td> <?php echo $total_hold." ".$unit_name ?></td><td> <?php echo $total_available." ".$unit_name ?></td><td> <?php echo $detailed_info ?></td></tr>
<?php
}
?>
</table>
</body>
</html>
<?php
include('pdf_footer.php');
?>