2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 require_once("include/utils/db_utils.php");
46 $this->script .= <<<EOQ
47 if (!alertsTimeoutId) {
52 $this->addActivities();
53 if(!empty($GLOBALS['sugar_config']['enable_timeout_alerts'])){
54 $this->addAlert($app_strings['ERROR_JS_ALERT_SYSTEM_CLASS'], $app_strings['ERROR_JS_ALERT_TIMEOUT_TITLE'],'', $app_strings['ERROR_JS_ALERT_TIMEOUT_MSG_1'], (session_cache_expire() - 2) * 60 );
55 $this->addAlert($app_strings['ERROR_JS_ALERT_SYSTEM_CLASS'], $app_strings['ERROR_JS_ALERT_TIMEOUT_TITLE'],'', $app_strings['ERROR_JS_ALERT_TIMEOUT_MSG_2'], (session_cache_expire()) * 60 , 'index.php');
58 function addAlert($type, $name, $subtitle, $description, $countdown, $redirect=''){
59 $this->script .= 'addAlert("' . addslashes($type) .'", "' . addslashes($name). '","' . addslashes($subtitle). '", "'. addslashes(str_replace(array("\r", "\n"), array('','<br>'),$description)) . '",' . $countdown . ',"'.addslashes($redirect).'")' . "\n";
64 return "<script>secondsSinceLoad = 0; alertList = [];" . $this->script . "</script>";
67 function addActivities(){
68 global $app_list_strings, $timedate, $current_user, $app_strings;
71 if (empty($current_user->id)) {
75 //Create separate variable to hold timedate value
76 $alertDateTimeNow = $timedate->nowDb();
78 // cn: get a boundary limiter
79 $dateTimeMax = $timedate->getNow()->modify("+{$app_list_strings['reminder_max_time']} seconds")->asDb();
80 $dateTimeNow = $timedate->nowDb();
83 $dateTimeNow = $db->convert($db->quoted($dateTimeNow), 'datetime');
84 $dateTimeMax = $db->convert($db->quoted($dateTimeMax), 'datetime');
85 $desc = $db->convert("description", "text2char");
86 if($desc != "description") {
87 $desc .= " description";
90 // Prep Meetings Query
91 $selectMeetings = "SELECT meetings.id, name,reminder_time, $desc,location, date_start, assigned_user_id
92 FROM meetings LEFT JOIN meetings_users ON meetings.id = meetings_users.meeting_id
93 WHERE meetings_users.user_id ='".$current_user->id."'
94 AND meetings_users.accept_status != 'decline'
95 AND meetings.reminder_time != -1
96 AND meetings_users.deleted != 1
97 AND meetings.status = 'Planned'
98 AND date_start >= $dateTimeNow
99 AND date_start <= $dateTimeMax";
100 $result = $db->query($selectMeetings);
102 ///////////////////////////////////////////////////////////////////////
103 //// MEETING INTEGRATION
104 $meetingIntegration = null;
105 if(isset($sugar_config['meeting_integration']) && !empty($sugar_config['meeting_integration'])) {
106 if(!class_exists($sugar_config['meeting_integration'])) {
107 require_once("modules/{$sugar_config['meeting_integration']}/{$sugar_config['meeting_integration']}.php");
109 $meetingIntegration = new $sugar_config['meeting_integration']();
111 //// END MEETING INTEGRATION
112 ///////////////////////////////////////////////////////////////////////
114 while($row = $db->fetchByAssoc($result)) {
115 // need to concatenate since GMT times can bridge two local days
116 $timeStart = strtotime($db->fromConvert($row['date_start'], 'datetime'));
117 $timeRemind = $row['reminder_time'];
118 $timeStart -= $timeRemind;
120 $url = 'index.php?action=DetailView&module=Meetings&record=' . $row['id'];
121 $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG'];
123 ///////////////////////////////////////////////////////////////////
124 //// MEETING INTEGRATION
125 if(!empty($meetingIntegration) && $meetingIntegration->isIntegratedMeeting($row['id'])) {
126 $url = $meetingIntegration->miUrlGetJsAlert($row);
127 $instructions = $meetingIntegration->miGetJsAlertInstructions();
129 //// END MEETING INTEGRATION
130 ///////////////////////////////////////////////////////////////////
134 if(!empty($row['name'])) {
135 $meetingName = from_html($row['name']);
136 // addAlert() uses double-quotes to pass to popup - escape double-quotes
137 //$meetingName = str_replace('"', '\"', $meetingName);
142 if(!empty($row['description'])) {
143 $desc1 = from_html($row['description']);
144 // addAlert() uses double-quotes to pass to popup - escape double-quotes
145 //$desc = str_replace('"', '\"', $desc);
148 $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n";
151 // standard functionality
152 $this->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName,
153 $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$timedate->to_display_date_time($db->fromConvert($row['date_start'], 'datetime')),
154 $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$row['location'].
157 $timeStart - strtotime($alertDateTimeNow),
164 SELECT calls.id, name, reminder_time, $desc, date_start
165 FROM calls LEFT JOIN calls_users ON calls.id = calls_users.call_id
166 WHERE calls_users.user_id ='".$current_user->id."'
167 AND calls_users.accept_status != 'decline'
168 AND calls.reminder_time != -1
169 AND calls_users.deleted != 1
170 AND calls.status = 'Planned'
171 AND date_start >= $dateTimeNow
172 AND date_start <= $dateTimeMax";
174 $result = $db->query($selectCalls);
176 while($row = $db->fetchByAssoc($result)){
177 // need to concatenate since GMT times can bridge two local days
178 $timeStart = strtotime($db->fromConvert($row['date_start'], 'datetime'));
179 $timeRemind = $row['reminder_time'];
180 $timeStart -= $timeRemind;
181 $row['description'] = (isset($row['description'])) ? $row['description'] : '';
184 $this->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_CALL'], $row['name'], $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$timedate->to_display_date_time($db->fromConvert($row['date_start'], 'datetime')) , $app_strings['MSG_JS_ALERT_MTG_REMINDER_DESC'].$row['description']. $app_strings['MSG_JS_ALERT_MTG_REMINDER_CALL_MSG'] , $timeStart - strtotime($alertDateTimeNow), 'index.php?action=DetailView&module=Calls&record=' . $row['id']);