@extends('admin.layouts.app')


@section('content')

@if (session('company_schedule_update_msg'))
<div class="alert alert-success">
    {{ session('company_schedule_update_msg') }}
</div>

@endif

{!! Form::model($company_schedule, ['method' => 'PATCH', 'route' => ['admin.company-schedules.update', $company_schedule->id], 'files' => true]) !!}
<div class="row">
    <div class="col-md-12">
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-primary">{{awtTrans('Company Schedule Update')}}</h6>
            </div>
            <div class="card-body">


                <!-- <div class="row">

                    <div class="form-group col-md-12" id="all-from-years">

                        {!! Form::label('from_year_id', awtTrans('Choose From Year')) !!}
                        {!! Form::select('from_year_id', ['' => awtTrans('Choose From Year'),] + $years, null, ['class' => 'form-control']) !!}
                        <small class="text-danger">{{ $errors->first('from_year_id') }}</small>

                    </div>

                </div>

                <div class="row">

                    <div class="form-group col-md-2">
                        <button type="button" class="btn btn-info btn-block" id="add-from-year" data-toggle="modal" data-target="#exampleModalLongFrom">{{ awtTrans('Add From Year') }} <i class="fas fa-plus"></i></button>
                    </div>

                </div>

                <div class="row">

                    <div class="form-group col-md-12" id="all-to-years">

                        {!! Form::label('to_year_id', awtTrans('Choose To Year')) !!}
                        {!! Form::select('to_year_id', ['' => awtTrans('Choose To Year'),] + $years, null, ['class' => 'form-control']) !!}
                        <small class="text-danger">{{ $errors->first('to_year_id') }}</small>
                        <small class="text-danger">{{ $errors->first('from_year_id_more_to_year_id') }}</small>

                    </div>

                </div>



                <div class="row">

                    <div class="form-group col-md-2">
                        <button type="button" class="btn btn-info btn-block" id="add-to-year" data-toggle="modal" data-target="#exampleModalLongTo">{{ awtTrans('Add To Year') }} <i class="fas fa-plus"></i></button>
                    </div>

                </div> -->


                <div class="row">

                    <div class="form-group col-md-6">
                        {!! Form::label('date_from', awtTrans('Date From')) !!}
                        <input type="date" name="date_from" id="date_from" value="{{ $company_schedule->date_from->format('Y-m-d') }}" class="form-control">
                        <small class="text-danger">{{ $errors->first('date_from') }}</small>

                    </div>

                    <div class="form-group col-md-6">
                        {!! Form::label('date_to', awtTrans('Date To')) !!}
                        <input type="date" name="date_to" id="date_to" value="{{ $company_schedule->date_to->format('Y-m-d') }}" class="form-control">
                        <small class="text-danger">{{ $errors->first('date_to') }}</small>

                    </div>

                </div>

                <div class="row">

                    <div class="form-group col-lg-6">
                        {!! Form::label('desc_ar', awtTrans('Description Arabic')) !!}
                        {!! Form::textarea('desc_ar', null, [ 'class' => 'form-control']) !!}
                        <small class="text-danger">{{ $errors->first('desc_ar') }}</small>
                    </div>

                    <div class="form-group col-lg-6">
                        {!! Form::label('desc_en', awtTrans('Description English')) !!}
                        {!! Form::textarea('desc_en', null, [ 'class' => 'form-control']) !!}
                        <small class="text-danger">{{ $errors->first('desc_en') }}</small>
                    </div>

                </div>


                <!-- <div class="row">

                    <div class="form-group col-lg-12">
                        {!! Form::label('photo', awtTrans('الصورة')) !!}
                        <div class="input-group">
                            <span class="input-group-btn">
                                <a id="lfm" data-input="photo" data-preview="holder" class="btn btn-secondary text-white px-4" style="border-top-right-radius: 0;border-bottom-right-radius: 0;border-top-left-radius: 0;border-bottom-left-radius: 0;">
                                    <i class="fa fa-picture-o"></i> {{ awtTrans('اختر الصورة') }}
                                </a>
                            </span>
                            {!! Form::text('photo', null, ['class' => $errors->has('photo') ? 'form-control is-invalid' : 'form-control' , 'readonly' => 'readonly']) !!}
                        </div>
                        <div class="mb-3 mt-3 d-block slider-holder" id="holder">
                            <img width="100" src="http://127.0.0.1:8000/storage/1/th.jpeg" alt="">
                        </div>
                        <small class="text-danger">{{ $errors->first('photo') }}</small>
                    </div>
                </div> -->


                <div class="row">

                    <div class="form-group col-lg-12">
                        <button type="button" class="btn btn-info btn-block" id="add-keyword"><i class="fas fa-plus"></i></button>
                    </div>
                </div>

                <div class="row" id="append-keyword">

                    @if ($company_schedule->keywords->isNotEmpty())
                    @foreach ($company_schedule->keywords as $key => $keyword)
                    @if ($key == 0)

                    <div class="row col-lg-12">


                        <div class="form-group col-lg-5">
                            <lable for="keyword_ar">الكلمات المفتاحية بالعربي</lable>
                            <input type="text" name="keyword_ar[]" value="{{ $keyword->body_ar }}" class="form-control" />
                        </div>

                        <div class="form-group col-lg-5">
                            <lable for="keyword_en">الكلمات المفتاحية بالانجليزي</lable>
                            <input type="text" name="keyword_en[]" value="{{ $keyword->body_en }}" class="form-control" />
                        </div>


                    </div>

                    @else

                    <div class="row col-lg-12">


                        <div class="form-group col-lg-5">
                            <lable for="keyword_ar">الكلمات المفتاحية بالعربي</lable>
                            <input type="text" name="keyword_ar[]" value="{{ $keyword->body_ar }}" class="form-control" />
                        </div>

                        <div class="form-group col-lg-5">
                            <lable for="keyword_en">الكلمات المفتاحية بالانجليزي</lable>
                            <input type="text" name="keyword_en[]" value="{{ $keyword->body_en }}" class="form-control" />
                        </div>

                        <div class="form-group col-lg-2">
                            <lable for="keyword_en">حذف</lable>
                            <button type="button" class="btn btn-danger btn-block" id="delete-keyword"><i class="fas fa-trash"></i></button>
                        </div>

                    </div>
                    @endif
                    @endforeach
                    @endif
                </div>

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


{!! Form::submit(awtTrans('Company Schedule Update'), ['class' => 'btn btn-success']) !!}
<a href="{{ route('admin.company-schedules.index') }}" class="btn btn-primary "><i class="fas fa-arrow-left  fa-sm  "></i>{{ awtTrans('Back') }}</a>

{!! Form::close() !!}

@endsection

@section('scripts')
<script src="https://cdn.ckeditor.com/4.16.1/standard/ckeditor.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment-hijri@2.1.2/moment-hijri.min.js"></script>
<script src="{{ asset('dashboard/js/bootstrap-hijri-datetimepicker.js?v2') }}"></script>
<script src="{{ asset('dashboard/forms/companies/create.js') }}"></script>

<script>

</script>
@endsection