// submit on select parameters
'default' => '', // default value when $_POST is not set
'select_submit' => false, //submit on select: true/false
+ 'edit_submit' => false, // call editor on F4
'async' => true, // select update via ajax (true) vs _page_body reload
// search box parameters
'sel_hint' => null,
if(!count($opts['search'])) {
$opts['search'] = array($by_id ? $valfield : $namefield);
}
- if ($opts['sel_hint'] === null)
+ if ($opts['sel_hint'] === null)
$opts['sel_hint'] = $by_id || $search_box==false ?
'' : _('Press Space tab for search pattern entry');
$limit = '';
if (isset($_POST[$select_submit])) {
-
if ($by_id) $txt = $_POST[$name];
if (!$opts['async'])
$rel = "rel='$search_box'"; // set relation to list
if ($opts['search_submit']) {
if (isset($_POST[$search_submit])) {
+ $selected_id = ''; // ignore selected_id while search
if (!$opts['async'])
$Ajax->activate('_page_body');
else
$descr = $opts['format']==null ? $contact_row[1] :
call_user_func($opts['format'], $contact_row);
$sel = '';
- if ((string)($selected_id) === $value) {
+ if (get_post($search_submit) && ($txt === $value)) {
+ $selected_id = $value;
+ }
+ if (get_post($search_submit) && ($txt === $value)) {
+ $selected_id = $value;
+ }
+ if ((string)($selected_id) === $value) {
$sel = 'selected';
$found = $value;
}
$_POST[$name] = $selected_id;
if ($by_id && $search_box != false) {
- $txt = $_POST[$name];
- $Ajax->addUpdate($name, $search_box, $txt);
+ $txt = $found;
+ $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
}
+ $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
$selector = "<select $disabled name='$name' class='$class' title='"
- . $opts['sel_hint']."' $rel>".$selector."</select>\n";
+ . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
$Ajax->addUpdate($name, "_{$name}_sel", $selector);
return $str;
}
+
+/*
+ Helper function.
+ Returns true if selector $name is subject to update.
+*/
+function list_updated($name)
+{
+ return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
+}
//----------------------------------------------------------------------------------------------
// Universal array combo generator
// $items is array of options 'value' => 'description'
'spec_option'=>false, // option text or false
'spec_id' => 0, // option id
'select_submit' => false, //submit on select: true/false
+ 'edit_submit' => false, // call editor on F4
'async' => true, // select update via ajax (true) vs _page_body reload
'default' => '', // default value when $_POST is not set
// search box parameters
$_POST[$name] = $first_id;
}
+ $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
$selector = "<select $disabled name='$name' class='combo' title='"
- . $opts['sel_hint']."' >".$selector."</select>\n";
+ . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
$Ajax->addUpdate($name, "_{$name}_sel", $selector);
array(
'format' => '_format_add_curr',
'search_box' => $mode!=0,
+ 'edit_submit' => true,
'type' => 1,
'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
'spec_id' => $all_items,
'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
'spec_id' => $all_items,
'select_submit'=> $submit_on_change,
+ 'edit_submit' => true, // call editor on F4
'async' => false,
- 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
+ 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
_('Select customer')
) );
}
$all_option=false, $submit_on_change=false)
{
$str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
- array('where'=>array("mb_flag!= 'M'")));
+ array('where'=>array("mb_flag!= 'M'"),
+ 'edit_submit' => true));
return $str;
}
if ($label != null)
echo "<td>$label</td>\n";
$str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
- array('where'=>array("mb_flag!= 'M'"), 'cells'=>true));
+ array('where'=>array("mb_flag!= 'M'"),
+ 'edit_submit' => true,
+ 'cells'=>true));
return $str;
}