100 lines
4.9 KiB
PHP
100 lines
4.9 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/functions.php');
|
||
|
include('log_entry.php');
|
||
|
$noOfRows = $_POST['count_items'];
|
||
|
// error_log();
|
||
|
error_log("rows: ========---------- " . $noOfRows);
|
||
|
$screening_date = $_REQUEST['date'];
|
||
|
error_log("date " . $screening_date);
|
||
|
$patient_id = $_REQUEST['patient_id'];
|
||
|
$canteen_location = $_REQUEST['canteen_location'];
|
||
|
error_log("canteen_location" . $canteen_location);
|
||
|
$remarks = $_REQUEST['remarks'];
|
||
|
error_log("remarks ".$remarks);
|
||
|
$observation = $_REQUEST['observation'];
|
||
|
$daily_caterer = $_REQUEST['daily_caterer'];
|
||
|
$daily_catering = $_REQUEST['daily_catering'];
|
||
|
$khs_no = $_REQUEST['khs_no'];
|
||
|
$approval_status = "approval";
|
||
|
$status = "DRP";
|
||
|
error_log("khs_no ". $khs_no);
|
||
|
$response_id = $_REQUEST['response_id'];
|
||
|
error_log("response_id "." ". $response_id);
|
||
|
$previous_survellance = $_REQUEST['previous_survellance'];
|
||
|
$open_total = $_REQUEST['open_total'];
|
||
|
$manpower=$_REQUEST['manpower'];
|
||
|
error_log("open_total" . $open_total);
|
||
|
$consern = $_REQUEST['consern'];
|
||
|
$capa = $_REQUEST['capa'];
|
||
|
$communication_notes = $_REQUEST['communication_notes'];
|
||
|
$responsibility = $_REQUEST['responsibility'];
|
||
|
$completion = $_REQUEST['completion'];
|
||
|
$supervisor=$_REQUEST['supervisor'];
|
||
|
|
||
|
|
||
|
begin();
|
||
|
|
||
|
|
||
|
// echo $response_id;
|
||
|
// exit;
|
||
|
|
||
|
$roleCode = $_SESSION['RoleCode'];
|
||
|
error_log("role Code ". $_SESSION['RoleCode']);
|
||
|
if (!empty($response_id)) {
|
||
|
if ($_SESSION['RoleCode'] == 'DOC') {
|
||
|
$main_query = "update questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),canteen_location='" . $canteen_location ."' ,remarks='" . $remarks ."',supervisor='".$supervisor. "',manpower='".$manpower."',f_status='".$status."',approval_status='".$approval_status."',approval_user='". $_SESSION['logged_user_empid'] ."',capa='". $capa . "',communication_notes='". $communication_notes . "',responsibility='". $responsibility ."',completion='".$completion."',previous_survellance= '" . $previous_survellance . "', open_total= '".$open_total. "',observation='" . $observation . "',daily_caterer='" . $daily_caterer . "',daily_catering='" . $daily_catering ."',medical_attend='" . $_SESSION['user_id'] . "',modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $response_id . "' ";
|
||
|
} else {
|
||
|
$main_query = "update questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),canteen_location='" . $canteen_location ."' ,remarks='" . $remarks . "',manpower='".$manpower."',f_status='".$status."',supervisor='".$supervisor."',approval_status='".'pending'."',previous_survellance= '" . $previous_survellance . "', open_total= '".$open_total. "',observation='" . $observation . "',daily_caterer='" . $daily_caterer . "',daily_catering='" . $daily_catering . "',medical_attend='" . $_SESSION['user_id'] . "',modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $response_id . "' ";
|
||
|
}
|
||
|
}
|
||
|
error_log("main query" . $main_query);
|
||
|
if (!$result = mysqli_query($conn, $main_query)) {
|
||
|
error_log("error in main " . mysqli_error($conn));
|
||
|
rollback();
|
||
|
} else {
|
||
|
|
||
|
if(empty($response_id)){
|
||
|
$r_id = mysqli_insert_id($conn);
|
||
|
}else{
|
||
|
$r_id = $response_id;
|
||
|
}
|
||
|
|
||
|
for ($i = 0; $i < $noOfRows; $i++) {
|
||
|
|
||
|
|
||
|
$get_query = "select count(*) as total,a.response_id from questionaire_master_response a left join questionaire_master_response_details b on a.response_id = b.response_id where b.question_id='" . ${"question_id$i"} . "' and a.medical_examination_no='" . $khs_no . "' and a.response_id='" . $response_id . "'";
|
||
|
error_log("query decides the update and delete " . $get_query);
|
||
|
$result1 = mysqli_query($conn, $get_query);
|
||
|
$row1 = mysqli_fetch_assoc($result1);
|
||
|
$count1 = $row1['total'];
|
||
|
if ($count1 != 0) {
|
||
|
error_log('update query');
|
||
|
$query1 = "update questionaire_master_response_details set question_remarks='" . ${"remarks$i"} . "',question_answer='" . ${"question_ans$i"} . "', modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $r_id . "' and question_id='" . ${"question_id$i"} . "' ";
|
||
|
} else {
|
||
|
$query1 = "insert into questionaire_master_response_details set question_id='" . ${"question_id$i"} . "',question_remarks='" . ${"remarks$i"} . "',question_answer='" . ${"question_ans$i"} . "',response_id='" . $r_id . "'";
|
||
|
}
|
||
|
error_log("khs details insert query------------------------- " . $query1);
|
||
|
if (!$result = @mysqli_query($conn, $query1)) {
|
||
|
error_log("khs details insert query error " . mysqli_error($conn));
|
||
|
rollback();
|
||
|
}
|
||
|
if (mysqli_num_rows($result) > 0) {
|
||
|
while ($row = @mysqli_fetch_assoc($result)) {
|
||
|
$data = $row;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
error_log("Data khs" . $data);
|
||
|
|
||
|
if ($data == null) {
|
||
|
$data['status'] = 200;
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
|
||
|
commit();
|
||
|
echo json_encode($data);
|
||
|
|
||
|
?>
|