@extends('adminlte::page')

@section('title', 'View Profile ')

@section('content')
<div class="wizard row">
    <br><br>
    <div class="col-md-12 pd-4">
        <div class="box ">
            <div class="box-group" id="accordion">
                <div class="panel box box-primary">
                    <div class="box-header with-border">
                        <h4 class="box-title">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Subscription Details</a>
                        </h4>
                    </div>
                    <div id="collapseOne" class="panel-collapse collapse in">
                        <div class="box-body">   
                            <div class="form-group col-md-4">
                                <div class="box-header with-border">
                                    <div class="form-group col-md-12">
                                        Subscription Installed : {{$plan->subscription_start}}
                                    </div>
                                    <div class="form-group col-md-12">
                                        Subscription Active Till : {{$plan->subscription_end}}
                                    </div>
                                    <div class="form-group col-md-12">
                                        &nbsp;
                                    </div>
                                </div>
                            </div>
                            <div class="form-group col-md-4">
                                <div class="box-header with-border">
                                    <div class="form-group col-md-12">
                                        @php
                                            $pname = $plan->plan_name;
                                        @endphp
                                        @foreach($slugname_arr as $slugname)
                                            @if($pname==$slugname)
                                                @php
                                                    $invoice_plan_name = $display_name_arr[$slugname];
                                                @endphp
                                            @endif
                                        @endforeach
                                        Plan Name : {{$invoice_plan_name}}                                        
                                    </div>
                                    <div class="form-group col-md-12">
                                        Maximum # of Users : 
                                        @if(isset($prd_det->number_of_users))
                                        {{$prd_det->number_of_users}}
                                        @endif
                                    </div>
                                    <div class="form-group col-md-12">
                                        
                                    </div>
                                    <div class="form-group col-md-12">
                                        Amount : {{$plan->currency}} {{number_format($plan->amount, 2) }} per {{$plan->payment_interval}}
                                    </div>
                                </div>
                            </div>
                            <div class="form-group col-md-4">
                                @if($plan->date_cancel_at)
                                <div class="box-header with-border">
                                    <span style="color: red;">
                                        <div class="form-group col-md-12">
                                            Your Cancellation Request is under processing.
                                        </div>
                                        <div class="form-group col-md-12">
                                            Cancellation Initiated at : {{$plan->date_cancelled_at}}
                                        </div>
                                        <div class="form-group col-md-12">
                                            It will be cancelled on {{$plan->date_cancel_at}}
                                        </div>
                                    </span>
                                </div>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-12 pd-4">
        <br>
        <br>
        <div class="box ">
            <!-- title of the page and heading-->
            <div class="box-header with-border main-box">
              <i class="ion ion-clipboard"></i>
              <h3 class="box-title">Invoice List</h3>
            </div>
            <!--end title-->
            <!-- start body of the page--> 
            <!-- start box body --> 
            <div class="box-body">
                <div class="col-12">
                    <table width="100%" border="1">
                        <tr>
                            <td>Date</td>
                            <td>Product</td>
                            <td>Invoice Number</td>
                            <td>Amount</td>
                            <td></td>
                        </tr>
                        @php
                            $invoice_plan_name ="";
                            $payment_interval ="";
                            $frequency = "";
                            $pname ="";
                            //dd($display_name);
                        @endphp
                        @foreach($invoices as $invoice_list)
                            @php
                                $payment_interval = $invoice_list->payment_interval;
                                if($payment_interval=="month")
                                {
                                    $frequency = "monthly";
                                }
                                if($payment_interval=="year")
                                {
                                    $frequency = "annual";
                                }
                                $pname = $invoice_list->plan_name;
                                if($pname)
                                {
                                  $pnamearr = explode("×", $pname);
                                  $pname_last = explode("(", $pnamearr[1]);
                                  $plan_name_stripe = trim($pname_last[0]);  ////slugname -- dewpas_starter_mon
                                }
                            @endphp
                            @foreach($slugname_arr as $slugname)
                                @if($plan_name_stripe==$slugname)
                                    @php
                                        $invoice_plan_name = $display_name_arr[$slugname];
                                    @endphp
                                @endif
                            @endforeach
                            <tr>
                                <td>{{$invoice_list->invoice_date}}</td>
                                <td>{{$invoice_plan_name}}</td>
                                <td>{{$invoice_list->invoice_number}}</td>
                                <td>{{$invoice_list->currency}}&nbsp;&nbsp;&nbsp;{{$invoice_list->amount}}</td>
                                <td><a href="{{$invoice_list->invoice_pdf_list}}"  class="btn btn-primary btn-sm" target="_blank">View PDF</a></td>
                            </tr>
                        @endforeach 
                    </table>
                </div>      
            </div>
            <!-- /.box-body -->
            <div class="box-footer t_cen">
                
            </div>   <!-- end of div box-footer t_cen -->
        </div>   <!-- end of div box -->
    </div>   <!-- end of div col-md-12 pd-4 -->  
</div>  <!-- end of div wizard row -->

@endsection