<?php if (isset($con)) { ?>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel"><i class='glyphicon glyphicon-edit'></i> Editar usuario</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" method="post" id="editar_usuario" name="editar_usuario">
          <div id="resultados_ajax2"></div>
          <input type="hidden" id="mod_id" name="mod_id">

          <div class="form-group">
            <label for="estado2" class="col-sm-3 control-label">Tienda</label>
            <div class="col-sm-8">
                <select class="form-control" id="estado2" name="estado2" required>
                    <option value="">-- Selecciona Tienda --</option>
                    <option value="">SEDE</option>
                    <?php 
                    $sql_t = mysqli_query($con, "SELECT id_tienda, nombre FROM tiendas ORDER BY nombre ASC");
                    while ($rw = mysqli_fetch_array($sql_t)) {
                        echo '<option value="'.$rw['id_tienda'].'">'.$rw['nombre'].'</option>';
                    }
                    ?>
                </select>
            </div>
          </div>

          <div class="form-group">
            <label for="firstname2" class="col-sm-3 control-label">Nombres</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="firstname2" name="firstname2" required>
            </div>
          </div>

          <div class="form-group">
            <label for="lastname2" class="col-sm-3 control-label">Apellidos</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="lastname2" name="lastname2" required>
            </div>
          </div>

          <div class="form-group">
            <label for="rol2" class="col-sm-3 control-label">Rol</label>
            <div class="col-sm-8">
                <select name="rol2" id="rol2" class="form-control" required>
                    <?php 
                    $sql_r = mysqli_query($con, "SELECT rol FROM roles");
                    while($row_r = mysqli_fetch_array($sql_r)) {
                        echo '<option value="'.$row_r['rol'].'">'.$row_r['rol'].'</option>';
                    }
                    ?>
                </select>
            </div>
          </div>

          <div class="form-group">
            <label for="user_name2" class="col-sm-3 control-label">Usuario</label>
            <div class="col-sm-8">
              <input type="text" class="form-control" id="user_name2" name="user_name2" required pattern="[a-zA-Z0-9]{2,64}">
            </div>
          </div>

          <div class="form-group">
            <label for="user_email2" class="col-sm-3 control-label">Email</label>
            <div class="col-sm-8">
              <input type="email" class="form-control" id="user_email2" name="user_email2" required>
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
        <button type="submit" class="btn btn-primary" id="actualizar_datos">Actualizar datos</button>
      </div>
      </form>
    </div>
  </div>
</div>
<?php } ?>