//----------------------------------------------------------------------------------------------------
function get_invoice_range($from, $to)
{
//----------------------------------------------------------------------------------------------------
function get_invoice_range($from, $to)
{
$sql = "SELECT trans.trans_no, trans.reference
FROM ".TB_PREF."debtor_trans trans
LEFT JOIN ".TB_PREF."voided voided ON trans.type=voided.type AND trans.trans_no=voided.id
WHERE trans.type=".ST_SALESINVOICE
." AND ISNULL(voided.id)"
$sql = "SELECT trans.trans_no, trans.reference
FROM ".TB_PREF."debtor_trans trans
LEFT JOIN ".TB_PREF."voided voided ON trans.type=voided.type AND trans.trans_no=voided.id
WHERE trans.type=".ST_SALESINVOICE
." AND ISNULL(voided.id)"
- ." AND trans.reference>=".db_escape(get_reference(ST_SALESINVOICE, $from))
- ." AND trans.reference<=".db_escape(get_reference(ST_SALESINVOICE, $to))
+ ." AND trans.trans_no BETWEEN ".db_escape($from)." AND ".db_escape($to)
." ORDER BY trans.tran_date, trans.$ref";
return db_query($sql, "Cant retrieve invoice range");
." ORDER BY trans.tran_date, trans.$ref";
return db_query($sql, "Cant retrieve invoice range");
if ($email == 0)
$rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation);
if ($email == 0)
$rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation);
$range = get_invoice_range($from, $to);
while($row = db_fetch($range))
{
$range = get_invoice_range($from, $to);
while($row = db_fetch($range))
{
$branch = get_branch($myrow["branch_code"]);
$sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER);
if ($email == 1)
$branch = get_branch($myrow["branch_code"]);
$sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER);
if ($email == 1)
- $rep = new FrontReport("", "", user_pagesize());
- $rep->SetHeaderType('Header2');
+ {
+ $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
+ $rep->title = _('INVOICE');
+ $rep->filename = "Invoice" . $myrow['reference'] . ".pdf";
+ }
$rep->Info($params, $cols, null, $aligns);
$rep->Info($params, $cols, null, $aligns);
- $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], false);
+ $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);
$baccount['payment_service'] = $pay_service;
$rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
$baccount['payment_service'] = $pay_service;
$rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
$rep->TextColLines($c++, $c, $myrow2['StockDescription'], -2);
$newrow = $rep->row;
$rep->row = $oldrow;
$rep->TextColLines($c++, $c, $myrow2['StockDescription'], -2);
$newrow = $rep->row;
$rep->row = $oldrow;
{
$rep->TextCol($c++, $c, $DisplayQty, -2);
$rep->TextCol($c++, $c, $myrow2['units'], -2);
{
$rep->TextCol($c++, $c, $DisplayQty, -2);
$rep->TextCol($c++, $c, $myrow2['units'], -2);
- $rep->TextColLines(1, 5, $memo, -2);
+ $rep->TextColLines(1, 3, $memo, -2);
// set to start of summary line:
$rep->row = $summary_start_row;
if (isset($prepayments))
{
// Partial invoices table
// set to start of summary line:
$rep->row = $summary_start_row;
if (isset($prepayments))
{
// Partial invoices table
- $rep->NewLine();
- $rep->TextCol(1, 4,_("Prepayments invoiced to this order up to day:"));
- $rep->TextCol(1, 4, str_pad('', 150, '_'));
- $rep->cols[3] -= 20;
- $rep->aligns[3] = 'right';
- $rep->NewLine(); $c = 1; $tot_pym=0;
- $rep->TextCol(1, 4, str_pad('', 150, '_'));
+ $rep->TextCol(0, 3,_("Prepayments invoiced to this order up to day:"));
+ $rep->TextCol(0, 3, str_pad('', 150, '_'));
+ $rep->cols[2] -= 20;
+ $rep->aligns[2] = 'right';
+ $rep->NewLine(); $c = 0; $tot_pym=0;
+ $rep->TextCol(0, 3, str_pad('', 150, '_'));
$rep->TextCol($c++, $c, _("Date"));
$rep->TextCol($c++, $c, _("Invoice reference"));
$rep->TextCol($c++, $c, _("Amount"));
$rep->TextCol($c++, $c, _("Date"));
$rep->TextCol($c++, $c, _("Invoice reference"));
$rep->TextCol($c++, $c, _("Amount"));
$rep->TextCol($c++, $c, sql2date($invoice['tran_date']));
$rep->TextCol($c++, $c, $invoice['reference']);
$rep->TextCol($c++, $c, number_format2($invoice['prep_amount'], $dec));
}
if ($invoice['reference']==$myrow['reference']) break;
}
$rep->TextCol($c++, $c, sql2date($invoice['tran_date']));
$rep->TextCol($c++, $c, $invoice['reference']);
$rep->TextCol($c++, $c, number_format2($invoice['prep_amount'], $dec));
}
if ($invoice['reference']==$myrow['reference']) break;
}
- $rep->TextCol(1, 4, str_pad('', 150, '_'));
+ $rep->TextCol(0, 3, str_pad('', 150, '_'));
- $rep->TextCol(2, 3, _("Total payments:"));
- $rep->TextCol(3, 4, number_format2($tot_pym, $dec));
+ $rep->TextCol(1, 2, _("Total payments:"));
+ $rep->TextCol(2, 3, number_format2($tot_pym, $dec));
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
$rep->TextCol(3, 6, _("Sub-total"), -2);
$rep->TextCol(6, 7, $DisplaySubTot, -2);
$rep->NewLine();
- $rep->TextCol(3, 6, _("Shipping"), -2);
- $rep->TextCol(6, 7, $DisplayFreight, -2);
- $rep->NewLine();
- $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i);
+ if ($myrow['ov_freight'] != 0.0)
+ {
+ $DisplayFreight = number_format2($sign*$myrow["ov_freight"],$dec);
+ $rep->TextCol(3, 6, _("Shipping"), -2);
+ $rep->TextCol(6, 7, $DisplayFreight, -2);
+ $rep->NewLine();
+ }
+ $tax_items = get_trans_tax_details(ST_SALESINVOICE, $row['trans_no']);
$tax_type_name = $tax_item['tax_type_name'];
else
$tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) ";
if ($myrow['tax_included'])
{
$tax_type_name = $tax_item['tax_type_name'];
else
$tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) ";
if ($myrow['tax_included'])
{
- $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2);
+ $rep->TextCol(3, 6, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2);