public static function submit_contact($values, $mode) { if ($mode == 'display') { $ret = array(); $in = self::Instance(); $filename = self::get_photo($values['id']); if ($filename) { $file = $in->get_data_dir() . $filename; } else { $file = Base_ThemeCommon::get_template_file('CRM/Contacts/Photo', 'placeholder.png'); $ret['photo_note'] = __('Click to change'); } $ret['photo_link'] = Module::create_href(array('upload_new_photo' => $values['id'])) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Click to change the photo'), false); $ret['photo_src'] = $file; } else { $ret = $values; } if (isset($_REQUEST['upload_new_photo']) && $_REQUEST['upload_new_photo'] == $values['id']) { unset($_REQUEST['upload_new_photo']); $x = ModuleManager::get_instance('/Base_Box|0'); if (!$x) { trigger_error('There is no base box module instance', E_USER_ERROR); } $x->push_main('CRM/Contacts/Photo', 'body', array($values)); } return $ret; }
function toHtml() { $str = ""; if ($this->_flagFrozen) { $str .= $this->getFrozenHtml(); } else { $value = $this->getAttribute('value'); if (is_numeric($value)) { $value = date('Y-m-d', $value); } $id = $this->getAttribute('id'); $name = $this->getAttribute('name'); if ($value) { $this->setAttribute('value', Base_RegionalSettingsCommon::time2reg($value, false, true, false)); } if (!isset($id)) { $id = 'datepicker_field_' . $name; $this->updateAttributes(array('id' => $id)); } $ex_date = Base_RegionalSettingsCommon::time2reg(null, false, true, false); $date_format = Base_RegionalSettingsCommon::date_format(); $this->setType('text'); if (!$this->getAttribute('placeholder')) { $this->setAttribute('placeholder', __('Click to select date')); } $js = Utils_PopupCalendarCommon::create_href(md5($id), 'new Ajax.Request(\'modules/Utils/PopupCalendar/up.php\',' . '{method:\'post\', parameters:{date: __YEAR__+\'-\'+__MONTH__+\'-\'+__DAY__},' . 'onSuccess:function(t){e=$(\'' . Epesi::escapeJS($id, false) . '\');if(e) {e.value=t.responseText;jq(e).change();}}})', null, null, 'popup.clonePosition(\'' . $id . '\',{setWidth:false,setHeight:false,offsetTop:$(\'' . $id . '\').getHeight()})', $value, $id); $str .= $this->_getTabs() . '<input ' . $js . ' ' . $this->_getAttrString($this->_attributes) . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Example date: %s', array($ex_date)), false) . ' />'; eval_js('Event.observe(\'' . $id . '\',\'keypress\',Utils_PopupCalendarDatePicker.validate.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))'); eval_js('Event.observe(\'' . $id . '\',\'blur\',Utils_PopupCalendarDatePicker.validate_blur.bindAsEventListener(Utils_PopupCalendarDatePicker,\'' . Epesi::escapeJS($date_format, false) . '\'))'); } return $str; }
public static function print_event($ev, $mode = '', $with_div = true) { $th = Base_ThemeCommon::init_smarty(); $ex = self::process_event($ev); $th->assign('event_id', $ev['id']); $th->assign('draggable', !isset($ev['draggable']) || $ev['draggable'] === true); $title = $ev['title']; $title_st = strip_tags($ev['title']); $title_s = $title; $th->assign('with_div', $with_div); $th->assign('title', $title); $th->assign('title_s', $title_s); $th->assign('description', $ev['description']); $th->assign('color', $ev['color']); $th->assign('start', $ex['start']); $th->assign('start_time', $ex['start_time']); $th->assign('end_time', $ex['end_time']); $th->assign('start_date', $ex['start_date']); $th->assign('end_date', $ex['end_date']); $th->assign('start_day', $ex['start_day']); $th->assign('end_day', $ex['end_day']); $th->assign('end', $ex['end']); $th->assign('duration', $ex['duration']); $th->assign('show_hide_info', __('Click to show / hide menu')); $th->assign('additional_info', $ev['additional_info']); $th->assign('additional_info2', $ev['additional_info2']); if (isset($ev['custom_tooltip'])) { $th->assign('custom_tooltip', $ev['custom_tooltip']); } ob_start(); Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event_tip'); $tip = ob_get_clean(); $th->assign('tip_tag_attrs', Utils_TooltipCommon::open_tag_attrs($tip, false)); if (!isset($ev['view_action']) || $ev['view_action'] === true) { $th->assign('view_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'view'))); } elseif ($ev['view_action'] !== false) { $th->assign('view_href', $ev['view_action']); } if (!isset($ev['edit_action']) || $ev['edit_action'] === true) { $th->assign('edit_href', Module::create_href(array('UCev_id' => $ev['id'], 'UCaction' => 'edit'))); } elseif ($ev['edit_action'] !== false) { $th->assign('edit_href', $ev['edit_action']); } $link_text = Module::create_href_js(array('UCev_id' => $ev['id'], 'UCaction' => 'move', 'UCdate' => '__YEAR__-__MONTH__-__DAY__')); if (!isset($ev['move_action']) || $ev['move_action'] === true) { $th->assign('move_href', Utils_PopupCalendarCommon::create_href('move_event' . str_replace(array('#', '-'), '_', $ev['id']), $link_text, null, null, 'popup.clonePosition(\'utils_calendar_event:' . $ev['id'] . '\',{setWidth:false,setHeight:false,offsetTop:$(\'utils_calendar_event:' . $ev['id'] . '\').getHeight()})')); } if (!isset($ev['delete_action']) || $ev['delete_action'] === true) { $th->assign('delete_href', Module::create_confirm_href(__('Delete this event?'), array('UCev_id' => $ev['id'], 'UCaction' => 'delete'))); } elseif ($ev['delete_action'] !== false) { $th->assign('delete_href', $ev['delete_action']); } $th->assign('handle_class', 'handle'); $th->assign('custom_actions', $ev['actions']); Base_ThemeCommon::display_smarty($th, 'Utils_Calendar', 'event' . ($mode ? '_' . $mode : '')); }
public function body() { print "Tooltip Test<hr>"; print(Utils_TooltipCommon::create('point mouse here', 'tip')); //------------------------------ print out src print('<hr><b>Main</b><br>'); $this->pack_module('Utils/CatFile','modules/Tests/Tooltip/Tooltip_0.php'); print('<hr><b>Common</b><br>'); $this->pack_module('Utils/CatFile','modules/Tests/Tooltip/TooltipCommon_0.php'); print('<hr><b>Install</b><br>'); $this->pack_module('Utils/CatFile','modules/Tests/Tooltip/TooltipInstall.php'); }
public function body() { print "Tooltip Test ver 1.5<hr>"; print Utils_TooltipCommon::create('point mouse here', 'tip'); //------------------------------ print out src print '<hr><b>Main</b><br>'; $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Tooltip/Tooltip_0.php'); print '<hr><b>Common</b><br>'; $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Tooltip/TooltipCommon_0.php'); print '<hr><b>Install</b><br>'; $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Tooltip/TooltipInstall.php'); }
function toHtml() { $str = ""; if ($this->_flagFrozen) { $str .= $this->getFrozenHtml(); } else { $id = $this->getAttribute('id'); $name = $this->getAttribute('name'); if(!isset($id)) { $id = 'currency_field_'.$name; $this->updateAttributes(array('id'=>$id)); } $this->dec_digits = DB::GetOne('SELECT MAX(decimals) FROM utils_currency'); $str .= $this->_getTabs() . '<div style="position: relative;">'; $str .= $this->_getTabs() . '<div style="margin-right:45px;" class="currency_amount"><input ' . $this->_getAttrString($this->_attributes) . ' '. Utils_TooltipCommon::open_tag_attrs(__('Example value: %s',array('123'.Utils_CurrencyFieldCommon::get_decimal_point().implode('',range(4,3+$this->dec_digits)))), false ). ' /></div>'; $str .= $this->_getTabs() . '<div style="margin-right:5px; width:40px; position:absolute;top:0px;right:0px;"><select style="width:40px;" name="__'.str_replace(array('[',']'),'',$name).'__currency" id="__'.$id.'__currency">'; $curs = DB::GetAll('SELECT id, symbol, active FROM utils_currency ORDER BY code'); foreach ($curs as $v) { if ($v['id']!=$this->currency && !$v['active']) continue; $str .= '<option value="'.$v['id'].'"'; if ($v['id']==$this->currency) $str .= ' selected="1"'; $str .= '>'.$v['symbol'].'</option>'; } $str .= '</select></div>'; $str .= $this->_getTabs() . '</div>'; load_js('modules/Utils/CurrencyField/currency.js'); $curr_format = '-?([0-9]*)\\'.Utils_CurrencyFieldCommon::get_decimal_point().'?[0-9]{0,'.$this->dec_digits.'}'; eval_js('Event.observe(\''.$id.'\',\'keypress\',Utils_CurrencyField.validate.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))'); eval_js('Event.observe(\''.$id.'\',\'blur\',Utils_CurrencyField.validate_blur.bindAsEventListener(Utils_CurrencyField,\''.Epesi::escapeJS($curr_format,false).'\'))'); } return $str; } //end func toHtml
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; }
private function create_tooltip($ref_rec, $col, $value, $c = '') { if ($this->pdf) { return ''; } return Utils_TooltipCommon::open_tag_attrs(strip_tags($ref_rec) . '<hr>' . $col . '<br>' . ($c != '' ? $c . ': ' : '') . $value, false) . ' '; }
public function sent_tab($count_f, $get_f, $statuses) { $t = time(); $start =& $this->get_module_variable('start', date('Y-m-d', $t - 7 * 24 * 60 * 60)); $end =& $this->get_module_variable('end', date('Y-m-d', $t)); $status =& $this->get_module_variable('sent_status', current(array_keys($statuses))); $offset =& $this->get_module_variable('sent_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('datepicker', 'start', __('From')); $form->addElement('datepicker', 'end', __('To')); $form->addElement('submit', 'submit_button', __('Show')); $form->addRule('start', 'Field required', 'required'); $form->addRule('status', 'Field required', 'required'); $form->addRule('end', 'Field required', 'required'); $form->setDefaults(array('status' => $status, 'start' => $start, 'end' => $end)); if ($form->validate()) { $data = $form->exportValues(); $start = $data['start']; $end = $data['end']; $end = date('Y-m-d', strtotime($end) + 86400); 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, 'sent'); $m->set_table_columns(array(array('name' => 'To', 'width' => 30, 'order' => 'toNumber'), array('name' => 'Status', 'width' => 10), array('name' => 'Date', 'width' => 10, 'order' => 'sentDate'), array('name' => 'Pages', 'width' => 10), array('name' => 'Cost', 'width' => 10), array('name' => 'File', 'width' => 30))); $m->set_default_order(array('Date' => 'DESC')); $count = call_user_func($count_f, $start, $end, $status); if ($count === false) { $count = 0; } $limits = $m->get_limit($count); $order = $m->get_order(); if ($count != 0) { $data = call_user_func($get_f, $start, $end, $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) . ')', Utils_TooltipCommon::create($statuses[$row['faxStatus']], $row['faxStatusDetails']), Base_RegionalSettingsCommon::time2reg($row['sentDate']), $row['noPages'], $row['sentCost'], '<a href="' . $row['fileUrl'] . '" target="_blank">' . $row['fileName'] . '</a>'); } $theme->assign('table_data', $this->get_html_of_module($m)); $theme->display(); }
public function body($arg = null, $rb = null, $uid = null) { if (isset($arg) && isset($rb)) { $this->group = $rb->tab . '/' . $arg['id']; if (Utils_WatchdogCommon::get_category_id($rb->tab) !== null) { $this->watchdog_category = $rb->tab; $this->watchdog_id = $arg['id']; } $this->set_view_func(array('Utils_RecordBrowserCommon', 'create_default_linked_label'), array($rb->tab, $arg['id'])); } if (!isset($this->group) && !$uid) { trigger_error('Key not given to attachment module', E_USER_ERROR); } $_SESSION['client']['utils_attachment_group'] = $this->group; load_js('modules/Utils/Attachment/attachments.js'); Base_ThemeCommon::load_css('Utils_Attachment', 'browse'); $this->rb = $this->init_module(Utils_RecordBrowser::module_name(), 'utils_attachment', 'utils_attachment'); $defaults = array('permission' => Base_User_SettingsCommon::get('CRM_Common', 'default_record_permission'), 'func' => serialize($this->func), 'args' => serialize($this->args)); $rb_cols = array(); $single_group = is_string($this->group) || count($this->group) == 1; if ($this->force_multiple) { $single_group = false; } if ($single_group) { $group = is_string($this->group) ? $this->group : reset($this->group); $defaults['local'] = $group; } else { // force attached to display $rb_cols['attached_to'] = true; $this->rb->set_button(false); } $this->rb->set_defaults($defaults); $this->rb->set_additional_actions_method(array($this, 'add_actions')); $this->rb->set_header_properties(array('sticky' => array('width' => 1, 'display' => false), 'attached_to' => array('width' => "16em"), 'edited_on' => array('width' => "12em"), 'title' => array('width' => "20em"))); if ($uid) { $this->rb->set_button(false); $this->rb->disable_actions(array('delete')); $this->display_module($this->rb, array(array(':Created_by' => $uid), $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } else { $crits = array(); if (!is_array($this->group)) { $this->group = array($this->group); } if (isset($_SESSION['attachment_copy']) && count($this->group) == 1 && $_SESSION['attachment_copy']['group'] != $this->group) { $this->rb->new_button(Base_ThemeCommon::get_template_file(Utils_Attachment::module_name(), 'link.png'), __('Paste'), Utils_TooltipCommon::open_tag_attrs($_SESSION['attachment_copy']['text']) . ' ' . $this->create_callback_href(array($this, 'paste'))); } if ($this->group) { $g = array_map(array('DB', 'qstr'), $this->group); $crits['id'] = DB::GetCol('SELECT attachment FROM utils_attachment_local WHERE local IN (' . implode(',', $g) . ')'); } else { $crits['id'] = 0; } $this->display_module($this->rb, array($crits, $rb_cols, array('sticky' => 'DESC', 'edited_on' => 'DESC')), 'show_data'); } }
public function body() { if (!Acl::is_user()) { return; } $th = $this->init_module('Base/Theme'); 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'); $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>'; }
private static function show_help() { if(!isset(self::$help_tooltips)) self::$help_tooltips = Base_User_SettingsCommon::get('Utils/Tooltip','help_tooltips'); }
public function register_form($data = null) { if ($this->is_back()) { return false; } Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href()); $f = $this->init_module(Libs_QuickForm::module_name()); $admin_email_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('This email will be used to send registation link and to contact Administator directly.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> '; $tax_id_tooltip = '<img ' . Utils_TooltipCommon::open_tag_attrs(__('Your company Tax ID for invoices.'), false) . ' src="' . Base_ThemeCommon::get_icon('info') . '"/> '; $f->addElement('text', 'company_name', __('Company Name'), array('maxlength' => 128)); $f->addRule('company_name', __('Field required'), 'required'); $f->addRule('company_name', __('Max length exceeded'), 'maxlength', 128); $f->addElement('text', 'short_name', __('Short Name'), array('maxlength' => 64)); $f->addRule('short_name', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'phone', __('Phone'), array('maxlength' => 64)); $f->addRule('phone', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'fax', __('Fax'), array('maxlength' => 64)); $f->addRule('fax', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'email', __('Company email'), array('maxlength' => 128)); $f->addRule('email', __('Max length exceeded'), 'maxlength', 128); $f->addRule('email', __('Invalid e-mail address'), 'email'); $f->addElement('text', 'web_address', __('Web address'), array('maxlength' => 64)); $f->addRule('web_address', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'address_1', __('Address 1'), array('maxlength' => 64)); $f->addRule('address_1', __('Field required'), 'required'); $f->addRule('address_1', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'address_2', __('Address 2'), array('maxlength' => 64)); $f->addRule('address_2', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'city', __('City'), array('maxlength' => 64)); $f->addRule('city', __('Field required'), 'required'); $f->addRule('city', __('Max length exceeded'), 'maxlength', 64); $f->addElement('commondata', 'country', __('Country'), 'Countries'); $f->addRule('country', __('Field required'), 'required'); $f->addElement('commondata', 'zone', __('Zone'), array('Countries', 'country'), array('empty_option' => true)); $f->addElement('text', 'postal_code', __('Postal Code'), array('maxlength' => 64)); $f->addRule('postal_code', __('Field required'), 'required'); $f->addRule('postal_code', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'tax_id', $tax_id_tooltip . __('Tax ID'), array('maxlength' => 64)); $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'admin_first_name', __('Administrator\'s first name'), array('maxlength' => 64)); $f->addRule('admin_first_name', __('Field required'), 'required'); $f->addRule('admin_first_name', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'admin_last_name', __('Administrator\'s last name'), array('maxlength' => 64)); $f->addRule('admin_last_name', __('Field required'), 'required'); $f->addRule('admin_last_name', __('Max length exceeded'), 'maxlength', 64); $f->addElement('text', 'admin_email', $admin_email_tooltip . __('Administrator\'s email'), array('maxlength' => 128)); $f->addRule('admin_email', __('Field required'), 'required'); $f->addRule('admin_email', __('Max length exceeded'), 'maxlength', 128); $f->addRule('admin_email', __('Invalid e-mail address'), 'email'); if ($f->validate()) { $ret = $f->exportValues(); $ret = Base_EssClientCommon::server()->register_installation_request($ret); if ($ret) { if (is_string($ret)) { Base_EssClientCommon::set_license_key($ret); } location(array()); return false; } } // set defaults print '<div class="important_notice">'; print __('Enter Company and Administrator details. This data will be sent to EPESI Store Server to provide us with contact information. The data sent to EPESI Store Server is limited only to the data you enter using this form and what modules are being purchased and downloaded.'); print '<br>'; if ($data) { $f->setDefaults($data); } else { if (ModuleManager::is_installed('CRM_Contacts') > -1) { print '<span style="color:gray;font-size:10px;">' . __('Data below was auto-filled based on Main Company and first Super administrator. Make sure that the data is correct and change it if necessary.') . '</span>'; $defaults = Base_EssClientCommon::get_possible_admin(); $mc = CRM_ContactsCommon::get_main_company(); if ($mc > 0) { $company = CRM_ContactsCommon::get_company($mc); if ($company) { $defaults = array_merge($company, $defaults); } } $f->setDefaults($defaults); } } if ($data) { if (isset($data['status']) && strcasecmp($data['status'], 'Confirmed') == 0) { print '<div style="color:gray;font-size:10px;">' . __('Updating Company data will require re-validation by our representative.') . '</div>'; } print '<div style="color:red;font-size:10px;">' . __('Changing Administrator e-mail address will require e-mail confirmation.') . '</div>'; } print '<center>'; $f->addElement('submit', 'submit', $data ? __('Update') : __('Register')); $f->display_as_column(); print '</center>'; print '</div>'; return true; }
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'); }
protected function GB_row_data_transform_module_licenses(array $data) { // module name if (isset($data['module'])) { $data['module'] = $this->module_info_tooltip($data['module']); } // paid if (isset($data['paid'])) { if (!$data['paid']) { $this->navigation_button_orders(); } $data['paid'] = $data['paid'] ? __('Yes') : __('No - Go to orders to pay'); } // active if (isset($data['active'])) { $text = $data['active'] ? __('Yes') : __('No'); $tip = $data['active'] ? __('You can download newer version if it\'s available') : __('You cannot download newer version'); $data['active'] = "<a " . Utils_TooltipCommon::open_tag_attrs($tip) . ">{$text}</a>"; } return $data; }
/** * Displays action bar. */ public function body() { $this->help('ActionBar basics', 'main'); $icons = Base_ActionBarCommon::get(); //sort usort($icons, array($this, 'compare')); //translate foreach ($icons as &$i) { $description = $i['description']; if ($i['description']) { $t = Utils_TooltipCommon::open_tag_attrs($description); } else { $t = ''; } $i['open'] = '<a ' . $i['action'] . ' ' . $t . '>'; $i['close'] = '</a>'; $i['helpID'] = 'ActionBar_' . $i['icon']; if (strpos($i['icon'], '/') !== false && file_exists($i['icon'])) { $i['icon_url'] = $i['icon']; unset($i['icon']); } //if (isset(Base_ActionBarCommon::$available_icons[$i['icon']])) // $i['icon'] = Base_ThemeCommon::get_template_file('Base_ActionBar','icons/'.$i['icon'].'.png'); } $launcher = array(); if (Base_AclCommon::is_user()) { $opts = Base_Menu_QuickAccessCommon::get_options(); if (!empty($opts)) { self::$launchpad = array(); foreach ($opts as $k => $v) { if (Base_ActionBarCommon::$quick_access_shortcuts && Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')) { $ii = array(); $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1)); $ii['label'] = $trimmed_label ? $trimmed_label : $v['label']; $ii['description'] = $v['label']; $arr = $v['link']; if (isset($arr['__url__'])) { $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank">'; } else { $ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . '>'; } $ii['close'] = '</a>'; if (isset($v['link']['__icon__'])) { $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']); } else { $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png'); } if (!$icon) { $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png'); } $ii['icon'] = $icon; $launcher[] = $ii; } if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) { $ii = array(); $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1)); $ii['label'] = $trimmed_label ? $trimmed_label : $v['label']; $ii['description'] = $v['label']; $arr = $v['link']; if (isset($arr['__url__'])) { $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" onClick="actionbar_launchpad_deactivate()">'; } else { $ii['open'] = '<a onClick="actionbar_launchpad_deactivate();' . Base_MenuCommon::create_href_js($this, $arr) . '" href="javascript:void(0)">'; } $ii['close'] = '</a>'; if (isset($v['link']['__icon__'])) { $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']); } else { $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png'); } if (!$icon) { $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png'); } $ii['icon'] = $icon; self::$launchpad[] = $ii; } } } } //display $th = $this->pack_module(Base_Theme::module_name()); $th->assign('icons', $icons); $th->assign('launcher', array_reverse($launcher)); $th->display(); }
public static function get_change_subscription_icon_tags($category_name, $id) { $category_id = self::get_category_id($category_name); if (!$category_id) { return; } $last_seen = self::check_if_notified($category_name, $id); load_js('modules/Utils/Watchdog/subscribe.js'); $tag_id = 'watchdog_sub_button_' . $category_name . '_' . $id; $href = ' onclick="utils_watchdog_set_subscribe(' . ($last_seen === null ? 1 : 0) . ',\'' . $category_name . '\',' . $id . ',\'' . $tag_id . '\')" href="javascript:void(0);"'; if ($last_seen === null) { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png'); $tooltip = __('Click to watch this record for changes.'); } else { if ($last_seen === true) { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png'); $tooltip = __('You are watching this record, click to stop watching this record for changes.'); } else { $icon = Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png'); $ev = self::display_events($category_id, $last_seen, $id); $tooltip = __('You are watching this record, click to stop watching this record for changes.') . ($ev ? '<br>' . __('The following changes were made since the last time you were viewing this record:') . '<br><br>' . $ev['events'] : ''); } } $subscribers = self::get_subscribers($category_name, $id); $my_user = Base_AclCommon::get_user(); if ($subscribers) { $icon_on = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"'; $icon_off = ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"'; $other_subscribers = array(); foreach ($subscribers as $subscriber) { if ($subscriber == $my_user) { continue; } if (class_exists('CRM_ContactsCommon')) { $contact = CRM_ContactsCommon::get_user_label($subscriber, true); } else { $contact = Base_UserCommon::get_user_login($subscriber); } $notified = self::user_check_if_notified($subscriber, $category_name, $id); $icon2 = $notified === true ? $icon_on : $icon_off; $other_subscribers[] = '<img style="margin-right:4px;" ' . $icon2 . ' /><a>' . Utils_RecordBrowserCommon::no_wrap($contact) . '</a>'; } if ($other_subscribers) { $tooltip .= '<hr />' . implode('<br>', $other_subscribers); } } $tooltip = Utils_TooltipCommon::open_tag_attrs($tooltip); return '<a ' . $href . ' ' . $tooltip . '><img border="0" src="' . $icon . '"></a>'; }
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'); $t->assign('packages', $sorted); $t->assign('filters', $filters); $t->assign('version_label', __('Ver. ')); $t->assign('labels', array('options' => __('Optional'))); $t->display(); }
public function agenda() { $theme = $this->pack_module('Base/Theme'); Base_ThemeCommon::load_css('Utils_Calendar', 'common'); /////////////// controls //////////////////////// $start = & $this->get_module_variable('agenda_start',date('Y-m-d',$this->date)); $end = & $this->get_module_variable('agenda_end',date('Y-m-d',$this->date + (7 * 24 * 60 * 60))); $form = $this->init_module('Libs/QuickForm',null,'agenda_frm'); $form->addElement('datepicker', 'start', __('From')); $form->addElement('datepicker', 'end', __('To')); $form->addElement('submit', 'submit_button', __('Show')); $form->addRule('start', 'Field required', 'required'); $form->addRule('end', 'Field required', 'required'); $form->setDefaults(array('start'=>$start,'end'=>$end)); if($form->validate()) { $data = $form->exportValues(); $start = $data['start']; $end = $data['end']; $end = date('Y-m-d',strtotime($end)+86400); } $form->assign_theme('form', $theme, new HTML_QuickForm_Renderer_TCMSArraySmarty()); 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); //////////////// data //////////////////////// $gb = $this->init_module('Utils/GenericBrowser', null, 'agenda'); $columns = array( array('name'=>__('Start'), 'order'=>'start', 'width'=>10), array('name'=>__('Duration'), 'order'=>'end', 'width'=>5), array('name'=>__('Title'), 'order'=>'title','width'=>10)); $add_cols = array(); if(is_array($this->settings['custom_agenda_cols'])) { $w = 50/count($this->settings['custom_agenda_cols']); foreach($this->settings['custom_agenda_cols'] as $k=>$col) { if (!is_array($col)) $col = array('name'=>$col, 'order'=>'cus_col_'.$k,'width'=>$w); $columns[] = $col; $add_cols[] = $k; } } $gb->set_table_columns( $columns ); $gb->set_default_order(array(__('Start')=>'ASC')); //add data $ret = $this->get_events($start,$end); $this->displayed_events = array('start'=>$start, 'end'=>$end,'events'=>$ret); foreach($ret as $row) { $r = $gb->get_new_row(); if (isset($row['status']) && $row['status']=='closed') continue; $view_h = $this->create_callback_href(array($this,'push_event_action'),array('view',$row['id'])); $edit_h = $this->create_callback_href(array($this,'push_event_action'),array('edit',$row['id'])); $del_h = $this->create_confirm_callback_href(__('Delete this event?'),array($this,'delete_event'),$row['id']); if (isset($row['view_action'])) $view_h = $row['view_action']; if (isset($row['edit_action'])) $edit_h = $row['edit_action']; if (isset($row['delete_action'])) $del_h = $row['delete_action']; $ex = Utils_CalendarCommon::process_event($row); $rrr = array(array('value'=>$ex['start'],'order_value'=>$row['start']),Utils_TooltipCommon::create($ex['duration'],$ex['end'],false),'<a '.$view_h.'>'.$row['title'].'</a>'); foreach($add_cols as $a) if (isset($row['custom_agenda_col_'.$a])) $rrr[] = $row['custom_agenda_col_'.$a]; else $rrr[] = ''; $r->add_data_array($rrr); if($row['additional_info']!=='' || $row['additional_info2']) $r->add_info($row['additional_info'].(($row['additional_info']!=='' && $row['additional_info2']!=='')?'<hr>':'').$row['additional_info2']); $r->add_action($del_h,'Delete'); $r->add_action($edit_h,'Edit'); $r->add_action($view_h,'View'); } $theme->assign('agenda',$this->get_html_of_module($gb,array(false),'automatic_display')); //////////////// display /////////////// $theme->display('agenda'); }
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 display_activities($events, $tasks, $phonecalls) { $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'activities', 'activities'); $gb->set_table_columns(array(array('name' => __('Type'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Subject'), 'width' => 20), array('name' => __('Date/Deadline'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Employees'), 'width' => 11), array('name' => __('Customers'), 'width' => 11), array('name' => __('Attachments'), 'width' => 4))); $amount = 0; if ($this->display['events']) { $amount += count($events); } if ($this->display['tasks']) { $amount += count($tasks); } if ($this->display['phonecalls']) { $amount += count($phonecalls); } $limit = $gb->get_limit($amount); for ($i = 0; $i < $limit['offset'] + $limit['numrows'] && $i < $amount; $i++) { if ($this->display['events'] && count($events)) { $ev = current($events); } else { $ev = array('start' => -1); } if ($this->display['tasks'] && count($tasks)) { $t = current($tasks); if (!$t['deadline']) { $t['deadline'] = 0; } else { $t['deadline'] = strtotime($t['deadline']); } } else { $t = array('deadline' => -1); } if ($this->display['phonecalls'] && count($phonecalls)) { $ph = current($phonecalls); $ph['date_and_time'] = strtotime($ph['date_and_time']); } else { $ph = array('date_and_time' => -1); } $maxt = max($ev['start'], $t['deadline'], $ph['date_and_time']); $gb_row = $gb->get_new_row(); if ($ev['start'] == $maxt) { $v = array_shift($events); if ($i >= $limit['offset'] && $v) { if (isset($v['view_action'])) { $view_href = $v['view_action']; } else { $view_href = $this->create_callback_href(array($this, 'view_event'), array($v['id'])); } $title = '<a ' . $view_href . '>' . $v['title'] . '</a>'; if (isset($v['description']) && $v['description'] != '') { $title = '<span ' . Utils_TooltipCommon::open_tag_attrs($v['description'], false) . '>' . $title . '</span>'; } $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('crm_meeting', $v['id'])); $gb_row->add_data(__('Meeting'), $title, Base_RegionalSettingsCommon::time2reg($v['start'], $v['duration'] == -1 ? false : 2), CRM_ContactsCommon::display_contact(array('employees' => $v['employees']), false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact(array('customers' => $v['customers']), false, array('id' => 'customers', 'param' => ';::')), Utils_AttachmentCommon::count('crm_meeting/' . $v['id'])); } } elseif ($t['deadline'] == $maxt) { $v = array_shift($tasks); $v = Utils_RecordBrowserCommon::filter_record_by_access('task', $v); if ($i >= $limit['offset'] && $v) { $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('task', $v['id'])); $gb_row->add_data(__('Task'), CRM_TasksCommon::display_title($v, false), !isset($v['deadline']) || !$v['deadline'] ? __('No deadline') : Base_RegionalSettingsCommon::time2reg($v['deadline'], false, true, false), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact($v, false, array('id' => 'customers')), Utils_AttachmentCommon::count('task/' . $v['id'])); } } else { $v = array_shift($phonecalls); $v = Utils_RecordBrowserCommon::filter_record_by_access('phonecall', $v); if ($i >= $limit['offset'] && $v) { $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('phonecall', $v['id'])); $gb_row->add_data(__('Phonecall'), CRM_PhoneCallCommon::display_subject($v), Base_RegionalSettingsCommon::time2reg($v['date_and_time'], 2), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_PhoneCallCommon::display_contact_name($v, false), Utils_AttachmentCommon::count('phonecall/' . $v['id'])); } } } $this->display_module($gb); }
public static function get_remove_applet_button($id, $default_dash) { return '<a class="remove" id="dashboard_remove_applet_' . $id . '" ' . (is_numeric($id) ? '' : 'style="display:none;" ') . Utils_TooltipCommon::open_tag_attrs(__('Remove')) . ' href="javascript:void(0);" onClick="if(confirm(\'' . __('Delete this applet?') . '\'))remove_applet(' . (is_numeric($id) ? $id : -1) . ',' . ($default_dash ? 1 : 0) . ');">x</a>'; }
public static function QFfield_select(&$form, $field, $label, $mode, $default, $desc, $rb_obj) { if (self::QFfield_static_display($form, $field, $label, $mode, $default, $desc, $rb_obj)) { return; } $record = $rb_obj->record; $comp = array(); $param = explode(';', $desc['param']); $crits_callback = isset($param[1]) ? $param[1] : null; $multi_adv_params_callback = isset($param[2]) ? explode('::', $param[2]) : null; $multi_adv_params = array(); if (is_callable($multi_adv_params_callback)) { $multi_adv_params = call_user_func($multi_adv_params_callback, $record); } // check multi_adv_params structure and fill empty values if (!is_array($multi_adv_params)) { $multi_adv_params = array(); } if (!isset($multi_adv_params['order'])) { $multi_adv_params['order'] = array(); } if (!isset($multi_adv_params['cols'])) { $multi_adv_params['cols'] = array(); } if (!isset($multi_adv_params['format_callback'])) { $multi_adv_params['format_callback'] = array(); } $reference = explode('::', $param[0]); $tab = $reference[0]; $columns = isset($reference[1]) ? $reference[1] : null; if (!isset($columns)) { trigger_error("Columns not set for field: {$field}"); } if ($tab == '__COMMON__') { $order = isset($reference[2]) ? $reference[2] : 'value'; $data = Utils_CommonDataCommon::get_translated_tree($columns, $order == 'key'); if (!is_array($data)) { $data = array(); } $comp = $comp + $data; $rec_count = 0; $label = Utils_RecordBrowserCommon::get_field_tooltip($label, 'commondata', $columns); } else { if (isset($crits_callback)) { $crit_callback = explode('::', $crits_callback); if (is_callable($crit_callback)) { $crits = call_user_func($crit_callback, false, $record); $adv_crits = call_user_func($crit_callback, true, $record); } else { $crits = $adv_crits = array(); } if ($adv_crits === $crits) { $adv_crits = null; } if ($adv_crits !== null) { $crits = $adv_crits; } } else { $crits = array(); } if ($tab == '__RECORDSETS__') { $tabs = DB::GetCol('SELECT tab FROM recordbrowser_table_properties'); } else { $tabs = explode(',', $tab); } $single_tab = count($tabs) == 1; if (!$single_tab && empty($crits)) { foreach ($tabs as $tab) { $crits[$tab] = array(); } } // get related records with proper columns $col_id = array(); if ($single_tab) { $columns = array_filter(explode('|', $columns)); foreach ($columns as $c) { $col_id[] = self::get_field_id($c); } } $rec_count = 0; foreach ($tabs as $t) { if (!empty($crits) && !$single_tab && !isset($crits[$t])) { continue; } $rec_count += Utils_RecordBrowserCommon::get_records_count($t, $single_tab ? $crits : $crits[$t], null); } if ($rec_count <= Utils_RecordBrowserCommon::$options_limit) { $records = array(); foreach ($tabs as $t) { if (!empty($crits) && !$single_tab && !isset($crits[$t])) { continue; } $access = self::get_access($t, 'selection', null, true); if ($access === false) { continue; } if ($access !== true && is_array($access)) { if ($single_tab) { $crits = self::merge_crits($crits, $access); } elseif (isset($crits[$t]) && is_array($crits[$t]) && $crits[$t]) { $crits[$t] = self::merge_crits($crits[$t], $access); } else { $crits[$t] = $access; } } $records_tmp = Utils_RecordBrowserCommon::get_records($t, $single_tab ? $crits : $crits[$t], array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array()); foreach ($records_tmp as $key => $rec) { if (!self::get_access($t, 'view', $rec)) { continue; } $records[($single_tab ? '' : $t . '/') . $key] = $rec; } } } else { $records = array(); } // set current record field value to array if (isset($record[$field])) { if (!is_array($record[$field])) { if ($record[$field] != '') { $record[$field] = array($record[$field] => $record[$field]); } else { $record[$field] = array(); } } } if ($default) { if (!is_array($default)) { $record[$field][$default] = $default; } else { foreach ($default as $v) { $record[$field][$v] = $v; } } } $ext_rec = array(); $columns_qty = count($col_id); if (isset($record[$field])) { $ext_rec = array_flip($record[$field]); foreach ($ext_rec as $k => $v) { $kk = explode('/', $k, 2); if (count($kk) == 1) { if ($single_tab && is_numeric($kk[0])) { $t = $tab; $record_id = $kk[0]; } else { continue; } } else { $t = $kk[0]; $record_id = $kk[1]; if (!self::check_table_name($t, false, false) || !is_numeric($record_id)) { continue; } } $c = Utils_RecordBrowserCommon::get_record($t, $record_id); if (!empty($multi_adv_params['format_callback'])) { $n = call_user_func($multi_adv_params['format_callback'], $c); } else { if ($columns_qty == 0) { $n = self::create_default_linked_label($t, $record_id, true); } elseif ($columns_qty == 1) { $n = self::get_val($t, $col_id[0], $c, true); } else { $n = array(); foreach ($col_id as $cid) { $n[] = self::get_val($t, $cid, $c, true); } $n = implode(' ', $n); } } $comp[($single_tab ? '' : $t . '/') . $record_id] = $n; } } // if (!empty($multi_adv_params['order'])) // natcasesort($comp); foreach ($records as $k => $v) { if (!empty($multi_adv_params['format_callback'])) { $n = call_user_func($multi_adv_params['format_callback'], $v); } else { if ($single_tab && is_numeric($k)) { $t = $tab; $record_id = $k; } else { $kk = explode('/', $k, 2); $t = $kk[0]; $record_id = $kk[1]; } if ($columns_qty == 0) { $n = self::create_default_linked_label($t, $record_id, true); } elseif ($columns_qty == 1) { $n = self::get_val($t, $col_id[0], $v, true); } else { $n = array(); foreach ($col_id as $cid) { $n[] = self::get_val($t, $cid, $v, true); } $n = implode(' ', $n); } } $comp[$k] = $n; unset($ext_rec[$v['id']]); unset($ext_rec[$k]); } if (empty($multi_adv_params['order'])) { natcasesort($comp); } if ($single_tab) { $label = Utils_RecordBrowserCommon::get_field_tooltip($label, $desc['type'], reset($tabs), $crits); } } if ($rec_count > Utils_RecordBrowserCommon::$options_limit) { $f_callback = $multi_adv_params['format_callback']; if (empty($f_callback)) { $f_callback = array('Utils_RecordBrowserCommon', 'autoselect_label'); } if ($desc['type'] == 'multiselect') { $el = $form->addElement('automulti', $field, $label, array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param']), $f_callback); if ($single_tab) { ${'rp_' . $field} = $rb_obj->init_module(Utils_RecordBrowser_RecordPicker::module_name(), array()); $filters_defaults = isset($multi_adv_params['filters_defaults']) ? $multi_adv_params['filters_defaults'] : array(); $rb_obj->display_module(${'rp_' . $field}, array($tab, $field, $multi_adv_params['format_callback'], $crits, array(), array(), array(), $filters_defaults)); $el->set_search_button('<a ' . ${'rp_' . $field}->create_open_href() . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Advanced Selection')) . ' href="javascript:void(0);"><img border="0" src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'icon_zoom.png') . '"></a>'); } } else { $form->addElement('autoselect', $field, $label, $comp, array(array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param'])), $f_callback); } } else { if ($desc['type'] === 'select') { $comp = array('' => '---') + $comp; } $form->addElement($desc['type'], $field, $label, $comp, array('id' => $field)); } if ($mode !== 'add') { $form->setDefaults(array($field => $default)); } }
/** * Format info table about module. * Used with Ajax request from EpesiStore_0.php file * @param array $r modules data * @return string html with table */ public static function module_format_info($r) { if (isset($r['id'])) { unset($r['id']); } if (isset($r['active'])) { $r['active'] = $r['active'] ? __('Yes') : __('No'); } $r['files'] = implode("<br/>", $r['files']); unset($r['icon_url']); unset($r['description_url']); unset($r['required_modules']); unset($r['needed_modules']); return Utils_TooltipCommon::format_info_tooltip($r); }
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; }
} @set_time_limit(0); $rec = Utils_RecordBrowserCommon::get_record('rc_accounts', $_POST['acc_id']); if ($rec['epesi_user'] !== Acl::get_user()) { die('invalid account id'); } $port = $rec['security'] == 'ssl' ? 993 : 143; $server_str = '{' . $rec['server'] . '/imap/readonly/novalidate-cert' . ($rec['security'] ? '/' . $rec['security'] : '') . ':' . $port . '}'; $mailbox = @imap_open(imap_utf7_encode($server_str), imap_utf7_encode($rec['login']), imap_utf7_encode($rec['password']), OP_READONLY || OP_SILENT); $err = imap_errors(); if (!$mailbox || $err) { die(Utils_TooltipCommon::create(__('Connection error'), $err, false)); } $uns = @imap_search($mailbox, 'UNSEEN ALL'); $unseen = array(); if ($uns) { $l = @imap_fetch_overview($mailbox, implode(',', $uns), 0); $err = imap_errors(); if (!$l || $err) { die('error reading messages overview'); } foreach ($l as $msg) { $from = isset($msg->from) ? $msg->from : '<unknown>'; $subject = isset($msg->subject) ? $msg->subject : '<no subject>'; $unseen[] = htmlspecialchars(imap_utf8($from)) . ': <i>' . htmlspecialchars(imap_utf8($subject)) . '</i>'; } } print Utils_TooltipCommon::create(count($unseen), implode('<br />', $unseen)); $err = imap_errors(); print_r('<span style="display:none;">' . $err . '</span>'); imap_close($mailbox);
public function applet($conf, &$opts) { Epesi::load_js('modules/CRM/Roundcube/utils.js'); $opts['go'] = true; $accounts = array(); $ret = array(); $update_applet = ''; foreach ($conf as $key => $on) { $x = explode('_', $key); if ($x[0] == 'account' && $on) { $id = $x[1]; $accounts[] = $id; } } $accs = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user(), 'id' => $accounts)); print '<ul>'; foreach ($accs as $row) { $mail = $row['account_name']; $cell_id = 'mailaccount_' . $opts['id'] . '_' . $row['id']; //interval execution eval_js_once('setInterval(\'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' , 0)\',300000)'); //and now $update_applet .= 'CRM_RC.update_msg_num(' . $opts['id'] . ' ,' . $row['id'] . ' ,1);'; print '<li><i><a' . $this->create_callback_href(array($this, 'open_rc_account'), $row['id']) . '>' . $mail . '</a></i> - <span id="' . $cell_id . '"></span></li>'; } print '</ul>'; $this->js($update_applet); $href = $this->create_callback_href(array('Base_BoxCommon', 'push_module'), array($this->get_type(), 'account_manager', array(true))); $img = '<img src="' . Base_ThemeCommon::get_template_file('Base_Dashboard', 'configure.png') . '" border="0">'; $tooltip = Utils_TooltipCommon::open_tag_attrs(__('Go to account settings')); $opts['actions'][] = "<a {$tooltip} {$href}>{$img}</a>"; }
public function manage_permissions() { $this->help('Permissions Editor','permissions'); $this->init(); $gb = $this->init_module('Utils/GenericBrowser','permissions_'.$this->tab, 'permissions_'.$this->tab); $gb->set_table_columns(array( array('name'=>__('Access type'), 'width'=>'100px'), array('name'=>__('Clearance required'), 'width'=>'30'), array('name'=>__('Applies to records'), 'width'=>'60'), array('name'=>__('Fields'), 'width'=>'100px') )); $ret = DB::Execute('SELECT * FROM '.$this->tab.'_access AS acs ORDER BY action DESC'); $tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_clearance AS acs'); $clearance = array(); foreach ($tmp as $t) $clearance[$t['rule_id']][] = $t['clearance']; $tmp = DB::GetAll('SELECT * FROM '.$this->tab.'_access_fields AS acs'); $fields = array(); foreach ($tmp as $t) $fields[$t['rule_id']][] = $t['block_field']; $all_clearances = array_flip(Base_AclCommon::get_clearance(true)); $all_fields = array(); foreach ($this->table_rows as $v) $all_fields[$v['id']] = $v['name']; $actions = $this->get_permission_actions(); $rules = array(); while ($row = $ret->FetchRow()) { if (!isset($clearance[$row['id']])) $clearance[$row['id']] = array(); if (!isset($fields[$row['id']])) $fields[$row['id']] = array(); $action = $actions[$row['action']]; $crits = Utils_RecordBrowserCommon::parse_access_crits($row['crits'], true); $crits = Utils_RecordBrowserCommon::crits_to_words($this->tab, $crits, false); $crits_text = ''; foreach ($crits as $c) { switch ($c) { case 'and': $crits_text .= '<span class="joint">'.__('and').'</span><br>'; break; case 'or': $crits_text .= '<span class="joint">'.__('or').'</span> '; break; default: $crits_text .= $c.' '; } } foreach ($fields[$row['id']] as $k=>$v) if (isset($all_fields[$v])) $fields[$row['id']][$k] = $all_fields[$v]; else unset($fields[$row['id']][$k]); foreach ($clearance[$row['id']] as $k=>$v) if (isset($all_clearances[$v])) $clearance[$row['id']][$k] = $all_clearances[$v]; else unset($clearance[$row['id']][$k]); $c_all_fields = count($all_fields); $c_fields = count($fields[$row['id']]); $props = $c_all_fields?($c_all_fields-$c_fields)/$c_all_fields:0; $color = dechex(255-68*$props).dechex(187+68*$props).'BB'; $fields_value = ($c_all_fields-$c_fields).' / '.$c_all_fields; if ($props!=1) $fields_value = Utils_TooltipCommon::create($fields_value, '<b>'.__('Excluded fields').':</b><hr>'.implode('<br>',$fields[$row['id']]), false); $rules[$row['action']][$row['id']] = array( $action, '<span class="Utils_RecordBrowser__permissions_crits">'.implode(' <span class="joint">'.__('and').'</span><br>',$clearance[$row['id']]).'</span>', array('value'=>'<span class="Utils_RecordBrowser__permissions_crits">'.$crits_text.'</span>', 'overflow_box'=>false), array('style'=>'background-color:#'.$color, 'value'=>$fields_value) ); } foreach ($actions as $a=>$l) if (isset($rules[$a])) foreach ($rules[$a] as $id=>$vals) { $gb_row = $gb->get_new_row(); $gb_row->add_data_array($vals); if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')==2) { $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id)), 'edit', 'Edit'); $gb_row->add_action($this->create_callback_href(array($this, 'edit_permissions_rule'), array($id, true)), 'copy', __('Clone rule'), Base_ThemeCommon::get_template_file('Utils/Attachment','copy_small.png')); $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this rule?'), array($this, 'delete_permissions_rule'), array($id)), 'delete', 'Delete'); } } if (Base_AdminCommon::get_access('Utils_RecordBrowser', 'permissions')==2) Base_ActionBarCommon::add('add',__('Add new rule'), $this->create_callback_href(array($this, 'edit_permissions_rule'), array(null))); Base_ThemeCommon::load_css('Utils_RecordBrowser', 'edit_permissions'); $this->display_module($gb); eval_js('utils_recordbrowser__crits_initialized = false;'); }
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'); $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 static function display_contacts_with_notification($recordset, $record, $nolink, $desc) { $icon_on = Utils_TooltipCommon::open_tag_attrs(__('This person is up to date with all changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small.png') . '"'; $icon_off = Utils_TooltipCommon::open_tag_attrs(__('This person has notifications pending about changes made to this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'watching_small_new_events.png') . '"'; $icon_none = Utils_TooltipCommon::open_tag_attrs(__('This person is not watching this record.')) . ' src="' . Base_ThemeCommon::get_template_file('Utils_Watchdog', 'not_watching_small.png') . '"'; $v = $record[$desc['id']]; $def = ''; $first = true; $param = explode(';', $desc['param']); if (!is_array($v) && !is_numeric($v)) { return $v; } if ($param[1] == '::') { $callback = array('CRM_ContactsCommon', 'contact_format_default'); } else { $callback = explode('::', $param[1]); } if (!is_array($v)) { $v = array($v); } foreach ($v as $k => $w) { if ($w == '') { break; } if ($first) { $first = false; } else { $def .= '<br>'; } $contact = CRM_ContactsCommon::get_contact($w); if (!$nolink) { if ($contact['login'] == '') { $icon = $icon_none; } else { $icon = Utils_WatchdogCommon::user_check_if_notified($contact['login'], $recordset, $record['id']); if ($icon === null) { $icon = $icon_none; } elseif ($icon === true) { $icon = $icon_on; } else { $icon = $icon_off; } } $def .= '<img style="margin-right:4px;" ' . $icon . ' />'; } $def .= Utils_RecordBrowserCommon::no_wrap(call_user_func($callback, $contact, $nolink)); } if (!$def) { $def = '---'; } return $def; }