From 7a50c189ea995d5fe6785feb7710c00396065d2b Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sun, 9 Mar 2008 16:07:36 +0000 Subject: [PATCH] Removed redundant form_types functions and the file /reporting/includes/form_types.inc. Removed table form_items. Bug in calculating exchange rates in Reports Supplier Balances and Customer Balances. clone replacement do_clone() for both PHP 4 and PHP 5. --- CHANGELOG.txt | 25 +++ dimensions/includes/dimensions_db.inc | 10 +- gl/includes/db/gl_db_banking.inc | 130 +++++++------- includes/main.inc | 36 ++-- includes/ui/ui_view.inc | 13 ++ inventory/includes/db/items_adjust_db.inc | 56 +++--- inventory/includes/db/items_transfer_db.inc | 48 +++--- .../includes/db/work_order_issues_db.inc | 66 ++++---- .../db/work_order_produce_items_db.inc | 76 ++++----- manufacturing/includes/db/work_orders_db.inc | 4 - .../includes/db/work_orders_quick_db.inc | 2 - purchasing/includes/db/grn_db.inc | 2 - purchasing/includes/db/po_db.inc | 160 +++++++++--------- purchasing/includes/db/supp_payment_db.inc | 54 +++--- reporting/includes/form_types.inc | 137 --------------- reporting/rep101.php | 46 ++--- reporting/rep105.php | 44 ++--- reporting/rep201.php | 50 +++--- reporting/rep302.php | 20 +-- reporting/rep303.php | 12 +- sales/includes/cart_class.inc | 2 +- sales/includes/db/sales_delivery_db.inc | 1 - sales/includes/db/sales_invoice_db.inc | 1 - sales/includes/db/sales_order_db.inc | 26 ++- sql/alter.sql | 1 + 25 files changed, 444 insertions(+), 578 deletions(-) delete mode 100644 reporting/includes/form_types.inc diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 173fb023..7dd750f0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,31 @@ Legend: ! -> Note $ -> Affected files +09-Mar-2008 Joe Hunt + - Removed redundant form_types functions and the file /reporting/includes/form_types.inc. Removed table form_items + $ /dimensions/includes/dimensions_db.inc + /gl/includes/db/gl_db_banking.inc + /includes/main.inc + /inventory/includes/db/items_adjust_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_payment_db.inc + /reporting/includes/form_types.inc (File removed) + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + /sales/includes/db/sales_order_db.inc + /sql/alter.sql + # Bug in calculating exchange rates in Reports Supplier Balances and Customer Balances + $ /reporting/rep101.php + /reporting/rep201.php + # clone replacement do_clone() for both PHP 4 and PHP 5. + $ /includes/ui/ui_view.inc (at the very bottom) + /sales/includes/cart_class.inc + 07-Mar-2008 Janusz Dobrowolski ! Changed name tax type uniqueness constraint to (name, rate) $ /includes/ui/ui_lists.inc diff --git a/dimensions/includes/dimensions_db.inc b/dimensions/includes/dimensions_db.inc index a66ca538..8ad1cfb1 100644 --- a/dimensions/includes/dimensions_db.inc +++ b/dimensions/includes/dimensions_db.inc @@ -15,8 +15,6 @@ function add_dimension($reference, $name, $type_, $date_, $due_date, $memo_) add_comments(systypes::dimension(), $id, $date_, $memo_); - add_forms_for_sys_type(systypes::dimension(), $id); - references::save_last($reference, systypes::dimension()); commit_transaction(); @@ -56,8 +54,6 @@ function delete_dimension($id) delete_comments(systypes::dimension(), $id); - delete_forms_for_systype(systypes::dimension(), $id); - commit_transaction(); } @@ -83,15 +79,15 @@ function get_dimension_string($id, $html=false, $space=' ') { if ($html) $dim = " "; - else + else $dim = ""; - } + } else { $row = get_dimension($id, true); $dim = $row['reference'] . $space . $row['name']; } - + return $dim; } diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index dbf5151a..dc86c0a4 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -2,45 +2,43 @@ //---------------------------------------------------------------------------------- -function add_bank_transfer($from_account, $to_account, $date_, +function add_bank_transfer($from_account, $to_account, $date_, $amount, $payment_type, $ref, $memo_) { begin_transaction(); - + $trans_type = systypes::bank_transfer(); - + $currency = get_bank_account_currency($from_account); $trans_no = get_next_trans_no($trans_type); - + // do the source account postings - add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "", - -$amount, $currency); - - add_bank_trans($trans_type, $trans_no, $from_account, $ref, - $date_, $payment_type, -$amount, - payment_person_types::misc(), "", $currency, + add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "", + -$amount, $currency); + + add_bank_trans($trans_type, $trans_no, $from_account, $ref, + $date_, $payment_type, -$amount, + payment_person_types::misc(), "", $currency, "Cannot insert a source bank transaction"); - + // do the destination account postings add_gl_trans($trans_type, $trans_no, $date_, $to_account, 0, 0, "", $amount, $currency); - - add_bank_trans($trans_type, $trans_no, $to_account, $ref, + + add_bank_trans($trans_type, $trans_no, $to_account, $ref, $date_, $payment_type, $amount, - payment_person_types::misc(), "", - $currency, + payment_person_types::misc(), "", + $currency, "Cannot insert a destination bank transaction"); - - add_comments($trans_type, $trans_no, $date_, $memo_); - - add_forms_for_sys_type($trans_type, $trans_no, $from_account, $to_account); - - references::save_last($ref, $trans_type); - + + add_comments($trans_type, $trans_no, $date_, $memo_); + + references::save_last($ref, $trans_type); + commit_transaction(); - - return $trans_no; + + return $trans_no; } //---------------------------------------------------------------------------------- @@ -57,89 +55,87 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, display_db_error("Invalid type ($trans_type) sent to add_bank_transaction"); begin_transaction(); - - $currency = get_bank_account_currency($from_account); - + + $currency = get_bank_account_currency($from_account); + // the gl items are already inversed/negated for type 2 (deposit) $total_amount = $items->gl_items_total(); - - if ($person_type_id == payment_person_types::customer()) + + if ($person_type_id == payment_person_types::customer()) { // we need to add a customer transaction record - + // convert to customer currency $cust_amount = exchange_from_to($total_amount, $currency, get_customer_currency($person_id), $date_); - + $trans_no = add_customer_trans($trans_type, $person_id, $person_detail_id, $date_, - $ref, $cust_amount); + $ref, $cust_amount); - } - elseif ($person_type_id == payment_person_types::supplier()) + } + elseif ($person_type_id == payment_person_types::supplier()) { // we need to add a supplier transaction record // convert to supp currency $supp_amount = exchange_from_to($total_amount, $currency, get_supplier_currency($person_id), $date_); - - // we need to negate it too + + // we need to negate it too $supp_amount = -$supp_amount; $trans_no = add_supp_trans($trans_type, $person_id, $date_, '', $ref, "", $supp_amount, 0, 0); - } - else + } + else { $trans_no = get_next_trans_no($trans_type); - } - + } + // do the source account postings add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "", - -$total_amount, $currency, $person_type_id, $person_id); - - add_bank_trans($trans_type, $trans_no, $from_account, $ref, + -$total_amount, $currency, $person_type_id, $person_id); + + add_bank_trans($trans_type, $trans_no, $from_account, $ref, $date_, $type, -$total_amount, - $person_type_id, $person_id, - $currency, + $person_type_id, $person_id, + $currency, "Cannot insert a source bank transaction"); - + foreach ($items->gl_items as $gl_item) { $is_bank_to = is_bank_account($gl_item->code_id); - - if ($trans_type == 1 AND $is_bank_to) + + if ($trans_type == 1 AND $is_bank_to) { // we don't allow payments to go to a bank account. use transfer for this ! display_db_error("invalid payment entered. Cannot pay to another bank account", ""); - } - + } + // do the destination account postings - add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id, - $gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference, + add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id, + $gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference, $gl_item->amount, $currency, $person_type_id, $person_id); - - if ($is_bank_to) + + if ($is_bank_to) { - add_bank_trans($trans_type, $trans_no, $gl_item->code_id, $ref, + add_bank_trans($trans_type, $trans_no, $gl_item->code_id, $ref, $date_, $type, $gl_item->amount, - $person_type_id, $person_id, $currency, - "Cannot insert a destination bank transaction"); - } + $person_type_id, $person_id, $currency, + "Cannot insert a destination bank transaction"); + } } - + add_comments($trans_type, $trans_no, $date_, $memo_); - - add_forms_for_sys_type($trans_type, $trans_no, $person_type_id, $person_id); - - references::save_last($ref, $trans_type); - + + references::save_last($ref, $trans_type); + commit_transaction(); - + return array($trans_type, $trans_no); } //---------------------------------------------------------------------------------------- -function add_bank_payment($from_account, $items, $date_, +function add_bank_payment($from_account, $items, $date_, $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_) { return add_bank_transaction(systypes::bank_payment(), $from_account, $items, $date_, @@ -148,7 +144,7 @@ function add_bank_payment($from_account, $items, $date_, //--------------------------------------------------------------------------------------------- -function add_bank_deposit($from_account, $items, $date_, +function add_bank_deposit($from_account, $items, $date_, $person_type_id, $person_id, $person_detail_id, $type, $ref, $memo_) { return add_bank_transaction(systypes::bank_deposit(), $from_account, $items, $date_, diff --git a/includes/main.inc b/includes/main.inc index 937d9a92..07666d28 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -8,34 +8,32 @@ include_once($path_to_root . "/includes/systypes.inc"); 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 . "/reporting/includes/form_types.inc"); - - include_once($path_to_root . "/admin/db/users_db.inc"); - - function page($title, $no_menu=false, $is_index=false, $onload="", $js="") + 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 . "/admin/db/users_db.inc"); + + function page($title, $no_menu=false, $is_index=false, $onload="", $js="") { - + global $path_to_root; - + $hide_menu = $no_menu; - + include($path_to_root . "/includes/page/header.inc"); - + page_header($title, $no_menu, $is_index, $onload, $js); - } - - function end_page($no_menu=false, $is_index=false) + } + + function end_page($no_menu=false, $is_index=false) { global $path_to_root; - + $hide_menu = $no_menu; - + include($path_to_root . "/includes/page/footer.inc"); - - page_footer($no_menu, $is_index); + + page_footer($no_menu, $is_index); } ?> \ No newline at end of file diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 639aea0b..f34a443b 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -1113,4 +1113,17 @@ if (!function_exists('_vd')) } } +/* ************************************** Backward compatible */ +function do_clone($object) +{ + if (version_compare(phpversion(), '5.0') < 0) + { + return $object; + } + else + { + return @clone($object); + } +} + ?> \ No newline at end of file diff --git a/inventory/includes/db/items_adjust_db.inc b/inventory/includes/db/items_adjust_db.inc index c245bb0f..bab75ba7 100644 --- a/inventory/includes/db/items_adjust_db.inc +++ b/inventory/includes/db/items_adjust_db.inc @@ -5,28 +5,26 @@ function add_stock_adjustment($items, $location, $date_, $type, $increase, $reference, $memo_) { begin_transaction(); - + $adj_id = get_next_trans_no(systypes::inventory_adjustment()); - - foreach ($items as $line_item) + + foreach ($items as $line_item) { - + if (!$increase) $line_item->quantity = -$line_item->quantity; - - add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $type, $reference, + + add_stock_adjustment_item($adj_id, $line_item->stock_id, $location, $date_, $type, $reference, $line_item->quantity, $line_item->standard_cost, $memo_); } - - add_comments(systypes::inventory_adjustment(), $adj_id, $date_, $memo_); - - add_forms_for_sys_type(systypes::inventory_adjustment(), $adj_id, $increase, $location); - - references::save_last($reference, systypes::inventory_adjustment()); - + + add_comments(systypes::inventory_adjustment(), $adj_id, $date_, $memo_); + + references::save_last($reference, systypes::inventory_adjustment()); + commit_transaction(); - return $adj_id; + return $adj_id; } //------------------------------------------------------------------------------------------------------------- @@ -42,39 +40,39 @@ function void_stock_adjustment($type_no) function get_stock_adjustment_items($trans_no) { $result = get_stock_moves(systypes::inventory_adjustment(), $trans_no); - - if (db_num_rows($result) == 0) + + if (db_num_rows($result) == 0) { - return null; + return null; } - + return $result; } //-------------------------------------------------------------------------------------------------- -function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $type, $reference, +function add_stock_adjustment_item($adj_id, $stock_id, $location, $date_, $type, $reference, $quantity, $standard_cost, $memo_) { $mb_flag = get_mb_flag($stock_id); - + if (is_service($mb_flag)) { - display_db_error("Cannot do inventory adjustment for Service item : $stock_id", ""); - } - + display_db_error("Cannot do inventory adjustment for Service item : $stock_id", ""); + } + add_stock_move(systypes::inventory_adjustment(), $stock_id, $adj_id, $location, - $date_, $reference, $quantity, $standard_cost, $type); + $date_, $reference, $quantity, $standard_cost, $type); if ($standard_cost > 0) { - + $stock_gl_codes = get_stock_gl_code($stock_id); - - add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, + + add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, $stock_gl_codes['adjustment_account'], $stock_gl_codes['dimension_id'], $stock_gl_codes['dimension2_id'], $memo_, ($standard_cost * -($quantity))); - - add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, $stock_gl_codes['inventory_account'], 0, 0, $memo_, ($standard_cost * $quantity)); + + add_gl_trans_std_cost(systypes::inventory_adjustment(), $adj_id, $date_, $stock_gl_codes['inventory_account'], 0, 0, $memo_, ($standard_cost * $quantity)); } } diff --git a/inventory/includes/db/items_transfer_db.inc b/inventory/includes/db/items_transfer_db.inc index 4d4a438b..67bbdc7c 100644 --- a/inventory/includes/db/items_transfer_db.inc +++ b/inventory/includes/db/items_transfer_db.inc @@ -5,24 +5,22 @@ function add_stock_transfer($Items, $location_from, $location_to, $date_, $type, $reference, $memo_) { begin_transaction(); - + $transfer_id = get_next_trans_no(systypes::location_transfer()); - - foreach ($Items as $line_item) + + foreach ($Items as $line_item) { - add_stock_transfer_item($transfer_id, $line_item->stock_id, $location_from, + add_stock_transfer_item($transfer_id, $line_item->stock_id, $location_from, $location_to, $date_, $type, $reference, $line_item->quantity); } - - add_comments(systypes::location_transfer(), $transfer_id, $date_, $memo_); - - add_forms_for_sys_type(systypes::location_transfer(), $transfer_id, $location_from, $location_to); - - references::save_last($reference, systypes::location_transfer()); - + + add_comments(systypes::location_transfer(), $transfer_id, $date_, $memo_); + + references::save_last($reference, systypes::location_transfer()); + commit_transaction(); - return $transfer_id; + return $transfer_id; } //------------------------------------------------------------------------------------------------------------- @@ -32,15 +30,15 @@ function add_stock_transfer($Items, $location_from, $location_to, $date_, $type, // std_cost is in HOME currency // it seems the standard_cost field is not used at all -function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to, +function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $location_to, $date_, $type, $reference, $quantity) { add_stock_move(systypes::location_transfer(), $stock_id, $transfer_id, $location_from, - $date_, $reference, -$quantity, 0, $type); - + $date_, $reference, -$quantity, 0, $type); + add_stock_move(systypes::location_transfer(), $stock_id, $transfer_id, $location_to, - $date_, $reference, $quantity, 0, $type); - + $date_, $reference, $quantity, 0, $type); + } //------------------------------------------------------------------------------------------------------------- @@ -48,17 +46,17 @@ function add_stock_transfer_item($transfer_id, $stock_id, $location_from, $locat function get_stock_transfer($trans_no) { $result = get_stock_transfer_items($trans_no); - if (db_num_rows($result) < 2) + if (db_num_rows($result) < 2) { - display_db_error("transfer with less than 2 items : $trans_no", ""); + display_db_error("transfer with less than 2 items : $trans_no", ""); } - + // this function is very bad that it assumes that 1st record and 2nd record contain the // from and to locations - if get_stock_moves uses a different ordering than trans_no then // it will bomb $move1 = db_fetch($result); $move2 = db_fetch($result); - + // return an array of (From, To) if ($move1['qty'] < 0) return array($move1, $move2); @@ -71,12 +69,12 @@ function get_stock_transfer($trans_no) function get_stock_transfer_items($trans_no) { $result = get_stock_moves(systypes::location_transfer(), $trans_no); - - if (db_num_rows($result) == 0) + + if (db_num_rows($result) == 0) { - return null; + return null; } - + return $result; } diff --git a/manufacturing/includes/db/work_order_issues_db.inc b/manufacturing/includes/db/work_order_issues_db.inc index fcc6d6f5..f59f8893 100644 --- a/manufacturing/includes/db/work_order_issues_db.inc +++ b/manufacturing/includes/db/work_order_issues_db.inc @@ -2,57 +2,55 @@ //-------------------------------------------------------------------------------------- -function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $workcentre, +function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $workcentre, $date_, $memo_) { begin_transaction(); $details = get_work_order($woid); - - if (strlen($details[0]) == 0) + + if (strlen($details[0]) == 0) { echo _("The order number sent is not valid."); cancel_transaction(); exit; } - - if (work_order_is_closed($woid)) + + if (work_order_is_closed($woid)) { display_error("UNEXPECTED : Issuing items for a closed Work Order"); cancel_transaction(); exit; - } - + } + // insert the actual issue - $sql = "INSERT INTO ".TB_PREF."wo_issues (workorder_id, reference, issue_date, loc_code, workcentre_id) + $sql = "INSERT INTO ".TB_PREF."wo_issues (workorder_id, reference, issue_date, loc_code, workcentre_id) VALUES ($woid, '$ref', '" . date2sql($date_) . "', '$location', $workcentre)"; db_query($sql,"The work order issue could not be added"); - + $number = db_insert_id(); - - foreach ($items as $item) + + foreach ($items as $item) { - + if ($to_work_order) $item->quantity = -$item->quantity; // insert a -ve stock move for each item - add_stock_move(28, $item->stock_id, $number, + add_stock_move(28, $item->stock_id, $number, $location, $date_, $memo_, -$item->quantity, 0); - - $sql = "INSERT INTO ".TB_PREF."wo_issue_items (issue_id, stock_id, qty_issued) + + $sql = "INSERT INTO ".TB_PREF."wo_issue_items (issue_id, stock_id, qty_issued) VALUES ('$number', '$item->stock_id', $item->quantity)"; db_query($sql,"A work order issue item could not be added"); } - + if ($memo_) - add_comments(28, $number, $date_, $memo_); - - add_forms_for_sys_type(28, $number, $to_work_order, $location); - + add_comments(28, $number, $date_, $memo_); + references::save_last($ref, 28); - + commit_transaction(); } @@ -68,8 +66,8 @@ function get_work_order_issues($woid) function get_work_order_issue($issue_no) { - $sql = "SELECT DISTINCT ".TB_PREF."wo_issues.*, ".TB_PREF."workorders.stock_id, - ".TB_PREF."stock_master.description, ".TB_PREF."locations.location_name, ".TB_PREF."workcentres.name AS WorkCentreName + $sql = "SELECT DISTINCT ".TB_PREF."wo_issues.*, ".TB_PREF."workorders.stock_id, + ".TB_PREF."stock_master.description, ".TB_PREF."locations.location_name, ".TB_PREF."workcentres.name AS WorkCentreName FROM ".TB_PREF."wo_issues, ".TB_PREF."workorders, ".TB_PREF."stock_master, ".TB_PREF."locations, ".TB_PREF."workcentres WHERE issue_no='$issue_no' AND ".TB_PREF."workorders.id = ".TB_PREF."wo_issues.workorder_id @@ -77,7 +75,7 @@ function get_work_order_issue($issue_no) AND ".TB_PREF."workcentres.id = ".TB_PREF."wo_issues.workcentre_id AND ".TB_PREF."stock_master.stock_id = ".TB_PREF."workorders.stock_id"; $result = db_query($sql, "A work order issue could not be retrieved"); - + return db_fetch($result); } @@ -85,7 +83,7 @@ function get_work_order_issue($issue_no) function get_work_order_issue_details($issue_no) { - $sql = "SELECT ".TB_PREF."wo_issue_items.*,".TB_PREF."stock_master.description, ".TB_PREF."stock_master.units + $sql = "SELECT ".TB_PREF."wo_issue_items.*,".TB_PREF."stock_master.description, ".TB_PREF."stock_master.units FROM ".TB_PREF."wo_issue_items, ".TB_PREF."stock_master WHERE issue_id=$issue_no AND ".TB_PREF."stock_master.stock_id=".TB_PREF."wo_issue_items.stock_id @@ -98,27 +96,27 @@ function get_work_order_issue_details($issue_no) function exists_work_order_issue($issue_no) { $sql = "SELECT issue_no FROM ".TB_PREF."wo_issues WHERE issue_no=$issue_no"; - $result = db_query($sql, "Cannot retreive a wo issue"); - - return (db_num_rows($result) > 0); -} + $result = db_query($sql, "Cannot retreive a wo issue"); + + return (db_num_rows($result) > 0); +} //-------------------------------------------------------------------------------------- function void_work_order_issue($type_no) { begin_transaction(); - + // void the actual issue items and their quantities $sql = "UPDATE ".TB_PREF."wo_issue_items Set qty_issued = 0 WHERE issue_id=$type_no"; db_query($sql,"A work order issue item could not be voided"); - + // void all related stock moves void_stock_move(28, $type_no); - + // void any related gl trans - void_gl_trans(28, $type_no, true); - + void_gl_trans(28, $type_no, true); + 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 c3da19dc..6339e87d 100644 --- a/manufacturing/includes/db/work_order_produce_items_db.inc +++ b/manufacturing/includes/db/work_order_produce_items_db.inc @@ -5,59 +5,57 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo) begin_transaction(); $details = get_work_order($woid); - - if (strlen($details[0]) == 0) + + if (strlen($details[0]) == 0) { echo _("The order number sent is not valid."); exit; } - - if (work_order_is_closed($woid)) + + if (work_order_is_closed($woid)) { display_error("UNEXPECTED : Producing Items for a closed Work Order"); cancel_transaction(); exit; - } - + } + $date = date2sql($date_); - + $sql = "INSERT INTO ".TB_PREF."wo_manufacture (workorder_id, reference, quantity, date_) VALUES ($woid, '$ref', $quantity, '$date')"; db_query($sql,"A work order manufacture could not be added"); - - $id = db_insert_id(); - + + $id = db_insert_id(); + // insert a +ve stock move for the item being manufactured // negative means "unproduce" or unassemble add_stock_move(29, $details["stock_id"], $id, - $details["loc_code"], $date_, $memo_, $quantity, 0); - + $details["loc_code"], $date_, $memo_, $quantity, 0); + // update wo quantity and close wo if requested work_order_update_finished_quantity($woid, $quantity, $close_wo); - + if ($memo_) - add_comments(29, $id, $date_, $memo_); - - add_forms_for_sys_type(29, $id, $quantity, $details["loc_code"]); - - references::save_last($ref, 29); - - commit_transaction(); + add_comments(29, $id, $date_, $memo_); + + references::save_last($ref, 29); + + commit_transaction(); } //-------------------------------------------------------------------------------------------- function get_work_order_produce($id) { - $sql = "SELECT ".TB_PREF."wo_manufacture.*,".TB_PREF."workorders.stock_id, ".TB_PREF."stock_master.description AS StockDescription - FROM ".TB_PREF."wo_manufacture, ".TB_PREF."workorders, ".TB_PREF."stock_master + $sql = "SELECT ".TB_PREF."wo_manufacture.*,".TB_PREF."workorders.stock_id, ".TB_PREF."stock_master.description AS StockDescription + FROM ".TB_PREF."wo_manufacture, ".TB_PREF."workorders, ".TB_PREF."stock_master WHERE ".TB_PREF."wo_manufacture.workorder_id=".TB_PREF."workorders.id AND ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id AND ".TB_PREF."wo_manufacture.id=$id"; $result = db_query($sql, "The work order production could not be retrieved"); - - return db_fetch($result); + + return db_fetch($result); } //-------------------------------------------------------------------------------------- @@ -73,33 +71,33 @@ function get_work_order_productions($woid) function exists_work_order_produce($id) { $sql = "SELECT id FROM ".TB_PREF."wo_manufacture WHERE id=$id"; - $result = db_query($sql, "Cannot retreive a wo production"); - - return (db_num_rows($result) > 0); -} + $result = db_query($sql, "Cannot retreive a wo production"); + + return (db_num_rows($result) > 0); +} //-------------------------------------------------------------------------------------------- function void_work_order_produce($type_no) { - begin_transaction(); - + begin_transaction(); + $row = get_work_order_produce($type_no); - + // deduct the quantity of this production from the parent work order work_order_update_finished_quantity($row["workorder_id"], -$row["quantity"]); - + // clear the production record - $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=$type_no"; + $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=$type_no"; db_query($sql, "Cannot void a wo production"); - + // void all related stock moves - void_stock_move(29, $type_no); - + void_stock_move(29, $type_no); + // void any related gl trans - void_gl_trans(29, $type_no, true); - - commit_transaction(); + void_gl_trans(29, $type_no, true); + + commit_transaction(); } diff --git a/manufacturing/includes/db/work_orders_db.inc b/manufacturing/includes/db/work_orders_db.inc index 6b2064b2..408fcc05 100644 --- a/manufacturing/includes/db/work_orders_db.inc +++ b/manufacturing/includes/db/work_orders_db.inc @@ -50,8 +50,6 @@ function add_work_order($wo_ref, $loc_code, $units_reqd, $stock_id, add_comments(systypes::work_order(), $woid, $required_by, $memo_); - add_forms_for_sys_type(systypes::work_order(), $woid); - references::save_last($wo_ref, systypes::work_order()); commit_transaction(); @@ -100,8 +98,6 @@ function delete_work_order($woid) delete_comments(systypes::work_order(), $woid); - delete_forms_for_systype(systypes::work_order(), $woid); - commit_transaction(); } diff --git a/manufacturing/includes/db/work_orders_quick_db.inc b/manufacturing/includes/db/work_orders_quick_db.inc index 3eecf015..940145af 100644 --- a/manufacturing/includes/db/work_orders_quick_db.inc +++ b/manufacturing/includes/db/work_orders_quick_db.inc @@ -63,8 +63,6 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, add_comments(systypes::work_order(), $woid, $date_, $memo_); - add_forms_for_sys_type(systypes::work_order(), $woid, $type); - references::save_last($wo_ref, systypes::work_order()); commit_transaction(); diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 88cab62e..81b11bb9 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -59,8 +59,6 @@ function add_grn(&$po, $date_, $reference, $location) } /*quantity received is != 0 */ } /*end of order_line loop */ - add_forms_for_sys_type(25, $grn, $location); - references::save_last($reference, 25); commit_transaction(); diff --git a/purchasing/includes/db/po_db.inc b/purchasing/includes/db/po_db.inc index 439ca58f..7e813e04 100644 --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@ -15,46 +15,44 @@ function delete_po($po) function add_po(&$po_obj) { - begin_transaction(); - + begin_transaction(); + /*Insert to purchase order header record */ $sql = "INSERT INTO ".TB_PREF."purch_orders (supplier_id, Comments, ord_date, reference, requisition_no, into_stock_location, delivery_address) VALUES("; - $sql .= "'" . $po_obj->supplier_id . "', '" . - db_escape($po_obj->Comments) . "','" . - date2sql($po_obj->orig_order_date) . "', '" . - $po_obj->reference . "', '" . - $po_obj->requisition_no . "', '" . - $po_obj->Location . "', '" . + $sql .= "'" . $po_obj->supplier_id . "', '" . + db_escape($po_obj->Comments) . "','" . + date2sql($po_obj->orig_order_date) . "', '" . + $po_obj->reference . "', '" . + $po_obj->requisition_no . "', '" . + $po_obj->Location . "', '" . $po_obj->delivery_address . "')"; - + db_query($sql, "The purchase order header record could not be inserted"); - + /*Get the auto increment value of the order number created from the sql above */ $po_obj->order_no = db_insert_id(); - + /*Insert the purchase order detail records */ - foreach ($po_obj->line_items as $po_line) + foreach ($po_obj->line_items as $po_line) { - if ($po_line->Deleted == false) + if ($po_line->Deleted == false) { $sql = "INSERT INTO ".TB_PREF."purch_order_details (order_no, item_code, description, delivery_date, unit_price, quantity_ordered) VALUES ("; - $sql .= $po_obj->order_no . ", '" . $po_line->stock_id . "','" . - $po_line->item_description . "','" . - date2sql($po_line->req_del_date) . "'," . - $po_line->price . ", " . + $sql .= $po_obj->order_no . ", '" . $po_line->stock_id . "','" . + $po_line->item_description . "','" . + date2sql($po_line->req_del_date) . "'," . + $po_line->price . ", " . $po_line->quantity . ")"; db_query($sql, "One of the purchase order detail records could not be inserted"); } - } - - add_forms_for_sys_type(systypes::po(), $po_obj->order_no); - - references::save_last($po_obj->reference, systypes::po()); - - //add_comments(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments); - - commit_transaction(); - + } + + references::save_last($po_obj->reference, systypes::po()); + + //add_comments(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments); + + commit_transaction(); + return $po_obj->order_no; } @@ -62,92 +60,92 @@ function add_po(&$po_obj) function update_po(&$po_obj) { - begin_transaction(); + begin_transaction(); /*Update the purchase order header with any changes */ - $sql = "UPDATE ".TB_PREF."purch_orders SET Comments='" . db_escape($po_obj->Comments) . "', - requisition_no= '" . $po_obj->requisition_no . "', - into_stock_location='" . $po_obj->Location . "', + $sql = "UPDATE ".TB_PREF."purch_orders SET Comments='" . db_escape($po_obj->Comments) . "', + requisition_no= '" . $po_obj->requisition_no . "', + into_stock_location='" . $po_obj->Location . "', ord_date='" . date2sql($po_obj->orig_order_date) . "', delivery_address='" . $po_obj->delivery_address . "'"; $sql .= " WHERE order_no = " . $po_obj->order_no; db_query($sql, "The purchase order could not be updated"); /*Now Update the purchase order detail records */ - foreach ($po_obj->line_items as $po_line) + foreach ($po_obj->line_items as $po_line) { - if ($po_line->Deleted==True) + if ($po_line->Deleted==True) { // Sherifoz 21.06.03 Handle deleting existing lines - if ($po_line->po_detail_rec!='') + if ($po_line->po_detail_rec!='') { $sql = "DELETE FROM ".TB_PREF."purch_order_details WHERE po_detail_item='" . $po_line->po_detail_rec . "'"; db_query($sql, "could not query purch order details"); } - } - else if ($po_line->po_detail_rec == '') + } + else if ($po_line->po_detail_rec == '') { // Sherifoz 21.06.03 Handle adding new lines vs. updating. if no key(po_detail_rec) then it's a new line $sql = "INSERT INTO ".TB_PREF."purch_order_details (order_no, item_code, description, delivery_date, unit_price, quantity_ordered) VALUES ("; - $sql .= $po_obj->order_no . ", '" . - $po_line->stock_id . "','" . - $po_line->item_description . "','" . - date2sql($po_line->req_del_date) . "'," . + $sql .= $po_obj->order_no . ", '" . + $po_line->stock_id . "','" . + $po_line->item_description . "','" . + date2sql($po_line->req_del_date) . "'," . $po_line->price . ", " . $po_line->quantity . ")"; - } - else + } + else { - $sql = "UPDATE ".TB_PREF."purch_order_details SET item_code='" . $po_line->stock_id . "', + $sql = "UPDATE ".TB_PREF."purch_order_details SET item_code='" . $po_line->stock_id . "', description ='" . $po_line->item_description . "', - delivery_date ='" . date2sql($po_line->req_del_date) . "', - unit_price=" . $po_line->price . ", - quantity_ordered=" . $po_line->quantity . " + delivery_date ='" . date2sql($po_line->req_del_date) . "', + unit_price=" . $po_line->price . ", + quantity_ordered=" . $po_line->quantity . " WHERE po_detail_item=" . $po_line->po_detail_rec; } db_query($sql, "One of the purchase order detail records could not be updated"); } - - //add_comments(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments); - - commit_transaction(); - - return $po_obj->order_no; + + //add_comments(systypes::po(), $po_obj->order_no, $po_obj->orig_order_date, $po_obj->Comments); + + commit_transaction(); + + return $po_obj->order_no; } //---------------------------------------------------------------------------------------- function read_po_header($order_no, &$order) { - $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, - ".TB_PREF."suppliers.curr_code, ".TB_PREF."locations.location_name - FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations + $sql = "SELECT ".TB_PREF."purch_orders.*, ".TB_PREF."suppliers.supp_name, + ".TB_PREF."suppliers.curr_code, ".TB_PREF."locations.location_name + FROM ".TB_PREF."purch_orders, ".TB_PREF."suppliers, ".TB_PREF."locations WHERE ".TB_PREF."purch_orders.supplier_id = ".TB_PREF."suppliers.supplier_id - AND ".TB_PREF."locations.loc_code = into_stock_location + AND ".TB_PREF."locations.loc_code = into_stock_location AND ".TB_PREF."purch_orders.order_no = " . $order_no; $result = db_query($sql, "The order cannot be retrieved"); - - if (db_num_rows($result) == 1) + + if (db_num_rows($result) == 1) { $myrow = db_fetch($result); - + $order->order_no = $order_no; $order->supplier_id = $myrow["supplier_id"]; $order->supplier_name = $myrow["supp_name"]; $order->curr_code = $myrow["curr_code"]; - + $order->orig_order_date = sql2date($myrow["ord_date"]); $order->Comments = $myrow["comments"]; $order->Location = $myrow["into_stock_location"]; $order->requisition_no = $myrow["requisition_no"]; $order->reference = $myrow["reference"]; $order->delivery_address = $myrow["delivery_address"]; - + return true; - } - + } + display_db_error("FATAL : duplicate purchase order found", "", true); return false; } @@ -158,38 +156,38 @@ function read_po_items($order_no, &$order, $open_items_only=false) { /*now populate the line po array with the purchase order details records */ - $sql = "SELECT ".TB_PREF."purch_order_details.*, units - FROM ".TB_PREF."purch_order_details - LEFT JOIN ".TB_PREF."stock_master - ON ".TB_PREF."purch_order_details.item_code=".TB_PREF."stock_master.stock_id + $sql = "SELECT ".TB_PREF."purch_order_details.*, units + FROM ".TB_PREF."purch_order_details + LEFT JOIN ".TB_PREF."stock_master + ON ".TB_PREF."purch_order_details.item_code=".TB_PREF."stock_master.stock_id WHERE order_no =$order_no "; - + if ($open_items_only) - $sql .= " AND (".TB_PREF."purch_order_details.quantity_ordered > ".TB_PREF."purch_order_details.quantity_received) "; - + $sql .= " AND (".TB_PREF."purch_order_details.quantity_ordered > ".TB_PREF."purch_order_details.quantity_received) "; + $sql .= " ORDER BY po_detail_item"; - $result = db_query($sql, "The lines on the purchase order cannot be retrieved"); + $result = db_query($sql, "The lines on the purchase order cannot be retrieved"); - if (db_num_rows($result) > 0) + if (db_num_rows($result) > 0) { - while ($myrow = db_fetch($result)) + while ($myrow = db_fetch($result)) { if (is_null($myrow["units"])) { $units = ""; - } - else + } + else { $units = $myrow["units"]; } - $order->add_to_order($order->lines_on_order+1, $myrow["item_code"], - $myrow["quantity_ordered"],$myrow["description"], + $order->add_to_order($order->lines_on_order+1, $myrow["item_code"], + $myrow["quantity_ordered"],$myrow["description"], $myrow["unit_price"],$units, sql2date($myrow["delivery_date"]), $myrow["qty_invoiced"], $myrow["quantity_received"]); - + $order->line_items[$order->lines_on_order]->po_detail_rec = $myrow["po_detail_item"]; $order->line_items[$order->lines_on_order]->standard_cost = $myrow["std_cost_unit"]; /*Needed for receiving goods and GL interface */ } /* line po from purchase order details */ @@ -200,10 +198,10 @@ function read_po_items($order_no, &$order, $open_items_only=false) function read_po($order_no, &$order, $open_items_only=false) { - $result = read_po_header($order_no, $order); - + $result = read_po_header($order_no, $order); + if ($result) - read_po_items($order_no, $order, $open_items_only); + read_po_items($order_no, $order, $open_items_only); } //---------------------------------------------------------------------------------------- diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index 7014cec4..38b1d440 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -4,54 +4,52 @@ function add_supp_payment($supplier_id, $date_, $payment_type, $bank_account, $amount, $discount, $ref, $memo_) { begin_transaction(); - + $supplier_currency = get_supplier_currency($supplier_id); $bank_account_currency = get_bank_account_currency($bank_account); - + $supp_amount = exchange_from_to($amount, $bank_account_currency, $supplier_currency, $date_); $supp_discount = exchange_from_to($discount, $bank_account_currency, $supplier_currency, $date_); - + // it's a supplier payment $trans_type = 22; /* Create a supp_trans entry for the supplier payment */ - $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_, - $ref, "", -$supp_amount, 0, -$supp_discount); + $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_, + $ref, "", -$supp_amount, 0, -$supp_discount); - // Now debit creditors account with payment + discount + // Now debit creditors account with payment + discount $supplier_accounts = get_supplier_accounts($supplier_id); - + add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0, - $supp_amount + $supp_discount, $supplier_id); - + $supp_amount + $supp_discount, $supplier_id); + // Now credit discount received account with discounts if ($supp_discount != 0) { add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0, - -$supp_discount, $supplier_id); + -$supp_discount, $supplier_id); } - - if ($supp_amount != 0) + + if ($supp_amount != 0) { add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_account, 0, 0, -$supp_amount, $supplier_id); - } + } /*now enter the bank_trans entry */ - add_bank_trans($trans_type, $payment_id, $bank_account, $ref, - $date_, $payment_type, -($amount), payment_person_types::supplier(), - $supplier_id, $bank_account_currency, + add_bank_trans($trans_type, $payment_id, $bank_account, $ref, + $date_, $payment_type, -($amount), payment_person_types::supplier(), + $supplier_id, $bank_account_currency, "Could not add the supplier payment bank transaction"); - - add_comments($trans_type, $payment_id, $date_, $memo_); - - add_forms_for_sys_type($trans_type, $payment_id, payment_person_types::supplier(), $supplier_id); - - references::save_last($ref, $trans_type); - - commit_transaction(); - + + add_comments($trans_type, $payment_id, $date_, $memo_); + + references::save_last($ref, $trans_type); + + commit_transaction(); + return $payment_id; } @@ -60,12 +58,12 @@ function add_supp_payment($supplier_id, $date_, $payment_type, $bank_account, function void_supp_payment($type, $type_no) { begin_transaction(); - + void_bank_trans($type, $type_no, true); void_gl_trans($type, $type_no, true); - void_supp_allocations($type, $type_no); + void_supp_allocations($type, $type_no); void_supp_trans($type, $type_no); - + commit_transaction(); } diff --git a/reporting/includes/form_types.inc b/reporting/includes/form_types.inc deleted file mode 100644 index 3050a660..00000000 --- a/reporting/includes/form_types.inc +++ /dev/null @@ -1,137 +0,0 @@ - array('code' => 'si', 'name' => _("Sales Invoice")), - 11=> array('code' => 'si', 'name' => _("Sales Credit Note")), - 30=> array('code' => 'so', 'name' => _("Sales Order")), - - 18=> array('code' => 'po', 'name' => _("Purchase Order")), - - 26=> array('code' => 'wo', 'name' => _("Work Order")), - 28=> array('code' => 'wo', 'name' => _("Work Order Issue")), - 29=> array('code' => 'wo', 'name' => _("Work Order Production")), - - 40=> array('code' => 'qw', 'name' => _("Cheque Withdrawal")), - 41=> array('code' => 'qd', 'name' => _("Cheque Deposit")), - - 50=> array('code' => 'cw', 'name' => _("Cash Withdrawal")), - 51=> array('code' => 'cd', 'name' => _("Cash Deposit")), - - 60=> array('code' => 'ir', 'name' => _("Inventory Release")), - 61=> array('code' => 'ia', 'name' => _("Inventory Add")), - 62=> array('code' => 'it', 'name' => _("Inventory Return")) - ); - -function getFormTypeName($type) -{ - global $form_types; - return $form_types[$type]['name']; -} - -function add_forms_for_sys_type($trans_type, $trans_id, $ParamFrom=null, $ParamTo=null) -{ - switch ($trans_type) { - case 1 : // bank payment - case 22 : // payment to supplier - add_form_entry(50, $trans_type, $trans_id, $ParamFrom, $ParamTo); - break; - - case 12: // payment from customer - case 2 : // bank deposit - add_form_entry(51, $trans_type, $trans_id, $ParamFrom, $ParamTo); - break; - - case 4 : // bank transfer - withdraw and deposit - add_form_entry(50, $trans_type, $trans_id, $ParamFrom, $ParamTo); - add_form_entry(51, $trans_type, $trans_id, $ParamTo, $ParamFrom); - break; - - case 10 : // sales invoice - invoice form - add_form_entry(10, $trans_type, $trans_id); - break; - - case 13 : // sales dispatch - inventory release - add_form_entry(60, $trans_type, $trans_id, $ParamFrom); - break; - - case 11 : // sales credit - inventory return and credit note forms - add_form_entry(62, $trans_type, $trans_id, $ParamFrom); - add_form_entry(11, $trans_type, $trans_id); - break; - - case 16 : // location transfer - add_form_entry(60, $trans_type, $trans_id, $ParamFrom); - add_form_entry(61, $trans_type, $trans_id, $ParamTo); - break; - - case systypes::inventory_adjustment() : // inventory adjustment - - // $ParamFrom : if 1 inventory add, 0 inventory release - if ($ParamFrom) - add_form_entry(61, $trans_type, $trans_id, $ParamTo); - else - add_form_entry(60, $trans_type, $trans_id, $ParamTo); - break; - - case systypes::po() : // purchase order - add_form_entry(18, $trans_type, $trans_id); - break; - - case 25 : // purchase order delivery - add_form_entry(61, $trans_type, $trans_id, $ParamFrom); - break; - - case systypes::work_order() : // work order - add_form_entry(26, $trans_type, $trans_id); - break; - - case 28 : // work order issue - // $ParamFrom : if 1 inventory add, 0 inventory release - if ($ParamFrom) - add_form_entry(61, $trans_type, $trans_id, $ParamTo); - else - add_form_entry(60, $trans_type, $trans_id, $ParamTo); - break; - - case 29 : // work order production - // $ParamFrom is the quantity - if +ve inventory add, -ve inventory release - if ($ParamFrom >= 0) - add_form_entry(61, $trans_type, $trans_id, $ParamTo); - else - add_form_entry(60, $trans_type, $trans_id, $ParamTo); - break; - - case 30 : // sales order - sales order form - add_form_entry(30, $trans_type, $trans_id); - break; - } -} - -function add_form_entry($form_type, $trans_type, $trans_id, $param1=null, $param2=null) -{ - $sql = "SELECT max(form_id) FROM ".TB_PREF."form_items WHERE form_type=$form_type"; - $result = db_query($sql, "could not get next form_id"); - $row = db_fetch_row($result); - $form_id = $row[0] + 1; - - $sql = "INSERT INTO ".TB_PREF."form_items (form_id, form_type, trans_type, trans_id, param1, param2) - VALUES ($form_id, $form_type, $trans_type, $trans_id, '$param1', '$param2')"; - $result = db_query($sql, "could not add form entry for $trans_type, $trans_id"); -} - -function delete_forms_for_systype($trans_type, $trans_id) -{ - $sql = "DELETE FROM ".TB_PREF."form_items WHERE trans_type=$trans_type AND trans_id=$trans_id"; - $result = db_query($sql, "could not delete form entry for $trans_type, $trans_id"); -} - -function get_form_entries($trans_type, $trans_id) -{ - $sql = "SELECT * FROM ".TB_PREF."form_items WHERE trans_type=$trans_type AND trans_id=$trans_id"; - $result = db_query($sql, "could not query form entry for $trans_type, $trans_id"); - - return $result; -} - -?> \ No newline at end of file diff --git a/reporting/rep101.php b/reporting/rep101.php index 022212ec..fa6d8328 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -23,8 +23,8 @@ print_customer_balances(); function get_transactions($debtorno, $date) { $date = date2sql($date); - - $sql = "SELECT ".TB_PREF."debtor_trans.*, ".TB_PREF."sys_types.type_name, + + $sql = "SELECT ".TB_PREF."debtor_trans.*, ".TB_PREF."sys_types.type_name, (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount) AS TotalAmount, ".TB_PREF."debtor_trans.alloc AS Allocated, ((".TB_PREF."debtor_trans.type = 10) @@ -70,7 +70,7 @@ function print_customer_balances() _('Allocated'), _('Outstanding')); $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); - + $params = array( 0 => $comments, 1 => array('text' => _('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => _('Customer'), 'from' => $from, 'to' => ''), @@ -91,57 +91,57 @@ function print_customer_balances() $sql .= "ORDER BY name"; $result = db_query($sql, "The customers could not be retrieved"); - while ($myrow = db_fetch($result)) + while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) continue; $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['name']); if ($convert) - { - $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); $rep->TextCol(3, 4, $myrow['curr_code']); - } - else - $rate = 1.0; $rep->fontSize -= 2; $rep->NewLine(1, 2); $res = get_transactions($myrow['debtor_no'], $to); if (db_num_rows($res)==0) continue; $rep->Line($rep->row + 4); - $total[0] = $total[1] = $total[2] = $total[3] = 0.0; + $total[0] = $total[1] = $total[2] = $total[3] = 0.0; while ($trans = db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['reference']); - $rep->TextCol(2, 3, sql2date($trans['tran_date'])); - if ($trans['type'] == 10) + $date = sql2date($trans['tran_date']); + $rep->TextCol(2, 3, $date); + if ($trans['type'] == 10) $rep->TextCol(3, 4, sql2date($trans['due_date'])); - $item[0] = $item[1] = 0.0; - if ($trans['TotalAmount'] > 0.0) + $item[0] = $item[1] = 0.0; + if ($convert) + $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date); + else + $rate = 1.0; + if ($trans['TotalAmount'] > 0.0) { - $item[0] = abs($trans['TotalAmount']) * $rate; + $item[0] = abs($trans['TotalAmount']) * $rate; $rep->TextCol(4, 5, number_format2($item[0], $dec)); - } - else + } + else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = Abs($trans['TotalAmount']) * $rate; $rep->TextCol(5, 6, number_format2($item[1], $dec)); - } + } $item[2] = $trans['Allocated'] * $rate; $rep->TextCol(6, 7, number_format2($item[2], $dec)); if ($trans['type'] == 10) - $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; - else - $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; + else + $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; - } + } } $rep->Line($rep->row - 8); $rep->NewLine(2); diff --git a/reporting/rep105.php b/reporting/rep105.php index ee7d3c21..a5e0ef3c 100644 --- a/reporting/rep105.php +++ b/reporting/rep105.php @@ -26,7 +26,7 @@ function GetSalesOrders($from, $to, $category=0, $location=null, $backorder=0) { $fromdate = date2sql($from); $todate = date2sql($to); - + $sql= "SELECT ".TB_PREF."sales_orders.order_no, ".TB_PREF."sales_orders.debtor_no, ".TB_PREF."sales_orders.branch_code, @@ -38,7 +38,7 @@ function GetSalesOrders($from, $to, $category=0, $location=null, $backorder=0) ".TB_PREF."stock_master.description, ".TB_PREF."stock_master.units, ".TB_PREF."sales_order_details.quantity, - ".TB_PREF."sales_order_details.qty_invoiced + ".TB_PREF."sales_order_details.qty_sent FROM ".TB_PREF."sales_orders INNER JOIN ".TB_PREF."sales_order_details ON ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no @@ -51,20 +51,20 @@ function GetSalesOrders($from, $to, $category=0, $location=null, $backorder=0) if ($location != null) $sql .= " AND ".TB_PREF."sales_orders.from_stk_loc='$location'"; if ($backorder) - $sql .= "AND ".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_invoiced > 0"; - $sql .= " ORDER BY ".TB_PREF."sales_orders.order_no"; - + $sql .= "AND ".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent > 0"; + $sql .= " ORDER BY ".TB_PREF."sales_orders.order_no"; + return db_query($sql, "Error getting order details"); } - + //---------------------------------------------------------------------------------------------------- function print_order_status_list() { global $path_to_root; - + include_once($path_to_root . "reporting/includes/pdf_report.inc"); - + $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; @@ -73,7 +73,7 @@ function print_order_status_list() $comments = $_POST['PARAM_5']; $dec = user_qty_dec(); - + if ($category == reserved_words::get_all_numeric()) $category = 0; if ($location == reserved_words::get_all()) @@ -90,17 +90,17 @@ function print_order_status_list() $back = _('All Orders'); else $back = _('Back Orders Only'); - + $cols = array(0, 60, 150, 260, 325, 385, 450, 515); - + $headers2 = array(_('Order'), _('Customer'), _('Branch'), _('Customer Ref'), _('Ord Date'), _('Del Date'), _('Loc')); - + $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right'); $headers = array(_('Code'), _('Description'), _('Ordered'), _('Invoiced'), _('Outstanding'), ''); - + $params = array( 0 => $comments, 1 => array( 'text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array( 'text' => _('Category'), 'from' => $cat,'to' => ''), @@ -109,7 +109,7 @@ function print_order_status_list() $cols2 = $cols; $aligns2 = $aligns; - + $rep = new FrontReport(_('Order Status Listing'), "OrderStatusListing.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); @@ -118,14 +118,14 @@ function print_order_status_list() $orderno = 0; $result = GetSalesOrders($from, $to, $category, $location, $backorder); - + while ($myrow=db_fetch($result)) { if ($rep->row < $rep->bottomMargin + (2 * $rep->lineHeight)) { $orderno = 0; $rep->Header(); - } + } $rep->NewLine(0, 2, false, $orderno); if ($orderno != $myrow['order_no']) { @@ -142,26 +142,26 @@ function print_order_status_list() $rep->TextCol(5, 6, sql2date($myrow['delivery_date'])); $rep->TextCol(6, 7, $myrow['from_stk_loc']); $rep->NewLine(2); - $orderno = $myrow['order_no']; + $orderno = $myrow['order_no']; } $rep->TextCol(0, 1, $myrow['stk_code']); $rep->TextCol(1, 2, $myrow['description']); $rep->TextCol(2, 3, number_format2($myrow['quantity'], $dec)); $rep->TextCol(3, 4, number_format2($myrow['qty_invoiced'], $dec)); - $rep->TextCol(4, 5, number_format2($myrow['quantity'] - $myrow['qty_invoiced'], $dec)); - if ($myrow['quantity'] - $myrow['qty_invoiced'] > 0) + $rep->TextCol(4, 5, number_format2($myrow['quantity'] - $myrow['qty_sent'], $dec)); + if ($myrow['quantity'] - $myrow['qty_sent'] > 0) { $rep->Font('italic'); $rep->TextCol(5, 6, _('Outstanding')); $rep->Font(); - } + } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + (2 * $rep->lineHeight)) { $orderno = 0; $rep->Header(); - } - } + } + } $rep->Line($rep->row); $rep->End(); } diff --git a/reporting/rep201.php b/reporting/rep201.php index 3a6f1cff..834ca6ce 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -22,8 +22,8 @@ print_supplier_balances(); function getTransactions($supplier_id, $date) { $date = date2sql($date); - - $sql = "SELECT ".TB_PREF."supp_trans.*, ".TB_PREF."sys_types.type_name, + + $sql = "SELECT ".TB_PREF."supp_trans.*, ".TB_PREF."sys_types.type_name, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) AS TotalAmount, ".TB_PREF."supp_trans.alloc AS Allocated, ((".TB_PREF."supp_trans.type = 20) @@ -50,7 +50,7 @@ function print_supplier_balances() $fromsupp = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; - + if ($fromsupp == reserved_words::get_all_numeric()) $from = _('All'); else @@ -91,58 +91,58 @@ function print_supplier_balances() $sql .= "WHERE supplier_id=$fromsupp "; $sql .= "ORDER BY supp_name"; $result = db_query($sql, "The customers could not be retrieved"); - - while ($myrow=db_fetch($result)) + + while ($myrow=db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) continue; $rep->fontSize += 2; $rep->TextCol(0, 3, $myrow['name']); if ($convert) - { - $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to); $rep->TextCol(3, 4, $myrow['curr_code']); - } - else - $rate = 1.0; $rep->fontSize -= 2; $rep->NewLine(1, 2); $res = getTransactions($myrow['supplier_id'], $to); if (db_num_rows($res)==0) continue; $rep->Line($rep->row + 4); - $total[0] = $total[1] = $total[2] = $total[3] = 0.0; + $total[0] = $total[1] = $total[2] = $total[3] = 0.0; while ($trans=db_fetch($res)) { $rep->NewLine(1, 2); $rep->TextCol(0, 1, $trans['type_name']); $rep->TextCol(1, 2, $trans['reference']); - $rep->TextCol(2, 3, sql2date($trans['tran_date'])); - if ($trans['type'] == 20) + $date = sql2date($trans['tran_date']); + $rep->TextCol(2, 3, $date); + if ($trans['type'] == 20) $rep->TextCol(3, 4, sql2date($trans['due_date'])); - $item[0] = $item[1] = 0.0; - if ($trans['TotalAmount'] > 0.0) + $item[0] = $item[1] = 0.0; + if ($convert) + $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date); + else + $rate = 1.0; + if ($trans['TotalAmount'] > 0.0) { - $item[0] = Abs($trans['TotalAmount']) * $rate; + $item[0] = Abs($trans['TotalAmount']) * $rate; $rep->TextCol(4, 5, number_format2($item[0], $dec)); - } - else + } + else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = Abs($trans['TotalAmount']) * $rate; $rep->TextCol(5, 6, number_format2($item[1], $dec)); - } + } $item[2] = $trans['Allocated'] * $rate; $rep->TextCol(6, 7, number_format2($item[2], $dec)); if ($trans['type'] == 20) - $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; - else - $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; + else + $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; - } + } } $rep->Line($rep->row - 8); $rep->NewLine(2); @@ -151,7 +151,7 @@ function print_supplier_balances() { $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec)); $total[$i] = 0.0; - } + } $rep->Line($rep->row - 4); $rep->NewLine(2); } diff --git a/reporting/rep302.php b/reporting/rep302.php index c9255bd2..ba7703cc 100644 --- a/reporting/rep302.php +++ b/reporting/rep302.php @@ -52,7 +52,7 @@ function getTransactions($category, $location) function getCustQty($stockid, $location) { - $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_invoiced) AS qty_demand + $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent) AS qty_demand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND @@ -66,7 +66,7 @@ function getCustQty($stockid, $location) function getCustAsmQty($stockid, $location) { - $sql = "SELECT SUM((".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_invoiced)*".TB_PREF."bom.quantity) + $sql = "SELECT SUM((".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent)*".TB_PREF."bom.quantity) AS Dem FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders, @@ -75,7 +75,7 @@ function getCustAsmQty($stockid, $location) WHERE ".TB_PREF."sales_order_details.stk_code=".TB_PREF."bom.parent AND ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND ".TB_PREF."sales_orders.from_stk_loc='$location' AND - ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_invoiced > 0 AND + ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND ".TB_PREF."bom.component='$stockid' AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.parent AND ".TB_PREF."stock_master.mb_flag='A'"; @@ -141,7 +141,7 @@ function print_inventory_planning() $category = $_POST['PARAM_0']; $location = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; - + $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) @@ -166,7 +166,7 @@ function print_inventory_planning() $per3 = strftime('%b',mktime(0,0,0,date('m')-3,date('d'),date('Y'))); $per4 = strftime('%b',mktime(0,0,0,date('m')-4,date('d'),date('Y'))); - $headers = array(_('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', + $headers = array(_('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', _('QOH'), _('Cust Ord'), _('Supp Ord'), _('Sugg Ord')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', @@ -198,7 +198,7 @@ function print_inventory_planning() $catt = $trans['cat_description']; $rep->NewLine(); } - + $custqty = getCustQty($trans['stock_id'], $trans['loc_code']); $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']); $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']); @@ -211,18 +211,18 @@ function print_inventory_planning() $rep->TextCol(4, 5, number_format2($period['prd2'], $dec)); $rep->TextCol(5, 6, number_format2($period['prd3'], $dec)); $rep->TextCol(6, 7, number_format2($period['prd4'], $dec)); - + $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']); $IdealStockHolding = $MaxMthSales * 3; $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec)); - + $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec)); $rep->TextCol(9, 10, number_format2($custqty, $dec)); $rep->TextCol(10, 11, number_format2($suppqty, $dec)); - + $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty; if ($SuggestedTopUpOrder < 0.0) - $SuggestedTopUpOrder = 0.0; + $SuggestedTopUpOrder = 0.0; $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec)); } $rep->Line($rep->row - 4); diff --git a/reporting/rep303.php b/reporting/rep303.php index 88328304..801561f1 100644 --- a/reporting/rep303.php +++ b/reporting/rep303.php @@ -50,7 +50,7 @@ function getTransactions($category, $location) function getDemandQty($stockid, $location) { - $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_invoiced) AS QtyDemand + $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent) AS QtyDemand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND @@ -64,7 +64,7 @@ function getDemandQty($stockid, $location) function getDemandAsmQty($stockid, $location) { - $sql = "SELECT SUM((".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_invoiced)*".TB_PREF."bom.quantity) + $sql = "SELECT SUM((".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent)*".TB_PREF."bom.quantity) AS Dem FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders, @@ -73,7 +73,7 @@ function getDemandAsmQty($stockid, $location) WHERE ".TB_PREF."sales_order_details.stk_code=".TB_PREF."bom.parent AND ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND ".TB_PREF."sales_orders.from_stk_loc='$location' AND - ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_invoiced > 0 AND + ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND ".TB_PREF."bom.component='$stockid' AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.parent AND ".TB_PREF."stock_master.mb_flag='A'"; @@ -102,7 +102,7 @@ function print_stock_check() $location = $_POST['PARAM_1']; $pictures = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; - + $dec = user_qty_dec(); if ($category == reserved_words::get_all_numeric()) @@ -133,7 +133,7 @@ function print_stock_check() $user_comp = user_company(); else $user_comp = ""; - + $rep = new FrontReport(_('Stock Check Sheets'), "StockCheckSheet.pdf", user_pagesize()); $rep->Font(); @@ -176,7 +176,7 @@ function print_stock_check() $rep->row -= $pic_height; $rep->NewLine(); } - } + } } $rep->Line($rep->row - 4); $rep->End(); diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 0e355efb..c2f7f4ab 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -142,7 +142,7 @@ class cart function write($policy=0) { if (count($this->src_docs) == 0 && ($this->trans_type == 10 || $this->trans_type == 13)) { // direct document -> first add parent - $src = $this; // make local copy of this cart + $src = do_clone($this); $src->trans_type = get_parent_type($src->trans_type); $src->reference = 'auto'; diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 2367c7da..b50d418a 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -111,7 +111,6 @@ function write_sales_delivery(&$delivery,$bo_policy) add_comments(13, $delivery_no, $delivery->document_date, $delivery->Comments); if ($trans_no == 0) { - // add_forms_for_sys_type(13, $delivery_no, $delivery->Location); if ($delivery->reference!='auto') references::save_last($delivery->reference, 13); } diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index 21ba9c5c..0a1683ab 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -134,7 +134,6 @@ function write_sales_invoice(&$invoice) add_comments(10, $invoice_no, $date_, $invoice->Comments); if ($trans_no == 0) { - //add_forms_for_sys_type(10, $invoice_no, $invoice->Location); references::save_last($invoice->reference, 10); } diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index a6c76106..72f54eeb 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -113,8 +113,6 @@ function add_sales_order(&$order) } /* inserted line items into sales order details */ - add_forms_for_sys_type(systypes::sales_order(), $order_no); - commit_transaction(); if ($loc_notification == 1 && count($st_ids) > 0) @@ -150,15 +148,13 @@ 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"); - delete_forms_for_systype(systypes::sales_order(), $order_no); - commit_transaction(); } //---------------------------------------------------------------------------------------- // Mark changes in sales_order_details // -function update_sales_order_version($order) +function update_sales_order_version($order) { foreach ($order as $so_num => $so_ver) { $sql= 'UPDATE '.TB_PREF.'sales_orders SET version=version+1 WHERE order_no='. $so_num. @@ -242,9 +238,9 @@ function update_sales_order($order) } } } - $sql = "INSERT INTO ".TB_PREF."sales_order_details - (order_no, stk_code, description, unit_price, quantity, - discount_percent, qty_sent) + $sql = "INSERT INTO ".TB_PREF."sales_order_details + (order_no, stk_code, description, unit_price, quantity, + discount_percent, qty_sent) VALUES ("; $sql .= $order_no . ",'" .$line->stock_id . "','" @@ -269,8 +265,8 @@ function update_sales_order($order) $subject = _("Stocks below Re-Order Level at " . $loc['location_name']); $msg = "\n"; for ($i = 0; $i < count($st_ids); $i++) - $msg .= $st_ids[$i] . " " . $st_names[$i] . ", " - . _("Re-Order Level") . ": " . $st_reorder[$i] . ", " + $msg .= $st_ids[$i] . " " . $st_names[$i] . ", " + . _("Re-Order Level") . ": " . $st_reorder[$i] . ", " . _("Below") . ": " . $st_num[$i] . "\n"; $msg .= "\n" . _("Please reorder") . "\n\n"; $msg .= $company['coy_name']; @@ -332,7 +328,7 @@ function get_sales_order_header($order_no) function get_sales_order_details($order_no) { $sql = "SELECT id, stk_code, unit_price, " .TB_PREF."sales_order_details.description," - .TB_PREF."sales_order_details.quantity, + .TB_PREF."sales_order_details.quantity, discount_percent, qty_sent as qty_done, " .TB_PREF."stock_master.units, @@ -355,7 +351,7 @@ function read_sales_order($order_no, &$order) $order->so_type = $myrow["type"]; $order->trans_no = array($order_no=> $myrow["version"]); - $order->set_customer($myrow["debtor_no"], $myrow["name"], + $order->set_customer($myrow["debtor_no"], $myrow["name"], $myrow["curr_code"], $myrow["discount"]); $order->set_branch($myrow["branch_code"], $myrow["tax_group_id"], @@ -365,9 +361,9 @@ function read_sales_order($order_no, &$order) $order->set_location($myrow["from_stk_loc"], $myrow["location_name"]); - $order->set_delivery($myrow["ship_via"], $myrow["deliver_to"], + $order->set_delivery($myrow["ship_via"], $myrow["deliver_to"], $myrow["delivery_address"], $myrow["freight_cost"]); - + $order->cust_ref = $myrow["customer_ref"]; $order->default_sales_type =$myrow["order_type"]; $order->Comments = $myrow["comments"]; @@ -465,7 +461,7 @@ function get_customer_to_order($customer_id) { } function get_branch_to_order($customer_id, $branch_id) { - + // the branch was also selected from the customer selection so default the delivery details from the customer branches table cust_branch. The order process will ask for branch details later anyway $sql = "SELECT ".TB_PREF."cust_branch.br_name, " .TB_PREF."cust_branch.br_address, " diff --git a/sql/alter.sql b/sql/alter.sql index 40f391c0..3a98d59f 100644 --- a/sql/alter.sql +++ b/sql/alter.sql @@ -16,6 +16,7 @@ -- ALTER TABLE -- +DROP TABLE IF EXISTS `0_form_items`; ALTER TABLE `0_tax_types` DROP INDEX `name`, ADD UNIQUE `name` ( `name` , `rate` ); -- 2.30.2