2024-10-16 19:18:52 +05:30
< ? php
error_reporting ( E_ERROR | E_PARSE );
include ( 'includes/config/config.php' );
include ( 'includes/functions.php' );
// it will be ambulance stock for now we can extend this feature to handle multiple ohcs like ambulance
$ohc_id = getFieldFromTable ( 'ohc_type_id' , 'ohc_type' , 'ohc_category' , 'AMB' );
$data = array ();
$selected_batch = " " ;
if ( ! empty ( $_POST [ 'batch' ])) {
$selected_batch = " and item_batch_no!=' " . $_POST [ 'batch' ] . " ' " ;
$sql_stock_item_selected = " select * from item_stock_miscellaneous where item_id=' " . $_POST [ 'item_id' ] . " ' and item_batch_no=' " . $_POST [ 'batch' ] . " ' and issue_to_ohc_id=' " . $ohc_id . " ' order by expiry_date " ;
error_log ( 'treatent_batch ' . $sql_stock_item_selected );
if ( ! $result_stock_item_selected = @ mysqli_query ( $conn , $sql_stock_item_selected )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $result_stock_item_selected ) > 0 ) {
while ( $row_stock_item_selected = mysqli_fetch_assoc ( $result_stock_item_selected )) {
//extract($row);
array_push ( $data , $row_stock_item_selected );
}
}
}
$sql_stock_item = " select * from item_stock_miscellaneous where item_id=' " . $_POST [ 'item_id' ] . " ' and item_batch_no!='' and stock_qty>0 and issue_to_ohc_id=' " . $ohc_id . " ' $selected_batch order by expiry_date " ;
error_log ( 'treatent_batch' . $sql_stock_item );
if ( ! $result_stock_item = @ mysqli_query ( $conn , $sql_stock_item )) {
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
if ( mysqli_num_rows ( $result_stock_item ) > 0 ) {
while ( $row_stock_item = mysqli_fetch_assoc ( $result_stock_item )) {
//extract($row);
if ( $row_stock_item [ 'expiry_date' ] != " 0000-00-00 " && $row_stock_item [ 'expiry_date' ] != " " && $row_stock_item [ 'expiry_date' ] != null ) {
$date = date ( 'Y-m-d' , strtotime ( $row_stock_item [ 'expiry_date' ]));
$date_today = date ( " Y-m-d " );
if ( $date >= $date_today ) {
array_push ( $data , $row_stock_item );
}
} else {
array_push ( $data , $row_stock_item );
}
}
}
echo json_encode ( $data );