Removed company custom fields, added default delivery required by
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 17 Mar 2009 11:13:24 +0000 (11:13 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 17 Mar 2009 11:13:24 +0000 (11:13 +0000)
setting.

admin/company_preferences.php
admin/db/company_db.inc
admin/gl_setup.php
includes/prefs/sysprefs.inc
sql/alter2.2.php [new file with mode: 0644]
sql/alter2.2.sql [new file with mode: 0644]
sql/en_US-demo.sql
sql/en_US-new.sql

index d020398a8bd94937751d10ec5b36a8fe23c9d8f6..ac5eb4496e74d5ad3c20ff00a84b4a1255f50c6a 100644 (file)
@@ -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)") . ":", "<input type='file' id='pic' name='pic'>");
@@ -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']);
index 672d95458e6335a58d82570f6a0876e32a673f6c..1215229a755a054dea33b3b010ce29ca811bfe10 100644 (file)
@@ -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
index 1a7efae9b078d83620cc82d318f8ab4c78a230e0..354e76c22d1d44330bc237fca68aacf491ff2522 100644 (file)
@@ -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"));
index 2b59f33cbd34a17fd471ccfdd4ee7c891590da34..733a18b1dcbf4f73448e278d38a983e628b91977 100644 (file)
@@ -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 (file)
index 0000000..7a9ca41
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+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 (file)
index 0000000..119331c
--- /dev/null
@@ -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';
index 8b80ee29b093cba6bcfdb9fd2aa2d8156f5798b1..845dbdcfb7133a4250613c6c8168a61632287d37 100644 (file)
@@ -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` ###
index cda5540a1cc8aa50146727174899674f21669d9f..5ec88861c419276bf889069c878ad00ab4565fee 100644 (file)
@@ -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` ###