Files correlati : Ricompilazione Demo : [ ] Commento : corretto nome programma git-svn-id: svn://10.65.10.50/trunk@9241 c028cbd2-c16b-5b4b-a496-9718f37d4682
375 lines
11 KiB
C++
Executable File
375 lines
11 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <execp.h>
|
|
#include <mask.h>
|
|
#include <msksheet.h>
|
|
#include <mailbox.h>
|
|
#include <prefix.h>
|
|
#include <progind.h>
|
|
#include <recarray.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <urldefid.h>
|
|
#include <validate.h>
|
|
#include <lffiles.h>
|
|
|
|
#include "at8.h"
|
|
|
|
// nomi campi maschera
|
|
#include "atlib.h"
|
|
|
|
// nomi dei campi
|
|
#include "soggetti.h"
|
|
#include "donaz.h"
|
|
#include "contsan.h"
|
|
#include "idoneita.h"
|
|
#include "rconvoc.h"
|
|
|
|
class TCTStato2AT : public TApplication
|
|
{
|
|
TMask* _msk;
|
|
TRelation* _rel;
|
|
|
|
TLocalisamfile* _soggetti;
|
|
TLocalisamfile* _donaz;
|
|
TLocalisamfile* _contsan;
|
|
TLocalisamfile* _idoneita;
|
|
TRecord_array* _sdonazioni;
|
|
TRecord_array* _scontrolli;
|
|
TRecord_array* _sidoneita;
|
|
// parametri di sezione
|
|
int _intsi_f1, _intsi_f2, _intsi_m, _intaf_m, _etadonne;
|
|
int _numdon1, _numdon2;
|
|
TString16 _catini1, _catfin1, _catini2, _catfin2, _motivoid;
|
|
bool _sttess2, _dataisc, _nomessage, _autoid;
|
|
|
|
|
|
protected:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual bool menu(MENU_TAG m);
|
|
virtual TMask& get_mask() { return *_msk; }
|
|
virtual TRelation* get_relation() const { return _rel; }
|
|
|
|
int write(TSheet_field& s);
|
|
|
|
public:
|
|
TCTStato2AT() {}
|
|
|
|
};
|
|
|
|
HIDDEN inline TCTStato2AT& app() { return (TCTStato2AT&) main_app(); }
|
|
|
|
bool TCTStato2AT::create()
|
|
{
|
|
TApplication::create();
|
|
_msk = new TMask("at8100a");
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
//_rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD);
|
|
_donaz = new TLocalisamfile(LF_DONAZ);
|
|
_contsan = new TLocalisamfile(LF_CONTSAN);
|
|
_idoneita = new TLocalisamfile(LF_IDONEITA);
|
|
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
|
|
_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
|
|
_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
|
|
TConfig config(CONFIG_STUDIO);
|
|
_numdon1 = config.get_int("NumDon1");
|
|
_numdon2 = config.get_int("NumDon2");
|
|
_catini1 = config.get("CatIni1");
|
|
_catfin1 = config.get("CatFin1");
|
|
_catini2 = config.get("CatIni2");
|
|
_catfin2 = config.get("CatFin2");
|
|
_sttess2 = config.get_bool("StTess2");
|
|
_dataisc = config.get_bool("DataIsc");
|
|
_nomessage = config.get_bool("NoMessage");
|
|
_etadonne = config.get_int("EtaDonne");
|
|
_intsi_f1 = config.get_int("IntSI_F1");
|
|
_intsi_f2 = config.get_int("IntSI_F2");
|
|
_intsi_m = config.get_int("IntSI_M");
|
|
_intaf_m = config.get_int("IntAF_M");
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TCTStato2AT::destroy()
|
|
{
|
|
delete _sidoneita;
|
|
delete _scontrolli;
|
|
delete _sdonazioni;
|
|
delete _idoneita;
|
|
delete _contsan;
|
|
delete _donaz;
|
|
delete _rel;
|
|
delete _msk;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
bool TCTStato2AT::menu(MENU_TAG m)
|
|
{
|
|
KEY tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_rel->lfile().setkey(2);
|
|
bool modificato = FALSE;
|
|
bool modifanagr = FALSE;
|
|
TDate oggi(TODAY);
|
|
TRectype recsog = _rel->curr();
|
|
TExternisamfile* f = new TExternisamfile("$ctdon");
|
|
TProgind *pi;
|
|
pi = new TProgind(f->eod(),"Aggiornamento stato soggetti da CT", FALSE, TRUE, 10);
|
|
pi->setstatus(1);
|
|
for(f->first(); !f->eof(); f->next())
|
|
{
|
|
pi->addstatus(1);
|
|
modificato = FALSE;
|
|
modifanagr = FALSE;
|
|
const TString80 cognome = f->get("COGNOME");
|
|
const TString80 nome = f->get("NOME");
|
|
const TDate datanasc = f->get_date("DATANASC");
|
|
const donaz_anno = f->get_int("DONAZ_ANNO");
|
|
recsog.zero();
|
|
recsog.put(SOG_COGNOME, cognome);
|
|
recsog.put(SOG_NOME, nome);
|
|
recsog.put(SOG_DATANASC, datanasc);
|
|
if (recsog.read(_rel->lfile())==NOERR)
|
|
{
|
|
// aggiorna anagrafica soggetto
|
|
TString16 tel_casa = f->get("TEL_CASA");
|
|
TString16 tel_lavoro = f->get("TEL_LAVORO");
|
|
if (tel_casa.not_empty())
|
|
{
|
|
recsog.put(SOG_TELABI,tel_casa);
|
|
modifanagr = TRUE;
|
|
}
|
|
if (tel_lavoro.not_empty())
|
|
{
|
|
recsog.put(SOG_TELLAV,tel_lavoro);
|
|
modifanagr = TRUE;
|
|
}
|
|
TString16 stato = f->get("STATO");
|
|
TString16 statoavis = recsog.get(SOG_STATO);
|
|
TDate dataini = f->get_date("DATAINI");
|
|
TDate datafin = f->get_date("DATAFIN");
|
|
TString16 idon = "";
|
|
if ((stato=="08") || (stato=="03") || (stato=="09"))
|
|
{
|
|
if (statoavis != "DE")
|
|
{
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
key->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
_scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
reccon.put(CON_PROGCON, progcon);
|
|
if (dataini.ok())
|
|
reccon.put(CON_DATACON, dataini);
|
|
else
|
|
reccon.put(CON_DATACON, oggi);
|
|
reccon.put(CON_TIPOCON, "DE");
|
|
if (datafin.ok())
|
|
{
|
|
reccon.put(CON_PROSSTIPO, "FS");
|
|
reccon.put(CON_PROSSDATA, datafin);
|
|
}
|
|
TString80 resp = "AGGIORNAMENTO DA CENTRO TRASF.";
|
|
reccon.put(CON_RESPONSAB, resp);
|
|
//reccon.put(IDO_MOTIVO, _motivoid);
|
|
modificato = TRUE;
|
|
_scontrolli->insert_row(reccon);
|
|
_scontrolli->write(TRUE);
|
|
}
|
|
}
|
|
if (stato=="05")
|
|
{
|
|
if (statoavis != "E")
|
|
{
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
key->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
int err = _scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
reccon.put(CON_PROGCON, progcon);
|
|
if (dataini.ok())
|
|
reccon.put(CON_DATACON, dataini);
|
|
else
|
|
reccon.put(CON_DATACON, oggi);
|
|
reccon.put(CON_TIPOCON, "E");
|
|
if (datafin.ok())
|
|
{
|
|
reccon.put(CON_PROSSTIPO, "FS");
|
|
reccon.put(CON_PROSSDATA, datafin);
|
|
}
|
|
TString80 resp = "AGGIORNAMENTO DA CENTRO TRASF.";
|
|
reccon.put(CON_RESPONSAB, resp);
|
|
//reccon.put(IDO_MOTIVO, _motivoid);
|
|
modificato = TRUE;
|
|
_scontrolli->insert_row(reccon);
|
|
_scontrolli->write(TRUE);
|
|
}
|
|
}
|
|
if ((stato=="022") || (stato=="04"))
|
|
{
|
|
if (modstato_tcs(statoavis) != 'S')
|
|
{
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
key->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
int err = _scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
reccon.put(CON_PROGCON, progcon);
|
|
if (dataini.ok())
|
|
reccon.put(CON_DATACON, dataini);
|
|
else
|
|
reccon.put(CON_DATACON, oggi);
|
|
reccon.put(CON_TIPOCON, "SO");
|
|
if (datafin.ok())
|
|
{
|
|
reccon.put(CON_PROSSTIPO, "FS");
|
|
reccon.put(CON_PROSSDATA, datafin);
|
|
}
|
|
TString80 resp = "AGGIORNAMENTO DA CENTRO TRASF.";
|
|
reccon.put(CON_RESPONSAB, resp);
|
|
//reccon.put(IDO_MOTIVO, _motivoid);
|
|
modificato = TRUE;
|
|
_scontrolli->insert_row(reccon);
|
|
_scontrolli->write(TRUE);
|
|
}
|
|
}
|
|
if (stato=="021")
|
|
{
|
|
const char modstato = modstato_tcs(statoavis);
|
|
bool id_soloaf = ((recsog.get(SOG_STATOSI)!="ID") && (recsog.get(SOG_STATOAF)=="ID"));
|
|
if ((modstato != 'I') && (modstato != 'F') && (!id_soloaf) )
|
|
{
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
key->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
_scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
reccon.put(CON_PROGCON, progcon);
|
|
reccon.put(CON_DATACON, oggi);
|
|
reccon.put(CON_TIPOCON, "PI");
|
|
reccon.put(CON_IDON1, "PL");
|
|
if (recsog.get_int(SOG_INTAF)==0)
|
|
reccon.put(CON_INTAF, _intaf_m);
|
|
else
|
|
reccon.put(CON_INTAF, recsog.get_int(SOG_INTAF));
|
|
TString80 resp = "AGGIORNAMENTO DA CENTRO TRASF.";
|
|
reccon.put(CON_RESPONSAB, resp);
|
|
//reccon.put(IDO_MOTIVO, _motivoid);
|
|
modificato = TRUE;
|
|
_scontrolli->insert_row(reccon);
|
|
_scontrolli->write(TRUE);
|
|
}
|
|
}
|
|
if ((stato=="02") || (stato=="01") || (stato=="011"))
|
|
{
|
|
if ((modstato_tcs(statoavis) != 'I') && (modstato_tcs(statoavis) != 'F'))
|
|
{
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
key->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
_scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
reccon.put(CON_PROGCON, progcon);
|
|
reccon.put(CON_DATACON, oggi);
|
|
reccon.put(CON_TIPOCON, "PI");
|
|
reccon.put(CON_IDON1, "SI");
|
|
if (donaz_anno==0)
|
|
{
|
|
if (recsog.get_int(SOG_INTSI)==0)
|
|
{
|
|
const TString16 sesso = recsog.get(SOG_SESSO);
|
|
if (sesso == "2")
|
|
{
|
|
TDate datanasc = recsog.get_date(SOG_DATANASC);
|
|
int eta = oggi.year() - datanasc.year();
|
|
if(eta <= _etadonne)
|
|
reccon.put(CON_INTSI, _intsi_f1);
|
|
else
|
|
reccon.put(CON_INTSI, _intsi_f2);
|
|
}
|
|
else
|
|
reccon.put(CON_INTSI, _intsi_m);
|
|
}
|
|
else
|
|
reccon.put(CON_INTSI, recsog.get_int(SOG_INTSI));
|
|
}
|
|
else
|
|
{
|
|
const int intsi = (360/donaz_anno);
|
|
reccon.put(CON_INTSI, intsi);
|
|
}
|
|
TString80 resp = "AGGIORNAMENTO DA CENTRO TRASF.";
|
|
reccon.put(CON_RESPONSAB, resp);
|
|
//reccon.put(IDO_MOTIVO, _motivoid);
|
|
modificato = TRUE;
|
|
_scontrolli->insert_row(reccon);
|
|
_scontrolli->write(TRUE);
|
|
}
|
|
}
|
|
if (modificato)
|
|
{
|
|
TRectype* key = new TRectype(LF_IDONEITA);
|
|
key->put(IDO_CODICE, recsog.get(SOG_CODICE));
|
|
_sidoneita->read(key);
|
|
con_reord(recsog,_scontrolli,_sidoneita);
|
|
const TDate dataprossi = recsog.get_date(SOG_DATAPROSSI);
|
|
const TDate dataconv = recsog.get_date(SOG_DATACONV);
|
|
const char stato = modstato_tcs(recsog.get(SOG_STATO));
|
|
const TString16 statosi = recsog.get(SOG_STATOSI);
|
|
if ((stato == 'S') || (statosi == SOSPENSIONE) || (dataprossi > dataconv) || !dataprossi.ok())
|
|
{
|
|
TLocalisamfile rconvoc(LF_RCONVOC);
|
|
rconvoc.setkey(3);
|
|
rconvoc.zero();
|
|
rconvoc.put(RCV_CODICE, recsog.get(SOG_CODICE));
|
|
rconvoc.put(RCV_DATACONV, recsog.get(SOG_DATACONV));
|
|
if (rconvoc.read() == NOERR)
|
|
{
|
|
rconvoc.put(RCV_ANNULLATO, TRUE);
|
|
int err = rconvoc.write();
|
|
}
|
|
const TDate datanulla(NULLDATE);
|
|
recsog.put(SOG_DATACONV, datanulla);
|
|
recsog.put(SOG_DATAULTSOL, datanulla);
|
|
const int numzero = 0;
|
|
recsog.put(SOG_NUMCONV,numzero);
|
|
}
|
|
modifanagr = TRUE;
|
|
}
|
|
if (modifanagr)
|
|
{
|
|
recsog.put(SOG_DATAULTAGG, oggi);
|
|
recsog.put(SOG_UTENULTAGG, "CT");
|
|
recsog.rewrite(_rel->lfile());
|
|
}
|
|
}
|
|
}
|
|
delete pi;
|
|
delete f;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int TCTStato2AT::write(TSheet_field& s)
|
|
{
|
|
return NOERR;
|
|
}
|
|
|
|
|
|
int at8100(int argc, char* argv[])
|
|
{
|
|
TCTStato2AT a;
|
|
a.run(argc, argv, "Aggiorna stato donatori da CT");
|
|
return 0;
|
|
} |