@extends('admin.layouts.app')

@push('styles_top')

@endpush

@section('content')
    <section class="section">
        <div class="section-header">
            <h1>{{ trans('admin/main.new_template') }}</h1>
            <div class="section-header-breadcrumb">
                <div class="breadcrumb-item active"><a href="/admin/">{{trans('admin/main.dashboard')}}</a>
                </div>
                <div class="breadcrumb-item">{{ trans('admin/main.new_template') }}</div>
            </div>
        </div>

        @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

        <div class="section-body">
            <div class="card">
                <div class="card-body">

                    <form method="post" action="{{ !empty($template) ? '/admin/certificates/imt_templates/'. $template->id .'/update' : '/admin/certificates/imt_templates/store' }}" class="form-horizontal form-bordered" enctype="multipart/form-data">
                        {{ csrf_field() }}

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

                                <div class="form-group">
                                    <label class="control-label" for="inputDefault">اسم القالب</label>
                                    <input type="text" name="name" class="form-control @error('name') is-invalid @enderror" value="{{ !empty($template) ? $template->name : old('name') }}">
                                    <div class="invalid-feedback">@error('name') {{ $message }} @enderror</div>
                                </div>

                                <div class="form-group">
                                    <label class="input-label">{{ trans('admin/main.template_image') }}</label>
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <button type="button" class="input-group-text admin-file-manager " data-input="image" data-preview="holder">
                                                <i class="fa fa-upload"></i>
                                            </button>
                                        </div>
                                        <input type="text" name="image" id="image" value="{{ !empty($template) ? $template->image : old('image') }}" class="js-certificate-image form-control @error('image') is-invalid @enderror"/>
                                        <div class="invalid-feedback">@error('image') {{ $message }} @enderror</div>
                                    </div>
                                    <div class="invalid-feedback">@error('image') {{ $message }} @enderror</div>
                                    <div class="text-muted text-small mt-1">{{ trans('update.certificate_image_hint') }}</div>
                                </div>

                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12">
                                <button class="btn btn-success pull-left" type="submit">{{ trans('public.save') }}</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </section>
@endsection

@push('scripts_bottom')


{{--    <script src="/assets/default/js/admin/certificates.min.js"></script>--}}
@endpush
