public function uninstall() { Utils_CommonDataCommon::remove('Calling_Codes'); Utils_CommonDataCommon::remove('Countries'); Base_ThemeCommon::uninstall_default_theme($this->get_type()); return true; }
public function uninstall() { Utils_RecordBrowserCommon::delete_addon('company', 'Tests/Bugtrack', 'company_bugtrack_addon'); Utils_AttachmentCommon::delete_addon('bugtrack'); Utils_RecordBrowserCommon::uninstall_recordset('bugtrack'); Utils_CommonDataCommon::remove('Bugtrack_Status'); return true; }
function HTML_QuickForm_commondata($elementName = null, $elementLabel = null, $commondata = null, $options = null, $attributes = null) { $this->HTML_QuickForm_select($elementName, $elementLabel, array(), $attributes); $this->_persistantFreeze = true; $this->_type = 'commondata'; $this->_appendName = true; if (isset($commondata)) { if (is_array($commondata)) { $this->_cd = $commondata; } elseif (is_string($commondata)) { $this->_cd = array($commondata); } } if (isset($options['empty_option'])) { $this->_add_empty_fields = $options['empty_option']; } if (isset($options['order_by_key'])) { $this->_order_by_key = $options['order_by_key']; } if (count($this->_cd) == 1) { $root_data = Utils_CommonDataCommon::get_translated_array($this->_cd[0], $this->_order_by_key); if ($this->_add_empty_fields) { $root_data = array('' => '---') + $root_data; } $this->loadArray($root_data); } }
public function uninstall() { $ret = true; $ret &= DB::DropTable('base_notify'); Base_ThemeCommon::uninstall_default_theme($this->get_type()); Utils_CommonDataCommon::remove('Base_Notify'); return $ret; }
public static function status_filter($rb) { $sts = Utils_CommonDataCommon::get_translated_array('CRM/Status', true); $trans = array('__NULL__' => array(), '__NO_CLOSED__' => array('!status' => array(3, 4))); foreach ($sts as $k => $v) { $trans[$k] = array('status' => $k); } $rb->set_custom_filter('status', array('type' => 'select', 'label' => __('Status'), 'args' => array('__NULL__' => '[' . __('All') . ']', '__NO_CLOSED__' => '[' . __('Not closed') . ']') + $sts, 'trans' => $trans)); }
function reset_sub_arrays($name) { Utils_CommonDataCommon::reset_array_positions($name); $arr = Utils_CommonDataCommon::get_array($name, false, false, true); foreach ($arr as $k => $v) { if (empty($k)) { continue; } reset_sub_arrays($name . '/' . $k); } }
public static function user_settings($settings_edit = false) { if ($settings_edit) { Base_ActionBarCommon::add(Base_ThemeCommon::get_template_file('Base_Notify', 'icon.png'), __('Browser Settings'), 'onClick="Base_Notify__notify (\'Notification\', {body: \'enabled\', icon: \'' . self::get_icon('Base_Notify') . '\'}, true);"', __('Click to set browser settings for tray notifications')); } $ret = array(array('name' => null, 'label' => __('General'), 'type' => 'header'), array('name' => 'general_timeout', 'reload' => 1, 'label' => __('Close Message Timeout'), 'type' => 'select', 'values' => Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => 0), array('name' => 'general_group', 'label' => __('Group Similar Notifications'), 'type' => 'checkbox', 'default' => 1), array('name' => null, 'label' => __('Module Specific Timeout'), 'type' => 'header')); $modules = ModuleManager::check_common_methods('tray_notification'); foreach ($modules as $module) { $label = self::get_module_caption($module); $ret = array_merge($ret, array(array('name' => $module . '_timeout', 'label' => $label, 'type' => 'select', 'values' => array(-2 => _M('Use general setting')) + Utils_CommonDataCommon::get_translated_array('Base_Notify/Timeout', true), 'default' => -2))); } return array(__('Notify') => $ret); }
public function uninstall() { Base_ThemeCommon::uninstall_default_theme($this->get_type()); Utils_CommonDataCommon::remove('crm_assets_category'); Utils_CommonDataCommon::remove('crm_assets_monitor_type'); Utils_CommonDataCommon::remove('crm_assets_printer_type'); Utils_RecordBrowserCommon::delete_addon('company', 'CRM/Assets', 'assets_addon'); Utils_AttachmentCommon::delete_addon('crm_assets'); Utils_AttachmentCommon::persistent_mass_delete('crm_assets'); Utils_RecordBrowserCommon::uninstall_recordset('crm_assets'); Utils_RecordBrowserCommon::unregister_processing_callback('crm_assets', array('CRM_AssetsCommon', 'process_request')); return true; }
public function applet($conf, &$opts) { $opts['go'] = true; $opts['title'] = __('Tasks') . ($conf['related'] == 0 ? ' - ' . __('Todo') : '') . ($conf['related'] == 1 ? ' - ' . __('Related') : '') . ($conf['term'] == 's' ? ' - ' . __('Short-term') : ($conf['term'] == 'l' ? ' - ' . __('Long-term') : '')); $me = CRM_ContactsCommon::get_my_record(); if ($me['id'] == -1) { CRM_ContactsCommon::no_contact_message(); return; } $short = $conf['term'] == 's' || $conf['term'] == 'b'; $long = $conf['term'] == 'l' || $conf['term'] == 'b'; $related = $conf['related']; $rb = $this->init_module(Utils_RecordBrowser::module_name(), 'task', 'task'); $status = array(); foreach (Utils_CommonDataCommon::get_array('CRM/Status') as $status_id => $label) { if (isset($conf['status_' . $status_id]) && $conf['status_' . $status_id]) { $status[] = $status_id; } } $crits = array(); $crits['status'] = $status; if ($short && !$long) { $crits['!longterm'] = 1; } if (!$short && $long) { $crits['longterm'] = 1; } if ($related == 0) { $crits['employees'] = array($me['id']); } if ($related == 1) { $crits['customers'] = array($me['id']); } if ($related == 2) { $crits['(employees'] = array($me['id']); $crits['|customers'] = array($me['id']); } $conds = array(array(array('field' => 'title', 'width' => 20, 'callback' => array('CRM_TasksCommon', 'display_title_with_mark')), array('field' => 'deadline', 'width' => 10), array('field' => 'status', 'width' => 6)), $crits, array('deadline' => 'ASC', 'status' => 'ASC', 'priority' => 'DESC'), array('CRM_TasksCommon', 'applet_info_format'), 15, $conf, &$opts); $opts['actions'][] = Utils_RecordBrowserCommon::applet_new_record_button('task', array('employees' => array($me['id']), 'status' => 0, 'permission' => 0, 'priority' => CRM_CommonCommon::get_default_priority())); $this->display_module($rb, $conds, 'mini_view'); }
public function install() { Utils_CommonDataCommon::new_array('Tests/RecordBrowser/Test_Commondata', array('Test0', 'Test1', 'Test2', 'Test3', 'Test4')); Utils_CommonDataCommon::new_array('Tests/RecordBrowser/Test_Permissions', array('none', 'partial view', 'full view', 'partial edit', 'full edit', 'delete')); $tr = new Tests_RecordBrowser_Recordset(); $tr->install(); //$ra = new RBO_RecordsetAccessor('tests_record_set'); //$records = array(); //$in = -1; //records for RB tests (full permission) $record = $tr->new_record($this->prepare_data(5, false, false)); $this->update_record($record, $this->prepare_data(5, true, false)); $record = $tr->new_record($this->prepare_data(5, false, true)); $this->update_record($record, $this->prepare_data(5, true, true)); //records for permissions tests for ($j = 0; $j < 5; $j++) { $record = $tr->new_record($this->prepare_data($j, false, true)); $this->update_record($record, $this->prepare_data($j, true, true)); } //setting permissions $this->prepare_permissions(); return true; }
public function uninstall() { Base_AclCommon::remove_clearance_callback(array('CRM_ContactsCommon', 'crm_clearance')); Base_ThemeCommon::uninstall_default_theme(CRM_ContactsInstall::module_name()); Utils_RecordBrowserCommon::unregister_datatype('crm_company'); Utils_RecordBrowserCommon::unregister_datatype('crm_contact'); Utils_RecordBrowserCommon::unregister_datatype('crm_company_contact'); Utils_RecordBrowserCommon::unregister_datatype('email'); Utils_RecordBrowserCommon::delete_addon('company', CRM_ContactsInstall::module_name(), 'company_addon'); Utils_AttachmentCommon::delete_addon('company'); Utils_AttachmentCommon::delete_addon('contact'); Utils_RecordBrowserCommon::uninstall_recordset('company'); Utils_RecordBrowserCommon::uninstall_recordset('contact'); Utils_CommonDataCommon::remove('Contacts_Groups'); Utils_CommonDataCommon::remove('Companies_Groups'); Utils_RecordBrowserCommon::unregister_processing_callback('contact', array('CRM_ContactsCommon', 'submit_contact')); return true; }
<?php defined("_VALID_ACCESS") || die('Direct access forbidden'); Utils_CommonDataCommon::extend_array('Contacts/Access', array('employee' => _M('Employee'))); $cmp = Variable::get('main_company', null); if ($cmp) { set_time_limit(0); $conts = DB::GetAll('SELECT * FROM contact_data_1 WHERE f_company_name=%d OR f_related_companies ' . DB::like() . ' ' . DB::Concat(DB::qstr('\\_\\_'), DB::qstr($cmp), DB::qstr('\\_\\_')), array($cmp)); foreach ($conts as $k => $v) { $v['access'] = Utils_RecordBrowserCommon::decode_multi($v['f_access']); $v['access'][] = 'employee'; Utils_RecordBrowserCommon::update_record('contact', $v['id'], array('access' => $v['access'])); } Variable::delete('main_company', false); } $tab = DB::GetAssoc('SELECT tab, tab FROM recordbrowser_table_properties'); foreach ($tab as $t) { DB::Execute('UPDATE ' . $t . '_access_clearance SET clearance=%s WHERE clearance=%s', array('ACCESS:employee', 'EMPLOYEE')); }
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 permissions_get_field_values($field, $in_depth=true) { static $all_fields = array(); if (!isset($all_fields[$this->tab])) foreach ($this->table_rows as $k=>$v) $all_fields[$this->tab][$v['id']] = $k; $args = $this->table_rows[$all_fields[$this->tab][$field]]; $arr = array(''=>'['.__('Empty').']'); switch (true) { case $args['type']=='text' && $args['filter']: $arr_add = @DB::GetAssoc('SELECT f_'.$args['id'].', f_'.$args['id'].' FROM '.$this->tab.'_data_1 GROUP BY f_'.$args['id'].' ORDER BY count(*) DESC LIMIT 20'); if($arr_add) $arr += $arr_add; break; case $args['commondata']: $array_id = is_array($args['param']) ? $args['param']['array_id'] : $args['ref_table']; if (strpos($array_id, '::')===false) $arr = $arr + Utils_CommonDataCommon::get_translated_array($array_id, is_array($args['param'])?$args['param']['order_by_key']:false); break; case $this->tab=='contact' && $field=='login' || $this->tab=='rc_accounts' && $field=='epesi_user': // just a quickfix, better solution will be needed $arr = $arr + array('USER_ID'=>__('User Login')); break; case $args['type']=='date' || $args['type']=='timestamp': $arr = $arr + Utils_RecordBrowserCommon::$date_values; break; case ($args['type']=='multiselect' || $args['type']=='select') && (!isset($args['ref_table']) || !$args['ref_table']): $arr = $arr + array('USER'=>__('User Contact')); $arr = $arr + array('USER_COMPANY'=>__('User Company')); break; case $args['type']=='checkbox': $arr = array('1'=>__('Yes'),'0'=>__('No')); break; case ($args['type']=='select' || $args['type']=='multiselect') && isset($args['ref_table']): if ($args['ref_table']=='contact') $arr = $arr + array('USER'=>__('User Contact')); if ($args['ref_table']=='company') $arr = $arr + array('USER_COMPANY'=>__('User Company')); if (!$in_depth) continue; $last_tab = $this->tab; $tabs = explode(',', $args['ref_table']); if (count($tabs) != 1) break; $one_tab = reset($tabs); if ($one_tab != '__RECORDSETS__' && Utils_RecordBrowserCommon::check_table_name($one_tab, false, false)) { $this->tab = $one_tab; $this->init(); if (!isset($all_fields[$this->tab])) foreach ($this->table_rows as $k=>$v) $all_fields[$this->tab][$v['id']] = $k; foreach ($all_fields[$this->tab] as $k=>$v) { if ($this->table_rows[$v]['type']=='calculated' || $this->table_rows[$v]['type']=='hidden') unset($all_fields[$this->tab][$k]); else { $arr2 = $this->permissions_get_field_values($k, false, $this->tab); foreach ($arr2 as $k2=>$v2) $arr2[$k2] = '"'.$k2.'":"'.$v2.'"'; eval_js('utils_recordbrowser__field_sub_values["'.$field.'__'.$k.'"] = {'.implode(',',$arr2).'};'); } } foreach ($all_fields[$this->tab] as $k=>$v) { $arr[$k] = __(' records with %s set to ', array(_V($v))); } } $this->tab = $last_tab; $this->init(); break; } return $arr; }
public static function drawLeightbox($prefix) { if (MOBILE_DEVICE) { return; } $meetings = CRM_MeetingInstall::is_installed(); $tasks = CRM_TasksInstall::is_installed(); $phonecall = CRM_PhoneCallInstall::is_installed(); self::check_location(); if (!isset(self::$leightbox_ready[$prefix])) { self::$leightbox_ready[$prefix] = true; $theme = Base_ThemeCommon::init_smarty(); eval_js_once($prefix . '_followups_deactivate = function(){leightbox_deactivate(\'' . $prefix . '_followups_leightbox\');}'); if ($meetings) { $theme->assign('new_meeting', array('open' => '<a id="' . $prefix . '_new_meeting_button" onclick="' . $prefix . '_set_action(\'new_meeting\');' . $prefix . '_submit_form();">', 'text' => __('New Meeting'), 'close' => '</a>')); eval_js('Event.observe(\'' . $prefix . '_new_meeting_button\',\'click\', ' . $prefix . '_followups_deactivate)'); } if ($tasks) { $theme->assign('new_task', array('open' => '<a id="' . $prefix . '_new_task_button" onclick="' . $prefix . '_set_action(\'new_task\');' . $prefix . '_submit_form();">', 'text' => __('New Task'), 'close' => '</a>')); eval_js('Event.observe(\'' . $prefix . '_new_task_button\',\'click\', ' . $prefix . '_followups_deactivate)'); } if ($phonecall) { $theme->assign('new_phonecall', array('open' => '<a id="' . $prefix . '_new_phonecall_button" onclick="' . $prefix . '_set_action(\'new_phonecall\');' . $prefix . '_submit_form();">', 'text' => __('New Phonecall'), 'close' => '</a>')); eval_js('Event.observe(\'' . $prefix . '_new_phonecall_button\',\'click\', ' . $prefix . '_followups_deactivate)'); } $theme->assign('just_close', array('open' => '<a id="' . $prefix . '_just_close_button" onclick="' . $prefix . '_set_action(\'none\');' . $prefix . '_submit_form();">', 'text' => __('Save'), 'close' => '</a>')); eval_js('Event.observe(\'' . $prefix . '_just_close_button\',\'click\', ' . $prefix . '_followups_deactivate)'); eval_js($prefix . '_submit_form = function () {' . '$(\'' . $prefix . '_follow_up_form\').submited.value=1;Epesi.href($(\'' . $prefix . '_follow_up_form\').serialize(), \'processing...\');$(\'' . $prefix . '_follow_up_form\').submited.value=0;' . '}'); eval_js($prefix . '_set_action = function (arg) {' . 'document.forms["' . $prefix . '_follow_up_form"].action.value = arg;' . '}'); eval_js($prefix . '_set_id = function (id) {' . 'document.forms["' . $prefix . '_follow_up_form"].id.value = id;' . '$("' . $prefix . '_closecancel").value=3;' . '$("' . $prefix . '_note").value="";' . '}'); $theme->assign('form_open', '<form id="' . $prefix . '_follow_up_form" name="' . $prefix . '_follow_up_form" method="POST">' . '<input type="hidden" name="submited" value="0" />' . '<input type="hidden" name="form_name" value="' . $prefix . '_follow_up_form" />' . '<input type="hidden" name="id" value="" />' . '<input type="hidden" name="action" value="" />'); $status_select_options = ''; $statuses = Utils_CommonDataCommon::get_translated_array('CRM/Status'); foreach ($statuses as $key => $value) { $status_select_options .= '<option value="' . htmlspecialchars($key) . '"' . ($key == 3 ? ' selected="1"' : '') . '>' . htmlspecialchars($value) . '</option>'; } $theme->assign('form_closecancel', array('label' => __('Status'), 'html' => '<select name="closecancel" id="' . $prefix . '_closecancel" value="0">' . $status_select_options . '</select>')); $theme->assign('form_note', array('label' => __('Note'), 'html' => '<textarea name="note" id="' . $prefix . '_note"></textarea>')); $theme->assign('form_close', '</form>'); ob_start(); Base_ThemeCommon::display_smarty($theme, 'CRM_Followup', 'leightbox'); $profiles_out = ob_get_clean(); Libs_LeightboxCommon::display($prefix . '_followups_leightbox', $profiles_out, __('Follow-up')); } }
public static function mobile_rb_edit($tab, $id) { if ($id === false) { $rec = array(); } else { $rec = self::get_record($tab, $id); } $cols = Utils_RecordBrowserCommon::init($tab); $defaults = array(); if ($id === false) { $mode = 'add'; $access = array(); $defaults = self::record_processing($tab, $defaults, 'adding'); } else { $mode = 'edit'; $access = Utils_RecordBrowserCommon::get_access($tab, 'view', $rec); if (is_array($access)) { foreach ($access as $k => $v) { if (!$v) { unset($rec[$k]); } } } $defaults = $rec = self::record_processing($tab, $rec, 'editing'); } $QFfield_callback_table = array(); $ret = DB::Execute('SELECT * FROM ' . $tab . '_callback WHERE freezed=0'); while ($row = $ret->FetchRow()) { $QFfield_callback_table[$row['field']] = $row['callback']; } $defaults = array_merge($defaults, $_SESSION['rb_' . $tab . '_defaults']); $qf = new HTML_QuickForm('rb_edit', 'post', 'mobile.php?' . http_build_query($_GET)); foreach ($cols as $field => $args) { if (isset($access[$args['id']]) && !$access[$args['id']]) { continue; } if (isset($rec[$args['id']])) { $val = $rec[$args['id']]; } elseif (isset($defaults[$args['id']])) { $val = $defaults[$args['id']]; } else { $val = null; } $label = _V($args['name']); // TRSL if (isset($QFfield_callback_table[$field])) { $mobile_rb = new Utils_RecordBrowserMobile($tab, $rec); self::call_QFfield_callback($QFfield_callback_table[$field], $qf, $args['id'], $label, $mode, $val, $args, $mobile_rb, null); if ($mode == 'edit') { unset($defaults[$args['id']]); } continue; } switch ($args['type']) { case 'calculated': $qf->addElement('static', $args['id'], $label); if (!is_array($rec)) { $values = $defaults; } else { $values = $rec; if (is_array($defaults)) { $values = $values + $defaults; } } if (!isset($values[$args['id']])) { $values[$args['id']] = ''; } $val = Utils_RecordBrowserCommon::get_val($tab, $field, $values, true, $args); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'integer': case 'float': $qf->addElement('text', $args['id'], $label); if ($args['type'] == 'integer') { $qf->addRule($args['id'], __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/'); } else { $qf->addRule($args['id'], __('Only numbers are allowed.'), 'numeric'); } if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'checkbox': $qf->addElement('checkbox', $args['id'], $label, ''); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'currency': $qf->addElement('currency', $args['id'], $label); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'text': $qf->addElement('text', $args['id'], $label, array('maxlength' => $args['param'])); $qf->addRule($args['id'], __('Maximum length for this field is %s characters.', array($args['param'])), 'maxlength', $args['param']); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'long text': $qf->addElement('textarea', $args['id'], $label, array('maxlength' => 200)); $qf->addRule($args['id'], __('Maximum length for this field in mobile edition is 200 chars.'), 'maxlengt', 200); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'commondata': $param = explode('::', $args['param']['array_id']); foreach ($param as $k => $v) { if ($k != 0) { $param[$k] = self::get_field_id($v); } } if (count($param) == 1) { $qf->addElement($args['type'], $args['id'], $label, $param, array('empty_option' => true, 'id' => $args['id'], 'order_by_key' => $args['param']['order_by_key'])); if ($val !== null) { $qf->setDefaults(array($args['id'] => $val)); } } break; case 'select': $comp = array(); $ref = explode(';', $args['param']); if (isset($ref[1])) { $crits_callback = $ref[1]; } else { $crits_callback = null; } if (isset($ref[2])) { $multi_adv_params = call_user_func(explode('::', $ref[2])); } else { $multi_adv_params = null; } if (!isset($multi_adv_params) || !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(); } $ref = $ref[0]; @(list($tab2, $col) = explode('::', $ref)); if (!isset($col)) { trigger_error($field); } if ($tab2 == '__RECORDSETS__') { continue; } //skip multi recordsets chained selector if ($tab2 == '__COMMON__') { $data = Utils_CommonDataCommon::get_translated_tree($col); if (!is_array($data)) { $data = array(); } $comp = $comp + $data; } else { if (isset($crits_callback)) { $crit_callback = explode('::', $crits_callback); if (is_callable($crit_callback)) { $crits = call_user_func($crit_callback, false, $rec); $adv_crits = call_user_func($crit_callback, true, $rec); } else { $crits = $adv_crits = array(); } if ($adv_crits === $crits) { $adv_crits = null; } if ($adv_crits !== null) { continue; //skip record picker } } else { $crits = array(); } $col = explode('|', $col); $col_id = array(); foreach ($col as $c) { $col_id[] = self::get_field_id($c); } $records = Utils_RecordBrowserCommon::get_records($tab2, $crits, empty($multi_adv_params['format_callback']) ? $col_id : array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array()); $ext_rec = array(); if (isset($rec[$args['id']])) { if (!is_array($rec[$args['id']])) { if ($rec[$args['id']] != '') { $rec[$args['id']] = array($rec[$args['id']] => $rec[$args['id']]); } else { $rec[$args['id']] = array(); } } } if (isset($defaults[$args['id']])) { if (!is_array($defaults[$args['id']])) { $rec[$args['id']][$defaults[$args['id']]] = $defaults[$args['id']]; } else { foreach ($defaults[$args['id']] as $v) { $rec[$args['id']][$v] = $v; } } } $single_column = count($col_id) == 1; if (isset($rec[$args['id']])) { $ext_rec = array_flip($rec[$args['id']]); foreach ($ext_rec as $k => $v) { $c = Utils_RecordBrowserCommon::get_record($tab2, $k); if (!empty($multi_adv_params['format_callback'])) { $n = call_user_func($multi_adv_params['format_callback'], $c); } else { if ($single_column) { $n = $c[$col_id[0]]; } else { $n = array(); foreach ($col_id as $cid) { $n[] = $c[$cid]; } $n = implode(' ', $n); } } $comp[$k] = $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 { // $n = $v[$col_id]; if ($single_column) { $n = $v[$col_id[0]]; } else { $n = array(); foreach ($col_id as $cid) { $n[] = $v[$cid]; } $n = implode(' ', $n); } } $comp[$k] = $n; unset($ext_rec[$v['id']]); } if (empty($multi_adv_params['order'])) { natcasesort($comp); } } if ($args['type'] === 'select') { $comp = array('' => '---') + $comp; } $qf->addElement($args['type'], $args['id'], $label, $comp, array('id' => $args['id'])); if ($id !== false) { $qf->setDefaults(array($args['id'] => $rec[$args['id']])); } break; case 'date': $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $qf->setDefaults(array($args['id'] => $val)); } break; case 'timestamp': $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y H:i', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false); $qf->setDefaults(array($args['id'] => $default)); } break; case 'time': $qf->addElement('date', $args['id'], $label, array('format' => 'H:i', 'addEmptyOption' => true, 'emptyOptionText' => '--')); if ($val) { $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false); $qf->setDefaults(array($args['id'] => $default)); } break; case 'multiselect': //ignore if ($id === false) { continue; } $val = Utils_RecordBrowserCommon::get_val($tab, $field, $rec, true, $args); if ($val === '') { continue; } $qf->addElement('static', $args['id'], $label); $qf->setDefaults(array($args['id'] => $val)); unset($defaults[$args['id']]); break; } if ($args['required']) { $qf->addRule($args['id'], __('Field required'), 'required'); } } $qf->addElement('submit', 'submit_button', __('Save'), IPHONE ? 'class="button white"' : ''); if ($qf->validate()) { $values = $qf->exportValues(); foreach ($cols as $v) { if ($v['type'] == 'checkbox' && !isset($values[$v['id']])) { $values[$v['id']] = 0; } elseif ($v['type'] == 'date') { if (is_array($values[$v['id']]) && $values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '') { $values[$v['id']] = sprintf("%d-%02d-%02d", $values[$v['id']]['Y'], $values[$v['id']]['M'], $values[$v['id']]['d']); } else { $values[$v['id']] = ''; } } elseif ($v['type'] == 'timestamp') { if ($values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '' && $values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') { $timestamp = $values[$v['id']]['Y'] . '-' . $values[$v['id']]['M'] . '-' . $values[$v['id']]['d'] . ' ' . $values[$v['id']]['H'] . ':' . $values[$v['id']]['i']; $values[$v['id']] = Base_RegionalSettingsCommon::reg2time($timestamp, true); } else { $values[$v['id']] = ''; } } elseif ($v['type'] == 'time') { if ($values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') { $time = recalculate_time(date('Y-m-d'), $values[$v['id']]); $timestamp = Base_RegionalSettingsCommon::reg2time(date('1970-01-01 H:i:s', $time), true); $values[$v['id']] = date('1970-01-01 H:i:s', $timestamp); } else { $values[$v['id']] = ''; } } } foreach ($defaults as $k => $v) { if (!isset($values[$k])) { $values[$k] = $v; } } if ($id !== false) { $values['id'] = $id; Utils_RecordBrowserCommon::update_record($tab, $id, $values); } else { $id = Utils_RecordBrowserCommon::new_record($tab, $values); } return false; } $renderer =& $qf->defaultRenderer(); $qf->accept($renderer); print $renderer->toHtml(); }
protected function hf_commondata($field, $operator, $value, $raw_sql_val, $field_def) { list($field, $sub_field) = Utils_RecordBrowser_CritsSingle::parse_subfield($field); if ($raw_sql_val) { return array("{$field} {$operator} {$value}", array()); } if ($value === null || $value === false || $value === '') { return array("{$field} IS NULL OR {$field}=''", array()); } if (!isset($field_def['ref_table'])) { // commondata type doesn't have this, only select/multiselect $field_def['ref_table'] = $field_def['param']['array_id']; } if ($sub_field !== false) { // may be empty string for value lookup with field[] $commondata_table = $field_def['ref_table']; $ret = Utils_CommonDataCommon::get_translated_array($commondata_table); $val_regex = $operator == DB::like() ? '/' . preg_quote($value, '/') . '/i' : '/^' . preg_quote($value, '/') . '$/i'; $final_vals = array_keys(preg_grep($val_regex, $ret)); if ($operator == DB::like()) { $operator = '='; } } else { $final_vals = array($value); } $multiselect = $field_def['type'] == 'multiselect'; if ($multiselect) { $operator = DB::like(); } $sql = array(); $vals = array(); foreach ($final_vals as $val) { $sql[] = "({$field} {$operator} %s AND {$field} IS NOT NULL)"; if ($multiselect) { $val = "%\\_\\_{$val}\\_\\_%"; } $vals[] = $val; } $sql_str = implode(' OR ', $sql); return array($sql_str, $vals); }
public function uninstall() { $this->drop_all_rc_tables(); Utils_RecordBrowserCommon::delete_addon('rc_mails', 'CRM/Roundcube', 'attachments_addon'); Utils_RecordBrowserCommon::delete_addon('contact', 'CRM/Roundcube', 'addon'); Utils_RecordBrowserCommon::delete_addon('company', 'CRM/Roundcube', 'addon'); DB::DropTable('rc_mails_attachments'); DB::DropTable('rc_mails_attachments_download'); Utils_RecordBrowserCommon::uninstall_recordset('rc_mails'); Utils_RecordBrowserCommon::uninstall_recordset('rc_accounts'); Utils_RecordBrowserCommon::uninstall_recordset('rc_multiple_emails'); Utils_CommonDataCommon::remove('CRM/Roundcube/Security'); Utils_RecordBrowserCommon::unregister_processing_callback('rc_accounts', array('CRM_RoundcubeCommon', 'submit_account')); Utils_RecordBrowserCommon::unregister_processing_callback('rc_mails', array('CRM_RoundcubeCommon', 'submit_mail')); Base_ThemeCommon::uninstall_default_theme($this->get_type()); Variable::delete('crm_roundcube_global_signature'); return true; }
/** * For internal use only. */ public static function remove_array($name) { Utils_CommonDataCommon::remove($name); }
public static function get_translated_tree($col, $order_by_key = false, $deep = 0) { $data = Utils_CommonDataCommon::get_translated_array($col, $order_by_key, false, true); if (!$data) { return array(); } $output = array(); foreach ($data as $k => $v) { $output[$k] = $v; $sub = self::get_translated_tree($col . '/' . $k, $order_by_key, $deep + 1); if ($sub) { foreach ($sub as $k2 => $v2) { $output[$k . '/' . $k2] = '* ' . $v2; } } } return $output; }
'Premium/Training/Training_Status/planned', 'Premium/Training/Training_Status/inprogress', 'Premium/Training/Training_Status/completed', 'Premium/Training/Training_Status/billed', 'Premium/Training/Training_Status/canceled', 'Premium/Vehicle', 'Premium/Vehicle/Classification', 'Premium/Vehicle/Availability_Type', 'Premium/Vehicle/Availability_Type/0', 'Premium/Vehicle/Availability_Type/1', 'Premium/Warehouse', 'Premium/Warehouse/eCommerce', 'Premium/Warehouse/eCommerce/Languages', 'Premium/Warehouse/eCommerce/CompareServices', 'Premium/Warehouse/eCommerce/CompareServices/ceneo', 'Premium/Warehouse/eCommerce/CompareServices/skapiec', 'Premium_Warehouse_Items_Type', 'Premium_Warehouse_Items_Categories', 'Premium_Items_Orders_Terms', 'Premium_Items_Orders_Shipment_Types', 'Premium_Items_Orders_Payment_Types', 'Premium_Items_Orders_Trans_Types', 'Premium_Items_Orders_TaxCalc', 'Premium_Items_Orders_TaxCalc/0', 'Premium_Items_Orders_TaxCalc/1', ); foreach($keys as $key) { $id = Utils_CommonDataCommon::get_id($key); if($id) DB::Execute('UPDATE utils_commondata_tree SET readonly=%b WHERE id=%d',array(true,$id)); }
public function show_filters($filters_set = array(), $f_id = '') { $this->init(); if ($this->get_access('browse') === false) { return; } $access = $this->get_access('view'); $filters_all = array(); foreach ($this->table_rows as $k => $v) { if (isset($access[$v['id']]) && $access[$v['id']]) { if (!isset($filters_set[$v['id']]) && $v['filter'] || isset($filters_set[$v['id']]) && $filters_set[$v['id']]) { $filters_all[] = $k; if (isset($filters_set[$v['id']])) { unset($filters_set[$v['id']]); } } } } if (!$this->data_gb) { $this->data_gb = $this->init_module(Utils_GenericBrowser::module_name(), null, $this->tab); } if (empty($filters_all)) { $this->crits = array(); return ''; } // TODO: move it $form = $this->init_module(Libs_QuickForm::module_name(), null, $this->tab . 'filters'); // $form_sub = $form->get_submit_form_js_by_name(array($form->get_name(), $this->data_gb->form_s->get_name()),true,null)."return false;"; // $this->data_gb->form_s->updateAttributes(array('onsubmit'=>$form_sub)); // $form->updateAttributes(array('onsubmit'=>$form_sub)); $empty_defaults = array(); $filters = array(); foreach ($filters_all as $filter) { $filter_id = preg_replace('/[^a-z0-9]/', '_', strtolower($filter)); $field_id = 'filter__' . $filter_id; if (isset($this->custom_filters[$filter_id])) { $f = $this->custom_filters[$filter_id]; if ($this->data_gb->show_all()) { if (isset($f['trans'])) { foreach ($f['trans'] as $k => $v) { if (empty($v)) { $empty_defaults[$field_id] = $k; } } } } if (!isset($f['label'])) { $f['label'] = $filter; } if (!isset($f['args'])) { $f['args'] = null; } if (!isset($f['args_2'])) { $f['args_2'] = null; } if (!isset($f['args_3'])) { $f['args_3'] = null; } $form->addElement($f['type'], $field_id, $f['label'], $f['args'], $f['args_2'], $f['args_3']); $filters[] = $filter_id; continue; } $field_label = _V($this->table_rows[$filter]['name']); $arr = array(); $autoselect = false; if ($this->table_rows[$filter]['type'] == 'timestamp' || $this->table_rows[$filter]['type'] == 'date') { $form->addElement('datepicker', $field_id . '__from', $field_label . ' (' . __('From') . ')', array('label' => false)); // TRSL $form->addElement('datepicker', $field_id . '__to', $field_label . ' (' . __('To') . ')', array('label' => false)); // TRSL $filters[] = $filter_id . '__from'; $filters[] = $filter_id . '__to'; continue; } elseif ($this->table_rows[$filter]['type'] == 'checkbox') { $arr = array('' => __('No'), 1 => __('Yes')); } elseif (in_array($this->table_rows[$filter]['type'], array('currency', 'float', 'integer', 'autonumber')) || $this->table_rows[$filter]['type'] == 'calculated' && $this->table_rows[$filter]['param'] != '' && in_array($this->table_rows[$filter]['style'], array('currency', 'float', 'integer', 'autonumber'))) { $form->addElement('text', $field_id . '__from', $field_label . ' (' . __('From') . ')', array('label' => false)); // TRSL $form->addElement('text', $field_id . '__to', $field_label . ' (' . __('To') . ')', array('label' => false)); // TRSL $form->addRule($field_id . '__from', __('Only numbers are allowed.'), 'numeric'); $form->addRule($field_id . '__to', __('Only numbers are allowed.'), 'numeric'); $filters[] = $filter_id . '__from'; $filters[] = $filter_id . '__to'; if ($this->table_rows[$filter]['type'] == 'currency' || $this->table_rows[$filter]['type'] == 'calculated' && $this->table_rows[$filter]['param'] != '' && $this->table_rows[$filter]['style'] == 'currency') { $arr = Utils_CurrencyFieldCommon::get_currencies(); if (count($arr) > 1) { $arr = array('__NULL__' => '---') + $arr; $form->addElement('select', $field_id . '__currency', $field_label . ' (' . __('Currency') . ')', $arr); // TRSL $filters[] = $filter_id . '__currency'; } } continue; } else { if ($this->table_rows[$filter]['type'] == 'commondata') { $parts = explode('::', $this->table_rows[$filter]['param']['array_id']); $array_id = array_shift($parts); $arr = Utils_CommonDataCommon::get_translated_array($array_id, $this->table_rows[$filter]['param']['order_by_key']); $made_of_parts = false; while (!empty($parts)) { $made_of_parts = true; array_shift($parts); $next_arr = array(); foreach ($arr as $k => $v) { $next = Utils_CommonDataCommon::get_translated_array($array_id . '/' . $k, $this->table_rows[$filter]['param']['order_by_key']); foreach ($next as $k2 => $v2) { $next_arr[$k . '/' . $k2] = $v . ' / ' . $v2; } } $arr = $next_arr; } if ($made_of_parts) { natcasesort($arr); } } else { $param = explode(';', $this->table_rows[$filter]['param']); $x = explode('::', $param[0]); if (!isset($x[1])) { continue; } list($tab, $col) = $x; if ($tab == '__COMMON__') { $arr = Utils_CommonDataCommon::get_translated_tree($col); } else { $col = explode('|', $col); Utils_RecordBrowserCommon::check_table_name($tab); foreach ($col as $k => $v) { $col[$k] = preg_replace('/[^a-z0-9]/', '_', strtolower($v)); } $crits = array(); if (isset($this->filter_crits[$this->table_rows[$filter]['id']])) { $crits = $this->filter_crits[$this->table_rows[$filter]['id']]; } else { if (isset($param[1])) { $callback = explode('::', $param[1]); if (is_callable($callback)) { $crits = call_user_func($callback, true); } } if (!is_array($crits)) { $crits = array(); if (isset($param[2])) { $callback = explode('::', $param[2]); if (is_callable($callback)) { $crits = call_user_func($callback, true); } } if (!is_array($crits)) { $crits = array(); } } } if ($tab != '__RECORDSETS__' && !preg_match('/,/', $tab)) { $qty = Utils_RecordBrowserCommon::get_records_count($tab, $crits); if ($qty <= Utils_RecordBrowserCommon::$options_limit) { $tpro = DB::GetRow('SELECT description_callback FROM recordbrowser_table_properties WHERE tab=%s', array($tab)); if ($tpro) { $descr = $tpro['description_callback']; if ($descr) { if (preg_match('/::/', $descr)) { $descr = explode('::', $descr); } if (!is_callable($descr)) { $descr = ''; } } } $ret2 = Utils_RecordBrowserCommon::get_records($tab, $crits); foreach ($ret2 as $k => $v) { if (empty($descr)) { $txt = array(); foreach ($col as $kk => $vv) { $txt[] = Utils_RecordBrowserCommon::get_val($tab, $vv, $v, true); } $option_label = implode(' ', $txt); } else { $option_label = call_user_func($descr, $v, true); } $arr[$k] = $option_label; } natcasesort($arr); } else { $arr = array(); $autoselect = true; $param = array($tab, $crits); } } else { $arr = array(); $autoselect = true; $param = array($tab, $crits); } if ($tab == 'contact') { $arr = array($this->crm_perspective_default() => '[' . __('Perspective') . ']') + $arr; } } } } if ($autoselect) { $f_callback = array('Utils_RecordBrowserCommon', 'autoselect_label'); $arr = array('__NULL__' => '---') + $arr; $form->addElement('autoselect', $field_id, $field_label, $arr, array(array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array_merge($param, array($f_callback, $this->table_rows[$filter]['param']))), $f_callback); $form->setDefaults(array($field_id => '__NULL__')); } else { $arr = array('__NULL__' => '---') + $arr; $form->addElement('select', $field_id, $field_label, $arr); // TRSL } $filters[] = $filter_id; } $form->addElement('submit', 'submit', __('Show')); $use_saving_filters = Base_User_SettingsCommon::get($this->get_type(), 'save_filters'); if ($this->data_gb->show_all()) { $this->set_module_variable('def_filter', $empty_defaults); if ($use_saving_filters) { Base_User_SettingsCommon::save($this->get_type(), $this->tab . '_filters', $empty_defaults); } print '<span style="display:none;">' . microtime(true) . '</span>'; } $def_filt = $this->get_module_variable('def_filter', array()); if ($use_saving_filters) { $saved_filters = Base_User_SettingsCommon::get($this->get_type(), $this->tab . '_filters'); if ($saved_filters) { $def_filt = $saved_filters; } } $this->crits = array(); $filter_crits = array(); $form->setDefaults($def_filt); $external_filters = array(); $dont_hide = Base_User_SettingsCommon::get(Utils_RecordBrowser::module_name(), $this->tab . '_show_filters'); $vals = $form->exportValues(); $ret = DB::Execute('SELECT * FROM recordbrowser_browse_mode_definitions WHERE tab=%s', array($this->tab)); while ($row = $ret->FetchRow()) { $m = $this->init_module($row['module']); $this->display_module($m, array(&$form, &$external_filters, &$vals, &$filter_crits, $this), $row['func']); } foreach ($filters_all as $filter) { if (in_array(strtolower($filter), $external_filters)) { continue; } $filter_id = preg_replace('/[^a-z0-9]/', '_', strtolower($filter)); $field_id = 'filter__' . $filter_id; if (isset($this->custom_filters[$filter_id])) { if (!isset($vals['filter__' . $filter_id])) { if ($this->custom_filters[$filter_id]['type'] != 'autoselect') { $vals['filter__' . $filter_id] = '__NULL__'; } else { $vals['filter__' . $filter_id] = ''; } } if (isset($this->custom_filters[$filter_id]['trans'][$vals['filter__' . $filter_id]])) { foreach ($this->custom_filters[$filter_id]['trans'][$vals['filter__' . $filter_id]] as $k => $v) { $filter_crits[$k] = $v; } } elseif (isset($this->custom_filters[$filter_id]['trans_callback'])) { $new_crits = call_user_func($this->custom_filters[$filter_id]['trans_callback'], $vals['filter__' . $filter_id], $filter_id); $this->crits = Utils_RecordBrowserCommon::merge_crits($this->crits, $new_crits); } } else { if (in_array($this->table_rows[$filter]['type'], array('currency', 'float', 'integer', 'autonumber')) || $this->table_rows[$filter]['type'] == 'calculated' && $this->table_rows[$filter]['param'] != '' && in_array($this->table_rows[$filter]['style'], array('currency', 'float', 'integer', 'autonumber'))) { if (isset($vals[$field_id . '__currency']) && $vals[$field_id . '__currency'] != "__NULL__") { $filter_crits["~{$filter_id}"] = "%\\_\\_" . $vals[$field_id . '__currency']; } if (isset($vals[$field_id . '__from']) && $vals[$field_id . '__from'] !== "") { $filter_crits[">={$filter_id}"] = floatval($vals[$field_id . '__from']); } if (isset($vals[$field_id . '__to']) && $vals[$field_id . '__to'] !== "") { $filter_crits["<={$filter_id}"] = floatval($vals[$field_id . '__to']); } continue; } if ($this->table_rows[$filter]['type'] == 'timestamp' || $this->table_rows[$filter]['type'] == 'date') { if (isset($vals[$field_id . '__from']) && $vals[$field_id . '__from']) { $filter_crits['>=' . $filter_id] = $vals[$field_id . '__from'] . ' 00:00:00'; } if (isset($vals[$field_id . '__to']) && $vals[$field_id . '__to']) { $filter_crits['<=' . $filter_id] = $vals[$field_id . '__to'] . ' 23:59:59'; } continue; } if (!isset($vals['filter__' . $filter_id]) || $this->table_rows[$filter]['type'] == 'select' && $vals['filter__' . $filter_id] === '') { $vals['filter__' . $filter_id] = '__NULL__'; } if ($vals['filter__' . $filter_id] === '__NULL__') { continue; } if ($this->table_rows[$filter]['type'] == 'commondata') { $vals2 = explode('/', $vals['filter__' . $filter_id]); $param = explode('::', $this->table_rows[$filter]['param']['array_id']); array_shift($param); $param[] = $filter_id; foreach ($vals2 as $v) { $filter_crits[preg_replace('/[^a-z0-9]/', '_', strtolower(array_shift($param)))] = $v; } } else { $filter_crits[$filter_id] = $vals['filter__' . $filter_id]; } } } $this->crits = Utils_RecordBrowserCommon::merge_crits($this->crits, $filter_crits); $this->set_module_variable('crits', $this->crits); $filters = array_merge($filters, $external_filters); foreach ($filters as $k => $v) { $filters[$k] = 'filter__' . $v; } foreach ($vals as $k => $v) { $c = str_replace('filter__', '', $k); if (isset($this->custom_filters[$c]) && $this->custom_filters[$c]['type'] == 'checkbox' && $v === '__NULL__') { unset($vals[$k]); } } if ($use_saving_filters && isset($vals['submited']) && $vals['submited']) { unset($vals['submited']); unset($vals['submit']); Base_User_SettingsCommon::save($this->get_type(), $this->tab . '_filters', $vals); } $this->set_module_variable('def_filter', $vals); $theme = $this->init_module(Base_Theme::module_name()); $form->assign_theme('form', $theme); $theme->assign('filters', $filters); load_js('modules/Utils/RecordBrowser/filters.js'); $theme->assign('show_filters', array('attrs' => 'onclick="rb_show_filters(\'' . $this->tab . '\',\'' . $f_id . '\');" id="show_filter_b_' . $f_id . '"', 'label' => __('Show filters'))); $theme->assign('hide_filters', array('attrs' => 'onclick="rb_hide_filters(\'' . $this->tab . '\',\'' . $f_id . '\');" id="hide_filter_b_' . $f_id . '"', 'label' => __('Hide filters'))); $theme->assign('id', $f_id); if (!$use_saving_filters) { if (!$this->isset_module_variable('filters_defaults')) { $this->set_module_variable('filters_defaults', $this->crits); } elseif ($this->crits != $this->get_module_variable('filters_defaults')) { $theme->assign('dont_hide', true); } } if ($dont_hide) { $theme->assign('dont_hide', true); } return $this->get_html_of_module($theme, 'Filter', 'display'); }
public static function display_phone($r, $nolink, $desc) { if ($nolink) { return $r[$desc['id']]; } if (MOBILE_DEVICE && IPHONE && preg_match('/^([0-9\\t\\+-]+)/', $r[$desc['id']], $args)) { return '<a href="tel:' . $args[1] . '">' . $r[$desc['id']] . '</a>'; } $num = $r[$desc['id']]; if ($num && strpos($num, '+') === false) { if (isset($r['country']) && $r['country']) { $calling_code = Utils_CommonDataCommon::get_value('Calling_Codes/' . $r['country']); if ($calling_code) { $num = $calling_code . $num; } } } return CRM_CommonCommon::get_dial_code($num); }
public function uninstall() { Base_ThemeCommon::uninstall_default_theme($this->get_type()); Utils_CommonDataCommon::remove('Base_Notify'); return true; }
public function uninstall() { Utils_CommonDataCommon::remove('CRM'); return true; }
public static function user_settings() { if (!Base_EpesiStoreCommon::admin_access()) { return array(); } set_time_limit(0); // get default data from user contact $my_contact = ModuleManager::is_installed('CRM_Contacts') > -1 ? CRM_ContactsCommon::get_my_record() : array(); // key = field name from contact => value = field name in settings $keys = self::get_payment_data_keys(); $values = array(); // do user setting entries from data foreach ($keys as $k => $v) { $x = array('name' => $v, 'label' => _V(ucwords(str_replace('_', ' ', $v))), 'type' => 'text', 'default' => isset($my_contact[$k]) ? $my_contact[$k] : ''); if ($k == 'country') { $x['type'] = 'select'; $x['values'] = Utils_CommonDataCommon::get_translated_array('Countries'); } $values[] = $x; } return array(__('EPESI Store') => array_merge(array(array('name' => 'payments_header', 'label' => '', 'type' => 'header', 'default' => __('Payment credentials'))), $values)); }
<?php /** * @author Paul Bukowski <*****@*****.**> * @copyright Copyright © 2006, Telaxus LLC * @version 1.0 * @license MIT * @package epesi-utils * @subpackage CommonData */ if (!isset($_POST['value'])) { die('alert(\'Invalid request\')'); } define('JS_OUTPUT', 1); define('SET_SESSION', 0); require_once '../../../include.php'; ModuleManager::load_modules(); $ret = Utils_CommonDataCommon::get_value($_POST['value'], true); if (!$ret) { $ret = array(); } print json_encode($ret); exit;
} } Utils_RecordBrowserCommon::wipe_access('contact'); Utils_RecordBrowserCommon::add_access('contact', 'view', 'ACCESS:employee', array('(!permission' => 2, '|:Created_by' => 'USER_ID'), array('birth_date', 'ssn', 'home_phone', 'home_address_1', 'home_address_2', 'home_city', 'home_country', 'home_zone', 'home_postal_code', 'view', 'edit', 'add', 'delete')); Utils_RecordBrowserCommon::add_access('contact', 'view', 'ALL', array('login' => 'USER_ID'), array('view', 'edit', 'add', 'delete')); Utils_RecordBrowserCommon::add_access('contact', 'view', array('ACCESS:employee', 'ACCESS:mrm'), array('(!permission' => 2, '|:Created_by' => 'USER_ID'), array('view', 'edit', 'add', 'delete')); Utils_RecordBrowserCommon::add_access('contact', 'add', array('ACCESS:employee', 'ACCESS:manager')); Utils_RecordBrowserCommon::add_access('contact', 'edit', 'ACCESS:employee', array('(permission' => 0, '|:Created_by' => 'USER_ID', '!group' => array('patient', 'ex_patient')), array('access', 'login')); Utils_RecordBrowserCommon::add_access('contact', 'edit', 'ALL', array('login' => 'USER_ID'), array('access', 'login')); Utils_RecordBrowserCommon::add_access('contact', 'edit', array('ACCESS:employee', 'ACCESS:mrm'), array()); Utils_RecordBrowserCommon::add_access('contact', 'delete', array('ACCESS:employee', 'ACCESS:mrm')); Utils_RecordBrowserCommon::add_access('contact', 'view', 'ALL', array('view' => 'USER'), array('view', 'edit', 'add', 'delete')); Utils_RecordBrowserCommon::add_access('contact', 'edit', 'ALL', array('edit' => 'USER')); Utils_RecordBrowserCommon::add_access('contact', 'delete', 'ALL', array('delete' => 'USER')); Utils_RecordBrowserCommon::uninstall_recordset('cades_access_control'); Utils_CommonDataCommon::remove('CADES/AccessLevel'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_appointments'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_allergies'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_behavior'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_behavior_log'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_diagnosis', 'patient'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_diet'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_hospitalizations'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_immunizations'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_insurance'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_issues', 'patient'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_medicaltests'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_medications'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_reviews'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_seizures'); Custom_CADES_AccessRestrictionsCommon::add_default_cades_permissions('cades_services');
public static function crm_event_get($id) { if (!is_array($id)) { $r = Utils_RecordBrowserCommon::get_record('task', $id); } else { $r = $id; $id = $r['id']; } $r = Utils_RecordBrowserCommon::filter_record_by_access('task', $r); if (!$r) { return null; } $next = array('type' => __('Task')); $day = $r['deadline']; $iday = strtotime($day); $next['id'] = $r['id']; $base_unix_time = strtotime(date('1970-01-01 00:00:00')); $next['start'] = $iday; $next['timeless'] = $day; $next['duration'] = -1; $next['title'] = (string) $r['title']; $next['description'] = (string) $r['description']; $next['color'] = 'gray'; if ($r['status'] == 0 || $r['status'] == 1) { switch ($r['priority']) { case 0: $next['color'] = 'green'; break; case 1: $next['color'] = 'yellow'; break; case 2: $next['color'] = 'red'; break; } } if ($r['status'] == 2) { $next['color'] = 'blue'; } if ($r['status'] == 3) { $next['color'] = 'gray'; } $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'view'); if (Utils_RecordBrowserCommon::get_access('task', 'edit', $r) !== false) { $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'edit'); } else { $next['edit_action'] = false; $next['move_action'] = false; } if (Utils_RecordBrowserCommon::get_access('task', 'delete', $r) == false) { $next['delete_action'] = false; } /* $r_new = $r; if ($r['status']==0) $r_new['status'] = 1; if ($r['status']<=1) $next['actions'] = array( array('icon'=>Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href'=>self::get_status_change_leightbox_href($r_new, false, array('id'=>'status'))) );*/ $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, false); $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, false); $inf2 = array(__('Date') => '<b>' . $event_date . '</b>'); $emps = array(); foreach ($r['employees'] as $e) { $e = CRM_ContactsCommon::contact_format_no_company($e, true); $e = str_replace(' ', ' ', $e); if (mb_strlen($e, 'UTF-8') > 33) { $e = mb_substr($e, 0, 30, 'UTF-8') . '...'; } $emps[] = $e; } $next['busy_label'] = $r['employees']; $cuss = array(); foreach ($r['customers'] as $c) { $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers')); $cuss[] = str_replace(' ', ' ', $c); } $inf2 += array(__('Task') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('task/' . $r['id'])); $next['employees'] = $r['employees']; $next['customers'] = $r['customers']; $next['status'] = $r['status'] <= 2 ? 'active' : 'closed'; $next['custom_tooltip'] = '<center><b>' . __('Task') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null); return $next; }
public function make_event_PDF($pdf, $id, $no_details = false, $type = 'Event') { $custom_event = false; if (!is_array($id)) { $check = explode('#', $id); if (isset($check[1])) { $callback = DB::GetOne('SELECT handler_callback FROM crm_calendar_custom_events_handlers WHERE id=%d', $check[0]); $callback = explode('::', $callback); $ev = call_user_func($callback, 'get', $check[1]); $no_details = true; $custom_event = true; } else { trigger_error('Invalid event id: ' . $id, E_USER_ERROR); } } else { $ev = $id; $id = $ev['id']; $id = explode('_', $id); $id = $id[0]; /* $ev_details = DB::GetRow('SELECT *, starts AS start, ends AS end FROM crm_calendar_event WHERE id=%d', array($id)); foreach ($ev_details as $k=>$v) if (!isset($ev[$k])) $ev[$k] = $v;*/ $ev['title'] = strip_tags($ev['title']); $check = explode('#', $id); if (isset($check[1])) { $no_details = true; $custom_event = true; } } $pdf_theme = $this->pack_module('Base/Theme'); $pdf_theme->assign('description', array('label' => __('Description'), 'value' => str_replace("\n", '<br/>', htmlspecialchars($ev['description'])))); if (!$no_details) { $ev['status'] = Utils_CommonDataCommon::get_value('CRM/Status/' . $ev['status'], true); $ev['access'] = self::$access[$ev['access']]; $ev['priority'] = self::$priority[$ev['priority']]; foreach (array('access' => __('Access'), 'priority' => __('Priority'), 'status' => __('Status')) as $v => $label) { $pdf_theme->assign($v, array('label' => $label, 'value' => $ev[$v])); } $created_by = CRM_ContactsCommon::get_contact_by_user_id($ev['created_by']); if ($created_by !== null) { $created_by = $created_by['last_name'] . ' ' . $created_by['first_name']; } else { $created_by = Base_UserCommon::get_user_login($ev['created_by']); } $created_on = Base_RegionalSettingsCommon::time2reg($ev['created_on'], false); $pdf_theme->assign('created_on', array('label' => __('Created on'), 'value' => $created_on)); $pdf_theme->assign('created_by', array('label' => __('Created by'), 'value' => $created_by)); if ($ev['edited_by'] != null) { $edited_by = CRM_ContactsCommon::get_contact_by_user_id($ev['edited_by']); if ($edited_by !== null) { $edited_by = $edited_by['last_name'] . ' ' . $edited_by['first_name']; } else { $edited_by = Base_UserCommon::get_user_login($ev['edited_by']); } $edited_on = Base_RegionalSettingsCommon::time2reg($ev['edited_on'], false); } else { $edited_by = '--'; $edited_on = '--'; } $pdf_theme->assign('edited_on', array('label' => __('Edited on'), 'value' => $edited_on)); $pdf_theme->assign('edited_by', array('label' => __('Edited by'), 'value' => $edited_by)); $pdf_theme->assign('printed_on', array('label' => __('Printed on'), 'value' => Base_RegionalSettingsCommon::time2reg(time()))); } $emps = array(); $cuss = array(); $cus_cmps = array(); if (isset($ev['employees']) && !empty($ev['employees'])) { foreach ($ev['employees'] as $v) { $c = CRM_ContactsCommon::get_contact($v); $emps[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone']); } } if (isset($ev['customers']) && !empty($ev['customers'])) { foreach ($ev['customers'] as $v) { $det = explode(':', $v); if (isset($det[1])) { $v = $det[1]; } else { $v = $det[0]; $det[0] = 'P'; } if ($det[0] == 'P') { $c = CRM_ContactsCommon::get_contact($v); $company_name = isset($c['company_name']) && is_numeric($c['company_name']) ? array(Utils_RecordBrowserCommon::get_value('company', $c['company_name'], 'Company Name')) : '---'; $cuss[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone'], 'company_name' => $company_name); } if ($det[0] == 'C') { $c = array('company_name' => array($v)); } if (is_array($c['company_name'])) { foreach ($c['company_name'] as $v2) { if (!isset($cus_cmps[$v2])) { $cus_cmps[$v2] = CRM_ContactsCommon::get_company($v2); } } } } } $pdf_theme->assign('employees', array('main_label' => __('Employees'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'lp_label' => __('Lp'), 'data' => $emps)); $pdf_theme->assign('customers', array('main_label' => __('Customers'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'company_name' => __('Company Name'), 'lp_label' => __('Lp'), 'data' => $cuss)); $pdf_theme->assign('customers_companies', array('main_label' => __('Customers Companies'), 'name_label' => __('Company Name'), 'phone_label' => __('Phone'), 'fax_label' => __('Fax'), 'address_label' => __('Address'), 'city_label' => __('City'), 'lp_label' => __('Lp'), 'data' => $cus_cmps)); $pdf_theme->assign('title', array('label' => __('Title'), 'value' => $ev['title'])); $start = Base_RegionalSettingsCommon::time2reg($ev['start'], false); $pdf_theme->assign('start_date', array('label' => __('Start Date'), 'value' => $start, 'details' => array('weekday' => __date('l', strtotime($start))))); if (!isset($ev['timeless'])) { $pdf_theme->assign('start_time', array('label' => __('Start Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['start'], true, false))); if (!isset($ev['end'])) { trigger_error(print_r($ev, true)); } $pdf_theme->assign('end_time', array('label' => __('End Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], true, false))); $hours = floor(($ev['end'] - $ev['start']) / 3600); $format = __('%d hours', array($hours)); $minutes = ($ev['end'] - $ev['start']) % 3600; if ($minutes != 0) { if ($hours == 0) { $format = ''; } else { $format .= ', '; } $format .= __('%d minutes', array($minutes / 60)); } $pdf_theme->assign('duration', array('label' => __('Duration'), 'value' => $format)); if (date('Y-m-d', $ev['start']) != date('Y-m-d', $ev['end'])) { $pdf_theme->assign('end_date', array('label' => __('End Date'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], false))); } } else { $pdf_theme->assign('timeless', array('label' => __('Timeless'), 'value' => __('Yes'))); } $pdf_theme->assign('type', $type); ob_start(); $pdf_theme->display('pdf_version'); $cont = ob_get_clean(); $pdf->writeHTML($cont); }