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

86 lines
2.7 KiB
PHP

<?php
include_once ('pdf_header_reverse.php');
include_once ('includes/config/config.php');
include_once ('includes/functions.php');
?>
<?php
$run_date = $_POST['run_date'];
$sql_shift="select a.* from shift_status_details a where current_status='R' and ohc_location_id='".$_SESSION['current_ohcttype']."'";
$result_shift = @mysqli_query($conn,$sql_shift);
$row_shift=@mysqli_fetch_assoc($result_shift);
error_log("dddddddddddd".$sql_shift);
$shift = 0;
if($row_shift['shift_id'] == 1){
$shift = 3;
}
elseif ($row_shift['shift_id'] == 2) {
$shift = 1;
}
else{
$shift = 2;
}
$sql_balance= "select i.item_id,trim(concat(ifnull(form_name,''),' ',item_name)) item_name, isdsb.stock_qty last_shift_stock, ifnull(r.received_qty,0) received_qty, isd.stock_qty current_stock,(isdsb.stock_qty+ifnull(r.received_qty,0)-isd.stock_qty) consumed_qty FROM tbl_items i left join medicine_form f on i.item_form_id=f.form_id left join item_stock_dispensary isd on i.item_id=isd.item_id left join item_stock_dispensary_shift_balance isdsb on i.item_id=isdsb.item_id left join
(SELECT item_id,rm.ohc_location_id, sum(received_qty) received_qty,received_date from received_issue_items ri, received_master rm where rm.received_id=ri.received_id and rm.received_date = '$run_date' and rm.ohc_location_id='".$_SESSION['current_ohcttype']."' group by item_id, rm.ohc_location_id,received_date ) r on isd.item_id=r.item_id WHERE isdsb.ohc_location_id='".$_SESSION['current_ohcttype']."' and isd.ohc_location_id = '".$_SESSION['current_ohcttype']."' and isdsb.record_date ='$run_date'and shift_id=$shift";
$result_balance = mysqli_query($conn,$sql_balance);
$row_balance = mysqli_fetch_array($result_balance);
error_log("eeeeeeeeeeeee".$sql_balance);
error_log("Balance".$row_balance['stock_qty']);
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<body>
<?php include_once ('pdf_ohc_header.php');?>
<table border="1" cellspacing="0" width="100%">
<tr>
<th width="5%">Sr.No.</th>
<th width="25%">Item Name</th>
<th width="20%">Shift Start Balance</th>
<th width="20%">Current Balance</th>
<th width="20%">Stock Consumed</th>
</tr>
<?php $count = 0;
while ($row_balance=@mysqli_fetch_array($result_balance)) {
$count++;
$unit_name = getItemUnitName($row_balance['item_id']); ?>
<tr>
<td><?php echo $count?></td>
<td><?php echo $row_balance['item_name']?></td>
<td align="right"><?php echo $row_balance['last_shift_stock']?> <?php echo $unit_name?></td>
<td align="right"><?php echo $row_balance['current_stock']?> <?php echo $unit_name?></td>
<td align="right"><?php echo $row_balance['consumed_qty']?> <?php echo $unit_name?></td>
</tr>
<?php }?>
</table>
</body>
<?php
include('pdf_footer.php')?>