$pref = $this->companies[$company]['tbpref'];
db_query("DROP TABLE IF EXISTS " . $pref . 'wo_costing');
db_query("DROP TABLE IF EXISTS " . $pref . 'stock_fa_class');
+ db_query("DELETE FROM ".$pref."sys_prefs
+ WHERE `name` in (
+ 'gl_closing_date', 'deferred_income_act', 'no_zero_lines_amount', 'accounts_alpha',
+ 'tax_algorithm', 'grn_clearing_act', 'default_receival_required',
+ 'default_quote_valid_days', 'no_zero_lines_amount', 'show_po_item_codes', 'accounts_alpha',
+ 'loc_notification', 'print_invoice_no', 'allow_negative_prices', 'print_item_images_on_quote',
+ 'bcc_email', 'alternative_tax_include_on_docs', 'suppress_tax_rates')");
}
function update_workorders()
global $db;
$sql = "SELECT DISTINCT type, type_no, tran_date, person_id FROM ".TB_PREF."gl_trans WHERE `type`=".ST_WORKORDER
- ." AND person_type_id=1";
+ ." AND person_type_id=1";
$res = db_query($sql);
if (!$res)
return $this->log_error(sprintf(_("Cannot update work orders costs:\n%s"), db_error_msg($db)));
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');
$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)"));
+
+ table_section_title(_("Manufacturing"));
+ gl_all_accounts_list_row(_("Work In Progress Account:"), 'wip_act', '1530',
+ true, false, _("None (will be set later)"));
+ end_row();
+ end_table();
+ br();
+ }
+
+ /*
+ Fetches selected upgrade parameters.
+ */
+ function prepare()
+ {
+ $this->wip_account = get_post('wip_act');
+ $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.
'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->wip_act)
+ ." WHERE name='wip_act'")
+ || !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;
}
{
$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',
+ 'wip_act')");
}
}
ALTER TABLE `0_stock_master` ADD COLUMN `fa_class_id` varchar(20) NOT NULL DEFAULT '' AFTER `depreciation_date`;
ALTER TABLE `0_stock_master` CHANGE `actual_cost` `purchase_cost` double NOT NULL default 0;
-INSERT INTO `0_sys_prefs` VALUES ('default_loss_on_asset_disposal_act', 'glsetup.items', 'varchar', '15', '5660');
-INSERT INTO `0_sys_prefs` VALUES ('depreciation_period', 'glsetup.company', 'tinyint', '1', '1');
-
-INSERT INTO `0_sys_prefs` VALUES ('use_manufacturing','setup.company', 'tinyint', 1, '1');
-INSERT INTO `0_sys_prefs` VALUES ('use_fixed_assets','setup.company', 'tinyint', 1, '1');
+INSERT IGNORE INTO `0_sys_prefs` VALUES
+ ('default_loss_on_asset_disposal_act', 'glsetup.items', 'varchar', '15', '5660'),
+ ('depreciation_period', 'glsetup.company', 'tinyint', '1', '1'),
+ ('use_manufacturing','setup.company', 'tinyint', 1, '1'),
+ ('use_fixed_assets','setup.company', 'tinyint', 1, '1'),
+ ('wip_act', 'glsetup.manuf', 'varchar', '15', '');