1999-04-08 10:57:04 +00:00
|
|
|
#include <applicat.h>
|
2007-03-30 13:51:17 +00:00
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
#include "atlib.h"
|
1999-04-08 10:57:04 +00:00
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
#include "at5.h"
|
1999-04-08 10:57:04 +00:00
|
|
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
#include "donaz.h"
|
|
|
|
#include "contsan.h"
|
|
|
|
#include "idoneita.h"
|
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
class TRiordinaSog : public TApplication
|
|
|
|
{
|
1999-04-08 10:57:04 +00:00
|
|
|
TLocalisamfile* _soggetti;
|
2002-10-31 13:50:41 +00:00
|
|
|
TLocalisamfile* _donaz;
|
|
|
|
TLocalisamfile* _contsan;
|
|
|
|
TLocalisamfile* _idoneita;
|
1999-04-08 10:57:04 +00:00
|
|
|
TRecord_array* _sdonazioni;
|
|
|
|
TRecord_array* _scontrolli;
|
|
|
|
TRecord_array* _sidoneita;
|
2002-10-31 13:50:41 +00:00
|
|
|
|
1999-04-08 10:57:04 +00:00
|
|
|
protected:
|
2002-10-31 13:50:41 +00:00
|
|
|
virtual bool create();
|
|
|
|
virtual bool destroy();
|
1999-04-08 10:57:04 +00:00
|
|
|
public:
|
2002-10-31 13:50:41 +00:00
|
|
|
TRiordinaSog() {}
|
|
|
|
virtual ~TRiordinaSog() {}
|
1999-04-08 10:57:04 +00:00
|
|
|
};
|
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
bool TRiordinaSog::create()
|
1999-04-08 10:57:04 +00:00
|
|
|
{
|
2002-10-31 13:50:41 +00:00
|
|
|
TApplication::create();
|
|
|
|
|
|
|
|
if (argc() < 3)
|
|
|
|
return error_box("Specificare il codice del soggetto");
|
|
|
|
long codsog = atol(argv(2));
|
|
|
|
_soggetti = new TLocalisamfile(LF_SOGGETTI);
|
|
|
|
_donaz = new TLocalisamfile(LF_DONAZ);
|
|
|
|
_contsan = new TLocalisamfile(LF_CONTSAN);
|
|
|
|
_idoneita = new TLocalisamfile(LF_IDONEITA);
|
1999-04-08 10:57:04 +00:00
|
|
|
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
|
|
|
|
_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
|
2002-10-31 13:50:41 +00:00
|
|
|
_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
|
1999-04-08 10:57:04 +00:00
|
|
|
TConfig config(CONFIG_STUDIO);
|
2002-10-31 13:50:41 +00:00
|
|
|
const int numdon1 = config.get_int("NumDon1");
|
|
|
|
const int numdon2 = config.get_int("NumDon2");
|
|
|
|
TString16 catini1 = config.get("CatIni1");
|
|
|
|
TString16 catfin1 = config.get("CatFin1");
|
|
|
|
TString16 catini2 = config.get("CatIni2");
|
|
|
|
TString16 catfin2 = config.get("CatFin2");
|
|
|
|
const bool sttess2 = config.get_bool("StTess2");
|
|
|
|
const bool dataisc = config.get_bool("DataIsc");
|
|
|
|
const int etadonne = config.get_int("EtaDonne");
|
|
|
|
const int intsi_f1 = config.get_int("IntSI_F1");
|
|
|
|
const int intsi_f2 = config.get_int("IntSI_F2");
|
|
|
|
const int intsi_m = config.get_int("IntSI_M");
|
|
|
|
const int intaf_m = config.get_int("IntAF_M");
|
|
|
|
TRectype soggetto(LF_SOGGETTI);
|
|
|
|
_soggetti->put(SOG_CODICE, codsog);
|
|
|
|
if (_soggetti->read() == NOERR)
|
|
|
|
{
|
|
|
|
TRectype& sog = _soggetti->curr();
|
|
|
|
TRectype* key = new TRectype(LF_DONAZ);
|
|
|
|
key->put(DON_CODICE, codsog);
|
|
|
|
int err = _sdonazioni->read(key);
|
|
|
|
if (err == NOERR)
|
1999-04-08 10:57:04 +00:00
|
|
|
{
|
2002-10-31 13:50:41 +00:00
|
|
|
calcola_donazioni_lib(sog, _sdonazioni);
|
|
|
|
_sdonazioni->rewrite();
|
|
|
|
_soggetti->rewrite();
|
|
|
|
}
|
|
|
|
TString16 catdon = sog.get(SOG_CATDON);
|
|
|
|
const int totdon = sog.get_int(SOG_TOTDON);
|
|
|
|
const TRectype& ctd = cache().get("CTD", catdon);
|
|
|
|
const bool dimissione = ctd.get_bool("B0");
|
|
|
|
if (dimissione)
|
|
|
|
{
|
|
|
|
const TString16 catcoll = ctd.get("S6");
|
|
|
|
if (catcoll.not_empty())
|
1999-04-08 10:57:04 +00:00
|
|
|
{
|
2002-10-31 13:50:41 +00:00
|
|
|
sog.put(SOG_CATDON, catcoll);
|
|
|
|
catdon = catcoll;
|
1999-04-08 10:57:04 +00:00
|
|
|
}
|
2002-10-31 13:50:41 +00:00
|
|
|
}
|
|
|
|
if ((catdon == catini1 || catini1.empty()) && (totdon==numdon1) && catfin1.not_empty())
|
|
|
|
sog.put(SOG_CATDON, catfin1);
|
|
|
|
if ((catdon == catini2 || catini2.empty()) && (totdon>=numdon2) && catfin2.not_empty() && (!sttess2 || dimissione))
|
|
|
|
sog.put(SOG_CATDON, catfin2);
|
|
|
|
TDate dataiscsog = sog.get_date(SOG_DATAISC);
|
|
|
|
if (!dataiscsog.ok() && dataisc)
|
|
|
|
{
|
|
|
|
if (!sog.get_date(SOG_DATAPRISI) == NULLDATE)
|
|
|
|
sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI));
|
1999-04-08 10:57:04 +00:00
|
|
|
else
|
2002-10-31 13:50:41 +00:00
|
|
|
{
|
|
|
|
const TRectype& riga = _sdonazioni->row(1);
|
|
|
|
sog.put(SOG_DATAISC,riga.get(DON_DATADON));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_soggetti->rewrite();
|
1999-04-08 10:57:04 +00:00
|
|
|
}
|
2002-10-31 13:50:41 +00:00
|
|
|
stop_run();
|
|
|
|
return TRUE;
|
1999-04-08 10:57:04 +00:00
|
|
|
}
|
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
bool TRiordinaSog::destroy()
|
|
|
|
{
|
|
|
|
delete _sidoneita;
|
|
|
|
delete _scontrolli;
|
|
|
|
delete _sdonazioni;
|
|
|
|
delete _idoneita;
|
|
|
|
delete _contsan;
|
|
|
|
delete _donaz;
|
|
|
|
delete _soggetti;
|
|
|
|
return TApplication::destroy();
|
|
|
|
}
|
1999-04-08 10:57:04 +00:00
|
|
|
|
2002-10-31 13:50:41 +00:00
|
|
|
int at5400(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TRiordinaSog a;
|
|
|
|
a.run(argc, argv, "Riordina donazioni soggetto");
|
|
|
|
return 0;
|
|
|
|
}
|