Current File : //home/tradevaly/public_html/resources/views/backend/pages/advertiser/money_receipt.blade.php
@extends('backend.ayaan.master')
@push('title') Money Receipt || Advertisment @endpush
@section('css')
    <style>
        #money-receipt {
            background: #fff;
            padding: 15px;
        }

        @media print {
            .row {
                display: flex;
                -ms-flex-wrap: wrap;
                flex-wrap: wrap;
            }
        }

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

        th, td {
            padding: 8px;
            text-align: left;
        }

        span.value {
            font-weight: normal;
            padding-left: 10px;
        }

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

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

        .bold {
            font-weight: bold;
            border-bottom: 1px dashed #4444;
            white-space: nowrap;
        }

        hr {
            border: none;
            border-top: 1px solid #ddd;
            margin: 20px 0;
        }

        .receipt-title {
            display: inline-block;
            border: 2px solid #6c6c6c;
            padding: 4px 24px;
            font-size: 20px;
            font-weight: 800;
        }
    </style>
@endsection
@section('content')
    @component('components.breadcrumb')
        @slot('li_1') Dashboard @endslot
        @slot('title') Money Receipt @endslot
    @endcomponent

    <div class="container mt-5 ">
        <div class="row justify-content-center">
            <div class="col-md-9">
                <div class="card" id="money-receipt">
                    <div class="card-body">
                        <table>
                            <tr>
                                <td>
                                    <h3 class="text-uppercase text-dark fw-bold">
                                        Tradevaly
                                    </h3>
                                    <p>{{ settings()->address }}</p>
                                </td>
                                <td>
                                    @php
                                        $settings = \Illuminate\Support\Facades\DB::table('logo')->first();
                                    @endphp
                                    @if(!empty($settings))
                                        <img
                                            src="{{asset('storage/images/admin/logo/'.$settings->image)}}"
                                            height="60" width="200" alt="">
                                    @else
                                        <img
                                            src="{{asset('fav-icon.png')}}" height="60" width="200" alt="">
                                    @endif
                                </td>
                            </tr>
                            <tr>
                                <th colspan="4" class="text-center">
                                    <h2 class="receipt-title">Money Receipt</h2>
                                </th>
                            </tr>
                            <tr>
                                <td class="bold">Invoice No.: <span class="value">{{ $money_receipt->order_id }}</span>
                                </td>
                                <td class="bold">Date: <span
                                        class="value">{{ date('d F Y',strtotime($money_receipt->created_at)) }}</span>
                                </td>
                                
                            </tr>
                            <tr>
                                <td class="bold">Received with thanks from: <span
                                        class="value">Tradevaly</span></td>
                                        <td class="bold">Transaction ID: <span
                                        class="value">{{ $money_receipt->transaction->transaction_id }}</span></td>
                            </tr>
                            @php
                                $formatter = new NumberFormatter("en", NumberFormatter::SPELLOUT);
                                $amount = $money_receipt->transaction ? $money_receipt->transaction->total_amount : $money_receipt->amount;
                            @endphp
                            <tr>
                                <td class="bold">Amount: <span
                                        class="text-right value">BDT {{ number_format($amount,2) }}</span>
                                </td>
                                <td class="bold">In Words: <span
                                        class="value text-capitalize">{{ $formatter->format($amount) }}</span>
                                </td>
                            </tr>
                            <tr>
                                <td class="bold">Payment Method: <span
                                        class="value">{{ $money_receipt->transaction ? $money_receipt->transaction->payment_method : ''}}</span></td>
                                <td class="bold">Payment Type: <span
                                        class="value">{{ $money_receipt->transaction ?$money_receipt->transaction->payment_type : '' }}</span></td>
                            </tr>
                            <tr>
                                <td class="bold">Payment For: <span
                                        class="value text-capitalize">Advertisment</span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    <hr>
                                </td>
                            </tr>
                            <tr>
                                <td class="text-center">This is an electronic money receipt signature is not required.
                                </td>
                                <td class="text-center">Powered by <b>Tradevaly</b>.</td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="col-lg-12 text-center my-5">
                    <a class="btn btn-info my-2" href="{{ route('admin.advertiser.index') }}">
                        <i class="fa fa-arrow-left"></i> Back to list
                    </a>
                    <a href="javascript:" class="btn btn-success" id="downloadInvoice">
                        <i class="fa fa-download default"></i>
                        <i class="fa fa-spinner fa-spin loader d-none"></i> Download PDF
                    </a>
                    <a href="javascript:" class="btn btn-warning" onclick="printHandler()">
                        <i class="fa fa-print"></i> Print
                    </a>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"
            integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg=="
            crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script type="text/javascript">
        $(document).ready(function ($) {
            $('#downloadInvoice').on('click', function (event) {
                event.preventDefault();
                $('.default').hide();
                $('.loader').show();
                const element = document.getElementById("money-receipt");
                var opt = {
                    margin: 0,
                    filename: 'money-receipt-{{ $money_receipt->order_id }}.pdf',
                    image: {type: 'jpeg', quality: 0.98},
                    html2canvas: {scale: 3, y: 0, scrollY: 0},
                    jsPDF: {unit: 'in', format: 'letter', orientation: 'portrait'}
                };
                html2pdf().set(opt).from(element).save();
                window.setTimeout(function () {
                    $('.loader').hide();
                    $('.default').show();
                }, 1000)
            })
        })

        function printHandler() {
            var printableContent = document.getElementById('money-receipt')
            var printContents = printableContent.innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;
            window.setTimeout(function () {
                document.title = "money-receipt"
                window.print();
                document.body.innerHTML = originalContents;
                window.location.reload()
            }, 1000);
        }
    </script>
@endsection