Daily Shift Wise Medicine Log Report
For Date:

= time('$shift_start_time') and time(date_of_issue) <= ('$shift_end_time') and ohc_location_id = '" . $ohc . "'"; error_log("sql_diect_issue_query: " . $sql_diect_issue_query); $result_sql_diect_issue_query = mysqli_query($GLOBALS['conn'],$sql_diect_issue_query); while ($row_result_sql_diect_issue_query = mysqli_fetch_array($result_sql_diect_issue_query)) { $consume_detail .= 'DIRECT ISSUE ' . ':' . $row_result_sql_diect_issue_query['direct_issue'] . ' : '; $issued_qty_total += $row_result_sql_diect_issue_query['direct_issue']; } error_log("issued_qty_total:::" . $issued_qty_total); $sql_opd_consumables = "SELECT ifnull(c.issued_qty,0) as consumable_issue,e.ticket_no FROM opd_consumables c LEFT JOIN employee_appointment e ON c.consume_id = e.appointment_id where medicine = '$item_id' and date(e.appointment_date) = '" . $date . "' and time(e.appointment_date)>= time('$shift_start_time') and time(e.appointment_date) <= time('$shift_end_time') and ohc_type_id = '" . $ohc . "'"; error_log("sql_opd_consumables: " . $sql_opd_consumables); $result_sql_opd_consumables = mysqli_query($GLOBALS['conn'],$sql_opd_consumables); while ($row_result_sql_opd_consumables = mysqli_fetch_array($result_sql_opd_consumables)) { $consume_detail .= 'ID-' . $row_result_sql_opd_consumables['ticket_no'] . ':' . $row_result_sql_opd_consumables['consumable_issue'] . ' : '; $issued_qty_total += $row_result_sql_opd_consumables['consumable_issue']; } error_log("issued_qty_total_2:::" . $issued_qty_total); $sql_consume = "select a.appointment_id, (ifnull(a.issued_qty,0)+ifnull(c.issued_qty,0)) as total_issued,b.ticket_no from treatment a left join employee_appointment b on a.appointment_id = b.appointment_id left join detention_intake c on b.appointment_id = c.det_id where item_id = '$item_id' and date(b.appointment_date) = '" . $date . "' and time(b.appointment_date)>= time('$shift_start_time') and time(b.appointment_date) <= time('$shift_end_time') and b.ohc_type_id = '" . $ohc . "'"; error_log("cccccccons" . $sql_consume); $result_consume = mysqli_query($GLOBALS['conn'],$sql_consume); while ($row_consume = mysqli_fetch_array($result_consume)) { $consume_detail .= 'ID-' . $row_consume['ticket_no'] . ':' . $row_consume['total_issued'] . ' : '; $issued_qty_total += $row_consume['total_issued']; error_log("detaiilllllllllll" . $row_consume['total_issued']); } error_log("issued_qty_total_3:::" . $issued_qty_total); if ($a == 1) { return $consume_detail; } else { return $issued_qty_total; } } function freshReceivedItemBalance($item_id, $date, $ohc, $shift_start_time, $shift_end_time) { $received_qty_total = 0; $sql_fresh_received = "select ris.received_qty from received_issue_items ris left join received_master rm on ris.received_id = rm.received_id where ris.item_id='" . $item_id . "' and rm.received_date = '" . $date . "' and rm.ohc_location_id = '" . $ohc . "' and rm.last_modified>='$shift_start_time' and rm.last_modified<='$shift_end_time'"; $result_fresh = mysqli_query($GLOBALS['conn'],$sql_fresh_received); while ($row_fresh = mysqli_fetch_assoc($result_fresh)) { $received_qty_total += $row_fresh['received_qty']; } error_log("fresh:::" . $sql_fresh_received); return $received_qty_total; } function prevDispensaryItemBalance($item_id, $ohc, $shift, $prev_shift_id) { $sql_prev_balance = "select stock_qty from item_stock_dispensary_shift_balance a left join shift_status_details b on a.shift_id = b.shift_id where a.item_id = '$item_id' and a.ohc_location_id = '$ohc' and a.shift_id='" . $shift . "' and b.shift_details_id = '" . $prev_shift_id . "' and a.record_date = date(b.start_date_time) "; error_log("sql_prev_balance:::" . $sql_prev_balance); $result_sql_prev_balance = mysqli_query($GLOBALS['conn'],$sql_prev_balance); $row_prev_balance = mysqli_fetch_array($result_sql_prev_balance); if ($row_prev_balance == 0) { return 0; } else { return $row_prev_balance['stock_qty']; } } function total_qty($fresh, $prev) { $total = $fresh + $prev; return $total; } function balance($total_balance, $total_consumed) { error_log("balancesjfbbf :::" . $total_balance . " - " . $total_consumed); $b = $total_balance - $total_consumed; return $b; } while ($row_m = mysqli_fetch_array($result)) { array_push($med_cat, $row_m['cat_id']); } foreach ($med_cat as $i => $value) { $newCat = true; $query = "select item_id, item_name from tbl_items where cat='$value' and status = '1' group by item_id"; error_log("###########QQQQQQQQ" . $query); $result = mysqli_query($conn,$query); $total = mysqli_num_rows($result); if ($total != 0) { ?>
Sr Items Fresh Previous Total Consumption Details Total Consumed Balance