Raport w trakcie budowy - Michał Zieliński<br>
<form action="index.php?module=EcmInvoiceOuts&action=Report_INTRASTAT" method="POST">
    <div id="report_settings" class="edit view search basic" style="width: 97vw;">
        <table cellspacing="0" cellpadding="0" style="width: 100%">
            <tbody> 
                <tr>
                    <td>
                    <input type="number" size="4" maxlength="4" value="{$year}" name="year"/>
                    <input type="number" size="2" maxlength="2" value="{$month}" name="month"/>
                    <input type="hidden" name="process" value="1"/>
                    <input class="button" type="submit" value="Generuj"/>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</form>
{if $process}
    <form action="index.php?module=EcmInvoiceOuts&action=Report_INTRASTAT" method="POST">
        <input type="hidden" name="xml" value="1"/>
        <input type="hidden" value="{$year}" name="xml_year"/>
        <input type="hidden" value="{$month}" name="xml_month"/>
        <input class="button" type="submit" value="XML"/>
    </form>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.24/datatables.min.css" />
    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.24/datatables.min.js"></script>
    <script>
        {literal}
            $(document).ready(function() {
                $('#report').DataTable({
                    lengthMenu: [
                        [50, 100, 200, 500, -1],
                        [50, 100, 200, 500, "Wszystkie"]
                    ],
                    pageLength: 200,
                    language: {
                        url: 'https://cdn.datatables.net/plug-ins/1.10.24/i18n/Polish.json'
                    },
                    scrollX: true,
                    scrollY: "60vh",
                    scrollCollapse: true,
                    order: [[ 0, "asc" ]],
                    columnDefs: [
                        { targets: [3,4,5,6,7, 8], className: 'dt-right'}
                    ]
                });
                $('#products').DataTable({
                    pageLength: 200,
                    language: {
                        url: 'https://cdn.datatables.net/plug-ins/1.10.24/i18n/Polish.json'
                    },
                    columnDefs: [
                        { targets: [2,3], className: 'dt-right'}
                    ],
                    lengthMenu: [
                        [50, 100, 200, 500, -1],
                        [50, 100, 200, 500, "Wszystkie"]
                    ],
                    scrollX: true,
                    scrollY: "60vh",
                    scrollCollapse: true,
                    order: [[ 0, "asc" ]],
                });
            });
        {/literal}
    </script>
    <style>
        {literal}
            div.dataTables_wrapper {
                width: 95vw;
                max-height: 50vw;
                margin: 0 auto;
            }
        {/literal}
    </style>
        Raport wygenerowany na podstawie dokumentów: 
        {foreach from=$invoices item="item"}
            <a target="new" href="index.php?module=EcmInvoiceOuts&action=DetailView&record={$item.id}">{$item.document_no}</a>&nbsp;
        {/foreach}
    <br><br>
    <table id="report" class="display nowrap hover" style="width:100%">
        <thead>
            <tr>
                <th>Numer pozycji</th>
                <th>Kod towarowy</th>
                <th>Opis towaru</th>
                <th>Rodzaj transakcji</th>
                <th>Kraj przeznaczenia</th>
                <th>Identyfikator kontrahenta zagranicznego</th>
                <th>Wartość fakturowa PLN</th>
                <th>Waga brutto</th>
                <th>Ilość intrastat</th>
            </tr>
        </thead>
        <tbody>
            {foreach from=$data item="item"}
                <tr>
                    <td>{$item.position}</td>
                    <td>{$item.pkwiu}</td>
                    <td>{$item.description|truncate:75}</td>
                    <td>11</td>
                    <td>{$item.country}</td>
                    <td>{$item.nip}</td>
                    <td>{$item.total}</td>
                    <td>{$item.weight}</td>
                    <td>{if $item.qty_intrastat > 0}{$item.qty_intrastat}{/if}</td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    {if $badProducts|@count>0}
        <hr>
        <h3>Niepoprawnie uzupełnione produkty</h3><br>
        <table id="products" class="display nowrap hover" style="width:100%">
        <thead>
            <tr>
                <th>Kod</th>
                <th>Nazwa</th>
                <th>PKWiU</th>
                <th>Waga brutto</th>
            </tr>
        </thead>
        <tbody>
            {foreach from=$badProducts item="item"}
                <tr>
                    <td>
                        <a target="new" href="index.php?module=EcmProducts&action=DetailView&record={$item.id}">{$item.code}</a>
                    </td>
                    <td>{$item.name}</td>
                    <td>{$item.pkwiu}</td>
                    <td>{$item.weight}</td>
                </tr>
            {/foreach}
        </tbody>
    </table>
    {/if}
{/if}