From ef2dabac1e80e72d3024a0072767f4d9057f3cc7 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Wed, 26 Nov 2008 16:54:07 +0000 Subject: [PATCH] Fixed combo_input for $sql with GROUP BY option. --- includes/ui/ui_lists.inc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index e2fc6a10..3da41541 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -121,8 +121,15 @@ $opts = array( // default options } // sql completion if (count($opts['where'])) { - $sql .= strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; - $sql .= '('. implode($opts['where'], ' AND ') . ')'; + $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; + $where .= '('. implode($opts['where'], ' AND ') . ')'; + $group_pos = strpos($sql, 'GROUP BY'); + if ($group_pos) { + $group = substr($sql, $group_pos); + $sql = substr($sql, 0, $group_pos) . $where.' '.$group; + } else { + $sql .= $where; + } } if ($opts['order'] != false) { $sql .= ' ORDER BY '.$opts['order']; @@ -133,7 +140,7 @@ $opts = array( // default options $selector = $first_opt = ''; $first_id = false; $found = false; -//if($name=='contact_sel') display_error($sql); +//if($name=='stock_id') display_error($sql); if($result = db_query($sql)) { while ($contact_row = db_fetch($result)) { $value = $contact_row[0]; @@ -684,7 +691,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false, 'spec_option' => $all_option===true ? _("All Items") : $all_option, 'spec_id' => $all_items, 'search_box' => true, - 'search' => array("i.item_code", "c.description","s.description"), + 'search' => array("i.item_code", "c.description"), 'search_submit' => get_company_pref('no_item_list')!=0, 'size'=>15, 'select_submit'=> $submit_on_change, -- 2.30.2