@extends('layouts.app')
@section('title')
{{ $user->name }}
@parent
@stop
@section('header_styles')
<meta name="csrf_token" content="{{ csrf_token() }}">
<link href="{{ asset('assets/vendors/jasny-bootstrap/css/jasny-bootstrap.css') }}" rel="stylesheet"/>
<link href="{{ asset('assets/vendors/x-editable/css/bootstrap-editable.css') }}" rel="stylesheet"/>
<link href="{{ asset('assets/css/pages/user_profile.css') }}" rel="stylesheet"/>
<style type="text/css">
.text-orange{
  color: var(--orange);
}
.text-teal{
  color: var(--teal);
}
</style>
@stop
{{-- Page content --}}
@section('content')
<?php
  
  $dataPoints = [];
  foreach ($monthly_denail_count as $count) {
    array_push($dataPoints, array('y' => $count->toal_count, "label" => $count->month));
  }
  
 
?>

<main id="users_ac">
   <!--section ends-->
   <section>
      <div class="container">
         <div class="row">
            <div class="col-md-12 mt-xs-5">
               <h2 class="h4 p-3 bg-dark-light text-primary-light">
                  <a href="{{route('crm.dashboard')}}"><i class="fa fa-home"></i> Dashboard / </a>  
                   <small  class="bg-dark-light text-dark"> Opportunity</small> /
                   <small  class="bg-dark-light text-dark"> Journal Wise Opportunity Detail ({{$agent}})</small> 
               </h2>
              
               <div class="card card-body">
                <div id="chartContainer"  style="height: 250px; width: 100%;"></div>  
               </div>
               

                 

               <table class="table table-striped mt-4">
                  <thead>
                    <tr bgcolor="#01547d" class="text-white">
                      <th >S.No</th>
                      <th >journal</th>
                      <th class="text-center">Denial Count</th>
                      <th class="text-center">Subscription Cost</th>
                      <th class="text-center">Cost Per Denial</th>
                      <th class="text-center">Opportunity</th>
                      <th>Action</th>
                    </tr>
                  </thead>
                  <tbody>
                    @if(!empty($journal_denail_count))
                        @if(!$journal_denail_count->isEmpty())
                          @php $cnt = 0; @endphp
                            @foreach($journal_denail_count as $row)
                            <tr <?php if( $row->subscribed_journal_usage > 0 ) { echo 'style="background-color: #57c770 !important"';} ?> >
                              <td width="7%">{{++$cnt}}</td>
                              <td width="18%">{{$row->subtitle}}</td>
                              <td width="8%" class="text-center">{{$row->total_denial_count}}</td>
                              <td width="8%" class="text-center">$ {{$row->journal_price}}</td>
                              <td width="8%" class="text-center">$ {{number_format($row->cost_per_denial,2)}}</td>
                              <td width="8%" class="text-center">
                                @if($row->cost_per_denial > 20)
                                  <label class="badge d-block badge-primary form-text">Subscription</label>
                                @else
                                  <label class="badge d-block badge-danger form-text">Best for PPV</label>
                                @endif
                              </td>
                              <td width="5%"><a href="{{route('crm.potential',['agent'=>$agent,'user_id' => $row->user_id, 'year'=> $year,'journal_id'=>$row->journal_id])}}" class="btn btn-sm btn-primary btn-block">View</a></td>
                            </tr>
                            @endforeach
                        @else
                          <tr><td colspan="5" class="text-center">No Record Found !!!</td></tr>
                        @endif
                     @else
                        <tr><td colspan="5" class="text-center">No Record Found !!!</td></tr>   
                     @endif

                  </tbody>
               </table>
               <div class="pt-2"> {{$journal_denail_count->links()}}</div>
               <div class="pt-2"> </div>
            </div>
            
            
         </div>
      </div>
      </div>
   </section>
</main>
@stop
{{-- page level scripts --}}
@section('footer_scripts') 
<!-- Bootstrap WYSIHTML5 --> 
<script>
window.onload = function () {
 
var chart = new CanvasJS.Chart("chartContainer", {
  title: {
    text: "{{$year}} | Monthly Denial Count"
  },
  axisY: {
    title: "Denial Count"
  },
  data: [{
    type: "line",
    dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
  }]
});
chart.render();
 
}
</script>

<script defer="" src="{{ asset('js/canvasjs.min.js') }}"></script> 
<script  src="{{ asset('assets/vendors/jasny-bootstrap/js/jasny-bootstrap.js') }}" type="text/javascript"></script> 
@stop