@extends('admin.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? ''}}</h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" action="{{ $action }}" onsubmit="saveForm(this)" enctype="multipart/form-data">

            @if($cobon ?? ''  && $cobon->id)
                @method('PUT')
            @endif
            @csrf
            <div class="form-group col-lg-6">
                <label>{{ meta('code', getCurrentLocale()) ?? __('cobons.code')}}</label>
                <input type="text"  class="form-control  {{ $errors->has('code') ? 'is-invalid' : '' }}" name="code" placeholder="{{ meta('code', getCurrentLocale()) ?? __('cobons.code') }}" value='{{ old("code", $cobon->code ?? "") }}'/>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ meta('count', getCurrentLocale()) ?? __('cobons.count')}}</label>
                <input type="number" min="0" class="form-control  {{ $errors->has('count') ? 'is-invalid' : '' }}" name="count" placeholder="{{ meta('count', getCurrentLocale()) ?? __('cobons.count') }}" value='{{ old("count", $cobon->count ?? "") }}'/>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ meta('user_count', getCurrentLocale()) ?? __('cobons.user_count')}}</label>
                <input type="number" min="0" class="form-control  {{ $errors->has('user_count') ? 'is-invalid' : '' }}" name="user_count" placeholder="{{ meta('user_count', getCurrentLocale()) ?? __('cobons.user_count') }}" value='{{ old("user_count", $cobon->user_count ?? "") }}'/>
            </div>
            @if($cobon ?? ''  && $cobon->id)
                <div class="form-group col-lg-6">
                    <label>{{ meta('usage', getCurrentLocale()) ?? __('cobons.usage')}}</label>
                    <input disabled class="form-control  "  value='{{ $cobon->user_count }}'/>
                </div>
                <div class="form-group col-lg-6">
                    <label>{{ meta('all_cobon', getCurrentLocale()) ?? __('cobons.all_cobon')}}</label>
                    <input disabled class="form-control  "  value='{{ $cobon->user_count }}'/>
                </div>
            @endif

            <div class="form-group col-lg-6">
                <label>{{ meta('status_user', getCurrentLocale()) ?? __('cobons.status_user')}}</label>
                <select class="form-control {{ $errors->has('status_user') ? 'is-invalid' : '' }}" name="status_user">
                    <option {{ (isset($cobon) ? $cobon->status_user : '')  == 'all' ? 'selected' : ''}}  value="all">{{__('cobons.all')}}</option>
                    <option {{ (isset($cobon) ? $cobon->status_user : '')  == 'users' ? 'selected' : ''}}  value="users">{{__('cobons.users')}}</option>
                    <option {{ (isset($cobon) ? $cobon->status_user : '')  == 'visitors' ? 'selected' : ''}} value="visitors">{{__('cobons.visitor')}}</option>
                    <option {{ (isset($cobon) ? $cobon->status_user : '')  == 'companies' ? 'selected' : ''}}   value="companies">{{__('cobons.companies')}}</option>
                </select>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('discount_type', getCurrentLocale()) ?? __('cobons.discount_type')}}</label>
                <select class="form-control {{ $errors->has('discount_type') ? 'is-invalid' : '' }}" name="discount_type">
                    <option {{ (isset($cobon) ? $cobon->discount_type : '')  == 'value' ? 'selected' : ''}} value="value">{{__('cobons.value')}}</option>
                    <option {{ (isset($cobon) ? $cobon->discount_type : '')  == 'percentage' ? 'selected' : ''}}  value="percentage">{{__('cobons.percentage')}}</option>
                </select>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ meta('discount_amount', getCurrentLocale()) ?? __('cobons.discount_amount')}}</label>
                <input type="number"  class="form-control  {{ $errors->has('discount_amount') ? 'is-invalid' : '' }}" name="discount_amount" placeholder="{{ meta('discount_amount', getCurrentLocale()) ?? __('cobons.discount_amount') }}" value='{{ old("discount_amount", $cobon->discount_amount ?? "") }}'/>
            </div>

            <div class="form-group col-lg-6">
                <label>{{ meta('start_date', getCurrentLocale()) ?? __('cobons.start_date')}}</label>
                <input type="date"  class="form-control  {{ $errors->has('start_date') ? 'is-invalid' : '' }}" name="start_date" placeholder="{{ meta('start_date', getCurrentLocale()) ?? __('cobons.start_date') }}" value='{{ old("start_date", $cobon->start_date ?? "") }}'/>
            </div>
            <div class="form-group col-lg-6">
                <label>{{ meta('end_date', getCurrentLocale()) ?? __('cobons.end_date')}}</label>
                <input type="date"  class="form-control  {{ $errors->has('end_date') ? 'is-invalid' : '' }}" name="end_date" placeholder="{{ meta('end_date', getCurrentLocale()) ?? __('cobons.end_date') }}" value='{{ old("end_date", $cobon->end_date ?? "") }}'/>
            </div>

            <div class="text-center mt-5 col-12">
                <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
            </div>
        </form>
    </div>

@endsection

@section('inner_js')
    <!-- Editor JS files -->
    {{--    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>--}}
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>


    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            url_type = {!! json_encode(url(getCurrentLocale().'/admin/type/')) !!},
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/articles.js') }}"></script>
    <script src="{{ asset('assets/admin/js/cobons.js') }}"></script>
@endsection



