git-svn-id: https://svn.coded.pt/svn/SIPRP@1459 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
Diogo Neves 15 years ago
parent 62965fc541
commit 4f719699e6

@ -7653,12 +7653,12 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
//stDataNascimento.setText(a.getData_nascimento()); //stDataNascimento.setText(a.getData_nascimento());
try try
{ {
java.util.Date ddate = new java.util.Date(a.getData_nascimento().getTime()); java.util.Date ddate = new java.util.Date( a.getData_nascimento().getTime() );
stDataNascimento.setText(utils.Utils.dateToYYYYMMDD(ddate)); stDataNascimento.setText( utils.Utils.dateToYYYYMMDD( ddate ) );
} }
catch(Exception ex) catch(Exception ex)
{ {
ErrorLogger.logException( ex ); // ErrorLogger.logException( ex );
} }
stBI.setText(a.getBilhete_identidade()); stBI.setText(a.getBilhete_identidade());
stMorada.setText(a.getMorada()); stMorada.setText(a.getMorada());
@ -7691,15 +7691,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
stCodPostal.setText(cod_postal); stCodPostal.setText(cod_postal);
stContactoTelefonico.setText(a.getContacto_telefonico()); stContactoTelefonico.setText(a.getContacto_telefonico());
//stDataAdmissao1.setText(a.getData_admissao()); //stDataAdmissao1.setText(a.getData_admissao());
try try
{ {
java.util.Date ddate = new java.util.Date(a.getData_admissao().getTime()); java.util.Date ddate = new java.util.Date( a.getData_admissao().getTime() );
stDataAdmissao1.setText(utils.Utils.dateToYYYYMMDD(ddate)); stDataAdmissao1.setText( utils.Utils.dateToYYYYMMDD( ddate ) );
} }
catch(Exception ex) catch(Exception ex)
{ {
ErrorLogger.logException( ex ); // ErrorLogger.logException( ex );
} }
stFuncao1.setText(a.getFuncao()); stFuncao1.setText(a.getFuncao());
String turno_str = ""; String turno_str = "";
if(a.getTurno() != null) if(a.getTurno() != null)
@ -7744,7 +7746,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
if(a.getData_acidente() != null) if(a.getData_acidente() != null)
{ {
java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime()); java.util.Date ddate = new java.util.Date(a.getData_acidente().getTime());
calDataOcorrencia.setValue(ddate); calDataOcorrencia.setValue( ddate );
} }
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();

@ -669,180 +669,174 @@ public class FichaUtilizador extends AbstractPageBean {
* values submitted with this request. Instead, they represent the * values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p> * property values that were saved for this view when it was rendered.</p>
*/ */
public void init() { public void init()
// Perform initializations inherited from our superclass {
super.init(); // Perform initializations inherited from our superclass
// Perform application initialization that must complete super.init();
// *before* managed components are initialized // Perform application initialization that must complete
// TODO - add your own initialiation code here // *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// *Note* - this logic should NOT be modified // Initialize automatically managed components
try { // *Note* - this logic should NOT be modified
_init(); try {
} catch (Exception e) { _init();
log("FichaUtilizador Initialization Failure", e); } catch (Exception e) {
throw e instanceof FacesException ? (FacesException) e: new FacesException(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);
}
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&ccedil;&atilde;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&ccedil;&atilde;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 * <p>Callback method that is called after the component tree has been

@ -1148,11 +1148,11 @@ public class UtilizadorFields extends AbstractPageBean {
} }
else else
{ {
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
try try
{ {
Utilizador u = udp.getUtilizador(login); UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
if(u.getLogin().equals(login)) Utilizador u = udp.getUtilizador( login );
if ( u != null && login.equals( u.getLogin() ) )
{ {
getSessionBean1().setMsg("O utilizador " + login + " já existe!"); getSessionBean1().setMsg("O utilizador " + login + " já existe!");
return false; return false;

@ -1631,17 +1631,21 @@ public class AnalisesDataProvider {
public String getEstabelecimentoNome(Integer estabelecimento_id) throws Exception public String getEstabelecimentoNome( Integer estabelecimento_id ) throws Exception
{ {
Dblocal dblocal = new Dblocal(); Dblocal dblocal = new Dblocal();
dblocal.connect(); dblocal.connect();
Statement stlocal = dblocal.createStatement(); Statement stlocal = dblocal.createStatement();
String sql ="SELECT nome FROM estabelecimentos WHERE id = " + estabelecimento_id; String sql = "SELECT nome FROM estabelecimentos WHERE id = " + estabelecimento_id;
ResultSet rslocal = stlocal.executeQuery(sql); ResultSet rslocal = stlocal.executeQuery( sql );
rslocal.first();
String nome = rslocal.getString("nome"); String nome = "";
dblocal.close(); if ( rslocal.first() )
return Utils.unicodeToHTML(nome); {
nome = rslocal.getString( "nome" );
dblocal.close();
}
return Utils.unicodeToHTML( nome );
} }
public String getMedicoNome(Integer medico_id) throws Exception public String getMedicoNome(Integer medico_id) throws Exception

@ -117,7 +117,7 @@ public class UtilizadoresDataProvider {
public Utilizador getUtilizador(String login) throws Exception public Utilizador getUtilizador(String login) throws Exception
{ {
Utilizador u = new Utilizador(); Utilizador u = new Utilizador();
Statement st = createStatement(); Statement st = createStatement();
String sql = "SELECT * FROM utilizadores WHERE LOWER(login) = '" + login.toLowerCase() + "' AND apagado = 'n'"; String sql = "SELECT * FROM utilizadores WHERE LOWER(login) = '" + login.toLowerCase() + "' AND apagado = 'n'";
ResultSet rs = st.executeQuery(sql); ResultSet rs = st.executeQuery(sql);

Loading…
Cancel
Save