@if($success_notes)

<!--Success Modal -->
<div class="modal fade color-modal" id="successModal"  data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="successModalTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-body text-center">
                <div class=" row ">
                    @if(! isset($error) )
                    <div class="col-12 ">
                        <div class="img ">
                            <img src="{{asset('assets/web/images/icons/like.svg')}}" alt=" ">
                        </div>
                    </div>
                    @endif

                    <div class="col-12 ">
                        <div class="info ">
                            <h2>{!! $success_notes !!} </h2>
                        </div>
                    </div>

                    <div class=" col-12 ">
                        <div class="btns">
                            @if($invoice['code'] ?? '')
                                <a href="javascript:;" data-dismiss="modal" data-toggle="modal" data-target="#billModal" class="butn light">Show Bill</a>
                            @endif

                            @if($route ?? '')
                                <a href="{{ $route }}" class="butn light">{{ $details_btn ?? __('main.back') }}</a>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@endif

@if($invoice['code'] ?? '')
<!-- Bill Modal -->
<div class="modal fade details-modal" id="billModal" tabindex="-1" role="dialog" aria-labelledby="billModalTitle" aria-hidden="true">

    <input type="hidden" class="go_to_route" value="{{ $route }}" />

    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content invoice_details">
            <div class="modal-head text-center">
                <h3>invoice number <span class="invoice_id">#{{ $invoice['code'] ?? '' }} </span></h3>
            </div>
            <div class="modal-body">
                <div class=" row">
                    <div class="col-6">
                        <ul>
                            <li>
                                <span>date</span>
                                <p class="subscribe_time">{{date('M d, Y', strtotime( $invoice['created_at'] ) )}}</p>
                            </li>
                            <li>
                                <span>start month</span>
                                <p class="loop_date">{{date('M Y', strtotime( $loopDetails['loop_date'] ) )}}</p>
                            </li>
                            <li>
                                <span>collecting month</span>
                                <p class="loop_date">{{date('M Y', strtotime( $loopDetails['encashment_month'] ) )}}</p>
                            </li>
                            <li>
                                <span>loop's period</span>
                                <p class="invoice_period">{{ $loopDetails['period'] }} months</p>
                            </li>

                            @if(count($paidMonth ?? []))
                            <li>
                                <span>Paid months</span>
                                <p> {{ count($paidMonth ?? []) }} months</p>
                            </li>
                            @endif

                            <li>
                                <span>share</span>
                                <p>{{ $loopDetails['share'] }} SAR</p>
                            </li>
                        </ul>
                    </div>

                    <div class="col-6 valign">
                        <ul class="text-right w-100">
                            <li>
                                <span>time</span>
                                <p class="subscribe_time">{{date('h:i A', strtotime( $invoice['created_at'] ) )}}</p>
                            </li>
                            @if($invoice['meta'])
                                @if($invoice['meta']['remainingAmount'] ?? 0)
                                <li>
                                    <span>{{ __('loops.remaining') }}</span>
                                    <p>{{ $invoice['meta']['remainingAmount'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['managment_fees'] ?? 0)
                                <li>
                                    <span>{{ __('loops.managment_fees') }}</span>
                                    <p>{{ $invoice['meta']['managment_fees'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['vat_fees'] ?? 0)
                                <li>
                                    <span>{{ __('loops.vat_fees') }}</span>
                                    <p>{{ $invoice['meta']['vat_fees'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['government_fees'] ?? 0)
                                <li>
                                    <span>{{ __('loops.government_fees') }}</span>
                                    <p>{{ $invoice['meta']['government_fees'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['withdraw_fees'] ?? 0)
                                <li>
                                    <span>{{ __('loops.withdraw_fees') }}</span>
                                    <p>{{ $invoice['meta']['withdraw_fees'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['delay_fees'] ?? 0)
                                <li>
                                    <span>{{ __('loops.delay_fees') }}</span>
                                    <p>{{ $invoice['meta']['delay_fees'] }} SAR</p>
                                </li>
                                @endif

                                @if($invoice['meta']['total'] ?? 0)
                                <li>
                                    <span> {{ __('loops.total') }} </span>
                                    <h4>{{ $invoice['meta']['total'] }} SAR</h4>
                                </li>
                                @endif
                            @endif
                        </ul>
                    </div>
                </div>

                <div class="butn wow zoomIn w-100">
                    <img src="{{ asset('assets/web/images/visa.png') }} " alt="">
                    <div class="info">
                        <p>{{$currentUserInfo->name}}</p>
                        <span>4200 1244 4459 2269</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endif


@section('container_js')
<script src="{{ asset('assets/web/js/loop.js') }}"></script>
@if($success_notes ?? '')
<script type="text/javascript">
    $(window).on('load',function(){
        if ($('#successModal').length) {
            $('#successModal').modal('show')
        }
    })
</script>
@elseif($invoice['code'])
<script type="text/javascript">
    $(window).on('load',function(){
        if ($('#billModal').length) {
            $('#billModal').modal('show')
        }
    })
</script>
@endif

@endsection
