|
|
|
@ -1,76 +1,159 @@
|
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <execp.h>
|
|
|
|
|
#include <filetext.h>
|
|
|
|
|
#include <form.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 <printer.h>
|
|
|
|
|
#include <progind.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "at8.h"
|
|
|
|
|
|
|
|
|
|
// nomi campi maschera
|
|
|
|
|
#include "at8100a.h"
|
|
|
|
|
#include "atlib.h"
|
|
|
|
|
|
|
|
|
|
// nomi dei campi
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
|
#include "donaz.h"
|
|
|
|
|
#include "contsan.h"
|
|
|
|
|
#include "donaz.h"
|
|
|
|
|
#include "idoneita.h"
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
|
#include "convoc.h"
|
|
|
|
|
#include "rconvoc.h"
|
|
|
|
|
#include "storico.h"
|
|
|
|
|
|
|
|
|
|
class TCTStato2AT : public TApplication
|
|
|
|
|
#define ATFILENAME "pippo.txt"
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// Classe TCtrn2at_file customizzata dalla TFile_text //
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TCtrn2at_file: public TFile_text
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TCTStato2AT() {}
|
|
|
|
|
virtual int autosave(TRelation& rel, const TRecord_text& rec);
|
|
|
|
|
|
|
|
|
|
TCtrn2at_file(const TString& file_name, const TString& config_name);
|
|
|
|
|
virtual ~TCtrn2at_file() { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HIDDEN inline TCTStato2AT& app() { return (TCTStato2AT&) main_app(); }
|
|
|
|
|
|
|
|
|
|
bool TCTStato2AT::create()
|
|
|
|
|
TCtrn2at_file::TCtrn2at_file(const TString& file_name, const TString& config_name)
|
|
|
|
|
: TFile_text(file_name, config_name)
|
|
|
|
|
{
|
|
|
|
|
TApplication::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TCtrn2at_file::autosave(TRelation& rel, const TRecord_text& rec)
|
|
|
|
|
{
|
|
|
|
|
const TString& type = rec.type();//prendo il tracciato record del tipo del record_text
|
|
|
|
|
TTracciato_record& tr = *t_rec(type);
|
|
|
|
|
|
|
|
|
|
TArray& a_tc = tr.tracciati_campo();
|
|
|
|
|
const int items = a_tc.items();
|
|
|
|
|
TString valore;
|
|
|
|
|
for (int i = 0; i < items; i++)
|
|
|
|
|
{
|
|
|
|
|
const TTracciato_campo& tc = tr.get(i);
|
|
|
|
|
TFieldref field(tc.field());
|
|
|
|
|
if (field.name().not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (field.file()==0)
|
|
|
|
|
field.set_file(rel.lfile().num());
|
|
|
|
|
valore = rec.row(i);
|
|
|
|
|
// formatta il campo del file di testo secondo le specifiche del campo su file isam
|
|
|
|
|
preformat_field(field,valore,rel,tr.type());
|
|
|
|
|
const TRectype& rel_rec = rel.curr(field.file());
|
|
|
|
|
TFieldtypes tipo_campo = rel_rec.type(field.name());
|
|
|
|
|
bool vuoto = valore.blank();
|
|
|
|
|
if (valore[0] == '@') //se trovo il carattere @ -> azzero il campo
|
|
|
|
|
valore.cut(0);
|
|
|
|
|
switch(tipo_campo) //in base al tipo di campo formatta i valori seguendo le specifiche del tracciato
|
|
|
|
|
{
|
|
|
|
|
case _datefld: //tipo data...
|
|
|
|
|
{
|
|
|
|
|
if (real::is_null(valore))
|
|
|
|
|
{
|
|
|
|
|
valore.cut(0);
|
|
|
|
|
vuoto = TRUE;
|
|
|
|
|
}
|
|
|
|
|
TDate data(valore);
|
|
|
|
|
format_date(data, fpicture(tc), valore);//formatta la data secondo le specifiche del tracciato
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case _realfld: //tipi numerici
|
|
|
|
|
case _intfld:
|
|
|
|
|
case _longfld:
|
|
|
|
|
{
|
|
|
|
|
const real numero(valore);
|
|
|
|
|
vuoto = numero.is_zero();
|
|
|
|
|
|
|
|
|
|
valore = numero.string(fpicture(tc));//formatta il numero secondo le specifiche del tracciato
|
|
|
|
|
|
|
|
|
|
int length = flength(tc,rel_rec);
|
|
|
|
|
if (falign(tc) == 'L')
|
|
|
|
|
valore.left_just(length, ffiller(tc));
|
|
|
|
|
else
|
|
|
|
|
valore.right_just(length, ffiller(tc)); }
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
valore = format_field(tc, rel.lfile().num(), valore);//formatta il campo secondo le specifiche del record
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!vuoto && rel.exist(field.file()))
|
|
|
|
|
field.write(valore, rel);//faccio una write sulla relazione del fieldref
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int err = NOERR;
|
|
|
|
|
if (pre_writerel(rel,rec))
|
|
|
|
|
{
|
|
|
|
|
err= rel.write();
|
|
|
|
|
if (err == _isdupkey || err ==_isreinsert)
|
|
|
|
|
err = rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// Classe TCtrn2at: applicazione principale //
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TCtrn2at: public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
TMask* _msk;
|
|
|
|
|
TCtrn2at_file* _trasfile;
|
|
|
|
|
int _numdon1, _numdon2;
|
|
|
|
|
TString16 _catini1, _catfin1, _catini2, _catfin2;
|
|
|
|
|
bool _sttess2, _dataisc;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create(void);
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
virtual bool destroy(void) ;
|
|
|
|
|
void transfer(void);
|
|
|
|
|
void inizializza_file(void);
|
|
|
|
|
static bool annulla_handler(TMask_field& f, KEY k);
|
|
|
|
|
bool test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon);
|
|
|
|
|
bool test_inter(TRectype& recsog, const char* tipo, const TDate& datadon, int inter);
|
|
|
|
|
void calcola_categoria(TRectype& recsog);
|
|
|
|
|
public:
|
|
|
|
|
const TMask& msk() const { return *_msk; }
|
|
|
|
|
TCtrn2at() {}
|
|
|
|
|
virtual ~TCtrn2at() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// restituisce un riferimento all' applicazione
|
|
|
|
|
inline TCtrn2at& app() { return (TCtrn2at&) main_app();}
|
|
|
|
|
|
|
|
|
|
// creazione dell'applicazione
|
|
|
|
|
bool TCtrn2at::create()
|
|
|
|
|
{
|
|
|
|
|
open_files(LF_SOGGETTI, LF_DONAZ, LF_CONTSAN, LF_IDONEITA, LF_CONVOC, LF_RCONVOC, LF_STORICO, 0);
|
|
|
|
|
_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);
|
|
|
|
|
_msk->set(F_FILENAME,ATFILENAME);
|
|
|
|
|
_trasfile = NULL;
|
|
|
|
|
TConfig config(CONFIG_STUDIO);
|
|
|
|
|
_numdon1 = config.get_int("NumDon1");
|
|
|
|
|
_numdon2 = config.get_int("NumDon2");
|
|
|
|
@ -80,296 +163,289 @@ bool TCTStato2AT::create()
|
|
|
|
|
_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;
|
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCTStato2AT::destroy()
|
|
|
|
|
// distruzione dell'applicazione
|
|
|
|
|
bool TCtrn2at::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete _sidoneita;
|
|
|
|
|
delete _scontrolli;
|
|
|
|
|
delete _sdonazioni;
|
|
|
|
|
delete _idoneita;
|
|
|
|
|
delete _contsan;
|
|
|
|
|
delete _donaz;
|
|
|
|
|
delete _rel;
|
|
|
|
|
delete _msk;
|
|
|
|
|
return TApplication::destroy();
|
|
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCTStato2AT::menu(MENU_TAG m)
|
|
|
|
|
// carica la maschera
|
|
|
|
|
void TCtrn2at::main_loop()
|
|
|
|
|
{
|
|
|
|
|
KEY tasto = _msk->run();
|
|
|
|
|
if (tasto == K_ENTER)
|
|
|
|
|
// Preimposta gli eventuali valori specificati sulla riga di comando
|
|
|
|
|
//error_box("Attenzione: manca la configurazione del trasferimento!");
|
|
|
|
|
KEY key = K_ENTER;
|
|
|
|
|
while (key != K_QUIT)
|
|
|
|
|
{
|
|
|
|
|
_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);
|
|
|
|
|
key = _msk->run();
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
transfer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (stato=="05")
|
|
|
|
|
|
|
|
|
|
bool TCtrn2at::test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon)
|
|
|
|
|
{
|
|
|
|
|
if (statoavis != "E")
|
|
|
|
|
//ricostruisce le donazioni del soggetto in esame
|
|
|
|
|
TRectype* key = new TRectype(LF_DONAZ);
|
|
|
|
|
key->put(DON_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array donazioni(LF_DONAZ,DON_PROGDON);
|
|
|
|
|
donazioni.read(key);
|
|
|
|
|
// verificare se ha fatto una donazione di tipo <tipo> con data successiva all'ultima donazione
|
|
|
|
|
const int r=donazioni.last_row();
|
|
|
|
|
if (r > 0)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
const TRectype& lastdon = donazioni[r];
|
|
|
|
|
if (lastdon.get_date(DON_DATADON) >= datadon)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TCTStato2AT::write(TSheet_field& s)
|
|
|
|
|
{
|
|
|
|
|
return NOERR;
|
|
|
|
|
//aggiunge la nuova donazione
|
|
|
|
|
// compila i dati della donazione in esame
|
|
|
|
|
TRectype* rec = new TRectype(LF_DONAZ);
|
|
|
|
|
rec->put(DON_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
rec->put(DON_PROGDON,r+1);
|
|
|
|
|
rec->put(DON_DATADON, datadon);
|
|
|
|
|
rec->put(DON_TIPODON, tipo);
|
|
|
|
|
rec->put(DON_CODSEZ,recsog.get(SOG_CODSEZ));
|
|
|
|
|
rec->put(DON_CODSOT,recsog.get(SOG_CODSOT));
|
|
|
|
|
rec->put(DON_LUOGODON, luogodon);
|
|
|
|
|
if (r == 0) //puó essere una prima donazione...
|
|
|
|
|
rec->put(DON_PRIMADON,"X");
|
|
|
|
|
|
|
|
|
|
donazioni.insert_row(rec);
|
|
|
|
|
donazioni.write(TRUE);
|
|
|
|
|
calcola_donazioni_lib(recsog, &donazioni); // questo metodo sistema tutto!!!
|
|
|
|
|
calcola_categoria(recsog);
|
|
|
|
|
// aggiorno data e utente ultimo aggiornamento
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
recsog.put(SOG_DATAULTAGG,oggi);
|
|
|
|
|
recsog.put(SOG_UTENULTAGG,"WINSIT");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TCtrn2at::calcola_categoria(TRectype& recsog)
|
|
|
|
|
{
|
|
|
|
|
TTable ctd("CTD");
|
|
|
|
|
TString16 catdon = recsog.get(SOG_CATDON);
|
|
|
|
|
const int totdon = recsog.get_int(SOG_TOTDON);
|
|
|
|
|
ctd.put("CODTAB",catdon);
|
|
|
|
|
if (ctd.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
bool dimissione = ctd.get_bool("B0");
|
|
|
|
|
if (dimissione)
|
|
|
|
|
{
|
|
|
|
|
const TString& cat_coll = ctd.get("S6");
|
|
|
|
|
if (cat_coll.not_empty())
|
|
|
|
|
{
|
|
|
|
|
catdon = cat_coll;
|
|
|
|
|
recsog.put(SOG_CATDON, catdon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((catdon == _catini1 || _catini1.empty()) && (totdon>=_numdon1) && _catfin1.not_empty())
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_CATDON, _catfin1);
|
|
|
|
|
catdon = _catfin1;
|
|
|
|
|
}
|
|
|
|
|
bool tstampata = recsog.get_bool(SOG_T_STAMPATA);
|
|
|
|
|
if ((catdon == _catini2 || _catini2.empty()) && (totdon>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata))
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_CATDON, _catfin2);
|
|
|
|
|
catdon = _catfin2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCtrn2at::test_inter(TRectype& recsog, const char* tipo, const TDate& datadon, int inter)
|
|
|
|
|
{
|
|
|
|
|
const char* tipoido = stricmp(tipo, "SI") != 0 ? "AF" : "SI";
|
|
|
|
|
int intervallo = 0;
|
|
|
|
|
|
|
|
|
|
TRectype* key_cont = new TRectype(LF_CONTSAN);
|
|
|
|
|
key_cont->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array controlli(LF_CONTSAN,CON_PROGCON);
|
|
|
|
|
controlli.read(key_cont);
|
|
|
|
|
|
|
|
|
|
TRectype* key = new TRectype(LF_IDONEITA);
|
|
|
|
|
key->put(IDO_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array idoneita(LF_IDONEITA,IDO_PROGIDO);
|
|
|
|
|
idoneita.read(key);
|
|
|
|
|
|
|
|
|
|
TString16 stato;
|
|
|
|
|
if (tipo == "SI")
|
|
|
|
|
{
|
|
|
|
|
stato = recsog.get(SOG_STATOSI);
|
|
|
|
|
intervallo = recsog.get_int(SOG_INTSI);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stato = recsog.get(SOG_STATOAF);
|
|
|
|
|
intervallo = recsog.get_int(SOG_INTAF);
|
|
|
|
|
}
|
|
|
|
|
if (stato.empty())
|
|
|
|
|
stato = recsog.get(SOG_STATO);
|
|
|
|
|
if (modstato_tcs(stato) != 'S' && stato.not_empty() && intervallo == inter)
|
|
|
|
|
return FALSE;
|
|
|
|
|
const int r = idoneita.last_row(); //se trova una data idoneita >= di quella in esame, quest'ultima viene ignorata
|
|
|
|
|
if (r > 0)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& lastido = idoneita[r];
|
|
|
|
|
if ((lastido.get_date(IDO_DATAIDO) >= datadon) && (tipoido == lastido.get(IDO_TIPOIDO)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRectype* rec = new TRectype(LF_IDONEITA);
|
|
|
|
|
rec->put(IDO_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
//rec->put(IDO_PROGIDO, r+1);
|
|
|
|
|
rec->put(IDO_DATAIDO, datadon);
|
|
|
|
|
rec->put(IDO_TIPOIDO, tipoido); // Il mondo è bello perchè c'é l'AVIS (tutte le donaz. non SI sono AF! mah?!)
|
|
|
|
|
rec->put(IDO_IDO_SOS, "ID");
|
|
|
|
|
rec->put(IDO_INTERVALLO, inter);
|
|
|
|
|
// aggiunto da cristina il 18/09/2002 altrimenti non so che quella riga é stata aggiunta da CT
|
|
|
|
|
rec->put(IDO_RESPONSAB, "TRASF. DA CT");
|
|
|
|
|
idoneita.add_row(rec);
|
|
|
|
|
idoneita.write();
|
|
|
|
|
|
|
|
|
|
con_reord(recsog, &controlli, &idoneita);
|
|
|
|
|
// verifico se occorre azzerare numero convocazioni e data ultima convocazione
|
|
|
|
|
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
|
|
|
|
if ((datadon - dataultdon) > 730)
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_DATACONV, NULLDATE);
|
|
|
|
|
recsog.put(SOG_NUMCONV, 0);
|
|
|
|
|
}
|
|
|
|
|
// aggiorno data e utente ultimo aggiornamento (Cristina 18/09/2002)
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
recsog.put(SOG_DATAULTAGG,oggi);
|
|
|
|
|
recsog.put(SOG_UTENULTAGG,"WINSIT");
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// trasferimento dati da file CT su programma avis
|
|
|
|
|
void TCtrn2at::transfer()
|
|
|
|
|
{
|
|
|
|
|
TFilename ctboini = "at8100a.ini";
|
|
|
|
|
|
|
|
|
|
_trasfile = new TCtrn2at_file(_msk->get(F_FILENAME), ctboini);
|
|
|
|
|
inizializza_file();
|
|
|
|
|
const long dimension = fsize(_msk->get(F_FILENAME));
|
|
|
|
|
TProgind pi(dimension,"Acquisizione in corso...");
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_SOGGETTI);
|
|
|
|
|
TRectype& sogg = rel.curr();
|
|
|
|
|
|
|
|
|
|
TString8 str; // Stringa jolly di lavoro
|
|
|
|
|
TRecord_text curr;
|
|
|
|
|
while (_trasfile->read(curr) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
pi.setstatus(_trasfile->read_file()->tellg());
|
|
|
|
|
//controlla se il donatore é AVIS oppure un cane sciolto o, peggio ancora, un adepto della
|
|
|
|
|
//concorrenza!!!(ovviamente si va a stringhe fisse e non a tabelle! roba da avis.....)
|
|
|
|
|
str = curr.get(31); //donatore della concorrenza -> lo salta
|
|
|
|
|
str.trim();
|
|
|
|
|
if (str == "ADVS")
|
|
|
|
|
continue;
|
|
|
|
|
if (str == "NOASS") //se il donatore é un cane sciolto -> va in sezione NI ed in categoria NI
|
|
|
|
|
{
|
|
|
|
|
curr.add("NI",0);
|
|
|
|
|
curr.add("@",1);
|
|
|
|
|
sogg.put(SOG_CATDON,"NI");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
str = curr.get(2);
|
|
|
|
|
sogg.put(SOG_CODICE, atol(str));
|
|
|
|
|
if (rel.read(_isequal) != NOERR)
|
|
|
|
|
sogg.zero();
|
|
|
|
|
//controlla se il donatore ha cambiato sezione spostandosi da Bologna in provincia;
|
|
|
|
|
//in questo caso gli deve cancellare il sottogruppo (veramente un procedimento da
|
|
|
|
|
//galera, ma se l'avis e winsit vogliono cosí.....)
|
|
|
|
|
str = curr.get(0);
|
|
|
|
|
str.trim();
|
|
|
|
|
TString8 str1;
|
|
|
|
|
str1 = curr.get(1);
|
|
|
|
|
str1.trim();
|
|
|
|
|
if (str != sogg.get(SOG_CODSEZ) && str != "01" && str1 == "")
|
|
|
|
|
curr.add("@",1);
|
|
|
|
|
|
|
|
|
|
//esegue l'effettivo passaggio dati basandosi sulla formattazione del file .ini
|
|
|
|
|
_trasfile->autosave(rel, curr);
|
|
|
|
|
|
|
|
|
|
const char* tipo[] = { "SI", "PL", "PI", "PP" };
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
bool update = FALSE;
|
|
|
|
|
TDate datadon(TODAY);
|
|
|
|
|
str = curr.get(23+i);
|
|
|
|
|
if (!str.blank())
|
|
|
|
|
{
|
|
|
|
|
datadon = TDate(str);
|
|
|
|
|
str = curr.get(32);
|
|
|
|
|
str.trim();
|
|
|
|
|
//cambio codice del punto di prelievo per casi speciali (sarebbe necessaria una tabella,
|
|
|
|
|
//ma con l'AVIS é tempo sprecato....)
|
|
|
|
|
if (str == "UROM")
|
|
|
|
|
str = "013"; else
|
|
|
|
|
if (str == "UROB")
|
|
|
|
|
str = "O.BE"; else
|
|
|
|
|
if (str == "IMOLA")
|
|
|
|
|
str = "70";
|
|
|
|
|
update |= test_donation(sogg, tipo[i], datadon, str);
|
|
|
|
|
}
|
|
|
|
|
str = curr.get(27+i);
|
|
|
|
|
if (!real::is_null(str))
|
|
|
|
|
update |= test_inter(sogg, tipo[i], datadon, atoi(str));
|
|
|
|
|
if (update)
|
|
|
|
|
{
|
|
|
|
|
calcola_categoria(sogg);
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
|
|
|
|
message_box("Operazione terminata");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//inizializza il file di testo su cui emettere i dati
|
|
|
|
|
void TCtrn2at::inizializza_file()
|
|
|
|
|
{
|
|
|
|
|
TFilename filect = _msk->get(F_FILENAME); //aggiungere lettura automatica nomi file
|
|
|
|
|
_trasfile->open(filect,'r');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handler per gestire la conferma dell'annullamento dei dati inseriti
|
|
|
|
|
// nella maschera
|
|
|
|
|
bool TCtrn2at::annulla_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TMask &m = f.mask();
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
if (yesno_box("Vuoi veramente annullare i dati inseriti"))
|
|
|
|
|
m.reset();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// gestione dei messaggi estesi nei campi
|
|
|
|
|
void TCtrn2at_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str)
|
|
|
|
|
{
|
|
|
|
|
const TString code(s.get(0));
|
|
|
|
|
TString valore;
|
|
|
|
|
if (code == "_UPPERCASE")
|
|
|
|
|
{
|
|
|
|
|
valore.upper();
|
|
|
|
|
}
|
|
|
|
|
else NFCHECK("Macro non definita: %s", (const char *)code);
|
|
|
|
|
str = valore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int at8100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TCTStato2AT a;
|
|
|
|
|
a.run(argc, argv, "Aggiorna stato donatori da CT");
|
|
|
|
|
TCtrn2at a ;
|
|
|
|
|
a.run(argc, argv, "Acquisizione dati da Eliot - CT");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|