To add a new printed form, click on the button of the same name in the "Printed forms" section.
The "New printed form" window appears with two tabs: "Main" and "Template".
In the "Template" tab you can configure the template of the printed form in the Twig-templates format.
Let's consider how to with a template, using the example of an invoice.
Code of invoice template
<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 3.2//EN">
<html>
<style>
body
{
font-family:"Arial", sans-serif;
font-size: 10pt;
}
p
{
line-height: 150%;
}
table.footer
{
To add a new printed form, click on the button of the same name in the "Printed forms" section.
The "New printed form" window appears with two tabs: "Main" and "Template".
In the "Template" tab you can configure the template of the printed form in the Twig-templates format.
Let's consider how to work with a template, using the example of an invoice.
Invoice template code
<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 3.2//EN">
<html>
<style>
body
{
font-family:"Arial", sans-serif;
font-size: 10pt;
}
p
{
line-height: 150%;
}
table.footer
{
font-size: 10pt;
margin-top: 15px;
line-height: 150%;
}
table.order
{
border-collapse: collapse;
}
table.order td
{
font-size: 10pt;
border: 1px solid #000000;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title langs="ru">Invoice</title>
</head>
<body bgcolor="white" lang="RU">
<div class="Section1">
<h1> Invoice # {{order.number}} from {{order.createdAt | date ("d.m.Y")}} </h1>
<p>
Seller: {{order.site.legalEntity}} <br>
Address: {{order.site.address}} <br>
TIN: {{order.site.inn}} <br>
Shipper and his address: {{order.site.legalEntity}} {{order.site.address}} <br>
Consignee and his address: {{order.customer.nickName}} {{order.deliveryAddress}} <br>
To payment and settlement document No. {{order.number}} from {{order.createdAt | date ("d.m.Y")}} <br>
Buyer: {{order.customer.nickName}} <br>
Address: {{order.customer.address}} <br>
Currency: name, code {{defaultCurrency}} <br>
</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%" class="order">
<tr>
<td rowspan=2 align="center" valign = middle> Product name (description of work performed, services rendered), property rights </td>
<td rowspan = 2 align = "center" valign = middle> Units of measurement </td>
<td rowspan = 2 align = "center" valign = middle> Quantity/volume </td>
<td rowspan = 2 align = "center" valign = middle> Price (tariff) per unit of measurement </td>
<td rowspan = 2 align = "center" valign = middle> Cost of products (works, services), property rights, excluding tax - total </td>
<td rowspan = 2 align = "center" valign = middle> Including the sum of excise tax </td>
<td rowspan = 2 align = "center" valign = middle> Tax rate </td>
<td rowspan = 2 align = "center" valign = middle> Buyer's tax amount </td>
<td rowspan = 2 align = "center" valign = middle> Cost of products (works, services), property rights with tax - total </td>
<td colspan = 2 align = "center" valign = middle> Country of origin of the product </td>
<td rowspan = 2 align = "center" valign = middle> Customs declaration number </td>
</tr>
<tr>
<td align = "left"> Code </td>
<td align = "left"> Symbol (national) </td>
<td align = "left"> Numerical code </td>
<td align = "left"> Short name </td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>2а</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>10а</td>
<td>11</td>
</tr>
{% for op in order.availableOrderProducts %}
<tr valign="top">
<td>
{{ op }}
</td>
<td>
</td>
<td>
</td>
<td>
{{ op.quantity }}
</td>
<td>
{{ op.price }}
</td>
<td>
{{ op.summ }}
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
{{ op.summ }}
</td>
<td>
</td>
<td>
{{ op.offer.product.manufacturer }}
</td>
<td>
</td>
</tr>
{% endfor %}
<tr valign="top">
<td colspan="5">
<h3>Total to payment:</h3>
</td>
<td>
{{ order.summ }}
</td>
<td colspan="2">
X
</td>
<td>
</td>
<td>
{{ order.totalSumm }}
</td>
<td colspan="3">
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" class="footer">
<tr>
<td width="20%">
Head of the organization:
</td>
<td width="80%">
_______________________ / ______________________________ /
</td>
</tr>
<tr>
<td width="20%">
Ch. accountant:
</td>
<td width="80%">
_______________________ / ______________________________ /
</td>
</tr>
</table>
</div>
</body>
</html>
Explanations for the code
Available variables: when choosing the "Order" template type - the variable order
(order), or in the case of the template type "List of orders" - the variable orders
(array of orders). Also available is the variable defaultCurrency
- the current currency.
The twig code Invoice №{{ order.number }} from {{ order.createdAt|date("d.m.Y") }}
generates the following html: <h1>Invoice No123654 from 22.11.2019</h1>
.
order
- the entity of the order, it has the field number
- this is the order number, using {{ }}
we display the value of the field number
for printing.
The order also has the field createdAt
indicating the date of creation. The system does not know in what form the date should be printed, therefore, using a filter, specify the date format: order.createdAt|date("d.m.Y")
. The format here is: day.month.year.
Twig-code Seller: {{ order.site.legalEntity }}
as a result forms html Seller: Online store Кроссовки.рф
. order
has the field site
which is the entity of the store. The store has a field legalEntity
that indicates the official name of the store.
Currency: name, code {{defaultCurrency}}
- the result is Currency: name, code Russian ruble
. The current currency is displayed in the administrative section, in the "Settings" section.
<table border="0" cellspacing="0" cellpadding="2" width="100%" class="order">
{% for op in order.availableOrderProducts %}
<tr valign="top">
...
<td>
{{ op.summ }}
</td>
...
</tr>
{% endfor %}
</table>
Above is a standard way of building a table, in which a loop displays a list of rows, each of which in this case is one product item in the order.
<table border="0" cellspacing="0" cellpadding="2" width="100%" class="order">
<tr valign="top">
...
<td>
123,0
</td>
...
</tr>
<tr valign="top">
...
<td>
743,0
</td>
...
</tr>
<tr valign="top">
...
<td>
8583,0
</td>
...
</tr>
...
</table>
{{ op.offer.product.manufacturer }}
- from the order item (op) we get the trade offer that was added to the order, then we get the related product to which the trade offer belongs and we find out the manufacturer of the product.
As a result, we get the following invoice form: