From: Janusz Dobrowolski Date: Fri, 8 May 2009 10:33:53 +0000 (+0000) Subject: References saved in refs table for all documents for easy access. X-Git-Tag: v2.4.2~19^2~1397 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=1a851e527fe366364c6d2baaf2684222f9394b48;p=fa-stable.git References saved in refs table for all documents for easy access. --- diff --git a/dimensions/includes/dimensions_db.inc b/dimensions/includes/dimensions_db.inc index 2dfe6838..344305a2 100644 --- a/dimensions/includes/dimensions_db.inc +++ b/dimensions/includes/dimensions_db.inc @@ -24,7 +24,7 @@ function add_dimension($reference, $name, $type_, $date_, $due_date, $memo_) add_comments(systypes::dimension(), $id, $date_, $memo_); - references::save_last($reference, systypes::dimension()); + references::save(systypes::dimension(), $id, $reference); commit_transaction(); diff --git a/includes/references.inc b/includes/references.inc index 6f3bd891..1f945599 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -17,8 +17,8 @@ class references function save($type, $id, $reference) { add_reference($type, $id, $reference); - - references::save_last($reference, $type); + if ($reference != 'auto') + references::save_last($reference, $type); } function get($type, $id) diff --git a/inventory/includes/db/items_adjust_db.inc b/inventory/includes/db/items_adjust_db.inc index 61d130d5..b5111069 100644 --- a/inventory/includes/db/items_adjust_db.inc +++ b/inventory/includes/db/items_adjust_db.inc @@ -29,7 +29,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()); + references::save(systypes::inventory_adjustment(), $adj_id, $reference); add_audit_trail(systypes::inventory_adjustment(), $adj_id, $date_); commit_transaction(); diff --git a/inventory/includes/db/items_transfer_db.inc b/inventory/includes/db/items_transfer_db.inc index c1eac28b..5784453b 100644 --- a/inventory/includes/db/items_transfer_db.inc +++ b/inventory/includes/db/items_transfer_db.inc @@ -25,7 +25,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()); + references::save(systypes::location_transfer(), $transfer_id, $reference); add_audit_trail(systypes::location_transfer(), $transfer_id, $date_); commit_transaction(); diff --git a/manufacturing/includes/db/work_order_issues_db.inc b/manufacturing/includes/db/work_order_issues_db.inc index a8fc6b1c..9fbbfb69 100644 --- a/manufacturing/includes/db/work_order_issues_db.inc +++ b/manufacturing/includes/db/work_order_issues_db.inc @@ -58,7 +58,7 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w if ($memo_) add_comments(28, $number, $date_, $memo_); - references::save_last($ref, 28); + references::save(28, $number, $ref); add_audit_trail(28, $number, $date_); commit_transaction(); diff --git a/manufacturing/includes/db/work_order_produce_items_db.inc b/manufacturing/includes/db/work_order_produce_items_db.inc index 4419e7e2..b4cac9fd 100644 --- a/manufacturing/includes/db/work_order_produce_items_db.inc +++ b/manufacturing/includes/db/work_order_produce_items_db.inc @@ -53,7 +53,7 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo) if ($memo_) add_comments(29, $id, $date_, $memo_); - references::save_last($ref, 29); + references::save(29, $id, $ref); add_audit_trail(29, $id, $date_, _("Production.")); commit_transaction(); diff --git a/manufacturing/includes/db/work_orders_db.inc b/manufacturing/includes/db/work_orders_db.inc index 1c17ea86..4c7f1855 100644 --- a/manufacturing/includes/db/work_orders_db.inc +++ b/manufacturing/includes/db/work_orders_db.inc @@ -59,7 +59,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()); + references::save(systypes::work_order(), $woid, $wo_ref); add_audit_trail(systypes::work_order(), $woid, $date_); commit_transaction(); diff --git a/manufacturing/includes/db/work_orders_quick_db.inc b/manufacturing/includes/db/work_orders_quick_db.inc index 8595b210..471ca420 100644 --- a/manufacturing/includes/db/work_orders_quick_db.inc +++ b/manufacturing/includes/db/work_orders_quick_db.inc @@ -72,7 +72,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()); + references::save(systypes::work_order(), $woid, $wo_ref); add_audit_trail(systypes::work_order(), $woid, $date_,_("Quick production.")); commit_transaction(); return $woid; diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index df526f14..6da54816 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -95,7 +95,7 @@ function add_grn(&$po, $date_, $reference, $location) } /*quantity received is != 0 */ } /*end of order_line loop */ - references::save_last($reference, 25); + references::save(25, $grn, $reference); add_audit_trail(25, $grn, $date_); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index 2ee49018..936f8cba 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -286,7 +286,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b add_comments($trans_type, $invoice_id, $date_, $supp_trans->Comments); - references::save_last($supp_trans->reference, $trans_type); + references::save($trans_type, $invoice_id, $supp_trans->reference); if ($invoice_no != 0) { diff --git a/purchasing/includes/db/po_db.inc b/purchasing/includes/db/po_db.inc index 350b8280..ca67638f 100644 --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@ -56,11 +56,11 @@ function add_po(&$po_obj) } } - references::save_last($po_obj->reference, systypes::po()); + references::save(systypes::po(), $po_obj->order_no, $po_obj->reference); //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); + add_audit_trail(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date); commit_transaction(); return $po_obj->order_no; diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index 35e93db4..516dfba1 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -68,7 +68,7 @@ function add_supp_payment($supplier_id, $date_, $bank_account, add_comments($trans_type, $payment_id, $date_, $memo_); - references::save_last($ref, $trans_type); + references::save($trans_type, $payment_id, $ref); commit_transaction(); diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index 12e7cc0f..36971969 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -71,7 +71,7 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou add_comments(12, $payment_no, $date_, $memo_); - references::save_last($ref, 12); + references::save(12, $payment_no, $ref); commit_transaction(); diff --git a/sales/includes/db/sales_credit_db.inc b/sales/includes/db/sales_credit_db.inc index 0cea7655..8e3cd494 100644 --- a/sales/includes/db/sales_credit_db.inc +++ b/sales/includes/db/sales_credit_db.inc @@ -171,7 +171,7 @@ function write_credit_note($credit_note, $write_off_acc) add_comments(11, $credit_no, $credit_date, $credit_note->Comments); if ($trans_no == 0) { - references::save_last($credit_note->reference, 11); + references::save(11, $credit_no, $credit_note->reference); } commit_transaction(); diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 9155c089..3945f286 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -135,8 +135,7 @@ function write_sales_delivery(&$delivery,$bo_policy) add_comments(13, $delivery_no, $delivery->document_date, $delivery->Comments); if ($trans_no == 0) { - if ($delivery->reference!='auto') - references::save_last($delivery->reference, 13); + references::save(13, $delivery_no, $delivery->reference); } commit_transaction(); diff --git a/sql/alter2.2.php b/sql/alter2.2.php index 72a26840..7a4cf751 100644 --- a/sql/alter2.2.php +++ b/sql/alter2.2.php @@ -19,7 +19,7 @@ class fa2_2 { // function install($pref, $force) { - global $db; + global $db, $systypes_array; // set item category dflt accounts to values from company GL setup $prefs = get_company_prefs(); $sql = "UPDATE {$pref}stock_category SET " @@ -33,6 +33,27 @@ class fa2_2 { .':
'. db_error_msg($db)); return false; } + // add all references to refs table for easy searching via journal interface + foreach($systypes_array as $typeno => $typename) { + $info = get_systype_db_info($typeno); + if ($info == null || $info[3] == null) continue; + $tbl = str_replace(TB_PREF, $pref, $info[0]); + $sql = "SELECT {$info[2]} as id,{$info[3]} as ref FROM $tbl"; + if ($info[1]) + $sql .= " WHERE {$info[1]}=$typeno"; + $result = db_query($sql); + if(db_num_rows($result)) { + while($row = db_fetch($result)) { + $res2 = db_query("INSERT INTO {$pref}refs VALUES(" + . $row['id'].",".$typeno.",'".$row['ref']."')"); + if (!$res2) { + display_error(_("Cannot copy references from $tbl") + .':
'. db_error_msg($db)); + return false; + } + } + } + } /* FIX // add audit_trail data for all transactions $datatbl = array ("gl_trans", "purch_orders", "sales_orders",