178 lines
7.9 KiB
PHP
178 lines
7.9 KiB
PHP
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
include ('log_entry.php');
|
|
error_log("Start Printing Request Attributes");
|
|
$requestStr = "";
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
error_log("End Printing Request Attributes");
|
|
save_log($requestStr, 'Sickness', 'SAVE', 'save_sickness_form.php');
|
|
error_reporting(0);
|
|
// error_log("Request sickness_id id :".$_REQUEST['id']);
|
|
// error_log("Request sickness_id sickness_id p:".$_POST['sickness_id']);
|
|
// $id = ($_REQUEST['id']!=''?$_REQUEST['id']:$_REQUEST['sickness_id']);
|
|
|
|
if (isset($_REQUEST['sickness_id'])) {
|
|
$id = $_REQUEST['sickness_id'];
|
|
} else {
|
|
$id = $_REQUEST['flex_sickness_id'];
|
|
}
|
|
error_log("Request sickness_id:" . $id);
|
|
|
|
|
|
if (isset($_REQUEST['sickness_id'])) {
|
|
$emp_id = $_REQUEST['emp_id'];
|
|
} else {
|
|
$emp_id = $_REQUEST['flex_opd_id'];
|
|
}
|
|
|
|
if (!isset($id)) {
|
|
$query = "SELECT sickness_id FROM sickness where emp_id='" . addslashes($_REQUEST['emp_id']) . "' and DATE(NOW()) = DATE(sickness_date) ";
|
|
error_log($query);
|
|
$result = @mysqli_query($conn, $query);
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$id = $row['sickness_id'];
|
|
}
|
|
}
|
|
error_log("sickness_id:" . $id);
|
|
//echo $emp_id;
|
|
|
|
$token_no = $_POST['token_no'];
|
|
|
|
$sickness_date = date('Y-m-d H:i:s', strtotime($_POST['sickness_date']));
|
|
$from_date = date('Y-m-d', strtotime($_POST['from_date']));
|
|
$to_date = date('Y-m-d', strtotime($_POST['to_date']));
|
|
$date_absent = date('Y-m-d', strtotime($_POST['date_absent']));
|
|
$date_absent_to = date('Y-m-d', strtotime($_POST['date_absent_to']));
|
|
$approval_date = $_POST['approval_date'];
|
|
$attended_status = $_POST['attendedStatus'];
|
|
|
|
$isfitness = false;
|
|
if (!empty($approval_date) && strtotime($approval_date) !== false) {
|
|
$approval_date = date('Y-m-d', strtotime($_POST['approval_date']));
|
|
$isfitness = true;
|
|
error_log("is fitness " . $isfitness. " approval date ". $approval_date);
|
|
} else {
|
|
$isfitness = false;
|
|
}
|
|
|
|
if (!empty($date_return) && strtotime($date_return) !== false) {
|
|
$date_return = date('Y-m-d', strtotime($_POST['date_return']));
|
|
}
|
|
|
|
if (!$isfitness) {
|
|
$attended_status = 'DRP';
|
|
}
|
|
|
|
$agency = $_POST['agency'];
|
|
$ailment = $_POST['ailment'];
|
|
$des = $_POST['des'];
|
|
|
|
$fitness_status = $_POST['approval_status'];
|
|
$ticket_no = $_POST['ticket_no'];
|
|
$comments = $_POST['remarks'];
|
|
$ref_no = $_POST['doc_ref_no'];
|
|
$des_dis = $_POST['des_dis'];
|
|
$des_sick = $_POST['des_sick'];
|
|
$des_future = $_POST['des_future'];
|
|
|
|
$followup_to_opd = $_POST['followup_to_opd'];
|
|
$justifiable_from = $_POST['justifiable_from'];
|
|
$justifiable_to = $_POST['justifiable_to'];
|
|
$date_just_from = $_POST['date_absents'];
|
|
$date_justifiable_to = $_POST['date_returns'];
|
|
$date_not_just = $_POST['date_not_just'];
|
|
$date_not_just_to = $_POST['date_not_just_to'];
|
|
$approval_date = $_POST['approval_date'];
|
|
// error_reporting(E_ERROR | E_PARSE);
|
|
$height = $_POST['height'];
|
|
$weight = $_POST['weight'];
|
|
$pulse = $_POST['pulse'];
|
|
$blood_group = $_POST['blood_group'];
|
|
$nose = $_POST['nose'];
|
|
$throat = $_POST['throat'];
|
|
$rs = $_POST['rs'];
|
|
$cvs = $_POST['cvs'];
|
|
$ch_uex = $_POST['ch_uex'];
|
|
$ch_ex = $_POST['ch_ex'];
|
|
$bp = $_POST['bp'];
|
|
$cns = $_POST['cns'];
|
|
$purpose = $_POST['purpose'];
|
|
$certificate_type = $_POST['certificate_type'];
|
|
error_log($nose . " NOSE ");
|
|
$ailment_ids_new = strtoupper($_POST['ailment_new']);
|
|
|
|
$ailment_ids_new = handleDynamicMasterInsert("ailment", "ailment_name", "ailment_id", $ailment_ids_new, true);
|
|
$ailment_ids_new = getMultiValuedSelectData($ailment_ids_new);
|
|
|
|
$ailment_system = strtoupper($_POST['ailment_system_new']);
|
|
//$ailment_name = implode(',',$_POST['ailmentD']);
|
|
|
|
|
|
$attended_doctor = null;
|
|
if ($_SESSION['RoleCode'] == "DOC") {
|
|
$attended_doctor = $_SESSION['logged_user_empid'];
|
|
|
|
}
|
|
|
|
$query_initial = "";
|
|
$query_end = " ";
|
|
|
|
if (!$isfitness) {
|
|
$query = " set ailment_system='" . addslashes($ailment_system) . "',ailment_name='" . addslashes($ailment_ids_new) . "',sickness_date = '" . $sickness_date . "', from_date = '" . $from_date . "',to_date = '" . $to_date . "', date_absent = '" . $date_absent . "',date_absent_to = '" . $date_absent_to . "', justifiable_from = STR_TO_DATE('" . $justifiable_from . "', '%d/%m/%Y'),justifiable_to = STR_TO_DATE('" . $justifiable_to . "', '%d/%m/%Y'),not_justifiable_from = STR_TO_DATE('" . $date_not_just . "', '%d/%m/%Y'),not_justifiable_to = STR_TO_DATE('" . $date_not_just_to . "', '%d/%m/%Y'),agency = '$agency',sickness_name='$ailment_system',des='$des' , emp_id='" . $emp_id . "',doctor_reference_no = '$ref_no',des_dis='$des_dis',des_sick='$des_sick',des_future='$des_future',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',doctor_last_attended='$attended_doctor',attended_status='$attended_status',followup_to_opd='$followup_to_opd',fitness_status='$fitness_status',comments='" . addslashes($comments) . "',token_no='$token_no',ticket_no='$ticket_no', modified_by='" . $_SESSION['user_id'] . "' , height = '$height' , weight = '$weight' , pulse = '$pulse' , chest_ex = '$ch_ex',chest_uex='$ch_uex', rs = '$rs' , cvs = '$cvs', bp ='$bp' , throat = '$throat' , blood = '$blood_group' , nose = '$nose' , cns = '$cns' , purpose = '$purpose' , certificate_type='$certificate_type' ";
|
|
} else {
|
|
$query = " set ailment_system='" . addslashes($ailment_system) . "',ailment_name='" . addslashes($ailment_ids_new) . "',sickness_date = '" . $sickness_date . "', from_date = '" . $from_date . "',to_date = '" . $to_date . "', date_absent = '" . $date_absent . "',date_absent_to = '" . $date_absent_to . "',date_return = '" . $date_return . "', justifiable_from = STR_TO_DATE('" . $justifiable_from . "', '%d/%m/%Y'),justifiable_to = STR_TO_DATE('" . $justifiable_to . "', '%d/%m/%Y'),not_justifiable_from = STR_TO_DATE('" . $date_not_just . "', '%d/%m/%Y'),not_justifiable_to = STR_TO_DATE('" . $date_not_just_to . "', '%d/%m/%Y'),agency = '$agency',sickness_name='$ailment_system',des='$des' , emp_id='" . $emp_id . "',doctor_reference_no = '$ref_no',des_dis='$des_dis',des_sick='$des_sick',des_future='$des_future',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',doctor_last_attended='$attended_doctor',attended_status='$attended_status',approval_date= '" . $approval_date . "',followup_to_opd='$followup_to_opd',fitness_status='$fitness_status',comments='" . addslashes($comments) . "',token_no='$token_no',ticket_no='$ticket_no', modified_by='" . $_SESSION['user_id'] . "' , height = '$height' , weight = '$weight' , pulse = '$pulse' , chest_ex = '$ch_ex',chest_uex='$ch_uex', rs = '$rs' , cvs = '$cvs', bp ='$bp' , throat = '$throat' , blood = '$blood_group' , nose = '$nose' , cns = '$cns' , purpose = '$purpose' , certificate_type='$certificate_type' ";
|
|
}
|
|
|
|
error_log("dskgsnhg" . $query);
|
|
|
|
|
|
|
|
if (!empty($id)) {
|
|
$query_initial = " update sickness ";
|
|
$query_end = " where sickness_id =$id";
|
|
} else {
|
|
$query_initial = "insert into sickness ";
|
|
|
|
}
|
|
$query = $query_initial . " " . $query . " " . $query_end;
|
|
|
|
error_log("query: " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
die(error_log(mysqli_error($conn)));
|
|
}
|
|
|
|
$data = array();
|
|
if (isset($id)) {
|
|
$data = $id;
|
|
} else {
|
|
$result = @mysqli_query($conn, "select max(sickness_id) from sickness");
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data = $row['sickness_id'];
|
|
}
|
|
}
|
|
if (empty($id)) {
|
|
$query = "select max(sickness_id) sickness_id from sickness where emp_id = '" . addslashes($_REQUEST['emp_id']) . "' ";
|
|
// echo $query;
|
|
error_log("query: " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
die(error_log(mysqli_error($conn)));
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$data[0] = $row;
|
|
// $sickness_id = $row['sickness_id'];
|
|
}
|
|
}
|
|
} else {
|
|
|
|
$data['sickness_id'] = $_REQUEST['sickness_id'];
|
|
}
|
|
|
|
//echo $query;
|
|
// error_log("data: ".print_r($data, true));
|
|
echo json_encode($data);
|
|
?>
|