vacancy_autolift.blade.php 16.5 KB
@extends('layout.frontend', ['title' => 'Автоподнятие вакансий'])
@section('scripts')
    <script>
        $(document).on('click', '#submit', function () {
            let data = {};
            data.is_enabled = document.querySelector('.js_autoraise_toggle').checked;
            data.times_per_day = $('[name="times_per_day"]').chosen().val();
            data.days_repeat = $('[name="days_repeat"]').chosen().val();
            data.time_send_first = $('[name="time_send_first"]').val();
            data.time_send_second = $('[name="time_send_second"]').val();
            data.time_send_third = $('[name="time_send_third"]').val();
            data.time_send_tg = $('[name="time_send_tg"]').val();

            data.vacancies = [];

            document.getElementsByName('vacancy_table_row').forEach(function(field) {
                data.vacancies.push({
                    'id': field.dataset.id,
                    'autolift_site': field.querySelector('input[name="autolift_site"]').checked,
                    'autosend_tg': field.querySelector('input[name="autosend_tg"]').checked
                })
            });

            $.ajax({
                url: '{{ route('employer.autolift_save') }}',
                type: 'POST',
                data: data,
                headers: {
                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
                },
                success: function (result) {
                    location.reload();
                },
                error: function (result) {
                    //todo пульнуть какуюнить модалку
                },
            });
        })
    </script>
@endsection
@section('content')
    <section class="cabinet">
        <div class="container">
            <ul class="breadcrumbs cabinet__breadcrumbs">
                <li><a href="{{ route('index') }}">Главная</a></li>
                <li><b>Личный кабинет</b></li>
            </ul>
            <div class="cabinet__wrapper">
                <div class="cabinet__side">
                    <div class="cabinet__side-toper">
                        @include('employers.emblema')
                    </div>
                    @include('employers.menu', ['item' => 15])
                </div>
                <form class="cabinet__body">
                    @csrf
                    <div class="cabinet__body-item">
                        <h2 class="title cabinet__title">Автоподнятие вакансий</h2>
                        <div class="cabinet__inputs">
                            <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth">
                                <?php
                                    $createdAtClone = isset($options->created_at) ? clone($options->created_at) : now();
                                    $diff = $createdAtClone->addDays($options->days_repeat)->diffInDays($options->created_at);
                                ?>
                                <label class="toggle">
                                    <input name="is_enabled" type="checkbox" @if($options->is_enabled) checked disabled @endif class="toggle__input js_autoraise_toggle">
                                    <span class="toggle__icon"></span>
                                    <span class="toggle__text">Деактивировано</span>
                                    <span class="toggle__text">Активировано</span>
                                </label>
                                <p class="mod js_autoraise_prompt @if($options->is_enabled === 1) hidden @endif">Срок действия автоподнятия вакансии истек. Желаете его возобновить?</p>
                                <p class="mod js_autoraise_prompt @if($options->is_enabled === 0) hidden @endif">Автоподнятие вакансии продолжит действовать в течение следующих дней: <span>{{$diff}}</span></p>
                            </div>
                            <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
                                <label class="form-group__label">Сколько раз в день необходимо обновлять
                                    вакансии?</label>
                                <div class="form-group__item">
                                    <div class="select">
                                        <select name="times_per_day" class="js-select2 js_autoraise_select">
                                            <option @if($options['times_per_day'] === null) selected @endif disabled>Выберите вариант из списка</option>
                                            <option @if($options['times_per_day'] === 1) selected @endif value="1">1 раз</option>
                                            <option @if($options['times_per_day'] === 2) selected @endif value="2">2 раза</option>
                                            <option @if($options['times_per_day'] === 3) selected @endif value="3">3 раза</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <label class="cabinet__inputs-item form-group">
                                <div class="form-group__label">Выберите первое время обновления (по
                                    МСК)</div>
                                <div class="form-group__item">
                                    <span class="form-group__item-icon">
                                        <svg>
                                            <use xlink:href="images/sprite.svg#date"></use>
                                        </svg>
                                    </span>
                                    <input
                                        name="time_send_first"
                                        type="text"
                                        class="input js-picker input-picker"
                                        placeholder="Время"
                                        value="{{ $options['time_send_first'] }}"
                                    >
                                </div>
                            </label>
                            <label class="cabinet__inputs-item form-group">
                                <div class="form-group__label">Выберите второе время обновления (по
                                    МСК)</div>
                                <div class="form-group__item">
                                    <span class="form-group__item-icon">
                                        <svg>
                                            <use xlink:href="images/sprite.svg#date"></use>
                                        </svg>
                                    </span>
                                    <input
                                        name="time_send_second"
                                        type="text"
                                        class="input js-picker input-picker"
                                        placeholder="Время"
                                        value="{{ $options['time_send_second'] }}"
                                        @if($options['times_per_day'] < 2) disabled @endif
                                    >
                                </div>
                            </label>
                            <label class="cabinet__inputs-item form-group">
                                <div class="form-group__label">Выберите третье время обновления (по МСК)</div>
                                <div class="form-group__item">
                                    <span class="form-group__item-icon">
                                        <svg>
                                            <use xlink:href="images/sprite.svg#date"></use>
                                        </svg>
                                    </span>
                                    <input
                                        name="time_send_third"
                                        type="text"
                                        class="input js-picker input-picker"
                                        placeholder="Время"
                                        value="{{ $options['time_send_third'] }}"
                                        @if($options['times_per_day'] < 3) disabled @endif
                                    >
                                </div>
                            </label>
                            <label class="cabinet__inputs-item form-group">
                                <div class="form-group__label">Выберите время отправки в телеграм (по МСК)</div>
                                <div class="form-group__item">
                                    <span class="form-group__item-icon">
                                        <svg>
                                            <use xlink:href="images/sprite.svg#date"></use>
                                        </svg>
                                    </span>
                                    <input
                                        name="time_send_tg"
                                        type="text"
                                        class="input js-picker"
                                        placeholder="Время"
                                        value="{{ $options['time_send_tg'] }}"
                                    >
                                </div>
                            </label>
                            <div class="cabinet__inputs-item form-group">
                                <label class="form-group__label">Выполнять это действие на протяжении</label>
                                <div class="form-group__item">
                                    <div class="select">
                                        <select name="days_repeat" class="js-select2">
                                            <option @if($options['days_repeat'] === null) selected @endif disabled>Выполнять это действие на протяжении</option>
                                            <option @if($options['days_repeat'] === 1) selected @endif value="1">1 день</option>
                                            <option @if($options['days_repeat'] === 3) selected @endif value="3">3 дня</option>
                                            <option @if($options['days_repeat'] === 5) selected @endif value="5">5 дней</option>
                                            <option @if($options['days_repeat'] === 7) selected @endif value="7">7 дней</option>
                                            <option @if($options['days_repeat'] === 10) selected @endif value="10">10 дней</option>
                                            <option @if($options['days_repeat'] === 15) selected @endif value="15">15 дней</option>
                                            <option @if($options['days_repeat'] === 30) selected @endif value="30">30 дней</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="table table_spoiler">
                            <button type="button"
                                    class="table__button js-toggle js-parent-toggle button button_light button_more">
                                <span>Показать ещё</span>
                                <span>Свернуть</span>
                            </button>
                            <div class="table__scroll">
                                <div class="table__body table__body_min-width">
                                    <table>
                                        <thead>
                                            <tr>
                                                <th>Название</th>
                                                <th>Обновлять на сайте</th>
                                                <th>Отправлять в ТГ</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @foreach($vacancies as $vacancy)
                                                <tr name="vacancy_table_row" data-id="{{ $vacancy->id }}">
                                                    <td>{{ $vacancy->name }}</td>
                                                    <td >
                                                        <span class="checkbox-empty">
                                                            <label class="checkbox">
                                                                <input
                                                                    type="checkbox"
                                                                    class="checkbox__input"
                                                                    @if($vacancy->autolift_site) checked @endif
                                                                    name="autolift_site"
                                                                >
                                                                <span class="checkbox__icon">
                                                                    <svg>
                                                                        <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
                                                                    </svg>
                                                                </span>
                                                            </label>
                                                        </span>
                                                    </td>
                                                    <td>
                                                        <span class="checkbox-empty">
                                                            <label class="checkbox">
                                                                <input
                                                                    type="checkbox"
                                                                    class="checkbox__input"
                                                                    @if($vacancy->autosend_tg) checked @endif
                                                                    name="autosend_tg"
                                                                >
                                                                <span class="checkbox__icon">
                                                                    <svg>
                                                                        <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
                                                                    </svg>
                                                                </span>
                                                            </label>
                                                        </span>
                                                    </td>
                                                </tr>
                                            @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="mrg-wrapper" style="display: flex; justify-content: center; clear: both;">
                                <ins class="mrg-tag" data-ad-client="ad-595528" data-ad-slot="595528" style="display: flex; align-items: center; justify-content: center; width: 300px; z-index: 1;">

                                </ins>
                            </div>
                        </div>
                        <div class="cabinet__inputs">
                            <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth">
                                <button id="submit" type="button" class="button">Сохранить</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
    </div>
@endsection