Added audit trail, changed users primary key, some smaler fixes.
[fa-stable.git] / sql / alter2.2.php
index 7a9ca410205c82f3c2008260db660fcfb33c3969..72a26840713d4475567153e67b46748fbd84c976 100644 (file)
@@ -20,7 +20,27 @@ class fa2_2 {
        function install($pref, $force) 
        {
                global $db;
-                               
+               // set item category dflt accounts to values from company GL setup
+               $prefs = get_company_prefs();
+               $sql = "UPDATE {$pref}stock_category SET "
+                       ."dflt_sales_act = '" . $prefs['default_inv_sales_act'] . "',"
+                       ."dflt_cogs_act = '". $prefs['default_cogs_act'] . "',"
+                       ."dflt_inventory_act = '" . $prefs['default_inventory_act'] . "',"
+                       ."dflt_adjustment_act = '" . $prefs['default_adj_act'] . "',"
+                       ."dflt_assembly_act = '" . $prefs['default_assembly_act']."'";
+               if (db_query($sql)==false) {
+                       display_error("Cannot update category default GL accounts"
+                       .':<br>'. db_error_msg($db));
+                       return false;
+               }
+/*     FIX
+               // add audit_trail data for all transactions
+               $datatbl = array ("gl_trans", "purch_orders", "sales_orders",
+                       "workorders");
+               $sql = "INSERT INTO ".$pref."audit_trail"
+               ." (type, trans_no, user, fiscal_year, gl_date) VALUES ("
+               . "$type,$trans_no,$user,$year,$date)";
+*/
                return true;
        }
        //
@@ -35,7 +55,10 @@ class fa2_2 {
        //
        function installed($pref) {
                if (check_table($pref, 'company', 'default_delivery_required')) return false;
-               return true;
+               if (check_table($pref, 'stock_category', 'dflt_dim2')) return false;
+               if (check_table($pref, 'users', 'sticky_doc_date')) return false;
+               if (check_table($pref, 'audit_trail')) return false;
+                       return true;
        }
 };