Esempio n. 1
0
 public function admin()
 {
     if ($this->is_back()) {
         if ($this->parent->get_type() == 'Base_Admin') {
             $this->parent->reset();
         } elseif (Base_BoxCommon::main_module_instance()->get_type() == $this->get_type()) {
             Base_BoxCommon::pop_main();
         }
         return;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'rb_custom');
     $gb->set_table_columns(array(array('name' => __('Table')), array('name' => __('Caption')), array('name' => __('Menu Entry'))));
     $tabs = DB::GetAll('SELECT * FROM recordbrowser_custom_recordsets ORDER BY tab ASC');
     foreach ($tabs as $t) {
         $gbr = $gb->get_new_row();
         if (!$t['active']) {
             $gbr->add_action($this->create_callback_href(array($this, 'set_active'), array($t['id'], true)), 'Activate', null, 'active-off');
         } else {
             $gbr->add_action($this->create_callback_href(array($this, 'set_active'), array($t['id'], false)), 'Deactivate', null, 'active-on');
         }
         $gbr->add_action($this->create_callback_href(array($this, 'edit_rset'), array($t['id'])), 'edit');
         $table_name = $t['tab'];
         $table_href = $this->create_callback_href(array($this, 'manage_recordset'), array($table_name));
         $gbr->add_data("<a {$table_href}>{$table_name}</a>", Utils_RecordBrowserCommon::get_caption($t['tab']), str_replace(Utils_RecordBrowser_CustomRecordsetsCommon::$sep, ' -> ', $t['menu']));
     }
     Base_ActionBarCommon::add('new', __('Create new'), $this->create_callback_href(array($this, 'edit_rset')));
     $this->display_module($gb);
 }
Esempio n. 2
0
 /**
  * This method is responsible for printing document.
  *
  * Example code:
  * <code>
  * $section = $this->new_section();
  * $section->assign('data', $data);
  * $this->print_section('section_name', $section);
  * </code>
  *
  * @param mixed $data This is a value that is passed to get_href method
  *
  * @see new_section
  * @see print_section
  * @see set_footer
  * @return null It doesn't have to return value
  */
 protected function print_document($data)
 {
     $tab = $data['tab'];
     $record_id = $data['record_id'];
     $printable_data = $this->format_values($tab, $record_id);
     $this->get_document()->set_filename($tab . '_' . $record_id);
     $section = $this->new_section();
     $section->assign('cols', $this->cols());
     $section->assign('caption', Utils_RecordBrowserCommon::get_caption($tab));
     $section->assign('record_id', $record_id);
     $section->assign('data', $printable_data);
     $this->print_section('record', $section);
 }
Esempio n. 3
0
 public static function display_recordset($r, $nolink = false)
 {
     $caption = Utils_RecordBrowserCommon::get_caption($r['recordset']);
     return $caption . ' (' . $r['recordset'] . ')';
 }
Esempio n. 4
0
    public function setup_loader() {
        if (isset($_REQUEST['field_pos'])) {
            list($field, $position) = $_REQUEST['field_pos'];
            // adjust position
            $position += 2;
            Utils_RecordBrowserCommon::change_field_position($this->tab, $field, $position);
        }
        $this->init(true);
        $action = $this->get_module_variable_or_unique_href_variable('setup_action', 'show');
        $subject = $this->get_module_variable_or_unique_href_variable('subject', 'regular');
		
		$full_access = Base_AdminCommon::get_access('Utils_RecordBrowser', 'fields')==2;

		if ($full_access) {
			Base_ActionBarCommon::add('add',__('New field'),$this->create_callback_href(array($this, 'view_field')));
			Base_ActionBarCommon::add('add',__('New page'),$this->create_callback_href(array($this, 'new_page')));
		}
        $gb = $this->init_module('Utils/GenericBrowser', null, 'fields');
        $gb->set_table_columns(array(
            array('name'=>__('Field'), 'width'=>20),
            array('name'=>__('Caption'), 'width'=>20),
            array('name'=>__('Type'), 'width'=>10),
            array('name'=>__('Table view'), 'width'=>5),
            array('name'=>__('Tooltip'), 'width'=>5),
            array('name'=>__('Required'), 'width'=>5),
            array('name'=>__('Filter'), 'width'=>5),
            array('name'=>__('Export'), 'width'=>5),
            array('name'=>__('Parameters'), 'width'=>27),
            array('name'=>__('Value display function'), 'width'=>5),
            array('name'=>__('Field generator function'), 'width'=>5)
		));
		
		$display_callbacbacks = DB::GetAssoc('SELECT field, callback FROM '.$this->tab.'_callback WHERE freezed=1');
		$QFfield_callbacbacks = DB::GetAssoc('SELECT field, callback FROM '.$this->tab.'_callback WHERE freezed=0');

        //read database
        $rows = end($this->table_rows);
		$rows = $rows['position'];
        foreach($this->table_rows as $field=>$args) {
            $gb_row = $gb->get_new_row();
			if ($full_access) {
				if ($args['type'] != 'page_split') {
					$gb_row->add_action($this->create_callback_href(array($this, 'view_field'),array('edit',$field)),'Edit');
				} elseif ($field!='General') {
					$gb_row->add_action($this->create_callback_href(array($this, 'delete_page'),array($field)),'Delete');
					$gb_row->add_action($this->create_callback_href(array($this, 'edit_page'),array($field)),'Edit');
				}
				if ($args['type']!=='page_split' && $args['extra']){
					if ($args['active']) $gb_row->add_action($this->create_callback_href(array($this, 'set_field_active'),array($field, false)),'Deactivate', null, 'active-on');
					else $gb_row->add_action($this->create_callback_href(array($this, 'set_field_active'),array($field, true)),'Activate', null, 'active-off');
				}
                if ($field != 'General') {
                    $gb_row->add_action('class="move-handle"','Move', __('Drag to change field position'), 'move-up-down');
                    $gb_row->set_attrs("field_name=\"$field\" class=\"sortable\"");
                }
			}
            switch ($args['type']) {
				case 'text':
					$args['param'] = __('Length').' '.$args['param'];
					break;
				case 'select':
				case 'multiselect':
					$reg = explode(';', $args['param']);
					$rege = explode('::', $reg[0]);
					if ($rege[0]=='__COMMON__') {
						$args['param'] = array('array_id'=>$rege[1], 'order_by_key'=>(isset($rege[2]) && $rege[2]=='key'));
						$args['type'] = 'multiselect';
					} elseif ($rege[0]=='__RECORDSETS__') {
						$param = __('Source').': Record Sets'.'<br/>';
						$param .= __('Crits callback').': '.(!isset($reg[1]) || $reg[1]=='::'?'---':$reg[1]);
						$args['param'] = $param;
						break;
					} else {
						$param = __('Source').': Record Set'.'<br/>';
						$param .= __('Recordset').': '.Utils_RecordBrowserCommon::get_caption($rege[0]).' ('.$rege[0].')<br/>';
						$fs = explode('|', isset($rege[1])?$rege[1]:'');
						foreach ($fs as $k=>$v)
							$fs[$k] = _V($v); // ****** RecordBrowser - field name
						$param .= __('Related field(s)').': '.(implode(', ',$fs)).'<br/>';
						$param .= __('Crits callback').': '.(!isset($reg[1]) || $reg[1]=='::'?'---':$reg[1]);
						$args['param'] = $param;
						break;
					}
				case 'commondata':
					if ($args['type']=='commondata') $args['type'] = 'select';
					$param = __('Source').': CommonData'.'<br/>';
					$param .= __('Table').': '.$args['param']['array_id'].'<br/>';
					$param .= __('Order by').': '.($args['param']['order_by_key']?__('Key'):__('Value'));
					$args['param'] = $param;
					break;
                case 'time':
                case 'timestamp':
                    $interval = $args['param'] ? $args['param'] : __('Default');
                    $args['param'] = __('Minutes Interval') . ': ' . $interval;
                    break;
				default:
					$args['param'] = '';
			}
			$types = array(
				'hidden'=>__('Hidden'),
				'calculated'=>__('Calculated'),
				'currency'=>__('Currency'),
				'checkbox'=>__('Checkbox'),
				'date'=>__('Date'),
				'integer'=>__('Integer'),
				'float'=>__('Float'),
				'text'=>__('Text'),
				'long text'=>__('Long text'),
				'select'=>__('Select field'),
				'multiselect'=>__('Multiselect field')
			);
            if ($args['type'] == 'page_split')
                    $gb_row->add_data(
                        array('style'=>'background-color: #DFDFFF;', 'value'=>$field),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>$args['name']),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>__('Page Split')),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>''),
                        array('style'=>'background-color: #DFDFFF;', 'value'=>'')
                    );
                else {
					if (isset($display_callbacbacks[$field])) {
						$d_c = '<b>Yes</b>';
						if (!is_callable(explode('::', $display_callbacbacks[$field]))) $d_c = '<span style="color:red;font-weight:bold;">Invalid!</span>';
						$d_c = Utils_TooltipCommon::create($d_c, $display_callbacbacks[$field], false);
					} else $d_c = '';
					if (isset($QFfield_callbacbacks[$field])) {
						$QF_c = '<b>Yes</b>';
						if (!is_callable(explode('::', $QFfield_callbacbacks[$field]))) $QF_c = '<span style="color:red;font-weight:bold;">Invalid!</span>';
						$QF_c = Utils_TooltipCommon::create($QF_c, $QFfield_callbacbacks[$field], false);
					} else $QF_c = '';
                    $gb_row->add_data(
                        $field,
                        $args['name'],
                        isset($types[$args['type']])?$types[$args['type']]:$args['type'],
                        $args['visible']?'<b>'.__('Yes').'</b>':__('No'),
                        $args['tooltip']?'<b>'.__('Yes').'</b>':__('No'),
                        $args['required']?'<b>'.__('Yes').'</b>':__('No'),
                        $args['filter']?'<b>'.__('Yes').'</b>':__('No'),
                        $args['export']?'<b>'.__('Yes').'</b>':__('No'),
                        is_array($args['param'])?serialize($args['param']):$args['param'],
						$d_c,
						$QF_c
                    );
				}
        }
        $this->display_module($gb);

        // sorting
        load_js($this->get_module_dir() . 'sort_fields.js');
        $table_md5 = md5($gb->get_path());
        eval_js("rb_admin_sort_fields_init(\"$table_md5\")");
    }
Esempio n. 5
0
 /**
  * Retrieve currrent caption of RecordSet.
  * @return string caption
  */
 public function get_caption()
 {
     return Utils_RecordBrowserCommon::get_caption($this->tab);
 }
Esempio n. 6
0
 public function body()
 {
     if (!Base_AclCommon::check_permission('View Activity Report')) {
         return;
     }
     $rb_tabs = DB::GetAssoc('SELECT tab, caption FROM recordbrowser_table_properties ORDER BY caption');
     foreach ($rb_tabs as $k => $v) {
         $rb_tabs[$k] = Utils_RecordBrowserCommon::get_caption($k);
     }
     $form = $this->init_module('Libs/QuickForm');
     $users_count = DB::GetOne('SELECT COUNT(id) FROM user_login') > Base_User_SettingsCommon::get('Utils_RecordBrowser', 'enable_autocomplete');
     if ($users_count) {
         $crits = array('!login' => '');
         $fcallback = array('CRM_ContactsCommon', 'contact_format_no_company');
         $form->addElement('autoselect', 'user', __('User'), array(), array(array('CRM_ContactsCommon', 'autoselect_contact_suggestbox'), array($crits, $fcallback)), $fcallback);
     } else {
         $users = DB::GetAssoc('SELECT id, id FROM user_login');
         foreach ($users as $k => $u) {
             $users[$k] = Base_UserCommon::get_user_label($u, true);
         }
         asort($users);
         $users = array('' => '[' . __('All') . ']') + $users;
         $form->addElement('select', 'user', __('User'), $users);
     }
     $form->addElement('multiselect', 'recordsets', __('Record Type'), $rb_tabs);
     $form->addElement('checkbox', 'new', __('New record'));
     $form->addElement('checkbox', 'edit', __('Record edit'));
     $form->addElement('checkbox', 'delete_restore', __('Record Delete/restore'));
     $form->addElement('checkbox', 'file', __('Files'));
     $form->addElement('datepicker', 'start_date', __('Start Date'));
     $form->addElement('datepicker', 'end_date', __('End Date'));
     //$form->addElement('submit', 'submit', __('Show'));
     Base_ActionBarCommon::add('search', __('Show'), $form->get_submit_form_href());
     $filters = $this->get_module_variable('filters', array('user' => '', 'new' => 1, 'edit' => 1, 'delete_restore' => 1, 'recordsets' => array_keys($rb_tabs), 'start_date' => date('Y-m-01'), 'end_date' => date('Y-m-d')));
     if ($form->validate()) {
         $filters = $form->exportValues();
         $this->set_module_variable('filters', $filters);
     }
     $form->setDefaults($filters);
     $theme = $this->init_module('Base/Theme');
     $form->assign_theme('form', $theme);
     $theme->display();
     $filters['recordsets'] = array_flip($filters['recordsets']);
     foreach ($rb_tabs as $k => $v) {
         if (!isset($filters['recordsets'][$k])) {
             unset($rb_tabs[$k]);
         }
     }
     $gb = $this->init_module('Utils/GenericBrowser', null, 'activity_report');
     $gb->set_table_columns(array(array('name' => __('Date'), 'width' => 40), array('name' => __('User'), 'width' => 40), array('name' => __('Type'), 'width' => 40), array('name' => __('Label')), array('name' => __('Actions taken'), 'width' => 40)));
     $tables = array();
     if ($users_count) {
         $filters['user'] = CRM_ContactsCommon::get_contact($filters['user']);
         $filters['user'] = $filters['user']['login'];
     }
     $af_where = array();
     foreach ($rb_tabs as $k => $t) {
         $af_where[] = 'ual.local ' . DB::like() . ' ' . DB::Concat(DB::qstr($k . '/'), DB::qstr('%'));
     }
     $af_where = count($af_where) ? ' (' . implode(' OR ', $af_where) . ')' : 'TRUE ';
     $e_where = array();
     $c_where = '';
     if ($filters['user']) {
         $e_where[] = ' edited_by = ' . $filters['user'];
         $c_where = ' created_by = ' . $filters['user'];
         $af_where .= ' AND uaf.created_by = ' . $filters['user'];
     }
     if (isset($filters['edit'])) {
         if (!isset($filters['delete_restore'])) {
             $e_where[] = ' ehd.field!=' . DB::qstr('id');
         }
     } else {
         if (isset($filters['delete_restore'])) {
             $e_where[] = ' ehd.field=' . DB::qstr('id');
         }
     }
     if ($filters['start_date']) {
         $date = DB::qstr(date('Y-m-d', strtotime($filters['start_date'])));
         $af_where .= ' AND uaf.created_on >= ' . $date;
         $c_where .= ($c_where ? ' AND' : '') . ' created_on >= ' . $date;
         $e_where[] = ' edited_on >= ' . $date;
     }
     if ($filters['end_date']) {
         $date = DB::qstr(date('Y-m-d 23:59:59', strtotime($filters['end_date'])));
         $af_where .= ' AND uaf.created_on <= ' . $date;
         $c_where .= ($c_where ? ' AND' : '') . ' created_on <= ' . $date;
         $e_where[] = ' edited_on <= ' . $date;
     }
     if (!empty($e_where)) {
         $e_where = ' WHERE' . implode(' AND', $e_where);
     } else {
         $e_where = '';
     }
     if ($c_where) {
         $c_where = ' WHERE' . $c_where;
     }
     $postgre_cast_type = DB::is_postgresql() ? '::varchar' : '';
     // **** files ****
     if (isset($filters['file'])) {
         $tables[] = 'SELECT uaf.id AS id,uaf.created_on AS edited_on,uaf.created_by AS edited_by, ual.local AS r_id, ' . DB::qstr('') . ' AS tab, ' . DB::qstr('file') . ' AS action FROM utils_attachment_file uaf INNER JOIN utils_attachment_data_1 ua ON uaf.attach_id=ua.id INNER JOIN utils_attachment_local ual ON ua.id=ual.attachment WHERE original!=' . DB::qstr('') . ' AND ' . $af_where;
     }
     // **** edit ****
     if (isset($filters['edit']) || isset($filters['delete_restore'])) {
         foreach ($rb_tabs as $k => $t) {
             $tables[] = 'SELECT id, edited_on, edited_by, ' . $k . '_id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('edit') . ' as action FROM ' . $k . '_edit_history eh LEFT JOIN ' . $k . '_edit_history_data ehd ON ehd.edit_id=eh.id' . $e_where;
         }
     }
     // **** create ****
     if (isset($filters['new'])) {
         foreach ($rb_tabs as $k => $t) {
             $tables[] = 'SELECT 0 AS id, created_on AS edited_on, created_by AS edited_by, id' . $postgre_cast_type . ' as r_id, ' . DB::qstr($k) . ' as tab, ' . DB::qstr('create') . ' as action FROM ' . $k . '_data_1' . $c_where;
         }
     }
     if (!empty($tables)) {
         $tables = implode(' UNION ', $tables);
         $limit = DB::GetOne('SELECT COUNT(*) FROM (' . $tables . ') AS tmp');
         $limit = $gb->get_limit($limit);
         $ret = DB::SelectLimit('SELECT * FROM (' . $tables . ') AS tmp ORDER BY edited_on DESC', $limit['numrows'], $limit['offset']);
         while ($row = $ret->FetchRow()) {
             $user = Base_UserCommon::get_user_label($row['edited_by']);
             $action = '';
             $link = '';
             switch ($row['action']) {
                 case 'edit':
                     $details = DB::GetAssoc('SELECT field, old_value FROM ' . $row['tab'] . '_edit_history_data WHERE edit_id=%d', array($row['id']));
                     if (isset($details['id'])) {
                         $action = $details['id'] == 'DELETED' ? __('Deleted') : __('Restored');
                     } else {
                         $action = __('Edited');
                         $action = '<a ' . Utils_TooltipCommon::tooltip_leightbox_mode() . ' ' . Utils_TooltipCommon::ajax_open_tag_attrs(array('Utils_RecordBrowserCommon', 'get_edit_details_label'), array($row['tab'], $row['r_id'], $row['id']), 500) . '>' . $action . '</a>';
                     }
                     $r_id = $row['r_id'];
                     break;
                 case 'create':
                     $action = __('Created');
                     $r_id = $row['r_id'];
                     break;
                 case 'file':
                     $action = __('Attachment') . ': ';
                     $action .= $row['id'] == 0 ? __('New') : __('Updated');
                     $id = explode('/', $row['r_id']);
                     $row['tab'] = $id[0];
                     $r_id = $id[1];
                     break;
                 case 'note':
                     $action = __('Note') . ': ';
                     $action .= $row['id'] == 0 ? __('New') : __('Updated');
                     $id = explode('/', $row['r_id']);
                     $row['tab'] = $id[0];
                     $r_id = $id[1];
                     break;
             }
             if (!Utils_RecordBrowserCommon::get_access($row['tab'], 'view', Utils_RecordBrowserCommon::get_record($row['tab'], $r_id))) {
                 $link = __('Access restricted');
                 $action = strip_tags($action);
             } else {
                 $link = Utils_TooltipCommon::create('<img src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'info.png') . '">', Utils_RecordBrowserCommon::get_html_record_info($row['tab'], $r_id), false);
                 $link .= '&nbsp;';
                 $link .= Utils_RecordBrowserCommon::create_default_linked_label($row['tab'], $r_id, false, false);
             }
             $gb->add_row(Base_RegionalSettingsCommon::time2reg($row['edited_on']), $user, $rb_tabs[$row['tab']], $link, $action);
         }
     }
     Base_ThemeCommon::load_css('Utils_RecordBrowser', 'changes_list');
     $this->display_module($gb);
 }
Esempio n. 7
0
        if ($qry) {
            $arrRow = array();
            $result = "";
            while ($rowValue = $qry->FetchRow()) {
                $rowValue["RECORD_SET"] = $key;
                $arrayKey[] = $rowValue;
            }
        }
    }
    if (is_array($arrayKey) && !empty($arrayKey)) {
        foreach ($arrayKey as $rows) {
            $result = "";
            $keyRecordset = $rows["RECORD_SET"];
            foreach ($formatString[$keyRecordset] as $keyIdx) {
                $result .= $rows[$keyIdx] . " ";
            }
            //Tooltip Code = <span ".Utils_TooltipCommon::open_tag_attrs($tooltip , false)."><img border='0' src='data/Base_Theme/templates/default/Utils/GenericBrowser/info.png'></span>
            $tooltip = ucwords($result);
            print "<tr style='background:#FFFFD5;'> \n\t\t\t\t\t\t<td class='Utils_GenericBrowser__td' style='width:80%;height:20px'></td>\n\t\t\t\t\t\t<td class='Utils_GenericBrowser__td' style='width:80%;height:20px'> <a onclick=\"_chj('__jump_to_RB_table=" . $keyRecordset . "&amp;__jump_to_RB_record=" . $rows["id"] . "&amp;__jump_to_RB_action=view', '', '');\" href=\"javascript: void(0)\">" . ucwords($result) . "</a></td>\n\t\t\t\t\t\t<td class='Utils_GenericBrowser__td' style='width:10%'>" . Utils_RecordBrowserCommon::get_caption($keyRecordset) . "</td></tr>";
        }
    }
}
$content = ob_get_contents();
ob_end_clean();
require_once 'libs/minify/HTTP/Encoder.php';
$he = new HTTP_Encoder(array('content' => $content));
if (MINIFY_ENCODE) {
    $he->encode();
}
$he->sendAll();
exit;
Esempio n. 8
0
 public function get_recordsets()
 {
     $options = array();
     $rb_tabs = DB::GetAssoc('SELECT tab, tpl FROM recordbrowser_table_properties');
     if ($rb_tabs) {
         foreach ($rb_tabs as $key => $value) {
             $options[$key] = Utils_RecordBrowserCommon::get_caption($key);
         }
     }
     return $options;
 }