Added missing company settings to upgrade script, fixed company settings refreshing...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 22 Mar 2015 10:20:11 +0000 (11:20 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 25 Mar 2015 11:49:48 +0000 (12:49 +0100)
admin/backups.php
admin/company_preferences.php
admin/db/company_db.inc
admin/gl_setup.php
admin/includes/fa_patch.class.inc
includes/db/connect_db_mysql.inc
includes/db/connect_db_mysqli.inc
includes/prefs/sysprefs.inc
includes/session.inc
sql/alter2.4.sql

index 1168b4f2fc9ce803268684f45a1c581502411c96..0c039dea42205b6a2f482b2d226b09a90f96c8c9 100644 (file)
@@ -140,7 +140,7 @@ if (get_post('restore')) {
        if ($backup_name) {
                if (db_import($backup_path, $conn))
                        display_notification(_("Restore backup completed."));
-               refresh_sys_prefs(); // re-read system setup
+               $SysPrefs->refesh(); // re-read system setup
        } else
                display_error(_("Select backup file first."));
 }
index b889aeb96031bbdedc115bdc56463648ce74a897..186d06bf848f45e0d419a7595e61c383597a3f6c 100644 (file)
@@ -117,20 +117,6 @@ if (isset($_POST['update']) && $_POST['update'] != "")
        $Ajax->activate('_page_body');
 } /* end of if submit */
 
-//---------------------------------------------------------------------------------------------
-if (get_company_pref('bcc_email') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
-       set_company_pref('bcc_email', 'setup.company', 'varchar', 100, '');
-       refresh_sys_prefs();
-}
-if (get_company_pref('alternative_tax_include_on_docs') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
-       set_company_pref('alternative_tax_include_on_docs', 'setup.company', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-if (get_company_pref('suppress_tax_rates') === null) { // available from 2.3.14, can be not defined on pre-2.4 installations
-       set_company_pref('suppress_tax_rates', 'setup.company', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
 start_form(true);
 
 $myrow = get_company_prefs();
index 479f92ac55f343120f47f0acc77c38ac3e30c3e3..447307b8d98d8d3bdd2db991ed5e4c36566f19de 100644 (file)
@@ -35,7 +35,7 @@ function get_company_pref($prefs = null)
        global $SysPrefs, $db_version;
 
        if (!isset($SysPrefs->prefs))    // just after first login or reset
-               $SysPrefs->refresh_company_prefs();
+               $SysPrefs->refresh();
 
        $all = $SysPrefs->prefs;
 
@@ -63,17 +63,6 @@ function set_company_pref($pref, $category, $type, $length, $value)
        return db_query($sql, "cannot set company pref");
 }
 
-function refresh_sys_prefs()
-{
-       global $SysPrefs;
-
-//     flush_dir(user_js_cache()); // clear cache
-       unset($_SESSION['SysPrefs']);
-       $_SESSION['SysPrefs'] = new sys_prefs();
-       $SysPrefs = &$_SESSION['SysPrefs'];
-       $SysPrefs->refresh_company_prefs();
-}
-
 function get_base_sales_type()
 {
        return get_company_pref('base_sales');
index cb53aba93376fb9fc89bc688342c7fe291d9b0cf..3836493b530f1b4c7e7d9a3c93176d24cf81393e 100644 (file)
@@ -94,55 +94,6 @@ start_outer_table(TABLESTYLE2);
 
 table_section(1);
 
-if (get_company_pref('grn_clearing_act') === null) { // available from 2.3.1, can be not defined on pre-2.4 installations
-       set_company_pref('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0);
-       refresh_sys_prefs();
-}
-if (get_company_pref('default_receival_required') === null) { // new in 2.4 installations
-       set_company_pref('default_receival_required', 'glsetup.purchase', 'smallint', 6, '10');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('default_quote_valid_days') === null) { // available from 2.3.23, can be not defined on pre-2.4 installations
-       set_company_pref('default_quote_valid_days', 'glsetup.sales', 'smallint', 6, 30);
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('no_zero_lines_amount') === null) { // new in 2.4 installations
-       set_company_pref('no_zero_lines_amount', 'glsetup.sales', 'tinyint', 1, '1');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('show_po_item_codes') === null) { // new in 2.4 installations
-       set_company_pref('show_po_item_codes', 'glsetup.purchase', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('accounts_alpha') === null) { // new in 2.4 installations
-       set_company_pref('accounts_alpha', 'glsetup.general', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('loc_notification') === null) { // new in 2.4 installations
-       set_company_pref('loc_notification', 'glsetup.inventory', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('print_invoice_no') === null) { // new in 2.4 installations
-       set_company_pref('print_invoice_no', 'glsetup.sales', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('allow_negative_prices') === null) { // new in 2.4 installations
-       set_company_pref('allow_negative_prices', 'glsetup.inventory', 'tinyint', 1, '1');
-       refresh_sys_prefs();
-}
-
-if (get_company_pref('print_item_images_on_quote') === null) { // new in 2.4 installations
-       set_company_pref('print_item_images_on_quote', 'glsetup.inventory', 'tinyint', 1, '0');
-       refresh_sys_prefs();
-}
-
 $myrow = get_company_prefs();
 
 $_POST['retained_earnings_act']  = $myrow["retained_earnings_act"];
index 631df8205430b5879044ef644efde46d7d073c2b..880e24b9ff87afc7a75f1f71c42bafcec2f87e56 100644 (file)
@@ -207,6 +207,8 @@ class fa_patch {
 */
 function get_site_status($connections)
 {
+               global $SysPrefs;
+
                $info = array();
 
                foreach($connections as $i => $conn)
@@ -221,7 +223,7 @@ function get_site_status($connections)
                        }
                }
                set_global_connection();
-               refresh_sys_prefs();
+               $SysPrefs->refresh();
 
                return $info;
 }
index 622745ce7ab166a8056928d7fd0c55aacc205e19..f6417e4547fd03ea117a27893aeb0beb2543652c 100644 (file)
@@ -14,7 +14,7 @@ define('SQL_MODE', ''); // STRICT_ALL_TABLES,NO_ZERO_IN_DATE ?
 
 function set_global_connection($company=-1)
 {
-       global $db, $path_to_root, $db_connections;
+       global $db, $path_to_root, $db_connections, $SysPrefs;
 
        include ($path_to_root . "/config_db.php");
        if ($company == -1) 
@@ -35,6 +35,7 @@ function set_global_connection($company=-1)
        ///// We are, however, investigating the existing code to be compatible in the future.
                db_query("SET sql_mode = '".SQL_MODE."'");
        /////
+       $SysPrefs->refresh();
        return $db;
 }
 
index 65b4a339080000f143a5f6a94deb678f8e7ec041..0654c460e1ed2fd7b1a5f1b1a498d6bee7c93ff7 100644 (file)
@@ -16,7 +16,7 @@ $db_last_inserted_id = 0;
 
 function set_global_connection($company=-1)
 {
-       global $db, $path_to_root, $db_connections;
+       global $db, $path_to_root, $db_connections, $SysPrefs;
 
        include ($path_to_root . "/config_db.php");
        if ($company == -1) 
@@ -37,7 +37,7 @@ function set_global_connection($company=-1)
        ///// We are, however, investigating the existing code to be compatible in the future.
                db_query("SET sql_mode = '".SQL_MODE."'");
        /////
-       refresh_sys_prefs();
+       $SysPrefs->refresh();
        return $db;
 }
 
index 9a8213c8ab01b11da8edf3b17bfef4a2f49865d3..cade4c2df8c93ab3f84f7d5d87c76697b5c989f8 100644 (file)
@@ -14,7 +14,7 @@ include_once($path_to_root . "/admin/db/company_db.inc");
 /*
        System and per company prefferences.
        Object is created only with site wide preffernces.
-       After user login refresh_company_prefs method have to be called to initialize company specific settings.
+       After user login refresh method have to be called to re-initialize company specific settings.
 */
 class sys_prefs 
 {
@@ -23,7 +23,7 @@ class sys_prefs
 
        function sys_prefs()
        {
-               global $path_to_root, $db_version;
+               global $path_to_root;
 
                // retrieve set system wide preferences
                include $path_to_root.'/config.default.php';
@@ -43,9 +43,9 @@ class sys_prefs
        }
 
        /*
-               Initialize company specific preferrencies.
+               Re-initialize company preferrencies.
        */
-       function refresh_company_prefs()
+       function refresh()
        {
                global $db_version;
 
index 65bc9929fa39c00b9d3695c0c48bdee400265170..d8a82f8bd0699087dae83f27ff70d1fc1bf3a6fb 100644 (file)
@@ -559,7 +559,7 @@ if (!defined('FA_LOGOUT_PHP_FILE')){
                if (db_fixed())
                        db_set_encoding($_SESSION['language']->encoding);
 
-               $SysPrefs->refresh_company_prefs();
+               $SysPrefs->refresh();
        }
        if (!isset($_SESSION["App"])) {
                $_SESSION["App"] = new front_accounting();
index e2bf6278ca48e068b41b182828db9c393f0bee2c..b2546519ba003817cf4e78bf599e45f4976aff81 100644 (file)
@@ -208,3 +208,17 @@ UPDATE `0_trans_tax_details` reg
        SET reg.reg_type=0
        WHERE reg.trans_type IN(10, 11);
 
+INSERT IGNORE INTO `0_sys_prefs` VALUES
+       ('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0),
+       ('default_receival_required', 'glsetup.purchase', 'smallint', 6, '10'),
+       ('default_quote_valid_days', 'glsetup.sales', 'smallint', 6, 30),
+       ('no_zero_lines_amount', 'glsetup.sales', 'tinyint', 1, '1'),
+       ('show_po_item_codes', 'glsetup.purchase', 'tinyint', 1, '0'),
+       ('accounts_alpha', 'glsetup.general', 'tinyint', 1, '0'),
+       ('loc_notification', 'glsetup.inventory', 'tinyint', 1, '0'),
+       ('print_invoice_no', 'glsetup.sales', 'tinyint', 1, '0'),
+       ('allow_negative_prices', 'glsetup.inventory', 'tinyint', 1, '1'),
+       ('print_item_images_on_quote', 'glsetup.inventory', 'tinyint', 1, '0'),
+       ('bcc_email', 'setup.company', 'varchar', 100, ''),
+       ('alternative_tax_include_on_docs', 'setup.company', 'tinyint', 1, '0'),
+       ('suppress_tax_rates', 'setup.company', 'tinyint', 1, '0');