<?php $__env->startSection('titulo','Usuario'); ?>
<?php $__env->startSection('contenido'); ?>
<?php $editando = (bool) $registro->id; ?>
<h4><i class="fa fa-user-plus"></i> <?php echo e($editando?'Editar':'Nuevo'); ?> usuario</h4>
<form method="POST" action="<?php echo e($editando ? route('usuarios.update',$registro) : route('usuarios.store')); ?>" class="card p-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">Usuario *</label>
      <input name="usuario" value="<?php echo e(old('usuario',$registro->usuario)); ?>" class="form-control" required></div>
    <div class="col-md-3"><label class="form-label small">DNI</label>
      <input name="dni" value="<?php echo e(old('dni',$registro->dni)); ?>" class="form-control"></div>
    <div class="col-md-3"><label class="form-label small">Teléfono</label>
      <input name="telefono" value="<?php echo e(old('telefono',$registro->telefono)); ?>" 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 class="col-md-6"><label class="form-label small">Nombres *</label>
      <input name="nombres" value="<?php echo e(old('nombres',$registro->nombres)); ?>" class="form-control" required></div>
    <div class="col-md-6"><label class="form-label small">Apellidos</label>
      <input name="apellidos" value="<?php echo e(old('apellidos',$registro->apellidos)); ?>" class="form-control"></div>
    <div class="col-md-6"><label class="form-label small">Cargo</label>
      <input name="cargo" value="<?php echo e(old('cargo',$registro->cargo)); ?>" class="form-control"></div>
    <div class="col-md-6"><label class="form-label small">Email (opcional)</label>
      <input type="email" name="email" value="<?php echo e(old('email',$registro->email)); ?>" class="form-control"></div>
    <div class="col-md-6"><label class="form-label small">Contraseña <?php echo e($editando?'(dejar vacío para no cambiar)':'*'); ?></label>
      <input type="password" name="password" class="form-control" <?php echo e($editando?'':'required'); ?> minlength="6" autocomplete="new-password"></div>
    <div class="col-md-6"><label class="form-label small">Clave de firma <?php echo e($editando?'(opcional)':'(opcional)'); ?></label>
      <input type="password" name="clave_firma" class="form-control" minlength="3" autocomplete="new-password"
             placeholder="Clave personal para firmar órdenes"></div>
    <div class="col-md-6"><label class="form-label small">Rol</label>
      <select name="rol" class="form-select">
        <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <option value="<?php echo e($r->name); ?>" <?php if(old('rol',$registro->roles->first()?->name)===$r->name): echo 'selected'; endif; ?>><?php echo e($r->name); ?></option>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </select></div>
  </div>
  <div class="mt-3 text-end">
    <a href="<?php echo e(route('usuarios.index')); ?>" class="btn btn-outline-secondary">Cancelar</a>
    <button class="btn btn-primario"><i class="fa fa-save"></i> Guardar</button>
  </div>
</form>
<?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/usuarios/form.blade.php ENDPATH**/ ?>