@extends('backend.header')
@section('index-content')
<style>
    .table-responsive {
        width: 100%;
        height: 75vh;
    }
    /*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: 52px;
        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: 52px;
/*        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;
    }
    .table-warning, .table-warning>td, .table-warning>th {
        background-color: #ffeeba !important;
    }
</style>
<?php
function convertToUnicodeNumber($input) {

    $standard_numsets = array("0","1","2","3","4","5","6","7","8","9");
    $devanagari_numsets = array("०","१","२","३","४","५","६","७","८","९");

    return str_replace($standard_numsets, $devanagari_numsets, $input);
}

?>
<div class="row px-3">


    <section role="main" class="content-body">
        <header class="page-header">
        <div class="row">
          <div class="col-lg-5">
            @if(session()->get('role')==6)
              <h2>Inwards Reports View</h2>
            @else
              <h2>Outwards Reports View</h2>
            @endif
          </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">Outwards Reports View</span></li>
            </ol>
          </div>
          <div class="col-lg-2">
                 @if(!Session::has('dashboardurl')) 
                    <div class="add-btn-div">
                        <a href="{{url('outwards_store')}}" class="btn btn-primary add-btn" style="margin-right: 25px;">Add </a>
                    </div>
                    @endif
          </div>
      </div>
    </header>
        <!-- @if(session()->get('role')==6)
        <header class="page-header">
            <h2>Inwards Reports View</h2>
        </header>
        @else
        <header class="page-header">
            <h2>Outwards Reports View</h2>
        </header>
        @endif -->
      <!--   <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><span class="active">Outwards Reports View</span></li>
                    </ol>
                </div>
            </div>
        </div> -->

        <!-- start: page -->
        <section class="panel  px-1">
           <!--  <header class="panel-heading">
                <h4 class="my-0">District Wise Search</h4>
                 @if(!Session::has('dashboardurl')) 
                    <div class="add-btn-div">
                        <a href="{{url('outwards_store')}}" class="btn btn-primary add-btn" >Add </a>
                    </div>
                    @endif
                </header> -->
        <div>
           <a href="{{url('/outwards_withmaker_list')}}" class="btn btn-primary ">With Make Name</a>
           <a href="{{url('/outwards_view')}}" class="btn btn-primary ">Without Make Name</a>
        </div>
                <div class="panel-body pt-3 px-0">
                    <div class="table-responsive">
            <table class="table table-bordered table-striped mb-none mt-0" id="">
           <thead>
            <tr class="table-success">
                  <th colspan="11">Received Quantity</th>
                  

                </tr>
               <tr class="table-warning">
                    <th>S.NO</th>
                    <th class="text-left">District&nbsp;Name</th>
          <th class="text-left">Make 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>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;$tbvw1=0; $tebw1=0; $sum=0;  $sum1=0; $buf=0; $buf1=0; $i=0;$sumofmake=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;$countvw=0;$tcountvw=0;
                ?>
           @foreach($area_dis_withmaker as $area_dis)
           @if(!empty($area_dis))
           <?php $spancount = count($area_dis); $c=0;  $vw1=0;$vw2=0;$vw3=0;$vw4=0;$vw5=0;$j=0; $bvw1=0; $ebw1=0; 
            ?>
            @foreach($area_dis 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'];

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

             ?>
            <tr>
                <td>{{$i}}</td>
        @if($c == 0)
        <?php $c++; ?>        
                <td class="text-left" style="vertical-align: middle;" rowspan="{{$spancount}}"><a href="{{url('outwards_invoice_list')}}?id={{$list['area_district']['id']}}">{{$list['area_district']['area_name']}}</a></td>
                @endif
        <td>{{$list['maker_name']??''}}</td>
        <td><?php $w1=isset($list['18w'])?$list['18w']:0?>{{$w1}}</td>
                <td><?php $w2=isset($list['35w'])?$list['35w']:0?>{{$w2}}</td>
                <td><?php $w3=isset($list['70w'])?$list['70w']:0?>{{$w3}}</td>
                <td><?php $w4=isset($list['110w'])?$list['110w']:0?>{{$w4}}</td>
                <td><?php $w5=isset($list['190w'])?$list['190w']:0?>{{$w5}}</td>
                <td><?php $sumofmake=$w1+$w2+$w3+$w4+$w5;?>{{$sumofmake}}</td>
                <td>{{$counts_buff_received??'0'}}</td>
                <td>{{$ex_buf_stock??'0'}}</td>
                
            </tr>
             <?php 

               $vw1=$w1+$vw1;
                                $vw2=$w2+$vw2;
                                $vw3=$w3+$vw3;
                                $vw4=$w4+$vw4;
                                $vw5=$w5+$vw5;
                                $countvw= $vw1+$vw2+$vw3+$vw4+$vw5;
                                $bvw1=$counts_buff_received+$bvw1;
                                $ebw1=$countvw+$bvw1;

                                     ?>
                                  @endforeach 

                                   <?php 
       $tw1=$vw1+$tw1;
       $tw2=$vw2+$tw2;
       $tw3=$vw3+$tw3;
       $tw4=$vw4+$tw4;
       $tw5=$vw5+$tw5;
      $tcountvw= $tw1+$tw2+$tw3+$tw4+$tw5;
       $tbvw1=$bvw1+$tbvw1;
        $tebw1=$ebw1+$tebw1;




   
        ?>
                                
     
   <tr>

                        <td></td>
                        <td></td>
                            <td><b>Total</b></td>
                            <td><b>{{$vw1}}</b></td>
                            <td><b>{{$vw2}}</b></td>
                            <td><b>{{$vw3}}</b></td>
                            <td><b>{{$vw4}}</b></td>
                            <td><b>{{$vw5}}</b></td>
                            <td><b>{{$countvw}}</b></td> 
                             <td><b>{{$bvw1??'0'}}</b></td>
                             <td><b>{{$ebw1??'0'}}</b></td></tr>
      

       @endif
       @endforeach
       <tr>
         <td><b>Total</b></td>
         <td></td>
         <td></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>{{$tcountvw??'0'}}</b></td>
           <td><b>{{$tbvw1??'0'}}</b></td>
            <td><b>{{$tebw1??'0'}}</b></td>
        
          
       </tr>

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


   <div class="panel-body pt-5">
            <table class="table table-bordered table-striped mb-none mt-0" id="">
           <thead>
            <tr>
                  <th colspan="10">Makes Quantity</th>
                  

                </tr>
               <tr>
                    <th>S.NO</th>
                
          <th class="text-left">Make&nbsp;Name</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&nbsp;Including&nbsp;Bufferstock </th>      
                    
               </tr>
           </thead>
           <tbody>
            <?php $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;$tbvw1=0; $tebw1=0; $sum=0;  $sum1=0; $buf=0; $buf1=0; $i=0;$sumofmake=0;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;$countvw=0;$tcountvw=0;
                ?>
           @foreach($area_dis_withmakers as $area_dis)
           @if(!empty($area_dis))
           <?php $spancount = count($area_dis); $c=0;  $vw1=0;$vw2=0;$vw3=0;$vw4=0;$vw5=0;$j=0; $bvw1=0; $ebw1=0; 
            ?>
            @foreach($area_dis 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'];

             $ex_buf_stock=$counts+$counts_buff_received;
              $in_buf_stock=$invoice_counts+$counts_buff_received;
             ?>
            <tr>
                <td>{{$i}}</td>
        @if($c == 0)
        <?php $c++; ?>        
               
                @endif
        <td>{{$list['maker_name']??''}}</td>
        <td><?php $w1=isset($list['18w'])?$list['18w']:0?>{{$w1}}</td>
                <td><?php $w2=isset($list['35w'])?$list['35w']:0?>{{$w2}}</td>
                <td><?php $w3=isset($list['70w'])?$list['70w']:0?>{{$w3}}</td>
                <td><?php $w4=isset($list['110w'])?$list['110w']:0?>{{$w4}}</td>
                <td><?php $w5=isset($list['190w'])?$list['190w']:0?>{{$w5}}</td>
                <td><?php $sumofmake=$w1+$w2+$w3+$w4+$w5;?>{{$sumofmake}}</td>
                <td>{{$counts_buff_received??'0'}}</td>
                <td>{{$ex_buf_stock??'0'}}</td>
                
            </tr>
             <?php 

               $vw1=$w1+$vw1;
                                $vw2=$w2+$vw2;
                                $vw3=$w3+$vw3;
                                $vw4=$w4+$vw4;
                                $vw5=$w5+$vw5;
                                $countvw= $vw1+$vw2+$vw3+$vw4+$vw5;
                                $bvw1=$counts_buff_received+$bvw1;
                                $ebw1=$countvw+$bvw1;

                                     ?>
                                  @endforeach 

                                   <?php 
       $tw1=$vw1+$tw1;
       $tw2=$vw2+$tw2;
       $tw3=$vw3+$tw3;
       $tw4=$vw4+$tw4;
       $tw5=$vw5+$tw5;
      $tcountvw= $tw1+$tw2+$tw3+$tw4+$tw5;
       $tbvw1=$bvw1+$tbvw1;
        $tebw1=$ebw1+$tebw1;




   
        ?>
                                
      

       @endif
       @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>{{$tcountvw??'0'}}</b></td>
           <td><b>{{$tbvw1??'0'}}</b></td>
            <td><b>{{$tebw1??'0'}}</b></td>
        
         
          <td></td>
          
       </tr>


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

        </section>
    </section>
</div>
@stop