<div class="table-responsive">
    <style>
        .progress { margin-bottom: 0; min-width: 75px;}
    </style>
    <table class="table table-list">
        <thead>
        <tr>
            <?php echo tableHeaderSort($sorting, 'device.name', trans('validation.attributes.device_id')); ?>

            <?php echo tableHeaderSort($sorting, 'name', trans('validation.attributes.name')); ?>

            <?php echo tableHeaderSort($sorting, 'odometer_percentage', trans('global.distance')); ?>

            <?php echo tableHeaderSort($sorting, 'odometer_left', trans('global.distance') . ' ' . trans('front.left')); ?>

            <?php echo tableHeaderSort($sorting, 'engine_hours_percentage', trans('validation.attributes.engine_hours')); ?>

            <?php echo tableHeaderSort($sorting, 'engine_hours_left', trans('validation.attributes.engine_hours') . ' ' . trans('front.left')); ?>

            <?php echo tableHeaderSort($sorting, 'days_percentage', trans('global.days')); ?>

            <?php echo tableHeaderSort($sorting, 'days_left', trans('global.days') . ' ' . trans('front.left')); ?>

            <th></th>
        </tr>
        </thead>
        <tbody>
        <?php if(count($services)): ?>
                <?php foreach($services as $service): ?>
                    <?php
                    $bar_class = $service->percentage < 20 ? 'progress-bar-danger' : ( $service->percentage < 50 ? 'progress-bar-warning' : 'progress-bar-success');
                    ?>
                    <tr>
                        <td><?php echo e($service->device->name); ?></td>
                        <td><?php echo e($service->name); ?></td>
                        <?php if($service->expiration_by == 'odometer'): ?>
                            <td>
                                <div class="progress">
                                    <div
                                            class="progress-bar progress-bar-striped <?php echo e($bar_class); ?>"
                                            role="progressbar"
                                            style="width: <?php echo e($service->percentage); ?>%"
                                            aria-valuenow="<?php echo e($service->percentage); ?>"
                                            aria-valuemin="0"
                                            aria-valuemax="100">
                                        <?php echo e($service->percentage); ?>%
                                    </div>
                                </div>
                            </td>
                            <td style="<?php echo e($service->isExpired() ? 'color:red' : ''); ?>"><?php echo e($service->left_formated()); ?></td>
                        <?php else: ?>
                            <td>-</td>
                            <td>-</td>
                        <?php endif; ?>
                        <?php if($service->expiration_by == 'engine_hours'): ?>
                            <td>
                                <div class="progress">
                                    <div
                                            class="progress-bar progress-bar-striped <?php echo e($bar_class); ?>"
                                            role="progressbar" style="width: <?php echo e($service->percentage); ?>%"
                                            aria-valuenow="<?php echo e($service->percentage); ?>"
                                            aria-valuemin="0"
                                            aria-valuemax="100">
                                        <?php echo e($service->percentage); ?>%
                                    </div>
                                </div>
                            </td>
                            <td style="<?php echo e($service->isExpired() ? 'color:red' : ''); ?>"><?php echo e($service->left_formated()); ?></td>
                        <?php else: ?>
                            <td>-</td>
                            <td>-</td>
                        <?php endif; ?>
                        <?php if($service->expiration_by == 'days'): ?>
                            <td>
                                <div class="progress">
                                    <div
                                            class="progress-bar progress-bar-striped <?php echo e($bar_class); ?>"
                                            role="progressbar"
                                            style="width: <?php echo e($service->percentage); ?>%"
                                            aria-valuenow="<?php echo e($service->percentage); ?>"
                                            aria-valuemin="0"
                                            aria-valuemax="100">
                                        <?php echo e($service->percentage); ?>%
                                    </div>
                                </div>
                            </td>
                            <td style="<?php echo e($service->isExpired() ? 'color:red' : ''); ?>"><?php echo e($service->left_formated()); ?></td>
                        <?php else: ?>
                            <td>-</td>
                            <td>-</td>
                        <?php endif; ?>
                        <td class="actions">
                            <a href="javascript:" class="btn icon edit" data-url="<?php echo route('services.edit', $service->id); ?>" data-modal="services_edit"></a>
                            <a href="javascript:" class="btn icon delete" data-url="<?php echo route('services.do_destroy', $service->id); ?>" data-modal="services_destroy"></a>
                            <?php if(Auth::user()->can('view', new \Tobuli\Entities\Checklist)): ?>
                            <i class="btn icon ico-arrow-down"
                               type="button"
                               title="<?php echo e(trans('front.checklists')); ?>"
                               data-url="<?php echo e(route('checklists.get_checklists', $service->id)); ?>"
                               data-toggle="collapse"
                               data-target="#service-checklists-<?php echo e($service->id); ?>">
                            </i>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <tr class="row-table-inner" style="text-align: center;">
                        <td colspan="9" id="service-checklists-<?php echo e($service->id); ?>" aria-expanded="false" class="collapse"></td>
                    </tr>
                <?php endforeach; ?>
        <?php else: ?>
            <tr>
                <td colspan="8"><?php echo trans('front.no_services'); ?></td>
            </tr>
        <?php endif; ?>
        </tbody>
    </table>
</div>
