/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cosmodas.validaciones;

import com.cosmodas.FacadeCosmos.WcUsuariosFacadeLocal;
import com.cosmodas.EntCosmos.WcUsuarios;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author obper
 */
@ManagedBean
@SessionScoped
public class validaPermisos implements Serializable {
private String per;
private WcUsuarios user;

@EJB
WcUsuariosFacadeLocal dao;

    public WcUsuarios getUser() {
        return user;
    }

    public void setUser(WcUsuarios user) {
        this.user = user;
    }

    
    public  boolean ValidaPermiso(String id){
        boolean rs = true;
    switch (id) {
        case "001":
            rs = false;
            break;
        case "002":
            rs = true;
            break;
    }
        
        return rs;
        }
    
       public  boolean validaPermisoFuncion(String id){
        boolean rs = true;
           if (true) {
               rs = false;
           }
        return rs;
        }
       
        public  boolean validaPermisoAdmin(String id){
        boolean rs = true;
           if (true) {
               rs = false;
           }
        return rs;
        }
   

    public String getPer() {
        return per;
    }

    public void setPer(String per) {
        System.out.println("valor de permisos "+per);
        this.per = per;
    }
   
   public boolean validaPermiso(String  per){
    HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
    this.user =  dao.ObtenerUsuario(session.getAttribute("usuarioCodigo").toString());
       
        boolean perm = true;
   
   
       
       
   return perm;
   }
   
    public validaPermisos() {
    }
    
}
