@extends('layouts.master')
  @section('page_title')
      @if(isset($page_title))
          {{ $page_title }}
      @endif
  @endsection

@section('content')
  <div class="">
      <div class="page-title">
        <div class="title_left">
          <div class="title_left">
            <ol class="breadcrumb">
              <li><a href="{!! url('dashboard') !!}">Dashboard</a></li>
              <li class="active">Marketing Reports</li>
            </ol>
          </div>
        </div>

        <div class="title_right">
          <div class="row">
            <form method="GET" action="{!! url('reports/search') !!}">
              <div class="col-md-5 col-sm-5 col-xs-12 form-group">
                <div style="margin-top:1px; margin-right:-90px;" class="top_search">
                  {!! Form::select('filter', $columns, null, ['class' => 'form-control', 'placeholder' => 'Select Filter here']) !!}
                </div>
              </div>
              <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search" style="margin-top: -2px;">
                <div class="input-group">
                  <input type="text" name="keyword" class="form-control" placeholder="Keyword here...">
                  <span class="input-group-btn">
                    <button type="submit" class="btn btn-primary" style="color: #fff;" type="button">Go!</button>
                  </span>
                </div>
              </div>
            </form>
          </div>
          <div class="row">
              <div class="col-sm-12">
              <div class="pull-right">
                  <a href="{!! url('marketreport') !!}" class="btn btn-warning btn-xs"><i class="fa fa-refresh"></i> Reset Filter</a>
              </div>
              </div>
          </div>
        </div>
      </div>

      <div class="clearfix"></div>
      <div class="row">
        @include('commons.notifications')
        <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
          <div class="x_title">
            <h2> Client Meeting Reports </h2>
            <div class="pull-right">
                <a class="btn btn-primary btn-sm" href="{!! url('marketreport/create') !!}"><i class="fa fa-plus-circle"></i> Add New Meeting Report
                </a>
            </div>
            <div class="clearfix"></div>
          </div>

          <div class="x_content">
              <div class="col-md-3 col-sm-3 col-xs-12 profile_left">
                <div class="profile_img">
                  <div id="crop-avatar">
                  </div>
                </div>
                <h3>{{ $clients[0]->name }}</h3>

                <ul class="list-unstyled user_data">
                  <li><i class="fa fa-envelope user-profile-icon"></i> {{ $clients[0]->email or 'N/A' }}</li>

                  <li><i class="fa fa-map-marker user-profile-icon"></i> {{ $clients[0]->country_info->en_short_name or 'N/A' }}</li>
                </ul>

                <a class="btn btn-success"><i class="fa fa-edit m-right-xs"></i>Edit Client</a>
                <br />

                <!-- start skills -->
                <h4>Services</h4>
                <ul class="list-unstyled user_data">
                  @if (count($clients[0]->client_services) > 0)
                    @foreach($clients[0]->client_services as $service)
                  <li>
                    <p>{{ $service }}</p>
                  </li>
                    @endforeach
                  @else
                  <li>
                    <p>No services found</p>
                  </li>
                  @endif
                  
                  
                </ul>
                <!-- end of skills -->

              </div>
              <div class="col-md-9 col-sm-9 col-xs-12">
                  <div class="profile_title">
                    Activities
                  </div>
                      <div class="" role="tabpanel" data-example-id="togglable-tabs">
                        <ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
                          <li role="presentation" class="active"><a href="#tab_content1" id="home-tab" role="tab" data-toggle="tab" aria-expanded="true">Recent Meetings</a>
                          </li>
                          <li role="presentation" class=""><a href="#tab_content2" role="tab" id="profile-tab" data-toggle="tab" aria-expanded="false">Payments</a>
                          </li>
                          <!-- <li role="presentation" class=""><a href="#tab_content3" role="tab" id="profile-tab2" data-toggle="tab" aria-expanded="false">Profile</a>
                          </li> -->
                        </ul>
                        <div id="myTabContent" class="tab-content">
                          <div role="tabpanel" class="tab-pane fade active in" id="tab_content1" aria-labelledby="home-tab">

                            <!-- start recent activity -->
                            <div style="border-radius: 8px; background-color: #dce2e4; height: 350px; overflow: scroll; padding-right: 10px;">
                              
                            <ul class="messages" style="padding: 15px;">
                              @if($clients[0]->report_info->isEmpty())
                              <li>No reports found</li>

                              @else
                              <?php for ($i = 0; $i < $clients[0]->report_info->count(); $i++) {  ?>
                              <li>
                                <div class="message_date">
                                  <h3 class="date text-info"><?php echo date('d', strtotime($clients[0]->report_info[$i]->created_at)); ?></h3>
                                  <p class="month"><?php echo date('M', strtotime($clients[0]->report_info[$i]->created_at)); ?></p>
                                  <p class="year"><?php echo date('Y', strtotime($clients[0]->report_info[$i]->created_at)); ?></p>
                                </div>
                                <div class="message_wrapper">
                                  <h4 class="heading">{{ $clients[0]->name }}</h4>
                                  <blockquote class="message"><em>Discussion : </em> {{ $clients[0]->report_info[$i]->discussion }}</blockquote>
                                  <br />
                                  <p class="url">
                                    <span class="fs1 text-info" aria-hidden="true" data-icon=""></span>
                                    <a href="#"><i class="fa fa-edit"></i>Staff :  {{ $clients[0]->auth_user_info->name }} </a>
                                  </p>
                                </div>
                              </li>
                              <?php } ?>
                              @endif
                            </ul>
                            </div>
                            <!-- end recent activity -->

                          </div>
                          <div role="tabpanel" class="tab-pane fade" id="tab_content2" aria-labelledby="profile-tab">

                            <div style="height: 350px; overflow: scroll; padding-right: 10px;">
                            <table class="data table table-striped no-margin">
                              <thead>
                                <tr>
                                  <th>#</th>
                                  <th>Amount Paid</th>
                                  <th>Description </th>
                                  <th class="hidden-phone">Payment Method Spent</th>
                                  <th>Notes</th>
                                </tr>
                              </thead>
                              <tbody>
                                <tr>
                                  <td>1</td>
                                  <td>MWK234,566</td>
                                  <td>Sample Payment 1</td>
                                  <td class="hidden-phone">Cash</td>
                                  <td class="vertical-align-mid">
                                      notes here
                                  </td>
                                </tr>
                                
                                <tr>
                                  <td>4</td>
                                  <td>MWK567,000</td>
                                  <td>Sample Payment 2</td>
                                  <td class="hidden-phone">Cheque</td>
                                  <td class="vertical-align-mid">
                                    Lorem Ipsum
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                            <!-- end user projects -->

                            </div>
                          </div>
                          
                        </div>
                      </div>
                    </div>
                <div class="clearfix"></div>
            {{ $clients->links() }} <br>
            Page : {{ $clients->currentPage() }} of {{ $clients->lastPage() }} |
            Total Records : <span id="totalRecords">{{ $clients->total() }}</span>
          </div>
        </div>
      </div>
    </div>
</div>

@endsection

@section('javascript')
  <script type="text/javascript">
  $(document).ready(function(){
    //$('select').select2();
      $(".removeReport").click(function(evt){
          var recordsTotal = Number($('#totalRecords').text());
          var Rrow = $(this).parents('tr');
          var recordID = $(evt.currentTarget).data('val')
          swal({
              title: "Delete Confirmation",
              text: "This will remove this record completely from the system. Do you want to continue",
              type: "info",
              showCancelButton: true,
              confirmButtonClass: "btn-danger conBtn",
              confirmButtonText: "Yes, remove it!",
              showLoaderOnConfirm: true,
              closeOnConfirm: false,
              closeOnCancel: false
            },
            function(isConfirm){
              if (isConfirm) {
                  $.ajax({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    type: "DELETE",
                    data: { id: recordID },
                    url: base_url + "/marketreport/" + recordID,
                    success: function(data){
                        if (data.code === 1) {
                            $(Rrow).remove();
                            $('#totalRecords').text(recordsTotal - 1);
                            swal("Deleted!", "Selected Report has been removed .", "success");
                        }
                        if (data.code === 3) {
                            swal("Not Permitted", "This Operator has transactions! .", "warning");
                        }
                    }
                  });// end of ajax function
              } else {
                swal("Cancelled", "You cancelled the operation :)", "error");
              }
            });
    });
  });
  </script>


@endsection
