<?php $__env->startSection('content'); ?>
<div class="container-fluid py-4">
    <div class="row">
        <div class="col-12">
            <div class="card p-4">
            <h4 class="fw-bold text-primary mb-4">Apply for Leave</h4>
            
            <form action="<?php echo e(route('leave-requests.store')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <div class="mb-4">
                    <label class="form-label">Leave Type</label>
                    <select name="leave_type" class="form-select" required>
                        <option value="Sick Leave">Sick Leave</option>
                        <option value="Casual Leave">Casual Leave</option>
                        <option value="Annual Leave">Annual Leave</option>
                        <option value="Other">Other</option>
                    </select>
                </div>

                <div class="row mb-4">
                    <div class="col-sm-6">
                        <label class="form-label">Start Date</label>
                        <input type="date" name="start_date" class="form-control" required>
                    </div>
                    <div class="col-sm-6">
                        <label class="form-label">End Date</label>
                        <input type="date" name="end_date" class="form-control" required>
                    </div>
                </div>

                <div class="mb-4">
                    <label class="form-label">Reason</label>
                    <textarea name="reason" class="form-control" rows="4" placeholder="Briefly describe the reason for your leave..." required></textarea>
                </div>

                <div class="row mb-4">
                    <div class="col-sm-6">
                        <div class="form-check">
                            <input type="checkbox" name="is_half_day" class="form-check-input" id="is_half_day_check" value="1">
                            <label class="form-check-label ms-2" for="is_half_day_check">Apply for Half Day?</label>
                        </div>
                    </div>
                    <div class="col-sm-6" id="half_day_session_container" style="display: none;">
                        <label class="form-label">Session</label>
                        <select name="half_day_session" class="form-select">
                            <option value="first_half">First Half</option>
                            <option value="second_half">Second Half</option>
                        </select>
                    </div>
                </div>

                <div class="mb-4 d-flex align-items-center">
                    <div class="form-check">
                        <input type="checkbox" name="is_lop" class="form-check-input" id="is_lop_check" value="1">
                        <label class="form-check-label ms-2" for="is_lop_check">Is Loss of Pay?</label>
                    </div>
                </div>

                <div class="d-flex justify-content-end gap-2">
                    <a href="<?php echo e(route('leave-requests.index')); ?>" class="btn btn-secondary">Cancel</a>
                    <button type="submit" class="btn btn-primary">Apply for Leave</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
$(document).ready(function() {
    $('#is_half_day_check').change(function() {
        if ($(this).is(':checked')) {
            $('#half_day_session_container').show();
            // When half day is checked, end date should be same as start date
            $('input[name="end_date"]').val($('input[name="start_date"]').val());
            $('input[name="end_date"]').prop('readonly', true);
        } else {
            $('#half_day_session_container').hide();
            $('input[name="end_date"]').prop('readonly', false);
        }
    });

    $('input[name="start_date"]').change(function() {
        if ($('#is_half_day_check').is(':checked')) {
            $('input[name="end_date"]').val($(this).val());
        }
    });
});
</script>
<?php $__env->stopPush(); ?>


<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\hrms\resources\views/leave_requests/create.blade.php ENDPATH**/ ?>