%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/production/resources/views/contests/
Upload File :
Create Path :
Current File : /www/loslex/production/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);
?>

@push('scripts')
    <script type="module">
        $(document).ready(function() {
            $('#director_id').select2({ width: 'element', language: { noResults: function(){return ' {{ __('No results found') }}';}}, dropdownCssClass: ':all:', selectionCssClass: ':all:' });
            $('#rangemaster_id').select2({ width: 'element', language: { noResults: function(){return ' {{ __('No results found') }}';}}, dropdownCssClass: ':all:', selectionCssClass: ':all:' });
            $('#range_id').select2({ width: 'element', language: { noResults: function(){return ' {{ __('No results found') }}';}}, dropdownCssClass: ':all:', selectionCssClass: ':all:' });
        });
    </script>
@endpush

<x-app-layout>
    <x-slot name="pagetitle">@isset ($contest) {{ __('Edit contest') . " - {$contest->contestname}" }} @else {{ __('Create new contest') }}@endisset</x-slot>

    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 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> --}}
            @if ($errors->any())<x-input-error class="mt-2" :messages="array(__('Fix any invalid fields before form saving.'))" />@endif

            <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" class="mt-1">
                    <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-4"
                 x-data="{
                    datevalue: '{{ old('date', $contest?->date->toDateString() ?? '') }}',
                    startregistration: '{{ old('registration_start', $contest?->registration_start ?? '') }}',
                    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;
                            case 4: this.endregistration = dayjs(this.datevalue).subtract(48,'h').format(timestamp); break;
                        }
                    },
                    setStartDate(type) {
                        let timestamp = 'YYYY-MM-DDTHH:mm';
                        switch (type) {
                            case 0: this.startregistration = dayjs(this.datevalue).subtract(1, 'M').add(18, 'h').format(timestamp); break;
                        }
                    }
                 }"
            >
                <div>
                    <x-input-label for="date" :value="__('Contest date')" />
                    <x-text-input class="mt-1 dark:[color-scheme:dark]" id="date" x-model="datevalue" name="date" type="date" />
                    <x-input-error class="mt-2" :messages="$errors->get('date')" />
                </div>

                <div class="flex flex-row flex-wrap gap-4 w-full"
                    x-data="{
                        get showonlinereg() { return this.registration_type == {{ \App\Enums\ContestRegistrationEnum::ONLINE }}},
                        get showexternalurl() { return this.registration_type == {{ \App\Enums\ContestRegistrationEnum::OFFSITE }}},
                        registration_type: {{ old('registration_type', $contest?->registration_type ?? \App\Enums\ContestRegistrationEnum::ONLINE) }}
                    }"
                >
                    <div>
                        <x-input-label for="registration_type" :value="__('Registration type')" />
                        <x-select class="mt-1" id="registration_type" name="registration_type" x-model="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="grow" x-show="showexternalurl">
                        <x-input-label for="offsiteregurl" :value="__('External registration URL')" />
                        <x-text-input id="offsiteregurl" name="offsiteregurl" type="text" class="mt-1 block w-full" :value="old('offsiteregurl', $contest?->externalregurl)" />
                        <x-input-error class="mt-2" :messages="$errors->get('offsiteregurl')" />
                    </div>

                    <div x-show="showonlinereg">
                        <div class="text-sm">
                            <div class="inline-flex items-center">
                                <x-input-label for="registration_start" :value="__('Online registration start')" />
                                <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="setStartDate(0)">{{ __('One month before contest at 6PM') }}</x-dropdown-button>
                                    </x-slot>
                                </x-dropdown>
                            </div>
                        </div>
                        <x-text-input class="mt-1 dark:[color-scheme:dark]" x-model="startregistration" id="registration_start" name="registration_start" type="datetime-local" />
                        <x-input-error class="mt-2" :messages="$errors->get('registration_start')" />
                    </div>

                    <div x-show="showonlinereg">
                        <div class="text-sm">
                            <div class="inline-flex items-center">
                                <x-input-label for="registration_end" :value="__('Online registration end')" />
                                <x-dropdown align="top" 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)">{{ __('At midnight before contest') }}</x-dropdown-button>
                                        <x-dropdown-button @click="setEndDate(1)">{{ __('At 6PM one day before contest') }}</x-dropdown-button>
                                        <x-dropdown-button @click="setEndDate(2)">{{ __('At noon one day before contest') }}</x-dropdown-button>
                                        <x-dropdown-button @click="setEndDate(3)">{{ __('At midnight one day before contest') }}</x-dropdown-button>
                                        <x-dropdown-button @click="setEndDate(4)">{{ __('At midnight two days before contest') }}</x-dropdown-button>
                                    </x-slot>
                                </x-dropdown>
                            </div>
                        </div>
                        <x-text-input class="mt-1 dark:[color-scheme:dark]" 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>
            </div>

            <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div>
                    <x-input-label for="contest_level_id" :value="__('Contest level')" />
                    <x-select class="mt-1 w-full" 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', $contest?->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>
                    <x-input-label for="contest_category_id" :value="__('Contest category')" />
                    <x-select class="mt-1 w-full" 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', $contest?->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>
                    <x-input-label for="organizer_group_id" :value="__('Organizer')" />
                    <x-select class="mt-1" id="organizer_group_id" name="organizer_group_id">
                        <option value="" selected disabled>{{ __('Select organizer group') }}</option>
                        @foreach ($orggroups as $grp)
                            <option class="{{ auth()->user()->is_admin && auth()->user()->is_organizer_member($grp->id) ? 'font-bold' : '' }}" 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>
                    <x-input-label for="organizeremail" :value="__('Organizer email')" />
                    <x-text-input placeholder="{{ __('If empty, email of contest director will be displayed.') }}" id="organizeremail" name="organizeremail" type="text" class="mt-1 block w-full" :value="old('organizeremail', $contest?->organizeremail)" />
                    <x-input-error class="mt-2" :messages="$errors->get('organizeremail')" />
                </div>

                <div>
                    <x-input-label for="director_id" :value="__('Contest director')" />
                    <x-select class="mt-1" 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->username }} - {{ $user->displayname }}</option>
                        @endforeach
                    </x-select>
                    <x-input-error class="mt-2" :messages="$errors->get('director_id')" />
                </div>

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

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

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

                <div>
                    <x-input-label for="protestdeposit" :value="__('Protest deposit')" />
                    <x-text-input class="mt-1" id="protestdeposit" name="protestdeposit" type="number" :value="old('protestdeposit', $contest?->protestdeposit)" />
                    <x-input-error class="mt-2" :messages="$errors->get('protestdeposit')" />
                </div>
            </div>

            <div class="flex flex-row flex-wrap gap-4">
                <div>
                    <x-input-label class="inline" for="accountnumber" :value="__('Account number')" />
                    <x-tooltip class="max-w-xs">{{ __('tooltips.bankaccformat') }}</x-tooltip>
                    <x-text-input class="block mt-1 w-64" id="accountnumber" name="accountnumber" type="text" :value="old('accountnumber', $contest?->accountnumber)" />
                    <x-input-error class="mt-2" :messages="$errors->get('accountnumber')" />
                </div>

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

                <div>
                    <x-input-label class="inline" for="accnote" :value="__('Payment note')" />
                    <x-tooltip class="max-w-xs">{{ __('tooltips.bankaccnote') }}</x-tooltip>
                    <x-text-input class="block mt-1 w-64" id="accnote" name="accnote" type="text" :value="old('accnote', $contest?->accnote)" />
                    <x-input-error class="mt-2" :messages="$errors->get('accnote')" />
                </div>

                <div>
                    <x-input-label class="inline" for="acccondition" :value="__('Payment conditions')" />
                    <x-text-input class="block mt-1 w-64" id="acccondition" name="acccondition" type="text" placeholder="{{ __('E.g. due date for entry fee') }}" :value="old('acccondition', $contest?->acccondition)" />
                    <x-input-error class="mt-2" :messages="$errors->get('acccondition')" />
                </div>
            </div>


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

            <fieldset class="text-sm text-gray-700 dark:text-gray-300 font-medium border border-gray-300 dark:border-gray-700 py-2 px-4 grid grid-cols-fitfirst gap-4 rounded-md"
                x-data="{
                    secretstages: '{{ old('secretstages', !is_null($contest) ? $contest->secretstages : '0') }}',
                    flashlight: '{{ old('flashlight', !is_null($contest) ? $contest->flashlight : '0') }}',
                    canteen: '{{ old('canteen', !is_null($contest) ? $contest->canteen : '1') }}',
                    toilet: '{{ old('toilet', !is_null($contest) ? $contest->toilet : '1') }}',
                }">
                <legend class="px-2 ">{{ __('Contest options') }}</legend>

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

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

                <div class="col-span-2">
                    <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>

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

                <div class="col-span-2">
                    <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="$nextTick(resize)" x-on:input="resize" x-on:focus="resize" id="instructions" name="instructions"
                        class="text-sm mt-1 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-full">{{ old('instructions', $contest?->instructions) }}</textarea>
                    <x-input-error class="mt-2" :messages="$errors->get('instructions')" />
                </div>

                <div class="col-span-2">
                    <x-input-label for="legend" :value="__('Legend or stages description')" />
                    <div class="mt-2">
                        <textarea
                            placeholder="{{ __('Specify contest legend, stages description or keep empty') }}"
                            x-data="{ resize() { $el.style.height = '2rem'; $el.style.height = 'calc(' + $el.scrollHeight + 'px + 1em)'; }}"
                            x-init="$nextTick(resize)" x-on:input="resize" x-on:focus="resize" id="legend" name="legend"
                            class="text-sm mt-1 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-full">{{ old('legend', $contest?->legend) }}</textarea>
                        <x-input-error class="mt-2" :messages="$errors->get('legend')" />
                    </div>
                </div>

                <div class="col-span-2">
                    <x-input-label for="restrictionstext" :value="__('Other requirements or restrictions')" />
                    <div class="mt-2">
                        <textarea
                            placeholder="{{ __('Specify additional requirements or restrictions or keep empty') }}"
                            x-data="{ resize() { $el.style.height = '2rem'; $el.style.height = 'calc(' + $el.scrollHeight + 'px + 1em)'; }}"
                            x-init="$nextTick(resize)" x-on:input="resize" x-on:focus="resize" id="restrictionstext" name="restrictionstext"
                            class="text-sm mt-1 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-full">{{ old('restrictionstext', $contest?->restrictionstext) }}</textarea>
                        <x-input-error class="mt-2" :messages="$errors->get('restrictionstext')" />
                    </div>
                </div>
            </fieldset>

            <div class="col-span-2">
                <x-input-label for="partners" :value="__('Partners or sponsors')" />
                <div class="text-sm">{{ __('One Partner per line or separated by semicolon. Partner name in plain text or format link using brackets [Partner name](URL).') }}</div>
                <textarea
                    placeholder="{{ __('Enter Partners or keep empty.') }}"
                    x-data="{ resize() { $el.style.height = '2rem'; $el.style.height = 'calc(' + $el.scrollHeight + 'px + 1em)'; }}"
                    x-init="$nextTick(resize)" x-on:input="resize" x-on:focus="resize" id="partners" name="partners"
                    class="text-sm mt-1 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm w-full">{{ old('partners', $contest?->partners) }}</textarea>
                <x-input-error class="mt-2" :messages="$errors->get('partners')" />
            </div>

            <div class="col-span-1 sm:col-span-1 text-sm">{{ __('Contest publication status') }}</div>
            <div class="col-span-2 sm:col-span-1 space-x-2 text-center"
                 x-data="{ published: '{{ old('published', !is_null($contest) ? $contest->published : '0') }}' }">
                @foreach (\App\Enums\ContestPublicationStatusEnum::cases() as $status)
                    <div class="inline">
                        <x-text-input type="radio" x-model="published" id="published-{{$status->value}}" name="published" :value="$status->value"/>
                        <x-input-label class="!inline ml-1" for="published-{{$status->value}}" :value="__('contest.' . $status->name)" />
                    </div>
                @endforeach
                <x-input-error class="block 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