@extends('layouts.app')

@section('content')
    <div class="card card-primary">
        <div class="panel panel-black">
            <div class="panel-heading">
                <a href="{{route('storeRequest', Auth::user()->store_id)}}" class="btn btn-raised btn-primary">Transfers</a>
                @if (Auth::user()->store_id)
                    <a href="{{ route('storeAdminInventory',Auth::user()->store_id)}}">
                        <button class="btn btn-primary btn-raised mbtn" data-store="{{Auth::user()->store_id}}">
                            Inventory
                        </button>
                    </a>


                    <a href="{{ route('storeSales' ,Auth::user()->store_id) }}">
                        <button class="btn btn-primary btn-raised mbtn" data-store="{{Auth::user()->store_id}}">
                            Sales
                        </button>
                    </a>

                    <a href="{{ url('store/procurement') }}">
                        <button class="btn btn-primary btn-raised mbtn" data-store="{{Auth::user()->store_id}}">
                            Procurement
                        </button>
                    </a>

                    <a href="{{ route('storeDistribution') }}">
                        <button class="btn btn-primary btn-raised">
                            Distribution
                        </button>
                    </a>
                @endif
                <hr/>
                <h3 class="text-center">STOCK REQUEST</h3>
            </div>
                <!-- Nav tabs -->
                <ul class="nav nav-tabs  shadow-2dp" role="tablist">
                    <li role="presentation" class="active"><a class="withoutripple" href="#sent" aria-controls="sent" role="tab" data-toggle="tab"><i class="zmdi zmdi-arrow-forward"></i> <span class="hidden-xs">Sent</span></a></li>
                    <li role="presentation"><a class="withoutripple" href="#received" aria-controls="received" role="tab" data-toggle="tab"> <span class="hidden-xs">Recieved</span>  <i class="zmdi zmdi-arrow-back"></i> </a></li>
                    <li role="presentation"><a class="withoutripple" href="#new" aria-controls="new" role="tab" data-toggle="tab"><i class="zmdi zmdi-plus"></i> <span class="hidden-xs">New</span></a></li>
                </ul>

            <div class="panel-body">
                @include('includes.flash')

                <div class="card-block">
                    <!-- Tab panes -->
                    <div class="tab-content">

                        <div role="tabpanel" class="tab-pane fade active in" id="sent">
                            <table id="dataTables" class="display table-responsive table-stripped" width="100%" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>S/N</th>
                                    <th>Product Name</th>
                                    <th>Quantity</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>

                                <tbody>
                                <?php $i = 0; ?>
                                @foreach($sentRequest as $sent)
                                    <tr>
                                        <td><?= ++$i; ?></td>
                                        <td>{!!$sent->product->name!!}</td>
                                        <td>{!!$sent->quantity!!}</td>
                                        <td>{!!$sent->status == 0? 'pending':'fulfilled'!!}</td>
                                        <td>{!!$sent->created_by!!}</td>
                                        <td>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-primary btn-raised">Action</button>
                                                <button type="button" class="btn btn-primary btn-raised dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <i class="zmdi zmdi-chevron-down right only"></i>
                                                </button>
                                                <ul class="dropdown-menu dropdown-menu-primary">
                                                    <li class="">
                                                        <a href="javascript: void(0);">Delivered</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript: void(0);" id="delete-btn" onclick="return confirm('Are you sure you want to delete the product?')" data-action="javascript: void(0);">Cancel</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript: void(0);">Details</a>
                                                    </li>
                                                    <li role="separator" class="divider"></li>
                                                    <li>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach

                                </tbody>
                            </table>
                        </div>

                        <div role="tabpanel" class="tab-pane fade" id="received">
                            <table id="dataTables" class="display table-responsive table-stripped" width="100%" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>S/N</th>
                                    <th>From</th>
                                    <th>Product Name</th>
                                    <th>Quantity</th>
                                    <th>Status</th>
                                    <th>By</th>
                                    <th>Action</th>
                                </tr>
                                </thead>

                                <tbody>
                                <?php $i = 0; ?>
                                @foreach($sentRequest as $sent)
                                    <tr>
                                        <td><?= ++$i; ?></td>
                                        <td>{!!$sent->from_store_id!!}</td>
                                        <td>{!!$sent->product_id!!}</td>
                                        <td>{!!$sent->quantity!!}</td>
                                        <td>{!!$sent->status!!}</td>
                                        <td>{!!$sent->created_by!!}</td>
                                        <td>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-primary btn-raised">Action</button>
                                                <button type="button" class="btn btn-primary btn-raised dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <i class="zmdi zmdi-chevron-down right only"></i>
                                                </button>
                                                <ul class="dropdown-menu dropdown-menu-primary">
                                                    <li class="">
                                                        <a href="javascript: void(0);">Accept</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript: void(0);" id="delete-btn" onclick="return confirm('Are you sure you want to delete the product?')" data-action="javascript: void(0);">Reject</a>
                                                    </li>

                                                    <li>
                                                        <a href="javascript: void(0);">Details</a>
                                                    </li>
                                                    <li role="separator" class="divider"></li>
                                                    <li>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach

                                </tbody>
                            </table>
                        </div>

                        <div role="tabpanel" class="tab-pane fade" id="new">
                            <form class="form-horizontal" method="post" action="{{ route('saveStoreRequest',Auth::user()->store_id)}}">
                                {!! csrf_field() !!}
                                <div class="form-group required">
                                    <label class="col-sm-2 control-label" for="productID">Stock</label>
                                    <div class="col-sm-6">
                                        <select name="productID" id="productID" onchange="getDetails()" class="form-control">
                                            @foreach ($products as $product)
                                                <option value="{!! $product->id !!}">{!!   $product->name !!}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group required">
                                    <label class="col-sm-2 control-label" for="storeID">To Store</label>
                                    <div class="col-sm-6">
                                        <select name="storeID" id="storeID" onchange="getStoreDetails()" class="form-control">
                                            @foreach ($stores as $store)
                                                <option value="{!! $store->id !!}">{!! $store->name !!}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group required">
                                    <label class="col-sm-2 control-label" for="quantity">Quantity</label>
                                    <div class="col-sm-6">
                                        <input type="number" name="quantity" required min="1" class="form-control" {{old('quantity')}} />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2"></div>
                                    <div class="col-md-6 ">
                                        <button type="submit" class="btn btn-success clear-fix" >Transfer</button>
                                    </div>
                                </div>
                            </form>
                        </div>

                    </div>
                </div>
            </div>

            <div class="panel-footer">
            </div>
        </div>
    </div>
@endsection










