示例#1
0
 public static function get_notifications()
 {
     $module = 'Base_Notify';
     $notifications_date = Base_User_SettingsCommon::get($module, 'last_update');
     if (!$notifications_date) {
         $notifications_date = time() - self::reset_time * 3600;
     }
     Base_User_SettingsCommon::save($module, 'last_update', time());
     return ModuleManager::call_common_methods('tray_notification', false, array($notifications_date));
 }
示例#2
0
文件: Tray_0.php 项目: 62BRAINS/EPESI
	public function get_tray_layout() {
		$tray_layout = Base_User_SettingsCommon::get('Utils/Tray','tray_layout');
		if (!isset(Utils_TrayCommon::$tray_layout[$tray_layout])) {
			$tray_layout = 'checkered';
			Base_User_SettingsCommon::save('Utils/Tray','tray_layout', 'checkered');
		}
		return $tray_layout;
	}
示例#3
0
 public function edit($user_settings_nav = true)
 {
     if ($user_settings_nav) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('add', __('Add preset'), $this->create_callback_href(array($this, 'edit_group')));
     $gb = $this->init_module('Utils/GenericBrowser', null, 'edit');
     $gb->set_table_columns(array(array('name' => __('Name'), 'width' => 20, 'order' => 'g.name'), array('name' => __('Description'), 'width' => 30, 'order' => 'g.description'), array('name' => __('Users in category'), 'width' => 50, 'order' => '')));
     $ret = DB::Execute('SELECT g.name,g.id,g.description FROM crm_filters_group g WHERE g.user_login_id=' . Acl::get_user());
     while ($row = $ret->FetchRow()) {
         $gb_row =& $gb->get_new_row();
         $gb_row->add_action($this->create_confirm_callback_href(__('Delete this group?'), array('CRM_Filters', 'delete_group'), $row['id']), 'Delete');
         $gb_row->add_action($this->create_callback_href(array($this, 'edit_group'), $row['id']), 'Edit');
         $cids = DB::GetAssoc('SELECT c.contact_id, c.contact_id FROM crm_filters_contacts c WHERE c.group_id=%d', array($row['id']));
         $users = array();
         foreach ($cids as $v) {
             $users[] = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact($v), true);
         }
         $gb_row->add_data($row['name'], $row['description'], implode(', ', $users));
     }
     $this->display_module($gb);
     $qf = $this->init_module('Libs/QuickForm', null, 'default_filter');
     $qf->addElement('checkbox', 'show_all_contacts_in_filters', __('Show all contacts in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->addElement('checkbox', 'show_only_users_in_filters', __('Show only users in Perspective selection'), null, array('onChange' => $qf->get_submit_form_js()));
     $qf->setDefaults(array('show_all_contacts_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_all_contacts_in_filters'), 'show_only_users_in_filters' => Base_User_SettingsCommon::get('CRM_Contacts', 'show_only_users_in_filters')));
     if ($qf->validate()) {
         $vals = $qf->exportValues();
         if (!isset($vals['show_all_contacts_in_filters'])) {
             $vals['show_all_contacts_in_filters'] = 0;
         }
         if (!isset($vals['show_only_users_in_filters'])) {
             $vals['show_only_users_in_filters'] = 0;
         }
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_all_contacts_in_filters', $vals['show_all_contacts_in_filters']);
         Base_User_SettingsCommon::save('CRM_Contacts', 'show_only_users_in_filters', $vals['show_only_users_in_filters']);
     }
     $qf->display();
 }
示例#4
0
    public function show_data($crits = array(), $cols = array(), $order = array(), $admin = false, $special = false, $pdf = false, $limit = null) {
		$this->help('RecordBrowser','main');
		if (Utils_RecordBrowserCommon::$admin_access) $admin = true;
        if (isset($_SESSION['client']['recordbrowser']['admin_access'])) Utils_RecordBrowserCommon::$admin_access = true;
        if (self::$clone_result!==null && $this->jump_to_new_record) {
            if (is_numeric(self::$clone_result)) $this->navigate('view_entry', 'view', self::$clone_result);
            $clone_result = self::$clone_result;
            self::$clone_result = null;
            if ($clone_result!='canceled') return;
        }
        if ($this->check_for_jump()) return;
        Utils_RecordBrowserCommon::$cols_order = $this->col_order;
        if ($this->get_access('browse')===false) {
            print(__('You are not authorised to browse this data.'));
            return;
        }

        $this->init();
        $this->action = 'Browse';
        if (!Base_AclCommon::i_am_admin() && $admin) {
            print(__('You don\'t have permission to access this data.'));
        }
        if ($this->data_gb!==null) $gb = $this->data_gb;
        else $gb = $this->init_module('Utils/GenericBrowser', null, $this->tab);

        if(!$pdf) $gb->set_expandable(true);
        
        if($pdf) $gb->set_resizable_columns(false);
        else $gb->set_fixed_columns_class($this->fixed_columns_class);

        if ($special) {
            $gb_per_page = Base_User_SettingsCommon::get('Utils/GenericBrowser','per_page');
            $gb->set_per_page(Base_User_SettingsCommon::get('Utils/RecordBrowser/RecordPicker','per_page'));
        }
        if (!$this->disabled['search']) {
            $gb->is_adv_search_on();
            $is_searching = $gb->get_module_variable('search','');
            if (!empty($is_searching)) {
                if ($this->get_module_variable('browse_mode')!='all'
//                  || $gb->get_module_variable('quickjump_to')!=null
                    ) {
                    $this->set_module_variable('browse_mode','all');
//                  $gb->set_module_variable('quickjump_to',null);
                    location(array());
                    return;
                }
            }
        }

        if ($special) {
            $table_columns = array(array('name'=>__('Select'), 'width'=>'40px'));
        } else {
            $table_columns = array();
            if (!$pdf && !$admin && $this->favorites) {
                $fav = array('name'=>' ', 'width'=>'24px', 'attrs'=>'class="Utils_RecordBrowser__favs"');
                if (!isset($this->force_order)) $fav['order'] = ':Fav';
                $table_columns[] = $fav;
            }
            if (!$pdf && !$admin && $this->watchdog)
                $table_columns[] = array('name'=>'', 'width'=>'24px', 'attrs'=>'class="Utils_RecordBrowser__watchdog"');
        }
        if (!$this->disabled['quickjump']) $quickjump = DB::GetOne('SELECT quickjump FROM recordbrowser_table_properties WHERE tab=%s', array($this->tab));
        else $quickjump = '';

        $hash = array();
        $query_cols = array();
        foreach($this->table_rows as $field => $args) {
            $hash[$args['id']] = $field;
            if ($field === 'id') continue;
            if ((!$args['visible'] && (!isset($cols[$args['id']]) || $cols[$args['id']] === false))) continue;
            if (isset($cols[$args['id']]) && $cols[$args['id']] === false) continue;
            $query_cols[] = $args['id'];
            $arr = array('name'=>$args['name']);
            if (!$pdf && !isset($this->force_order) && $this->browse_mode!='recent' && $args['type']!=='multiselect' && ($args['type']!=='calculated' || $args['param']!='') && $args['type']!=='hidden') $arr['order'] = $field;
            if ($args['type']=='checkbox' || (($args['type']=='date' || $args['type']=='timestamp' || $args['type']=='time') && !$this->add_in_table) || $args['type']=='commondata') {
                $arr['wrapmode'] = 'nowrap';
                $arr['width'] = 50;
            } else {
                $arr['width'] = 100;
			}
            $arr['name'] = _V($arr['name']); // ****** Translate field name for table header
            if (isset($this->more_table_properties[$args['id']])) {
                foreach (array('name','wrapmode','width','display','order') as $v) if (isset($this->more_table_properties[$args['id']][$v])) {
                    if (is_numeric($this->more_table_properties[$args['id']][$v]) && $v=='width') $this->more_table_properties[$args['id']][$v] = $this->more_table_properties[$args['id']][$v]*10;
                    $arr[$v] = $this->more_table_properties[$args['id']][$v];
                }
            }
            if (is_array($args['param']))
                $str = explode(';', $args['param']['array_id']);
            else
                $str = explode(';', $args['param']);
            $ref = explode('::', $str[0]);
            $each = array();
            if (!$pdf && $quickjump!=='' && $args['name']===$quickjump) $each[] = 'quickjump';
            if (!$pdf && !$this->disabled['search']) $each[] = 'search';
            foreach ($each as $e) {
                if ($args['type']=='text' || $args['type']=='currency' || $args['type'] == 'autonumber' || ($args['type']=='calculated' && preg_match('/^[a-z]+(\([0-9]+\))?$/i',$args['param'])!==0)) $arr[$e] = $args['id'];
				
                if (isset($args['ref_field']) && $args['ref_field']) $arr[$e] = $args['id'];
                if ($args['commondata'] && (!is_array($args['param']) || strpos($args['param']['array_id'],':')===false)) {
                    $arr[$e] = $args['id'];
                }
            }
            if (isset($arr['quickjump'])) $arr['quickjump'] = '"~'.$arr['quickjump'];
			if ($pdf) {
				$arr['attrs'] = 'style="border:1px solid black;font-weight:bold;text-align:center;color:white;background-color:gray"';
				if (!isset($arr['width'])) $arr['width'] = 100;
				if ($arr['width']==1) $arr['width'] = 100;
			}
            $table_columns[] = $arr;
        }
		if ($pdf) {
			$max = 0;
			$width_sum = 0;
			foreach ($table_columns as $k=>$v)
				if ($v['width']>$max) $max = $v['width'];
			foreach ($table_columns as $k=>$v) {
				$table_columns[$k]['width'] = intval($table_columns[$k]['width']);
				if ($table_columns[$k]['width']<$max/2) $table_columns[$k]['width'] = $max/2;
				$width_sum += $table_columns[$k]['width'];
			}
			$fraction = 0;
			foreach ($table_columns as $k=>$v) {
				$table_columns[$k]['width'] = floor(100*$v['width']/$width_sum);
				$fraction += 100*$v['width']/$width_sum - $table_columns[$k]['width'];
				if ($fraction>1) {
					$table_columns[$k]['width'] += 1;
					$fraction -= 1;
				}
				$table_columns[$k]['width'] = $table_columns[$k]['width'].'%';
			}
		}
		if (empty($table_columns)) {
			print('Invalid view, no fields to display');
			return;
		}

		$gb->set_table_columns( $table_columns );
		
		if (!$pdf) {
			$clean_order = array();
			foreach ($order as $k => $v) {
                if ($k[0] == ':') {
                    $clean_order[$k] = $v;
                    continue;
                }
				if(!in_array($k,$query_cols)) continue;
				if (isset($this->more_table_properties[$k]) && isset($this->more_table_properties[$k]['name'])) $key = $this->more_table_properties[$k]['name'];
				elseif (isset($hash[$k])) $key = $hash[$k];
				else $key = $k;
   				$clean_order[_V($key)] = $v; // TRSL
			}

			if ($this->browse_mode != 'recent')
				$gb->set_default_order($clean_order, $this->changed_view);
		}

        $search = $gb->get_search_query(true);
        $search_res = array();
		if ($this->search_calculated_callback) {
			$search_res = call_user_func($this->search_calculated_callback, $search);
		}
        if ($gb->is_adv_search_on()) {
            foreach ($search as $k=>$v) {
				$f_id = str_replace(array('"','~'),'',$k);
				$args = $this->table_rows[$hash[$f_id]];
				if ($args['commondata']) $k = $k.'[]';
				elseif (isset($args['ref_field']) && $args['ref_field']) $k = $k.'['.Utils_RecordBrowserCommon::get_field_id($args['ref_field']).']';
                if ($k[0]=='"') {
                    $search_res['~_'.$k] = $v;
                    continue;
                }
                if (is_array($v)) $v = $v[0];
                $v = explode(' ', $v);
                foreach ($v as $w) {
					if (!$args['commondata']) {
						$w = DB::Concat(DB::qstr('%'),DB::qstr($w),DB::qstr('%'));
						$op = '"';
					} else {
						$op = '';
					}
                    $search_res = Utils_RecordBrowserCommon::merge_crits($search_res, array('~'.$op.$k =>$w));
				}
            }
        } else {
            $val = reset($search);
            $isearch = $gb->get_module_variable('search');
            if (empty($isearch)) $val = null;
            $val2 = explode(' ', $val[0]);
            $leftovers = array();
            foreach ($val2 as $vv) {
                foreach ($search as $k=>$v) {
                    if ($v!=$val) {
                        $leftovers[$k] = $v;
                        continue;
                    }
                    if ($k[0]=='"') {
                        $search_res['~_'.$k] = $vv;
                        continue;
                    }
					$args = $this->table_rows[$hash[trim($k, '(|')]];
					if ($args['commondata']) $k = $k.'[]';
					elseif (isset($args['ref_field']) && $args['ref_field']) $k = $k.'['.Utils_RecordBrowserCommon::get_field_id($args['ref_field']).']';
					if (!$args['commondata']) {
						$w = DB::Concat(DB::qstr('%'),DB::qstr($vv),DB::qstr('%'));
						$op = '"';
					} else {
						$w = $vv;
						$op = '';
					}
                    $search_res = Utils_RecordBrowserCommon::merge_crits($search_res, array('~'.$op.$k =>$w));
                }
            }
            $search_res = Utils_RecordBrowserCommon::merge_crits($search_res, $leftovers);
        }

        if (!$pdf) $order = $gb->get_order();
        $crits = array_merge($crits, $search_res);
        if ($this->browse_mode == 'favorites')
            $crits[':Fav'] = true;
        if ($this->browse_mode == 'watchdog')
            $crits[':Sub'] = true;
        if ($this->browse_mode == 'recent') {
            $crits[':Recent'] = true;
            $order = array(':Visited_on'=>'DESC');
        }

        if ($admin && !$pdf) {
            $order = array(':Edited_on'=>'DESC');
            $form = $this->init_module('Libs/QuickForm', null, $this->tab.'_admin_filter');
            $form->addElement('select', 'show_records', __('Show records'), array(0=>'['.__('All').']',1=>'['.__('All active').']',2=>'['.__('All deactivated').']'), array('onchange'=>$form->get_submit_form_js()));
            $f = $this->get_module_variable('admin_filter', 0);
            $form->setDefaults(array('show_records'=>$f));
            $admin_filter = $form->exportValue('show_records');
            $this->set_module_variable('admin_filter', $admin_filter);
            switch($admin_filter) {
                case 0: Utils_RecordBrowserCommon::$admin_filter = '';
                    break;
                case 1: Utils_RecordBrowserCommon::$admin_filter = 'active=1 AND ';
                    break;
                case 2: Utils_RecordBrowserCommon::$admin_filter = 'active=0 AND ';
                    break;
            }
            $form->display_as_row();
        }
        if (isset($this->force_order)) $order = $this->force_order;
        if (!$order) $order = array();

        $this->amount_of_records = Utils_RecordBrowserCommon::get_records_count($this->tab, $crits, $admin, $order);

        if ($limit === null && !$this->disabled['pagination'])
            $limit = $gb->get_limit($this->amount_of_records);

		if (!$this->disabled['pdf'] && !$pdf && $this->get_access('print')) {
            $limited_print_records = 200;
            $limited_print = ($this->amount_of_records >= $limited_print_records);
            $print_limit = $limited_print ? $limit : null;
            $key = md5(serialize($this->tab).serialize($crits).serialize($cols).serialize($order).serialize($admin).serialize($print_limit));
            $_SESSION['client']['utils_recordbrowser'][$key] = array(
                'tab'=>$this->tab,
                'crits'=>$crits,
                'cols'=>$cols,
                'order'=>$order,
                'admin'=>$admin,
                'more_table_properties'=>$this->more_table_properties,
                'limit' => $print_limit,
            );
            $print_href = 'href="modules/Utils/RecordBrowser/print.php?'.http_build_query(array('key'=>$key, 'cid'=>CID)).'" target="_blank"';
            $print_tooltip_text = $limited_print ?
                __('Due to more than %d records, you are allowed to print current view', array($limited_print_records)) :
                __('Print all records');
            $print_tooltip = Utils_TooltipCommon::open_tag_attrs($print_tooltip_text, false);
            $this->new_button('print', __('Print'), "$print_href $print_tooltip");
		}

        $records = Utils_RecordBrowserCommon::get_records($this->tab, $crits, array(), $order, $limit, $admin);

        if (($this->get_access('export') || $this->enable_export) && !$this->disabled['export'])
            $this->new_button('save',__('Export'), 'href="modules/Utils/RecordBrowser/csv_export.php?'.http_build_query(array('tab'=>$this->tab, 'admin'=>$admin, 'cid'=>CID, 'path'=>$this->get_path())).'"');

        $this->set_module_variable('crits_stuff',$crits?$crits:array());
        $this->set_module_variable('order_stuff',$order?$order:array());

        $custom_label = '';
        if (!$pdf && !$special && $this->get_access('add',$this->custom_defaults)!==false) {
            if ($this->add_button!==null) $label = $this->add_button;
            elseif (!$this->multiple_defaults) $label = $this->create_callback_href(array($this, 'navigate'), array('view_entry', 'add', null, $this->custom_defaults));
            else $label = Utils_RecordBrowserCommon::create_new_record_href($this->tab,$this->custom_defaults,'multi',true,true);
            if ($label!==false && $label!=='') $custom_label = '<a '.$label.'><span class="record_browser_add_new" '.Utils_TooltipCommon::open_tag_attrs(__('Add new record')).'><img src="'.Base_ThemeCommon::get_template_file('Utils/RecordBrowser/add.png').'" /><div class="add_new">'.__('Add new').'</div></span></a>';
        }
        if ($this->more_add_button_stuff) {
            if ($custom_label) $custom_label = '<table><tr><td>'.$custom_label.'</td><td>'.$this->more_add_button_stuff.'</td></tr></table>';
            else $custom_label = $this->more_add_button_stuff;
        }
        $gb->set_custom_label($custom_label);

        if ($admin) $this->browse_mode = 'all';
        if ($this->browse_mode == 'recent') {
            $ret = DB::Execute('SELECT * FROM '.$this->tab.'_recent WHERE user_id=%d ORDER BY visited_on DESC', array(Acl::get_user()));
            while ($row = $ret->FetchRow()) {
                if (!isset($records[$row[$this->tab.'_id']])) continue;
                $records[$row[$this->tab.'_id']]['visited_on'] = Base_RegionalSettingsCommon::time2reg(strtotime($row['visited_on']));
            }
        } else {
            $this->set_module_variable('set_browsed_records',array('tab'=>$this->tab,'crits'=>$crits, 'order'=>$order, 'records'=>array()));
        }
        if ($special) $rpicker_ind = array();

        if (!$pdf && !$admin && $this->favorites) {
            $favs = array();
            $ret = DB::Execute('SELECT '.$this->tab.'_id FROM '.$this->tab.'_favorite WHERE user_id=%d', array(Acl::get_user()));
            while ($row=$ret->FetchRow()) $favs[$row[$this->tab.'_id']] = true;
        }
        self::$access_override['tab'] = $this->tab;
        if (isset($limit)) $i = $limit['offset'];

        $grid_enabled = $this->grid===null?Base_User_SettingsCommon::get('Utils/RecordBrowser','grid'):$this->grid;
        if ($grid_enabled) load_js('modules/Utils/RecordBrowser/grid.js');

        $this->view_fields_permission = $this->get_access('add', $this->custom_defaults);
        if (!$pdf && !$special && $this->add_in_table && $this->view_fields_permission) {
            $form = $this->init_module('Libs/QuickForm',null, 'add_in_table__'.$this->tab);
            $form_name = $form->get_name();
        } else $form_name = '';
        foreach ($records as $row) {
            if ($this->browse_mode!='recent' && isset($limit)) {
                self::$browsed_records['records'][$row['id']] = $i;
                $i++;
            }
            $row = Utils_RecordBrowserCommon::record_processing($this->tab, $row, 'browse');
            self::$access_override['id'] = $row['id'];
            $gb_row = $gb->get_new_row();
			$row_data = array();
            if (!$pdf && !$admin && $this->favorites) {
                $isfav = isset($favs[$row['id']]);
                $row_data[] = Utils_RecordBrowserCommon::get_fav_button($this->tab, $row['id'], $isfav);
            }
            if (!$pdf && !$admin && $this->watchdog)
                $row_data[] = Utils_WatchdogCommon::get_change_subscription_icon($this->tab,$row['id']);
            if ($special) {
                $element = $this->get_module_variable('element');
                $format = $this->get_module_variable('format_func');
                $row_data = array('<input type="checkbox" id="leightbox_rpicker_'.$element.'_'.$row['id'].'" formated_name="'.(is_callable($format)?strip_tags(call_user_func($format, $row, true)):'').'" />');
                $rpicker_ind[] = $row['id'];
            }
            $r_access = $this->get_access('view', $row);
            foreach($query_cols as $k=>$argsid) {
				if (!$r_access || !$r_access[$argsid]) {
					$row_data[] = '';
					continue;
				}
                $field = $hash[$argsid];
                $args = $this->table_rows[$field];
                $value = $this->get_val($field, $row, ($special || $pdf), $args);
                if (strip_tags($value)=='') $value .= '&nbsp;';
                if ($args['style']=='currency' || $args['style']=='number') $value = array('style'=>'text-align:right;','value'=>$value);
                if ($grid_enabled && !in_array($args['type'], array('calculated','multiselect','commondata'))) {
                    $table = '<table class="Utils_RecordBrowser__grid_table" style="width:100%" cellpadding="0" cellspacing="0" border="0"><tr><td id="grid_form_field_'.$argsid.'_'.$row['id'].'" style="display:none;">Loading...</td><td id="grid_value_field_'.$argsid.'_'.$row['id'].'">';
                    $ed_icon = '</td><td style="min-width:18px;width:18px;padding:0px;margin:0px;">'.
                                '<span id="grid_edit_'.$argsid.'_'.$row['id'].'" style="float:right;display:none;"><a href="javascript:void(0);" onclick="grid_enable_field_edit(\''.$argsid.'\','.$row['id'].',\''.$this->tab.'\',\''.$form_name.'\');"><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'edit.png').'"></a></span>'.
                                '<span id="grid_save_'.$argsid.'_'.$row['id'].'" style="float:right;display:none;"><a href="javascript:void(0);" onclick="grid_submit_field(\''.$argsid.'\','.$row['id'].',\''.$this->tab.'\');"><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils/RecordBrowser', 'save_grid.png').'"></a></span>'.
                                '</td></tr></table>';

/*                  $table = '<span id="grid_form_field_'.$argsid.'_'.$row['id'].'" style="display:none;">Loading...</span><span id="grid_value_field_'.$argsid.'_'.$row['id'].'">';
                    $ed_icon = '</span>'.
                                '<span id="grid_edit_'.$argsid.'_'.$row['id'].'" style="float:right;display:none;"><a href="javascript:void(0);" onclick="grid_enable_field_edit(\''.$argsid.'\','.$row['id'].',\''.$this->tab.'\',\''.$form_name.'\');"><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'edit.png').'"></a></span>'.
                                '<span id="grid_save_'.$argsid.'_'.$row['id'].'" style="float:right;display:none;"><a href="javascript:void(0);" onclick="grid_submit_field(\''.$argsid.'\','.$row['id'].',\''.$this->tab.'\');"><img border="0" src="'.Base_ThemeCommon::get_template_file('Utils/RecordBrowser', 'save_grid.png').'"></a></span>';*/


                    $attrs = 'onmouseover="if(typeof(mouse_over_grid)!=\'undefined\')mouse_over_grid(\''.$argsid.'\',\''.$row['id'].'\');" onmouseout="if(typeof(mouse_out_grid)!=\'undefined\')mouse_out_grid(\''.$argsid.'\',\''.$row['id'].'\');"';
//                  $attrs = 'onmouseover="$(\'grid_edit_'.$argsid.'_'.$row['id'].'\').style.display=\'inline\'" onmouseout="$(\'grid_edit_'.$argsid.'_'.$row['id'].'\').style.display=\'none\'"';
                } else {
                    $table = '';
                    $ed_icon = '';
                    $attrs = '';
                }
                if (is_array($value)) {
                    $value['value'] = $table.$value['value'].$ed_icon;
                    $value['attrs'] = $attrs;
                } else {
                    $value = array(
                        'value'=>$table.$value.$ed_icon,
                        'attrs'=>$attrs
                    );
                }
				if ($pdf) {
                    $value['overflow_box'] = false;
					$value['attrs'] = $attrs.' style="border:1px solid black;"';
					$value['value'] = '&nbsp;'.$value['value'].'&nbsp;';
				}
                $row_data[] = $value;
            }

            $gb_row->add_data_array($row_data);
            if (!$pdf && $this->disabled['actions']!==true) {
                if ($this->disabled['actions']===false) $da = array();
                else $da = array_flip($this->disabled['actions']);
                if (!$special) {
                    if (!isset($da['view'])) $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_entry', 'view', $row['id'])),__('View'), null, 'view');
					if (!isset($da['edit'])) {
						if ($this->get_access('edit',$row)) $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_entry', 'edit',$row['id'])),__('Edit'), null, 'edit');
						else $gb_row->add_action('',__('Edit'),__('You don\'t have permission to edit this record.'),'edit',0,true);
					}
                    if ($admin) {
                        if (!$row[':active']) $gb_row->add_action($this->create_callback_href(array($this,'set_active'),array($row['id'],true)),__('Activate'), null, 'active-off');
                        else $gb_row->add_action($this->create_callback_href(array($this,'set_active'),array($row['id'],false)),__('Deactivate'), null, 'active-on');
                        $info = Utils_RecordBrowserCommon::get_record_info($this->tab, $row['id']);
                        if ($info['edited_on']===null) $gb_row->add_action('',__('This record was never edited'),null,'history_inactive');
                        else $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_edit_history', $row['id'])),__('View edit history'),null,'history');
                    } else {
						if (!isset($da['delete'])) {
                            if ($this->get_access('delete',$row)) $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this record?'),array($this,'delete_record'),array($row['id'], false)),__('Delete'), null, 'delete');
                            else $gb_row->add_action('',__('Delete'),__('You don\'t have permission to delete this record'),'delete',0,true);
                        }
					}
                }
                if (!isset($da['info'])) $gb_row->add_info(($this->browse_mode=='recent'?'<b>'.__('Visited on: %s', array($row['visited_on'])).'</b><br>':'').Utils_RecordBrowserCommon::get_html_record_info($this->tab, isset($info)?$info:$row['id']));
                $this->call_additional_actions_methods($row, $gb_row);
            }
        }
        if (!$special && $this->add_in_table && $this->view_fields_permission) {

            $visible_cols = array();
            foreach($this->table_rows as $field => $args){
                if ((!$args['visible'] && (!isset($cols[$args['id']]) || $cols[$args['id']] === false))) continue;
                if (isset($cols[$args['id']]) && $cols[$args['id']] === false) continue;
                $visible_cols[$args['id']] = true;
            }

			self::$last_record = $this->record = $this->custom_defaults = Utils_RecordBrowserCommon::record_processing($this->tab, $this->custom_defaults, 'adding');

            $this->prepare_view_entry_details($this->custom_defaults, 'add', null, $form, $visible_cols);
            $form->setDefaults($this->custom_defaults);

            if ($form->isSubmitted()) {
                $this->set_module_variable('force_add_in_table_after_submit', true);
                if ($form->validate()) {
                    $values = $form->exportValues();
                    foreach ($this->custom_defaults as $k=>$v)
                        if (!isset($values[$k])) $values[$k] = $v;
                    $id = Utils_RecordBrowserCommon::new_record($this->tab, $values);
                    location(array());
                } else {
                    $this->show_add_in_table = true;
                }
            }
            $form->addElement('submit', 'submit_qanr', __('Save'), array('style'=>'width:100%;height:19px;', 'class'=>'button'));
            $renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
            $form->accept($renderer);
            $data = $renderer->toArray();

            $gb->set_prefix($data['javascript'].'<form '.$data['attributes'].'>'.$data['hidden']."\n");
            $gb->set_postfix("</form>\n");

            if (!$admin && $this->favorites) {
                $row_data= array('&nbsp;');
            } else $row_data= array();
            if (!$admin && $this->watchdog)
                $row_data[] = '&nbsp;';


            $first = true;
            foreach($visible_cols as $k => $v) {
                if (isset($data[$k])) {
                    $row_data[] = array('value'=>$data[$k]['error'].$data[$k]['html'], 'overflow_box'=>false);
                    if ($first) eval_js('focus_on_field = "'.$k.'";');
                    $first = false;
                } else $row_data[] = '&nbsp;';
            }

//          if ($this->browse_mode == 'recent')
//              $row_data[] = '&nbsp;';

            $gb_row = $gb->get_new_row();
            $gb_row->add_action('',$data['submit_qanr']['html'],'', null, 0, false, 7);
            $gb_row->set_attrs('id="add_in_table_row" style="display:'.($this->show_add_in_table?'':'none').';"');
            $gb_row->add_data_array($row_data);
        }
        if ($special) {
            $this->set_module_variable('rpicker_ind',$rpicker_ind);
            $ret = $this->get_html_of_module($gb);
            Base_User_SettingsCommon::save('Utils/RecordBrowser/RecordPicker','per_page',$gb->get_module_variable('per_page'));
            Base_User_SettingsCommon::save('Utils/GenericBrowser','per_page',$gb_per_page);
            return $ret;
        }
		if ($pdf) {
			$gb->absolute_width(true);
			$args = array(Base_ThemeCommon::get_template_filename('Utils_GenericBrowser','pdf'));
		} else $args = array();
		$this->display_module($gb, $args);
    }
示例#5
0
 public function submit_settings($values)
 {
     $reload = false;
     foreach ($this->settings_fields as $k) {
         $v = isset($values[$k]) ? $values[$k] : 0;
         $x = explode(self::$sep, $k);
         if (count($x) != 2) {
             continue;
         }
         list($module_name, $module_part) = $x;
         //print($module_name.':'.$module_part.'=>'.$v.'<br>');
         if ($this->get_module_variable('admin_settings')) {
             Base_User_SettingsCommon::save_admin($module_name, $module_part, $v);
             continue;
         } else {
             Base_User_SettingsCommon::save($module_name, $module_part, $v);
         }
         //check reload
         $cmr = ModuleManager::call_common_methods('user_settings');
         //already cached output
         if (!$reload && isset($cmr[$module_name])) {
             $menu = $cmr[$module_name];
             if (!is_array($menu)) {
                 continue;
             }
             foreach ($menu as $vv) {
                 if (!is_array($vv)) {
                     continue;
                 }
                 foreach ($vv as $v) {
                     if ($v['type'] == 'group') {
                         foreach ($v['elems'] as $e) {
                             if ($e['name'] == $module_part && isset($e['reload']) && $e['reload'] != 0) {
                                 $reload = true;
                             }
                         }
                     } elseif ($v['name'] == $module_part) {
                         if (isset($v['reload']) && $v['reload'] != 0) {
                             $reload = true;
                         }
                     }
                     if ($reload) {
                         break;
                     }
                 }
             }
         }
     }
     Base_StatusBarCommon::message($reload ? __('Setting saved - reloading page') : __('Setting saved'));
     if ($reload) {
         eval_js('setTimeout(\'document.location=\\\'index.php\\\'\',\'1500\')', false);
     }
     return true;
 }
示例#6
0
 public static function set_standard_mailto($value)
 {
     Base_User_SettingsCommon::save('CRM_Roundcube', 'standard_mailto', $value);
 }
示例#7
0
	/**
	 * Displays the table.
	 *
	 * @param string template file that should be used to display the table, use Base_ThemeCommon::get_template_filename() for proper filename
	 * @param bool enabling paging, true by default
	 */
	public function body($template=null,$paging=true){
		if(!$this->columns) trigger_error('columns array empty, please call set_table_columns',E_USER_ERROR);
		$md5_id = md5($this->get_path());
		$this->set_module_variable('first_display','done');
		$theme = $this->init_module('Base/Theme');
		$per_page = $this->get_module_variable('per_page');
		$order = $this->get_module_variable('order');
        $this->expandable = $this->get_module_variable('expandable',$this->expandable);
        $expand_action_only = false;
        if ($this->expandable) {
            if(!$this->en_actions) {
                $expand_action_only = true;
                $this->en_actions = true;
            }
        }
		if ($this->en_actions) $actions_position = Base_User_SettingsCommon::get('Utils/GenericBrowser','actions_position');

		$ch_adv_search = $this->get_unique_href_variable('adv_search');
		if (isset($ch_adv_search)) {
			$this->set_module_variable('adv_search',$ch_adv_search);
			$this->set_module_variable('search',array());
			location(array());
		}

		$search = $this->get_module_variable('search');

		$renderer = new HTML_QuickForm_Renderer_TCMSArraySmarty();
		$form_p = $this->init_module('Libs/QuickForm');
		$pager_on = false;
		if(isset($this->rows_qty) && $paging) {
			if(!$this->forced_per_page) {
				$form_p->addElement('select','per_page',__('Number of rows per page'), Utils_GenericBrowserCommon::$possible_vals_for_per_page, 'onChange="'.$form_p->get_submit_form_js(false).'"');
				$form_p->setDefaults(array('per_page'=>$per_page));
			}
			$qty_pages = ceil($this->rows_qty/$this->per_page);
			if ($qty_pages<=25) {
					$pages = array();
				if($this->rows_qty==0)
					$pages[0] = 1;
				else
					foreach (range(1, $qty_pages) as $v) $pages[$v] = $v;
				$form_p->addElement('select','page',__('Page'), $pages, 'onChange="'.$form_p->get_submit_form_js(false).'"');
				$form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1)));
			} else {
				$form_p->addElement('text','page',__('Page (%s to %s)', array(1,$qty_pages)), array('onclick'=>'this.focus();this.select();', 'onChange'=>$form_p->get_submit_form_js(false), 'style'=>'width:'.(7*strlen($qty_pages)).'px;'));
				$form_p->setDefaults(array('page'=>(int)(ceil($this->offset/$this->per_page)+1)));
			}
			$pager_on = true;
		}
		$search_on=false;
		if(!$this->is_adv_search_on()) {
			foreach($this->columns as $k=>$v)
				if (isset($v['search'])) {
					$this->form_s->addElement('text','search',__('Keyword'), array('id'=>'gb_search_field', 'placeholder'=>__('search keyword...'), 'x-webkit-speech'=>'x-webkit-speech', 'lang'=>Base_LangCommon::get_lang_code(), 'onwebkitspeechchange'=>$this->form_s->get_submit_form_js()));
					$this->form_s->setDefaults(array('search'=>isset($search['__keyword__'])?$search['__keyword__']:''));
					$search_on=true;
					break;
				}
		} else {
			$search_fields = array();
			if ($this->en_actions && $actions_position==0) $mov = 1;
			else $mov=0;
			foreach($this->columns as $k=>$v) {
				if(isset($v['display']) && !$v['display']) {
					$mov--;
					continue;
				}
				if (isset($v['search'])) {
					$this->form_s->addElement('hidden','search__'.$v['search'],'');
					$default = isset($search[$v['search']])?$search[$v['search']]:'';
					$this->form_s->setDefaults(array('search__'.$v['search']=>$default));
					$in = '<input value="'.$default.'" x-webkit-speech="x-webkit-speech" lang="'.Base_LangCommon::get_lang_code().'" name="search__textbox_'.$v['search'].'" placeholder="'.__('search keyword...').'" onblur="document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;" onkeydown="if (event.keyCode==13) {document.forms[\''.$this->form_s->getAttribute('name').'\'].search__'.$v['search'].'.value = this.value;'.$this->form_s->get_submit_form_js().';}" />';
					$search_fields[$k+$mov] = $in;
					$search_on=true;
				}
			}
			$theme->assign('search_fields', $search_fields);
		}
		if ($search_on) {
			$this->form_s->addElement('submit','submit_search',__('Search'), array('id'=>'gb_search_button'));
			if (Base_User_SettingsCommon::get($this->get_type(), 'show_all_button')) {
				$el = $this->form_s->addElement('hidden','show_all_pressed');
				$this->form_s->addElement('button','show_all',__('Show all'), array('onclick'=>'document.forms["'.$this->form_s->getAttribute('name').'"].show_all_pressed.value="1";'.$this->form_s->get_submit_form_js()));
				$el->setValue('0');
			}
		}
		if ($pager_on) {
			$form_p->accept($renderer);
			$form_array = $renderer->toArray();
			$theme->assign('form_data_paging', $form_array);
			$theme->assign('form_name_paging', $form_p->getAttribute('name'));

			// form processing
			if($form_p->validate()) {
				$values = $form_p->exportValues();
				if(isset($values['per_page'])) {
					$this->set_module_variable('per_page',$values['per_page']);
					Base_User_SettingsCommon::save('Utils/GenericBrowser','per_page',$values['per_page']);
				}
				if(isset($values['page']) && is_numeric($values['page']) && ($values['page']>=1 && $values['page']<=$qty_pages)) {
					$this->set_module_variable('offset',($values['page']-1)*$this->per_page);
				}
				location(array());
				return;
			}
		}
		if ($search_on) {
			$this->form_s->accept($renderer);
			$form_array = $renderer->toArray();
			$theme->assign('form_data_search', $form_array);
			$theme->assign('form_name_search', $this->form_s->getAttribute('name'));

			// form processing
			if($this->form_s->validate()) {
				$values = $this->form_s->exportValues();
				if (isset($values['show_all_pressed']) && $values['show_all_pressed']) {
					$this->set_module_variable('search',array());
					$this->set_module_variable('show_all_triggered',true);
					location(array());
					return;
				}
				$search = array();
				foreach ($values as $k=>$v){
					if ($k=='search') {
						if ($v!=__('search keyword...') && $v!='')
							$search['__keyword__'] = $v;
						break;
					}
					if (substr($k,0,8)=='search__') {
						$val = substr($k,8);
						if ($v!=__('search keyword...') && $v!='') $search[$val] = $v;
					}
				}
				$this->set_module_variable('search',$search);
				location(array());
				return;
			}
		}

		$headers = array();
		if ($this->en_actions) {
			$max_actions = 0; // Possibly improve it to calculate it during adding actions
			foreach($this->actions as $i=>$v) {
				$this_width = 0;
				foreach ($v as $vv) {
					$this_width += $vv['size'];
				}
				if ($this_width>$max_actions) $max_actions = $this_width;
			}
			if ($actions_position==0) $headers[-1] = array('label'=>'<span>'.'&nbsp;'.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"');
			else $headers[count($this->columns)] = array('label'=>'<span>'.'&nbsp;'.'</span>','attrs'=>'style="width: '.($max_actions*16+6).'px;" class="Utils_GenericBrowser__actions"');
		}

		$all_width = 0;
		foreach($this->columns as $k=>$v) {
			if (!isset($this->columns[$k]['width'])) $this->columns[$k]['width'] = 100;
			if (!is_numeric($this->columns[$k]['width'])) continue;
			$all_width += $this->columns[$k]['width'];
			if (isset($v['quickjump'])) {
				$quickjump = $this->set_module_variable('quickjump',$v['quickjump']);
				$quickjump_col = $k;
			}
		}
		$i = 0;
		$is_order = false;
		$adv_history = Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history');
		foreach($this->columns as $v) {
			if (array_key_exists('display', $v) && $v['display']==false) {
				$i++;
				continue;
			}
			if(isset($v['order'])) $is_order = true;
			if(!isset($headers[$i])) $headers[$i] = array('label'=>'');
			if (!$adv_history && $v['name'] && $v['name']==$order[0]['column']) $label = '<span style="padding-right: 12px; margin-right: 12px; background-image: url('.Base_ThemeCommon::get_template_file('Utils_GenericBrowser','sort-'.strtolower($order[0]['direction']).'ending.png').'); background-repeat: no-repeat; background-position: right;">'.$v['name'].'</span>';
			else $label = $v['name'];
			$headers[$i]['label'] .= (isset($v['preppend'])?$v['preppend']:'').(isset($v['order'])?'<a '.$this->create_unique_href(array('change_order'=>$v['name'])).'>' . $label . '</a>':$label).(isset($v['append'])?$v['append']:'');
			//if ($v['search']) $headers[$i] .= $form_array['search__'.$v['search']]['label'].$form_array['search__'.$v['search']]['html'];
            if ($this->absolute_width) {
                 $headers[$i]['attrs'] = 'width="'.$v['width'].'" ';
            } elseif (!is_numeric($v['width'])) {
                $headers[$i]['attrs'] = 'style="width:'.$v['width'].'" ';
            } else {
                $headers[$i]['attrs'] = 'width="'.intval(100*$v['width']/$all_width).'%" ';
            }
			$headers[$i]['attrs'] .= 'nowrap="1" ';
			if (isset($v['attrs'])) $headers[$i]['attrs'] .= $v['attrs'].' ';
			$i++;
		}
		ksort($headers);
		$out_headers = array_values($headers);
		unset($headers);

		$out_data = array();

        if($this->expandable) {
            eval_js_once('gb_expandable["'.$md5_id.'"] = {};');
            eval_js_once('gb_expanded["'.$md5_id.'"] = 0;');

            eval_js_once('gb_expand_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand.gif').'";');
            eval_js_once('gb_collapse_icon = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse.gif').'";');
            eval_js_once('gb_expand_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'expand_gray.gif').'";');
            eval_js_once('gb_collapse_icon_off = "'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'collapse_gray.gif').'";');
        }

		foreach($this->rows as $i=>$r) {
			$col = array();

            if($this->expandable) {
                $row_id =  $md5_id.'_'.$i;
                $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_expand(\''.$md5_id.'\',\''.$i.'\')" id="gb_more_'.$row_id.'"','Expand', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'plus_gray.png'), 1001);
                $this->__add_row_action($i,'style="display:none;" href="javascript:void(0)" onClick="gb_collapse(\''.$md5_id.'\',\''.$i.'\')" id="gb_less_'.$row_id.'"','Collapse', null, Base_ThemeCommon::get_template_file('Utils/GenericBrowser', 'minus_gray.png'), 1001, false, 0);
                $this->__add_row_js($i,'gb_expandable_init("'.Epesi::escapeJS($md5_id,true,false).'","'.Epesi::escapeJS($i,true,false).'")');
                if(!isset($this->row_attrs[$i])) $this->row_attrs[$i]='';
                $this->row_attrs[$i] .= 'id="gb_row_'.$row_id.'"';
            }

            if ($this->en_actions) {
				if ($actions_position==0) $column_no = -1;
				else $column_no = count($this->columns);
				$col[$column_no]['attrs'] = '';
				if (!empty($this->actions[$i])) {
					uasort($this->actions[$i], array($this,'sort_actions'));
					$actions = '';
					foreach($this->actions[$i] as $icon=>$arr) {
						$actions .= '<a '.Utils_TooltipCommon::open_tag_attrs($arr['tooltip']!==null?$arr['tooltip']:$arr['label'], $arr['tooltip']===null).' '.$arr['tag_attrs'].'>';
					    if ($icon=='view' || $icon=='delete' || $icon=='edit' || $icon=='info' || $icon=='restore' || $icon=='append data' || $icon=='active-on' || $icon=='active-off' || $icon=='history' || $icon=='move-down' || $icon=='move-up' || $icon=='history_inactive' || $icon=='print' || $icon == 'move-up-down') {
							$actions .= '<img class="action_button" src="'.Base_ThemeCommon::get_template_file('Utils/GenericBrowser',$icon.($arr['off']?'-off':'').'.png').'" border="0">';
					    } elseif(file_exists($icon)) {
							$actions .= '<img class="action_button" src="'.$icon.'" border="0">';
					    } else {
							$actions .= $arr['label'];
					    }
						$actions .= '</a>';
					}
					$col[$column_no]['label'] = $actions;
                    $col[$column_no]['attrs'] .= ' class="Utils_GenericBrowser__actions Utils_GenericBrowser__td"';

					// Add overflow_box to actions
					$settings = Base_User_SettingsCommon::get('Utils_GenericBrowser', 'zoom_actions');
					if ($settings==2 || ($settings==1 && detect_iphone()))
						$col[$column_no]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this,true);"';
				} else {
					$col[$column_no]['label'] = '&nbsp;';
                    $col[$column_no]['attrs'] .= 'nowrap="nowrap"'.' class="Utils_GenericBrowser__td"';
				}
				if (isset($this->no_actions[$i]))
					$col[$column_no]['attrs'] .= ' style="display:none;"';
			}
			foreach($r as $k=>$v) {
				if (is_array($v) && isset($v['dummy'])) $v['style'] = 'display:none;';
				if (array_key_exists('display',$this->columns[$k]) && $this->columns[$k]['display']==false) continue;
				if (is_array($v) && isset($v['attrs'])) $col[$k]['attrs'] = $v['attrs'];
				else $col[$k]['attrs'] = '';
				if ($this->absolute_width) $col[$k]['attrs'] .= ' width="'.$this->columns[$k]['width'].'"';
				if (!is_array($v)) $v = array('value'=>$v);
				$col[$k]['label'] = $v['value'];
				if (!isset($v['overflow_box']) || $v['overflow_box']) {
					$col[$k]['attrs'] .= ' onmouseover="if(typeof(table_overflow_show)!=\'undefined\')table_overflow_show(this);"';
				} else {
					if (!isset($v['style'])) $v['style'] = '';
					$v['style'] .= 'white-space: normal;';
				}
				$col[$k]['attrs'] .= ' class="Utils_GenericBrowser__td '.(isset($v['class'])?$v['class']:'').'"';
				$col[$k]['attrs'] .= isset($v['style'])? ' style="'.$v['style'].'"':'';
				if (isset($quickjump_col) && $k==$quickjump_col) $col[$k]['attrs'] .= ' class="Utils_GenericBrowser__quickjump"';
				if ((!isset($this->columns[$k]['wrapmode']) || $this->columns[$k]['wrapmode']!='cut') && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"';
				$col[$k]['attrs'] .= (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='nowrap')?' nowrap':'';
				if ($all_width!=0)
        				$max_width = 130*$this->columns[$k]['width']/$all_width*(7+(isset($this->columns[$k]['fontsize'])?$this->columns[$k]['fontsize']:0));
        			else
        			        $max_width = 0;
				if (isset($this->columns[$k]['wrapmode']) && $this->columns[$k]['wrapmode']=='cut'){
					if (strlen($col[$k]['label'])>$max_width){
						if (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].': '.$v['hint'].'"';
						else $col[$k]['attrs'] .= ' title="'.$col[$k]['label'].'"';
						$col[$k]['label'] = substr($col[$k]['label'],0,$max_width-3).'...';
					} elseif (is_array($v) && isset($v['hint'])) $col[$k]['attrs'] .= ' title="'.$v['hint'].'"';
					$col[$k]['attrs'] .= ' nowrap';
				}
			}
			ksort($col);
			$expanded = $this->expandable ? ' expanded' : '';
			foreach($col as $v)
				$out_data[] = array('label'=>'<div class="expandable'.$expanded.'">'.$v['label'].'</div>','attrs'=>$v['attrs']);
			if(isset($this->rows_jses[$i]))
				eval_js($this->rows_jses[$i]);
		}
		if (isset($quickjump)) {
			$quickjump_to = $this->get_module_variable('quickjump_to');
			$all = '<span class="all">'.__('All').'</span>';
			if (isset($quickjump_to) && $quickjump_to != '') $all = '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'')).'>'.__('All').'</a>';
			$letter_links = array(0 => $all);
			if ($quickjump_to != '0')
				$letter_links[] .= '<a class="all" '.$this->create_unique_href(array('quickjump_to'=>'0')).'>'.'123'.'</a>';
			else
				$letter_links[] .= '<span class="all">' . '123' . '</span>';
			$letter = 'A';
			while ($letter<='Z') {
				if ($quickjump_to != $letter)
					$letter_links[] .= '<a class="letter" '.$this->create_unique_href(array('quickjump_to'=>$letter)).'>'.$letter.'</a>';
				else
					$letter_links[] .= '<span class="letter">' . $letter . '</span>';
				$letter = chr(ord($letter)+1);
			}
			$theme->assign('letter_links', $letter_links);
			$theme->assign('quickjump_to', $quickjump_to);
		}

		$theme->assign('data', $out_data);
		$theme->assign('cols', $out_headers);

		$theme->assign('row_attrs', $this->row_attrs);

        $theme->assign('table_id','table_'.$md5_id);
        if($expand_action_only) {
            eval_js('gb_expandable_hide_actions("'.$md5_id.'")');
        }
		$theme->assign('table_prefix', $this->table_prefix);
		$theme->assign('table_postfix', $this->table_postfix);

		$theme->assign('summary', $this->summary());
		$theme->assign('first', $this->gb_first());
		$theme->assign('prev', $this->gb_prev());
		$theme->assign('next', $this->gb_next());
		$theme->assign('last', $this->gb_last());
		$theme->assign('custom_label', $this->custom_label);
		$theme->assign('custom_label_args', $this->custom_label_args);

        if($this->expandable) {
            $theme->assign('expand_collapse',array(
                'e_label'=>__('Expand All'),
                'e_href'=>'href="javascript:void(0);" onClick=\'gb_expand_all("'.$md5_id.'")\'',
                'e_id'=>'expand_all_button_'.$md5_id,
                'c_label'=>__('Collapse All'),
                'c_href'=>'href="javascript:void(0);" onClick=\'gb_collapse_all("'.$md5_id.'")\'',
                'c_id'=>'collapse_all_button_'.$md5_id
            ));
            $max_actions = isset($max_actions) ? $max_actions : 0;
            eval_js('gb_expandable_adjust_action_column("'.$md5_id.'", ' . $max_actions . ')');
            eval_js('gb_show_hide_buttons("'.$md5_id.'")');
        }

		if ($search_on) $theme->assign('adv_search','<a id="switch_search_'.($this->is_adv_search_on()?'simple':'advanced').'" class="button" '.$this->create_unique_href(array('adv_search'=>!$this->is_adv_search_on())).'>' . ($this->is_adv_search_on()?__('Simple Search'):__('Advanced Search')) . '&nbsp;&nbsp;&nbsp;<img src="' . Base_ThemeCommon::get_template_file($this -> get_type(), 'advanced.png') . '" width="8px" height="20px" border="0" style="vertical-align: middle;"></a>');
		else $theme->assign('adv_search','');

		if (Base_User_SettingsCommon::get('Utils/GenericBrowser','adv_history') && $is_order){
			$theme->assign('reset', '<a '.$this->create_unique_href(array('action'=>'reset_order')).'>'.__('Reset Order').'</a>');
			$theme->assign('order',$this->get_module_variable('order_history_display'));
		}
		$theme->assign('id',md5($this->get_path()));
		
		if ($this->resizable_columns) {
			load_js($this->get_module_dir().'js/col_resizable.js');
				
			$fixed_col_setting = !empty($this->fixed_columns_selector)? ', skipColumnClass:"'.$this->fixed_columns_selector.'"':'';
			eval_js('jq("#table_'.$md5_id.'").colResizable({liveDrag:true, postbackSafe:true, partialRefresh:true'.$fixed_col_setting.'});');
		}
		
		if(isset($template))
			$theme->display($template,true);
		else
			$theme->display();
		$this->set_module_variable('show_all_triggered',false);
	}
示例#8
0
<?php
/**
 * @author Arkadiusz Bisaga <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license Commercial
 * @version 1.0
 * @package epesi-utils
 * @subpackage recordbrowser
 */
if (!isset($_POST['tab']) || !isset($_POST['value']) || !isset($_POST['cid']))
	die('Invalid request: '.print_r($_POST,true));

define('JS_OUTPUT',1);
define('CID',$_POST['cid']); 
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();

if (!Acl::is_user()) die('');

$tab = json_decode($_POST['tab']);
$value = json_decode($_POST['value']);

if (!is_numeric($value) || !is_string($tab)) 
	die('Invalid request');

Base_User_SettingsCommon::save('Utils/RecordBrowser',$tab.'_show_filters', $value);

?>
示例#9
0
<?php

/**
 * @author Arkadiusz Bisaga <*****@*****.**>
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license Commercial
 * @version 1.0
 * @package epesi-utils
 * @subpackage recordbrowser
 */
if (!isset($_POST['tab']) || !isset($_POST['value']) || !isset($_POST['cid'])) {
    die('Invalid request: ' . print_r($_POST, true));
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Acl::is_user()) {
    die('');
}
$tab = json_decode($_POST['tab']);
$value = json_decode($_POST['value']);
if (!is_numeric($value) || !is_string($tab)) {
    die('Invalid request');
}
Base_User_SettingsCommon::save(Utils_RecordBrowser::module_name(), $tab . '_show_filters', $value);
示例#10
0
 public function get_navigation_bar_additions()
 {
     $custom_handlers = CRM_CalendarCommon::get_event_handlers();
     if (empty($custom_handlers)) {
         return '';
     }
     $form = $this->init_module(Libs_QuickForm::module_name());
     $elements_name = array();
     $default = array();
     foreach ($custom_handlers as $k => $v) {
         $form->addElement('checkbox', 'events_handlers__' . $k, $v, null, array('onclick' => 'calendar_event_handlers_changed=1;'));
         $elements_name[$k] = 'events_handlers__' . $k;
         $default[] = $k;
     }
     $form->addElement('hidden', 'event_handlers_changed', '', array('id' => 'event_handlers_changed'));
     eval_js('calendar_event_handlers_changed=0;');
     eval_js('hide_calendar_event_handlers_popup = function() {' . 'if(var_hide_calendar_event_handlers_popup==1){' . '$("calendar_event_handlers_popup").style.display="none";' . '$("calendar_event_handlers_trigger").innerHTML=calendar_event_handlers_message_default;' . 'if(calendar_event_handlers_changed==1){' . $form->get_submit_form_js() . '$("calendar_event_handlers_trigger").innerHTML=calendar_event_handlers_message_processing;' . '}' . '}' . '}');
     eval_js('show_calendar_event_handlers_popup = function() {' . '$("calendar_event_handlers_popup").style.display="";' . '$("calendar_event_handlers_trigger").innerHTML=calendar_event_handlers_message_confirm;' . '}');
     $selected = Base_User_SettingsCommon::get('CRM_Calendar_Event', 'event_handlers');
     if ($selected === null) {
         $selected = $default;
     }
     if ($form->validate()) {
         $vals = $form->exportValues();
         $selected = array();
         foreach ($elements_name as $k => $e) {
             if (isset($vals[$e]) && $vals[$e]) {
                 $selected[] = $k;
             }
         }
         Base_User_SettingsCommon::save('CRM_Calendar_Event', 'event_handlers', $selected);
     }
     CRM_Calendar_EventCommon::$events_handlers = $selected;
     foreach ($selected as $k => $e) {
         if (isset($elements_name[$e])) {
             $form->setDefaults(array($elements_name[$e] => true));
         }
     }
     $label = 'Filter: Error';
     $select_count = count($selected);
     if ($select_count == count($custom_handlers)) {
         $label = __('All');
     } else {
         $label = __('Selection (%d)', array($select_count));
     }
     if ($select_count == 1) {
         $label = $custom_handlers[reset($selected)];
     }
     if ($select_count == 0) {
         $label = __('None');
     }
     $theme = $this->init_module(Base_Theme::module_name());
     $theme->assign('elements_name', $elements_name);
     $theme->assign('label', $label);
     eval_js('calendar_event_handlers_message_default="' . $label . '";');
     eval_js('calendar_event_handlers_message_processing="' . __('Processing...') . '";');
     eval_js('calendar_event_handlers_message_confirm="' . __('Save selection') . '";');
     $form->assign_theme('form', $theme);
     ob_start();
     $theme->display('custom_event_handlers_form');
     $handlers_form = ob_get_clean();
     return $handlers_form;
 }