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

<?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(__('Appraisals')); ?></li>
<?php $__env->stopSection(); ?>

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

</a>
<a href="#" data-url="<?php echo e(route('appraisal_reviews.notify.create')); ?>" data-ajax-popup="true" data-title="<?php echo e(__('Send Review 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(__('Employee')); ?></th>
                                <th><?php echo e(__('Goals')); ?></th>
                                <th><?php echo e(__('Rating Type')); ?></th>
                                <th><?php echo e(__('Status')); ?></th>
                                <th><?php echo e(__('Final Rating')); ?></th>
                                <th><?php echo e(__('Process')); ?></th>
                                <th width="120px"><?php echo e(__('Action')); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $appraisals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $appraisal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                    <tr>
                                                                                        <td><?php echo e(optional($appraisal->employee)->name); ?></td>
                                                                                        <td>
                                                                                            <?php $__currentLoopData = $appraisal->goals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $goal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                                            <span class="badge bg-light text-dark mb-1"><?php echo e($goal->title); ?></span><br>
                                                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                                        </td>
                                                                                        <td><?php echo e(optional($appraisal->ratingType)->name); ?></td>
                                                                                        <td>
                                                                                            <?php
                                $statusColor = $appraisal->status === 'closed' ? 'success' : 'warning';
                                                                                            ?>
                                                                                            <span class="badge bg-<?php echo e($statusColor); ?> px-3 py-2 rounded-pill text-white">
                                                                                                <?php echo e(__(ucwords(str_replace('_', ' ', $appraisal->status)))); ?>

                                                                                            </span>
                                                                                        </td>
                                                                                        <td>
                                                                                            <?php if($appraisal->final_score === 'ungraded'): ?>
                                                                                                <span class="text-info"><?php echo e(__('Ungraded')); ?></span>
                                                                                            <?php elseif($appraisal->final_score !== null): ?>
                                                                                                <?php echo e($appraisal->final_score); ?>

                                                                                            <?php else: ?>
                                                                                                <span class="text-muted"><?php echo e(__('N/A')); ?></span>
                                                                                            <?php endif; ?>
                                                                                        </td>
                                                                                        <td>
                                                                                        <?php if($appraisal->status === 'closed' && !$isEmployee): ?>
                                                                                            <?php if($appraisal->appraisalFinalScore): ?>
                                                                                                <span class="badge bg-secondary">
                                                                                                    <?php echo e(ucwords(str_replace('_', ' ', $appraisal->appraisalFinalScore->action_type))); ?>

                                                                                                </span>
                                                                                            <?php else: ?>
                                                                                                                                    
                                                                                                                                    <a href="#" class="btn btn-sm btn-success"
                                                                                                                                        data-url="<?php echo e(route('appraisal_reviews.process_final_score', $appraisal->id)); ?>"
                                                                                                                                        data-ajax-popup="true" data-title="<?php echo e(__('Performance Outcomes')); ?>">
                                                                                                                                        <span class="me-1"><?php echo e(__('Process')); ?></span>
                                                                                                                                        <i class="ti ti-chart-line"></i>
                                                                                                                                    </a>
                                                                                            <?php endif; ?>
                                                                                        <?php endif; ?>
                                                                                    </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('appraisal_reviews.edit', $appraisal)); ?>"
                                                                                                            data-ajax-popup="true"
                                                                                                            data-title="<?php echo e(__('Edit Appraisal')); ?>">
                                                                                                            <i class="ti ti-pencil text-white"></i>
                                                                                                        </a>
                                                                                                    </div>

                                                                                                    <?php if($appraisal->status === 'on_going' && $userIsAdmin): ?>
                                                                                                                                                                        
                                                                                                                                                                        <div class="action-btn me-2">
                                                                                                                                                                            <?php echo Form::open([
                                                                                                            'method' => 'POST',
                                                                                                            'route' => ['appraisal_reviews.close', $appraisal->id],
                                                                                                            'id' => 'close-form-' . $appraisal->id,
                                                                                                        ]); ?>

                                                                                                                                                                            <a href="#"
                                                                                                                                                                                class="btn btn-sm bg-danger align-items-center bs-pass-para"
                                                                                                                                                                                data-bs-toggle="tooltip"
                                                                                                                                                                                title="<?php echo e(__('Close Appraisal')); ?>"
                                                                                                                                                                                data-confirm="<?php echo e(__('Are You Sure?') . '|' . __('Closing this appraisal will finalize it and prevent further ratings/comments. Do you want to continue?')); ?>"
                                                                                                                                                                                data-text="<?php echo e(__('Closing this appraisal will finalize it and prevent further ratings/comments. Do you want to continue?')); ?>"
                                                                                                                                                                                data-confirm-yes="close-form-<?php echo e($appraisal->id); ?>">
                                                                                                                                                                                <i class="ti ti-lock text-white"></i>
                                                                                                                                                                            </a>
                                                                                                                                                                            <?php echo Form::close(); ?>

                                                                                                                                                                        </div>
                                                                                                    <?php endif; ?>
                                                                                                    <?php if(!$isEmployee): ?>
                                                                                                                                                                        <div class="action-btn">
                                                                                                                                                                            <?php echo Form::open([
                                                                                                            'method' => 'DELETE',
                                                                                                            'route' => ['appraisal_reviews.destroy', $appraisal->id],
                                                                                                            'id' => 'delete-form-' . $appraisal->id,
                                                                                                        ]); ?>

                                                                                                                                                                            <a href="#"
                                                                                                                                                                                class="btn btn-sm bg-danger align-items-center bs-pass-para"
                                                                                                                                                                                data-bs-toggle="tooltip"
                                                                                                                                                                                title="<?php echo e(__('Delete')); ?>">
                                                                                                                                                                                <i class="ti ti-trash text-white"></i>
                                                                                                                                                                            </a>
                                                                                                                                                                            <?php echo Form::close(); ?>

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

                                                                        <div class="mt-3"><?php echo e($appraisals->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/appraisal_reviews/index.blade.php ENDPATH**/ ?>