- text_cells_ex($label, $name, 16, 18, $init, $title, $params, null, $submit_on_change);
+ global $Ajax, $Refs;
+
+ if (isset($type)) {
+ if (empty($_POST[$name.'_list'])) // restore refline id
+ $_POST[$name.'_list'] = $Refs->reflines->find_refline_id(empty($_POST[$name]) ? $init : $_POST[$name], $type);
+
+ if (empty($_POST[$name]) || ($_SERVER['REQUEST_METHOD'] == 'GET')) // initialization
+ {
+ if (isset($init))
+ {
+ $_POST[$name] = $init;
+ } else {
+ $_POST[$name] = $Refs->get_next($type, $_POST[$name.'_list'], $context); // set default
+ }
+ $Ajax->addUpdate(true, $name, $_POST[$name]);
+ }
+
+ if (check_ui_refresh($name)) { // call context changed
+ $_POST[$name] = $Refs->normalize($init, $type, $context, $_POST[$name.'_list']);
+ $Ajax->addUpdate(true, $name, $_POST[$name]);
+ }
+
+ if ($Refs->reflines->count($type)>1) {
+ if (list_updated($name.'_list')) {
+ $_POST[$name] = $Refs->get_next($type, $_POST[$name.'_list'], $context);
+ $Ajax->addUpdate(true, $name, $_POST[$name]);
+ }
+ $list = refline_list($name.'_list', $type);
+ } else {
+ $list = '';
+ }
+
+ if (isset($label))
+ label_cell($label, $params);
+
+ label_cell($list."<input name='".$name."' "
+ .(check_edit_access($name) ? '' : 'disabled ')
+ ."value='".@$_POST[$name]."' size=10 maxlength=35>");
+ }
+ else // just wildcard ref field (e.g. for global inquires)
+ {
+ text_cells_ex($label, $name, 16, 35, $init, $title, $params, null, $submit_on_change);
+ }