add_comments($trans_type, $trans_no, $date_, $memo_);
references::save_last($ref, $trans_type);
+ add_audit_trail($trans_type, $trans_no, $date_);
commit_transaction();
add_comments($trans_type, $trans_no, $date_, $memo_);
references::save_last($ref, $trans_type);
+ add_audit_trail($trans_type, $trans_no, $date_);
commit_transaction();
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)
{
}
// 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();
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");
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();
$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;
}
//-------------------------------------------------------------------------------------------------------------
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();
add_comments(28, $number, $date_, $memo_);
references::save_last($ref, 28);
+ add_audit_trail(28, $number, $date_);
commit_transaction();
}
add_comments(29, $id, $date_, $memo_);
references::save_last($ref, 29);
+ add_audit_trail(29, $id, $date_, _("Production."));
commit_transaction();
}
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();
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();
}
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();
}
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();
}
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;
}
references::save_last($reference, 25);
+ add_audit_trail(25, $grn, $date_);
+
commit_transaction();
return $grn;
//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;
$err_msg = "Cannot insert a supplier transaction record";
db_query($sql, $err_msg);
+ add_audit_trail($type, $trans_no, $date_);
return $trans_no;
}
$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 (
}
db_query($sql, "The debtor transaction record could not be inserted");
+ add_audit_trail($trans_type, $trans_no, $date_, $new ? '': _("Updated."));
+
return $trans_no;
}
} /* 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)
$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();
}
} /* 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)
{
."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
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;
}
};
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`;
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 ;
+
### 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` ###
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 '',
`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` ###
INSERT INTO `0_areas` VALUES ('1', 'USA', '0');
-
### Structure of table `0_attachments` ###
DROP TABLE IF EXISTS `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` ###
### 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` ###
`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` ###
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 '',
`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` ###