@extends('backend.layouts.app')
@section('title', @$data['title'])

@section('content')
    {!! breadcrumb([
        'title' => @$data['title'],
        route('admin.dashboard') => _trans('common.Dashboard'),
        '#' => @$data['title'],
    ]) !!}

    <div class="card ot-card">
        <div class="card-body">
            <form 
                method="POST" 
                action="{{ route('travel.workflows.store') }}" 
                enctype="multipart/form-data" 
                autocomplete="off"
                id="form"
            >
                @csrf
                <div class="col-md-12">
                    <div class="row form-group mb-3 text-start">
                        <label for="date" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Date') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="date" name="date" class="form-control ot-form-control ot-input" value="{{ old('date', date('Y-m-d')) }}" required>
                            @if ($errors->has('date'))
                                <span class="error text-danger">
                                    {{ $errors->first('date') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="start_time" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Start Time') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="time" name="start_time" class="form-control ot-form-control ot-input" value="{{ old('start_time') }}" required>
                            @if ($errors->has('start_time'))
                                <span class="error text-danger">
                                    {{ $errors->first('start_time') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="end_time" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.End Time') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="time" name="end_time" class="form-control ot-form-control ot-input" value="{{ old('end_time') }}" required>
                            @if ($errors->has('end_time'))
                                <span class="error text-danger">
                                    {{ $errors->first('end_time') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="calls_made" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Calls Made') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="number" name="calls_made" class="form-control ot-form-control ot-input" value="{{ old('calls_made') }}" step="0.01" min="0" required>
                            <small class="text-muted">{{ _trans('common.Number Of Calls You Did Today?') }}</small>
                            @if ($errors->has('calls_made'))
                                <br>
                                <span class="error text-danger">
                                    {{ $errors->first('calls_made') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="positive_leads" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Positive Leads') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="number" name="positive_leads" class="form-control ot-form-control ot-input" value="{{ old('positive_leads') }}" step="0.01" min="0" required>
                            @if ($errors->has('positive_leads'))
                                <span class="error text-danger">
                                    {{ $errors->first('positive_leads') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="total_sales" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Total Sales') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="text" name="total_sales" class="form-control ot-form-control ot-input" value="{{ old('total_sales') }}" required>
                            @if ($errors->has('total_sales'))
                                <span class="error text-danger">
                                    {{ $errors->first('total_sales') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="is_update_pending_and_leads" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Update your pending and leads?') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <div class="pt-3">
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_update_pending_and_leads" id="pendingAndLeadsYes" value="Yes" onchange="togglePendingAndLeadsOtherNote(this)" {{ old('is_update_pending_and_leads') == 'Yes' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="pendingAndLeadsYes">{{ _trans('common.Yes') }}</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_update_pending_and_leads" id="pendingAndLeadsNo" value="No" onchange="togglePendingAndLeadsOtherNote(this)" {{ old('is_update_pending_and_leads') == 'No' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="pendingAndLeadsNo">{{ _trans('common.No') }}</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_update_pending_and_leads" id="pendingAndLeadsOther" value="Other" onchange="togglePendingAndLeadsOtherNote(this)" {{ old('is_update_pending_and_leads') == 'Other' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="pendingAndLeadsOther">{{ _trans('common.Other') }}</label>
                                </div>
                            </div>
                            <input type="text" name="pending_and_leads_other_note" id="pendingAndLeadsOtherNote" class="{{ old('is_update_pending_and_leads') == 'Other' ? '' : 'd-none' }} form-control ot-form-control ot-input mt-3" value="{{ old('pending_and_leads_other_note') }}" placeholder="{{ _trans('common.Please type another option here') }}">
                            @if ($errors->has('pending_and_leads_other_note'))
                                <span class="error text-danger">
                                    {{ $errors->first('pending_and_leads_other_note') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="is_worked_on_recovery_today" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Worked on recovery today?') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <div class="pt-3">
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_worked_on_recovery_today" id="workedOnRecoveryTodayYes" value="Yes" onchange="toggleRecoveryTodayOtherNote(this)" {{ old('is_worked_on_recovery_today') == 'Yes' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="workedOnRecoveryTodayYes">{{ _trans('common.Yes') }}</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_worked_on_recovery_today" id="workedOnRecoveryTodayNo" value="No" onchange="toggleRecoveryTodayOtherNote(this)" {{ old('is_worked_on_recovery_today') == 'No' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="workedOnRecoveryTodayNo">{{ _trans('common.No') }}</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="is_worked_on_recovery_today" id="workedOnRecoveryTodayOther" value="Other" onchange="toggleRecoveryTodayOtherNote(this)" {{ old('is_worked_on_recovery_today') == 'Other' ? 'checked' : '' }}>
                                    <label class="form-check-label" for="workedOnRecoveryTodayOther">{{ _trans('common.Other') }}</label>
                                </div>
                            </div>
                            <input type="text" name="recovery_today_other_note" id="recoveryTodayOtherNote" class="{{ old('is_worked_on_recovery_today') == 'Other' ? '' : 'd-none' }} form-control ot-form-control ot-input mt-3" value="{{ old('recovery_today_other_note') }}" placeholder="{{ _trans('common.Please type another option here') }}">
                            @if ($errors->has('recovery_today_other_note'))
                                <span class="error text-danger">
                                    {{ $errors->first('recovery_today_other_note') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="daily_report_summary" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Daily Report Summary') }} <span class="text-danger">*</span></label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <textarea name="daily_report_summary" class="form-control" rows="5">{!! nl2br(old('daily_report_summary')) !!}</textarea>
                            <small class="text-muted">{{ _trans('common.Write a general summary of your work activity today') }}</small>
                            @if ($errors->has('daily_report_summary'))
                                <br>
                                <span class="error text-danger">
                                    {{ $errors->first('daily_report_summary') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="complaints_questions_comments" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.Complaints, Questions, Comments') }}</label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <input type="text" name="complaints_questions_comments" class="form-control ot-form-control ot-input" value="{{ old('complaints_questions_comments') }}">
                            @if ($errors->has('complaints_questions_comments'))
                                <span class="error text-danger">
                                    {{ $errors->first('complaints_questions_comments') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="remark" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.File') }}</label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <div class="ot_fileUploader left-side mb-3">
                                <input class="form-control" type="text" name="file" readonly="" id="placeholder3">
                                <button class="primary-btn-small-input" type="button">
                                    <label class="btn btn-lg ot-btn-primary m-0" for="fileBrouse3">Browse</label>
                                    <input type="file" class="d-none form-control" name="file" id="fileBrouse3">
                                </button>
                            </div>
                            @if ($errors->has('file'))
                                <span class="error text-danger">
                                    {{ $errors->first('file') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="row form-group mb-3 text-start">
                        <label for="how_was_your_day_mark" class="col-md-4 col-lg-3 col-xl-2 form-label pt-3 text-end">{{ _trans('common.In Terms of Production, How was your day?') }}</label>
                        <div class="col-md-8 col-lg-9 col-xl-10">
                            <select name="how_was_your_day_mark" class="form-control select2">
                                <option value="" selected></option>
                                <option value="1" {{ old('how_was_your_day_mark') == 1 ? 'selected' : '' }}>1</option>
                                <option value="2" {{ old('how_was_your_day_mark') == 2 ? 'selected' : '' }}>2</option>
                                <option value="3" {{ old('how_was_your_day_mark') == 3 ? 'selected' : '' }}>3</option>
                                <option value="4" {{ old('how_was_your_day_mark') == 4 ? 'selected' : '' }}>4</option>
                                <option value="5" {{ old('how_was_your_day_mark') == 5 ? 'selected' : '' }}>5</option>
                                <option value="6" {{ old('how_was_your_day_mark') == 6 ? 'selected' : '' }}>6</option>
                                <option value="7" {{ old('how_was_your_day_mark') == 7 ? 'selected' : '' }}>7</option>
                                <option value="8" {{ old('how_was_your_day_mark') == 8 ? 'selected' : '' }}>8</option>
                                <option value="9" {{ old('how_was_your_day_mark') == 9 ? 'selected' : '' }}>9</option>
                                <option value="10" {{ old('how_was_your_day_mark') == 10 ? 'selected' : '' }}>10</option>
                            </select>
                            @if ($errors->has('how_was_your_day_mark'))
                                <span class="error text-danger">
                                    {{ $errors->first('how_was_your_day_mark') }}
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="d-flex justify-content-end gap-2 mt-5">
                        <a href="{{ route('travel.workflows.index') }}" class="btn btn-secondary d-flex align-items-center gap-2">
                            <i class="las la-arrow-left fs-4"></i> 
                            {{ _trans('common.Back to list') }}
                        </a>
                        <button class="btn btn-gradian d-flex align-items-center gap-2"><i class="las la-check fs-4"></i> {{ _trans('common.Submit') }}</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection

@section('script')
    <script>
        const togglePendingAndLeadsOtherNote = (obj) => {

            if($(obj).val() == 'Other') {
                $('#pendingAndLeadsOtherNote').removeClass('d-none');
            } else {
                $('#pendingAndLeadsOtherNote').addClass('d-none');
            }
        }

        const toggleRecoveryTodayOtherNote = (obj) => {

            if($(obj).val() == 'Other') {
                $('#recoveryTodayOtherNote').removeClass('d-none');
            } else {
                $('#recoveryTodayOtherNote').addClass('d-none');
            }
        }
    </script>
@endsection