<?php $__env->startSection('page-title', __('Manage Goals')); ?>

<?php $__env->startSection('breadcrumb'); ?>
<li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>"><?php echo e(__('Home')); ?></a></li>
<li class="breadcrumb-item"><?php echo e(__('Goals')); ?></li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('action-button'); ?>
<a href="#" data-url="<?php echo e(route('simple-goals.create')); ?>" data-ajax-popup="true"
    data-title="<?php echo e(__('Create Goal')); ?>" class="btn btn-sm btn-primary">
    <i class="ti ti-plus"></i><?php echo e(__('Create Goal')); ?>

</a>
<a href="#" data-url="<?php echo e(route('goals.notify.create')); ?>" data-ajax-popup="true" data-title="<?php echo e(__('Send Goal Reminders')); ?>" class="btn btn-sm btn-primary">
    <i class="ti ti-mail"></i> <?php echo e(__('Notify Employees')); ?>

</a>
<?php $__env->stopSection(); ?>



<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body table-border-style">
                <table class="table datatable">
                    <thead>
                        <tr>
                            <th><?php echo e(__('Goal')); ?></th>
                            <th><?php echo e(__('Status')); ?></th>
                            <th><?php echo e(__('Approval Status')); ?></th> 
                            <th><?php echo e(__('Due')); ?></th>
                            <th width="120px"><?php echo e(__('Action')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $goals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $goal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($goal->title); ?></td>
                            <td>
                                <?php
                                $statusColors = [
                                'not_started' => 'secondary',
                                'in_progress' => 'secondary',
                                'on_hold' => 'warning',
                                'completed' => 'success',
                                'cancelled' => 'danger',
                                'archived' => 'dark',
                                ];

                                $color = $statusColors[$goal->status] ?? 'secondary';
                                ?>

                                <span class="badge bg-<?php echo e($color); ?> px-3 py-2 rounded-pill text-white">
                                    <?php echo e(__(ucwords(str_replace('_', ' ', $goal->status)))); ?>

                                </span>
                            </td>
                            <td> 
                                <?php if($goal->is_active): ?>
                                    <span class="badge bg-success px-3 py-2 rounded-pill text-white"><?php echo e(__('Active')); ?></span>
                                <?php else: ?>
                                    <span class="badge bg-warning text-dark px-3 py-2 rounded-pill"><?php echo e(__('Pending Approval')); ?></span>
                                <?php endif; ?>
                            </td>
                            <td><?php echo e(optional($goal->due_date)->format('Y-m-d') ?? '—'); ?></td>
                            <td class="Action">
                                <div class="dt-buttons">
                                    <span class="float-start">
                                        
                                        <div class="action-btn me-2">
                                            <a href="#" class="btn btn-sm bg-info"
                                                data-url="<?php echo e(route('simple-goals.edit', $goal)); ?>"
                                                data-ajax-popup="true"
                                                data-title="<?php echo e(__('Edit Goal')); ?>">
                                                <i class="ti ti-pencil text-white"></i>
                                            </a>
                                        </div>

                                        
                                        <?php if(!$goal->is_active && ($canApproveGoals ?? Auth::user()->can('manage goals'))): ?>
                                            <div class="action-btn me-2">
                                                <?php echo Form::open([
                                                    'method' => 'POST',
                                                    'route' => ['simple-goals.activate', $goal->id],
                                                    'id' => 'activate-form-' . $goal->id,
                                                    'onsubmit' => "return confirm('".__('Are you sure you want to activate this goal?')."');" // Simple JS confirmation
                                                ]); ?>

                                                <a href="#" class="btn btn-sm bg-success align-items-center"
                                                    data-bs-toggle="tooltip" title="<?php echo e(__('Activate Goal')); ?>"
                                                    onclick="document.getElementById('activate-form-<?php echo e($goal->id); ?>').submit();">
                                                    <i class="ti ti-check text-white"></i>
                                                </a>
                                                <?php echo Form::close(); ?>

                                            </div>
                                        <?php endif; ?>

                                        
                                        <div class="action-btn">
                                            <?php echo Form::open([
                                                'method' => 'DELETE',
                                                'route' => ['simple-goals.destroy', $goal->id],
                                                'id' => 'delete-form-' . $goal->id,
                                            ]); ?>

                                            <a href="#"
                                                class="btn btn-sm bg-danger align-items-center bs-pass-para"
                                                data-bs-toggle="tooltip"
                                                title="<?php echo e(__('Delete')); ?>"
                                                data-confirm="<?php echo e(__('Are You Sure?') . '|' . __('This action cannot be undone. Do you want to continue?')); ?>"
                                                data-text="<?php echo e(__('This action cannot be undone. Do you want to continue?')); ?>"
                                                data-confirm-yes="delete-form-<?php echo e($goal->id); ?>">
                                                <i class="ti ti-trash text-white"></i>
                                            </a>
                                            <?php echo Form::close(); ?>

                                        </div>
                                    </span>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>

                <div class="mt-3"><?php echo e($goals->links()); ?></div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/payraty/hris/resources/views/simple-goals/index.blade.php ENDPATH**/ ?>