@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 class="font-weight-bold">Factures de vente ({{$ventes->count()}})</h3>
          <form method="get" action="{{asset('date_vente')}}">
  <div class="form-row">
    <div class="col">
      <input type="date" name="debut" class="form-control" placeholder="City">
    </div>
    <div class="col">
      <input type="date" name="fin" class="form-control" placeholder="State">
    </div>
    <div class="col">
    <button type="submit" class="btn btn-primary">Filter</button>
    </div>
  </div>
</form>
          </div><!-- /.col -->
          <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <a href="{{asset('vente')}}" class="btn btn-info">+facture</a>
            </ol>
         </div>  </div>  </div>
     

    <section class="content">
    <div class="content">
      <div class="container-fluid">
   


 
        <div class="row">
          <div class="col-12 col-sm-12">
            <div class="card card-info card-tabs">
              <div class="card-header p-0 pt-1">
                <ul class="nav nav-tabs" id="custom-tabs-one-tab" role="tablist">
                  <li class="nav-item">
                    <a class="nav-link active" id="custom-tabs-one-home-tab" data-toggle="pill" href="#custom-tabs-one-home" role="tab" aria-controls="custom-tabs-one-home" aria-selected="true">tous les factures</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" id="custom-tabs-one-profile-tab" data-toggle="pill" href="#custom-tabs-one-profile" role="tab" aria-controls="custom-tabs-one-profile" aria-selected="false">factures payer</a>
                  </li>
                
                  <li class="nav-item">
                    <a class="nav-link" id="custom-tabs-one-regle-tab" data-toggle="pill" href="#custom-tabs-one-regle" role="tab" aria-controls="custom-tabs-one-regle" aria-selected="false">factures en cours</a>
                  </li>
             
                </ul>
              </div>
              <div class="card-body">
                <div class="tab-content" id="custom-tabs-one-tabContent">
                  <div class="tab-pane fade show active" id="custom-tabs-one-home" role="tabpanel" aria-labelledby="custom-tabs-one-home-tab">

            <!-- /.card-header -->
     

            <div class="card-body">
            <div class="table-responsive">
            <div class="table-responsive">
            <table id="example" class="table table-bordered display nowrap" cellspacing="0" width="100%"
                data-order='[[ 0, "desc" ]]'>
                <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>action</th>
             
             
                </tr>
                </thead>
                <tbody>
                    @foreach($ventes as $vente)
                    <tr>
                      <td>{{$vente->id}} </td>
                    
             <td class="text-primary font-weight-bold"> <a href="{{asset('detaille_client/'.$vente->client_id)}}">{{$vente->client->nom}}</a>   </td> 
             <td>{{date('d-m-Y', strtotime($vente->created_at))}}  </td> 
                <td> {{$vente->modepayement->mode}} </td> 
              <td class="text-success font-weight-bold"> {{$vente->prixtotal}} DH</td> 
             <td> {{$vente->encour->etat}} </td> 
             <td> 

             <a class="btn btn-info btn-sm" href="{{asset('ventepdf/'.$vente->id)}}">
             <i style="color:aliceblue" class="fas fa-file"></i>
             </a>   
             <a class="btn btn-warning btn-sm" href="{{asset('ventepdfsansentete/'.$vente->id)}}">
             <i style="color:aliceblue" class="fas fa-plus"></i>
             </a>   
             
             <form style="display:inline" method="GET" action="{{asset('modifevente2')}}" >      
   @csrf 
  <input name="idvente" type="hidden" value="{{$vente->id}}"type="hidden">
  <button class="btn btn-primary btn-sm" type="submit">
  <i class="fas fa-edit">
                                </i>
  </button>  
  </form>
  <a class="btn btn-danger btn-sm" href="{{asset('deletevente/'.$vente->id)}}">
  <i class="fas fa-trash"></i>
                                
             </a>


         <!-- Button trigger modal -->
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal{{$vente->id}}">
 + categorie
</button>

<!-- 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 bg-info text-white">

      <div class="modal-body">
      <div class="card-body">
            <div class="table-responsive">

                  <table id="example1" class="table table-bordered table-striped text-center" data-order='[[ 0, "desc" ]]'>
                <thead>
                <tr>
                  <th>Ref facture</th>
                  <th>user</th>
                  <th>operation</th>
                   <th>date operation</th>
               
                
             
             
                </tr>
                </thead>
                <tbody>
                    @foreach($hystorique_factur as $hyst)
                    @if($hyst->facture_id==$vente->id)
                    <tr>
                      <td>{{$hyst->facture_id}} </td>
                      <td>{{$hyst->user->name}} </td>
                      <td>{{$hyst->catfacture->cat}} </td>
                      <td>{{$hyst->created_at}} </td>
         
          
            
  
            </tr>
            @endif
             @endforeach
          </tbody>
     
        </table>
</div>
          
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    
             </td> 
            
  
            </tr>
             @endforeach
          </tbody>
          <tfoot>
            <tr>
            <th></th>
                  <th></th>
                  <th></th>
                 
                  <th>Total TTC</th> 
                  <th></th>
                  <th></th>
                  <th></th>
               
             
            </tr>
        </tfoot>
        </table>
</div> 
</div> 



             
    </div>












                
                  <div class="tab-pane fade" id="custom-tabs-one-profile" role="tabpanel" aria-labelledby="custom-tabs-one-profile-tab">
                  

                  <div class="card-body">
            <div class="table-responsive">

                  <table id="example2" class="table table-bordered table-striped text-center" data-order='[[ 0, "desc" ]]'>
                <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>action</th>
             
             
                </tr>
                </thead>
                <tbody>
                @foreach($ventes_payer as $vente)
                    <tr>
                      <td>{{$vente->id}} </td>
                    
             <td class="text-primary font-weight-bold"> <a href="{{asset('detaille_client/'.$vente->client_id)}}">{{$vente->client->nom}}</a>   </td> 
             <td>{{date('d-m-Y', strtotime($vente->created_at))}}  </td> 
                <td> {{$vente->modepayement->mode}} </td> 
              <td class="text-success font-weight-bold"> {{$vente->prixtotal}} DH</td> 
             <td> {{$vente->encour->etat}} </td> 
             <td> 

<a class="btn btn-infoo btn-sm" href="{{asset('ventepdf/'.$vente->id)}}">
<i style="color:aliceblue" class="fas fa-file"></i>
</a>   
<a class="btn btn-warning btn-sm" href="{{asset('ventepdfsansentete/'.$vente->id)}}">
<i style="color:aliceblue" class="fas fa-plus"></i>
</a>   

<form style="display:inline" method="POST" action="{{asset('modifevente2')}}" >      
@csrf 
<input name="idvente" type="hidden" value="{{$vente->id}}"type="hidden">
<button class="btn btn-primary btn-sm" type="submit">
<i class="fas fa-edit"></i>
</button>  
</form>
<a class="btn btn-danger btn-sm" href="{{asset('deletevente/'.$vente->id)}}">
<i class="fas fa-trash"></i>
</a>
</td> 
            
  
            </tr>
             @endforeach
          </tbody>
          <tfoot>
            <tr>
            <th></th>
                  <th></th>
                  <th></th>
                 
                  <th>Total TTC</th> 
                  <th></th>
                  <th></th>
                  <th></th>
               
             
            </tr>
        </tfoot>
        </table>
</div> 
</div> 



             
    </div>










   

     
                  <div class="tab-pane fade" id="custom-tabs-one-regle" role="tabpanel" aria-labelledby="custom-tabs-one-regle-tab">
                  
                
            <div class="card-body">
            <div class="table-responsive">

                  <table id="example5" class="table table-bordered table-striped text-center" data-order='[[ 0, "desc" ]]'>
                <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>action</th>
             
             
                </tr>
                </thead>
                <tbody>
                @foreach($ventes_encour as $vente)
                    <tr>
                      <td>{{$vente->id}} </td>
                    
             <td class="text-primary font-weight-bold"> <a href="{{asset('detaille_client/'.$vente->client_id)}}">{{$vente->client->nom}}</a>   </td> 
             <td>{{date('d-m-Y', strtotime($vente->created_at))}}  </td> 
                <td> {{$vente->modepayement->mode}} </td> 
              <td class="text-success font-weight-bold"> {{$vente->prixtotal}} DH</td> 
             <td> {{$vente->encour->etat}} </td> 
             <td> 

<a class="btn btn-info btn-sm" href="{{asset('ventepdf/'.$vente->id)}}">
<i style="color:aliceblue" class="fas fa-file"></i>
</a>   
<a class="btn btn-warning btn-sm" href="{{asset('ventepdfsansentete/'.$vente->id)}}">
<i style="color:aliceblue" class="fas fa-plus"></i>
</a>   

<form style="display:inline" method="POST" action="{{asset('modifevente2')}}" >      
@csrf 
<input name="idvente" type="hidden" value="{{$vente->id}}"type="hidden">
<button class="btn btn-primary btn-sm" type="submit">
<i class="fas fa-edit"></i>
</button>  
</form>
<a class="btn btn-danger btn-sm" href="{{asset('deletevente/'.$vente->id)}}">
<i class="fas fa-trash"></i>
</a>
</td> 
            
  
            </tr>
             @endforeach
          </tbody>
          <tfoot>
            <tr>
            <th></th>
                  <th></th>
                  <th></th>
                 
                  <th>Total TTC</th> 
                  <th></th>
                  <th></th>
                  <th></th>
               
             
            </tr>
        </tfoot>
        </table>
</div> 
</div> 



             
    </div>










              


                </div>
              </div>
              <!-- /.card -->


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

 




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

        <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>

<script src="https://cdn.datatables.net/datetime/1.5.1/js/dataTables.dateTime.min.js"></script>





<script>
$(document).ready(function() {
   $('#example').DataTable( {
responsive:true,
    "footerCallback": function( tfoot, data, start, end, display ) {
    var api = this.api();
    $( api.column( 4 ).footer() ).html(
        api.column( 4 ).data().reduce( function ( a, b ) {
          $('#tot').html(parseInt(a) + parseInt(b));
            return parseInt(a) + parseInt(b);
        }, 0 )
    );

  } ,

      dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ],
        dom: 'Bfrtip',     
    buttons: [      
           
         {
            extend: 'excelHtml5',
            title: 'Report',
       
         },
        {
            extend: 'pdfHtml5',
            footer: true ,
            title: 'facture des ventes  ',
            exportOptions: {
                    columns: [ 0, 1 ,2,3,4,5]
                }
        },
        {
            extend:'print'  ,
            footer: true ,
            title: 'facture des ventes  ',
            exportOptions: {
                    columns: [ 0, 1 ,2,3,4,5]
                }           
        }
 
    ]   

    
    } );
    $('#example2').DataTable( {

"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api();
$( api.column( 4 ).footer() ).html(
    api.column( 4 ).data().reduce( function ( a, b ) {
      $('#tot').html(parseInt(a) + parseInt(b));
        return parseInt(a) + parseInt(b);
    }, 0 )
);

} ,

  dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],
    dom: 'Bfrtip',     
buttons: [      
       
     {
        extend: 'excelHtml5',
        title: 'Report',
   
     },
    {
        extend: 'pdfHtml5',
        footer: true ,
        title: 'factures payer',
        exportOptions: {
                columns: [ 0, 1,3,4,5 ]
            }
    },
    {
        extend:'print'             
    }

]   


} );
$('#example3').DataTable( {

"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api();
$( api.column( 4 ).footer() ).html(
    api.column( 4 ).data().reduce( function ( a, b ) {
      $('#tot').html(parseInt(a) + parseInt(b));
        return parseInt(a) + parseInt(b);
    }, 0 )
);

} ,

  dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],
    dom: 'Bfrtip',     
buttons: [      
       
     {
        extend: 'excelHtml5',
        title: 'Report',
   
     },
    {
        extend: 'pdfHtml5',
        footer: true ,
        title: 'factures urgents  ',
        exportOptions: {
                columns: [ 0, 1,2,3,4,5 ]
            }
    },
    {
        extend:'print'             
    }

]   


} );
$('#example4').DataTable( {

"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api();
$( api.column( 4 ).footer() ).html(
    api.column( 4 ).data().reduce( function ( a, b ) {
      $('#tot').html(parseInt(a) + parseInt(b));
        return parseInt(a) + parseInt(b);
    }, 0 )
);

} ,

  dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],
    dom: 'Bfrtip',     
buttons: [      
       
     {
        extend: 'excelHtml5',
        title: 'Report',
   
     },
    {
        extend: 'pdfHtml5',
        footer: true ,
        title: 'facture en attands  ',
        exportOptions: {
                columns: [ 0, 1,2,3,4,5 ]
            }
    },
    {
        extend:'print'             
    }

]   


} );
$('#example5').DataTable( {

"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api();
$( api.column( 4 ).footer() ).html(
    api.column( 4 ).data().reduce( function ( a, b ) {
      $('#tot').html(parseInt(a) + parseInt(b));
        return parseInt(a) + parseInt(b);
    }, 0 )
);

} ,

  dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],
    dom: 'Bfrtip',     
buttons: [      
       
     {
        extend: 'excelHtml5',
        title: 'Report',
   
     },
    {
        extend: 'pdfHtml5',
        footer: true ,
        title: 'factures en cours  ',
        exportOptions: {
          columns: [ 0, 1,2,3,4,5 ]
            }
    },
    {
        extend:'print'             
    }

]   


} );
} );
</script>
</body>
</html>