@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 {
      width: 100%;
      height: 75vh;
      overflow: auto;
  }
  /*.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: 52px;
      background: #fff;
      color: #000;
      z-index: 9;
  }
  table tr th:first-child {
      position: sticky;
      width: 50px;
      left: 0;
      background: #c3e6cb !important;
      color: #000;
      z-index: 10;
  }
  table tr th:nth-child(2) {
      position: sticky;
      left: 52px;
      background: #c3e6cb !important;
      color: #000;
      z-index: 10 !important;
  }
  tr.table-success {
      position: sticky;
      left: 0;
      z-index: 10;
/*        background: #fff !important;*/
  }
  tr.table-success {
      top: 0px !important;
      position: sticky !important;
  }
  .table-success,
    .table-success > td,
    .table-success > th {
        background-color: #c3e6cb;
    }
</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">District Reports </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">District Reports </span></li>
					
					</ol>
				</div>
			</div>
		</div> -->

		<!-- start: page -->
		<section class="panel px-1">
		<!-- 	@if(session()->get('role')==0)
			<header class="panel-heading">
				<h4 class="my-0">Outwards Reports View </h4>
				
					<div class="add-btn-div">
						<a href="{{url('outwards_store')}}" class="btn btn-primary add-btn">Add </a>
					</div>
					
				</header>
				@else
			<header class="panel-heading">
				<h4 class="my-0">Inwards Reports View </h4>
				</header>
				@endif -->
				<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="datatable-default">
           <thead>
            @if(session()->get('role')==0)
           	<tr >
           	<td colspan="10"><b>Outwards Quantity<b></td>
           	</tr>
            
            @else
                <tr >
            <td colspan="10"><b>Inwards Quantity<b></td>
            </tr>
            @endif

            

               <tr class="table-success">

					<th>S.NO</th>
					<th class="text-left">District&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;$buf=0; $i=0;?>
           
            @foreach($area_dis 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'];
               $ex_buf_stock=$counts+$counts_buff_received;
            
             ?>
            
            <tr>
                <td data-order="{{$i}}">{{$i}}</td>
                <td><a href="{{url('outwards_invoice_list')}}?id={{$list['area_district']['id']}}">{{$list['area_district']['area_name']}}</a></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><b>{{$counts??'0'}}</b></td>
				<td>{{$counts_buff_received??'0'}}</td>
				<td>{{$ex_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+$counts_buff_received;
        $total_inclu_buf=$sum+$buf;
        ?>
                                
       @endforeach
   </tbody>
   <tfoot>
       <tr>
         <td data-order="{{$i}}"></td>
         <td><b>Total</b></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>{{$sum??'0'}}</b></td>
          <td><b>{{$buf??'0'}}</b></td>
          <td><b>{{$total_inclu_buf??'0'}}</b></td>
           
          <!-- <td></td> -->
          
       </tr>

           </tfoot>
       </table>
   </div>

      <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>      
                                         
               </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'];

               

            

         $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;
             
             ?>
            <tr>
                <td>{{$i}}</td>
                <td class="text-left"><a href="{{url('inwards_invoice_list')}}?id={{$list['area_district']['id']}}">{{$list['maker_name']??'0'}}</a></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>
                         
            </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;

       
      
        ?>
                                
       @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>
          
       </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>
@if(session()->get('role')==6)
   <div class="panel-body pt-5">
			<table class="table table-bordered table-striped mb-none mt-0" >
           <thead>
           	<tr >
           	<td colspan="11"><b>Balance Quantity<b></td>
           	</tr>
               <tr>
					<th>S.NO</th>
					<th class="text-left">District&nbsp;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 Lights</th>
					<th>Buffer 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;$buf=0; $i=0;?>
           
            @foreach($area_disc 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'];
               $ex_buf_stock=$counts+$counts_buff_received;
            
             ?>
            
            <tr>
                <td>{{$i}}</td>
                <td><a href="{{url('outwards_invoice_list')}}?id={{$list['area_district']['id']}}">{{$list['area_district']['area_name']}}</a></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><b>{{$counts??'0'}}</b></td>
				<td>{{$counts_buff_received??'0'}}</td>
				<td>{{$ex_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+$counts_buff_received;
        $total_inclu_buf=$sum+$buf;
        ?>
                                
       @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>{{$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&nbsp;Total&nbsp;Without&nbsp;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>
		</section>
	</section>

</div>



@stop