@extends('layouts.print')

@section('content')
<div class="main-content-wrapper">
    <div class="main-box">
        <div class="main-content">
            <div class="container">
                <div class="page">
                    <div class="row">
                        <div class="report-capital layout-print">
                            <div class="header">
                                <div class="logo">
                                    <img src="{{nsoLogo()}}" alt="" width="200px">
                                </div>
                                <div style="text-align: center;font-family: 'Khmer OS Muol Light'">
                                    <h3>យូ ធី អិល</h3>
                                    <h3>UTrust Land</h3>
                                    <h3>Voucher សក្ខីប័ត្រ</h3>
                                </div>
                                <div class="clear"></div>
                                <div class="border-bottom"></div>
                                <div class="voucher-header">
                                    <div class="voucher-header-title">
                                        <label for="">VOUCHER REF#: {{$data[0]->voucher_ref}}</label>
                                        <label for="">DATE: {{date('d M Y')}}</label>
                                    </div>
                                </div>
                                <div class="voucher-box">
                                    <div class="voucher-box-left">
                                        <div class="voucher-purpose">
                                            <h5>Purpose of the transaction : គោលបំណងនៃប្រតិបត្តិការ</h5>
                                        </div>
                                        <div class="voucher-purpose-detail">
                                            <p>{{$data[0]->journal_des}}</p>
                                        </div>
                                    </div>
                                    <div class="voucher-box-right">
                                        <div class="voucher-type">
                                            <h5 class="voucher-title">Voucher Type : Tick ប្រភេទសក្ខីប័ត្រ</h5>
                                        </div>
                                        <div class="voucher-type-list">
                                            <ul class="voucher-list">
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 1) ? "checked" : "" ?>><span>Cash​ Receipt លុយចូល</span></li>
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 2) ? "checked" : "" ?>><span>Cash Disbursement លុយចេញ</span></li>
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 3) ? "checked" : "" ?>><span>Cash Reimbursement ការទូទាត់ប្រាក់វិញ</span></li>
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 4) ? "checked" : "" ?>><span>Cash Advance បុគ្គលិកយកលុយមុនដើម្បីប្រើប្រាស់</span></li>
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 5) ? "checked" : "" ?>><span>Advance Settlement ការទូទាត់សាច់ប្រាក់ដែលបានយកមុន</span></li>
                                                <li><input type="checkbox" <?php echo ($data[0]->voucher_type == 6) ? "checked" : "" ?>><span>Journal Entry/Adjustment ការកែតម្រូវ</span></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <div >
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th>DATE ថ្ងៃខែឆ្នាំ</th>
                                                <th>DESCRIPTION ឈ្មោះគណនី</th>
                                                <th>REF លេខយោង</th>
                                                <th>ACCOUNT # លេខគណន័យ</th>
                                                <th>DEBIT</th>
                                                <th>CREDIT</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @php
                                            $total_debit_usd = 0;
                                            $total_debit_baht = 0;
                                            $total_credit_usd = 0;
                                            $total_credit_baht = 0;
                                            @endphp
                                            @foreach($data as $key => $list)
                                            <?php
                                            $currency = findCurrency($list->journal_currency);
                                            $currency = $currency?$currency->symbol:'';
                                            if($list->journal_currency==2){
                                                $total_credit_usd += $list->journal_credit;
                                                $total_debit_usd += $list->journal_debit;
                                            }
                                            if($list->journal_currency==3){
                                                $total_credit_baht += $list->journal_credit;
                                                $total_debit_baht += $list->journal_debit;
                                            }
                                            ?>
                                            <tr>
                                                <td>{{$list->journal_paydate}}</td>
                                                <td>{{$list->acc_name}} {{$list->acc_namekh}}</td>
                                                <td>{{$list->journal_invoice}}</td>
                                                <td>{{$list->journal_acccode}}</td>
                                                <td>{{$list->journal_debit}}</td>
                                                <td>{{$list->journal_credit}}</td>
                                            </tr>
                                            @endforeach
                                        </tbody>
                                        <tfoot>
                                            <tr class="no-border">
                                                <td colspan="4" class="no-border footer-text-right">TOTAL</td>
                                                <td class="double-bb footer-text-right">{!!($total_debit_usd?('$'.$total_debit_usd.'<br>'):'').($total_debit_baht?'฿'.$total_debit_baht:'') !!}</td>
                                                <td class="double-bb footer-text-right">{!! ($total_credit_usd?('$'.$total_credit_usd.'<br>'):'').($total_credit_baht?'฿'.$total_credit_baht:'') !!}</td>
                                            </tr>
                                        </tfoot>

                                    </table>
                                    <div class="make-date">
                                        <p>ធ្វើនៅ​ <strong>ភ្នំពេញ</strong> ថ្ងៃទី <strong>{{\Globals::date_khmers(date('d-m-Y'))}}</strong></p>
                                    </div>
                                    <div class="row">
                                        <div class="col-lg-12 col-sm-12 col-xs-12 tt">
                                            <div class="col-lg-4 col-sm-4 col-xs-4">
                                                <p>អ្នកធ្វើបញ្ជី</p>
                                                <p></p>
                                            </div>
                                            <div class="col-lg-4 col-sm-4 col-xs-4">
                                                <p>អ្នកពិនិត្យ</p>
                                                <p>_________________</p>
                                            </div>
                                            <div class="col-lg-4 col-sm-4 col-xs-4">
                                                <p>ឯកភាព</p>
                                                <p></p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    .container {
        width: 420mm !important;
        margin-top: 10px;
    }

    @media print {

        html,
        body {
            width: 450mm !important;
            margin: 0mm 0 0 0 !important;
            background-color: #FFFFFF;
        }

    }

    .voucher-box .voucher-box-left,
    .voucher-box-right {
        -webkit-box-flex: 1;
        -moz-box-flex: 1;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
    }

    .voucher-box {
        display: -webkit-box;
        display: -moz-box;
        display: -webkit-flexbox;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }

    .voucher-box .voucher-box-left .voucher-purpose {
        height: 30px;
    }

    .voucher-box .voucher-box-left .voucher-purpose-detail {
        border: 1px solid #bbb;
        padding: 1em;
        height: calc(100% - 40px);
        border-right: none;
    }

    .voucher-box .voucher-box-right {
        border: 1px solid #bbb;
    }

    .voucher-box .voucher-box-right .voucher-type .voucher-title {
        padding-top: 10px;
        padding-bottom: 10px;
        text-align: center;
        font-weight: bolder;
    }

    .voucher-box .voucher-box-right .voucher-type-list input {
        width: 10%;
    }

    .voucher-box .voucher-box-right .voucher-type-list .voucher-list {
        padding: 0;
    }

    .footer-text-right {
        text-align: right;
        padding-right: 10% !important;
        font-size: 20px !important;
        font-weight: bold !important;
    }

    .no-border {
        border: none !important;
    }

    .double-bb {
        border-bottom-style: double !important;
        border-bottom-width: 3px !important;
    }

    .voucher-header {
        width: 100%;
    }

    .voucher-header .voucher-header-title {
        text-align: right;
        margin-bottom: 20px;
    }
</style>
@endsection