X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fui%2Fui_lists.inc;h=2034446a1126764625eea53b1c179cf319266eb7;hb=c678e0167be0d6773ae1b3da6ab8f2750c21f757;hp=fe373e8df1489869c685c4fccc3dcd4e8bca942c;hpb=a96e9d18d632cc730a2b4f44d0774a73246915c5;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index fe373e8d..2034446a 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -3,304 +3,369 @@ include_once($path_to_root . "/includes/banking.inc"); include_once($path_to_root . "/includes/reserved.inc"); include_once($path_to_root . "/includes/types.inc"); +include_once($path_to_root . "/includes/current_user.inc"); -define("DEFVAL", "--"); -$search_button = " "; -//$search_button = " "; +$_search_button = " "; -$all_items = reserved_words::get_all(); - -// TDB for all list functions : if there is no data, display a link to the releveant -// page to add an item, eg. for locations, if no locations, link to Add Location - -function supplier_list($name, $selected_id, $all_option=false, $submit_on_change=false) -{ - global $all_items; - - default_focus($name); - if ($selected_id == null) - $selected_id = ((!isset($_POST[$name]) || $_POST[$name] == "") ? "" : $_POST[$name]); +$_select_button = " "; +$all_items = reserved_words::get_all(); - $supplier_sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers "; - if (get_company_pref('no_supplier_list')) - { - global $search_button; - $edit_name = $name."_edit"; - $edit_button = $name."_button"; - - $val = (isset($_POST[$edit_name]) && $_POST[$edit_name] != "" ? $_POST[$edit_name] : ""); - if (isset($_POST[$edit_button])) - { - $selected_id = $_POST[$name] = ""; - set_focus($name); - } - - if ($selected_id != "") - { - $val = DEFVAL; - $supplier_sql .= "WHERE supplier_id=$selected_id"; - } - elseif ($val != "" && $val != DEFVAL) - { - $supplier_sql .= "WHERE supp_name LIKE '%{$val}%' ORDER BY supp_name"; - } +//---------------------------------------------------------------------------- +// Universal combo generator +// $sql must return selector values and selector texts in columns 0 & 1 +// Options are merged with defaults. + +function combo_input($name, $selected_id, $sql, $valfield, $namefield, + $options=null) +{ + global $Ajax; + + $opts = array( // default options + 'where'=> array(), // additional constraints + 'order' => $namefield, // list sort order + // special option parameters + 'spec_option'=>false, // option text or false + 'spec_id' => 0, // option id + // submit on select parameters + 'select_submit' => false, //submit on select: true/false + 'async' => true, // select update via ajax (true) vs _page_body reload + // search box parameters + 'sel_hint' => null, + 'search_box' => false, // name or true/false + 'type' => 0, // type of extended selector: + // 0 - with (optional) visible search box, search by id + // 1 - with hidden search box, search by option text + // 2 - TODO reverse: box with hidden selector available via enter; this + // would be convenient for optional ad hoc adding of new item + 'search_submit' => true, //search submit button: true/false + 'size' => 8, // size and max of box tag + 'max' => 50, + 'cells' => false, // combo displayed as 2