<?php echo e(Form::open(['route' => 'goals.notify.send', 'method' => 'post'])); ?>

<div class="modal-body">
    <div class="row">
        
        <?php if($userIsAdmin): ?>
        <div class="col-md-12 mb-3">
            <div class="form-group">
                <?php echo e(Form::label('type', __('Select Recipients'), ['class' => 'form-label'])); ?>

                <select name="type" id="recipient-type" class="form-control" required>
                    <option value="all_employees"><?php echo e(__('All Employees')); ?></option>
                    <option value="departments"><?php echo e(__('By Department')); ?></option>
                </select>
            </div>
        </div>
        <div class="col-md-12" id="department-select-container" style="display:none;">
            <div class="form-group">
                <?php echo e(Form::label('departments[]', __('Departments'), ['class' => 'form-label'])); ?>

                <select name="departments[]" id="department-select" class="form-control select2" multiple="multiple">
                    <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($id); ?>"><?php echo e($name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
        <?php endif; ?>

        
        <?php if($isManager): ?>
        <div class="col-md-12 mb-3">
            <div class="form-group">
                <?php echo e(Form::label('', __('Your Department: ') . $department->name, ['class' => 'form-label font-bold'])); ?>

                <?php echo e(Form::hidden('type', 'departments')); ?>

                <?php echo e(Form::hidden('departments[]', $department->id)); ?>

            </div>
        </div>
        <div class="col-md-12">
            <div class="form-group">
                <?php echo e(Form::label('employees[]', __('Employees in Your Department'), ['class' => 'form-label'])); ?>

                <select name="employees[]" id="employee-select" class="form-control select2" multiple="multiple">
                    <?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($employee->id); ?>" selected><?php echo e($employee->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
        <?php endif; ?>
    </div>
</div>

<div class="modal-footer">
    <input type="button" value="<?php echo e(__('Cancel')); ?>" class="btn btn-light" data-bs-dismiss="modal">
    <button type="submit" class="btn btn-primary"><?php echo e(__('Send Notifications')); ?></button>
</div>
<?php echo e(Form::close()); ?>


<script>
    // Toggle department dropdown based on user's selection
    $(document).ready(function() {
        $('#recipient-type').change(function() {
            console.log('Recipient type changed to:', $(this).val());
            if ($(this).val() === 'departments') {
                $('#department-select-container').show();
                $('#department-select').attr('required', true);
            } else {
                $('#department-select-container').hide();
                $('#department-select').removeAttr('required');
            }
        });
    });
</script><?php /**PATH /var/www/payraty/hris/resources/views/simple-goals/notify_modal.blade.php ENDPATH**/ ?>