Enabling popup search in Customers, branches, suppliers, inventory, fixed assets...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 9 Dec 2015 12:34:52 +0000 (13:34 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 9 Dec 2015 12:34:52 +0000 (13:34 +0100)
22 files changed:
.gitignore
admin/gl_setup.php
config.default.php
gl/inquiry/accounts_list.php [new file with mode: 0644]
gl/manage/gl_accounts.php
includes/prefs/sysprefs.inc
includes/ui/ui_input.inc
includes/ui/ui_lists.inc
includes/ui/ui_view.inc
inventory/inquiry/stock_list.php [new file with mode: 0644]
inventory/inquiry/stock_status.php
inventory/manage/item_categories.php
inventory/manage/item_codes.php
inventory/manage/sales_kits.php
inventory/prices.php
inventory/purchasing_data.php
inventory/reorder_level.php
purchasing/inquiry/suppliers_list.php [new file with mode: 0644]
reporting/reports_main.php
sales/inquiry/customer_branches_list.php [new file with mode: 0644]
sales/inquiry/customers_list.php [new file with mode: 0644]
sales/manage/customer_branches.php

index 12a5b6ddf0ec568d730a94b3d05eb834da88528a..ef755821e909a1506d442013d79517819beef0d0 100644 (file)
@@ -19,3 +19,4 @@ installed_extensions.php
 config.php
 config_db.php
 !index.php
+/gl/inquiry/accounts_list.php
index 62af2b02717c8348f7f68058bc490fc65c1bda2c..07f70b7b713ee188a2fde356eed680b530a1ad8d 100644 (file)
@@ -13,7 +13,11 @@ $page_security = 'SA_GLSETUP';
 $path_to_root="..";
 include($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "System and General GL Setup"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context = "System and General GL Setup"), false, false, "", $js);
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
index 386759e14431a8d7b2a8402d29568c24bef1d4a8..cdbb2d44b87eecd221fa7d6851ebb283fac111a2 100644 (file)
@@ -205,3 +205,10 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_
        If not defined $comp_path/%s/backup/ is used.
 */
 //     $backup_path = dirname(__FILE__).'/company/%s/backup/';
+
+/*
+       Optional popup search enabled if this is true.
+       $max_rows_in_search = 10 is used for maximum rows in search
+*/
+       $use_popup_search = true;
+       $max_rows_in_search = 10;
diff --git a/gl/inquiry/accounts_list.php b/gl/inquiry/accounts_list.php
new file mode 100644 (file)
index 0000000..9bccf88
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**********************************************************************
+  Page for searching GL account list and select it to GL account
+  selection in page that has GL account dropdown list.
+***********************************************************************/
+$page_security = "SA_GLACCOUNT";
+$path_to_root = "../..";
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui.inc");
+
+$js = get_js_select_combo_item();
+
+page(_($help_context = "GL Accounts"), true, false, "", $js);
+
+if (isset($SysPrefs->max_rows_in_search))
+       $limit = $SysPrefs->max_rows_in_search;
+else
+       $limit = 10;
+
+// Activate Ajax on form submit
+if(get_post("search")) {
+       $Ajax->activate("account_tbl");
+}
+
+// BEGIN: Filter form. Use query string so the client_id will not disappear
+// after ajax form post.
+start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
+
+start_table(TABLESTYLE_NOBORDER);
+
+start_row();
+
+text_cells(_("Description"), "description");
+submit_cells("search", _("Search"), "", _("Search GL accounts"), "default");
+
+end_row();
+
+end_table();
+
+end_form();
+// END: Filter form
+
+// BEGIN: Account list
+div_start("account_tbl");
+
+start_table(TABLESTYLE);
+
+$th = array("", _("Account Code"), _("Description"), _("Category"));
+
+table_header($th);
+
+// Query based on function gl_all_accounts_list in includes/ui/ui_lists.inc.
+$sql = "SELECT chart.account_code, chart.account_name, type.name
+                       FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
+                       WHERE chart.account_type=type.id
+        AND (
+          chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR
+          chart.account_name LIKE " . db_escape("%" . get_post("description"). "%") . " OR
+          chart.account_code LIKE " . db_escape("%" . get_post("description"). "%") . "
+        ) 
+       ORDER BY chart.account_code LIMIT 0, $limit"; // We only display 10 items.
+$result = db_query($sql, "Failed in retreiving GL account list.");
+
+$k = 0; //row colour counter
+$name = $_GET["client_id"];
+while ($myrow = db_fetch_assoc($result)) {
+       alt_table_row_color($k);
+       $value = $myrow['account_code'];
+       ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
+       label_cell($myrow["account_code"]);
+       label_cell($myrow["account_name"]);
+       label_cell($myrow["name"]);
+       end_row();
+}
+
+end_table(1);
+
+div_end();
+// END: Account list
+
+end_page(true);
\ No newline at end of file
index 3f59c1b2e7d6b5809700ce9c8fde33c692cc9858..417d51d70b3127c5646bc9a153e4aeeb82b1770d 100644 (file)
@@ -13,7 +13,11 @@ $page_security = 'SA_GLACCOUNT';
 $path_to_root = "../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Chart of Accounts"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context = "Chart of Accounts"), false, false, "", $js);
 
 include($path_to_root . "/includes/ui.inc");
 include($path_to_root . "/gl/includes/gl_db.inc");
index cade4c2df8c93ab3f84f7d5d87c76697b5c989f8..cce4769c563fcf3cfc80a58a65090ffe24e8af69 100644 (file)
@@ -38,6 +38,9 @@ class sys_prefs
 
                if (!$this->time_zone)
                        $this->time_zone = 'Europe/Berlin';
+                       
+               if (!isset($this->use_popup_search))
+                       $this->use_popup_search = false;
 
            ini_set('date.timezone', $this->time_zone);
        }
index f5f87cff9b336c392cdad88c5986af077fb4ab9d..b15ba10e5af23a10ad0425f6831376fa9c905481 100644 (file)
@@ -287,7 +287,7 @@ function set_icon($icon, $title=false)
        global $path_to_root;
        if (basename($icon) === $icon) // standard icons does not contain path separator
                $icon = "$path_to_root/themes/".user_theme()."/images/$icon";
-       return "<img src='$icon' width='12' height='12' border='0'".($title ? " title='$title'" : "")." >\n";   
+       return "<img src='$icon' style='vertical-align:middle;width:12px;height:12px;border:0;'".($title ? " title='$title'" : "")." >\n";      
 }
 
 function button($name, $value, $title=false, $icon=false,  $aspect='')
@@ -1012,3 +1012,12 @@ function bank_balance_row($bank_acc, $parms='')
                ."</a>", $parms);
 }
 
+function ahref($label, $href, $target="", $onclick="") {
+  echo "<a href='$href' target='$target' onclick='$onclick'>$label</a>";
+}
+
+function ahref_cell($label, $href, $target="", $onclick="") {
+  echo "<td align='center'>&nbsp;&nbsp;";
+  ahref($label, $href, $target, $onclick);
+  echo "&nbsp;&nbsp;</td>";
+}
index 0149442508ed5d95404f9af2b151170373f3abdb..12ebceaef666c6434fc81170dbf772ddc0dac024 100644 (file)
@@ -25,9 +25,9 @@ define('SELECT_BUTTON', "<input %s type='submit' class='combo_select' style='bor
 //     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
@@ -239,11 +239,16 @@ $opts = array(            // default options
        
        $_POST[$name] = $multi ? $selected_id : $selected_id[0];
 
-       $selector = "<select autocomplete='off' ".($multi ? "multiple" : '')
+       if ($SysPrefs->use_popup_search)
+               $selector = "<select id='$name' autocomplete='off' ".($multi ? "multiple" : '')
+               . ($opts['height']!==false ? ' size="'.$opts['height'].'"' : '')
+               . "$disabled name='$name".($multi ? '[]':'')."' class='$class' title='"
+               . $opts['sel_hint']."' $rel>".$selector."</select>\n";
+       else
+               $selector = "<select autocomplete='off' ".($multi ? "multiple" : '')
                . ($opts['height']!==false ? ' size="'.$opts['height'].'"' : '')
                . "$disabled name='$name".($multi ? '[]':'')."' class='$class' title='"
                . $opts['sel_hint']."' $rel>".$selector."</select>\n";
-
        if ($by_id && ($search_box != false || $opts['editable']) ) {
                // on first display show selector list
                if (isset($_POST[$search_box]) && $opts['editable'] && $edit) {
@@ -287,13 +292,87 @@ $opts = array(            // default options
        }
        default_focus(($search_box && $by_id) ? $search_box : $name);
 
+       if ($SysPrefs->use_popup_search)
+       {
+               $img = "";
+               $img_title = "";
+               $link = "";
+               $id = $name;
+               if ($SysPrefs->use_popup_windows) {
+                       //_vd("type= $type");
+               switch (strtolower($type)) {
+                       case "stock":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "stock_manufactured":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=manufactured&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "stock_purchased":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=purchasable&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "stock_sales":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=sales&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "stock_costable":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "kits":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "assets":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=assets&client_id=" . $id;
+                               $img_title = _("Search items");
+                               break;
+                       case "customer":
+                               $link = $path_to_root . "/sales/inquiry/customers_list.php?popup=1&client_id=" . $id;
+                               $img_title = _("Search customers");
+                               break;
+                       case "branch":
+                               $link = $path_to_root . "/sales/inquiry/customer_branches_list.php?popup=1&client_id=" . $id . "#customer_id";
+                               $img_title = _("Search branches");
+                               break;
+                       case "supplier":
+                               $link = $path_to_root . "/purchasing/inquiry/suppliers_list.php?popup=1&client_id=" . $id;
+                               $img_title = _("Search suppliers");
+                               break;
+                       case "account":
+                               $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&client_id=" . $id;
+                               $img_title = _("Search GL accounts");
+                               break;
+               }
+               }
+
+               if ($link !=="") {
+               $theme = user_theme();
+               $img = '<img src="'.$path_to_root.'/themes/'.$theme.'/images/'.ICON_VIEW.
+                       '" style="vertical-align:middle;width:12px;height:12px;border:0;" onclick="javascript:lookupWindow(&quot;'.
+                       $link.'&quot;, &quot;&quot;);" title="' . $img_title . '" style="cursor:pointer;" />';
+               }
+       }
+
        if ($opts['editlink'])
                $selector .= ' '.$opts['editlink'];
 
-       if ($search_box && $opts['cells'])
-               $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
+       if ($SysPrefs->use_popup_search)
+       {
+               if ($search_box && $opts['cells'])
+                       $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector$img</td>";
+               else
+                       $str = $edit_entry.$selector.$img;
+       }
        else
-               $str = $edit_entry.$selector;
+       {
+               if ($search_box && $opts['cells'])
+                       $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
+               else
+                       $str = $edit_entry.$selector;
+       }               
        return $str;
 }
 
@@ -462,7 +541,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_
                _('Select supplier'),
                'show_inactive'=>$all,
                'editlink' => $editkey ? add_edit_combo('supplier') : false
-               ));
+               ), "supplier");
        return $ret;
 }
 
@@ -513,7 +592,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_
                _('Select customer'),
                'show_inactive' => $show_inactive,
                'editlink' => $editkey ? add_edit_combo('customer') : false
-       ) );
+       ), "customer" );
        return $ret;
 }
 
@@ -560,7 +639,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null,
                'select_submit'=> $submit_on_change,
                'sel_hint' => _('Select customer branch'),
                'editlink' => $editkey ? add_edit_combo('branch') : false
-       ) );
+       ), "branch" );
        return $ret;
 }
 //------------------------------------------------------------------------------------------------
@@ -732,9 +811,8 @@ function dimensions_list_row($label, $name, $selected_id=null, $no_option=false,
 //---------------------------------------------------------------------------------------------------
 
 function stock_items_list($name, $selected_id=null, $all_option=false, 
-       $submit_on_change=false, $opts=array(), $editkey = false)
+       $submit_on_change=false, $opts=array(), $editkey = false, $type = "stock")
 {
-
        $sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable
                        FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
 
@@ -746,6 +824,8 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
        if ($editkey)
                set_editor('item', $name, $editkey);
 
+       if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
+               $type = 'assets';
        $ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
                array_merge(
                  array(
@@ -762,7 +842,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
                        'editlink' => $editkey ? add_edit_combo('item') : false,
                        'editable' => false,
                        'max' => 255
-                 ), $opts) );
+                 ), $opts), $type );
        return $ret;
 }
 
@@ -845,7 +925,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false,
                        'order' => array('c.description','i.item_code'),
                        'editable' => 30,
                        'max' => 255
-                 ), $opts) );
+                 ), $opts), $type == 'kits' ? $type : "stock_sales" );
 }
 
 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false)
@@ -881,7 +961,7 @@ function stock_manufactured_items_list($name, $selected_id=null,
        $all_option=false, $submit_on_change=false)
 {
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("mb_flag= 'M'")));
+               array('where'=>array("mb_flag= 'M'")), false, "stock_manufactured");
 }
 
 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
@@ -925,7 +1005,7 @@ function stock_costable_items_list($name, $selected_id=null,
        $all_option=false, $submit_on_change=false)
 {
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("mb_flag!='D'")));
+               array('where'=>array("mb_flag!='D'")), false, "stock_costable");
 }
 
 function stock_costable_items_list_cells($label, $name, $selected_id=null, 
@@ -934,7 +1014,7 @@ function stock_costable_items_list_cells($label, $name, $selected_id=null,
        if ($label != null)
                echo "<td>$label</td>\n";
        echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("mb_flag!='D'"), 'cells'=>true));
+               array('where'=>array("mb_flag!='D'"), 'cells'=>true), false, "stock_costable");
 }
 
 //------------------------------------------------------------------------------------
@@ -943,7 +1023,7 @@ function stock_purchasable_items_list($name, $selected_id=null,
 {
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
                array('where'=>array("NOT no_purchase"), 
-                       'show_inactive'=>$all), $editkey);
+                       'show_inactive'=>$all), $editkey, "stock_purchased");
 }
 //
 //     This helper is used in PO/GRN/PI entry and supports editable descriptions.
@@ -1745,7 +1825,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals
                        'async' => false,
                        'category' => 2,
                        'show_inactive' => $all
-               ) );
+               ), "account" );
 }
 
 function _format_account($row)
index 5352cb91371cebd4ee9590ca625a2034614cb242..1284a918667466fe0155bffff67d304006d41b3f 100644 (file)
@@ -888,6 +888,51 @@ function get_js_open_window($width, $height)
                . " var top = (screen.height - $height) / 2;\n"
                . " return window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
                . "}\n";
+       $js .= get_js_lookup_window();
+       return $js;
+}
+
+function get_js_lookup_window() {
+       $js = "function lookupWindow(url, title) {
+       var u = url.split('#');
+       if (u.length == 2) {
+               var element = document.getElementById(u[1]);
+               var options = element.options;
+               url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value;
+       }
+       openWindow(url, title);
+       }";
+       return $js;
+}
+
+function get_js_select_combo_item() {
+       $js = "function selectComboItem(doc, client_id, value){
+       var element = doc.getElementById(client_id);
+               var options = element.options;
+               for (var i = 0, optionsLength = options.length; i < optionsLength; i++) {
+                       if (options[i].value == value) {
+                               element.selectedIndex = i;
+                       element.onchange();
+                       }
+               }
+               window.close();
+       }";
+       return $js;
+}
+/* for space search option */
+function get_js_set_combo_item() {
+       $js = "function setComboItem(doc, client_id, value, text){
+       var element = doc.getElementById(client_id);
+               var options = element.options;
+               options.length = 0;
+               var option = doc.createElement('option');
+               option.value = value;
+               option.text = text;
+       element.add(option, 0);
+               element.selectedIndex = 0;
+        element.onchange();
+               window.close();
+       }";
        return $js;
 }
 
diff --git a/inventory/inquiry/stock_list.php b/inventory/inquiry/stock_list.php
new file mode 100644 (file)
index 0000000..1d1c589
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/**********************************************************************
+  Page for searching item list and select it to item selection
+  in sales order and purchase order.
+***********************************************************************/
+$page_security = "SA_ITEM";
+$path_to_root = "../..";
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui.inc");
+
+$mode = get_company_pref('no_item_list');
+if ($mode != 0)
+       $js = get_js_set_combo_item();
+else
+       $js = get_js_select_combo_item();
+
+page(_($help_context = "Items"), true, false, "", $js);
+
+if (isset($SysPrefs->max_rows_in_search))
+       $limit = $SysPrefs->max_rows_in_search;
+else
+       $limit = 10;
+
+// Activate Ajax on form submit
+if(get_post("search")) {
+  $Ajax->activate("item_tbl");
+}
+
+// BEGIN: Filter form. Use query string so the client_id will not disappear
+// after ajax form post.
+start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
+
+start_table(TABLESTYLE_NOBORDER);
+
+start_row();
+
+text_cells(_("Description"), "description");
+submit_cells("search", _("Search"), "", _("Search items"), "default");
+
+end_row();
+
+end_table();
+
+end_form();
+// END: Filter form
+
+// BEGIN: Link to add new item
+// hyperlink_params($path_to_root . "/inventory/manage/items.php", _("Add new"), "popup=1");
+// END: Link to add new item
+
+// BEGIN: Item list
+div_start("item_tbl");
+
+start_table(TABLESTYLE);
+
+$th = array("", _("Item Code"), _("Description"), _("Category"));
+
+table_header($th);
+
+// Query based on function sales_items_list in includes/ui/ui_lists.inc.
+$sql = "SELECT COUNT(i.item_code) AS kit, i.item_code, i.description, c.description category
+  FROM
+    ".TB_PREF."stock_master s,
+    ".TB_PREF."item_codes i
+  LEFT JOIN
+    ".TB_PREF."stock_category c
+    ON i.category_id=c.category_id
+  WHERE i.stock_id=s.stock_id
+    AND !i.inactive AND !s.inactive
+    AND (  i.item_code LIKE " . db_escape("%" . get_post("description"). "%") . " OR 
+         i.description LIKE " . db_escape("%" . get_post("description"). "%") . " OR 
+         c.description LIKE " . db_escape("%" . get_post("description"). "%") . ") ";
+
+$type = "";
+if (isset($_GET['type'])) {
+  $type = $_GET['type'];
+}
+//_vd("type = $type");
+switch ($type) {
+  case "sales":
+    $sql .= " AND !s.no_sale AND mb_flag != 'F'";
+    break;
+  case "manufactured":
+    $sql .= " AND mb_flag = 'M'";
+    break;
+  case "purchasable":
+    $sql .= " AND NOT no_purchase AND mb_flag != 'F' AND i.item_code=i.stock_id";
+    break;
+  case "costable":
+    $sql .= " AND mb_flag != 'D' AND mb_flag != 'F' AND  i.item_code=i.stock_id";
+    break;
+  case "assets":
+    $sql .= " AND mb_flag = 'F'";
+    break;
+  case "kits":
+       $sql .= " AND !i.is_foreign AND i.item_code!=i.stock_id AND mb_flag != 'F'";
+       break;
+  case "all":
+    $sql .= " AND mb_flag != 'F' AND i.item_code=i.stock_id";
+    // NOTHING TO DO.
+    break;
+}
+
+$sql .= " GROUP BY i.item_code ORDER BY i.description LIMIT 0, $limit"; // We only display 10 items.
+//_vd($sql);
+$result = db_query($sql, "Failed in retreiving item list.");
+
+$k = 0; //row colour counter
+$name = $_GET["client_id"];
+while ($myrow = db_fetch_assoc($result)) {
+       alt_table_row_color($k);
+       $value = $myrow['item_code'];
+       if ($mode != 0) {
+               $text = $myrow['description'];
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'",  "'.$value.'", "'.$text.'")');
+       }
+       else {
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
+       }
+       label_cell($myrow["item_code"]);
+       label_cell($myrow["description"]);
+       label_cell($myrow["category"]);
+       end_row();
+}
+
+end_table(1);
+
+div_end();
+// END: Item list
+
+end_page(true);
index 6c0c0ba96422474333c1fcf93fbefbec1bd09ce1..b83c6038e4c63d6f448986d25f2798d1039f2421 100644 (file)
@@ -13,11 +13,15 @@ $page_security = 'SA_ITEMSSTATVIEW';
 $path_to_root = "../..";
 include_once($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Inventory Item Status"), isset($_GET['stock_id']));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
 
 if (isset($_GET['stock_id']))
        $_POST['stock_id'] = $_GET['stock_id'];
 
+page(_($help_context = "Inventory Item Status"), isset($_GET['stock_id']), false, "", $js);
+
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
index 21e0b394f2ad92fd3bfba16d001ebd8f65e27ab5..cd39e498dd463736f7ed8ba3dbf2568084ae758e 100644 (file)
@@ -22,7 +22,11 @@ else {
   $help_context = "Item Categories";
 }
 
-page(_($help_context));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context), false, false, "", $js);
 
 include_once($path_to_root . "/includes/ui.inc");
 
index 9fa68ebb43a813c4f252b4349d7f550909e3bd99..236ac79592bfe482ff912632149c6b71e297ae06 100644 (file)
@@ -13,7 +13,11 @@ $page_security = 'SA_FORITEMCODE';
 $path_to_root = "../..";
 include_once($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Foreign Item Codes"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context = "Foreign Item Codes"), false, false, "", $js);
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
index 2f4066787f548658e938f07cb28bae179122d044..f7199e8c0a6483a69cd2a08d5159ad30f51de816 100644 (file)
@@ -13,7 +13,11 @@ $page_security = 'SA_SALESKIT';
 $path_to_root = "../..";
 include_once($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Sales Kits & Alias Codes"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context = "Sales Kits & Alias Codes"), false, false, "", $js);
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
index a464e62e6000581119d6a7bea3fd44313be5caf6..70dd97d8a39f4a4639fb885e12ff714e0ad32899 100644 (file)
@@ -23,7 +23,10 @@ include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
-page(_($help_context = "Inventory Item Sales prices"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+page(_($help_context = "Inventory Item Sales prices"), false, false, "", $js);
 
 //---------------------------------------------------------------------------------------------------
 
index 8c36581ddd5d30823652d613f56eb02dc3c01b47..8be2566b88555e276826ad0e10de247473c0122f 100644 (file)
@@ -21,7 +21,10 @@ include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 
-page(_($help_context = "Supplier Purchasing Data"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+page(_($help_context = "Supplier Purchasing Data"), false, false, "", $js);
 
 check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system."));
 check_db_has_suppliers(_("There are no suppliers defined in the system."));
index cc0d6979ff33d6f929be01c234df133d1a16a743..6dfba5f0bdff8f36594c829434c97ff4db0ebb9c 100644 (file)
@@ -22,7 +22,10 @@ include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
-page(_($help_context = "Reorder Levels"));
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+page(_($help_context = "Reorder Levels"), false, false, "", $js);
 
 check_db_has_costable_items(_("There are no inventory items defined in the system (Purchased or manufactured items)."));
 
diff --git a/purchasing/inquiry/suppliers_list.php b/purchasing/inquiry/suppliers_list.php
new file mode 100644 (file)
index 0000000..11bb108
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**********************************************************************
+  Page for searching item list and select it to item selection
+  in sales order and purchase order.
+***********************************************************************/
+$page_security = "SA_PURCHASEORDER";
+$path_to_root = "../..";
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui.inc");
+
+$mode = get_company_pref('no_supplier_list');
+if ($mode != 0)
+       $js = get_js_set_combo_item();
+else
+       $js = get_js_select_combo_item();
+
+page(_($help_context = "Suppliers"), true, false, "", $js);
+
+if (isset($SysPrefs->max_rows_in_search))
+       $limit = $SysPrefs->max_rows_in_search;
+else
+       $limit = 10;
+
+// Activate Ajax on form submit
+if(get_post("search")) {
+  $Ajax->activate("supplier_tbl");
+}
+
+// BEGIN: Filter form. Use query string so the client_id will not disappear
+// after ajax form post.
+start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
+
+start_table(TABLESTYLE_NOBORDER);
+
+start_row();
+
+text_cells(_("Supplier"), "supplier");
+submit_cells("search", _("Search"), "", _("Search suppliers"), "default");
+
+end_row();
+
+end_table();
+
+end_form();
+// END: Filter form
+
+// BEGIN: Link to add new supplier
+// hyperlink_params($path_to_root . "/purchasing/manage/suppliers.php", _("Add new"), "popup=1");
+// END: Link to add new supplier
+
+// BEGIN: Supplier list
+div_start("supplier_tbl");
+
+start_table(TABLESTYLE);
+
+$th = array("", _("Supplier"), _("Short Name"), _("Address"), _("Tax ID"));
+
+table_header($th);
+
+// Query based on function supplier_list in includes/ui/ui_lists.inc.
+$sql = "SELECT supplier_id, supp_name, supp_ref, address, gst_no FROM ".TB_PREF."suppliers
+  WHERE (supp_name LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR 
+          supp_ref LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR 
+           address LIKE " . db_escape("%" . get_post("supplier"). "%") . " OR 
+            gst_no LIKE " . db_escape("%" . get_post("supplier"). "%") . ")
+  ORDER BY supp_name LIMIT 0, $limit"; // We only display 10 items.
+$result = db_query($sql, "Failed in retreiving supplier list.");
+
+$k = 0; //row colour counter
+$name = $_GET["client_id"];
+while ($myrow = db_fetch_assoc($result)) {
+       alt_table_row_color($k);
+       $value = $myrow['supplier_id'];
+       if ($mode != 0) {
+               $text = $myrow['supp_name'];
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'",  "'.$value.'", "'.$text.'")');
+       }
+       else {
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
+       }
+       label_cell($myrow["supp_name"]);
+       label_cell($myrow["supp_ref"]);
+       label_cell($myrow["address"]);
+       label_cell($myrow["gst_no"]);
+       end_row();
+}
+
+end_table(1);
+
+div_end();
+// END: Supplier list
+
+end_page(true);
index 9c571eb85d96aa81288ad79997f3a4983054d519..87efba8167d38f308937623b643567651527e437 100644 (file)
@@ -18,6 +18,8 @@ include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/includes/ui.inc");
 include_once($path_to_root . "/reporting/includes/reports_classes.inc");
 $js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
 if (user_use_date_picker())
        $js .= get_js_date_picker();
 
diff --git a/sales/inquiry/customer_branches_list.php b/sales/inquiry/customer_branches_list.php
new file mode 100644 (file)
index 0000000..3586628
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**********************************************************************
+  Page for searching item list and select it to item selection
+  in sales order and purchase order.
+***********************************************************************/
+$page_security = "SA_SALESORDER";
+$path_to_root = "../..";
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui.inc");
+
+$js = get_js_select_combo_item();
+
+if (isset($SysPrefs->max_rows_in_search))
+       $limit = $SysPrefs->max_rows_in_search;
+else
+       $limit = 10;
+
+page(_($help_context = "Customer Branches"), true, false, "", $js);
+
+// Activate Ajax on form submit
+if(get_post("search")) {
+  $Ajax->activate("customer_branch_tbl");
+}
+
+// BEGIN: Filter form. Use query string so the client_id will not disappear
+// after ajax form post.
+start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
+
+start_table(TABLESTYLE_NOBORDER);
+
+start_row();
+
+text_cells(_("Branch"), "branch");
+submit_cells("search", _("Search"), "", _("Search branches"), "default");
+
+end_row();
+
+end_table();
+
+end_form();
+// END: Filter form
+
+// BEGIN: Link to add new customer branch
+// hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", _("Add new"), "debtor_no=" . strip_tags($_GET["SelectedBranch"]) . "&popup=1");
+// END: Link to add new customer branch
+
+// BEGIN: Customer branches list
+div_start("customer_branch_tbl");
+
+start_table(TABLESTYLE);
+
+$th = array("", _("Ref"), _("Branch"), _("Contact"), _("Phone"));
+
+table_header($th);
+
+// Query based on function get_sql_for_customer_branches in includes/db/branches_db.inc.
+$sql = "SELECT 
+    b.branch_code,
+    b.branch_ref,
+    b.br_name,
+    p.name as contact_name,
+    p.phone
+  FROM ".TB_PREF."cust_branch b
+  LEFT JOIN ".TB_PREF."crm_contacts c
+    ON c.entity_id=b.branch_code AND c.type='cust_branch' AND c.action='general'
+  LEFT JOIN ".TB_PREF."crm_persons p
+    on c.person_id=p.id
+  WHERE b.debtor_no = ".db_escape($_GET["customer_id"])."
+    AND b.br_name LIKE " . db_escape("%" . get_post("branch"). "%") . "
+  ORDER BY b.br_name LIMIT 0, $limit"; // We only display 10 items.
+
+$result = db_query($sql, "Failed in retreiving branches list.");
+
+$k = 0; //row colour counter
+$name = $_GET["client_id"];
+while ($myrow = db_fetch_assoc($result))
+{
+       alt_table_row_color($k);
+       $value = $myrow['branch_code'];
+       ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
+       label_cell($myrow["branch_ref"]);
+       label_cell($myrow["br_name"]);
+       label_cell($myrow["contact_name"]);
+       label_cell($myrow["phone"]);
+       end_row();
+}
+
+end_table(1);
+
+div_end();
+// END: Customer list
+
+end_page(true);
diff --git a/sales/inquiry/customers_list.php b/sales/inquiry/customers_list.php
new file mode 100644 (file)
index 0000000..6ff94cc
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/**********************************************************************
+  Page for searching item list and select it to item selection
+  in sales order and purchase order.
+***********************************************************************/
+$page_security = "SA_SALESORDER";
+$path_to_root = "../..";
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/ui.inc");
+
+$mode = get_company_pref('no_customer_list');
+if ($mode != 0)
+       $js = get_js_set_combo_item();
+else
+       $js = get_js_select_combo_item();
+
+page(_($help_context = "Customers"), true, false, "", $js);
+
+if (isset($SysPrefs->max_rows_in_search))
+       $limit = $SysPrefs->max_rows_in_search;
+else
+       $limit = 10;
+
+// Activate Ajax on form submit
+if(get_post("search")) {
+  $Ajax->activate("customer_tbl");
+}
+
+// BEGIN: Filter form. Use query string so the client_id will not disappear
+// after ajax form post.
+start_form(false, false, $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']);
+
+start_table(TABLESTYLE_NOBORDER);
+
+start_row();
+
+text_cells(_("Customer"), "customer");
+submit_cells("search", _("Search"), "", _("Search customers"), "default");
+
+end_row();
+
+end_table();
+
+end_form();
+// END: Filter form
+
+// BEGIN: Link to add new customer
+// hyperlink_params($path_to_root . "/sales/manage/customers.php", _("Add new"), "popup=1");
+// END: Link to add new customer
+
+// BEGIN: Customer list
+div_start("customer_tbl");
+
+start_table(TABLESTYLE);
+
+$th = array("", _("Customer"), _("Short Name"), _("Address"), _("Tax ID"));
+
+table_header($th);
+
+// Query based on function customer_list in includes/ui/ui_lists.inc.
+
+$sql = "SELECT debtor_no, name, debtor_ref, address, tax_id FROM ".TB_PREF."debtors_master 
+  WHERE (  name LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
+     debtor_ref LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
+        address LIKE " . db_escape("%" . get_post("customer"). "%") . " OR 
+         tax_id LIKE " . db_escape("%" . get_post("customer") . "%").")
+  ORDER BY name LIMIT 0, $limit"; // We only display 10 items.
+$result = db_query($sql, "Failed in retreiving customer list.");
+
+$k = 0; //row colour counter
+$name = $_GET["client_id"];
+while ($myrow = db_fetch_assoc($result)) {
+       alt_table_row_color($k);
+       $value = $myrow['debtor_no'];
+       if ($mode != 0) {
+               $text = $myrow['name'];
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'setComboItem(window.opener.document, "'.$name.'",  "'.$value.'", "'.$text.'")');
+       }
+       else {
+               ahref_cell(_("Select"), 'javascript:void(0)', '', 'selectComboItem(window.opener.document, "'.$name.'", "'.$value.'")');
+       }
+       label_cell($myrow["name"]);
+       label_cell($myrow["debtor_ref"]);
+       label_cell($myrow["address"]);
+       label_cell($myrow["tax_id"]);
+       end_row();
+}
+
+end_table(1);
+
+div_end();
+// END: Customer list
+
+end_page(true);
index 7cd65cb3795b92eb9497506a40e5c1a463b574b1..2e1eae54fca9ef9e2d954d60c1e8c130d591146e 100644 (file)
@@ -15,7 +15,11 @@ $path_to_root="../..";
 include($path_to_root . "/includes/db_pager.inc");
 include($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Customer Branches"), @$_REQUEST['popup']);
+$js = "";
+if ($SysPrefs->use_popup_windows && $SysPrefs->use_popup_search)
+       $js .= get_js_open_window(900, 500);
+
+page(_($help_context = "Customer Branches"), @$_REQUEST['popup'], false, "", $js);
 
 include($path_to_root . "/includes/ui.inc");
 include($path_to_root . "/includes/ui/contacts_view.inc");