public function applet($conf, &$opts) { $opts['go'] = false; $this->date = $this->get_module_variable_or_unique_href_variable('date'); if ($this->date == null) { $this->date = date('Y-m-15'); } $this->set_module_variable('date', $this->date); $this->date = strtotime($this->date); $theme = $this->pack_module('Base/Theme'); $theme->assign('nextyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date + 30 * 24 * 60 * 60)))); $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d')))); $theme->assign('prevyear_href', $this->create_unique_href(array('date' => date('Y-m-15', $this->date - 30 * 24 * 60 * 60)))); $link_text = $this->create_unique_href_js(array('date' => '__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'month', null, null, '')); $day_headers = array(); $day = strtotime('Sun'); $day = strtotime('+' . Utils_PopupCalendarCommon::get_first_day_of_week() . ' days', $day); for ($i = 0; $i < 7; $i++) { $day_headers[] = __date('D', $day); $day = strtotime('+1 day', $day); } $year = array(); $me = CRM_ContactsCommon::get_my_record(); CRM_Calendar_EventCommon::$filter = '(' . $me['id'] . ')'; $ret = call_user_func(array('CRM_Calendar_EventCommon', 'get_event_days'), date('Y-m-01', $this->date), date('Y-m-d', strtotime(date('Y-m-t', $this->date)) + 86400)); $month = $this->month_array($this->date, $ret); $year[] = array('month' => $month, 'month_link' => Base_BoxCommon::create_href($this, 'CRM_Calendar', null, null, null, array('jump_to_date' => $this->date, 'switch_to_tab' => 'Month')), 'month_label' => __date('F', $this->date), 'year_label' => date('Y', $this->date)); $theme->assign('year', $year); $theme->assign('day_headers', $day_headers); $theme->display('year'); }
public function applet($conf, &$opts) { $opts['go'] = true; $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agendaX'); $columns = array(array('name' => __('Start'), 'order' => 'e.starts', 'width' => 25, 'wrapmode' => 'nowrap'), array('name' => __('Title'), 'order' => 'e.title', 'width' => 50)); $gb->set_table_columns($columns); $start = date('Y-m-d', time()); $end = date('Y-m-d', time() + $conf['days'] * 24 * 60 * 60); $gb->set_default_order(array(__('Start') => 'ASC')); CRM_Calendar_EventCommon::$filter = '(' . CRM_FiltersCommon::get_my_profile() . ')'; $data = array(); Base_ThemeCommon::load_css('CRM_Calendar', 'agenda'); $custom_events = DB::GetAssoc('SELECT id, handler_callback FROM crm_calendar_custom_events_handlers ORDER BY group_name'); $ret = array(); if (!empty($custom_events)) { $c = 0; foreach ($custom_events as $id => $cb) { if ($conf['events_handlers__' . $id]) { $cb = explode('::', $cb); if (!is_callable($cb)) { continue; } $add = call_user_func($cb, 'get_all', $start, $end, CRM_Calendar_EventCommon::$filter); foreach ($add as $v) { $ret[str_pad($v['start'], 16, '0', STR_PAD_LEFT) . '__' . $c] = $v; $c++; } } } } ksort($ret); foreach ($ret as $row) { if (isset($row['status']) && $row['status'] == 'closed') { continue; } if (!isset($row['view_action'])) { $ex = Utils_CalendarCommon::process_event($row); $view_action = '<a ' . $this->create_callback_href(array($this, 'view_event'), $row['id']) . '>'; $ev_id = explode('_', $row['id'], 2); $ev_id = $ev_id[0]; } else { $tmp = Utils_CalendarCommon::process_event($row); $ex = $row; $ex['start'] = $tmp['start']; $view_action = '<a ' . $row['view_action'] . '>'; } ////////////////////////// // left column $date = $ex['start']; /////////////////// // right column $title = Utils_TooltipCommon::create($row['title'], $row['custom_tooltip']); $day = isset($row['timeless']) && $row['timeless'] ? $row['timeless'] : Base_RegionalSettingsCommon::time2reg($row['start'], false, true, true, false); if ($day < date('Y-m-d')) { $class = 'past'; } elseif ($day == date('Y-m-d')) { $class = 'today'; } elseif ($day == date('Y-m-d', strtotime('+1 day'))) { $class = 'tomorrow'; } else { $class = 'other'; } $gb_row = $gb->get_new_row(); $gb_row->set_attrs('class="CRM_Calendar_applet__' . $class . '"'); $gb_row->add_data(array('value' => $date, 'order_value' => isset($row['timeless']) && $row['timeless'] ? strtotime($row['timeless']) : $row['start']), array('value' => $view_action . $title . '</a>')); } $this->display_module($gb, array(false), 'automatic_display'); }
public static function mobile_agenda($time_shift = 0) { print '<center>' . Base_RegionalSettingsCommon::time2reg(time() + $time_shift, false, true) . ' - ' . Base_RegionalSettingsCommon::time2reg(time() + 7 * 24 * 3600 + $time_shift, false, true) . '</center>'; CRM_Calendar_EventCommon::$filter = CRM_FiltersCommon::get(); if ($time_shift) { print '<a ' . (IPHONE ? 'class="button red" ' : '') . mobile_stack_href(array('CRM_CalendarCommon', 'mobile_agenda'), array(0)) . '>' . __('Show current week') . '</a>'; } else { print '<a ' . (IPHONE ? 'class="button green" ' : '') . mobile_stack_href(array('CRM_CalendarCommon', 'mobile_agenda'), array(7 * 24 * 60 * 60)) . '>' . __('Show next week') . '</a>'; } Utils_CalendarCommon::mobile_agenda(CRM_Calendar_Event::module_name(), array('custom_agenda_cols' => array(__('Description'), __('Assigned to'), __('Related with'))), $time_shift, array('CRM_CalendarCommon', 'mobile_view_event')); }