Changed all numeric constants to the new defined constants. A huge task.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 14 Sep 2009 21:34:56 +0000 (21:34 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 14 Sep 2009 21:34:56 +0000 (21:34 +0000)
80 files changed:
CHANGELOG.txt
admin/db/voiding_db.inc
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_db.inc
manufacturing/view/wo_production_view.php
purchasing/allocations/supplier_allocation_main.php
purchasing/includes/db/grn_db.inc
purchasing/includes/db/invoice_db.inc
purchasing/includes/db/supp_payment_db.inc
purchasing/includes/db/supp_trans_db.inc
purchasing/includes/db/suppalloc_db.inc
purchasing/includes/db/suppliers_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/po_receive_items.php
purchasing/supplier_credit.php
purchasing/supplier_invoice.php
purchasing/supplier_payment.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/includes/reporting.inc
reporting/includes/reports_classes.inc
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
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/includes/cart_class.inc
sales/includes/db/cust_trans_db.inc
sales/includes/db/custalloc_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/sales_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/sales_order_entry.php
sales/view/view_credit.php
sales/view/view_dispatch.php
sales/view/view_invoice.php
sales/view/view_sales_order.php

index 3ea230c13934b76f9f9892b378ca94f7083ee23a..f1d2169e31bdb50cf309139b2b10e7f8bf8b99b4 100644 (file)
@@ -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
index e8a3f14fdbd69966320d72b9a47509b40a06022c..8efc0036dbdd0d13451545894da9200601ce363a 100644 (file)
@@ -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
index e7a2ff7454ac754ef66276f63ae729f1639da0db..abff8a968444b66bf5d265adac3ff0f019358c58 100644 (file)
@@ -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");
                        }               
                }       
index bb21dc368456d6e59fe25436ad136aa6acd27351..9a6be87a3e81e90a0aa4cf0b455abac015a5790d 100644 (file)
@@ -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);
index aca82ee8df6fe60ed8d731f4198fcff865384412..ec5e0f2d157e2938c0231367e891ca5bd595e5a1 100644 (file)
@@ -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(
index 23cb4237f3e0699ca84103f39b70f95bafb54478..55c6a9f0e3bc51c4f46e432e9da43492fff7575b 100644 (file)
@@ -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"));
index cc028ac75e0314469ab85a5d6a7aa873595b8814..b20644c58c2d79113383e18df7ce2057ff4ee6be 100644 (file)
@@ -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", "");
index 723ea087aa1634c69d93fd3c519b549767718423..3776a0f07ee12ca687adddcabfea5da5a18b4bd0 100644 (file)
@@ -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_);
index fee17602ebda89e9532a7dd8cd838fc4dbe2b934..2eb935e73ca63d0baac00df4186ee309b271681b 100644 (file)
@@ -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,
index a736f129f2cf31927963a9874a0c168a415e28a0..9f93fd541aeb4afbc38c05c0a0f782a6cb2ac452 100644 (file)
@@ -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);
index e1f45ce1bdd20c6258e5b358694060dbe75c67f1..45bc0e8239d8955b36b5f46e4c069461c9d1514e 100644 (file)
@@ -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();
 
index 2d4f120c8ca18ceddb0270246801003cc8113a82..9a0d9cce20b952b078b3f131a3178cb63c66772b 100644 (file)
@@ -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;
index bf80e27a6688085baa596c9ef2750bb595f988e2..6b83d04599c6ae3319921d6169e6fc581357f066 100644 (file)
@@ -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 = "";
        }
index d9361bda8bf77d2c24717328730276f50ae966be..0e0999b0cb460725b555370b3222d9f29962162d 100644 (file)
@@ -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();
 }
index 695e696df33a3c2c00a46572927507118b203826..a6233050d455e965c3096551d0141cd0db3e6a68 100644 (file)
@@ -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();
 }
index f3690b5eb336e4f51441f8b4379d7b59266b93cf..ae486646ec19b04334e9defe110f7715b1e15903 100644 (file)
@@ -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."));
 }
 
 //-------------------------------------------------------------------------------------------------
index 69d342fa9996f31e619e78252432bf3b566cc636..06e24e4fedec4bac5e93bd68c96a133214f163c2 100644 (file)
@@ -64,7 +64,7 @@ function systype_name($dummy, $type)
 {
        global $systypes_array;
 
-       return $systypes_array[$type;
+       return $systypes_array[$type];
 }
 
 function trans_view($trans)
index 3a9e45955515ffca5dbc8f67e97b680160807871..07c53190804aa7a64c70381b405adc70fd25b5f4 100644 (file)
@@ -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();
 
index bca0bd2fe5c989f7ca2471ed6259c189aa9ecb11..0fbb05099d9f0aee8bbc18e1a3a0208af914a2ce 100644 (file)
@@ -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);
 
index d4dc4706ea3f02d9000648176f08867c8db7888c..3d848ed639b6eabc755d18ee9d0de2c7ae32908c 100644 (file)
@@ -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_,
index 52071cc601cd55d32d716803e16c73cd39d2e8d2..e1715a6e713df0b27e5a3529dec5c2c4fdb71a84 100644 (file)
@@ -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);
        }
index 1c0f16eb8da44d7f76b6f6f46a06a52bab08b14f..b31adc52e0c28755ec3909a03eaf7c5bfe9b9d85 100644 (file)
@@ -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");
        }
 
index eaead9ecb890e81c48c2a031129c0b5120f84fe6..1cfa85daa45c3c4ec858a8f53a37a64ed99b0d2a 100644 (file)
@@ -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,
index 81bd8617153be72374c5174a09af7efcbf9189c0..a0fdae4bdc981f0c88f405a7bccee431893473cc 100644 (file)
@@ -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']))
index 75c8a24f304bb923ee9b2bda717d9794484e43b2..c5eafa8039f8188b66015f546cf63526d42cd42c 100644 (file)
@@ -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);
index b0d9d51b1d71b8c258149276af5969dd4942bc3e..98e7e4d1ff9225a6392d730b115a43153277dfe3 100644 (file)
@@ -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'))
index 38508f71ea5fec9141509a9f51b11084d99e1d6b..dff07c662cbf465f6b7485ecc355d5fbca486f2c 100644 (file)
@@ -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')) 
index 5059807be0e433350209e5934cefe5c7501729c8..601e5d5f0458f83e388be565080646e0343b9c06 100644 (file)
@@ -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 "<BR>";
-       //echo get_gl_view_str(25, $grn, _("View the GL &Journal Entries for this Delivery"));
-
-//     echo "<br>";
        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');
index 25c24e3b0afdf31771954d07b0ede86581ad817f..319bab0bb1acf583fec8d99a4198668a47bc718e 100644 (file)
@@ -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 "<center>";
@@ -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');
index 33c745a1c60c453ba577bc92b6871da328d25718..15a6529f1667438d4cb72d32503b4779ac153ef6 100644 (file)
@@ -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 "<center>";
@@ -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();
index ee0b81a6538434ec35a4662a88666824228e7f9b..713d0122ffda7fc292716b9cf3a767bf1fea960e 100644 (file)
@@ -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);
 
index b47881996db4706b041ab4ea6e6afcd64e5f109c..0a94ac8c8912ad922e280a342343833056d776d2 100644 (file)
@@ -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);
 
index 049c8c5ed575cc446164a0d6bffff4f0050ca098..052103deeff636c073bf4161085a329996ee85aa 100644 (file)
@@ -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();
index 60fa7f41b52b334e2b95b66fea9b7ec2c1042e3f..79e6e5b9b9d7ddf3bc80d22857559f4c02ce4a23 100644 (file)
@@ -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 "<br>";
@@ -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);
index bf77703aa9ca181c3375cfef5ac839bef1af4021..bbab14eb2fb6428e64bca5f34021628f7dfc1046 100644 (file)
@@ -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);
 
index 7ee909784aed83c89daadb8b35be95a2ef1bc124..52be7141e0e8626b56e875e7b3a5634509407cfb 100644 (file)
@@ -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);
index 9df4942975e2d1850605f5193d7aa05a5136b546..e38ed6a225119a276ea76359fa7bc65f1a4505b9 100644 (file)
@@ -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(
index 9ed5a4ab11d99e20f1c2821cd098dbd1ebf03a9e..fd1fae781bc19f721652aa26b2bc5e3cd60d4a0c 100644 (file)
@@ -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':
index 95a092810e0ce6f8678d7db98e0d19d5461b7bb9..913c12b40f7ce42f81645e99f2b62df519b8d798 100644 (file)
@@ -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];
index f8a2a52dfa44715b943e022edb2297ac08afda70..9070ae186a9a45a92e7690e3a1ed96eab08f1844 100644 (file)
@@ -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;
index e8a418910daab345965c7e506fd7b37321f3a28e..5eeeb22860b735725ce4cf3d2e459d10894df62c 100644 (file)
@@ -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");
index d4916ca8428ca7849173749af2ea9c1fa5a7cbda..dd535b9858b4b23cb993b9c05ffd636349b1a58b 100644 (file)
@@ -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'
index 09dd921cdb777aa18289a7a9ff020ef3e6b69d39..4aac08ab275ad665a614d3e960c9e44c51daae63 100644 (file)
@@ -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";
index a265bd603a69c9442ff3f5ad4fb38c427628d405..5a297da48397a835a716bef6892478bcb0c22c44 100644 (file)
@@ -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);
index 0fcfb6e40061af1e79bae48a93bfad6e36ff773b..156b5499455f322e1be81b4535144837931676d4 100644 (file)
@@ -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);
index 2a151def233bde1eaeac89f9791a6d098b6765c7..3fb0ad5af0dd413c0b4aef88e9e6603bb22c7e83 100644 (file)
@@ -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))
                {
index a0051c4586d4c1ed3c550363ba35283a4b2cb541..5af4a83ce15544652b40d9c7b7f7dc015052e1a5 100644 (file)
@@ -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();
index 4272dbf6aec9f5cb9bbc2038d0e180f5e7aa8f30..cbf48a04f68f03f6bf4e91bf6b1ba3a481af8c9e 100644 (file)
@@ -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))
                {
index 61048e871f6762c7cdcc1a810927f6ad6915fcd3..a5614755dc079e4f0053fcafc8cc91847a51f8e6 100644 (file)
@@ -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];
index 2245ae01ca0bab5d52d2163da985b3e0094dbf8a..97156dc513ccc06ec51dd6e78f77230421b8096b 100644 (file)
@@ -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,
index ffe28416f75f70167b43550c00872677e3a630e3..91fdfde62b5356cc9f1a287ef13532ecf0a132b2 100644 (file)
@@ -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'];
index 7dbe339afbeef53b8743aae6f60130e9c96dbcad..3958536fe9440c5f8526b793a16d778b7a65f532 100644 (file)
@@ -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'";
index 07e76f38486a8bf5bd5e2b90290931c0207923a8..bf6bb3d466fe0b75ac78b170a37df1718a8477bd 100644 (file)
@@ -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();
index f20e48e0692c23a0d2e7f5f35d73f3d216d4841d..4baf0105841b9e4e4b91416a7c8446ab4258f03e 100644 (file)
@@ -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 {
index 644f60b203e83016594aa3c78bd82706840c559e..f1897335ba88887d9bf9f835b8d0212c00959ea9 100644 (file)
@@ -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);
index 7dcc461dd3c132541447de6df5d96c1451bf58c0..5d2ebb8d4ea17455f567d06cdc76af43ff609413 100644 (file)
@@ -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;
index d6dd0fb78b236e9b8b6d1750675422f106e798dd..5c62eba6e8a87deee9d311e09462e70ba999b416 100644 (file)
@@ -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_no<count($ci->line_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;
index 366d9a29fe9b4df3bba2efbe9c0f558e7287ebab..f4ffe9158752fb13b318e8d68acde9fb8b7cc7a9 100644 (file)
@@ -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 '<br>';
-       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 ("<br><b>" . _("This order has no items. There is nothing to delivery.") . "</b>");
        }
 
-       $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'");
index a943b099c755419f8a1b682700aada2b87ed7a12..acf3013712aad45cf9a4cfcf98a77db49843226c 100644 (file)
@@ -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 '<br>';
-       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 ("<br><b>" . _("There are no delivered items with a quantity left to invoice. There is nothing left to invoice.") . "</b>");
        }
 
-       $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"<center><br><b>" . _("There are no delivery notes for this invoice.<br>
                Most likely this invoice was created in Front Accounting version prior to 2.0
                and therefore can not be modified.") . "</b></center>";
                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"<center><br><b>" . _("All quantities on this invoice has been credited. There is nothing to modify on this invoice") . "</b></center>";
@@ -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');
 
index 53f92be50d40505e54c1f312fd2a980bcb0f1b23..1dcce02d3f6411535da166cefaa7a279f6cea83f 100644 (file)
@@ -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);
index 3f22e4f359a628858bd4d568c8282c17e8d96d3b..d85136c531b1fa1cfc1967c7e683ed523493215c 100644 (file)
@@ -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
index e3e220063acb34495fe4ec999becfdb3aa14f1e3..fab74ab6e6ec4f4ee94501a65d820755c10223dc 100644 (file)
@@ -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;
        }
index addb867e50d1f04b9c61d8ad1c1b10c0c0fa46f3..9152a3f41142dbba608c1a3117168bb525c57673 100644 (file)
@@ -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");
        }
 
index f7e56866f8950b6974621530008867d1ec002c1e..a73bc8ad237fab478412f22e8298a1439412ba42 100644 (file)
@@ -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();
 
index caff001fa196df7ce629c80bcf5d3e69707605b1..a71d686acc77e876fbda050ce5464a1ca2102fcc 100644 (file)
@@ -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");
index 4b38c28c6dd3c861e9e8c6589462d0056fbaed81..8bd2d785a3750c6a8836cc8172e4c8d1b5d3a3c8 100644 (file)
@@ -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']);
                }
        }
 
index d5e129bb03ef2aa3efea18ead4d8258ad64aae2d..c4e97e4c6dd84545f5585e26fda8105c00f997c3 100644 (file)
@@ -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();
index 952587c5beb00c63fb60b2f8d9d325d7df43d371..39c67bedd2dfa8355cbe4335a431b87b51e00c6d 100644 (file)
@@ -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");
 }
index 7f8b5e21cfb5eef85ab14eb5f663b7d1eb5a074f..fc6f290479c1e2b64348969da51b59bab84cf068 100644 (file)
@@ -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";
index 0731752d8fcd5e9ea72def7cbc0f783ff3d225bf..96c24ef76079514ab79f16fc1d073d30498dee70 100644 (file)
@@ -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'));
 
index 51749f2cc1c50c7d70df628e167b1683c15f72af..5fb9ad81361fb0e6476ba24b0f6c82083ad504fa 100644 (file)
@@ -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." ";
        }
 
 
index 5602fed553b93f5013e1f3d2b5112fa5f50d8e49..abfb73daf301b6edd3001a356b8cd477a315af6d 100644 (file)
@@ -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')
index d9a7af5aaf5af456279f990d2ce3133556c5b6d4..4f601014ef4451cb961fc1ad9ab5b8cb185e8e72 100644 (file)
@@ -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
index 7ebcb822de408fc2fcf5d108d6f320c98067ab1e..e0d2f957981c87e09ecbdac3439d48c4a7eaaa40 100644 (file)
@@ -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'),
index ad2e4b4e675b328600c207298e4a0d816dce1e14..cdbc3bfaa2dc33a048df928ee4a429597df7b35f 100644 (file)
@@ -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("");
index e15543e57f1d9d94071c71430b8319e00879e765..ff7945785279f3f00fc800787e513759b910197a 100644 (file)
@@ -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");
index 85cd1de3fe53704ba2067c6729918b5621a1a6f8..e1e51aa2b755d357717bd310f340b2bff41ff05d 100644 (file)
@@ -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 "</td></tr>";
@@ -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("<font color=red>" . _("TOTAL CREDIT") . "</font",
        "<font color=red>$display_total</font>", "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 */
 
index db73299b3f9a53f500aa0b8d8bcb22b3c2cb6a58..dac9f7dd71bededfff1a366df1e8c485b437798a 100644 (file)
@@ -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 "</td></tr>";
 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);
 
index aa2bbe78ca7a2ad5dc3e90b2f23a73a2f9b0402b..6a13b1aedba50b6c41947ccee8f77667fbb8cd92 100644 (file)
@@ -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 "</td></tr>";
 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);
 
index 920b1fc7d4cd65e4f3e7c229a569e28c99aafd0c..352b68234a28dd0b23c0aa532aeb5cd6d4d64d98 100644 (file)
@@ -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 "<tr valign=top><td>";
 display_heading2(_("Order Information"));
-if ($_GET['trans_type'] != 32)
+if ($_GET['trans_type'] != ST_SALESQUOTE)
 {
        echo "</td><td>";
        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"), "<a href='mailto:" . $_SESSION['View']->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 "</td><td valign='top'>";
 
@@ -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;