@extends('adminlte::page')
@section('title', 'Subscription Cancel')
@section('content')
<div class="wizard row">
    <div class="col-md-12 pd-4">
      <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">Subscription Cancel</h3>
        </div> 
        <!--end title-->
        <!-- start body of the page--> 
        <!-- start box body --> 
        <div class="box-body">
          <div class="col-12">
              @php
                //dd($plans);
                $pname = $plans->plan_name;
              @endphp
              @foreach($slugname_arr as $slugname)
                  @if($pname==$slugname)
                      @php
                          $invoice_plan_name = $display_name_arr[$slugname];
                      @endphp
                  @endif
              @endforeach
              @if($plans->date_cancel_at!="")
                <div class="form-group col-md-12">
                    @if($plans->date_cancel_at)
                      <div class="box-header with-border">
                          <span style="color: red;font-size: 18px;">
                              <div class="form-group col-md-12">  
                                  Your Cancellation Request for {{$invoice_plan_name}} is under processing.
                              </div>
                              <div class="form-group col-md-12">
                                  Cancellation Initiated at : {{$plans->date_cancelled_at}}
                              </div>
                              <div class="form-group col-md-12">
                                  It will be cancelled on {{$plans->date_cancel_at}}
                              </div>
                          </span>
                      </div>
                    @endif
                </div>
              @endif
              @if($plans->date_cancel_at=="")
                <form id="payment-form" action="{{URL::to('/subscription_cancel_post')}}" method="POST">
                  {!! csrf_field() !!}
                  <div class="form-group ">
                      <div class="col-12">
                          <span style="font-size: 18px;">
                              You have an active subscription of {{$plans->currency}} {{$plans->amount}} per {{$plans->payment_interval}} for <span style="color: blue;"> {{$invoice_plan_name}} </span> Plan
                          
                          </span>
                      </div>
                  </div>
                  <div class="form-group">
                        <div class="col-12">
                            <span style="font-size: 18px;">
                                Subscription Activated From : {{$plans->subscription_start}}
                                <br>
                                Subscription Active Till {{$plans->subscription_end}}
                            </span>
                        </div>
                  </div>
                  
                  <div class="form-group">
                      <div class="col-6">
                       
                          <label style="color: blue;">Please Click the button to Cancel the plan.</label>
                          <br>
                          <input type="hidden" name="email" id="email" value="{{$email}}">
                          <button type="submit" class="btn btn-primary btn-sm" onClick='return confirmCancel();'>Cancel</button>
                        
                      </div>
                  </div>
                </form>
              @endif
          </div>
        </div>
      </div>
    </div>
</div>
<script>
  function confirmCancel() 
  {
      var result = confirm('Are you sure you want to Cancel Your Active Plan?');

      if (result) 
      {
          return true;
      } 
      else 
      {
          return false;
      }
  }
  </script>
@endsection 