0 and item_batch_no!='' "; error_log("query for available medicine : ".$query); if (!$result = @mysqli_query($conn,$query)) { die(mysqli_error($conn)); } $data = array(); if(mysqli_num_rows($result) > 0) { $qty=0; while ($row = @mysqli_fetch_assoc($result)) { $item_batch=$_POST["batch"]; $item_id = $row['item_id']; $sql_treatment_qty = "select * from treatment where appointment_id='" . $appointment_id . "' and is_display!='N' and item_id='" . $item_id . "' and item_batch_no='".$item_batch."' "; error_log("qyery ".$sql_treatment_qty); $res_treatment_qty = mysqli_query($conn, $sql_treatment_qty); $row_treatment_qty = mysqli_fetch_assoc($res_treatment_qty); $data["pre_issued_qty"] = $row_treatment_qty['issued_qty']; $data["unit_id"]=$row["unit_id"]; $data["item_id"]=$row["item_id"]; if($row['expiry_date']!="0000-00-00" && $row['expiry_date']!="" && $row['expiry_date']!=null){ $date= date('Y-m-d', strtotime($row['expiry_date'])) ; $date_today= date("Y-m-d"); // error_log($date_today." pp ".$date); if($date>=$date_today){ $qty+=$row["stock_qty"]; } }else{ $qty+=$row["stock_qty"]; } } $data["stock_qty"]=$qty; } else { $data['status'] = 200; $data['message'] = "Data not found!"; } error_log(print_r($data,true)); echo json_encode($data); ?>