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."));
}
$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();
global $SysPrefs, $db_version;
if (!isset($SysPrefs->prefs)) // just after first login or reset
- $SysPrefs->refresh_company_prefs();
+ $SysPrefs->refresh();
$all = $SysPrefs->prefs;
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');
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"];
*/
function get_site_status($connections)
{
+ global $SysPrefs;
+
$info = array();
foreach($connections as $i => $conn)
}
}
set_global_connection();
- refresh_sys_prefs();
+ $SysPrefs->refresh();
return $info;
}
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)
///// We are, however, investigating the existing code to be compatible in the future.
db_query("SET sql_mode = '".SQL_MODE."'");
/////
+ $SysPrefs->refresh();
return $db;
}
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)
///// 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;
}
/*
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
{
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';
}
/*
- Initialize company specific preferrencies.
+ Re-initialize company preferrencies.
*/
- function refresh_company_prefs()
+ function refresh()
{
global $db_version;
if (db_fixed())
db_set_encoding($_SESSION['language']->encoding);
- $SysPrefs->refresh_company_prefs();
+ $SysPrefs->refresh();
}
if (!isset($_SESSION["App"])) {
$_SESSION["App"] = new front_accounting();
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');