Temporary fixes for php encoding library bugs ending with segfault.
[fa-stable.git] / sql / alter2.4rc1.php
index 02e17122d7c085be11ba3105ad7e17353a9e0cd2..66a029fbda63c6630099c92bafb5aa5d09389f38 100644 (file)
@@ -16,12 +16,37 @@ class fa2_4rc1 extends fa_patch {
        var $description;
        var $sql = ''; // 'alter2.4rc1.sql';
        var $preconf = true;
+       var     $max_upgrade_time = 900;        // table recoding is really long process
 
-       function fa2_4rc1() {
-               parent::fa_patch();
+       function __construct() {
+               parent::__construct();
                $this->description = _('Upgrade from version 2.4beta to 2.4RC1');
        }
 
+    /*
+           Shows parameters to be selected before upgrade (if any)
+       */
+    function show_params($comp)
+       {
+         display_note(_('Set optimal parameters and start upgrade:'));
+         start_table(TABLESTYLE);
+         start_row();
+               table_section_title(_("Fixed Assets Defaults"));
+               gl_all_accounts_list_row(_("Loss On Asset Disposal Account:"), 'default_loss_on_asset_disposal_act', '5660',
+                       true, false, _("None (will be set later)"));
+         end_row();
+         end_table();
+         br();
+    }
+
+       /*
+           Fetches selected upgrade parameters.
+    */
+       function prepare()
+    {
+               $this->fixed_disposal_act = get_post('default_loss_on_asset_disposal_act');
+               return true;
+       }
        //
        //      Install procedure. All additional changes 
        //      not included in sql file should go here.
@@ -36,6 +61,15 @@ class fa2_4rc1 extends fa_patch {
                                'SA_DEPRECIATION', 'SA_ASSETSANALYTIC'),
                );
                $result = $this->update_security_roles($sec_updates);
+
+               $pref = $this->companies[$company]['tbpref'];
+
+               if ($result)
+                       if (!db_query("UPDATE ".$pref."sys_prefs SET value=".db_escape($this->fixed_disposal_act)
+                                       ." WHERE name='default_loss_on_asset_disposal_act'")
+                       )
+                               return $this->log_error(sprintf(_("Cannot update sys prefs setting:\n%s"), db_error_msg($db)));
+
                return $result;
        }
 
@@ -46,6 +80,13 @@ class fa2_4rc1 extends fa_patch {
        {
                $pref = $this->companies[$company]['tbpref'];
                db_query("DROP TABLE IF EXISTS " . $pref . 'stock_fa_class');
+
+               db_query("DELETE FROM ".$pref."sys_prefs "
+                       ."WHERE `name` in (
+                               'default_loss_on_asset_disposal_act',
+                               'depreciation_period',
+                               'use_manufacturing',
+                               'use_fixed_assets')");
        }
 
 }