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 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
48 require_once("include/upload_file.php");
50 global $currentModule;
57 global $app_list_strings;
58 //we don't want the parent module's string file, but rather the string file specific to this subpanel
59 global $current_language;
60 $current_module_strings = return_module_language($current_language, 'Activities');
65 // history_list is the means of passing data to a SubPanelView.
66 global $focus_tasks_list;
67 global $focus_meetings_list;
68 global $focus_calls_list;
69 global $focus_emails_list;
71 $open_activity_list = Array();
72 $history_list = Array();
74 foreach ($focus_tasks_list as $task) {
75 if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") {
76 $history_list[] = Array('name' => $task->name,
81 'status' => $task->status,
82 'parent_id' => $task->parent_id,
83 'parent_type' => $task->parent_type,
84 'parent_name' => $task->parent_name,
85 'contact_id' => $task->contact_id,
86 'contact_name' => $task->contact_name,
87 'date_modified' => $timedate->to_display_date($task->date_modified, true),
91 if ($task->date_due == '0000-00-00') $date_due = '';
93 $date_due = $task->date_due;
96 $open_activity_list[] = Array('name' => $task->name,
101 'status' => $task->status,
102 'parent_id' => $task->parent_id,
103 'parent_type' => $task->parent_type,
104 'parent_name' => $task->parent_name,
105 'contact_id' => $task->contact_id,
106 'contact_name' => $task->contact_name,
107 'date_due' => $date_due
112 foreach ($focus_meetings_list as $meeting) {
113 if ($meeting->status != "Planned") {
114 $history_list[] = Array('name' => $meeting->name,
115 'id' => $meeting->id,
118 'module' => "Meetings",
119 'status' => $meeting->status,
120 'parent_id' => $meeting->parent_id,
121 'parent_type' => $meeting->parent_type,
122 'parent_name' => $meeting->parent_name,
123 'contact_id' => $meeting->contact_id,
124 'contact_name' => $meeting->contact_name,
125 'date_modified' => $meeting->date_modified
129 $open_activity_list[] = Array('name' => $meeting->name,
130 'id' => $meeting->id,
133 'module' => "Meetings",
134 'status' => $meeting->status,
135 'parent_id' => $meeting->parent_id,
136 'parent_type' => $meeting->parent_type,
137 'parent_name' => $meeting->parent_name,
138 'contact_id' => $meeting->contact_id,
139 'contact_name' => $meeting->contact_name,
140 'date_due' => $meeting->date_start
145 foreach ($focus_calls_list as $call) {
146 if ($call->status != "Planned") {
147 $history_list[] = Array('name' => $call->name,
150 'direction' => $call->direction,
152 'status' => $call->status,
153 'parent_id' => $call->parent_id,
154 'parent_type' => $call->parent_type,
155 'parent_name' => $call->parent_name,
156 'contact_id' => $call->contact_id,
157 'contact_name' => $call->contact_name,
158 'date_modified' => $call->date_modified
162 $open_activity_list[] = Array('name' => $call->name,
164 'direction' => $call->direction,
167 'status' => $call->status,
168 'parent_id' => $call->parent_id,
169 'parent_type' => $call->parent_type,
170 'parent_name' => $call->parent_name,
171 'contact_id' => $call->contact_id,
172 'contact_name' => $call->contact_name,
173 'date_due' => $call->date_start
178 foreach ($focus_emails_list as $email) {
179 $history_list[] = Array('name' => $email->name,
183 'module' => "Emails",
185 'parent_id' => $email->parent_id,
186 'parent_type' => $email->parent_type,
187 'parent_name' => $email->parent_name,
188 'contact_id' => $email->contact_id,
189 'contact_name' => $email->contact_name,
190 'date_modified' => $email->date_start." ".$email->time_start
194 foreach ($focus_notes_list as $note) {
195 $history_list[] = Array('name' => $note->name,
201 'parent_id' => $note->parent_id,
202 'parent_type' => $note->parent_type,
203 'parent_name' => $note->parent_name,
204 'contact_id' => $note->contact_id,
205 'contact_name' => $note->contact_name,
206 'date_modified' => $note->date_modified
208 if (!empty($note->filename))
210 $count = count($history_list);
212 $history_list[$count]['filename'] = $note->filename;
213 $history_list[$count]['fileurl'] = UploadFile::get_upload_url($note);
218 if ($currentModule == 'Contacts')
220 $xtpl=new XTemplate ('modules/Activities/SubPanelViewContacts.html');
221 $xtpl->assign("CONTACT_ID", $focus->id);
225 $xtpl=new XTemplate ('modules/Activities/SubPanelView.html');
228 $xtpl->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"', null,null,'.gif',$app_strings['LNK_DELETE']));
229 $xtpl->assign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline','align="absmiddle" border="0"', null,null,'.gif',$app_strings['LNK_EDIT']));
231 $xtpl->assign("MOD", $current_module_strings);
232 $xtpl->assign("APP", $app_strings);
234 $button = "<form border='0' action='index.php' method='post' name='form' id='form'>\n";
235 $button .= "<input type='hidden' name='module'>\n";
236 $button .= "<input type='hidden' name='type'>\n";
237 if ($currentModule == 'Accounts')
239 $button .= "<input type='hidden' name='parent_type' value='Accounts'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
241 elseif ($currentModule == 'Opportunities')
243 $button .= "<input type='hidden' name='parent_type' value='Opportunities'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
245 elseif ($currentModule == 'Cases')
247 $button .= "<input type='hidden' name='parent_type' value='Cases'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
249 elseif ($currentModule == 'Contacts')
251 $button .= "<input type='hidden' name='contact_id' value='$focus->id'>\n<input type='hidden' name='contact_name' value='$focus->first_name $focus->last_name'>\n";
252 $button .= "<input type='hidden' name='parent_type' value='Accounts'>\n<input type='hidden' name='parent_id' value='$focus->account_id'>\n<input type='hidden' name='parent_name' value='$focus->account_name'>\n";
253 $button .= "<input type='hidden' name='to_email_addrs' value='$focus->email1'>\n";
257 $button .= "<input type='hidden' name='parent_type' value='$currentModule'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
260 $button .= "<input type='hidden' name='return_module' value='".$currentModule."'>\n";
261 $button .= "<input type='hidden' name='return_action' value='".$action."'>\n";
262 $button .= "<input type='hidden' name='return_id' value='".$focus->id."'>\n";
263 $button .= "<input type='hidden' name='type' value='out'>\n";
264 $button .= "<input type='hidden' name='action'>\n";
266 if($currentModule != 'Project' && $currentModule != 'ProjectTask')
268 $button .= "<input title='".$current_module_strings['LBL_NEW_TASK_BUTTON_TITLE']."' class='button' onclick=\"this.form.action.value='EditView';this.form.module.value='Tasks'\" type='submit' name='button' value='".$current_module_strings['LBL_NEW_TASK_BUTTON_LABEL']."'>\n";
271 $button .= "<input title='".$current_module_strings['LBL_SCHEDULE_MEETING_BUTTON_TITLE']."' class='button' onclick=\"this.form.action.value='EditView';this.form.module.value='Meetings'\" type='submit' name='button' value='".$current_module_strings['LBL_SCHEDULE_MEETING_BUTTON_LABEL']."'>\n";
273 $button .= "<input title='".$current_module_strings['LBL_SCHEDULE_CALL_BUTTON_LABEL']."' class='button' onclick=\"this.form.action.value='EditView';this.form.module.value='Calls'\" type='submit' name='button' value='".$current_module_strings['LBL_SCHEDULE_CALL_BUTTON_LABEL']."'>\n";
275 $button .= "<input title='".$app_strings['LBL_COMPOSE_EMAIL_BUTTON_TITLE']."' class='button' onclick=\"this.form.type.value='out';this.form.action.value='EditView';this.form.module.value='Emails';\" type='submit' name='button' value='".$app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL']."'>\n";
277 $button .= "</form>\n";
279 // Stick the form header out there.
280 echo get_form_header($current_module_strings['LBL_OPEN_ACTIVITIES'], $button, false);
282 $xtpl->assign("RETURN_URL", "&return_module=$currentModule&return_action=DetailView&return_id=$focus->id");
285 if (count($open_activity_list) > 0) $open_activity_list = array_csort($open_activity_list, 'date_due', SORT_DESC);
286 foreach($open_activity_list as $activity)
288 $activity_fields = array(
289 'ID' => $activity['id'],
290 'NAME' => $activity['name'],
291 'MODULE' => $activity['module'],
292 'CONTACT_NAME' => $activity['contact_name'],
293 'CONTACT_ID' => $activity['contact_id'],
294 'PARENT_TYPE' => $activity['parent_type'],
295 'PARENT_NAME' => $activity['parent_name'],
296 'PARENT_ID' => $activity['parent_id'],
297 'DATE' => $activity['date_due']
300 if (empty($activity['direction'])) {
301 $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
304 $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']].' '.$app_list_strings['activity_dom'][$activity['type']];
306 if (isset($activity['parent_type'])) $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
307 switch ($activity['type']) {
309 $activity_fields['SET_COMPLETE'] = "<a href='index.php?return_module=$currentModule&return_action=$action&return_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>";
310 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
313 $activity_fields['SET_COMPLETE'] = "<a href='index.php?return_module=$currentModule&return_action=$action&return_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>";
314 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
317 $activity_fields['SET_COMPLETE'] = "<a href='index.php?return_module=$currentModule&return_action=$action&return_id=$focus->id&action=EditView&module=Tasks&status=Completed&record=".$activity['id']."&status=Completed'>".SugarThemeRegistry::current()->getImage("close_inline","title=".translate('LBL_LIST_CLOSE','Activities')." border='0'", null,null,'.gif',$mod_strings['LBL_LIST_CLOSE'])."</a>";
318 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
326 $xtpl->assign("BG_HILITE", $hilite_bg);
327 $xtpl->assign("BG_CLICK", $click_bg);
328 $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'].'','border="0"', null,null,'.gif',$activity_fields['NAME']));
329 $xtpl->assign("ACTIVITY", $activity_fields);
333 //todo move to themes
334 $xtpl->assign("ROW_COLOR", 'oddListRow');
335 $xtpl->assign("BG_COLOR", $odd_bg);
339 //todo move to themes
340 $xtpl->assign("ROW_COLOR", 'evenListRow');
341 $xtpl->assign("BG_COLOR", $even_bg);
345 $xtpl->parse("open_activity.row");
349 $xtpl->parse("open_activity");
350 $xtpl->out("open_activity");
355 $popup_request_data = array(
356 'call_back_function' => 'set_return',
357 'form_name' => 'EditView',
358 'field_to_name_array' => array(),
361 $json = getJSONobj();
362 $encoded_popup_request_data = $json->encode($popup_request_data);
364 $button = "<form border='0' action='index.php' method='post' name='form' id='form'>\n";
365 $button .= "<input type='hidden' name='module'>\n";
366 $button .= "<input type='hidden' name='type' value='archived'>\n";
367 if ($currentModule == 'Accounts') $button .= "<input type='hidden' name='parent_type' value='Accounts'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
368 if ($currentModule == 'Opportunities') $button .= "<input type='hidden' name='parent_type' value='Opportunities'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
369 elseif ($currentModule == 'Cases') $button .= "<input type='hidden' name='parent_type' value='Cases'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
370 elseif ($currentModule == 'Contacts') {
371 $button .= "<input type='hidden' name='contact_id' value='$focus->id'>\n<input type='hidden' name='contact_name' value='$focus->first_name $focus->last_name'>\n";
372 $button .= "<input type='hidden' name='to_email_addrs' value='$focus->email1'>\n";
373 $button .= "<input type='hidden' name='parent_type' value='Accounts'>\n<input type='hidden' name='parent_id' value='$focus->account_id'>\n<input type='hidden' name='parent_name' value='$focus->account_name'>\n";
375 $button .= "<input type='hidden' name='parent_type' value='$currentModule'>\n<input type='hidden' name='parent_id' value='$focus->id'>\n<input type='hidden' name='parent_name' value='$focus->name'>\n";
377 $button .= "<input type='hidden' name='return_module' value='".$currentModule."'>\n";
378 $button .= "<input type='hidden' name='return_action' value='".$action."'>\n";
379 $button .= "<input type='hidden' name='return_id' value='".$focus->id."'>\n";
380 $button .= "<input type='hidden' name='action'>\n";
381 $button .= "<input title='".$current_module_strings['LBL_NEW_NOTE_BUTTON_TITLE']."' class='button' onclick=\"this.form.action.value='EditView';this.form.module.value='Notes'\" type='submit' name='button' value='".$current_module_strings['LBL_NEW_NOTE_BUTTON_LABEL']."'>\n";
382 $button .= "<input title='".$current_module_strings['LBL_TRACK_EMAIL_BUTTON_TITLE']."' class='button' onclick=\"this.form.type.value='archived';this.form.action.value='EditView';this.form.module.value='Emails'\" type='submit' name='button' value='".$current_module_strings['LBL_TRACK_EMAIL_BUTTON_LABEL']."'>\n";
383 $button .= "<input title='".$current_module_strings['LBL_ACCUMULATED_HISTORY_BUTTON_TITLE']."' class='button' type='button' onclick='open_popup(\"Activities\", \"600\", \"400\", \"&record=$focus->id&module_name=$currentModule\", true, false, $encoded_popup_request_data);' name='button' value='".$current_module_strings['LBL_ACCUMULATED_HISTORY_BUTTON_LABEL']."'>\n";
384 $button .= "</form>\n";
386 // Stick the form header out there.
387 echo get_form_header($current_module_strings['LBL_HISTORY'], $button, false);
389 $xtpl->assign("RETURN_URL", "&return_module=$currentModule&return_action=DetailView&return_id=$focus->id");
392 if (count($history_list) > 0) $history_list = array_csort($history_list, 'date_modified', SORT_DESC);
393 foreach($history_list as $activity)
395 $activity_fields = array(
396 'ID' => $activity['id'],
397 'NAME' => $activity['name'],
398 'MODULE' => $activity['module'],
399 'CONTACT_NAME' => $activity['contact_name'],
400 'CONTACT_ID' => $activity['contact_id'],
401 'PARENT_TYPE' => $activity['parent_type'],
402 'PARENT_NAME' => $activity['parent_name'],
403 'PARENT_ID' => $activity['parent_id'],
404 'DATE' => $activity['date_modified'],
406 if (empty($activity['direction'])) {
407 $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
410 $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']].' '.$app_list_strings['activity_dom'][$activity['type']];
413 switch ($activity['type']) {
415 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
418 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
421 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
425 if (isset($activity['location'])) $activity_fields['LOCATION'] = $activity['location'];
426 if (isset($activity['filename'])) {
427 $activity_fields['ATTACHMENT'] = "<a href='".$activity['fileurl']."' target='_blank'>".SugarThemeRegistry::current()->getImage("attachment","border='0' align='absmiddle'",null,null,'.gif',$activity['filename'])."</a>";
430 if (isset($activity['parent_type'])) $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
432 $xtpl->assign("ACTIVITY", $activity_fields);
433 $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'].'','border="0"', null,null,'.gif',$activity_fields['NAME']));
437 //todo move to themes
438 $xtpl->assign("ROW_COLOR", 'oddListRow');
439 $xtpl->assign("BG_COLOR", $odd_bg);
443 //todo move to themes
444 $xtpl->assign("ROW_COLOR", 'evenListRow');
445 $xtpl->assign("BG_COLOR", $even_bg);
449 $xtpl->parse("history.row");
453 $xtpl->parse("history");
454 $xtpl->out("history");