X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=includes%2Fui%2Fui_lists.inc;h=ca85d26e74d9ae77e38d2a208b3b19433d9f5cc6;hb=f5a86be183c6023b189199c69ac409df1b7116df;hp=718363d45c31f6235c068c591d842270fb8146f0;hpb=5013b34a926e2386afdb8e1be7f55bb8cdd872a2;p=fa-stable.git
diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc
index 718363d4..ca85d26e 100644
--- a/includes/ui/ui_lists.inc
+++ b/includes/ui/ui_lists.inc
@@ -13,13 +13,11 @@ include_once($path_to_root . "/includes/banking.inc");
include_once($path_to_root . "/includes/types.inc");
include_once($path_to_root . "/includes/current_user.inc");
-$_search_button = " ";
+define('SEARCH_BUTTON', " ");
-$_select_button = " ";
-
-$all_items = ALL_TEXT;
+define('SELECT_BUTTON', " ");
//----------------------------------------------------------------------------
// Universal sql combo generator
@@ -27,9 +25,9 @@ $all_items = ALL_TEXT;
// Options are merged with defaults.
function combo_input($name, $selected_id, $sql, $valfield, $namefield,
- $options=null)
+ $options=null, $type=null)
{
-global $Ajax;
+global $Ajax, $path_to_root, $SysPrefs ;
$opts = array( // default options
'where'=> array(), // additional constraints
@@ -46,9 +44,10 @@ $opts = array( // default options
'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
+ // 0 - with (optional) visible search box, search by fragment inside id
// 1 - with hidden search box, search by option text
- // 2 - TODO reverse: box with hidden selector available via enter; this
+ // 2 - with (optional) visible search box, search by fragment at the start of id
+ // 3 - 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
@@ -61,7 +60,8 @@ $opts = array( // default options
'box_hint' => null, // box/selectors hints; null = std see below
'category' => false, // category column name or false
'show_inactive' => false, // show inactive records.
- 'editable' => false // false, or length of editable entry field
+ 'editable' => false, // false, or length of editable entry field
+ 'editlink' => false // link to entity entry/edit page (optional)
);
// ------ merge options with defaults ----------
if($options != null)
@@ -77,8 +77,17 @@ $opts = array( // default options
$select_submit = $opts['select_submit'];
$spec_id = $opts['spec_id'];
$spec_option = $opts['spec_option'];
- $by_id = ($opts['type'] == 0);
- $class = $by_id ? 'combo':'combo2';
+ if ($opts['type'] == 0) {
+ $by_id = true;
+ $class = 'combo';
+ } elseif($opts['type'] == 1) {
+ $by_id = false;
+ $class = 'combo2';
+ } else {
+ $by_id = true;
+ $class = 'combo3';
+ }
+
$disabled = $opts['disabled'] ? "disabled" : '';
$multi = $opts['multi'];
@@ -133,13 +142,14 @@ $opts = array( // default options
if ($spec_option === false && $selected_id == array())
$limit = ' LIMIT 1';
else
- $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
+ $opts['where'][] = $valfield . "=". db_escape(get_post($name, $spec_id));
}
else
if ($txt != '*') {
foreach($opts['search'] as $i=> $s)
- $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
+ $opts['search'][$i] = $s . " LIKE "
+ .db_escape(($class=='combo3' ? '' : '%').$txt.'%');
$opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
}
}
@@ -170,13 +180,14 @@ $opts = array( // default options
$found = false;
$lastcat = null;
$edit = false;
-//if($name=='stock_id') display_notification('