Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            : corretto calcolo stato e controlli sulle convocazioni nel giornaliero don./con.


git-svn-id: svn://10.65.10.50/trunk@9223 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2000-10-10 07:54:45 +00:00
parent b3cd9c64a9
commit 97270ae0c0

View File

@ -460,271 +460,276 @@ int TGiornalieroDC::write(TSheet_field& s)
if (!exist) if (!exist)
{ {
err = _sdonazioni->write(TRUE); err = _sdonazioni->write(TRUE);
// controllo se è idoneo if (err == NOERR)
bool ctrlsi = FALSE; //devo controllare se è idoneo SI {
bool ctrlaf = FALSE; //devo controllare se è idoneo AF // controllo se è idoneo
bool id_si = FALSE; // il soggetto è idoneo per si? bool ctrlsi = FALSE; //devo controllare se è idoneo SI
bool id_af = FALSE; // il soggetto è idoneo per af? bool ctrlaf = FALSE; //devo controllare se è idoneo AF
char modstato = ' '; bool id_si = FALSE; // il soggetto è idoneo per si?
TString16 stato = sog.get(SOG_STATO); // stato attuale bool id_af = FALSE; // il soggetto è idoneo per af?
TString16 statosi = sog.get(SOG_STATOSI); // stato attuale SI char modstato = ' ';
TString16 statoaf = sog.get(SOG_STATOAF); // stato attuale AF TString16 stato = sog.get(SOG_STATO); // stato attuale
TString16 id1 = sog.get(SOG_IDON1); // idon. 1 TString16 statosi = sog.get(SOG_STATOSI); // stato attuale SI
TString16 id2 = sog.get(SOG_IDON2); // idon. 2 TString16 statoaf = sog.get(SOG_STATOAF); // stato attuale AF
TString16 id3 = sog.get(SOG_IDON3); // idon. 3 TString16 id1 = sog.get(SOG_IDON1); // idon. 1
TString16 id4 = sog.get(SOG_IDON4); // idon. 4 TString16 id2 = sog.get(SOG_IDON2); // idon. 2
int intsi = sog.get_int(SOG_INTSI); // intervallo per SI TString16 id3 = sog.get(SOG_IDON3); // idon. 3
int intaf = sog.get_int(SOG_INTAF); // intervallo per AF TString16 id4 = sog.get(SOG_IDON4); // idon. 4
//id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (statosi == "ID")) && intsi != 0); // il soggetto è idoneo SI int intsi = sog.get_int(SOG_INTSI); // intervallo per SI
//id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (statoaf == "ID")) && intaf != 0); // il soggetto è idoneo AF int intaf = sog.get_int(SOG_INTAF); // intervallo per AF
id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI //id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (statosi == "ID")) && intsi != 0); // il soggetto è idoneo SI
id_af = ((statoaf == "ID") && (intaf != 0)); // il soggetto è idoneo AF //id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (statoaf == "ID")) && intaf != 0); // il soggetto è idoneo AF
int totdon = sog.get_int(SOG_TOTDON);
TDate dataultdon = sog.get_date(SOG_DATAULTDON);
sog.put(SOG_TOTDON,totdon+1);
if (datadonazione > dataultdon)
{
sog.put(SOG_DATAULTDON,datadonazione);
sog.put(SOG_TIPOULTDON,tipodon);
}
if (is_donaz(tipodon,IDON_SI))
{
ctrlsi = TRUE;
totdon = sog.get_int(SOG_TOTDONSI);
sog.put(SOG_TOTDONSI,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTSI);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTSI,datadonazione);
}
if (is_donaz(tipodon,IDON_AF))
{
ctrlaf = TRUE;
totdon = sog.get_int(SOG_TOTDONAF);
sog.put(SOG_TOTDONAF,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTAF);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTAF,datadonazione);
}
dataultdon = sog.get_date(SOG_DATAULTDON); // data ultima donazione
const TString16 tipoultdon = (sog.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
modstato = modstato_tcs(stato);
// il soggetto è idoneo per il tipo di donazione ?
if ((ctrlsi) && (!id_si) && (_autoid) && (modstato!='B'))
{
TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "SI");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTSI));
if (sog.get_int(SOG_INTSI) == 0)
{
const TString16 sesso = sog.get(SOG_SESSO);
if (sesso == "2")
{
TDate datanasc = sog.get_date(SOG_DATANASC);
int eta = datadonazione.year() - datanasc.year();
if(eta <= _etadonne)
recido.put(IDO_INTERVALLO, _intsi_f1);
else
recido.put(IDO_INTERVALLO, _intsi_f2);
}
else
recido.put(IDO_INTERVALLO, _intsi_m);
}
_sidoneita->add_row(recido);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
if ((ctrlaf) && (!id_af) && (_autoid) && (modstato!='B'))
{
TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "AF");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTAF));
if (sog.get_int(SOG_INTAF) == 0)
recido.put(IDO_INTERVALLO, _intaf_m);
_sidoneita->add_row(recido);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
sog.get(SOG_STATO); // stato attuale
statosi = sog.get(SOG_STATOSI); // stato attuale SI
statoaf = sog.get(SOG_STATOAF); // stato attuale AF
id1 = sog.get(SOG_IDON1); // idon. 1
id2 = sog.get(SOG_IDON2); // idon. 2
id3 = sog.get(SOG_IDON3); // idon. 3
id4 = sog.get(SOG_IDON4); // idon. 4
intsi = sog.get_int(SOG_INTSI); // intervallo per SI
intaf = sog.get_int(SOG_INTAF); // intervallo per AF
modstato = modstato_tcs(stato);
if (modstato == 'I' || modstato == 'F') // il soggetto è idoneo
{
//id_si = (is_idon(id1,id2,id3,id4,IDON_SI) && intsi != 0); // il soggetto è idoneo SI
//id_af = (is_idon(id1,id2,id3,id4,IDON_AF) && intaf != 0); // il soggetto è idoneo AF
id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI
id_af = ((statoaf == "ID") && (intaf != 0)); // il soggetto è idoneo AF id_af = ((statoaf == "ID") && (intaf != 0)); // il soggetto è idoneo AF
int totdon = sog.get_int(SOG_TOTDON);
TDate dataultdon = sog.get_date(SOG_DATAULTDON);
sog.put(SOG_TOTDON,totdon+1);
if (datadonazione > dataultdon)
{
sog.put(SOG_DATAULTDON,datadonazione);
sog.put(SOG_TIPOULTDON,tipodon);
}
if (is_donaz(tipodon,IDON_SI))
{
ctrlsi = TRUE;
totdon = sog.get_int(SOG_TOTDONSI);
sog.put(SOG_TOTDONSI,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTSI);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTSI,datadonazione);
}
if (is_donaz(tipodon,IDON_AF))
{
ctrlaf = TRUE;
totdon = sog.get_int(SOG_TOTDONAF);
sog.put(SOG_TOTDONAF,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTAF);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTAF,datadonazione);
}
dataultdon = sog.get_date(SOG_DATAULTDON); // data ultima donazione
const TString16 tipoultdon = (sog.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
if (dataultdon.ok()) // se ha fatto almeno una donazione modstato = modstato_tcs(stato);
{ // il soggetto è idoneo per il tipo di donazione ?
if (is_donaz(tipoultdon,IDON_SI)) // se l'ultima donazione è una SI if ((ctrlsi) && (!id_si) && (_autoid) && (modstato!='B'))
{ {
if (id_si) TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "SI");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTSI));
if (sog.get_int(SOG_INTSI) == 0)
{
const TString16 sesso = sog.get(SOG_SESSO);
if (sesso == "2")
{ {
datasi=dataultdon; TDate datanasc = sog.get_date(SOG_DATANASC);
datasi+=intsi; int eta = datadonazione.year() - datanasc.year();
} if(eta <= _etadonne)
if (id_af) recido.put(IDO_INTERVALLO, _intsi_f1);
{
dataaf=dataultdon;
dataaf+=intaf;
}
}
if (is_donaz(tipoultdon,IDON_AF)) // se l'ultima donazione è una AF
{
dataultsi = sog.get_date(SOG_DATAULTSI);
if (id_si)
{
if (intaf != 0)
{
datasi=dataultdon;
datasi+=intaf;
}
else else
recido.put(IDO_INTERVALLO, _intsi_f2);
}
else
recido.put(IDO_INTERVALLO, _intsi_m);
}
_sidoneita->add_row(recido);
err = _sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
if ((ctrlaf) && (!id_af) && (_autoid) && (modstato!='B'))
{
TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "AF");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTAF));
if (sog.get_int(SOG_INTAF) == 0)
recido.put(IDO_INTERVALLO, _intaf_m);
_sidoneita->add_row(recido);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
sog.get(SOG_STATO); // stato attuale
statosi = sog.get(SOG_STATOSI); // stato attuale SI
statoaf = sog.get(SOG_STATOAF); // stato attuale AF
id1 = sog.get(SOG_IDON1); // idon. 1
id2 = sog.get(SOG_IDON2); // idon. 2
id3 = sog.get(SOG_IDON3); // idon. 3
id4 = sog.get(SOG_IDON4); // idon. 4
intsi = sog.get_int(SOG_INTSI); // intervallo per SI
intaf = sog.get_int(SOG_INTAF); // intervallo per AF
modstato = modstato_tcs(stato);
if (modstato == 'I' || modstato == 'F') // il soggetto è idoneo
{
//id_si = (is_idon(id1,id2,id3,id4,IDON_SI) && intsi != 0); // il soggetto è idoneo SI
//id_af = (is_idon(id1,id2,id3,id4,IDON_AF) && intaf != 0); // il soggetto è idoneo AF
id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI
id_af = ((statoaf == "ID") && (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=dataultdon;
datasi+=intsi; datasi+=intsi;
} }
if (dataultsi.ok()) if (id_af)
dataultsi+=intsi; {
if (dataultsi > datasi) dataaf=dataultdon;
datasi = dataultsi; dataaf+=intaf;
} }
if (id_af) }
{ if (is_donaz(tipoultdon,IDON_AF)) // se l'ultima donazione è una AF
dataaf=dataultdon; {
dataaf+=intaf; dataultsi = sog.get_date(SOG_DATAULTSI);
} if (id_si)
} {
} if (intaf != 0)
else {
{ datasi=dataultdon;
if (id_si) datasi+=intaf;
datasi=sog.get_date(SOG_DATAULTID); }
if (id_af) else
dataaf=sog.get_date(SOG_DATAULTID); {
} datasi=dataultdon;
} datasi+=intsi;
sog.put(SOG_DATAPROSSI,datasi); }
sog.put(SOG_DATAPROSAF,dataaf); if (dataultsi.ok())
dataultsi+=intsi;
// se la data prossima SI è superiore all'ultima convocazione if (dataultsi > datasi)
// va cancellata, anche dall'archivio convocazioni datasi = dataultsi;
TDate dataprossi = sog.get_date(SOG_DATAPROSSI); }
TDate dataconv = sog.get_date(SOG_DATACONV); if (id_af)
if (dataprossi >= dataconv) {
{ dataaf=dataultdon;
rconv.setkey(2); dataaf+=intaf;
rconv.zero(); }
rconv.put(RCV_DATACONV, dataconv); }
rconv.put(RCV_CODICE, codsog); }
int err = rconv.read(); else
if (err == NOERR) {
if (id_si)
datasi=sog.get_date(SOG_DATAULTID);
if (id_af)
dataaf=sog.get_date(SOG_DATAULTID);
}
}
sog.put(SOG_DATAPROSSI,datasi);
sog.put(SOG_DATAPROSAF,dataaf);
// se la data prossima SI è superiore all'ultima convocazione
// va cancellata, anche dall'archivio convocazioni
TDate dataprossi = sog.get_date(SOG_DATAPROSSI);
TDate dataconv = sog.get_date(SOG_DATACONV);
if (dataprossi >= dataconv)
{ {
rconv.put(RCV_ANNULLATO,TRUE); rconv.setkey(2);
rconv.rewrite(); rconv.zero();
} rconv.put(RCV_DATACONV, dataconv);
sog.put(SOG_DATACONV, NULLDATE); rconv.put(RCV_CODICE, codsog);
sog.put(SOG_DATAULTSOL, NULLDATE); int err = rconv.read();
const int zeroconv = 0; if (err == NOERR)
sog.put(SOG_NUMCONV, zeroconv); {
} rconv.put(RCV_ANNULLATO,TRUE);
// controllo la sua categoria rconv.rewrite();
// se dimesso diventa della categoria collegata }
// se non c'e' la categoria collegata ??? sog.put(SOG_DATACONV, NULLDATE);
TTable ctd("CTD"); sog.put(SOG_DATAULTSOL, NULLDATE);
TString16 catdon = sog.get(SOG_CATDON); const int zeroconv = 0;
ctd.put("CODTAB",catdon); sog.put(SOG_NUMCONV, zeroconv);
if (ctd.read() == NOERR) }
{ // controllo la sua categoria
bool dimissione = ctd.get_bool("B0"); // se dimesso diventa della categoria collegata
if (dimissione) // se non c'e' la categoria collegata ???
{ TTable ctd("CTD");
sog.put(SOG_CATDON,ctd.get("S6")); TString16 catdon = sog.get(SOG_CATDON);
if (ctd.get("S6").not_empty()) ctd.put("CODTAB",catdon);
catdon = ctd.get("S6"); if (ctd.read() == NOERR)
sog.put(SOG_DATADIM,NULLDATE); {
} bool dimissione = ctd.get_bool("B0");
if ((catdon == _catini1 || _catini1.empty()) && (totdon+1>=_numdon1) && _catfin1.not_empty()) if (dimissione)
sog.put(SOG_CATDON, _catfin1); {
const bool tstampata = sog.get_bool(SOG_T_STAMPATA); sog.put(SOG_CATDON,ctd.get("S6"));
if ((catdon == _catini2 || _catini2.empty()) && (totdon+1>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata)) if (ctd.get("S6").not_empty())
sog.put(SOG_CATDON, _catfin2); catdon = ctd.get("S6");
} sog.put(SOG_DATADIM,NULLDATE);
TDate dataisc = sog.get_date(SOG_DATAISC); }
if (!dataisc.ok() && _dataisc) if ((catdon == _catini1 || _catini1.empty()) && (totdon+1>=_numdon1) && _catfin1.not_empty())
{ sog.put(SOG_CATDON, _catfin1);
if (sog.get_date(SOG_DATAPRISI).ok()) const bool tstampata = sog.get_bool(SOG_T_STAMPATA);
sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI)); if ((catdon == _catini2 || _catini2.empty()) && (totdon+1>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata))
sog.put(SOG_CATDON, _catfin2);
}
TDate dataisc = sog.get_date(SOG_DATAISC);
if (!dataisc.ok() && _dataisc)
{
if (sog.get_date(SOG_DATAPRISI).ok())
sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI));
else
{
const TRectype& riga = _sdonazioni->row(1);
sog.put(SOG_DATAISC,riga.get(DON_DATADON));
}
}
// aggiorno data e utente ultimo aggiornamento
const TDate oggi(TODAY);
sog.put(SOG_DATAULTAGG,oggi);
sog.put(SOG_UTENULTAGG,user());
if (err == NOERR)
sog.rewrite();
else else
{ {
const TRectype& riga = _sdonazioni->row(1); error_box("Errore %d in scrittura archivio soggetti, riga %d", err, rigasog);
sog.put(SOG_DATAISC,riga.get(DON_DATADON)); break;
} }
} }
// aggiorno data e utente ultimo aggiornamento
const TDate oggi(TODAY);
sog.put(SOG_DATAULTAGG,oggi);
sog.put(SOG_UTENULTAGG,user());
if (err == NOERR)
sog.rewrite();
else else
{ error_box("Errore %d in scrittura archivio donazioni, riga %d", err, rigasog);
error_box("Errore %d durante la scrittura della riga %d", err, rigasog); }
break;
}
}
} }
} }
} }