Fixed field population and date popup in the generated view.php file.
[openemr.git] / modules / sms_email_reminder / cron_email_notification.php
blob788089282f480f5768e09cabb6fecc16eb5e4dc6
1 <?
2 ////////////////////////////////////////////////////////////////////
3 // Package: cron_email_notification
4 // Purpose: to be run by cron every hour, look for appointments
5 // in the pre-notification period and send an email reminder
6 //
7 // Created by:
8 // Updated by: Larry Lart on 10/03/2008
9 ////////////////////////////////////////////////////////////////////
11 // larry :: hack add for command line version
12 $_SERVER['REQUEST_URI']=$_SERVER['PHP_SELF'];
13 $_SERVER['SERVER_NAME']='localhost';
14 $backpic = "";
16 // email notification
17 $ignoreAuth=1;
18 include_once("../../interface/globals.php");
19 include_once("cron_functions.php");
21 $TYPE = "Email";
22 $CRON_TIME = 5;
24 // set cron time (time to event ?) - todo extra tests
25 $vectNotificationSettings = cron_GetNotificationSettings( );
26 $CRON_TIME = $vectNotificationSettings['Send_Email_Before_Hours'];
28 $check_date = date("Y-m-d", mktime(date("h")+$EMAIL_NOTIFICATION_HOUR, 0, 0, date("m"), date("d"), date("Y")));
31 // get data from automatic_notification table
32 $db_email_msg = cron_getNotificationData($TYPE);
33 //my_print_r($db_email_msg);
35 // get patient data for send alert
36 $db_patient = cron_getAlertpatientData($TYPE);
37 echo "<br>Total ".count($db_patient)." Records Found\n";
38 for($p=0;$p<count($db_patient);$p++)
40 $prow =$db_patient[$p];
41 //my_print_r($prow);
43 if($prow['pc_eventDate'] < $check_date)
45 $app_date = date("Y-m-d")." ".$prow['pc_startTime'];
46 }else{
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)
64 // insert entry in notification_log table
65 cron_InsertNotificationLogEntry($TYPE,$prow,$db_email_msg);
67 //set message
68 $db_email_msg['message'] = cron_setmessage( $prow, $db_email_msg );
70 // send mail to patinet
71 cron_SendMail( $prow['email'], $db_email_msg['email_subject'],
72 $db_email_msg['message'], $db_email_msg['email_sender'] );
74 //update entry >> pc_sendalertemail='Yes'
75 cron_updateentry($TYPE,$prow['pid'],$prow['pc_eid']);
77 $strMsg .= " || ALERT SENT SUCCESSFULLY TO ".$prow['email'];
78 $strMsg .= "\n".$patient_info."\n".$smsgateway_info."\n".$data_info."\n".$db_email_msg['message'];
81 WriteLog( $strMsg );
83 // larry :: get notification data again - since was updated by cron_updateentry
84 // todo :: instead fix not to modify the template aka $db_email_msg
85 $db_email_msg = cron_getNotificationData($TYPE);
88 sqlClose();
91 <html>
92 <head>
93 <title>Conrjob - Email Notification</title>
94 </head>
95 <body>
96 <center>
97 </center>
98 </body>
99 </html>