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

@push('css')
    <link rel="stylesheet" href="{{asset('backend/plugins/select2.min.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>
                            <a href="{{route('product.list')}}" class="btn btn-xs btn-primary"> Product List</a>
                            Product Entry
                        </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">
                            <div class="col-sm-3"></div>
                            <div class="col-sm-6">
                                <form action="{{route('product.store')}}" method="post">
                                    {{ csrf_field()}}
                                    <div class="form-group">
                                        <label for="category_id">Chose Category</label>
                                        <select class="form-control select2" id="category_id" name="category_id">
                                            <option value="">--Select Category--</option>
                                            @foreach($categories as $m)
                                            <option value="{{$m->id}}" {{old('category_id') == $m->id ? 'selected' : ''}}>{{$m->name}}</option>
                                            @endforeach
                                        </select>
                                        <span class="error"><b>{{$errors->first('category_id')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="unit_id">Chose Unit</label>
                                        <select class="form-control select2" id="unit_id" name="unit_id">
                                            <option value="">--Select Unit--</option>
                                            @foreach($units as $u)
                                            <option value="{{$u->id}}" {{old('unit_id') == $u->id ? 'selected' : ''}}>{{$u->name}}</option>
                                            @endforeach
                                        </select>
                                        <span class="error"><b>{{$errors->first('unit_id')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="product_name">Product Name*</label>
                                        <input type="text" class="form-control" id="product_name" name="product_name" value="{{old('product_name')}}" placeholder="Enter Product Name">
                                        <span class="error"><b> {{$errors->first('product_name')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="code">Code*</label>
                                        <input type="text" class="form-control" id="code" name="code" value="{{old('code')}}" placeholder="Enter Product code">
                                        <span class="error"><b>{{$errors->first('code')}} </b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="code">Square Foot *</label>
                                        <input type="text" class="form-control" id="square_foot" name="square_foot" value="{{old('square_foot')}}" placeholder="Enter Product Square Foot">
                                        <span class="error"><b>{{$errors->first('square_foot')}} </b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="supplier_price">Purchase Price</label>
                                        <input type="text" class="form-control" id="supplier_price" name="supplier_price" value="{{old('supplier_price')}}" placeholder="Purchase Price">
                                        <span class="error"><b>{{$errors->first('supplier_price')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="sale_price">Sale Price *</label>
                                        <input type="text" class="form-control" id="sale_price" name="sale_price" value="{{old('sale_price')}}" placeholder="Sale Price">
                                        <span class="error"><b>{{$errors->first('sale_price')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="sale_price">Worker Wage *</label>
                                        <input type="text" class="form-control" id="worker_wage" name="worker_wage" value="{{old('worker_wage')}}" placeholder="Worker Wage">
                                        <span class="error"><b>{{$errors->first('worker_wage')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label for="re_order_label">Re Order Label *</label>
                                        <input type="text" class="form-control" id="re_order_label" name="re_order_label" value="{{old('re_order_label')}}" placeholder="Product Re-Order Label">
                                        <span class="error"><b>{{$errors->first('re_order_label')}}</b></span>
                                    </div>
                                    <div class="form-group">
                                        <label>Status</label>
                                        <input type="radio" name="status" value="1" id="Active" checked=""><label for="Active"> Active</label>
                                        <input type="radio" name="status" id="deactive" value="0"><label for="deactive">DeActive</label>
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <button type="submit" name="btnCreate" class="btn btn-primary btn-block">Save Product</button>
                                    </div>
                                </form>
                            </div>
                            <div class="col-sm-3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- /page content -->
@endsection

@push('js')
    <script src="{{asset('backend/plugins/select2.min.js')}}"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            /*-------------*/
            $(".select2").select2();
        })
    </script>
@endpush