<?php $__env->startSection('titulo','Paros de planta'); ?>
<?php $__env->startSection('contenido'); ?>
<div class="d-flex flex-wrap justify-content-between align-items-center mb-3">
  <h4><i class="fa fa-circle-stop"></i> Paros de planta</h4>
  <div>
    <a href="<?php echo e(route('programacion.index')); ?>" class="btn btn-outline-secondary"><i class="fa fa-calendar-days"></i> Programación</a>
    <a href="<?php echo e(route('paros.create')); ?>" class="btn btn-primario"><i class="fa fa-plus"></i> Nuevo paro</a>
  </div>
</div>

<?php if($activos->count()): ?>
<div class="card mb-3 border-danger">
  <div class="card-header bg-danger text-white"><strong><i class="fa fa-triangle-exclamation"></i> Paros ACTIVOS (<?php echo e($activos->count()); ?>)</strong></div>
  <div class="table-responsive"><table class="table table-sm mb-0 align-middle">
    <thead><tr>
      <th>#</th><th>Desde</th><th>Días</th><th>Motivo</th><th>Descripción</th><th>Por</th><th class="text-end" style="width:300px;">Acciones</th>
    </tr></thead><tbody>
    <?php $__currentLoopData = $activos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
      <tr>
        <td><?php echo e($p->id); ?></td>
        <td><?php echo e($p->fecha_inicio->format('d/m/Y')); ?></td>
        <td><span class="badge text-bg-warning"><?php echo e($p->fecha_inicio->diffInDays(now())); ?> d</span></td>
        <td><strong><?php echo e($p->motivo); ?></strong></td>
        <td><small><?php echo e($p->descripcion); ?></small></td>
        <td><small><?php echo e(optional($p->usuario)->usuario); ?></small></td>
        <td class="text-end">
          <form method="POST" action="<?php echo e(route('paros.cerrar', $p)); ?>" class="d-flex gap-1 justify-content-end" onsubmit="return confirm('¿Cerrar y desplazar OT?');">
            <?php echo csrf_field(); ?>
            <input type="date" name="fecha_fin" value="<?php echo e(now()->toDateString()); ?>" class="form-control form-control-sm" style="max-width:140px;" required>
            <button class="btn btn-sm btn-primario"><i class="fa fa-check"></i> Cerrar</button>
            <a href="<?php echo e(route('paros.edit', $p)); ?>" class="btn btn-sm btn-outline-primary"><i class="fa fa-pen"></i></a>
            <form method="POST" action="<?php echo e(route('paros.destroy', $p)); ?>" class="d-inline" onsubmit="return confirm('¿Eliminar?');">
              <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-outline-danger"><i class="fa fa-trash"></i></button>
            </form>
          </form>
        </td>
      </tr>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody></table></div>
</div>
<?php endif; ?>

<div class="card">
  <div class="card-header"><strong><i class="fa fa-clock-rotate-left"></i> Histórico</strong></div>
  <div class="table-responsive"><table class="table table-sm mb-0">
    <thead><tr><th>#</th><th>Desde</th><th>Hasta</th><th>Días</th><th>Motivo</th><th>OT afectadas</th><th>Por</th></tr></thead>
    <tbody>
    <?php $__empty_1 = true; $__currentLoopData = $historial; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
      <tr>
        <td><?php echo e($p->id); ?></td>
        <td><?php echo e($p->fecha_inicio->format('d/m/Y')); ?></td>
        <td><?php echo e($p->fecha_fin?->format('d/m/Y')); ?></td>
        <td><strong><?php echo e($p->duracion_dias); ?></strong></td>
        <td><?php echo e($p->motivo); ?></td>
        <td><?php echo e($p->ots_afectadas); ?></td>
        <td><small><?php echo e(optional($p->usuario)->usuario); ?></small></td>
      </tr>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
      <tr><td colspan="7" class="text-muted text-center py-4">Sin paros registrados</td></tr>
    <?php endif; ?>
    </tbody>
  </table></div>
</div>
<div class="mt-2"><?php echo e($historial->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/paros/index.blade.php ENDPATH**/ ?>