New Company Option for showing both Short Names and Names in Customer/Supplier lists.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 17 Sep 2017 09:52:23 +0000 (11:52 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 17 Sep 2017 09:52:23 +0000 (11:52 +0200)
admin/company_preferences.php
includes/ui/ui_lists.inc
sql/alter2.4.php
sql/en_US-demo.sql
sql/en_US-new.sql

index fc8c7091f95198d49a40ea9986e40b4218cedb30..34af247c9b601b43d540242fbeaac5d9c9bb471b 100644 (file)
@@ -111,7 +111,7 @@ if (isset($_POST['update']) && $_POST['update'] != "")
                update_company_prefs(
                        get_post( array('coy_name','coy_no','gst_no','tax_prd','tax_last',
                                'postal_address','phone', 'fax', 'email', 'coy_logo', 'domicile',
-                               'use_dimension', 'curr_default', 'f_year', 
+                               'use_dimension', 'curr_default', 'f_year', 'shortname_name_in_list',
                                'no_item_list' => 0, 'no_customer_list' => 0, 
                                'no_supplier_list' =>0, 'base_sales', 
                                'time_zone' => 0, 'company_logo_report' => 0, 'add_pct', 'round_to', 'login_tout', 'auto_curr_reval',
@@ -143,6 +143,12 @@ $_POST['coy_logo']  = $myrow["coy_logo"];
 $_POST['domicile']  = $myrow["domicile"];
 $_POST['use_dimension']  = $myrow["use_dimension"];
 $_POST['base_sales']  = $myrow["base_sales"];
+if (!isset($myrow["shortname_name_in_list"]))
+{
+       set_company_pref("shortname_name_in_list", "setup.company", "tinyint", 1, '0');
+       $myrow["shortname_name_in_list"] = get_company_pref("shortname_name_in_list");
+}
+$_POST['shortname_name_in_list']  = $myrow["shortname_name_in_list"];
 $_POST['no_item_list']  = $myrow["no_item_list"];
 $_POST['no_customer_list']  = $myrow["no_customer_list"];
 $_POST['no_supplier_list']  = $myrow["no_supplier_list"];
@@ -223,6 +229,7 @@ number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
 
 table_section_title(_("User Interface Options"));
 
+check_row(_("Short Name and Name in List"), 'shortname_name_in_list', $_POST['shortname_name_in_list']);
 check_row(_("Search Item List"), 'no_item_list', null);
 check_row(_("Search Customer List"), 'no_customer_list', null);
 check_row(_("Search Supplier List"), 'no_supplier_list', null);
index c603ead26d027375729832139fc12beebe36c382..e8121c35977f762d9fd4503cd544cd1238f691a7 100644 (file)
@@ -180,11 +180,14 @@ $opts = array(            // default options
        $found = false;
        $lastcat = null;
        $edit = false;
+       $pname = false;
+       if (($type === "customer" || $type === "supplier") && !empty($SysPrefs->prefs['shortname_name_in_list']))
+               $pname = true;
        if($result = db_query($sql)) {
                while ($contact_row = db_fetch($result)) {
                        $value = $contact_row[0];
                        $descr = $opts['format']==null ?  $contact_row[1] :
-                               call_user_func($opts['format'], $contact_row);
+                               call_user_func($opts['format'], $contact_row, $pname);
                        $sel = '';
                        if (get_post($search_button) && ($txt == $value)) {
                                $selected_id[] = $value;
@@ -478,7 +481,7 @@ function array_selector_row($label, $name, $selected_id, $items, $options=null)
 }
 
 //----------------------------------------------------------------------------------------------
-function _format_add_curr($row)
+function _format_add_curr($row, $pname=false)
 {
        static $company_currency;
 
@@ -486,8 +489,14 @@ function _format_add_curr($row)
        {
                $company_currency = get_company_currency();
        }
-       return $row[1] . ($row[2] == $company_currency ?
-               '' : ("&nbsp;-&nbsp;" . $row[2]));
+       if (!$pname)
+       {
+               return $row[1] . ($row[2] == $company_currency ? '' : ("&nbsp;-&nbsp;" . $row[2]));
+       }               
+       else
+       {
+               return $row[1] . "&nbsp;-&nbsp;" . $row[2] . ($row[3] == $company_currency ? '' : ("&nbsp;-&nbsp;" . $row[3]));
+       }               
 }
 
 function add_edit_combo($type)
@@ -508,8 +517,11 @@ function add_edit_combo($type)
 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false,
        $all=false, $editkey = false)
 {
-
-       $sql = "SELECT supplier_id, supp_ref, curr_code, inactive FROM ".TB_PREF."suppliers ";
+       global $SysPrefs;
+       if (!empty($SysPrefs->prefs['shortname_name_in_list']))
+               $sql = "SELECT supplier_id, supp_ref, supp_name, curr_code, inactive FROM ".TB_PREF."suppliers ";
+       else    
+               $sql = "SELECT supplier_id, supp_ref, curr_code, inactive FROM ".TB_PREF."suppliers ";
 
        $mode = get_company_pref('no_supplier_list');
 
@@ -558,8 +570,11 @@ function supplier_list_row($label, $name, $selected_id=null, $all_option = false
 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, 
        $show_inactive=false, $editkey = false)
 {
-
-       $sql = "SELECT debtor_no, debtor_ref, curr_code, inactive FROM ".TB_PREF."debtors_master ";
+       global $SysPrefs;
+       if (!empty($SysPrefs->prefs['shortname_name_in_list']))
+               $sql = "SELECT debtor_no, debtor_ref, name, curr_code, inactive FROM ".TB_PREF."debtors_master ";
+       else    
+               $sql = "SELECT debtor_no, debtor_ref, curr_code, inactive FROM ".TB_PREF."debtors_master ";
 
        $mode = get_company_pref('no_customer_list');
 
index c51fbb2392e03aea906a419eb20efffc56916cb5..5e9b83db0df12f7b06370fbff92672dcc70ef776 100644 (file)
@@ -74,6 +74,9 @@ class fa2_4 extends fa_patch {
                if (get_company_pref('company_logo_report') === null) { // available from 2.4.2, during updates
                        set_company_pref('company_logo_report', 'setup.company', 'tinyint', 1, '0');
                }
+               if (get_company_pref('shortname_name_in_list') === null) { // available from 2.4.2, during updates
+                       set_company_pref('shortname_name_in_list', 'setup.company', 'tinyint', 1, '0');
+               }
 
                $result = $this->update_workorders()  && $this->update_grn_rates() && $this->switch_database_to_utf($pref);
 
index a4152da79b6941001cb4be4d96e1102f36993097..dd13f532831b5a97d3172823e3cd52bfc909027e 100644 (file)
@@ -2116,6 +2116,7 @@ INSERT INTO `0_sys_prefs` VALUES ('domicile', 'setup.company', 'varchar', 55, ''
 INSERT INTO `0_sys_prefs` VALUES ('curr_default', 'setup.company', 'char', 3, 'USD');
 INSERT INTO `0_sys_prefs` VALUES ('use_dimension', 'setup.company', 'tinyint', 1, '1');
 INSERT INTO `0_sys_prefs` VALUES ('f_year', 'setup.company', 'int', 11, '1');
+INSERT INTO `0_sys_prefs` VALUES ('shortname_name_in_list','setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_item_list', 'setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_customer_list', 'setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_supplier_list', 'setup.company', 'tinyint', 1, '0');
index b26d66264101b808569e0d07ab5edd69a5b93f55..ad8316591e6bd9ddaf1ee594d67a5e60096b74c9 100644 (file)
@@ -1840,6 +1840,7 @@ INSERT INTO `0_sys_prefs` VALUES ('domicile', 'setup.company', 'varchar', 55, ''
 INSERT INTO `0_sys_prefs` VALUES ('curr_default', 'setup.company', 'char', 3, 'USD');
 INSERT INTO `0_sys_prefs` VALUES ('use_dimension', 'setup.company', 'tinyint', 1, '1');
 INSERT INTO `0_sys_prefs` VALUES ('f_year', 'setup.company', 'int', 11, '1');
+INSERT INTO `0_sys_prefs` VALUES ('shortname_name_in_list','setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_item_list', 'setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_customer_list', 'setup.company', 'tinyint', 1, '0');
 INSERT INTO `0_sys_prefs` VALUES ('no_supplier_list', 'setup.company', 'tinyint', 1, '0');