ESH/followup_reminder_batch.php

162 lines
6.8 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/auth/auth.php');
include('includes/functions.php');
include 'log_entry.php';
include('access.php');
error_reporting(E_ERROR | E_PARSE);
?>
<script src="assets/js/jquery-2.1.4.min.js"></script>
<script>
function open_item(appointmentId, appointment_type, dept_id, rowElement, emp_mail) {
$.ajax({
url: 'get_emp_app_details.php',
type: "POST",
data: {
'value': appointmentId,
'action': 'e'
},
dataType: 'json',
success: function(data) {
var app_id = data.id;
// alert(app_id);
$("#appointmentId").val("");
$("#appointment_type").val("");
var to = emp_mail;
var to_dept = dept_id;
var emailContent = "";
if (appointment_type == "O") {
var app_root = '<?php echo getConfigKey('APP_ROOT') ?>';
var to_list = "" + to + "," + to_dept +
",<?php echo getConfigKey('GENERAL_EMAIL_LIST_TO_OPD') ?>";
// alert(to_list);
var link = "" + app_root + "/opd_form_pdf.php?appointment_id_pdf=" + app_id;
ref_type = "OPD";
var email_list_to = to_list;
var email_list_cc = '<?php echo getConfigKey('GENERAL_EMAIL_LIST_CC_OPD') ?>';
$("#email_form").find("#subject").val(
'<?php echo getConfigKey('GENERAL_EMAIL_SUBJECT_OPD') ?>');
$("#email_form").find("#email_content").text(
"<div style=`text-transform: none; !important`><?php echo getConfigKey('GENERAL_EMAIL_TEXT_OPD') ?></div>"
);
emailContent +=
"<table class=`table-bordered` width=`100%`><thead><tr><th>Date</th><th>Patient Name</th><th>Emp Code</th><th>Complaints</th><th>Findings</th></tr><thead><tbody>";
emailContent += "<tr><td>" + data['appointment_date'] + "</td><td>" + data['patient_name'] +
"</td><td>" +
data['emp_code'] +
"</td><td>" + data['complaints'] +
"</td><td>" + data['examination_remarks'] + "</td></tr>";
emailContent +=
"</tbody></table>";
emailContent += "<br><a href=`" + link +
"`> Details</a> ";
message = emailContent;
} else if (appointment_type == "I") {
var app_root = '<?php echo getConfigKey('APP_ROOT') ?>';
var to_list = "" + to + "," + to_dept +
",<?php echo getConfigKey('GENERAL_EMAIL_LIST_TO_INJURY') ?>";
// alert(to_list)
var link = "" + app_root + "/form24_incident_report.php?appointment_id_pdf=" + app_id;
//var link=""+app_root+"/injury_form_pdf.php?appointment_id_pdf="+appointmentId;
var ref_type = "INJURY";
var email_list_to = to_list;
var email_list_cc = '<?php echo getConfigKey('GENERAL_EMAIL_LIST_CC_INJURY') ?>';
$("#email_form").find("#subject").val(
'<?php echo getConfigKey('GENERAL_EMAIL_SUBJECT_INJURY') ?>');
emailContent +=
"<div style=`text-transform: none; !important`><?php echo getConfigKey('GENERAL_EMAIL_TEXT_INJURY') ?></div>";
emailContent +=
"<table class=`table-bordered` width=`100%`><thead><tr><th>Date</th><th>Patient Name</th><th>Emp Code</th><th>Complaints</th><th>Findings</th></tr><thead><tbody>";
emailContent += "<tr><td>" + data['appointment_date'] + "</td><td>" + data['patient_name'] +
"</td><td>" +
data['emp_code'] +
"</td><td>" + data['complaints'] +
"</td><td>" + data['examination_remarks'] + "</td></tr>";
emailContent +=
"</tbody></table>";
emailContent += "<br><a href=`" + link +
"`> Details</a> ";
message = emailContent;
}
// window.alert("{appointmentId}");
var id = appointmentId;
message = emailContent;
// resizeChosen();
// jQuery(window).on('resize', resizeChosen);
send_email(ref_type, appointmentId, email_list_to, email_list_cc, 'Appointment Details',
message);
},
error: function(data) {
console.log('Error In Pulling Id');
return id;
}
});
}
function send_email(ref_type, ref_identifier, email_list_to, email_list_cc, subject, message) {
$.ajax({
url: 'send_email.php',
type: 'POST',
data: {
ref_type: ref_type,
ref_identifier: ref_identifier,
email_list_to: email_list_to,
email_list_cc: email_list_cc,
subject: subject,
message: message,
},
success: function(data) {
console.log('Mail send Successfully');
location.href =
"<?php echo getTableFieldValue('role_master','role_home_page','role_id',$_SESSION['RoleId']) ?>"
return;
},
error: function(data) {
console.log('Error in sending mail');
return;
}
});
$('.close').click();
}
</script>
<?php
$folowups = "select * ,date(appointment_date) as appointment_date from employee_appointment where date(followup) between Now() and date(Now() + interval 7 day) ";
error_log("$folowups");
if(!$result_today_bal= mysqli_query ($GLOBALS['conn'],$folowups)){
error_log("sql_existing_today_balance:".$folowups);
}
while ($row_bal = @mysqli_fetch_array ( $result_today_bal )) {
$is_followup_done=0;
$folowups_details = "select count(*) as count from followup_details where appointment_id='".$row_bal['appointment_id']."' and date(appointment_date) between STR_TO_DATE('" . $row_bal['appointment_date'] . "', '%Y-%m-%d') and STR_TO_DATE('" . $row_bal['followup'] . "', '%Y-%m-%d')";
$result_folowups_details= mysqli_query ($GLOBALS['conn'],$folowups_details);
$row_followup_done=@mysqli_fetch_array ( $result_folowups_details );
$is_followup_done=$row_followup_done['count'];
error_log($is_followup_done);
$dept_id=getTableFieldValue('patient_master','dept_id','id',$row_bal['emp_id']);
$dept_email = getTableFieldValue('department', 'dept_email', 'dept_id',$dept_id );
$emp_mail = getTableFieldValue('patient_master','offiial_email_id','id',$row_bal['emp_id']);
if($is_followup_done!=0){
echo "<script type='text/javascript'>open_item(".$row_bal['appointment_id'].",'".$row_bal['appointment_type']."','".$dept_email."','','".$emp_mail."')</script>";
}
}
?>