3 ////////////////////////////////////////////////////////////////////
4 // Package: cron_email_notification
5 // Purpose: to be run by cron every hour, look for appointments
6 // in the pre-notification period and send an email reminder
9 // Updated by: Larry Lart on 10/03/2008
10 ////////////////////////////////////////////////////////////////////
12 // larry :: hack add for command line version
13 $_SERVER['REQUEST_URI']=$_SERVER['PHP_SELF'];
14 $_SERVER['SERVER_NAME']='localhost';
19 include_once("../../interface/globals.php");
20 include_once("cron_functions.php");
25 // set cron time (time to event ?) - todo extra tests
26 $vectNotificationSettings = cron_GetNotificationSettings();
27 $CRON_TIME = $vectNotificationSettings['Send_Email_Before_Hours'];
29 $check_date = date("Y-m-d", mktime(date("h")+
$EMAIL_NOTIFICATION_HOUR, 0, 0, date("m"), date("d"), date("Y")));
32 // get data from automatic_notification table
33 $db_email_msg = cron_getNotificationData($TYPE);
34 //my_print_r($db_email_msg);
36 // get patient data for send alert
37 $db_patient = cron_getAlertpatientData($TYPE);
38 echo "<br>Total ".count($db_patient)." Records Found\n";
39 for ($p=0; $p<count($db_patient); $p++
) {
40 $prow =$db_patient[$p];
43 if($prow['pc_eventDate'] < $check_date)
45 $app_date = date("Y-m-d")." ".$prow['pc_startTime'];
47 $app_date = $prow['pc_eventDate']." ".$prow['pc_startTime'];
50 $app_date = $prow['pc_eventDate']." ".$prow['pc_startTime'];
51 $app_time = strtotime($app_date);
53 $app_time_hour = round($app_time/3600);
54 $curr_total_hour = round(time()/3600);
56 $remaining_app_hour = round($app_time_hour - $curr_total_hour);
57 $remain_hour = round($remaining_app_hour - $EMAIL_NOTIFICATION_HOUR);
59 $strMsg = "\n========================".$TYPE." || ".date("Y-m-d H:i:s")."=========================";
60 $strMsg .= "\nSEND NOTIFICATION BEFORE:".$EMAIL_NOTIFICATION_HOUR." || CRONJOB RUN EVERY:".$CRON_TIME." || APPDATETIME:".$app_date." || REMAINING APP HOUR:".($remaining_app_hour)." || SEND ALERT AFTER:".($remain_hour);
62 if ($remain_hour >= -($CRON_TIME) && $remain_hour <= $CRON_TIME) {
63 // insert entry in notification_log table
64 cron_InsertNotificationLogEntry($TYPE, $prow, $db_email_msg);
67 $db_email_msg['message'] = cron_setmessage($prow, $db_email_msg);
69 // send mail to patinet
72 $db_email_msg['email_subject'],
73 $db_email_msg['message'],
74 $db_email_msg['email_sender']
77 //update entry >> pc_sendalertemail='Yes'
78 cron_updateentry($TYPE, $prow['pid'], $prow['pc_eid']);
80 $strMsg .= " || ALERT SENT SUCCESSFULLY TO ".$prow['email'];
81 $strMsg .= "\n".$patient_info."\n".$smsgateway_info."\n".$data_info."\n".$db_email_msg['message'];
86 // larry :: get notification data again - since was updated by cron_updateentry
87 // todo :: instead fix not to modify the template aka $db_email_msg
88 $db_email_msg = cron_getNotificationData($TYPE);
96 <title
>Conrjob
- Email Notification
</title
>