@extends('layouts.appadmin')

@section('content')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-12">
          
            <h3 style="color: blue;font-weight: bold;">Factures Achats ({{$achats->count()}})</h3>
            <form method="GET" action="{{asset('cherchefacturachat')}}">
  <div class="row mb-4">
    <div class="col-md-3">
      <label for="start_date">Date de début</label>
      <input type="date" name="start_date" id="start_date" class="form-control" value="{{ request('start_date') }}">
    </div>
    <div class="col-md-3">
      <label for="end_date">Date de fin</label>
      <input type="date" name="end_date" id="end_date" class="form-control" value="{{ request('end_date') }}">
    </div>
    <div class="col-md-3">
      <label for="reference">Référence</label>
      <input type="text" name="reference" id="reference" class="form-control" value="{{ request('reference') }}">
    </div>
    <div class="col-md-3">
      <button type="submit" class="btn btn-primary" style="margin-top: 32px;">Rechercher</button>
    </div>
  </div>
</form>



    <section class="content">
      <div class="row">
        <div class="col-12">
          <div class="card">
          <div class="card-header  bg-info">
          <div class="col-md-6 font-weight-bold">Facture achat
      </div> 
      </div> 


 





            <!-- /.card-header -->
            <div class="card-body">
            <div class="table-responsive">
            <table id="exa" class="table table-bordered display nowrap" cellspacing="0" width="100%">
                <thead>
                <tr>
                <th>Ref facture</th>
                  <th>fournisseur</th>
                  <th>date</th>
             
                  <th>Total TTC</th>
              
       
                  <th style="width: 300px;">Action</th>
             
                </tr>
                </thead>
                <tbody>
                    @foreach($achats as $achat)
                    <tr>
             <td> {{$achat->id}} </td> 
             <td class="text-primary font-weight-bold"> <a href="">{{$achat->fournisseur->nom}}</a>   </td> 
             <td>{{date('d-m-Y', strtotime($achat->created_at))}}  </td> 
           
              <td class="text-success font-weight-bold"> {{$achat->prixtotal}} DH</td> 
            
          

             <td>   
             <a class="btn btn-info btn-sm mx-1" href="{{asset('achatpdf/'.$achat->id)}}">
        <i class="fas fa-file-pdf"></i> PDF
    </a>
            
             
    <form style="display:inline">
        @csrf
        <button class="btn btn-primary btn-sm mx-1" type="submit">
            <i class="fas fa-edit"></i> Modifier
        </button>
    </form>
    <form style="display:inline" method="" action="">
    
        <button class="btn btn-danger btn-sm mx-1" type="submit">
            <i class="fas fa-trash"></i> Supprimer
        </button>
    </form>     
            
            </td>
            </tr>
             @endforeach
          </tbody>
        </table>
        <div class="d-flex justify-content-center mt-4">
                                                {{ $achats->links('pagination::bootstrap-4') }}
                                            </div>


                </div>  </div>
    </div>
  
  </div>

                </section>
    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  
        @endsection