2024-10-16 19:18:52 +05:30
< ? 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 subjectValue = < ? = getConfigKey_table ( 'chronic_reminder_subject' ) ?> ;
var subject = ! subjectValue || subjectValue . trim () === '' ? 'Regular Medicine Reminder' : subjectValue ;
// console.log('subject', subject);
var name = 'OHC' ;
var message = " <p>Dear " + name + " ,</p><p> " + " <?= getConfigKey_table('cronic_reminder_contant') ?> " + " </p><p>Regards</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 subjectValue = < ? = getConfigKey_table ( 'chronic_reminder_subject' ) ?> ;
var subject = ! subjectValue || subjectValue . trim () === '' ? 'Regular Medicine Reminder' : subjectValue ;
// console.log('subject', subject);
var message = " <p>Dear " + name + " ,</p><p> " + " <?= getConfigKey_table('cronic_reminder_contant') ?> " + " </p><p>Regards</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 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 ();
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
$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 ();
2024-11-02 18:03:13 +05:30
die ( mysqli_error ( $conn ));
2024-10-16 19:18:52 +05:30
}
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' ] == 'success' ) {
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 );
}
?>