

<?php if (isset($component)) { $__componentOriginal9f64f32e90b9102968f2bc548315018c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9f64f32e90b9102968f2bc548315018c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.modal','data' => ['name' => 'quick-create-department','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'quick-create-department','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']); ?>
     <?php $__env->slot('title', null, []); ?> Add Department <?php $__env->endSlot(); ?>
    <form
        data-quick-create-form
        data-select="department_id"
        action="<?php echo e(route('departments.store')); ?>"
        method="POST"
        class="space-y-4"
    >
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
            <input type="text" name="name" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. Engineering">
            <p data-error="name" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <p data-quick-create-error class="hidden text-sm text-red-600"></p>
        <div class="flex gap-2 pt-2">
            <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit','variant' => 'primary']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','variant' => 'primary']); ?>Save <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
            <button type="button" @click="$dispatch('close-modal')" class="inline-flex items-center rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</button>
        </div>
    </form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $attributes = $__attributesOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__attributesOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $component = $__componentOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__componentOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>

<?php if (isset($component)) { $__componentOriginal9f64f32e90b9102968f2bc548315018c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9f64f32e90b9102968f2bc548315018c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.modal','data' => ['name' => 'quick-create-designation','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'quick-create-designation','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']); ?>
     <?php $__env->slot('title', null, []); ?> Add Designation <?php $__env->endSlot(); ?>
    <form
        data-quick-create-form
        data-select="designation_id"
        action="<?php echo e(route('designations.store')); ?>"
        method="POST"
        class="space-y-4"
    >
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
            <input type="text" name="name" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. Software Engineer">
            <p data-error="name" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <p data-quick-create-error class="hidden text-sm text-red-600"></p>
        <div class="flex gap-2 pt-2">
            <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit','variant' => 'primary']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','variant' => 'primary']); ?>Save <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
            <button type="button" @click="$dispatch('close-modal')" class="inline-flex items-center rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</button>
        </div>
    </form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $attributes = $__attributesOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__attributesOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $component = $__componentOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__componentOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>

<?php if (isset($component)) { $__componentOriginal9f64f32e90b9102968f2bc548315018c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9f64f32e90b9102968f2bc548315018c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.modal','data' => ['name' => 'quick-create-location','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'quick-create-location','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']); ?>
     <?php $__env->slot('title', null, []); ?> Add Location <?php $__env->endSlot(); ?>
    <form
        data-quick-create-form
        data-select="location_id"
        action="<?php echo e(route('locations.store')); ?>"
        method="POST"
        class="space-y-4"
    >
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
            <input type="text" name="name" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. Hyderabad HQ">
            <p data-error="name" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <div>
            <label class="block text-sm font-medium text-slate-700">Code <span class="text-red-500">*</span></label>
            <input type="text" name="code" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. HYD">
            <p data-error="code" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <div>
            <label class="block text-sm font-medium text-slate-700">Address</label>
            <textarea name="address" rows="3" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2"></textarea>
            <p data-error="address" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <p data-quick-create-error class="hidden text-sm text-red-600"></p>
        <div class="flex gap-2 pt-2">
            <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit','variant' => 'primary']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','variant' => 'primary']); ?>Save <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
            <button type="button" @click="$dispatch('close-modal')" class="inline-flex items-center rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</button>
        </div>
    </form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $attributes = $__attributesOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__attributesOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $component = $__componentOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__componentOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>

<?php if (isset($component)) { $__componentOriginal9f64f32e90b9102968f2bc548315018c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9f64f32e90b9102968f2bc548315018c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.modal','data' => ['name' => 'quick-create-shift','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'quick-create-shift','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']); ?>
     <?php $__env->slot('title', null, []); ?> Add Shift <?php $__env->endSlot(); ?>
    <form
        data-quick-create-form
        data-select="shift_id"
        action="<?php echo e(route('shifts.store')); ?>"
        method="POST"
        class="space-y-4"
    >
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
            <input type="text" name="name" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. General Shift">
            <p data-error="name" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <div>
            <label class="block text-sm font-medium text-slate-700">Clock In <span class="text-red-500">*</span></label>
            <input type="time" name="clock_in_time" value="09:00" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">
            <p data-error="clock_in_time" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <div>
            <label class="block text-sm font-medium text-slate-700">Clock Out <span class="text-red-500">*</span></label>
            <input type="time" name="clock_out_time" value="18:00" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">
            <p data-error="clock_out_time" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <input type="hidden" name="grace_period_minutes" value="0">
        <input type="hidden" name="early_going_grace_minutes" value="0">
        <input type="hidden" name="is_active" value="1">
        <input type="hidden" name="is_night_shift" value="0">
        <p data-quick-create-error class="hidden text-sm text-red-600"></p>
        <div class="flex gap-2 pt-2">
            <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit','variant' => 'primary']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','variant' => 'primary']); ?>Save <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
            <button type="button" @click="$dispatch('close-modal')" class="inline-flex items-center rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</button>
        </div>
    </form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $attributes = $__attributesOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__attributesOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $component = $__componentOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__componentOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>

<?php if (isset($component)) { $__componentOriginal9f64f32e90b9102968f2bc548315018c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9f64f32e90b9102968f2bc548315018c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.modal','data' => ['name' => 'quick-create-salary-group','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'quick-create-salary-group','slideFrom' => 'right','class' => 'ml-auto h-full w-full max-w-md overflow-y-auto rounded-none border-l border-slate-200']); ?>
     <?php $__env->slot('title', null, []); ?> Add Salary Group <?php $__env->endSlot(); ?>
    <form
        data-quick-create-form
        data-select="salary_group_id"
        action="<?php echo e(route('salary-groups.store')); ?>"
        method="POST"
        class="space-y-4"
    >
        <?php echo csrf_field(); ?>
        <div>
            <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
            <input type="text" name="name" required class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2" placeholder="e.g. Standard CTC">
            <p data-error="name" class="mt-1 hidden text-sm text-red-600"></p>
        </div>
        <p class="text-xs text-slate-500">Components can be configured later from Salary Groups.</p>
        <p data-quick-create-error class="hidden text-sm text-red-600"></p>
        <div class="flex gap-2 pt-2">
            <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit','variant' => 'primary']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit','variant' => 'primary']); ?>Save <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
            <button type="button" @click="$dispatch('close-modal')" class="inline-flex items-center rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</button>
        </div>
    </form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $attributes = $__attributesOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__attributesOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9f64f32e90b9102968f2bc548315018c)): ?>
<?php $component = $__componentOriginal9f64f32e90b9102968f2bc548315018c; ?>
<?php unset($__componentOriginal9f64f32e90b9102968f2bc548315018c); ?>
<?php endif; ?>

<script>
(function () {
    function csrfToken() {
        const meta = document.querySelector('meta[name="csrf-token"]');
        return meta ? meta.getAttribute('content') : '';
    }

    function clearErrors(form) {
        form.querySelectorAll('[data-error]').forEach(function (el) {
            el.textContent = '';
            el.classList.add('hidden');
        });
        const general = form.querySelector('[data-quick-create-error]');
        if (general) {
            general.textContent = '';
            general.classList.add('hidden');
        }
    }

    function showErrors(form, errors, message) {
        clearErrors(form);
        if (errors && typeof errors === 'object') {
            Object.keys(errors).forEach(function (field) {
                const el = form.querySelector('[data-error="' + field + '"]');
                if (el && errors[field] && errors[field][0]) {
                    el.textContent = errors[field][0];
                    el.classList.remove('hidden');
                }
            });
        }
        if (message) {
            const general = form.querySelector('[data-quick-create-error]');
            if (general) {
                general.textContent = message;
                general.classList.remove('hidden');
            }
        }
    }

    function appendAndSelect(selectName, id, name) {
        const select = document.querySelector('select[name="' + selectName + '"]');
        if (!select) {
            return;
        }
        const value = String(id);
        let option = Array.from(select.options).find(function (opt) {
            return opt.value === value;
        });
        if (!option) {
            option = new Option(name, value, true, true);
            select.appendChild(option);
        } else {
            option.text = name;
            option.selected = true;
        }
        if (window.jQuery && window.jQuery.fn && window.jQuery.fn.select2) {
            window.jQuery(select).val(value).trigger('change');
        } else {
            select.dispatchEvent(new Event('change', { bubbles: true }));
        }
    }

    document.querySelectorAll('[data-quick-create-form]').forEach(function (form) {
        form.addEventListener('submit', async function (event) {
            event.preventDefault();
            clearErrors(form);

            const submitBtn = form.querySelector('button[type="submit"]');
            if (submitBtn) {
                submitBtn.disabled = true;
            }

            try {
                const response = await fetch(form.action, {
                    method: 'POST',
                    headers: {
                        'Accept': 'application/json',
                        'X-Requested-With': 'XMLHttpRequest',
                        'X-CSRF-TOKEN': csrfToken(),
                    },
                    body: new FormData(form),
                    credentials: 'same-origin',
                });

                const data = await response.json().catch(function () {
                    return {};
                });

                if (response.status === 422) {
                    showErrors(form, data.errors || {}, data.message || 'Please fix the highlighted errors.');
                    return;
                }

                if (!response.ok) {
                    showErrors(form, null, data.message || 'Could not create the record.');
                    return;
                }

                appendAndSelect(form.getAttribute('data-select'), data.id, data.name);
                form.reset();
                // Restore shift time defaults after reset
                if (form.getAttribute('data-select') === 'shift_id') {
                    const clockIn = form.querySelector('[name="clock_in_time"]');
                    const clockOut = form.querySelector('[name="clock_out_time"]');
                    if (clockIn) clockIn.value = '09:00';
                    if (clockOut) clockOut.value = '18:00';
                }
                window.dispatchEvent(new CustomEvent('close-modal'));
            } catch (err) {
                showErrors(form, null, 'Network error. Please try again.');
            } finally {
                if (submitBtn) {
                    submitBtn.disabled = false;
                }
            }
        });
    });
})();
</script>
<?php /**PATH /var/www/html/kiyohr/v2_version/resources/views/employees/partials/quick-create-modals.blade.php ENDPATH**/ ?>