|
|
|
|
@ -669,180 +669,174 @@ public class FichaUtilizador extends AbstractPageBean {
|
|
|
|
|
* values submitted with this request. Instead, they represent the
|
|
|
|
|
* property values that were saved for this view when it was rendered.</p>
|
|
|
|
|
*/
|
|
|
|
|
public void init() {
|
|
|
|
|
// Perform initializations inherited from our superclass
|
|
|
|
|
super.init();
|
|
|
|
|
// Perform application initialization that must complete
|
|
|
|
|
// *before* managed components are initialized
|
|
|
|
|
// TODO - add your own initialiation code here
|
|
|
|
|
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
|
|
|
|
|
// Initialize automatically managed components
|
|
|
|
|
// *Note* - this logic should NOT be modified
|
|
|
|
|
try {
|
|
|
|
|
_init();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log("FichaUtilizador Initialization Failure", e);
|
|
|
|
|
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// </editor-fold>
|
|
|
|
|
// Perform application initialization that must complete
|
|
|
|
|
// *after* managed components are initialized
|
|
|
|
|
// TODO - add your own initialization code here
|
|
|
|
|
if (!getSessionBean1().isLoggedIn()) {
|
|
|
|
|
try {
|
|
|
|
|
getExternalContext().redirect("Login.jsp");
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
|
// . . . handle exception . . .
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
FacesContext fc = getFacesContext();
|
|
|
|
|
System.out.println("REQUEST PARAMETERS : " + JSFUtils.requestHasParameters(fc));
|
|
|
|
|
isFromPlanos = false;
|
|
|
|
|
if(JSFUtils.requestHasParameters(fc))
|
|
|
|
|
{
|
|
|
|
|
isFromPlanos = true;
|
|
|
|
|
String user_id = JSFUtils.getRequestParameter(fc, "user");
|
|
|
|
|
String mode = JSFUtils.getRequestParameter(fc, "mode");
|
|
|
|
|
if(mode != null)
|
|
|
|
|
{
|
|
|
|
|
if(mode.matches("edit"))
|
|
|
|
|
{
|
|
|
|
|
System.out.println("MODE PARAMETER : " + mode);
|
|
|
|
|
getSessionBean1().setModoEdicaoUtilizador("edit");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utilizador u = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Integer userId = new Integer(Integer.parseInt(user_id));
|
|
|
|
|
System.out.println("USER ID FROM PLANOS : " + user_id);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
|
|
//udp.checkConnection();
|
|
|
|
|
u = udp.getUtilizador(userId);
|
|
|
|
|
getSessionBean1().setCurrentUser(u);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex1)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH
|
|
|
|
|
|| getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP )
|
|
|
|
|
{
|
|
|
|
|
lnkGerirUtilizadores.setDisabled(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lnkGerirUtilizadores.setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
// Perform initializations inherited from our superclass
|
|
|
|
|
super.init();
|
|
|
|
|
// Perform application initialization that must complete
|
|
|
|
|
// *before* managed components are initialized
|
|
|
|
|
// TODO - add your own initialiation code here
|
|
|
|
|
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
|
|
|
|
|
// Initialize automatically managed components
|
|
|
|
|
// *Note* - this logic should NOT be modified
|
|
|
|
|
try {
|
|
|
|
|
_init();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log("FichaUtilizador Initialization Failure", e);
|
|
|
|
|
throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
|
|
|
|
|
String referer = request.getRequestURI();
|
|
|
|
|
String pageFrom = Utils.getPageFrom(referer);
|
|
|
|
|
if(isFromPlanos)
|
|
|
|
|
{
|
|
|
|
|
isPostData = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(pageFrom.matches("FichaUtilizador.jsp"))
|
|
|
|
|
{
|
|
|
|
|
isPostData = true;
|
|
|
|
|
System.out.println("IS POSTDATA : " + isPostData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!isPostData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lblUser.setText( getSessionBean1().getCurrentUser().getLogin() );
|
|
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
|
|
|
|
|
|
|
AnalisesDataProvider adp = new AnalisesDataProvider();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Integer permissao = udp.getPermissionCode( getSessionBean1().getCurrentUser().getId() );
|
|
|
|
|
getSessionBean1().setTiposOptions(adp.getTiposList(permissao));
|
|
|
|
|
drpTipo.setSelected(new Integer(0));
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
getSessionBean1().setEstabelecimentosOptions(adp.getEstabelecimentosList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false) ));
|
|
|
|
|
System.out.println("ESTABELECIMENTOS OPTIONS : " + getSessionBean1().getEstabelecimentosOptions().length);
|
|
|
|
|
drpEstabelecimentos.setSelected(new Integer(-1));
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else //postData
|
|
|
|
|
{
|
|
|
|
|
String del_user = (String)getExternalContext().getRequestParameterMap().get("del_user");
|
|
|
|
|
if(del_user != null)
|
|
|
|
|
{
|
|
|
|
|
if(del_user.matches("yes"))
|
|
|
|
|
{
|
|
|
|
|
hidConfDelUser.setValue("");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
deleteUser();
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
getSessionBean1().setMsg("Erro na eliminação do utilizador!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//force a page reload
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// getExternalContext().redirect("FichaUtilizador.jsp");
|
|
|
|
|
// System.out.println("REDIRECT");
|
|
|
|
|
// }
|
|
|
|
|
// catch(Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorLogger.logException( ex );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(del_user.matches("no"))
|
|
|
|
|
{
|
|
|
|
|
hidConfDelUser.setValue("");
|
|
|
|
|
showUser();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// </editor-fold>
|
|
|
|
|
// Perform application initialization that must complete
|
|
|
|
|
// *after* managed components are initialized
|
|
|
|
|
// TODO - add your own initialization code here
|
|
|
|
|
if ( ! getSessionBean1().isLoggedIn() )
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
getExternalContext().redirect("Login.jsp");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
// . . . handle exception . . .
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FacesContext fc = getFacesContext();
|
|
|
|
|
System.out.println( "REQUEST PARAMETERS : " + JSFUtils.requestHasParameters( fc ) );
|
|
|
|
|
isFromPlanos = false;
|
|
|
|
|
|
|
|
|
|
if ( JSFUtils.requestHasParameters( fc ) )
|
|
|
|
|
{
|
|
|
|
|
isFromPlanos = true;
|
|
|
|
|
String user_id = JSFUtils.getRequestParameter(fc, "user");
|
|
|
|
|
String mode = JSFUtils.getRequestParameter(fc, "mode");
|
|
|
|
|
if (mode != null)
|
|
|
|
|
{
|
|
|
|
|
if (mode.matches("edit"))
|
|
|
|
|
{
|
|
|
|
|
System.out.println("MODE PARAMETER : " + mode);
|
|
|
|
|
getSessionBean1().setModoEdicaoUtilizador("edit");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utilizador u = null;
|
|
|
|
|
if (user_id != null )
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Integer userId = new Integer( Integer.parseInt( user_id ) );
|
|
|
|
|
System.out.println( "USER ID FROM PLANOS : " + user_id );
|
|
|
|
|
|
|
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
|
|
//udp.checkConnection();
|
|
|
|
|
u = udp.getUtilizador( userId );
|
|
|
|
|
getSessionBean1().setCurrentUser( u );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH
|
|
|
|
|
|| getSessionBean1().getCurrentUser().getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP )
|
|
|
|
|
{
|
|
|
|
|
lnkGerirUtilizadores.setDisabled( false );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lnkGerirUtilizadores.setDisabled( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpServletRequest request = (HttpServletRequest) getExternalContext().getRequest();
|
|
|
|
|
String referer = request.getRequestURI();
|
|
|
|
|
String pageFrom = Utils.getPageFrom(referer);
|
|
|
|
|
if ( isFromPlanos )
|
|
|
|
|
{
|
|
|
|
|
isPostData = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( pageFrom.matches( "FichaUtilizador.jsp" ) )
|
|
|
|
|
{
|
|
|
|
|
isPostData = true;
|
|
|
|
|
System.out.println( "IS POSTDATA : " + isPostData );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! isPostData )
|
|
|
|
|
{
|
|
|
|
|
lblUser.setText(getSessionBean1().getCurrentUser().getLogin());
|
|
|
|
|
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
|
|
|
|
|
|
|
|
|
|
AnalisesDataProvider adp = new AnalisesDataProvider();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Integer permissao = udp.getPermissionCode( getSessionBean1().getCurrentUser().getId() );
|
|
|
|
|
getSessionBean1().setTiposOptions( adp.getTiposList( permissao ) );
|
|
|
|
|
drpTipo.setSelected( new Integer( 0 ) );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
getSessionBean1().setEstabelecimentosOptions(adp.getEstabelecimentosList(getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(false)));
|
|
|
|
|
System.out.println("ESTABELECIMENTOS OPTIONS : " + getSessionBean1().getEstabelecimentosOptions().length);
|
|
|
|
|
drpEstabelecimentos.setSelected(new Integer(-1));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else //postData
|
|
|
|
|
{
|
|
|
|
|
String del_user = (String) getExternalContext().getRequestParameterMap().get("del_user");
|
|
|
|
|
if (del_user != null)
|
|
|
|
|
{
|
|
|
|
|
if (del_user.matches("yes"))
|
|
|
|
|
{
|
|
|
|
|
hidConfDelUser.setValue("");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
deleteUser();
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
getSessionBean1().setMsg("Erro na eliminação do utilizador!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//force a page reload
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// getExternalContext().redirect("FichaUtilizador.jsp");
|
|
|
|
|
// System.out.println("REDIRECT");
|
|
|
|
|
// }
|
|
|
|
|
// catch(Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorLogger.logException( ex );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if ( del_user.matches( "no" ) )
|
|
|
|
|
{
|
|
|
|
|
hidConfDelUser.setValue("");
|
|
|
|
|
showUser();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>Callback method that is called after the component tree has been
|
|
|
|
|
|