X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=43a4d685b84438a6e3f0786b96697aade6f56daf;hb=af03975abbd624d17cc6c4f61b71808a0a5c82ea;hp=9d7801b01a9d231db47b688257f4351e339cc924;hpb=303eb17e9cdd9702eee9fdfcaee51e654a1da541;p=fa-stable.git
diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc
index 9d7801b0..43a4d685 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'];
@@ -89,21 +98,20 @@ $opts = array( // default options
$opts['sel_hint'] = $by_id || $search_box==false ?
'' : _('Press Space tab for search pattern entry');
- if ($opts['box_hint'] === null) // dodaƦ hint dla pustego ****
+ if ($opts['box_hint'] === null)
$opts['box_hint'] = $search_box && $search_submit != false ?
($by_id ? _('Enter code fragment to search or * for all')
: _('Enter description fragment to search or * for all')) :'';
if ($selected_id == null) {
- $selected_id = get_post($name, $opts['default']);
+ $selected_id = get_post($name, (string)$opts['default']);
}
if(!is_array($selected_id))
- $selected_id = array($selected_id); // code is generalized for multiple selection support
+ $selected_id = array((string)$selected_id); // code is generalized for multiple selection support
$txt = get_post($search_box);
$rel = '';
$limit = '';
-
if (isset($_POST['_'.$name.'_update'])) { // select list or search box change
if ($by_id) $txt = $_POST[$name];
@@ -134,21 +142,23 @@ $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['where'][] = '('. implode($opts['search'], ' OR ') . ')';
+ $opts['search'][$i] = $s . " LIKE "
+ .db_escape(($class=='combo3' ? '' : '%').$txt.'%');
+ $opts['where'][] = '('. implode(' OR ', $opts['search']) . ')';
}
}
}
+
// sql completion
if (count($opts['where'])) {
$where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
- $where .= '('. implode($opts['where'], ' AND ') . ')';
+ $where .= '('. implode(' AND ', $opts['where']) . ')';
$group_pos = strpos($sql, 'GROUP BY');
if ($group_pos) {
$group = substr($sql, $group_pos);
@@ -170,23 +180,25 @@ $opts = array( // default options
$found = false;
$lastcat = null;
$edit = false;
-//if($name=='stock_id') display_notification('