%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /mnt/tnb2/git/loslex/resources/views/contests/
Upload File :
Create Path :
Current File : //mnt/tnb2/git/loslex/resources/views/contests/edit.blade.php

<?php
    $filteredmsg = array();
    foreach ($errors->toArray() as $field => $data) {
        if (preg_match('/(presentation|contest)_(start|end).*/', $field)) {
            foreach ($data as $msg) { array_push($filteredmsg, $msg); }
        }
    }
    $errors->add("manualtimetable", $filteredmsg);
?>

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            @if (request()->routeIs('contest.create')) {{ __('New contest') }} @else {{ __('Edit contest') }} @endif
        </h2>
    </x-slot>

    <section>
        <form method="POST" action="{{ request()->routeIs('contest.create') ? route('contest.store') : route('contest.update', ['contest' => $contest->id]) }}" class="space-y-6">
            @csrf
            @if (request()->routeIs('contest.edit'))
                @method('patch')
            @endif

            {{-- <div>{{ print_r($errors->all()) }}</div> --}}

            <div>
                <x-input-label for="contestname" :value="__('Contest name')" />
                <x-text-input id="contestname" name="contestname" type="text" class="mt-1 block w-full" :value="old('contestname', $contest?->contestname)" />
                <x-input-error class="mt-2" :messages="$errors->get('contestname')" />
            </div>

            <div>
                <x-input-label for="range_id" :value="__('Range')" />
                <x-select id="range_id" name="range_id">
                    <option value="" selected disabled>{{ __('Select shooting range') }}</option>
                    @foreach ($ranges as $range)
                        <option @selected(old('range_id', $contest?->range_id) == $range->id) value="{{ $range->id }}">{{ $range->name }}</option>
                    @endforeach
                </x-select>
                <x-input-error class="mt-2" :messages="$errors->get('range_id')" />
            </div>

            <div class="flex flex-row flex-wrap gap-x-4"
                 x-data="{
                    datevalue: '{{ old('date', $contest?->date->toDateString() ?? '') }}',
                    endregistration: '{{ old('registration_end', $contest?->registration_end ?? '') }}',
                    setEndDate(type) {
                        let timestamp = 'YYYY-MM-DDTHH:mm';
                        switch (type) {
                            case 0: this.endregistration = dayjs(this.datevalue).format(timestamp); break;
                            case 1: this.endregistration = dayjs(this.datevalue).subtract(6,'h').format(timestamp); break;
                            case 2: this.endregistration = dayjs(this.datevalue).subtract(12,'h').format(timestamp); break;
                            case 3: this.endregistration = dayjs(this.datevalue).subtract(24,'h').format(timestamp); break;
                        }
                        console.log(this.endregistration);
                    }
                 }"
            >
                <div>
                    <x-input-label for="date" :value="__('Date')" />
                    <x-text-input id="date" x-model="datevalue" name="date" type="date" />
                    <x-input-error class="mt-2" :messages="$errors->get('date')" />
                </div>

                <div>
                    <x-input-label for="registration_start" :value="__('Online registration start')" />
                    <x-text-input id="registration_start" name="registration_start" type="datetime-local" :value="old('registration_start', $contest?->registration_start)" />
                    <x-input-error class="mt-2" :messages="$errors->get('registration_start')" />
                </div>

                <div>
                    <div class="text-sm">
                        <div class="inline-flex">
                            <x-input-label for="registration_end" :value="__('Online registration end')" />
                            <x-dropdown align="right" x-show="datevalue" width="w-max">
                                <x-slot name="trigger"><x-dropdown-arrow class="fill-red-700" /></x-slot>
                                <x-slot name="content">
                                    <x-dropdown-button @click="setEndDate(0)">{{ __('Midnight before contest') }}</x-dropdown-button>
                                    <x-dropdown-button @click="setEndDate(1)">{{ __('At 6PM day before contest') }}</x-dropdown-button>
                                    <x-dropdown-button @click="setEndDate(2)">{{ __('Noon day before contest') }}</x-dropdown-button>
                                    <x-dropdown-button @click="setEndDate(3)">{{ __('Midnight one day before contest') }}</x-dropdown-button>
                                </x-slot>
                            </x-dropdown>
                        </div>
                    </div>
                    <x-text-input class="" x-model="endregistration" id="registration_end" name="registration_end" type="datetime-local" />
                    <x-input-error class="mt-2" :messages="$errors->get('registration_end')" />
                </div>

                {{-- <div x-text="datevalue" class="border"></div>
                <div x-text="endregistration" class="border"></div> --}}
            </div>

            <div class="flex flex-row flex-wrap gap-x-4">
                <div class="grow">
                    <x-input-label for="contest_level_id" :value="__('Contest level')" />
                    <x-select id="contest_level_id" name="contest_level_id">
                        <option value="" selected disabled>{{__('Select contest level')}}</option>
                        @foreach ($contestlevels as $level)
                            <option value="{{ $level->id }}" @selected(old('contest_level_id') == $level->id)>{{ __('contest.' . $level->name) }}</option>
                        @endforeach
                    </x-select>
                    <x-input-error class="mt-2" :messages="$errors->get('contest_level_id')" />
                </div>

                <div class="grow">
                    <x-input-label for="contest_category_id" :value="__('Contest category')" />
                    <x-select id="contest_category_id" name="contest_category_id">
                        <option value="" selected disabled>{{__('Select contest category')}}</option>
                        @foreach ($contestcategories as $category)
                            <option value="{{ $category->id }}" @selected(old('contest_category_id') == $category->id)>{{ __('contest.' . $category->name)}}</option>
                        @endforeach
                    </x-select>
                    <x-input-error class="mt-2" :messages="$errors->get('contest_category_id')" />
                </div>
            </div>

            <div class="flex flex-row flex-wrap gap-x-4">
                <div class="grow">
                    <div>
                        <x-input-label for="organizer_group_id" :value="__('Organizer group')" />
                        <x-select id="organizer_group_id" name="organizer_group_id">
                            <option value="" selected disabled>{{ __('Select organizer group') }}</option>
                            @foreach ($orggroups as $grp)
                                <option value="{{$grp->id}}" @selected($orggroups->count() == 1 || old('organizer_group_id', $contest?->organizer_group_id) == $grp->id)>{{ $grp->name }}</option>
                            @endforeach
                        </x-select>
                        <x-input-error class="mt-2" :messages="$errors->get('organizer_group_id')" />
                    </div>
                </div>

                <div class="grow">
                    <x-input-label for="director_id" :value="__('Contest director')" />
                    <x-select id="director_id" name="director_id">
                        <option value="" selected disabled>{{ __('Select person') }}</option>
                        @foreach ($organizators as $user)
                            <option value="{{$user->id}}" @selected(old('director_id', $contest?->director_id) == $user->id)>{{ $user->displayname }}</option>
                        @endforeach
                    </x-select>
                    <x-input-error class="mt-2" :messages="$errors->get('director_id')" />
                </div>

                <div class="grow">
                    <x-input-label for="rangemaster_id" :value="__('Range master')" />
                    <x-select id="rangemaster_id" name="rangemaster_id">
                        <option value="" selected disabled>{{__('Select person')}}</option>
                        @foreach ($organizators as $user)
                            <option value="{{$user->id}}" @selected(old('rangemaster_id', $contest?->rangemaster_id) == $user->id)>{{ $user->displayname }}</option>
                        @endforeach
                    </x-select>
                    <x-input-error class="mt-2" :messages="$errors->get('rangemaster_id')" />
                </div>
            </div>

            <div>
                <x-input-label for="registration_type" :value="__('Registration type')" />
                <x-select id="registration_type" name="registration_type">
                    <option value="" selected disabled>{{ __('Select type of registration') }}</option>
                    @foreach(\App\Enums\ContestRegistrationEnum::cases() as $regtype)
                        <option value="{{ $regtype->value }}" @selected(old('registration_type', $contest?->registration_type) == $regtype->value)>{{ __('contest.' . $regtype->name) }}</option>
                    @endforeach
                </x-select>
                <x-input-error class="mt-2" :messages="$errors->get('registration_type')" />
            </div>

            <div class="flex flex-row flex-wrap gap-x-4">
                <div>
                    <x-input-label for="feebasic" :value="__('Basic entry fee')" />
                    <x-text-input id="feebasic" name="feebasic" type="number" :value="old('feebasic', $contest?->feebasic)" />
                    <x-input-error class="mt-2" :messages="$errors->get('feebasic')" />
                </div>

                <div>
                    <x-input-label for="feelex" :value="__('LEX members entry fee')" />
                    <x-text-input id="feelex" name="feelex" type="number" :value="old('feelex', $contest?->feelex)" />
                    <x-input-error class="mt-2" :messages="$errors->get('feelex')" />
                </div>
            </div>

            @include('contests.partials.registration-online')

            <div>
                <x-input-label for="instructions" :value="__('Instructions')" />
                <textarea
                    placeholder="{{ __('Specify contest instructions') }}"
                    x-data="{ resize: () => { $el.style.height = '6rem'; $el.style.height = 'calc(' + $el.scrollHeight + 'px + 1em)'; }}"
                    x-init="resize" x-on:input="resize" id="instructions" name="instructions"
                    class="w-full">{{ old('instructions', $contest?->instructions) }}</textarea>
                <x-input-error class="mt-2" :messages="$errors->get('instructions')" />
            </div>

            <div>
                <x-input-label for="calibrationwpn" :value="__('Calibration weapon/ammunition')" />
                <x-text-input id="calibrationwpn" name="calibrationwpn" type="text" class="mt-1 block w-full" :value="old('calibrationwpn', $contest?->calibrationwpn)" />
                <x-input-error class="mt-2" :messages="$errors->get('calibrationwpn')" />
            </div>

            <fieldset class="text-sm text-gray-700 font-medium border py-2 px-4 grid grid-cols-fitfirst gap-4"
                x-data="{
                    secretstages: '{{ old('secretstages', !is_null($contest) ? $contest->secretstages : '0') }}',
                    flashlight: '{{ old('flashlight', !is_null($contest) ? $contest->flashlight : '0') }}',
                    restrictions: {{ !empty(old('restrictions')) ? 'true' : (!empty($contest->restrictions) ? 'true' : 'false') }},
                }">
                <legend class="px-2">{{ __('Additional options') }}</legend>

                <div class="">{{ __('Secret stages') }}</div>
                <div class="space-x-2 text-center sm:text-left">
                    <div class="inline"><input type="radio" x-model="secretstages" id="secretstages-no" name="secretstages" value="0" /><x-input-label class="ml-1 inline" for="secretstages-no" :value="__('contest.' . \App\Enums\ContestOptionsEnum::NO->name)" /></div>
                    <div class="inline"><input type="radio" x-model="secretstages" id="secretstages-yes" name="secretstages" value="1" /><x-input-label class="ml-1 inline" for="secretstages-yes" :value="__('contest.' . \App\Enums\ContestOptionsEnum::YES->name)" /></div>
                    <x-input-error class="mt-2" :messages="$errors->get('secretstages')" />
                </div>


                <div class="col-span-1 sm:col-span-1">{{ __('Flashlight needed') }}</div>
                <div class="col-span-2 sm:col-span-1 space-x-2 text-center sm:text-left">
                    <input type="radio" x-model="flashlight" id="flashlight-no" name="flashlight" value="{{\App\Enums\ContestOptionsEnum::NO}}" /><x-input-label class="ml-1 inline" for="flashlight-no" :value="__('contest.' . \App\Enums\ContestOptionsEnum::NO->name)" />
                    <input type="radio" x-model="flashlight" id="flashlight-maybe" name="flashlight" value="{{\App\Enums\ContestOptionsEnum::POSSIBLY}}" /><x-input-label class="ml-1 inline" for="flashlight-maybe" :value="__('contest.' . \App\Enums\ContestOptionsEnum::POSSIBLY->name)" />
                    <input type="radio" x-model="flashlight" id="flashlight-yes" name="flashlight" value="{{\App\Enums\ContestOptionsEnum::YES}}" /><x-input-label class="ml-1 inline" for="flashlight-yes" :value="__('contest.' . \App\Enums\ContestOptionsEnum::YES->name)" />
                </div>

                <div class="col-span-2">
                    <input type="checkbox" id="restrictions" x-model="restrictions" name="restrictions" /><x-input-label class="ml-1 inline" for="restrictions" :value="__('Other requirements/restrictions')" />
                    <div x-show="restrictions" class="mt-2">
                        <textarea
                            placeholder="{{ __('Specify additional requirements or restrictions') }}"
                            x-data="{ resize: () => { $el.style.height = '2rem'; if(restrictions) {$el.style.height = 'calc(' + $el.scrollHeight + 'px + 1em)'; }}}"
                            x-init="$watch('restrictions', value => resize)" x-on:input="resize" id="restrictionstext" name="restrictionstext"
                            class="w-full">{{ old('restrictionstext', $contest?->restrictionstext) }}</textarea>
                        <x-input-error class="mt-2" :messages="$errors->get('restrictionstext')" />

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

            <div class="flex flex-row flex-wrap gap-x-4 text-sm text-gray-700 font-medium"
                x-data="{ published: '{{ old('published', !is_null($contest) ? $contest->published : '0') }}' }">
                <div class="font-semibold">{{ __('Contest publication status') }}</div>
                <div>
                    <input type="radio" x-model="published" id="published-no" name="published" value="0"/>
                    <x-input-label class="!inline ml-1" for="published-no" :value="__('Hidden')" />
                </div>
                <div>
                    <input type="radio" x-model="published" id="published-yes" name="published" value="1" />
                    <x-input-label class="!inline ml-1" for="published-yes" :value="__('Published')" />
                </div>
                <x-input-error class="mt-2" :messages="$errors->get('published')" />
            </div>

            <div class="flex items-center gap-4 justify-end"><x-primary-button class="mr-4">{{ __('Save') }}</x-primary-button></div>
        </form>
    </section>
</x-app-layout>

Zerion Mini Shell 1.0