<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>Historique client</title>
    <style>
		th {
			font-size:12px;
		}
		td {
			font-size:12px;
		}
		
		.bloc2{
		display:inline-block;
		position:relative;
		text-align:center;
		margin-top:-25px;
		width:100%;
		padding-top: -10px;
		}
		</style>
    </head>
      <body style="font-family:'Montserrat';" onload="window.print();">
           <div class="bloc"> 
			<div class="bloc2">
                <span style="margin-top:15px;margin-bottom:10px;color:#000;font-size:30px;text-align:center"><b>AV'S ELECTRIC</b></span><br><hr style="width:60px;">
                <span style="margin-top:20px;color:#000;font-size:14px;text-align:center"><b>VENTE DE MATÉRIAUX DE CONSTRUCTION</b></span><br>	
                <span style="margin-top:15px;color:#000;font-size:13px;text-align:center">Tél: {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->telephone}} </span><br>	
                <span style="margin-top:15px;color:#000;font-size:13px;text-align:center">{{DB::table('magasin')->orderBydesc('id')->take(1)->first()->adresse}}</span><br>	
		    </div>
		</div>
		<!--BLOC DU GERANT-->
		<div class="container">
		<div class="row"> 
                <div class="col-md-4" style="margin-left:20px;">
					<p><b>Client : @php if($client==0){$cli="Tous les clients";} else {$cli=DB::table('client_externe')->where('id', $client)->first()->noms;}@endphp {{$cli}}</b></p>
					@php
					$date_debut= explode('-', $date_debut);
					$date_debut= array_reverse($date_debut);
					$date_debut= implode('/', $date_debut);

					
					$date_fin= explode('-', $date_fin);
					$date_fin= array_reverse($date_fin);
					$date_fin= implode('/', $date_fin);
					@endphp
					<p><b>Période :</b> Du {{$date_debut}} au {{$date_fin}}</p>
			        </div>
				<div class="col-md-4">  
                    &nbsp;
		        </div>
		</div>
		</div>
     <center>
	    <br/>
        <table border='1' style="border-collapse: collapse;width:410px;margin-left:-30px" cellspacing="3">
        <thead>
						<tr>
						<th colspan="4" style="text-align:center">Liste des achats</th>
					  </tr>
                      <tr>
                        <th style="width:25%;">N°</th>
                        <th style="width:20%;">Référence</th>
						<th style="width:20%;">Date</th>
						<th style="width:20%;">Montant</th>
						
                      </tr>
                    </thead>
		 <tbody>
			@foreach($vente as $ventes)
			@php
			$dv = implode('/', array_reverse(explode('-', $ventes->date)));
			@endphp
           <tr>
		   <td align="center">{{$loop->iteration}}</td>
		   <td align="center">{{$ventes->numero}}</td>
		   <td align="center">{{$dv}}</td>
		   <td align="center">{{$ventes->montant}}</td>
		   
		   </tr>
			@endforeach
		</tbody>
		<tr>
			<td style="text-align:center"> Total achats</td>
			<td style="text-align:center"> <b>Total paiement</b></td>
			<td style="text-align:center" colspan="2"> <b>Reste à payer</b></td>
		</tr>
		<tr>
			@php
			$reste = $total - $sommePaiement;
			$reste =  number_format($reste, 0, ' ', ' ');
			$total1 = $total;
			$total1 =  number_format($total1, 0, ' ', ' ');
			$sommePaiement1 = $sommePaiement;
			$sommePaiement1 =  number_format($sommePaiement1, 0, ' ', ' ');
			@endphp
			<td style="text-align:center">{{$total1}}</td>
			<td style="text-align:center"> {{$sommePaiement1}}</td>
			
			<td style="text-align:center" colspan="2"> <b>{{$reste}}</b></td>
		</tr>
    </table>
    <table border='1' style="border-collapse: collapse;margin-left:410px;width:300px;margin-top:-175px;" cellspacing="3">
        <thead>
                      <tr>
						<th colspan="3" style="text-align:center">Liste des paiements</th>
					  </tr>
					  <tr>
                        <th style="width:10%;">N°</th>
						<th style="width:40%;">Date</th>
						<th style="width:50%;">Montant</th>
						
                      </tr>
                    </thead>
		 <tbody>
			@foreach($paiement as $paiements)
			@php
			$dp = implode('/', array_reverse(explode('-', $paiements->date)));
			@endphp
           <tr>
		   <td align="center">{{$loop->iteration}}</td>
		   <td align="center">{{$dp}}</td>
		   <td align="center">{{ number_format($paiements->montant, 0, ' ', ' ')}}</td>
		   
		   </tr>
			@endforeach
		</tbody>
		</table>
		<br/>
		<p style="margin-left:430px;margin-top:100px;"><br/>
        Ce <?php echo date('d-m-Y');?>
        </p>
      </div>
        <footer style="position:fixed;bottom:50px;text-align:center;width:100%;font-size:11px">
        <p align="center">
		<hr/>
		Contacts : {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->telephone}} <br/>
				{{DB::table('magasin')->orderBydesc('id')->take(1)->first()->adresse}}<br/>
		<strong>&copy; {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->nom}} 2019-2020 </strong>  </p>
        </footer>
      </body>
     </html> 