@using PantheonRA.BackOffice.Enums
@model PantheonRA.BackOffice.Models.Reports.JournalPrintData
<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-xs-6">
                <h4>@(Model.CashReg.Date != null ? Loc.JournalNumber : Loc.OpenJournalNumber): @Model.JournalNumber</h4>
                <p style="margin-bottom:0">
                    <span><strong>@Loc.From:</strong> @string.Format("{0:dd.MM.yyyy}", Model.DateFrom)</span><br>
                    <span><strong>@Loc.To:</strong> @string.Format("{0:dd.MM.yyyy}", Model.CashReg.Date)</span><br>
                    <span><strong>@Loc.InvoiceNumber <span style="text-transform:lowercase">@Loc.From</span>:</strong> @Model.InvoiceFrom</span><br>
                    <span><strong>@Loc.InvoiceNumber <span style="text-transform:lowercase">@Loc.To</span>:</strong> @Model.InvoiceTo</span><br>
                    <table>
                        <tr><td><strong>@Loc.InvoiceAmount:</strong></td><td style="padding-left:10px" class="text-right">@string.Format("{0:n2}", Model.CashReg.Value)</td></tr>
                        <tr>
                            <td><strong>@Loc.CashInRegister:</strong></td>
                            <td style="padding-left:10px" class="text-right">
                                @string.Format("{0:n2}", Model.PaymentTypes.Where(x => x.SetOf == "G").Sum(x => x.Price))
                            </td>
                        </tr>
                    </table>
                </p>
            </div>
            <div class="col-xs-6">
                <address>
                    <strong>@Model.CompanyName</strong><br>
                    @Model.CompanyAddress<br>
                    @if (!string.IsNullOrEmpty(Model.CompanyTRR))
                    {
                        @Model.CompanyTRR<br>
                    }
                    @Loc.VAT:&nbsp;@Model.CompanyVAT<br>
                    @Loc.CompanyIdShort:&nbsp;@Model.CompanyID<br>
                    @Loc.CompanyUnitShort:&nbsp;@Model.CompanyUnit<br>
                    @Model.CompanyUnitDescription<br>
                    @Model.CompanyUnitAddress<br>
                </address>
            </div>
        </div>
        <!-- PAYMENT METHOD -->
        @if (Model.PaymentTypes != null)
        {
            <div id="PaymentMethodTable">
                <div class="table-responsive m-t">
                    <table class="table invoice-table">
                        <thead>
                            <tr>
                                <th>@Loc.PaymentMethod</th>
                                <th class="text-right">@Loc.ValueWithTax</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.PaymentTypes)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td class="text-right">@string.Format("{0:n2}", item.Price)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div><!-- /table-responsive -->
                <table class="table invoice-total">
                    <tbody>
                        <tr>
                            <td> </td>
                            <td>@string.Format("{0:n2}", Model.TotalByPayment)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        }

        <!-- OPERATOR -->
        @if (Model.Clerks != null)
        {
            <div id="OperatorTable">
                <div class="table-responsive m-t">
                    <table class="table invoice-table">
                        <thead>
                            <tr>
                                <th>@Loc.Operator</th>
                                <th class="text-right">@Loc.ValueWithTax</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.Clerks)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td class="text-right">@string.Format("{0:n2}", item.Price)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div><!-- /table-responsive -->
                <table class="table invoice-total">
                    <tbody>
                        <tr>
                            <td> </td>
                            <td>@string.Format("{0:n2}", Model.TotalByClerks)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        }

        <!-- PRODUCT -->
        @if (Model.Products != null)
        {
            <div id="ProductTable">
                <div class="table-responsive m-t">
                    <table class="table invoice-table">
                        <thead>
                            <tr>
                                <th width="30%">@Loc.ProductName</th>
                                <th>@Loc.Quantity</th>
                                <th width="30%" class="text-right">@Loc.ValueWithTax</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.Products)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td>@string.Format("{0:n2}", item.Quantity)</td>
                                    <td class="text-right">@string.Format("{0:n2}", item.Price)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div><!-- /table-responsive -->
                <table class="table invoice-total">
                    <tbody>
                        <tr>
                            <td> </td>
                            <td>@string.Format("{0:n2}", Model.TotalByProducts)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        }

        <!-- TAX -->
        @if (Model.Taxes != null)
        {
            <div id="TaxTable">
                <div class="table-responsive m-t">
                    <table class="table invoice-table">
                        <thead>
                            <tr>
                                <th width="30%">@Loc.Tax</th>
                                <th width="20%">@Loc.VATPercent</th>
                                <th width="20%">@Loc.BaseAmountShort</th>
                                <th width="30%" class="text-right">@Loc.Value</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.Taxes)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td>@string.Format("{0:n2}", item.Tax)</td>
                                    <td>@string.Format("{0:n2}", item.TaxBase)</td>
                                    <td class="text-right">@string.Format("{0:n2}", item.TaxValue)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
                <table class="table invoice-total">
                    <tbody>
                        <tr>
                            <td> </td>
                            <td>@string.Format("{0:n2}", Model.Taxes != null ? Model.Taxes.Sum(x => x.TaxValue) : 0)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        }

        <!-- INVOICES -->
        @if (Model.Invoices != null)
        {
            <div id="InvoiceTable">
                <div class="table-responsive m-t">
                    <table class="table invoice-table">
                        <thead>
                            <tr>
                                <th width="30%">@Loc.BillNo</th>
                                <th width="30%" class="text-right">@Loc.Amount</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model.Invoices)
                            {
                                <tr>
                                    <td>@item.Name</td>
                                    <td class="text-right">@string.Format("{0:n2}", item.Price)</td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div><!-- /table-responsive -->
                <table class="table invoice-total">
                    <tbody>
                        <tr>
                            <td> </td>
                            <td>@string.Format("{0:n2}", Model.TotalByInvoices)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        }

        <div class="row">
            <div class="col-sm-12">
                <span><strong>@Loc.TotalCashInRegister: </strong>@string.Format("{0:n2}", Model.PaymentTypes.Where(x => x.SetOf == "G").Sum(x => x.Price))</span>
            </div>
        </div>

        @if (!string.IsNullOrEmpty(Model.Footer))
        {
            <div class="m-t">
                @Model.Footer
            </div>
        }
    </div>
</div>