|  |  | @ -456,12 +456,32 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public Integer getMarcacaoIDByTrabalhador( Integer trabalhadorID ) |  |  |  | 	public Integer getMarcacaoIDByTrabalhador( Integer trabalhadorID ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		throws Exception  |  |  |  | 		throws Exception  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Select select =  |  |  |  | 		Select realizadaSelect =  | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			new Select( new String[]{ "marcacoes_trabalhador" }, |  |  |  | 			new Select( new String[]{ "marcacoes_trabalhador" }, | 
			
		
	
		
		
			
				
					
					|  |  |  | 						new String[]{ "id" }, |  |  |  | 						new String[]{ "MAX(data)" }, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( |  |  |  | 						new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "data" ).isGreater( new Date() ) ).and( |  |  |  | 						new Field( "estado" ).isEqual( new Integer( 2 ) ) ).and( | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); |  |  |  | 						new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Virtual2DArray realizadaArray = executer.executeQuery( realizadaSelect ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Date realizada = (Date) realizadaArray.get( 0, 0 ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Select select; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if( realizada == null ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			select = new Select( new String[]{ "marcacoes_trabalhador" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new String[]{ "MIN(id)" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			select = new Select( new String[]{ "marcacoes_trabalhador" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new String[]{ "MIN(id)" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "data" ).isGreater( realizada ) ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Virtual2DArray array = executer.executeQuery( select ); |  |  |  | 		Virtual2DArray array = executer.executeQuery( select ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		if( array.columnLength() == 0 ) |  |  |  | 		if( array.columnLength() == 0 ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
	
		
		
			
				
					|  |  | 
 |