@extends('layout')
@section('title','Détails facture ')
@section('content')


<div class="section-header">
            <h1>Détails facture</h1>
            <div class="section-header-breadcrumb">
              <div class="breadcrumb-item active"><a href="#">Détails facture</a></div>
              <div class="breadcrumb-item"><a href="#">Détails</a></div>
            </div>
          </div>
        
		  
		  
		  <div class="section-body">
            <div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Détails facture</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
                            <th class="text-center"> N° </th>
                            <th class="text-center">Désignation</th>
                            <th class="text-center">Quantité</th>
							 <th class="text-center">Prix unitaire</th>
							  <th class="text-center">Montant total</th>
							  <th class="text-center">Etat</th>
							  <th class="text-center">Actions</th>
                   
                          </tr>
                        </thead>
                        <tbody>
						 @foreach($detail as $details)
                          <tr>
                            <td class="text-center">{{$loop->iteration}}</td>
                            <td class="text-center"> {{ $details->designation }}</td>
							 
                            <td class="text-center"> {{$details->qte}} </td>
							 @php
                            	
								$mtl = $details->montligne;
                                $mtl1 =  number_format($mtl, 0, ' ', ' ');
								$mp = $details->pu;
                                $mp1 =  number_format($mp, 0, ' ', ' ');
								
                              @endphp
							<td class="text-center"> {{$mp1}} FCFA</td>
							<td class="text-center"> {{$mtl1}} FCFA</td>
							<td class="align-middle">
							    @if( $details->etat ==  "Proforma")
                                <div class="badge badge-warning badge-shadow">{{$details->etat}}</div>
							    @elseif( $details->etat ==  "Validée")
                                      <div class="badge badge-success badge-shadow">{{$details->etat}}</div>
								@else
                                      <div class="badge badge-danger badge-shadow">{{$details->etat}}</div>
                                @endif
                            </td>
							<td style="text-align:center">
							@if ($details->etat == "Proforma")
							<a type="button" href="#" data-id="{{$details->id}}" data-toggle="tooltip" data-placement="bottom" title="Supprimer" class="btn btn-icon btn-danger data-supprimer"><i class="fas fa-trash"></i></a>
							@endif
							</td>
                          </tr>
                      @endforeach
                        </tbody>
                      </table>
					  <a type="button" href="{{route('prestation')}}" class="btn btn-icon btn-primary"><i class="fas fa-chevron-left"></i> Retour</a>
                    </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 vraiment supprimer cette ligne ?
              </div>
              <div class="modal-footer bg-whitesmoke br" style="background-color:#ffffff" id="delete">
                
              </div>
            </div>
          </div>
        </div>
		  
		@push('scripts') 
		<script>
			$(".data-supprimer").on('click', function () {
					var id=$(this).data('id');
					$.get(location.origin+'/es/LignePrestation/'+id, function (data) {
					  var html = `
				<button type="button" class=" btn btn-danger" data-dismiss="modal">Non</button>
						  <form action="{{route('Supprimerdetailprestation')}}" method="post" style="display: inline">
							{{csrf_field()}}
						  <input type="hidden" value="`+data.detail.id+`" name="id" >
						  <button type="submit" class="btn btn-success">Oui</button>

				</form>`
				;
				$('#delete').html('').append(html);
			  })
			  $('#Supprimermodal').modal();
			});
		</script>
		@endpush

@endsection