@extends('layouts.appadmin')

@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">
          
            <h3 style="color: blue;font-weight: bold;">Dernier mouvement du stock</h3>
          </div><!-- /.col -->
          
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
<!-- Button trigger modal -->
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#exampleModal">
 + Nouveau 
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      <form method="POST" action="{{asset('addstock')}}" enctype="multipart/form-data">      
   @csrf 
   <div class="form-group">
    <label for="exampleFormControlSelect1">liieu du stock</label>
    <select name="mouvement" class="form-control" id="exampleFormControlSelect1">
    @foreach($lieustock as $lieu)
      <option value="{{$lieu->id}}">{{$lieu->lieu}}</option>
     
      @endforeach
    </select>
   <div class="form-group">
    <label for="exampleFormControlSelect1">mouvement</label>
    <select name="mouvement" class="form-control" id="exampleFormControlSelect1">
    @foreach($mouvements as $mouvement)
      <option value="{{$mouvement->id}}">{{$mouvement->mouvement}}</option>
     
      @endforeach
    </select>

  </div> 
   <div class="form-group">
    <label for="exampleFormControlSelect1">Example select</label>
    <select name="produit" class="form-control" id="exampleFormControlSelect1">
    @foreach($produits as $produit)
      <option value="{{$produit->id}}">{{$produit->nom}}</option>
     
      @endforeach
    </select>

  </div> 
  <div class="form-group">
    <label for="exampleInputEmail1">qty</label>
    <input name="qty" type="number" class="form-control" placeholder="Enter categorie">
    
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <section class="content">
      <div class="row">
   
   <div class="col-md-9">
   <div class="card">
   <div class="card-header  bg-info">
          1
            </div>  
  

 





    <!-- /.card-header -->
    <div class="card-body">
    <div class="table-responsive">
            <table id="example" class="table table-bordered display nowrap" cellspacing="0" width="100%">
        <thead>
        <tr>
        <th style="color: blue;font-weight: bold;">Ref</th>
        <th style="color: blue;font-weight: bold;">designation</th>
        <th style="color: blue;font-weight: bold;">reference</th>
        <th style="color: blue;font-weight: bold;">quantité</th>
        <th style="color: blue;font-weight: bold;">mouvement</th>
        <th style="color: blue;font-weight: bold;">date</th>
     
        </tr>
        </thead>
        <tbody>
            @foreach($stocks as $stock)
            <tr>
     <td> {{$stock->id}} </td> 
     <td><a class="text-primary font-weight-bold" href="{{asset('detaille/'.$produit->id)}}">
     <i class="fa fa-binoculars" aria-hidden="true"></i>

     {{$stock->produit->nom}}</a>  </td>
     <td>{{$stock->produit->ref}}</td>
     @if($stock->mouvement_id==1)
     <td class="text-success font-weight-bold">+ {{$stock->qty}} </td> 
     <td class="text-success font-weight-bold"><i class="fas fa-arrow-circle-right"></i> {{$stock->mouvement->mouvement}} </td> 
@elseif($stock->mouvement_id==2)
<td class="text-danger font-weight-bold">- {{$stock->qty}} </td> 
     <td class="text-danger font-weight-bold"> <i class="fas fa-arrow-circle-left"></i>{{$stock->mouvement->mouvement}} </td> 
@endif
     <td> {{$stock->created_at}} </td> 
    </tr>
     @endforeach
  </tbody>
</table>
<div class="d-flex justify-content-center mt-4">
                                                {{ $stocks->links('pagination::bootstrap-4') }}
                                            </div>
</div> 


        </div> 





   </div>
   <div class="col-md-3">
   <div class="row">
   <div class="col-md-12">
            <!-- small box -->
            <div class="small-box ">
              <div class="inner">
                <h3 class="text-center">{{$stocks->count()}}</h3>

            
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a class="small-box-footer text-success font-weight-bold">En stock</a>
            </div>
          </div>
          </div>

          <div class="col-md-12">
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <h3 class="text-center">0</h3>

            
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="#" class="small-box-footer">En repture</a>
            </div>
          </div>
          </div>
          

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

        <script src="{{asset('dash/plugins/jquery/jquery.min.js')}}"></script>








</body>
</html>