@extends('admin.master')
@section('title') Invoice | SKIN CARE @endsection
@section('supplier-due-purchase-payment-invoice') active @endsection
@section('styles')
@endsection


@section('main_content_section')

<div class="row min-vh-100">
    <!-- all content will be here. start -->

    <div class="row invoice p-0 m-0">
        <div class="col-md-9 p-0 m-0">
            <div class="shadow rounded m-3">

                @php
                ///To get logo...
                $softLogo = App\Models\InvoiceLogo::getSoftwareInvoiceLogo();
                @endphp
                <div class="d-md-flex justify-content-between custom-billing-invoice-header">
                    <div class="custom-invoice-logo-section">
                        <div class="d-flex align-items-center  custom-billing-invoice-logo">
                            @if(isset($softLogo) && $softLogo->logo_image != null)
                            <img src="{{ asset('uploads/invoice_logo_img/'.$softLogo->logo_image) }}" alt="logo">
                            @else
                            <img src="{{asset('backend')}}/billing_invoice_logo.png" alt="logo">
                            @endif
                        </div>
                    </div>
                    <div class="custom-issue-due-date-section">

                        <div class="d-flex align-items-center gap-2">
                            <div class="d-flex flex-column justify-content-end custom-issue-due-date-text-area gap-2">
                                <p class="">Payment Number: </p>
                                <p class="">Payment Date: </p>
                                <p class="">Payment Generate: </p>
                            </div>

                            <div class="d-flex flex-column gap-2 custom-billing-invoice-header-right">
                                <input type="text" name="invoice_id"
                                    class="form-control custom-cursor-pointer custom-readonly-bg-color"
                                    value="#{{$singleSDPD->supplier_invoice}}" readonly>
                                <input type="text"
                                    class=" form-control custom-readonly-bg-color flatpickr-basic custom-date-picker"
                                    name="date_issue" id="date_issue" placeholder="DD-MM-YYYY"
                                    value="{{Carbon\Carbon::parse($singleSDPD->payment_date)->format('d-m-Y')}}"
                                    readonly>
                                <input type="text"
                                    class="form-control custom-readonly-bg-color flatpickr-basic custom-date-picker"
                                    value="{{Str::title(Auth::user()->name)}}" readonly>
                            </div>
                        </div>

                    </div>
                </div>

                <hr>

                <div class="row px-4">
                    <div class="col-12">
                        <h5>Reference Invoice</h5>
                        <table class="table table-bordered py-3">
                            <!-- <hr class="mb-1"> -->
                            <thead>
                                <tr>
                                    <th class="text-center" scope="col"><span>Invoice</span></th>
                                    <th class="text-center" scope="col"><span>Service QTY</span></th>
                                    <th class="text-center" scope="col"><span>Net Amount</span></th>
                                    <th class="text-center" scope="col"><span>Paid Amount</span></th>
                                    <th class="text-center" scope="col"><span>Due Amount</span></th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($unpaidPurchaseData as $item)
                                @if(isset($item) && $item != null)
                                <tr class="">
                                    <td class="text-center">
                                        <div class="row_title">
                                            <b>#{{$item['purchase_id']}}</b>
                                        </div>
                                        <div class="row-actions mt-2">
                                            @if (Auth::user()->can('purchase-edit'))
                                            @endif
                                        </div>
                                    </td>

                                    <td class="text-center">
                                        <span class="fw-bolder text-secondary">{{ $item['service_qty'] }}</span>
                                    </td>
                                    <td class="text-center">
                                        <span class="fw-bolder text-success">{{ $item['net_amount'] }}</span>
                                    </td>
                                    <td class="text-center">
                                        <span class="fw-bolder text-success">{{ $item['paid_amount'] }}</span>
                                    </td>
                                    <td class="text-center">
                                        <span class="fw-bolder text-danger">{{ $item['due_amount'] }}</span>
                                    </td>
                                </tr>
                                @endif
                                @endforeach
                            </tbody>

                        </table>
                    </div>
                </div>

                <hr>

                <div class="row px-4">
                    <div class="col-12">
                        <h5>After Payment</h5>
                        <table class="table table-bordered py-3">
                            <!-- <hr class="mb-1"> -->
                            <thead>
                                <tr>
                                    <th scope="col" class="text-center"> Invoice </th>
                                    <th scope="col" class="text-center"> Due Amount(tk) </th>
                                    <th scope="col" class="text-center"> Paid Amount(tk) </th>
                                    <th scope="col" class="text-center"> Current Due(tk) </th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($supplierDPD as $singleDPD)
                                @if(isset($singleDPD) && $singleDPD != null)
                                <tr>
                                    <td class="text-center">
                                        <b>#{{$singleDPD->purchaseData->purchase_id}}</b>
                                    </td>
                                    <td class="text-center">
                                        <span class="text-danger fw-bolder">{{$singleDPD->due_amount}}</span>
                                    </td>
                                    <td class="text-center">
                                        <span class="text-success fw-bolder">{{$singleDPD->paid_amount}}</span>
                                    </td>
                                    <td class="text-center">
                                        <span
                                            class="text-info fw-bolder">{{$singleDPD->due_amount - $singleDPD->paid_amount}}</span>
                                    </td>
                                </tr>
                                @endif
                                @endforeach
                            </tbody>

                        </table>
                    </div>
                </div>

                <hr>

                <div class="custom-invoice-common-padding pb-5">
                    <div class="row">
                        <div class="col-md-6">
                            <span class="">

                                <p class="mb-1">
                                    Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod, molestias.
                                </p>
                            </span>
                        </div>
                        <div class="col-md-6">
                            <div class="w-100 d-flex gap-2">
                                <div class="text-end w-50 custom-footer-right-text-block">
                                    <p>Previous Due:</p>
                                    <p>Paid Amount:</p>
                                    <p>Remaining Due:</p>
                                </div>
                                <div class="d-flex flex-column gap-2 w-50">
                                    <input type="text" name="sub_total_quantity" id="sub_total_quantity"
                                        class="form-control custom-cursor-pointer custom-readonly-bg-color"
                                        value="{{ $subTotalDueAmount > 0 ? $subTotalDueAmount : 0}}" readonly>
                                    <input type="text" name="sub_total_price" id="sub_total_price"
                                        class="form-control custom-cursor-pointer custom-readonly-bg-color"
                                        value="{{ $subTotalPaidAmount > 0 ? $subTotalPaidAmount : 0.00}}" readonly>
                                    <input type="text" name="sub_total_discount" id="sub_total_discount"
                                        class="form-control custom-cursor-pointer custom-readonly-bg-color"
                                        value="{{ $subaTotalCurrentDueAmount > 0 ? $subaTotalCurrentDueAmount : 0.00}}"
                                        readonly>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="col-md-3 p-0 m-0">
            <div class="row p-3">
                <div class="col-12 mb-4">
                    <div class="">
                        <div class="card card-stats">
                            <div class="card-header custom-payment-section-header">
                                <div class="icon icon-warning d-flex">
                                    <span class="material-symbols-outlined">equalizer</span>
                                    <p class="category custom-card-header-title custom-payment-section-heading-title">
                                        <strong>Payment Status</strong>
                                    </p>
                                </div>
                            </div>
                            <div class="card-footer p-0 dashboard-card-footer text-center custom-invoice-card-status">
                                <div class="stats">
                                    <div class="row">
                                        <div class="col-12">
                                            <i class="material-symbols-outlined text-success">check_circle</i><br>
                                            <span>Completed</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-12 mb-4">
                    <div class="">
                        <div class="card card-stats">
                            <div class="card-header custom-payment-section-header">
                                <div class="icon icon-warning d-flex">
                                    <span class="material-symbols-outlined">equalizer</span>
                                    <p class="category custom-card-header-title custom-payment-section-heading-title">
                                        <strong>Payment Options</strong>
                                    </p>
                                </div>
                            </div>
                            <div class="card-footer p-0 dashboard-card-footer">
                                <div class="stats">
                                    <div class="row">
                                        <a href="{{route('print-supplier-due-payment-invoice', $singleSDPD->supplier_invoice)}}"
                                            class="text-white btn" target="_blank">
                                            <div class="col-12 invoice-print-button text-center py-2">
                                                <i class="material-symbols-outlined custom-bill-pay-icon">print</i>Print
                                            </div>
                                        </a>

                                        <a href="{{route('download-supplier-due-payment-invoice', $singleSDPD->supplier_invoice)}}" class="text-white btn"
                                            target="_download">
                                            <div class="col-12 invoice-download-button text-center py-2">
                                                <i class="material-symbols-outlined custom-bill-pay-icon">visibility</i>View
                                            </div>
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-12 mb-4">
                    <div class="">
                        <div class="card card-stats">
                            <div class="card-header custom-payment-section-header">
                                <div class="icon icon-warning d-flex">
                                    <span class="material-symbols-outlined">equalizer</span>
                                    <p class="category custom-card-header-title custom-payment-section-heading-title">
                                        <strong>Payment Notes</strong>
                                    </p>
                                </div>
                            </div>
                            <div class="card-footer p-0 dashboard-card-footer text-center custom-invoice-card-status">
                                <div class="stats">
                                    <div class="row">
                                        <div class="col-12">
                                            <p class="mb-0">{{$singleSDPD->payment_note}}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>
    <!-- all content will be here. end -->
</div>

@endsection

@section('scripts')
<script>
</script>
@endsection