From ddadb47f2620ce6902ad4694ce6512568862ba05 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Mon, 14 Sep 2009 21:34:56 +0000 Subject: [PATCH] Changed all numeric constants to the new defined constants. A huge task. --- CHANGELOG.txt | 81 ++++++++++++++ admin/db/voiding_db.inc | 34 +++--- admin/fiscalyears.php | 8 +- admin/forms_setup.php | 2 +- admin/view_print_transaction.php | 4 +- admin/void_transaction.php | 36 +++--- gl/includes/db/gl_db_banking.inc | 6 +- gl/includes/db/gl_db_trans.inc | 22 ++-- gl/inquiry/journal_inquiry.php | 4 +- includes/systypes.inc | 48 ++++---- includes/ui/allocation_cart.inc | 4 +- includes/ui/ui_view.inc | 32 +++--- inventory/inquiry/stock_movements.php | 8 +- .../includes/db/work_order_issues_db.inc | 12 +- .../db/work_order_produce_items_db.inc | 12 +- manufacturing/view/wo_production_view.php | 4 +- .../allocations/supplier_allocation_main.php | 2 +- purchasing/includes/db/grn_db.inc | 18 +-- purchasing/includes/db/invoice_db.inc | 41 ++++--- purchasing/includes/db/supp_payment_db.inc | 2 +- purchasing/includes/db/supp_trans_db.inc | 12 +- purchasing/includes/db/suppalloc_db.inc | 4 +- purchasing/includes/db/suppliers_db.inc | 2 +- purchasing/includes/ui/grn_ui.inc | 2 +- purchasing/includes/ui/invoice_ui.inc | 8 +- .../inquiry/supplier_allocation_inquiry.php | 14 +-- purchasing/inquiry/supplier_inquiry.php | 14 +-- purchasing/po_receive_items.php | 9 +- purchasing/supplier_credit.php | 4 +- purchasing/supplier_invoice.php | 6 +- purchasing/supplier_payment.php | 6 +- purchasing/view/view_grn.php | 2 +- purchasing/view/view_po.php | 2 +- purchasing/view/view_supp_credit.php | 10 +- purchasing/view/view_supp_invoice.php | 8 +- purchasing/view/view_supp_payment.php | 8 +- reporting/includes/reporting.inc | 4 +- reporting/includes/reports_classes.inc | 14 +-- reporting/rep101.php | 18 +-- reporting/rep102.php | 6 +- reporting/rep103.php | 2 +- reporting/rep105.php | 2 +- reporting/rep106.php | 2 +- reporting/rep107.php | 12 +- reporting/rep108.php | 8 +- reporting/rep109.php | 4 +- reporting/rep110.php | 8 +- reporting/rep111.php | 4 +- reporting/rep201.php | 10 +- reporting/rep202.php | 2 +- reporting/rep203.php | 4 +- reporting/rep304.php | 2 +- reporting/rep409.php | 2 +- reporting/rep709.php | 8 +- sales/create_recurrent_invoices.php | 8 +- sales/credit_note_entry.php | 8 +- sales/customer_credit_invoice.php | 21 ++-- sales/customer_delivery.php | 22 ++-- sales/customer_invoice.php | 22 ++-- sales/customer_payments.php | 6 +- sales/includes/cart_class.inc | 30 ++--- sales/includes/db/cust_trans_db.inc | 16 +-- sales/includes/db/custalloc_db.inc | 10 +- sales/includes/db/payment_db.inc | 26 ++--- sales/includes/db/sales_credit_db.inc | 54 ++++----- sales/includes/db/sales_delivery_db.inc | 30 ++--- sales/includes/db/sales_invoice_db.inc | 40 +++---- sales/includes/db/sales_order_db.inc | 4 +- sales/includes/sales_db.inc | 6 +- sales/includes/ui/sales_order_ui.inc | 22 ++-- sales/inquiry/customer_allocation_inquiry.php | 14 +-- sales/inquiry/customer_inquiry.php | 34 +++--- sales/inquiry/sales_deliveries_view.php | 6 +- sales/inquiry/sales_orders_view.php | 26 ++--- sales/manage/recurrent_invoices.php | 2 +- sales/sales_order_entry.php | 104 +++++++++--------- sales/view/view_credit.php | 12 +- sales/view/view_dispatch.php | 12 +- sales/view/view_invoice.php | 14 +-- sales/view/view_sales_order.php | 14 +-- 80 files changed, 624 insertions(+), 542 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3ea230c1..f1d2169e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,87 @@ Legend: ! -> Note $ -> Affected files +14-Sep-2009 Joe Hunt +! Changed all numeric constants to the new defined constants. A huge task. +$ /admin/fiscalyears.php + /admin/forms_setup.php + /admin/view_print_transaction.php + /admin/void_transaction.php + /gl/includes/db/gl_db_banking.inc + /gl_includes/db/gl_db_trans.inc + /gl/inquiry/journal_inquiry.php + /includes/systypes.inc + /includes/ui/allocation_cart.inc + /includes/ui/ui_view.inc + /inventory/inquiry/stock_movements.php + /manufacturing/includes/db/work_order_issues_db.inc + /manufacturing/includes/db/work_order_produce_items.inc + /manufacturing/view/wo_production_view.php + /purchasing/po_receive_items.php + /purchasing/supplier_credit.php + /purchasing/supplier_invoice.php + /purchasing/supplier_payment.php + /purchasing/allocations/supplier_allocation_main.php + /purchasing/includes/db/grn_db.inc + /purchasing/includes/db/invoice_db.inc + /purchasing/includes/db/suballoc_db.inc + /purchasing/includes/db/suppliers_db.inc + /purchasing/includes/db/supp_payment_db.inc + /purchasing/includes/db/supp_trans_db.inc + /purchasing/includes/ui/grn_ui.inc + /purchasing/includes/ui/invoice_ui.inc + /purchasing/inquiry/supplier_allocation_inquiry.php + /purchasing/inquiry/supplier_inquiry.php + /purchasing/view/view_grn.php + /purchasing/view/view_po.php + /purchasing/view/view_supp_credit.php + /purchasing/view/view_supp_invoice.php + /purchasing/view/view_supp_payment.php + /reporting/rep101.php + /reporting/rep102.php + /reporting/rep103.php + /reporting/rep105.php + /reporting/rep106.php + /reporting/rep107.php + /reporting/rep108.php + /reporting/rep109.php + /reporting/rep110.php + /reporting/rep111.php + /reporting/rep201.php + /reporting/rep202.php + /reporting/rep203.php + /reporting/rep304.php + /reporting/rep409.php + /reporting/rep709.php + /reporting/includes/reporting.inc + /reporting/includes/reports_classes.inc + /sales/create_recurrent_invoices.php + /sales/credit_note_entry.php + /sales/customer_credit_invoice.php + /sales/customer_delivery.php + /sales/customer_invoice.php + /sales/customer_payments.php + /sales/sales_order_entry.php + /sales/includes/cart_class.inc + /sales/includes/sales_db.inc + /sales/includes/db/custalloc_db.inc + /sales/includes/db/cust_trans_db.inc + /sales/includes/db/payment_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + /sales/includes/db/sales_order_db.inc + /sales/includes/ui/sales_order_ui.inc + /sales/inquiry/customer_allocation_inquiry.php + /sales/inquiry/customer_inquiry.php + /sales/inquiry/sales_deliveries_view.php + /sales/inquiry/sales_orders_view.php + /sales/manage/recurrent_invoices.php + /sales/view/view_credit.php + /sales/view/view_dispatch.php + /sales/view/view_invoice.php + /sales/view/view_sales_order.php + 13-Sep-2009 Janusz Dobrowolski ! Eliminated non-static method calls and some more fixes to avoid log warnings on both php 4 and 5: Classes systypes, bank_account_types, payment_person_types, wo_types, reserved replaced by diff --git a/admin/db/voiding_db.inc b/admin/db/voiding_db.inc index e8a3f14f..8efc0036 100644 --- a/admin/db/voiding_db.inc +++ b/admin/db/voiding_db.inc @@ -22,24 +22,24 @@ function void_transaction($type, $type_no, $date_, $memo_) return false; switch ($type) { - case 0 : // it's a journal entry + case ST_JOURNAL : // it's a journal entry if (!exists_gl_trans($type, $type_no)) return false; void_journal_trans($type, $type_no); break; - case 1 : // it's a payment - case 2 : // it's a deposit - case 4 : // it's a transfer + case ST_BANKPAYMENT : // it's a payment + case ST_BANKDEPOSIT : // it's a deposit + case ST_BANKTRANSFER : // it's a transfer if (!exists_bank_trans($type, $type_no)) return false; void_bank_trans($type, $type_no); break; - case 10 : // it's a customer invoice - case 11 : // it's a customer credit note - case 12 : // it's a customer payment - case 13 : // it's a customer dispatch + case ST_SALESINVOICE : // it's a customer invoice + case ST_CUSTCREDIT : // it's a customer credit note + case ST_CUSTPAYMENT : // it's a customer payment + case ST_CUSTDELIVERY : // it's a customer dispatch if (!exists_customer_trans($type, $type_no)) return false; if ($type == 13) // added 04 Oct 2008 by Joe Hunt. If delivery note has a not voided invoice, then NO. @@ -66,12 +66,12 @@ function void_transaction($type, $type_no, $date_, $memo_) void_stock_adjustment($type_no); break; - case 18 : // it's a PO - case 25 : // it's a GRN + case ST_PURCHORDER : // it's a PO + case ST_SUPPRECEIVE : // it's a GRN return false; - case 20 : // it's a suppler invoice - case 21 : // it's a supplier credit note - case 22 : // it's a supplier payment + case ST_SUPPINVOICE : // it's a suppler invoice + case ST_SUPPCREDIT : // it's a supplier credit note + case ST_SUPPAYMENT : // it's a supplier payment if (!exists_supp_trans($type, $type_no)) return false; if (!post_void_supp_trans($type, $type_no)) @@ -84,20 +84,20 @@ function void_transaction($type, $type_no, $date_, $memo_) void_work_order($type_no); break; - case 28 : // it's a work order issue + case ST_MANUISSUE : // it's a work order issue if (!exists_work_order_issue($type_no)) return false; void_work_order_issue($type_no); break; - case 29 : // it's a work order production + case ST_MANURECEIVE : // it's a work order production if (!exists_work_order_produce($type_no)) return false; void_work_order_produce($type_no); break; - case 30: // it's a sales order - case 32: // it's a sales quotation + case ST_SALESORDER: // it's a sales order + case ST_SALESQUOTE: // it's a sales quotation return false; case ST_COSTUPDATE : // it's a stock cost update diff --git a/admin/fiscalyears.php b/admin/fiscalyears.php index e7a2ff74..abff8a96 100644 --- a/admin/fiscalyears.php +++ b/admin/fiscalyears.php @@ -262,14 +262,14 @@ function delete_this_fiscalyear($selected_id) $result = db_query($sql, "Could not retrieve debtor trans"); while ($row = db_fetch($result)) { - if ($row['type'] == 10) + if ($row['type'] == ST_SALESINVOICE) { - $deliveries = get_parent_trans(10,$row['trans_no']); + $deliveries = get_parent_trans(ST_SALESINVOICE,$row['trans_no']); foreach ($deliveries as $delivery) { - $sql = "DELETE FROM ".TB_PREF."debtor_trans_details WHERE debtor_trans_no = $delivery AND debtor_trans_type = 13"; + $sql = "DELETE FROM ".TB_PREF."debtor_trans_details WHERE debtor_trans_no = $delivery AND debtor_trans_type = ".ST_CUSTDELIVERY; db_query($sql, "Could not delete debtor trans details"); - $sql = "DELETE FROM ".TB_PREF."debtor_trans WHERE trans_no = $delivery AND type = 13"; + $sql = "DELETE FROM ".TB_PREF."debtor_trans WHERE trans_no = $delivery AND type = ".ST_CUSTDELIVERY; db_query($sql, "Could not delete debtor trans"); } } diff --git a/admin/forms_setup.php b/admin/forms_setup.php index bb21dc36..9a6be87a 100644 --- a/admin/forms_setup.php +++ b/admin/forms_setup.php @@ -48,7 +48,7 @@ table_header($th); $i = 0; while ($type = db_fetch($systypes)) { - if ($i++ == 11) + if ($i++ == ST_CUSTCREDIT) { table_section(2); table_header($th); diff --git a/admin/view_print_transaction.php b/admin/view_print_transaction.php index aca82ee8..ec5e0f2d 100644 --- a/admin/view_print_transaction.php +++ b/admin/view_print_transaction.php @@ -33,7 +33,7 @@ function view_link($trans) function prt_link($row) { - if ($row['type'] != 12 && $row['type'] != 2) // customer payment or bank deposit printout not defined yet. + if ($row['type'] != ST_CUSTPAYMENT && $row['type'] != ST_BANKDEPOSIT) // customer payment or bank deposit printout not defined yet. return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT); } @@ -119,7 +119,7 @@ function handle_search() $print_type = $_POST['filterType']; - $print_out = ($print_type == 10 || $print_type == 11 || $print_type == ST_CUSTDELIVERY || + $print_out = ($print_type == ST_SALESINVOICE || $print_type == ST_CUSTCREDIT || $print_type == ST_CUSTDELIVERY || $print_type == ST_PURCHORDER || $print_type == ST_SALESORDER || $print_type == ST_SALESQUOTE); $cols = array( diff --git a/admin/void_transaction.php b/admin/void_transaction.php index 23cb4237..55c6a9f0 100644 --- a/admin/void_transaction.php +++ b/admin/void_transaction.php @@ -36,22 +36,22 @@ function exist_transaction($type, $type_no) switch ($type) { - case 0 : // it's a journal entry + case ST_JOURNAL : // it's a journal entry if (!exists_gl_trans($type, $type_no)) return false; break; - case 1 : // it's a payment - case 2 : // it's a deposit - case 4 : // it's a transfer + case ST_BANKPAYMENT : // it's a payment + case ST_BANKDEPOSIT : // it's a deposit + case ST_BANKTRANSFER : // it's a transfer if (!exists_bank_trans($type, $type_no)) return false; break; - case 10 : // it's a customer invoice - case 11 : // it's a customer credit note - case 12 : // it's a customer payment - case 13 : // it's a customer dispatch + case ST_SALESINVOICE : // it's a customer invoice + case ST_CUSTCREDIT : // it's a customer credit note + case ST_CUSTPAYMENT : // it's a customer payment + case ST_CUSTDELIVERY : // it's a customer dispatch if (!exists_customer_trans($type, $type_no)) return false; break; @@ -66,12 +66,12 @@ function exist_transaction($type, $type_no) return false; break; - case 18 : // it's a PO - case 25 : // it's a GRN + case ST_PURCHORDER : // it's a PO + case ST_SUPPRECEIVE : // it's a GRN return false; - case 20 : // it's a suppler invoice - case 21 : // it's a supplier credit note - case 22 : // it's a supplier payment + case ST_SUPPINVOICE : // it's a suppler invoice + case ST_SUPPCREDIT : // it's a supplier credit note + case ST_SUPPAYMENT : // it's a supplier payment if (!exists_supp_trans($type, $type_no)) return false; break; @@ -81,18 +81,18 @@ function exist_transaction($type, $type_no) return false; break; - case 28 : // it's a work order issue + case ST_MANUISSUE : // it's a work order issue if (!exists_work_order_issue($type_no)) return false; break; - case 29 : // it's a work order production + case ST_MANURECEIVE : // it's a work order production if (!exists_work_order_produce($type_no)) return false; break; - case 30: // it's a sales order - case 32: // it's a sales quotation + case ST_SALESORDER: // it's a sales order + case ST_SALESQUOTE: // it's a sales quotation return false; case ST_COSTUPDATE : // it's a stock cost update return false; @@ -135,7 +135,7 @@ function voiding_controls() else { display_warning(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1); - if ($_POST['filterType'] == 0) // GL transaction are not included in get_trans_view_str + if ($_POST['filterType'] == ST_JOURNAL) // GL transaction are not included in get_trans_view_str $view_str = get_gl_view_str($_POST['filterType'],$_POST['trans_no'], _("View Transaction")); else $view_str = get_trans_view_str($_POST['filterType'],$_POST['trans_no'], _("View Transaction")); diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index cc028ac7..b20644c5 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -41,11 +41,11 @@ function add_exchange_variation($trans_type, $trans_no, $date_, $acc_id, $accoun function add_exchange_variation_all() { - $trans_no = get_next_trans_no(0); + $trans_no = get_next_trans_no(ST_JOURNAL); $sql = "SELECT * FROM ".TB_PREF."bank_accounts"; $result = db_query($sql, "could not retreive bank accounts"); while ($myrow = db_fetch($result)) - add_exchange_variation(0, $trans_no, null, $myrow['id'], $myrow['account_code'], + add_exchange_variation(ST_JOURNAL, $trans_no, null, $myrow['id'], $myrow['account_code'], $myrow['currency_code']); } //---------------------------------------------------------------------------------- @@ -189,7 +189,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, { $is_bank_to = is_bank_account($gl_item->code_id); - if ($trans_type == 1 AND $is_bank_to) + if ($trans_type == ST_BANKPAYMENT 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", ""); diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 723ea087..3776a0f0 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -329,21 +329,21 @@ function get_tax_summary($from, $to) $todate = date2sql($to); $sql = "SELECT - SUM(IF(trans_type=11 || trans_type=20,-1,1)* - IF(trans_type=2 || trans_type=10 || trans_type=11, net_amount*ex_rate,0)) net_output, - SUM(IF(trans_type=11 || trans_type=20,-1,1)* - IF(trans_type=2 || trans_type=10 || trans_type=11, amount*ex_rate,0)) payable, - SUM(IF(trans_type=11 || trans_type=20,-1,1)* - IF(trans_type=2 || trans_type=10 || trans_type=11, 0, net_amount*ex_rate)) net_input, - SUM(IF(trans_type=11 || trans_type=20,-1,1)* - IF(trans_type=2 || trans_type=10 || trans_type=11, 0, amount*ex_rate)) collectible, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", net_amount*ex_rate,0)) net_output, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", amount*ex_rate,0)) payable, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, net_amount*ex_rate)) net_input, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, amount*ex_rate)) collectible, taxrec.rate, ttype.id, ttype.name FROM ".TB_PREF."tax_types ttype, ".TB_PREF."trans_tax_details taxrec WHERE taxrec.tax_type_id=ttype.id - AND taxrec.trans_type != 13 + AND taxrec.trans_type != ".ST_CUSTDELIVERY." AND taxrec.tran_date >= '$fromdate' AND taxrec.tran_date <= '$todate' GROUP BY ttype.id"; @@ -390,7 +390,7 @@ function write_journal_entries(&$cart, $reverse) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? 2 : 1), $trans_id, -$journal_item->amount, 1, $date_, $memo_); + ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, -$journal_item->amount, 1, $date_, $memo_); } if ($new) { @@ -427,7 +427,7 @@ function write_journal_entries(&$cart, $reverse) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? 2 : 1), $trans_id, $journal_item->amount, 1, $date, $memo_); + ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, $journal_item->amount, 1, $date, $memo_); } add_comments($trans_type, $trans_id_reverse, $reversingDate, $memo_); diff --git a/gl/inquiry/journal_inquiry.php b/gl/inquiry/journal_inquiry.php index fee17602..2eb935e7 100644 --- a/gl/inquiry/journal_inquiry.php +++ b/gl/inquiry/journal_inquiry.php @@ -84,14 +84,14 @@ $editors = array( // 1=> Bank Payment, // 2=> Bank Deposit, // 4=> Funds Transfer, - 10=> "/sales/customer_invoice.php?ModifyInvoice=%d", + ST_SALESINVOICE => "/sales/customer_invoice.php?ModifyInvoice=%d", // 11=> // free hand (debtors_trans.order_==0) // "/sales/credit_note_entry.php?ModifyCredit=%d" // credit invoice // "/sales/customer_credit_invoice.php?ModifyCredit=%d" // 12=> Customer Payment, - 13=> "/sales/customer_delivery.php?ModifyDelivery=%d", + ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d", // 16=> Location Transfer, // 17=> Inventory Adjustment, // 20=> Supplier Invoice, diff --git a/includes/systypes.inc b/includes/systypes.inc index a736f129..9f93fd54 100644 --- a/includes/systypes.inc +++ b/includes/systypes.inc @@ -37,30 +37,30 @@ function get_systype_db_info($type) { switch ($type) { - case 0 : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date"); - case 1 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); - case 2 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); - case 3 : return null; - case 4 : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); - case 10 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); - case 11 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); - case 12 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); - case 13 : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); - case 16 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); - case 17 : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); - case 18 : return array("".TB_PREF."purch_orders", null, "order_no", "reference", "tran_date"); - case 20 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); - case 21 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); - case 22 : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); - case 25 : return array("".TB_PREF."grn_batch", null, "id", "reference", "delivery_date"); - case 26 : return array("".TB_PREF."workorders", null, "id", "wo_ref", "released_date"); - case 28 : return array("".TB_PREF."wo_issues", null, "issue_no", "reference", "issue_date"); - case 29 : return array("".TB_PREF."wo_manufacture", null, "id", "reference", "date_"); - case 30 : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); - case 31 : return array("".TB_PREF."service_orders", null, "order_no", "cust_ref", "date"); - case 32 : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); - case 40 : return array("".TB_PREF."dimensions", null, "id", "reference", "date_"); - case 35 : return null; + case ST_JOURNAL : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date"); + case ST_BANKPAYMENT : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); + case ST_BANKDEPOSIT : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); + case 3 : return null; + case ST_BANKTRANSFER : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); + case ST_SALESINVOICE : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); + case ST_CUSTCREDIT : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); + case ST_CUSTPAYMENT : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); + case ST_CUSTDELIVERY : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); + case ST_LOCTRANSFER : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); + case ST_INVADJUST : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); + case ST_PURCHORDER : return array("".TB_PREF."purch_orders", null, "order_no", "reference", "tran_date"); + case ST_SUPPINVOICE : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); + case ST_SUPPCREDIT : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); + case ST_SUPPAYMENT : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); + case ST_SUPPRECEIVE : return array("".TB_PREF."grn_batch", null, "id", "reference", "delivery_date"); + case ST_WORKORDER : return array("".TB_PREF."workorders", null, "id", "wo_ref", "released_date"); + case ST_MANUISSUE : return array("".TB_PREF."wo_issues", null, "issue_no", "reference", "issue_date"); + case ST_MANURECEIVE : return array("".TB_PREF."wo_manufacture", null, "id", "reference", "date_"); + case ST_SALESORDER : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); + case 31 : return array("".TB_PREF."service_orders", null, "order_no", "cust_ref", "date"); + case ST_SALESQUOTE : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); + case ST_DIMENSION : return array("".TB_PREF."dimensions", null, "id", "reference", "date_"); + case ST_COSTUPDATE : return null; } display_db_error("invalid type ($type) sent to get_systype_db_info", "", true); diff --git a/includes/ui/allocation_cart.inc b/includes/ui/allocation_cart.inc index e1f45ce1..45bc0e82 100644 --- a/includes/ui/allocation_cart.inc +++ b/includes/ui/allocation_cart.inc @@ -92,7 +92,7 @@ class allocation $trans_no = $this->trans_no; } - $sup = $type == 21 || $type == 22; + $sup = $type == ST_SUPPCREDIT || $type == ST_SUPPAYMENT; $this->allocs = array(); if ($trans_no) { @@ -155,7 +155,7 @@ class allocation // function write() { - $sup = $this->type == 21 || $this->type == 22; + $sup = $this->type == ST_SUPPCREDIT || $this->type == ST_SUPPAYMENT; begin_transaction(); diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 2d4f120c..9a0d9cce 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -20,13 +20,13 @@ function get_supplier_trans_view_str($type, $trans_no, $label="", $icon=false, $viewer = "purchasing/view/"; if ($type == ST_PURCHORDER) $viewer .= "view_po.php"; - elseif ($type == 20) + elseif ($type == ST_SUPPINVOICE) $viewer .= "view_supp_invoice.php"; - elseif ($type == 21) + elseif ($type == ST_SUPPCREDIT) $viewer .= "view_supp_credit.php"; - elseif ($type == 22) + elseif ($type == ST_SUPPAYMENT) $viewer .= "view_supp_payment.php"; - elseif ($type == 25) + elseif ($type == ST_SUPPRECEIVE) $viewer .= "view_grn.php"; else return null; @@ -73,15 +73,15 @@ function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false, { $viewer = "sales/view/"; - if ($type == 10) + if ($type == ST_SALESINVOICE) $viewer .= "view_invoice.php"; - elseif ($type == 11) + elseif ($type == ST_CUSTCREDIT) $viewer .= "view_credit.php"; - elseif ($type == 12) + elseif ($type == ST_CUSTPAYMENT) $viewer .= "view_receipt.php"; - elseif ($type == 13) + elseif ($type == ST_CUSTDELIVERY) $viewer .= "view_dispatch.php"; - elseif ($type == 30 || $type == 32) + elseif ($type == ST_SALESORDER || $type == ST_SALESQUOTE) $viewer .= "view_sales_order.php"; else return null; @@ -111,11 +111,11 @@ function get_banking_trans_view_str($type, $trans_no, $label="", if ($label == "") $label = $trans_no; - if ($type == 4) + if ($type == ST_BANKTRANSFER) $viewer = "bank_transfer_view.php"; - elseif ($type == 1) + elseif ($type == ST_BANKPAYMENT) $viewer = "gl_payment_view.php"; - elseif ($type == 2) + elseif ($type == ST_BANKDEPOSIT) $viewer = "gl_deposit_view.php"; else return null; @@ -152,9 +152,9 @@ function get_manufacturing_trans_view_str($type, $trans_no, $label="", { $viewer = "manufacturing/view/"; - if ($type == 28) + if ($type == ST_MANUISSUE) $viewer .= "wo_issue_view.php"; - elseif ($type == 29) + elseif ($type == ST_MANURECEIVE) $viewer .= "wo_production_view.php"; elseif ($type == ST_WORKORDER) $viewer .= "work_order_view.php"; @@ -174,7 +174,7 @@ function get_manufacturing_trans_view_str($type, $trans_no, $label="", function get_dimensions_trans_view_str($type, $trans_no, $label="", $icon=false, $class='', $id='') { - if ($type == 40) + if ($type == ST_DIMENSION) $viewer = "dimensions/view/view_dimension.php?trans_no=$trans_no"; else return null; @@ -190,7 +190,7 @@ function get_dimensions_trans_view_str($type, $trans_no, $label="", $icon=false, function get_journal_trans_view_str($type, $trans_no, $label="", $icon=false, $class='', $id='') { - if ($type == 0 || $type == 35) + if ($type == ST_JOURNAL || $type == ST_COSTUPDATE) $viewer = "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no"; else return null; diff --git a/inventory/inquiry/stock_movements.php b/inventory/inquiry/stock_movements.php index bf80e27a..6b83d045 100644 --- a/inventory/inquiry/stock_movements.php +++ b/inventory/inquiry/stock_movements.php @@ -136,7 +136,7 @@ while ($myrow = db_fetch($result)) $person = $myrow["person_id"]; $gl_posting = ""; - if (($myrow["type"] == 13) || ($myrow["type"] == 11)) + if (($myrow["type"] == ST_CUSTDELIVERY) || ($myrow["type"] == ST_CUSTCREDIT)) { $cust_row = get_customer_details_from_trans($myrow["type"], $myrow["trans_no"]); @@ -144,7 +144,7 @@ while ($myrow = db_fetch($result)) $person = $cust_row['name'] . " (" . $cust_row['br_name'] . ")"; } - elseif ($myrow["type"] == 25 || $myrow['type'] == 21) + elseif ($myrow["type"] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT) { // get the supplier name $sql = "SELECT supp_name FROM ".TB_PREF."suppliers WHERE supplier_id = '" . $myrow["person_id"] . "'"; @@ -161,8 +161,8 @@ while ($myrow = db_fetch($result)) $movement_type = get_movement_type($myrow["person_id"]); $person = $movement_type["name"]; } - elseif ($myrow["type"]==ST_WORKORDER || $myrow["type"] == 28 || - $myrow["type"] == 29) + elseif ($myrow["type"]==ST_WORKORDER || $myrow["type"] == ST_MANUISSUE || + $myrow["type"] == ST_MANURECEIVE) { $person = ""; } diff --git a/manufacturing/includes/db/work_order_issues_db.inc b/manufacturing/includes/db/work_order_issues_db.inc index d9361bda..0e0999b0 100644 --- a/manufacturing/includes/db/work_order_issues_db.inc +++ b/manufacturing/includes/db/work_order_issues_db.inc @@ -49,7 +49,7 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w $item->quantity = -$item->quantity; // insert a -ve stock move for each item - add_stock_move(28, $item->stock_id, $number, + add_stock_move(ST_MANUISSUE, $item->stock_id, $number, $location, $date_, $memo_, -$item->quantity, 0); $sql = "INSERT INTO ".TB_PREF."wo_issue_items (issue_id, stock_id, qty_issued) @@ -58,10 +58,10 @@ function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $w } if ($memo_) - add_comments(28, $number, $date_, $memo_); + add_comments(ST_MANUISSUE, $number, $date_, $memo_); - $Refs->save(28, $number, $ref); - add_audit_trail(28, $number, $date_); + $Refs->save(ST_MANUISSUE, $number, $ref); + add_audit_trail(ST_MANUISSUE, $number, $date_); commit_transaction(); } @@ -132,10 +132,10 @@ function void_work_order_issue($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_stock_move(ST_MANUISSUE, $type_no); // void any related gl trans - void_gl_trans(28, $type_no, true); + void_gl_trans(ST_MANUISSUE, $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 695e696d..a6233050 100644 --- a/manufacturing/includes/db/work_order_produce_items_db.inc +++ b/manufacturing/includes/db/work_order_produce_items_db.inc @@ -46,17 +46,17 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo) // ------------------------------------------------------------------------- // insert a +ve stock move for the item being manufactured // negative means "unproduce" or unassemble - add_stock_move(29, $details["stock_id"], $id, + add_stock_move(ST_MANURECEIVE, $details["stock_id"], $id, $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_comments(ST_MANURECEIVE, $id, $date_, $memo_); - $Refs->save(29, $id, $ref); - add_audit_trail(29, $id, $date_, _("Production.")); + $Refs->save(ST_MANURECEIVE, $id, $ref); + add_audit_trail(ST_MANURECEIVE, $id, $date_, _("Production.")); commit_transaction(); } @@ -109,10 +109,10 @@ function void_work_order_produce($type_no) db_query($sql, "Cannot void a wo production"); // void all related stock moves - void_stock_move(29, $type_no); + void_stock_move(ST_MANURECEIVE, $type_no); // void any related gl trans - void_gl_trans(29, $type_no, true); + void_gl_trans(ST_MANURECEIVE, $type_no, true); commit_transaction(); } diff --git a/manufacturing/view/wo_production_view.php b/manufacturing/view/wo_production_view.php index f3690b5e..ae486646 100644 --- a/manufacturing/view/wo_production_view.php +++ b/manufacturing/view/wo_production_view.php @@ -56,11 +56,11 @@ function display_wo_production($prod_id) label_cell(sql2date($myrow["date_"])); end_row(); - comments_display_row(29, $prod_id); + comments_display_row(ST_MANURECEIVE, $prod_id); end_table(1); - is_voided_display(29, $prod_id, _("This production has been voided.")); + is_voided_display(ST_MANURECEIVE, $prod_id, _("This production has been voided.")); } //------------------------------------------------------------------------------------------------- diff --git a/purchasing/allocations/supplier_allocation_main.php b/purchasing/allocations/supplier_allocation_main.php index 69d342fa..06e24e4f 100644 --- a/purchasing/allocations/supplier_allocation_main.php +++ b/purchasing/allocations/supplier_allocation_main.php @@ -64,7 +64,7 @@ function systype_name($dummy, $type) { global $systypes_array; - return $systypes_array[$type; + return $systypes_array[$type]; } function trans_view($trans) diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 3a9e4595..07c53190 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -26,7 +26,7 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; if ($adj_only) - $exclude = 13; + $exclude = ST_CUSTDELIVERY; else $exclude = 0; $qoh = get_qoh_on_date($stock_id, null, $date, $exclude); @@ -88,16 +88,16 @@ function add_grn(&$po, $date_, $reference, $location) $order_line->standard_cost, $order_line->receive_qty, $order_line->price); /* Update location stock records - NB a po cannot be entered for a service/kit parts */ - add_stock_move(25, $order_line->stock_id, $grn, $location, $date_, "", + add_stock_move(ST_SUPPRECEIVE, $order_line->stock_id, $grn, $location, $date_, "", $order_line->receive_qty, $order_line->standard_cost, $po->supplier_id, 1, $order_line->price); } /*quantity received is != 0 */ } /*end of order_line loop */ - $Refs->save(25, $grn, $reference); + $Refs->save(ST_SUPPRECEIVE, $grn, $reference); - add_audit_trail(25, $grn, $date_); + add_audit_trail(ST_SUPPRECEIVE, $grn, $date_); commit_transaction(); @@ -183,7 +183,7 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date) quantity_inv=quantity_inv+$entered_grn->this_quantity_inv WHERE id=$entered_grn->id"; db_query($sql); - add_stock_move(21, $entered_grn->item_code, $transno, $myrow['loc_code'], $date, "", + add_stock_move(ST_SUPPCREDIT, $entered_grn->item_code, $transno, $myrow['loc_code'], $date, "", $entered_grn->this_quantity_inv, $mcost, $supplier, 1, $entered_grn->chg_price); } @@ -198,7 +198,7 @@ function get_grn_items($grn_batch_id=0, $supplier_id="", $outstanding_only=false $sql .= " WHERE ".TB_PREF."grn_items.grn_batch_id=".TB_PREF."grn_batch.id AND ".TB_PREF."grn_items.po_detail_item=".TB_PREF."purch_order_details.po_detail_item"; if ($invoice_no != 0) - $sql .= " AND ".TB_PREF."supp_invoice_items.supp_trans_type=20 AND + $sql .= " AND ".TB_PREF."supp_invoice_items.supp_trans_type=".ST_SUPPINVOICE." AND ".TB_PREF."supp_invoice_items.supp_trans_no=$invoice_no AND ".TB_PREF."grn_items.id=".TB_PREF."supp_invoice_items.grn_item_id"; $sql .= " AND ".TB_PREF."stock_master.stock_id=".TB_PREF."grn_items.item_code "; @@ -344,8 +344,8 @@ function void_grn($grn_batch) begin_transaction(); - void_bank_trans(25, $grn_batch, true); - void_gl_trans(25, $grn_batch, true); + void_bank_trans(ST_SUPPRECEIVE, $grn_batch, true); + void_gl_trans(ST_SUPPRECEIVE, $grn_batch, true); // clear the quantities of the grn items in the POs and invoices $result = get_grn_items($grn_batch); @@ -371,7 +371,7 @@ function void_grn($grn_batch) db_query($sql, "A grn detail item could not be voided."); // clear the stock move items - void_stock_move(25, $grn_batch); + void_stock_move(ST_SUPPRECEIVE, $grn_batch); commit_transaction(); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index bca0bd2f..0fbb0509 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -101,7 +101,7 @@ function get_deliveries_between($stock_id, $from, $to) $from = date2sql($from); $to = date2sql($to); $sql = "SELECT SUM(-qty), SUM(-qty*standard_cost) FROM ".TB_PREF."stock_moves - WHERE type=13 AND stock_id='$stock_id' AND + WHERE type=".ST_CUSTDELIVERY." AND stock_id='$stock_id' AND tran_date>='$from' AND tran_date<='$to' GROUP BY stock_id"; $result = db_query($sql, "The deliveries could not be updated"); return db_fetch_row($result); @@ -136,10 +136,10 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $invoice_items_total = $supp_trans->get_total_charged($supp_trans->tax_group_id); if ($supp_trans->is_invoice) - $trans_type = 20; + $trans_type = ST_SUPPINVOICE; else { - $trans_type = 21; + $trans_type = ST_SUPPCREDIT; // let's negate everything because it's a credit note $invoice_items_total = -$invoice_items_total; $tax_total = -$tax_total; @@ -190,6 +190,8 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b $entered_gl_code->amount, $memo_); // store tax details if the gl account is a tax account + if (!$supp_trans->is_invoice) + $entered_gl_code->amount = -$entered_gl_code->amount; add_gl_tax_details($entered_gl_code->gl_code, $trans_type, $invoice_id, $entered_gl_code->amount, $ex_rate, $date_, $supp_trans->supp_reference); @@ -252,9 +254,9 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b 0, 0, _("Cost diff."), -$amt, null, null, null, "The general ledger transaction could not be added for the price variance of the inventory item"); } - update_stock_move_pid(13, $entered_grn->item_code, $old_date, $date_, 0, $mat_cost); + update_stock_move_pid(ST_CUSTDELIVERY, $entered_grn->item_code, $old_date, $date_, 0, $mat_cost); } - update_stock_move_pid(25, $entered_grn->item_code, $old_date, $old_date, $supp_trans->supplier_id, $mat_cost); + update_stock_move_pid(ST_SUPPRECEIVE, $entered_grn->item_code, $old_date, $old_date, $supp_trans->supplier_id, $mat_cost); //} } // ---------------------------------------------------------------------- @@ -271,12 +273,17 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b { if (!$supp_trans->is_invoice) + { + $taxitem['Net'] = -$taxitem['Net']; $taxitem['Value'] = -$taxitem['Value']; + } // here we suppose that tax is never included in price (we are company customer). add_trans_tax_details($trans_type, $invoice_id, $taxitem['tax_type_id'], $taxitem['rate'], 0, $taxitem['Value'], $taxitem['Net'], $ex_rate, $date_, $supp_trans->supp_reference); + if (!$supp_trans->is_invoice) + $taxitem['Value'] = -$taxitem['Value']; $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'], $supp_trans->supplier_id, @@ -293,24 +300,24 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b if ($invoice_no != 0) { - $invoice_alloc_balance = get_supp_trans_allocation_balance(20, $invoice_no); + $invoice_alloc_balance = get_supp_trans_allocation_balance(ST_SUPPINVOICE, $invoice_no); if ($invoice_alloc_balance > 0) { //the invoice is not already fully allocated - $trans = get_supp_trans($invoice_no, 20); + $trans = get_supp_trans($invoice_no, ST_SUPPINVOICE); $total = $trans['Total']; $allocate_amount = ($invoice_alloc_balance > $total) ? $total : $invoice_alloc_balance; /*Now insert the allocation record if > 0 */ if ($allocate_amount != 0) { - update_supp_trans_allocation(20, $invoice_no, $allocate_amount); - update_supp_trans_allocation(21, $invoice_id, $allocate_amount); // *** - add_supp_allocation($allocate_amount, 21, $invoice_id, 20, $invoice_no, + update_supp_trans_allocation(ST_SUPPINVOICE, $invoice_no, $allocate_amount); + update_supp_trans_allocation(ST_SUPPCREDIT, $invoice_id, $allocate_amount); // *** + add_supp_allocation($allocate_amount, ST_SUPPCREDIT, $invoice_id, ST_SUPPINVOICE, $invoice_no, $date_); // Exchange Variations Joe Hunt 2008-09-20 //////////////////////////////////////// - exchange_variation(21, $invoice_id, 20, $invoice_no, $date_, + exchange_variation(ST_SUPPCREDIT, $invoice_id, ST_SUPPINVOICE, $invoice_no, $date_, $allocate_amount, PT_SUPPLIER); /////////////////////////////////////////////////////////////////////////// @@ -407,7 +414,7 @@ function read_supp_invoice($trans_no, $trans_type, &$supp_trans) function get_matching_invoice_item($stock_id, $po_item_id) { $sql = "SELECT *, tran_date FROM ".TB_PREF."supp_invoice_items, ".TB_PREF."supp_trans - WHERE supp_trans_type = 20 AND stock_id = '$stock_id' AND po_detail_item_id = $po_item_id + WHERE supp_trans_type = ".ST_SUPPINVOICE." AND stock_id = '$stock_id' AND po_detail_item_id = $po_item_id AND supp_trans_no = trans_no"; $result = db_query($sql, "Cannot retreive supplier transaction detail records"); return db_fetch($result); @@ -446,7 +453,7 @@ function void_supp_invoice($type, $type_no) $batch = get_grn_batch_from_item($details_row["grn_item_id"]); $grn = get_grn_batch($batch); - if ($type == 21) // credit note 2009-06-14 Joe Hunt Must restore the po and grn + if ($type == ST_SUPPCREDIT) // credit note 2009-06-14 Joe Hunt Must restore the po and grn { // We must get the corresponding invoice item to check for price chg. $match = get_matching_invoice_item($details_row["stock_id"], $details_row["po_detail_item_id"]); if ($match !== false) @@ -477,15 +484,15 @@ function void_supp_invoice($type, $type_no) $deliveries = get_deliveries_between($details_row["stock_id"], $old_date, $date_); if ($deliveries[0] != 0) // have deliveries been done during the period? { - update_stock_move_pid(13, $details_row["stock_id"], $old_date, $date_, 0, $mat_cost); + update_stock_move_pid(ST_CUSTDELIVERY, $details_row["stock_id"], $old_date, $date_, 0, $mat_cost); } - update_stock_move_pid(25, $details_row["stock_id"], $old_date, $old_date, $grn['supplier_id'], $mat_cost); + update_stock_move_pid(ST_SUPPRECEIVE, $details_row["stock_id"], $old_date, $old_date, $grn['supplier_id'], $mat_cost); } } } - if ($type == 21) // void the credits in stock moves - void_stock_move(21, $type_no); + if ($type == ST_SUPPCREDIT) // void the credits in stock moves + void_stock_move($type, $type_no); void_supp_invoice_items($type, $type_no); void_trans_tax_details($type, $type_no); diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index d4dc4706..3d848ed6 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -35,7 +35,7 @@ function add_supp_payment($supplier_id, $date_, $bank_account, // it's a supplier payment - $trans_type = 22; + $trans_type = ST_SUPPAYMENT; /* Create a supp_trans entry for the supplier payment */ $payment_id = add_supp_trans($trans_type, $supplier_id, $date_, $date_, diff --git a/purchasing/includes/db/supp_trans_db.inc b/purchasing/includes/db/supp_trans_db.inc index 52071cc6..e1715a6e 100644 --- a/purchasing/includes/db/supp_trans_db.inc +++ b/purchasing/includes/db/supp_trans_db.inc @@ -49,7 +49,7 @@ function get_supp_trans($trans_no, $trans_type=-1) $sql = "SELECT ".TB_PREF."supp_trans.*, (".TB_PREF."supp_trans.ov_amount+".TB_PREF."supp_trans.ov_gst+".TB_PREF."supp_trans.ov_discount) AS Total, ".TB_PREF."suppliers.supp_name AS supplier_name, ".TB_PREF."suppliers.curr_code AS SupplierCurrCode "; - if ($trans_type == 22) + if ($trans_type == ST_SUPPAYMENT) { // it's a payment so also get the bank account $sql .= ", ".TB_PREF."bank_accounts.bank_name, ".TB_PREF."bank_accounts.bank_account_name, ".TB_PREF."bank_accounts.bank_curr_code, @@ -59,7 +59,7 @@ function get_supp_trans($trans_no, $trans_type=-1) $sql .= " FROM ".TB_PREF."supp_trans, ".TB_PREF."suppliers "; - if ($trans_type == 22) + if ($trans_type == ST_SUPPAYMENT) { // it's a payment so also get the bank account $sql .= ", ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts"; @@ -71,7 +71,7 @@ function get_supp_trans($trans_no, $trans_type=-1) if ($trans_type > 0) $sql .= " AND ".TB_PREF."supp_trans.type=$trans_type "; - if ($trans_type == 22) + if ($trans_type == ST_SUPPAYMENT) { // it's a payment so also get the bank account $sql .= " AND ".TB_PREF."bank_trans.trans_no =$trans_no @@ -126,19 +126,19 @@ function void_supp_trans($type, $type_no) function post_void_supp_trans($type, $type_no) { - if ($type == 22) + if ($type == ST_SUPPAYMENT) { void_supp_payment($type, $type_no); return true; } - if ($type == 20 || $type == 21) + if ($type == ST_SUPPINVOICE || $type == ST_SUPPCREDIT) { void_supp_invoice($type, $type_no); return true; } - if ($type == 25) + if ($type == SUPPRECEIVE) { return void_grn($type_no); } diff --git a/purchasing/includes/db/suppalloc_db.inc b/purchasing/includes/db/suppalloc_db.inc index 1c0f16eb..b31adc52 100644 --- a/purchasing/includes/db/suppalloc_db.inc +++ b/purchasing/includes/db/suppalloc_db.inc @@ -145,7 +145,7 @@ function get_allocatable_from_supp_sql($supplier_id, $settled) $supp_sql = " AND trans.supplier_id = $supplier_id"; $sql = get_alloc_supp_sql("round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) <= 0 AS settled", - "(type=22 OR type=21 OR type=1) AND (ov_amount < 0) " . $settled_sql . $supp_sql); + "(type=".ST_SUPPAYMENT." OR type=".ST_SUPPCREDIT." OR type=".ST_BANKPAYMENT.") AND (ov_amount < 0) " . $settled_sql . $supp_sql); return $sql; } @@ -166,7 +166,7 @@ function get_allocatable_to_supp_transactions($supplier_id, $trans_no=null, $typ else { $sql = get_alloc_supp_sql(null, "round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) > 0 - AND trans.type != 22 + AND trans.type != ".ST_SUPPAYMENT." AND trans.supplier_id=$supplier_id"); } diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index eaead9ec..1cfa85da 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -21,7 +21,7 @@ function get_supplier_details($supplier_id, $to=null) // removed - supp_trans.alloc from all summations $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; - $due = "IF (".TB_PREF."supp_trans.type=20 OR ".TB_PREF."supp_trans.type=21,".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; + $due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; $sql = "SELECT ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.curr_code, ".TB_PREF."payment_terms.terms, Sum($value) AS Balance, diff --git a/purchasing/includes/ui/grn_ui.inc b/purchasing/includes/ui/grn_ui.inc index 81bd8617..a0fdae4b 100644 --- a/purchasing/includes/ui/grn_ui.inc +++ b/purchasing/includes/ui/grn_ui.inc @@ -33,7 +33,7 @@ function display_grn_summary(&$po, $editable=false) if ($editable) { if (!isset($_POST['ref'])) - $_POST['ref'] = $Refs->get_next(25); + $_POST['ref'] = $Refs->get_next(ST_SUPPRECEIVE); ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'"); if (!isset($_POST['Location'])) diff --git a/purchasing/includes/ui/invoice_ui.inc b/purchasing/includes/ui/invoice_ui.inc index 75c8a24f..c5eafa80 100644 --- a/purchasing/includes/ui/invoice_ui.inc +++ b/purchasing/includes/ui/invoice_ui.inc @@ -67,7 +67,7 @@ function invoice_header(&$supp_trans) if (isset($_POST['invoice_no'])) { - $trans = get_supp_trans($_POST['invoice_no'], 20); + $trans = get_supp_trans($_POST['invoice_no'], ST_SUPPINVOICE); $_POST['supplier_id'] = $trans['supplier_id']; $supp = $trans['supplier_name'] . " - " . $trans['SupplierCurrCode']; label_row(_("Supplier:"), $supp.hidden('supplier_id', $_POST['supplier_id'], false)); @@ -90,9 +90,9 @@ function invoice_header(&$supp_trans) } if ($supp_trans->is_invoice) - ref_row(_("Reference:"), 'reference', '', $Refs->get_next(20)); + ref_row(_("Reference:"), 'reference', '', $Refs->get_next(ST_SUPPINVOICE)); else - ref_row(_("Reference:"), 'reference', '', $Refs->get_next(21)); + ref_row(_("Reference:"), 'reference', '', $Refs->get_next(ST_SUPPCREDIT)); if (isset($_POST['invoice_no'])) { @@ -496,7 +496,7 @@ function display_grn_items(&$supp_trans, $mode=0) alt_table_row_color($k); $grn_batch = get_grn_batch_from_item($entered_grn->id); - label_cell(get_trans_view_str(25,$grn_batch)); + label_cell(get_trans_view_str(ST_SUPPRECEIVE,$grn_batch)); if ($mode == 1) { label_cell($entered_grn->id); diff --git a/purchasing/inquiry/supplier_allocation_inquiry.php b/purchasing/inquiry/supplier_allocation_inquiry.php index b0d9d51b..98e7e4d1 100644 --- a/purchasing/inquiry/supplier_allocation_inquiry.php +++ b/purchasing/inquiry/supplier_allocation_inquiry.php @@ -82,13 +82,13 @@ function view_link($trans) function due_date($row) { - return (($row["type"] == 20) || ($row["type"]== 21)) + return (($row["type"] == ST_SUPPINVOICE) || ($row["type"]== ST_SUPPCREDIT)) ? $row["due_date"] : ""; } function fmt_balance($row) { - $value = ($row["type"] == 1 || $row["type"] == 21 || $row["type"] == 22) + $value = ($row["type"] == ST_BANKPAYMENT || $row["type"] == ST_SUPPCREDIT || $row["type"] == ST_SUPPAYMENT) ? -$row["TotalAmount"] - $row["Allocated"] : $row["TotalAmount"] - $row["Allocated"]; return $value; @@ -101,7 +101,7 @@ function alloc_link($row) "/purchasing/allocations/supplier_allocate.php?trans_no=" . $row["trans_no"]. "&trans_type=" . $row["type"], ICON_MONEY ); - return (($row["type"] == 1 || $row["type"] == 21 || $row["type"] == 22) + return (($row["type"] == ST_BANKPAYMENT || $row["type"] == ST_SUPPCREDIT || $row["type"] == ST_SUPPAYMENT) && (-$row["TotalAmount"] - $row["Allocated"]) > 0) ? $link : ''; } @@ -135,7 +135,7 @@ function fmt_credit($row) supplier.curr_code, (trans.ov_amount + trans.ov_gst + trans.ov_discount) AS TotalAmount, trans.alloc AS Allocated, - ((trans.type = 20 OR trans.type = 21) AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue + ((trans.type = ".ST_SUPPINVOICE." OR trans.type = ".ST_SUPPCREDIT.") AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue FROM " .TB_PREF."supp_trans as trans, " .TB_PREF."suppliers as supplier @@ -148,15 +148,15 @@ function fmt_credit($row) { if (($_POST['filterType'] == '1') || ($_POST['filterType'] == '2')) { - $sql .= " AND trans.type = 20 "; + $sql .= " AND trans.type = ".ST_SUPPINVOICE." "; } elseif ($_POST['filterType'] == '3') { - $sql .= " AND trans.type = 22 "; + $sql .= " AND trans.type = ".ST_SUPPAYMENT." "; } elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5')) { - $sql .= " AND trans.type = 21 "; + $sql .= " AND trans.type = ".ST_SUPPCREDIT." "; } if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5')) diff --git a/purchasing/inquiry/supplier_inquiry.php b/purchasing/inquiry/supplier_inquiry.php index 38508f71..dff07c66 100644 --- a/purchasing/inquiry/supplier_inquiry.php +++ b/purchasing/inquiry/supplier_inquiry.php @@ -115,7 +115,7 @@ function trans_view($trans) function due_date($row) { - return ($row["type"]== 20) || ($row["type"]== 21) ? $row["due_date"] : ''; + return ($row["type"]== ST_SUPPINVOICE) || ($row["type"]== ST_SUPPCREDIT) ? $row["due_date"] : ''; } function gl_view($row) @@ -125,7 +125,7 @@ function gl_view($row) function credit_link($row) { - return $row['type'] == 20 && $row["TotalAmount"] - $row["Allocated"] > 0 ? + return $row['type'] == ST_SUPPINVOICE && $row["TotalAmount"] - $row["Allocated"] > 0 ? pager_link(_("Credit This"), "/purchasing/supplier_credit.php?New=1&invoice_no=". $row['trans_no'], ICON_CREDIT) @@ -171,7 +171,7 @@ function check_overdue($row) supplier.curr_code, (trans.ov_amount + trans.ov_gst + trans.ov_discount) AS TotalAmount, trans.alloc AS Allocated, - ((trans.type = 20 OR trans.type = 21) AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue, + ((trans.type = ".ST_SUPPINVOICE." OR trans.type = ".ST_SUPPCREDIT.") AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue, (ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc) <= 0.005) AS Settled FROM ".TB_PREF."supp_trans as trans, ".TB_PREF."suppliers as supplier WHERE supplier.supplier_id = trans.supplier_id @@ -184,19 +184,19 @@ function check_overdue($row) { if (($_POST['filterType'] == '1')) { - $sql .= " AND (trans.type = 20 OR trans.type = 2)"; + $sql .= " AND (trans.type = ".ST_SUPPINVOICE." OR trans.type = ".ST_BANKDEPOSIT.")"; } elseif (($_POST['filterType'] == '2')) { - $sql .= " AND trans.type = 20 "; + $sql .= " AND trans.type = ".ST_SUPPINVOICE." "; } elseif ($_POST['filterType'] == '3') { - $sql .= " AND (trans.type = 22 OR trans.type = 1) "; + $sql .= " AND (trans.type = ".ST_SUPPAYMENT." OR trans.type = ".ST_BANKPAYMENT.") "; } elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5')) { - $sql .= " AND trans.type = 21 "; + $sql .= " AND trans.type = ".ST_SUPPCREDIT." "; } if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5')) diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index 5059807b..601e5d5f 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -29,16 +29,12 @@ page(_("Receive Purchase Order Items"), false, false, "", $js); if (isset($_GET['AddedID'])) { $grn = $_GET['AddedID']; - $trans_type = 25; + $trans_type = ST_SUPPRECEIVE; display_notification_centered(_("Purchase Order Delivery has been processed")); display_note(get_trans_view_str($trans_type, $grn, _("&View this Delivery"))); - //echo "
"; - //echo get_gl_view_str(25, $grn, _("View the GL &Journal Entries for this Delivery")); - -// echo "
"; hyperlink_params("$path_to_root/purchasing/supplier_invoice.php", _("Entry purchase &invoice for this receival"), "New=1"); hyperlink_no_params("$path_to_root/purchasing/inquiry/po_search.php", _("Select a different &purchase order for receiving items against")); @@ -49,7 +45,6 @@ if (isset($_GET['AddedID'])) //-------------------------------------------------------------------------------------------------- if ((!isset($_GET['PONumber']) || $_GET['PONumber'] == 0) && !isset($_SESSION['PO'])) -//if (isset($_GET['PONumber']) && !$_GET['PONumber'] > 0 && !isset($_SESSION['PO'])) { die (_("This page can only be opened if a purchase order has been selected. Please select a purchase order first.")); } @@ -180,7 +175,7 @@ function can_process() return false; } - if (!is_new_reference($_POST['ref'], 25)) + if (!is_new_reference($_POST['ref'], ST_SUPPRECEIVE)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); diff --git a/purchasing/supplier_credit.php b/purchasing/supplier_credit.php index 25c24e3b..319bab0b 100644 --- a/purchasing/supplier_credit.php +++ b/purchasing/supplier_credit.php @@ -36,7 +36,7 @@ check_db_has_suppliers(_("There are no suppliers defined in the system.")); if (isset($_GET['AddedID'])) { $invoice_no = $_GET['AddedID']; - $trans_type = 21; + $trans_type = ST_SUPPCREDIT; echo "
"; @@ -153,7 +153,7 @@ function check_data() return false; } - if (!is_new_reference($_SESSION['supp_trans']->reference, 21)) + if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPCREDIT)) { display_error(_("The entered reference is already in use.")); set_focus('reference'); diff --git a/purchasing/supplier_invoice.php b/purchasing/supplier_invoice.php index 33c745a1..15a6529f 100644 --- a/purchasing/supplier_invoice.php +++ b/purchasing/supplier_invoice.php @@ -36,7 +36,7 @@ check_db_has_suppliers(_("There are no suppliers defined in the system.")); if (isset($_GET['AddedID'])) { $invoice_no = $_GET['AddedID']; - $trans_type = 20; + $trans_type = ST_SUPPINVOICE; echo "
"; @@ -153,7 +153,7 @@ function check_data() return false; } - if (!is_new_reference($_SESSION['supp_trans']->reference, 20)) + if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPINVOICE)) { display_error(_("The entered reference is already in use.")); set_focus('reference'); @@ -359,7 +359,7 @@ if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) update_average_material_cost($grn["supplier_id"], $myrow["item_code"], $myrow["unit_price"], -$myrow["QtyOstdg"], Today()); - add_stock_move(25, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "", + add_stock_move(ST_SUPPRECEIVE, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "", -$myrow["QtyOstdg"], $myrow['std_cost_unit'], $grn["supplier_id"], 1, $myrow['unit_price']); commit_transaction(); diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index ee0b81a6..713d0122 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -153,7 +153,7 @@ function check_inputs() return false; } - if (!is_new_reference($_POST['ref'], 22)) + if (!is_new_reference($_POST['ref'], ST_SUPPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); @@ -219,7 +219,7 @@ start_form(); supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true); if (!isset($_POST['bank_account'])) // first page call - $_SESSION['alloc'] = new allocation(22, 0); + $_SESSION['alloc'] = new allocation(ST_SUPPAYMENT, 0); set_global_supplier($_POST['supplier_id']); @@ -227,7 +227,7 @@ start_form(); table_section(2); - ref_row(_("Reference:"), 'ref', '', $Refs->get_next(22)); + ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_SUPPAYMENT)); date_row(_("Date Paid") . ":", 'DatePaid', '', true, 0, 0, 0, null, true); diff --git a/purchasing/view/view_grn.php b/purchasing/view/view_grn.php index b4788199..0a94ac8c 100644 --- a/purchasing/view/view_grn.php +++ b/purchasing/view/view_grn.php @@ -72,7 +72,7 @@ label_row(_("Total Excluding Tax/Shipping"), $display_total, end_table(1); -is_voided_display(25, $_GET['trans_no'], _("This delivery has been voided.")); +is_voided_display(ST_SUPPRECEIVE, $_GET['trans_no'], _("This delivery has been voided.")); end_page(true); diff --git a/purchasing/view/view_po.php b/purchasing/view/view_po.php index 049c8c5e..052103de 100644 --- a/purchasing/view/view_po.php +++ b/purchasing/view/view_po.php @@ -108,7 +108,7 @@ if (db_num_rows($grns_result) > 0) { alt_table_row_color($k); - label_cell(get_trans_view_str(25,$myrow["id"])); + label_cell(get_trans_view_str(ST_SUPPRECEIVE,$myrow["id"])); label_cell($myrow["reference"]); label_cell(sql2date($myrow["delivery_date"])); end_row(); diff --git a/purchasing/view/view_supp_credit.php b/purchasing/view/view_supp_credit.php index 60fa7f41..79e6e5b9 100644 --- a/purchasing/view/view_supp_credit.php +++ b/purchasing/view/view_supp_credit.php @@ -34,7 +34,7 @@ elseif (isset($_POST["trans_no"])) $supp_trans = new supp_trans(); $supp_trans->is_invoice = false; -read_supp_invoice($trans_no, 21, $supp_trans); +read_supp_invoice($trans_no, ST_SUPPCREDIT, $supp_trans); display_heading(_("SUPPLIER CREDIT NOTE") . " # " . $trans_no); echo "
"; @@ -49,7 +49,7 @@ label_cells(_("Invoice Date"), $supp_trans->tran_date, "class='tableheader2'"); label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'"); label_cells(_("Currency"), get_supplier_currency($supp_trans->supplier_id), "class='tableheader2'"); end_row(); -comments_display_row(21, $trans_no); +comments_display_row(ST_SUPPCREDIT, $trans_no); end_table(1); $total_gl = display_gl_items($supp_trans, 3); @@ -60,7 +60,7 @@ $display_sub_tot = number_format2($total_gl+$total_grn,user_price_dec()); start_table("$table_style width=95%"); label_row(_("Sub Total"), $display_sub_tot, "align=right", "nowrap align=right width=17%"); -$tax_items = get_trans_tax_details(21, $trans_no); +$tax_items = get_trans_tax_details(ST_SUPPCREDIT, $trans_no); display_supp_trans_tax_details($tax_items, 1); $display_total = number_format2(-($supp_trans->ov_amount + $supp_trans->ov_gst),user_price_dec()); @@ -68,11 +68,11 @@ label_row(_("TOTAL CREDIT NOTE"), $display_total, "colspan=1 align=right", "nowr end_table(1); -$voided = is_voided_display(21, $trans_no, _("This credit note has been voided.")); +$voided = is_voided_display(ST_SUPPCREDIT, $trans_no, _("This credit note has been voided.")); if (!$voided) { - display_allocations_from(PT_SUPPLIER, $supp_trans->supplier_id, 21, $trans_no, -($supp_trans->ov_amount + $supp_trans->ov_gst)); + display_allocations_from(PT_SUPPLIER, $supp_trans->supplier_id, ST_SUPPCREDIT, $trans_no, -($supp_trans->ov_amount + $supp_trans->ov_gst)); } end_page(true); diff --git a/purchasing/view/view_supp_invoice.php b/purchasing/view/view_supp_invoice.php index bf77703a..bbab14eb 100644 --- a/purchasing/view/view_supp_invoice.php +++ b/purchasing/view/view_supp_invoice.php @@ -34,7 +34,7 @@ elseif (isset($_POST["trans_no"])) $supp_trans = new supp_trans(); $supp_trans->is_invoice = true; -read_supp_invoice($trans_no, 20, $supp_trans); +read_supp_invoice($trans_no, ST_SUPPINVOICE, $supp_trans); $supplier_curr_code = get_supplier_currency($supp_trans->supplier_id); @@ -53,7 +53,7 @@ label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'"); if (!is_company_currency($supplier_curr_code)) label_cells(_("Currency"), $supplier_curr_code, "class='tableheader2'"); end_row(); -comments_display_row(20, $trans_no); +comments_display_row(ST_SUPPINVOICE, $trans_no); end_table(1); @@ -65,7 +65,7 @@ $display_sub_tot = number_format2($total_gl+$total_grn,user_price_dec()); start_table("width=95% $table_style"); label_row(_("Sub Total"), $display_sub_tot, "align=right", "nowrap align=right width=15%"); -$tax_items = get_trans_tax_details(20, $trans_no); +$tax_items = get_trans_tax_details(ST_SUPPINVOICE, $trans_no); display_supp_trans_tax_details($tax_items, 1); $display_total = number_format2($supp_trans->ov_amount + $supp_trans->ov_gst,user_price_dec()); @@ -74,7 +74,7 @@ label_row(_("TOTAL INVOICE"), $display_total, "colspan=1 align=right", "nowrap a end_table(1); -is_voided_display(20, $trans_no, _("This invoice has been voided.")); +is_voided_display(ST_SUPPINVOICE, $trans_no, _("This invoice has been voided.")); end_page(true); diff --git a/purchasing/view/view_supp_payment.php b/purchasing/view/view_supp_payment.php index 7ee90978..52be7141 100644 --- a/purchasing/view/view_supp_payment.php +++ b/purchasing/view/view_supp_payment.php @@ -26,7 +26,7 @@ if (isset($_GET["trans_no"])) $trans_no = $_GET["trans_no"]; } -$receipt = get_supp_trans($trans_no, 22); +$receipt = get_supp_trans($trans_no, ST_SUPPAYMENT); $company_currency = get_company_currency(); @@ -69,16 +69,16 @@ if ($show_both_amounts) label_cells(_("Amount"), number_format2(-$receipt['Total'], user_price_dec()), "class='tableheader2'"); label_cells(_("Reference"), $receipt['ref'], "class='tableheader2'"); end_row(); -comments_display_row(22, $trans_no); +comments_display_row(ST_SUPPAYMENT, $trans_no); end_table(1); -$voided = is_voided_display(22, $trans_no, _("This payment has been voided.")); +$voided = is_voided_display(ST_SUPPAYMENT, $trans_no, _("This payment has been voided.")); // now display the allocations for this payment if (!$voided) { - display_allocations_from(PT_SUPPLIER, $receipt['supplier_id'], 22, $trans_no, -$receipt['Total']); + display_allocations_from(PT_SUPPLIER, $receipt['supplier_id'], ST_SUPPAYMENT, $trans_no, -$receipt['Total']); } end_page(true); diff --git a/reporting/includes/reporting.inc b/reporting/includes/reporting.inc index 9df49429..e38ed6a2 100644 --- a/reporting/includes/reporting.inc +++ b/reporting/includes/reporting.inc @@ -56,8 +56,8 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no, 'PARAM_2' => $email, 'PARAM_3' => ""); break; - case 10 : // Sales Invoice - case 11 : // Customer Credit Note + case ST_SALESINVOICE : // Sales Invoice + case ST_CUSTCREDIT : // Customer Credit Note $rep = 107; // from, to, currency, bank acc, email, paylink, comments, type $ar = array( diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index 9ed5a4ab..fd1fae78 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -263,12 +263,12 @@ class Report $CN = _("CN"); if ($print_invoice_no == 1) $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', - ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName - FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=".ST_SALESINVOICE.", ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; else $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', - ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName - FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=".ST_SALESINVOICE.", ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; case 'DELIVERY': @@ -277,7 +277,7 @@ class Report concat(".TB_PREF."debtor_trans.trans_no, '-', ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, ' $DN ', ".TB_PREF."debtors_master.name) as IName FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans - WHERE type=13 AND ".TB_PREF."debtors_master.debtor_no=". + WHERE type=".ST_CUSTDELIVERY." AND ".TB_PREF."debtors_master.debtor_no=". TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; @@ -285,14 +285,14 @@ class Report $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-', ".TB_PREF."debtors_master.name) as IName FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no - AND ".TB_PREF."sales_orders.trans_type=30 ORDER BY ".TB_PREF."sales_orders.order_no DESC"; + AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." ORDER BY ".TB_PREF."sales_orders.order_no DESC"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; case 'QUOTATIONS': $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-', ".TB_PREF."debtors_master.name) as IName FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no - AND ".TB_PREF."sales_orders.trans_type=32 ORDER BY ".TB_PREF."sales_orders.order_no DESC"; + AND ".TB_PREF."sales_orders.trans_type=".ST_SALESQUOTE." ORDER BY ".TB_PREF."sales_orders.order_no DESC"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; case 'PO': diff --git a/reporting/rep101.php b/reporting/rep101.php index 95a09281..913c12b4 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -33,12 +33,12 @@ function get_open_balance($debtorno, $to, $convert) { $to = date2sql($to); - $sql = "SELECT SUM(IF(".TB_PREF."debtor_trans.type = 10, (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + + $sql = "SELECT SUM(IF(".TB_PREF."debtor_trans.type = ".ST_SALESINVOICE.", (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount)"; if ($convert) $sql .= " * rate"; $sql .= ", 0)) AS charges, - SUM(IF(".TB_PREF."debtor_trans.type <> 10, (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + + SUM(IF(".TB_PREF."debtor_trans.type <> ".ST_SALESINVOICE.", (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount)"; if ($convert) $sql .= " * rate"; @@ -47,7 +47,7 @@ function get_open_balance($debtorno, $to, $convert) if ($convert) $sql .= " * rate"; $sql .= ") AS Allocated, - SUM(IF(".TB_PREF."debtor_trans.type = 10, (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + + SUM(IF(".TB_PREF."debtor_trans.type = ".ST_SALESINVOICE.", (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount - ".TB_PREF."debtor_trans.alloc)"; if ($convert) $sql .= " * rate"; @@ -60,7 +60,7 @@ function get_open_balance($debtorno, $to, $convert) FROM ".TB_PREF."debtor_trans WHERE ".TB_PREF."debtor_trans.tran_date < '$to' AND ".TB_PREF."debtor_trans.debtor_no = '$debtorno' - AND ".TB_PREF."debtor_trans.type <> 13 GROUP BY debtor_no"; + AND ".TB_PREF."debtor_trans.type <> ".ST_CUSTDELIVERY." GROUP BY debtor_no"; $result = db_query($sql,"No transactions were returned"); return db_fetch($result); @@ -74,13 +74,13 @@ function get_transactions($debtorno, $from, $to) $sql = "SELECT ".TB_PREF."debtor_trans.*, (".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) + ((".TB_PREF."debtor_trans.type = ".ST_SALESINVOICE.") AND ".TB_PREF."debtor_trans.due_date < '$to') AS OverDue FROM ".TB_PREF."debtor_trans WHERE ".TB_PREF."debtor_trans.tran_date >= '$from' AND ".TB_PREF."debtor_trans.tran_date <= '$to' AND ".TB_PREF."debtor_trans.debtor_no = '$debtorno' - AND ".TB_PREF."debtor_trans.type <> 13 + AND ".TB_PREF."debtor_trans.type <> ".ST_CUSTDELIVERY." ORDER BY ".TB_PREF."debtor_trans.tran_date"; return db_query($sql,"No transactions were returned"); @@ -180,14 +180,14 @@ function print_customer_balances() $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['reference']); $rep->DateCol(2, 3, $trans['tran_date'], true); - if ($trans['type'] == 10) + if ($trans['type'] == ST_SALESINVOICE) $rep->DateCol(3, 4, $trans['due_date'], true); $item[0] = $item[1] = 0.0; if ($convert) $rate = $trans['rate']; else $rate = 1.0; - if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) + if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) $trans['TotalAmount'] *= -1; if ($trans['TotalAmount'] > 0.0) { @@ -207,7 +207,7 @@ function print_customer_balances() else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; */ - if ($trans['type'] == 10 || $trans['type'] == 1) + if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) $item[3] = $item[0] + $item[1] - $item[2]; else $item[3] = $item[0] - $item[1] + $item[2]; diff --git a/reporting/rep102.php b/reporting/rep102.php index f8a2a52d..9070ae18 100644 --- a/reporting/rep102.php +++ b/reporting/rep102.php @@ -37,7 +37,7 @@ function get_invoices($costomer_id, $to) $value = "(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + " .TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_freight_tax + " .TB_PREF."debtor_trans.ov_discount)"; - $due = "IF (".TB_PREF."debtor_trans.type=10,".TB_PREF."debtor_trans.due_date,".TB_PREF."debtor_trans.tran_date)"; + $due = "IF (".TB_PREF."debtor_trans.type=".ST_SALESINVOICE.",".TB_PREF."debtor_trans.due_date,".TB_PREF."debtor_trans.tran_date)"; $sql = "SELECT ".TB_PREF."debtor_trans.type, ".TB_PREF."debtor_trans.reference, ".TB_PREF."debtor_trans.tran_date, $value as Balance, @@ -49,7 +49,7 @@ function get_invoices($costomer_id, $to) ".TB_PREF."payment_terms, ".TB_PREF."debtor_trans - WHERE ".TB_PREF."debtor_trans.type <> 13 + WHERE ".TB_PREF."debtor_trans.type <> ".ST_CUSTDELIVERY." AND ".TB_PREF."debtors_master.payment_terms = ".TB_PREF."payment_terms.terms_indicator AND ".TB_PREF."debtors_master.debtor_no = ".TB_PREF."debtor_trans.debtor_no AND ".TB_PREF."debtor_trans.debtor_no = $costomer_id @@ -177,7 +177,7 @@ function print_aged_customer_analysis() $rep->TextCol(0, 1, $systypes_array[$trans['type']], -2); $rep->TextCol(1, 2, $trans['reference'], -2); $rep->DateCol(2, 3, $trans['tran_date'], true, -2); - if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) + if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) { $trans['Balance'] *= -1; $trans['Due'] *= -1; diff --git a/reporting/rep103.php b/reporting/rep103.php index e8a41891..5eeeb228 100644 --- a/reporting/rep103.php +++ b/reporting/rep103.php @@ -80,7 +80,7 @@ function getTransactions($debtorno, $branchcode, $date) FROM ".TB_PREF."debtor_trans WHERE debtor_no='$debtorno' AND branch_code='$branchcode' - AND (type=10 or type=11) + AND (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND trandate >='$date'"; $result = db_query($sql,"No transactions were returned"); diff --git a/reporting/rep105.php b/reporting/rep105.php index d4916ca8..dd535b98 100644 --- a/reporting/rep105.php +++ b/reporting/rep105.php @@ -51,7 +51,7 @@ function GetSalesOrders($from, $to, $category=0, $location=null, $backorder=0) INNER JOIN ".TB_PREF."sales_order_details ON (".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND ".TB_PREF."sales_orders.trans_type = ".TB_PREF."sales_order_details.trans_type - AND ".TB_PREF."sales_orders.trans_type = 30) + AND ".TB_PREF."sales_orders.trans_type = ".ST_SALESORDER.") INNER JOIN ".TB_PREF."stock_master ON ".TB_PREF."sales_order_details.stk_code = ".TB_PREF."stock_master.stock_id WHERE ".TB_PREF."sales_orders.ord_date >='$fromdate' diff --git a/reporting/rep106.php b/reporting/rep106.php index 09dd921c..4aac08ab 100644 --- a/reporting/rep106.php +++ b/reporting/rep106.php @@ -45,7 +45,7 @@ function GetSalesmanTrans($from, $to) AND ".TB_PREF."sales_orders.branch_code=".TB_PREF."cust_branch.branch_code AND ".TB_PREF."cust_branch.salesman=".TB_PREF."salesman.salesman_code AND ".TB_PREF."debtor_trans.debtor_no=".TB_PREF."debtors_master.debtor_no - AND (".TB_PREF."debtor_trans.type=10 OR ".TB_PREF."debtor_trans.type=11) + AND (".TB_PREF."debtor_trans.type=".ST_SALESINVOICE." OR ".TB_PREF."debtor_trans.type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtor_trans.tran_date>='$fromdate' AND ".TB_PREF."debtor_trans.tran_date<='$todate' ORDER BY ".TB_PREF."salesman.salesman_code, ".TB_PREF."debtor_trans.tran_date"; diff --git a/reporting/rep107.php b/reporting/rep107.php index a265bd60..5a297da4 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -74,18 +74,18 @@ function print_invoices() for ($i = $fno[0]; $i <= $tno[0]; $i++) { - for ($j = 10; $j <= 11; $j++) + for ($j = ST_SALESINVOICE; $j <= ST_CUSTCREDIT; $j++) { if (isset($_POST['PARAM_7']) && $_POST['PARAM_7'] != $j) continue; if (!exists_customer_trans($j, $i)) continue; - $sign = $j==10 ? 1 : -1; + $sign = $j==ST_SALESINVOICE ? 1 : -1; $myrow = get_customer_trans($i, $j); $branch = get_branch($myrow["branch_code"]); $branch['disable_branch'] = $paylink; // helper - if ($j == 10) - $sales_order = get_sales_order_header($myrow["order_"], 30); + if ($j == ST_SALESINVOICE) + $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); else $sales_order = null; if ($email == 1) @@ -93,7 +93,7 @@ function print_invoices() $rep = new FrontReport("", "", user_pagesize()); $rep->currency = $cur; $rep->Font(); - if ($j == 10) + if ($j == ST_SALESINVOICE) { $rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; @@ -106,7 +106,7 @@ function print_invoices() $rep->Info($params, $cols, null, $aligns); } else - $rep->title = ($j == 10) ? _('INVOICE') : _('CREDIT NOTE'); + $rep->title = ($j == ST_SALESINVOICE) ? _('INVOICE') : _('CREDIT NOTE'); $rep->Header2($myrow, $branch, $sales_order, $baccount, $j); $result = get_customer_trans_details($j, $i); diff --git a/reporting/rep108.php b/reporting/rep108.php index 0fcfb6e4..156b5499 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -34,11 +34,11 @@ function getTransactions($debtorno, $date) $sql = "SELECT ".TB_PREF."debtor_trans.*, (".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) + ((".TB_PREF."debtor_trans.type = ".ST_SALESINVOICE.") AND ".TB_PREF."debtor_trans.due_date < '$date') AS OverDue FROM ".TB_PREF."debtor_trans WHERE ".TB_PREF."debtor_trans.tran_date <= '$date' AND ".TB_PREF."debtor_trans.debtor_no = '$debtorno' - AND ".TB_PREF."debtor_trans.type <> 13 + AND ".TB_PREF."debtor_trans.type <> ".ST_CUSTDELIVERY." ORDER BY ".TB_PREF."debtor_trans.tran_date"; return db_query($sql,"No transactions were returned"); @@ -133,9 +133,9 @@ function print_statements() $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); $rep->TextCol(1, 2, $myrow2['reference'], -2); $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); - if ($myrow2['type'] == 10) + if ($myrow2['type'] == ST_SALESINVOICE) $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); - if ($myrow2['type'] == 10) + if ($myrow2['type'] == ST_SALESINVOICE) $rep->TextCol(4, 5, $DisplayTotal, -2); else $rep->TextCol(5, 6, $DisplayTotal, -2); diff --git a/reporting/rep109.php b/reporting/rep109.php index 2a151def..3fb0ad5a 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -74,7 +74,7 @@ function print_sales_orders() for ($i = $from; $i <= $to; $i++) { - $myrow = get_sales_order_header($i, 30); + $myrow = get_sales_order_header($i, ST_SALESORDER); $branch = get_branch($myrow["branch_code"]); if ($email == 1) { @@ -97,7 +97,7 @@ function print_sales_orders() $rep->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER")); $rep->Header2($myrow, $branch, $myrow, $baccount, 9); - $result = get_sales_order_details($i, 30); + $result = get_sales_order_details($i, ST_SALESORDER); $SubTotal = 0; while ($myrow2=db_fetch($result)) { diff --git a/reporting/rep110.php b/reporting/rep110.php index a0051c45..5af4a83c 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -70,11 +70,11 @@ function print_deliveries() for ($i = $fno[0]; $i <= $tno[0]; $i++) { - if (!exists_customer_trans(13, $i)) + if (!exists_customer_trans(ST_CUSTDELIVERY, $i)) continue; - $myrow = get_customer_trans($i, 13); + $myrow = get_customer_trans($i, ST_CUSTDELIVERY); $branch = get_branch($myrow["branch_code"]); - $sales_order = get_sales_order_header($myrow["order_"], 30); // ? + $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); // ? if ($email == 1) { $rep = new FrontReport("", "", user_pagesize()); @@ -118,7 +118,7 @@ function print_deliveries() $rep->Header2($myrow, $branch, $sales_order,'',13); } - $comments = get_comments(13, $i); + $comments = get_comments(ST_CUSTDELIVERY, $i); if ($comments && db_num_rows($comments)) { $rep->NewLine(); diff --git a/reporting/rep111.php b/reporting/rep111.php index 4272dbf6..cbf48a04 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -68,7 +68,7 @@ function print_sales_quotations() for ($i = $from; $i <= $to; $i++) { - $myrow = get_sales_order_header($i, 32); + $myrow = get_sales_order_header($i, ST_SALESQUOTE); $branch = get_branch($myrow["branch_code"]); if ($email == 1) { @@ -81,7 +81,7 @@ function print_sales_quotations() $rep->title = _("SALES QUOTATION"); $rep->Header2($myrow, $branch, $myrow, $baccount, 7); - $result = get_sales_order_details($i, 32); + $result = get_sales_order_details($i, ST_SALESQUOTE); $SubTotal = 0; while ($myrow2=db_fetch($result)) { diff --git a/reporting/rep201.php b/reporting/rep201.php index 61048e87..a5614755 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -31,12 +31,12 @@ function get_open_balance($supplier_id, $to, $convert) { $to = date2sql($to); - $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + + $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= " * rate"; $sql .= ", 0)) AS charges, - SUM(IF(".TB_PREF."supp_trans.type <> 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + + SUM(IF(".TB_PREF."supp_trans.type <> ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= "* rate"; @@ -66,7 +66,7 @@ function getTransactions($supplier_id, $from, $to) $sql = "SELECT ".TB_PREF."supp_trans.*, (".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) + ((".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.") AND ".TB_PREF."supp_trans.due_date < '$to') AS OverDue FROM ".TB_PREF."supp_trans WHERE ".TB_PREF."supp_trans.tran_date >= '$from' AND ".TB_PREF."supp_trans.tran_date <= '$to' @@ -173,7 +173,7 @@ function print_supplier_balances() $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['reference']); $rep->DateCol(2, 3, $trans['tran_date'], true); - if ($trans['type'] == 20) + if ($trans['type'] == ST_SUPPINVOICE) $rep->DateCol(3, 4, $trans['due_date'], true); $item[0] = $item[1] = 0.0; if ($convert) @@ -198,7 +198,7 @@ function print_supplier_balances() else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; */ - if ($trans['type'] == 20 || $trans['type'] == 2) + if ($trans['type'] == ST_SUPPINVOICE || $trans['type'] == ST_BANKDEPOSIT) $item[3] = $item[0] + $item[1] - $item[2]; else $item[3] = $item[0] - $item[1] + $item[2]; diff --git a/reporting/rep202.php b/reporting/rep202.php index 2245ae01..97156dc5 100644 --- a/reporting/rep202.php +++ b/reporting/rep202.php @@ -37,7 +37,7 @@ function get_invoices($supplier_id, $to) // Revomed allocated from sql $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; - $due = "IF (".TB_PREF."supp_trans.type=20 OR ".TB_PREF."supp_trans.type=21,".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; + $due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; $sql = "SELECT ".TB_PREF."supp_trans.type, ".TB_PREF."supp_trans.reference, ".TB_PREF."supp_trans.tran_date, diff --git a/reporting/rep203.php b/reporting/rep203.php index ffe28416..91fdfde6 100644 --- a/reporting/rep203.php +++ b/reporting/rep203.php @@ -133,11 +133,11 @@ function print_payment_report() $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['supp_reference']); - if ($trans['type'] == 20) + if ($trans['type'] == ST_SUPPINVOICE) $rep->DateCol(2, 3, $trans['due_date'], true); else $rep->DateCol(2, 3, $trans['tran_date'], true); - if ($trans['type'] != 20) + if ($trans['type'] != ST_SUPPINVOICE) { $trans['TranTotal'] = -$trans['TranTotal']; $trans['Balance'] = -$trans['Balance']; diff --git a/reporting/rep304.php b/reporting/rep304.php index 7dbe339a..3958536f 100644 --- a/reporting/rep304.php +++ b/reporting/rep304.php @@ -56,7 +56,7 @@ function getTransactions($category, $location, $fromcust, $from, $to) AND ".TB_PREF."stock_moves.trans_no=".TB_PREF."debtor_trans.trans_no AND ".TB_PREF."stock_moves.tran_date>='$from' AND ".TB_PREF."stock_moves.tran_date<='$to' - AND ((".TB_PREF."debtor_trans.type=13 AND ".TB_PREF."debtor_trans.version=1) OR ".TB_PREF."stock_moves.type=11) + AND ((".TB_PREF."debtor_trans.type=".ST_CUSTDELIVERY." AND ".TB_PREF."debtor_trans.version=1) OR ".TB_PREF."stock_moves.type=".ST_CUSTCREDIT.") AND (".TB_PREF."stock_master.mb_flag='B' OR ".TB_PREF."stock_master.mb_flag='M')"; if ($category != 0) $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'"; diff --git a/reporting/rep409.php b/reporting/rep409.php index 07e76f38..bf6bb3d4 100644 --- a/reporting/rep409.php +++ b/reporting/rep409.php @@ -131,7 +131,7 @@ function print_workorders() $rep->NewLine(1); $rep->TextCol(0, 5," *** = "._("Insufficient stock"), -2); - $comments = get_comments(26, $i); + $comments = get_comments(ST_WORKORDER, $i); if ($comments && db_num_rows($comments)) { $rep->NewLine(); diff --git a/reporting/rep709.php b/reporting/rep709.php index f20e48e0..4baf0105 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -45,8 +45,8 @@ function getTaxTransactions($from, $to) ON taxrec.trans_no=dtrans.trans_no AND taxrec.trans_type=dtrans.type LEFT JOIN ".TB_PREF."debtors_master as debt ON dtrans.debtor_no=debt.debtor_no LEFT JOIN ".TB_PREF."cust_branch as branch ON dtrans.branch_code=branch.branch_code - WHERE (taxrec.amount != 0 OR taxrec.net_amount != 0) - AND taxrec.trans_type != 13 + WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0) + AND taxrec.trans_type <> ".ST_CUSTDELIVERY." AND taxrec.tran_date >= '$fromdate' AND taxrec.tran_date <= '$todate' ORDER BY taxrec.tran_date"; @@ -116,7 +116,7 @@ function print_tax_report() while ($trans=db_fetch($transactions)) { - if (in_array($trans['trans_type'], array(11,20))) { + if (in_array($trans['trans_type'], array(ST_CUSTCREDIT,ST_SUPPINVOICE))) { $trans['net_amount'] *= -1; $trans['amount'] *= -1; } @@ -143,7 +143,7 @@ function print_tax_report() $rep->Header(); } } - if (in_array($trans['trans_type'], array(2,10,11))) { + if (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) { $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount']; $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount']; } else { diff --git a/sales/create_recurrent_invoices.php b/sales/create_recurrent_invoices.php index 644f60b2..f1897335 100644 --- a/sales/create_recurrent_invoices.php +++ b/sales/create_recurrent_invoices.php @@ -34,11 +34,11 @@ function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no { global $Refs; - $doc = new Cart(30, array($order_no)); + $doc = new Cart(ST_SALESORDER, array($order_no)); get_customer_details_to_order($doc, $customer_id, $branch_id); - $doc->trans_type = 30; + $doc->trans_type = ST_SALESORDER; $doc->trans_no = 0; $doc->document_date = Today(); // 2006-06-15. Added so Invoices and Deliveries get current day @@ -52,7 +52,7 @@ function create_recurrent_invoices($customer_id, $branch_id, $order_no, $tmpl_no $doc->sales_type, $doc->price_factor, $doc->document_date); } $cart = $doc; - $cart->trans_type = 10; + $cart->trans_type = ST_SALESINVOICE; $cart->reference = $Refs->get_next($cart->trans_type); $invno = $cart->write(1); set_last_sent($tmpl_no, $cart->document_date); @@ -89,7 +89,7 @@ if (isset($_GET['recurrent'])) if (count($invs) > 0) { $ar = array('PARAM_0' => $min, 'PARAM_1' => $max, 'PARAM_2' => "", 'PARAM_3' => get_first_bank_account(), - 'PARAM_4' => 0, 'PARAM_5' => 0, 'PARAM_6' => "", 'PARAM_7' => 10); + 'PARAM_4' => 0, 'PARAM_5' => 0, 'PARAM_6' => "", 'PARAM_7' => ST_SALESINVOICE); display_note(print_link(_("&Print Recurrent Invoices # $min - # $max"), 107, $ar), 0, 1); $ar['PARAM_4'] = 1; display_note(print_link(_("&Email Recurrent Invoices # $min - # $max"), 107, $ar), 0, 1); diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 7dcc461d..5d2ebb8d 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -61,14 +61,14 @@ if (list_updated('branch_id')) { if (isset($_GET['AddedID'])) { $credit_no = $_GET['AddedID']; - $trans_type = 11; + $trans_type = ST_CUSTCREDIT; display_notification_centered(sprintf(_("Credit Note # %d has been processed"),$credit_no)); display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View this credit note")), 0, 1); - display_note(print_document_link($credit_no, _("&Print This Credit Invoice"), true, 11),0, 1); - display_note(print_document_link($credit_no, _("&Email This Credit Invoice"), true, 11, false, "", "", 1),0, 1); + display_note(print_document_link($credit_no, _("&Print This Credit Invoice"), true, ST_CUSTCREDIT),0, 1); + display_note(print_document_link($credit_no, _("&Email This Credit Invoice"), true, ST_CUSTCREDIT, false, "", "", 1),0, 1); display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note"))); @@ -143,7 +143,7 @@ function can_process() display_error( _("You must enter a reference.")); set_focus('ref'); $input_error = 1; - } elseif (!is_new_reference($_POST['ref'], 11)) { + } elseif (!is_new_reference($_POST['ref'], ST_CUSTCREDIT)) { display_error( _("The entered reference is already in use.")); set_focus('ref'); $input_error = 1; diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index d6dd0fb7..5c62eba6 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -48,13 +48,13 @@ page($_SESSION['page_title'], false, false, "", $js); if (isset($_GET['AddedID'])) { $credit_no = $_GET['AddedID']; - $trans_type = 11; + $trans_type = ST_CUSTCREDIT; display_notification_centered(_("Credit Note has been processed")); display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View This Credit Note")), 0, 0); - display_note(print_document_link($credit_no, _("&Print This Credit Note"), true, 11),1); + display_note(print_document_link($credit_no, _("&Print This Credit Note"), true, $trans_type),1); display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")),1); @@ -62,13 +62,13 @@ if (isset($_GET['AddedID'])) { } elseif (isset($_GET['UpdatedID'])) { $credit_no = $_GET['UpdatedID']; - $trans_type = 11; + $trans_type = ST_CUSTCREDIT; display_notification_centered(_("Credit Note has been updated")); display_note(get_customer_trans_view_str($trans_type, $credit_no, _("&View This Credit Note")), 0, 0); - display_note(print_document_link($credit_no, _("&Print This Credit Note"), true, 11),1); + display_note(print_document_link($credit_no, _("&Print This Credit Note"), true, $trans_type),1); display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL &Journal Entries for this Credit Note")),1); @@ -100,7 +100,7 @@ function can_process() return false; } - if (!is_new_reference($_POST['ref'], 11)) { + if (!is_new_reference($_POST['ref'], ST_CUSTCREDIT)) { display_error(_("The entered reference is already in use."));; set_focus('ref'); return false; @@ -122,14 +122,14 @@ function can_process() if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { - $ci = new Cart(10, $_GET['InvoiceNumber'], true); + $ci = new Cart(ST_SALESINVOICE, $_GET['InvoiceNumber'], true); - $ci->trans_type = 11; + $ci->trans_type = ST_CUSTCREDIT; $ci->src_docs = $ci->trans_no; $ci->src_date = $ci->document_date; $ci->trans_no = 0; $ci->document_date = new_doc_date(); - $ci->reference = $Refs->get_next(11); + $ci->reference = $Refs->get_next(ST_CUSTCREDIT); for ($line_no=0; $line_noline_items); $line_no++) { $ci->line_items[$line_no]->qty_dispatched = '0'; @@ -140,7 +140,7 @@ if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { } elseif ( isset($_GET['ModifyCredit']) && $_GET['ModifyCredit']>0) { - $_SESSION['Items'] = new Cart(11,$_GET['ModifyCredit']); + $_SESSION['Items'] = new Cart(ST_CUSTCREDIT,$_GET['ModifyCredit']); copy_from_cart(); } elseif (!processing_active()) { @@ -257,8 +257,7 @@ function display_credit_items() } else { label_cells(_("Reference"), $_SESSION['Items']->reference, "class='tableheader2'"); } -// label_cells(_("Crediting Invoice"), get_customer_trans_view_str(10, $_SESSION['InvoiceToCredit']), "class='tableheader2'"); - label_cells(_("Crediting Invoice"), get_customer_trans_view_str(10, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'"); + label_cells(_("Crediting Invoice"), get_customer_trans_view_str(ST_SALESINVOICE, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'"); if (!isset($_POST['ShipperID'])) { $_POST['ShipperID'] = $_SESSION['Items']->ship_via; diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 366d9a29..f4ffe915 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -49,10 +49,10 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf(_("Delivery # %d has been entered."),$dispatch_no)); - display_note(get_customer_trans_view_str(13, $dispatch_no, _("&View This Delivery")), 0, 1); + display_note(get_customer_trans_view_str(ST_CUSTDELIVERY, $dispatch_no, _("&View This Delivery")), 0, 1); - display_note(print_document_link($dispatch_no, _("&Print Delivery Note"), true, 13)); - display_note(print_document_link($dispatch_no, _("&Email Delivery Note"), true, 13, false, "", "", 1), 1); + display_note(print_document_link($dispatch_no, _("&Print Delivery Note"), true, ST_CUSTDELIVERY)); + display_note(print_document_link($dispatch_no, _("&Email Delivery Note"), true, ST_CUSTDELIVERY, false, "", "", 1), 1); display_note(get_gl_view_str(13, $dispatch_no, _("View the GL Journal Entries for this Dispatch")),1); @@ -68,9 +68,9 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf(_('Delivery Note # %d has been updated.'),$delivery_no)); - display_note(get_trans_view_str(13, $delivery_no, _("View this delivery"))); + display_note(get_trans_view_str(ST_CUSTDELIVERY, $delivery_no, _("View this delivery"))); echo '
'; - display_note(print_document_link($delivery_no, _("Print this delivery"), true, 13)); + display_note(print_document_link($delivery_no, _("Print this delivery"), true, ST_CUSTDELIVERY)); hyperlink_params($path_to_root . "/sales/customer_invoice.php", _("Confirm Delivery and Invoice"), "DeliveryNumber=$delivery_no"); @@ -82,7 +82,7 @@ if (isset($_GET['AddedID'])) { if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { - $ord = new Cart(30, $_GET['OrderNumber'], true); + $ord = new Cart(ST_SALESORDER, $_GET['OrderNumber'], true); /*read in all the selected order into the Items cart */ @@ -92,18 +92,18 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { die ("
" . _("This order has no items. There is nothing to delivery.") . ""); } - $ord->trans_type = 13; + $ord->trans_type = ST_CUSTDELIVERY; $ord->src_docs = $ord->trans_no; $ord->order_no = key($ord->trans_no); $ord->trans_no = 0; - $ord->reference = $Refs->get_next(13); + $ord->reference = $Refs->get_next(ST_CUSTDELIVERY); $ord->document_date = new_doc_date(); $_SESSION['Items'] = $ord; copy_from_cart(); } elseif (isset($_GET['ModifyDelivery']) && $_GET['ModifyDelivery'] > 0) { - $_SESSION['Items'] = new Cart(13,$_GET['ModifyDelivery']); + $_SESSION['Items'] = new Cart(ST_CUSTDELIVERY,$_GET['ModifyDelivery']); if ($_SESSION['Items']->count_items() == 0) { hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", @@ -167,7 +167,7 @@ function check_data() return false; } - if ($_SESSION['Items']->trans_no==0 && !is_new_reference($_POST['ref'], 13)) { + if ($_SESSION['Items']->trans_no==0 && !is_new_reference($_POST['ref'], ST_CUSTDELIVERY)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; @@ -328,7 +328,7 @@ end_row(); start_row(); //if (!isset($_POST['ref'])) -// $_POST['ref'] = $Refs->get_next(13); +// $_POST['ref'] = $Refs->get_next(ST_CUSTDELIVERY); if ($_SESSION['Items']->trans_no==0) { ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'"); diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index a943b099..acf30137 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -50,14 +50,14 @@ check_edit_conflicts(); if (isset($_GET['AddedID'])) { $invoice_no = $_GET['AddedID']; - $trans_type = 10; + $trans_type = ST_SALESINVOICE; display_notification(_("Selected deliveries has been processed"), true); display_note(get_customer_trans_view_str($trans_type, $invoice_no, _("&View This Invoice")), 0, 1); - display_note(print_document_link($invoice_no, _("&Print This Invoice"), true, 10)); - display_note(print_document_link($invoice_no, _("&Email This Invoice"), true, 10, false, "", "", 1),1); + display_note(print_document_link($invoice_no, _("&Print This Invoice"), true, ST_SALESINVOICE)); + display_note(print_document_link($invoice_no, _("&Email This Invoice"), true, ST_SALESINVOICE, false, "", "", 1),1); display_note(get_gl_view_str($trans_type, $invoice_no, _("View the GL &Journal Entries for this Invoice")),1); @@ -71,9 +71,9 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf(_('Sales Invoice # %d has been updated.'),$invoice_no)); - display_note(get_trans_view_str(10, $invoice_no, _("&View This Invoice"))); + display_note(get_trans_view_str(ST_SALESINVOICE, $invoice_no, _("&View This Invoice"))); echo '
'; - display_note(print_document_link($invoice_no, _("&Print This Invoice"), true, 10)); + display_note(print_document_link($invoice_no, _("&Print This Invoice"), true, ST_SALESINVOICE)); hyperlink_no_params($path_to_root . "/sales/inquiry/customer_inquiry.php", _("Select A Different &Invoice to Modify")); @@ -109,7 +109,7 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) $src = array($_GET['DeliveryNumber']); } /*read in all the selected deliveries into the Items cart */ - $dn = new Cart(13, $src, true); + $dn = new Cart(ST_CUSTDELIVERY, $src, true); if ($dn->count_items() == 0) { hyperlink_params($path_to_root . "/sales/inquiry/sales_deliveries_view.php", @@ -117,10 +117,10 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) die ("
" . _("There are no delivered items with a quantity left to invoice. There is nothing left to invoice.") . ""); } - $dn->trans_type = 10; + $dn->trans_type = ST_SALESINVOICE; $dn->src_docs = $dn->trans_no; $dn->trans_no = 0; - $dn->reference = $Refs->get_next(10); + $dn->reference = $Refs->get_next(ST_SALESINVOICE); $dn->due_date = get_invoice_duedate($dn->customer_id, $dn->document_date); $_SESSION['Items'] = $dn; @@ -128,14 +128,14 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) } elseif (isset($_GET['ModifyInvoice']) && $_GET['ModifyInvoice'] > 0) { - if ( get_parent_trans(10, $_GET['ModifyInvoice']) == 0) { // 1.xx compatibility hack + if ( get_parent_trans(ST_SALESINVOICE, $_GET['ModifyInvoice']) == 0) { // 1.xx compatibility hack echo"

" . _("There are no delivery notes for this invoice.
Most likely this invoice was created in Front Accounting version prior to 2.0 and therefore can not be modified.") . "
"; display_footer_exit(); } processing_start(); - $_SESSION['Items'] = new Cart(10, $_GET['ModifyInvoice']); + $_SESSION['Items'] = new Cart(ST_SALESINVOICE, $_GET['ModifyInvoice']); if ($_SESSION['Items']->count_items() == 0) { echo"

" . _("All quantities on this invoice has been credited. There is nothing to modify on this invoice") . "
"; @@ -340,7 +340,7 @@ $dspans[] = $spanlen; $is_batch_invoice = count($_SESSION['Items']->src_docs) > 1; -$is_edition = $_SESSION['Items']->trans_type == 10 && $_SESSION['Items']->trans_no != 0; +$is_edition = $_SESSION['Items']->trans_type == ST_SALESINVOICE && $_SESSION['Items']->trans_no != 0; start_form(); hidden('cart_id'); diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 53f92be5..1dcce02d 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -60,7 +60,7 @@ if (isset($_GET['AddedID'])) { display_notification_centered(_("The customer payment has been successfully entered.")); - display_note(get_gl_view_str(12, $payment_no, _("&View the GL Journal Entries for this Customer Payment"))); + display_note(get_gl_view_str(ST_CUSTPAYMENT, $payment_no, _("&View the GL Journal Entries for this Customer Payment"))); // hyperlink_params($path_to_root . "/sales/allocations/customer_allocate.php", _("&Allocate this Customer Payment"), "trans_no=$payment_no&trans_type=12"); @@ -92,7 +92,7 @@ function can_process() return false; } - if (!is_new_reference($_POST['ref'], 12)) { + if (!is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; @@ -218,7 +218,7 @@ start_form(); customer_list_row(_("From Customer:"), 'customer_id', null, false, true); if (!isset($_POST['bank_account'])) // first page call - $_SESSION['alloc'] = new allocation(12,0); + $_SESSION['alloc'] = new allocation(ST_CUSTPAYMENT,0); if (db_customer_has_branches($_POST['customer_id'])) { customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true); diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 3f22e4f3..d85136c5 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -82,10 +82,10 @@ class cart /*Constructor function initialises a new shopping cart */ $this->line_items = array(); $this->sales_type = ""; - if ($type == 32) + if ($type == ST_SALESQUOTE) $this->trans_type = $type; else - $this->trans_type = 30; + $this->trans_type = ST_SALESORDER; $this->dimension_id = 0; $this->dimension2_id = 0; $this->read($type, $trans_no, $view ); @@ -101,7 +101,7 @@ class cart if (!is_array($trans_no)) $trans_no = array($trans_no); if ($trans_no[0]) { - if ($type == 30 || $type == 32) { // sales order || sales quotation + if ($type == ST_SALESORDER || $type == ST_SALESQUOTE) { // sales order || sales quotation read_sales_order($trans_no[0], $this, $type); if ($view) { // prepare for DN/IV entry for($line_no = 0; $line_no < count($this->line_items); $line_no++) { @@ -113,7 +113,7 @@ class cart } else { // derivative transaction read_sales_trans($type, $trans_no, $this); if ($this->order_no) { // free hand credit notes have no order_no - $sodata = get_sales_order_header($this->order_no, 30); + $sodata = get_sales_order_header($this->order_no, ST_SALESORDER); $this->cust_ref = $sodata["customer_ref"]; // currently currency is hard linked to debtor account // $this->customer_currency = $sodata["curr_code"]; @@ -123,9 +123,9 @@ class cart if (!$view && ($type!=11 || $this->trans_link!=0)) { $src_type = get_parent_type($type); $src_details = 0; - if ($src_type == 30) { // get src data from sales_orders + if ($src_type == ST_SALESORDER) { // get src data from sales_orders $this->src_docs = array( $sodata['order_no']=>$sodata['version']); - $srcdetails = get_sales_order_details($this->order_no, 30); + $srcdetails = get_sales_order_details($this->order_no, ST_SALESORDER); } else { // get src_data from debtor_trans $this->src_docs = get_customer_trans_version($src_type, get_parent_trans($type,$trans_no[0])); $srcdetails = get_customer_trans_details($src_type,array_keys($this->src_docs)); @@ -160,7 +160,7 @@ class cart if (!is_date_in_fiscalyear($this->document_date)) $this->document_date = end_fiscalyear(); $this->reference = $Refs->get_next($this->trans_type); - if ($type != 30 && $type != 32) // Added 2.1 Joe Hunt 2008-11-12 + if ($type != ST_SALESORDER && $type != ST_SALESQUOTE) // Added 2.1 Joe Hunt 2008-11-12 { $dim = get_company_pref('use_dimension'); if ($dim > 0) @@ -181,7 +181,7 @@ class cart } } } - if ($type == 10) { + if ($type == ST_SALESINVOICE) { $this->due_date = get_invoice_duedate($this->customer_id, $this->document_date); $this->pos = user_pos(); @@ -208,7 +208,7 @@ class cart // Makes parent documents for direct delivery/invoice by recurent call. // $policy - 0 or 1: writeoff/return for IV, back order/cancel for DN function write($policy=0) { - if (count($this->src_docs) == 0 && ($this->trans_type == 10 || $this->trans_type == 13)) { + if (count($this->src_docs) == 0 && ($this->trans_type == ST_SALESINVOICE || $this->trans_type == ST_CUSTDELIVERY)) { // this is direct document - first add parent $src = (PHP_VERSION<5) ? $this : clone( $this ); // make local copy of this cart $src->trans_type = get_parent_type($src->trans_type); @@ -225,7 +225,7 @@ class cart $this->trans_type = $type; $this->src_docs= $this->trans_no; $this->trans_no = 0; - $this->order_no= $this->trans_type==13 ? key($src->trans_no) : $src->order_no; + $this->order_no= $this->trans_type==ST_CUSTDELIVERY ? key($src->trans_no) : $src->order_no; } $this->reference = @html_entity_decode($this->reference); $this->Comments = @html_entity_decode($this->Comments); @@ -234,14 +234,14 @@ class cart $this->line_items[$lineno]->item_description = @html_entity_decode($line->item_description); } switch($this->trans_type) { - case 10: + case ST_SALESINVOICE: return write_sales_invoice($this); - case 11: + case ST_CUSTCREDIT: return write_credit_note($this, $policy); - case 13: + case ST_CUSTDELIVERY: return write_sales_delivery($this, $policy); - case 30: - case 32: + case ST_SALESORDER: + case ST_SALESQUOTE: if ($this->trans_no==0) // new document return add_sales_order($this); else diff --git a/sales/includes/db/cust_trans_db.inc b/sales/includes/db/cust_trans_db.inc index e3e22006..fab74ab6 100644 --- a/sales/includes/db/cust_trans_db.inc +++ b/sales/includes/db/cust_trans_db.inc @@ -24,7 +24,7 @@ function get_parent_trans($trans_type, $trans_no) { $link = db_fetch($result); return array($link['trans_link']); } - if ($trans_type!=10) return 0; // this is credit note with no parent invoice + if ($trans_type!=ST_SALESINVOICE) return 0; // this is credit note with no parent invoice // invoice: find batch invoice parent trans. $sql = 'SELECT trans_no FROM '.TB_PREF.'debtor_trans WHERE @@ -157,7 +157,7 @@ function get_customer_trans($trans_id, $trans_type) ".TB_PREF."bank_accounts.account_type AS BankTransType "; } - if ($trans_type == 10 OR $trans_type == 11 OR $trans_type == 13) { + if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) { // it's an invoice so also get the shipper and salestype $sql .= ", ".TB_PREF."shippers.shipper_name, " .TB_PREF."sales_types.sales_type, " @@ -176,7 +176,7 @@ function get_customer_trans($trans_id, $trans_type) $sql .= ", ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts"; } - if ($trans_type == 10 OR $trans_type == 11 OR $trans_type == 13) { + if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) { // it's an invoice so also get the shipper, salestypes $sql .= ", ".TB_PREF."shippers, ".TB_PREF."sales_types, ".TB_PREF."cust_branch, ".TB_PREF."tax_groups "; } @@ -191,7 +191,7 @@ function get_customer_trans($trans_id, $trans_type) AND ".TB_PREF."bank_trans.type=$trans_type AND ".TB_PREF."bank_accounts.id=".TB_PREF."bank_trans.bank_act "; } - if ($trans_type == 10 OR $trans_type == 11 OR $trans_type == 13) { + if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTCREDIT || $trans_type == ST_CUSTDELIVERY) { // it's an invoice so also get the shipper $sql .= " AND ".TB_PREF."shippers.shipper_id=".TB_PREF."debtor_trans.ship_via AND ".TB_PREF."sales_types.id = ".TB_PREF."debtor_trans.tpe @@ -276,14 +276,14 @@ function void_customer_trans($type, $type_no) function post_void_customer_trans($type, $type_no) { switch ($type) { - case 10 : - case 11 : + case ST_SALESINVOICE : + case ST_CUSTCREDIT : void_sales_invoice($type, $type_no); break; - case 13 : + case ST_CUSTDELIVERY : void_sales_delivery($type, $type_no); break; - case 12 : + case ST_CUSTPAYMENT : void_customer_payment($type, $type_no); break; } diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index addb867e..9152a3f4 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -139,7 +139,7 @@ function get_allocatable_from_cust_sql($customer_id, $settled) $cust_sql = " AND trans.debtor_no = $customer_id"; $sql = get_alloc_trans_sql("round(ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount-alloc,6) <= 0 AS settled", - "(type=12 OR type=11 OR type=2) AND (trans.ov_amount > 0) " . $settled_sql . $cust_sql); + "(type=".ST_CUSTPAYMENT." OR type=".ST_CUSTCREDIT." OR type=".ST_BANKDEPOSIT.") AND (trans.ov_amount > 0) " . $settled_sql . $cust_sql); return $sql; } @@ -160,10 +160,10 @@ function get_allocatable_to_cust_transactions($customer_id, $trans_no=null, $typ else { $sql = get_alloc_trans_sql(null, "round(ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount-alloc,6) > 0 - AND trans.type != " . ST_CUSTPAYMENT . " - AND trans.type != " . ST_BANKDEPOSIT . " - AND trans.type != 11 - AND trans.type != 13 + AND trans.type <> " . ST_CUSTPAYMENT . " + AND trans.type <> " . ST_BANKDEPOSIT . " + AND trans.type <> " . ST_CUSTCREDIT . " + AND trans.type <> " . ST_CUSTDELIVERY . " AND trans.debtor_no=$customer_id"); } diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index f7e56866..a73bc8ad 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -21,20 +21,20 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou $company_record = get_company_prefs(); - $payment_no = write_customer_trans(12, $trans_no, $customer_id, $branch_id, + $payment_no = write_customer_trans(ST_CUSTPAYMENT, $trans_no, $customer_id, $branch_id, $date_, $ref, $amount, $discount, 0, 0, 0, 0, 0, 0, 0, "", 0, $rate); $bank_gl_account = get_bank_gl_account($bank_account); if ($trans_no != 0) { - delete_comments(12, $trans_no); - void_bank_trans(12, $trans_no, true); - void_gl_trans(12, $trans_no, true); - void_cust_allocations(12, $trans_no, $date_); + delete_comments(ST_CUSTPAYMENT, $trans_no); + void_bank_trans(ST_CUSTPAYMENT, $trans_no, true); + void_gl_trans(ST_CUSTPAYMENT, $trans_no, true); + void_cust_allocations(ST_CUSTPAYMENT, $trans_no, $date_); } $total = 0; /* Bank account entry first */ - $total += add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_, $bank_gl_account, 0, 0, $amount - $charge, $customer_id, "Cannot insert a GL transaction for the bank account debit", $rate); @@ -52,13 +52,13 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou if (($discount + $amount) != 0) { /* Now Credit Debtors account with receipts + discounts */ - $total += add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_, $debtors_account, 0, 0, -($discount + $amount), $customer_id, "Cannot insert a GL transaction for the debtors account credit", $rate); } if ($discount != 0) { /* Now Debit discount account with discounts allowed*/ - $total += add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_, $discount_account, 0, 0, $discount, $customer_id, "Cannot insert a GL transaction for the payment discount debit", $rate); } @@ -66,21 +66,21 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou if ($charge != 0) { /* Now Debit bank charge account with charges */ $charge_act = get_company_pref('bank_charge_act'); - $total += add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(ST_CUSTPAYMENT, $payment_no, $date_, $charge_act, 0, 0, $charge, $customer_id, "Cannot insert a GL transaction for the payment bank charge debit", $rate); } /*Post a balance post if $total != 0 */ - add_gl_balance(12, $payment_no, $date_, -$total, PT_CUSTOMER, $customer_id); + add_gl_balance(ST_CUSTPAYMENT, $payment_no, $date_, -$total, PT_CUSTOMER, $customer_id); /*now enter the bank_trans entry */ - add_bank_trans(12, $payment_no, $bank_account, $ref, + add_bank_trans(ST_CUSTPAYMENT, $payment_no, $bank_account, $ref, $date_, $amount - $charge, PT_CUSTOMER, $customer_id, get_customer_currency($customer_id), "", $rate); - add_comments(12, $payment_no, $date_, $memo_); + add_comments(ST_CUSTPAYMENT, $payment_no, $date_, $memo_); - $Refs->save(12, $payment_no, $ref); + $Refs->save(ST_CUSTPAYMENT, $payment_no, $ref); commit_transaction(); diff --git a/sales/includes/db/sales_credit_db.inc b/sales/includes/db/sales_credit_db.inc index caff001f..a71d686a 100644 --- a/sales/includes/db/sales_credit_db.inc +++ b/sales/includes/db/sales_credit_db.inc @@ -67,7 +67,7 @@ function write_credit_note($credit_note, $write_off_acc) /*Now insert the Credit Note into the debtor_trans table with the allocations as calculated above*/ // all amounts in debtor's currency - $credit_no = write_customer_trans(11, $trans_no, $credit_note->customer_id, + $credit_no = write_customer_trans(ST_CUSTCREDIT, $trans_no, $credit_note->customer_id, $credit_note->Branch, $credit_date, $credit_note->reference, $credit_note_total, 0, $items_added_tax, $credit_note->freight_cost, $freight_added_tax, @@ -80,15 +80,15 @@ function write_credit_note($credit_note, $write_off_acc) $credit_note->trans_no = array($credit_no=>0); set_document_parent($credit_note); } else { - delete_comments(11, $credit_no); - void_cust_allocations(11, $credit_no, $credit_date); - void_gl_trans(11, $credit_no, true); - void_stock_move(11, $credit_no); - void_trans_tax_details(11, $credit_no); + delete_comments(ST_CUSTCREDIT, $credit_no); + void_cust_allocations(ST_CUSTCREDIT, $credit_no, $credit_date); + void_gl_trans(ST_CUSTCREDIT, $credit_no, true); + void_stock_move(ST_CUSTCREDIT, $credit_no); + void_trans_tax_details(ST_CUSTCREDIT, $credit_no); } if ($credit_invoice) { - $invoice_alloc_balance = get_DebtorTrans_allocation_balance(10, $credit_invoice); - update_customer_trans_version(get_parent_type(11), $credit_note->src_docs ); + $invoice_alloc_balance = get_DebtorTrans_allocation_balance(ST_SALESINVOICE, $credit_invoice); + update_customer_trans_version(get_parent_type(ST_CUSTCREDIT), $credit_note->src_docs ); if ($invoice_alloc_balance > 0) { //the invoice is not already fully allocated $total = $credit_note_total + $credit_note->freight_cost + $items_added_tax + $freight_added_tax; @@ -96,12 +96,12 @@ function write_credit_note($credit_note, $write_off_acc) $allocate_amount = ($invoice_alloc_balance > $total) ? $total : $invoice_alloc_balance; /*Now insert the allocation record if > 0 */ if ($allocate_amount != 0) { - update_debtor_trans_allocation(10, $credit_invoice, $allocate_amount); - update_debtor_trans_allocation(11, $credit_no, $allocate_amount); // *** - add_cust_allocation($allocate_amount, 11, $credit_no, 10, $credit_invoice); + update_debtor_trans_allocation(ST_SALESINVOICE, $credit_invoice, $allocate_amount); + update_debtor_trans_allocation(ST_CUSTCREDIT, $credit_no, $allocate_amount); // *** + add_cust_allocation($allocate_amount, ST_CUSTCREDIT, $credit_no, ST_SALESINVOICE, $credit_invoice); // Exchange Variations Joe Hunt 2008-09-20 //////////////////////////////////////// - exchange_variation(11, $credit_no, 10, $credit_invoice, $credit_date, + exchange_variation(ST_CUSTCREDIT, $credit_no, ST_SALESINVOICE, $credit_invoice, $credit_date, $allocate_amount, PT_CUSTOMER); /////////////////////////////////////////////////////////////////////////// @@ -124,7 +124,7 @@ function write_credit_note($credit_note, $write_off_acc) $line_tax = get_full_price_for_item($credit_line->stock_id, $credit_line->price, 0, $credit_note->tax_included, $credit_note->tax_group_array) - $line_taxfree_price; - write_customer_trans_detail_item(11, $credit_no, $credit_line->stock_id, + write_customer_trans_detail_item(ST_CUSTCREDIT, $credit_no, $credit_line->stock_id, $credit_line->item_description, $credit_line->qty_dispatched, $credit_line->line_price(), $line_tax, $credit_line->discount_percent, $credit_line->standard_cost, $trans_no==0 ? 0: $credit_line->id); @@ -141,14 +141,14 @@ function write_credit_note($credit_note, $write_off_acc) if (($credit_note_total + $credit_note->freight_cost) != 0) { - $total += add_gl_trans_customer(11, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0, + $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0, -($credit_note_total + $credit_note->freight_cost + $items_added_tax + $freight_added_tax), $credit_note->customer_id, "The total debtor GL posting for the credit note could not be inserted"); } - if ($credit_note->freight_cost !=0) { - $total += add_gl_trans_customer(11, $credit_no, $credit_date, $company_data["freight_act"], 0, 0, + if ($credit_note->freight_cost != 0) { + $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $company_data["freight_act"], 0, 0, $credit_note->get_tax_free_shipping(), $credit_note->customer_id, "The freight GL posting for this credit note could not be inserted"); } @@ -157,23 +157,23 @@ function write_credit_note($credit_note, $write_off_acc) if ($taxitem['Net'] != 0) { $ex_rate = get_exchange_rate_from_home_currency(get_customer_currency($credit_note->customer_id), $credit_note->document_date); - add_trans_tax_details(11, $credit_no, $taxitem['tax_type_id'], + add_trans_tax_details(ST_CUSTCREDIT, $credit_no, $taxitem['tax_type_id'], $taxitem['rate'], $credit_note->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $credit_note->document_date, $credit_note->reference); - $total += add_gl_trans_customer(11, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0, + $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0, $taxitem['Value'], $credit_note->customer_id, "A tax GL posting for this credit note could not be inserted"); } } /*Post a balance post if $total != 0 */ - add_gl_balance(11, $credit_no, $credit_date, -$total, PT_CUSTOMER, $credit_note->customer_id); + add_gl_balance(ST_CUSTCREDIT, $credit_no, $credit_date, -$total, PT_CUSTOMER, $credit_note->customer_id); - add_comments(11, $credit_no, $credit_date, $credit_note->Comments); + add_comments(ST_CUSTCREDIT, $credit_no, $credit_date, $credit_note->Comments); if ($trans_no == 0) { - $Refs->save(11, $credit_no, $credit_note->reference); + $Refs->save(ST_CUSTCREDIT, $credit_no, $credit_note->reference); } commit_transaction(); @@ -202,14 +202,14 @@ function add_credit_movements_item(&$credit_note, &$credit_line, if ($credited_invoice) $reference .= "Ex Inv: " . $credited_invoice; - add_stock_move_customer(11, $credit_line->stock_id, + add_stock_move_customer(ST_CUSTCREDIT, $credit_line->stock_id, key($credit_note->trans_no), $credit_note->Location, $credit_note->document_date, $reference, -$credit_line->qty_dispatched, $credit_line->standard_cost, 0, $price, $credit_line->discount_percent); } - add_stock_move_customer(11, $credit_line->stock_id, + add_stock_move_customer(ST_CUSTCREDIT, $credit_line->stock_id, key($credit_note->trans_no), $credit_note->Location, $credit_note->document_date, $reference, $credit_line->qty_dispatched, $credit_line->standard_cost, 0, $price, @@ -237,7 +237,7 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, if ($standard_cost != 0) { /*first the cost of sales entry*/ - $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"], + $total += add_gl_trans_std_cost(ST_CUSTCREDIT, $credit_no, $date_, $stock_gl_codes["cogs_account"], $dim, $dim2, "", -($standard_cost * $order_line->qty_dispatched), PT_CUSTOMER, $order->customer_id, "The cost of sales GL posting could not be inserted"); @@ -250,7 +250,7 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $stock_entry_account = $stock_gl_code["inventory_account"]; } - $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0, + $total += add_gl_trans_std_cost(ST_CUSTCREDIT, $credit_no, $date_, $stock_entry_account, 0, 0, "", ($standard_cost * $order_line->qty_dispatched), PT_CUSTOMER, $order->customer_id, "The stock side (or write off) of the cost of sales GL posting could not be inserted"); @@ -275,13 +275,13 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $sales_account = $branch_data['sales_account']; else $sales_account = $stock_gl_codes['sales_account']; - $total += add_gl_trans_customer(11, $credit_no, $date_, $sales_account, $dim, $dim2, + $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $date_, $sales_account, $dim, $dim2, ($line_taxfree_price * $order_line->qty_dispatched), $order->customer_id, "The credit note GL posting could not be inserted"); if ($order_line->discount_percent != 0) { - $total += add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"], + $total += add_gl_trans_customer(ST_CUSTCREDIT, $credit_no, $date_, $branch_data["sales_discount_account"], $dim, $dim2, -($line_taxfree_price * $order_line->qty_dispatched * $order_line->discount_percent), $order->customer_id, "The credit note discount GL posting could not be inserted"); diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 4b38c28c..8bd2d785 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -36,7 +36,7 @@ function write_sales_delivery(&$delivery,$bo_policy) $tax_total += $taxitem['Value']; } /* Insert/update the debtor_trans */ - $delivery_no = write_customer_trans(13, $trans_no, $delivery->customer_id, + $delivery_no = write_customer_trans(ST_CUSTDELIVERY, $trans_no, $delivery->customer_id, $delivery->Branch, $delivery->document_date, $delivery->reference, $delivery_items_total, 0, $delivery->tax_included ? 0 : $tax_total-$freight_tax, @@ -48,10 +48,10 @@ function write_sales_delivery(&$delivery,$bo_policy) if ($trans_no == 0) { $delivery->trans_no = array($delivery_no=>0); } else { - void_gl_trans(13, $delivery_no, true); - void_stock_move(13, $delivery_no); - void_trans_tax_details(13, $delivery_no); - delete_comments(13, $delivery_no); + void_gl_trans(ST_CUSTDELIVERY, $delivery_no, true); + void_stock_move(ST_CUSTDELIVERY, $delivery_no); + void_trans_tax_details(ST_CUSTDELIVERY, $delivery_no); + delete_comments(ST_CUSTDELIVERY, $delivery_no); } foreach ($delivery->line_items as $delivery_line) { @@ -67,7 +67,7 @@ function write_sales_delivery(&$delivery,$bo_policy) $delivery_line->standard_cost = get_standard_cost($delivery_line->stock_id); /* add delivery details for all lines */ - write_customer_trans_detail_item(13, $delivery_no, $delivery_line->stock_id, + write_customer_trans_detail_item(ST_CUSTDELIVERY, $delivery_no, $delivery_line->stock_id, $delivery_line->item_description, $delivery_line->qty_dispatched, $delivery_line->line_price(), $line_tax, $delivery_line->discount_percent, $delivery_line->standard_cost, @@ -75,11 +75,11 @@ function write_sales_delivery(&$delivery,$bo_policy) // Now update sales_order_details for the quantity delivered if ($delivery_line->qty_old != $delivery_line->qty_dispatched) - update_parent_line(13, $delivery_line->src_id, + update_parent_line(ST_CUSTDELIVERY, $delivery_line->src_id, $delivery_line->qty_dispatched-$delivery_line->qty_old); if ($delivery_line->qty_dispatched != 0) { - add_stock_move_customer(13, $delivery_line->stock_id, $delivery_no, + add_stock_move_customer(ST_CUSTDELIVERY, $delivery_line->stock_id, $delivery_no, $delivery->Location, $delivery->document_date, $delivery->reference, -$delivery_line->qty_dispatched, $delivery_line->standard_cost,1, $line_price, $delivery_line->discount_percent); @@ -98,7 +98,7 @@ function write_sales_delivery(&$delivery,$bo_policy) $dim2 = ($delivery->dimension2_id != $customer['dimension2_id'] ? $delivery->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); - add_gl_trans_std_cost(13, $delivery_no, + add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $stock_gl_code["cogs_account"], $dim, $dim2, "", $delivery_line->standard_cost * $delivery_line->qty_dispatched, PT_CUSTOMER, $delivery->customer_id, @@ -107,7 +107,7 @@ function write_sales_delivery(&$delivery,$bo_policy) /*now the stock entry*/ //$stock_gl_code = get_stock_gl_code($order_line->stock_id); - add_gl_trans_std_cost(13, $delivery_no, $delivery->document_date, + add_gl_trans_std_cost(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $stock_gl_code["inventory_account"], 0, 0, "", (-$delivery_line->standard_cost * $delivery_line->qty_dispatched), PT_CUSTOMER, $delivery->customer_id, @@ -127,16 +127,16 @@ function write_sales_delivery(&$delivery,$bo_policy) foreach ($taxes as $taxitem) { if ($taxitem['Net'] != 0) { $ex_rate = get_exchange_rate_from_home_currency(get_customer_currency($delivery->customer_id), $delivery->document_date); - add_trans_tax_details(13, $delivery_no, $taxitem['tax_type_id'], + add_trans_tax_details(ST_CUSTDELIVERY, $delivery_no, $taxitem['tax_type_id'], $taxitem['rate'], $delivery->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $delivery->document_date, $delivery->reference ); } } - add_comments(13, $delivery_no, $delivery->document_date, $delivery->Comments); + add_comments(ST_CUSTDELIVERY, $delivery_no, $delivery->document_date, $delivery->Comments); if ($trans_no == 0) { - $Refs->save(13, $delivery_no, $delivery->reference); + $Refs->save(ST_CUSTDELIVERY, $delivery_no, $delivery->reference); } commit_transaction(); @@ -158,10 +158,10 @@ function void_sales_delivery($type, $type_no) $order = get_customer_trans_order($type, $type_no); if ($order) { - $order_items = get_sales_order_details($order, 30); + $order_items = get_sales_order_details($order, ST_SALESORDER); while ($row = db_fetch($items_result)) { $order_line = db_fetch($order_items); - update_parent_line(13, $order_line['id'], -$row['quantity']); + update_parent_line(ST_CUSTDELIVERY, $order_line['id'], -$row['quantity']); } } diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index d5e129bb..c4e97e4c 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -39,7 +39,7 @@ function write_sales_invoice(&$invoice) if (is_array($delivery_no)) $delivery_no = 0; - update_customer_trans_version(get_parent_type(10), $invoice->src_docs); + update_customer_trans_version(get_parent_type(ST_SALESINVOICE), $invoice->src_docs); $ov_gst = 0; $taxes = $invoice->get_taxes(); // all taxes with freight_tax @@ -68,7 +68,7 @@ function write_sales_invoice(&$invoice) if (is_array($sales_order)) $sales_order = $sales_order[0]; // assume all crucial SO data are same for every delivery - $invoice_no = write_customer_trans(10, $trans_no, $invoice->customer_id, + $invoice_no = write_customer_trans(ST_SALESINVOICE, $trans_no, $invoice->customer_id, $invoice->Branch, $date_, $invoice->reference, $items_total, 0, $items_added_tax, $invoice->freight_cost, $freight_added_tax, $invoice->sales_type, $sales_order, $delivery_no, @@ -79,10 +79,10 @@ function write_sales_invoice(&$invoice) $invoice->trans_no = array($invoice_no=>0); set_document_parent($invoice); } else { - delete_comments(10, $invoice_no); - void_gl_trans(10, $invoice_no, true); - void_cust_allocations(10, $invoice_no); // ? - void_trans_tax_details(10, $invoice_no); + delete_comments(ST_SALESINVOICE, $invoice_no); + void_gl_trans(ST_SALESINVOICE, $invoice_no, true); + void_cust_allocations(ST_SALESINVOICE, $invoice_no); // ? + void_trans_tax_details(ST_SALESINVOICE, $invoice_no); } $total = 0; foreach ($invoice->line_items as $invoice_line) { @@ -95,7 +95,7 @@ function write_sales_invoice(&$invoice) $invoice_line->price, 0, $invoice->tax_included, $invoice->tax_group_array) - $line_taxfree_price; - write_customer_trans_detail_item(10, $invoice_no, $invoice_line->stock_id, + write_customer_trans_detail_item(ST_SALESINVOICE, $invoice_no, $invoice_line->stock_id, $invoice_line->item_description, $invoice_line->qty_dispatched, $invoice_line->line_price(), $line_tax, $invoice_line->discount_percent, $invoice_line->standard_cost, @@ -103,7 +103,7 @@ function write_sales_invoice(&$invoice) // Update delivery items for the quantity invoiced if ($invoice_line->qty_old != $invoice_line->qty_dispatched) - update_parent_line(10, $invoice_line->src_id, ($invoice_line->qty_dispatched-$invoice_line->qty_old)); + update_parent_line(ST_SALESINVOICE, $invoice_line->src_id, ($invoice_line->qty_dispatched-$invoice_line->qty_old)); if ($invoice_line->qty_dispatched != 0) { $stock_gl_code = get_stock_gl_code($invoice_line->stock_id); @@ -120,13 +120,13 @@ function write_sales_invoice(&$invoice) ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); $dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); - $total += add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2, + $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $sales_account, $dim, $dim2, (-$line_taxfree_price * $invoice_line->qty_dispatched), $invoice->customer_id, "The sales price GL posting could not be inserted"); if ($invoice_line->discount_percent != 0) { - $total += add_gl_trans_customer(10, $invoice_no, $date_, + $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $branch_data["sales_discount_account"], $dim, $dim2, ($line_taxfree_price * $invoice_line->qty_dispatched * $invoice_line->discount_percent), $invoice->customer_id, "The sales discount GL posting could not be inserted"); @@ -136,13 +136,13 @@ function write_sales_invoice(&$invoice) } /*end of delivery_line loop */ if (($items_total + $charge_shipping) != 0) { - $total += add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, + $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax), $invoice->customer_id, "The total debtor GL posting could not be inserted"); } if ($charge_shipping != 0) { - $total += add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0, + $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $company_data["freight_act"], 0, 0, -$invoice->get_tax_free_shipping(), $invoice->customer_id, "The freight GL posting could not be inserted"); } @@ -151,23 +151,23 @@ function write_sales_invoice(&$invoice) if ($taxitem['Net'] != 0) { $ex_rate = get_exchange_rate_from_home_currency(get_customer_currency($invoice->customer_id), $date_); - add_trans_tax_details(10, $invoice_no, $taxitem['tax_type_id'], + add_trans_tax_details(ST_SALESINVOICE, $invoice_no, $taxitem['tax_type_id'], $taxitem['rate'], $invoice->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $date_, $invoice->reference); - $total += add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, + $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, (-$taxitem['Value']), $invoice->customer_id, "A tax GL posting could not be inserted"); } } /*Post a balance post if $total != 0 */ - add_gl_balance(10, $invoice_no, $date_, -$total, PT_CUSTOMER, $invoice->customer_id); + add_gl_balance(ST_SALESINVOICE, $invoice_no, $date_, -$total, PT_CUSTOMER, $invoice->customer_id); add_comments(10, $invoice_no, $date_, $invoice->Comments); if ($trans_no == 0) { - $Refs->save(10, $invoice_no, $invoice->reference); + $Refs->save(ST_SALESINVOICE, $invoice_no, $invoice->reference); if ($invoice->cash) { $amount = $items_total + $items_added_tax + $invoice->freight_cost + $freight_added_tax; @@ -178,12 +178,12 @@ function write_sales_invoice(&$invoice) $discount = 0; // $invoice->cash_discount*$amount; $pmtno = write_customer_payment(0, $invoice->customer_id, $invoice->Branch, $invoice->cash_account, $date_, - $Refs->get_next(12), $amount-$discount, $discount, + $Refs->get_next(ST_CUSTPAYMENT), $amount-$discount, $discount, _('Cash invoice').' '.$invoice_no); - add_cust_allocation($amount, 12, $pmtno, 10, $invoice_no); + add_cust_allocation($amount, ST_CUSTPAYMENT, $pmtno, ST_SALESINVOICE, $invoice_no); - update_debtor_trans_allocation(10, $invoice_no, $amount); - update_debtor_trans_allocation(12, $pmtno, $amount); + update_debtor_trans_allocation(ST_SALESINVOICE, $invoice_no, $amount); + update_debtor_trans_allocation(ST_CUSTPAYMENT, $pmtno, $amount); } } commit_transaction(); diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index 952587c5..39c67bed 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -375,7 +375,7 @@ function read_sales_order($order_no, &$order, $trans_type) function sales_order_has_deliveries($order_no) { $sql = "SELECT SUM(qty_sent) FROM ".TB_PREF. - "sales_order_details WHERE order_no=$order_no AND trans_type=30"; + "sales_order_details WHERE order_no=$order_no AND trans_type=".ST_SALESORDER.""; $result = db_query($sql, "could not query for sales order usage"); @@ -392,7 +392,7 @@ function close_sales_order($order_no) $sql = "UPDATE ".TB_PREF."sales_order_details SET quantity = qty_sent, type = 0, - WHERE order_no = $order_no AND trans_type=30"; + WHERE order_no = $order_no AND trans_type=".ST_SALESORDER.""; db_query($sql, "The sales order detail record could not be updated"); } diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index 7f8b5e21..fc6f2904 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -192,7 +192,7 @@ function set_document_parent($cart) db_query($sql, 'Child document link cannot be updated'); } - if ($cart->trans_type != 10) + if ($cart->trans_type != ST_SALESINVOICE) return 0; // the rest is batch invoice specific @@ -220,7 +220,7 @@ function set_document_parent($cart) //-------------------------------------------------------------------------------------------------- function get_parent_type($type) { - $parent_types = array( 11=>10, 10=>13, 13=>30 ); + $parent_types = array( ST_CUSTCREDIT => ST_SALESINVOICE, ST_SALESINVOICE => ST_CUSTDELIVERY, ST_CUSTDELIVERY => ST_SALESORDER ); return isset($parent_types[$type]) ? $parent_types[$type] : 0; } @@ -233,7 +233,7 @@ function update_parent_line($doc_type, $line_id, $qty_dispatched) if ($doc_type==0) return false; else { - if ($doc_type==30) + if ($doc_type==ST_SALESORDER) $sql = "UPDATE ".TB_PREF."sales_order_details SET qty_sent = qty_sent + $qty_dispatched WHERE id=$line_id"; diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 0731752d..96c24ef7 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -89,7 +89,7 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $order->set_sales_type($myrow['salestype'], $myrow['sales_type'], $myrow['tax_included'], $myrow['factor']); - if ($order->trans_type != 30) + if ($order->trans_type != ST_SALESORDER && $order->trans_type != ST_SALESQUOTE) { $order->dimension_id = $myrow['dimension_id']; $order->dimension2_id = $myrow['dimension2_id']; @@ -111,7 +111,7 @@ function get_customer_details_to_order(&$order, $customer_id, $branch_id) $order->set_delivery($myrow["default_ship_via"], $myrow["br_name"], $address); - if ($order->trans_type == 10) { + if ($order->trans_type == ST_SALESINVOICE) { $order->due_date = get_invoice_duedate($customer_id, $order->document_date); if ($order->pos != -1) $order->cash = date_diff2($order->due_date, Today(), 'd')<2; @@ -251,7 +251,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group hidden('customer_id', $order->customer_id); hidden('branch_id', $order->Branch); hidden('sales_type', $order->sales_type); - if ($order->trans_type != 30) { + if ($order->trans_type != ST_SALESORDER && $order->trans_type != ST_SALESQUOTE) { hidden('dimension_id', $order->dimension_id); // 2008-11-12 Joe Hunt hidden('dimension2_id', $order->dimension2_id); } @@ -298,7 +298,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group $Ajax->activate('delivery'); $Ajax->activate('cash'); } else { - if ($order->trans_type == 10) + if ($order->trans_type == ST_SALESINVOICE) { $_POST['delivery_date'] = $order->due_date; $Ajax->activate('delivery_date'); @@ -352,7 +352,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group } table_section(3); - if ($order->trans_type == 10 && $order->pos != -1) { + if ($order->trans_type == ST_SALESINVOICE && $order->pos != -1) { sale_payment_list_cells(_('Payment:'), 'cash', null, true); $cash_payment = get_post('cash', 0); // current user can issue both credit and cash invoices @@ -402,14 +402,14 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group $change_prices = 1; } $Ajax->activate('_ex_rate'); - if ($order->trans_type == 10) { + if ($order->trans_type == ST_SALESINVOICE) { $_POST['delivery_date'] = get_invoice_duedate(get_post('customer_id'), get_post('OrderDate')); } else $_POST['delivery_date'] = add_days(get_post('OrderDate'), $SysPrefs->default_delivery_required_by()); $Ajax->activate('items_table'); $Ajax->activate('delivery_date'); } - if ($order->trans_type != 30 && $order->trans_type != 32) + if ($order->trans_type != ST_SALESORDER && $order->trans_type != ST_SALESQUOTE) { // 2008-11-12 Joe Hunt added dimensions $dim = get_company_pref('use_dimension'); if ($dim > 0) @@ -551,17 +551,17 @@ function display_delivery_details(&$order) end_table(); } else { - if ($order->trans_type==10) + if ($order->trans_type==ST_SALESINVOICE) { $title = _("Delivery Details"); $delname = _("Due Date").':'; } - elseif ($order->trans_type==13) + elseif ($order->trans_type==ST_CUSTDELIVERY) { $title = _("Invoice Delivery Details"); $delname = _("Invoice before").':'; } - elseif ($order->trans_type==32) + elseif ($order->trans_type==ST_SALESQUOTE) { $title = _("Quotation Delivery Details"); $delname = _("Valid until").':'; @@ -582,7 +582,7 @@ function display_delivery_details(&$order) date_row($delname, 'delivery_date', - $order->trans_type==30 ? _('Enter requested day of delivery') : $order->trans_type==32 ? _('Enter Valid until Date') : ''); + $order->trans_type==ST_SALESORDER ? _('Enter requested day of delivery') : $order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : ''); text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40, _('Additional identifier for delivery e.g. name of receiving person')); diff --git a/sales/inquiry/customer_allocation_inquiry.php b/sales/inquiry/customer_allocation_inquiry.php index 51749f2c..5fb9ad81 100644 --- a/sales/inquiry/customer_allocation_inquiry.php +++ b/sales/inquiry/customer_allocation_inquiry.php @@ -98,7 +98,7 @@ function alloc_link($row) "/sales/allocations/customer_allocate.php?trans_no=" . $row["trans_no"] ."&trans_type=" . $row["type"], ICON_MONEY); - if ($row["type"] == 11 && $row['TotalAmount'] > 0) + if ($row["type"] == ST_CUSTCREDIT && $row['TotalAmount'] > 0) { /*its a credit note which could have an allocation */ return $link; @@ -119,7 +119,7 @@ function alloc_link($row) function fmt_debit($row) { $value = - $row['type']==11 || $row['type']==12 || $row['type']==2 ? + $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT ? -$row["TotalAmount"] : $row["TotalAmount"]; return $value>=0 ? price_format($value) : ''; @@ -128,7 +128,7 @@ function fmt_debit($row) function fmt_credit($row) { $value = - !($row['type']==11 || $row['type']==12 || $row['type']==2) ? + !($row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT) ? -$row["TotalAmount"] : $row["TotalAmount"]; return $value>0 ? price_format($value) : ''; } @@ -149,7 +149,7 @@ function fmt_credit($row) (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) AS TotalAmount, trans.alloc AS Allocated, - ((trans.type = 10) + ((trans.type = ".ST_SALESINVOICE.") AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue FROM " .TB_PREF."debtor_trans as trans, " @@ -167,7 +167,7 @@ function fmt_credit($row) { if ($_POST['filterType'] == '1' || $_POST['filterType'] == '2') { - $sql .= " AND trans.type = 10 "; + $sql .= " AND trans.type = ".ST_SALESINVOICE." "; } elseif ($_POST['filterType'] == '3') { @@ -175,7 +175,7 @@ function fmt_credit($row) } elseif ($_POST['filterType'] == '4') { - $sql .= " AND trans.type = 11 "; + $sql .= " AND trans.type = ".ST_CUSTCREDIT." "; } if ($_POST['filterType'] == '2') @@ -188,7 +188,7 @@ function fmt_credit($row) } }else { - $sql .= " AND trans.type != 13 "; + $sql .= " AND trans.type <> ".ST_CUSTDELIVERY." "; } diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index 5602fed5..abfb73da 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -129,7 +129,7 @@ function trans_view($trans) function due_date($row) { - return $row["type"] == 10 ? $row["due_date"] : ''; + return $row["type"] == ST_SALESINVOICE ? $row["due_date"] : ''; } function gl_view($row) @@ -140,7 +140,7 @@ function gl_view($row) function fmt_debit($row) { $value = - $row['type']==11 || $row['type']==12 || $row['type']==2 ? + $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT ? -$row["TotalAmount"] : $row["TotalAmount"]; return $value>=0 ? price_format($value) : ''; @@ -149,14 +149,14 @@ function fmt_debit($row) function fmt_credit($row) { $value = - !($row['type']==11 || $row['type']==12 || $row['type']==2) ? + !($row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT) ? -$row["TotalAmount"] : $row["TotalAmount"]; return $value>0 ? price_format($value) : ''; } function credit_link($row) { - return $row['type'] == 10 && $row["TotalAmount"] - $row["Allocated"] > 0 ? + return $row['type'] == ST_SALESINVOICE && $row["TotalAmount"] - $row["Allocated"] > 0 ? pager_link(_("Credit This"), "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT) @@ -168,12 +168,12 @@ function edit_link($row) $str = ''; switch($row['type']) { - case 10: - if (get_voided_entry(10, $row["trans_no"]) === false && $row['Allocated'] == 0) + case ST_SALESINVOICE: + if (get_voided_entry(ST_SALESINVOICE, $row["trans_no"]) === false && $row['Allocated'] == 0) $str = "/sales/customer_invoice.php?ModifyInvoice=".$row['trans_no']; break; - case 11: - if (get_voided_entry(11, $row["trans_no"]) === false && $row['Allocated'] == 0) // 2008-11-19 Joe Hunt + case ST_CUSTCREDIT: + if (get_voided_entry(ST_CUSTCREDIT, $row["trans_no"]) === false && $row['Allocated'] == 0) // 2008-11-19 Joe Hunt { if ($row['order_']==0) // free-hand credit note $str = "/sales/credit_note_entry.php?ModifyCredit=".$row['trans_no']; @@ -181,8 +181,8 @@ function edit_link($row) $str = "/sales/customer_credit_invoice.php?ModifyCredit=".$row['trans_no']; } break; - case 13: - if (get_voided_entry(13, $row["trans_no"]) === false) + case ST_CUSTDELIVERY: + if (get_voided_entry(ST_CUSTDELIVERY, $row["trans_no"]) === false) $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no']; break; } @@ -193,7 +193,7 @@ function edit_link($row) function prt_link($row) { - if ($row['type'] != 12 && $row['type'] != 2) // customer payment or bank deposit printout not defined yet. + if ($row['type'] != ST_CUSTPAYMENT && $row['type'] != ST_BANKDEPOSIT) // customer payment or bank deposit printout not defined yet. return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT); } @@ -219,7 +219,7 @@ function check_overdue($row) (trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) AS TotalAmount, trans.alloc AS Allocated, - ((trans.type = 10) + ((trans.type = ".ST_SALESINVOICE.") AND trans.due_date < '" . date2sql(Today()) . "') AS OverDue FROM " .TB_PREF."debtor_trans as trans, " @@ -237,24 +237,24 @@ function check_overdue($row) { if ($_POST['filterType'] == '1') { - $sql .= " AND (trans.type = 10 OR trans.type = 1) "; + $sql .= " AND (trans.type = ".ST_SALESINVOICE." OR trans.type = ST_BANKPAYMENT) "; } elseif ($_POST['filterType'] == '2') { - $sql .= " AND (trans.type = 10) "; + $sql .= " AND (trans.type = ".ST_SALESINVOICE.") "; } elseif ($_POST['filterType'] == '3') { $sql .= " AND (trans.type = " . ST_CUSTPAYMENT - ." OR trans.type = 2) "; + ." OR trans.type = ".ST_BANKDEPOSIT.") "; } elseif ($_POST['filterType'] == '4') { - $sql .= " AND trans.type = 11 "; + $sql .= " AND trans.type = ".ST_CUSTCREDIT." "; } elseif ($_POST['filterType'] == '5') { - $sql .= " AND trans.type = 13 "; + $sql .= " AND trans.type = ".ST_CUSTDELIVERY." "; } if ($_POST['filterType'] == '2') diff --git a/sales/inquiry/sales_deliveries_view.php b/sales/inquiry/sales_deliveries_view.php index d9a7af5a..4f601014 100644 --- a/sales/inquiry/sales_deliveries_view.php +++ b/sales/inquiry/sales_deliveries_view.php @@ -131,7 +131,7 @@ else //--------------------------------------------------------------------------------------------- function trans_view($trans, $trans_no) { - return get_customer_trans_view_str(13, $trans['trans_no']); + return get_customer_trans_view_str(ST_CUSTDELIVERY, $trans['trans_no']); } function batch_checkbox($row) @@ -153,7 +153,7 @@ function edit_link($row) function prt_link($row) { - return print_document_link($row['trans_no'], _("Print"), true, 13, ICON_PRINT); + return print_document_link($row['trans_no'], _("Print"), true, ST_CUSTDELIVERY, ICON_PRINT); } function invoice_link($row) @@ -191,7 +191,7 @@ $sql = "SELECT trans.trans_no, WHERE sorder.order_no = trans.order_ AND trans.debtor_no = debtor.debtor_no - AND trans.type = 13 + AND trans.type = ".ST_CUSTDELIVERY." AND line.debtor_trans_no = trans.trans_no AND line.debtor_trans_type = trans.type AND trans.branch_code = branch.branch_code diff --git a/sales/inquiry/sales_orders_view.php b/sales/inquiry/sales_orders_view.php index 7ebcb822..e0d2f957 100644 --- a/sales/inquiry/sales_orders_view.php +++ b/sales/inquiry/sales_orders_view.php @@ -25,11 +25,11 @@ if ($use_date_picker) if (get_post('type')) $trans_type = $_POST['type']; -elseif (isset($_GET['type']) && $_GET['type'] == 32) - $trans_type = 32; +elseif (isset($_GET['type']) && $_GET['type'] == ST_SALESQUOTE) + $trans_type = ST_SALESQUOTE; else - $trans_type = 30; -if ($trans_type == 30) + $trans_type = ST_SALESORDER; +if ($trans_type == ST_SALESORDER) { if (isset($_GET['OutstandingOnly']) && ($_GET['OutstandingOnly'] == true)) { @@ -87,7 +87,7 @@ else function check_overdue($row) { global $trans_type; - if ($trans_type == 32) + if ($trans_type == ST_SALESQUOTE) return (date1_greater_date2(Today(), sql2date($row['delivery_date']))); else return ($row['type'] == 0 @@ -110,7 +110,7 @@ function prt_link($row) function edit_link($row) { global $trans_type; - $modify = ($trans_type == 30 ? "ModifyOrderNumber" : "ModifyQuotationNumber"); + $modify = ($trans_type == ST_SALESORDER ? "ModifyOrderNumber" : "ModifyQuotationNumber"); return pager_link( _("Edit"), "/sales/sales_order_entry.php?$modify=" . $row['order_no'], ICON_EDIT); } @@ -118,7 +118,7 @@ function edit_link($row) function dispatch_link($row) { global $trans_type; - if ($trans_type == 30) + if ($trans_type == ST_SALESORDER) return pager_link( _("Dispatch"), "/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC); else @@ -129,7 +129,7 @@ function dispatch_link($row) function invoice_link($row) { global $trans_type; - if ($trans_type == 30) + if ($trans_type == ST_SALESORDER) return pager_link( _("Invoice"), "/sales/sales_order_entry.php?NewInvoice=" .$row["order_no"], ICON_DOC); else @@ -151,7 +151,7 @@ function order_link($row) function tmpl_checkbox($row) { global $trans_type; - if ($trans_type == 32) + if ($trans_type == ST_SALESQUOTE) return ''; $name = "chgtpl" .$row['order_no']; $value = $row['type'] ? 1:0; @@ -223,7 +223,7 @@ locations_list_cells(_("Location:"), 'StockLocation', null, true); stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true); -if ($trans_type == 32) +if ($trans_type == ST_SALESQUOTE) check_cells(_("Show All:"), 'show_all'); submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default'); @@ -304,7 +304,7 @@ else // ... or select inquiry constraints sorder.deliver_to"; } -if ($trans_type == 30) +if ($trans_type == ST_SALESORDER) $cols = array( _("Order #") => array('fun'=>'view_link'), _("Ref"), @@ -346,12 +346,12 @@ if ($_POST['order_view_mode'] == 'OutstandingOnly') { array('insert'=>true, 'fun'=>'delivery_link')) ); -} elseif ($trans_type == 32) { +} elseif ($trans_type == ST_SALESQUOTE) { array_append($cols,array( array('insert'=>true, 'fun'=>'edit_link'), array('insert'=>true, 'fun'=>'order_link'), array('insert'=>true, 'fun'=>'prt_link'))); -} elseif ($trans_type == 30) { +} elseif ($trans_type == ST_SALESORDER) { array_append($cols,array( _("Tmpl") => array('insert'=>true, 'fun'=>'tmpl_checkbox'), array('insert'=>true, 'fun'=>'edit_link'), diff --git a/sales/manage/recurrent_invoices.php b/sales/manage/recurrent_invoices.php index ad2e4b4e..cdbc3bfa 100644 --- a/sales/manage/recurrent_invoices.php +++ b/sales/manage/recurrent_invoices.php @@ -114,7 +114,7 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["description"]); - label_cell(get_customer_trans_view_str(30, $myrow["order_no"])); + label_cell(get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"])); if ($myrow["debtor_no"] == 0) { label_cell(""); diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index e15543e5..ff794578 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -40,36 +40,36 @@ if ($use_date_picker) { if (isset($_GET['NewDelivery']) && is_numeric($_GET['NewDelivery'])) { $_SESSION['page_title'] = _("Direct Sales Delivery"); - create_cart(13, $_GET['NewDelivery']); + create_cart(ST_CUSTDELIVERY, $_GET['NewDelivery']); } elseif (isset($_GET['NewInvoice']) && is_numeric($_GET['NewInvoice'])) { $_SESSION['page_title'] = _("Direct Sales Invoice"); - create_cart(10, $_GET['NewInvoice']); + create_cart(ST_SALESINVOICE, $_GET['NewInvoice']); } elseif (isset($_GET['ModifyOrderNumber']) && is_numeric($_GET['ModifyOrderNumber'])) { $help_page_title = _('Modifying Sales Order'); $_SESSION['page_title'] = sprintf( _("Modifying Sales Order # %d"), $_GET['ModifyOrderNumber']); - create_cart(30, $_GET['ModifyOrderNumber']); + create_cart(ST_SALESORDER, $_GET['ModifyOrderNumber']); } elseif (isset($_GET['ModifyQuotationNumber']) && is_numeric($_GET['ModifyQuotationNumber'])) { $help_page_title = _('Modifying Sales Quotation'); $_SESSION['page_title'] = sprintf( _("Modifying Sales Quotation # %d"), $_GET['ModifyQuotationNumber']); - create_cart(32, $_GET['ModifyQuotationNumber']); + create_cart(ST_SALESQUOTE, $_GET['ModifyQuotationNumber']); } elseif (isset($_GET['NewOrder'])) { $_SESSION['page_title'] = _("New Sales Order Entry"); - create_cart(30, 0); + create_cart(ST_SALESORDER, 0); } elseif (isset($_GET['NewQuotation'])) { $_SESSION['page_title'] = _("New Sales Quotation Entry"); - create_cart(32, 0); + create_cart(ST_SALESQUOTE, 0); } elseif (isset($_GET['NewQuoteToSalesOrder'])) { $_SESSION['page_title'] = _("Sales Order Entry"); - create_cart(32, $_GET['NewQuoteToSalesOrder']); + create_cart(ST_SALESQUOTE, $_GET['NewQuoteToSalesOrder']); } page($_SESSION['page_title'], false, false, "", $js); @@ -86,10 +86,10 @@ if (isset($_GET['AddedID'])) { $order_no = $_GET['AddedID']; display_notification_centered(sprintf( _("Order # %d has been entered."),$order_no)); - submenu_view(_("&View This Order"), 30, $order_no); + submenu_view(_("&View This Order"), ST_SALESORDER, $order_no); - submenu_print(_("&Print This Order"), 30, $order_no, 'prtopt'); - submenu_print(_("&Email This Order"), 30, $order_no, null, 1); + submenu_print(_("&Print This Order"), ST_SALESORDER, $order_no, 'prtopt'); + submenu_print(_("&Email This Order"), ST_SALESORDER, $order_no, null, 1); set_focus('prtopt'); submenu_option(_("Make &Delivery Against This Order"), @@ -104,10 +104,10 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf( _("Order # %d has been updated."),$order_no)); - submenu_view(_("&View This Order"), 30, $order_no); + submenu_view(_("&View This Order"), ST_SALESORDER, $order_no); - submenu_print(_("&Print This Order"), 30, $order_no, 'prtopt'); - submenu_print(_("&Email This Order"), 30, $order_no, null, 1); + submenu_print(_("&Print This Order"), ST_SALESORDER, $order_no, 'prtopt'); + submenu_print(_("&Email This Order"), ST_SALESORDER, $order_no, null, 1); set_focus('prtopt'); submenu_option(_("Confirm Order Quantities and Make &Delivery"), @@ -122,10 +122,10 @@ if (isset($_GET['AddedID'])) { $order_no = $_GET['AddedQU']; display_notification_centered(sprintf( _("Quotation # %d has been entered."),$order_no)); - submenu_view(_("&View This Quotation"), 32, $order_no); + submenu_view(_("&View This Quotation"), ST_SALESQUOTE, $order_no); - submenu_print(_("&Print This Quotation"), 32, $order_no, 'prtopt'); - submenu_print(_("&Email This Quotation"), 32, $order_no, null, 1); + submenu_print(_("&Print This Quotation"), ST_SALESQUOTE, $order_no, 'prtopt'); + submenu_print(_("&Email This Quotation"), ST_SALESQUOTE, $order_no, null, 1); set_focus('prtopt'); submenu_option(_("Make &Sales Order Against This Quotation"), @@ -140,17 +140,17 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf( _("Quotation # %d has been updated."),$order_no)); - submenu_view(_("&View This Quotation"), 32, $order_no); + submenu_view(_("&View This Quotation"), ST_SALESQUOTE, $order_no); - submenu_print(_("&Print This Quotation"), 32, $order_no, 'prtopt'); - submenu_print(_("&Email This Quotation"), 32, $order_no, null, 1); + submenu_print(_("&Print This Quotation"), ST_SALESQUOTE, $order_no, 'prtopt'); + submenu_print(_("&Email This Quotation"), ST_SALESQUOTE, $order_no, null, 1); set_focus('prtopt'); submenu_option(_("Make &Sales Order Against This Quotation"), "/sales/sales_order_entry.php?NewQuoteToSalesOrder=$order_no"); submenu_option(_("Select A Different &Quotation"), - "/sales/inquiry/sales_orders_view.php?type=32"); + "/sales/inquiry/sales_orders_view.php?type=".ST_SALESQUOTE); display_footer_exit(); } elseif (isset($_GET['AddedDN'])) { @@ -158,13 +158,13 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf(_("Delivery # %d has been entered."),$delivery)); - submenu_view(_("&View This Delivery"), 13, $delivery); + submenu_view(_("&View This Delivery"), ST_CUSTDELIVERY, $delivery); - submenu_print(_("&Print Delivery Note"), 13, $delivery, 'prtopt'); - submenu_print(_("&Email Delivery Note"), 13, $delivery, null, 1); + submenu_print(_("&Print Delivery Note"), ST_CUSTDELIVERY, $delivery, 'prtopt'); + submenu_print(_("&Email Delivery Note"), ST_CUSTDELIVERY, $delivery, null, 1); set_focus('prtopt'); - display_note(get_gl_view_str(13, $delivery, _("View the GL Journal Entries for this Dispatch")),0, 1); + display_note(get_gl_view_str(ST_CUSTDELIVERY, $delivery, _("View the GL Journal Entries for this Dispatch")),0, 1); submenu_option(_("Make &Invoice Against This Delivery"), "/sales/customer_invoice.php?DeliveryNumber=$delivery"); @@ -183,13 +183,13 @@ if (isset($_GET['AddedID'])) { display_notification_centered(sprintf(_("Invoice # %d has been entered."), $invoice)); - submenu_view(_("&View This Invoice"), 10, $invoice); + submenu_view(_("&View This Invoice"), ST_SALESINVOICE, $invoice); - submenu_print(_("&Print Sales Invoice"), 10, $invoice, 'prtopt'); - submenu_print(_("&Email Sales Invoice"), 10, $invoice, null, 1); + submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice, 'prtopt'); + submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice, null, 1); set_focus('prtopt'); - display_note(get_gl_view_str(10, $invoice, _("View the GL &Journal Entries for this Invoice")),0, 1); + display_note(get_gl_view_str(ST_SALESINVOICE, $invoice, _("View the GL &Journal Entries for this Invoice")),0, 1); if ((isset($_GET['Type']) && $_GET['Type'] == 1)) submenu_option(_("Enter a &New Template Invoice"), @@ -212,7 +212,7 @@ function copy_to_cart() $cart->Comments = $_POST['Comments']; $cart->document_date = $_POST['OrderDate']; - if ($cart->trans_type == 10) + if ($cart->trans_type == ST_SALESINVOICE) $cart->cash = $_POST['cash']; if ($cart->cash) { $cart->due_date = $cart->document_date; @@ -238,7 +238,7 @@ function copy_to_cart() $cart->Branch = $_POST['branch_id']; $cart->sales_type = $_POST['sales_type']; // POS - if ($cart->trans_type!=30 && $cart->trans_type!=32) { // 2008-11-12 Joe Hunt + if ($cart->trans_type!=ST_SALESORDER && $cart->trans_type!=ST_SALESQUOTE) { // 2008-11-12 Joe Hunt $cart->dimension_id = $_POST['dimension_id']; $cart->dimension2_id = $_POST['dimension2_id']; } @@ -268,9 +268,9 @@ function copy_from_cart() $_POST['branch_id'] = $cart->Branch; $_POST['sales_type'] = $cart->sales_type; // POS - if ($cart->trans_type == 10) + if ($cart->trans_type == ST_SALESINVOICE) $_POST['cash'] = $cart->cash; - if ($cart->trans_type!=30 && $cart->trans_type!=32) { // 2008-11-12 Joe Hunt + if ($cart->trans_type!=ST_SALESORDER && $cart->trans_type!=ST_SALESQUOTE) { // 2008-11-12 Joe Hunt $_POST['dimension_id'] = $cart->dimension_id; $_POST['dimension2_id'] = $cart->dimension2_id; } @@ -295,7 +295,7 @@ function can_process() { set_focus('OrderDate'); return false; } - if ($_SESSION['Items']->trans_type!=30 && $_SESSION['Items']->trans_type!=32 && !is_date_in_fiscalyear($_POST['OrderDate'])) { + if ($_SESSION['Items']->trans_type!=ST_SALESORDER && $_SESSION['Items']->trans_type!=ST_SALESQUOTE && !is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(_("The entered date is not in fiscal year")); set_focus('OrderDate'); return false; @@ -327,7 +327,7 @@ function can_process() { return false; } if (!is_date($_POST['delivery_date'])) { - if ($_SESSION['Items']->trans_type==32) + if ($_SESSION['Items']->trans_type==ST_SALESQUOTE) display_error(_("The Valid date is invalid.")); else display_error(_("The delivery date is invalid.")); @@ -336,7 +336,7 @@ function can_process() { } //if (date1_greater_date2($_SESSION['Items']->document_date, $_POST['delivery_date'])) { if (date1_greater_date2($_POST['OrderDate'], $_POST['delivery_date'])) { - if ($_SESSION['Items']->trans_type==32) + if ($_SESSION['Items']->trans_type==ST_SALESQUOTE) display_error(_("The requested valid date is before the date of the quotation.")); else display_error(_("The requested delivery date is before the date of the order.")); @@ -369,15 +369,15 @@ if (isset($_POST['ProcessOrder']) && can_process()) { new_doc_date($_SESSION['Items']->document_date); processing_end(); if ($modified) { - if ($trans_type == 32) + if ($trans_type == ST_SALESQUOTE) meta_forward($_SERVER['PHP_SELF'], "UpdatedQU=$trans_no"); else meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$trans_no"); - } elseif ($trans_type == 30) { + } elseif ($trans_type == ST_SALESORDER) { meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); - } elseif ($trans_type == 32) { + } elseif ($trans_type == ST_SALESQUOTE) { meta_forward($_SERVER['PHP_SELF'], "AddedQU=$trans_no"); - } elseif ($trans_type == 10) { + } elseif ($trans_type == ST_SALESINVOICE) { meta_forward($_SERVER['PHP_SELF'], "AddedDI=$trans_no&Type=$so_type"); } else { meta_forward($_SERVER['PHP_SELF'], "AddedDN=$trans_no&Type=$so_type"); @@ -405,7 +405,7 @@ function check_item_data() display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; } // Joe Hunt added 2008-09-22 ------------------------- - elseif ($_SESSION['Items']->trans_type!=30 && $_SESSION['Items']->trans_type!=32 && !$SysPrefs->allow_negative_stock() && + elseif ($_SESSION['Items']->trans_type!=ST_SALESORDER && $_SESSION['Items']->trans_type!=ST_SALESQUOTE && !$SysPrefs->allow_negative_stock() && is_inventory_item($_POST['stock_id'])) { $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']); @@ -467,11 +467,11 @@ function handle_cancel_order() global $path_to_root, $Ajax; - if ($_SESSION['Items']->trans_type == 13) { + if ($_SESSION['Items']->trans_type == ST_CUSTDELIVERY) { display_note(_("Direct delivery entry has been cancelled as requested."), 1); submenu_option(_("Enter a New Sales Delivery"), $_SERVER['PHP_SELF']."?NewDelivery=0"); - } elseif ($_SESSION['Items']->trans_type == 10) { + } elseif ($_SESSION['Items']->trans_type == ST_SALESINVOICE) { display_note(_("Direct invoice entry has been cancelled as requested."), 1); submenu_option(_("Enter a New Sales Invoice"), $_SERVER['PHP_SELF']."?NewInvoice=0"); } else { @@ -480,7 +480,7 @@ function handle_cancel_order() display_error(_("This order cannot be cancelled because some of it has already been invoiced or dispatched. However, the line item quantities may be modified.")); else { delete_sales_order(key($_SESSION['Items']->trans_no), $_SESSION['Items']->trans_type); - if ($_SESSION['Items']->trans_type == 32) + if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { display_note(_("This sales quotation has been cancelled as requested."), 1); submenu_option(_("Enter a New Sales Quotation"), $_SERVER['PHP_SELF']."?NewQuotation=Yes"); @@ -515,22 +515,22 @@ function create_cart($type, $trans_no) if (isset($_GET['NewQuoteToSalesOrder'])) { $trans_no = $_GET['NewQuoteToSalesOrder']; - $doc = new Cart(32, $trans_no); + $doc = new Cart(ST_SALESQUOTE, $trans_no); $doc->trans_no = 0; - $doc->trans_type = 30; + $doc->trans_type = ST_SALESORDER; $doc->reference = $Refs->get_next($doc->trans_type); $doc->document_date = $doc->due_date = new_doc_date(); $doc->Comments = _("Sales Quotation") . " # " . $trans_no; $_SESSION['Items'] = $doc; } - elseif($type != 30 && $type != 32 && $trans_no != 0) { // this is template - $doc_type = 30; + elseif($type != ST_SALESORDER && $type != ST_SALESQUOTE && $trans_no != 0) { // this is template + $doc_type = ST_SALESORDER; - $doc = new Cart(30, array($trans_no)); + $doc = new Cart(ST_SALESORDER, array($trans_no)); $doc->trans_type = $type; $doc->trans_no = 0; $doc->document_date = new_doc_date(); - if ($type == 10) { + if ($type == ST_SALESINVOICE) { $doc->due_date = get_invoice_duedate($doc->customer_id, $doc->document_date); $doc->pos = user_pos(); $pos = get_sales_point($doc->pos); @@ -576,19 +576,19 @@ check_db_has_stock_items(_("There are no inventory items defined in the system." check_db_has_customer_branches(_("There are no customers, or there are no customers with branches. Please define customers and customer branches.")); -if ($_SESSION['Items']->trans_type == 10) { +if ($_SESSION['Items']->trans_type == ST_SALESINVOICE) { $idate = _("Invoice Date:"); $orderitems = _("Sales Invoice Items"); $deliverydetails = _("Enter Delivery Details and Confirm Invoice"); $cancelorder = _("Cancel Invoice"); $porder = _("Place Invoice"); -} elseif ($_SESSION['Items']->trans_type == 13) { +} elseif ($_SESSION['Items']->trans_type == ST_CUSTDELIVERY) { $idate = _("Delivery Date:"); $orderitems = _("Delivery Note Items"); $deliverydetails = _("Enter Delivery Details and Confirm Dispatch"); $cancelorder = _("Cancel Delivery"); $porder = _("Place Delivery"); -} elseif ($_SESSION['Items']->trans_type == 32) { +} elseif ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { $idate = _("Quotation Date:"); $orderitems = _("Sales Quotation Items"); $deliverydetails = _("Enter Delivery Details and Confirm Quotation"); diff --git a/sales/view/view_credit.php b/sales/view/view_credit.php index 85cd1de3..e1e51aa2 100644 --- a/sales/view/view_credit.php +++ b/sales/view/view_credit.php @@ -32,7 +32,7 @@ elseif (isset($_POST["trans_no"])) $trans_id = $_POST["trans_no"]; } -$myrow = get_customer_trans($trans_id, 11); +$myrow = get_customer_trans($trans_id, ST_CUSTCREDIT); $branch = get_branch($myrow["branch_code"]); @@ -73,7 +73,7 @@ start_row(); label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'"); label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'"); end_row(); -comments_display_row(11, $trans_id); +comments_display_row(ST_CUSTCREDIT, $trans_id); end_table(); echo ""; @@ -81,7 +81,7 @@ end_table(1); // outer table $sub_total = 0; -$result = get_customer_trans_details(11, $trans_id); +$result = get_customer_trans_details(ST_CUSTCREDIT, $trans_id); start_table("$table_style width=95%"); @@ -137,18 +137,18 @@ if ($sub_total != 0) "nowrap align=right width=15%"); label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right"); -$tax_items = get_trans_tax_details(11, $trans_id); +$tax_items = get_trans_tax_details(ST_CUSTCREDIT, $trans_id); display_customer_trans_tax_details($tax_items, 6); label_row("" . _("TOTAL CREDIT") . "$display_total", "colspan=6 align=right", "nowrap align=right"); end_table(1); -$voided = is_voided_display(11, $trans_id, _("This credit note has been voided.")); +$voided = is_voided_display(ST_CUSTCREDIT, $trans_id, _("This credit note has been voided.")); if (!$voided) display_allocations_from(PT_CUSTOMER, - $myrow['debtor_no'], 11, $trans_id, $credit_total); + $myrow['debtor_no'], ST_CUSTCREDIT, $trans_id, $credit_total); /* end of check to see that there was an invoice record to print */ diff --git a/sales/view/view_dispatch.php b/sales/view/view_dispatch.php index db73299b..dac9f7dd 100644 --- a/sales/view/view_dispatch.php +++ b/sales/view/view_dispatch.php @@ -34,11 +34,11 @@ elseif (isset($_POST["trans_no"])) // 3 different queries to get the information - what a JOKE !!!! -$myrow = get_customer_trans($trans_id, 13); +$myrow = get_customer_trans($trans_id, ST_CUSTDELIVERY); $branch = get_branch($myrow["branch_code"]); -$sales_order = get_sales_order_header($myrow["order_"], 30); +$sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); display_heading(sprintf(_("DISPATCH NOTE #%d"),$trans_id)); @@ -96,14 +96,14 @@ start_row(); label_cells(_("Dispatch Date"), sql2date($myrow["tran_date"]), "class='tableheader2'", "nowrap"); label_cells(_("Due Date"), sql2date($myrow["due_date"]), "class='tableheader2'", "nowrap"); end_row(); -comments_display_row(13, $trans_id); +comments_display_row(ST_CUSTDELIVERY, $trans_id); end_table(); echo ""; end_table(1); // outer table -$result = get_customer_trans_details(13, $trans_id); +$result = get_customer_trans_details(ST_CUSTDELIVERY, $trans_id); start_table("$table_style width=95%"); @@ -155,7 +155,7 @@ label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right", "nowrap align=right width=15%"); label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right"); -$tax_items = get_trans_tax_details(13, $trans_id); +$tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $trans_id); display_customer_trans_tax_details($tax_items, 6); $display_total = price_format($myrow["ov_freight"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]+$myrow["ov_gst"]); @@ -164,7 +164,7 @@ label_row(_("TOTAL VALUE"), $display_total, "colspan=6 align=right", "nowrap align=right"); end_table(1); -is_voided_display(13, $trans_id, _("This dispatch has been voided.")); +is_voided_display(ST_CUSTDELIVERY, $trans_id, _("This dispatch has been voided.")); end_page(true); diff --git a/sales/view/view_invoice.php b/sales/view/view_invoice.php index aa2bbe78..6a13b1ae 100644 --- a/sales/view/view_invoice.php +++ b/sales/view/view_invoice.php @@ -34,11 +34,11 @@ elseif (isset($_POST["trans_no"])) // 3 different queries to get the information - what a JOKE !!!! -$myrow = get_customer_trans($trans_id, 10); +$myrow = get_customer_trans($trans_id, ST_SALESINVOICE); $branch = get_branch($myrow["branch_code"]); -$sales_order = get_sales_order_header($myrow["order_"], 30); +$sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); display_heading(sprintf(_("SALES INVOICE #%d"),$trans_id)); @@ -96,16 +96,16 @@ start_row(); label_cells(_("Invoice Date"), sql2date($myrow["tran_date"]), "class='tableheader2'", "nowrap"); label_cells(_("Due Date"), sql2date($myrow["due_date"]), "class='tableheader2'", "nowrap"); label_cells(_("Deliveries"), get_customer_trans_view_str(ST_CUSTDELIVERY, - get_parent_trans(10,$trans_id)), "class='tableheader2'"); + get_parent_trans(ST_SALESINVOICE,$trans_id)), "class='tableheader2'"); end_row(); -comments_display_row(10, $trans_id); +comments_display_row(ST_SALESINVOICE, $trans_id); end_table(); echo ""; end_table(1); // outer table -$result = get_customer_trans_details(10, $trans_id); +$result = get_customer_trans_details(ST_SALESINVOICE, $trans_id); start_table("$table_style width=95%"); @@ -157,7 +157,7 @@ label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right", "nowrap align=right width=15%"); label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right"); -$tax_items = get_trans_tax_details(10, $trans_id); +$tax_items = get_trans_tax_details(ST_SALESINVOICE, $trans_id); display_customer_trans_tax_details($tax_items, 6); $display_total = price_format($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"]); @@ -166,7 +166,7 @@ label_row(_("TOTAL INVOICE"), $display_total, "colspan=6 align=right", "nowrap align=right"); end_table(1); -is_voided_display(10, $trans_id, _("This invoice has been voided.")); +is_voided_display(ST_SALESINVOICE, $trans_id, _("This invoice has been voided.")); end_page(true); diff --git a/sales/view/view_sales_order.php b/sales/view/view_sales_order.php index 920b1fc7..352b6823 100644 --- a/sales/view/view_sales_order.php +++ b/sales/view/view_sales_order.php @@ -23,7 +23,7 @@ $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 600); -if ($_GET['trans_type'] == 32) +if ($_GET['trans_type'] == ST_SALESQUOTE) { page(_("View Sales Quotation"), true, false, "", $js); display_heading(sprintf(_("Sales Quotation #%d"),$_GET['trans_no'])); @@ -44,7 +44,7 @@ $_SESSION['View'] = new Cart($_GET['trans_type'], $_GET['trans_no'], true); start_table("$table_style2 width=95%", 5); echo ""; display_heading2(_("Order Information")); -if ($_GET['trans_type'] != 32) +if ($_GET['trans_type'] != ST_SALESQUOTE) { echo ""; display_heading2(_("Deliveries")); @@ -64,7 +64,7 @@ label_cells(_("Deliver To Branch"), $_SESSION['View']->deliver_to, "class='table end_row(); start_row(); label_cells(_("Ordered On"), $_SESSION['View']->document_date, "class='tableheader2'"); -if ($_GET['trans_type'] == 32) +if ($_GET['trans_type'] == ST_SALESQUOTE) label_cells(_("Valid until"), $_SESSION['View']->due_date, "class='tableheader2'"); else label_cells(_("Requested Delivery"), $_SESSION['View']->due_date, "class='tableheader2'"); @@ -83,7 +83,7 @@ label_row(_("E-mail"), "email . "'>" . $_ label_row(_("Comments"), $_SESSION['View']->Comments, "class='tableheader2'", "colspan=3"); end_table(); -if ($_GET['trans_type'] != 32) +if ($_GET['trans_type'] != ST_SALESQUOTE) { echo ""; @@ -93,7 +93,7 @@ if ($_GET['trans_type'] != 32) $th = array(_("#"), _("Ref"), _("Date"), _("Total")); table_header($th); - $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=13 AND order_=" . $_GET['trans_no']; + $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=".ST_CUSTDELIVERY." AND order_=" . $_GET['trans_no']; $result = db_query($sql,"The related delivery notes could not be retreived"); $delivery_total = 0; @@ -126,7 +126,7 @@ if ($_GET['trans_type'] != 32) $th = array(_("#"), _("Ref"), _("Date"), _("Total")); table_header($th); - $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no']; + $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=".ST_SALESINVOICE." AND order_=" . $_GET['trans_no']; $result = db_query($sql,"The related invoices could not be retreived"); $invoices_total = 0; @@ -158,7 +158,7 @@ if ($_GET['trans_type'] != 32) $th = array(_("#"), _("Ref"), _("Date"), _("Total")); table_header($th); - $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no']; + $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=".ST_CUSTCREDIT." AND order_=" . $_GET['trans_no']; $result = db_query($sql,"The related credit notes could not be retreived"); $credits_total = 0; -- 2.30.2