@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">
           
            @if ($ventes->count() == 0) 
       
    <div class="alert alert-success alert-dismissible fade show" role="alert">
        <p>Aucune facture à liquider.</p>
    </div>
@endif
          <h1 style="color: blue;font-weight: bold;">Reglement des Factures de ventes({{$ventes->count()}})</h3>

          </div><!-- /.col -->
          <div class="col-sm-6">
          
         </div>  </div>  </div>
     

    <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"><i class="fas  fa fa-users"></i> 
          vous avez 2 facture(s) arrivant a échéance.
      </div> 
      </div> 


 



 
            <!-- /.card-header -->
         
            <div class="card-body">
              <table  class="table table-bordered table-striped text-center">
                <thead>
                <tr>

                  <th>Ref facture</th>
                  <th>client</th>
                  <th>date</th>
                  <th>Mode réglement</th>
                  <th>Total TTC</th>
                  <th>Etat</th>
                  <th>avance</th>
                  <th>rest</th>
                  <th>Echeance</th>
                  <th width="210">action</th>
             
                </tr>
                </thead>
                <tbody>
               

                    @foreach($ventes as $vente)
                    <tr>
           
                      <td>{{$vente->id}} </td>

             <td class="text-primary font-weight-bold"> <a href="">{{$vente->client->nom}}</a>   </td> 
             <td>{{date('d-m-Y', strtotime($vente->createf_at))}}  </td> 
                <td> {{$vente->modepayement->mode}} </td> 
              <td class="text-success font-weight-bold"> {{$vente->prixtotal}} DH</td> 
             <td> {{$vente->encour->etat}} </td> 
             <td> {{$vente->avance}} </td> 
             <td> {{$vente->rest}} </td> 
             <td> {{$vente->dateecheance}} </td> 
            
             <td>
          
                          <a  data-toggle="modal" data-target="#exampleModal{{$vente->id}}" class="btn btn-info btn-sm" href="#">
                              <i class="fas fa-pencil-alt">
                              </i>
                              Reglement
                          </a>
                      


<!-- Modal -->
<div class="modal fade" id="exampleModal{{$vente->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-success font-weight-bold" id="exampleModalLabel ">changer etat facture :{{$vente->id}}</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        cette factur doit etre régiée avant le {{$vente->dateecheance}} (11)
      {{$vente->id}}
      <h2>Mntant de Facture: {{$vente->prixtotal}} DH</h2>  
    <h2>Avance: {{$vente->avance}} DH</h2>  
    <h2>rest: {{$vente->rest}} DH</h2>  
    <form method="POST" action="{{asset('modiffacture/'.$vente->id)}}" enctype="multipart/form-data">   
    @csrf     
  <div class="form-group">
    <label for="exampleInputEmail1">Nouveau vercement</label>
    <input name="monton" type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter">
    </div>  


        <button type="submit" class="btn btn-primary">Save changes</button>
</form>
      </div>
      <div class="modal-footer">

    
      </div>
    </div>
  </div>
</div>
             </td>
            </tr>
             @endforeach
          </tbody>
        </table>
        <div class="d-flex justify-content-center mt-4">
          {{ $ventes->links('pagination::bootstrap-4') }}
      </div>
</div>


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

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

        <script src="{{asset('dash/plugins/jquery/jquery.min.js')}}"></script>







</body>
</html>