@extends('layouts.appadmin')



<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/datetime/1.5.1/css/dataTables.dateTime.min.css">
@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-6">
            <h1  style="color: blue;font-weight: bold;">Liste des clients</h1>
            @if(session('success'))
    <div class="alert alert-success alert-dismissible fade show" role="alert">
        {{ session('success') }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
@endif

@if(session('error'))
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        {{ session('error') }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
@endif

 

          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
<!-- Button trigger modal -->
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-xl">
 Nouveu client
</button>
<!-- Modal -->
<div class="modal fade" id="modal-xl">
          <div class="modal-dialog modal-xl">
            <div class="modal-content">
              <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Ajouter nouveau client</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      <form method="POST" action="{{asset('addclient')}}" enctype="multipart/form-data">      
   @csrf 
   
 <div class="row">
 <div class="col-md-6">
  <div class="form-group">
    <label for="exampleInputEmail1">nom</label>
    <input name="nom" type="text" class="form-control" placeholder="Enter categorie">
    </div>  
    
    <div class="form-group">
    <label for="exampleInputEmail1">Monton</label>
    <input name="monton" type="text" class="form-control" placeholder="Enter categorie">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">telephone</label>
    <input name="tele" type="text" class="form-control" placeholder="Enter categorie">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">adress</label>
    <input name="adress" type="text" class="form-control" placeholder="Enter categorie">
    </div>
    <div class="form-group">
    <label for="exampleInputEmail1">email</label>
    <input name="email" type="text" class="form-control" placeholder="Enter categorie">
    </div> </div> 
    <div class="col-md-6">
    <div class="form-group">
    <label for="exampleFormControlSelect1">ville</label>
    <select name="ville" class="form-control" id="exampleFormControlSelect1">
    @foreach($villes as $ville)
      <option value="{{$ville->id}}">{{$ville->ville}}</option>
     
      @endforeach
    </select>

  </div> 
  <div class="form-group">
    <label for="exampleFormControlSelect1">statut</label>
    <select name="statut" class="form-control" id="exampleFormControlSelect1">
    @foreach($statuts as $statut)
      <option value="{{$statut->id}}">{{$statut->id}}</option>
     
      @endforeach
    </select>

  </div> 

</div>
</div> 
 
  <button type="submit" class="btn btn-primary">Enregistrer</button>
</form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      
      </div>
    </div>
  </div>
</div>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <section class="content">
      <div class="row">
        <div class="col-12">
          <div class="card">
    
          <div class="card-header  bg-info">
          <div class="col-md-3 font-success-bold"><i class="fas fa fa-users"></i>  clients
          <span class="badge badge-pill badge-warning" style="font-size:20px;"> {{$clients->count() }}</span>
          <span>total creances : </span>
          <span class="badge badge-pill badge-warning" style="font-size:20px;"> {{$amountSum}}Dh</span>
      </div>
      
            </div>  

                    <div class="card">
        
              <!-- /.card-header -->
              <div class="card-body">
    

             
              <div class="table-responsive">
            <table id="example" class="table table-bordered display nowrap" cellspacing="0" width="100%"data-order='[[ 0, "desc" ]]'>           
                <thead>
                  
                <tr>
               
                <th style="color: blue;font-weight: bold;">Ref</th>
                <th style="color: blue;font-weight: bold;">nom complet</th>
                <th style="color: blue;font-weight: bold;">statut</th>
          
               <th style="color: blue;font-weight: bold;">date</th>
                <th style="color: blue;font-weight: bold;">ville</th>
           
                <th style="color: blue;font-weight: bold;">tele</th>
                <th style="color: blue;font-weight: bold;">solde</th>
            <th style="color: blue;font-weight: bold;">Reglemen global</th>
                <th style="color: blue;font-weight: bold;">action</th>
                </tr>
                </thead>
                <tbody>
                    @foreach($clients as $client)
                    <tr>
                    <td> {{$client->id}} </td>
                   <!-- detaille_client/'.$client->id-->
             <td> {{$client->nom}} </td>
             <td> 1</td>
  <td> {{$client->created_at}}

  </td>
         
             <td> {{$client->ville->ville}} </td>
             
             <td> {{$client->tele}} </td>
          
        
             <td> {{$client->monton}} </td>
             <td>
         

            <a  data-bs-toggle="modal" data-bs-target="#exampleModa{{$client->id}}" class="btn btn-info btn-sm" href="#">
                            
             Reglement
          </a>
        

    
<!-- Modal -->
<div class="modal fade" id="exampleModa{{$client->id}}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Liquidation total</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
  <form method="POST" action="{{asset('liquidation/'.$client->id)}}" enctype="multipart/form-data">       
@csrf  
<div class="form-group">
<label for="exampleInputEmail1">Entrer montant</label>
<input name="monton" type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter">

</div>
<button type="submit" class="btn btn-primary">enregistrer</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">fermer</button>
</form>
</div>
<div class="modal-footer">


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


             </td>
             <td>
              <a class="btn btn-danger btn-sm" href="{{asset('cientsup/'.$client->id)}}">
                <i class="fas fa-trash">
                </i>
           
            </a>
            <!-- Button trigger modal -->

            <button type="button" class="btn btn-success" data-toggle="modal" data-target="#exampleModal2{{$client->id}}">
            <i class="fas fa-edit"></i> 
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal2{{$client->id}}">
          <div class="modal-dialog modal-xl">
            <div class="modal-content">
              <div class="modal-header">
        <h5 class="modal-title " id="exampleModalLabel">Modifier client {{$client->nom}}<span></span></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      <form method="POST" action="{{asset('mdiflientlient/'.$client->id)}}" enctype="multipart/form-data">      
   @csrf 
   
 <div class="row">
 <div class="col-md-6">
  <div class="form-group">
    <label for="exampleInputEmail1">nom</label>
    <input name="nom" type="text" value="{{$client->nom}}" class="form-control" placeholder="Enter categorie">
    </div>  
    
    <div class="form-group">
    <label for="exampleInputEmail1">Monton</label>
    <input name="monton" value="{{$client->monton}}" type="text" class="form-control" placeholder="Enter categorie">
    </div>  

    <div class="form-group">
    <label for="exampleInputEmail1">telephone</label>
    <input name="tele" type="text" value="{{$client->tele}}" class="form-control" placeholder="Enter categorie">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">email</label>
    <input name="email" type="text" value="{{$client->email}}" class="form-control" placeholder="Enter categorie">
    </div> </div> 
    <div class="col-md-6">
    <div class="form-group">
    <label for="exampleFormControlSelect1">ville</label>
    <select name="ville" value="{{$client->ville_id}}" class="form-control" id="exampleFormControlSelect1">
    @foreach($villes as $ville)
      <option value="{{$ville->id}}">{{$ville->ville}}</option>
     
      @endforeach
    </select>

  </div> 
  <div class="form-group">
    <label for="exampleFormControlSelect1">statut</label>
    <select name="statut" class="form-control" id="exampleFormControlSelect1">
    @foreach($statuts as $statut)
      <option value="{{$client->statut_id}}">{{$statut->id}}</option>
     
      @endforeach
    </select>

  </div> 

</div> 



      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">modifier</button>
      </div>
    </div></form>
  </div>
</div>
                          </a>

            
            
            </td>
              </tr>
             @endforeach
          </tbody>
      
        </table>
        <div class="d-flex justify-content-center mt-4">
          {{ $clients->links('pagination::bootstrap-4') }}
      </div>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>

</div></div>
<!-- ./wrapper -->

@endsection
<!-- jQuery -->

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

<script src="https://cdn.datatables.net/datetime/1.5.1/js/dataTables.dateTime.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.2/moment.min.js"></script>




</body>
</html>
