66 lines
3.0 KiB
PHP
66 lines
3.0 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/functions.php');
|
||
|
include('log_entry.php');
|
||
|
|
||
|
error_log('$SELECT REQ'.print_r($_REQUEST,true));
|
||
|
|
||
|
|
||
|
if (isset($_POST['staff_id'])) {
|
||
|
|
||
|
error_log("got_id :" .$_POST['staff_id']);
|
||
|
$query = "select a.* from tbl_users a where staff_id =" . $_POST['staff_id'] . "";
|
||
|
// $query="SELECT a.user_name,a.status, a.email, a.user_id,a.user_password, a.role_id, b.role_name, a.patient_id,c.client_name, e.patient_name, a.remarks,a.ohc_type FROM tbl_users a left join role_master b on a.role_id=b.role_id left join patient_master e on a.patient_id=e.id left join client_master c on e.client_id = c.client_id where a.user_id = '".$userId."' ";
|
||
|
error_log("SELECT Staff:" . $query);
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
$data = array();
|
||
|
if (mysqli_num_rows($result) > 0) {
|
||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||
|
$data = $row;
|
||
|
}
|
||
|
} else {
|
||
|
$data['status'] = '200';
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
error_log("SELECT staff" . print_r($data, true));
|
||
|
echo json_encode($data);
|
||
|
}
|
||
|
else if(isset($_POST['userId'])) {
|
||
|
$userId = $_REQUEST['userId'];
|
||
|
error_log("got_id :" . $userId);
|
||
|
$query = "select a.*,c.client_name from tbl_users a left join client_master c on c.id where user_id =" . $userId . " ";
|
||
|
// $query="SELECT a.user_name,a.status, a.email, a.user_id,a.user_password, a.role_id, b.role_name, a.patient_id,c.client_name, e.patient_name, a.remarks,a.ohc_type FROM tbl_users a left join role_master b on a.role_id=b.role_id left join patient_master e on a.patient_id=e.id left join client_master c on e.client_id = c.client_id where a.user_id = '".$userId."' ";
|
||
|
error_log("SELECT :" . $query);
|
||
|
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
$data = array();
|
||
|
if (mysqli_num_rows($result) > 0) {
|
||
|
while ($row = mysqli_fetch_assoc($result)) {
|
||
|
|
||
|
if ($row['patient_id'] != 0 && $row['patient_id'] != null) {
|
||
|
$data = $row['id'] = $row['patient_id'];
|
||
|
$data = $row['status'] = $row['status'];
|
||
|
$data = $row['name'] = getFieldFromTable('patient_name', 'patient_master', 'id', $row['patient_id']);
|
||
|
} else if ($row['staff_id'] != 0 && $row['staff_id'] != null) {
|
||
|
$data = $row['id'] = $row['staff_id'];
|
||
|
$data = $row['name'] = getFieldFromTable('staff_name', 'staff_master', 'staff_id', $row['staff_id']);
|
||
|
} else {
|
||
|
$data = $row['id'] = $row['staff_id'];
|
||
|
// $data=$row['patient_name']=getFieldFromTable('patient_name','patient_master','id',$row['patient_id']);
|
||
|
$data = $row['name'] = getFieldFromTable('staff_name', 'staff_master', 'staff_id', $row['staff_id']);
|
||
|
}
|
||
|
$data = $row;
|
||
|
}
|
||
|
} else {
|
||
|
$data['status'] = '200';
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
error_log("SELECT USERs" . print_r($data, true));
|
||
|
echo json_encode($data);
|
||
|
}
|
||
|
?>
|