public static function get_val($tab, $field, $record, $links_not_recommended = false, $args = null) { static $recurrence_call_stack = array(); self::init($tab); $commondata_sep = '/'; if (!isset(self::$table_rows[$field])) { if (!isset(self::$hash[$field])) { trigger_error('Unknown field "' . $field . '" for recordset "' . $tab . '"', E_USER_ERROR); } $field = self::$hash[$field]; } if ($args === null) { $args = self::$table_rows[$field]; } if (!array_key_exists('id', $record)) { $record['id'] = null; } if (!array_key_exists($args['id'], $record)) { trigger_error($args['id'] . ' - unknown field for record ' . serialize($record), E_USER_ERROR); } $val = $record[$args['id']]; $function_call_id = implode('|', array($tab, $field, serialize($val))); if (isset($recurrence_call_stack[$function_call_id])) { return '!! ' . __('recurrence issue') . ' !!'; } else { $recurrence_call_stack[$function_call_id] = true; } self::display_callback_cache($tab); if (isset(self::$display_callback_table[$tab][$field])) { $ret = self::call_display_callback(self::$display_callback_table[$tab][$field], $record, $links_not_recommended, self::$table_rows[$field], $tab); } else { $ret = $val; if ($args['type'] == 'select' || $args['type'] == 'multiselect') { if (is_array($val) && empty($val) || !is_array($val) && $val == '') { $ret = '---'; unset($recurrence_call_stack[$function_call_id]); return $ret; } $param = explode(';', $args['param']); $pp = explode('::', $param[0]); $tab = $pp[0]; if (isset($pp[1])) { $col = $pp[1]; } else { $col = null; } //return;//trigger_error("\"param\" attribute of field \"$field\" is not valid. Please set <recordset>::<field>"); if (!$col && $tab == '__COMMON__') { unset($recurrence_call_stack[$function_call_id]); return; } if (!is_array($val)) { $val = array($val); } // if ($tab=='__COMMON__') $data = Utils_CommonDataCommon::get_translated_array($col, true); if ($tab == '__RECORDSETS__') { $single_tab = false; } else { $tabs = explode(',', $tab); $single_tab = count($tabs) == 1; } $ret = ''; $first = true; foreach ($val as $k => $v) { // if ($tab=='__COMMON__' && !isset($data[$v])) continue; if ($tab == '__COMMON__') { $path = explode('/', $v); $tooltip = ''; $res = ''; if (count($path) > 1) { $res .= Utils_CommonDataCommon::get_value($col . '/' . $path[0], true); if (count($path) > 2) { $res .= $commondata_sep . '...'; $tooltip = ''; $full_path = $col; foreach ($path as $w) { $full_path .= '/' . $w; $tooltip .= ($tooltip ? $commondata_sep : '') . Utils_CommonDataCommon::get_value($full_path, true); } } $res .= $commondata_sep; } $val = Utils_CommonDataCommon::get_value($col . '/' . $v, true); if (!$val) { continue; } $res .= $val; if ($first) { $first = false; } else { $ret .= '<br>'; } $res = self::no_wrap($res); if ($tooltip) { $res = '<span ' . Utils_TooltipCommon::open_tag_attrs($tooltip, false) . '>' . $res . '</span>'; } $ret .= $res; } else { if (!$single_tab) { list($tab, $v) = explode('/', $v, 2); } if ($first) { $first = false; } else { $ret .= '<br>'; } if ($col) { $columns = explode('|', $col); $ret .= Utils_RecordBrowserCommon::create_linked_label($tab, $columns, $v, $links_not_recommended); } else { $ret .= Utils_RecordBrowserCommon::create_default_linked_label($tab, $v, $links_not_recommended); } } } if ($ret == '') { $ret = '---'; } } elseif ($args['type'] == 'commondata') { if (!isset($val) || $val === '') { $ret = ''; } else { $arr = explode('::', $args['param']['array_id']); $path = array_shift($arr); foreach ($arr as $v) { $path .= '/' . $record[self::get_field_id($v)]; } $path .= '/' . $record[$args['id']]; $ret = Utils_CommonDataCommon::get_value($path, true); } /* } elseif ($args['type']=='record') { if (!isset($val) || $val==='') { $ret = ''; } else { @list($rs,$rid) = explode('#',$record[$args['id']],2); if(!$rid) $ret = ''; else { $ret = self::create_default_linked_label($rs,$rid,$links_not_recommended); } }*/ } elseif ($args['type'] == 'autonumber') { if (!$links_not_recommended && isset($record['id']) && $record['id']) { $ret = self::record_link_open_tag_r($tab, $record) . $val . self::record_link_close_tag(); } } elseif ($args['type'] == 'currency') { $val = Utils_CurrencyFieldCommon::get_values($val); $ret = Utils_CurrencyFieldCommon::format($val[0], $val[1]); } elseif ($args['type'] == 'checkbox') { $ret = $ret ? __('Yes') : __('No'); } elseif ($args['type'] == 'date') { if ($val != '') { $ret = Base_RegionalSettingsCommon::time2reg($val, false, true, false); } } elseif ($args['type'] == 'timestamp') { if ($val != '') { $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds'); } } elseif ($args['type'] == 'time') { if ($val != '') { $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds', false); } } elseif ($args['type'] == 'long text') { $ret = htmlspecialchars($val); $ret = str_replace("\n", '<br>', $ret); $ret = Utils_BBCodeCommon::parse($ret); } } unset($recurrence_call_stack[$function_call_id]); return $ret; }
/** * Create linked label with text values from fields. * @param string|array $field Fields' ids list. In array or string separated * by '|'. e.g. array('first_name', 'last_name') or 'first_name|last_name'. * @param int $id Record's ID * @param bool $nolink Do not create link * @return string html with link */ public function create_linked_label($field, $id, $nolink = false) { return Utils_RecordBrowserCommon::create_linked_label($this->tab, $field, $id, $nolink); }
public static function display_company($record, $nolink = false, $desc = null) { if ($desc !== null) { $v = $record[$desc['id']]; } elseif (is_array($record)) { $v = $record['id']; } else { $v = $record; } if (!is_numeric($v) && !is_array($v)) { return $v; } if ($v == -1) { return '---'; } $def = ''; $first = true; if (!is_array($v)) { $v = array($v); } foreach ($v as $k => $w) { if ($w == '') { break; } if ($first) { $first = false; } else { $def .= '<br>'; } $def .= Utils_RecordBrowserCommon::no_wrap(Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $w, $nolink)); } if (!$def) { return '---'; } return $def; }
public function queue_tab($count_f, $get_f, $statuses) { $t = time(); $status =& $this->get_module_variable('queue_status', current(array_keys($statuses))); $offset =& $this->get_module_variable('queue_offset', 0); $form = $this->init_module(Libs_QuickForm::module_name()); $theme = $this->pack_module(Base_Theme::module_name()); $form->addElement('select', 'status', __('Status'), $statuses); $form->addElement('submit', 'submit_button', __('Show')); $form->addRule('status', 'Field required', 'required'); $form->setDefaults(array('status' => $status)); if ($form->validate()) { $data = $form->exportValues(); if (array_key_exists($data['status'], $statuses)) { $status = $data['status']; } $offset = 0; } $form->assign_theme('form', $theme); $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'queue'); $m->set_table_columns(array(array('name' => 'To', 'width' => 30, 'order' => 'toNumber'), array('name' => 'Status', 'width' => 10), array('name' => 'Date', 'width' => 10, 'order' => 'creationDate'), array('name' => 'File', 'width' => 30, 'order' => 'fileName'))); $m->set_default_order(array('Date' => 'DESC')); $count = call_user_func($count_f, $status); if ($count === false) { $count = 0; } $limits = $m->get_limit($count); $order = $m->get_order(); if ($count != 0) { $data = call_user_func($get_f, $status, $order[0]['order'], $order[0]['direction'], $limits['numrows'], (string) ($limits['offset'] + 1)); } if ($count == 0 || $data === false) { $data = array(); } foreach ($data as $row) { $from_rec = CRM_ContactsCommon::get_contacts(array('fax' => $row['toNumber'])); foreach ($from_rec as &$rec) { $rec = CRM_ContactsCommon::contact_format_default($rec); } $from_rec_comp = CRM_ContactsCommon::get_companies(array('fax' => $row['toNumber'])); foreach ($from_rec_comp as $rec) { $from_rec[] = Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $rec); } $m->add_row(empty($from_rec) ? $row['toNumber'] : ' (' . implode(', ', $from_rec) . ')', $statuses[$row['faxStatus']], Base_RegionalSettingsCommon::time2reg($row['creationDate']), '<a href="' . $row['fileUrl'] . '" target="_blank">' . $row['fileName'] . '</a>'); } $theme->assign('table_data', $this->get_html_of_module($m)); $theme->display(); }
public static function display_bugtrack($v) { return Utils_RecordBrowserCommon::create_linked_label('bugtrack', 'Project Name', $v['id']); }