public static function crm_event_get($id) { if (!is_array($id)) { $r = Utils_RecordBrowserCommon::get_record('task', $id); } else { $r = $id; $id = $r['id']; } $r = Utils_RecordBrowserCommon::filter_record_by_access('task', $r); if (!$r) { return null; } $next = array('type' => __('Task')); $day = $r['deadline']; $iday = strtotime($day); $next['id'] = $r['id']; $base_unix_time = strtotime(date('1970-01-01 00:00:00')); $next['start'] = $iday; $next['timeless'] = $day; $next['duration'] = -1; $next['title'] = (string) $r['title']; $next['description'] = (string) $r['description']; $next['color'] = 'gray'; if ($r['status'] == 0 || $r['status'] == 1) { switch ($r['priority']) { case 0: $next['color'] = 'green'; break; case 1: $next['color'] = 'yellow'; break; case 2: $next['color'] = 'red'; break; } } if ($r['status'] == 2) { $next['color'] = 'blue'; } if ($r['status'] == 3) { $next['color'] = 'gray'; } $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'view'); if (Utils_RecordBrowserCommon::get_access('task', 'edit', $r) !== false) { $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'edit'); } else { $next['edit_action'] = false; $next['move_action'] = false; } if (Utils_RecordBrowserCommon::get_access('task', 'delete', $r) == false) { $next['delete_action'] = false; } /* $r_new = $r; if ($r['status']==0) $r_new['status'] = 1; if ($r['status']<=1) $next['actions'] = array( array('icon'=>Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href'=>self::get_status_change_leightbox_href($r_new, false, array('id'=>'status'))) );*/ $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, false); $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, false); $inf2 = array(__('Date') => '<b>' . $event_date . '</b>'); $emps = array(); foreach ($r['employees'] as $e) { $e = CRM_ContactsCommon::contact_format_no_company($e, true); $e = str_replace(' ', ' ', $e); if (mb_strlen($e, 'UTF-8') > 33) { $e = mb_substr($e, 0, 30, 'UTF-8') . '...'; } $emps[] = $e; } $next['busy_label'] = $r['employees']; $cuss = array(); foreach ($r['customers'] as $c) { $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers')); $cuss[] = str_replace(' ', ' ', $c); } $inf2 += array(__('Task') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('task/' . $r['id'])); $next['employees'] = $r['employees']; $next['customers'] = $r['customers']; $next['status'] = $r['status'] <= 2 ? 'active' : 'closed'; $next['custom_tooltip'] = '<center><b>' . __('Task') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null); return $next; }
public static function crm_event_get($id, $day = null) { if (!is_array($id)) { $id = explode('_', $id); if (isset($id[1]) && $day === null) { $day = $id[1]; } $id = reset($id); $r = Utils_RecordBrowserCommon::get_record('crm_meeting', $id); } else { $r = $id; $id = $r['id']; } $r = Utils_RecordBrowserCommon::filter_record_by_access('crm_meeting', $r); if ($r === false) { return null; } $next = array('type' => __('Meeting')); // if ($r['duration']!=-1) { // $r['date'] = Base_RegionalSettingsCommon::time2reg($r['date'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false); // $r['recurrence_end'] = Base_RegionalSettingsCommon::time2reg($r['recurrence_end'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false); // } if ($day === null) { $day = $r['date']; $iday = strtotime($day); $next['id'] = $r['id']; } else { $iday = strtotime($day); if ($day < $r['date']) { return null; } if ($r['recurrence_end'] && $day > $r['recurrence_end']) { return null; } if ($r['recurrence_type'] <= 7 && $r['recurrence_type'] > 0) { $diff = round(($iday - strtotime($r['date'])) / (3600 * 24)); if ($diff < 0 || $diff % $r['recurrence_type'] != 0) { return null; } } if ($r['recurrence_type'] == 8) { if (isset($r['recurrence_hash'][date('N', $iday) - 1]) && !$r['recurrence_hash'][date('N', $iday) - 1]) { return null; } } if ($r['recurrence_type'] == 9) { $diff = round(($iday - strtotime($r['date'])) / (3600 * 24)); if ($diff < 0 || $diff % 14 != 0) { return null; } } if ($r['recurrence_type'] == 10) { $numdays = date('t', $iday); $cday = date('d', $iday); $tday = date('d', strtotime($r['date'])); if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) { return null; } } if ($r['recurrence_type'] == 11) { $cmonth = date('m', $iday); $tmonth = date('m', strtotime($r['date'])); if ($cmonth != $tmonth) { return null; } $numdays = date('t', $iday); $cday = date('d', $iday); $tday = date('d', strtotime($r['date'])); if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) { return null; } } $next['id'] = $r['id']; } if ($r['recurrence_type'] > 0) { $next['id'] = $r['id'] . '_' . $day; } $base_unix_time = strtotime(date('1970-01-01 00:00:00')); // $next['start'] = Base_RegionalSettingsCommon::reg2time(Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])), true, false, true, false)); // $next['end'] = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$iday).' '.Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])+$r['duration']), true, false, true, false)); $next['start'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time'])); $next['end'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time']) + $r['duration']); $next['start'] = strtotime($next['start']); $next['end'] = strtotime($next['end']); if ($r['duration'] == -1) { $next['timeless'] = $day; } $next['duration'] = intval($r['duration']); $next['title'] = (string) $r['title']; $next['description'] = (string) $r['description']; $next['color'] = 'gray'; if ($r['status'] == 0 || $r['status'] == 1) { switch ($r['priority']) { case 0: $next['color'] = 'green'; break; case 1: $next['color'] = 'yellow'; break; case 2: $next['color'] = 'red'; break; } } if ($r['status'] == 2) { $next['color'] = 'blue'; } if ($r['status'] == 3) { $next['color'] = 'gray'; } if ($r['recurrence_type']) { $next['title'] = '<img src="' . Base_ThemeCommon::get_template_file('CRM_Calendar_Event', 'recurrence.png') . '" border=0 hspace=0 vspace=0 align=left>' . $next['title']; } $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'view', array('day' => $day)); if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'edit', $r) !== false) { $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'edit'); if ($r['status'] <= 1) { $r_new = $r; if ($r['status'] == 0) { $r_new['status'] = 1; } $next['actions'] = array(array('icon' => Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href' => self::get_status_change_leightbox_href($r_new, false, array('id' => 'status')))); } } else { $next['edit_action'] = false; $next['move_action'] = false; } if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'delete', $r) == false) { $next['delete_action'] = false; } $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, $r['duration'] != -1); $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, $r['duration'] != -1); $end_time = Base_RegionalSettingsCommon::time2reg($next['end'], 2, false, $r['duration'] != -1); $inf2 = array(__('Date') => '<b>' . $event_date . '</b>'); if ($r['duration'] == -1) { $inf2 += array(__('Time') => __('Timeless event')); } else { $inf2 += array(__('Time') => $start_time . ' - ' . $end_time, __('Duration') => Base_RegionalSettingsCommon::seconds_to_words($r['duration'])); } $emps = array(); foreach ($r['employees'] as $e) { $e = CRM_ContactsCommon::contact_format_no_company($e, true); $e = str_replace(' ', ' ', $e); if (mb_strlen($e, 'UTF-8') > 33) { $e = mb_substr($e, 0, 30, 'UTF-8') . '...'; } $emps[] = $e; } $next['busy_label'] = $r['employees']; $cuss = array(); foreach ($r['customers'] as $c) { $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers')); $cuss[] = str_replace(' ', ' ', $c); } $inf2 += array(__('Event') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('crm_meeting/' . $r['id'])); // $next['employees'] = implode('<br>',$emps); // $next['customers'] = implode('<br>',$cuss); $next['employees'] = $r['employees']; $next['customers'] = $r['customers']; $next['status'] = $r['status'] <= 2 ? 'active' : 'closed'; $next['custom_tooltip'] = '<center><b>' . __('Meeting') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null); return $next; }