X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fprefs%2Fsysprefs.inc;h=34e52bccb706a0d7355096ab7a288c87efbf31fe;hb=a67b9dfc9f6932d5fe64ae21758f86bdb9250df2;hp=733a18b1dcbf4f73448e278d38a983e628b91977;hpb=2250f142e1034dc28adb819c4d8f7cce05911489;p=fa-stable.git diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index 733a18b1..34e52bcc 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -11,21 +11,73 @@ ***********************************************************************/ 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 method have to be called to re-initialize company specific settings. +*/ class sys_prefs { - + var $prefs; + var $db_ok; // check whether database has been upgraded after src update. + + function __construct() + { + global $path_to_root; + + // retrieve set system wide preferences + include $path_to_root.'/config.default.php'; + if (file_exists($path_to_root.'/config.php')) + include $path_to_root.'/config.php'; + + foreach(get_defined_vars() as $name => $value) + $this->$name = $value; + + if (!@$this->time_zone) + $this->time_zone = ini_get('date.timezone'); + + 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); + } + + /* + Re-initialize company preferrencies. + */ + function refresh() + { + global $db_version; + + $sql = "SELECT name, value FROM ".TB_PREF."sys_prefs"; + $result = @db_query($sql); // supress errors before 2.3 db structure upgrade + + if(!$result) + return null; + + while($pref = db_fetch_assoc($result)) { + $this->prefs[$pref['name']] = $pref['value']; + } + + // update current db status for info in log file + $this->db_ok = $this->prefs['version_id'] == $db_version; + } + function allow_negative_stock() { - return get_company_pref('allow_negative_stock'); + return $this->prefs['allow_negative_stock']; } - + /* Sherifoz 26.06.03 Proportion by which items can be received over the quantity that is specified in a purchase invoice The figure entered is interpreted as a percentage ie 10 means 0.1 or 10% not 10 times */ function over_receive_allowance() { - return get_company_pref('po_over_receive'); + return $this->prefs['po_over_receive']; } /* Proportion by which a purchase invoice line is an overcharge for a purchase order item received @@ -35,36 +87,103 @@ class sys_prefs */ function over_charge_allowance() { - return get_company_pref('po_over_charge'); + return $this->prefs['po_over_charge']; } function default_credit_limit() { - return get_company_pref('default_credit_limit'); + return $this->prefs['default_credit_limit']; } function default_wo_required_by() { - return get_company_pref('default_workorder_required'); + return $this->prefs['default_workorder_required']; + } + + function default_quote_valid_days() + { + return $this->prefs['default_quote_valid_days']; } function default_delivery_required_by() { - return get_company_pref('default_delivery_required'); - return 1; + return $this->prefs['default_delivery_required']; + } + + function default_receival_required_by() + { + return $this->prefs['default_receival_required']; } function default_dimension_required_by() { - return get_company_pref('default_dim_required'); + return $this->prefs['default_dim_required']; + } + + function auto_currency_revaluation() + { + return $this->prefs['auto_curr_reval']; } function allocation_settled_allowance() { - global $config_allocation_settled_allowance; - return $config_allocation_settled_allowance; + return $this->config_allocation_settled_allowance; + } + + function no_zero_lines_amount() + { + return $this->prefs['no_zero_lines_amount']; + } + + function show_po_item_codes() + { + return $this->prefs['show_po_item_codes']; + } + + function accounts_alpha() + { + return $this->prefs['accounts_alpha']; + } + + function loc_notification() + { + return $this->prefs['loc_notification']; + } + + function print_invoice_no() + { + return $this->prefs['print_invoice_no']; + } + + function allow_negative_prices() + { + return $this->prefs['allow_negative_prices']; + } + + function print_item_images_on_quote() + { + return $this->prefs['print_item_images_on_quote']; + } + + function alternative_tax_include_on_docs() + { + return $this->prefs['alternative_tax_include_on_docs']; + } + + function suppress_tax_rates() + { + return $this->prefs['suppress_tax_rates']; + } + + function backup_dir($comp=null) + { + if (!isset($comp)) + $comp = user_company(); + + if (isset($this->backup_path)) + return sprintf($this->backup_path, $comp); + else + return $this->comp_path.'/'.$comp."/backup/"; } - } -?> \ No newline at end of file