I have a problem why i install the SalesOpportunity module no activities addon? under the activities addon have task and phonecall function. I need this two function.
public function activities_addon($r) {
$gb = $this->init_module('Utils_GenericBrowser',null,'activities_addon');
$gb->set_table_columns(array(
array('name'=>'Type', 'width'=>3),
array('name'=>'Title', 'width'=>9),
array('name'=>'Employees', 'width'=>9),
array('name'=>'Date/Deadline', 'width'=>9)
));
$inc_task = (ModuleManager::is_installed('CRM_Task')>=0);
$inc_meeting = (ModuleManager::is_installed('CRM_Meeting')>=0);
$inc_phonecall = (ModuleManager::is_installed('CRM_PhoneCall')>=0);
$count = 0;
if ($inc_task) $count += $count_tasks = Utils_RecordBrowserCommon::get_records_count('task', array('opportunity'=>$r['id']));
if ($inc_phonecall) $count += $count_phonecalls = Utils_RecordBrowserCommon::get_records_count('phonecall', array('opportunity'=>$r['id']));
if ($inc_meeting) $count += $count_meetings = Utils_RecordBrowserCommon::get_records_count('crm_meeting', array('opportunity'=>$r['id']));
$limit = $gb->get_limit($count);
$rec_limit = array('numrows'=>$limit['offset']+$limit['numrows'], 'offset'=>0);
$tasks = array();
$phonecalls = array();
$meetings = array();
if ($inc_task) $tasks = Utils_RecordBrowserCommon::get_records('task', array('opportunity'=>$r['id']), array(), array('deadline'=>'DESC'));
if ($inc_phonecall) $phonecalls = Utils_RecordBrowserCommon::get_records('phonecall', array('opportunity'=>$r['id']), array(), array('date_and_time'=>'DESC'));
if ($inc_meeting) $meetings = Utils_RecordBrowserCommon::get_records('crm_meeting', array('opportunity'=>$r['id']), array(), array('date'=>'DESC', 'time'=>'DESC'));
$activities = array();
$count = 0;
while ($count<$rec_limit['numrows']) {
$task = reset($tasks);
$phonecall = reset($phonecalls);
$meeting = reset($meetings);
if ($task) $task_tstamp = intval(strtotime($task['deadline']));
else $task_tstamp = -1;
if ($phonecall) $phonecall_tstamp = strtotime($phonecall['date_and_time']);
else $phonecall_tstamp = -1;
if ($meeting) $meeting_tstamp = strtotime($meeting['date'].' '.date('H:i:s',strtotime($meeting['time'])));
else $meeting_tstamp = -1;
if (!$task && !$meeting && !$phonecall) break;
$pick = 'task';
if ($phonecall_tstamp>$task_tstamp) $pick = 'phonecall';
if ($meeting_tstamp>$task_tstamp && $meeting_tstamp>$phonecall_tstamp) $pick = 'meeting';
switch ($pick) {
case 'task':
$task = array_shift($tasks);
$arr = array(
'Task',
CRM_TasksCommon::display_title($task,false),
CRM_ContactsCommon::display_contact(array('emp'=>$task['employees']),false,array('id'=>'emp','param'=>';CRM_ContactsCommon::contact_format_no_company')),
$task['deadline']?Base_RegionalSettingsCommon::time2reg($task['deadline'],false,true,false):'---'
);
$tab = 'task';
$id = $task['id'];
break;
case 'phonecall':
$phonecall = array_shift($phonecalls);
$arr = array(
'Phonecall',
CRM_PhoneCallCommon::display_subject($phonecall),
CRM_ContactsCommon::display_contact(array('emp'=>$phonecall['employees']),false,array('id'=>'emp','param'=>';CRM_ContactsCommon::contact_format_no_company')),
Base_RegionalSettingsCommon::time2reg($phonecall['date_and_time'], 'without_seconds',true,false)
);
$tab = 'phonecall';
$id = $phonecall['id'];
break;
case 'meeting':
$meeting = array_shift($meetings);
$arr = array(
'Meeting',
CRM_MeetingCommon::display_title($meeting),
CRM_ContactsCommon::display_contact(array('emp'=>$meeting['employees']),false,array('id'=>'emp','param'=>';CRM_ContactsCommon::contact_format_no_company')),
Base_RegionalSettingsCommon::time2reg($meeting_tstamp, 'without_seconds')
);
$tab = 'crm_meeting';
$id = $meeting['id'];
break;
default:
$arr = array(
'Error',
$pick,
serialize($$pick),
''
);
}
if ($count>=$limit['offset']) {
$gb_row = $gb->get_new_row();
$gb_row->add_data_array($arr);
$gb_row->add_action(Utils_RecordBrowserCommon::create_record_href($tab, $id, 'view'), 'View');
$gb_row->add_action(Utils_RecordBrowserCommon::create_record_href($tab, $id, 'edit'), 'Edit');
}
$count++;
}
$this->display_module($gb);
}
This code is activities addon? This is the original code. I never modify.
Can someone help me solve this problem please, my SalesOpportunity module no activities addon and task and phonecall fucntion.
Thanks