140 lines
4.9 KiB
PHP
140 lines
4.9 KiB
PHP
<?php
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
function getConfigKey_table($config)
|
|
{
|
|
$val = getTableFieldValue('config', 'value', 'key_name', '"' . $config . '"');
|
|
return $val;
|
|
}
|
|
?>
|
|
<script src="assets/js/jquery-2.1.4.min.js"></script>
|
|
|
|
|
|
<script>
|
|
function formatDate(input) {
|
|
// alert(input);
|
|
var datePart = input.match(/\d+/g),
|
|
year = datePart[0],
|
|
month = datePart[1],
|
|
day = datePart[2];
|
|
return day + '/' + month + '/' + year;
|
|
}
|
|
|
|
function send_template_on_center() {
|
|
var subject = 'Regular Medicine Reminder.';
|
|
var name = 'OHC';
|
|
var message = "<p>Dear " + name + " ,</p><p>Regular medicines for this month have not been collected Kindly get your medicines at the earliest. </p><p>Team OHC</p>";
|
|
var ref_type = 'cronic medication reminder';
|
|
var email_list_to = '';
|
|
var email_list_cc = '<?= getConfigKey_table('cronic_reminder_cc') ?>';
|
|
|
|
send_email(ref_type, '', email_list_to, email_list_cc, subject,
|
|
message);
|
|
|
|
|
|
}
|
|
|
|
|
|
function open_mail(mail, name, ohc, appointmentId, app_date) {
|
|
app_date = formatDate(app_date);
|
|
var subject = 'Regular Medicine Reminder.';
|
|
var message = "<p>Dear " + name + " ,</p><p>Regular medicines for this month have not been collected Kindly get your medicines at the earliest. </p><p>Team OHC</p>";
|
|
var ref_type = 'cronic medication reminder';
|
|
var email_list_to = mail;
|
|
// var email_list_cc='<?= getConfigKey_table('cronic_reminder_cc') ?>';
|
|
var email_list_cc = '';
|
|
send_email(ref_type, appointmentId, email_list_to, email_list_cc, subject,
|
|
message);
|
|
|
|
|
|
}
|
|
|
|
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) {
|
|
return;
|
|
|
|
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error in sending mail');
|
|
return;
|
|
}
|
|
});
|
|
$('.close').click();
|
|
}
|
|
</script>
|
|
<?php
|
|
begin();
|
|
echo "<script type='text/javascript'>send_template_on_center()</script>";
|
|
$chronic_filter = '';
|
|
$config_chronic = getConfigKey_table('selected_cronic_for_reminder');
|
|
if ($config_chronic != '' && $config_chronic != null) {
|
|
$chronic_filter = " and diseases not in (" . $config_chronic . ") ";
|
|
}
|
|
$query = "SELECT distinct(emp_id) FROM `prescription_master` where `medicine_name` is not null and `medicine_name`!='' " . $chronic_filter;
|
|
|
|
|
|
error_log("sql " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
rollback();
|
|
die(mysqli_error($conn));
|
|
}
|
|
$data = array();
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$app_q = " select date(appointment_date) + INTERVAL chronic_day DAY AS DATE,date(appointment_date) as app_date,appointment_id,ohc_type_id,emp_id from employee_appointment where appointment_id=(select max(appointment_id) from employee_appointment where emp_id='" . $row['emp_id'] . "' and chronic_day!=0 ) ";
|
|
|
|
if (!$result_app_q = @mysqli_query($conn, $app_q)) {
|
|
rollback();
|
|
die(mysqli_error($conn));
|
|
}
|
|
if (mysqli_num_rows($result_app_q) > 0) {
|
|
while ($row_app_q = mysqli_fetch_assoc($result_app_q)) {
|
|
|
|
$emp_mail = getTableFieldValue('patient_master', 'offiial_email_id', 'id', $row_app_q['emp_id']);
|
|
|
|
|
|
$emp_name = getTableFieldValue('patient_master', 'patient_name', 'id', $row_app_q['emp_id']);
|
|
|
|
$ohc = getTableFieldValue('ohc_type', 'ohc_type_name', 'ohc_type_id', $row_app_q['ohc_type_id']);
|
|
|
|
$cronic_date = $row_app_q['DATE'];
|
|
|
|
if ($cronic_date < date("Y-m-d")) {
|
|
|
|
echo "<script type='text/javascript'>open_mail('" . $emp_mail . "','" . $emp_name . "','" . $ohc . "','" . $row_app_q['appointment_id'] . "','" . date($row_app_q['app_date']) . "')</script>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$data['status'] = "succes";
|
|
$data['message'] = "Assign menu done!";
|
|
} else {
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
|
|
commit();
|
|
if ($data['status'] == 'succes') {
|
|
echo "<h3>Remider Sent Succesfully</h3><br><button type='button' class='btn btn-info btn-sm save_button' onclick='window.location=`chronic_illness.php`;'><i class='ace-icon fa fa-floppy-o bigger-110'></i>Back </button>";
|
|
} else {
|
|
echo json_encode($data);
|
|
}
|
|
|
|
|
|
?>
|