<?php $__env->startSection('titulo','Historial horómetro'); ?>
<?php $__env->startSection('contenido'); ?>
<div class="d-flex flex-wrap justify-content-between align-items-center mb-3">
  <h4><i class="fa fa-clock-rotate-left"></i> <?php echo e($equipo->codigo); ?> — <?php echo e($equipo->nombre); ?></h4>
  <a href="<?php echo e(route('horometro.index')); ?>" class="btn btn-outline-secondary"><i class="fa fa-arrow-left"></i> Volver</a>
</div>
<div class="row mb-3">
  <div class="col-md-3"><div class="card"><div class="card-body p-2">
    <small class="text-muted">Horómetro actual</small><br>
    <span class="fs-4 fw-bold"><?php echo e(number_format((float)$equipo->horometro_actual, 2)); ?> h</span>
  </div></div></div>
  <?php $__currentLoopData = ['ultimo_pm_360'=>'PM 01 (360h)','ultimo_pm_720'=>'PM 02 (720h)','ultimo_pm_4320'=>'PM 03 (4320h)','ultimo_pm_8640'=>'PM 04 (8640h)']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $col => $lbl): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php $base = (float)($equipo->$col ?? 0); $umbral = (int) explode('_', $col)[2]; $pendiente = $base > 0 ? (((float)$equipo->horometro_actual) - $base) : 0; $rest = $umbral - $pendiente; $color = $rest <= 0 ? 'danger' : ($rest < $umbral * 0.1 ? 'warning' : 'success'); ?>
    <?php if($base > 0): ?>
      <div class="col-md-2"><div class="card border-<?php echo e($color); ?>"><div class="card-body p-2">
        <small class="text-muted"><?php echo e($lbl); ?></small><br>
        <small>Última: <?php echo e(number_format($base,0)); ?> h</small><br>
        <span class="badge text-bg-<?php echo e($color); ?>"><?php echo e($rest > 0 ? 'Faltan '.number_format($rest,0).' h' : 'Excedido '.number_format(-$rest,0).' h'); ?></span>
      </div></div></div>
    <?php endif; ?>
  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<div class="card"><div class="table-responsive"><table class="table table-hover mb-0">
<thead><tr><th>Fecha lectura</th><th class="text-end">Horómetro</th><th class="text-end">Δ (h)</th><th>Observaciones</th><th>Registró</th></tr></thead>
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $lecturas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr>
  <td><?php echo e($l->fecha_lectura->format('d/m/Y H:i')); ?></td>
  <td class="text-end"><?php echo e(number_format((float)$l->horometro, 2)); ?></td>
  <td class="text-end"><?php echo e(number_format((float)$l->delta, 2)); ?></td>
  <td><?php echo e($l->observaciones); ?></td>
  <td><small><?php echo e(optional($l->usuario)->usuario); ?></small></td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?> <tr><td colspan="5" class="text-muted text-center py-4">Sin lecturas registradas</td></tr> <?php endif; ?>
</tbody></table></div></div>
<div class="mt-2"><?php echo e($lecturas->links()); ?></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\mto\resources\views/horometro/historial.blade.php ENDPATH**/ ?>