@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 !important;
    }
    .table-responsive {
        width: 100%;
        height: 76vh !important;
    }
    .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: 43px;
        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: 43px;
/*        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>Inwards Invoice</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="{{url('inwards_view')}}"><span class="active">{{$district->area_name??"District"}}</span></a></li>
            </ol>
          </div>
      </div>
  </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="{{url('inwards_view')}}"><span class="active">{{$district->area_name??"District"}}</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')==0) Selected @endif>Pending</option>
          <option value="" @if(Request::get('status')=="") Selected @endif>All</option>
          
        </select>

      
      </div>
   
        
      </div>


		<section class="panel mt-2">
			<!-- <header class="panel-heading">
				<h4 class="my-0">Inwards Invoice</h4>
			</header>
 -->
			<div class="panel-body pt-3 " style="padding-left: 0px !important; padding-right: 0px !important;">
        <!-- id="datatable-default" -->
            <table class="table table-bordered table-striped mb-none mt-0" id="datatable-default">
               <thead>
              <tr class="table-success">
                  <th colspan="17">Balance Quantity&nbsp;By&nbsp;Makewise(After Inter Districts And EESL Transfers)</th></tr>
            <tr class="table-success">
						<th>S.NO</th>
						<th>Invoice number</th> 
                        <th>Received Date</th>
                        <th>Make Name</th> 
						<!-- <th>Phase No</th>  -->
						<th>18 W </th>
						<th>35 W </th>
						<th>70 W </th>
						<th>110 W </th>
						<th>190 W </th>
						<th>Total Lights</th>
						<th>Buffer Stock </th>
						<th>Total Lights Including Bufferstock </th> 
                        <th>Drivers </th>  
                        <th>Spds</th>           
                        <th>Tiltable Adapters</th>     
						

            <!-- invoice table  -->
            <!-- <th>Phase&nbsp;No</th>  -->
           <!--  <th>18&nbsp;W </th>
            <th>35&nbsp;W </th>
            <th>70&nbsp;W </th>
            <th>110&nbsp;W </th>
            <th>190&nbsp;W </th>
            <th>Total&nbsp;Lights</th>
            <th>Buffer&nbsp;Stock </th>
            <th>Total&nbsp;Lights Including Bufferstock </th>  -->
            <th>Remarks</th> 
            <th>Status</th>           
             </tr>
               </thead>

               <tbody>
                <?php
               $count = 0;
                        ?>

                <?php $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;  $sum=0; $sum1=0; $buf=0; $buf1=0; $i=0;$drv=0; $spds=0; $tltd=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;   $mw1=0;$mw2=0;$mw3=0;$mw4=0;$mw5=0;$mw6=0;?>
                @foreach($area_invoice as $list)
                <?php $i++;

					$counts=$list['18w']+$list['35w']+$list['70w']+$list['110w']+$list['190w'];
          $invoice_counts=$list['invoice_18w']+$list['invoice_35w']+$list['invoice_70w']+$list['invoice_110w']+$list['invoice_190w'];

				 $counts_buff_invoice=$list['buffer_stk_18']+$list['buffer_stk_35']+$list['buffer_stk_70']+$list['buffer_stk_110']+$list['buffer_stk_190'];

         $counts_buff_received=$list['buffer_stk_rcv_18']+$list['buffer_stk_rcv_35']+$list['buffer_stk_rcv_70']+$list['buffer_stk_rcv_110']+$list['buffer_stk_rcv_190'];

         $counts_drivers_received=$list['drivers_received_qty_18w']+$list['drivers_received_qty_35w']+$list['drivers_received_qty_70w']+$list['drivers_received_qty_110w']+$list['drivers_received_qty_190w'];

           $counts_spds_received=$list['spd_received_qty_18w']+$list['spd_received_qty_35w']+$list['spd_received_qty_70w']+$list['spd_received_qty_110w']+$list['spd_received_qty_190w'];

           $counts_tiltables_received=$list['tiltadap_rcv_qty'];

				 $ex_buf_stock=$counts+$counts_buff_received;
          $in_buf_stock=$invoice_counts+$counts_buff_invoice;



          
            
				 ?>
                <tr>
					<td data-order="{{$i}}">{{$i}}</td>
					<td class="text-left"><a target="blank" href="{{url('inwards_list')}}?id={{$list['invoice_number']}}&&jilla_id={{$list['jilla_id']}}">{{$list['invoice_number']??'0'}}</a></td>
                    <td data-sort="{{strtotime( $list['date_of_receiving'] )}}">{{ Carbon\Carbon::parse($list['date_of_receiving'])->format('d/m/Y') }}</td>
					<td>{{$list['maker_name']}}</td>
          <!-- <td>
						@if($list['phase_no'] !=0 && $list['phase_no'] > 0)
							Phase_{{$list['phase_no']??'-'}}
						@else
							-
						@endif
					</td> -->
					<td>{{$list['18w']??'0'}}</td>
					<td>{{$list['35w']??'0'}}</td>
					<td>{{$list['70w']??'0'}}</td>
					<td>{{$list['110w']??'0'}}</td>
					<td>{{$list['190w']??'0'}}</td>
				<td><b>{{$counts??'0'}}</b></td>
				 <td>{{$counts_buff_received??'0'}}</td>
				<td>{{$ex_buf_stock??'0'}}</td>
                 <td>{{$counts_drivers_received??'0'}}</td>
                <td>{{$counts_spds_received??'0'}}</td>
                <td>{{$counts_tiltables_received??'0'}}</td>
				
         <!-- <td>{{$list['invoice_18w']??'0'}}</td>
          <td>{{$list['invoice_35w']??'0'}}</td>
          <td>{{$list['invoice_70w']??'0'}}</td>
          <td>{{$list['invoice_110w']??'0'}}</td>
          <td>{{$list['invoice_190w']??'0'}}</td>
           <td>{{$invoice_counts??'0'}}</td>  
            
             <td>{{$counts_buff_invoice??'0'}}</td>
             <td>{{$in_buf_stock??'0'}}</td> -->
              <td>{{$list['remarks']??''}}</td>
         <td>@if($list['approve_status']=='1')
           {{"Approved"}}
           @elseif($list['approve_status']=='2')
           {{"Rejected"}}
           @else
           {{'Pending'}}
         @endif </td>
                </tr>
                <?php 
					$tw1=$list['18w']+$tw1;
					$tw2=$list['35w']+$tw2;             
					$tw3=$list['70w']+$tw3;
					$tw4=$list['110w']+$tw4;
					$tw5=$list['190w']+$tw5;
					// $tw6=$list['buffer_stk']+$tw6;

					   $sum=$sum+$counts;


        $buf=$buf+$counts_buff_received;
        $total_inclu_buf=$sum+$buf;
        $drv=$drv+$counts_drivers_received;
        $spds=$spds+$counts_spds_received;
        $tltd=$tltd+$counts_tiltables_received;

         $sum1=$sum1+$invoice_counts; 
          $buf1=$buf1+$counts_buff_received;
            $total1_inclu_buf=$sum1+$buf1;

       $iw1=$list['invoice_18w']+$iw1;
          $iw2=$list['invoice_35w']+$iw2;
          $iw3=$list['invoice_70w']+$iw3;
          $iw4=$list['invoice_110w']+$iw4;
          $iw5=$list['invoice_190w']+$iw5;


				?>        
                           
                @endforeach

        </tbody>
        <tfoot>        
    <tr>      
    
    <td data-order="{{$i}}"></td>
    <td><b>Total</b></td>
    <td></td>
    <td></td>
    <td><b>{{$tw1}}</b></td>
    <td><b>{{$tw2}}</b></td>
    <td><b>{{$tw3}}</b></td>
    <td><b>{{$tw4}}</b></td>
    <td><b>{{$tw5}}</b></td>
    <td><b>{{$sum??'0'}}</b></td>
    <td><b>{{$buf??'0'}}</b></td>
    <td><b>{{$total_inclu_buf??'0'}}</b></td>
    <td><b>{{$drv??'0'}}</b></td>
    <td><b>{{$spds??'0'}}</b></td>
    <td><b>{{$tltd??'0'}}</b></td>
    <!-- <td><b>{{$iw1}}</b></td>
    <td><b>{{$iw2}}</b></td>
    <td><b>{{$iw3}}</b></td>
    <td><b>{{$iw4}}</b></td>
    <td><b>{{$iw5}}</b></td>
    <td><b>{{$sum1??'0'}}</b></td>
    <td><b>{{$buf1??'0'}}</b></td>
    <td><b>{{$total1_inclu_buf??'0'}}</b></td> -->
    <td></td>
    <td></td>
</tr>

 <?php $inventory_total_total_count=$inventory_total[0]['18w']+$inventory_total[0]['35w']+$inventory_total[0]['70w']+$inventory_total[0]['110w']+$inventory_total[0]['190w'];
     $inventory_total_buf_count=$inventory_total[0]['buffer_stk_rcv_18']+$inventory_total[0]['buffer_stk_rcv_35']+$inventory_total[0]['buffer_stk_rcv_70']+$inventory_total[0]['buffer_stk_rcv_110']+$inventory_total[0]['buffer_stk_rcv_190']; 

     $inventory_total_drivers_count=$inventory_total[0]['drivers_received_qty_18w']+$inventory_total[0]['drivers_received_qty_35w']+$inventory_total[0]['drivers_received_qty_70w']+$inventory_total[0]['drivers_received_qty_110w']+$inventory_total[0]['drivers_received_qty_190w'];

    $inventory_total_spds_count=$inventory_total[0]['spd_received_qty_18w']+$inventory_total[0]['spd_received_qty_35w']+$inventory_total[0]['spd_received_qty_70w']+$inventory_total[0]['spd_received_qty_110w']+$inventory_total[0]['spd_received_qty_190w'];

    $inventory_total_tltd_count=$inventory_total[0]['tiltadap_rcv_qty'];

     $total_total_with_buff=$inventory_total_total_count+$inventory_total_buf_count;?>
       <!--  <tr>
         <td data-order="{{$i}}"></td>
         <td><b>Total Transferred</b></td>
         <td></td>
         <td></td>
          <td><b>{{$inventory_total[0]['18w']??'0'}}</b></td>
          <td><b>{{$inventory_total[0]['35w']??'0'}}</b></td>
          <td><b>{{$inventory_total[0]['70w']??'0'}}</b></td>
          <td><b>{{$inventory_total[0]['110w']??'0'}}</b></td>
          <td><b>{{$inventory_total[0]['190w']??'0'}}</b></td>
          <td><b>{{$inventory_total_total_count??'0'}}</b></td>
          <td><b>{{$inventory_total_buf_count??'0'}}</b></td>
          <td><b>{{$total_total_with_buff??'0'}}</b></td>
            <td><b>{{$inventory_total_drivers_count??'0'}}</b></td>
          <td><b>{{$inventory_total_spds_count??'0'}}</b></td>
          <td><b>{{$inventory_total_tltd_count??'0'}}</b></td>
          <td></td>
          <td></td>
        
        
          
       </tr> -->

<?php


$counts_buff_received=$area_balance[0]['n_buffer_stk_rcv_18']+$area_balance[0]['n_buffer_stk_rcv_35']+$area_balance[0]['n_buffer_stk_rcv_70']+$area_balance[0]['n_buffer_stk_rcv_110']+$area_balance[0]['n_buffer_stk_rcv_190'];

$counts=$area_balance[0]['n18w']+$area_balance[0]['n35w']+$area_balance[0]['n70w']+$area_balance[0]['n110w']+$area_balance[0]['n190w'];

                 $ex_buf_stock=$counts+$counts_buff_received;
          ?>
<!--  <tr>  
     <td data-order="{{$i}}"></td>    
    <td><b>Balance Total</b></td>
     <td></td>
    <td></td>
   
    <td><b>{{$area_balance[0]['n18w']}}</b></td>
    <td><b>{{$area_balance[0]['n35w']}}</b></td>
    <td><b>{{$area_balance[0]['n70w']}}</b></td>
    <td><b>{{$area_balance[0]['n110w']}}</b></td>
    <td><b>{{$area_balance[0]['n190w']}}</b></td>
                <td><b>{{$counts??'0'}}</b></td>
                 <td><b>{{$counts_buff_received??'0'}}</b></td>
                <td><b>{{$ex_buf_stock??'0'}}</b></td>
     <td></td>
    <td></td>

</tr> -->
 

<!-- <tr>
    <td colspan="5"><b>Grand Total Without Bufferstock </b></td>
    <td colspan="5"><b></b>{{$sum}}</td>
    <td colspan="5"><b>Grand Total Without Bufferstock </b></td>
    <td colspan="5"><b></b>{{$sum1}}</td>
</tr> -->
               
               </tfoot>
            </table>
          </div>

           <div class="panel-body pt-3 " style="padding-left: 0px !important; padding-right: 0px !important;">
         <div >
          <table class="table table-bordered table-striped mb-none my-0" >
                                    <thead>
                                        <tr class="table-success">
                                        <th colspan="16">Incoming Move Inventory Invoices</th> </tr>
                                        <tr class="table-warning">
                                             <th>S.NO</th>
                        <th>Invoice number</th> 
                        <th>Received Date</th>
                        <th>Make Name</th> 
                        <!-- <th>Phase No</th>  -->
                        <th>18 W </th>
                        <th>35 W </th>
                        <th>70 W </th>
                        <th>110 W </th>
                        <th>190 W </th>
                        <th>Total Lights</th>
                        <th>Buffer Stock </th>
                        <th>Total Lights Including Bufferstock </th>
                        <th>Spds</th>           
                       <th>Tiltable Adapters</th>
                        <th>Remarks</th>
                        <th>Remarks</th>
                                          
                                        
                                        </tr>
                                    </thead>
                                    <tbody>
                                       <?php
               

        $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;  $sum=0; $sum1=0; $buf=0; $buf1=0; $i=0;$drv=0; $spds=0; $tltd=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;   $mw1=0;$mw2=0;$mw3=0;$mw4=0;$mw5=0;$mw6=0;?>
                                        @foreach($incoming_inventory_total as $inv)

                                         <?php $i++;

                    $counts=$inv['18w']+$inv['35w']+$inv['70w']+$inv['110w']+$inv['190w'];
         

         $counts_bufff_received=$inv['buffer_stk_rcv_18']+$inv['buffer_stk_rcv_35']+$inv['buffer_stk_rcv_70']+$inv['buffer_stk_rcv_110']+$inv['buffer_stk_rcv_190'];

         $counts_drivers_received=$inv['drivers_received_qty_18w']+$inv['drivers_received_qty_35w']+$inv['drivers_received_qty_70w']+$inv['drivers_received_qty_110w']+$inv['drivers_received_qty_190w'];

           $counts_spds_received=$inv['spd_received_qty_18w']+$inv['spd_received_qty_35w']+$inv['spd_received_qty_70w']+$inv['spd_received_qty_110w']+$inv['spd_received_qty_190w'];

           $counts_tiltables_received=$inv['tiltadap_rcv_qty'];

                 $ex_buff_stock=$counts+$counts_bufff_received;

          
            
                 ?>
                                        <tr>
                                            <td>{{$i}}</td>
                                            <td><a target="blank" href="{{url('move_inventory_list')}}?id={{$inv['invoice_number']}}">{{$inv['invoice_number']??'0'}}</a></td>
                                            <!-- <td>{{$inv->invoice_number??'0'}}</td>  -->
                                             <td>{{ Carbon\Carbon::parse($inv['date_of_transfer'])->format('d/m/Y') }}</td>
                                           <td>{{$inv['maker_name']}}</td>
                                                     <td>{{$inv['18w']??'0'}}</td>
                    <td>{{$inv['35w']??'0'}}</td>
                    <td>{{$inv['70w']??'0'}}</td>
                    <td>{{$inv['110w']??'0'}}</td>
                    <td>{{$inv['190w']??'0'}}</td>
                    <td><b>{{$counts??'0'}}</b></td>
                 <td>{{$counts_bufff_received??'0'}}</td>
                <td>{{$ex_buff_stock??'0'}}</td>
                 <td>{{$counts_drivers_received??'0'}}</td>
                <td>{{$counts_spds_received??'0'}}</td>
                <td>{{$counts_tiltables_received??'0'}}</td>

                                 <td>{{$inv['remarks']??''}}</td>
                  
                                            
                                        
                                        </tr>

                                         <?php 
                    $tw1=$inv['18w']+$tw1;
                    $tw2=$inv['35w']+$tw2;             
                    $tw3=$inv['70w']+$tw3;
                    $tw4=$inv['110w']+$tw4;
                    $tw5=$inv['190w']+$tw5;
                    // $tw6=$inv['buffer_stk']+$tw6;

                       $sum=$sum+$counts;

        $drv=$drv+$counts_drivers_received;
        $spds=$spds+$counts_spds_received;
        $tltd=$tltd+$counts_tiltables_received;
        $buf=$buf+$counts_bufff_received;
        $total_includ_buf=$buf+$sum;

         $sum1=$sum1+$invoice_counts; 
          $buf1=$buf1+$counts_buff_received;
            $total1_inclu_buf=$sum1+$buf1;

                ?> 
                                      
                                        @endforeach
                                     <tr>      
    
    <td data-order="{{$i}}"></td>
    <td><b>Total</b></td>
    <td></td>
    <td></td>
    <td><b>{{$tw1}}</b></td>
    <td><b>{{$tw2}}</b></td>
    <td><b>{{$tw3}}</b></td>
    <td><b>{{$tw4}}</b></td>
    <td><b>{{$tw5}}</b></td>
    <td><b>{{$sum??'0'}}</b></td>
    <td><b>{{$buf??'0'}}</b></td>
    <td><b>{{$total_includ_buf??'0'}}</b></td>
     <td><b>{{$drv??'0'}}</b></td>
          <td><b>{{$spds??'0'}}</b></td>
          <td><b>{{$tltd??'0'}}</b></td>
       <td></td>
    </tr>

    

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

          <div class="panel-body pt-3 " style="padding-left: 0px !important; padding-right: 0px !important;">
         <div >
          <table class="table table-bordered table-striped mb-none my-0" >
                                    <thead>
                                        <tr class="table-success">
                                        <th colspan="16">Outgoing Move Inventory Invoices</th> </tr>
                                        <tr class="table-warning">
                                             <th>S.NO</th>
                        <th>Invoice number</th> 
                        <th>Received Date</th>
                        <th>Make Name</th> 
                        <!-- <th>Phase No</th>  -->
                        <th>18 W </th>
                        <th>35 W </th>
                        <th>70 W </th>
                        <th>110 W </th>
                        <th>190 W </th>
                        <th>Total Lights</th>
                        <th>Buffer Stock </th>
                        <th>Total Lights Including Bufferstock </th>
                        <th>Spds</th>           
                       <th>Tiltable Adapters</th>
                        <th>Remarks</th>
                        <th>Remarks</th>
                                          
                                        
                                        </tr>
                                    </thead>
                                    <tbody>
                                       <?php
               

        $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;  $sum=0; $sum1=0; $buf=0; $buf1=0; $i=0;$drv=0; $spds=0; $tltd=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;   $mw1=0;$mw2=0;$mw3=0;$mw4=0;$mw5=0;$mw6=0;?>
                                        @foreach($inventory as $inv)

                                         <?php $i++;

                    $counts=$inv['18w']+$inv['35w']+$inv['70w']+$inv['110w']+$inv['190w'];
         

         $counts_bufff_received=$inv['buffer_stk_rcv_18']+$inv['buffer_stk_rcv_35']+$inv['buffer_stk_rcv_70']+$inv['buffer_stk_rcv_110']+$inv['buffer_stk_rcv_190'];

         $counts_drivers_received=$inv['drivers_received_qty_18w']+$inv['drivers_received_qty_35w']+$inv['drivers_received_qty_70w']+$inv['drivers_received_qty_110w']+$inv['drivers_received_qty_190w'];

           $counts_spds_received=$inv['spd_received_qty_18w']+$inv['spd_received_qty_35w']+$inv['spd_received_qty_70w']+$inv['spd_received_qty_110w']+$inv['spd_received_qty_190w'];

           $counts_tiltables_received=$inv['tiltadap_rcv_qty'];

                 $ex_buff_stock=$counts+$counts_bufff_received;

          
            
                 ?>
                                        <tr>
                                            <td>{{$i}}</td>
                                            <td><a target="blank" href="{{url('move_inventory_list')}}?id={{$inv['invoice_number']}}">{{$inv['invoice_number']??'0'}}</a></td>
                                            <!-- <td>{{$inv->invoice_number??'0'}}</td>  -->
                                             <td>{{ Carbon\Carbon::parse($inv['date_of_transfer'])->format('d/m/Y') }}</td>
                                           <td>{{$inv['maker_name']}}</td>
                                                     <td>{{$inv['18w']??'0'}}</td>
                    <td>{{$inv['35w']??'0'}}</td>
                    <td>{{$inv['70w']??'0'}}</td>
                    <td>{{$inv['110w']??'0'}}</td>
                    <td>{{$inv['190w']??'0'}}</td>
                    <td><b>{{$counts??'0'}}</b></td>
				 <td>{{$counts_bufff_received??'0'}}</td>
				<td>{{$ex_buff_stock??'0'}}</td>
                 <td>{{$counts_drivers_received??'0'}}</td>
                <td>{{$counts_spds_received??'0'}}</td>
                <td>{{$counts_tiltables_received??'0'}}</td>

                                 <td>{{$inv['remarks']??''}}</td>
                  
                                            
                                        
                                        </tr>

                                         <?php 
					$tw1=$inv['18w']+$tw1;
					$tw2=$inv['35w']+$tw2;             
					$tw3=$inv['70w']+$tw3;
					$tw4=$inv['110w']+$tw4;
					$tw5=$inv['190w']+$tw5;
					// $tw6=$inv['buffer_stk']+$tw6;

					   $sum=$sum+$counts;

        $drv=$drv+$counts_drivers_received;
        $spds=$spds+$counts_spds_received;
        $tltd=$tltd+$counts_tiltables_received;
        $buf=$buf+$counts_buff_received;
        $total_includ_buf=$buf+$sum;

         $sum1=$sum1+$invoice_counts; 
          $buf1=$buf1+$counts_bufff_received;
            $total1_inclu_buf=$sum1+$buf1;

				?> 
                                      
                                        @endforeach
                                     <tr>      
    
    <td data-order="{{$i}}"></td>
    <td><b>Total</b></td>
    <td></td>
    <td></td>
    <td><b>{{$tw1}}</b></td>
    <td><b>{{$tw2}}</b></td>
    <td><b>{{$tw3}}</b></td>
    <td><b>{{$tw4}}</b></td>
    <td><b>{{$tw5}}</b></td>
    <td><b>{{$sum??'0'}}</b></td>
    <td><b>{{$buf??'0'}}</b></td>
    <td><b>{{$total_includ_buf??'0'}}</b></td>
     <td><b>{{$drv??'0'}}</b></td>
          <td><b>{{$spds??'0'}}</b></td>
          <td><b>{{$tltd??'0'}}</b></td>
       <td></td>
    </tr>

    

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



         <div class="panel-body pt-3 " style="padding-left: 0px !important; padding-right: 0px !important;">
         <div class="table-responsive my-4">
          <table class="table table-bordered table-striped mb-none my-0" >
               <thead>
                <tr class="table-success">
                  <th colspan="13">Balance Quantity&nbsp;By&nbsp;Makewise(After Inter Districts And EESL Transfers)</th></tr>
              
            <tr class="table-warning">
            <th>S.NO</th>
           
            <th>Make Name</th> 
            <!-- <th>Phase&nbsp;No</th>  -->
            <th>18&nbsp;W </th>
            <th>35&nbsp;W </th>
            <th>70&nbsp;W </th>
            <th>110&nbsp;W </th>
            <th>190&nbsp;W </th>
            <th>Total&nbsp;Lights</th>
            <th>Buffer&nbsp;Stock </th>
            <th>Total&nbsp;Lights Including Bufferstock </th> 
             <th>Drivers </th>  
             <th>Spds</th>           
             <th>Tiltable Adapters</th>      
                
             </tr>
               </thead>

               <tbody>
                <?php
               $count = 0;
                        ?>

                <?php $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;  $sum=0; $sum1=0; $buf=0; $buf1=0; $i=0;$drv=0; $spds=0; $tltd=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;   $mw1=0;$mw2=0;$mw3=0;$mw4=0;$mw5=0;$mw6=0;?>
                @foreach($maker_counts as $list)
                <?php $i++;

          $counts=$list['18w']+$list['35w']+$list['70w']+$list['110w']+$list['190w'];
          $invoice_counts=$list['invoice_18w']+$list['invoice_35w']+$list['invoice_70w']+$list['invoice_110w']+$list['invoice_190w'];

         $counts_buff_invoice=$list['buffer_stk_18']+$list['buffer_stk_35']+$list['buffer_stk_70']+$list['buffer_stk_110']+$list['buffer_stk_190'];

         $counts_buff_received=$list['buffer_stk_rcv_18']+$list['buffer_stk_rcv_35']+$list['buffer_stk_rcv_70']+$list['buffer_stk_rcv_110']+$list['buffer_stk_rcv_190'];
         $counts_drivers_received=$list['drivers_received_qty_18w']+$list['drivers_received_qty_35w']+$list['drivers_received_qty_70w']+$list['drivers_received_qty_110w']+$list['drivers_received_qty_190w'];

           $counts_spds_received=$list['spd_received_qty_18w']+$list['spd_received_qty_35w']+$list['spd_received_qty_70w']+$list['spd_received_qty_110w']+$list['spd_received_qty_190w'];

           $counts_tiltables_received=$list['tiltadap_rcv_qty'];

         $ex_buf_stock=$counts+$counts_buff_received;
          $in_buf_stock=$invoice_counts+$counts_buff_invoice;

          
            
         ?>
                <tr>
          <td>{{$i}}</td>
      
          <td>{{$list['maker_name']}}</td>
          <!-- <td>
            @if($list['phase_no'] !=0 && $list['phase_no'] > 0)
              Phase_{{$list['phase_no']??'-'}}
            @else
              -
            @endif
          </td> -->
          <td>{{$list['18w']??'0'}}</td>
          <td>{{$list['35w']??'0'}}</td>
          <td>{{$list['70w']??'0'}}</td>
          <td>{{$list['110w']??'0'}}</td>
          <td>{{$list['190w']??'0'}}</td>
        <td><b>{{$counts??'0'}}</b></td>
         <td>{{$counts_buff_received??'0'}}</td>
        <td>{{$ex_buf_stock??'0'}}</td>
         <td>{{$counts_drivers_received??'0'}}</td>
                <td>{{$counts_spds_received??'0'}}</td>
                <td>{{$counts_tiltables_received??'0'}}</td>
        
         <!-- <td>{{$list['invoice_18w']??'0'}}</td>
          <td>{{$list['invoice_35w']??'0'}}</td>
          <td>{{$list['invoice_70w']??'0'}}</td>
          <td>{{$list['invoice_110w']??'0'}}</td>
          <td>{{$list['invoice_190w']??'0'}}</td>
           <td>{{$invoice_counts??'0'}}</td>  
            
             <td>{{$counts_buff_invoice??'0'}}</td>
             <td>{{$in_buf_stock??'0'}}</td> -->
             
                </tr>
                <?php 
          $tw1=$list['18w']+$tw1;
          $tw2=$list['35w']+$tw2;             
          $tw3=$list['70w']+$tw3;
          $tw4=$list['110w']+$tw4;
          $tw5=$list['190w']+$tw5;
          // $tw6=$list['buffer_stk']+$tw6;

             $sum=$sum+$counts;

         $drv=$drv+$counts_drivers_received;
        $spds=$spds+$counts_spds_received;
        $tltd=$tltd+$counts_tiltables_received;
        $buf=$buf+$counts_buff_received;
        $total_inclu_buf=$sum+$buf;

         $sum1=$sum1+$invoice_counts; 
          $buf1=$buf1+$counts_buff_received;
            $total1_inclu_buf=$sum1+$buf1;

       $iw1=$list['invoice_18w']+$iw1;
          $iw2=$list['invoice_35w']+$iw2;
          $iw3=$list['invoice_70w']+$iw3;
          $iw4=$list['invoice_110w']+$iw4;
          $iw5=$list['invoice_190w']+$iw5;


        ?>        
                           
                @endforeach

                
    <tr>  
     <td></td>    
    <td><b>Total</b></td>

   
    <td><b>{{$tw1}}</b></td>
    <td><b>{{$tw2}}</b></td>
    <td><b>{{$tw3}}</b></td>
    <td><b>{{$tw4}}</b></td>
    <td><b>{{$tw5}}</b></td>
    <td><b>{{$sum??'0'}}</b></td>
    <td><b>{{$buf??'0'}}</b></td>
    <td><b>{{$total_inclu_buf??'0'}}</b></td>
     <td><b>{{$drv??'0'}}</b></td>
          <td><b>{{$spds??'0'}}</b></td>
          <td><b>{{$tltd??'0'}}</b></td>

</tr>
 

<!-- <tr>
    <td colspan="5"><b>Grand Total Without Bufferstock </b></td>
    <td colspan="5"><b></b>{{$sum}}</td>
    <td colspan="5"><b>Grand Total Without Bufferstock </b></td>
    <td colspan="5"><b></b>{{$sum1}}</td>
</tr> -->

<div class="panel-body pt-5">
            <table class="table table-bordered table-striped mb-none mt-0" >
           <thead>
            <tr  class="table-success">
                <th colspan="13">Transfer Quantity&nbsp;By&nbsp;Makewise</th>
            </tr>
               <tr  class="table-warning">
                    <th>S.NO</th>
                    <th class="text-left">Make&nbsp;Name</th>
                    <th>18 W </th>
                    <th>35 W </th>
                    <th>70 W </th>
                    <th>110 W </th>
                    <th>190 W </th>
                    <th>Total Lights</th>
                    <th>Buffer Stock </th>
                    <th>Total Lights Including Bufferstock </th>
                     <th>Drivers </th>  
                    <th>Spds</th>           
                    <th>Tiltable Adapters</th>       
                    <!-- <th>18&nbsp;W </th>
            <th>35&nbsp;W </th>
            <th>70&nbsp;W </th>
            <th>110&nbsp;W </th>
            <th>190&nbsp;W </th>
            <th>Total&nbsp;Lights</th>
            <th>Buffer&nbsp;Stock </th>
            <th>Total&nbsp;Lights Including Bufferstock </th>  -->
            <!-- <th>Remarks</th>                          -->
               </tr>


           </thead>
           <tbody>
            <?php $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0; $sum=0;  $sum1=0; $buf=0; $buf1=0; $i=0;$i=0;$drv=0; $spds=0; $tltd=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;
                ?>
           
            @foreach($makers_inventory_total as $list)

             <?php $i++;
                        $counts=$list['18w']+$list['35w']+$list['70w']+$list['110w']+$list['190w'];

           


         $counts_buff_received=$list['buffer_stk_rcv_18']+$list['buffer_stk_rcv_35']+$list['buffer_stk_rcv_70']+$list['buffer_stk_rcv_110']+$list['buffer_stk_rcv_190'];
         $counts_drivers_received=$list['drivers_received_qty_18w']+$list['drivers_received_qty_35w']+$list['drivers_received_qty_70w']+$list['drivers_received_qty_110w']+$list['drivers_received_qty_190w'];

           $counts_spds_received=$list['spd_received_qty_18w']+$list['spd_received_qty_35w']+$list['spd_received_qty_70w']+$list['spd_received_qty_110w']+$list['spd_received_qty_190w'];

           $counts_tiltables_received=$list['tiltadap_rcv_qty'];

             $ex_buf_stock=$counts+$counts_buff_received;
        
             ?>
            <tr>

                <td data-order="{{$i}}">{{$i}}</td>
                <td class="text-left">{{$list['maker_name']??'0'}}</td>
                <td>{{$list['18w']??'0'}}</td>
                <td>{{$list['35w']??'0'}}</td>
                <td>{{$list['70w']??'0'}}</td>
                <td>{{$list['110w']??'0'}}</td>
                <td>{{$list['190w']??'0'}}</td>
                <td><b>{{$counts??'0'}}</b></td>
                <td>{{$counts_buff_received??'0'}}</td>
                <td>{{$ex_buf_stock??'0'}}</td>
                 <td>{{$counts_drivers_received??'0'}}</td>
                <td>{{$counts_spds_received??'0'}}</td>
                <td>{{$counts_tiltables_received??'0'}}</td>
                <!-- <td>{{$list['invoice_18w']??'0'}}</td>
                <td>{{$list['invoice_35w']??'0'}}</td>
                <td>{{$list['invoice_70w']??'0'}}</td>
                <td>{{$list['invoice_110w']??'0'}}</td>
                <td>{{$list['invoice_190w']??'0'}}</td>
                <td>{{$invoice_counts??'0'}}</td>  
                <td>{{$counts_buff_invoice??'0'}}</td>
                <td>{{$in_buf_stock??'0'}}</td> -->
                <!-- <td>N/A</td>              -->
            </tr>
             <?php 
       $tw1=$list['18w']+$tw1;
       $tw2=$list['35w']+$tw2;
       $tw3=$list['70w']+$tw3;
       $tw4=$list['110w']+$tw4;
       $tw5=$list['190w']+$tw5;

       $sum=$sum+$counts;

         $drv=$drv+$counts_drivers_received;
        $spds=$spds+$counts_spds_received;
        $tltd=$tltd+$counts_tiltables_received;
        $buf=$buf+$counts_buff_received;
        $total_inclu_buf=$sum+$buf;

        ?>
                                
       @endforeach
       <tr>
         <td></td>
         <td><b>Total</b></td>
          <td><b>{{$tw1??'0'}}</b></td>
          <td><b>{{$tw2??'0'}}</b></td>
          <td><b>{{$tw3??'0'}}</b></td>
          <td><b>{{$tw4??'0'}}</b></td>
          <td><b>{{$tw5??'0'}}</b></td>
          <td><b>{{$sum??'0'}}</b></td>
          <td><b>{{$buf??'0'}}</b></td>
          <td><b>{{$total_inclu_buf??'0'}}</b></td>
            <td><b>{{$drv??'0'}}</b></td>
          <td><b>{{$spds??'0'}}</b></td>
          <td><b>{{$tltd??'0'}}</b></td>
          <!-- <td><b>{{$iw1}}</b></td>
          <td><b>{{$iw2}}</b></td>
          <td><b>{{$iw3}}</b></td>
          <td><b>{{$iw4}}</b></td>
          <td><b>{{$iw5}}</b></td>
          <td><b>{{$sum1??'0'}}</b></td>
          <td><b>{{$buf1??'0'}}</b></td>
          <td><b>{{$total1_inclu_buf}}</b></td> -->
    
          
       </tr>
               
               </tbody>
            </table>
          </div>
      </div>
       </section>
   </section>
 </div>

                            
                           
                       
 <script type="text/javascript">

  $('#status_filter').change(function(){
    var status = $('#status_filter').val(); 
      window.location.href="{{url('inwards_invoice_list')}}?id={{$district->id}}&&status="+status;
  })
</script>
     @stop