php js css php js css

Changes

Changes to Page: invoice-template


System
Change
Can't Undo: The change does not exist
373437
Oct 3 11:33pm
System
Deleted page
Can't Undo: The page /admin/commerce/configuration/invoicing/invoice-template/ already exists.
Title:
Invoice Template
Content Additional:

														
													
													
													
												
Accept Child 404:
0
Search Title:

														
													
													
													
												
Search Title Prefix:

														
													
													
													
												
Search Description:

														
													
													
													
												
Search Keywords:

														
													
													
													
												
Search Noindex:
0
Search Nofollow:
0
Search Change Frequency:

														
													
													
													
												
Search Priority:
0.5
Is Invisible:
0
Is Hidden In Navigation:
0
Is Hidden In Sitemap:
0
Security New:
0
Security Ssl:
1
Order:
0
Type Id:
0
Contact Id:
0
Design Id:
-100
Header Functions:

														
													
													
													
												
Header Category:

														
													
													
													
												
Is Domain:
0
Security Contact Mode:

														
													
													
													
												
Security Contact Squeeze Viewlimit:

														
													
													
													
												
Security Heading:

														
													
													
													
												
Security Description:

														
													
													
													
												
Other Fields:

														
													
													
													
												
Id:
/admin/commerce/configuration/invoicing/invoice-template/
Parent Id:
/admin/commerce/configuration/invoicing/
Content:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ss="http://synergy8.com">
<head>
<title></title>
</head>
<body>

<style type="text/css">

@page
{
margin: 0.26in 0.26in 0.26in 0.26in;
}

body
{
font-size: 12pt;
font-family: helvetica, tahoma, verdana, sans-serif;
margin: 0px;
cursor: default;
color: #101010;
}

a
{
color: #101010;
text-decoration: none;
}

a:hover
{
color: #101010;
text-decoration: none;
}

.iconSmall
{
width: 18px;
height: 14px;
}

th
{
background-color: #E7E5D1;
padding-left: 4px;
padding-right: 4px;
}

small
{
font-size: 10pt;
}

img
{
border: 0px;
}

table.bordered
{
border-right: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
}

table.bordered td, table.bordered th
{
border-top: 1px solid #aaaaaa;
border-left: 1px solid #aaaaaa;
}

.boxbordered
{
border: 1px dotted #aaaaaa;
padding: 4px;
}

.boxpadded
{
padding: 4px;
}

#receipts_table td, #sale_items_table td
{
border-bottom: 1px dotted #aaaaaa;
padding-top: 4px;
padding-bottom: 4px;
}

#receipts_table td td, #sale_items_table td td
{
border-bottom: 0px;
padding-top: 0px;
padding-bottom: 0px;
}

#credit_table1 td, #credit_table1 td
{
border-bottom: 1px dotted #aaaaaa;
padding-top: 4px;
padding-bottom: 4px;
}

#credit_table1 td td, #credit_table1 td td
{
border-bottom: 0px;
padding-top: 0px;
padding-bottom: 0px;
}

#credit_table2 td, #credit_table2 td
{
border-bottom: 1px dotted #aaaaaa;
padding-top: 4px;
padding-bottom: 4px;
}

#credit_table2 td td, #credit_table2 td td
{
border-bottom: 0px;
padding-top: 0px;
padding-bottom: 0px;
}
</style>

<div id="invoice_header" class="editableItem">
<div class="boxpadded" style="height: 190px">
<ss:logic:if test="!getInvoiceLogo()">
<div style="height: 25px"></div>
</ss:logic:if>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td valign="top">
<div style="width: 375px">
<ss:logic:if test="getInvoiceLogo()">
<img alt="" src="[? getInvoiceLogo() ?]" />
<br />
<ss:logic:if test="$website['account_company']">
<big><strong>[? $website['account_company'] ?]</strong></big><br />
</ss:logic:if>
<ss:logic:else>
<big><strong>[? $website['account_title'] ?]</strong></big><br />
</ss:logic:else>
</ss:logic:if>
<ss:logic:else>
<ss:logic:if test="$website['account_company']">
<big style="font-size: 18pt"><strong>[? $website['account_company'] ?]</strong></big><br />
</ss:logic:if>
<ss:logic:else>
<big style="font-size: 18pt"><strong>[? $website['account_title'] ?]</strong></big><br />
</ss:logic:else>
</ss:logic:else>

<small>
[? $website['account_address'] ?]<br />
[? $website['account_suburb_city'] ?] [? $website['account_state'] ?] [? $website['account_postcode'] ?], [? \Framework\I18N\Countries::getTitle($website['account_country']) ?]
</small>
</div>
</td>
<td valign="top" style="text-align: right" nowrap="nowrap">

[? renderInvoiceTitle($sale['sale_id']) ?]<br />
Date: [? \Framework\Date::format($sale['sale_datetime'], '%d-%b-%Y') ?]<br />


[? $website['account_company_number_type'] ?]: [? $website['account_company_number'] ?]<br />

<ss:logic:if test="$sale['sale_receipt_status'] == 'paid' &amp;&amp; floatval($sale['sale_total'])">
<div style="float: right">
<ss:logic:if test="$sale['sale_type'] == 'adjustment'">
<img alt="USED" align="right" style="float: right" src="/admin/commerce/sales/used.gif" />
</ss:logic:if>
<ss:logic:else>
<img alt="PAID" align="right" style="float: right" src="/admin/commerce/sales/paid.gif" />
</ss:logic:else>
</div>
</ss:logic:if>
</td>
</tr>
</table>
</div>
</div>

<div class="boxbordered" style="padding-left: 100px;">
<ss:logic:variable as="has_shipping" parsenow="value" value="intval($sale['sale_shipping_method_id']) &amp;&amp; $sale['sale_shipping_method_data']" />
<ss:logic:variable as="invoice_box_width" parsenow="value" value="$has_shipping ? '50' : '100'" />

<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<ss:logic:if test="$has_shipping">
<td valign="top" style="width: 50%">
<ss:logic:variable value="unserialize($sale['sale_shipping_method_data'])" as="shipping" parsenow="value" />
<strong>Ship To: </strong><br />
<ss:logic:if test="$shipping['shipping_contact_type'] == 'Company'">
[? $shipping['shipping_company'] ?]
</ss:logic:if>
<ss:logic:else>
[? $shipping['shipping_first_name'] ?] [? $shipping['shipping_last_name'] ?]
</ss:logic:else>
<br />

[? $shipping['shipping_address'] ?]<br />
[? $shipping['shipping_suburb_city'] ?] [? $shipping['shipping_state'] ?] [? $shipping['shipping_postcode'] ?], [? \Framework\I18N\Countries::getTitle($shipping['shipping_country']) ?]<br />
</td>
</ss:logic:if>

<td valign="top" style="width: [? $invoice_box_width ?]%">
<strong><ss:logic:if test="$sale['sale_type'] == 'adjustment'">To:</ss:logic:if><ss:logic:else>Invoice To:</ss:logic:else></strong><br />
<ss:logic:if test="$sale['contact_type'] == 'Individual'">
[? $sale['contact_first_name'] ?] [? $sale['contact_last_name'] ?]
</ss:logic:if>
<ss:logic:else>
[? $sale['contact_company'] ?]
</ss:logic:else>
<br />
[? $sale['contact_address'] ?]<br />
[? $sale['contact_suburb_city'] ?] [? $sale['contact_state'] ?] [? $sale['contact_postcode'] ?], [? \Framework\I18N\Countries::getTitle($sale['contact_country_id']) ?]<br />
<br style="line-height: 50%" />
<small>
<ss:logic:if test="$sale['contact_phone_home']">Phone: [? $sale['contact_phone_home'] ?]<br /></ss:logic:if>
<ss:logic:if test="$sale['contact_phone_mobile']">Mobile: [? $sale['contact_phone_mobile'] ?]<br /></ss:logic:if>
<ss:logic:if test="$sale['contact_phone_work']">Work: [? $sale['contact_phone_work'] ?]<br /></ss:logic:if>
<ss:logic:if test="$sale['contact_fax']">Fax: [? $sale['contact_fax'] ?]<br /></ss:logic:if>
<ss:logic:if test="$sale['contact_email']">E-mail: <a href="mailto:[? $sale['contact_email'] ?]">[? $sale['contact_email'] ?]</a><br /></ss:logic:if>
</small>
</td>
</tr>
</table>
</div>

<ss:logic:if test="$sale['sale_type'] != 'adjustment'">
<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_details_show_payment_method')">
<td class="boxbordered" valign="top" width="20%">
<strong>Payment Method:</strong><br />
<small>
[? \Components\Commerce\Configuration\PaymentMethods::getColumn($sale['payment_method_id'], 'payment_method_title') ?]<br />
</small>
</td>
</ss:logic:if>
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_details_show_shipping_method')">
<td class="boxbordered" valign="top" width="20%">
<strong>Shipping Method:</strong><br />
<small>
<ss:logic:if test="$sale['sale_shipping_method_id'] == 0">
Over Counter
</ss:logic:if>
<ss:logic:else test="$sale['sale_shipping_method_id'] != null">
[? \Components\Commerce\Configuration\ShippingMethods::getColumn($sale['sale_shipping_method_id'], 'shipping_method_title') ?]<br />
</ss:logic:else>
<ss:logic:else>
Not Required
</ss:logic:else>

<ss:logic:variable value="calculateWeight($sale['sale_id'])" as="weight" parsenow="value" />
<ss:logic:if test="$weight">
Weight: [? formatNumber($weight) ?]g
</ss:logic:if>
</small>
</td>
</ss:logic:if>

<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_details_show_ship_via')">
<td id="invoice_ship_via" class="boxbordered editableItem" valign="top" width="20%">
<strong>Ship via:</strong><br />
<ss:logic:if test="$sale['sale_shipping_company_id']">
<small>[? \Components\Commerce\Configuration\ShippingMethods\Companies::getColumn($sale['sale_shipping_company_id'], 'shipping_company_title') ?]<br />
[? $sale['sale_shipping_consignment_number'] ?]</small>
</ss:logic:if>
&nbsp;
</td>
</ss:logic:if>

<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_details_show_shipping_date')">
<td id="invoice_shipping_date" class="boxbordered editableItem" valign="top" width="20%">
<strong>Shipping Date:</strong><br />
<ss:logic:variable parsenow="value" as="shipping_data" value="unserialize($sale['sale_shipping_method_data'])" />
<small>[? $shipping_data['shipping_date'] ?]</small>
</td>
</ss:logic:if>

<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_details_show_packed_by')">
<td id="invoice_packed_by" class="boxbordered editableItem" valign="top" width="20%">
<strong>Packed by:</strong><br />
&nbsp;
</td>
</ss:logic:if>
</tr>
</table>
</ss:logic:if>


<br />
<ss:logic:if test="$sale['sale_adjustment_reason_class_id']">
<ss:logic:variable as="reason" parsenow="value" value="\Components\Commerce\Sales\Adjustments::reasonsGet($sale['sale_adjustment_reason_class_id'])" />
Adjustment Reason: [? $reason['class_title'] ?]
<br />
</ss:logic:if>

<ss:logic:if test="$sale['sale_type'] != 'adjustment'">
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_header_text')">
<ss:logic:parse text="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_header_text')" parsenow="text" />
</ss:logic:if>
</ss:logic:if>

<br />

<ss:data:table id="sale_items_table" as="saleItem" cellspacing="1" cellpadding="3" classrow="tableRow" datasource="\Components\Commerce\Sales\Items::getAllForSale($sale['sale_id'])">
<ss:data:column heading="Qty" style="white-space: nowrap" width="30" valign="top">
[? $saleItem['sale_item_quantity'] ?] x
</ss:data:column>
<ss:data:column heading="Item">
<ss:logic:if test="$saleItem['sale_item_code']">[? $saleItem['sale_item_code'] ?] - </ss:logic:if>
[? $saleItem['sale_item_title'] ?]

<ss:logic:if test="$saleItem['adjustment_sale_id']">
<small>(Sale [? $saleItem['adjustment_sale_id'] ?])</small>
</ss:logic:if>

<ss:logic:if test="$saleItem['bought_for_contact_id']">
<br />
<small>Ordered For:
<ss:logic:variable as="boughtfor_contact" value="\Components\Customers\Contacts::get($saleItem['bought_for_contact_id'])" parsenow="value" />
[? \Components\Customers\Contacts::renderName($boughtfor_contact) ?]
</small>
</ss:logic:if>

<ss:logic:if test="$saleItem['sale_item_order_options']">
<br />
<ss:data:table as="optionvalue" datasource="unserialize($saleItem['sale_item_order_options'])" width="0" keyas="optionid" hasheadings="false" cellpadding="0" cellspacing="0">
<ss:data:column><small>[? $optionid ?]:</small></ss:data:column>
<ss:data:column width="10" />
<ss:data:column><small>[? is_string($optionvalue) ? $optionvalue : '' ?]</small></ss:data:column>
</ss:data:table>
</ss:logic:if>
<ss:logic:if test="$saleItem['sale_item_description']">
<br />
<small>[? $saleItem['sale_item_description'] ?]</small>
</ss:logic:if>
<ss:data:repeater as="discount" datasource="\Components\Commerce\Sales\Items\Discounts::getAllForSaleItem($saleItem['sale_item_id'])">
<br />
<small>[? \Components\Commerce\Sales\Items\Discounts::render($discount, false) ?]</small>
</ss:data:repeater>
</ss:data:column>
<ss:data:column heading="Per Unit" width="65" align="right" style="white-space: nowrap;" valign="top">
[? formatCurrency($saleItem['sale_item_price'], $sale['sale_currency_id'], null, false) ?]
</ss:data:column>
<ss:data:column heading="Total" width="80" align="right" style="white-space: nowrap;" valign="top">
[? formatCurrency($saleItem['sale_item_quantity'] * $saleItem['sale_item_price'], $sale['sale_currency_id'], null, false) ?]
</ss:data:column>
</ss:data:table>

<table border="0" cellspacing="1" cellpadding="3" width="100%">
<tr>
<td valign="top">
[? $sale['sale_tax_label'] ?]: [? formatCurrency($sale['sale_total_tax'], $sale['sale_currency_id'], null, false) ?] <br />
</td>
<td valign="top" style="text-align: right">
<strong>TOTAL: [? $sale['sale_currency_id'] ?] [? formatCurrency($sale['sale_total'], $sale['sale_currency_id'], false, false) ?]</strong>
</td>
</tr>
</table>

<br /><br />
<div style="border-top: 1px dashed">&nbsp;</div>

<ss:logic:if test="count($receipts)">
<div class="boxpadded"><strong>Receipts:</strong></div>
<ss:data:table id="receipts_table" as="receipt" classrow="tableRow" datasource="$receipts" emptymessage="No related transactions found.">
<ss:data:column heading="Date" width="80" nowrap="nowrap" valign="top" style="white-space: nowrap">
[? date('d M Y', strtotime($receipt['receipt_datetime'])) ?]
</ss:data:column>
<ss:data:column heading="Receipt" nowrap="nowrap" valign="top">
Receipt [? $receipt['receipt_id'] ?]<ss:logic:if test="$receipt['receipt_title']"> - [? $receipt['receipt_title'] ?]</ss:logic:if>
</ss:data:column>
<ss:data:column heading="Method" valign="top">
<small>
[? \Components\Commerce\Configuration\PaymentMethods::getColumn($receipt['payment_method_id'], 'payment_method_title') ?]

<ss:logic:variable as="cc_type" value="\Components\Commerce\Configuration\PaymentMethods\Methods\CreditCard::getReceiptCreditCardType($receipt)" parsenow="value" />
<ss:logic:if test="$cc_type">
&nbsp;([? $cc_type ?])
</ss:logic:if>
</small>
</ss:data:column>

<ss:data:column heading="Transaction" valign="top">

<ss:logic:variable as="receipt_data" value="\Components\Commerce\Sales\Receipts::renderReceiptData($receipt)" parsenow="value" />

<ss:logic:if test="$receipt_data">
<small>[? $receipt_data ?]</small>
</ss:logic:if>
<ss:logic:else>
<small>[? $receipt['receipt_gateway_id'] ?]</small>
</ss:logic:else>

</ss:data:column>

<ss:data:column heading="Amount" width="80" align="right" nowrap="nowrap" valign="top">
<ss:logic:variable value="\Components\Commerce\Sales\Receipts\Allocations::getTotalAllocatedForReceiptToSale($receipt['receipt_id'], $sale['sale_id'])" as="sale_receipt_amount" parsenow="value" />
<ss:logic:if test="$sale_receipt_amount &lt; 0"><span style="color: #ff0000">[? formatCurrency($sale_receipt_amount, $receipt['receipt_currency_id'], false, false) ?]</span></ss:logic:if>
<ss:logic:else>[? formatCurrency($sale_receipt_amount, $receipt['receipt_currency_id'], false, false) ?]</ss:logic:else>
</ss:data:column>
</ss:data:table>
</ss:logic:if>

<ss:logic:variable as="credittaken" value="\Components\Commerce\Sales\CreditAllocations::getAllCreditTaken($sale['sale_id'])" parsenow="value" />
<ss:logic:if test="count($credittaken)">
<div class="boxpadded"><strong>Credit Used:</strong></div>
<ss:data:table id="credit_table1" datasource="$credittaken" as="credit" classrow="tableRow">
<ss:data:column heading="Sale">
[? \Components\Commerce\Sales::renderAdminText($credit['sale_id_spent_credit']) ?]
</ss:data:column>
<ss:data:column heading="Amount" width="80" align="right" nowrap="nowrap" valign="top">
[? formatCurrency($credit['sale_credit_allocation_amount'], $sale['sale_currency_id']) ?]
</ss:data:column>
</ss:data:table>
</ss:logic:if>


<ss:logic:variable as="creditapplied" value="\Components\Commerce\Sales\CreditAllocations::getAllCreditApplied($sale['sale_id'])" parsenow="value" />
<ss:logic:if test="count($creditapplied)">
<div class="boxpadded"><strong>Credit Applied:</strong></div>
<ss:data:table id="credit_table1" datasource="$creditapplied" as="credit" classrow="tableRow">
<ss:data:column heading="Sale">
[? \Components\Commerce\Sales::renderAdminText($credit['sale_id_with_credit']) ?]

<ss:logic:variable as="reason_id" parsenow="value" value="\Components\Commerce\Sales::getColumn($credit['sale_id_with_credit'], 'sale_adjustment_reason_class_id')" />
<ss:logic:if test="$reason_id">
<ss:logic:variable as="reason" parsenow="value" value="\Components\Commerce\Sales\Adjustments::reasonsGet($reason_id)" />
- [? $reason['class_title'] ?]
</ss:logic:if>
</ss:data:column>
<ss:data:column heading="Amount" width="80" align="right" nowrap="nowrap" valign="top">
[? formatCurrency($credit['sale_credit_allocation_amount'], $sale['sale_currency_id']) ?]
</ss:data:column>
</ss:data:table>
</ss:logic:if>

<table border="0" cellspacing="1" cellpadding="3" width="100%">
<tr>
<td valign="top">
<ss:logic:if test="$sale['sale_type'] != 'adjustment'">
<ss:logic:if test="!floatval($sale['sale_receipt_balance'])">Do not pay further on this invoice.</ss:logic:if>
</ss:logic:if>
</td>
<td valign="top" style="text-align: right">
<ss:logic:if test="$sale['sale_receipt_balance'] &lt; 0">
<strong>REMAINING CREDIT: [? $sale['sale_currency_id'] ?] [? formatCurrency(-$sale['sale_receipt_balance'], $sale['sale_currency_id'], false, false) ?]</strong>
</ss:logic:if>
<ss:logic:else>
<strong>REMAINING PAYABLE: [? $sale['sale_currency_id'] ?] [? formatCurrency($sale['sale_receipt_balance'], $sale['sale_currency_id'], false, false) ?]</strong>
</ss:logic:else>
</td>
</tr>
</table>


<br />

<ss:logic:if test="!count($receipts) &amp;&amp; is_numeric($sale['payment_method_id']) &amp;&amp; \Components\Commerce\Configuration\PaymentMethods::getColumn($sale['payment_method_id'], 'payment_method_class')">
<div class="boxpadded">
<ss:logic:parse parsenow="text" text="(\Components\Commerce\Configuration\PaymentMethods::getColumn($sale['payment_method_id'], 'payment_method_class'))::getRequiresPaymentMessage()" />
</div>
</ss:logic:if>

<ss:logic:if test="$sale['sale_comments']">
<div class="boxpadded">
<strong>Comments:</strong><br />
[? $sale['sale_comments'] ?]
</div>
</ss:logic:if>

<ss:logic:if test="$sale['sale_type'] != 'adjustment'">
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_footer_text')">
<div class="boxpadded">
<ss:logic:parse text="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_footer_text')" parsenow="text" />
</div>
</ss:logic:if>
</ss:logic:if>

<table cellspacing="1" cellpadding="3" width="100%" style="margin-top: 16px">
<tr>
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_footer_show_phone')">
<td class="boxbordered" nowrap="nowrap" style="text-align: center; width: 33%">
<small>Phone: [? $website['account_contact_phone'] ?]</small>
</td>
</ss:logic:if>
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_footer_show_website')">
<td class="boxbordered" nowrap="nowrap" style="text-align: center; width: 33%">
<small>Website: www.[? \Components\Settings\Domains::getPrimary() ?] </small>
</td>
</ss:logic:if>
<ss:logic:if test="\Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'invoice_footer_show_email')">
<td class="boxbordered" nowrap="nowrap" style="text-align: center; width: 33%">
<small>Email: [? \Components\Settings\ConfigurationItems::getValue('\Components\Commerce\Sales', 'primary_contact') ?] </small>
</td>
</ss:logic:if>
</tr>
</table>

<ss:logic:if test="$sale['sale_type'] != 'adjustment'">
<ss:data:repeater datasource="\Components\Commerce\Sales::getPDFAdditionalDocuments($sale)" as="document">

<ss:logic:if test="$document">

<ss:data:repeater as="document_variable" datasource="$document['document_variables']">
<ss:logic:variable as="$document_variable['variable_name']" value="$document_variable['variable_value']" parsenow="as,value" />
</ss:data:repeater>

<ss:logic:parse text="$document['document_template']" parsenow="text" />
</ss:logic:if>
</ss:data:repeater>
</ss:logic:if>
</body>
</html>
Php Source:
<?php

// TODO: This causes error on invoice
// if (!\Components\Settings\Administrators::currentIsAdministrator(true))
// {
// die('Access denied');
// }

if (!function_exists('getInvoiceLogo'))
{

function getInvoiceLogo()
{
$arrMedias = \Components\Website\Media::getChildren('/commerce_configuration/');

foreach ($arrMedias as $arrMedia)
{
if (substr($arrMedia['media_name'], 0, -4) == 'invoice_logo')
{
return '/media/commerce_configuration/' . $arrMedia['media_name'];
}
}
return null;
}
}

if (!function_exists('calculateWeight'))
{

function calculateWeight($iSaleId)
{
$arrSaleItems = \Components\Commerce\Sales\Items::getAllForSale($iSaleId);

$iWeight = 0;

foreach ($arrSaleItems as $arrItem)
{
$iG = \Components\Commerce\Products::getColumn($arrItem['product_id'], 'product_shipping_weight_g');
$iWeight += $iG * $arrItem['sale_item_quantity'];
}

return $iWeight;
}
}

if (!function_exists('renderInvoiceTitle'))
{

function renderInvoiceTitle($iSaleId)
{
$arrDefaultTax = \Components\Commerce\Configuration\TaxRates::getDefaultTax();
$arrSale = \Components\Commerce\Sales::get($iSaleId);

if (!$arrSale)
{
return '';
}

$arrShipping = unserialize(@$arrSale['sale_shipping_method_data']);

// International Shipping
$bInternationalShipping = false;
$strShippingCountry = null;
if (isset($arrShipping['shipping_country']) && $arrShipping['shipping_country'])
{
if ($arrDefaultTax['country_id'] !== $arrShipping['shipping_country'])
{
$bInternationalShipping = true;
}
}

// Has Tax
$bHasTax = floatval($arrSale['sale_total_tax']) > 0 ? true : false;

$strTitle = '<span style="font-size: 16pt;';

if ($bInternationalShipping)
{
$strTitle .= 'color: #bb0000;';
}

$strTitle .= '">';

if ($arrSale['sale_type'] == 'adjustment')
{
$strTitle .= 'ADJUSTMENT ';
} else
{
if ($bHasTax)
{
$strTitle .= 'TAX ';
}

$strTitle .= 'INVOICE ';
}

$strTitle .= $arrSale['sale_id'] . '</span>';

if ($bInternationalShipping)
{
$strTitle .= '<br />
<small>INTERNATIONAL SHIPPING</small>';
}

return $strTitle;
}
}

?>