<html>
    <head>
	
        <title>Facture client</title>
    </head>
	<style>

		table {
			border-collapse: collapse;
			border-radius: 1em;
			overflow: hidden;
		}
		
		th, td {
			padding : 0.3em;
			background : #ddd;
			border-bottom: 2px solid white;
		}

	.bloc2{
		display:inline-block;
		position:relative;
		text-align:center;
		margin-top:-25px;
		width:100%;
		padding-top: -10px;
		border-bottom:1px solid #000;
	}
	
		
		</style>
      <body style="font-family:'Montserrat';">
            <div class="bloc"> 
		   @php
			$ig = DB::table('magasin')->where('id', $prestation->magasin_id)->first()->logo_fichier;
			@endphp
			<div class="bloc2">
				<p style="margin-top:15px;color:#000;font-size:16px;">
				<img src="{{public_path('/storage/'.$ig)}}" style="height:75px"> <br/>
				<b><u>{{DB::table('magasin')->where('id', $prestation->magasin_id)->first()->nom}}</u><br>
				{{DB::table('magasin')->where('id', $prestation->magasin_id)->first()->telephone}} {{DB::table('magasin')->where('id', $prestation->magasin_id)->first()->email}} <br/>
				{{DB::table('magasin')->where('id', $prestation->magasin_id)->first()->adresse}}
				</b>
				</p>
		    </div>
		    </div>
		<!--BLOC DU GERANT-->
		<div class="container">
		<div class="row"> 
                <div class="col-md-4" style="margin-left:540px;">
					<p><b><font color="brown"><u>FACTURE</u></font></b></p>
					<p><b>No @if ($prestation->etat=="Validée") Facture @else Proforma @endif : {{$prestation->numero}}</b></p>
					@php
					$date_prestation= explode('-', $prestation->date_prestation);
					$date_prestation= array_reverse($date_prestation);
					$date_prestation= implode('/', $date_prestation);
					@endphp
					<p><b>Client : {{DB::table('fournisseur')->where('id', $prestation->client_id)->first()->nom}}</b></p>
					<p><b>Date :</b> {{$date_prestation}}</p>
			    </div>
				<div class="col-md-4" style="margin-left:50px;margin-top:-180px">
				<p><b><font color="brown"><u>EMETTEUR</u></font></b></p>
					<p><b>{{DB::table('magasin')->orderBydesc('id')->take(1)->first()->nom}}</b></p>
					<p><b>Contacts : {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->telephone}}</b></p>
					@php
					$date_prestation= explode('-', $prestation->date_prestation);
					$date_prestation= array_reverse($date_prestation);
					$date_prestation= implode('/', $date_prestation);
					@endphp
					<p><b>Email : {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->email}}</b></p>
					<p><b>Adresse : {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->adresse}}</b></p>
		        </div>
		</div>
		</div>
     <center>
	    <br/>
        <table class="rpp" style="border-collapse: collapse;margin-left:25px;width:auto" cellspacing="3">
		<thead>
                      <tr style="background-color:#FAFAD2">
                        <th style="width:55px;">N°</th>
                        <th style="width:105px;">Désignation</th>
						<th style="width:105px;">P.U</th>
                        <th style="width:105px;">Qté</th>
						<th style="width:205px;">Montant</th>
                      </tr>
                    </thead>
        <tbody>
			@foreach($ligne as $lignes)
           <tr>
		   <td align="center">{{$loop->iteration}}</td>
			<td width="200px" height="30px" align="center">
			{{$lignes->designation}}
			</td>
			<td align="center">{{$lignes->pu}}</td>
			<td align="center">{{$lignes->qte}}</td>
			<td align="center">{{$lignes->montligne}} </td>
			</tr>
			@endforeach
			<tr>
				<td colspan="3"></td>
				<td height="25px" style="text-align:center"> <b>Total HT </b></td>
				@php
			$lh = $prestation->montant;
			$lh1 =  number_format($lh, 0, ' ', ' ');
			$tva = DB::table('taxes')->sum('taux');
			$ttaxes = $lh * $tva;
			$ttc = $lh + ( $lh * $tva);
			@endphp
			<td style="text-align:center;background-color:#FAFAD2"> <b>{{number_format($prestation->montant, 0, ' ', ' ')}} </b></td>
			</tr>
			<tr>
				<td colspan="3"></td>
				<td height="25px" style="text-align:center"> <b>Remise </b></td>
				<td style="text-align:center;background-color:#FAFAD2"> <b>{{number_format($prestation->remise, 0, ' ', ' ')}}  </b></td>
			</tr>
			<tr>
				<td colspan="3"></td>
				<td height="25px" style="text-align:center"> <b>Montant Taxes ({{$tva * 100}}%) </b></td>
				<td style="text-align:center;background-color:#FAFAD2"> <b>{{number_format($prestation->montant_taxe, 0, ' ', ' ')}} </b></td>
			</tr>
			<tr>
				<td colspan="3"></td>
				<td height="25px" style="text-align:center"> <b>Montant TTC </b></td>
				<td style="text-align:center;background-color:#FAFAD2"> <b>{{number_format($prestation->ttc, 0, ' ', ' ')}} </b></td>
			</tr>
		</tbody>
        </table>
		<p style="margin-top:50px; font-size:18px;text-align:center;">
			<strong>@if ($prestation->etat=="Validée") Facture @else Proforma @endif arrêtée à la somme de <u><i><font color="brown">{{$montant1}} francs </font></i></u>
			</strong><br/>
        </p>
      </div>
        <footer style="position:fixed;bottom:0;text-align:center;">
        <p align="center"><strong>&copy; {{DB::table('magasin')->orderBydesc('id')->take(1)->first()->nom}} </strong>  </p>
        </footer>
      </body>
     </html> 