! -> 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
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.
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))
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
$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");
}
}
$i = 0;
while ($type = db_fetch($systypes))
{
- if ($i++ == 11)
+ if ($i++ == ST_CUSTCREDIT)
{
table_section(2);
table_header($th);
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);
}
$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(
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;
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;
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;
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"));
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']);
}
//----------------------------------------------------------------------------------
{
$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", "");
$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";
}
// 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) {
}
// 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_);
// 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,
{
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);
$trans_no = $this->trans_no;
}
- $sup = $type == 21 || $type == 22;
+ $sup = $type == ST_SUPPCREDIT || $type == ST_SUPPAYMENT;
$this->allocs = array();
if ($trans_no) {
//
function write()
{
- $sup = $this->type == 21 || $this->type == 22;
+ $sup = $this->type == ST_SUPPCREDIT || $this->type == ST_SUPPAYMENT;
begin_transaction();
$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;
{
$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;
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;
{
$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";
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;
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;
$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"]);
$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"] . "'";
$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 = "";
}
$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)
}
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();
}
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();
}
// -------------------------------------------------------------------------
// 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();
}
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();
}
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."));
}
//-------------------------------------------------------------------------------------------------
{
global $systypes_array;
- return $systypes_array[$type;
+ return $systypes_array[$type];
}
function trans_view($trans)
$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);
$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();
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);
}
$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 ";
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);
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();
$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);
$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;
$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);
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);
//}
}
// ----------------------------------------------------------------------
{
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,
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);
///////////////////////////////////////////////////////////////////////////
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);
$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)
$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);
// 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_,
$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,
$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";
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
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);
}
$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;
}
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");
}
// 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,
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']))
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));
}
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']))
{
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);
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;
"/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 : '';
}
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
{
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'))
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)
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)
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
{
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'))
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"));
//--------------------------------------------------------------------------------------------------
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."));
}
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');
if (isset($_GET['AddedID']))
{
$invoice_no = $_GET['AddedID'];
- $trans_type = 21;
+ $trans_type = ST_SUPPCREDIT;
echo "<center>";
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');
if (isset($_GET['AddedID']))
{
$invoice_no = $_GET['AddedID'];
- $trans_type = 20;
+ $trans_type = ST_SUPPINVOICE;
echo "<center>";
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');
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();
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');
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']);
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);
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);
{
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();
$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>";
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);
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());
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);
$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);
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);
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());
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);
$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();
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);
'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(
$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':
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;
$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':
{
$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";
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";
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);
$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");
$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)
{
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];
$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,
".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
$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;
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");
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'
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";
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)
$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";
$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);
$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");
$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);
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)
{
$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))
{
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());
$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();
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)
{
$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))
{
{
$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";
$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'
$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)
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];
// 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,
$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'];
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'";
$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();
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";
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;
}
$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 {
{
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
$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);
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);
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")));
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;
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);
} 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);
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;
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';
} 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()) {
} 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;
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);
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");
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 */
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",
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;
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'");
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);
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"));
$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",
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;
} 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>";
$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');
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");
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;
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);
/*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 );
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++) {
} 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"];
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));
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)
}
}
}
- if ($type == 10) {
+ if ($type == ST_SALESINVOICE) {
$this->due_date =
get_invoice_duedate($this->customer_id, $this->document_date);
$this->pos = user_pos();
// 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);
$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);
$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
$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
".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, "
$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 ";
}
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
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;
}
$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;
}
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");
}
$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);
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);
}
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();
/*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,
$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;
$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);
///////////////////////////////////////////////////////////////////////////
$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);
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");
}
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();
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,
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");
$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");
$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");
$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,
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) {
$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,
// 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);
$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,
/*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,
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();
$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']);
}
}
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
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,
$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) {
$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,
// 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);
($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");
} /*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");
}
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;
$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();
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");
$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");
}
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
//--------------------------------------------------------------------------------------------------
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;
}
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";
$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'];
$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;
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);
}
$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');
}
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
$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)
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").':';
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'));
"/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;
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) : '';
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) : '';
}
(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, "
{
if ($_POST['filterType'] == '1' || $_POST['filterType'] == '2')
{
- $sql .= " AND trans.type = 10 ";
+ $sql .= " AND trans.type = ".ST_SALESINVOICE." ";
}
elseif ($_POST['filterType'] == '3')
{
}
elseif ($_POST['filterType'] == '4')
{
- $sql .= " AND trans.type = 11 ";
+ $sql .= " AND trans.type = ".ST_CUSTCREDIT." ";
}
if ($_POST['filterType'] == '2')
}
}else
{
- $sql .= " AND trans.type != 13 ";
+ $sql .= " AND trans.type <> ".ST_CUSTDELIVERY." ";
}
function due_date($row)
{
- return $row["type"] == 10 ? $row["due_date"] : '';
+ return $row["type"] == ST_SALESINVOICE ? $row["due_date"] : '';
}
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) : '';
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)
$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'];
$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;
}
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);
}
(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, "
{
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')
//---------------------------------------------------------------------------------------------
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)
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)
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
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))
{
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
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);
}
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
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
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;
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');
sorder.deliver_to";
}
-if ($trans_type == 30)
+if ($trans_type == ST_SALESORDER)
$cols = array(
_("Order #") => array('fun'=>'view_link'),
_("Ref"),
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'),
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("");
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);
$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"),
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"),
$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"),
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'])) {
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");
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"),
$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;
$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'];
}
$_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;
}
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;
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."));
}
//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."));
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");
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']);
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 {
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");
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);
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");
$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"]);
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>";
$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%");
"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 */
// 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));
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%");
"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"]);
"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);
// 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));
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%");
"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"]);
"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);
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']));
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"));
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'");
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'>";
$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;
$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;
$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;