<!DOCTYPE html>
<html lang="en">


<!-- Mirrored from www.radixtouch.in/templates/logicswave/ality/source/light/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 02 Sep 2020 20:02:10 GMT -->
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
  <title>Mouvements stock : {{$date_debut}} - {{$date_fin}}</title>  
		</head>
			<body style="font-family:'Montserrat';font-size:12px;">
			<h3> Mouvements stock : 
					@if ($date_debut == $date_fin)
					{{$date_debut}} 
					@else
					{{$date_debut}} au {{$date_fin}}
					@endif
			</h3>
			  <table border="1" class="table table-striped" id="table-1" style="border-collapse: collapse;font-family:'Montserrat';font-size:12px;width:720px;">
                        <thead>
                          <tr>
							<th style="text-align:center;">N°</th>
							<th style="text-align:center;">Désignation</th>
							<th style="text-align:center;">Entrées(Qté approv.)</th>
							<th style="text-align:center;">Sorties(Qté transférée)</th>
							<th style="text-align:center;">En stock</th>
						</tr>
                        </thead>
                       <tbody>
	@foreach($produits as $produit)
	@php
		$totap0 = DB::table('magasin_general')->where('produit_id', $produit->id)->where('type_operation', 'Inventaire')->whereBetween('date', [$date_debut,$date_fin])->sum('qte');
		$totap1 = DB::table('magasin_general')->where('produit_id', $produit->id)->where('type_operation', 'Appro')->whereBetween('date', [$date_debut,$date_fin])->sum('qte');
		//$totap2 =  DB::table('magasin_general')->where('produit_id', $produit->id)->where('type_operation', 'TransfertRecu')->sum('qte');
		$totap = $totap0 + $totap1;
		$totvente0 = DB::table('magasin_general')->where('produit_id', $produit->id)->where('type_operation', 'Transfert')->whereBetween('date', [$date_debut,$date_fin])->sum('qte');
		$totvente = $totvente0;
		$totstk = $totap - $totvente;
		
	@endphp
	<tr>
        <td style="text-align:center;font-size:14px;">{{$loop->iteration}}</td>
        <td style="text-align:center;font-size:14px;">{{$produit->desi}}</td>
        <td style="text-align:center;font-size:14px;"> {{$totap}}</td>
        <td style="text-align:center;font-size:14px;">{{$totvente}} </td>
        <td style="text-align:center;font-size:14px;">{{$totstk}}</td>
    </tr>
	@endforeach
                        </tbody>
                      </table>
                    </body>
</html>