retrieve($_REQUEST['record']); if($result == null) { sugar_die($app_strings['ERROR_NO_RECORD']); } } $activitiesRels = array('tasks' => 'Task', 'meetings' => 'Meeting', 'calls' => 'Call', 'emails' => 'Email', 'notes' => 'Note'); //Setup the arrays to store the linked records. foreach($activitiesRels as $relMod => $beanName) { $varname = "focus_" . $relMod . "_list"; $$varname = array(); } foreach($focus->get_linked_fields() as $field => $def) { if ($focus->load_relationship($field)) { $relTable = $focus->$field->getRelatedTableName(); if (in_array($relTable, array_keys($activitiesRels))) { $varname = "focus_" . $relTable . "_list"; $$varname = sugarArrayMerge($$varname, $focus->get_linked_beans($field,$activitiesRels[$relTable])); } } } foreach ($focus_tasks_list as $task) { $sort_date_time=''; if (empty($task->date_due) || $task->date_due == '0000-00-00') { $date_due = ''; } else { $date_due = $task->date_due; } if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") { $history_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_modified' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE'], 'sort_value' => strtotime($task->fetched_row['date_due'].' GMT'), ); } else { $open_activity_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_due' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE'] ); } } // end Tasks foreach ($focus_meetings_list as $meeting) { if (empty($meeting->contact_id) && empty($meeting->contact_name)) { $meeting_contacts = $meeting->get_linked_beans('contacts','Contact'); if (!empty($meeting_contacts[0]->id) && !empty($meeting_contacts[0]->name)) { $meeting->contact_id = $meeting_contacts[0]->id; $meeting->contact_name = $meeting_contacts[0]->name; } } if ($meeting->status != "Planned") { $history_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_modified' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => strtotime($meeting->fetched_row['date_start'].' GMT'), ); } else { $open_activity_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_due' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START'] ); } } // end Meetings foreach ($focus_calls_list as $call) { if (empty($call->contact_id) && empty($call->contact_name)) { $call_contacts = $call->get_linked_beans('contacts','Contact'); if (!empty($call_contacts[0]->id) && !empty($call_contacts[0]->name)) { $call->contact_id = $call_contacts[0]->id; $call->contact_name = $call_contacts[0]->name; } } if ($call->status != "Planned") { $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => strtotime($call->fetched_row['date_start'].' GMT'), ); } else { $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START'] ); } } // end Calls foreach ($focus_emails_list as $email) { if (empty($email->contact_id) && empty($email->contact_name)) { $email_contacts = $email->get_linked_beans('contacts','Contact'); if (!empty($email_contacts[0]->id) && !empty($email_contacts[0]->name)) { $email->contact_id = $email_contacts[0]->id; $email->contact_name = $email_contacts[0]->name; } } $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start." ".$email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => strtotime($email->fetched_row['date_sent'].' GMT'), ); } //end Emails foreach ($focus_notes_list as $note) { $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified, 'description' => $this->formatDescription($note->description), 'date_type' => $app_strings['DATA_TYPE_MODIFIED'], 'sort_value' => strtotime($note->fetched_row['date_modified'].' GMT'), ); if(!empty($note->filename)) { $count = count($history_list); $count--; $history_list[$count]['filename'] = $note->filename; $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename,$note->id); } } // end Notes $xtpl=new XTemplate ('modules/Activities/Popup_picker.html'); $xtpl->assign('MOD', $mod_strings); $xtpl->assign('APP', $app_strings); insert_popup_header(); //output header echo "
"; echo getClassicModuleTitle($focus->module_dir, array(translate('LBL_MODULE_NAME', $focus->module_dir),$focus->name), false); echo ""; echo "".$app_strings[ ".$app_strings['LNK_PRINT']."\n"; echo "
"; $oddRow = true; if (count($history_list) > 0) $history_list = array_csort($history_list, 'sort_value', SORT_DESC); foreach($history_list as $activity) { $activity_fields = array( 'ID' => $activity['id'], 'NAME' => $activity['name'], 'MODULE' => $activity['module'], 'CONTACT_NAME' => $activity['contact_name'], 'CONTACT_ID' => $activity['contact_id'], 'PARENT_TYPE' => $activity['parent_type'], 'PARENT_NAME' => $activity['parent_name'], 'PARENT_ID' => $activity['parent_id'], 'DATE' => $activity['date_modified'], 'DESCRIPTION' => $activity['description'], 'DATE_TYPE' => $activity['date_type'] ); if (empty($activity['direction'])) { $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']]; } else { $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']].' '.$app_list_strings['activity_dom'][$activity['type']]; } switch ($activity['type']) { case 'Call': $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']]; break; case 'Meeting': $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']]; break; case 'Task': $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']]; break; } if (isset($activity['location'])) $activity_fields['LOCATION'] = $activity['location']; if (isset($activity['filename'])) { $activity_fields['ATTACHMENT'] = "".SugarThemeRegistry::current()->getImage("attachment","alt='".$activity['filename']."' border='0' align='absmiddle'").""; } if (isset($activity['parent_type'])) $activity_fields['PARENT_MODULE'] = $activity['parent_type']; $xtpl->assign("ACTIVITY", $activity_fields); $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'].'','border="0" alt="'.$activity_fields['NAME'].'"')); if($oddRow) { //todo move to themes $xtpl->assign("ROW_COLOR", 'oddListRow'); $xtpl->assign("BG_COLOR", $odd_bg); } else { //todo move to themes $xtpl->assign("ROW_COLOR", 'evenListRow'); $xtpl->assign("BG_COLOR", $even_bg); } $oddRow = !$oddRow; if(!empty($activity_fields['DESCRIPTION'])) { $xtpl->parse("history.row.description"); } $xtpl->parse("history.row"); // Put the rows in. } $xtpl->parse("history"); $xtpl->out("history"); insert_popup_footer(); } function getEmailDetails($email){ $details = ""; if(!empty($email->to_addrs)){ $details .= "To: ".$email->to_addrs."
"; } if(!empty($email->from_addr)){ $details .= "From: ".$email->from_addr."
"; } if(!empty($email->cc_addrs)){ $details .= "CC: ".$email->cc_addrs."
"; } if(!empty($email->from_addr) || !empty($email->cc_addrs) || !empty($email->to_addrs)){ $details .= "
"; } // cn: bug 8433 - history does not distinguish b/t text/html emails $details .= empty($email->description_html) ? $this->formatDescription($email->description) : $this->formatDescription(strip_tags(br2nl(from_html($email->description_html)))); return $details; } function getTaskDetails($task){ global $app_strings; $details = ""; if (!empty($task->date_start) && $task->date_start != '0000-00-00') { $details .= $app_strings['DATA_TYPE_START'].$task->date_start."
"; $details .= "
"; } $details .= $this->formatDescription($task->description); return $details; } function formatDescription($description){ return nl2br($description); } } // end of class Popup_Picker ?>