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-2011 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 ********************************************************************************/
38 /*********************************************************************************
40 ********************************************************************************/
42 require_once('modules/Activities/config.php');
43 require_once('include/json_config.php');
44 $json_config = new json_config();
47 global $currentModule, $theme, $focus, $action, $open_status;
49 global $current_language;
54 global $sugar_version, $sugar_config;
56 $focus_meetings_list = array();
57 $focus_calls_list = array();
58 $focus_tasks_list = array();
60 //we don't want the parent module's string file, but rather the string file specifc to this subpanel
61 $current_module_strings = return_module_language($current_language, 'Activities');
65 ///////////////////////////////////////////////////////////////////////////////
67 if (empty($_REQUEST['appointment_filter'])) {
68 if ($current_user->getPreference('appointment_filter') == '') {
69 $appointment_filter = 'today';
71 $appointment_filter = $current_user->getPreference('appointment_filter');
74 $appointment_filter = $_REQUEST['appointment_filter'];
75 $current_user->setPreference('appointment_filter', $_REQUEST['appointment_filter']);
78 if ($appointment_filter == 'last this_month') {
79 $laterDate = $timedate->getNow(true)->get("last day of this month");
80 } elseif ($appointment_filter == 'last next_month') {
81 $laterDate = $timedate->getNow(true)->get("last day of next month");
83 $laterDate = $timedate->fromString($appointment_filter);
86 $dayEnd = $timedate->asDb($laterDate->get_day_end_time());
87 $GLOBALS['log']->debug("filter $appointment_filter date $dayEnd");
89 if(ACLController::checkAccess('Meetings', 'list', true)){
90 $meeting = new Meeting();
93 foreach ($open_status as $status) {
94 if ($or) $where .= ' OR ';
96 $where .= " meetings.status = '$status' ";
99 $where .= " AND meetings_users.user_id='$current_user->id' ";
100 $where .= " AND meetings_users.accept_status != 'decline'";
102 // allow for differences between MySQL and Oracle 9
103 if($sugar_config["dbconfig"]["db_type"] == "mysql") {
104 $where .= " HAVING datetime <= '$dayEnd' ";
105 } elseif ($sugar_config["dbconfig"]["db_type"] == "oci8") {
107 else if ($sugar_config["dbconfig"]["db_type"] == "mssql")
109 $where .= " AND meetings.date_start + ' ' + meetings.time_start <= '$dayEnd' ";
112 $GLOBALS['log']->fatal("No database type identified.");
115 $meeting->disable_row_level_security = true;
116 $focus_meetings_list = $meeting->get_full_list("time_start", $where);
119 if(ACLController::checkAccess('Calls', 'list', true)) {
124 foreach ($open_status as $status) {
125 if ($or) $where .= ' OR ';
127 $where .= " calls.status = '$status' ";
131 $where .= " AND calls_users.user_id='$current_user->id' ";
132 $where .= " AND calls_users.accept_status != 'decline'";
134 // allow for differences between MySQL and Oracle 9
135 if($sugar_config["dbconfig"]["db_type"] == "mysql") {
136 $where .= " HAVING datetime <= '$dayEnd' ";
137 } elseif ($sugar_config["dbconfig"]["db_type"] == "oci8") {
138 }else if ($sugar_config["dbconfig"]["db_type"] == "mssql")
140 //add condition for MS Sql server.
141 $where .= " AND calls.date_start + ' ' + calls.time_start <= '$dayEnd' ";
143 $GLOBALS['log']->fatal("No database type identified.");
146 $call->disable_row_level_security = true;
147 $focus_calls_list = $call->get_full_list("time_start", $where);
150 $open_activity_list = array();
151 if(count($focus_meetings_list)>0) {
152 foreach ($focus_meetings_list as $meeting) {
153 $td = $timedate->merge_date_time(from_db_convert($meeting->date_start,'date'),from_db_convert($meeting->time_start, 'time'));
156 if($meeting->ACLAccess('view', $meeting->isOwner($current_user->id))){
160 $open_activity_list[] = array(
161 'name' => $meeting->name,
162 'id' => $meeting->id,
164 'module' => 'Meetings',
165 'status' => $meeting->status,
166 'parent_id' => $meeting->parent_id,
167 'parent_type' => $meeting->parent_type,
168 'parent_name' => $meeting->parent_name,
169 'contact_id' => $meeting->contact_id,
170 'contact_name' => $meeting->contact_name,
171 'normal_date_start' => $meeting->date_start,
172 'date_start' => $timedate->to_display_date($td),
173 'normal_time_start' => $meeting->time_start,
174 'time_start' => $timedate->to_display_time($td,true),
175 'required' => $meeting->required,
176 'accept_status' => $meeting->accept_status,
182 if (count($focus_calls_list)>0) {
183 foreach ($focus_calls_list as $call) {
185 $td = $timedate->merge_date_time(from_db_convert($call->date_start,'date'),from_db_convert($call->time_start, 'time'));
188 if($call->ACLAccess('view', $call->isOwner($current_user->id))) {
192 $open_activity_list[] = array(
193 'name' => $call->name,
197 'status' => $call->status,
198 'parent_id' => $call->parent_id,
199 'parent_type' => $call->parent_type,
200 'parent_name' => $call->parent_name,
201 'contact_id' => $call->contact_id,
202 'contact_name' => $call->contact_name,
203 'date_start' => $timedate->to_display_date($td),
204 'normal_date_start' => $call->date_start,
205 'normal_time_start' => $call->time_start,
206 'time_start' => $timedate->to_display_time($td,true),
207 'required' => $call->required,
208 'accept_status' => $call->accept_status,
214 ///////////////////////////////////////////////////////////////////////////////
217 $xtpl=new XTemplate ('modules/Activities/OpenListView.html');
218 $xtpl->assign("MOD", $current_module_strings);
219 $xtpl->assign("APP", $app_strings);
220 $xtpl->assign('JSON_CONFIG_JAVASCRIPT', $json_config->get_static_json_server());
221 $xtpl->assign("SUGAR_VERSION", $sugar_version);
222 $xtpl->assign("JS_CUSTOM_VERSION", $sugar_config['js_custom_version']);
224 // Stick the form header out there.
225 $filter = get_select_options_with_id($current_module_strings['appointment_filter_dom'], $appointment_filter );
226 echo "<form method='POST' action='index.php'>\n";
227 echo "<input type='hidden' name='module' value='Home'>\n";
228 echo "<input type='hidden' name='action' value='index'>\n";
229 $day_filter = "<select name='appointment_filter' language='JavaScript' onchange='this.form.submit();'>$filter</select>";
231 echo get_form_header($current_module_strings['LBL_UPCOMING'], $current_module_strings['LBL_TODAY'].$day_filter.' ('.$timedate->to_display_date($later, false).') ', false);
234 $xtpl->assign("RETURN_URL", "&return_module=$currentModule&return_action=DetailView&return_id=" . ((is_object($focus) && ! empty($focus->id)) ? $focus->id : ""));
237 if(count($open_activity_list) > 0) {
238 $open_activity_list = array_csort($open_activity_list, 'normal_date_start', 'normal_time_start', SORT_ASC);
241 $today = $timedate->handle_offset('today', $timedate->dbDayFormat.' '.$timedate->dbTimeFormat, false);
242 $todayOffset = $timedate->handleOffsetMax('today', $timedate->dbDayFormat.' '.$timedate->dbTimeFormat, true);
244 foreach($open_activity_list as $activity) {
245 $concatActDate = $activity['normal_date_start'].' '.$activity['normal_time_start'];
247 if($concatActDate < $today) {
248 $time = "<font class='overdueTask'>".$activity['date_start'].' '.$activity['time_start']."</font>";
249 } elseif(($concatActDate >= $todayOffset['min']) && ($concatActDate <= $todayOffset['max'])) {
250 $time = "<font class='todaysTask'>".$activity['date_start'].' '.$activity['time_start']."</font>";
252 $time = "<font class='futureTask'>".$activity['date_start'].' '.$activity['time_start']."</font>";
255 $activity_fields = array(
256 'ID' => $activity['id'],
257 'NAME' => $activity['name'],
258 'TYPE' => $activity['type'],
259 'MODULE' => $activity['module'],
260 'STATUS' => $activity['status'],
261 'CONTACT_NAME' => $activity['contact_name'],
262 'CONTACT_ID' => $activity['contact_id'],
263 'PARENT_TYPE' => $activity['parent_type'],
264 'PARENT_NAME' => $activity['parent_name'],
265 'PARENT_ID' => $activity['parent_id'],
267 'TAG' => $activity['tag'],
270 switch ($activity['parent_type']) {
272 $activity_fields['PARENT_MODULE'] = 'Accounts';
275 $activity_fields['PARENT_MODULE'] = 'Cases';
277 case 'Opportunities':
278 $activity_fields['PARENT_MODULE'] = 'Opportunities';
281 $activity_fields['PARENT_MODULE'] = 'Quotes';
284 switch ($activity['type']) {
286 $activity_fields['SET_COMPLETE'] = "<a href='index.php?return_module=$currentModule&return_action=$action&return_id=" . ((is_object($focus) && ! empty($focus->id)) ? $focus->id : "")."&action=EditView&module=Calls&status=Held&record=".$activity['id']."&status=Held'>".SugarThemeRegistry::current()->getImage("close_inline","title=".translate('LBL_LIST_CLOSE','Activities')." border='0'", null, null, '.gif', $mod_strings['LBL_LIST_CLOSE'])."</a>";
289 $activity_fields['SET_COMPLETE'] = "<a href='index.php?return_module=$currentModule&return_action=$action&return_id=" . ((is_object($focus) && ! empty($focus->id)) ? $focus->id : "")."&action=EditView&module=Meetings&status=Held&record=".$activity['id']."&status=Held'>".SugarThemeRegistry::current()->getImage("close_inline","title=".translate('LBL_LIST_CLOSE','Activities')." border='0'",null,null,'.gif',$mod_strings['LBL_LIST_CLOSE'])."</a>";
293 if (! empty($activity['accept_status'])) {
294 if ( $activity['accept_status'] == 'none') {
295 $activity_fields['SET_ACCEPT_LINKS'] = "<div id=\"accept".$activity['id']."\"><a title=\"".$app_list_strings['dom_meeting_accept_options']['accept']."\" href=\"javascript:setAcceptStatus('".$activity_fields['MODULE']."','".$activity['id']."','accept');\">". SugarThemeRegistry::current()->getImage("accept_inline","title='".$app_list_strings['dom_meeting_accept_options']['accept']."' border='0'", null,null,'.gif',$mod_strings['LBL_ACCEPT']). "</a> <a title=\"".$app_list_strings['dom_meeting_accept_options']['tentative']."\" href=\"javascript:setAcceptStatus('".$activity_fields['MODULE']."','".$activity['id']."','tentative');\">".SugarThemeRegistry::current()->getImage("tentative_inline","alt='".$app_list_strings['dom_meeting_accept_options']['tentative']."' border='0'", null,null,'.gif',$mod_strings['LBL_ACCEPT'])."</a> <a title=\"".$app_list_strings['dom_meeting_accept_options']['decline']."\" href=\"javascript:setAcceptStatus('".$activity_fields['MODULE']."','".$activity['id']."','decline');\">".SugarThemeRegistry::current()->getImage("decline_inline","alt='".$app_list_strings['dom_meeting_accept_options']['decline']."' border='0'", null,null,'.gif',$mod_strings['LBL_ACCEPT'])."</a></div>";
297 $activity_fields['SET_ACCEPT_LINKS'] = $app_list_strings['dom_meeting_accept_status'][$activity['accept_status']];
301 $activity_fields['TITLE'] = '';
302 if (!empty($activity['contact_name'])) {
303 $activity_fields['TITLE'] .= $current_module_strings['LBL_LIST_CONTACT'].": ".$activity['contact_name'];
305 if (!empty($activity['parent_name'])) {
306 $activity_fields['TITLE'] .= "\n".$app_list_strings['record_type_display'][$activity['parent_type']].": ".$activity['parent_name'];
309 $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'].'','border="0"', null,null,'.gif',$activity_fields['NAME']));
310 $xtpl->assign("ACTIVITY", $activity_fields);
311 $xtpl->assign("BG_HILITE", $hilite_bg);
312 $xtpl->assign("BG_CLICK", $click_bg);
315 $xtpl->assign("ROW_COLOR", 'oddListRow');
316 $xtpl->assign("BG_COLOR", $odd_bg);
318 $xtpl->assign("ROW_COLOR", 'evenListRow');
319 $xtpl->assign("BG_COLOR", $even_bg);
322 $xtpl->parse("open_activity.row");
325 $xtpl->parse("open_activity");
326 if (count($open_activity_list)>0) $xtpl->out("open_activity");
327 else echo "<i>".$current_module_strings['NTC_NONE_SCHEDULED']."</i>";