示例#1
0
 public static function QFfield_select(&$form, $field, $label, $mode, $default, $desc, $rb_obj)
 {
     if (self::QFfield_static_display($form, $field, $label, $mode, $default, $desc, $rb_obj)) {
         return;
     }
     $record = $rb_obj->record;
     $comp = array();
     $param = explode(';', $desc['param']);
     $crits_callback = isset($param[1]) ? $param[1] : null;
     $multi_adv_params_callback = isset($param[2]) ? explode('::', $param[2]) : null;
     $multi_adv_params = array();
     if (is_callable($multi_adv_params_callback)) {
         $multi_adv_params = call_user_func($multi_adv_params_callback, $record);
     }
     // check multi_adv_params structure and fill empty values
     if (!is_array($multi_adv_params)) {
         $multi_adv_params = array();
     }
     if (!isset($multi_adv_params['order'])) {
         $multi_adv_params['order'] = array();
     }
     if (!isset($multi_adv_params['cols'])) {
         $multi_adv_params['cols'] = array();
     }
     if (!isset($multi_adv_params['format_callback'])) {
         $multi_adv_params['format_callback'] = array();
     }
     $reference = explode('::', $param[0]);
     $tab = $reference[0];
     $columns = isset($reference[1]) ? $reference[1] : null;
     if (!isset($columns)) {
         trigger_error("Columns not set for field: {$field}");
     }
     if ($tab == '__COMMON__') {
         $order = isset($reference[2]) ? $reference[2] : 'value';
         $data = Utils_CommonDataCommon::get_translated_tree($columns, $order == 'key');
         if (!is_array($data)) {
             $data = array();
         }
         $comp = $comp + $data;
         $rec_count = 0;
         $label = Utils_RecordBrowserCommon::get_field_tooltip($label, 'commondata', $columns);
     } else {
         if (isset($crits_callback)) {
             $crit_callback = explode('::', $crits_callback);
             if (is_callable($crit_callback)) {
                 $crits = call_user_func($crit_callback, false, $record);
                 $adv_crits = call_user_func($crit_callback, true, $record);
             } else {
                 $crits = $adv_crits = array();
             }
             if ($adv_crits === $crits) {
                 $adv_crits = null;
             }
             if ($adv_crits !== null) {
                 $crits = $adv_crits;
             }
         } else {
             $crits = array();
         }
         if ($tab == '__RECORDSETS__') {
             $tabs = DB::GetCol('SELECT tab FROM recordbrowser_table_properties');
         } else {
             $tabs = explode(',', $tab);
         }
         $single_tab = count($tabs) == 1;
         if (!$single_tab && empty($crits)) {
             foreach ($tabs as $tab) {
                 $crits[$tab] = array();
             }
         }
         // get related records with proper columns
         $col_id = array();
         if ($single_tab) {
             $columns = array_filter(explode('|', $columns));
             foreach ($columns as $c) {
                 $col_id[] = self::get_field_id($c);
             }
         }
         $rec_count = 0;
         foreach ($tabs as $t) {
             if (!empty($crits) && !$single_tab && !isset($crits[$t])) {
                 continue;
             }
             $rec_count += Utils_RecordBrowserCommon::get_records_count($t, $single_tab ? $crits : $crits[$t], null);
         }
         if ($rec_count <= Utils_RecordBrowserCommon::$options_limit) {
             $records = array();
             foreach ($tabs as $t) {
                 if (!empty($crits) && !$single_tab && !isset($crits[$t])) {
                     continue;
                 }
                 $access = self::get_access($t, 'selection', null, true);
                 if ($access === false) {
                     continue;
                 }
                 if ($access !== true && is_array($access)) {
                     if ($single_tab) {
                         $crits = self::merge_crits($crits, $access);
                     } elseif (isset($crits[$t]) && is_array($crits[$t]) && $crits[$t]) {
                         $crits[$t] = self::merge_crits($crits[$t], $access);
                     } else {
                         $crits[$t] = $access;
                     }
                 }
                 $records_tmp = Utils_RecordBrowserCommon::get_records($t, $single_tab ? $crits : $crits[$t], array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array());
                 foreach ($records_tmp as $key => $rec) {
                     if (!self::get_access($t, 'view', $rec)) {
                         continue;
                     }
                     $records[($single_tab ? '' : $t . '/') . $key] = $rec;
                 }
             }
         } else {
             $records = array();
         }
         // set current record field value to array
         if (isset($record[$field])) {
             if (!is_array($record[$field])) {
                 if ($record[$field] != '') {
                     $record[$field] = array($record[$field] => $record[$field]);
                 } else {
                     $record[$field] = array();
                 }
             }
         }
         if ($default) {
             if (!is_array($default)) {
                 $record[$field][$default] = $default;
             } else {
                 foreach ($default as $v) {
                     $record[$field][$v] = $v;
                 }
             }
         }
         $ext_rec = array();
         $columns_qty = count($col_id);
         if (isset($record[$field])) {
             $ext_rec = array_flip($record[$field]);
             foreach ($ext_rec as $k => $v) {
                 $kk = explode('/', $k, 2);
                 if (count($kk) == 1) {
                     if ($single_tab && is_numeric($kk[0])) {
                         $t = $tab;
                         $record_id = $kk[0];
                     } else {
                         continue;
                     }
                 } else {
                     $t = $kk[0];
                     $record_id = $kk[1];
                     if (!self::check_table_name($t, false, false) || !is_numeric($record_id)) {
                         continue;
                     }
                 }
                 $c = Utils_RecordBrowserCommon::get_record($t, $record_id);
                 if (!empty($multi_adv_params['format_callback'])) {
                     $n = call_user_func($multi_adv_params['format_callback'], $c);
                 } else {
                     if ($columns_qty == 0) {
                         $n = self::create_default_linked_label($t, $record_id, true);
                     } elseif ($columns_qty == 1) {
                         $n = self::get_val($t, $col_id[0], $c, true);
                     } else {
                         $n = array();
                         foreach ($col_id as $cid) {
                             $n[] = self::get_val($t, $cid, $c, true);
                         }
                         $n = implode(' ', $n);
                     }
                 }
                 $comp[($single_tab ? '' : $t . '/') . $record_id] = $n;
             }
         }
         //            if (!empty($multi_adv_params['order']))
         //                natcasesort($comp);
         foreach ($records as $k => $v) {
             if (!empty($multi_adv_params['format_callback'])) {
                 $n = call_user_func($multi_adv_params['format_callback'], $v);
             } else {
                 if ($single_tab && is_numeric($k)) {
                     $t = $tab;
                     $record_id = $k;
                 } else {
                     $kk = explode('/', $k, 2);
                     $t = $kk[0];
                     $record_id = $kk[1];
                 }
                 if ($columns_qty == 0) {
                     $n = self::create_default_linked_label($t, $record_id, true);
                 } elseif ($columns_qty == 1) {
                     $n = self::get_val($t, $col_id[0], $v, true);
                 } else {
                     $n = array();
                     foreach ($col_id as $cid) {
                         $n[] = self::get_val($t, $cid, $v, true);
                     }
                     $n = implode(' ', $n);
                 }
             }
             $comp[$k] = $n;
             unset($ext_rec[$v['id']]);
             unset($ext_rec[$k]);
         }
         if (empty($multi_adv_params['order'])) {
             natcasesort($comp);
         }
         if ($single_tab) {
             $label = Utils_RecordBrowserCommon::get_field_tooltip($label, $desc['type'], reset($tabs), $crits);
         }
     }
     if ($rec_count > Utils_RecordBrowserCommon::$options_limit) {
         $f_callback = $multi_adv_params['format_callback'];
         if (empty($f_callback)) {
             $f_callback = array('Utils_RecordBrowserCommon', 'autoselect_label');
         }
         if ($desc['type'] == 'multiselect') {
             $el = $form->addElement('automulti', $field, $label, array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param']), $f_callback);
             if ($single_tab) {
                 ${'rp_' . $field} = $rb_obj->init_module(Utils_RecordBrowser_RecordPicker::module_name(), array());
                 $filters_defaults = isset($multi_adv_params['filters_defaults']) ? $multi_adv_params['filters_defaults'] : array();
                 $rb_obj->display_module(${'rp_' . $field}, array($tab, $field, $multi_adv_params['format_callback'], $crits, array(), array(), array(), $filters_defaults));
                 $el->set_search_button('<a ' . ${'rp_' . $field}->create_open_href() . ' ' . Utils_TooltipCommon::open_tag_attrs(__('Advanced Selection')) . ' href="javascript:void(0);"><img border="0" src="' . Base_ThemeCommon::get_template_file('Utils_RecordBrowser', 'icon_zoom.png') . '"></a>');
             }
         } else {
             $form->addElement('autoselect', $field, $label, $comp, array(array('Utils_RecordBrowserCommon', 'automulti_suggestbox'), array($rb_obj->tab, $crits, $f_callback, $desc['param'])), $f_callback);
         }
     } else {
         if ($desc['type'] === 'select') {
             $comp = array('' => '---') + $comp;
         }
         $form->addElement($desc['type'], $field, $label, $comp, array('id' => $field));
     }
     if ($mode !== 'add') {
         $form->setDefaults(array($field => $default));
     }
 }
示例#2
0
    public function mini_view($cols, $crits, $order, $info=null, $limit=null, $conf = array('actions_edit'=>true, 'actions_info'=>true), & $opts = array()){
        unset($_SESSION['client']['recordbrowser']['admin_access']);
        $this->init();
        $gb = $this->init_module('Utils/GenericBrowser',$this->tab,$this->tab);
        $field_hash = array();
        foreach($this->table_rows as $field => $args)
            $field_hash[$args['id']] = $field;
        $header = array();
        $callbacks = array();
        foreach($cols as $k=>$v) {
            if (isset($v['callback'])) $callbacks[] = $v['callback'];
            else $callbacks[] = null;
            if (is_array($v)) {
                $arr = array('name'=>_V($field_hash[$v['field']])); // TRSL
				if (isset($v['width'])) $arr['width'] = $v['width'];
                $cols[$k] = $v['field'];
            } else {
                $arr = array('name'=>_V($field_hash[$v])); // TRSL
                $cols[$k] = $v;
            }
            if (isset($v['label'])) $arr['name'] = $v['label'];
            $arr['wrapmode'] = 'nowrap';
            $header[] = $arr;
        }
        $gb->set_table_columns($header);
        $gb->set_fixed_columns_class($this->fixed_columns_class);

        $clean_order = array();
        foreach($order as $k=>$v) {
    	    if ($k==':Visited_on') $field_hash[$k] = $k;
    	    if ($k==':Fav') $field_hash[$k] = $k;
    	    if ($k==':Edited_on') $field_hash[$k] = $k;
            if ($k==':id') $field_hash[$k] = $k;
            $clean_order[] = array('column'=>$field_hash[$k],'order'=>$field_hash[$k],'direction'=>$v);
        }
        if ($limit!=null && !isset($conf['force_limit'])) {
            $limit = array('offset'=>0, 'numrows'=>$limit);
            $records_qty = Utils_RecordBrowserCommon::get_records_count($this->tab, $crits);
            if ($records_qty>$limit['numrows']) {
                if ($this->get_module_variable('no_limit_in_mini_view',false)) {
                    $opts['actions'][] = '<a '.Utils_TooltipCommon::open_tag_attrs(__('Display first %d records', array($limit['numrows']))).' '.$this->create_callback_href(array($this, 'set_no_limit_in_mini_view'), array(false)).'><img src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','show_some.png').'" border="0"></a>';
                    $limit = null;
                } else {
                    print(__('Displaying %s of %s records', array($limit['numrows'], $records_qty)));
                    $opts['actions'][] = '<a '.Utils_TooltipCommon::open_tag_attrs(__('Display all records')).' '.$this->create_callback_href(array($this, 'set_no_limit_in_mini_view'), array(true)).'><img src="'.Base_ThemeCommon::get_template_file('Utils_RecordBrowser','show_all.png').'" border="0"></a>';
                }
            }
        }
        $records = Utils_RecordBrowserCommon::get_records($this->tab, $crits, array(), $clean_order, $limit);
        foreach($records as $v) {
            $gb_row = $gb->get_new_row();
            $arr = array();
            foreach($cols as $k=>$w) {
                if (!isset($callbacks[$k])) $s = $this->get_val($field_hash[$w], $v, false, $this->table_rows[$field_hash[$w]]);
                else $s = call_user_func($callbacks[$k], $v);
                $arr[] = $s;
            }
            $gb_row->add_data_array($arr);
            if (is_callable($info)) {
                $additional_info = call_user_func($info, $v);
            } else $additional_info = '';
            if (!is_array($additional_info) && isset($additional_info)) $additional_info = array('notes'=>$additional_info);
            if (isset($additional_info['notes'])) $additional_info['notes'] = $additional_info['notes'].'<hr />';
            if (isset($additional_info['row_attrs'])) $gb_row->set_attrs($additional_info['row_attrs']);
            if (isset($conf['actions_info']) && $conf['actions_info']) $gb_row->add_info($additional_info['notes'].Utils_RecordBrowserCommon::get_html_record_info($this->tab, $v['id']));
            if (isset($conf['actions_view']) && $conf['actions_view']) $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_entry', 'view',$v['id'])),'View');
            if (isset($conf['actions_edit']) && $conf['actions_edit']) if ($this->get_access('edit',$v)) $gb_row->add_action($this->create_callback_href(array($this,'navigate'),array('view_entry', 'edit',$v['id'])),'Edit');
            if (isset($conf['actions_delete']) && $conf['actions_delete']) if ($this->get_access('delete',$v)) $gb_row->add_action($this->create_confirm_callback_href(__('Are you sure you want to delete this record?'),array($this,'delete_record'),array($v['id'], false)),'Delete');
            if (isset($conf['actions_history']) && $conf['actions_history']) {
                $r_info = Utils_RecordBrowserCommon::get_record_info($this->tab, $v['id']);
                if ($r_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', $v['id'])),'View edit history',null,'history');
            }
            $this->call_additional_actions_methods($v, $gb_row);
        }
        $this->display_module($gb);
    }
示例#3
0
文件: print.php 项目: 62BRAINS/EPESI
$rb->construct($tab);
$rb->set_inline_display();
$rb->set_header_properties($more_table_properties);
$rb->disable_pagination();

ob_start();
$rb->show_data($crits, $cols, $order, $admin, false, true, $limit);
$html = ob_get_clean();

$limit_info = '';
if (is_array($limit)) {
    $offset = $limit['offset'];
    $per_page = $limit['numrows'];
    $start = $offset + 1;
    $end = $offset + $per_page;
    $total = Utils_RecordBrowserCommon::get_records_count($tab, $crits, $admin, $order);
    if ($end > $total)
        $end = $total;
    $limit_info = __('Records %s to %s of %s', array($start, $end, $total)) . "\n";
}

$tcpdf = Libs_TCPDFCommon::new_pdf();

$filters = implode(' ',Utils_RecordBrowserCommon::crits_to_words($tab, $crits));
$filters = strip_tags($filters);
$filters = str_replace('&nbsp;', ' ', $filters);
$filters = str_replace(' and ', "\n", $filters);
$filters = str_replace(' is equal to', ':', $filters);

$subject = $limit_info . $filters;
Libs_TCPDFCommon::prepare_header($tcpdf, _V(DB::GetOne('SELECT caption FROM recordbrowser_table_properties WHERE tab=%s', array($tab))), $subject, false);
示例#4
0
 private function archive($uids, $verbose = true)
 {
     global $E_SESSION;
     $rcmail = rcmail::get_instance();
     $path = getcwd();
     chdir(str_replace(array('/modules/CRM/Roundcube/RC', '\\modules\\CRM\\Roundcube\\RC'), '', $path));
     $msgs = array();
     if (!is_array($uids)) {
         $uids = $uids->get();
     }
     foreach ($uids as $uid) {
         $msg = new rcube_message($uid);
         if ($msg === null || empty($msg->headers)) {
             if ($verbose) {
                 $rcmail->output->command('display_message', 'messageopenerror', 'error');
             }
             return false;
         } else {
             $msgs[$uid] = $msg;
         }
     }
     $map = array();
     foreach ($msgs as $k => $msg) {
         $sends = $rcmail->storage->decode_address_list($msg->headers->to);
         $map[$k] = array();
         foreach ($sends as $send) {
             $addr = $send['mailto'];
             $ret = $this->look_contact($addr);
             $map[$k] = array_merge($map[$k], $ret);
         }
         $addr = $rcmail->storage->decode_address_list($msg->headers->from);
         if ($addr) {
             $addr = array_shift($addr);
         }
         if (!isset($addr['mailto']) || !$addr['mailto']) {
             $map[$k] = false;
             continue;
         }
         $ret = $this->look_contact($addr['mailto']);
         $map[$k] = array_merge($map[$k], $ret);
     }
     if (!isset($_SESSION['force_archive'])) {
         $_SESSION['force_archive'] = array();
     }
     foreach ($map as $k => $ret) {
         if (!$ret && !isset($_SESSION['force_archive'][$k]) && $verbose) {
             $_SESSION['force_archive'][$k] = 1;
             $rcmail->output->command('display_message', $this->gettext('contactnotfound'), 'error');
             return false;
         }
     }
     $attachments_dir = DATA_DIR . '/CRM_Roundcube/attachments/';
     $epesi_mails = array();
     if (!file_exists($attachments_dir)) {
         mkdir($attachments_dir);
     }
     foreach ($msgs as $k => $msg) {
         $contacts = $map[$k];
         $mime_map = array();
         foreach ($msg->mime_parts as $mid => $m) {
             $mime_map[$m->mime_id] = md5($k . microtime(true) . $mid);
         }
         if ($msg->has_html_part()) {
             //            $body = $msg->first_html_part();
             foreach ($msg->mime_parts as $mime_id => $part) {
                 $mimetype = strtolower($part->ctype_primary . '/' . $part->ctype_secondary);
                 if ($mimetype == 'text/html') {
                     $body = $rcmail->storage->get_message_part($msg->uid, $mime_id, $part);
                     if (isset($part->replaces)) {
                         $cid_map = $part->replaces;
                     } else {
                         $cid_map = array();
                     }
                     break;
                 }
             }
             foreach ($cid_map as $k => &$v) {
                 if (preg_match('/_part=(.*?)&/', $v, $matches)) {
                     $mid = $matches[1];
                     if (isset($mime_map[$mid])) {
                         $v = 'get.php?' . http_build_query(array('mail_id' => '__MAIL_ID__', 'mime_id' => $mime_map[$mid]));
                     }
                 } else {
                     unset($cid_map[$k]);
                 }
             }
             $body = rcmail_wash_html($body, array('safe' => true, 'inline_html' => true), $cid_map);
         } else {
             $body = '<pre>' . $msg->first_text_part() . '</pre>';
         }
         $date = rcube_imap_generic::strToTime($msg->get_header('DATE'));
         $headers = array();
         foreach ($msg->headers as $k => $v) {
             if (is_string($v) && $k != 'from' && $k != 'to' && $k != 'body_structure') {
                 $headers[] = $k . ': ' . rcube_mime::decode_mime_string((string) $v);
             }
         }
         $message_id = str_replace(array('<', '>'), '', $msg->get_header('MESSAGE-ID'));
         if (Utils_RecordBrowserCommon::get_records_count('rc_mails', array('message_id' => $message_id)) > 0) {
             $rcmail->output->command('display_message', $this->gettext('archived_duplicate'), 'warning');
             return false;
         }
         $employee = DB::GetOne('SELECT id FROM contact_data_1 WHERE active=1 AND f_login=%d', array($E_SESSION['user']));
         $data = array('message_id' => $message_id, 'references' => $msg->get_header('REFERENCES'), 'contacts' => $contacts, 'date' => $date, 'subject' => substr($msg->subject, 0, 256), 'body' => $body, 'headers_data' => implode("\n", $headers), 'from' => $rcmail->storage->decode_header($msg->headers->from), 'to' => $rcmail->storage->decode_header($msg->headers->to), 'employee' => $employee);
         $id = Utils_RecordBrowserCommon::new_record('rc_mails', $data);
         $epesi_mails[] = $id;
         foreach ($contacts as $c) {
             list($rs, $con_id) = explode(':', $c);
             if ($rs == 'P') {
                 Utils_WatchdogCommon::new_event('contact', $con_id, 'N_New mail');
             } else {
                 Utils_WatchdogCommon::new_event('company', $con_id, 'N_New mail');
             }
         }
         Utils_WatchdogCommon::new_event('contact', $employee, 'N_New mail');
         /*DB::Execute('INSERT INTO rc_mails_data_1(created_on,created_by,f_contacts,f_date,f_employee,f_subject,f_body,f_headers_data,f_direction) VALUES(%T,%d,%s,%T,%d,%s,%s,%s,%b)',array(
                       time(),$E_SESSION['user'],$contacts,$date,$employee,substr($msg->subject,0,256),$body,implode("\n",$headers),$sent_mbox));
           $id = DB::Insert_ID('rc_mails_data_1','id');*/
         foreach ($msg->mime_parts as $mid => $m) {
             if (!$m->disposition) {
                 continue;
             }
             if (isset($cid_map['cid:' . $m->content_id])) {
                 $attachment = 0;
             } else {
                 $attachment = 1;
             }
             DB::Execute('INSERT INTO rc_mails_attachments(mail_id,type,name,mime_id,attachment) VALUES(%d,%s,%s,%s,%b)', array($id, $m->mimetype, $m->filename, $mime_map[$m->mime_id], $attachment));
             if (!file_exists($attachments_dir . $id)) {
                 mkdir($attachments_dir . $id);
             }
             $fp = fopen($attachments_dir . $id . '/' . $mime_map[$m->mime_id], 'w');
             $msg->get_part_content($m->mime_id, $fp);
             fclose($fp);
         }
     }
     //$rcmail->output->command('delete_messages');
     $E_SESSION['rc_mails_cp'] = $epesi_mails;
     chdir($path);
     return true;
 }
示例#5
0
 /**
  * Get records count from recordset.
  * @param array $crits
  * @param bool $admin Admin mode - count deleted records also
  * @param array $order
  * @return int records count
  */
 public function get_records_count($crits = null, $admin = false, $order = array())
 {
     return Utils_RecordBrowserCommon::get_records_count($this->tab, $crits, $admin, $order);
 }
示例#6
0
 public static function QFfield_company(&$form, $field, $label, $mode, $default, $desc, $rb, $display_callbacks)
 {
     static $showed_create_company = false;
     if (($mode == 'add' || $mode == 'edit') && is_object($rb) && $rb->tab === 'contact' && !$showed_create_company) {
         $showed_create_company = true;
         if (self::$paste_or_new == 'new') {
             $access = Utils_RecordBrowserCommon::get_access('contact', $mode, Utils_RecordBrowser::$last_record);
             $c_access = Utils_RecordBrowserCommon::get_access('company', 'add');
             if ($c_access && $access['company_name']) {
                 $form->addElement('checkbox', 'create_company', __('Create new company'), null, 'onClick="document.getElementById(\'company_name\').disabled = this.checked;document.getElementsByName(\'create_company_name\')[0].disabled=!this.checked;" ' . Utils_TooltipCommon::open_tag_attrs(__('Create a new company for this contact')));
                 $form->addElement('text', 'create_company_name', __('New company name'), array('disabled' => 1));
                 $form->addFormRule(array('CRM_ContactsCommon', 'check_new_company_name'));
                 if (isset($rb) && isset($rb->record['last_name']) && isset($rb->record['first_name'])) {
                     $form->setDefaults(array('create_company_name' => $rb->record['last_name'] . ' ' . $rb->record['first_name']));
                 }
                 eval_js('Event.observe(\'last_name\',\'change\', update_create_company_name_field);' . 'Event.observe(\'first_name\',\'change\', update_create_company_name_field);' . 'function update_create_company_name_field() {' . 'document.forms[\'' . $form->getAttribute('name') . '\'].create_company_name.value = document.forms[\'' . $form->getAttribute('name') . '\'].last_name.value+" "+document.forms[\'' . $form->getAttribute('name') . '\'].first_name.value;' . '}');
                 eval_js('$("company_name").disabled = document.getElementsByName("create_company")[0].checked;document.getElementsByName("create_company_name")[0].disabled=!document.getElementsByName("create_company")[0].checked;');
             }
         } else {
             $comp = self::get_company(self::$paste_or_new);
             foreach ($comp as &$cf) {
                 if (is_string($cf)) {
                     $cf = escapeJS($cf);
                 }
             }
             $paste_company_info = 'document.getElementsByName(\'address_1\')[0].value=\'' . $comp['address_1'] . '\';' . 'document.getElementsByName(\'address_2\')[0].value=\'' . $comp['address_2'] . '\';' . 'document.getElementsByName(\'work_phone\')[0].value=\'' . $comp['phone'] . '\';' . 'document.getElementsByName(\'fax\')[0].value=\'' . $comp['fax'] . '\';' . 'document.getElementsByName(\'city\')[0].value=\'' . $comp['city'] . '\';' . 'document.getElementsByName(\'postal_code\')[0].value=\'' . $comp['postal_code'] . '\';' . 'var country = $(\'country\');' . 'var k = 0; while (k < country.options.length) if (country.options[k].value==\'' . $comp['country'] . '\') break; else k++;' . 'country.selectedIndex = k;' . 'country.fire(\'e_u_cd:load\');' . 'setTimeout(\'' . 'var zone = $(\\\'zone\\\'); k = 0; while (k < zone.options.length) if (zone.options[k].value==\\\'' . $comp['zone'] . '\\\') break; else k++;' . 'zone.selectedIndex = k;' . '\',900);' . 'document.getElementsByName(\'web_address\')[0].value=\'' . $comp['web_address'] . '\';';
             Base_ActionBarCommon::add('add', __('Paste Company Info'), 'href="javascript:void(0);" onclick="' . $paste_company_info . '"');
         }
     }
     $comp = array();
     $param = explode(';', $desc['param']);
     if ($mode == 'add' || $mode == 'edit') {
         if (isset($param[1]) && $param[1] != '::') {
             $crits = call_user_func(explode('::', $param[1]), false, isset($rb->record) ? $rb->record : null);
         } else {
             $crits = array();
         }
         if (isset($crits['_no_company_option'])) {
             $no_company_option = true;
             unset($crits['_no_company_option']);
         } else {
             $no_company_option = false;
         }
         $count = Utils_RecordBrowserCommon::get_records_count('company', $crits);
         if ($count > Utils_RecordBrowserCommon::$options_limit) {
             $companies = array();
         } else {
             $companies = self::get_companies($crits);
             if (!is_array($default)) {
                 if ($default != '') {
                     $default = array($default);
                 } else {
                     $default = array();
                 }
             }
             $ext_rec = array_flip($default);
             foreach ($companies as $v) {
                 $comp[$v['id']] = $v['company_name'];
                 unset($ext_rec[$v['id']]);
             }
             foreach ($ext_rec as $k => $v) {
                 $c = CRM_ContactsCommon::get_company($k);
                 $comp[$k] = $c['company_name'];
             }
             natcasesort($comp);
             $key = '';
             if ($no_company_option) {
                 $comp = array('' => '[' . __('w/o company') . ']') + $comp;
                 $key = -1;
             }
             if ($desc['type'] !== 'multiselect') {
                 $comp = array($key => '---') + $comp;
             }
         }
         $label = Utils_RecordBrowserCommon::get_field_tooltip($label, $desc['type'], 'company', $crits);
         if ($count > Utils_RecordBrowserCommon::$options_limit) {
             $callback = array('CRM_ContactsCommon', 'display_company');
             if ($desc['type'] !== 'multiselect') {
                 $form->addElement('autoselect', $field, $label, array(), array(array('CRM_ContactsCommon', 'autoselect_company_suggestbox'), array($crits, $callback)), $callback, array('id' => $field));
             } else {
                 $form->addElement('automulti', $field, $label, array('CRM_ContactsCommon', 'autoselect_company_suggestbox'), array($crits, $callback), $callback);
             }
             //                  $form->addElement($desc['type'], $field, $label, $comp, array('id'=>$field));
         } else {
             $form->addElement($desc['type'], $field, $label, $comp, array('id' => $field));
         }
         if ($mode !== 'add') {
             $form->setDefaults(array($field => $default));
         }
     } else {
         /*$def = '';
           $first = true;
           if (is_numeric($default) || is_array($default)) {
               if (!is_array($default)) $default = array($default);
               foreach($default as $k=>$v){
                   if ($v=='') break;
                   if ($first) $first = false;
                   else $def .= '<br>';
                   $def .= Utils_RecordBrowserCommon::no_wrap(Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $v));
               }
           }
           if (!$def)  $def = '---';
           $form->setDefaults(array($field=>$def));*/
         if (isset($display_callbacks[$desc['name']])) {
             $callback = $display_callbacks[$desc['name']];
         } else {
             $callback = array('CRM_ContactsCommon', 'display_company');
         }
         //            trigger_error(print_r($rb->record,true),E_USER_ERROR);
         $form->addElement('static', $field, $label, call_user_func($callback, array('company' => $default), false, array('id' => 'company')));
     }
 }
示例#7
0
	public static function count($group=null,$group_starts_with=false) {
		return Utils_RecordBrowserCommon::get_records_count('utils_attachment',array('id'=>self::get_where($group,$group_starts_with)));
	}
示例#8
0
 public static function attachment_getters()
 {
     $ret = Utils_RecordBrowserCommon::get_records_count('rc_accounts', array('epesi_user' => Acl::get_user()));
     if ($ret) {
         return array(_M('Mail') => array('func' => 'mail_file', 'icon' => Base_ThemeCommon::get_template_file(CRM_Roundcube::module_name(), 'icon.png')));
     }
 }
示例#9
0
 public static function get_slots($tab, $tray_settings)
 {
     if (!isset($tray_settings['__title__']) || !isset($tray_settings['__slots__'])) {
         return array();
     }
     $ret = array();
     foreach ($tray_settings['__slots__'] as $slot) {
         if (!isset($slot['__name__'])) {
             continue;
         }
         $crits = self::get_slot_crits($slot, $tray_settings);
         $slot_id = Utils_RecordBrowserCommon::get_field_id($slot['__name__']);
         $ret[$slot_id] = $slot + array('__id__' => $slot_id, '__count__' => Utils_RecordBrowserCommon::get_records_count($tab, $crits), '__crits__' => $crits);
     }
     return $ret;
 }
示例#10
0
文件: mobile.php 项目: cretzu89/EPESI
        $open = self::record_link_open_tag($table, $v['id'], false);
        $close = self::record_link_close_tag();
        $row = $open . $row_sort . $close . $open . $row_info . $close;
        print '<li class="arrow">' . $row . '</li>';
    } else {
        $data_out[] = $row;
    }
}
//display table
if (IPHONE) {
    print '</ul>';
} else {
    Utils_GenericBrowserCommon::mobile_table($cols_out, $data_out, false);
}
//display paging
$cur_num_rows = Utils_RecordBrowserCommon::get_records_count($table, $crits);
if ($offset > 0) {
    print '<a ' . (IPHONE ? 'class="button red" ' : '') . 'href="mobile.php?' . http_build_query(array_merge($_GET, array('rb_offset' => $offset - 1))) . '">' . __('Prev') . '</a>';
}
if ($offset < $cur_num_rows / $num_rows - 1) {
    print ' <a ' . (IPHONE ? 'class="button green" ' : '') . 'href="mobile.php?' . http_build_query(array_merge($_GET, array('rb_offset' => $offset + 1))) . '">' . __('Next') . '</a>';
}
if ($cur_num_rows > $num_rows) {
    $qf = new HTML_QuickForm('rb_page', 'get', 'mobile.php?' . http_build_query($_GET));
    $qf->addElement('text', 'rb_offset', __('Page(0-%d)', array($cur_num_rows / $num_rows)));
    $qf->addElement('submit', 'submit_button', __('OK'), IPHONE ? 'class="button white"' : '');
    $qf->addRule('rb_offset', __('Field required'), 'required');
    $qf->addRule('rb_offset', __('Invalid page number'), 'numeric');
    $renderer =& $qf->defaultRenderer();
    /*	if(IPHONE) {
    		$renderer->setFormTemplate("<form{attributes}>{hidden}<ul>{content}</ul></form>");