<script>
$(function () {
  'use strict';
    // get sent lists
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_sent_lists',
    beforeSend: function( xhr ) {  
      $('#div-sent-lists').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-sent-lists').html(data);
  });

  // get sent sending servers
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_sent_sending_servers',
    beforeSend: function( xhr ) {  
      $('#div-sent-sending-servers').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-sent-sending-servers').html(data);
  });
    // get opens
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_opens',
    beforeSend: function( xhr ) {  
      $('#div-opens').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-opens').html(data);
  });

  // get clicks
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_clicks',
    beforeSend: function( xhr ) {  
      $('#div-clicks').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-clicks').html(data);
  });

  // get unsubscribed
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_unsubscribed',
    beforeSend: function( xhr ) {  
      $('#div-unsubscribed').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-unsubscribed').html(data);
  });

  // get bounces
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_bounces',
    beforeSend: function( xhr ) {  
      $('#div-bounces').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-bounces').html(data);
  });

  // get spam
  $.ajax({
    url: '/detail/stat/campaign/'+{{$schedule_stat->id}}+'/summary_spam',
    beforeSend: function( xhr ) {  
      $('#div-spam').html('<div class="spinner-border spinner-border-sm text-dark" role="status"><spam class="visually-hidden"></span></div>');
    }
  })
  .done(function( data ) {
    $('#div-spam').html(data);
  });
});
</script>
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
<div class="modal-content">
  <div class="modal-header">
    <h6 class="modal-title">{{ $schedule_stat->schedule_campaign_name }}</h6>
    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </div>
  <div class="modal-body">
    <div class="box-body">
      <div class="col-md-12">
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.name') }}</label>
          <div class="col-md-9">{{ $schedule_stat->schedule_campaign_name}}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.scheduled_by') }}</label>
          <div class="col-md-9">{{ $schedule_stat->schedule_by}}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.created') }}</label>
          <div class="col-md-9">{{ !empty($schedule_stat->created_at) ? \App\Http\Helper\Helper::datetimeDisplay($schedule_stat->created_at) : '---' }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.started_at') }}</label>
          <div class="col-md-9">{{ !empty($schedule_stat->start_datetime) ? \App\Http\Helper\Helper::datetimeDisplay($schedule_stat->start_datetime) : '---' }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.ended_at') }}</label>
          <div class="col-md-9">{{ !empty($schedule_stat->end_datetime) ? \App\Http\Helper\Helper::datetimeDisplay($schedule_stat->end_datetime) : '---' }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.subject') }}</label>
          <div class="col-md-9">{{ $schedule_stat->email_subject ?? '---' }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.content') }}</label>
          <div class="col-md-9"><a class="link-info" target="_blank" href="{{route('get.schedule_campaign.content', [$schedule_stat->schedule_campaign_id])}}">{{ __('app.view') }}</a></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.lists') }}</label>
          <div class="col-md-9" id="div-sent-lists"></div>
        </div>        
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.delivery_servers') }}</label>
          <div class="col-md-9" id="div-sent-sending-servers"></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.limit') }} ({{ __('app.hourly') }})</label>
          <div class="col-md-9">{{ (json_decode($schedule_stat->sending_speed)->speed == 'unlimited') ? __('app.unlimited') : json_decode($schedule_stat->sending_speed)->limit }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.total') }}</label>
          <div class="col-md-9">{{ $schedule_stat->total }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.scheduled') }}</label>
          <div class="col-md-9"><a href="javascript:;" onclick="viewModal('modal', '{{ route('scheduled.detail.campaign', ['id' => $schedule_stat->schedule_campaign_id]) }}')">{{ $schedule_stat->scheduled }}</a></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.sent') }}</label>
          <div class="col-md-9">{{ $schedule_stat->sent }}</div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.opens') }}</label>
          <div class="col-md-9" id="div-opens"></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.clicks') }}</label>
          <div class="col-md-9" id="div-clicks"></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.unsubscribed') }}</label>
          <div class="col-md-9" id="div-unsubscribed"></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.bounces') }}</label>
          <div class="col-md-9" id="div-bounces"></div>
        </div>
        <div class="row mt-2">
          <label class="col-md-3 form-label text-dark">{{ __('app.spams') }}</label>
          <div class="col-md-9" id="div-spam"></div>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-danger" data-bs-dismiss="modal">{{__('app.close')}}</button>
    <a href="{{route('detail.stat.campaign', ['id' => $schedule_stat->id])}}">
      <button type="button" class="btn btn-primary">{{ __('app.detail') }}</button>
    </a>
  </div>
</div>
</div>