<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>Facture globale</title>
		<style>
		table {
			border-collapse: collapse;
			border-radius: 1em;
			overflow: hidden;
		}
		
		th, td {
			padding : 0.4em;
			background : #EEEEE4;
			border-bottom: 2px solid white;
			font-size:14px;
		}
		
		
		.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">
			    <div style="display:inline-block;position:absolute;margin-left:-30px">
			    <!--<img src="logo/i1.jpg" style="height:40px;margin-bottom:2px;margin-left:10px">-->
			    </div>
                <span style="margin-top:15px;margin-bottom:10px;color:#000;font-size:25px;margin-left:-40px"><b>ETS MAHAMED</b></span><br><hr style="width:60px;">
                <div style="display:inline-block;position:absolute">
			    <!--<img src="logo/i2.jpg" style="height:40px;margin-bottom:2px;margin-left:400px;margin-top:-45px">-->
			    </div>
<span style="margin-top:20px;color:#000;font-size:14px;text-align:center"><b>Sale of Tenis Shoes (Adidas, Nike, Campus, Airmax)</b></span><br>	
<span style="margin-top:15px;color:#000;font-size:13px;text-align:center">Tel: (+228) 92727244/ 99245555 </span><br>	
<span style="margin-top:15px;color:#000;font-size:13px;text-align:center">Grand marche, Lome Togo</span><br>	
				</p>
				
		    </div>
		</div>
		<!--BLOC DU GERANT-->
		<br/><br/>
		<div class="container">
		<div class="row"> 
		
				
				<div class="col-md-12" style="margin-left:80px;margin-top:-30px;width:500px;border:1px solid #000;border-radius:10px;height:60px">
				<h6 align="center">GLOBAL PURCHASE AND PAYMENT INVOICE : <b>{{$client->noms}}</b></h6>
			    </div>
			    
		</div>
		</div>
     <center>
	    <br/>
	    <br/>
		<div style="width:360px;margin-left:20px">
			<table style="border-collapse: collapse;width:360px;margin-left:-30px">
			<thead>
			<tr>
				<th colspan="3">Sales list</th>
			  </tr>
			  <tr>
				<th style="text-align:left">N°</th>
				<th style="text-align:left">Date</th>
				<th >Amount</th>
			  </tr>
			</thead>
			<tbody>
				@foreach($vente as $ventes)
				<tr>
					<td style="text-align:left">{{$loop->iteration}}</td>
					<td style="text-align:left">{{$ventes->date}}</td>
					<td style="text-align:right">{{number_format($ventes->montant, 0, ' ', ' ')}}</td>
				</tr>
				@endforeach
				<tr>
					<td></td>
					<td ><b>Total amount</b></td>
					<td style="text-align:right"><b>{{number_format($tvente, 0, ' ', ' ')}}</b></td>
				</tr>
			</tbody>
			</table>
		</div>
		
		<div style="width:370px; margin-left:405px;margin-top:-145px">
			<table style="border-collapse: collapse;width:300px;margin-left:-30px">
			<thead>
			<tr>
				<th colspan="3">List of payments</th>
			  </tr>
			  <tr>
				<th style="text-align:left">N°</th>
				<th style="text-align:left">Date</th>
				<th >Amount paid</th>
			  </tr>
			</thead>
			<tbody>
				@foreach($paie as $paies)
				<tr>
					<td>{{$loop->iteration}}</td>
					<td>{{$paies->date}}</td>
					<td style="text-align:right">{{number_format($paies->montant, 0, ' ', ' ')}}</td>
				</tr>
				@endforeach
				<tr>
					<td></td>
					<td><b>Total payment</b></td>
					<td style="text-align:right"><b>{{number_format($tpaie, 0, ' ', ' ')}}</b></td>
				</tr>
			</tbody>
			</table>
		</div>
		
		@php
			 $today = date('Y-m-d');
			 $df = date_parse($today);
			 $y = $df['year'];
			 $si = DB::table('soldepaiment')
					->whereYear('date', '=', $y)
					->where('etat', 'Validée')
					->where('client_id', $client->id)
					->get()->count();
			 if ($si>0){
			 $sd = DB::table('soldepaiment')
					->whereYear('date', '=', $y)
					->where('etat', 'Validée')
					->where('client_id', $client->id)
					->orderBydesc('id')
					->take(1)->first()->montant;
			 }else{
				$sd = 0;
			 }
			 
			$reste = ($sd + $tvente) - $tpaie;
		@endphp
		<br/>
		<br/>
		<br/>
		<div style="width:200px; margin-left:230px;margin-left:405px">
			<table style="border-collapse: collapse;width:300px;margin-left:-30px">
			<thead>
			<tr>
				<th colspan="2">Account</th>
			  </tr>
			</thead>
			<tbody>
				<tr>
					<td>Balance before</td>
					<td style="text-align:right">{{number_format($sd, 0, ' ', ' ')}}</td>
				</tr>
				<tr>
					<td>Total purchase</td>
					<td style="text-align:right">{{number_format($tvente, 0, ' ', ' ')}}</td>
				</tr>
				<tr>
					<td>Total Payment</td>
					<td style="text-align:right">{{number_format($tpaie, 0, ' ', ' ')}}</td>
				</tr>
				<tr>
					<td><b>Still to pay</b></td>
					<td style="color:brown; text-align:right"><b>{{number_format($reste, 0, ' ', ' ')}}</b></td>
				</tr>
			</tbody>
			</table>
		</div>
		
        <footer style="position:fixed;bottom:0;text-align:center;">
        <p align="center"><strong></strong>  </p>
        </footer>
      </body>
     </html> 