@extends('layouts.ecc.main')

@section('content')
<div class="row">
    <div class="col-sm-12">
        <div class="col-sm-6">
            <div class="card">
                <div class="content">
                    <table class="table" id="book">
                        <thead>
                            <tr>
                                <th>Quantité</th>
                                <th>Nom</th>
                                <th>Description</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($items as $item)
                            <tr>
                                <td>{{$item->quantity}}</td>
                                <td scope="row">{{$item->name}}</td>
                                <td>{{$item->desc}}</td>
                                <td style="width:12%"><form action="/ecc/inventory/remove/{{$schedule->id}}/{{$periode}}/{{$niveau}}" method="post">{{ csrf_field() }}<button type="submit" name="remove" class="btn btn-danger" value="{{$item->id}}:{{$item->quantity}}"><i class="fa fa-arrow-right"></i></button></form></td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="card">
                <div class="content">
                    <table class="table" id="tobook">
                        <thead>
                            <tr>
                                <th></th>
                                <th>Nom</th>
                                <th>Description</th>
                               <th>Quantité</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($dispo_item as $item)
                            <tr>
                                <td style="width:12%"><form action="/ecc/inventory/add/{{$schedule->id}}/{{$periode}}/{{$niveau}}" method="post">{{ csrf_field() }}<button type="submit" name="add" class="btn btn-success" value="{{$item->id}}"><i class="fa fa-arrow-left"></i></button></td>
                                <td scope="row">{{$item->name}}</td>
                                <td>{{$item->desc}}</td>
                                <td><input type="number" class="form-control" name="qt" id="qt" min="1" max="{{$item->quantity}}" value="{{$item->quantity}}"></form><td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>  
@endsection

@section('active_page')
    <?php $active_page = "inventory" ?>
@endsection

@section('custom_scripts')
<script>
    (function($) {
        $(document).ready(function() {
            $('#book').DataTable({
                "order": [[ 0, "desc" ]],
                "lengthMenu": [[25, 50, -1], [25, 50, "All"]],
            });
        });
    })(jQuery);

    (function($) {
        $(document).ready(function() {
            $('#tobook').DataTable({
                "order": [[ 0, "desc" ]],
                "lengthMenu": [[25, 50, -1], [25, 50, "All"]],
            });
        });
    })(jQuery);
</script>
@endsection