saved with xajax and php

0

I'm doing a save with xajax and php where I validate the required fields and then I send the complete form to the controller this is the function in the view

function validarFrmUsuario(){
    if(validarCampo('txtEmpleado',1) === true
      && validarCampo('txtUsuario',1) === true
      && validarCampo('txtClave',1) === true
      && validarCampo('lstPerfil',1,'lista') === true
      ){
        xajax_ctUsuario.guardarUsuario(xajax.getFormValues('frmUsuario'));
    alert($r)
    } else {
        validarCampo('txtEmpleado',1);
        validarCampo('txtUsuario',1);
        validarCampo('txtClave',1);
        validarCampo('lstPerfil',1,'lista');
        alert("Los campos señalados en rojo son requeridos, o no cumplen con el formato establecido");
    }
}

If everything is fine I send it to the controller, here the controller function

function guardarUsuario($frmUsuario){
    print_r($frmUsuario);

    $r = new xajaxResponse();

    if (!verificarSession($r)) { return $r; }
    if ($frmUsuario['hddIdUsuario'] > 0) {
        if (!validarAcceso('acceso_editar_usuarios')){ return $r->alert("Acceso denegado"); }
    } else {
        if (!validarAcceso('acceso_ingresar_usuarios')){ return $r->alert("Acceso denegado"); }
    }        
    if($frmUsuario['txtUsuario'] == "" || $frmUsuario['txtClave'] == "" || $frmUsuario['lstPerfil'] == ""
        || $frmUsuario['hddIdEmpleado'] == ""){
        return $r->alert('No puedes dejar ningún campo vacío');
    }

    $cambioClave = $frmUsuario['hddCambioClave'];
    if(isset($frmUsuario['cbxCambioClave'])){// 0 = no la cambió (forzar a cambiar en inicio de sesion), 1 = ya la cambió
        $cambioClave = 0;
    }

    $respuesta = $frmUsuario['txtRespuesta'];
    if(isset($frmUsuario['cbxCambioPreguntaSecreta'])){// NULL = sino tiene respuesta forzar a seleccionar pregunta y respuesta en inicio de sesion
        $respuesta = NULL;
    }

    $idUsuario = $frmUsuario['hddIdUsuario'];
    $idEmpleado = $frmUsuario['hddIdEmpleado'];
    $usuario = $frmUsuario['txtUsuario'];
    $clave = $frmUsuario['txtClave'];
    $idPerfil = $frmUsuario['lstPerfil'];

    try 
    {
        if($this->mdUsuario->verificarUsuario($usuario, $idUsuario)){
            return $r->alert('El usuario ya existe');
        }

        if ($idUsuario > 0) {
            $this->mdUsuario->actualizarUsuario($idUsuario, $usuario, $clave, $idPerfil, $respuesta, $idEmpleado, $cambioClave);
        } else {
            $idUsuario = $this->mdUsuario->guardarUsuario($usuario, $clave, $idPerfil, $respuesta, $idEmpleado, 0);
        }
    } 

    catch (Exception $exc) 
    {
        return $r->alert(mensajeError($exc));
    }

    $r->alert('Usuario guardado correctamente');
    $r->script('byId("btnCerrar").click();');
    $r->script('buscar();');

    return $r;
}

but when I give it to save it is processing the data and never stores anything, I have the form in a bootstrap modal and I do not know how I could print what I am sending from this

    
asked by Angel Gutierrez 25.06.2018 в 19:59
source

0 answers