@extends('backend.layout.main') @section('content')
@if(session()->has('not_permitted'))
  <div class="alert alert-danger alert-dismissible text-center"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>{{ session()->get('not_permitted') }}</div>
@endif
<section class="forms">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header d-flex align-items-center">
                        <h4>{{trans('file.Add Tailor')}}</h4>
                    </div>
                    <div class="card-body">
                        <p class="italic"><small>{{trans('file.The field labels marked with * are required input fields')}}.</small></p>
                        {!! Form::open(['route' => 'tailor.store', 'method' => 'post', 'files' => false]) !!}
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>{{trans('file.name')}} *</strong> </label>
                                    <input type="text" id="name" name="name" required class="form-control">
                                    @if($errors->has('name'))
                                   <span>
                                       <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                    @endif
                                </div>
                            </div>
                            <div class="col-md-4">
                                    <div class="form-group">
                                        <label>{{trans('file.category')}} *</strong> </label>
                                        <div class="input-group">
                                            <select name="category_id" required class="form-control selectpicker  order_input" id="category">
                                                @foreach ($lims_category_list as $category)
                                                <option value="{{ $category->id }}">{{ $category->name }}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>
                            </div>
                            <input type="hidden" name="tailor_fee" value="0">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>{{trans('file.Phone Number')}} *</label>
                                    <input type="text" name="phone" required class="form-control">
                                    @if($errors->has('phone'))
                                   <span>
                                       <strong>{{ $errors->first('phone') }}</strong>
                                    </span>
                                    @endif
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>{{trans('file.Address')}} *</label>
                                    <input type="text" name="address" required class="form-control">
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <h5 class="mt-2 mb-3">{{ trans('file.Curtain Tailor Fees') }}</h5>
                            </div>
                            @foreach(['fabric_meter_fee' => 'Fabric Meter Fee', 'netting_meter_fee' => 'Netting Meter Fee', 'mattress_fee' => 'Mattress Fee', 'pillow_fee' => 'Pillow Fee', 'bolster_fee' => 'Bolster Fee'] as $field => $label)
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label>{{ trans('file.' . $label) }} *</label>
                                        <input type="number" name="{{ $field }}" value="{{ old($field, 0) }}" min="0" step="0.01" required class="form-control">
                                        @if($errors->has($field))
                                            <span><strong>{{ $errors->first($field) }}</strong></span>
                                        @endif
                                    </div>
                                </div>
                            @endforeach
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>{{ trans('file.Under-cover Fee Method') }} *</label>
                                    <select name="under_cover_fee_method" id="under_cover_fee_method" class="form-control" required>
                                        <option value="corresponding" @if(old('under_cover_fee_method', 'corresponding') === 'corresponding') selected @endif>{{ trans('file.Include Under-cover in Item Fee') }}</option>
                                        <option value="separate" @if(old('under_cover_fee_method') === 'separate') selected @endif>{{ trans('file.Use Separate Under-cover Fees') }}</option>
                                    </select>
                                </div>
                            </div>
                            @foreach(['mattress_under_cover_fee' => 'Mattress Under-cover Fee', 'pillow_under_cover_fee' => 'Pillow Under-cover Fee', 'bolster_under_cover_fee' => 'Bolster Under-cover Fee'] as $field => $label)
                                <div class="col-md-4 separate-under-cover-fee">
                                    <div class="form-group">
                                        <label>{{ trans('file.' . $label) }} *</label>
                                        <input type="number" name="{{ $field }}" value="{{ old($field, 0) }}" min="0" step="0.01" class="form-control under-cover-fee-input">
                                    </div>
                                </div>
                            @endforeach
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <h5 class="mt-2 mb-1">{{ trans('file.Tailor Login Account') }}</h5>
                                <p class="text-muted">{{ trans('file.Every tailor needs a login account to receive and manage assigned orders') }}</p>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>{{trans('file.Email')}} <span >*</span></label>
                                    <input type="email" name="email" value="{{ old('email') }}" placeholder="example@example.com" required class="form-control">
                                    @if($errors->has('email'))
                                   <span>
                                       <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                    @endif
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>{{trans('file.Password')}} *</label>
                                    <input type="password" name="password" required class="form-control">
                                    @if($errors->has('password'))
                                        <span><strong>{{ $errors->first('password') }}</strong></span>
                                    @endif
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="submit" value="{{trans('file.submit')}}" class="btn btn-primary">
                        </div>
                        {!! Form::close() !!}
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>


@endsection

@push('scripts')
<script type="text/javascript">
    $("ul#tailoring").siblings('a').attr('aria-expanded','true');
    $("ul#tailoring").addClass("show");
    $("ul#tailoring #tailor-create-menu").addClass("active");

    function toggleUnderCoverFees() {
        var separate = $('#under_cover_fee_method').val() === 'separate';
        $('.separate-under-cover-fee').toggle(separate);
        $('.under-cover-fee-input').prop('required', separate);
    }
    $('#under_cover_fee_method').on('change', toggleUnderCoverFees);
    toggleUnderCoverFees();
</script>
@endpush
