
<?php $__env->startSection('cssDashboard'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('text'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="card shadow mb-4">
    <div class="card-header py-3">
        <span class="m-0 font-weight-bold text-primary title-table" id="titleForm"><?php echo e($action == "new" ? 'Registrar nuevo usuario' : 'Modificar usuario'); ?></span>
      </div>
    <div class="card-body">
        <form method="POST" action="<?php echo e(Request::url()); ?>" class="needs-validation" enctype="multipart/form-data" novalidate>
            <?php echo csrf_field(); ?>
            <input type="hidden" name="action" id="action" value="<?php echo e($action); ?>"/>
            <?php if(isset($user)): ?>
              <input type="hidden" name="id" id="id" value="<?php echo e($user['id']); ?>">
            <?php else: ?>
              <input type="hidden" name="id" id="id" value="0">
            <?php endif; ?>

            <div class="form-row">
              <div class="form-group col-md-6">
                <label for="owner">Nombre del dueño:</label>
                <?php if(isset($user)): ?>
                  <input type="text" class="form-control" id="owner" name="owner" placeholder="Ingrese el nombre del dueño del usuario" required value="<?php echo e($user['owner']); ?>">
                <?php else: ?>
                  <input type="text" class="form-control" id="owner" name="owner" placeholder="Ingrese el nombre del dueño del usuario" required>
                <?php endif; ?>
                <div class="invalid-feedback">
                    Favor de ingresar el nombre del dueño del usuario
                </div>
              </div>
              <div class="form-group col-md-6">
                <label for="email">Correo electrónico</label>
                <?php if(isset($user)): ?>
                  <input type="email" class="form-control" id="email" name="email" placeholder="Ingrese el correo electrónico" required value="<?php echo e($user['email']); ?>">
                <?php else: ?>
                  <input type="email" class="form-control" id="email" name="email" placeholder="Ingrese el correo electrónico" required>
                <?php endif; ?>  
                <div class="invalid-feedback">
                    Favor de ingresar el correo electrónico del usuario
                </div>
              </div>
            </div>
            <div class="form-row">
              <div class="form-group col-md-6">
                <label for="name">Nombre de usuario:</label>
                <?php if(isset($user)): ?>
                  <input type="text" class="form-control" id="name" name="name" placeholder="Ingrese el nombre del usuario" value="<?php echo e($user['name']); ?>" required>
                <?php else: ?>
                  <input type="text" class="form-control" id="name" name="name" placeholder="Ingrese el nombre del usuario" required>
                <?php endif; ?>  
                <div class="invalid-feedback">
                    Favor de ingresar el nombre del usuario
                </div>
              </div>
              <div class="form-group col-md-6">
                <label for="password">Contraseña</label>
                <?php if(isset($user)): ?>
              <input type="password" class="form-control" id="password" name="password" placeholder="Ingrese la contraseña" required value="<?php echo e($user['password']); ?>">
                <?php else: ?>
                <input type="password" class="form-control" id="password" name="password" placeholder="Ingrese la contraseña" required>
                <?php endif; ?> 
                
                <div class="invalid-feedback">
                    Favor de ingresar la contraseña del usuario
                </div>
              </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-3">
                    <label for="roles_id">Rol</label>
                      <select id="roles_id" name="roles_id" class="form-control" required>
                      <option value="">selecciona...</option>
                      <?php if(isset($roles)): ?>
                        <?php if(isset($user)): ?>
                          <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($element['id']); ?>" <?php echo e(( $element['id'] == $user["roles_id"]) ? 'selected' : ''); ?>><?php echo e($element['name']); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php else: ?>
                          <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($element['id']); ?>"><?php echo e($element['name']); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                      <?php endif; ?>
                    </select>
                  </div>
                  <div class="form-group col-md-6">
                    <label for="departments_institutes_id">Departamento</label>
                    <select id="departments_institutes_id" name="departments_institutes_id" class="form-control" required>
                      <option value="">selecciona...</option>
                      <?php if(isset($departments)): ?>
                        <?php if(isset($user)): ?>
                          <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($element['id_of_institute_deparment']); ?>" <?php echo e(( $element['id_of_institute_deparment'] == $user["departments_institutes_id"]) ? 'selected' : ''); ?>><?php echo e($element['name_with_institute']); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php else: ?>
                          <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($element['id_of_institute_deparment']); ?>"><?php echo e($element['name_with_institute']); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                      <?php endif; ?>
                    </select>
                  </div>
                  <div class="form-group col-md-3">
                    <label for="active">¿Activo?</label>
                    
                    <div class="custom-control custom-switch">
                      <?php if(isset($user)): ?>
                      <input type="checkbox" class="custom-control-input" name="active" id="active" <?php echo e(($user["active"] == true) ? 'checked' : ''); ?>>
                      <?php else: ?>
                      <input type="checkbox" class="custom-control-input" name="active" id="active">
                      <?php endif; ?>  
                      <label class="custom-control-label" for="active">Deslice a la derecha para activar usuario</label>
                    </div>                  
                  </div>
            </div>
            <div class="form-row">
              <div class="form-group col-md-6 files-div">
                <?php if(isset($user['signature'])): ?>
                <span class="file">
                  <input type="file" accept="image/*" name="signature" id="signature" class="form-control">
                </span>
                <label for="signature">
                    <span><?php echo e($user['signature']); ?></span>
                </label>                
                    <?php else: ?>
                    <span class="file">
                      <input type="file" accept="image/*" name="signature" id="signature" class="form-control" required>
                      <div class="invalid-feedback">
                        Favor de ingresar la imagen de la firma del usuario
                    </div>
                    </span>
                    <label for="signature">
                        <span>Subir la firma del usuario</span>
                    </label>
                    <?php endif; ?>  
              </div>
              <div class="form-group col-md-6 files-div">
                <?php if(isset($user)): ?>
                  <img id="imagenPrevisualizacion" src="<?php echo e($user['signatureSRC']); ?>" class="file-img">
                <?php else: ?>
                  <img id="imagenPrevisualizacion" class="file-img">
                <?php endif; ?>
              </div>
            </div>

            <a href="usuarios"  class="btn btn-primary float-right">Cancelar</a>
            <button type="submit" class="btn btn-primary float-right" style="margin-right: 3px;">Guardar</button>
          </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('jsDashboard'); ?>
  <script src="../assets/js/mainForm.js"></script>
  <script src="../assets/js/UserForm.js"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('base.base', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\ADIF2021\resources\views/catalogs/usersForm.blade.php ENDPATH**/ ?>