From eb4f2b7e4ec3f94e3ed833908726b7f261ae72a7 Mon Sep 17 00:00:00 2001 From: cris Date: Fri, 8 Aug 2003 13:24:47 +0000 Subject: [PATCH] Patch level : AT Files correlati : Ricompilazione Demo : [ ] Commento : ultima versione di AVIS git-svn-id: svn://10.65.10.50/trunk@11386 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- at/at0100.cpp | 6 + at/at0700.cpp | 61 ++-- at/at7300.cpp | 5 +- at/at8100.cpp | 754 +++++++++++++++++++++++++++---------------------- at/at8800.cpp | 10 +- at/at8900.cpp | 4 +- at/atlib1.cpp | 8 +- at/batbpr1.h | 2 +- at/batbpr1.uml | 2 +- at/f96.dir | 2 +- 10 files changed, 473 insertions(+), 381 deletions(-) diff --git a/at/at0100.cpp b/at/at0100.cpp index b1f1b5d4a..851b9fb07 100755 --- a/at/at0100.cpp +++ b/at/at0100.cpp @@ -2054,6 +2054,12 @@ void TGestioneSoggetti::c_reord(TSheet_field& s, TSheet_field& si) mask.set(F_DATASTATO,datastatoaf); else mask.set(F_DATASTATO,datastatosi); + const TString16 catcoll = cache().get("TCS",stato).get("S7"); + if (catcoll.not_empty()) + { + mask.set(F_CATDON,catcoll); + mask.field(F_CATDON).on_key(K_TAB); + } } } d_datepross(s); diff --git a/at/at0700.cpp b/at/at0700.cpp index acf333aa7..07b094fbf 100755 --- a/at/at0700.cpp +++ b/at/at0700.cpp @@ -223,6 +223,11 @@ bool TSbloccoSospesi::preprocess_page(int file, int counter) long codice = recsog.get_long(SOG_CODICE); key->put(CON_CODICE, codice); int err = _scontrolli->read(key); + + TRectype* key1 = new TRectype(LF_IDONEITA); + key1->put(IDO_CODICE, codice); + err = _sidoneita->read(key1); + int progcon = _scontrolli->rows()+1; TRectype& reccon = _contsan->curr(); reccon.zero(); @@ -306,37 +311,37 @@ bool TSbloccoSospesi::preprocess_page(int file, int counter) _sidoneita->add_row(recido); _sidoneita->rewrite(); } - con_reord(recsog, _scontrolli, _sidoneita); - const TDate oggi(TODAY); - recsog.put(SOG_DATAULTAGG,oggi); - recsog.put(SOG_UTENULTAGG,user()); + } + con_reord(recsog, _scontrolli, _sidoneita); + const TDate oggi(TODAY); + recsog.put(SOG_DATAULTAGG,oggi); + recsog.put(SOG_UTENULTAGG,user()); - TString16 catdon = recsog.get(SOG_CATDON); - const TRectype& ctd = cache().get("CTD", catdon); - const int totdon = recsog.get_int(SOG_TOTDON); - if (ctd.get_bool("B0")) - { - const TString16 catcoll = ctd.get("S6"); - if (catcoll.not_empty()) - { - recsog.put(SOG_CATDON, catcoll); - recsog.put(SOG_DATADIM,NULLDATE); - catdon = catcoll; - } - } - if ((catdon == _catini1 || _catini1.empty()) && (totdon>=_numdon1) && _catfin1.not_empty()) + TString16 catdon = recsog.get(SOG_CATDON); + const TRectype& ctd = cache().get("CTD", catdon); + const int totdon = recsog.get_int(SOG_TOTDON); + if (ctd.get_bool("B0")) + { + const TString16 catcoll = ctd.get("S6"); + if (catcoll.not_empty()) { - recsog.put(SOG_CATDON, _catfin1); - catdon = _catfin1; + recsog.put(SOG_CATDON, catcoll); + recsog.put(SOG_DATADIM,NULLDATE); + catdon = catcoll; } - 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; - } - current_cursor()->file().rewrite(); - } + } + 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; + } + current_cursor()->file().rewrite(); } // salto pagina se cambio sezione const TString16 codsez = recsog.get(SOG_CODSEZ); diff --git a/at/at7300.cpp b/at/at7300.cpp index 73280e8aa..b7eb3b331 100755 --- a/at/at7300.cpp +++ b/at/at7300.cpp @@ -69,6 +69,7 @@ class TStampeSingole : public TPrintapp TString80 _note, _intest1, _intest2, _intest3, _intest4; bool _usomodo, _usasez; int _etlarghezza, _etcolonne, _schxpag, _lenpage; + int _contaschede; protected: virtual bool user_create(); @@ -227,6 +228,7 @@ void TStampeSingole::set_page(int file, int cnt) TPrint_section& corpo = _form_sch->get_body(); corpo.update_and_print(printmode_normal, TRUE); force_setpage(TRUE); + _contaschede++; } break; case donazioni: @@ -320,7 +322,7 @@ bool TStampeSingole::set_print(int m) break; case F_SCHEDE: _tipostampa=schede; - if (_schxpag > 1) + if (_schxpag > 1) printer().formlen(_lenpage/_schxpag); break; case F_ETICHETTE: @@ -334,6 +336,7 @@ bool TStampeSingole::set_print(int m) { if (_tipostampa == cartoline) dati_cartolina(); + _contaschede = 0; reset_files(); add_file(LF_SOGGETTI); _asoggetti.destroy(); diff --git a/at/at8100.cpp b/at/at8100.cpp index d55a803d9..77f0b15e5 100755 --- a/at/at8100.cpp +++ b/at/at8100.cpp @@ -1,76 +1,159 @@ #include -#include +#include +#include #include -#include -#include -#include -#include -#include #include #include -#include -#include -#include +#include +#include +#include +#include #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 -{ - TMask* _msk; - TRelation* _rel; +#define ATFILENAME "pippo.txt" - 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; - - +//////////////////////////////////////////////////////// +// Classe TCtrn2at_file customizzata dalla TFile_text // +//////////////////////////////////////////////////////// + +class TCtrn2at_file: public TFile_text +{ 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(); - _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); +} + +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"); + _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; -} - -bool TCTStato2AT::destroy() -{ - delete _sidoneita; - delete _scontrolli; - delete _sdonazioni; - delete _idoneita; - delete _contsan; - delete _donaz; - delete _rel; - delete _msk; - return TApplication::destroy(); + return TSkeleton_application::create(); } -bool TCTStato2AT::menu(MENU_TAG m) +// distruzione dell'applicazione +bool TCtrn2at::destroy() +{ + delete _msk; + return TSkeleton_application::destroy(); +} + +// carica la maschera +void TCtrn2at::main_loop() { - 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; + // 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) + { + key = _msk->run(); + if (key == K_ENTER) + transfer(); + } +} + +bool TCtrn2at::test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon) +{ + //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 con data successiva all'ultima donazione + const int r=donazioni.last_row(); + if (r > 0) + { + const TRectype& lastdon = donazioni[r]; + if (lastdon.get_date(DON_DATADON) >= datadon) + return FALSE; + } + + //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; -int TCTStato2AT::write(TSheet_field& s) -{ - return NOERR; + 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"); - return 0; -} \ No newline at end of file + TCtrn2at a ; + a.run(argc, argv, "Acquisizione dati da Eliot - CT"); + return 0; +} diff --git a/at/at8800.cpp b/at/at8800.cpp index ef8046c46..4deb84991 100755 --- a/at/at8800.cpp +++ b/at/at8800.cpp @@ -275,19 +275,22 @@ bool TCtbo2at::test_inter(TRectype& recsog, const char* tipo, const TDate& datad idoneita.read(key); TString16 stato; + TDate datapross; if (tipo == "SI") { stato = recsog.get(SOG_STATOSI); intervallo = recsog.get_int(SOG_INTSI); + datapross = recsog.get_int(SOG_DATAPROSSI); } else { stato = recsog.get(SOG_STATOAF); intervallo = recsog.get_int(SOG_INTAF); + datapross = recsog.get_int(SOG_DATAPROSAF); } if (stato.empty()) stato = recsog.get(SOG_STATO); - if (modstato_tcs(stato) != 'S' && stato.not_empty() && intervallo == inter) + if (modstato_tcs(stato) != 'S' && stato.not_empty() && intervallo == inter && !datapross.empty()) return FALSE; const int r = idoneita.last_row(); //se trova una data idoneita >= di quella in esame, quest'ultima viene ignorata if (r > 0) @@ -299,7 +302,10 @@ bool TCtbo2at::test_inter(TRectype& recsog, const char* tipo, const TDate& datad TRectype* rec = new TRectype(LF_IDONEITA); rec->put(IDO_CODICE, recsog.get(SOG_CODICE)); - //rec->put(IDO_PROGIDO, r+1); + if (idoneita.rows() == 0) + rec->put(IDO_PROGIDO, 1); + else + 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"); diff --git a/at/at8900.cpp b/at/at8900.cpp index 7076cb497..18e245290 100755 --- a/at/at8900.cpp +++ b/at/at8900.cpp @@ -837,7 +837,7 @@ bool TCtpr2at::update_record(TRectype& record_at, TAssoc_array& record_ct) if ((elab == "CELLULARE") && ((str[0]!='0') && (str.len()>9))) record_at.put(campo, str); else - if ((elab == "NOCELLULARE") && !((str[0]!='0') && (str.len()>9))) + if ((elab == "NOCELLULARE") && (str[0]=='0')) record_at.put(campo, str); } } @@ -1289,7 +1289,7 @@ bool TCtpr2at::sacca(const TString& istruzione) } calcola_donazioni_lib(recsog, _sdonazioni); // questo metodo sistema tutto!!! calcola_categoria(recsog); // modificato per dare i messaggi al posto dei veri cambiamenti - print_line(); + //print_line(); // tolto perchè altrimenti stampa alcuni fogli vuoti // aggiorno data e utente ultimo aggiornamento TDate oggi(TODAY); recsog.put(SOG_DATAULTAGG, oggi); diff --git a/at/atlib1.cpp b/at/atlib1.cpp index 0a73c05c2..77e77dcba 100755 --- a/at/atlib1.cpp +++ b/at/atlib1.cpp @@ -203,10 +203,10 @@ void con_reord(TRectype& soggetto, TRecord_array* controlli, TRecord_array* idon if (tipoido == IDON_AF) if ((intervallo != 0) && (intaf == 0)) soggetto.put(SOG_INTAF, intervallo); - if (dataido >= dataultstato) + if ((dataido >= dataultstato) || (ultstato) == 'F') { if (tipoido == IDON_SI) - { + { soggetto.put(SOG_DATASI,dataido); soggetto.put(SOG_STATOSI,ido_sos); soggetto.put(SOG_FINESOSSI,finesos); @@ -262,15 +262,11 @@ void con_reord(TRectype& soggetto, TRecord_array* controlli, TRecord_array* idon char modstato = modstato_tcs(stato); const char tipostatosi = modstato_tcs(statosi); const char tipostatoaf = modstato_tcs(statoaf); - //if ((statosi == IDONEITA) || (statoaf == IDONEITA)) if ((tipostatosi == 'I') || (tipostatoaf == 'I')) if ((modstato != 'I') || (modstato != 'F')) stato = IDONEITA; - //if ((statosi == SOSPENSIONE || statosi.empty()) && (statoaf == SOSPENSIONE || statoaf.empty())) - //if ((statosi == SOSPENSIONE) && (statoaf == SOSPENSIONE)) if ((tipostatosi == 'S') && (tipostatoaf == 'S')) if (modstato != 'S') - //stato = SOSPENSIONE; stato == statosi; char statocalcolato = modstato_tcs(stato); if (modstato != statocalcolato) diff --git a/at/batbpr1.h b/at/batbpr1.h index 963c8d473..c4f1432c3 100755 --- a/at/batbpr1.h +++ b/at/batbpr1.h @@ -1,4 +1,4 @@ -// tabella di conversione CT Parma- AVIS per stato trasfusionale +// tabella di conversione CT Rimini- AVIS per stato trasfusionale #define F_TABPR1_CODTAB 100 #define F_TABPR1_DESCR 101 #define F_TABPR1_OPERAZIONE 102 diff --git a/at/batbpr1.uml b/at/batbpr1.uml index 9d3229dca..9175b67eb 100755 --- a/at/batbpr1.uml +++ b/at/batbpr1.uml @@ -4,7 +4,7 @@ TOOLBAR "" 0 20 0 2 #include ENDPAGE -PAGE "Tabella conversione stato trasfusionale" -1 -1 78 18 +PAGE "Tabella conversione stato trasfusionale CETRAPLUS" -1 -1 78 18 STRING F_TABPR1_CODTAB 3 BEGIN diff --git a/at/f96.dir b/at/f96.dir index c2dd83b77..437914fc2 100755 --- a/at/f96.dir +++ b/at/f96.dir @@ -1,3 +1,3 @@ 96 1 -%sezioni|0|0|469|17|Sezioni AVIS||| +%sezioni|0|0|519|17|Sezioni AVIS|||