+ if ($id != "")
+ $id = "id='$id'";
+ label_cells($label, "<input type='file' name='$name' $id >");
+}
+function file_row($label, $name, $id = "")
+{
+ echo "<tr><td class='label'>$label</td>";
+ file_cells(null, $name, $id);
+ echo "</tr>\n";
+}
+
+/*-----------------------------------------------------------------------------------
+
+ Reference number input.
+
+ Optional $context array contains transaction data used in number parsing:
+ 'data' - data used for month/year codes
+ 'location' - location code
+ 'customer' - debtor_no
+ 'supplier' - supplier id
+ 'branch' - branch_code
+*/
+function ref_cells($label, $name, $title=null, $init=null, $params=null, $submit_on_change=false, $type=null, $context=null)
+{
+ 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])) // initialization
+ {
+ if (isset($init))
+ {
+ $_POST[$name] = $init;
+ } else {
+ $_POST[$name] = $Refs->get_next($type, $_POST[$name.'_list'], $context);
+ }
+ $Ajax->addUpdate(true, $name, $_POST[$name]);
+ }
+
+ if (check_ui_refresh($name)) { // call context changed
+ $_POST[$name] = $Refs->normalize($_POST[$name], $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);
+ }