@extends('backend.header')
@section('index-content')

<style>
 .table-responsive{
    width: 100%;
    height: 75vh;
  }
  table tr td{
    vertical-align: middle !important;
  }
  /*th,
    td {
        white-space: nowrap;
        
    }*/
    table tr td:first-child {
        position: sticky;
        width: 50px;
        left: 0;
        background: #fff;
        color: #000;
        z-index: 9;
    }
    table tr td:nth-child(2) {
        position: sticky;
        left: 56px;
        background: #fff;
        color: #000;
        z-index: 9;
    }
    table tr th:first-child {
        position: sticky;
        width: 50px;
        left: 0;
        /*   background: #fff;*/
        color: #000;
        z-index: 10;
    }
    table tr th:nth-child(2) {
        position: sticky;
        left: 56px;
/*        background: #fff !important;*/
        color: #000;
        z-index: 10;
    }
    tr.table-success {
        position: sticky;
        left: 0;
        z-index: 10;
/*        background: #fff !important;*/
    }
    tr.table-success {
        top: 0px !important;
        position: sticky !important;
    }
    tr.table-warning {
         top: 36px !important;
         position: sticky !important;
    }
    tr.table-warning,
    tr.table-success{
         position: sticky;
         left: 0;
         z-index: 10;
         background: #fff !important;
    }
    .table-success,
    .table-success > td,
    .table-success > th {
        background-color: #c3e6cb !important;
    }
    .table-warning, .table-warning>td, .table-warning>th {
        background-color: #ffeeba !important;
    }
</style>
<div class="row px-4">



  <section role="main" class="content-body">
    <header class="page-header">
        <div class="row">
          <div class="col-lg-5">
            <h2>Approve & Reject Report</h2>  
          </div>
        
          <div class="col-lg-5">
            <ol class="breadcrumbs">
            <li>
              <a href="{{url('index')}}">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><span class="active">Approve & Reject Report</span></li>
          </ol>
          </div>
      </header>
    <!-- <header class="page-header">
      <h2>Approve & Reject Report</h2>
    </header>
    <div class="row">
      <div class="col-xs-12">
        <div class="">
          <ol class="breadcrumbs">
            <li>
              <a href="{{url('index')}}">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><span class="active">Approve & Reject Report</span></li>
          </ol>
        </div>
      </div>
    </div> -->


    <!-- start: page -->
    <section class="panel pt-2">
      <!-- <header class="panel-heading mb-5">
        <h4 class="my-0">Approve & Reject Report</h4> 
      </header> -->
      <div class="col-12">
        <div class="row">
          <div class="col-md-4 mb-4 pr-2">
            <select class="form-control" id="status_filter">
              <option value="1" @if(Request::get('status')==1) Selected @endif>Approved</option>
               <option value="2" @if(Request::get('status')==2) Selected @endif>Rejected</option>
              <option value="0" @if(Request::get('status')==0) Selected @endif>Pending</option>
              <option value="" @if(Request::get('status')=="") Selected @endif>All</option>
            </select>
          </div>
         <!--  <div>
            <select class="form-control" id="status_filter">
             <option value="1" @if(Request::get('status')==1) Selected @endif>Approved</option>
               <option value="2" @if(Request::get('status')==2) Selected @endif>Rejected</option>
              <option value="0" @if(Request::get('status')==0) Selected @endif>Pending</option>
              <option value="" @if(Request::get('status')=="") Selected @endif>All</option>

            </select>
          </div> -->
          <div class="col-md-4 mb-4 px-2">
              <div>
                <input type="text" class="form-control selected_date" name="selected_date" id="selected_date" value="{{Request::get('date')}}" placeholder="Select From Date">
              </div>
          </div>
          <div class="col-md-4 mb-4 pl-2">
              <div>
                <input type="text" class="form-control selected_date" name="to_date" id="to_date"  value="{{Request::get('to_date')}}" placeholder="Select To Date">
              </div>
          </div>
        </div>
      </div>
      <div class="col-12">

        

      <table class="table table-bordered table-striped mb-none mt-0" id="datatable-default">
       <thead>
         <tr class="table-success">
           <th>S.No</th>
           <th>District Name</th>
           <th>Mandal Name</th>
           <th>Gram Name</th>
           <th>Date</th>
           <th>Status</th>
           <th>Action</th>
           
         </tr>
       </thead>
       <tbody>
        <?php $i=1; $count=0; ?>
        @foreach($list as $data)
        <?php $count++; ?>
        <tr>
          <td>{{$count}}</td>
          <!-- <td>{{$data['id']}}</td> -->
          <td>{{$data['jilla_details']?$data['jilla_details']['area_name']:""}}</td>
          <td>{{$data['taluka_details']?$data['taluka_details']['area_name']:""}}</td>

          <td>
            {{$data['gram_details']?$data['gram_details']['area_name']:""}}</a>
             
          </td>
          <td>{{date('Y-m-d',strtotime($data['created_at']))}}</td> 
          
          <td>@if($data['approve_status']=='1')
           {{"Approved"}}
           @elseif($data['approve_status']=='2')
           {{"Rejected"}}
           @else
           {{'Pending'}}
         @endif </td>
         <td>
          @if(!empty($data['jilla_details']) && !empty($data['taluka_details']) && !empty($data['gram_details']))
          <a  target="_blank" href="{{url('displayallsearch')}}?jillase={{$data['jilla_details']['id']}}&talukase={{$data['taluka_details']['id']}}&gramse={{$data['gram_details']['id']}}&from_date={{date('Y-m-d',strtotime($data['created_at']))}}" class="btn btn-primary">View Report</a>
          @endif
           @if($data['approve_status']=='2')
         <a href="{{url('delete_reject_report')}}?gram_id={{$data['gram_details']['id']}}&&phase_no={{$data['phase_no']}}" class="btn btn-danger">Delete</a>
         @endif

        </td>
         

        <!--  <td><form action="{{url('delete_reject_report')}}" method="post">
                        @csrf
                        @method('DELETE')
                        <input type="submit" onclick="return confirm('Are you sure you want to delete this ($data['gram_details']['area_name']) ');" class="btn btn-danger" value="Delete">
                        </form>
                      </td> -->

        
      </tr>
      <?php $i++; ?>
      @endforeach


    </tbody>
  </table>
</div>
</section>
</section>



 <link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script type="text/javascript">

  $('.selected_date').datepicker({
  });
//   var enableDays = JSON.parse('<?php echo json_encode($edates); ?>');
// $('.selected_date').datepicker({
//     beforeShowDay: function(dt) {
//       var datestring = dt.getDate() + "-" + (dt.getMonth() + 1) + "-" + dt.getFullYear();
//        //var datestring = $.datepicker.formatDate('dd-mm-yy', dt);
//        if($.inArray(datestring, enableDays) != -1) {
//          return [true];
//      }
//      else{
//          return false;
//      }


//  }});

 </script>
<script type="text/javascript">
  $('#status_filter,#selected_date,#to_date').change(function(){
    var status = $('#status_filter').val(); var dates=$('#selected_date').val();
    var to_date=$('#to_date').val();
      window.location.href="{{url('approve_reject_report')}}?status="+status+"&date="+dates+"&to_date="+to_date;
  })
</script>

@stop


