System preferences moved form company to new sys_prefs table
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 23 Jan 2010 18:32:04 +0000 (18:32 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 23 Jan 2010 18:32:04 +0000 (18:32 +0000)
15 files changed:
admin/company_preferences.php
admin/db/company_db.inc
admin/db/users_db.inc
admin/display_prefs.php
admin/gl_setup.php
admin/users.php
includes/current_user.inc
includes/prefs/sysprefs.inc
includes/prefs/userprefs.inc
includes/session.inc
sql/alter2.1.php
sql/alter2.3.php
sql/alter2.3.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 3ee19edbc7a493be95e19e3763c7ecd0d95cf7ef..44abcc2c987bdd11203fa647bdd811e2bc7f67c4 100644 (file)
@@ -106,15 +106,15 @@ if (isset($_POST['update']) && $_POST['update'] != "")
                $_POST['round_to'] = 1;
        if ($input_error != 1)
        {
-               update_company_setup($_POST['coy_name'], $_POST['coy_no'], 
-                       $_POST['gst_no'], $_POST['tax_prd'], $_POST['tax_last'],
-                       $_POST['postal_address'], $_POST['phone'], $_POST['fax'], 
-                       $_POST['email'], $_POST['coy_logo'], $_POST['domicile'],
-                       $_POST['use_dimension'], $_POST['curr_default'], $_POST['f_year']
-                       check_value('no_item_list'), check_value('no_customer_list')
-                       check_value('no_supplier_list'), $_POST['base_sales'], 
-                       check_value('time_zone'), $_POST['add_pct'], $_POST['round_to'],
-                       $_POST['login_tout']);
+               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', 
+                               'no_item_list' => 0, 'no_customer_list' => 0
+                               'no_supplier_list' =>0, 'base_sales'
+                               'time_zone' => 0, 'add_pct', 'round_to', 'login_tout'))
+               );
+
                $_SESSION['wa_current_user']->timeout = $_POST['login_tout'];
                display_notification_centered(_("Company setup has been updated."));
        }
index 22fc2d20d8e90a2984e9ec10548ac0d58b8bebfd..75d89eae034fda36bdd62960cbb371dab7a4e065 100644 (file)
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-
-function update_company_gl_setup($retained_act, $profit_loss_act, $debtors_act, $pyt_discount_act, $creditors_act,
-               $freight_act,
-               $exchange_diff_act,
-               $bank_charge_act,
-               $default_sales_act,
-               $default_sales_discount_act,
-               $default_prompt_payment_act,
-               $default_inventory_act,
-               $default_cogs_act,
-               $default_adj_act,
-               $default_inv_sales_act,
-               $default_assembly_act,
-               $allow_negative_stock,
-               $po_over_receive,
-               $po_over_charge,
-               $accumulate_shipping,
-               $legal_text,
-               $past_due_days,
-               $default_credit_limit,
-               $default_workorder_required,
-               $default_dim_required,
-               $default_delivery_required)
+/*
+       Update main or gl company setup.
+*/
+function update_company_prefs( $params )
 {
-       $sql = "UPDATE ".TB_PREF."company SET
-               retained_earnings_act=".db_escape($retained_act).", profit_loss_year_act=".db_escape($profit_loss_act).",
-               debtors_act=".db_escape($debtors_act).", pyt_discount_act=".db_escape($pyt_discount_act).",
-               creditors_act=".db_escape($creditors_act).",
-               freight_act=".db_escape($freight_act).",
-               exchange_diff_act=".db_escape($exchange_diff_act).",
-               bank_charge_act=".db_escape($bank_charge_act).",
-               default_sales_act=".db_escape($default_sales_act).",
-               default_sales_discount_act=".db_escape($default_sales_discount_act).",
-               default_prompt_payment_act=".db_escape($default_prompt_payment_act).",
-               default_inventory_act=".db_escape($default_inventory_act).",
-               default_cogs_act=".db_escape($default_cogs_act).",
-               default_adj_act=".db_escape($default_adj_act).",
-               default_inv_sales_act=".db_escape($default_inv_sales_act).",
-               default_assembly_act=".db_escape($default_assembly_act).",
-               allow_negative_stock=$allow_negative_stock,
-               po_over_receive=$po_over_receive,
-               po_over_charge=$po_over_charge,
-               accumulate_shipping=$accumulate_shipping,
-               legal_text=".db_escape($legal_text).",
-               past_due_days=$past_due_days,
-               default_credit_limit=$default_credit_limit,
-               default_workorder_required=$default_workorder_required,
-               default_dim_required=$default_dim_required,
-               default_delivery_required=$default_delivery_required
-               WHERE coy_code=1";
-
-       db_query($sql, "The company gl setup could not be updated ");
-}
-
-function update_company_setup($coy_name, $coy_no, $gst_no, $tax_prd, $tax_last, 
-       $postal_address, $phone, $fax, $email, $coy_logo, $domicile, $Dimension, 
-       $curr_default, $f_year, $no_item_list, $no_customer_list, $no_supplier_list, 
-       $base_sales, $time_zone, $add_pct, $round_to, $login_tout)
-{
-       if ($f_year == null)
-               $f_year = 0;
-       $sql = "UPDATE ".TB_PREF."company SET coy_name=".db_escape($coy_name).",
-               coy_no = ".db_escape($coy_no).",
-               gst_no=".db_escape($gst_no).",
-               tax_prd=$tax_prd,
-               tax_last=$tax_last,
-               postal_address =".db_escape($postal_address).",
-               phone=".db_escape($phone).", fax=".db_escape($fax).",
-               email=".db_escape($email).",
-               coy_logo=".db_escape($coy_logo).",
-               domicile=".db_escape($domicile).",
-               use_dimension=$Dimension,
-               no_item_list=$no_item_list,
-               no_customer_list=$no_customer_list,
-               no_supplier_list=$no_supplier_list,
-               curr_default=".db_escape($curr_default).",
-               f_year=$f_year,
-               base_sales=$base_sales,
-               time_zone=$time_zone,
-               add_pct=$add_pct,
-               round_to=$round_to,
-               login_tout = ".db_escape($login_tout)."
-               WHERE coy_code=1";
-
-       db_query($sql, "The company setup could not be updated ");
+       $sql = "UPDATE ".TB_PREF."sys_prefs SET value = ";
+       foreach($params as $name => $value) {
+               if (!db_query($sql. db_escape($value). " WHERE name=".db_escape($name),
+                        "The company prefferences could not be updated "))
+                       return false;
+       }
+       return true;
 }
-
-function get_company_prefs($tbpref = TB_PREF)
+/*
+       Get company preferences. Returns cached values from global variable SysPrefs
+       or retrieved from database if SysPrefs values are not set.
+       $prefs can be preference name, array of names, or null for all preferences.
+       
+*/
+function get_company_pref($prefs = null, $tbpref = TB_PREF)
 {
-       $sql = "SELECT * FROM ".$tbpref."company WHERE coy_code=1";
+       global $SysPrefs, $core_version;
        
-       $result = db_query($sql, "The company preferences could not be retrieved");
+       if (!isset($_SESSION['SysPrefs']->prefs)) { // cached preferences
 
-       if (db_num_rows($result) == 0)
-               display_db_error("FATAL : Could not find company prefs", $sql);
+               $_SESSION['SysPrefs'] = new sys_prefs();
 
-       return db_fetch($result);
+               $sql = "SELECT name, value FROM ".$tbpref."sys_prefs";
+               $result = @db_query($sql); // supress errors before 2.3 db structure upgrade
+
+               if(!$result)
+                       return null;
+
+               while($pref = db_fetch_assoc($result)) {
+                       $_SESSION['SysPrefs']->prefs[$pref['name']] = $pref['value'];
+               }
+
+               $SysPrefs = &$_SESSION['SysPrefs'];
+
+               // update current db status for info in log file
+               $SysPrefs->db_ok = $SysPrefs->prefs['version_id'] == $core_version;
+       }
+
+       $all = $_SESSION['SysPrefs']->prefs;
+
+       if (!$prefs)
+               return $all;
+       elseif (is_string($prefs))
+               return $all[$prefs];
+
+       $ret = array();
+       foreach($prefs as $name)
+               $ret[$name] = $all[$name];
+
+               return $ret;
 }
 
-function get_company_pref($pref_name, $tbpref = TB_PREF)
+function get_company_prefs($tbpref = TB_PREF)
 {
-       $prefs = get_company_prefs($tbpref);
-       return $prefs[$pref_name];
+       return get_company_pref(null, $tbpref);
 }
 
 function get_base_sales_type()
index c0bd02b152b315a00f9dfac2b43e3879c7377b9a..00acb48e2dc71c1919a2a4c1d3fabf6b48943961 100644 (file)
@@ -54,35 +54,15 @@ function update_user($id, $user_id, $real_name, $phone, $email, $role_id,
 
 //-----------------------------------------------------------------------------------------------
 
-function update_user_display_prefs($id, $price_dec, $qty_dec, $exrate_dec, 
-       $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, 
-       $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, 
-       $graphic_links, $lang, $stickydate, $startup_tab)
+function update_user_prefs($id, $prefs)
 {
-       $sql = "UPDATE ".TB_PREF."users SET
-               prices_dec=".db_escape($price_dec).",
-               qty_dec=".db_escape($qty_dec).",
-               rates_dec=".db_escape($exrate_dec).",
-               percent_dec=".db_escape($percent_dec).",
-               show_gl=".db_escape($showgl).",
-               show_codes=".db_escape($showcodes).",
-               date_format=".db_escape($date_format).",
-               date_sep=".db_escape($date_sep).",
-               tho_sep=".db_escape($tho_sep).",
-               dec_sep=".db_escape($dec_sep).",
-               theme=".db_escape($theme).",
-               page_size=".db_escape($pagesize).",
-               show_hints=".db_escape($show_hints).",
-               print_profile=".db_escape($profile).",
-               rep_popup=".db_escape($rep_popup).",
-               query_size=".db_escape($query_size).",
-               graphic_links=".db_escape($graphic_links).",
-               language=".db_escape($lang).",
-               sticky_doc_date=".db_escape($stickydate).",
-               startup_tab=".db_escape($startup_tab)."
-               WHERE id = ".db_escape($id);
-
-       db_query($sql, "could not update user display prefs for $id");
+       $sql = "UPDATE ".TB_PREF."users SET ";
+       foreach($prefs as $name => $value) {
+               $prefs[$name] = $name.'='. db_escape($value);
+       }
+       $sql .= implode(',', $prefs) . " WHERE id=".db_escape($id);
+
+       return db_query($sql, "could not update user display prefs for $id");
 }
 
 //-----------------------------------------------------------------------------------------------
index 4374df3a6fcbab9dcf20b2ef0cc1a9a65a3675c4..228987cb26ea11c5d82584dede86cc72e1b27e73 100644 (file)
@@ -33,16 +33,13 @@ if (isset($_POST['setprefs']))
                $chg_theme = user_theme() != $_POST['theme'];
                $chg_lang = $_SESSION['language']->code != $_POST['language'];
 
-               set_user_prefs($_POST['prices'], $_POST['Quantities'],
-                       $_POST['Rates'], $_POST['Percent'],
-                       check_value('show_gl'),
-                       check_value('show_codes'),
-                       $_POST['date_format'], $_POST['date_sep'],
-                       $_POST['tho_sep'], $_POST['dec_sep'],
-                       $_POST['theme'], $_POST['page_size'], check_value('show_hints'),
-                       $_POST['profile'], check_value('rep_popup'), 
-                       (int)($_POST['query_size']), check_value('graphic_links'), 
-                       $_POST['language'], check_value('sticky_doc_date'), $_POST['startup_tab']);
+               set_user_prefs(get_post( 
+                       array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec',
+                       'date_format', 'date_sep', 'tho_sep', 'dec_sep', 'print_profile', 
+                       'theme', 'page_size', 'language', 'startup_tab',
+                       'show_gl' => 0, 'show_codes'=> 0, 'show_hints' => 0,
+                       'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0,
+                       'query_size' => 10.0)));
 
                if ($chg_lang)
                        $_SESSION['language']->set_language($_POST['language']);
@@ -71,10 +68,10 @@ start_outer_table($table_style2);
 table_section(1);
 table_section_title(_("Decimal Places"));
 
-text_row_ex(_("Prices/Amounts:"), 'prices', 5, 5, '', user_price_dec());
-text_row_ex(_("Quantities:"), 'Quantities', 5, 5, '', user_qty_dec());
-text_row_ex(_("Exchange Rates:"), 'Rates', 5, 5, '', user_exrate_dec());
-text_row_ex(_("Percentages:"), 'Percent',  5, 5, '', user_percent_dec());
+text_row_ex(_("Prices/Amounts:"), 'prices_dec', 5, 5, '', user_price_dec());
+text_row_ex(_("Quantities:"), 'qty_dec', 5, 5, '', user_qty_dec());
+text_row_ex(_("Exchange Rates:"), 'rates_dec', 5, 5, '', user_exrate_dec());
+text_row_ex(_("Percentages:"), 'percent_dec',  5, 5, '', user_percent_dec());
 
 table_section_title(_("Dateformat and Separators"));
 
@@ -122,10 +119,10 @@ tab_list_row(_("Start-up Tab"), 'startup_tab', user_startup_tab());
 /* The array $pagesizes is set up in config.php for modifications
 possible separators can be added by modifying the array definition by editing that file */
 
-if (!isset($_POST['profile']))
-       $_POST['profile'] = user_print_profile();
+if (!isset($_POST['print_profile']))
+       $_POST['print_profile'] = user_print_profile();
 
-print_profiles_list_row(_("Printing profile"). ':', 'profile', 
+print_profiles_list_row(_("Printing profile"). ':', 'print_profile', 
        null, _('Browser printing support'));
 
 check_row(_("Use popup window to display reports:"), 'rep_popup', user_rep_popup(),
index 48e67c4ba5805f2676a3f402f67908bcdafd0d5d..ddd2b8e2640d72a07df22852d00f39983d107976 100644 (file)
@@ -52,28 +52,16 @@ function can_process()
 
 if (isset($_POST['submit']) && can_process())
 {
-       update_company_gl_setup($_POST['retained_earnings_act'], $_POST['profit_loss_year_act'],
-               $_POST['debtors_act'], $_POST['pyt_discount_act'],
-               $_POST['creditors_act'], $_POST['freight_act'],
-               $_POST['exchange_diff_act'], $_POST['bank_charge_act'],
-               $_POST['default_sales_act'],
-               $_POST['default_sales_discount_act'],
-               $_POST['default_prompt_payment_act'],
-               $_POST['default_inventory_act'],
-               $_POST['default_cogs_act'],
-               $_POST['default_adj_act'],
-               $_POST['default_inv_sales_act'],
-               $_POST['default_assembly_act'],
-               check_value('allow_negative_stock'),
-               input_num('po_over_receive'),
-               input_num('po_over_charge'),
-               check_value('accumulate_shipping'),
-               $_POST['legal_text'],
-               $_POST['past_due_days'],
-               $_POST['default_credit_limit'],
-               $_POST['default_workorder_required'],
-               $_POST['default_dim_required'],
-               $_POST['default_delivery_required']);
+       update_company_prefs( get_post( array( 'retained_earnings_act', 'profit_loss_year_act',
+               'debtors_act', 'pyt_discount_act', 'creditors_act', 'freight_act',
+               'exchange_diff_act', 'bank_charge_act', 'default_sales_act', 'default_sales_discount_act',
+               'default_prompt_payment_act', 'default_inventory_act', 'default_cogs_act',
+               'default_adj_act', 'default_inv_sales_act', 'default_assembly_act', 'legal_text',
+               'past_due_days', 'default_workorder_required', 'default_dim_required',
+               'default_delivery_required',
+               'allow_negative_stock'=> 0, 'accumulate_shipping'=> 0,
+               'po_over_receive' => 0.0, 'po_over_charge' => 0.0, 'default_credit_limit'=>0.0
+)));
 
        display_notification(_("The general GL setup has been updated."));
 
index 52058b298df7d36a3d12bc6f7d5e995b2847d5db..5d56aff15c844c9709cce9d5bafa683afab77f01 100644 (file)
@@ -62,9 +62,9 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        {
        if ($selected_id != -1) 
        {
-               update_user($selected_id, $_POST['user_id'], $_POST['real_name'], $_POST['phone'],
-                       $_POST['email'], $_POST['Access'], $_POST['language'], 
-                               $_POST['profile'], check_value('rep_popup'), $_POST['pos']);
+               update_user_prefs($selected_id,
+                       get_post(array('user_id', 'real_name', 'phone', 'email', 'role_id', 'language',
+                                       'print_profile', 'rep_popup' => 0, 'pos')));
 
                if ($_POST['password'] != "")
                        update_user_password($selected_id, $_POST['user_id'], md5($_POST['password']));
@@ -74,16 +74,14 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        else 
        {
                add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']),
-                               $_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language'],
-                               $_POST['profile'], check_value('rep_popup'), $_POST['pos']);
+                               $_POST['phone'], $_POST['email'], $_POST['role_id'], $_POST['language'],
+                               $_POST['print_profile'], check_value('rep_popup'), $_POST['pos']);
                        $id = db_insert_id();
                        // use current user display preferences as start point for new user
-                       update_user_display_prefs($id, user_price_dec(), user_qty_dec(), user_exrate_dec(), 
-                               user_percent_dec(), user_show_gl_info(), user_show_codes(), 
-                               user_date_format(), user_date_sep(), user_tho_sep(), 
-                               user_dec_sep(), user_theme(), user_pagesize(), user_hints(), 
-                               $_POST['profile'], check_value('rep_popup'), user_query_size(), 
-                               user_graphic_links(), $_POST['language'], sticky_doc_date(), user_startup_tab());
+                       $prefs = $_SESSION['wa_current_user']->prefs->get_all();
+                       
+                       update_user_prefs($id, array_merge($prefs, get_post(array('print_profile',
+                               'rep_popup' => 0, 'language'))));
 
                        display_notification_centered(_("A new user has been added."));
        }
@@ -169,9 +167,9 @@ if ($selected_id != -1)
                $_POST['real_name'] = $myrow["real_name"];
                $_POST['phone'] = $myrow["phone"];
                $_POST['email'] = $myrow["email"];
-               $_POST['Access'] = $myrow["role_id"];
+               $_POST['role_id'] = $myrow["role_id"];
                $_POST['language'] = $myrow["language"];
-               $_POST['profile'] = $myrow["print_profile"];
+               $_POST['print_profile'] = $myrow["print_profile"];
                $_POST['rep_popup'] = $myrow["rep_popup"];
                $_POST['pos'] = $myrow["pos"];
        }
@@ -185,7 +183,7 @@ else
 { //end of if $selected_id only do the else when a new record is being entered
        text_row(_("User Login:"), "user_id",  null, 22, 20);
        $_POST['language'] = user_language();
-       $_POST['profile'] = user_print_profile();
+       $_POST['print_profile'] = user_print_profile();
        $_POST['rep_popup'] = user_rep_popup();
        $_POST['pos'] = user_pos();
 }
@@ -206,13 +204,13 @@ text_row_ex(_("Telephone No.:"), 'phone', 30);
 
 email_row_ex(_("Email Address:"), 'email', 50);
 
-security_roles_list_row(_("Access Level:"), 'Access', null); 
+security_roles_list_row(_("Access Level:"), 'role_id', null); 
 
 languages_list_row(_("Language:"), 'language', null);
 
 pos_list_row(_("User's POS"). ':', 'pos', null);
 
-print_profiles_list_row(_("Printing profile"). ':', 'profile', null,
+print_profiles_list_row(_("Printing profile"). ':', 'print_profile', null,
        _('Browser printing support'));
 
 check_row(_("Use popup window for reports:"), 'rep_popup', $_POST['rep_popup'],
index bca45f0875cdcd589a6430b5b701498979e04d67..408addb427866289ae329ffa8de4ccdcd2396849 100644 (file)
@@ -167,33 +167,15 @@ class current_user
        return $db;
        }
 
-       function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, 
-               $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, 
-               $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, 
-               $graphic_links, $lang, $stickydate, $startup_tab)
+       function update_prefs($prefs)
        {
                global $allow_demo_mode;
-
-               $user = array(
-                       'prices_dec' => $price_dec,     'qty_dec' => $qty_dec,
-                       'rates_dec' => $exrate_dec,             'percent_dec' => $percent_dec,
-                       'show_gl' => $showgl,                   'show_codes' => $showcodes,
-                       'date_format' => $date_format,  'date_sep' => $date_sep,
-                       'tho_sep' => $tho_sep,                  'dec_sep' => $dec_sep,
-                       'theme' => $theme,                              'page_size' => $pagesize,
-                       'show_hints' => $show_hints,    'print_profile' => $profile,
-                       'rep_popup' => $rep_popup,              'query_size' => $query_size,
-                       'graphic_links' => $graphic_links,      'language' => $lang,
-                       'sticky_doc_date' => $stickydate,       'startup_tab' => $startup_tab
-               );
-
+               
                if(!$allow_demo_mode) {
-                       update_user_display_prefs($this->user, $price_dec, 
-                               $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, 
-                               $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, 
-                               $show_hints, $profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab);
+                       update_user_prefs($this->user, $prefs);
                }
-               $this->prefs = new user_prefs($user);
+
+               $this->prefs = new user_prefs($prefs);
        }
 }
 
@@ -412,14 +394,9 @@ function user_startup_tab()
        return $_SESSION["wa_current_user"]->prefs->start_up_tab();
 }
 
-function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
-       $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints,
-       $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab)
+function set_user_prefs($prefs)
 {
-
-       $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes,
-               $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints,
-               $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab);
+       $_SESSION["wa_current_user"]->update_prefs($prefs);
 }
 
 function add_user_js_data() {
index f8e782826386d78afcec9e0fc7a7dbf44a852f9e..7b738ad3729707ef6d783cb8fef24ca91b5bdfe6 100644 (file)
@@ -13,10 +13,18 @@ include_once($path_to_root . "/admin/db/company_db.inc");
 
 class sys_prefs 
 {
+       var $prefs;
+       var $db_ok; // check whether database has been upgraded after src update.
+
+       function sys_prefs()
+       {
+//             $this->prefs = get_company_prefs();
+       
+       }
        
        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
@@ -25,7 +33,7 @@ class sys_prefs
     */
        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,27 +43,27 @@ 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_delivery_required_by() 
        {
-               return get_company_pref('default_delivery_required');
+               return $this->prefs['default_delivery_required'];
        }
 
        function default_dimension_required_by() 
        {
-               return get_company_pref('default_dim_required');
+               return $this->prefs['default_dim_required'];
        }       
        
        function allocation_settled_allowance()
index 93f941807bc40143a16205270a8805eb6895259f..50fa0a8811e1b5cf3a32a220dcae1179ff0a1746 100644 (file)
@@ -84,7 +84,32 @@ class user_prefs
                        }
                }
        }
-
+       
+       function get_all()
+       {
+                       return array(
+                       'language' => $this->language,
+                       'qty_dec' => $this->qty_dec,
+                       'prices_dec' => $this->price_dec,
+                       'rates_dec' => $this->exrate_dec,
+                       'percent_dec' => $this->percent_dec,
+                       'show_gl' => $this->show_gl_info,
+                       'show_codes' => $this->show_codes,
+                       'date_format' =>$this->date_format,
+                       'date_sep' => $this->date_sep,
+                       'tho_sep' => $this->tho_sep,
+                       'dec_sep' => $this->dec_sep,
+                       'theme' => $this->theme,
+                       'page_size' => $this->pagesize,
+                       'show_hints' => $this->show_hints,
+                       'print_profile' => $this->print_profile,
+                       'rep_popup' => $this->rep_popup,
+                       'query_size' => $this->query_size,
+                       'graphic_links' => $this->graphic_links,
+                       'sticky_doc_date' => $this->sticky_date,
+                       'startup_tab' => $this->startup_tab);
+       }
+       
        function language() 
        {
                return $this->language;
index 8929ff2e4341e83a777b7e75ebd4fb7d76e8789c..f6ac6b26ce8bbcba0e29b98c605b6fc8f819476a 100644 (file)
@@ -51,6 +51,10 @@ function login_fail()
 
 function check_page_security($page_security)
 {
+       global $SysPrefs;
+       
+       $msg = '';
+       
        if (!$_SESSION["wa_current_user"]->check_user_access())
        {
                // notification after upgrade from pre-2.2 version
@@ -58,7 +62,11 @@ function check_page_security($page_security)
                         _("Security settings have not been defined for your user account.")
                                . "<br>" . _("Please contact your system administrator.")       
                        : _("Please remove \$security_groups and \$security_headings arrays from config.php file!");
-
+       } elseif (!$_SESSION['SysPrefs']->db_ok && !$_SESSION["wa_current_user"]->can_access('SA_SOFTWAREUPGRADE')) {
+               $msg = _('Access to application has been blocked until database upgrade is completed by system administrator.');
+       }
+       
+       if ($msg){
                display_error($msg);
                end_page();
                kill_login();
@@ -75,6 +83,14 @@ function check_page_security($page_security)
                end_page();
                exit;
        }
+       if (!$_SESSION['SysPrefs']->db_ok 
+               && !in_array($page_security, array('SA_SOFTWAREUPGRADE', 'SA_OPEN', 'SA_BACKUP')))
+       {
+               display_error(_('System is blocked after source upgrade until database is updated on System/Software Upgrade page'));
+               end_page();
+               exit;
+       }
+
 }
 /*
        Helper function for setting page security level depeding on 
@@ -147,6 +163,7 @@ include_once($path_to_root . "/includes/lang/language.php");
 include_once($path_to_root . "/config_db.php");
 include_once($path_to_root . "/includes/ajax.inc");
 include_once($path_to_root . "/includes/ui/ui_msgs.inc");
+include_once($path_to_root . "/includes/prefs/sysprefs.inc");
 
 /*
        Uncomment the setting below when using FA on shared hosting
@@ -196,8 +213,6 @@ $Editors = array();
 // page help. Currently help for function keys.
 $Pagehelp = array();
 
-$SysPrefs = new sys_prefs();
-
 $Refs = new references();
 
 // intercept all output to destroy it in case of ajax call
@@ -257,6 +272,7 @@ if (strstr($_SERVER['PHP_SELF'], 'logout.php') == false){
        }
 }
 
+$SysPrefs = &$_SESSION['SysPrefs'];
 
 // POST vars cleanup needed for direct reuse.
 // We quote all values later with db_escape() before db update.
index fae78321cf033afef1f53f61c4ca41eac340fd47..ff9467a292f4fa1e3446f3008e5cfa7a3c3d3335 100644 (file)
@@ -150,9 +150,9 @@ class fa2_1 {
        //      Test if patch was applied before.
        //
        function installed($pref) {
-               $n = 5; // number of features to be installed
+               $n = 4; // number of features to be installed
                if (!check_table($pref, 'item_codes')) $n--;
-               if (!check_table($pref, 'company', 'foreign_codes')) $n--;
+//             if (!check_table($pref, 'company', 'foreign_codes')) $n--;
                if (!check_table($pref, 'suppliers', 'credit_limit')) $n--;
                if (!check_table($pref, 'bank_trans', 'reconciled', 
                        array('Type'=>'date'))) $n--;
index 07e84e44a2f49f0c5cdb09001332c94f6940b9a5..338729246b9da887d7f6049f835aeed4cbc4183f 100644 (file)
@@ -26,7 +26,10 @@ class fa2_3 {
        //
        function install($pref, $force) 
        {
-               return true;
+               // remove old prefereces table after upgrade script has been executed
+               $sql = "DROP TABLE IF EXISTS `".$pref."company`";
+
+               return db_query($sql) && update_company_prefs(array('version_id'=>'2.3'));
        }
        //
        //      Checking before install
@@ -39,10 +42,11 @@ class fa2_3 {
        //      Test if patch was applied before.
        //
        function installed($pref) {
-               $n = 1; // number of patches to be installed
+               $n = 2; // number of patches to be installed
                $patchcnt = 0;
 
                if (!check_table($pref, 'comments', 'type', array('Key'=>'MUL'))) $patchcnt++;
+               if (!check_table($pref, 'sys_prefs')) $patchcnt++;
 
                $n -= $patchcnt;
                return $n == 0 ? true : $patchcnt;
index 17984dd1589d7d31f6abd6411aea483cc8f8ecaa..84bea8314f067440789b20c63820328df9a6cba2 100644 (file)
@@ -37,3 +37,78 @@ ALTER TABLE 0_sales_order_details ADD KEY `sorder` (`trans_type`, `order_no`);
 ALTER TABLE 0_chart_master ADD KEY `accounts_by_type` (`account_type`, `account_code`);
 # fix invalid constraint on databases generated from 2.2 version on en_US-new.sql
 #ALTER TABLE `0_tax_types` DROP KEY `name`;
+
+DROP TABLE IF EXISTS `0_sys_prefs`;
+
+CREATE TABLE `0_sys_prefs` (
+  `name` varchar(35) NOT NULL default '',
+  `category` varchar(30),
+  `type` varchar(20) NOT NULL default '',
+  `length` smallint(6),
+  `value` tinytext NULL,
+  PRIMARY KEY  (`name`),
+  KEY (`category`)
+) TYPE=MyISAM;
+
+
+INSERT INTO `0_sys_prefs` SELECT 'coy_name','setup.company', 'varchar','60', c.coy_name FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'gst_no','setup.company', 'varchar','25', c.gst_no FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'coy_no','setup.company', 'varchar','25', c.coy_no FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'tax_prd','setup.company', 'int','11', c.tax_prd FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'tax_last','setup.company', 'int','11', c.tax_last FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'postal_address','setup.company', 'tinytext','', c.postal_address FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'phone','setup.company', 'varchar','30', c.phone FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'fax','setup.company', 'varchar','30',c.fax FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'email','setup.company', 'varchar','100', c.email FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'coy_logo','setup.company', 'varchar','100', c.coy_logo FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'domicile','setup.company', 'varchar','55', c.domicile FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'curr_default','setup.company', 'char','3', c.curr_default FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'use_dimension','setup.company', 'tinyint','1', c.use_dimension FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'f_year','setup.company', 'int','11', c.f_year FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'no_item_list','setup.company', 'tinyint','1', c.no_item_list FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'no_customer_list','setup.company', 'tinyint','1', c.no_customer_list FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'no_supplier_list','setup.company', 'tinyint','1', c.no_supplier_list FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'base_sales','setup.company', 'int','11', c.base_sales FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'time_zone','setup.company', 'tinyint','1', c.time_zone FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'add_pct','setup.company', 'int','5', c.add_pct FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'round_to','setup.company', 'int','5', c.round_to FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'login_tout','setup.company', 'smallint','6', c.login_tout FROM `0_company` c;
+#INSERT INTO `0_sys_prefs` SELECT 'foreign_codes','setup.company', 'tinyint','1', c.foreign_codes FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'past_due_days','glsetup.general', 'int','11', c.past_due_days FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'profit_loss_year_act','glsetup.general', 'varchar','11', c.profit_loss_year_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'retained_earnings_act','glsetup.general', 'varchar','11', c.retained_earnings_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'bank_charge_act','glsetup.general', 'varchar','11',  c.bank_charge_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'exchange_diff_act','glsetup.general', 'varchar','11', c.exchange_diff_act FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'default_credit_limit','glsetup.customer', 'int','11', c.default_credit_limit FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'accumulate_shipping','glsetup.customer', 'tinyint','1', c.accumulate_shipping FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'legal_text','glsetup.customer', 'tinytext','', c.legal_text FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'freight_act','glsetup.customer', 'varchar','11', c.freight_act FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'debtors_act','glsetup.sales', 'varchar','11', c.debtors_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_sales_act','glsetup.sales', 'varchar','11', c.default_sales_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_sales_discount_act','glsetup.sales', 'varchar','11', c.default_sales_discount_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_prompt_payment_act','glsetup.sales', 'varchar','11', c.default_prompt_payment_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_delivery_required','glsetup.sales', 'smallint','6', c.default_delivery_required FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'default_dim_required','glsetup.dims', 'int','11', c.default_dim_required FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'pyt_discount_act','glsetup.purchase', 'varchar','11', c.pyt_discount_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'creditors_act','glsetup.purchase', 'varchar','11', c.creditors_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'po_over_receive','glsetup.purchase', 'int','11', c.po_over_receive FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'po_over_charge','glsetup.purchase', 'int','11', c.po_over_charge FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'allow_negative_stock','glsetup.inventory', 'tinyint','1', c.allow_negative_stock FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'default_inventory_act','glsetup.items', 'varchar','11', c.default_inventory_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_cogs_act','glsetup.items', 'varchar','11', c.default_cogs_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_adj_act','glsetup.items', 'varchar','11', c.default_adj_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_inv_sales_act','glsetup.items', 'varchar','11', c.default_inv_sales_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'default_assembly_act','glsetup.items', 'varchar','11', c.default_assembly_act FROM `0_company` c;
+
+INSERT INTO `0_sys_prefs` SELECT 'default_workorder_required','glsetup.manuf', 'int', '11', c.default_workorder_required FROM `0_company` c;
+
+#INSERT INTO `0_sys_prefs` SELECT 'payroll_act','glsetup.payroll', 'varchar','11', c.payroll_act FROM `0_company` c;
+INSERT INTO `0_sys_prefs` SELECT 'version_id', 'system', 'varchar', '11', c.version_id FROM `0_company` c;
+
index 7c8e5be3d2e83eee5d3509d219115beea7bf8672..1e9d9255874d1f2f094efe11621be3d04aa800fa 100644 (file)
@@ -1762,6 +1762,74 @@ INSERT INTO `0_suppliers` VALUES ('1', 'Junk Beer ApS', 'Junk Beer', 'Mailing 1\
 INSERT INTO `0_suppliers` VALUES ('2', 'Lucky Luke Inc.', 'Lucky Luke', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '(111) 222.333.444', '', '', '654321', 'Luke', '333', '', '', '', 'USD', '3', '0', '0', '1', '1', '5010', '2100', '5060', '', '0');
 INSERT INTO `0_suppliers` VALUES ('3', 'Money Makers Ltd.', 'Money Makers', 'Mailing 1\r\nMailing 2\r\nMailing 3', 'Address 1\r\nAddress 2\r\nAddress 3', '+44 444 555 666', '', '', '987654', 'Makers', '222', '', '', '', 'GBP', '3', '0', '0', '2', '1', '5010', '2100', '5060', '', '0');
 
+### Structure of table `0_sys_prefs` ###
+
+DROP TABLE IF EXISTS `0_sys_prefs`;
+
+CREATE TABLE `0_sys_prefs` (
+  `name` varchar(35) NOT NULL default '',
+  `category` varchar(30) default NULL,
+  `type` varchar(20) NOT NULL default 'varchar',
+  `length` smallint(6) default NULL,
+  `value` tinytext,
+  PRIMARY KEY  (`name`),
+  KEY `category` (`category`)
+) TYPE=MyISAM;
+
+
+### Data of table `0_sys_prefs` ###
+
+INSERT INTO `0_sys_prefs` VALUES ('coy_name', 'setup.company', 'varchar', '60', 'Training Co.');
+INSERT INTO `0_sys_prefs` VALUES ('gst_no', 'setup.company', 'varchar', '25', '9876543');
+INSERT INTO `0_sys_prefs` VALUES ('coy_no', 'setup.company', 'varchar', '25', '123456789');
+INSERT INTO `0_sys_prefs` VALUES ('tax_prd', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('tax_last', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('postal_address', 'setup.company', 'tinytext', '0', 'Address 1\r\nAddress 2\r\nAddress 3');
+INSERT INTO `0_sys_prefs` VALUES ('phone', 'setup.company', 'varchar', '30', '(222) 111.222.333');
+INSERT INTO `0_sys_prefs` VALUES ('fax', 'setup.company', 'varchar', '30', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('email', 'setup.company', 'varchar', '100', 'delta@delta.com');
+INSERT INTO `0_sys_prefs` VALUES ('coy_logo', 'setup.company', 'varchar', '100', 'logo_frontaccounting.jpg');
+INSERT INTO `0_sys_prefs` VALUES ('domicile', 'setup.company', 'varchar', '55', NULL);
+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', '2');
+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');
+INSERT INTO `0_sys_prefs` VALUES ('base_sales', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('time_zone', 'setup.company', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('add_pct', 'setup.company', 'int', '5', '-1');
+INSERT INTO `0_sys_prefs` VALUES ('round_to', 'setup.company', 'int', '5', '1');
+INSERT INTO `0_sys_prefs` VALUES ('login_tout', 'setup.company', 'smallint', '6', '600');
+INSERT INTO `0_sys_prefs` VALUES ('past_due_days', 'glsetup.general', 'int', '11', '30');
+INSERT INTO `0_sys_prefs` VALUES ('profit_loss_year_act', 'glsetup.general', 'varchar', '11', '9990');
+INSERT INTO `0_sys_prefs` VALUES ('retained_earnings_act', 'glsetup.general', 'varchar', '11', '3590');
+INSERT INTO `0_sys_prefs` VALUES ('bank_charge_act', 'glsetup.general', 'varchar', '11', '5690');
+INSERT INTO `0_sys_prefs` VALUES ('exchange_diff_act', 'glsetup.general', 'varchar', '11', '4450');
+INSERT INTO `0_sys_prefs` VALUES ('default_credit_limit', 'glsetup.customer', 'int', '11', '1000');
+INSERT INTO `0_sys_prefs` VALUES ('accumulate_shipping', 'glsetup.customer', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('legal_text', 'glsetup.customer', 'tinytext', '0', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('freight_act', 'glsetup.customer', 'varchar', '11', '4430');
+INSERT INTO `0_sys_prefs` VALUES ('debtors_act', 'glsetup.sales', 'varchar', '11', '1200');
+INSERT INTO `0_sys_prefs` VALUES ('default_sales_act', 'glsetup.sales', 'varchar', '11', '4010');
+INSERT INTO `0_sys_prefs` VALUES ('default_sales_discount_act', 'glsetup.sales', 'varchar', '11', '4510');
+INSERT INTO `0_sys_prefs` VALUES ('default_prompt_payment_act', 'glsetup.sales', 'varchar', '11', '4500');
+INSERT INTO `0_sys_prefs` VALUES ('default_delivery_required', 'glsetup.sales', 'smallint', '6', '1');
+INSERT INTO `0_sys_prefs` VALUES ('default_dim_required', 'glsetup.dims', 'int', '11', '20');
+INSERT INTO `0_sys_prefs` VALUES ('pyt_discount_act', 'glsetup.purchase', 'varchar', '11', '5060');
+INSERT INTO `0_sys_prefs` VALUES ('creditors_act', 'glsetup.purchase', 'varchar', '11', '2100');
+INSERT INTO `0_sys_prefs` VALUES ('po_over_receive', 'glsetup.purchase', 'int', '11', '10');
+INSERT INTO `0_sys_prefs` VALUES ('po_over_charge', 'glsetup.purchase', 'int', '11', '10');
+INSERT INTO `0_sys_prefs` VALUES ('allow_negative_stock', 'glsetup.inventory', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('default_inventory_act', 'glsetup.items', 'varchar', '11', '1510');
+INSERT INTO `0_sys_prefs` VALUES ('default_cogs_act', 'glsetup.items', 'varchar', '11', '5010');
+INSERT INTO `0_sys_prefs` VALUES ('default_adj_act', 'glsetup.items', 'varchar', '11', '5040');
+INSERT INTO `0_sys_prefs` VALUES ('default_inv_sales_act', 'glsetup.items', 'varchar', '11', '4010');
+INSERT INTO `0_sys_prefs` VALUES ('default_assembly_act', 'glsetup.items', 'varchar', '11', '1530');
+INSERT INTO `0_sys_prefs` VALUES ('default_workorder_required', 'glsetup.manuf', 'int', '11', '20');
+INSERT INTO `0_sys_prefs` VALUES ('version_id', 'system', 'varchar', '11', '2.3');
+
+
 
 ### Structure of table `0_sys_types` ###
 
index 46e2248ce4bd115e568442c1d6d057835e052d4c..921ac774759eaf2094fb2adcd3d875c88fe00583 100644 (file)
@@ -1541,6 +1541,73 @@ CREATE TABLE `0_suppliers` (
 ### Data of table `0_suppliers` ###
 
 
+### Structure of table `0_sys_prefs` ###
+
+DROP TABLE IF EXISTS `0_sys_prefs`;
+
+CREATE TABLE `0_sys_prefs` (
+  `name` varchar(35) NOT NULL default '',
+  `category` varchar(30) default NULL,
+  `type` varchar(20) NOT NULL default 'varchar',
+  `length` smallint(6) default NULL,
+  `value` tinytext,
+  PRIMARY KEY  (`name`),
+  KEY `category` (`category`)
+) TYPE=MyISAM;
+
+
+### Data of table `0_sys_prefs` ###
+
+INSERT INTO `0_sys_prefs` VALUES ('coy_name', 'setup.company', 'varchar', '60', 'Company name');
+INSERT INTO `0_sys_prefs` VALUES ('gst_no', 'setup.company', 'varchar', '25', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('coy_no', 'setup.company', 'varchar', '25', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('tax_prd', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('tax_last', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('postal_address', 'setup.company', 'tinytext', '0', 'N/A');
+INSERT INTO `0_sys_prefs` VALUES ('phone', 'setup.company', 'varchar', '30', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('fax', 'setup.company', 'varchar', '30', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('email', 'setup.company', 'varchar', '100', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('coy_logo', 'setup.company', 'varchar', '100', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('domicile', 'setup.company', 'varchar', '55', NULL);
+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 ('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');
+INSERT INTO `0_sys_prefs` VALUES ('base_sales', 'setup.company', 'int', '11', '1');
+INSERT INTO `0_sys_prefs` VALUES ('time_zone', 'setup.company', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('add_pct', 'setup.company', 'int', '5', '-1');
+INSERT INTO `0_sys_prefs` VALUES ('round_to', 'setup.company', 'int', '5', '1');
+INSERT INTO `0_sys_prefs` VALUES ('login_tout', 'setup.company', 'smallint', '6', '600');
+INSERT INTO `0_sys_prefs` VALUES ('past_due_days', 'glsetup.general', 'int', '11', '30');
+INSERT INTO `0_sys_prefs` VALUES ('profit_loss_year_act', 'glsetup.general', 'varchar', '11', '9990');
+INSERT INTO `0_sys_prefs` VALUES ('retained_earnings_act', 'glsetup.general', 'varchar', '11', '3590');
+INSERT INTO `0_sys_prefs` VALUES ('bank_charge_act', 'glsetup.general', 'varchar', '11', '5690');
+INSERT INTO `0_sys_prefs` VALUES ('exchange_diff_act', 'glsetup.general', 'varchar', '11', '4450');
+INSERT INTO `0_sys_prefs` VALUES ('default_credit_limit', 'glsetup.customer', 'int', '11', '1000');
+INSERT INTO `0_sys_prefs` VALUES ('accumulate_shipping', 'glsetup.customer', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('legal_text', 'glsetup.customer', 'tinytext', '0', NULL);
+INSERT INTO `0_sys_prefs` VALUES ('freight_act', 'glsetup.customer', 'varchar', '11', '4430');
+INSERT INTO `0_sys_prefs` VALUES ('debtors_act', 'glsetup.sales', 'varchar', '11', '1200');
+INSERT INTO `0_sys_prefs` VALUES ('default_sales_act', 'glsetup.sales', 'varchar', '11', '4010');
+INSERT INTO `0_sys_prefs` VALUES ('default_sales_discount_act', 'glsetup.sales', 'varchar', '11', '4510');
+INSERT INTO `0_sys_prefs` VALUES ('default_prompt_payment_act', 'glsetup.sales', 'varchar', '11', '4500');
+INSERT INTO `0_sys_prefs` VALUES ('default_delivery_required', 'glsetup.sales', 'smallint', '6', '1');
+INSERT INTO `0_sys_prefs` VALUES ('default_dim_required', 'glsetup.dims', 'int', '11', '20');
+INSERT INTO `0_sys_prefs` VALUES ('pyt_discount_act', 'glsetup.purchase', 'varchar', '11', '5060');
+INSERT INTO `0_sys_prefs` VALUES ('creditors_act', 'glsetup.purchase', 'varchar', '11', '2100');
+INSERT INTO `0_sys_prefs` VALUES ('po_over_receive', 'glsetup.purchase', 'int', '11', '10');
+INSERT INTO `0_sys_prefs` VALUES ('po_over_charge', 'glsetup.purchase', 'int', '11', '10');
+INSERT INTO `0_sys_prefs` VALUES ('allow_negative_stock', 'glsetup.inventory', 'tinyint', '1', '0');
+INSERT INTO `0_sys_prefs` VALUES ('default_inventory_act', 'glsetup.items', 'varchar', '11', '1510');
+INSERT INTO `0_sys_prefs` VALUES ('default_cogs_act', 'glsetup.items', 'varchar', '11', '5010');
+INSERT INTO `0_sys_prefs` VALUES ('default_adj_act', 'glsetup.items', 'varchar', '11', '5040');
+INSERT INTO `0_sys_prefs` VALUES ('default_inv_sales_act', 'glsetup.items', 'varchar', '11', '4010');
+INSERT INTO `0_sys_prefs` VALUES ('default_assembly_act', 'glsetup.items', 'varchar', '11', '1530');
+INSERT INTO `0_sys_prefs` VALUES ('default_workorder_required', 'glsetup.manuf', 'int', '11', '20');
+INSERT INTO `0_sys_prefs` VALUES ('version_id', 'system', 'varchar', '11', '2.3');
+
 
 ### Structure of table `0_sys_types` ###