@extends('backend.header')
@section('index-content')
<?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">
			<h2>Inwards Reports View</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><span class="active">District Reports </span></li>
					
					</ol>
				</div>
			</div>
		</div>

		<!-- start: page -->
		<section class="panel mt-3">
			
			<header class="panel-heading">
				<h4 class="my-0">Inwards Reports View </h4>
				</header>
				 <div>
          
           <a href="{{url('subvendor_inwardslights')}}?with=makername" class="btn btn-primary mt-2">With Make Name</a>
           <a href="{{url('subvendor_inwardslights')}}" class="btn btn-primary mt-2">Without Make Name</a>
           
        
        </div>

        @if($withmaker)
         <div class="panel-body pt-5">
            <table class="table table-bordered table-striped mb-none mt-0" id="">
           <thead>
            <tr>
                  <th colspan="10">Received Quantity</th>
                  

                </tr>
               <tr>
                    <th>S.NO</th>
                    <th class="text-left">District&nbsp;Name</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_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'];

              $ex_buf_stock=$counts;
              $in_buf_stock=$counts + $list['buffer_stk'];

             ?>
            <tr>
                <td>{{$i}}</td>
        @if($c == 0)
        <?php $c++; ?>        
                <td class="text-left" style="vertical-align: middle;" rowspan="{{$spancount}}">{{$list['area_mandal']['area_name']}}</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>{{$list['buffer_stk']??'0'}}</td>
                <td>{{$in_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=$list['buffer_stk']+$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>
        
         
          <td></td>
          
       </tr>
       <tr>
         <td colspan="2"><b>Grand Total Without Bufferstock </b></td>
         <td colspan="8"><b><?php $grandcounts=$tw1+$tw2+$tw3+$tw4+$tw5; ?>{{$grandcounts}}</b></td>
          <td ><b></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>

   @else



				<div class="panel-body pt-5">
			<table class="table table-bordered table-striped mb-none mt-0" >
           <thead>
               <tr>
					<th>S.NO</th>
					<th class="text-left">Mandals Name</th>
					<!-- <th class="text-left">Vendor Name</th> -->
					<th>18 W </th>
					<th>35 W </th>
					<th>70 W </th>
					<th>110 W </th>
					<th>190 W </th>
					<th>Total&nbsp;Lights</th>
					<th>Buffer&nbsp;Stock </th>
					<th>Total 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; $i=0;?>
           
            @foreach($area_dis as $list)

             <?php $i++;
             $counts=$list['18w']+$list['35w']+$list['70w']+$list['110w']+$list['190w']+$list['buffer_stk'];
             $ex_buf_stock=$counts-$list['buffer_stk'];
             ?>
            
            <tr>
                <td>{{$i}}</td>
                <td>{{$list['area_mandal']['area_name']}}</td>
                <td>{{$list['18w']??'0'}}</td>
                <td>{{$list['35w']??'0'??'0'}}</td>
                <td>{{$list['70w']??'0'}}</td>
                <td>{{$list['110w']??'0'}}</td>
				<td>{{$list['190w']??'0'}}</td>              
				<td>{{$ex_buf_stock??'0'}}</td>
				<td>{{$list['buffer_stk']??'0'}}</td>
				<td>{{$counts??'0'}}</td> 
				<td></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; 

        $excl_bufstk=$sum-$tw6;?>
                                
       @endforeach
       <tr>
         <td><b>Total</b></td>
         <td></td>
          <td><b>{{$tw1??'0'}}</b></td>
          <td><b>{{$tw2??'0'}}</b></td>
          <td><b>{{$tw3??'0'??'0'}}</b></td>
          <td><b>{{$tw4??'0'}}</b></td>
          <td><b>{{$tw5??'0'}}</b></td>
          <td><b>{{$excl_bufstk??'0'}}</b></td>
          <td><b>{{$tw6??'0'}}</b></td>
          <td><b>{{$sum??'0'}}</b></td>
           
          <td></td>
          
       </tr>

     <tr>
         <td colspan="2"><b>Grand Total Without Bufferstock </b></td>
         <td colspan="8"><b><?php $grandcounts=$tw1+$tw2+$tw3+$tw4+$tw5; ?>{{$grandcounts}}</b></td>
          <td ><b></b></td>
    </tr>
           
        
           
           </tbody>
       </table>
   </div>
@endif
         <div class="panel-body pt-5">
            <table class="table table-bordered table-striped mb-none mt-0">
           <thead>
            <tr>
                <th colspan="10">Quantity&nbsp;By&nbsp;Makewise</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>    
                    <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;
                $iw1=0;$iw2=0;$iw3=0;$iw4=0;$iw5=0;
                ?>
           
            @foreach($maker_name_count as $list)

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

             $in_buf_stock=$counts+$list['buffer_stk'];
             
             ?>
            <tr>
                <td>{{$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>{{$counts??'0'}}</td>
                <td>{{$list['buffer_stk']??'0'}}</td>
                <td>{{$in_buf_stock??'0'}}</td>
                <td></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+$list['buffer_stk'];
        $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></td>
       </tr>
     <tr>
         <td colspan="2"><b>Grand Total Without Bufferstock </b></td>
         <td colspan="8"><b><?php $grandcounts=$tw1+$tw2+$tw3+$tw4+$tw5; ?>{{$grandcounts}}</b></td>
          <td ><b></b></td>
    </tr>      
           </tbody>
       </table>

   </div>


		</section>
	</section>

</div>



@stop