@extends('layout')
@section('title','Liste de toutes les ventes de la journée ')
@section('description','Liste de toutes les ventes de la journée')
@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
			  </div>
		  </div>
			<div class="row">
              <div class="col-12">
				<div class="card">
                  <div class="card-header">
                    <h4>Recherche</h4>
                  </div>
                  <div class="card-body">
				<form  action="{{route('liste-recherche-ventes-jour')}}" method="POST">
                         {{csrf_field()}}
				  <div class="row" style="padding-top: 30px">
                     <div class="col-lg-5 col-md-5"> 
					  <div class="form-group">
                      <label>Date début <font color="red">*</font></label>
                      <input type="text" class="form-control" name="date_debut" id="champ_date" required>
					  <div id="calendarMain"></div>
                    </div>
					</div>
					<div class="col-lg-5 col-md-5"> 
					  <div class="form-group">
                      <label>Date fin <font color="red">*</font></label>
                      <input type="text" class="form-control" name="date_fin" id="champ_date2" required>
					  <div id="calendarMain2"></div>
                    </div>
					</div>
					<div class="col-lg-2 col-md-2"> 
                      <button class="btn btn-icon icon-left btn-success"><i class="fas fa-search"></i> Rech</button>
					</div>
                      </div>
					<br><br>	  
				</form>
					  
					    </div>
						 
                    </div>
                <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>Nom du dépot/magasin</th>
                            <th>Montant</th>
                          </tr>
                        </thead>
                        <tbody>
						@foreach($magasin as $magasins)
						@php
						$vendu = DB::table('vente')->where('magasin_id', $magasins->id)->get()->sum('montant');
						
						$somvendu1 = DB::table('vente')->get()->sum('montant');
						$vendu =  number_format($vendu, 0, ' ', ' ');
						$somvendu =  number_format($somvendu1, 0, ' ', ' ');
						$tv = $somvendu1;
						@endphp
                          <tr>
							<td style="text-align:center;">{{$loop->iteration}}</td>
							<td style="text-align:center;">{{$magasins->nom}}</td>
							<td style="text-align:center;">{{$vendu}} F</td>
                          </tr>
						  @endforeach
                        </tbody>
                        <tfoot>
							
						  <tr>
								<td></td>
								<td style="text-align:center;"> Total</td>
								<td style="text-align:center;"><b>{{$tv}} F</b></td>
								<td style="text-align:center;"><b></b></td>
							</tr>
                        </tfoot>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
		
@endsection