Current File : //home/tradevaly/new.tradevaly.com.bd/resources/views/backend/subscriber/invoice.blade.php
@extends('backend.ayaan.master')
@section('title') Invoice Details || Package @endsection
@section('css')
    <style>
        #invoice {
            margin-left: auto;
            margin-right: auto;
            background: #d0d0d044;
            position: relative;
            top: 0;
        }

        #invoice .table-bordered td, .table-bordered th {
            border: 1px solid #444 !important;
        }

        .card-title {
            font-size: 15px;
            margin: 0 0 7px;
            font-weight: 600;
            padding: 15px;
            background: #cdd7ef;
        }
    </style>
@endsection
@section('content')
    @component('components.breadcrumb')
        @slot('li_1') Dashboard @endslot
        @slot('title') Invoice Details @endslot
    @endcomponent
    <div class="row justify-content-center">
        <div class="col-11">
            <div class="card" id="invoice">
                <div class="card-body p-5">
                    <table style="width: 100%;">
                        <tr>
                            <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>
                            <td style="text-align: right">
                                <h3 class="text-uppercase text-dark fw-bold">
                                    Tradevaly
                                </h3>
                                <p>{{ settings()->address }}</p>
                            </td>
                        </tr>
                    </table>
                    <div class="card-title mb-4 d-flex align-items-center justify-content-between">
                        <h5 class="m-0">Invoice ID: {{ $invoice->order_id }}</h5>
                        <h5 class="m-0">Invoice Date: {{ date('F m Y', strtotime($invoice->created_at)) }}</h5>
                        <h5 class="m-0">
                            Payment Status:
                            <span
                                class="text-uppercase badge bg-{{ $invoice->payment_status == 'paid' ? 'success':'danger' }}">{{ $invoice->payment_status }}</span>
                        </h5>
                    </div>
                    <div class="col-lg-4 col-12">
                        <h5>Invoiced To</h5>
                        <h6 class="mb-2"><b>{{ $invoice->user->industry }},</b></h6>
                        <p class="mb-2"><b>Member ID:</b> {{ $invoice->user->id }},</p>
                        <p class="mb-2">{{ $invoice->user->name }},</p>
                        <p class="mb-2">{{ $invoice->user->address }},</p>
                        <p class="mb-2">{{ $invoice->user->phone ?? '' }}</p>
                        <p class="mb-2">{{ $invoice->user->email }},</p>
                    </div>
                    <table class="table table-bordered mt-4">
                        <thead>
                        <tr>
                            <th>Description</th>
                            <th>Expire Date</th>
                            <th>Amount</th>
                            <th>Discount</th>
                            <th>Total Amount</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>
                                <span
                                    class="text-capitalize">{{ str_replace('_',' ',$invoice->package->name) }}</span>
                            </td>
                            <td>
                                <span
                                    class="text-capitalize">
                                    @if ($invoice->user->expire)
                                        {{ date('F d Y', strtotime($invoice->user->expire)) }}
                                    @endif
                                </span>
                            </td>
                            <td><span
                                    class="text-uppercase">BDT</span> {{ number_format($invoice->package->price,2) }}
                            </td>
                            <td>{{ number_format($invoice->package->discount,2) }}</td>
                            <td>
                                BDT {{ number_format(($invoice->package->price - $invoice->package->discount),2)  }}
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="col-lg-12 py-5 text-center">
                    <p><a href="">www.tradevaly.com.bd</a></p>
                </div>
            </div>
            <div class="col-lg-12 text-center my-5">
                <a class="btn btn-info my-2" href="{{ route('admin.subscriber.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"></i> Download PDF
                </a>
                <a href="javascript:" class="btn btn-warning" onclick="printHandler()">
                    <i class="fa fa-print"></i> Print
                </a>
            </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();
                const element = document.getElementById("invoice");

                var options = {
                    margin: [0, 0, 0, 0],
                    filename: "invoice.pdf",
                    image: {type: "jpeg", quality: 0.98},
                    html2canvas: {scale: 3, y: 0, scrollY: 0},
                    jsPDF: {unit: "px", format: [800, 800], orientation: "portrait"},
                };
                html2pdf().set(options).from(element).save();
            })
        })

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