@extends('layout')
@section('title','Liste de toutes les ventes ')
@section('description','Liste de toutes les ventes')
@section('content')
			<br/>
          <div class="section-body">
		  <div class="row">
              <div class="col-12">
			  @if ($count>0 || $count2>0)
			  <form action="{{route('Cloturervente')}}" method="post">
				{{csrf_field()}}
			  <button type="submit" class="btn btn-icon btn-danger pull-right"><i class="fas fa-check"></i> Cloturer les ventes de la journée</button>
			  </form>
			  @endif
			  <br/>
			  <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
			  </div>
		  </div>
			<div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Liste des ventes</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th>N°</th>
                            <th>Date</th>
                            <th>Montant</th>
                            <th>Etat</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($ventes as $vente)
                          <tr>
							@php
							$dd = $vente->date;
							$dd= explode('-', $dd);
							$dd= array_reverse($dd);
							$dd= implode('/', $dd);
							@endphp
							<td style="text-align:center;">{{$vente->numero}}</td>
							<td style="text-align:center;">{{$dd}}</td>
							@php
							
							$dd = implode('/', array_reverse(explode('-', $vente->date)));
						    
							$lh1 =  number_format($vente->montant, 0, ' ', ' ');
							
							@endphp
							
							<td style="text-align:center;">{{$lh1}} FCFA</td>
							<td style="text-align:center;">
							@if( $vente->etat ==  "Proforma")
							<div class="badge badge-warning badge-shadow">{{$vente->etat}}</div>
							@elseif( $vente->etat ==  "Validée")
							<div class="badge badge-success badge-shadow">{{$vente->etat}}</div>
							@else
							<div class="badge badge-danger badge-shadow">{{$vente->etat}}</div>
							@endif
							</td>
                          </tr>
						  @endforeach
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
			<div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Liste des paiements clients</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th style="text-align:center;">N°</th>
                            <th style="text-align:center;">Date</th>
                            <th style="text-align:center;">Montant</th>
                            <th style="text-align:center;">Etat</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($paiecli as $paiecli)
                          <tr>
							@php
							$ddd = $paiecli->date;
							$ddd= explode('-', $ddd);
							$ddd= array_reverse($ddd);
							$ddd= implode('/', $ddd);
							@endphp
							<td style="text-align:center;">{{$loop->iteration}}</td>
							<td style="text-align:center;">{{$ddd}}</td>
							@php
						
							$lh11 =  number_format($paiecli->montant, 0, ' ', ' ');
							
							@endphp
							
							<td style="text-align:center;">{{$lh11}} FCFA</td>
							<td style="text-align:center;">
							@if( $paiecli->etat ==  "En cours")
							<div class="badge badge-warning badge-shadow">{{$paiecli->etat}}</div>
							@elseif( $paiecli->etat ==  "Validé")
							<div class="badge badge-success badge-shadow">{{$paiecli->etat}}</div>
							@else
							<div class="badge badge-danger badge-shadow">{{$paiecli->etat}}</div>
							@endif
							</td>
                          </tr>
						  @endforeach
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Liste des dépenses</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th style="text-align:center;">N°</th>
                            <th style="text-align:center;">Date</th>
                            <th style="text-align:center;">Type</th>
                            <th style="text-align:center;">Montant</th>
                            <th style="text-align:center;">Etat</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($dep as $deps)
                          <tr>
							@php
							$ddd1 = $deps->date;
							$ddd1= explode('-', $ddd1);
							$ddd1= array_reverse($ddd1);
							$ddd1= implode('/', $ddd1);
							@endphp
							<td style="text-align:center;">{{$loop->iteration}}</td>
							<td style="text-align:center;">{{$ddd1}}</td>
							<td style="text-align:center;">{{$deps->nature}}</td>
							@php
						
							$lh111 =  number_format($deps->montant, 0, ' ', ' ');
							
							@endphp
							
							<td style="text-align:center;">{{$lh111}} FCFA</td>
							<td style="text-align:center;">
							@if( $deps->etat ==  "En cours")
							<div class="badge badge-warning badge-shadow">{{$deps->etat}}</div>
							@elseif( $deps->etat ==  "Validée")
							<div class="badge badge-success badge-shadow">{{$deps->etat}}</div>
							@else
							<div class="badge badge-danger badge-shadow">{{$deps->etat}}</div>
							@endif
							</td>
                          </tr>
						  @endforeach
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
			<div class="row" hidden>
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Liste des consignations non clôturées</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th>N°</th>
                            <th>Date</th>
                            <th>Montant</th>
                            <th>Etat</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($consignation as $consignations)
                          <tr>
							@php
							$dd = $consignations->date;
							$dd= explode('-', $dd);
							$dd= array_reverse($dd);
							$dd= implode('/', $dd);
							@endphp
							<td style="text-align:center;">{{$consignations->numero}}</td>
							<td style="text-align:center;">{{$dd}}</td>
							@php
							
							$dd = implode('/', array_reverse(explode('-', $consignations->date)));
						    
							$lh1 =  number_format($consignations->montant, 0, ' ', ' ');
							
							@endphp
							
							<td style="text-align:center;">{{$lh1}} FCFA</td>
							<td style="text-align:center;">
							@if( $consignations->etat ==  "Proforma")
							<div class="badge badge-warning badge-shadow">{{$consignations->etat}}</div>
							@elseif( $consignations->etat ==  "Validée")
							<div class="badge badge-success badge-shadow">{{$consignations->etat}}</div>
							@else
							<div class="badge badge-danger badge-shadow">{{$consignations->etat}}</div>
							@endif
							</td>
                          </tr>
						  @endforeach
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
		
@endsection