<style>
    p {
        margin: 0;
    }

    .btop2 {
        border-top: 2px solid #000;
    }

    .btop1 {
        border-top: 1px solid #000;
    }

    .tright {
        text-align: right;
    }

    .mt15 {
        margin-top: 15px;
    }

    .bold {
        font-weight: bolder;
    }

    .address span,
    .address p,
    .address div,
    .address li,
    .address u,
    .address b {
        font-weight: normal !important;
    }

    .sendInvoice {
        background: green;
        border: 1px solid #000;
        box-shadow: 0 0 1px 1px #ddd;
        padding: 5px 15px;
        color: #fff;
        border-radius: 2px;
        cursor: pointer;
        float: right;
    }

    .invoicewrapper {
        width: 750px;
        height: 1000px;
        padding: 25px;
        margin: 0 auto;
        background: #fff;
        font-family: 'Roboto', sans-serif;
        position: relative;
        border: 1px solid #ddd;
        margin-bottom: 10px;
        margin-top: 10px;
    }

    .paymnettable {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid #ddd;
        padding: 2px;
    }

    .paymnettable tr,
    .paymnettable td,
    .paymnettable th {
        border: 1px solid #ddd;
        padding: 5px;
    }

    .paymnettable th {
        background: #ddd;
    }

    .notpaid {
        font-size: 50px;
        position: absolute;
        opacity: .5;
        font-weight: bold;
        top: 20%;
        left: 50%;
        width: 200px;
        margin-left: -100px;
        color: red;
        border-bottom: 1px solid red;
        text-align: center;
    }

    .paid {
        font-size: 50px;
        position: absolute;
        opacity: .5;
        font-weight: bold;
        top: 20%;
        left: 50%;
        width: 200px;
        margin-left: -100px;
        color: green;
        border-bottom: 1px solid green;
        text-align: center;
    }

    .row:after {
        content: "";
        display: table;
        clear: both;
    }

    th {
        text-align: left;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }

    .shopname {
        text-align: center;
    }

    .footerInfo {
        text-align: center;
    }

    .footerInfo2 {
        text-align: left;
    }

    hr.new2 {
        border-top: 1px dashed red;
    }
</style>

<style>
    .printInvoice {
        background: green;
        border: 1px solid #000;
        box-shadow: 0 0 1px 1px #ddd;
        padding: 5px 15px;
        color: #fff;
        border-radius: 2px;
        cursor: pointer;
        float: right;
        margin-right: 2px;
    }

    .footer {
        position: fixed;
        bottom: 0;
        width: 100%;
        background: white;
    }

    @media print {

        html,
        body {}

        thead th {
            font-size: 20 !important;
            border: 5px solid #ddd;
        }

        button {
            visibility: hidden;
        }

        table,
        tr,
        thead th,
        td {
            padding: 5px !important;
            border: none;
            border-collapse: collapse;
        }

        .center {
            text-align: center;
            vertical-align: middle;
        }

        .bigfont {
            font-size: 150px;
        }

        .midiumfont {
            font-size: 50px;
        }

        .smallfont {
            font-size: 40px;
        }

        .verysmallfont {
            font-size: 30px;
        }

        .bold {
            font-weight: bold;
        }

        hr {
            display: block;
            height: 5px;
            background: transparent;
            width: 100%;
            border: none;
            border-top: solid 1px #aaa;
        }
    }
</style>

<div class="invoicewrapper">
    <section class="invoice" style="position: relative">
        <button class="btn btn-danger btn-sm invoiceClose">X</button>
        <button data-id="{{ $billpayment->clients->id }}" class="btn btn-danger btn-sm sendInvoice"><i
                class="fa fa-envelope"></i> Send</button>

        <button type="button" onclick="window.print()" class="btn btn-danger btn-sm printInvoice">Print
            <i class="fa fa-print"></i>
        </button>
        <table>
            <tr>
                <td>
                    <div style="margin-top:100px;">
                        <address>
                            Name : {{ $billpayment->clientsinfo->clients_name }}<br>
                            Mobile : {{ $billpayment->clientsinfo->contact_no ?? '' }}<br>
                            Username: <strong>{{ $billpayment->clients->userid }}</strong><br>
                            CID: <strong>{{ $billpayment->clients->id }}</strong> Password:
                            <strong>{{ $billpayment->clients->password }}</strong> <br>
                            Expire Date: {{ date('d-M-Y', strtotime($billpayment->clients->expire_date ?? '')) }}
                        </address>
                    </div>
                </td>
                <td class="tright">
                    <h3 class="page-header shopname" style="text-align:right;">
                        @if ($company_info->img_url)
                            <img src="{{ asset('storage/company/' . $company_info->img_url) }}" alt="logo"
                                width="200"><br>
                        @endif
                        {{ $company_info->name ?? '' }}
                    </h3>
                    <div class="address" style="text-align:right">{!! $company_info->address ?? '' !!}</div>
                    <h4 class="tright">
                        Date : {{ $billpayment->created_at->format('d-M-Y') }}
                    </h4>
                </td>
            </tr>
        </table>
        <div>
        </div>
        <hr size="2" color="black" style="width:100%;text-align:left;margin-left:0">
        <div>
            <div>
                <table>
                    <tr>
                        <td colspan="2">
                            <h2>Invoice No: {{ $billpayment->money_receipt_number ?? '' }}</h2>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <hr size="2" color="black" style="width:100%;text-align:left;margin-left:0">
        <table>
            <thead>
                <tr>
                    <th>Type</th>
                    <th>Description</th>
                    <th>Entry By</th>
                    <th>Collect By</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>{{ $billpayment->income->name ?? '' }}</td>
                    <td>{{ $billpayment->description }}</td>
                    <td>
                        <span class="badge badge-success">
                        </span>{{ $billpayment->user->name ?? 'Online Payment' }}
                    </td>
                    <td>
                        <span class="badge badge-success"></span>{{ $billpayment->employee->name ?? '' }}
                    </td>
                </tr>

                <tr style="border-top:1px solid #999">
                    <td colspan="3"></td>
                </tr>
                <tr>
                    <td colspan="3" class="tright">Paid</td>
                    <td class="tright">{{ $billpayment->paid_amount }}</td>
                </tr>
                <tr>
                    <td colspan="3" class="tright">Discount</td>
                    <td class="tright">{{ $billpayment->discount_amount }}</td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td class="tright btop2 bold">Total Paid</td>
                    <td class="tright btop2 bold">
                        {{ number_format($billpayment->paid_amount + $billpayment->discount_amount, 2) }}</td>
                </tr>

                {{-- @if ($billpayment->clients->customerAccount->dueAmount ?? '' < 0)
                    <tr>
                        <td></td>
                        <td class="tright btop2 bold">Advanced Balance</td>
                        <td class="tright btop2 bold">
                            {{ abs($billpayment->clients->customerAccount->dueAmount ?? '') }}</td>
                    </tr>
                @else
                    <tr>
                        <td></td>
                        <td class="tright btop2 bold">Balance Due</td>
                        <td class="tright btop2 bold">{{ $billpayment->clients->customerAccount->dueAmount ?? '' }}
                        </td>
                    </tr>
                @endif --}}
            </tbody>
        </table>

        @if ($company_info->invoice_terms)
            <div style="margin-top:50px;"><strong>Terms:</strong><br>
                {!! $company_info->invoice_terms !!} </div>
        @endif
        <div class="footer">
            <h6 class="footerInfo2">System Developed By YetFix Limited.</h6>
        </div>
    </section>
</div>
<script type="text/javascript">
    window.onload = function() {
        window.print();
    }
</script>
