Added audit trail.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 3 May 2009 13:58:07 +0000 (13:58 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 3 May 2009 13:58:07 +0000 (13:58 +0000)
19 files changed:
gl/includes/db/gl_db_banking.inc
gl/includes/db/gl_db_trans.inc
includes/main.inc
inventory/includes/db/items_adjust_db.inc
inventory/includes/db/items_trans_db.inc
inventory/includes/db/items_transfer_db.inc
manufacturing/includes/db/work_order_issues_db.inc
manufacturing/includes/db/work_order_produce_items_db.inc
manufacturing/includes/db/work_orders_db.inc
manufacturing/includes/db/work_orders_quick_db.inc
purchasing/includes/db/grn_db.inc
purchasing/includes/db/po_db.inc
purchasing/includes/db/supp_trans_db.inc
sales/includes/db/cust_trans_db.inc
sales/includes/db/sales_order_db.inc
sql/alter2.2.php
sql/alter2.2.sql
sql/en_US-demo.sql
sql/en_US-new.sql

index 903b22b5ff0a24fe6bf3b96b0c1acedc07f14d83..981de46e9d4796d7db0ad86d50fc3ef9774c4110 100644 (file)
@@ -99,6 +99,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
        add_comments($trans_type, $trans_no, $date_, $memo_);
 
        references::save_last($ref, $trans_type);
+       add_audit_trail($trans_type, $trans_no, $date_);
 
        commit_transaction();
 
@@ -218,6 +219,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
        add_comments($trans_type, $trans_no, $date_, $memo_);
 
        references::save_last($ref, $trans_type);
+       add_audit_trail($trans_type, $trans_no, $date_);
 
        commit_transaction();
 
index 89eaa25243d6d1ace619fe56680326b4f0dfbbd6..eb9cf02f385f02135ed680e0f57faa5850437393 100644 (file)
@@ -338,6 +338,7 @@ function add_journal_entries($items, $date_, $ref, $reverse, $memo_=null)
        add_comments($trans_type, $trans_id, $date_, $memo_);
 
        references::save($trans_type, $trans_id, $ref);
+       add_audit_trail($trans_type, $trans_id, $date_);
 
        if ($reverse)
        {
@@ -364,12 +365,13 @@ function add_journal_entries($items, $date_, $ref, $reverse, $memo_=null)
                }
                        // store tax details if the gl account is a tax account
                        add_gl_tax_details($journal_item->code_id, 
-                               $trans_type, $trans_id, $journal_item->amount, 1, $date, $memo_);
+                               $trans_type, $trans_id, $journal_item->amount, 1, $reversingDate, $memo_);
        }
 
        add_comments($trans_type, $trans_id_reverse, $reversingDate, $memo_);
 
        references::save($trans_type, $trans_id_reverse, $ref);
+               add_audit_trail($trans_type, $trans_id_reverse, $reversingDate);
        }
 
        commit_transaction();
index 5d4371ba68d6c0efbfa1e2fdb52e7271db0f84be..4687f7070c0caf81215aa68642deee85271b0cea 100644 (file)
@@ -19,6 +19,7 @@ include_once($path_to_root . "/includes/references.inc");
 include_once($path_to_root . "/includes/prefs/sysprefs.inc");
 include_once($path_to_root . "/includes/db/comments_db.inc");
 include_once($path_to_root . "/includes/db/sql_functions.inc");
+include_once($path_to_root . "/includes/db/audit_trail_db.inc");
 
 include_once($path_to_root . "/admin/db/users_db.inc");
 include_once($path_to_root . "/includes/ui/ui_view.inc");
index 57f74bb53b8f8376db783ae2f5dd20fd5f83755d..61d130d5f01e6788379a127f319ec06813b261fb 100644 (file)
@@ -30,6 +30,7 @@ function add_stock_adjustment($items, $location, $date_, $type, $increase, $refe
        add_comments(systypes::inventory_adjustment(), $adj_id, $date_, $memo_);
 
        references::save_last($reference, systypes::inventory_adjustment());
+       add_audit_trail(systypes::inventory_adjustment(), $adj_id, $date_);
 
        commit_transaction();
 
index 9a16d7b3822aa7426a1e2d0b42ceaa88c82a994e..eb044cd7a2c6930e1135382ea6759d28dad573c5 100644 (file)
@@ -43,22 +43,23 @@ function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_co
                        $date_ = end_fiscalyear();
           
                $stock_gl_code = get_stock_gl_code($stock_id);
-        
+
                $new_cost = $material_cost + $labour_cost + $overhead_cost;
-         
+
                $value_of_change = $qoh * ($new_cost - $last_cost);
-          
+
                $memo_ = "Cost was " . $last_cost . " changed to " . $new_cost . " x quantity on hand of $qoh";
                add_gl_trans_std_cost(systypes::cost_update(), $update_no, $date_, $stock_gl_code["adjustment_account"], 
                        $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change));     
 
                add_gl_trans_std_cost(systypes::cost_update(), $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_, 
-                       $value_of_change);         
-       }                               
+                       $value_of_change);
+       }
 
+       add_audit_trail(systypes::cost_update(), $update_no, $date_);
        commit_transaction();
-       
-       return $update_no;              
+
+       return $update_no;
 }
 
 //-------------------------------------------------------------------------------------------------------------
index dc587e3d2c52c4ecd5f0635895aa2f956bec06a3..c1eac28b8538f06064d905963b1c684cf71a0f9c 100644 (file)
@@ -26,6 +26,7 @@ function add_stock_transfer($Items, $location_from, $location_to, $date_, $type,
        add_comments(systypes::location_transfer(), $transfer_id, $date_, $memo_);
 
        references::save_last($reference, systypes::location_transfer());
+       add_audit_trail(systypes::location_transfer(), $transfer_id, $date_);
 
        commit_transaction();
 
index 0df0684652b2e1987858f2cc9f8c79f36dacc724..a8fc6b1c95e95cfe1e7e5084d74c5e7de7599452 100644 (file)
@@ -59,6 +59,7 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w
                add_comments(28, $number, $date_, $memo_);
 
        references::save_last($ref, 28);
+       add_audit_trail(28, $number, $date_);
 
        commit_transaction();
 }
index 5b2dad2dbaba4f60b3d8e0192d910c8c9a3418dd..4419e7e23b2f702a7b9c7a804953d7ee63a90932 100644 (file)
@@ -54,6 +54,7 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo)
                add_comments(29, $id, $date_, $memo_);
 
        references::save_last($ref, 29);
+       add_audit_trail(29, $id, $date_, _("Production."));
 
        commit_transaction();
 }
index 5df4082ba5cf7c902f81c8da628e87e67a79c7b3..1c17ea86a5f9a4b886984200f8d13d07226c2f22 100644 (file)
@@ -60,6 +60,7 @@ function add_work_order($wo_ref, $loc_code, $units_reqd, $stock_id,
        add_comments(systypes::work_order(), $woid, $required_by, $memo_);
 
        references::save_last($wo_ref, systypes::work_order());
+       add_audit_trail(systypes::work_order(), $woid, $date_);
 
        commit_transaction();
 
@@ -88,6 +89,7 @@ function update_work_order($woid, $loc_code, $units_reqd, $stock_id,
        db_query($sql, "could not update work order");
 
        update_comments(systypes::work_order(), $woid, null, $memo_);
+       add_audit_trail(systypes::work_order(), $woid, $date_, _("Updated."));
 
        commit_transaction();
 }
@@ -106,6 +108,7 @@ function delete_work_order($woid)
        db_query($sql,"The work order could not be deleted");
 
        delete_comments(systypes::work_order(), $woid);
+       add_audit_trail(systypes::work_order(), $woid, $_POST['date_'], _("Canceled."));
 
        commit_transaction();
 }
@@ -181,6 +184,7 @@ function release_work_order($woid, $releaseDate, $memo_)
        create_wo_requirements($woid, $stock_id);
 
        add_comments(systypes::work_order(), $woid, $releaseDate, $memo_);
+       add_audit_trail(systypes::work_order(), $woid, $releaseDate,_("Released."));
 
        commit_transaction();
 }
index a2b3c1240a1b8fb759b7619f2d2eeb54278f4a68..8595b21066c4e56d632bc70f32297af6a96fb52d 100644 (file)
@@ -73,7 +73,7 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
        add_comments(systypes::work_order(), $woid, $date_, $memo_);
 
        references::save_last($wo_ref, systypes::work_order());
-
+       add_audit_trail(systypes::work_order(), $woid, $date_,_("Quick production."));
        commit_transaction();
        return $woid;
 }
index c0fdf54ac824bb3e3cdce1ef1ce7f461d1b1745d..df526f14fdb85328a45050dd04195bc39fe51058 100644 (file)
@@ -97,6 +97,8 @@ function add_grn(&$po, $date_, $reference, $location)
 
        references::save_last($reference, 25);
 
+       add_audit_trail(25, $grn, $date_);
+
        commit_transaction();
 
        return $grn;
index d3135f56c52c9d6ed6f11d3830fdadea549cf9bd..350b828086d0074c5ab21c43a2dc446c777dac70 100644 (file)
@@ -60,6 +60,7 @@ function add_po(&$po_obj)
 
        //add_comments(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments);
 
+       add_audit_trail(systypes::po(), systypes::po(), $po_obj->orig_order_date);
        commit_transaction();
 
        return $po_obj->order_no;
index 207cd7dcad108ff86a100bbe460a7307825b29a4..52071cc601cd55d32d716803e16c73cd39d2e8d2 100644 (file)
@@ -37,6 +37,7 @@ function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $sup
                $err_msg = "Cannot insert a supplier transaction record";
 
        db_query($sql, $err_msg);
+       add_audit_trail($type, $trans_no, $date_);
 
        return $trans_no;
 }
index 7beb733cde6559b7e728c79d6d0900bc011a77c2..fb98b62fe284ce0e5bf4e580b0c39efe19774035 100644 (file)
@@ -91,18 +91,18 @@ function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
        $sales_type=0, $order_no=0, $trans_link=0, $ship_via=0, $due_date="",
        $AllocAmt=0, $rate=0, $dimension_id=0, $dimension2_id=0)
 {
-
+       $new = $trans_no==0;
        $curr = get_customer_currency($debtor_no);
        if ($rate == 0)
                $rate = get_exchange_rate_from_home_currency($curr, $date_);
 
        $SQLDate = date2sql($date_);
        if ($due_date == "")
-               $SQLDueDate = "000-00-00";
+               $SQLDueDate = "0000-00-00";
        else
                $SQLDueDate = date2sql($due_date);
 
-       if ($trans_no==0) {
+       if ($new) {
        $trans_no = get_next_trans_no($trans_type);
 
        $sql = "INSERT INTO ".TB_PREF."debtor_trans (
@@ -134,6 +134,8 @@ function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
        }
        db_query($sql, "The debtor transaction record could not be inserted");
 
+       add_audit_trail($trans_type, $trans_no, $date_, $new ? '': _("Updated."));
+
        return $trans_no;
 }
 
index ef66b0b7d72166792bb172c49be19cbe4d26fa46..03b18e020b137955011250047d59c9d1a3835835 100644 (file)
@@ -128,6 +128,7 @@ function add_sales_order(&$order)
 
        } /* inserted line items into sales order details */
 
+       add_audit_trail(30, $order_no, $order->document_date);
        commit_transaction();
 
        if ($loc_notification == 1 && count($st_ids) > 0)
@@ -163,6 +164,7 @@ function delete_sales_order($order_no)
        $sql = "DELETE FROM ".TB_PREF."sales_order_details WHERE order_no =" . $order_no;
        db_query($sql, "order Detail Delete");
 
+       add_audit_trail(30, $order_no, Today(), _("Deleted."));
        commit_transaction();
 }
 
@@ -268,6 +270,7 @@ function update_sales_order($order)
 
        } /* inserted line items into sales order details */
 
+       add_audit_trail(30, $order_no, $order->document_date, _("Updated."));
        commit_transaction();
        if ($loc_notification == 1 && count($st_ids) > 0)
        {
index c839df17ea6a6594459fea10378efd71733b0faa..72a26840713d4475567153e67b46748fbd84c976 100644 (file)
@@ -28,8 +28,20 @@ class fa2_2 {
                        ."dflt_inventory_act = '" . $prefs['default_inventory_act'] . "',"
                        ."dflt_adjustment_act = '" . $prefs['default_adj_act'] . "',"
                        ."dflt_assembly_act = '" . $prefs['default_assembly_act']."'";
-               $ret = db_query($sql, "Cannot update category default GL accounts");
-               return $ret;
+               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;
        }
        //
        //      Checking before install
@@ -45,6 +57,7 @@ class fa2_2 {
                if (check_table($pref, 'company', 'default_delivery_required')) return false;
                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;
        }
 };
index 5904d82b6b75eb70ce2e954855b1d9c372878636..b70e3a0805fec2599609f2225bedc584fa842f55 100644 (file)
@@ -7,9 +7,10 @@ ALTER TABLE `0_company` DROP COLUMN `custom3_value`;
 
 ALTER TABLE `0_company` ADD COLUMN `default_delivery_required` SMALLINT(6) NULL DEFAULT '1';
 ALTER TABLE `0_company` ADD COLUMN `version_id` VARCHAR(11) NOT NULL DEFAULT '';
-ALTER TABLE `0_company` CHANGE `purch_exchange_diff_act` `profit_loss_year_act` VARCHAR(11) NOT NULL DEFAULT '';
+ALTER TABLE `0_company` DROP COLUMN `purch_exchange_diff_act`;
+ALTER TABLE `0_company` ADD COLUMN`profit_loss_year_act` VARCHAR(11) NOT NULL DEFAULT '' AFTER `exchange_diff_act`;
 ALTER TABLE `0_company` ADD COLUMN `time_zone` TINYINT(1) NOT NULL DEFAULT '0';
-INSERT INTO `0_chart_master` VALUES ('8900', '', 'Profit and Loss this year', '52', '0');
+#INSERT INTO `0_chart_master` VALUES ('8900', '', 'Profit and Loss this year', '52', '0');
 UPDATE `0_company` SET `profit_loss_year_act`='8900', `version_id`='2.2' WHERE `coy_code`=1; 
 
 ALTER TABLE `0_stock_category` DROP COLUMN `stock_act`;
@@ -43,3 +44,25 @@ ALTER TABLE `0_item_tax_types` ADD COLUMN `inactive` tinyint(1) NOT NULL default
 ALTER TABLE `0_tax_types` ADD COLUMN `inactive` tinyint(1) NOT NULL default '0';
 ALTER TABLE `0_tax_groups` ADD COLUMN `inactive` tinyint(1) NOT NULL default '0';
 ALTER TABLE `0_tax_group_items` DROP COLUMN `included_in_price`;
+
+ALTER TABLE `0_users` DROP PRIMARY KEY;
+ALTER TABLE `0_users` ADD `id` SMALLINT(6) AUTO_INCREMENT PRIMARY KEY FIRST;
+ALTER TABLE `0_users` ADD UNIQUE KEY (`user_id`);
+ALTER TABLE `0_users` ADD COLUMN `inactive` tinyint(1) NOT NULL default '0';
+
+DROP TABLE IF EXISTS `0_audit_trail`;
+# fiscal_year, gl_date, gl_seq - journal sequence data
+CREATE TABLE `0_audit_trail` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `type` smallint(6) unsigned NOT NULL default '0',
+  `trans_no` int(11) unsigned NOT NULL default '0',
+  `user` smallint(6) unsigned NOT NULL default '0',
+  `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `description` varchar(60) default NULL,
+  `fiscal_year` int(11) NOT NULL,
+  `gl_date` date NOT NULL default '0000-00-00',
+  `gl_seq` int(11) unsigned default NULL,
+   PRIMARY KEY (`id`),
+  KEY (`fiscal_year`, `gl_seq`)
+) TYPE=InnoDB  ;
+
index 538f1dfd66c4f3dcf5dcb9a9430dfd7a23df3126..60650bd33c5effecd064f9938ffd817dea1f109c 100644 (file)
@@ -50,6 +50,28 @@ CREATE TABLE `0_attachments` (
 
 ### Data of table `0_attachments` ###
 
+### Structure of table `0_audit_trail` ###
+
+DROP TABLE IF EXISTS `0_audit_trail`;
+
+CREATE TABLE `0_audit_trail` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `type` smallint(6) unsigned NOT NULL default '0',
+  `trans_no` int(11) unsigned NOT NULL default '0',
+  `user` smallint(6) unsigned NOT NULL default '0',
+  `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `description` varchar(60) default NULL,
+  `fiscal_year` int(11) NOT NULL,
+  `gl_date` date NOT NULL default '0000-00-00',
+  `gl_seq` int(11) unsigned default NULL,
+   PRIMARY KEY (`id`),
+  KEY (`fiscal_year`, `gl_seq`)
+) TYPE=InnoDB  ;
+
+### Data of table `0_audit_trail` ###
+
+
+
 
 
 ### Structure of table `0_bank_accounts` ###
@@ -2245,12 +2267,12 @@ INSERT INTO `0_trans_tax_details` VALUES ('57', '1', '8', '2009-01-29', '3', '25
 INSERT INTO `0_trans_tax_details` VALUES ('58', '20', '13', '2009-01-29', '3', '25', '1', '0', '40', '10', 'gg');
 INSERT INTO `0_trans_tax_details` VALUES ('59', '2', '6', '2009-01-29', '3', '25', '1', '0', '40', '10', '');
 
-
 ### Structure of table `0_users` ###
 
 DROP TABLE IF EXISTS `0_users`;
 
 CREATE TABLE `0_users` (
+  `id` SMALLINT(6) AUTO_INCREMENT,
   `user_id` varchar(60) NOT NULL default '',
   `password` varchar(100) NOT NULL default '',
   `real_name` varchar(100) NOT NULL default '',
@@ -2278,15 +2300,16 @@ CREATE TABLE `0_users` (
   `print_profile` varchar(30) NOT NULL default '1',
   `rep_popup` tinyint(1) default '1',
   `sticky_doc_date` tinyint(1) default '0',
-  PRIMARY KEY  (`user_id`)
-) TYPE=MyISAM  ;
+  `inactive` tinyint(1) NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY  (`user_id`)
+) TYPE=MyISAM  AUTO_INCREMENT=2;
 
 
 ### Data of table `0_users` ###
 
-INSERT INTO `0_users` VALUES ('demouser', '5f4dcc3b5aa765d61d8327deb882cf99', 'Demo User', '1', '999-999-999', 'demo@demo.nu', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '3', '1', '1', '0', '0', '2008-02-06 19:02:35', '10', '1', '1', '1', '1', '0');
-INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2009-01-30 09:39:03', '10', '1', '1', '', '1', '0');
-
+INSERT INTO `0_users` VALUES ('1', 'admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2009-01-30 09:39:03', '10', '1', '1', '1', '1', '0', '0');
+INSERT INTO `0_users` VALUES ('2', 'demouser', '5f4dcc3b5aa765d61d8327deb882cf99', 'Demo User', '1', '999-999-999', 'demo@demo.nu', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '3', '1', '1', '0', '0', '2008-02-06 19:02:35', '10', '1', '1', '1', '1', '0', '0');
 
 ### Structure of table `0_voided` ###
 
index a9681851bcf145ff9ba1306ce7ffbefe1eb5699d..76658b745b7505e6a07358fb95284ec5a91bdb8a 100644 (file)
@@ -24,7 +24,6 @@ CREATE TABLE `0_areas` (
 
 INSERT INTO `0_areas` VALUES ('1', 'USA', '0');
 
-
 ### Structure of table `0_attachments` ###
 
 DROP TABLE IF EXISTS `0_attachments`;
@@ -46,6 +45,26 @@ CREATE TABLE `0_attachments` (
 
 ### Data of table `0_attachments` ###
 
+### Structure of table `0_audit_trail` ###
+
+DROP TABLE IF EXISTS `0_audit_trail`;
+
+CREATE TABLE `0_audit_trail` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `type` smallint(6) unsigned NOT NULL default '0',
+  `trans_no` int(11) unsigned NOT NULL default '0',
+  `user` smallint(6) unsigned NOT NULL default '0',
+  `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  `description` varchar(60) default NULL,
+  `fiscal_year` int(11) NOT NULL,
+  `gl_date` date NOT NULL default '0000-00-00',
+  `gl_seq` int(11) unsigned default NULL,
+   PRIMARY KEY (`id`),
+  KEY (`fiscal_year`, `gl_seq`)
+) TYPE=InnoDB  ;
+
+### Data of table `0_audit_trail` ###
+
 
 
 ### Structure of table `0_bank_accounts` ###
@@ -347,7 +366,7 @@ CREATE TABLE `0_company` (
 
 ### 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', '', '1'. '2.2', '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', '2.2', '0');
 
 
 ### Structure of table `0_credit_status` ###
@@ -1518,7 +1537,7 @@ CREATE TABLE `0_trans_tax_details` (
   `amount` double NOT NULL default '0',
   `memo` tinytext,
   PRIMARY KEY  (`id`)
-) TYPE=InnoDB  AUTO_INCREMENT=1 ;
+) TYPE=InnoDB AUTO_INCREMENT=1 ;
 
 
 ### Data of table `0_trans_tax_details` ###
@@ -1530,6 +1549,7 @@ CREATE TABLE `0_trans_tax_details` (
 DROP TABLE IF EXISTS `0_users`;
 
 CREATE TABLE `0_users` (
+  `id` SMALLINT(6) AUTO_INCREMENT,
   `user_id` varchar(60) NOT NULL default '',
   `password` varchar(100) NOT NULL default '',
   `real_name` varchar(100) NOT NULL default '',
@@ -1557,13 +1577,15 @@ CREATE TABLE `0_users` (
   `print_profile` varchar(30) NOT NULL default '1',
   `rep_popup` tinyint(1) default '1',
   `sticky_doc_date` tinyint(1) default '0',
-  PRIMARY KEY  (`user_id`)
-) TYPE=MyISAM  ;
+  `inactive` tinyint(1) NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY  (`user_id`)
+) TYPE=MyISAM  AUTO_INCREMENT=2;
 
 
 ### Data of table `0_users` ###
 
-INSERT INTO `0_users` VALUES ('admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2008-04-04 12:34:29', '10', '1', '1', '1', '1', '0');
+INSERT INTO `0_users` VALUES ('1', 'admin', '5f4dcc3b5aa765d61d8327deb882cf99', 'Administrator', '2', '', 'adm@adm.com', 'en_US', '0', '0', '0', '0', 'default', 'Letter', '2', '2', '4', '1', '1', '0', '0', '2008-04-04 12:34:29', '10', '1', '1', '1', '1', '0', '0');
 
 
 ### Structure of table `0_voided` ###