@extends('layout')
@section('title','Détails retour commande')
@section('content')
<br/>
		  <div class="section-body">
            <div class="row">
              <div class="col-12">
			  @if (session('status'))
            <div class="alert alert-warning" style="font-size: 15px; background-color: #328039; color: white">
                <i class="fa fa-check"></i> &nbsp; {{ session('status') }}
            </div>
            @endif
            @if (session('error'))
            <div class="alert alert-danger" style="font-size: 15px; background-color: #fb5757; color: white">
                <i class="ti-na"></i> {{ session('error') }}
            </div>
            @endif
            @if ($errors->any())
            <div class="alert alert-danger" style="font-size: 15px; background-color: #fb5757; color: white">
                <ul>
                    @foreach ($errors->all() as $error)
                    <li> <i class="ti-na"></i> {{ $error }}</li>
                    @endforeach
                </ul>
            </div>
            @endif
                <div class="card">
                  <div class="card-header">
                    <h4>Détails retour commande</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 (en FCFA)</th>
							  <th class="text-center">Montant total (en FCFA)</th>
							   <th class="text-center">Actions</th>
                   
                          </tr>
                        </thead>
                        <tbody>
	@foreach($detail as $details)
	<tr>
		<td>
        {{$loop->iteration}}
        </td>
        <td>
        {{ DB::table('produit_vendable')->where('id', $details->produit_id)->first()->desi }}/
        {{ DB::table('produit_vendable')->where('id', $details->produit_id)->first()->code }}
        </td>
        @php
		$lh = $details->pu;
		$lh1 =  number_format($lh, 0, ' ', ' ');

        $lh2 = $details->montligne;
		$lh2 =  number_format($lh2, 0, ' ', ' ');

		@endphp
        <td style="text-align:center;font-size:14px;">
               {{$details->qte}}
		</td>
        <td style="text-align:center;font-size:14px;">
           {{ $lh1 }} F
		</td>
		<td style="text-align:center;font-size:14px;">
             {{$lh2}} F
        </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>
                    </div>
                  </div>
                </div>
				<a type="button" href="{{route('nouveau-retour')}}" data-toggle="tooltip"
                                            data-placement="bottom" title="Retour"
                                            class="btn btn-icon btn-warning" style="margin-left:15px;">Retourner sur la liste des retours</a>
            </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 ce détail vente ?
              </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+'/Detailvente/'+id, function (data) {
                  var html = `
            <button type="button" class=" btn btn-danger" data-dismiss="modal">Non</button>
                      <form action="{{route('SupprimerdetailPost')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.detailvente.id+`" name="id" >
                      <button type="submit" class="btn btn-success">Oui</button>

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

@endsection