<html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link id="bs-css" href="css/bootstrap-cerulean.min.css" rel="stylesheet">
	<link href="css/charisma-app.css" rel="stylesheet">
    <link href='bower_components/fullcalendar/dist/fullcalendar.css' rel='stylesheet'>
    <link href='bower_components/fullcalendar/dist/fullcalendar.print.css' rel='stylesheet' media='print'>
    <link href='bower_components/chosen/chosen.min.css' rel='stylesheet'>
    <link href='bower_components/colorbox/example3/colorbox.css' rel='stylesheet'>
    <link href='bower_components/responsive-tables/responsive-tables.css' rel='stylesheet'>
    <link href='bower_components/bootstrap-tour/build/css/bootstrap-tour.min.css' rel='stylesheet'>
    <link href='css/jquery.noty.css' rel='stylesheet'>
    <link href='css/noty_theme_default.css' rel='stylesheet'>
    <link href='css/elfinder.min.css' rel='stylesheet'>
    <link href='css/elfinder.theme.css' rel='stylesheet'>
    <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
    <link href='css/uploadify.css' rel='stylesheet'>
    <link href='css/animate.min.css' rel='stylesheet'>
        <title>Comptes client sur une période</title>
    </head>
      <body style="font-family:'Montserrat';" onload="window.print();">
            <div class="container">
		   <div class="row">
		    <div class="col-md-12">  
                <center>
				<br/>				
				<img src="{{public_path('assets/img/logo3.png')}}"/><br/>
				<p><b>EasyShop Pro 2.0</b></p>
				<hr style="width:100px;" />
				<p><b></b></p>
				</center>
		    </div>
		</div></div>
		<!--BLOC DU GERANT-->
		<div class="container">
		<div class="row"> 
				@php
					$date_debut1= explode('-', $date_debut);
					$date_debut1= array_reverse($date_debut1);
					$date_debut1= implode('/', $date_debut1);
					
					$date_fin1= explode('-', $date_fin);
					$date_fin1= array_reverse($date_fin1);
					$date_fin1= implode('/', $date_fin1);
					@endphp
                <div class="col-md-4" style="margin-left:20px;">
					<p><b>Créance du </b> {{$date_debut1}} au {{$date_fin1}}</p>
			        </div>
				<div class="col-md-4">  
                    &nbsp;
		        </div>
		</div>
		</div>
     <center>
	    <br/>
        <table class="rpp" border='1' style="border-collapse: collapse;margin-left:25px;width:700px" cellspacing="3">
		<thead>
                          <tr>
                            <th style="text-align:center;height:30px;"> N° </th>
                            <th style="text-align:center;">Nom du client</th>
							<th style="text-align:center;">A payer</th>
							<th style="text-align:center;">Payé</th>
                          </tr>
                        </thead>
        <tbody>
						@foreach($client as $clients)
						
						    @php
							$apayer = DB::table('vente_client')->where('client_id',$clients->id)->whereBetween('date', [$date_debut,$date_fin])->get()->sum('montant');
							$paye = DB::table('paiement_client')->where('client_id',$clients->id)->whereBetween('date', [$date_debut,$date_fin])->get()->sum('montant');
							@endphp
                          <tr>
							<td style="text-align:center;height:30px;">{{$loop->iteration}}</td>
							<td style="text-align:center;">{{$clients->noms}} </td>
							<td style="text-align:center;">
							@php
							$lh = $apayer;
							$lh1 =  number_format($lh, 0, ' ', ' ');
							echo $lh1."&nbsp;F";
							@endphp
							</td>
							@php
							$paye = $paye;
							$paye =  number_format($paye, 0, ' ', ' ');
							@endphp
							<td style="text-align:center;">{{$paye}} </td>
                          </tr>
						  @endforeach
                        </tbody>
						<tr>
							@php
							$totvente =  number_format($totvente, 0, ' ', ' ');
							$totpaie =  number_format($totpaie, 0, ' ', ' ');
							@endphp
							<td style="text-align:center;"></td>
							<td style="text-align:center;"><b>Total</b></td>
							<td style="text-align:center;;height:30px;"><b>{{$totvente}} F</b></td>
							<td style="text-align:center;;height:30px;"><b>{{$totpaie}} F</b></td>
						</tr>
        
        </table>
		<p style="margin-left:430px;margin-top:90px;"><strong>{{DB::table('users')->where('id', session('user')->id)->first()->nom}},</strong><br/>
        Ce <?php echo date('d-m-Y');?>
        </p>
      </div>
        <footer style="position:fixed;bottom:0;text-align:center;">
        <p align="center"><strong>&copy; EasyShop Pro 2.0 2019-2020. </strong>  </p>
        </footer>
      </body>
     </html> 