From: Joe Hunt Date: Sun, 17 Sep 2017 09:52:23 +0000 (+0200) Subject: New Company Option for showing both Short Names and Names in Customer/Supplier lists. X-Git-Tag: v2.4.3~42 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=4caf520181fb8539cb52079552b650aef81cb1cb New Company Option for showing both Short Names and Names in Customer/Supplier lists. --- diff --git a/admin/company_preferences.php b/admin/company_preferences.php index fc8c7091..34af247c 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -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); diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index c603ead2..e8121c35 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -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 ? - '' : (" - " . $row[2])); + if (!$pname) + { + return $row[1] . ($row[2] == $company_currency ? '' : (" - " . $row[2])); + } + else + { + return $row[1] . " - " . $row[2] . ($row[3] == $company_currency ? '' : (" - " . $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'); diff --git a/sql/alter2.4.php b/sql/alter2.4.php index c51fbb23..5e9b83db 100644 --- a/sql/alter2.4.php +++ b/sql/alter2.4.php @@ -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); diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index a4152da7..dd13f532 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -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'); diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index b26d6626..ad831659 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -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');