 @extends('backend.header')
@section('index-content')
<style>
  .add-btn{
    width: auto !important;
    height: 31px !important;
    border-radius: 3px !important;
    line-height: 16px !important;
  }
  .table-responsive:nth-child(2) {
        width: 100%;
        height: 76vh;
    }
    .table-responsive:first-child{
        overflow-x: hidden;
    }
    /*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: 65px;
        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: 65px;
/*        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-3">
  <section role="main" class="content-body">
    <header class="page-header">
        <div class="row">
          <div class="col-lg-5">
            <h2>CCMS Inwards Invoice List</h2>  
          </div>
        
          <div class="col-lg-5">
           <ol class="breadcrumbs">
              <li>
                <a href="{{url('index')}}">
                  <i class="fa fa-home"></i>
                </a>
              </li>
              <li><a href="{{'armsclamps_view'}}"><span class="active">{{$district->area_name??"Districts"}}</span></a></li>
            </ol>
          </div>
          <div class="col-lg-2">
              <div class="back-btn-div">
            <button class="btn btn-primary back-btn" onclick="window.history.back()" style="margin-right: 85px;">Back</button>
             <a href="{{url('ccmstype_store')}}" class="btn btn-primary add-btn" style="margin-right: 25px;">Add </a>
        </div>
          </div>
      </div>
    </header>
      <!-- <header class="page-header">
          <h2>CCMS Inwards Invoice List</h2>

      </header> -->
      <div class="row">
        <!-- <div class="col-xs-12">
          <div class="right-wrapper">
            <ol class="breadcrumbs">
              <li>
                <a href="{{url('index')}}">
                  <i class="fa fa-home"></i>
                </a>
              </li>
              <li><a href="{{'armsclamps_view'}}"><span class="active">{{$district->area_name??"Districts"}}</span></a></li>
            </ol>
          </div>
        </div> -->
         
      <div class="col-md-4 mt-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')==3) Selected @endif>Pending</option>
            <option value="" @if(Request::get('status')=="") Selected @endif>All</option>
          
        </select>

      
      
      
    </div>
       <!--  <div class="col-xs-12 mt-3">
          <div>
            <button class="btn btn-primary" onclick="window.history.back()">Back</button>
          </div>
        </div> -->
      </div>


      <!-- start: page -->
          <section class="panel pt-4">
            <!-- <header class="panel-heading mb-5">
              <h4 class="my-0">CCMS Inwards Invoice List</h4> 
              <div class="add-btn-div">
            <a href="{{url('ccmstype_store')}}" class="btn btn-primary add-btn">Add </a>
          </div>
             
            
            </header> -->
             <table class="table table-bordered table-striped mb-none mt-0" id="datatable-default">
               <thead>
                   <tr class="table-success">
          <th>S.NO</th>
          <th class="text-left">Invoice&nbsp;Number</th>
          <th class="text-left">Received&nbsp;Date</th>
          <th>CCMS&nbsp;Ph&nbsp;Transfer&nbsp;Quantity</th>
          <th>Transferred&nbsp;cable </th>
          <th>Total</th>  
          <th>Status</th>       
                   </tr>
               </thead>
               <tbody>
               <?php $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0; $sum=0; $i=0;?>
           
            @foreach($area_dis as $list)

             <?php $i++;
             $counts=$list['ccmsph']+$list['rcv_cbl']
             // $ex_buf_stock=$counts-$list['buffer_stk'];
             ?>
                <tr>
                  <td data-order="{{$i}}">{{$i}}</td>
                    <td><a target="blank" href="{{url('ccmstypes_list')}}?id={{$list['invoice_number']}}&&jilla_id={{$list['jilla_id']}}">{{$list['invoice_number']}}</a></td>
                    <td data-sort="{{strtotime( $list['date_of_receiving'] )}}">{{ Carbon\Carbon::parse($list['date_of_receiving'])->format('d/m/Y') }}</td>
                     <td>{{$list['ccmsph']??'0'}}</td>
                      <td>{{$list['rcv_cbl']??'0'}}</td>
                      <td>{{$counts??'0'}}</td>
                       <td>@if($list['approve_status']=='1')
           {{"Approved"}}
           @elseif($list['approve_status']=='2')
           {{"Rejected"}}
           @else
           {{'Pending'}}
         @endif </td>
     
                </tr>
           <?php 
       $tw1=$list['ccmsph']+$tw1;
       $tw2=$list['rcv_cbl']+$tw2;
       $sum=$sum+$counts; ?>
                                
       @endforeach
     </tbody><tfoot>
       <tr>
         
         <td data-order="{{$i}}"></td>
         <td><b>Total</b></td>
         <td></td>
          <td><b>{{$tw1??'0'}}</b></td>
          <td><b>{{$tw2??'0'}}</b></td>
          <td><b>{{$sum??'0'}}</b></td> 
          <td></td>    
       </tr>  

         <?php   $sum1=$inventory_total[0]['ccmsph']+$inventory_total[0]['rcv_cbl'];?>
        <tr>
         
         <td data-order="{{$i}}"></td>
         <td><b>Transferred Total</b></td>
         <td></td>
            <td><b>{{$inventory_total[0]['ccmsph']??'0'}}</b></td>
          <td><b>{{$inventory_total[0]['rcv_cbl']??'0'}}</b></td>
          <td><b>{{$sum1??'0'}}</b></td> 
          <td></td>    
       </tr>
        <?php   $sum2=$area_balance[0]['ccmsph']+$area_balance[0]['rcv_cbl'];?>
       <tr>
         
         <td data-order="{{$i}}"></td>
         <td><b>Balance Total</b></td>
         <td></td>
            <td><b>{{$area_balance[0]['ccmsph']??'0'}}</b></td>
          <td><b>{{$area_balance[0]['rcv_cbl']??'0'}}</b></td>
          <td><b>{{$sum2??'0'}}</b></td> 
          <td></td>    
       </tr>
               
               
               </tfoot>
           </table>

         
                <table class="table table-bordered table-striped mb-none mt-0" >
                  <thead>
                    <tr class="table-success">
                      <th>S.NO</th>
                      <th class="text-left">Invoice&nbsp;Number</th>
                      <th class="text-left">Received&nbsp;Date</th>
                      <th>CCMS&nbsp;Ph&nbsp;Transfer&nbsp;Quantity</th>
                       <th>Transferred&nbsp;cable </th>
                       <th>Total</th> 
                    
                    </tr>
                  </thead>
                  <tbody>
                    <?php $i=1;$tw1=0;$tw2=0; ?>
                    @foreach($inventory as $inv)
                  <?php   $counts=$inv['ccmsph']+$inv['rcv_cbl'];?>
                    <tr >
                      <td>{{$i}}</td>
                      <td><a href="{{url('ccmsmove_inventory_list')}}?id={{$inv['invoice_number']}}">{{$inv['invoice_number']}}</a></td>
                       <td>{{ Carbon\Carbon::parse($inv['date_of_transfer'])->format('d/m/Y') }}</td>
                     <td>{{$inv['ccmsph']??'0'}}</td>
                      <td>{{$inv['rcv_cbl']??'0'}}</td>
                      <td>{{$counts??'0'}}</td>
                      
                    
                    </tr>
                    <?php $i++;
                    
       $tw1=$inv['ccmsph']+$tw1;
       $tw2=$inv['rcv_cbl']+$tw2;
       $counts1=$tw1+$tw2;
        ?>
                    @endforeach
         
                    <tr>
                      <td><b></b></td>
                      <td><b>Total</b></td>
                      <td><b></b></td>
                      <td><b>{{$tw1??'0'}}</b></td>
                      <td><b>{{$tw2??'0'}}</b></td>
                      <td><b>{{$counts1??'0'}}</b></td>
                    </tr>

                  
                  </tbody>
                </table>
             
       </section>
   </section>
 </div>
 <script type="text/javascript">
  $('#status_filter').change(function(){
    var status = $('#status_filter').val(); 
      window.location.href="{{url('ccmstypes_invoice_list')}}?id={{$district->id}}&&status="+status;
  })
</script>
     @stop