<html>
<head>
    <meta charset="utf-8">

    <style>
        .receipt {
            font-family: Arial;
            font-size: 17px;
            width: 90mm;
            font-smooth: never;
            -webkit-font-smoothing: none;
        }

        .print-header {
            margin-bottom: 10px;
            margin-top: 10px;
        }

        .price {
            text-align: right;
        }

        .item-row {
            margin-bottom: 5px;
        }

        .item-row div {
            line-height: initial;
        }

        table {
            width: 100%;
            font-size: 17px;
        }

        table th {
            text-align: right;
            float: left;
            font-weight: normal;
            margin-bottom: 3px;
        }

        table tr {
            padding-bottom: 5px;
        }

        .vat {
            padding-left: 20px;
        }

        .item-top {
            margin-top: 10px;
        }

        .text-right {
            text-align: right;
        }

        @media print {
            @page {
                font-family: Arial;
                margin: 10mm 9mm 0mm 4mm !important;
                padding: 0;
                width: 80mm;
                font-smooth: never;
                -webkit-font-smoothing: none;
            }
        }
    </style>

</head>
<body>
<div class="receipt" id="receipt">

    <div class="seller-info">
        <div style="text-align: center;">
            {$dbcfg.shop_title} <br/>
            {$dbcfg.shop_address} <br/>
            IČ: {$dbcfg.shop_ico}, DIČ: {$dbcfg.shop_dic}<br/>
        </div>
    </div>

    <div class="print-header">
        <div style="text-align: center">
            {'treasury_receipt'|translate:'NewPOSClosure':false:false}
        </div>
        <div style="text-align: center">
            {'pos'|translate:'NewPOSClosure':false:false} <strong>{$admin_name}</strong>
        </div>
        <div style="text-align: center">
            {'date_and_time'|translate:'NewPOSClosure':false:false}: <strong>{$now_time|date_format:"d.m.Y H:i:s"}</strong>
        </div>
    </div>

    <hr width="90%">
        <table>
            {foreach $stats as $payment_id => $payment}
                {if is_array($payment)}
                    <tr>
                        <th class="item-top">{Pos::getMethodDescr($payment_id)}</th>
                    </tr>
                    {foreach $payment as $vat => $payment_vat}
                        <tr>
                            <th class="vat">{'total_with_vat'|translate:'NewPOSClosure':false:false} {$vat}%</th>
                            <td class="text-right">{$payment_vat|format_price:'ceil=false'}</td>
                        </tr>
                        <tr>
                            <th class="vat">{'vat'|translate:'NewPOSClosure':false:false} {$vat}%</th>
                            <td class="text-right">{$payment_vat->div(toDecimal(100 + $vat))->mul(toDecimal($vat))|format_price:'ceil=false'}</td>
                        </tr>
                    {/foreach}
                {else}
                    <tr>
                        <th class="item-top">{Pos::getMethodDescr($payment_id)}</th>
                        <td class="text-right">{$payment|format_price:'ceil=false'}</td>
                    </tr>
                {/if}
            {/foreach}

           {ifmodule SKEET}
              <tr>
                 <th class="item-top">{'paid_of_the_invoice'|translate:'NewPOSClosure':false:false}</th>
              </tr>
              <tr>
                 <th class="vat">{'paid_of_the_invoice_cash'|translate:'NewPOSClosure':false:false}</th>
                 <td class="text-right">{$paid_by_the_invoice_cash|format_price:'ceil=false'}</td>
              </tr>
              <tr>
                 <th class="vat">{'paid_of_the_invoice_card'|translate:'NewPOSClosure':false:false}</th>
                 <td class="text-right">{$paid_by_the_invoice_card|format_price:'ceil=false'}</td>
              </tr>
              <tr>
                 <th class="vat">{'paid_of_the_invoice_total'|translate:'NewPOSClosure':false:false}</th>
                 <td class="text-right">{($paid_by_the_invoice_card->add($paid_by_the_invoice_cash))|format_price:'ceil=false'}</td>
              </tr>
           {/ifmodule}

            <tr>
                <th class="item-top">{'rounding'|translate:'NewPOSClosure':false:false}</th>
                <td class="text-right">{$roundings|format_price:'ceil=false'}</td>
            </tr>

            <tr>
                <th class="item-top">{'discounts'|translate:'NewPOSClosure':false:false}</th>
                <td class="text-right">{$discounts|format_price:'ceil=false'}</td>
            </tr>

            <tr>
                <th class="item-top">{'sales'|translate:'NewPOSClosure':false:false}</th>
                <td class="text-right">{$today_sales|format_price:'ceil=false'}</td>
            </tr>

            <tr>
                <th class="item-top">{'actually_in_pos'|translate:'NewPOSClosure':false:false}</th>
                <td class="text-right">{$actually_in_pos|format_price:'ceil=false'}</td>
            </tr>
        </table>

    {if $smarty.get.now}
        <script>
            $(window).on('load', function() {
                window.print();
                var isChrome = !!window.chrome;
                if (!isChrome)
                    window.close();
            });
        </script>
    {/if}
</div>
</body>
</html>
