@extends('layout')
@section('title','Liste des proforma')
@section('description','Liste des proforma')
@section('content')
			<br/>
<div class="container section-body">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4>Liste des proforma</h4>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped" id="table-1">
                            <thead>
                                <tr>
                                    <th class="text-center"> ID </th>
                                    <th class="text-center"> N° </th>
                                    <th class="text-center"> Client </th>
                                    <th class="text-center">Montant HT</th>
                                    <th class="text-center">Montant Rem.</th>
                                    <th class="text-center">Montant TTC</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($ventes as $vente)
                                <tr>
                                    <td style="text-align:center;">{{$loop->iteration}}</td>
                                    <td style="text-align:center;">D{{$vente->numero}}</td>
                                    <td style="text-align:center;">{{$vente->nomcli}}</td>
                                    @php
                                    $dd = implode('/', array_reverse(explode('-', $vente->date)));
                                    $mht = number_format($vente->montant_ht, 0, ' ', ' ');
                                    $total_taxe2 = number_format($vente->total_taux, 0, ' ', ' ');
                                    $lh3 = number_format($vente->montant, 0, ' ', ' ');

                                    @endphp
                                    <td style="text-align:center;">{{$mht}} F</td>
                                    <td style="text-align:center;">{{$vente->montant_remise}} F</td>
                                    <td style="text-align:center;">{{$lh3}} F</td>
                                    <td class="align-middle">
                                        <a type="button" href="{{route('ligne-proforma',['id'=>$vente->id])}}"
                                            data-toggle="tooltip" data-placement="bottom" title="Détails"
                                            class="btn btn-icon btn-info"><i class="fas fa-info"></i></a>
                                        <a type="button" target="_blank"
                                            href="{{route('facture-proforma',['id'=>$vente->id])}}" data-placement="bottom" data-toggle="tooltip"
										title="Imprimer" 
                                            class="btn btn-icon btn-warning"><i class="fas fa-print"></i></a>
										<a type="button" href="#" data-toggle="tooltip" data-id="{{$vente->id}}" data-placement="bottom" 
										title="Transformer en BL" class="btn btn-icon btn-success data-valider"
										data-toggle="tooltip" data-placement="bottom" title="Transformer en BL"
										><i class="fas fa-file-import"></i></a>
										<a type="button" href="#" data-toggle="tooltip" data-id="{{$vente->id}}" data-placement="bottom" 
										title="Transformer en Facture" class="btn btn-icon btn-danger data-valider2"
										data-toggle="tooltip" data-placement="bottom" title="Transformer en Facture"
										><i class="fas fa-file-import"></i></a>
										<a type="button" href="{{route('modifierproforma',['id'=>$vente->id])}}"
                                            data-toggle="tooltip" data-placement="bottom" title="Modifier"
                                            class="btn btn-icon btn-primary"><i class="fas fa-edit"></i></a>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
          </div>
          </div>
		 <div class="modal fade" id="Supprimermodal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Suppression</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                Voulez-vous supprimer cette vente ?
            </div>
            <div class="modal-footer bg-whitesmoke br" style="background-color:#ffffff" id="delete">

            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="Validermodal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Transformer en BL</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="progress progress-lg" id="pg" style="display:none">
					<div class="progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;height:50px">
						<br>Traitement en cours, veuillez patienter...
					</div>
				</div>
                <p id="nn" style="text-align:center">Voulez-vous transformer en BL?</p>
            </div>
            <div class="modal-footer bg-whitesmoke br" style="background-color:#ffffff" id="valider">

            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="Validermodal2">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Transformer en Facture</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="progress progress-lg" id="pg" style="display:none">
					<div class="progress-bar progress-bar-warning progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;height:50px">
						<br>Traitement en cours, veuillez patienter...
					</div>
				</div>
                <p id="nn" style="text-align:center">Voulez-vous transformer en Facture?</p>
            </div>
            <div class="modal-footer bg-whitesmoke br" style="background-color:#ffffff" id="valider2">

            </div>
        </div>
    </div>
</div>
		@push('scripts') 
		<script>
        $(".data-valider").on('click', function () {
                var id=$(this).data('id');
                $.get(location.origin+'/he/es/Proformav/'+id, function (data) {
                  var html = `
                      <form action="{{route('transformerenfacture')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.proforma.id+`" name="id" >
					  <button type="button" class=" btn btn-danger" data-dismiss="modal" id="bregister2">Non</button>
					  <button type="submit" class="btn btn-success" onclick="myFunction()" id="bregister">Oui</button>

            </form>`
            ;
            $('#valider').html('').append(html);
          })
          $('#Validermodal').modal();
        });
    </script>
    <script>
        $(".data-valider2").on('click', function () {
                var id=$(this).data('id');
                $.get(location.origin+'/he/es/Proformav/'+id, function (data) {
                  var html = `
                      <form action="{{route('transformerenfacture_')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.proforma.id+`" name="id" >
					  <button type="button" class=" btn btn-danger" data-dismiss="modal" id="bregister2">Non</button>
					  <button type="submit" class="btn btn-success" onclick="myFunction()" id="bregister">Oui</button>

            </form>`
            ;
            $('#valider2').html('').append(html);
          })
          $('#Validermodal2').modal();
        });
    </script>
		<script>
        $(".data-supprimer").on('click', function () {
                var id=$(this).data('id');
                $.get(location.origin+'/he/es/Vente/'+id, function (data) {
                  var html = `
            <button type="button" class=" btn btn-danger" data-dismiss="modal">Non</button>
                      <form action="{{route('SupprimerventePost')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.ven.id+`" name="id" >
                      <button type="submit" class="btn btn-success">Oui</button>

            </form>`
            ;
            $('#delete').html('').append(html);
          })
          $('#Supprimermodal').modal();
        });
    </script>
		<script>
        $(".data-annuler").on('click', function () {
                var id=$(this).data('id');
                $.get(location.origin+'/he/es/Annulervente/'+id, function (data) {
                  var html = `
            <button type="button" class=" btn btn-danger" data-dismiss="modal">Non</button>
                      <form action="{{route('AnnulerventePost')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.vent.id+`" name="id" >
                      <button type="submit" class="btn btn-success">Oui</button>

            </form>`
            ;
            $('#annuler').html('').append(html);
          })
          $('#Annulermodal').modal();
        });
    </script>
@endpush
@endsection