retailCRM Documentation

Templates of printed forms

Settings of printed form

Printed form is being configured by two actions:

Main settings of printed form

Main settings:

Note: you can also save and immediately go out of form template using «Save and go back» button

Creation of template of printed form for one order

For creation of new printed form you should click «Add» button in «Settings» section of Administration:

You will see the window «New printed form» with «Main» and «Template» tabs.

On the «Template» tab you can configure the template of printed form using twig-templates.

Let`s see the working with template on example of tax invoice.

Tax 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">Tax invoice</title>
    </head>
    <body bgcolor="white" lang="RU">


        <div class="Section1">

            <h1>Tax invoice №{{ order.number }} of {{ order.createdAt|date("d.m.Y") }}</h1>
            <p>
                Seller: {{ order.site.contragent.legalName }}<br>
                Address: {{ order.site.address }}<br>
                TIN: {{ order.site.contragent.inn }}<br>
                Consignor and his address: {{ order.site.contragent.legalName }} {{ order.site.address }}<br>
                Consignee and his address: {{ order.nickName }} {{ order.deliveryAddress }}<br>
                WAYBILL/CMR/Bill of lading №{{ order.number }} of {{ order.createdAt|date("d.m.Y") }} <br>
                Customer: {{ order.nickName }}<br>
                Address: {{ order.customer.address }}<br>
                Currency: name, code {{
                    crm_settings_get('default_currency', true) ~ ' ' ~ crm_settings_get('default_currency')
                }}<br>
            </p>

            <table border="0" cellspacing="0" cellpadding="2" width="100%" class="order">
                <TR>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Full description of goods/TD>
                    <TD COLSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Unit value</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Quantity</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Price for unit</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Total value w/o VAT</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Including excise</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Tax rate</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Tax amount for the customer</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Total value with VAT</TD>
                    <TD COLSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Country of origin</TD>
                    <TD ROWSPAN=2 ALIGN="CENTER" VALIGN=MIDDLE>Customs Commodity Code</TD>
                </TR>
                <TR>
                        <TD ALIGN="LEFT">Code</TD>
                        <TD ALIGN="LEFT">Symbol (national)</TD>
                        <TD ALIGN="LEFT">Numeric 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 >
                            &nbsp;
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            {{ op.quantity }}
                        </td>
                        <td >
                            {{ op.price }}
                        </td>
                        <td >
                            {{ op.summ }}
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            {{ op.summ }}
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            {{ op.offer.product.manufacturer }}
                        </td>
                        <td >
                            &nbsp;
                        </td>
                    </tr>
                {% endfor %}

                <tr valign="top">
                        <td colspan="5">
                            <h3>Total to pay:</h3>
                        </td>

                        <td >
                            {{ order.summ }}
                        </td>
                        <td colspan="2">
                            X
                        </td>
                        <td >
                            &nbsp;
                        </td>
                        <td >
                            {{ order.totalSumm }}
                        </td>
                        <td colspan="3">
                            &nbsp;
                        </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%">
                        Chief accountant:
                    </td>
                    <td width="80%">
                        _______________________ / ______________________________ /
                    </td>
                </tr>
            </table>
        </div>
    </body>
</html>

Code explanation

Allowed variables: in case of «Order» template type it is order or in case of «Order list» type it is orders (orders array). Also there is a defaultCurrency variable allowed (current currency).

Twig-code <h1>Tax invoice №{{ order.number }} from {{ order.createdAt|date("d.m.Y") }}</h1> as a result will generate the following html: <h1>Tax invoice №123654 from 22.11.2013</h1>.

order is the order entity, it has number field; using {{ }} we can display the value of number field for printing.

Also the order has createdAt, field, meaning the creation date of order. The system doesn't know the format of date printing, so it is necessary to specify the date format using filter: order.createdAt|date("d.m.Y"). Now the format is date.month.year.

Twig-code Seller: {{ order.site.legalEntity }}<br> as a result will generate the following html Seller: Online-store Demo-store.com<br>. Order has the site field, which is the store entity. The store has the legalEntity field, which means the official name of store.

Currency: name, code {{ defaultCurrency }}<br> as a result will generate the Currency: name, code US dollar USD<br>. Default currency is set in «Settings» of Administration 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 there is a standard table, with the list of rows in cycle, which are the items in 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 }} - we get the offer, which was added in order, from item (op), then we get the product, related to this offer, and get the product manufacturer.

As a result we get the following tax invoice:

Example of image insertion into document template

If it is necessary to insert image of organization logotype or stamp into the document template, you should specify the path to image file: url('data:image/jpg;base64,<image_code_here>')

To generate the image code, you can use the special Base64 service.

For example, to encode the image file, you need to upload the image. Then click the «show code» button and you will see the result.

In the template code this insertion of image code will look as follows:

Creation of template for order list

To create the template of printed form for order list, it is necessary to select «Order list» in «Template type» field when creating the template.

Further, all settings are the same as other printed form for order.

For printing the template of form for group of orders, you should go to «Orders» section and mark by tick necessary orders. Then you should select «Print documents» in «Actions» menu and choose the created template of printed form.

Note: when printing, the .PDF file is created, which is being uploaded to your computer


PrintEditHistory
Page last modified on June 13, 2018, at 10:16 AM