<?php

class Personalizar extends Conexion {

    /* =============================================
      VER DATOS PERSONALIZAR POR USUARIO
      ============================================= */

    public function Personalizar_por_Usuario($userId) {
        $conectar = parent::conectar();
        parent::set_names();
        $sql = "
                SELECT * FROM personalizar                
                WHERE per_usuariodbk = ?
                ";
        $sql = $conectar->prepare($sql);
        $sql->bindValue(1, $userId);
        $sql->execute();
        return $resultado = $sql->fetchAll();
    }

    /* =============================================
      ACTUALIZAR DATOS PERSONALIZAR
      ============================================= */

    public function mdlActualizar($datos) {
        $conectar = parent::conectar();
        parent::set_names();
        $sql = "UPDATE personalizar SET per_menu = ?, per_pie = ?,per_accesos = ?, per_icono= ?, per_texto = ? WHERE per_usuariodbk = ?";
        $sql = $conectar->prepare($sql);
        $sql->bindValue(1, $datos["per_menu"]);
        $sql->bindValue(2, $datos["per_pie"]);
        $sql->bindValue(3, $datos["per_accesos"]);
        $sql->bindValue(4, $datos["per_icono"]);
        $sql->bindValue(5, $datos["per_texto"]);
        $sql->bindValue(6, $datos["per_usuariodbk"]);
        $sql->execute();
        return $resultado = $sql->fetchAll();
    }
    
/* =============================================
      INSERTAR DATOS PERSONALIZAR
      ============================================= */

    public function mdlInsertar($datos) {
        $conectar = parent::conectar();
        parent::set_names();
        $sql = "INSERT INTO personalizar (per_usuariodbk,per_menu,per_pie,per_accesos,per_icono,per_texto)
                VALUES (?,?,?,?,?,?)";
        $sql = $conectar->prepare($sql);
        $sql->bindValue(1, $datos["per_usuariodbk"]);
        $sql->bindValue(2, $datos["per_menu"]);
        $sql->bindValue(3, $datos["per_pie"]);
        $sql->bindValue(4, $datos["per_accesos"]);
        $sql->bindValue(5, $datos["per_icono"]);
        $sql->bindValue(6, $datos["per_texto"]);
        $sql->execute();
        return $resultado = $sql->fetchAll();
    }    
    /* =============================================
      ELIMINAR REGISTRO
      ============================================= */

    public function Eliminar($userId) {
        $conectar = parent::conectar();
        parent::set_names();
        $sql = "
                DELETE FROM personalizar                
                WHERE per_usuariodbk = ?
                ";
        $sql = $conectar->prepare($sql);
        $sql->bindValue(1, $userId);
        $sql->execute();
        return $resultado = $sql->fetchAll();
    }
}

?>
