<?php $__env->startSection('titulo','Repuesto'); ?>
<?php $__env->startSection('contenido'); ?>
<?php $editando = (bool) $registro->id; ?>
<h4><i class="fa fa-box"></i> <?php echo e($editando?'Editar':'Nuevo'); ?> repuesto</h4>
<form method="POST" action="<?php echo e($editando ? route('repuestos.update',$registro) : route('repuestos.store')); ?>" class="card p-3 mb-3">
  <?php echo csrf_field(); ?> <?php if($editando): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>
  <div class="row g-3">
    <div class="col-md-3"><label class="form-label small">Código *</label>
      <input name="codigo" value="<?php echo e(old('codigo',$registro->codigo)); ?>" class="form-control" required></div>
    <div class="col-md-6"><label class="form-label small">Nombre *</label>
      <input name="nombre" value="<?php echo e(old('nombre',$registro->nombre)); ?>" class="form-control" required></div>
    <div class="col-md-3"><label class="form-label small">Unidad</label>
      <select name="unidad_id" class="form-select"><option value="">—</option>
        <?php $__currentLoopData = $unidades; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($u->id); ?>" <?php if(old('unidad_id',$registro->unidad_id)==$u->id): echo 'selected'; endif; ?>><?php echo e($u->nombre); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </select></div>
    <div class="col-md-12"><label class="form-label small">Descripción</label>
      <textarea name="descripcion" class="form-control" rows="2"><?php echo e(old('descripcion',$registro->descripcion)); ?></textarea></div>
    <div class="col-md-3"><label class="form-label small">Stock</label>
      <input type="number" step="0.001" name="stock" value="<?php echo e(old('stock',$registro->stock)); ?>" class="form-control"></div>
    <div class="col-md-3"><label class="form-label small">Stock mínimo</label>
      <input type="number" step="0.001" name="stock_minimo" value="<?php echo e(old('stock_minimo',$registro->stock_minimo)); ?>" class="form-control"></div>
    <div class="col-md-3"><label class="form-label small">Costo unitario</label>
      <input type="number" step="0.01" name="costo_unitario" value="<?php echo e(old('costo_unitario',$registro->costo_unitario)); ?>" class="form-control"></div>
    <div class="col-md-3"><label class="form-label small">Ubicación</label>
      <input name="ubicacion" value="<?php echo e(old('ubicacion',$registro->ubicacion)); ?>" class="form-control"></div>
    <div class="col-md-3 d-flex align-items-end">
      <div class="form-check form-switch">
        <input type="hidden" name="activo" value="0">
        <input type="checkbox" name="activo" value="1" class="form-check-input" <?php echo e(old('activo',$registro->activo??1)?'checked':''); ?>>
        <label class="form-check-label">Activo</label>
      </div>
    </div>
  </div>
  <div class="mt-3 text-end">
    <a href="<?php echo e(route('repuestos.index')); ?>" class="btn btn-outline-secondary">Cancelar</a>
    <button class="btn btn-primario"><i class="fa fa-save"></i> Guardar</button>
  </div>
</form>

<?php if($editando): ?>
<form method="POST" action="<?php echo e(route('repuestos.entrada',$registro)); ?>" class="card p-3"><?php echo csrf_field(); ?>
  <h6><i class="fa fa-truck-arrow-right"></i> Registrar entrada de stock</h6>
  <div class="row g-2">
    <div class="col-md-3"><input type="number" step="0.001" name="cantidad" class="form-control" placeholder="Cantidad" required></div>
    <div class="col-md-3"><input type="number" step="0.01" name="costo_unitario" class="form-control" placeholder="Costo unitario" required></div>
    <div class="col-md-4"><input name="motivo" class="form-control" placeholder="Motivo / OC"></div>
    <div class="col-md-2"><button class="btn btn-acento w-100"><i class="fa fa-plus"></i> Entrada</button></div>
  </div>
</form>
<?php endif; ?>
<?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/repuestos/form.blade.php ENDPATH**/ ?>