@extends('backend.layouts.master')
@section('title','Product Manage')

@push('css')

@endpush
<!-- page content -->
@section('content')
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            @if(Session::has('success'))
                <div class="alert alert-success">
                    {{ Session::get('success') }}
                </div>
            @endif
            @if(Session::has('error'))
                <div class="alert alert-danger">
                    {{ Session::get('error') }}
                </div>
            @endif
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Product Management 
                                <a href="{{route('product.create')}}" class="btn btn-xs btn-primary">Create Product</a>
                            </h2> 
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
                            <div class="row search-section">
								<form action="{{route('product.list')}}" id="searchForm" method="Get">
									<div class="col-sm-3">
										<select class="form-control" name="show" id="show">
											<option value="{{$products->count()}}">{{$products->count()}}</option>
											<option value="10">10</option>
											<option value="25">25</option>
											<option value="50">50</option>
											<option value="100">100</option>
											<option value="250">250</option>
											<option value="500">500</option>
										</select>
									</div>
									<div class="col-sm-6"></div>
									<div class="col-sm-3">
										<div class="input-group">
											<input type="text" id="myInput" class="form-control" placeholder="Search">
											<span class="input-group-btn">
												<button type="button" class="btn btn-primary">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
											</span>
										</div>
									</div>
								</form> 
							</div>
                            <table  class="table table-bordered table-condensed" id="">
                                <thead>
                                <tr class="bg-primary">
                                    <th>SL</th>
                                    <th>Product</th>
                                    <th>Category</th>
                                    <th>Type</th>
                                    <th>Unit</th>
                                    <th>Code</th>
                                    <th>Square Foot</th>
                                    <th>Rate</th>
                                    <th>Sale Price</th>
                                    <th>Order Label</th>
                                    <th>Stock</th>
                                    <th>Status</th>
                                    <th>Action</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $i=1 ?>
                                @foreach($products as $pc)
                                    <tr class="{{$pc->re_order_label > $pc->pdetail->sum('now_stock') ? 'bg-warning' : ''}}">
                                        <td>{{$i++}}</td>
                                        <td>{{$pc->product_name}} </td>
                                        <td>{{$pc->category->name}} </td>
                                        <td>{{$pc->type->name}} </td>
                                        <td>{{$pc->unit->name}} </td>
                                        <td>{{$pc->code}} </td>
                                        <td>{{$pc->square_foot}} </td>
                                        <td>{{$pc->supplier_price}}</td>
                                        <td>{{$pc->sale_price}}</td>
                                        <td>{{$pc->re_order_label}}</td>
                                        <td>{{$pc->pdetail->sum('now_stock')}}</td>
                                        <td>
                                            @if($pc->status == 1)
                                                <span class="label label-success"> Active </span>
                                            @else
                                                <span class="label label-danger">DeActive</span>
                                            @endif
                                        </td>
                                        <td>
                                            <div class="row">
                                                <div class="col-md-2">
                                                    <a href="{{route('product.edit',$pc->id)}}" class="btn btn-xs btn-warning"><i class="fa fa-pencil"></i></a>
                                                </div>
                                                @can('product-delete')
                                                <div class="col-md-2">
                                                    <form action="{{route('product.delete' ,$pc->id)}}" method="post">
                                                        <input type="hidden" name="_method" value="DELETE">
                                                        {{ csrf_field()}}
                                                        <button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('are you sure to delete?')" ><i class="fa fa-trash-o"></i></button>
                                                    </form>
                                                </div>
                                                @endcan
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="text-center">
                                {{$products->links()}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
@endsection

@push('js')

@endpush