Files correlati : Ricompilazione Demo : [ ] Commento : ultima versione di AVIS git-svn-id: svn://10.65.10.50/trunk@11386 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			509 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			509 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <recarray.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include "atlib.h"
 | 
						|
 | 
						|
#include "contsan.h"
 | 
						|
#include "donaz.h"
 | 
						|
#include "idoneita.h"
 | 
						|
#include "rconvoc.h"
 | 
						|
 | 
						|
static int compare_date(const TObject** o1, const TObject** o2)
 | 
						|
{
 | 
						|
  TRectype* s1 = (TRectype*)*o1;
 | 
						|
  TRectype* s2 = (TRectype*)*o2;
 | 
						|
  const TDate d1(s1->get(DON_DATADON));
 | 
						|
  const TDate d2(s2->get(DON_DATADON));
 | 
						|
  int d=0;
 | 
						|
  if (d1>d2) d=+1;
 | 
						|
  else
 | 
						|
  	if (d1<d2) d=-1;
 | 
						|
	return d;
 | 
						|
}	
 | 
						|
 | 
						|
bool is_idon_one(TString16 idon, const char* tipo)        
 | 
						|
// verifica che l'idoneità "idon" sia del tipo "tipo"
 | 
						|
// esempio: se passo PL, AF restituisce TRUE
 | 
						|
{                      
 | 
						|
	bool is_idon = FALSE;
 | 
						|
	TTable ido("IDO");
 | 
						|
	ido.put("CODTAB",idon); 		
 | 
						|
 	if (ido.read() == NOERR)
 | 
						|
 	{
 | 
						|
 		TString tipol(2);
 | 
						|
 		tipol = ido.get("S6");
 | 
						|
  	if (tipol == tipo)
 | 
						|
  		is_idon = TRUE;
 | 
						|
	}  		
 | 
						|
	return is_idon;
 | 
						|
}
 | 
						|
 | 
						|
bool is_idon(TString16 id1, TString16 id2, TString16 id3, TString16 id4, const char* tipo)
 | 
						|
//verifica che almeno una delle "id" sia del tipo "tipo"
 | 
						|
{
 | 
						|
	return (is_idon_one(id1,tipo) || is_idon_one(id2,tipo) || is_idon_one(id3,tipo) || is_idon_one(id4,tipo));
 | 
						|
}
 | 
						|
 | 
						|
bool is_donaz(TString16 don, const char* tipo)
 | 
						|
// verifica che il tipo di donazione "don" sia del tipo "tipo"
 | 
						|
{
 | 
						|
	bool is_don = FALSE;
 | 
						|
	TTable tdn("TDN");
 | 
						|
	tdn.put("CODTAB",don); 		
 | 
						|
  if (tdn.read() == NOERR)
 | 
						|
  {
 | 
						|
  	TString tipol(2);
 | 
						|
  	tipol = tdn.get("S6");
 | 
						|
  	if (tipol == tipo)
 | 
						|
  		is_don = TRUE;
 | 
						|
	}
 | 
						|
	return is_don;
 | 
						|
}
 | 
						|
 | 
						|
char modstato_tcs(const TString16 tipo)
 | 
						|
// verifica se il controllo sanitario "tipo" e' un controllo che modifica 
 | 
						|
// lo stato del soggetto
 | 
						|
{
 | 
						|
	char modstato = ' ';
 | 
						|
	TTable tcs("TCS");
 | 
						|
	tcs.put("CODTAB",tipo);
 | 
						|
	if (tcs.read() == NOERR)
 | 
						|
		modstato = tcs.get_char("S6");
 | 
						|
	return modstato;		
 | 
						|
}
 | 
						|
 | 
						|
void con_reord(TRectype& soggetto, TRecord_array* controlli, TRecord_array* idoneita)
 | 
						|
{ 
 | 
						|
	const TDate datanulla(NULLDATE);
 | 
						|
	TDate data(NULLDATE);
 | 
						|
	TDate prossdata(NULLDATE);
 | 
						|
	TString16 tipo = "  ";
 | 
						|
	TString16 prosstipo = "  ";
 | 
						|
	char modstato = ' ';			  
 | 
						|
	int r_ultid = -1;					// riga ultima idoneità
 | 
						|
	int r_ultstato = -1;			// riga ultimo stato valido
 | 
						|
	char penultstato = ' ';		// penultimo stato valido
 | 
						|
	char ultstato = ' ';			// ultimo stato valido
 | 
						|
	TDate dataultstato(NULLDATE);	// data ultimo stato valido
 | 
						|
		
 | 
						|
	for (int r=controlli->rows(); r>0; r--)
 | 
						|
	{ 			
 | 
						|
		const TRectype& row = controlli->row(r);
 | 
						|
		tipo = row.get(CON_TIPOCON);
 | 
						|
   	modstato = modstato_tcs(tipo);
 | 
						|
 		if ((modstato != 'N') && (r_ultstato == -1))
 | 
						|
 			r_ultstato = r;
 | 
						|
 		else if ((modstato != 'N') && (penultstato == ' '))
 | 
						|
					 penultstato = modstato;
 | 
						|
		if ((modstato == 'I') && (r_ultid == -1))
 | 
						|
			r_ultid = r;
 | 
						|
 	}		
 | 
						|
	TString16 id1 = "  ";		
 | 
						|
	TString16 id2 = "  ";		
 | 
						|
	TString16 id3 = "  ";		
 | 
						|
	TString16 id4 = "  ";			
 | 
						|
	int intsi = 0;
 | 
						|
	int intaf = 0;
 | 
						|
	tipo = "  ";
 | 
						|
	prosstipo = "  ";
 | 
						|
	data = TDate(NULLDATE);
 | 
						|
	prossdata = TDate(NULLDATE);
 | 
						|
 | 
						|
 	if (r_ultid != -1)
 | 
						|
 	{
 | 
						|
		const TRectype& row = controlli->row(r_ultid);
 | 
						|
		data = TDate(row.get(CON_DATACON));
 | 
						|
		tipo = row.get(CON_TIPOCON);
 | 
						|
		id1 = row.get(CON_IDON1);		
 | 
						|
		id2 = row.get(CON_IDON2);
 | 
						|
		id3 = row.get(CON_IDON3);
 | 
						|
		id4 = row.get(CON_IDON4);
 | 
						|
		intsi = row.get_int(CON_INTSI);
 | 
						|
		intaf = row.get_int(CON_INTAF);
 | 
						|
 	}
 | 
						|
	soggetto.put(SOG_DATAULTID,data);			
 | 
						|
	soggetto.put(SOG_TIPOULTID,tipo);
 | 
						|
	soggetto.put(SOG_IDON1,id1);
 | 
						|
	soggetto.put(SOG_IDON2,id2);
 | 
						|
	soggetto.put(SOG_IDON3,id3);
 | 
						|
	soggetto.put(SOG_IDON4,id4);
 | 
						|
	if (intsi > 0)
 | 
						|
		soggetto.put(SOG_INTSI,intsi);
 | 
						|
	if (intaf > 0)
 | 
						|
		soggetto.put(SOG_INTAF,intaf);
 | 
						|
 	tipo = "  ";
 | 
						|
 	if (r_ultstato != -1)
 | 
						|
 	{
 | 
						|
 	 	const TRectype& row = controlli->row(r_ultstato);
 | 
						|
		dataultstato = TDate(row.get(CON_DATACON)); 	 	
 | 
						|
		tipo = row.get(CON_TIPOCON);
 | 
						|
		prosstipo = row.get(CON_PROSSTIPO);
 | 
						|
		prossdata = TDate(row.get(CON_PROSSDATA));
 | 
						|
		ultstato = modstato_tcs(tipo);
 | 
						|
	}
 | 
						|
	soggetto.put(SOG_STATO,tipo);
 | 
						|
	soggetto.put(SOG_DATASTATO,dataultstato);
 | 
						|
	soggetto.put(SOG_PROS_STATO,prosstipo);
 | 
						|
	soggetto.put(SOG_DATA_PROS,prossdata);
 | 
						|
 | 
						|
	/*
 | 
						|
	soggetto.put(SOG_STATOSI, "  ");
 | 
						|
	soggetto.put(SOG_STATOAF, "  ");
 | 
						|
	soggetto.put(SOG_DATASI, datanulla);
 | 
						|
	soggetto.put(SOG_DATAAF, datanulla);
 | 
						|
	soggetto.put(SOG_FINESOSSI, datanulla);
 | 
						|
	soggetto.put(SOG_FINESOSAF, datanulla);
 | 
						|
	*/
 | 
						|
	if (intsi > 0)
 | 
						|
	{
 | 
						|
		soggetto.put(SOG_STATOSI, tipo);
 | 
						|
		soggetto.put(SOG_DATASI, dataultstato);
 | 
						|
		//if (prosstipo == "FS")
 | 
						|
	  if (modstato_tcs(prosstipo)=='F')
 | 
						|
			soggetto.put(SOG_FINESOSSI, prossdata);
 | 
						|
		else			
 | 
						|
			soggetto.put(SOG_FINESOSSI, datanulla);		
 | 
						|
	}
 | 
						|
	else
 | 
						|
	{
 | 
						|
		soggetto.put(SOG_STATOSI, "  ");
 | 
						|
		soggetto.put(SOG_DATASI, datanulla);
 | 
						|
		soggetto.put(SOG_FINESOSSI, datanulla);
 | 
						|
	}		                                   
 | 
						|
	if (intaf > 0)
 | 
						|
	{
 | 
						|
		soggetto.put(SOG_STATOAF, tipo);
 | 
						|
		soggetto.put(SOG_DATAAF, dataultstato);
 | 
						|
		//if (prosstipo == "FS")
 | 
						|
	  if (modstato_tcs(prosstipo)=='F')
 | 
						|
			soggetto.put(SOG_FINESOSAF, prossdata);
 | 
						|
		else
 | 
						|
			soggetto.put(SOG_FINESOSAF, datanulla);					
 | 
						|
	}
 | 
						|
	else                               
 | 
						|
	{
 | 
						|
		soggetto.put(SOG_STATOAF, "  ");
 | 
						|
		soggetto.put(SOG_DATAAF, datanulla);
 | 
						|
		soggetto.put(SOG_FINESOSAF, datanulla);
 | 
						|
	}		
 | 
						|
 | 
						|
	// riordino le idoneita
 | 
						|
	for (int ri=1; ri<=idoneita->rows(); ri++)
 | 
						|
	{ 			  
 | 
						|
		const TRectype& row = idoneita->row(ri);
 | 
						|
		TDate dataido = row.get_date(IDO_DATAIDO);   
 | 
						|
		TString16 tipoido = row.get(IDO_TIPOIDO);
 | 
						|
		TString16 ido_sos = row.get(IDO_IDO_SOS);
 | 
						|
		int intervallo = row.get_int(IDO_INTERVALLO);
 | 
						|
		TDate finesos = row.get_date(IDO_FINESOS);
 | 
						|
		if (tipoido == IDON_SI)
 | 
						|
			if ((intervallo != 0) && (intsi == 0))
 | 
						|
				soggetto.put(SOG_INTSI, intervallo);
 | 
						|
		if (tipoido == IDON_AF)
 | 
						|
			if ((intervallo != 0) && (intaf == 0))
 | 
						|
				soggetto.put(SOG_INTAF, intervallo);
 | 
						|
		if ((dataido >= dataultstato) || (ultstato) == 'F')
 | 
						|
		{ 
 | 
						|
			if (tipoido == IDON_SI)
 | 
						|
			{ 
 | 
						|
				soggetto.put(SOG_DATASI,dataido);			
 | 
						|
				soggetto.put(SOG_STATOSI,ido_sos);			
 | 
						|
				soggetto.put(SOG_FINESOSSI,finesos);
 | 
						|
				if (intervallo != 0 && ido_sos == IDONEITA)
 | 
						|
				{
 | 
						|
					soggetto.put(SOG_INTSI,intervallo);
 | 
						|
					if (id1 != IDON_SI && id2 != IDON_SI && id3 != IDON_SI && id4 != IDON_SI)
 | 
						|
						if (id1.empty())
 | 
						|
							soggetto.put(SOG_IDON1,IDON_SI);
 | 
						|
						else						
 | 
						|
							if (id2.empty())
 | 
						|
								soggetto.put(SOG_IDON2,IDON_SI);
 | 
						|
							else						
 | 
						|
								if (id3.empty())
 | 
						|
									soggetto.put(SOG_IDON3,IDON_SI);
 | 
						|
								else						
 | 
						|
									if (id4.empty())
 | 
						|
										soggetto.put(SOG_IDON4,IDON_SI);
 | 
						|
				}				
 | 
						|
			}				
 | 
						|
			if (tipoido == IDON_AF)
 | 
						|
			{
 | 
						|
				soggetto.put(SOG_DATAAF,dataido);			
 | 
						|
				soggetto.put(SOG_STATOAF,ido_sos);			
 | 
						|
				soggetto.put(SOG_FINESOSAF,finesos);
 | 
						|
				if (intervallo != 0 && ido_sos == IDONEITA)
 | 
						|
				{
 | 
						|
					soggetto.put(SOG_INTAF,intervallo);
 | 
						|
					if (id1 != IDON_PL && id2 != IDON_PL && id3 != IDON_PL && id4 != IDON_PL)
 | 
						|
						if (id1.empty())
 | 
						|
							soggetto.put(SOG_IDON1,IDON_PL);
 | 
						|
						else						
 | 
						|
							if (id2.empty())
 | 
						|
								soggetto.put(SOG_IDON2,IDON_PL);
 | 
						|
							else						
 | 
						|
								if (id3.empty())
 | 
						|
									soggetto.put(SOG_IDON3,IDON_PL);
 | 
						|
								else						
 | 
						|
									if (id4.empty())
 | 
						|
										soggetto.put(SOG_IDON4,IDON_PL);					
 | 
						|
				}				
 | 
						|
			}				
 | 
						|
		}			
 | 
						|
	}				
 | 
						|
	// verifico la concordanza di stato soggetto e stato idoneita
 | 
						|
	TString16 statosi = soggetto.get(SOG_STATOSI);
 | 
						|
	TString16 statoaf = soggetto.get(SOG_STATOAF);
 | 
						|
	TDate datastatosi = soggetto.get_date(SOG_DATASI);
 | 
						|
	TDate datastatoaf = soggetto.get_date(SOG_DATAAF);
 | 
						|
	if (statosi.not_empty() || statoaf.not_empty())
 | 
						|
	{ 
 | 
						|
		TString16 stato = soggetto.get(SOG_STATO);
 | 
						|
		char modstato = modstato_tcs(stato);
 | 
						|
		const char tipostatosi = modstato_tcs(statosi);
 | 
						|
		const char tipostatoaf = modstato_tcs(statoaf);
 | 
						|
		if ((tipostatosi == 'I') || (tipostatoaf == 'I'))
 | 
						|
	  	if ((modstato != 'I') || (modstato != 'F'))
 | 
						|
	  		stato = IDONEITA;
 | 
						|
		if ((tipostatosi == 'S') && (tipostatoaf == 'S'))
 | 
						|
	  	if (modstato != 'S')
 | 
						|
	  		stato == statosi;
 | 
						|
		char statocalcolato =	modstato_tcs(stato);
 | 
						|
		if (modstato != statocalcolato)
 | 
						|
		{
 | 
						|
			soggetto.put(SOG_STATO, stato);
 | 
						|
			soggetto.put(SOG_PROS_STATO,"  ");
 | 
						|
			soggetto.put(SOG_DATA_PROS, datanulla);
 | 
						|
			if (statocalcolato == 'I')
 | 
						|
			{   
 | 
						|
				TDate datacalcolata = NULLDATE;
 | 
						|
				if (statosi == IDONEITA)
 | 
						|
					datacalcolata = datastatosi;
 | 
						|
				if ((statoaf == IDONEITA) && (datastatoaf > datacalcolata))
 | 
						|
					datacalcolata = datastatoaf;					
 | 
						|
				soggetto.put(SOG_DATASTATO,datacalcolata);
 | 
						|
			}
 | 
						|
			else
 | 
						|
				if (datastatoaf > datastatosi)
 | 
						|
					soggetto.put(SOG_DATASTATO,datastatoaf);
 | 
						|
				else
 | 
						|
					soggetto.put(SOG_DATASTATO,datastatosi);							
 | 
						|
	  }
 | 
						|
	}	  
 | 
						|
	TString stato = soggetto.get(SOG_STATO);
 | 
						|
	TTable tcs("TCS"); 
 | 
						|
	tcs.put("CODTAB",stato);
 | 
						|
	if (tcs.read() == NOERR)
 | 
						|
	{
 | 
						|
		TString catcoll = tcs.get("S7");
 | 
						|
		if (catcoll.not_empty())
 | 
						|
			soggetto.put(SOG_CATDON,catcoll);
 | 
						|
	}	
 | 
						|
 	don_datepross(soggetto);
 | 
						|
	
 | 
						|
 	if (((penultstato == 'S') || (penultstato == 'I')) && ((ultstato == 'I') || (ultstato == 'F')))
 | 
						|
 	{
 | 
						|
 		data = soggetto.get_date(SOG_DATAPROSSI);
 | 
						|
		if (data < dataultstato && data.ok()) soggetto.put(SOG_DATAPROSSI,dataultstato);
 | 
						|
 		data = soggetto.get_date(SOG_DATAPROSAF);		
 | 
						|
 		if (data < dataultstato && data.ok()) soggetto.put(SOG_DATAPROSAF,dataultstato);
 | 
						|
	}				
 | 
						|
}
 | 
						|
 | 
						|
void don_datepross(TRectype& soggetto)
 | 
						|
// calcola le date di prossima donazione in base a: donazioni, stato attuale, idoneità
 | 
						|
{
 | 
						|
	char modstato = ' ';     
 | 
						|
	const TString16 stato = soggetto.get(SOG_STATO);	// stato attuale
 | 
						|
	const TString16 id1 	= soggetto.get(SOG_IDON1);		// idon. 1
 | 
						|
	const TString16 id2 	= soggetto.get(SOG_IDON2);		// idon. 2
 | 
						|
	const TString16 id3	 	= soggetto.get(SOG_IDON3);		// idon. 3
 | 
						|
	const TString16 id4 	= soggetto.get(SOG_IDON4);	  // idon. 4
 | 
						|
	const int intsi = soggetto.get_int(SOG_INTSI);		// intervallo per SI
 | 
						|
	const int intaf = soggetto.get_int(SOG_INTAF);		// intervallo per AF
 | 
						|
	const TDate dataultdon(soggetto.get_date(SOG_DATAULTDON));	// data ultima donazione
 | 
						|
	const TString16 tipoultdon(soggetto.get(SOG_TIPOULTDON));	// tipo ultima donazione
 | 
						|
	TDate datasi(NULLDATE);		// data prossima si calcolata
 | 
						|
	TDate dataaf(NULLDATE);		// data prossima af calcolata
 | 
						|
	TDate dataultsi(NULLDATE);	// data ultima donazione si
 | 
						|
	
 | 
						|
	bool id_si = FALSE;		// il soggetto è idoneo per si?
 | 
						|
	bool id_af = FALSE;		// il soggetto è idoneo per af?
 | 
						|
	
 | 
						|
  modstato = modstato_tcs(stato);
 | 
						|
	if (modstato == 'I' || modstato == 'F')	// il soggetto è idoneo
 | 
						|
	{ 
 | 
						|
		id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (soggetto.get(SOG_STATOSI) == IDONEITA)) && (intsi != 0));		// il soggetto è idoneo SI
 | 
						|
		id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (soggetto.get(SOG_STATOAF) == IDONEITA)) && (intaf != 0));		// il soggetto è idoneo AF
 | 
						|
 | 
						|
		if (dataultdon.ok())		// se ha fatto almeno una donazione
 | 
						|
		{
 | 
						|
			if (is_donaz(tipoultdon,IDON_SI))	// se l'ultima donazione è una SI
 | 
						|
			{
 | 
						|
				if (id_si) 
 | 
						|
				{
 | 
						|
					datasi=dataultdon;
 | 
						|
					datasi+=intsi;
 | 
						|
				}	
 | 
						|
  			if (id_af) 
 | 
						|
  			{
 | 
						|
  				dataaf=dataultdon;
 | 
						|
  				dataaf+=intaf;
 | 
						|
  			}	
 | 
						|
      }
 | 
						|
      if (is_donaz(tipoultdon,IDON_AF))	// se l'ultima donazione è una AF
 | 
						|
      {
 | 
						|
      	dataultsi = soggetto.get(SOG_DATAULTSI);
 | 
						|
				if (id_si)
 | 
						|
				{
 | 
						|
					if (intaf != 0)
 | 
						|
					{
 | 
						|
						datasi=dataultdon; 
 | 
						|
						datasi+=intaf;
 | 
						|
					}	
 | 
						|
					else
 | 
						|
					{
 | 
						|
						datasi=dataultdon;
 | 
						|
					  datasi+=intsi;    
 | 
						|
					}  
 | 
						|
					if (dataultsi.ok())
 | 
						|
						dataultsi+=intsi;
 | 
						|
					if (dataultsi > datasi)
 | 
						|
						datasi = dataultsi;
 | 
						|
				}
 | 
						|
				if (id_af)
 | 
						|
				{
 | 
						|
					dataaf=dataultdon;
 | 
						|
					dataaf+=intaf;
 | 
						|
				}					
 | 
						|
      }	
 | 
						|
 		}
 | 
						|
 		else
 | 
						|
 		{
 | 
						|
 			if (id_si)
 | 
						|
 				datasi = soggetto.get_date(SOG_DATAULTID);
 | 
						|
 			if (id_af)
 | 
						|
 				dataaf = soggetto.get_date(SOG_DATAULTID); 				
 | 
						|
 		}
 | 
						|
	}	
 | 
						|
	TString16 statoparziale;
 | 
						|
	TDate datastatoparziale;
 | 
						|
	char tipostato;
 | 
						|
	statoparziale = soggetto.get(SOG_STATOSI);
 | 
						|
	datastatoparziale = soggetto.get_date(SOG_DATASI);
 | 
						|
	tipostato = modstato_tcs(statoparziale);
 | 
						|
	if (tipostato == 'S')
 | 
						|
		datasi = NULLDATE;
 | 
						|
	if (tipostato == 'I')
 | 
						|
		if (datastatoparziale > datasi)
 | 
						|
			datasi = datastatoparziale;
 | 
						|
	statoparziale = soggetto.get(SOG_STATOAF);
 | 
						|
	datastatoparziale = soggetto.get_date(SOG_DATAAF);
 | 
						|
	tipostato = modstato_tcs(statoparziale);
 | 
						|
	if (tipostato == 'S')
 | 
						|
		dataaf = NULLDATE;
 | 
						|
	if (tipostato == 'I')
 | 
						|
		if (datastatoparziale > dataaf)
 | 
						|
			dataaf = datastatoparziale;
 | 
						|
	soggetto.put(SOG_DATAPROSSI,datasi);
 | 
						|
	soggetto.put(SOG_DATAPROSAF,dataaf);
 | 
						|
	// se la data prossima SI è superiore all'ultima convocazione
 | 
						|
	// va cancellata, anche dall'archivio convocazioni
 | 
						|
	TDate dataconv = soggetto.get_date(SOG_DATACONV);
 | 
						|
	if (datasi >= dataconv)
 | 
						|
	{                                                   
 | 
						|
		TLocalisamfile rconv(LF_RCONVOC);
 | 
						|
	 	const long codsog = soggetto.get_long(SOG_CODICE);
 | 
						|
		rconv.setkey(2);
 | 
						|
		rconv.zero();
 | 
						|
		rconv.put(RCV_DATACONV, dataconv);
 | 
						|
		rconv.put(RCV_CODICE, codsog);
 | 
						|
		int err = rconv.read();
 | 
						|
		if (err == NOERR)
 | 
						|
		{
 | 
						|
			rconv.put(RCV_ANNULLATO,TRUE);
 | 
						|
			rconv.rewrite();
 | 
						|
		}							
 | 
						|
		soggetto.put(SOG_DATACONV, NULLDATE);
 | 
						|
		soggetto.put(SOG_DATAULTSOL, NULLDATE);
 | 
						|
		const int zeroconv = 0;
 | 
						|
		soggetto.put(SOG_NUMCONV, zeroconv);
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
void calcola_donazioni_lib(TRectype& soggetto, TRecord_array* donazioni)
 | 
						|
{
 | 
						|
	TDate ultdata(NULLDATE);
 | 
						|
	TString16 ulttipo = "  ";
 | 
						|
	const int i = donazioni->rows();
 | 
						|
	const int donprecsi = soggetto.get_int(SOG_DONPRECSI);
 | 
						|
	const int donprecaf = soggetto.get_int(SOG_DONPRECAF);	
 | 
						|
	if (i <= 0)	// non ha donazioni
 | 
						|
	{
 | 
						|
		int zerodon = 0;
 | 
						|
		soggetto.put(SOG_DATAULTDON,ultdata);
 | 
						|
		soggetto.put(SOG_DATAULTSI,ultdata);
 | 
						|
		soggetto.put(SOG_DATAULTAF,ultdata);
 | 
						|
		soggetto.put(SOG_TOTDONSI,donprecsi);
 | 
						|
		soggetto.put(SOG_TOTDONAF,donprecaf);
 | 
						|
		soggetto.put(SOG_TIPOULTDON,ulttipo);
 | 
						|
		soggetto.put(SOG_TOTDON,donprecsi+donprecaf);
 | 
						|
	}	
 | 
						|
	else	
 | 
						|
	{          
 | 
						|
		donazioni->sort(compare_date);
 | 
						|
		const TRectype& row = donazioni->row(i);
 | 
						|
		ultdata = row.get_date(DON_DATADON);
 | 
						|
		ulttipo = row.get(DON_TIPODON);
 | 
						|
		soggetto.put(SOG_DATAULTDON,ultdata);  			  	
 | 
						|
		soggetto.put(SOG_TIPOULTDON,ulttipo);  			  	
 | 
						|
		TDate dataultsi(NULLDATE);
 | 
						|
		TDate dataultaf(NULLDATE);
 | 
						|
		int totdonsi = 0;
 | 
						|
		int totdonaf = 0;        
 | 
						|
		for (int r=1; r<=donazioni->rows(); r++)
 | 
						|
		{
 | 
						|
			const TRectype& row = donazioni->row(r);
 | 
						|
			ultdata = row.get_date(DON_DATADON);
 | 
						|
			ulttipo = row.get(DON_TIPODON);
 | 
						|
			if (is_donaz(ulttipo,IDON_SI))
 | 
						|
			{
 | 
						|
				dataultsi = ultdata;
 | 
						|
				totdonsi++;
 | 
						|
			}
 | 
						|
			else
 | 
						|
				if (is_donaz(ulttipo,IDON_AF))
 | 
						|
				{
 | 
						|
					dataultaf = ultdata;
 | 
						|
					totdonaf++;
 | 
						|
				}
 | 
						|
		}					
 | 
						|
		soggetto.put(SOG_DATAULTSI, dataultsi);
 | 
						|
		soggetto.put(SOG_TOTDONSI, totdonsi+donprecsi);
 | 
						|
		soggetto.put(SOG_DATAULTAF, dataultaf);
 | 
						|
		soggetto.put(SOG_TOTDONAF, totdonaf+donprecaf);
 | 
						|
		
 | 
						|
		soggetto.put(SOG_TOTDON, totdonsi+donprecsi+totdonaf+donprecaf);
 | 
						|
	}		
 | 
						|
	don_datepross(soggetto);
 | 
						|
}
 | 
						|
 | 
						|
bool configura_stampante(TPrinter& p, const TString16& configurazione, const TString16& tipostampa)
 | 
						|
{
 | 
						|
  p.read_configuration(configurazione);
 | 
						|
  p.set_printtype(winprinter);
 | 
						|
  if (p.set())  
 | 
						|
  {
 | 
						|
  	TString80 messaggio = "Stampante configurata per stampa ";
 | 
						|
  	messaggio << tipostampa;
 | 
						|
		message_box(messaggio);    	
 | 
						|
		return TRUE;
 | 
						|
	}	
 | 
						|
	else           
 | 
						|
	{
 | 
						|
  	TString80 messaggio = "Operazione di stampa ";
 | 
						|
  	messaggio << tipostampa << " annullata";
 | 
						|
		message_box(messaggio);    	
 | 
						|
		return FALSE;
 | 
						|
	}
 | 
						|
} 
 |