@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 bg-warning text-white">
        <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 nom">
    </div>  
    
    <div class="form-group">
    <label for="exampleInputEmail1">Monton</label>
    <input name="monton" type="text" class="form-control" placeholder="Enter montant">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">telephone</label>
    <input name="tele" type="text" class="form-control" placeholder="Enter tele">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">adress</label>
    <input name="adress" type="text" class="form-control" placeholder="Enter adress">
    </div>
    <div class="form-group">
    <label for="exampleInputEmail1">email</label>
    <input name="email" type="text" class="form-control" placeholder="Enter email">
    </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-12 d-flex align-items-center">
              <div class="me-3"><i class="fas fa-users"></i> <strong>Clients</strong></div>
              <span class="badge badge-pill badge-warning me-3" style="font-size:20px;">{{$clients->count()}}</span>
              <div class="me-2">Total créances :</div>
              <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;">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 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 bg-warning text-white">
        <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 nom">
    </div>  
    
    <div class="form-group">
    <label for="exampleInputEmail1">Monton</label>
    <input name="monton" value="{{$client->monton}}" type="text" class="form-control" placeholder="Enter montant">
    </div>  

    <div class="form-group">
    <label for="exampleInputEmail1">telephone</label>
    <input name="tele" type="text" value="{{$client->tele}}" class="form-control" placeholder="Enter tele">
    </div>  
    <div class="form-group">
    <label for="exampleInputEmail1">email</label>
    <input name="email" type="text" value="{{$client->email}}" class="form-control" placeholder="Enter email">
    </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>
