@extends('layout')
@section('title','Détails  ')
@section('description','Détails inventaire')
@section('content')
			<br/>
          <div class="section-body">
		  <br/>
			<div class="row">
              <div class="col-12">
                <div class="card">
                  <div class="card-header">
                    <h4>Détails inventaire</h4>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-striped" id="table-1">
                        <thead>
                          <tr>
							<th style="text-align:center;">N°</th>
							<th class="text-center">Emballage</th>
						    <th class="text-center">Qte réelle </th>
                            <th class="text-center">Qte théorique </th>
                            <th class="text-center">Différence</th>
                            <th class="text-center">Qté ajustée</th>
							<th style="text-align:center;">Actions</th>
						</tr>
                        </thead>
                        <tbody>
						@foreach($ligne as $lignes)
						<tr>
							<td>
							{{$loop->iteration}}
							</td>
							
							<td style="text-align:center;font-size:15px;">
							{{ DB::table('emballage')->where('id', $lignes->emballage_id)->first()->designation }}
							</td>
							<td style="text-align:center;font-size:15px;">
							   {{$lignes->qte}}
							</td>
							<td style="text-align:center;font-size:15px;">
							   {{$lignes->qte_theo}}
							</td>
							<td style="text-align:center;font-size:15px;">&nbsp;&nbsp; 
							@php
								$dif = $lignes->qte - $lignes->qte_theo;
							@endphp
							{{$dif}}
						   </td>
						   <td style="text-align:center;font-size:15px;">
							   {{$lignes->qte_ajuste}}
							</td>
							<td style="text-align:center;font-size:17px;">
							@if ($lignes->etat=="En cours")
							 <a type="button" href="#" data-id="{{$lignes->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
							<!--@if ($dif > 0)
							 <a type="button" href="{{route('ajuster-stock', ['id'=>$lignes->id])}}" data-toggle="tooltip" data-placement="bottom" title="Ajuster le stock" class="btn btn-icon btn-info"><i class="fas fa-plus"></i> </a>					
							 @endif
							 <a type="button" href="{{route('ajuster-stock', ['id'=>$lignes->id])}}" data-toggle="tooltip" data-placement="bottom" title="Ajuster le stock" class="btn btn-icon btn-info"><i class="fas fa-plus"></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 définitivement 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/Detailinvemballage/'+id, function (data) {
                  var html = `
            <button type="button" class=" btn btn-danger" data-dismiss="modal">Non</button>
                      <form action="{{route('supprimerdetailemballage')}}" method="post" style="display: inline">
                        {{csrf_field()}}
                      <input type="hidden" value="`+data.ligne.id+`" name="id" >
                      <button type="submit" class="btn btn-success">Oui</button>

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

@endsection