From 2250f142e1034dc28adb819c4d8f7cce05911489 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 17 Mar 2009 11:13:24 +0000 Subject: [PATCH] Removed company custom fields, added default delivery required by setting. --- admin/company_preferences.php | 42 ++++++++-------------------------- admin/db/company_db.inc | 20 +++++++--------- admin/gl_setup.php | 6 ++++- includes/prefs/sysprefs.inc | 4 ++-- sql/alter2.2.php | 43 +++++++++++++++++++++++++++++++++++ sql/alter2.2.sql | 8 +++++++ sql/en_US-demo.sql | 9 ++------ sql/en_US-new.sql | 9 ++------ 8 files changed, 80 insertions(+), 61 deletions(-) create mode 100644 sql/alter2.2.php create mode 100644 sql/alter2.2.sql diff --git a/admin/company_preferences.php b/admin/company_preferences.php index d020398a..ac5eb449 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -95,11 +95,12 @@ if (isset($_POST['update']) && $_POST['update'] != "") } 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['custom1_name'], $_POST['custom2_name'], $_POST['custom3_name'], - $_POST['custom1_value'], $_POST['custom2_value'], $_POST['custom3_value'], - $_POST['curr_default'], $_POST['f_year'], check_value('no_item_list'), check_value('no_customer_list'), + 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']); display_notification_centered(_("Company setup has been updated.")); @@ -131,12 +132,6 @@ $_POST['base_sales'] = $myrow["base_sales"]; $_POST['no_item_list'] = $myrow["no_item_list"]; $_POST['no_customer_list'] = $myrow["no_customer_list"]; $_POST['no_supplier_list'] = $myrow["no_supplier_list"]; -$_POST['custom1_name'] = $myrow["custom1_name"]; -$_POST['custom2_name'] = $myrow["custom2_name"]; -$_POST['custom3_name'] = $myrow["custom3_name"]; -$_POST['custom1_value'] = $myrow["custom1_value"]; -$_POST['custom2_value'] = $myrow["custom2_value"]; -$_POST['custom3_value'] = $myrow["custom3_value"]; $_POST['curr_default'] = $myrow["curr_default"]; $_POST['f_year'] = $myrow["f_year"]; $_POST['del_coy_logo'] = 0; @@ -146,7 +141,7 @@ start_outer_table($table_style2); table_section(1); text_row_ex(_("Name (to appear on reports):"), 'coy_name', 42, 50); -textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 35, 5); +textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 35, 6); text_row_ex(_("Phone Number:"), 'phone', 25, 55); text_row_ex(_("Fax Number:"), 'fax', 25); @@ -155,13 +150,13 @@ email_row_ex(_("Email Address:"), 'email', 25, 55); text_row_ex(_("Official Company Number:"), 'coy_no', 25); text_row_ex(_("GSTNo:"), 'gst_no', 25); -text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.')); -text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.')); - currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']); table_section(2); +text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.')); +text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.')); + fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']); label_row(_("Company Logo:"), $_POST['coy_logo']); label_row(_("New Company Logo (.jpg)") . ":", ""); @@ -178,23 +173,6 @@ check_row(_("Search Supplier List"), 'no_supplier_list', $_POST['no_supplier_lis start_row(); end_row(); -label_row(_("Custom Field Name"), _("Custom Field Value")); - -start_row(); -text_cells(null, 'custom1_name', $_POST['custom1_name'], 25, 25); -text_cells(null, 'custom1_value', $_POST['custom1_value'], 30, 30); -end_row(); - -start_row(); -text_cells(null, 'custom2_name', $_POST['custom2_name'], 25, 25); -text_cells(null, 'custom2_value', $_POST['custom2_value'], 30, 30); -end_row(); - -start_row(); -text_cells(null, 'custom3_name', $_POST['custom3_name'], 25, 25); -text_cells(null, 'custom3_value', $_POST['custom3_value'], 30, 30); -end_row(); - end_outer_table(1); hidden('coy_logo', $_POST['coy_logo']); diff --git a/admin/db/company_db.inc b/admin/db/company_db.inc index 672d9545..1215229a 100644 --- a/admin/db/company_db.inc +++ b/admin/db/company_db.inc @@ -29,7 +29,8 @@ function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act $past_due_days, $default_credit_limit, $default_workorder_required, - $default_dim_required) + $default_dim_required, + $default_delivery_required) { $sql = "UPDATE ".TB_PREF."company SET debtors_act=".db_escape($debtors_act).", pyt_discount_act=".db_escape($pyt_discount_act).", @@ -52,16 +53,17 @@ function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act 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_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, $custom1_name, $custom2_name, $custom3_name, - $custom1_value, $custom2_value, $custom3_value, $curr_default, $f_year, $no_item_list, $no_customer_list, - $no_supplier_list, $base_sales) +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) { if ($f_year == null) $f_year = 0; @@ -79,12 +81,6 @@ function update_company_setup($coy_name, $coy_no, $gst_no, $tax_prd, $tax_last, no_item_list=$no_item_list, no_customer_list=$no_customer_list, no_supplier_list=$no_supplier_list, - custom1_name=".db_escape($custom1_name).", - custom2_name=".db_escape($custom2_name).", - custom3_name=".db_escape($custom3_name).", - custom1_value=".db_escape($custom1_value).", - custom2_value=".db_escape($custom2_value).", - custom3_value=".db_escape($custom3_value).", curr_default=".db_escape($curr_default).", f_year=$f_year, base_sales=$base_sales diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 1a7efae9..354e76c2 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -71,7 +71,8 @@ if (isset($_POST['submit']) && can_process()) $_POST['past_due_days'], $_POST['default_credit_limit'], $_POST['default_workorder_required'], - $_POST['default_dim_required']); + $_POST['default_dim_required'], + $_POST['default_delivery_required']); display_notification(_("The general GL setup has been updated.")); @@ -116,6 +117,7 @@ $_POST['accumulate_shipping'] = $myrow['accumulate_shipping']; $_POST['default_workorder_required'] = $myrow['default_workorder_required']; $_POST['default_dim_required'] = $myrow['default_dim_required']; +$_POST['default_delivery_required'] = $myrow['default_delivery_required']; //--------------- @@ -156,6 +158,8 @@ gl_all_accounts_list_row(_("Sales Discount Account:"), 'default_sales_discount_a gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'default_prompt_payment_act'); +text_row(_("Delivery Required By:"), 'default_delivery_required', $_POST['default_delivery_required'], 6, 6, '', "", _("days")); + //---------------- table_section_title(_("Dimension Defaults")); diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index 2b59f33c..733a18b1 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -49,8 +49,8 @@ class sys_prefs } function default_delivery_required_by() - { // FIX this in next major release -// return get_company_pref('default_delivery_required'); + { + return get_company_pref('default_delivery_required'); return 1; } diff --git a/sql/alter2.2.php b/sql/alter2.2.php new file mode 100644 index 00000000..7a9ca410 --- /dev/null +++ b/sql/alter2.2.php @@ -0,0 +1,43 @@ +. +***********************************************************************/ +class fa2_2 { + var $version = '2.2'; // version installed + var $description = 'Version 2.2'; + var $sql = 'alter2.2.sql'; + // + // Install procedure. All additional changes + // not included in sql file should go here. + // + function install($pref, $force) + { + global $db; + + return true; + } + // + // Checking before install + // + function pre_check($pref) + { + return true; // true when ok, fail otherwise + } + // + // Test if patch was applied before. + // + function installed($pref) { + if (check_table($pref, 'company', 'default_delivery_required')) return false; + return true; + } +}; + +$install = new fa2_2; +?> \ No newline at end of file diff --git a/sql/alter2.2.sql b/sql/alter2.2.sql new file mode 100644 index 00000000..119331c2 --- /dev/null +++ b/sql/alter2.2.sql @@ -0,0 +1,8 @@ +ALTER TABLE `0_company` DROP COLUMN `custom1_name`; +ALTER TABLE `0_company` DROP COLUMN `custom2_name`; +ALTER TABLE `0_company` DROP COLUMN `custom3_name`; +ALTER TABLE `0_company` DROP COLUMN `custom1_value`; +ALTER TABLE `0_company` DROP COLUMN `custom2_value`; +ALTER TABLE `0_company` DROP COLUMN `custom3_value`; + +ALTER TABLE `0_company` ADD COLUMN `default_delivery_required` SMALLINT(6) DEFAULT '1'; diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 8b80ee29..845dbdcf 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -347,12 +347,6 @@ CREATE TABLE `0_company` ( `default_inv_sales_act` varchar(11) NOT NULL default '', `default_assembly_act` varchar(11) NOT NULL default '', `payroll_act` varchar(11) NOT NULL default '', - `custom1_name` varchar(60) NOT NULL default '', - `custom2_name` varchar(60) NOT NULL default '', - `custom3_name` varchar(60) NOT NULL default '', - `custom1_value` varchar(100) NOT NULL default '', - `custom2_value` varchar(100) NOT NULL default '', - `custom3_value` varchar(100) NOT NULL default '', `allow_negative_stock` tinyint(1) NOT NULL default '0', `po_over_receive` int(11) NOT NULL default '10', `po_over_charge` int(11) NOT NULL default '10', @@ -369,13 +363,14 @@ CREATE TABLE `0_company` ( `foreign_codes` tinyint(1) NOT NULL default '0', `accumulate_shipping` tinyint(1) NOT NULL default '0', `legal_text` tinytext NOT NULL, + `default_delivery_required` smallint(6) NOT NULL default '1', PRIMARY KEY (`coy_code`) ) TYPE=MyISAM ; ### Data of table `0_company` ### -INSERT INTO `0_company` VALUES ('1', 'Training Co.', '987654321', '123123123', '1', '1', 'N/A', '202-122320', '202-18889123', 'delta@delta.com', 'logo_frontaccounting.jpg', 'DownTown', 'USD', '1500', '4250', '2630', '1430', '4260', '4220', '2050', '3800', '3000', '3000', '3200', '1420', '4010', '4210', '3000', '1410', '5000', '', '', '', '', '', '', '0', '10', '10', '1000', '20', '20', '30', '1', '7', '0', '0', '0', '0', '0', '0', ''); +INSERT INTO `0_company` VALUES ('1', 'Training Co.', '987654321', '123123123', '1', '1', 'N/A', '202-122320', '202-18889123', 'delta@delta.com', 'logo_frontaccounting.jpg', 'DownTown', 'USD', '1500', '4250', '2630', '1430', '4260', '4220', '2050', '3800', '3000', '3000', '3200', '1420', '4010', '4210', '3000', '1410', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '7', '0', '0', '0', '0', '0', '0', '', '1'); ### Structure of table `0_credit_status` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index cda5540a..5ec88861 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -318,12 +318,6 @@ CREATE TABLE `0_company` ( `default_inv_sales_act` varchar(11) NOT NULL default '', `default_assembly_act` varchar(11) NOT NULL default '', `payroll_act` varchar(11) NOT NULL default '', - `custom1_name` varchar(60) NOT NULL default '', - `custom2_name` varchar(60) NOT NULL default '', - `custom3_name` varchar(60) NOT NULL default '', - `custom1_value` varchar(100) NOT NULL default '', - `custom2_value` varchar(100) NOT NULL default '', - `custom3_value` varchar(100) NOT NULL default '', `allow_negative_stock` tinyint(1) NOT NULL default '0', `po_over_receive` int(11) NOT NULL default '10', `po_over_charge` int(11) NOT NULL default '10', @@ -340,13 +334,14 @@ CREATE TABLE `0_company` ( `foreign_codes` tinyint(1) NOT NULL default '0', `accumulate_shipping` tinyint(1) NOT NULL default '0', `legal_text` tinytext NOT NULL, + `default_delivery_required` smallint(6) NOT NULL default '1', PRIMARY KEY (`coy_code`) ) TYPE=MyISAM ; ### Data of table `0_company` ### -INSERT INTO `0_company` VALUES ('1', 'Company name', '', '', '1', '1', 'N/A', '', '', '', '', '', 'USD', '1500', '4250', '2630', '1430', '4260', '4220', '2050', '3800', '3000', '3000', '3200', '1420', '4010', '4210', '3000', '1410', '5000', '', '', '', '', '', '', '0', '10', '10', '1000', '20', '20', '30', '1', '1', '0', '0', '0', '-1', '0', '0', ''); +INSERT INTO `0_company` VALUES ('1', 'Company name', '', '', '1', '1', 'N/A', '', '', '', '', '', 'USD', '1500', '4250', '2630', '1430', '4260', '4220', '2050', '3800', '3000', '3000', '3200', '1420', '4010', '4210', '3000', '1410', '5000', '0', '10', '10', '1000', '20', '20', '30', '1', '1', '0', '0', '0', '-1', '0', '0', '', '1'); ### Structure of table `0_credit_status` ### -- 2.30.2