<?php $__env->startSection('actions'); ?>
    <div class="btn-group">
        <a href="<?php echo e(URL::action('PolicyController@getCreate',['type'=>$type])); ?>" class="btn btn-dark">
            Add a <?php echo e(strtoupper($type)); ?> Policy
        </a>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title'); ?>
    <i class="icon icon-policies"></i> <?php echo e(\Illuminate\Support\Str::upper($type)); ?> Policies Control
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="table-responsive">
        <table class="table hr-table table-hover">
            <thead>
            <tr>
                <th> #</th>
                <th> Name</th>
                <th> Scope</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            <?php $index = 1; ?>
            <?php foreach($policies as $item): ?>
                <tr>
                    <td>
                        <?php echo e($index++); ?>

                    </td>
                    <td> <?php echo e($item->name); ?></td>
                    <td>
                    <span class="label label-default" data-toggle="tooltip"
                          title="Applies to: <?php echo e(ucfirst($item->applicants_type).($item->applicants_type != 'all'?'s':'')); ?>"><?php echo e(strtoupper(substr($item->applicants_type,0,1))); ?></span>
                        <?php if($type == 'leave'): ?>
                            <?php if($item->deductible): ?>
                                <span data-toggle="tooltip" title="Deducts from the annual leave balance"
                                      class="label label-success">D</span>
                            <?php else: ?>
                                <span data-toggle="tooltip"
                                      title="Deducts from it's own leave balance, allowed days: <?php echo e($item->days); ?>"
                                      class="label label-success">ND: <?php echo e($item->days); ?></span>
                            <?php endif; ?>
                            <span class="label label-warning" data-toggle="tooltip"
                                  title="Deduction is based on <?php echo e($item->days_type); ?> days"><?php echo e($item->days_type=="calender"?"C":"W"); ?></span>
                            <?php if($item->hides_balance): ?>
                                <span data-toggle="tooltip"
                                      title="Leave Balance is hidden in user profiles"
                                      class="label label-danger">HB</span>
                            <?php endif; ?>
                        <?php else: ?>
                            <span class="label label-warning" data-toggle="tooltip"
                                  title="Service Level Agreement: <?php echo e($item->sla); ?>">S: <?php echo e($item->sla); ?></span>
                        <?php endif; ?>
                        <span class="label label-info" data-toggle="tooltip"
                              title="Available after: <?php echo e($item->available_after); ?> months from joining date">M: <?php echo e($item->available_after); ?></span>
                    </td>
                    <td>
                        <div class="hr-actions-cell">
                            <?php if($item->active): ?>
                                <a class="btn btn-dark"
                                   href="<?php echo e(URL::action('PolicyController@getUpdatePolicy',['id'=>$item->id,'type'=>$type])); ?>">
                                    Edit
                                </a>
                            <?php endif; ?>
                            <a class="btn btn-<?php echo e(($item->active)?'red':'green'); ?>"
                               data-target="#change_active_status<?php echo e($item->id); ?>"
                               data-toggle="modal">
                                <?php echo e(($item->active)?"Deactivate":"Activate"); ?>

                            </a>
                        </div>

                    </td>
                    <div class="modal fade" id="change_active_status<?php echo e($item->id); ?>">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-body">
                                    <form id="deactivate_policy_<?php echo e($item->id); ?>" method="post"
                                          action="<?php echo e(URL::action('PolicyController@postActivatePolicy')); ?>">
                                        <?php echo csrf_field(); ?>

                                        <input type="hidden" name="policy_id" value="<?php echo e($item->id); ?>">
                                        <input type="hidden" name="type"
                                               value="<?php echo e(($item->active)?'deactivate':'activate'); ?>">
                                        <input type="hidden" name="request_type" value="<?php echo e($type); ?>">
                                        <div class="help-block">
                                            Are you sure you want to <?php echo e(($item->active)?"deactivate":"activate"); ?> the
                                            policy "<?php echo e($item->name); ?>"
                                        </div>
                                        <div class="form-actions">
                                            <button type="submit" class="btn btn-<?php echo e(($item->active)?"red":"green"); ?>">
                                                <?php echo e(($item->active)?"Deactivate":"Activate"); ?>

                                            </button>
                                            <button type="button" data-dismiss="modal" class="btn btn-dark">
                                                Back
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>