! -> Note
$ -> Affected files
+25-Jan-2010 Joe Hunt
++ Added document Receipt and small rearrangements and bugfixes
+$ /
22-Jan-2010 Tom Hallman/Joe Hunt
# Exchange rate doesn't update table when adding new or deleting rate
$ /gl/manage/exchange_rates.php
define('ST_COSTUPDATE', 35);
define('ST_DIMENSION', 40);
+// Don't include these defines in the $systypes_array.
+// They are used for documents only.
+define ('ST_STATEMENT', 91);
+define ('ST_CHEQUE', 92);
+
$systypes_array = array (
ST_JOURNAL => _("Journal Entry"),
ST_BANKPAYMENT => _("Bank Payment"),
return $bank_amount;
}
+//--------------------------------------------------------------------------------------
+//
+// Simple English version of number to words conversion.
+//
+function _number_to_words($number)
+{
+ $Bn = floor($number / 1000000000); /* Billions (giga) */
+ $number -= $Bn * 1000000000;
+ $Gn = floor($number / 1000000); /* Millions (mega) */
+ $number -= $Gn * 1000000;
+ $kn = floor($number / 1000); /* Thousands (kilo) */
+ $number -= $kn * 1000;
+ $Hn = floor($number / 100); /* Hundreds (hecto) */
+ $number -= $Hn * 100;
+ $Dn = floor($number / 10); /* Tens (deca) */
+ $n = $number % 10; /* Ones */
+
+ $res = "";
+
+ if ($Bn)
+ $res .= _number_to_words($Bn) . " Billion";
+ if ($Gn)
+ $res .= (empty($res) ? "" : " ") . _number_to_words($Gn) . " Million";
+ if ($kn)
+ $res .= (empty($res) ? "" : " ") . _number_to_words($kn) . " Thousand";
+ if ($Hn)
+ $res .= (empty($res) ? "" : " ") . _number_to_words($Hn) . " Hundred";
+
+ $ones = array("", "One", "Two", "Three", "Four", "Five", "Six",
+ "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
+ "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen",
+ "Nineteen");
+ $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
+ "Seventy", "Eigthy", "Ninety");
+
+ if ($Dn || $n)
+ {
+ if (!empty($res))
+ $res .= " and ";
+ if ($Dn < 2)
+ $res .= $ones[$Dn * 10 + $n];
+ else
+ {
+ $res .= $tens[$Dn];
+ if ($n)
+ $res .= "-" . $ones[$n];
+ }
+ }
+
+ if (empty($res))
+ $res = "zero";
+ return $res;
+}
+
+function price_in_words($amount, $document=0)
+{
+ global $Hooks;
+ // use local price_in_words() if the hook is defined
+ if (method_exists($Hooks, 'price_in_words'))
+ {
+ return $Hooks->price_in_words($amount, $document);
+ }
+ // Only usefor Remittance and Receipts as default
+ if (!($document == ST_SUPPAYMENT || $document == ST_CUSTPAYMENT || $document == ST_CHEQUE))
+ return "";
+ if ($amount < 0 || $amount > 999999999999)
+ return "";
+ $dec = user_price_dec();
+ if ($dec > 0)
+ {
+ $divisor = pow(10, $dec);
+ $frac = round2($amount - floor($amount), $dec) * $divisor;
+ $frac = sprintf("%0{$dec}d", $frac);
+ $and = _("and");
+ $frac = " $and $frac/$divisor";
+ }
+ else
+ $frac = "";
+ return _number_to_words(intval($amount)) . $frac;
+}
function get_js_open_window($width, $height)
{
}
else
{
- $doc_Charge_To = _("Charge To");
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Charge_To = _("With thanks from");
+ else
+ $doc_Charge_To = _("Charge To");
$doc_Delivered_To = _("Delivered To");
}
$doc_Shipping_Company = _("Shipping Company");
}
else
{
- if ($doctype == ST_SUPPAYMENT)
+ if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
$doc_Our_Ref = _("Type");
else
$doc_Our_Ref = _("Sales Person");
$doc_Our_VAT_no = _("Our VAT No.");
$doc_Domicile = _("Domicile");
if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER ||
- $doctype == ST_SUPPAYMENT) {
- $doc_Bank_Account = '';
- $doc_Please_Quote = _("All amounts stated in");
+ $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) {
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Extra = _("* Subject to Realisation of the Cheque.");
+ else
+ $doc_Extra = "";
+ $doc_Bank_Account = '';
+ $doc_Please_Quote = _("All amounts stated in");
} else {
$doc_Bank_Account = _("Bank Account");
$doc_Please_Quote = $doctype==ST_SALESINVOICE ?
$doc_Bank = _("Bank");
$doc_Payment_Link = _("You can pay through");
if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE ||
- $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT)
+ $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT ||
+ $doctype == ST_CUSTPAYMENT)
{
if ($doctype == ST_SALESQUOTE)
$this->title = _("SALES QUOTATION");
$this->title = _("WORK ORDER");
elseif ($doctype == ST_SUPPAYMENT)
$this->title = _("REMITTANCE");
+ elseif ($doctype == ST_CUSTPAYMENT)
+ $this->title = _("RECEIPT");
else
$this->title = _("CREDIT NOTE");
if ($doctype == ST_PURCHORDER)
elseif ($doctype == ST_WORKORDER)
$this->headers = array(_("Item Code"), _("Item Description"),
_("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"));
- elseif ($doctype == ST_SUPPAYMENT)
+ elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
$this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation"));
else
$this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"),
_("Unit"), _("Price"), _("Discount %"), _("Total"));
}
- else if ($doctype == ST_CUSTPAYMENT)
+ else if ($doctype == ST_STATEMENT)
{
$this->title = _("STATEMENT");
$this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"),
if (isset($header2type) || isset($linetype))
{
$doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? _("Delivery Note No.") :
+ ($doctype == ST_CUSTPAYMENT ? _("Receipt No.") :
($doctype == ST_SUPPAYMENT ? _("Remittance No.") :
(($doctype==ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? _("Order no.") :
- ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No."))))));
+ ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No.")))))));
$doc_Delivery_no = _("Delivery Note No.");
$doc_Order_no = _("Order no.");
}
$doc_TOTAL_PO = _("TOTAL PO EX VAT");
$doc_TOTAL_DELIVERY = _("TOTAL DELIVERY INCL. VAT");
}
- elseif ($doctype == ST_SUPPAYMENT)
+ elseif ($doctype == ST_SUPPAYMENT || ST_CUSTPAYMENT)
{
+ $doc_Towards = _("As advance / full / part / payment towards:");
+ $doc_by_Cheque = _("By Cash / Cheque* / Draft No.");
+ $doc_Dated = _("Dated");
+ $doc_Drawn = _("Drawn on Bank");
+ $doc_Drawn_Branch = _("Branch");
+ $doc_Received = _("Received / Sign");
$doc_Total_Allocated = _("Total Allocated");
$doc_Left_To_Allocate = _("Left to Allocate");
- $doc_Total_Payment = _("TOTAL REMITTANCE");
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Total_Payment = _("TOTAL RECEIPT");
+ else
+ $doc_Total_Payment = _("TOTAL REMITTANCE");
}
- elseif ($doctype == ST_CUSTPAYMENT)
+ elseif ($doctype == ST_STATEMENT)
{
$doc_Outstanding = _("Outstanding Transactions");
$doc_Current = _("Current");
}
else
{
- $doc_Charge_To = "Charge To";
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Charge_To = "With thanks from";
+ else
+ $doc_Charge_To = "Charge To";
$doc_Delivered_To = "Delivered To";
}
$doc_Shipping_Company = "Shipping Company";
}
else
{
- if ($doctype == ST_SUPPAYMENT)
+ if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
$doc_Our_Ref = "Type";
else
$doc_Our_Ref = "Sales Person";
$doc_Our_VAT_no = "Our VAT No.";
$doc_Domicile = "Domicile";
if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER ||
- $doctype == ST_SUPPAYMENT) {
- $doc_Bank_Account = '';
- $doc_Please_Quote = "All amounts stated in";
+ $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) {
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Extra = "* Subject to Realisation of the Cheque.";
+ else
+ $doc_Extra = "";
+ $doc_Bank_Account = '';
+ $doc_Please_Quote = "All amounts stated in";
} else {
$doc_Please_Quote = "Please quote ".($doctype==ST_SALESINVOICE ? "Invoice" : "Credit")
." no. when paying. All amounts stated in";
$doc_Bank = "Bank";
$doc_Payment_Link = "You can pay through";
if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE ||
- $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT)
+ $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT ||
+ $doctype == ST_CUSTPAYMENT)
{
if ($doctype == ST_SALESQUOTE)
$this->title = "SALES QUOTATION";
$this->title = "WORK ORDER";
elseif ($doctype == ST_SUPPAYMENT)
$this->title = "REMITTANCE";
+ elseif ($doctype == ST_CUSTPAYMENT)
+ $this->title = "RECEIPT";
else
$this->title = "CREDIT NOTE";
if ($doctype == ST_PURCHORDER)
elseif ($doctype == ST_WORKORDER)
$this->headers = array("Item Code", "Item Description",
"From Location", "Work Centre", "Unit Quantity", "Total Quantity", "Units Issued");
- elseif ($doctype == ST_SUPPAYMENT)
+ elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
$this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Total Amount', 'Left to Allocate', 'This Allocation');
else
$this->headers = array('Item Code', 'Item Description', 'Quantity', 'Unit',
'Price', 'Discount %', 'Total');
}
- elseif ($doctype == ST_CUSTPAYMENT)
+ elseif ($doctype == ST_STATEMENT)
{
$this->title = "STATEMENT";
$this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Charges',
if (isset($header2type) || isset($linetype))
{
$doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? "Delivery Note No." :
+ ($doctype == ST_CUSTPAYMENT ? "Receipt No." :
($doctype == ST_SUPPAYMENT ? "Remittance No." :
(($doctype == ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? "Order no." :
- ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No.")))));
+ ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No."))))));
$doc_Delivery_no = "Delivery Note No.";
$doc_Order_no = "Order no.";
}
$doc_TOTAL_PO = "TOTAL PO EX VAT";
$doc_TOTAL_DELIVERY = "TOTAL DELIVERY INCL. VAT";
}
- elseif ($doctype == ST_SUPPAYMENT)
+ elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
{
+ $doc_Towards = "As advance / full / part / payment towards:";
+ $doc_by_Cheque = "By Cash / Cheque* / Draft No.";
+ $doc_Dated = "Dated";
+ $doc_Drawn = "Drawn on Bank";
+ $doc_Drawn_Branch = "Branch";
+ $doc_Received = "Received / Sign";
$doc_Total_Allocated = "Total Allocated";
$doc_Left_To_Allocate = "Left to Allocate";
- $doc_Total_Payment = "TOTAL REMITTANCE";
+ if ($doctype == ST_CUSTPAYMENT)
+ $doc_Total_Payment = "TOTAL RECEIPT";
+ else
+ $doc_Total_Payment = "TOTAL REMITTANCE";
}
- elseif ($doctype == ST_CUSTPAYMENT)
+ elseif ($doctype == ST_STATEMENT)
{
$doc_Outstanding = "Outstanding Transactions";
$doc_Current = "Current";
$this->Text($c2col, $this->company['gst_no'], $mcol);
$this->NewLine();
}
- if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['domicile'] != "")
+ if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['domicile'] != "")
{
$this->Text($ccol, $doc_Domicile, $c2col);
$this->Text($c2col, $this->company['domicile'], $mcol);
$this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C');
elseif (isset($sales_order["customer_ref"]))
$this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C');
+ else
+ $this->TextWrap($col, $this->row, $width, $myrow["debtor_ref"], 'C');
$col += $width;
if ($branch != null)
{
$row = db_fetch($result);
$this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C');
}
- elseif ($doctype == ST_SUPPAYMENT)
+ elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT)
$this->TextWrap($col, $this->row, $width, $systypes_array[$myrow["type"]], 'C');
elseif ($doctype == ST_WORKORDER)
$this->TextWrap($col, $this->row, $width, $wo_types_array[$myrow["type"]], 'C');
}
elseif ($doctype == ST_WORKORDER)
$this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C');
- elseif (isset($myrow['order_']))
+ elseif (isset($myrow['order_']) && $myrow['order_'] != 0)
$this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C');
$col += $width;
if ($doctype == ST_SALESORDER || $doctype == ST_SALESQUOTE)
$this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C');
elseif ($doctype == ST_WORKORDER)
$this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C');
- elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && isset($myrow['due_date']))
+ elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && $doctype != ST_CUSTPAYMENT &&
+ $doctype != ST_SUPPAYMENT && isset($myrow['due_date']))
$this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C');
if (!isset($packing_slip) || $packing_slip == 0)
{
$this->row -= $this->lineHeight;
}
}
+ if ($doc_Extra != "")
+ {
+ $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Extra, 'C');
+ $this->row -= $this->lineHeight;
+ }
if ($this->params['comments'] != '')
{
$this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C');
$this->row -= $this->lineHeight;
}
- if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['legal_text'] != "")
+ if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['legal_text'] != "")
{
$this->TextWrapLines($ccol, $right - $ccol, $this->company['legal_text'], 'C');
}
'PARAM_3' => $email,
'PARAM_4' => '');
break;
+ case ST_CUSTPAYMENT :
+ $rep = 112;
+ // from, to, currency, bank acc, email, comments
+ $ar = array(
+ 'PARAM_0' => $doc_no,
+ 'PARAM_1' => $doc_no,
+ 'PARAM_2' => '',
+ 'PARAM_4' => '');
+ break;
case ST_SUPPAYMENT :
$rep = 210;
// from, to, currency, bank acc, email, comments
FROM ".TB_PREF."suppliers, ".TB_PREF."supp_trans WHERE (type=".ST_BANKPAYMENT." OR type=".ST_SUPPAYMENT." OR type=".ST_SUPPCREDIT.") AND ".TB_PREF."suppliers.supplier_id=".TB_PREF."supp_trans.supplier_id ORDER BY ".TB_PREF."supp_trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
+ case 'RECEIPT':
+ $BD = _("BD");
+ $CP = _("CP");
+ $CN = _("CN");
+ $ref = ($print_invoice_no == 1 ? "trans_no" : "reference");
+ $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+ ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, if (type=".ST_BANKDEPOSIT.", ' $BD ', if (type=".ST_CUSTPAYMENT.", ' $CP ', ' $CN ')), ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_BANKDEPOSIT." OR type=".ST_CUSTPAYMENT." 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";
+ return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
+
case 'ITEMS':
return stock_manufactured_items_list($name);
$rep->Font('bold');
$rep->TextCol(3, 6, $doc_TOTAL_INVOICE, - 2);
$rep->TextCol(6, 7, $DisplayTotal, -2);
+ $words = price_in_words($myrow['Total'], $j);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
if ($email == 1)
{
$rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf";
$rep->Info($params, $cols, null, $aligns);
}
- $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT);
+ $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT);
$rep->NewLine();
$linetype = true;
- $doctype = ST_CUSTPAYMENT;
+ $doctype = ST_STATEMENT;
if ($rep->currency != $myrow['curr_code'])
{
include($path_to_root . "/reporting/includes/doctext2.inc");
$rep->TextCol(7, 8, $DisplayNet, -2);
$rep->NewLine();
if ($rep->row < $rep->bottomMargin + (10 * $rep->lineHeight))
- $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT);
+ $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT);
}
$nowdue = "1-" . $PastDueDays1 . " " . $doc_Days;
$pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days;
for ($i = 0; $i < 5; $i++)
$rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right');
if ($email == 1)
- $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_CUSTPAYMENT);
+ $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_STATEMENT);
}
if ($email == 0)
else
$rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2);
$rep->TextCol(6, 7, $DisplayTotal, -2);
+ $words = price_in_words($myrow['Total'], ST_SALESORDER);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
if ($email == 1)
{
$rep->Font('bold');
$rep->TextCol(3, 6, $doc_TOTAL_DELIVERY, - 2);
$rep->TextCol(6, 7, $DisplayTotal, -2);
+ $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
}
if ($email == 1)
else
$rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2);
$rep->TextCol(6, 7, $DisplayTotal, -2);
+ $words = price_in_words($myrow['Total'], ST_SALESQUOTE);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
if ($email == 1)
{
--- /dev/null
+<?php
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+
+$page_security = $_POST['PARAM_0'] == $_POST['PARAM_1'] ?
+ 'SA_SALESTRANSVIEW' : 'SA_SALESBULKREP';
+// ----------------------------------------------------------------
+// $ Revision: 2.0 $
+// Creator: Joe Hunt
+// date_: 2005-05-19
+// Title: Purchase Orders
+// ----------------------------------------------------------------
+$path_to_root="..";
+
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/date_functions.inc");
+include_once($path_to_root . "/includes/data_checks.inc");
+
+//----------------------------------------------------------------------------------------------------
+
+print_receipts();
+
+//----------------------------------------------------------------------------------------------------
+function get_receipt($type, $trans_no)
+{
+ $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_freight_tax + ".TB_PREF."debtor_trans.ov_discount) AS Total,
+ ".TB_PREF."debtors_master.name AS DebtorName, ".TB_PREF."debtors_master.debtor_ref,
+ ".TB_PREF."debtors_master.curr_code, ".TB_PREF."debtors_master.payment_terms, ".TB_PREF."debtors_master.tax_id AS tax_id,
+ ".TB_PREF."debtors_master.email, ".TB_PREF."debtors_master.address
+ FROM ".TB_PREF."debtor_trans, ".TB_PREF."debtors_master
+ WHERE ".TB_PREF."debtor_trans.debtor_no = ".TB_PREF."debtors_master.debtor_no
+ AND ".TB_PREF."debtor_trans.type = ".db_escape($type)."
+ AND ".TB_PREF."debtor_trans.trans_no = ".db_escape($trans_no);
+ $result = db_query($sql, "The remittance cannot be retrieved");
+ if (db_num_rows($result) == 0)
+ return false;
+ return db_fetch($result);
+}
+
+function get_allocations_for_receipt($debtor_id, $type, $trans_no)
+{
+ $sql = get_alloc_trans_sql("amt, trans.reference, trans.alloc", "trans.trans_no = alloc.trans_no_to
+ AND trans.type = alloc.trans_type_to
+ AND alloc.trans_no_from=$trans_no
+ AND alloc.trans_type_from=$type
+ AND trans.debtor_no=".db_escape($debtor_id),
+ TB_PREF."cust_allocations as alloc");
+ $sql .= " ORDER BY trans_no";
+ return db_query($sql, "Cannot retreive alloc to transactions");
+}
+
+function print_receipts()
+{
+ global $path_to_root, $systypes_array;
+
+ include_once($path_to_root . "/reporting/includes/pdf_report.inc");
+
+ $from = $_POST['PARAM_0'];
+ $to = $_POST['PARAM_1'];
+ $currency = $_POST['PARAM_2'];
+ $comments = $_POST['PARAM_3'];
+
+ if ($from == null)
+ $from = 0;
+ if ($to == null)
+ $to = 0;
+ $dec = user_price_dec();
+
+ $fno = explode("-", $from);
+ $tno = explode("-", $to);
+
+ $cols = array(4, 85, 150, 225, 275, 360, 450, 515);
+
+ // $headers in doctext.inc
+ $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right');
+
+ $params = array('comments' => $comments);
+
+ $cur = get_company_Pref('curr_default');
+
+ if ($email == 0)
+ {
+ $rep = new FrontReport(_('RECEIPT'), "ReceiptBulk", user_pagesize());
+ $rep->currency = $cur;
+ $rep->Font();
+ $rep->Info($params, $cols, null, $aligns);
+ }
+
+ for ($i = $fno[0]; $i <= $tno[0]; $i++)
+ {
+ if ($fno[0] == $tno[0])
+ $types = array($fno[1]);
+ else
+ $types = array(ST_BANKDEPOSIT, ST_CUSTPAYMENT, ST_CUSTCREDIT);
+ foreach ($types as $j)
+ {
+ $myrow = get_receipt($j, $i);
+ if (!$myrow)
+ continue;
+ $baccount = get_default_bank_account($myrow['curr_code']);
+ $params['bankaccount'] = $baccount['id'];
+
+ $rep->title = _('RECEIPT');
+ $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT);
+ $result = get_allocations_for_receipt($myrow['debtor_no'], $myrow['type'], $myrow['trans_no']);
+
+ $linetype = true;
+ $doctype = ST_CUSTPAYMENT;
+ if ($rep->currency != $myrow['curr_code'])
+ {
+ include($path_to_root . "/reporting/includes/doctext2.inc");
+ }
+ else
+ {
+ include($path_to_root . "/reporting/includes/doctext.inc");
+ }
+
+ $total_allocated = 0;
+ $rep->TextCol(0, 4, $doc_Towards, -2);
+ $rep->NewLine(2);
+
+ while ($myrow2=db_fetch($result))
+ {
+ $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);
+ $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2);
+ $rep->AmountCol(4, 5, $myrow2['Total'], $dec, -2);
+ $rep->AmountCol(5, 6, $myrow2['Total'] - $myrow2['alloc'], $dec, -2);
+ $rep->AmountCol(6, 7, $myrow2['amt'], $dec, -2);
+
+ $total_allocated += $myrow2['amt'];
+ $rep->NewLine(1);
+ if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
+ $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT);
+ }
+
+ $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
+
+ $rep->TextCol(3, 6, $doc_Total_Allocated, -2);
+ $rep->AmountCol(6, 7, $total_allocated, $dec, -2);
+ $rep->NewLine();
+ $rep->TextCol(3, 6, $doc_Left_To_Allocate, -2);
+ $rep->AmountCol(6, 7, $myrow['Total'] - $total_allocated, $dec, -2);
+ $rep->NewLine();
+ $rep->Font('bold');
+ $rep->TextCol(3, 6, $doc_Total_Payment, - 2);
+ $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2);
+ $words = price_in_words($myrow['Total'], ST_CUSTPAYMENT);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(0, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
+ $rep->Font();
+ $rep->NewLine();
+ $rep->TextCol(6, 7, $doc_Received, - 2);
+ $rep->NewLine();
+ $rep->TextCol(0, 2, $doc_by_Cheque, - 2);
+ $rep->TextCol(2, 4, "______________________________", - 2);
+ $rep->TextCol(4, 5, $doc_Dated, - 2);
+ $rep->TextCol(5, 6, "__________________", - 2);
+ $rep->NewLine(1);
+ $rep->TextCol(0, 2, $doc_Drawn, - 2);
+ $rep->TextCol(2, 4, "______________________________", - 2);
+ $rep->TextCol(4, 5, $doc_Drawn_Branch, - 2);
+ $rep->TextCol(5, 6, "__________________", - 2);
+ $rep->TextCol(6, 7, "__________________");
+ }
+ }
+ if ($email == 0)
+ $rep->End();
+}
+
+?>
\ No newline at end of file
$rep->Font('bold');
$rep->TextCol(3, 6, $doc_TOTAL_PO, - 2);
$rep->TextCol(6, 7, $DisplayTotal, -2);
+ $words = price_in_words($myrow['Total'], ST_PURCHORDER);
+ if ($words != "")
+ {
+ $rep->NewLine(1);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
if ($email == 1)
{
if ($email == 0)
{
- $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize());
+ $rep = new FrontReport(_('REMITTANCE'), "RemittanceBulk", user_pagesize());
$rep->currency = $cur;
$rep->Font();
$rep->Info($params, $cols, null, $aligns);
else
$types = array(ST_BANKPAYMENT, ST_SUPPAYMENT, ST_SUPPCREDIT);
foreach ($types as $j)
- //for ($j = ST_BANKPAYMENT; $j <= ST_SUPPAYMENT; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999))
- //for ($j = $ft; $j <= $tt; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999))
{
$myrow = get_remittance($j, $i);
if (!$myrow)
$rep->Header2($myrow, null, $myrow, $baccount, ST_SUPPAYMENT);
$result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']);
+ $linetype = true;
+ $doctype = ST_SUPPAYMENT;
+ if ($rep->currency != $myrow['curr_code'])
+ {
+ include($path_to_root . "/reporting/includes/doctext2.inc");
+ }
+ else
+ {
+ include($path_to_root . "/reporting/includes/doctext.inc");
+ }
+
$total_allocated = 0;
+ $rep->TextCol(0, 4, $doc_Towards, -2);
+ $rep->NewLine(2);
+
while ($myrow2=db_fetch($result))
{
$rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2);
}
$rep->row = $rep->bottomMargin + (15 * $rep->lineHeight);
- $linetype = true;
- $doctype = ST_SUPPAYMENT;
- if ($rep->currency != $myrow['curr_code'])
- {
- include($path_to_root . "/reporting/includes/doctext2.inc");
- }
- else
- {
- include($path_to_root . "/reporting/includes/doctext.inc");
- }
$rep->TextCol(3, 6, $doc_Total_Allocated, -2);
$rep->AmountCol(6, 7, $total_allocated, $dec, -2);
$rep->Font('bold');
$rep->TextCol(3, 6, $doc_Total_Payment, - 2);
$rep->AmountCol(6, 7, $myrow['Total'], $dec, -2);
+ $words = price_in_words($myrow['Total'], ST_SUPPAYMENT);
+ if ($words != "")
+ {
+ $rep->NewLine(2);
+ $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2);
+ }
$rep->Font();
if ($email == 1)
{
_('Currency Filter') => 'CURRENCY',
_('Email Customers') => 'YES_NO',
_('Comments') => 'TEXTBOX'));
+$reports->addReport(_('Customer'),111,_('&Print Sales Quotations'),
+ array( _('From') => 'QUOTATIONS',
+ _('To') => 'QUOTATIONS',
+ _('Currency Filter') => 'CURRENCY',
+ _('Email Customers') => 'YES_NO',
+ _('Comments') => 'TEXTBOX'));
+$reports->addReport(_('Customer'),112,_('Print Receipts'),
+ array( _('From') => 'RECEIPT',
+ _('To') => 'RECEIPT',
+ _('Currency Filter') => 'CURRENCY',
+ _('Comments') => 'TEXTBOX'));
$reports->addReportClass(_('Supplier'));
$reports->addReport(_('Supplier'),201,_('Supplier &Balances'),
display_notification_centered(_("The customer payment has been successfully entered."));
+ submenu_print(_("&Print This Receipt"), ST_CUSTPAYMENT, $payment_no."-".ST_CUSTPAYMENT, 'prtopt');
+
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");
function prt_link($row)
{
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);
+ return print_document_link($row['trans_no']."-".$row['type'], _("Print"), true, $row['type'], ICON_PRINT);
+ else
+ return print_document_link($row['trans_no']."-".$row['type'], _("Print Receipt"), true, ST_CUSTPAYMENT, ICON_PRINT);
}
function check_overdue($row)
submenu_view(_("&View This Invoice"), ST_SALESINVOICE, $invoice);
- submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice, 'prtopt');
- submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice, null, 1);
+ submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, 'prtopt');
+ submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, null, 1);
set_focus('prtopt');
+
+ $sql = "SELECT trans_type_from, trans_no_from FROM ".TB_PREF."cust_allocations
+ WHERE trans_type_to=".ST_SALESINVOICE." AND trans_no_to=".db_escape($invoice);
+ $result = db_query($sql, "could not retrieve customer allocation");
+ $row = db_fetch($result);
+ if ($row !== false)
+ submenu_print(_("Print &Receipt"), $row['trans_type_from'], $row['trans_no_from']."-".$row['trans_type_from'], 'prtopt');
display_note(get_gl_view_str(ST_SALESINVOICE, $invoice, _("View the GL &Journal Entries for this Invoice")),0, 1);