@extends('layouts.app')

@section('content')
    <div class="card card-primary">
        <div class="panel panel-black">
            <div class="panel-heading">
                <a href="{{route('suppliers')}}" class="btn btn-raised btn-primary">Suppliers</a>
                <hr/>
                <h3 class="text-center">Create Supplier</h3>
            </div>

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

                <form class="form-horizontal" method="post" action="{{ route('saveSupplier') }}">
                    {!! csrf_field() !!}
                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="name">Name</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" value="{{old('name')}}" required placeholder="Supplier Name"
                                   id="name" class="form-control"/>
                        </div>
                        @if($errors->has('name'))
                            <span class="help-block">
                                {{$errors->first('name')}}
                            </span>
                        @endif
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="address1">Address Line 1</label>
                        <div class="col-sm-10">
                            <input type="text" name="address1" value="{{old('address1')}}" required placeholder="Address Line"
                                   id="address1" class="form-control"/>

                            @if($errors->has('address1'))
                                <span class="help-block">
                                {{$errors->first('address1')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="address2">Address Line 2</label>
                        <div class="col-sm-6">
                            <input type="text" name="address2" value="{{old('address2')}}"  placeholder="Address"
                                   id="address2" class="form-control"/>
                            @if($errors->has('address2'))
                                <span class="help-block">
                                {{$errors->first('address2')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="postal">Zip/Postal</label>
                        <div class="col-sm-6">
                            <input type="text" name="postal" value="{{old('postal')}}"  placeholder="Enter Zip/postal code"
                                   id="postal" class="form-control"/>

                            @if($errors->has('postal'))
                                <span class="help-block">
                                {{$errors->first('postal')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="landmark">Landmark</label>
                        <div class="col-sm-6">
                            <input type="text" name="landmark" value="{{old('landmark')}}" required placeholder="Enter closest landmark"
                                   id="landmark" class="form-control"/>
                            @if($errors->has('landmark'))
                                <span class="help-block">
                                {{$errors->first('landmark')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="phone">Phone</label>
                        <div class="col-sm-6">
                            <input type="text" name="phone" value="{{old('phone')}}" required placeholder="Enter contact phone number"
                                   id="phone" class="form-control"/>
                            @if($errors->has('phone'))
                                <span class="help-block">
                                {{$errors->first('phone')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="city">City</label>
                        <div class="col-sm-6">
                            <input type="text" name="city" value="{{old('city')}}"  placeholder="Enter city"
                                   id="city" class="form-control"/>
                            @if($errors->has('city'))
                                <span class="help-block">
                                {{$errors->first('city')}}
                            </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="country">Country</label>
                        <div class="col-sm-10">
                            <select name="country" required id="country" class="form-control">
                                <option value="0" >
                                    Select country
                                </option>
                                @foreach ($countries as $country)
                                    <option value="{{$country}}" <?php if (isset($country) && $country == 'Nigeria'){echo 'selected';}else{echo '';} ?>>{!! $country !!}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="form-group required">
                        <label class="col-sm-2 control-label" for="country">State</label>
                        <div class="col-sm-8" id="statesBox">
                            @include('includes.states')
                        </div>
                        <div class="col-sm-2">
                            <span class="" id="loader" style="display:none;"></span>
                        </div>
                    </div>


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

                    </div>
                </form>

            </div>

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





