X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fui%2Fui_lists.inc;h=1176cc5f8d538dff76d8e7a721a21c729c6080af;hb=2a839495da2c19e1fad93019cae5a49e37687964;hp=4b2294e314e9c95313afe8b090d9733a398f4601;hpb=c7a6b173102b5df624ce18780e057b3d61953ce6;p=fa-stable.git
diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc
index 4b2294e3..1176cc5f 100644
--- a/includes/ui/ui_lists.inc
+++ b/includes/ui/ui_lists.inc
@@ -74,13 +74,16 @@ $opts = array( // default options
: _('Enter description fragment to search or * for all')) :'';
if ($selected_id == null) {
- $selected_id = get_post($name);
+ $selected_id = get_post($name, null);
}
$txt = get_post($search_box);
$rel = '';
$limit = '';
if (isset($_POST[$select_submit])) {
+
+ if ($by_id) $txt = $_POST[$name];
+
if (!$opts['async'])
$Ajax->activate('_page_body');
else
@@ -91,15 +94,17 @@ $opts = array( // default options
$rel = "rel='$search_box'"; // set relation to list
if ($opts['search_submit']) {
- // if selected from list - set focus on next field
if (isset($_POST[$search_submit])) {
- $Ajax->activate($name);
+ if (!$opts['async'])
+ $Ajax->activate('_page_body');
+ else
+ $Ajax->activate($name);
}
if ($txt == '') {
- if ($spec_option === false)
- $limit = ' LIMIT 1';
+ if ($spec_option === false && $selected_id==null)
+ $limit = ' LIMIT 1';
else
- $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
+ $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
}
else
if ($txt != '*') {
@@ -124,61 +129,38 @@ $opts = array( // default options
$selector = $first_opt = '';
$first_id = false;
$found = false;
-//if($name=='code_id') display_error($sql);
+//if($name=='SelectStockFromList') display_error($sql);
if($result = db_query($sql)) {
while ($contact_row = db_fetch($result)) {
$value = $contact_row[0];
$descr = $opts['format']==null ? $contact_row[1] :
call_user_func($opts['format'], $contact_row);
$sel = '';
- if (isset($_POST[$search_submit])) {
- if (($by_id ? $value : $contact_row[1]) === $txt)
- $selected_id = $value;
- }
- // if no initial selection - set the first item
- if ($selected_id === "") {
- $selected_id = $value;
- }
- if ($selected_id == $value) {
+ if ((string)($selected_id) === $value) {
$sel = 'selected';
$found = $value;
- $_POST[$name] = $selected_id;
}
- if ($first_opt == false) {
+ if ($first_id === false) {
$first_id = $value;
$first_opt = $descr;
- continue;
}
$selector .= "\n";
}
db_free_result($result);
}
- if ($first_id !== false) {
- // add first option - selected also if no match for selected_id was found
- // and no special option defined
- $sel = $spec_option===false || $found === $first_id ? 'selected' : '';
- $selector = "\n"
- . $selector;
- }
// Prepend special option.
if ($spec_option !== false) { // if special option used - add it
$first_id = $spec_id;
$first_opt = $spec_option;
- if (isset($_POST[$search_submit])) {
- if ($txt == '')
- $selected_id = $spec_id;
- }
$sel = $found===false ? 'selected' : '';
$selector = "\n"
. $selector;
- $first_id = $spec_id;
}
if ($found === false) {
$_POST[$name] = $first_id;
}
-
if ($by_id) {
$txt = $_POST[$name];
if ($search_box)
@@ -203,7 +185,7 @@ $opts = array( // default options
}
// ------ make combo ----------
-$edit_entry = '';
+ $edit_entry = '';
if ($search_box != false) {
$edit_entry = " $all_option === true ? _("All Locations") : $all_option,
'spec_id' => $all_items,
- 'select_submit'=> $submit_on_change,
- 'async' => false
+ 'select_submit'=> $submit_on_change
) );
}
@@ -670,7 +651,7 @@ function stock_costable_items_list($name, $selected_id,
function stock_purchasable_items_list($name, $selected_id, $all_option=false,
$submit_on_change=false, $opts=array())
{
-
+ global $all_items;
$sql = "SELECT stock_id, s.description, c.description
FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c
WHERE s.category_id=c.category_id
@@ -719,7 +700,8 @@ function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)
echo "
$label | \n";
echo "";
if ($enabled)
- $sel = " |