public function admin() { if ($this->is_back()) { if ($this->parent->get_type() == 'Base_Admin') { $this->parent->reset(); } else { location(array()); } return; } $form = $this->init_module(Libs_QuickForm::module_name(), 'Changing template'); $themes = Base_Theme::list_themes(); $form->addElement('header', 'install_module_header', __('Themes Administration')); $form->addElement('select', 'theme', __('Choose template'), $themes); $form->addElement('static', null, '', '<br /><br />'); $form->addElement('header', 'upload_theme_header', __('Upload template')); $form->setDefaults(array('theme' => Variable::get('default_theme'))); if ($form->validate()) { $form->process(array(&$this, 'submit_admin')); } else { $form->display(); if (class_exists('ZipArchive')) { $this->pack_module(Utils_FileUpload::module_name(), array(array($this, 'upload_template'), __('Upload template'))); // Base_ActionBarCommon::add('edit',__('Manage templates'),$this->create_callback_href(array($this,'download_template'))); } } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); }
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::module_name()); $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'); }
/** * For internal use only. */ public function construct() { $this->set_inline_display(); if (!isset(self::$theme)) { self::$theme = Base_ThemeCommon::get_default_template(); } $this->smarty = Base_ThemeCommon::init_smarty(); }
public function contact_activities($me) { $this->theme = $this->pack_module(Base_Theme::module_name()); $this->filters(); $this->theme->display(); $events = null; $tasks = null; $phonecalls = null; $date_filter = ''; // if ($this->activities_date==0) $date_filter = ' cce.starts>'.Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00')).' AND'; // if ($this->activities_date==1) $date_filter = ' cce.ends<'.Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00')).' AND'; if ($this->display['events']) { //$events = DB::GetAll('SELECT * FROM crm_calendar_event AS cce WHERE cce.deleted=0 AND'.$date_filter.(!$this->display['closed']?' cce.status<2 AND':'').' (EXISTS (SELECT contact FROM crm_calendar_event_group_emp AS ccegp WHERE ccegp.id=cce.id AND contact=%d) OR EXISTS (SELECT contact FROM crm_calendar_event_group_cus AS ccegc WHERE ccegc.id=cce.id AND contact=%d)) ORDER BY starts DESC', array($me['id'], $me['id'])); if ($this->activities_date == 0) { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s'), date('Y-m-d H:i:s', time() + 10 * 365 * 24 * 3600), '(' . $me['id'] . ')', array('P:' . $me['id'])); } elseif ($this->activities_date == 1) { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s', 0), date('Y-m-d H:i:s'), '(' . $me['id'] . ')', array('P:' . $me['id'])); } else { $events = CRM_MeetingCommon::crm_event_get_all(date('Y-m-d H:i:s', 0), date('Y-m-d H:i:s', time() + 10 * 365 * 24 * 3600), '(' . $me['id'] . ')', array('P:' . $me['id'])); } } $crits = array('(employees' => $me['id'], '|customers' => 'P:' . $me['id']); if ($this->activities_date == 0) { $crits['(>=deadline'] = date('Y-m-d'); $crits['|deadline'] = ''; } if ($this->activities_date == 1) { $crits['(<deadline'] = date('Y-m-d'); $crits['|deadline'] = ''; } if (!$this->display['closed']) { $crits['!status'] = array(2, 3); } if ($this->display['tasks']) { $tasks = CRM_TasksCommon::get_tasks($crits, array(), array('deadline' => 'DESC')); } $crits = array('(employees' => $me['id'], '|customer' => 'P:' . $me['id']); if ($this->activities_date == 0) { $crits['>=date_and_time'] = date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00'))); } if ($this->activities_date == 1) { $crits['<date_and_time'] = date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time(date('Y-m-d 0:00:00'))); } if (!$this->display['closed']) { $crits['!status'] = array(2, 3); } if ($this->display['phonecalls']) { $phonecalls = CRM_PhoneCallCommon::get_phonecalls($crits, array(), array('date_and_time' => 'DESC')); } $this->display_activities($events, $tasks, $phonecalls); }
public function admin() { if ($this->is_back()) { $this->parent->reset(); } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $theme = $this->init_module(Base_Theme::module_name()); $new_token_href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'new_token')); $theme->assign('new_token_href', $new_token_href); $theme->assign('wiki_url', 'http://www.epesi.org/Cron'); $theme->assign('cron_url', Base_CronCommon::get_cron_url()); $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'cron'); $m->set_table_columns(array(array('name' => 'Description', 'width' => 65), array('name' => 'Last Run', 'width' => 20), array('name' => 'Running', 'width' => 15))); $ret = DB::Execute('SELECT description,last,running FROM cron ORDER BY last DESC'); while ($row = $ret->FetchRow()) { $m->add_row($row['description'] ? $row['description'] : '???', $row['last'] ? Base_RegionalSettingsCommon::time2reg($row['last']) : '---', $row['running'] ? '<span style="color:red">' . __('Yes') . '</span>' : '<span style="color:green">' . __('No') . '</span>'); } $html = $this->get_html_of_module($m); $theme->assign('history', $html); $theme->display(); }
/** * Displays and processes post replying form. */ public function post_reply() { if ($this->is_back()) { $this->unset_module_variable('action'); $this->unset_module_variable('answer'); location(array()); } $form = $this->init_module(Libs_QuickForm::module_name(), __('Posting reply')); $theme = $this->init_module(Base_Theme::module_name()); if ($this->tree_structure) { $answer = $this->get_module_variable_or_unique_href_variable('answer', -1); $this->set_module_variable('answer', $answer); } else { $answer = -1; } $form->addElement('hidden', 'comment_content', 'none'); if ($answer != -1) { $comment_info = DB::Execute('SELECT c.id, c.text, ul.login, c.created_on FROM comment AS c LEFT JOIN user_login AS ul ON (c.user_login_id = ul.id) WHERE c.id = %d ORDER BY created_on', array($answer))->FetchRow(); $form->addElement('header', 'reply', __('Reply to %s\'s comment given at %s', array($comment_info['login'], date('G:i, d M Y', strtotime($comment_info['created_on']))))); } $form->addElement('textarea', 'comment_page_reply', __('Message'), array('rows' => 4, 'cols' => 40)); //,'onBlur'=>'document.getElementsByName(\'comment_content\')[0].value = document.getElementsByName(\'comment_page_reply\')[0].value.replace(/\n/g,\'<br>\');')); $form->addRule('comment_page_reply', __('Field required'), 'required'); $form->addElement('submit', 'submit_comment', __('Submit')); $form->addElement('button', 'cancel_comment', __('Cancel'), $this->create_back_href()); if ($form->validate() && $this->reply) { $this->add_post($form->exportValue('comment_page_reply'), $answer); $this->unset_module_variable('answer'); $this->unset_module_variable('action'); $answer = -1; location(array()); } else { $form->assign_theme('form', $theme); $theme->assign('required', '<span align=top size=4 style="color:#FF0000">*</span>'); $theme->assign('required_description', __('Indicates required fields.')); $theme->display('Reply'); } }
/** * Displays wizard current step. * You can also specify function to process the data from all the pages. * * @param method method to process the data */ public function body($func) { $this->next_page(); $this->flush_deleted(); if (!isset($this->displayed) || is_int($this->curr_page) && $this->curr_page >= $this->counter || is_string($this->curr_page) && !isset($this->r_aliases[$this->curr_page])) { if (is_callable($func)) { $args = func_get_args(); $args[0] = $this->data; if (!call_user_func_array($func, $args)) { print '<br><input ' . $this->create_back_href() . ' type="button" value="back">'; } } else { print __('Wizard complete! No more pages to display...'); } } else { $t = $this->init_module(Base_Theme::module_name()); $t->assign('page', $this->displayed); $t->assign('captions', $this->captions); $t->assign('curr_page', $this->curr_page); $keys = array_keys($this->captions); $x = key($this->captions); for ($i = 0; $i < count($keys); $i++) { if ($this->curr_page >= $keys[$i] && (!isset($keys[$i + 1]) || $this->curr_page < $keys[$i + 1])) { $x = $keys[$i]; break; } } $t->assign('active_caption_key', $x); $t->display(); } }
public function login_logo() { $t = $this->pack_module(Base_Theme::module_name()); $l = Variable::get('login_logo_file'); if ($l && file_exists($l)) { $l .= '?' . filemtime($l); } $t->assign('logo', $l); $t->display('login-logo'); }
public function admin() { if (!Base_AclCommon::i_am_sa() || $this->is_back()) { $this->parent->reset(); return; } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $cmr = ModuleManager::call_common_methods('admin_caption'); foreach ($cmr as $name => $caption) { if (!ModuleManager::check_access($name, 'admin') || $name == 'Base_Admin') { continue; } if (!isset($caption)) { continue; } if (!is_array($caption)) { $caption = array('label' => $caption); } if (!isset($caption['section'])) { $caption['section'] = __('Misc'); } $mod_ok[$name] = $caption; } uksort($mod_ok, 'strcasecmp'); $form = $this->init_module('Libs_QuickForm'); $buttons = array(); load_js('modules/Base/Admin/js/main.js'); foreach ($mod_ok as $name => $caption) { if (method_exists($name . 'Common', 'admin_icon')) { $icon = call_user_func(array($name . 'Common', 'admin_icon')); } else { $icon = Base_ThemeCommon::get_template_file($name, 'icon.png'); if (!file_exists($icon)) { $icon = Base_ThemeCommon::get_template_file('Base_Admin', 'icon.png'); } } $button_id = $name . '__button'; $enable_field = $name . '_enable'; $sections = array(); $sections_id = $name . '__sections'; $enable_default = Base_AdminCommon::get_access($name, '', true); $form->addElement('checkbox', $enable_field, $enable_default === null ? __('Access blocked') : __('Allow access'), null, array('onchange' => 'admin_switch_button("' . $button_id . '",this.checked, "' . $sections_id . '");', 'id' => $enable_field, 'style' => $enable_default === null ? 'display:none;' : '')); $form->setDefaults(array($enable_field => $enable_default)); eval_js('admin_switch_button("' . $button_id . '",$("' . $enable_field . '").checked, "' . $sections_id . '", 1);'); if (class_exists($name . 'Common') && is_callable(array($name . 'Common', 'admin_access_levels'))) { $raws = call_user_func(array($name . 'Common', 'admin_access_levels')); if (is_array($raws)) { foreach ($raws as $s => $v) { $type = isset($v['values']) ? 'select' : 'checkbox'; $vals = isset($v['values']) ? $v['values'] : null; $s_field = $name . '__' . $s . '__switch'; $form->addElement($type, $s_field, $v['label'], $vals); $form->setDefaults(array($s_field => Base_AdminCommon::get_access($name, $s, true))); $sections[$s] = $s_field; } } } $buttons[$caption['section']][$name] = array('label' => $caption['label'], 'icon' => $icon, 'id' => $button_id, 'enable_switch' => $enable_field, 'sections_id' => $sections_id, 'sections' => $sections); } if ($form->validate()) { $vals = $form->exportValues(); DB::Execute('DELETE FROM base_admin_access'); foreach ($buttons as $section => $bs) { foreach ($bs as $name => $b) { DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, '', isset($vals[$b['enable_switch']]) && $vals[$b['enable_switch']] ? 1 : 0)); foreach ($b['sections'] as $s => $f) { DB::Execute('INSERT INTO base_admin_access (module, section, allow) VALUES (%s, %s, %d)', array($name, $s, isset($vals[$f]) ? $vals[$f] : 0)); } } } $this->parent->reset(); return; } Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href()); $sections = array(); foreach ($buttons as $section => $b) { $sections[$section] = array('header' => $section, 'buttons' => $b); } $sections = $this->sort_sections($sections); $theme = $this->pack_module(Base_Theme::module_name()); $form->assign_theme('form', $theme); $theme->assign('header', __('Admin Panel Access')); $theme->assign('sections', $sections); $theme->display('access_panel'); }
/** * Displays the module. */ public function body() { $s = $this->print_structure($this->_structure); $expand_all = '<div class=utils_tree_expand_all id=tree_expand_all_' . $this->_id . ' onclick="utils_tree_expand_all(' . $this->_id . ',' . $this->_sub . ')">Expand All</div> '; $collapse_all = '<div class=utils_tree_expand_all id=tree_expand_all_' . $this->_id . ' onclick="utils_tree_collapse_all(' . $this->_id . ',' . $this->_sub . ')">Collapse All</div> '; $theme = $this->init_module(Base_Theme::module_name()); $theme->assign('collapse_all', $collapse_all); $theme->assign('expand_all', $expand_all); $theme->assign('tree', $s); eval_js('utils_tree_reset(' . $this->_id . ')'); foreach ($this->_opened_paths as $path) { $path = explode('_', $path); $path = '[' . join(', ', $path) . ']'; eval_js('utils_tree_open(' . $this->_id . ', ' . $path . ')'); } if ($this->_opened == true) { eval_js('utils_tree_expand_all(' . $this->_id . ',' . $this->_sub . ')'); //eval_js('utils_tree_expand_all('.$this->_id.','.$this->_sub.');'); } $theme->display(); }
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); } } }
/** * Displays tabs. * You can alternatively choose to use different template file for tabs display. * * @param string template file that will be used */ public function body($template = null) { if (empty($this->tabs)) { return; } $theme = $this->init_module(Base_Theme::module_name()); load_js($this->get_module_dir() . 'tb_.js'); $i = 0; if (is_numeric($this->page) && $this->page >= count($this->tabs)) { $this->page = 0; } $this->max = count($this->tabs); $body = ''; $submenus = array(); foreach ($this->tabs as $caption => $val) { if (substr_count($caption, '#') == 1) { list($group, $s_caption) = explode('#', $caption); if (!isset($submenus[$group])) { $submenus[$group] = array(); } $submenus[$group][$s_caption] = $val; $this->tabs[$s_caption] = $val; unset($this->tabs[$caption]); } } foreach ($submenus as $group => $captions) { if (count($captions) == 1) { unset($submenus[$group]); } else { if (isset($this->tabs[$group])) { $submenus[$group][$group] = $this->tabs[$group]; unset($this->tabs[$group]); } foreach ($captions as $caption => $val) { unset($this->tabs[$caption]); } } } $final_captions = array(); foreach ($this->tabs as $caption => $val) { $selected = $this->page === $i || is_string($this->page) && $this->page == $caption; $final_captions[$caption] = $this->get_link($i, $val, $caption); if ($selected || $val['js']) { $body .= $this->display_contents($val, $i, $selected); } $i++; } $captions_subs = array(); foreach ($submenus as $group => $captions) { $selected_c = ' class="tabbed_browser_unselected"'; $subs = array(); foreach ($captions as $caption => $val) { $selected = $this->page === $i || is_string($this->page) && $this->page == $caption; if ($selected) { $selected_c = ' class="tabbed_browser_selected"'; $group = $group . ': ' . $caption; } if ($selected || $val['js']) { $body .= $this->display_contents($val, $i, $selected); } $subs[] = $this->get_link($i, $val, $caption, $group); $i++; } $final_captions[$group] = '<span id="tabbed_browser_submenu_' . $group . '"' . $selected_c . '>' . $group . ' ' . '<img src="' . Base_ThemeCommon::get_template_file('Utils_TabbedBrowser', 'submenu.png') . '">' . '</span>'; $captions_subs[$group] = $subs; } $this->tag = md5($body . $this->page); $theme->assign('selected', $this->page); $theme->assign('captions', $final_captions); $theme->assign('captions_submenus', $captions_subs); $theme->assign('body', $body); $theme->display($template); }
public function quick_access_menu() { $this->set_inline_display(true); // preparing quick access menu if (ModuleManager::is_installed(Base_Menu_QuickAccessCommon::module_name()) >= 0) { $qaccess_menu = Base_Menu_QuickAccessCommon::quick_access_menu(); if (is_array($qaccess_menu)) { Base_MenuCommon::add_default_menu($qaccess_menu, Base_Menu_QuickAccessCommon::module_name()); } else { $qaccess_menu = array(); } } else { $qaccess_menu = array(); } if (empty($qaccess_menu)) { return; } $menu_mod = $this->init_module("Utils/Menu", "horizontal"); $this->build_menu($menu_mod, $qaccess_menu, false); $theme = $this->init_module(Base_Theme::module_name()); $menu_mod->set_inline_display(); $theme->assign('menu', $this->get_html_of_module($menu_mod)); $theme->display(); }
public function queue_tab($count_f, $get_f, $statuses) { $t = time(); $status =& $this->get_module_variable('queue_status', current(array_keys($statuses))); $offset =& $this->get_module_variable('queue_offset', 0); $form = $this->init_module(Libs_QuickForm::module_name()); $theme = $this->pack_module(Base_Theme::module_name()); $form->addElement('select', 'status', __('Status'), $statuses); $form->addElement('submit', 'submit_button', __('Show')); $form->addRule('status', 'Field required', 'required'); $form->setDefaults(array('status' => $status)); if ($form->validate()) { $data = $form->exportValues(); if (array_key_exists($data['status'], $statuses)) { $status = $data['status']; } $offset = 0; } $form->assign_theme('form', $theme); $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'queue'); $m->set_table_columns(array(array('name' => 'To', 'width' => 30, 'order' => 'toNumber'), array('name' => 'Status', 'width' => 10), array('name' => 'Date', 'width' => 10, 'order' => 'creationDate'), array('name' => 'File', 'width' => 30, 'order' => 'fileName'))); $m->set_default_order(array('Date' => 'DESC')); $count = call_user_func($count_f, $status); if ($count === false) { $count = 0; } $limits = $m->get_limit($count); $order = $m->get_order(); if ($count != 0) { $data = call_user_func($get_f, $status, $order[0]['order'], $order[0]['direction'], $limits['numrows'], (string) ($limits['offset'] + 1)); } if ($count == 0 || $data === false) { $data = array(); } foreach ($data as $row) { $from_rec = CRM_ContactsCommon::get_contacts(array('fax' => $row['toNumber'])); foreach ($from_rec as &$rec) { $rec = CRM_ContactsCommon::contact_format_default($rec); } $from_rec_comp = CRM_ContactsCommon::get_companies(array('fax' => $row['toNumber'])); foreach ($from_rec_comp as $rec) { $from_rec[] = Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $rec); } $m->add_row(empty($from_rec) ? $row['toNumber'] : ' (' . implode(', ', $from_rec) . ')', $statuses[$row['faxStatus']], Base_RegionalSettingsCommon::time2reg($row['creationDate']), '<a href="' . $row['fileUrl'] . '" target="_blank">' . $row['fileName'] . '</a>'); } $theme->assign('table_data', $this->get_html_of_module($m)); $theme->display(); }
public function chat($big = false, $uid = null) { $to =& $this->get_module_variable('to', "all"); eval_js('shoutbox_uid="' . $to . '"'); if (Base_AclCommon::is_user()) { //initialize HTML_QuickForm $qf = $this->init_module(Libs_QuickForm::module_name()); /* $myid = Base_AclCommon::get_user(); if(Base_User_SettingsCommon::get('Apps_Shoutbox','enable_im')) { $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox','enable_im'); if(ModuleManager::is_installed('CRM_Contacts')>=0) { $emps = DB::GetAssoc('SELECT l.id,IF(cd.f_last_name!=\'\',CONCAT(cd.f_last_name,\' \',cd.f_first_name,\' (\',l.login,\')\'),l.login) as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY name',array($myid,serialize(1))); } else $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY l.login',array($myid,serialize(1))); } else $emps = array(); if(ModuleManager::is_installed('Tools_WhoIsOnline')>=0) { $online = Tools_WhoIsOnlineCommon::get_ids(); foreach($online as $id) { if(isset($emps[$id])) $emps[$id] = '* '.$emps[$id] ; } } $qf->addElement('select','to',__('To'),array('all'=>'['.__('All').']')+$emps,array('id'=>'shoutbox_to'.($big?'_big':''),'onChange'=>'shoutbox_uid=this.value;shoutbox_refresh'.($big?'_big':'').'()'));*/ $myid = Base_AclCommon::get_user(); if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im') && ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) { $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im'); $online = Tools_WhoIsOnlineCommon::get_ids(); if ($online) { if (ModuleManager::is_installed('CRM_Contacts') >= 0) { $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name', DB::qstr(' ('), 'l.login', DB::qstr(')')), 'l.login')) . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY name', array($myid, serialize(1))); } else { $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), 'l.login') . ' FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY l.login', array($myid, serialize(1))); } } else { $emps = array(); } } else { $emps = array(); } $e = $qf->addElement('autoselect', 'shoutbox_to', __('To'), array('all' => '[' . __('All') . ']') + $emps, array(array($this->get_type() . 'Common', 'user_search'), array()), array($this->get_type() . 'Common', 'user_format')); $e->setAttribute('id', 'shoutbox_to' . ($big ? '_big' : '')); $e->setAttribute('onChange', 'shoutbox_uid=this.value;shoutbox_refresh' . ($big ? '_big' : '') . '()'); if (!Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) { $qf->freeze(array('shoutbox_to')); } //create text box $qf->addElement($big ? 'textarea' : 'textarea', 'post', __('Message'), 'class="border_radius_6px" id="shoutbox_text' . ($big ? '_big' : '') . '"'); $qf->addRule('post', __('Field required'), 'required'); //create submit button $qf->addElement('submit', 'submit_button', __('Send'), 'id="shoutbox_button' . ($big ? '_big' : '') . '"'); //add it $qf->setRequiredNote(null); $qf->setDefaults(array('shoutbox_to' => $to)); $theme = $this->init_module(Base_Theme::module_name()); $qf->assign_theme('form', $theme); //confirm when sending messages to all eval_js("jq('#shoutbox_button, #shoutbox_button_big').click(function() {\n \t\t\t\t\tvar submit = true;\n\t\t \t\t\tif (jq('#shoutbox_to').val() == 'all' && !confirm('" . __('Send message to all?') . "')) {\n \t\t\t\t\tsubmit = false;\n \t\t\t\t\t}\n\t\t \n\t\t \t\t\treturn submit;\t\t \t\t\t\n\t\t\t\t\t});"); //if submited if ($qf->validate()) { //get post group $msg = $qf->exportValue('post'); $to = $qf->exportValue('shoutbox_to'); //get msg from post group $msg = Utils_BBCodeCommon::optimize($msg); //get logged user id $user_id = Base_AclCommon::get_user(); //clear text box and focus it eval_js('$(\'shoutbox_text' . ($big ? '_big' : '') . '\').value=\'\';focus_by_id(\'shoutbox_text' . ($big ? '_big' : '') . '\');shoutbox_uid="' . $to . '"'); //insert to db DB::Execute('INSERT INTO apps_shoutbox_messages(message,base_user_login_id,to_user_login_id) VALUES(%s,%d,%d)', array(htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'), $user_id, is_numeric($to) ? $to : null)); } } else { print __('Please log in to post message') . '<br>'; return; } $theme->assign('board', '<div id=\'shoutbox_board' . ($big ? '_big' : '') . '\'></div>'); $theme->assign('header', __('Shoutbox')); $theme->display('chat_form' . ($big ? '_big' : '')); //if shoutbox is diplayed, call myFunctions->refresh from refresh.php file every 5s eval_js_once('shoutbox_refresh' . ($big ? '_big' : '') . ' = function(){if(!$(\'shoutbox_board' . ($big ? '_big' : '') . '\')) return;' . 'new Ajax.Updater(\'shoutbox_board' . ($big ? '_big' : '') . '\',\'modules/Apps/Shoutbox/refresh.php\',{method:\'get\', parameters: { uid: shoutbox_uid }});' . '};setInterval(\'shoutbox_refresh' . ($big ? '_big' : '') . '()\',' . ($big ? '10000' : '30000') . ')'); eval_js('shoutbox_refresh' . ($big ? '_big' : '') . '()'); }
public function body($header = '', $params = array(), $add_disp = '', $big = true) { if (MOBILE_DEVICE) { return; } if (isset($_REQUEST['__location']) && $this->last_location != $_REQUEST['__location']) { $this->last_location = $_REQUEST['__location']; $this->leightbox_ready = false; } if (!$this->leightbox_ready) { if (!empty($params)) { $this->params = $params; $js = 'f' . $this->group . '_set_params = function(arg' . implode(',arg', array_keys($params)) . '){'; foreach ($params as $k => $v) { $js .= 'els=document.getElementsByName(\'' . $this->group . '_' . $v . '\');'; $js .= 'i=0;while(i<els.length){els[i].value=arg' . $k . ';i++;}'; } $js .= '}'; eval_js($js); } $this->leightbox_ready = true; eval_js_once('f' . $this->group . '_prompt_deactivate = function(){leightbox_deactivate(\'' . $this->group . '_prompt_leightbox\');}'); eval_js_once('f' . $this->group . '_show_form = function(arg){$(arg+\'_' . $this->group . '_form_section\').style.display=\'block\';$(\'' . $this->group . '_buttons_section\').style.display=\'none\';}'); eval_js('$(\'' . $this->group . '_buttons_section\').style.display=\'' . (count($this->options) == 1 ? 'none' : 'block') . '\';'); $buttons = array(); $sections = array(); foreach ($this->options as $k => $v) { $next_button = array('icon' => $v['icon'], 'label' => $v['label']); if ($v['form'] !== null) { $form = $v['form']; } else { $form = $this->options[$k]['form'] = $this->init_module(Libs_QuickForm::module_name()); } if (!empty($params)) { foreach ($params as $w) { $form->addElement('hidden', $this->group . '_' . $w, 'none', array('id' => $this->group . '_' . $w)); } } if ($v['form'] !== null) { $v['form']->addElement('button', 'cancel', __('Cancel'), array('id' => $this->group . '_lp_cancel', 'onclick' => count($this->options) == 1 ? 'f' . $this->group . '_prompt_deactivate();' : '$(\'' . $this->group . '_buttons_section\').style.display=\'block\';$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'none\';')); $v['form']->addElement('submit', 'submit', __('OK'), array('id' => $this->group . '_lp_submit', 'onclick' => 'f' . $this->group . '_prompt_deactivate();')); ob_start(); $th = $this->init_module(Base_Theme::module_name()); $v['form']->assign_theme('form', $th); $th->assign('id', $this->get_instance_id()); $th->display('form'); $form_contents = ob_get_clean(); $next_button['open'] = '<a href="javascript:void(0);" onclick="f' . $this->group . '_show_form(\'' . $k . '\');">'; $sections[] = '<div id="' . $k . '_' . $this->group . '_form_section" style="display:none;">' . $form_contents . '</div>'; eval_js('$(\'' . $k . '_' . $this->group . '_form_section\').style.display=\'' . (count($this->options) != 1 ? 'none' : 'block') . '\';'); if ($v['form']->exportValue('submited') && !$v['form']->validate()) { // open this selection eval_js('f' . $this->get_group_key() . "_show_form('{$k}')"); } } else { // $next_button['open'] = '<a '.$this->create_callback_href(array($this,'option_chosen'), array($k)).' onmouseup="f'.$this->group.'_prompt_deactivate();">'; $next_button['open'] = '<a href="javascript:void(0);" onmouseup="f' . $this->group . '_prompt_deactivate();' . $form->get_submit_form_js() . ';">'; $form->display(); } $next_button['close'] = '</a>'; $buttons[] = $next_button; } $theme = $this->init_module(Base_Theme::module_name()); $theme->assign('open_buttons_section', '<div id="' . $this->group . '_buttons_section">'); $theme->assign('buttons', $buttons); $theme->assign('sections', $sections); $theme->assign('additional_info', $add_disp); $theme->assign('close_buttons_section', '</div>'); ob_start(); $theme->display('leightbox'); $profiles_out = ob_get_clean(); Libs_LeightboxCommon::display($this->group . '_prompt_leightbox', $profiles_out, $header, $big); } }
private function output($applet = false) { Base_ThemeCommon::load_css($this->get_type(), 'tray'); $tray_settings = Utils_TrayCommon::get_trays(); $tray_def = array(); $total_pending = 0; $displayed = 0; foreach ($tray_settings as $module => $module_settings) { foreach ($module_settings as $tab => $tab_settings) { if (!isset($tab_settings['__title__'])) { continue; } $tray = Utils_TrayCommon::get_tray($tab, $tab_settings); if (!isset($tray['__slots__']) || count($tray['__slots__']) == 0) { continue; } $tray_id = $this->get_type() . '__' . Utils_RecordBrowserCommon::get_field_id($tray['__title__']); $tray_def += array($tray_id => array('__title__' => $tray['__title__'], '__weight__' => isset($tray['__weight__']) ? $tray['__weight__'] : 0)); foreach ($tray['__slots__'] as $slot_id => $slot_def) { $total_pending += $slot_def['__count__']; $displayed += $slot_def['__count__']; $tray_def[$tray_id]['__slots__'][$slot_id]['__weight__'] = isset($slot_def['__weight__']) ? $slot_def['__weight__'] : 0; $icon = $this->get_icon($slot_def['__count__']); $tray_count_width = $slot_def['__count__'] > 99 ? 'style="width:28px;"' : ''; $tip_text = __('Click to view %s items from %s<br><br>%d item(s)', array(_V($slot_def['__name__']), _V($tray['__title__']), $slot_def['__count__'])); $tray_def[$tray_id]['__slots__'][$slot_id]['__html__'] = '<td><a ' . $this->create_main_href($module, null, array($tab), null, array('tray_slot' => $slot_id)) . '><div class="Utils_Tray__slot">' . Utils_TooltipCommon::create('<img src="' . $icon . '"> <div class="Utils_Tray__count" ' . $tray_count_width . '>' . $slot_def['__count__'] . '</div><div>' . _V($slot_def['__name__']) . '</div>', $tip_text) . '</div></a></td>'; } } } Utils_TrayCommon::sort_trays($tray_def); $trays = array(); $tray_slots_html = array(); $current_tray = 0; $tray_cols = $applet ? 2 : $this->get_tray_cols(); foreach ($tray_def as $tray_id => $def) { $current_tray += 1; $current_row = max(array(round($current_tray / $tray_cols), 1)); $current_col = $current_tray - $tray_cols * ($current_row - 1); if (isset($this->max_trays) && $this->max_trays != '__NULL__') { //allow only trays in applet mode as per setting if (count($trays) >= $this->max_trays) { break; } } if (self::get_tray_layout() == 'checkered') { $class = ($current_row + $current_col) % 2 ? 'Utils_Tray__group_even' : 'Utils_Tray__group_odd'; } else { $class = 'Utils_Tray__group_even'; } $trays[] = array('class' => $class, 'col' => $current_col, 'title' => _V($def['__title__']), 'id' => $tray_id); foreach ($def['__slots__'] as $slot) { $tray_slots_html[$tray_id][] = $slot['__html__']; if (isset($this->max_slots) && $this->max_slots != '__NULL__') { //allow slots in applet mode as per setting if (count($tray_slots_html[$tray_id]) >= $this->max_slots) { continue 2; } } } } eval_js('function Utils_Tray__trays() { var trays = ' . json_encode($tray_slots_html) . '; return trays; } jq( document ).ready(function() { var resizeId; jq(window).resize(function(){ clearTimeout(resizeId); resizeId = setTimeout(Utils_Tray__resize, 300); }); Utils_Tray__resize(); });'); load_js($this->get_module_dir() . 'tray.js'); $theme = $this->init_module(Base_Theme::module_name()); $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'pile2.png'); $theme->assign('main_page', !$applet); $theme->assign('caption', Utils_TrayCommon::caption()); $theme->assign('icon', $icon); $theme->assign('trays', $trays); $theme->assign('tray_cols', $tray_cols); if ($total_pending != $displayed) { print __('Displaying %d of %d pending', array($displayed, $total_pending)); } $theme->display('tray'); }
public function display_dashboard($tab_id) { // Base_ActionBarCommon::add('add',__('Add applet'),$this->create_callback_href(array($this,'applets_list'),$tab_id)); $default_dash = $this->get_module_variable('default'); $colors = Base_DashboardCommon::get_available_colors(); $applets = array(0 => array(), 1 => array(), 2 => array()); $config_mode = $this->get_module_variable('config_mode', false); if ($default_dash || !Base_DashboardCommon::has_permission_to_manage_applets()) { $ret = DB::Execute('SELECT col,id,module_name,color FROM base_dashboard_default_applets WHERE tab=%d ORDER BY col,pos', array($tab_id)); } else { $ret = DB::Execute('SELECT col,id,module_name,color FROM base_dashboard_applets WHERE user_login_id=%d AND tab=%d ORDER BY pos', array(Base_AclCommon::get_user(), $tab_id)); } while ($row = $ret->FetchRow()) { $applets[$row['col']][] = $row; } print '<div id="dashboard" style="width: 100%;">'; for ($j = 0; $j < 3; $j++) { print '<div id="dashboard_applets_' . $tab_id . '_' . $j . '" style="width:33%;min-height:200px;padding-bottom:10px;vertical-align:top;display:inline-block">'; foreach ($applets[$j] as $row) { if (!is_callable(array($row['module_name'] . 'Common', 'applet_caption'))) { continue; } $cap = call_user_func(array($row['module_name'] . 'Common', 'applet_caption')); if (!$cap || ModuleManager::is_installed($row['module_name']) == -1) { //if its invalid entry continue; } $m = $this->init_module($row['module_name'], null, $row['id']); $opts = array(); $opts['title'] = $cap; $opts['toggle'] = true; $opts['href'] = null; $opts['go'] = false; $opts['go_function'] = 'body'; $opts['go_arguments'] = array(); $opts['go_constructor_arguments'] = array(); $opts['actions'] = array(); $opts['id'] = $row['id']; $th = $this->init_module(Base_Theme::module_name()); if ($config_mode || !$m) { $content = ''; } else { $content = $this->get_html_of_module($m, array($this->get_values($row['id'], $row['module_name']), &$opts, $row['id']), 'applet'); } $th->assign('content', '<div class="content">' . $content . '</div>'); $th->assign('handle_class', 'handle'); $th->assign('fixed', !($default_dash || Base_DashboardCommon::has_permission_to_manage_applets())); if ($opts['toggle'] && !$config_mode) { $th->assign('toggle', '<a class="toggle" ' . Utils_TooltipCommon::open_tag_attrs(__('Toggle')) . '>=</a>'); } foreach ($opts['actions'] as $k => $v) { if (!$v) { unset($opts['actions'][$k]); } } if ($opts['go']) { $opts['href'] = $this->create_main_href($row['module_name'], $opts['go_function'], $opts['go_arguments'], $opts['go_constructor_arguments']); } if ($opts['href']) { $th->assign('href', '<a class="href" ' . Utils_TooltipCommon::open_tag_attrs(__('Fullscreen')) . ' ' . $opts['href'] . '>G</a>'); } if ($default_dash || Base_DashboardCommon::has_permission_to_manage_applets()) { $th->assign('remove', Base_DashboardCommon::get_remove_applet_button($row['id'], $default_dash)); if (!$config_mode) { $th->assign('configure', '<a class="configure" ' . Utils_TooltipCommon::open_tag_attrs(__('Configure')) . ' ' . $this->create_callback_href(array($this, 'configure_applet'), array($row['id'], $row['module_name'])) . '>c</a>'); } } $th->assign('caption', $opts['title']); $th->assign('color', $colors[$row['color']]['class']); $th->assign('actions', $opts['actions']); $th->assign('config_mode', $config_mode); print '<div class="applet" id="ab_item_' . $row['id'] . '">'; $th->display(); print '</div>'; } print '</div>'; } print '</div>'; }
public function year() { $theme = $this->pack_module(Base_Theme::module_name()); Base_ThemeCommon::load_css('Utils_Calendar', 'common'); $theme->assign('nextyear_href', $this->create_unique_href(array('date' => date('Y', $this->date) + 1 . date('-m-d', $this->date)))); $theme->assign('nextyear_label', __('Next year')); $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prevyear_href', $this->create_unique_href(array('date' => date('Y', $this->date) - 1 . date('-m-d', $this->date)))); $theme->assign('prevyear_label', __('Previous year')); $theme->assign('info', __('Double click on cell to add event')); $link_text = $this->create_unique_href_js(array('date' => '__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'year')); $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); } $theme->assign('month_view_label', __('Year calendar')); $year = array(); $ret = call_user_func(array($this->event_module . 'Common', 'get_event_days'), date('Y-01-01', $this->date), date('Y', $this->date) + 1 . '-01-01'); for ($i = 1; $i <= 12; $i++) { $date = strtotime(date('Y', $this->date) . '-' . str_pad($i, 2, '0', STR_PAD_LEFT) . '-15'); $month = $this->month_array($date, $ret); $year[] = array('month' => $month, 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $date, 'tab' => 'Month')), 'month_label' => __date('F', $date), 'year_label' => date('Y', $date)); } $theme->assign('year', $year); $theme->assign('day_headers', $day_headers); $navigation_bar_additions = ''; $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->display('year'); }
public function display_pdf_row($grow) { if (empty($grow)) { return; } static $first_row; if (!isset($first_row)) { $first_row = true; } $table = ''; foreach ($grow as $row) { $theme = $this->init_module(Base_Theme::module_name()); $theme->assign('row', $row); $theme->assign('params', array('widths' => $this->widths, 'height' => $this->height)); ob_start(); $theme->display('pdf_row'); $table .= ob_get_clean(); } $table = Libs_TCPDFCommon::stripHTML($table); $pages = $this->pdf_ob->getNumPages(); $tmppdf = clone $this->pdf_ob->tcpdf; $tmppdf->WriteHTML($table, false, 0, false); if ($pages == $tmppdf->getNumPages() || $first_row) { $this->pdf_ob->writeHTML($table, false); $first_row = false; return; } $this->pdf_ob->AddPage(); $this->display_pdf_header(); $this->pdf_ob->writeHTML($table, false); }
/** * This method displays menu. */ public function body() { $this->help('Menu', 'index'); $theme = $this->init_module(Base_Theme::module_name()); $str = '<div id=menu_contener_' . $this->menu_id . '><img width="16" height="16" border="0" style="width: 16px; height: 16px; margin-top: 2px; margin-left: 2px; background-color: white; color: white; border: 0px;" src="modules/Utils/Menu/theme/loader.gif"></div>'; $theme->assign('menu', $str); $theme->display(); $this->menu_string .= 'writeOut(\'' . $this->menu_id . '\');'; $this->menu_string .= '}; '; $this->menu_string .= 'wait_while_null( "CustomMenubar", "load_menu_' . $this->menu_id . '(12)" );'; $new_md5 = md5($this->menu_string); $old_md5 =& $this->get_module_variable('old'); if ($new_md5 != $old_md5) { eval_js($this->menu_string); $old_md5 = $new_md5; } }
public function body() { if (isset(Base_BoxCommon::$override_box_main)) { $this->pack_module(Base_BoxCommon::$override_box_main); return; } $theme = $this->pack_module(Base_Theme::module_name()); $ini = Base_BoxCommon::get_ini_file(); if (!$ini) { print __('Unable to read Base/Box/default.ini file! Please create one, or change theme.'); $this->pack_module(Base_Theme_Administrator::module_name(), null, 'admin'); return; } $ini_file = parse_ini_file($ini, true); $logged = Base_AclCommon::is_user(); $theme->assign('logged', $logged); $containers = array(); $containers['main'] = array('module' => null, 'name' => ''); //so 'main' is first in array $name = 0; foreach ($ini_file as $tag => $opts) { $name++; if ($logged && $opts['display'] == 'anonymous' || !$logged && $opts['display'] == 'logged') { continue; } if (isset($opts['function'])) { $containers[$tag]['function'] = $opts['function']; $containers[$tag]['arguments'] = null; } if (isset($opts['arguments'])) { $containers[$tag]['arguments'] = $opts['arguments']; } if (isset($opts['module'])) { $containers[$tag]['module'] = $opts['module']; } else { trigger_error('No module specified.', E_USER_ERROR); } $containers[$tag]['name'] = $tag; } if (isset($containers['main'])) { $containers['main']['name'] = 'main_0'; } if (isset($_REQUEST['base_box_pop_main'])) { $pop_main = $_REQUEST['base_box_pop_main']; unset($_REQUEST['base_box_pop_main']); } else { $pop_main = false; } if ($this->isset_module_variable('main')) { $mains = $this->get_module_variable('main'); if ($pop_main) { while ($pop_main--) { array_pop($mains); } $pop_main = true; } $main = array_pop($mains); if (isset($main['module']) && $main['module'] != null) { $containers['main'] =& $main; } foreach ($mains as $k => $m) { if (ModuleManager::is_installed($m['module']) >= 0) { $this->freeze_module($m['module'], isset($m['name']) ? $m['name'] : null); } } } else { $mains = array(); } if (isset($_REQUEST['box_main_href'])) { if (!isset($_SESSION['client']['base_box_hrefs'])) { $_SESSION['client']['base_box_hrefs'] = array(); } $hs =& $_SESSION['client']['base_box_hrefs']; if (isset($hs[$_REQUEST['box_main_href']])) { $rh = $hs[$_REQUEST['box_main_href']]; $href = $rh['m']; $containers['main']['module'] = $href; if (isset($rh['f'])) { $containers['main']['function'] = $rh['f']; } else { unset($containers['main']['function']); } if (isset($rh['a'])) { $containers['main']['arguments'] = $rh['a']; } else { unset($containers['main']['arguments']); } if (isset($rh['c'])) { $containers['main']['constructor_arguments'] = $rh['c']; } else { unset($containers['main']['constructor_arguments']); } $mains = array(); $pop_main = true; } unset($_REQUEST['box_main_href']); $hs = array(); } array_push($mains, $containers['main']); $main_length = count($mains); $this->set_module_variable('main', $mains); // Epesi::alert(print_r($mains,true)); // $containers['main']['name'] .= '_'.$main_length; //print_r($containers); $this->modules = array(); foreach ($containers as $k => $v) { ob_start(); if (ModuleManager::is_installed($v['module']) != -1) { $module_type = str_replace('/', '_', $v['module']); if (!isset($v['name'])) { $v['name'] = null; } if (isset($href) && $k == 'main') { $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name'], true); } else { $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name']); } if ($k == 'main' && $pop_main) { $this->modules[$k]->set_reload(true); } if (isset($v['function'])) { $this->display_module($this->modules[$k], isset($v['arguments']) ? $v['arguments'] : null, $v['function']); } elseif (isset($v['arguments'])) { $this->display_module($this->modules[$k], $v['arguments']); } else { $this->display_module($this->modules[$k]); } } $theme->assign($k, ob_get_contents()); ob_end_clean(); } //main output $version_no = Base_BoxCommon::update_version_check_indicator(); if (SUGGEST_DONATION) { $theme->assign('donate', Utils_TooltipCommon::create('<a target="_blank" href="http://epe.si/donate/">' . __('Support EPESI!') . '</a>', '<center>' . __('If you find our software useful, please support us by making a %s.', array(__('donation'))) . '<br/>' . __('Your funding will help to ensure continued development of this project.') . '<br/>' . __('Click for details.') . '</center>', false, 500)); } // Consider moving this code properly as initated module by *.ini file $theme->assign('home', array('href' => Base_HomePageCommon::get_href(), 'label' => __('Home'))); $theme->assign('version_no', $version_no); $theme->display(); }
public function launchpad() { if (self::$launchpad == null) { return; } $launcher = array(); usort(self::$launchpad, array($this, 'compare_launcher')); if (!empty(self::$launchpad)) { $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'launcher.png'); $th = $this->pack_module(Base_Theme::module_name()); usort(self::$launchpad, array($this, 'compare_launcher')); $th->assign('icons', self::$launchpad); eval_js_once('actionbar_launchpad_deactivate = function(){leightbox_deactivate(\'actionbar_launchpad\');}'); ob_start(); $th->display('launchpad'); $lp_out = ob_get_clean(); $big = count(self::$launchpad) > 10; Libs_LeightboxCommon::display('actionbar_launchpad', $lp_out, __('Launchpad'), $big); $launcher[] = array('label' => __('Launchpad'), 'description' => 'Quick modules launcher', 'open' => '<a ' . Libs_LeightboxCommon::get_open_href('actionbar_launchpad') . '>', 'close' => '</a>', 'icon' => $icon); $th = $this->pack_module(Base_Theme::module_name()); $th->assign('icons', array()); $th->assign('launcher', array_reverse($launcher)); $th->display(); eval_js('$("launchpad_button_section").style.display="";'); eval_js('$("launchpad_button_section_spacing").style.display="";'); } }
public function body() { if (empty($this->grid)) { print 'Time grid not defined, aborting'; return; } load_js('modules/Utils/Planner/planner.js'); eval_js('disableSelection($("Utils_Planner__grid"))'); eval_js('Event.observe(window,"mouseup",time_grid_mouse_up)'); $theme = $this->init_module(Base_Theme::module_name()); /* HEADERS */ $fdow = Utils_PopupCalendarCommon::get_first_day_of_week(); $headers = array(); $select_all = array(); if ($this->date === null) { $days_of_week = array(0 => __('Sunday'), 1 => __('Monday'), 2 => __('Tuesday'), 3 => __('Wednesday'), 4 => __('Thursday'), 5 => __('Friday'), 6 => __('Saturday')); while (count($headers) < 7) { $headers[$fdow] = $days_of_week[$fdow]; $fdow++; if ($fdow > 6) { $fdow -= 7; } } } else { // while (date('w',$this->date)!=$fdow) $this->date = strtotime('-1 day', $this->date); $_SESSION['client']['utils_planner']['date'] = $this->date; $days_of_week = array(0 => __('Sun'), 1 => __('Mon'), 2 => __('Tue'), 3 => __('Wed'), 4 => __('Thu'), 5 => __('Fri'), 6 => __('Sat')); $curr = $this->date; while (count($headers) < 7) { $headers[$curr] = Base_RegionalSettingsCommon::time2reg($curr, false, true, false) . ' ' . $days_of_week[date('w', $curr)]; $curr = strtotime('+1 day', $curr); } } $theme->assign('headers', $headers); foreach ($headers as $k1 => $v1) { $select_all[$k1] = ''; } /* GRID LEGEND */ $grid_legend = array(); $grid_attrs = array(); foreach ($this->grid as $k => $v) { if (!isset($this->grid[$k + 1])) { break; } foreach ($headers as $k1 => $v1) { $select_all[$k1] .= ($select_all[$k1] ? 'time_grid_mouse_move' : 'time_grid_mouse_down') . '(' . $v . ',' . $k1 . ');'; } $grid_legend[$v] = Utils_PlannerCommon::format_time($v * 60); $grid_legend[$v] .= ' - ' . Utils_PlannerCommon::format_time($this->grid[$k + 1] * 60); $grid_attrs[$v] = array(); foreach ($headers as $k2 => $v2) { $grid_attrs[$v][$k2] = 'class="noconflict unused" id="' . $k2 . '__' . $v . '" onmousedown="time_grid_mouse_down(' . $v . ',' . $k2 . ')" onmousemove="if(typeof(time_grid_mouse_move)!=\'undefined\')time_grid_mouse_move(' . $v . ',' . $k2 . ')"'; } } foreach ($headers as $k1 => $v1) { $select_all[$k1] .= 'time_grid_mouse_up();'; } /* GRID LEGEND END */ $theme->assign('select_all', $select_all); $theme->assign('select_all_label', __('Select all')); $theme->assign('grid_legend', $grid_legend); $theme->assign('grid_attrs', $grid_attrs); $theme->assign('time_frames', array('label' => __('Time frames'), 'html' => '<div id="Utils_Planner__time_frames" />')); $_SESSION['client']['utils_planner']['grid'] = array('timetable' => $this->grid, 'days' => $headers); if ($this->date !== null) { $this->form->addElement('submit', 'next_day', __('Next day'), array('onclick' => '$("planner_navigation").value="next_day";')); $this->form->addElement('submit', 'prev_day', __('Previous day'), array('onclick' => '$("planner_navigation").value="prev_day";')); $this->form->addElement('submit', 'next_week', __('Next week'), array('onclick' => '$("planner_navigation").value="next_week";')); $this->form->addElement('submit', 'prev_week', __('Previous week'), array('onclick' => '$("planner_navigation").value="prev_week";')); $this->form->addElement('submit', 'today', __('Today'), array('onclick' => '$("planner_navigation").value="today";')); $this->form->addElement('hidden', 'navigation', '', array('id' => 'planner_navigation')); $link_text = '$(\'planner_navigation\').value=\'__YEAR__-__MONTH__-__DAY__\';' . $this->form->get_submit_form_js() . ';'; $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $fdow, null, null, $this->date)); eval_js('$("planner_navigation").value="";'); } $values = $this->get_module_variable('preserve_values', null); if ($values === null) { $values = $this->form->exportValues(); } else { $this->unset_module_variable('preserve_values'); } $this->form->setDefaults($values); $validate = false; if ($this->form->validate()) { $validate = true; foreach ($values as $k => $v) { $this->values[$k] = $v; } } $this->form->assign_theme('form', $theme); $theme->display(); Base_ActionBarCommon::add('save', __('Save'), $this->form->get_submit_form_href()); Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $time_frames = explode(';', $values['grid_selected_frames']); if (!empty($time_frames) && $time_frames[0]) { foreach ($time_frames as $k => $v) { $x = explode('::', $v); if (!isset($x[2])) { trigger_error(print_r($time_frames, true)); } list($day, $s, $e) = explode('::', $v); foreach ($this->grid as $v) { if ($v >= $s && $v < $e) { eval_js('time_grid_mouse_down(' . $v . ',' . $day . ',"used");'); } } } eval_js('time_grid_mouse_up();'); } if (isset($values['navigation']) && $values['navigation']) { switch ($values['navigation']) { case 'next_day': $ch = strtotime('+1 day', $this->date); break; case 'prev_day': $ch = strtotime('-1 day', $this->date); break; case 'next_week': $ch = strtotime('+7 days', $this->date); break; case 'prev_week': $ch = strtotime('-7 days', $this->date); break; case 'today': $ch = strtotime(date('Y-m-d')); break; default: $ch = strtotime($values['navigation']); } if ($ch) { $values['navigation'] = ''; $this->set_module_variable('fixed_date', $ch); $this->set_module_variable('preserve_values', $values); location(array()); return; } } if ($validate) { unset($values['grid_selected_frames']); foreach ($time_frames as $k => $v) { if (!$v) { unset($time_frames[$k]); break; } list($day, $s, $e) = explode('::', $v); $time_frames[$k] = array('day' => $day, 'start' => $s, 'end' => $e); } call_user_func($_SESSION['client']['utils_planner']['processing_callback'], $values, $time_frames); $this->set_back_location(); location(array()); } foreach ($this->values as $k => $v) { $_SESSION['client']['utils_planner']['resources'][$k]['value'] = $v; $_SESSION['client']['utils_planner']['resources'][$k]['in_use'] = array(); } foreach ($this->values as $k => $v) { eval_js(Utils_PlannerCommon::resource_changed($k, $v)); } }
public function mini() { if (!Base_AclCommon::check_permission('Search')) { return ''; } $form = $this->init_module(Libs_QuickForm::module_name(), __('Searching')); $form->addElement('text', 'quick_search', __('Quick Search'), array('x-webkit-speech' => 'x-webkit-speech', 'lang' => Base_LangCommon::get_lang_code(), 'onwebkitspeechchange' => $form->get_submit_form_js())); $form->addElement('submit', 'quick_search_submit', __('Search'), array('class' => 'mini_submit')); $theme = $this->pack_module(Base_Theme::module_name()); $theme->assign('submit_href', $form->get_submit_form_href()); $theme->assign('submit_label', __('Search')); $form->assign_theme('form', $theme); $theme->assign('form_mini', 'yes'); $theme->display('Search'); if ($form->validate()) { $search = $form->exportValues(); Base_BoxCommon::location('Base_Search', null, null, null, array('quick_search' => $search['quick_search'])); } }
public function simple_setup() { Base_ActionBarCommon::add('settings', __('Advanced view'), $this->create_confirm_callback_href(__('Switch to advanced view?'), array($this, 'switch_simple'), false)); $module_dirs = $this->get_module_dirs(); $is_required = ModuleManager::required_modules(true); $structure = array(); foreach ($module_dirs as $entry => $versions) { $installed = ModuleManager::is_installed($entry); $module_install_class = $entry . 'Install'; $func_simple = array($module_install_class, 'simple_setup'); if (is_callable($func_simple)) { $simple_module = call_user_func($func_simple); } else { $simple_module = false; } if ($simple_module === false) { continue; } if ($simple_module === true) { $simple_module = array('package' => __('Uncategorized'), 'option' => $entry); } if (is_string($simple_module)) { $simple_module = array('package' => $simple_module); } if (!isset($simple_module['option'])) { $simple_module['option'] = null; } $simple_module['module'] = $entry; $simple_module['installed'] = $installed >= 0; $simple_module['key'] = $simple_module['package'] . ($simple_module['option'] ? '|' . $simple_module['option'] : ''); $structure[$entry] = $simple_module; } $packages = array(); foreach ($structure as $s) { if (!isset($packages[$s['key']])) { $packages[$s['key']] = array('also_uninstall' => array(), 'modules' => array(), 'is_required' => array(), 'installed' => null, 'icon' => false, 'version' => null, 'url' => null, 'core' => 0); } $package =& $packages[$s['key']]; $package['modules'][] = $s['module']; $package['name'] = $s['package']; $package['option'] = $s['option']; if (isset($s['core'])) { $package['core'] = $s['core']; } if ($package['installed'] === null) { $package['installed'] = $s['installed']; } else { if ($s['installed'] && !$package['installed'] || !$s['installed'] && $package['installed']) { $package['installed'] = 'partial'; } } if (!isset($is_required[$s['module']])) { $is_required[$s['module']] = array(); } foreach ($is_required[$s['module']] as $r) { if (!isset($structure[$r])) { $package['also_uninstall'][] = $r; continue; } if ($structure[$r]['package'] == $s['package']) { continue; } $package['is_required'][$structure[$r]['key']] = $structure[$r]['key']; } if (isset($s['icon'])) { $package['icon'] = Base_ThemeCommon::get_template_file($s['module'], 'package-icon.png'); } if (isset($s['version'])) { $package['version'] = $s['version']; } if (isset($s['url'])) { $package['url'] = $s['url']; } } $sorted = array(); foreach ($packages as $key => $p) { if ($key === 0) { continue; } $name = $p['name']; $option = $p['option']; if (!isset($sorted[$name])) { $sorted[$name] = array(); $sorted[$name]['name'] = $name; $sorted[$name]['modules'] = array(); $sorted[$name]['buttons'] = array(); $sorted[$name]['options'] = array(); $sorted[$name]['status'] = __('Options only'); $sorted[$name]['filter'] = array('available'); $sorted[$name]['style'] = 'disabled'; $sorted[$name]['installed'] = null; $sorted[$name]['instalable'] = 0; $sorted[$name]['uninstalable'] = 0; $sorted[$name]['core'] = 0; } $sorted[$name]['core'] |= $p['core']; $buttons = array(); $status = ''; if ($p['installed'] === true || $p['installed'] === 'partial') { if (!$p['core'] && empty($p['is_required'])) { $mods = $p['modules']; foreach ($p['also_uninstall'] as $pp) { $mods[] = $pp; } if ($p['option'] === null) { // also add all options as available for uninstall foreach ($packages as $pp) { if ($pp['name'] === $p['name']) { $mods = array_merge($mods, $pp['modules']); } } } $buttons[] = array('label' => __('Uninstall'), 'style' => 'uninstall', 'href' => $this->create_confirm_callback_href(__('Are you sure you want to uninstall this package and remove all associated data?'), array($this, 'simple_uninstall'), array($mods))); } else { if ($p['core']) { $message = __('EPESI Core can not be uninstalled'); } elseif (empty($p['is_required'])) { $message = __('This package can not be uninstalled'); } else { $required = array(); foreach ($p['is_required'] as $v) { $required[] = str_replace('|', ' / ', $v); } $message = __('This package is required by the following packages: %s', array('<br>' . implode('<br>', $required))); } $buttons[] = array('label' => __('Uninstall'), 'style' => 'disabled', 'href' => Utils_TooltipCommon::open_tag_attrs($message, false)); } } if ($p['installed'] === false || $p['installed'] === 'partial') { $buttons[] = array('label' => __('Install'), 'style' => 'install', 'href' => $this->create_callback_href(array($this, 'simple_install'), array($p['modules']))); } switch (true) { case $p['installed'] === false: $style = 'available'; $filter = array('available'); $status = __('Available'); break; case $p['installed'] === true: $style = 'install'; $filter = array('installed'); $status = __('Installed'); break; case $p['installed'] === 'partial': $style = 'partial-install'; $filter = array('installed'); $status = __('Partially'); break; } if ($option === null) { $sorted[$name]['modules'] = $p['modules']; $sorted[$name]['buttons'] = $buttons; $sorted[$name]['status'] = $status; $sorted[$name]['style'] = $style; $sorted[$name]['installed'] = $p['installed']; $sorted[$name]['instalable'] = 1; $sorted[$name]['uninstalable'] = empty($p['is_required']); $sorted[$name]['filter'] = $filter; $sorted[$name]['icon'] = $p['icon']; $sorted[$name]['version'] = $p['version']; $sorted[$name]['url'] = $p['url']; } else { $sorted[$name]['options'][$option] = array('name' => $option, 'buttons' => $buttons, 'status' => $status, 'style' => $style); } } $filters = array(__('All') => array('arg' => ''), __('Installed') => array('arg' => 'installed'), __('Available') => array('arg' => 'available')); if (ModuleManager::is_installed('Base_EpesiStore') >= 0) { $store_visible = Base_SetupCommon::is_store_visible(); if ($store_visible) { $this->add_store_products($sorted, $filters); } $icon = $store_visible ? 'delete' : 'add'; $text = $store_visible ? __('Disable EPESI Store') : __('Enable EPESI Store'); $href = $this->create_callback_href(array('Base_SetupCommon', 'set_store_visibility'), array(!$store_visible)); $desc = $store_visible ? __('Disabling communication with EPESI Store will improve processing speed, but will not update the list of additional modules in the store.') : ''; Base_ActionBarCommon::add($icon, $text, $href, $desc); } foreach ($sorted as $name => $v) { ksort($sorted[$name]['options']); $buttons_tooltip =& $sorted[$name]['buttons_tooltip']; $buttons_tooltip = $buttons_tooltip ? Utils_TooltipCommon::open_tag_attrs($buttons_tooltip, false) : ''; } uasort($sorted, array($this, 'simple_setup_sort')); $t = $this->init_module(Base_Theme::module_name()); $t->assign('packages', $sorted); $t->assign('filters', $filters); $t->assign('version_label', __('Ver. ')); $t->assign('labels', array('options' => __('Optional'))); $t->display(); }
public function body() { if (!Acl::is_user()) { return; } $th = $this->init_module(Base_Theme::module_name()); eval_js_once('crm_filters_deactivate = function(){leightbox_deactivate(\'crm_filters\');}'); $th->assign('my', '<a ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), 'my') . ' id="crm_filters_my">' . __('My records') . '</a>'); eval_js('Event.observe(\'crm_filters_my\',\'click\', crm_filters_deactivate)'); /*$th->assign('all','<a '.$this->create_callback_href(array('CRM_FiltersCommon','set_profile'),'all').' id="crm_filters_all">'.__('All records').'</a>'); eval_js('Event.observe(\'crm_filters_all\',\'click\', crm_filters_deactivate)');*/ $th->assign('manage', '<a ' . $this->create_callback_href(array($this, 'manage_filters')) . ' id="crm_filters_manage">' . __('Manage presets') . '</a>'); eval_js('Event.observe(\'crm_filters_manage\',\'click\', crm_filters_deactivate)'); $ret = DB::Execute('SELECT id,name,description FROM crm_filters_group WHERE user_login_id=%d', array(Acl::get_user())); $filters = array(); while ($row = $ret->FetchRow()) { $filters[] = array('title' => $row['name'], 'description' => '', 'open' => '<a ' . Utils_TooltipCommon::open_tag_attrs($row['description'], false) . ' ' . $this->create_callback_href(array('CRM_FiltersCommon', 'set_profile'), $row['id']) . ' id="crm_filters_' . $row['id'] . '">', 'close' => '</a>'); eval_js('Event.observe(\'crm_filters_' . $row['id'] . '\',\'click\', crm_filters_deactivate)'); } $th->assign('filters', $filters); $qf = $this->init_module(Libs_QuickForm::module_name()); $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company'); $recent_crits = array(); if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) { $recent_crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company())); } if (Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')) { $recent_crits['!login'] = ''; } $contacts = CRM_ContactsCommon::get_contacts($recent_crits, array(), array(), 15); $cont = array(); foreach ($contacts as $v) { $cont[$v['id']] = call_user_func($fcallback, $v, true); } asort($cont); $crits = array(); if (!Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters')) { $crits = array('(company_name' => CRM_ContactsCommon::get_main_company(), '|related_companies' => array(CRM_ContactsCommon::get_main_company())); } $qf->addElement('autoselect', 'crm_filter_contact', __('Records of'), $cont, array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback, false)), $fcallback); if (isset($_SESSION['client']['filter_' . Acl::get_user()]['value'])) { $qf->setDefaults(array('crm_filter_contact' => explode(',', $_SESSION['client']['filter_' . Acl::get_user()]['value']))); } $qf->addElement('submit', 'submit', __('Show'), array('onclick' => 'crm_filters_deactivate()')); if ($qf->validate()) { $c = $qf->exportValue('crm_filter_contact'); CRM_FiltersCommon::set_profile('c' . $c); location(array()); } $th->assign('saved_filters', __('Saved Presets')); $qf->assign_theme('contacts', $th); //$th->assign('contacts',$qf->toHtml()); ob_start(); $th->display(); $profiles_out = ob_get_clean(); Libs_LeightboxCommon::display('crm_filters', $profiles_out, __('Perspective'), true); if (!isset($_SESSION['client']['filter_' . Acl::get_user()]['desc'])) { CRM_FiltersCommon::set_profile('my'); } //Base_ActionBarCommon::add('folder',__('Filters'),'class="lbOn" rel="crm_filters"',$this->get_module_variable('profile_desc',__('My records'))); if (isset($_REQUEST['__location'])) { $in_use = CRM_FiltersCommon::$in_use === $_REQUEST['__location']; } else { $in_use = CRM_FiltersCommon::$in_use; } print '<a class="lbOn' . ($in_use ? '' : ' disabled') . ' button" rel="crm_filters">' . __('Perspective') . ': ' . '<b>' . $_SESSION['client']['filter_' . Acl::get_user()]['desc'] . '</b><div class="filter_icon_img"></div></a>'; }
public function search_by_id_form($label) { $message = ''; $form = $this->init_module(Libs_QuickForm::module_name()); $theme = $this->init_module(Base_Theme::module_name()); $form->addElement('text', 'record_id', $label); $form->addRule('record_id', __('Must be a number'), 'numeric'); $form->addRule('record_id', __('Field required'), 'required'); $ret = false; if ($form->isSubmitted()) { $ret = true; } if ($form->validate()) { $id = $form->exportValue('record_id'); if (!is_numeric($id)) { trigger_error('Invalid id', E_USER_ERROR); } $r = Utils_RecordBrowserCommon::get_record($this->tab, $id); if (!$r || empty($r)) { $message = __('There is no such record') . '<br>'; } else { if (!$r[':active']) { $message = __('This record was deleted from the system') . '<br>'; } else { $x = ModuleManager::get_instance('/Base_Box|0'); if (!$x) { trigger_error('There is no base box module instance', E_USER_ERROR); } $x->push_main(Utils_RecordBrowser::module_name(), 'view_entry', array('view', $id), array($this->tab)); return; } } } $form->assign_theme('form', $theme); $theme->assign('message', $message); $theme->display('search_by_id'); return $ret; }
public function week() { $theme = $this->pack_module(Base_Theme::module_name()); Base_ThemeCommon::load_css('Utils_CalendarBusyReport', 'common'); $theme->assign('next7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date + 604800)))); $theme->assign('next7_label', __('Next week')); $theme->assign('next_href', $this->create_unique_href(array('shift_week_day' => 1))); $theme->assign('next_label', __('Next day')); $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d')))); $theme->assign('today_label', __('Today')); $theme->assign('prev_href', $this->create_unique_href(array('shift_week_day' => 0))); $theme->assign('prev_label', __('Previous day')); $theme->assign('prev7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date - 604800)))); $theme->assign('prev7_label', __('Previous week')); $link_text = $this->create_unique_href_js(array('week_date' => '__YEAR__-__MONTH__-__DAY__')); $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $this->settings['first_day_of_week'])); $week_shift = $this->get_module_variable('week_shift', 0); $first_day_of_displayed_week = date('w', $this->date) - $this->settings['first_day_of_week']; if ($first_day_of_displayed_week < 0) { $first_day_of_displayed_week += 7; } $diff = $week_shift - $first_day_of_displayed_week; $dis_week_from = strtotime(($diff < 0 ? $diff : '+' . $diff) . ' days', $this->date); //headers $day_headers = array(); $today = Base_RegionalSettingsCommon::time2reg(null, false, true, true, false); if (date('m', $dis_week_from) != date('m', $dis_week_from + 518400)) { $second_span_width = date('d', $dis_week_from + 518400); $header_month = array('first_span' => array('colspan' => 7 - $second_span_width, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))), 'second_span' => array('colspan' => $second_span_width, 'month' => __date('M', $dis_week_from + 518400), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from + 518400), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Year')))); } else { $header_month = array('first_span' => array('colspan' => 7, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year')))); } for ($i = 0; $i < 7; $i++) { $that_day = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $day_headers[] = array('date' => date('d', $that_day) . ' ' . __date('D', $that_day), 'style' => (date('Y-m-d', $that_day) == $today ? 'today' : 'other') . (date('N', $that_day) >= 6 ? '_weekend' : ''), 'link' => $this->create_unique_href(array('action' => 'switch', 'time' => $that_day, 'tab' => 'Day'))); } $theme->assign('header_month', $header_month); $theme->assign('day_headers', $day_headers); $theme->assign('head_col_width', $this->settings['head_col_width']); $report = array(); //timeline and ids $time_ids = array(); $timeline = array(); for ($i = 0; $i < 7; $i++) { $time_ids[$i] = array(); $today_t_timeless = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from)); $today_t = Base_RegionalSettingsCommon::reg2time(date('Y-m-d', $today_t_timeless)); $today_date = date('Y-m-d', $today_t_timeless); $timeline[$today_date] = $this->get_timeline($today_date); $prev = null; foreach ($timeline[$today_date] as &$v) { if ($v['time'] === false) { $time_ids[$i][] = false; } elseif (is_string($v['time'])) { $ii = $today_t_timeless . '_' . $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.$ii.'";'); // *DEBUG* } else { $ii = $today_t + $v['time']; $time_ids[$i][] = $ii; $report[$ii] = array(); // eval_js('$("UCcell_'.$ii.'").innerHTML="'.Base_RegionalSettingsCommon::time2reg($ii).'";'); // *DEBUG* } $prev = $v; } } $navigation_bar_additions = ''; if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) { $event_module_instance = $this->init_module($this->event_module); $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', ''); } $theme->assign('navigation_bar_additions', $navigation_bar_additions); $theme->assign('time_ids', $time_ids); $theme->assign('timeline', reset($timeline)); $theme->assign('week_view_label', __('Week calendar')); //data //$dis_week_from = Base_RegionalSettingsCommon::reg2time($dis_week_from); //$dis_week_to = $dis_week_from+7*86400-1; $dis_week_to = date('Y-m-d', $dis_week_from + 7.5 * 86400); $dis_week_from = date('Y-m-d', $dis_week_from); $ret = $this->get_events($dis_week_from, $dis_week_to); $this->displayed_events = array('start' => $dis_week_from, 'end' => $dis_week_to, 'events' => $ret); $custom_keys = $this->settings['custom_rows']; $busy_labels = $this->settings['busy_labels']; foreach ($ret as $k => $ev) { if (!isset($ev['busy_label'])) { continue; } if (!is_array($ev['busy_label'])) { $ev['busy_label'] = array($ev['busy_label']); } ob_start(); Utils_CalendarBusyReportCommon::print_event($ev); $ev_print = ob_get_clean(); $day_start = explode(':', $this->settings['start_day']); $day_start = ($day_start[0] * 60 + $day_start[1]) * 60; if (!isset($ev['start'])) { $diff = 1; } else { $diff = ($day_start - ($ev['start'] - $today_t)) / 3600; } $dur = ceil($ev['duration'] / (strtotime($this->settings['interval']) - strtotime('0:00'))); if (isset($ev['timeless']) && $ev['timeless']) { if (!isset($ev['custom_row_key'])) { $ev['custom_row_key'] = 'timeless'; } $today_t_timeless = strtotime($ev['timeless']); if (isset($custom_keys[$ev['custom_row_key']])) { $dest_id = $today_t_timeless . '_' . $ev['custom_row_key']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } else { // trigger_error('Invalid custom_row_key:'.$ev['custom_row_key'],E_USER_ERROR); continue; } } else { $today_t = Base_RegionalSettingsCommon::time2reg($ev['start'], true, true, true, false); $today_date = date('Y-m-d', strtotime($today_t)); $today_t = strtotime(date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time($today_date))); $ev_start = $ev['start'] - $today_t; if (!isset($timeline[$today_date])) { continue; } $ct = count($timeline[$today_date]); for ($i = 1, $j = 2; $j < $ct; $i++, $j++) { while ($timeline[$today_date][$i]['time'] === false) { $i++; } while (($timeline[$today_date][$j]['time'] === false || $i >= $j) && $j < $ct) { $j++; } if ($j == $ct) { break; } if ($timeline[$today_date][$i]['time'] <= $ev_start && $ev_start < $timeline[$today_date][$j]['time']) { break; } } for ($k = $i; $k < $i + $dur; $k++) { $dest_id = $today_t + $timeline[$today_date][$k]['time']; if (isset($report[$dest_id])) { foreach ($ev['busy_label'] as $busy_label) { if (!isset($busy_labels[$busy_label])) { $busy_labels[$busy_label] = $busy_label; } if (!isset($report[$dest_id][$busy_label])) { $report[$dest_id][$busy_label] = ''; } $report[$dest_id][$busy_label] .= $ev_print; } } } } } $theme->assign('report', $report); $theme->assign('busy_labels', $busy_labels); //ok, display $theme->display('week'); if ($this->custom_new_event_href_js !== null) { $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__', '__OBJECT__'); } else { $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => '__TIME__', 'timeless' => '__TIMELESS__', 'object' => '__OBJECT__')); } eval_js('Utils_CalendarBusyReport.activate_dclick(\'' . Epesi::escapeJS($jshref, false) . '\')'); }
public function construct() { $this->theme = $this->pack_module(Base_Theme::module_name()); }