14/01/2009

git-svn-id: https://svn.coded.pt/svn/SIPRP@909 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
L Luís = 17 years ago
parent 6126b9ee53
commit 8c6e627e8e

@ -2,15 +2,15 @@
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
<Node id="RecuperarPassword.jsp" x="400" y="150" zoom="true"/>
<Node id="GestaoUtilizadores.jsp" x="400" y="450" zoom="true"/>
<Node id="RecuperarPassword.jsp" x="400" y="150" zoom="true"/>
<Node id="FormDirGerRh.jsp" x="150" y="750" zoom="true"/>
<Node id="FormGestor.jsp" x="400" y="300" zoom="true"/>
<Node id="Acesso.jsp" x="400" y="750" zoom="false"/>
<Node id="Erro.jsp" x="650" y="450" zoom="true"/>
<Node id="Acesso.jsp" x="400" y="750" zoom="false"/>
<Node id="FormRH.jsp" x="400" y="600" zoom="true"/>
<Node id="AnaliseAcidenteTrabalho.jsp" x="150" y="450" zoom="true"/>
<Node id="FormSeguranca.jsp" x="1150" y="150" zoom="true"/>
<Node id="AnaliseAcidenteTrabalho.jsp" x="150" y="450" zoom="true"/>
<Node id="NovoUtilizador.jsp" x="900" y="150" zoom="true"/>
<Node id="FormDirSiprp.jsp" x="1400" y="150" zoom="true"/>
<Node id="FichaUtilizador.jsp" x="150" y="300" zoom="true"/>
@ -20,8 +20,8 @@
<Node id="UtilizadorFields.jsp" x="1150" y="300" zoom="true"/>
<Node id="Dummy.jsp" x="150" y="600" zoom="true"/>
<Node id="LoadImage.jsp" x="650" y="600" zoom="true"/>
<Node id="Login.jsp" x="650" y="300" zoom="true"/>
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="650" y="150" zoom="true"/>
<Node id="Login.jsp" x="650" y="300" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>

@ -7,10 +7,13 @@
package analiseacidentestrabalho;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.DropDown;
import com.sun.rave.web.ui.component.StaticText;
import db.AnalisesDataProvider;
import db.UtilizadoresDataProvider;
import global.Global;
import javax.faces.FacesException;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import utils.JSFUtils;
import utils.Utils;
@ -43,6 +46,24 @@ public class Acesso extends AbstractPageBean {
public void setStWelcome(StaticText st) {
this.stWelcome = st;
}
private DropDown drpEstabelecimentos = new DropDown();
public DropDown getDrpEstabelecimentos() {
return drpEstabelecimentos;
}
public void setDrpEstabelecimentos(DropDown dd) {
this.drpEstabelecimentos = dd;
}
private HtmlPanelGrid gridEstabelecimento = new HtmlPanelGrid();
public HtmlPanelGrid getGridEstabelecimento() {
return gridEstabelecimento;
}
public void setGridEstabelecimento(HtmlPanelGrid hpg) {
this.gridEstabelecimento = hpg;
}
// </editor-fold>
@ -118,6 +139,16 @@ public class Acesso extends AbstractPageBean {
//System.out.println("NOME UNICODE : " + nomeUnicode);
String nomeHtml = Utils.unicodeToHTML( u.getNome() );
stWelcome.setText("Bem vindo(a) " + nomeHtml);
if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
{
initializeEstabelecimentos();
}
else
{
gridEstabelecimento.setRendered(false);
}
}
/**
@ -200,9 +231,29 @@ public class Acesso extends AbstractPageBean {
switch(permissao.intValue())
{
case 1: //seguranca
return "form_seguranca";
return "form_seguranca";
case 2: //rh
return "form_rh";
case 3: //hs
return "form_hs";
return "form_hs";
case 6: //gestor
Integer estabelecimento = null;
if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
{
estabelecimento = (Integer) drpEstabelecimentos.getSelected();
// if(estabelecimento.intValue() == -1)
// {
// getSessionBean1().setMsg("Falta estabelecimento!");
// return null;
// }
// else
// {
// u.setEstabelecimento(estabelecimento_outro);
u.setEstabelecimento_gestor(estabelecimento);
}
return "form_gestor";
case 7: //dir ger rh
return "form_dir_ger_rh";
case 8: //dir_siprp
return "form_dir_siprp";
default:
@ -223,8 +274,25 @@ public class Acesso extends AbstractPageBean {
Utilizador u = getSessionBean1().getCurrentUser();
// String curUser = "?user=" + u.getId().toString();
FacesContext fc = getFacesContext().getCurrentInstance();
Global.redirectToPlanos(fc, u);
FacesContext fc = getFacesContext().getCurrentInstance();
Integer estabelecimento = null;
if(u.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
{
estabelecimento = (Integer) drpEstabelecimentos.getSelected();
// if(estabelecimento.intValue() == -1)
// {
// getSessionBean1().setMsg("Falta estabelecimento!");
// return null;
// }
// else
// {
// u.setEstabelecimento(estabelecimento_outro);
u.setEstabelecimento_gestor(estabelecimento);
}
Global.redirectToPlanos(fc, u);
// FacesContext fc = getFacesContext().getCurrentInstance();
// Utilizador u = getSessionBean1().getCurrentUser();
@ -240,6 +308,24 @@ public class Acesso extends AbstractPageBean {
return null;
}
private void initializeEstabelecimentos()
{
AnalisesDataProvider adp = new AnalisesDataProvider();
try
{
com.sun.rave.web.ui.model.Option[] listGestorOptions = adp.getEstabelecimentosGestorList( getSessionBean1().getCurrentUser().getEmpresa_id(), new Boolean(true));
//listGestorOptions[0].setLabel("-Seleccionar-");
getSessionBean1().setEstabelecimentosGestorOptions( listGestorOptions );
drpEstabelecimentos.setSelected(new Integer(0));
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

@ -11606,8 +11606,15 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
if(txtCoefIncapacidade.getText() != null)
{
String coef_str = txtCoefIncapacidade.getText().toString();
int coef = Integer.parseInt(coef_str);
a.setCoef_incapacidade(new Integer(coef));
try
{
int coef = Integer.parseInt(coef_str);
a.setCoef_incapacidade(new Integer(coef));
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
DateFormat formatador = new SimpleDateFormat("yyyy-MM-dd");

@ -148,6 +148,15 @@ public class Dummy extends AbstractPageBean {
public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown1DefaultOptions = ssol;
}
private SingleSelectOptionsList dropDown2DefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDropDown2DefaultOptions() {
return dropDown2DefaultOptions;
}
public void setDropDown2DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown2DefaultOptions = ssol;
}
// </editor-fold>

@ -911,14 +911,29 @@ public class FormGestor extends AbstractPageBean {
AnalisesDataProvider adp = new AnalisesDataProvider();
try
{
Integer estabelecimento_id = null;
//lblActivos.setRendered(true);
table1.setRendered(true);
ArrayList seguimentoList = null;
if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA)
//if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA)
if(curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
{
estabelecimento_id = curUser.getEstabelecimento_gestor();
if(estabelecimento_id.intValue() == 0)
{
seguimentoList = adp.getAnalisesSeguimentoGestorList(null);
}
else
{
seguimentoList = adp.getAnalisesSeguimentoGestorList(curUser.getEstabelecimento_id());
}
}
else if(curUser.getGestor_geral().matches("y") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_NACIONAL_SEGURANCA)
{
seguimentoList = adp.getAnalisesSeguimentoGestorList(null);
}
else if(curUser.getGestor_geral().matches("n") )
else if(curUser.getGestor_geral().matches("n") || curUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA)
{
seguimentoList = adp.getAnalisesSeguimentoGestorList(curUser.getEstabelecimento_id());
}

@ -398,7 +398,15 @@ public class Login extends AbstractPageBean {
}
else if(permissao.intValue() == 2) // rh
{
sRet = "form_rh";
if(u.getResponsavel_loja().matches("y"))
{
sRet = "acesso";
}
else
{
sRet = "form_rh";
}
//sRet = "form_rh";
}
else if(permissao.intValue() == 3) // hs
{
@ -411,12 +419,14 @@ public class Login extends AbstractPageBean {
}
else if(permissao.intValue() == 6) // gestor
{
sRet = "form_gestor";
//sRet = "form_gestor";
sRet = "acesso";
}
else if(permissao.intValue() == 7) // director geral rh
{
//sRet = "form_rh";
sRet = "form_dir_ger_rh";
//sRet = "form_dir_ger_rh";
sRet = "acesso";
}
else if(permissao.intValue() == 8) // director siprp
{

@ -438,7 +438,28 @@ public class SessionBean1 extends AbstractSessionBean {
public void setEstabelecimentosOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosOptions) {
this.estabelecimentosOptions = estabelecimentosOptions;
}
}
private Integer estabelecimentoGestorChoice;
public Integer getEstabelecimentoGestorChoice() {
return estabelecimentoGestorChoice;
}
public void setEstabelecimentoGestorChoice(Integer estabelecimentoGestorChoice) {
this.estabelecimentoGestorChoice = estabelecimentoGestorChoice;
}
private com.sun.rave.web.ui.model.Option[] estabelecimentosGestorOptions;
public com.sun.rave.web.ui.model.Option[] getEstabelecimentosGestorOptions() {
return estabelecimentosGestorOptions;
}
public void setEstabelecimentosGestorOptions(com.sun.rave.web.ui.model.Option[] estabelecimentosGestorOptions) {
this.estabelecimentosGestorOptions = estabelecimentosGestorOptions;
}
//
@ -451,6 +472,8 @@ public class SessionBean1 extends AbstractSessionBean {
public void setEstabelecimentoOutroChoice(Integer estabelecimentoOutroChoice) {
this.estabelecimentoOutroChoice = estabelecimentoOutroChoice;
}
private com.sun.rave.web.ui.model.Option[] estabelecimentosOutroOptions;

@ -49,6 +49,8 @@ public class Utilizador {
private String apagado;
private Date data_password;
private Integer estabelecimento_gestor = null;
/** Creates a new instance of Utilizador */
public Utilizador() {
@ -245,5 +247,19 @@ public class Utilizador {
public void setData_password(Date data_password) {
this.data_password = data_password;
}
/**
* @return the estabelecimento_gestor
*/
public Integer getEstabelecimento_gestor() {
return estabelecimento_gestor;
}
/**
* @param estabelecimento_gestor the estabelecimento_gestor to set
*/
public void setEstabelecimento_gestor(Integer estabelecimento_gestor) {
this.estabelecimento_gestor = estabelecimento_gestor;
}
}

@ -1883,7 +1883,61 @@ public class AnalisesDataProvider {
}
dblocal.close();
return listOptions;
}
}
public com.sun.rave.web.ui.model.Option[] getEstabelecimentosGestorList(Integer empresa_id, Boolean booGestor) throws Exception
{
Dblocal dblocal = new Dblocal();
dblocal.connect();
Statement stlocal = dblocal.createStatement();
ArrayList list = new ArrayList();
Estabelecimento e = null;
//Estabelecimento e = new Estabelecimento();
//e.setId(new Integer(-1));
//e.setNome("-Seleccionar-");
//list.add(e);
if(booGestor.equals(new Boolean(true)))
{
e = new Estabelecimento();
e.setId(new Integer(0));
e.setNome("-Todos os estabelecimentos-");
list.add(e);
}
String sql ="SELECT * FROM estabelecimentos WHERE empresa_id = " + empresa_id + " AND inactivo = 'n' ORDER BY nome_plain";
ResultSet rslocal = stlocal.executeQuery(sql);
if(rslocal.isBeforeFirst())
{
rslocal.first();
do
{
e = new Estabelecimento();
e.setId(new Integer(rslocal.getInt("id")));
//e.setNome_plain(rslocal.getString("nome_plain"));
e.setNome(rslocal.getString("nome"));
System.out.println("ESTABELECIMENTOAA : " + e.getId().toString() + " - " + e.getNome());
//t.setActivo(rs.getString("activo"));
//t.setOrdem(new Integer(rs.getInt("ordem")));
list.add(e);
}while(rslocal.next());
}
com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[list.size()];
ListIterator iter = list.listIterator();
int i = 0;
while(iter.hasNext())
{
e = (Estabelecimento) iter.next();
System.out.println("ESTABELECIMENTOL : " + e.getId().toString() + " - " + e.getNome());
listOptions[i] = new Option(e.getId(), Utils.unicodeToHTML(e.getNome()));
i++;
}
dblocal.close();
return listOptions;
}
public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception
{

@ -22,7 +22,7 @@ import javax.servlet.http.HttpSession;
*/
public class Dblocal {
//String connectionURL = "jdbc:postgresql://storage/siprp_local"; //testes
String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3";
String connectionURL = "jdbc:postgresql://localhost:5436/siprp_local_3";
String User = "postgres";
String Pass = null;
Connection connection = null;

@ -145,11 +145,17 @@ public class Global {
public static void redirectToPlanos(FacesContext fc, Utilizador currentUser)
{
String curUser = "?user=" + currentUser.getId().toString();
String curUser = "?user=" + currentUser.getId().toString();
String estab = "";
if(currentUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
{
//obtem estabelecimento da lista de estabelecimentos
estab = "&estab_gestor=" + currentUser.getEstabelecimento_gestor().intValue();
}
fc = fc.getCurrentInstance();
try
{
JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser);
JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser + estab);
//JSFUtils.dispatch(fc, Global.PLANOS_ACTUACAO_URL + curUser);
}
catch(Exception ex)

@ -42,6 +42,15 @@
<ui:hyperlink action="#{Acesso.lnkPlanos_action}" id="lnkPlanos" style="font-size: 16px" text="Planos de Actuação"/>
</ui:panelGroup>
</h:panelGrid>
<ui:staticText escape="false" id="staticText11" style="font-size: 18px" text="&amp;nbsp;"/>
<h:panelGrid binding="#{Acesso.gridEstabelecimento}" columnClasses="gridColCenter" columns="1" id="gridEstabelecimento"
style="height: 24px; width: 100%" width="168">
<ui:panelGroup id="groupPanel4">
<ui:staticText escape="false" id="staticText10" text="Seleccionar estabelecimento:&amp;nbsp;"/>
<ui:dropDown binding="#{Acesso.drpEstabelecimentos}" id="drpEstabelecimentos"
items="#{SessionBean1.estabelecimentosGestorOptions}" selected="#{SessionBean1.estabelecimentoGestorChoice}" style="width: 190px"/>
</ui:panelGroup>
</h:panelGrid>
</h:panelGrid>
<ui:staticText escape="false" id="staticText8" style="font-size: xx-large" text="&amp;nbsp;"/>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridPanel3" style="height: 24px; width: 100%">

@ -63,8 +63,18 @@
</ui:panelGroup>
</h:panelGrid>
</h:panelGrid>
<ui:staticText id="staticText9" style="position: absolute; left: 72px; top: 120px" text="Enviar para: "/>
<ui:dropDown id="dropDown1" items="#{Dummy.dropDown1DefaultOptions.options}" style="position: absolute; left: 168px; top: 120px"/>
<h:panelGrid columnClasses="gridColLeft" columns="1" id="gridEstabelecimento"
style="height: 24px; left: 96px; top: 216px; position: absolute" width="168">
<ui:panelGroup id="groupPanel5">
<ui:staticText escape="false" id="staticText10" text="Seleccionar estabelecimento:&amp;nbsp;"/>
<ui:dropDown id="dropDown3" items="#{Dummy.dropDown2DefaultOptions.options}" style="width: 190px"/>
</ui:panelGroup>
</h:panelGrid>
<ui:panelGroup id="groupPanel4" style="position: absolute; left: 72px; top: 288px">
<ui:staticText escape="false" id="staticText9" text="Seleccionar estabelecimento:&amp;nbsp;"/>
<ui:dropDown id="dropDown2" items="#{Dummy.dropDown2DefaultOptions.options}" style="width: 190px"/>
</ui:panelGroup>
<ui:dropDown id="dropDown1" items="#{Dummy.dropDown1DefaultOptions.options}" style="position: absolute; left: 216px; top: 120px"/>
</ui:form>
</ui:body>
</ui:html>

@ -423,6 +423,14 @@
<from-outcome>gestor</from-outcome>
<to-view-id>/FormGestor.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_rh</from-outcome>
<to-view-id>/FormRH.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_dir_ger_rh</from-outcome>
<to-view-id>/FormDirGerRh.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_hs</from-outcome>
<to-view-id>/FormHS.jsp</to-view-id>
@ -434,7 +442,11 @@
<navigation-case>
<from-outcome>form_dir_siprp</from-outcome>
<to-view-id>/FormDirSiprp.jsp</to-view-id>
</navigation-case>
</navigation-case>
<navigation-case>
<from-outcome>form_gestor</from-outcome>
<to-view-id>/FormGestor.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/Login.jsp</to-view-id>

Loading…
Cancel
Save