1997-03-20 10:33:28 +00:00
|
|
|
|
#include <tabutil.h>
|
1999-01-26 14:09:41 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include "atlib.h"
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include "contsan.h"
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include "donaz.h"
|
1997-12-09 13:53:23 +00:00
|
|
|
|
#include "idoneita.h"
|
2001-11-06 09:48:07 +00:00
|
|
|
|
#include "rconvoc.h"
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
2002-10-24 08:58:42 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool is_idon_one(TString16 idon, const char* tipo)
|
1996-07-30 14:46:52 +00:00
|
|
|
|
// verifica che l'idoneit<69> "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;
|
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool is_idon(TString16 id1, TString16 id2, TString16 id3, TString16 id4, const char* tipo)
|
1996-07-30 14:46:52 +00:00
|
|
|
|
//verifica che almeno una delle "id" sia del tipo "tipo"
|
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
return (is_idon_one(id1,tipo) || is_idon_one(id2,tipo) || is_idon_one(id3,tipo) || is_idon_one(id4,tipo));
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool is_donaz(TString16 don, const char* tipo)
|
1996-07-30 14:46:52 +00:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-24 08:58:42 +00:00
|
|
|
|
char modstato_tcs(const TString16 tipo)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
// verifica se il controllo sanitario "tipo" e' un controllo che modifica
|
|
|
|
|
// lo stato del soggetto
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
|
|
|
|
char modstato = ' ';
|
|
|
|
|
TTable tcs("TCS");
|
|
|
|
|
tcs.put("CODTAB",tipo);
|
|
|
|
|
if (tcs.read() == NOERR)
|
|
|
|
|
modstato = tcs.get_char("S6");
|
|
|
|
|
return modstato;
|
|
|
|
|
}
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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 = " ";
|
1997-03-20 10:33:28 +00:00
|
|
|
|
char modstato = ' ';
|
1998-02-04 13:46:27 +00:00
|
|
|
|
int r_ultid = -1; // riga ultima idoneit<69>
|
|
|
|
|
int r_ultstato = -1; // riga ultimo stato valido
|
1997-03-20 10:33:28 +00:00
|
|
|
|
char penultstato = ' '; // penultimo stato valido
|
|
|
|
|
char ultstato = ' '; // ultimo stato valido
|
|
|
|
|
TDate dataultstato(NULLDATE); // data ultimo stato valido
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
for (int r=controlli->rows(); r>0; r--)
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
|
|
|
|
const TRectype& row = controlli->row(r);
|
|
|
|
|
tipo = row.get(CON_TIPOCON);
|
|
|
|
|
modstato = modstato_tcs(tipo);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if ((modstato != 'N') && (r_ultstato == -1))
|
1997-03-20 10:33:28 +00:00
|
|
|
|
r_ultstato = r;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
else if ((modstato != 'N') && (penultstato == ' '))
|
1997-03-20 10:33:28 +00:00
|
|
|
|
penultstato = modstato;
|
|
|
|
|
if ((modstato == 'I') && (r_ultid == -1))
|
|
|
|
|
r_ultid = r;
|
|
|
|
|
}
|
2001-10-22 09:07:33 +00:00
|
|
|
|
TString16 id1 = " ";
|
|
|
|
|
TString16 id2 = " ";
|
|
|
|
|
TString16 id3 = " ";
|
|
|
|
|
TString16 id4 = " ";
|
1997-03-20 10:33:28 +00:00
|
|
|
|
int intsi = 0;
|
|
|
|
|
int intaf = 0;
|
2001-10-22 09:07:33 +00:00
|
|
|
|
tipo = " ";
|
|
|
|
|
prosstipo = " ";
|
1997-03-20 10:33:28 +00:00
|
|
|
|
data = TDate(NULLDATE);
|
1997-06-17 15:50:08 +00:00
|
|
|
|
prossdata = TDate(NULLDATE);
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
if (r_ultid != -1)
|
|
|
|
|
{
|
1997-06-17 15:50:08 +00:00
|
|
|
|
const TRectype& row = controlli->row(r_ultid);
|
1997-03-20 10:33:28 +00:00
|
|
|
|
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);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (intsi > 0)
|
1997-12-09 13:53:23 +00:00
|
|
|
|
soggetto.put(SOG_INTSI,intsi);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (intaf > 0)
|
1997-12-09 13:53:23 +00:00
|
|
|
|
soggetto.put(SOG_INTAF,intaf);
|
2001-10-22 09:07:33 +00:00
|
|
|
|
tipo = " ";
|
1997-03-20 10:33:28 +00:00
|
|
|
|
if (r_ultstato != -1)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& row = controlli->row(r_ultstato);
|
|
|
|
|
dataultstato = TDate(row.get(CON_DATACON));
|
|
|
|
|
tipo = row.get(CON_TIPOCON);
|
1997-06-17 15:50:08 +00:00
|
|
|
|
prosstipo = row.get(CON_PROSSTIPO);
|
|
|
|
|
prossdata = TDate(row.get(CON_PROSSDATA));
|
1997-03-20 10:33:28 +00:00
|
|
|
|
ultstato = modstato_tcs(tipo);
|
|
|
|
|
}
|
|
|
|
|
soggetto.put(SOG_STATO,tipo);
|
|
|
|
|
soggetto.put(SOG_DATASTATO,dataultstato);
|
1997-06-17 15:50:08 +00:00
|
|
|
|
soggetto.put(SOG_PROS_STATO,prosstipo);
|
|
|
|
|
soggetto.put(SOG_DATA_PROS,prossdata);
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
1998-02-25 07:50:36 +00:00
|
|
|
|
/*
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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);
|
1998-02-25 07:50:36 +00:00
|
|
|
|
*/
|
|
|
|
|
if (intsi > 0)
|
|
|
|
|
{
|
|
|
|
|
soggetto.put(SOG_STATOSI, tipo);
|
|
|
|
|
soggetto.put(SOG_DATASI, dataultstato);
|
1999-03-15 10:56:56 +00:00
|
|
|
|
//if (prosstipo == "FS")
|
|
|
|
|
if (modstato_tcs(prosstipo)=='F')
|
1998-07-03 13:02:45 +00:00
|
|
|
|
soggetto.put(SOG_FINESOSSI, prossdata);
|
|
|
|
|
else
|
|
|
|
|
soggetto.put(SOG_FINESOSSI, datanulla);
|
1998-02-25 07:50:36 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
1999-03-15 10:56:56 +00:00
|
|
|
|
//if (prosstipo == "FS")
|
|
|
|
|
if (modstato_tcs(prosstipo)=='F')
|
1998-07-03 13:02:45 +00:00
|
|
|
|
soggetto.put(SOG_FINESOSAF, prossdata);
|
|
|
|
|
else
|
|
|
|
|
soggetto.put(SOG_FINESOSAF, datanulla);
|
1998-02-25 07:50:36 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
soggetto.put(SOG_STATOAF, " ");
|
|
|
|
|
soggetto.put(SOG_DATAAF, datanulla);
|
|
|
|
|
soggetto.put(SOG_FINESOSAF, datanulla);
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
|
|
|
|
|
// riordino le idoneita
|
|
|
|
|
for (int ri=1; ri<=idoneita->rows(); ri++)
|
1997-12-09 13:53:23 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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);
|
2003-08-08 13:24:47 +00:00
|
|
|
|
if ((dataido >= dataultstato) || (ultstato) == 'F')
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
|
|
|
|
if (tipoido == IDON_SI)
|
2003-08-08 13:24:47 +00:00
|
|
|
|
{
|
1997-12-09 13:53:23 +00:00
|
|
|
|
soggetto.put(SOG_DATASI,dataido);
|
|
|
|
|
soggetto.put(SOG_STATOSI,ido_sos);
|
|
|
|
|
soggetto.put(SOG_FINESOSSI,finesos);
|
|
|
|
|
if (intervallo != 0 && ido_sos == IDONEITA)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1997-12-09 13:53:23 +00:00
|
|
|
|
soggetto.put(SOG_INTSI,intervallo);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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)
|
1997-12-09 13:53:23 +00:00
|
|
|
|
{
|
|
|
|
|
soggetto.put(SOG_DATAAF,dataido);
|
|
|
|
|
soggetto.put(SOG_STATOAF,ido_sos);
|
|
|
|
|
soggetto.put(SOG_FINESOSAF,finesos);
|
|
|
|
|
if (intervallo != 0 && ido_sos == IDONEITA)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1997-12-09 13:53:23 +00:00
|
|
|
|
soggetto.put(SOG_INTAF,intervallo);
|
1998-09-25 13:12:07 +00:00
|
|
|
|
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);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-12-09 13:53:23 +00:00
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
// 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())
|
1997-12-09 13:53:23 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TString16 stato = soggetto.get(SOG_STATO);
|
|
|
|
|
char modstato = modstato_tcs(stato);
|
1999-03-15 10:56:56 +00:00
|
|
|
|
const char tipostatosi = modstato_tcs(statosi);
|
|
|
|
|
const char tipostatoaf = modstato_tcs(statoaf);
|
|
|
|
|
if ((tipostatosi == 'I') || (tipostatoaf == 'I'))
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if ((modstato != 'I') || (modstato != 'F'))
|
|
|
|
|
stato = IDONEITA;
|
1999-03-15 10:56:56 +00:00
|
|
|
|
if ((tipostatosi == 'S') && (tipostatoaf == 'S'))
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (modstato != 'S')
|
1999-03-15 10:56:56 +00:00
|
|
|
|
stato == statosi;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
char statocalcolato = modstato_tcs(stato);
|
|
|
|
|
if (modstato != statocalcolato)
|
1997-12-09 13:53:23 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-03-09 13:29:22 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
don_datepross(soggetto);
|
|
|
|
|
|
|
|
|
|
if (((penultstato == 'S') || (penultstato == 'I')) && ((ultstato == 'I') || (ultstato == 'F')))
|
1997-12-09 13:53:23 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
1997-12-09 13:53:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
void don_datepross(TRectype& soggetto)
|
|
|
|
|
// calcola le date di prossima donazione in base a: donazioni, stato attuale, idoneit<69>
|
|
|
|
|
{
|
|
|
|
|
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 <20> idoneo per si?
|
|
|
|
|
bool id_af = FALSE; // il soggetto <20> idoneo per af?
|
|
|
|
|
|
|
|
|
|
modstato = modstato_tcs(stato);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (modstato == 'I' || modstato == 'F') // il soggetto <20> idoneo
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (soggetto.get(SOG_STATOSI) == IDONEITA)) && (intsi != 0)); // il soggetto <20> idoneo SI
|
|
|
|
|
id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (soggetto.get(SOG_STATOAF) == IDONEITA)) && (intaf != 0)); // il soggetto <20> idoneo AF
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
if (dataultdon.ok()) // se ha fatto almeno una donazione
|
|
|
|
|
{
|
|
|
|
|
if (is_donaz(tipoultdon,IDON_SI)) // se l'ultima donazione <20> 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 <20> 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TString16 statoparziale;
|
|
|
|
|
TDate datastatoparziale;
|
1999-03-15 10:56:56 +00:00
|
|
|
|
char tipostato;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
statoparziale = soggetto.get(SOG_STATOSI);
|
|
|
|
|
datastatoparziale = soggetto.get_date(SOG_DATASI);
|
1999-03-15 10:56:56 +00:00
|
|
|
|
tipostato = modstato_tcs(statoparziale);
|
|
|
|
|
if (tipostato == 'S')
|
1998-02-04 13:46:27 +00:00
|
|
|
|
datasi = NULLDATE;
|
1999-03-15 10:56:56 +00:00
|
|
|
|
if (tipostato == 'I')
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (datastatoparziale > datasi)
|
|
|
|
|
datasi = datastatoparziale;
|
|
|
|
|
statoparziale = soggetto.get(SOG_STATOAF);
|
|
|
|
|
datastatoparziale = soggetto.get_date(SOG_DATAAF);
|
1999-03-15 10:56:56 +00:00
|
|
|
|
tipostato = modstato_tcs(statoparziale);
|
|
|
|
|
if (tipostato == 'S')
|
1998-02-04 13:46:27 +00:00
|
|
|
|
dataaf = NULLDATE;
|
2002-03-13 12:27:20 +00:00
|
|
|
|
if (tipostato == 'I')
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (datastatoparziale > dataaf)
|
|
|
|
|
dataaf = datastatoparziale;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
soggetto.put(SOG_DATAPROSSI,datasi);
|
|
|
|
|
soggetto.put(SOG_DATAPROSAF,dataaf);
|
2001-11-06 09:48:07 +00:00
|
|
|
|
// se la data prossima SI <20> 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);
|
|
|
|
|
}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
void calcola_donazioni_lib(TRectype& soggetto, TRecord_array* donazioni)
|
|
|
|
|
{
|
|
|
|
|
TDate ultdata(NULLDATE);
|
2001-10-22 09:07:33 +00:00
|
|
|
|
TString16 ulttipo = " ";
|
1998-02-04 13:46:27 +00:00
|
|
|
|
const int i = donazioni->rows();
|
|
|
|
|
const int donprecsi = soggetto.get_int(SOG_DONPRECSI);
|
|
|
|
|
const int donprecaf = soggetto.get_int(SOG_DONPRECAF);
|
1999-04-08 11:03:45 +00:00
|
|
|
|
if (i <= 0) // non ha donazioni
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
1999-04-08 11:03:45 +00:00
|
|
|
|
soggetto.put(SOG_TOTDON,donprecsi+donprecaf);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2002-10-24 08:58:42 +00:00
|
|
|
|
{
|
|
|
|
|
donazioni->sort(compare_date);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-08 09:23:45 +00:00
|
|
|
|
bool configura_stampante(TPrinter& p, const char* configurazione, const char* tipostampa)
|
|
|
|
|
{
|
|
|
|
|
TString cfg = configurazione;
|
|
|
|
|
cfg << '_' << user();
|
|
|
|
|
p.read_configuration(cfg);
|
1999-01-26 14:09:41 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|