示例#1
0
 public function body($args = array())
 {
     $ev_mod = $this->init_module(CRM_Calendar_Event::module_name());
     $ev_mod->help('Calendar Help', 'main');
     if (isset($_REQUEST['search_date']) && is_numeric($_REQUEST['search_date']) && isset($_REQUEST['ev_id']) && is_numeric($_REQUEST['ev_id'])) {
         $default_date = intval($_REQUEST['search_date']);
         $this->view_event(intval($_REQUEST['ev_id']));
     } else {
         $default_date = null;
     }
     $handlers = DB::GetAll('SELECT id, group_name, handler_callback FROM crm_calendar_custom_events_handlers');
     $this->lp = $this->init_module('Utils_LeightboxPrompt');
     $count = 0;
     foreach ($handlers as $v) {
         $callback = explode('::', $v['handler_callback']);
         if (!is_callable($callback)) {
             continue;
         }
         $new_events = call_user_func($callback, 'new_event_types');
         if ($new_events !== null) {
             foreach ($new_events as $k => $w) {
                 if (!is_array($w)) {
                     $w = array('label' => $w, 'icon' => null);
                 }
                 $this->lp->add_option('new_event__' . $v['id'] . '__' . $k, $w['label'], $w['icon'], null);
                 $count++;
             }
         }
     }
     if ($count < 2) {
         $this->lp = null;
     } else {
         $this->display_module($this->lp, array(__('New Event'), array('timestamp', 'timeless'), '', false));
         $vals = $this->lp->export_values();
         if ($vals) {
             $this->jump_to_new_event($vals['option'], $vals['params']['timestamp'], $vals['params']['timeless']);
             return;
         }
     }
     CRM_Calendar_EventCommon::$filter = CRM_FiltersCommon::get();
     $args_defaults = array('default_view' => Base_User_SettingsCommon::get('CRM_Calendar', 'default_view'), 'first_day_of_week' => Utils_PopupCalendarCommon::get_first_day_of_week(), 'start_day' => Base_User_SettingsCommon::get('CRM_Calendar', 'start_day'), 'end_day' => Base_User_SettingsCommon::get('CRM_Calendar', 'end_day'), 'interval' => Base_User_SettingsCommon::get('CRM_Calendar', 'interval'), 'default_date' => $default_date, 'custom_agenda_cols' => array(array('name' => __('Type'), 'order' => 'cus_col_0', 'width' => 6, 'wrapmode' => 'nowrap'), __('Description'), __('Assigned to'), __('Related with')));
     foreach ($args_defaults as $k => $v) {
         if (!isset($args[$k])) {
             $args[$k] = $args_defaults[$k];
         }
     }
     if (isset($_REQUEST['jump_to_date']) && is_numeric($_REQUEST['jump_to_date']) && isset($_REQUEST['switch_to_tab']) && is_string($_REQUEST['switch_to_tab'])) {
         $args['default_date'] = $_REQUEST['jump_to_date'];
         $args['default_view'] = $_REQUEST['switch_to_tab'];
     }
     $theme = $this->init_module(Base_Theme::module_name());
     $c = $this->init_module(Utils_Calendar::module_name(), array(CRM_Calendar_Event::module_name(), $args, array($this, 'get_new_event_href_js')));
     $view_type = $c->get_current_view();
     CRM_CalendarCommon::$mode = $view_type;
     $theme->assign('calendar', $this->get_html_of_module($c));
     $theme->display();
     $events = $c->get_displayed_events();
     if (!empty($events['events'])) {
         switch ($view_type) {
             case 'Day':
                 $view = __('Daily agenda');
                 break;
             case 'Month':
                 $view = __('Monthly agenda');
                 break;
             case 'Week':
                 $view = __('Weekly agenda');
                 break;
             case 'Agenda':
                 $view = __('Agenda');
                 break;
         }
         if (isset($view)) {
             $pdf = $this->pack_module(Libs_TCPDF::module_name(), null, null, 'L');
             if ($pdf->prepare()) {
                 set_time_limit(0);
                 $start = date('d F Y', Base_RegionalSettingsCommon::reg2time($events['start']));
                 $end = date('d F Y', Base_RegionalSettingsCommon::reg2time($events['end']));
                 $pdf->set_title($view . ', ' . $start . ($view_type != 'Day' ? ' - ' . $end : ''));
                 $filter = CRM_FiltersCommon::get();
                 $me = CRM_ContactsCommon::get_my_record();
                 if (trim($filter, '()') == $me['id']) {
                     $desc = $me['last_name'] . ' ' . $me['first_name'];
                 } else {
                     $desc = CRM_FiltersCommon::get_profile_desc();
                 }
                 $pdf->set_subject(__('CRM Filters: %s', array($desc)));
                 $pdf->prepare_header();
                 $pdf->AddPage();
                 foreach ($events['events'] as $v) {
                     $ev_mod->make_event_PDF($pdf, $v, true, $view_type);
                 }
             }
             $pdf->add_actionbar_icon($view);
         }
     }
 }
示例#2
0
 public function body()
 {
     $c = $this->init_module(Utils_Calendar::module_name(), array('Tests/Calendar/Event', array('default_view' => 'month', 'first_day_of_week' => 1)));
     $this->display_module($c);
 }