91 lines
2.7 KiB
PHP
91 lines
2.7 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include("includes/functions.php");
|
|
include("log_entry.php");
|
|
|
|
$request_type=$_REQUEST['request_type'];
|
|
|
|
switch($request_type)
|
|
{
|
|
|
|
case 'check_if_uniquefield_exists':
|
|
$tableName=$_REQUEST['tableName'];
|
|
$uniqueColumnNm=$_REQUEST['uniqueColumnNm'];
|
|
$uniqueColumnVal=$_REQUEST['uniqueColumnVal'];
|
|
|
|
$query = "select * from ".$tableName." where upper(".$uniqueColumnNm.") = upper('".$uniqueColumnVal."') ";
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
error_log("error in query checking unique value:".mysqli_errno($conn)." Query:".$query);
|
|
exit(mysqli_error($conn));
|
|
}else{
|
|
if(mysqli_num_rows($result) > 0) {
|
|
echo "true";
|
|
}else{
|
|
echo "false";
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case 'selectAllTableElementsByIdJSON':
|
|
$tableName=$_REQUEST['tableName'];
|
|
$idColumn=$_REQUEST['idCol'];
|
|
$idColumnVal=$_REQUEST['idColVal'];
|
|
$query = "select * from ".$tableName." where $idColumn ='".$idColumnVal."' ";
|
|
error_log("Query:".$query);
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
error_log("error in query reading table values:".mysqli_error($conn)." Query:".$query);
|
|
exit(mysqli_error($conn));
|
|
}else{
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data[] = $row;
|
|
}
|
|
}else{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
echo json_encode($data);
|
|
}
|
|
break;
|
|
|
|
case 'selectedTableElementsByIdJSON':
|
|
$tableName=$_REQUEST['tableName'];
|
|
$idColumn=$_REQUEST['idCol'];
|
|
$idColumnVal=$_REQUEST['idColVal'];
|
|
$resultColumnVal=$_REQUEST['resultColumnVal'];
|
|
$query = "select $resultColumnVal from ".$tableName." where $idColumn ='".$idColumnVal."' ";
|
|
error_log("Query selectedTableElementsByIdJSON:".$query);
|
|
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
error_log("error in query reading table values:".mysqli_error($conn)." Query:".$query);
|
|
exit(mysqli_error($conn));
|
|
}else{
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data[] = $row[$resultColumnVal];
|
|
}
|
|
}else{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
echo json_encode($data);
|
|
}
|
|
break;
|
|
case 'getDispensaryItemAvailableQty':
|
|
$ohcTypeId=$_REQUEST['ohc_type_id'];
|
|
$itemId=$_REQUEST['item_id'];
|
|
$item_stock=getStockQtyAtDispensaryLevel($itemId, $ohcTypeId);
|
|
if ($item_stock==null) {
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
error_log("error in query item stock for dispensary. Please check if the input params are right.:ohc_type_id:".$ohcTypeId." item_id:".$itemId);
|
|
}else{
|
|
$data['item_available_qty'] = $item_stock;
|
|
}
|
|
echo json_encode($data);
|
|
|
|
break;
|
|
}//end of switch
|
|
?>
|