|
|
|
|
@ -10,11 +10,13 @@ import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
import com.sun.data.provider.RowKey;
|
|
|
|
|
import com.sun.rave.web.ui.appbase.AbstractPageBean;
|
|
|
|
|
import com.sun.webui.jsf.component.Button;
|
|
|
|
|
import com.sun.webui.jsf.component.DropDown;
|
|
|
|
|
import com.sun.webui.jsf.component.PanelGroup;
|
|
|
|
|
import com.sun.webui.jsf.component.Table;
|
|
|
|
|
import com.sun.webui.jsf.component.TableColumn;
|
|
|
|
|
import com.sun.webui.jsf.component.TableRowGroup;
|
|
|
|
|
import com.sun.webui.jsf.component.TextField;
|
|
|
|
|
import com.sun.webui.jsf.model.Option;
|
|
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
|
|
import db.entidades.Utilizador;
|
|
|
|
|
import db.providers.PlanosDataProvider;
|
|
|
|
|
@ -27,12 +29,15 @@ import java.util.List;
|
|
|
|
|
import javax.faces.FacesException;
|
|
|
|
|
import javax.faces.component.html.HtmlPanelGrid;
|
|
|
|
|
import javax.faces.context.FacesContext;
|
|
|
|
|
import javax.faces.event.ValueChangeEvent;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import shst.higiene.planoactuacao.print.PlanoActuacaoPDFCreator;
|
|
|
|
|
import tabledataproviders.PlanosActualDataProvider;
|
|
|
|
|
import tabledataproviders.PlanosConcluidosDataProvider;
|
|
|
|
|
import tabledataproviders.PlanosSeguimentoDataProvider;
|
|
|
|
|
import utils.JSFUtils;
|
|
|
|
|
import utils.Utils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>Page bean that corresponds to a similarly named JSP page. This
|
|
|
|
|
@ -419,6 +424,19 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
{
|
|
|
|
|
this.buttonFilterConc = b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DropDown dropCurrentYear = new DropDown();
|
|
|
|
|
|
|
|
|
|
public DropDown getDropCurrentYear()
|
|
|
|
|
{
|
|
|
|
|
return dropCurrentYear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDropCurrentYear( DropDown dropCurrentYear )
|
|
|
|
|
{
|
|
|
|
|
this.dropCurrentYear = dropCurrentYear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final DateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" );
|
|
|
|
|
// </editor-fold>
|
|
|
|
|
|
|
|
|
|
@ -494,7 +512,19 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
public void prerender()
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "LISTA PLANOS - PRERENDER" );
|
|
|
|
|
HttpServletRequest request = ( HttpServletRequest ) getExternalContext().getRequest();
|
|
|
|
|
String referer = request.getRequestURI();
|
|
|
|
|
String pageFrom = Utils.getPageFrom( referer );
|
|
|
|
|
if ( !pageFrom.matches( "FormMedico.jsp" )
|
|
|
|
|
|| dropCurrentYear.getItems() == null )
|
|
|
|
|
{
|
|
|
|
|
fillCurrentYearDrop();
|
|
|
|
|
fillInitialForm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillInitialForm()
|
|
|
|
|
{
|
|
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
|
|
System.out.println( "\tUser Logged In : " + ( u == null ? "NONE !" : "[" + u.getId() + "] : " + u.getLogin() ) );
|
|
|
|
|
|
|
|
|
|
@ -789,6 +819,7 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
private void initialize()
|
|
|
|
|
{
|
|
|
|
|
Utilizador u = getSessionBean1().getCurrentUser();
|
|
|
|
|
Integer ano = getSelectedYear();
|
|
|
|
|
|
|
|
|
|
// Integer estabelecimento_id = null;
|
|
|
|
|
// if ( u.getTipo().intValue() != Global.TECNICO_HS )
|
|
|
|
|
@ -803,13 +834,13 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
System.out.println( "\tGETTING INITIAL VALUES FOR EACH TABLE." );
|
|
|
|
|
long startedTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
List< PlanoActuacao > listPlanosActivos = getPlanosActivos( u );
|
|
|
|
|
List< PlanoActuacao > listPlanosActivos = getPlanosActivos( u, ano );
|
|
|
|
|
getSessionBean1().getPlanosActualDataProvider().setList( listPlanosActivos );
|
|
|
|
|
|
|
|
|
|
List< PlanoActuacao > listPlanosSeguimento = getPlanosSeguimento( u );
|
|
|
|
|
List< PlanoActuacao > listPlanosSeguimento = getPlanosSeguimento( u, ano );
|
|
|
|
|
getSessionBean1().getPlanosSeguimentoDataProvider().setList( listPlanosSeguimento );
|
|
|
|
|
|
|
|
|
|
List< PlanoActuacao > listPlanosConcluidos = getPlanosConcluidos( u );
|
|
|
|
|
List< PlanoActuacao > listPlanosConcluidos = getPlanosConcluidos( u, ano );
|
|
|
|
|
getSessionBean1().getPlanosConcluidosDataProvider().setList( listPlanosConcluidos );
|
|
|
|
|
|
|
|
|
|
long endedTime = System.currentTimeMillis();
|
|
|
|
|
@ -855,7 +886,7 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita )
|
|
|
|
|
private List< PlanoActuacao > searchPlanosActivos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
List< PlanoActuacao > list = null;
|
|
|
|
|
try
|
|
|
|
|
@ -863,7 +894,7 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
if ( u.getTipo().intValue() != Global.DIRECTOR_SIPRP && u.getTipo().intValue() != Global.GESTOR && u.getTipo().intValue() != Global.DIRECTOR_GERAL_RH )
|
|
|
|
|
{
|
|
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
|
|
list = pdp.searchPlanosActivos( u, nome, estabelecimento, dataVisita );
|
|
|
|
|
list = pdp.searchPlanosActivos( u, nome, estabelecimento, dataVisita, ano );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception e )
|
|
|
|
|
@ -873,18 +904,18 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
return list == null ? new LinkedList< PlanoActuacao >() : list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PlanoActuacao> getPlanosActivos( Utilizador u )
|
|
|
|
|
private List<PlanoActuacao> getPlanosActivos( Utilizador u, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
return searchPlanosActivos( u, null, null, null );
|
|
|
|
|
return searchPlanosActivos( u, null, null, null, ano );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita )
|
|
|
|
|
private List< PlanoActuacao > searchPlanosSeguimento( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
List< PlanoActuacao > list = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
|
|
list = pdp.searchPlanosSeguimento( u, nome, estabelecimento, dataVisita );
|
|
|
|
|
list = pdp.searchPlanosSeguimento( u, nome, estabelecimento, dataVisita, ano );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
@ -893,18 +924,18 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
return list == null ? new LinkedList< PlanoActuacao >() : list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List< PlanoActuacao > getPlanosSeguimento( Utilizador u )
|
|
|
|
|
private List< PlanoActuacao > getPlanosSeguimento( Utilizador u, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
return searchPlanosSeguimento( u, null, null, null );
|
|
|
|
|
return searchPlanosSeguimento( u, null, null, null, ano );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita )
|
|
|
|
|
private List< PlanoActuacao > searchPlanosConcluidos( Utilizador u, String nome, String estabelecimento, String dataVisita, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
List< PlanoActuacao > list = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PlanosDataProvider pdp = PlanosDataProvider.getInstance();
|
|
|
|
|
list = pdp.searchPlanosConcluidos( u, nome, estabelecimento, dataVisita );
|
|
|
|
|
list = pdp.searchPlanosConcluidos( u, nome, estabelecimento, dataVisita, ano );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
@ -913,9 +944,9 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
return list == null ? new LinkedList< PlanoActuacao >() : list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List< PlanoActuacao > getPlanosConcluidos( Utilizador u )
|
|
|
|
|
private List< PlanoActuacao > getPlanosConcluidos( Utilizador u, Integer ano )
|
|
|
|
|
{
|
|
|
|
|
return searchPlanosConcluidos( u, null, null, null );
|
|
|
|
|
return searchPlanosConcluidos( u, null, null, null, ano );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String buttonFilterActual_action()
|
|
|
|
|
@ -942,9 +973,11 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
|
|
|
|
|
String visitaDateStr = calFilterDate == null ? null : D_F.format( calFilterDate );
|
|
|
|
|
|
|
|
|
|
Integer ano = getSelectedYear();
|
|
|
|
|
|
|
|
|
|
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
|
|
|
|
|
getSessionBean1().getPlanosActualDataProvider().setList(
|
|
|
|
|
searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) );
|
|
|
|
|
searchPlanosActivos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
@ -973,9 +1006,11 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
|
|
|
|
|
String visitaDateStr = calFilterDateSeguimento == null ? null : D_F.format( calFilterDateSeguimento );
|
|
|
|
|
|
|
|
|
|
Integer ano = getSelectedYear();
|
|
|
|
|
|
|
|
|
|
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
|
|
|
|
|
getSessionBean1().getPlanosSeguimentoDataProvider().setList(
|
|
|
|
|
searchPlanosSeguimento( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) );
|
|
|
|
|
searchPlanosSeguimento( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
@ -1004,11 +1039,54 @@ public class ListaPlanos extends AbstractPageBean
|
|
|
|
|
|
|
|
|
|
String visitaDateStr = calFilterDateConcluidos == null ? null : D_F.format( calFilterDateConcluidos );
|
|
|
|
|
|
|
|
|
|
Integer ano = getSelectedYear();
|
|
|
|
|
|
|
|
|
|
getSessionBean1().setIsSearchingPlanosActuacao( Boolean.TRUE );
|
|
|
|
|
getSessionBean1().getPlanosConcluidosDataProvider().setList(
|
|
|
|
|
searchPlanosConcluidos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr ) );
|
|
|
|
|
searchPlanosConcluidos( getSessionBean1().getCurrentUser(), nome, estabelecimento, visitaDateStr, ano ) );
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void dropCurrentYear_valueChangeListener( ValueChangeEvent event )
|
|
|
|
|
{
|
|
|
|
|
Object oldValue = event.getOldValue();
|
|
|
|
|
Object newValue = event.getNewValue();
|
|
|
|
|
|
|
|
|
|
if ( newValue != null && newValue instanceof Integer )
|
|
|
|
|
{
|
|
|
|
|
Integer newYear = ( Integer ) newValue;
|
|
|
|
|
getSessionBean1().setAnoChoice( newYear);
|
|
|
|
|
Integer oldYear = oldValue != null && oldValue instanceof Integer ? ( Integer ) oldValue : null;
|
|
|
|
|
if ( oldYear == null || !newYear.equals( oldYear ) )
|
|
|
|
|
{
|
|
|
|
|
fillInitialForm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Integer getSelectedYear()
|
|
|
|
|
{
|
|
|
|
|
Integer result = getSessionBean1().getAnoChoice();
|
|
|
|
|
if ( result == null && dropCurrentYear != null )
|
|
|
|
|
{
|
|
|
|
|
Object selected = dropCurrentYear.getSelected();
|
|
|
|
|
if ( selected != null && selected instanceof Integer )
|
|
|
|
|
{
|
|
|
|
|
result = ( Integer ) selected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillCurrentYearDrop()
|
|
|
|
|
{
|
|
|
|
|
Integer selectedYear = getSelectedYear();
|
|
|
|
|
|
|
|
|
|
Option[] opts = Utils.getYearDropValues();
|
|
|
|
|
dropCurrentYear.setItems( opts );
|
|
|
|
|
|
|
|
|
|
dropCurrentYear.setSelected( selectedYear != null ? selectedYear : Utils.getDefaultSelectedYear() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|