@extends('layout')
@section('title','Historique de vente par caissier ')
@section('description','Historique de vente par caissier')
@section('content')
			<br/>
          <div class="section-body">
		  <div class="row">
              <div class="col-12">
			  <br/>
				@if (session('status'))
					<div class="alert alert-warning" style="font-size: 15px; background-color: #328039; color: white">
						<i class="fa fa-check"></i> &nbsp; {{ session('status') }}
					</div>
				@endif
				@if (session('error'))
					<div class="alert alert-danger" style="font-size: 15px; background-color: #fb5757; color: white">
						<i class="ti-na"></i> {{ session('error') }}
					</div>
				@endif
				@if ($errors->any())
					<div class="alert alert-danger" style="font-size: 15px; background-color: #fb5757; color: white" >
						<ul>
							@foreach ($errors->all() as $error)
								<li> <i class="ti-na"></i> {{ $error }}</li>
							@endforeach
						</ul>
					</div>
				@endif
				<br/>
			  </div>
		  </div>
			<div class="section-body">
            <div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Détail des ventes de la caisse : {{DB::table('users')->where('id', $caissier)->first()->login}} au {{implode('/', array_reverse(explode('-', $dd)))}}</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th class="text-center"> ID </th>
                            <th class="text-center"> N° Facture</th>
                            <th class="text-center"> Nom du client </th>
                            <th class="text-center">Produit</th>
                            <th class="text-center">Prix</th>
							<th class="text-center">Qté</th>
                            <th class="text-center">Total</th>
                            <th class="text-center">Etat</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($ligne as $lignes)
                          <tr>
							<td style="text-align:center;">{{$loop->iteration}}</td>
							<td style="text-align:center;">{{DB::table('vente')->where('id', $lignes->vente_id)->first()->numero}}</td>
							<td style="text-align:center;">{{DB::table('vente')->where('id', $lignes->vente_id)->first()->nomcli}}</td>
							<td style="text-align:center;">{{DB::table('produit_vendable')->where('id', $lignes->produit_id)->first()->desi}}</td>
							<td style="text-align:center;">{{$lignes->pv}}</td>
							<td style="text-align:center;">{{$lignes->qte}}</td>
							<td style="text-align:center;">{{$lignes->montligne}}</td>
							<td style="text-align:center;">
								@if ($lignes->etat == "Annulée")
								 <font color="red"> {{$lignes->etat}} </font>
								@else
								{{$lignes->etat}} 
								@endif
							</td>
                          </tr>
						@endforeach
                        </tbody>
                        <tfoot>
						@php
						$tot =  number_format($total, 0, ' ', ' ');
						@endphp
							<tr>
								<td></td>
								<td></td>
								<td style="text-align:center;"><b>Total vente</b></td>
								<td style="text-align:center;"><b>{{number_format($montant, 0, ' ', ' ')}}</b></td>
								<td style="text-align:center;"><b>Total Remise</b></td>
								<td style="text-align:center;"><b>{{number_format($remise, 0, ' ', ' ')}}</b></td>
								<td style="text-align:center;"><b>Total net</b></td>
								<td style="text-align:center;color:red"><b>{{$tot}}</b></td>
							</tr>
                        </tfoot>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          </div>
          </div>
          </div>
@endsection