diff --git a/at/at0600.cpp b/at/at0600.cpp index c09c50bd0..38e4de651 100755 --- a/at/at0600.cpp +++ b/at/at0600.cpp @@ -19,454 +19,459 @@ #include "storico.h" #include "sezioni.h" -#define ALIAS_CTD 700 // categoria donatori -#define ALIAS_TCS 200 // tipi/esiti controlli sanitari +#define ALIAS_CTD 700 // categoria donatori +#define ALIAS_TCS 200 // tipi/esiti controlli sanitari class TChiusuraPeriodica : public TPrintapp { static bool filter_func_chiusura(const TRelation* rel); - TMask* _msk; - TRelation* _rel; - TLocalisamfile* _contsan; - TLocalisamfile* _idoneita; - TRecord_array* _scontrolli; - TRecord_array* _sidoneita; - int _cur; - TDate _data_chiusura, _dataud; - TParagraph_string _operazione; - bool _definitiva, _sospesi, _usosez; - TString16 _codsez, _codsot; - int _numdon; - TString16 _catfin1, _catfin2, _contsan1, _contsan2, _motivo; - TAssoc_array _categorie; - int _contatore, _totale; + TMask* _msk; + TRelation* _rel; + TLocalisamfile* _contsan; + TLocalisamfile* _idoneita; + TRecord_array* _scontrolli; + TRecord_array* _sidoneita; + int _cur; + TDate _data_chiusura, _dataud; + TParagraph_string _operazione; + bool _definitiva, _sospesi, _usosez; + TString16 _codsez, _codsot; + int _numdon; + TString16 _catfin1, _catfin2, _contsan1, _contsan2, _motivo; + TAssoc_array _categorie; + int _contatore, _totale; + - protected: - virtual bool user_create(); - virtual bool user_destroy(); - virtual bool set_print(int m); - virtual void set_page(int file, int cnt); - virtual bool preprocess_page(int file, int counter); + virtual bool user_create(); + virtual bool user_destroy(); + virtual bool set_print(int m); + virtual void set_page(int file, int cnt); + virtual bool preprocess_page(int file, int counter); virtual print_action postprocess_print(int file, int counter); - virtual TMask& get_mask() { return *_msk; } - + virtual TMask& get_mask() { return *_msk; } + public: void filtra_sezioni(); void header_sezione(const TString16 codsez, const TString16 codsot); void footer_sezione(); void fine_stampa(); void crea_intestazione(); - TChiusuraPeriodica() : _data_chiusura(TODAY), _operazione("",35) {} + TChiusuraPeriodica() : _data_chiusura(TODAY), _operazione("",35) {} }; HIDDEN inline TChiusuraPeriodica& app() { return (TChiusuraPeriodica&) main_app(); } void TChiusuraPeriodica::filtra_sezioni() { - const TString16 sezini = _msk->get(F_SEZINI); - const TString16 sotini = _msk->get(F_SOTINI); - const TString16 sezfin = _msk->get(F_SEZFIN); - const TString16 sotfin = _msk->get(F_SOTFIN); + const TString16 sezini = _msk->get(F_SEZINI); + const TString16 sotini = _msk->get(F_SOTINI); + const TString16 sezfin = _msk->get(F_SEZFIN); + const TString16 sotfin = _msk->get(F_SOTFIN); TRectype da(LF_SOGGETTI); TRectype a(LF_SOGGETTI); if (sezini.not_empty()) - da.put(SOG_CODSEZ, sezini); + da.put(SOG_CODSEZ, sezini); if (sotini.not_empty()) - da.put(SOG_CODSOT, sotini); + da.put(SOG_CODSOT, sotini); if (sezfin.not_empty()) - a.put(SOG_CODSEZ, sezfin); + a.put(SOG_CODSEZ, sezfin); if (sotfin.not_empty()) - a.put(SOG_CODSOT, sotfin); - current_cursor()->setregion(da, a); -} + a.put(SOG_CODSOT, sotfin); + current_cursor()->setregion(da, a); +} bool TChiusuraPeriodica::preprocess_page(int file, int counter) { const TDate oggi(TODAY); - _operazione = "Situazione da controllare"; - TRectype& recsez = current_cursor()->curr(LF_SEZIONI); - TRectype& recsog = current_cursor()->curr(); - // salto pagina se cambio sezione - const TString16 codsez = recsog.get(SOG_CODSEZ); - const TString16 codsot = recsog.get(SOG_CODSOT); - if ((_codsez!=codsez)||(_codsot!=codsot)) - { - if (_codsez != "**") - footer_sezione(); - _contatore = 0; - _codsez = codsez; - _codsot = codsot; - header_sezione(codsez, codsot); - } - TLocalisamfile& filesog = current_cursor()->file(); - const TString16 catsog = recsog.get(SOG_CATDON); - if (_usosez) - { - const TString16 cat_estinti = recsez.get(SEZ_CATESTI); - const TString16 cat_cancellati = recsez.get(SEZ_CATCANC); - const TString16 cat_emeriti = recsez.get(SEZ_CATEMER); - const int intesti = recsez.get_int(SEZ_INTESTI); - const int donemer = recsez.get_int(SEZ_DONEMER); - if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0)) - { - if (catsog == cat_cancellati && cat_cancellati.not_empty()) - { - _operazione = "Cancellato"; - if (_definitiva) - filesog.remove(); - } - else - { - if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0)) - { - bool dimesso = current_cursor()->curr(-ALIAS_CTD).get_bool("B0"); - if (!dimesso) - { - TDate dataultdon = recsog.get(SOG_DATAULTDON); - if (dataultdon.ok()) - { - dataultdon.addyear(intesti); - if (dataultdon < app()._data_chiusura) - { - const int totdon = recsog.get_int(SOG_TOTDON); - if (cat_emeriti.not_empty() && donemer!=0 && totdon>donemer) - { - _operazione = "da"; - _operazione << " "; - _operazione << catsog; - _operazione << " a "; - _operazione << cat_emeriti; - if (_definitiva) - { - recsog.put(SOG_CATDON,cat_emeriti); - recsog.put(SOG_DATADIM, _data_chiusura); - recsog.put(SOG_DATAULTAGG, oggi); - recsog.put(SOG_UTENULTAGG, user()); - filesog.rewrite(); - } - } - else - { - if (cat_estinti.not_empty()) - { - _operazione = "da"; - _operazione << " "; - _operazione << catsog; - _operazione << " a "; - _operazione << cat_estinti; - if (_definitiva) - { - recsog.put(SOG_CATDON,cat_estinti); - recsog.put(SOG_DATADIM, _data_chiusura); - recsog.put(SOG_DATAULTAGG, oggi); - recsog.put(SOG_UTENULTAGG, user()); - filesog.rewrite(); - } - } - } - } - } - } - } - } - } - } - else - { - TRectype* key = new TRectype(LF_CONTSAN); - long codice = recsog.get_long(SOG_CODICE); - key->put(CON_CODICE, codice); - const int totdon = recsog.get_int(SOG_TOTDON); - if (_catfin1.not_empty() && totdon<=_numdon) - { - _operazione = "da"; - _operazione << " "; - _operazione << catsog; - _operazione << " a "; - _operazione << _catfin1; - if (_definitiva) - { - recsog.put(SOG_CATDON,_catfin1); - recsog.put(SOG_DATADIM, oggi); - recsog.put(SOG_DATAULTAGG, oggi); - recsog.put(SOG_UTENULTAGG, user()); - filesog.rewrite(); - if (_contsan1.not_empty()) - { - int err = _scontrolli->read(key); - int progcon = _scontrolli->rows()+1; - TRectype& reccon = _contsan->curr(); - reccon.zero(); - reccon.put(CON_CODICE, codice); - reccon.put(CON_PROGCON, progcon); - reccon.put(CON_DATACON, oggi); - reccon.put(CON_TIPOCON, _contsan1); - TString80 resp = user(); - resp << " - CHIUSURA PERIODICA"; - reccon.put(CON_RESPONSAB, resp); - reccon.put(CON_MOTIVO, _motivo); - _scontrolli->add_row(reccon); - _scontrolli->rewrite(); - } - } - } - else - { - if (_catfin2.not_empty()) - { - _operazione = "da"; - _operazione << " "; - _operazione << catsog; - _operazione << " a "; - _operazione << _catfin2; - if (_definitiva) - { - recsog.put(SOG_CATDON, _catfin2); - recsog.put(SOG_DATADIM, oggi); - recsog.put(SOG_DATAULTAGG, oggi); - recsog.put(SOG_UTENULTAGG, user()); - filesog.rewrite(); - if (_contsan2.not_empty()) - { - int err = _scontrolli->read(key); - int progcon = _scontrolli->rows()+1; - TRectype& reccon = _contsan->curr(); - reccon.zero(); - reccon.put(CON_CODICE, codice); - reccon.put(CON_PROGCON, progcon); - reccon.put(CON_DATACON, oggi); - reccon.put(CON_TIPOCON, _contsan2); - TString80 resp = user(); - resp << " - CHIUSURA PERIODICA"; - reccon.put(CON_RESPONSAB, resp); - reccon.put(CON_MOTIVO, _motivo); - _scontrolli->add_row(reccon); - _scontrolli->rewrite(); - } - } - } - } - } - _contatore++; - _totale++; + _operazione = "Situazione da controllare"; + TRectype& recsez = current_cursor()->curr(LF_SEZIONI); + TRectype& recsog = current_cursor()->curr(); + // salto pagina se cambio sezione + const TString16 codsez = recsog.get(SOG_CODSEZ); + const TString16 codsot = recsog.get(SOG_CODSOT); + if ((_codsez!=codsez)||(_codsot!=codsot)) + { + if (_codsez != "**") + footer_sezione(); + _contatore = 0; + _codsez = codsez; + _codsot = codsot; + header_sezione(codsez, codsot); + } + TLocalisamfile& filesog = current_cursor()->file(); + const TString16 catsog = recsog.get(SOG_CATDON); + if (_usosez) + { + const TString16 cat_estinti = recsez.get(SEZ_CATESTI); + const TString16 cat_cancellati = recsez.get(SEZ_CATCANC); + const TString16 cat_emeriti = recsez.get(SEZ_CATEMER); + const int intesti = recsez.get_int(SEZ_INTESTI); + const int donemer = recsez.get_int(SEZ_DONEMER); + if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0)) + { + if (catsog == cat_cancellati && cat_cancellati.not_empty()) + { + _operazione = "Cancellato"; + if (_definitiva) + filesog.remove(); + } + else + { + if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0)) + { + bool dimesso = current_cursor()->curr(-ALIAS_CTD).get_bool("B0"); + if (!dimesso) + { + TDate dataultdon = recsog.get(SOG_DATAULTDON); + if (dataultdon.ok()) + { + dataultdon.addyear(intesti); + if (dataultdon < app()._data_chiusura) + { + const int totdon = recsog.get_int(SOG_TOTDON); + if (cat_emeriti.not_empty() && donemer!=0 && totdon>donemer) + { + _operazione = "da"; + _operazione << " "; + _operazione << catsog; + _operazione << " a "; + _operazione << cat_emeriti; + if (_definitiva) + { + recsog.put(SOG_CATDON,cat_emeriti); + recsog.put(SOG_DATADIM, _data_chiusura); + recsog.put(SOG_DATAULTAGG, oggi); + recsog.put(SOG_UTENULTAGG, user()); + filesog.rewrite(); + } + } + else + { + if (cat_estinti.not_empty()) + { + _operazione = "da"; + _operazione << " "; + _operazione << catsog; + _operazione << " a "; + _operazione << cat_estinti; + if (_definitiva) + { + recsog.put(SOG_CATDON,cat_estinti); + recsog.put(SOG_DATADIM, _data_chiusura); + recsog.put(SOG_DATAULTAGG, oggi); + recsog.put(SOG_UTENULTAGG, user()); + filesog.rewrite(); + } + } + } + } + } + } + } + } + } + } + else + { + TRectype* key = new TRectype(LF_CONTSAN); + long codice = recsog.get_long(SOG_CODICE); + key->put(CON_CODICE, codice); + const int totdon = recsog.get_int(SOG_TOTDON); + if (_catfin1.not_empty() && totdon<=_numdon) + { + _operazione = "da"; + _operazione << " "; + _operazione << catsog; + _operazione << " a "; + _operazione << _catfin1; + if (_definitiva) + { + recsog.put(SOG_CATDON,_catfin1); + recsog.put(SOG_DATADIM, oggi); + recsog.put(SOG_DATAULTAGG, oggi); + recsog.put(SOG_UTENULTAGG, user()); + filesog.rewrite(); + if (_contsan1.not_empty()) + { + int err = _scontrolli->read(key); + int progcon = _scontrolli->rows()+1; + TRectype& reccon = _contsan->curr(); + reccon.zero(); + reccon.put(CON_CODICE, codice); + reccon.put(CON_PROGCON, progcon); + reccon.put(CON_DATACON, oggi); + reccon.put(CON_TIPOCON, _contsan1); + TString80 resp = user(); + resp << " - CHIUSURA PERIODICA"; + reccon.put(CON_RESPONSAB, resp); + reccon.put(CON_MOTIVO, _motivo); + _scontrolli->add_row(reccon); + _scontrolli->rewrite(); + } + } + } + else + { + if (_catfin2.not_empty()) + { + _operazione = "da"; + _operazione << " "; + _operazione << catsog; + _operazione << " a "; + _operazione << _catfin2; + if (_definitiva) + { + recsog.put(SOG_CATDON, _catfin2); + recsog.put(SOG_DATADIM, oggi); + recsog.put(SOG_DATAULTAGG, oggi); + recsog.put(SOG_UTENULTAGG, user()); + filesog.rewrite(); + if (_contsan2.not_empty()) + { + int err = _scontrolli->read(key); + int progcon = _scontrolli->rows()+1; + TRectype& reccon = _contsan->curr(); + reccon.zero(); + reccon.put(CON_CODICE, codice); + reccon.put(CON_PROGCON, progcon); + reccon.put(CON_DATACON, oggi); + reccon.put(CON_TIPOCON, _contsan2); + TString80 resp = user(); + resp << " - CHIUSURA PERIODICA"; + reccon.put(CON_RESPONSAB, resp); + reccon.put(CON_MOTIVO, _motivo); + _scontrolli->add_row(reccon); + _scontrolli->rewrite(); + } + } + } + } + } + _contatore++; + _totale++; return TRUE; } print_action TChiusuraPeriodica::postprocess_print(int file, int counter) { - if (_contatore > 0) - footer_sezione(); - fine_stampa(); - return NEXT_PAGE; + if (_contatore > 0) + footer_sezione(); + fine_stampa(); + return NEXT_PAGE; } void TChiusuraPeriodica::footer_sezione() { - // stampa totale soggetti appartenenti alla sezione - reset_footer(); - TString sep(132); - sep.fill('-'); - set_footer(2, (const char *) sep); - set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore); - printer().formfeed(); - reset_footer(); + // stampa totale soggetti appartenenti alla sezione + reset_footer(); + TString sep(132); + sep.fill('-'); + set_footer(2, (const char *) sep); + set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore); + printer().formfeed(); + reset_footer(); } void TChiusuraPeriodica::fine_stampa() { - // stampa totale soggetti a fine stampa - reset_footer(); - TString sep(132); - sep.fill('-'); - set_footer(2, (const char *) sep); - if (_totale > 0 && _totale != _contatore) - { - set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _totale); - printer().formfeed(); - } - reset_footer(); + // stampa totale soggetti a fine stampa + reset_footer(); + TString sep(132); + sep.fill('-'); + set_footer(2, (const char *) sep); + if (_totale > 0 && _totale != _contatore) + { + set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _totale); + printer().formfeed(); + } + reset_footer(); } void TChiusuraPeriodica::header_sezione(const TString16 codsez, const TString16 codsot) { - const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ); - const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT); - TString intestazione(132); - intestazione = "Sezione: "; - intestazione << codsez; - if (codsot.not_empty()) - { - intestazione << '/'; - intestazione << codsot; - } - intestazione << ' '; - intestazione << densez; - if (densot.not_empty()) - { - intestazione << '/'; - intestazione << densot; - } + const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ); + const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT); + TString intestazione(132); + intestazione = "Sezione: "; + intestazione << codsez; + if (codsot.not_empty()) + { + intestazione << '/'; + intestazione << codsot; + } + intestazione << ' '; + intestazione << densez; + if (densot.not_empty()) + { + intestazione << '/'; + intestazione << densot; + } - intestazione.center_just(); - set_header(1,"@0g%s", (const char*) intestazione); - return; + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; } void TChiusuraPeriodica::set_page(int file, int cnt) { - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); - set_row(1,"@12g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - set_row(1,"@38g@S", FLD(LF_SOGGETTI,SOG_NOME)); - set_row(1,"@64g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); - set_row(1,"@75g@S", FLD(LF_SOGGETTI,SOG_TELABI)); - set_row(1,"@90g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); - set_row(1,"@105g@S", FLD(LF_SOGGETTI,SOG_TELALT)); - set_row(1,"@120g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); - set_row(1,"@131g@ld", FLD(LF_SOGGETTI,SOG_DATAISC)); - set_row(1,"@142g@pn", FLD(LF_SOGGETTI,SOG_TOTDON, "###")); - set_row(1,"@152g@6,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); - set_row(1,"@159g#a", &_operazione); + set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); + set_row(1,"@12g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(1,"@38g@S", FLD(LF_SOGGETTI,SOG_NOME)); + set_row(1,"@64g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@75g@S", FLD(LF_SOGGETTI,SOG_TELABI)); + set_row(1,"@90g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); + set_row(1,"@105g@S", FLD(LF_SOGGETTI,SOG_TELALT)); + set_row(1,"@120g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@131g@ld", FLD(LF_SOGGETTI,SOG_DATAISC)); + set_row(1,"@142g@pn", FLD(LF_SOGGETTI,SOG_TOTDON, "###")); + set_row(1,"@152g@6,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@159g#a", &_operazione); } bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel) { - bool filtrato = FALSE; - TRectype& recsog = rel->lfile().curr(); - if (!app()._sospesi) - { - const char stato = modstato_tcs(recsog.get(SOG_STATO)); - if (stato == 'S') - return FALSE; - const char statosi = modstato_tcs(recsog.get(SOG_STATOSI)); - if (statosi == 'S') - return FALSE; - const char statoaf = modstato_tcs(recsog.get(SOG_STATOAF)); - if (statoaf == 'S') - return FALSE; - } + bool filtrato = FALSE; + TRectype& recsog = rel->lfile().curr(); + if (!app()._sospesi) + { + const char stato = modstato_tcs(recsog.get(SOG_STATO)); + if (stato == 'S') + return FALSE; + const char statosi = modstato_tcs(recsog.get(SOG_STATOSI)); + if (statosi == 'S') + return FALSE; + const char statoaf = modstato_tcs(recsog.get(SOG_STATOAF)); + if (statoaf == 'S') + return FALSE; + } if (app()._usosez) { - TRectype& recsez = rel->lfile(LF_SEZIONI).curr(); - const TString16 cat_estinti = recsez.get(SEZ_CATESTI); - const TString16 cat_cancellati = recsez.get(SEZ_CATCANC); - const TString16 cat_emeriti = recsez.get(SEZ_CATEMER); - const int intesti = recsez.get_int(SEZ_INTESTI); - const int donemer = recsez.get_int(SEZ_DONEMER); - if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0)) - { - const TString16 catsog = recsog.get(SOG_CATDON); - if (catsog == cat_cancellati && cat_cancellati.not_empty()) - filtrato = TRUE; // da cancellare - else - { - if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0)) - { - const bool dimesso = rel->lfile(-ALIAS_CTD).get_bool("B0"); - if (!dimesso) - { - TDate dataultdon = recsog.get(SOG_DATAULTDON); - if (dataultdon.ok()) - { - dataultdon.addyear(intesti); - filtrato = (dataultdon < app()._data_chiusura); - } - } - } - } - } - } - else - { - TAssoc_array& categorie = app()._categorie; - if (categorie.items() != 0) - { - const TString16 cat = recsog.get(SOG_CATDON); - filtrato = categorie.is_key((const char*) cat); - } - if (filtrato) - { - const bool dimesso = rel->lfile(-ALIAS_CTD).get_bool("B0"); - if (!dimesso) - { - TDate data = recsog.get(SOG_DATAULTDON); - if (data.ok()) - filtrato = (data < app()._dataud); - else - { - data = recsog.get(SOG_DATAISC); - if (data.ok()) - filtrato = (data < app()._dataud); - } - if (filtrato) - { - TRectype* key = new TRectype(LF_CONTSAN); - long codice = recsog.get_long(SOG_CODICE); - key->put(CON_CODICE, codice); - int err = app()._scontrolli->read(key); - if (err == NOERR) - { - const TRectype& riga = app()._scontrolli->row(app()._scontrolli->rows()); - data = riga.get_date(CON_DATACON); - if (data >= app()._dataud) - filtrato = FALSE; - } - } - } - } - } - return filtrato; + TRectype& recsez = rel->lfile(LF_SEZIONI).curr(); + const TString16 cat_estinti = recsez.get(SEZ_CATESTI); + const TString16 cat_cancellati = recsez.get(SEZ_CATCANC); + const TString16 cat_emeriti = recsez.get(SEZ_CATEMER); + const int intesti = recsez.get_int(SEZ_INTESTI); + const int donemer = recsez.get_int(SEZ_DONEMER); + if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0)) + { + const TString16 catsog = recsog.get(SOG_CATDON); + if (catsog == cat_cancellati && cat_cancellati.not_empty()) + filtrato = TRUE; // da cancellare + else + { + if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0)) + { + const bool dimesso = rel->lfile(-ALIAS_CTD).get_bool("B0"); + if (!dimesso) + { + TDate dataultdon = recsog.get(SOG_DATAULTDON); + if (dataultdon.ok()) + { + dataultdon.addyear(intesti); + filtrato = (dataultdon < app()._data_chiusura); + } + } + } + } + } + } + else + { + TAssoc_array& categorie = app()._categorie; + if (categorie.items() != 0) + { + const TString16 cat = recsog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + if (filtrato) + { + const bool dimesso = rel->lfile(-ALIAS_CTD).get_bool("B0"); + if (!dimesso) + { + TDate data = recsog.get(SOG_DATAULTDON); + if (data.ok()) + filtrato = (data < app()._dataud); + else + { + data = recsog.get(SOG_DATAISC); + if (data.ok()) + filtrato = (data < app()._dataud); + } + if (filtrato) + { + TRectype* key = new TRectype(LF_CONTSAN); + long codice = recsog.get_long(SOG_CODICE); + key->put(CON_CODICE, codice); + TRecord_array& contsan = *app()._scontrolli; + int err = contsan.read(key); + if (err == NOERR) + { + int ultimariga = contsan.last_row(); + if (ultimariga > 0) + { + const TRectype& riga = contsan.row(ultimariga); + data = riga.get_date(CON_DATACON); + if (data >= app()._dataud) + filtrato = FALSE; + } + } + } + } + } + } + return filtrato; } bool TChiusuraPeriodica::set_print(int) { KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { - _codsez = "**"; - _codsez = "**"; - _contatore = 0; - _totale = 0; - _usosez = _msk->get_bool(F_USOSEZ); - _data_chiusura = _msk->get_date(F_DATA); - _categorie.destroy(); - const TString16 catpri = _msk->get(F_CAT1); - const TString16 catsec = _msk->get(F_CAT2); - const TString16 catter = _msk->get(F_CAT3); - const TString16 catqua = _msk->get(F_CAT4); - const TString16 catqui = _msk->get(F_CAT5); - const TString16 catses = _msk->get(F_CAT6); - if (catpri.not_empty()) - _categorie.add((const char*) catpri); - if (catsec.not_empty()) - _categorie.add((const char*) catsec); - if (catter.not_empty()) - _categorie.add((const char*) catter); - if (catqua.not_empty()) - _categorie.add((const char*) catqua); - if (catqui.not_empty()) - _categorie.add((const char*) catqui); - if (catses.not_empty()) - _categorie.add((const char*) catses); - _dataud = _msk->get_date(F_DATAUD); - _numdon = _msk->get_int(F_NUMDON); - _catfin1 = _msk->get(F_CATFIN1); - _catfin2 = _msk->get(F_CATFIN2); - _contsan1 = _msk->get(F_CONTSAN1); - _contsan2 = _msk->get(F_CONTSAN2); - _motivo = _msk->get(F_MOTIVO); - _definitiva = _msk->get_bool(F_DEFINITIVA); - _sospesi = _msk->get_bool(F_SOSPESI); + if (tasto == K_ENTER) + { + _codsez = "**"; + _codsez = "**"; + _contatore = 0; + _totale = 0; + _usosez = _msk->get_bool(F_USOSEZ); + _data_chiusura = _msk->get_date(F_DATA); + _categorie.destroy(); + const TString16 catpri = _msk->get(F_CAT1); + const TString16 catsec = _msk->get(F_CAT2); + const TString16 catter = _msk->get(F_CAT3); + const TString16 catqua = _msk->get(F_CAT4); + const TString16 catqui = _msk->get(F_CAT5); + const TString16 catses = _msk->get(F_CAT6); + if (catpri.not_empty()) + _categorie.add((const char*) catpri); + if (catsec.not_empty()) + _categorie.add((const char*) catsec); + if (catter.not_empty()) + _categorie.add((const char*) catter); + if (catqua.not_empty()) + _categorie.add((const char*) catqua); + if (catqui.not_empty()) + _categorie.add((const char*) catqui); + if (catses.not_empty()) + _categorie.add((const char*) catses); + _dataud = _msk->get_date(F_DATAUD); + _numdon = _msk->get_int(F_NUMDON); + _catfin1 = _msk->get(F_CATFIN1); + _catfin2 = _msk->get(F_CATFIN2); + _contsan1 = _msk->get(F_CONTSAN1); + _contsan2 = _msk->get(F_CONTSAN2); + _motivo = _msk->get(F_MOTIVO); + _definitiva = _msk->get_bool(F_DEFINITIVA); + _sospesi = _msk->get_bool(F_SOSPESI); reset_files(); add_file(LF_SOGGETTI); - filtra_sezioni(); - current_cursor()->set_filterfunction(filter_func_chiusura,TRUE); - reset_print(); - printer().footerlen(0); + filtra_sezioni(); + current_cursor()->set_filterfunction(filter_func_chiusura,TRUE); + reset_print(); + printer().footerlen(0); crea_intestazione(); return TRUE; } @@ -476,62 +481,62 @@ bool TChiusuraPeriodica::set_print(int) void TChiusuraPeriodica::crea_intestazione() { - reset_header(); - TString sep(132); - sep = ""; - if (_definitiva) - sep << "CHIUSURA - DEFINITIVA - ALLA DATA "; - else - sep << "CHIUSURA - PROVVISORIA - ALLA DATA "; - if (_usosez) - sep << _data_chiusura.string(); - else - sep << _dataud.string(); - sep.center_just(); - set_header(2, "@0g%s", (const char*) sep); - TDate data_stampa(TODAY); - set_header(2,"@0g%10s", (const char*) data_stampa.string()); - sep = ""; - sep << "Pag. @#"; - set_header(2, "@120g%s", (const char*) sep); - sep = ""; - sep.fill('-'); - set_header(3, (const char *) sep); - set_header(4,"@0gCodice@9gC.@12gCognome@38gNome@64gData nasc.@75gTel.Abit.@90gTel. Lav.@105gTel.Altro@120gDt.ult.don.@131gData Iscr.@142gTot. don.@152gT.AVIS@159gOp."); - set_header(5,"@0g--------@9g--@12g-------------------------@38g-------------------------@64g----------@75g--------------@90g--------------@105g--------------@120g----------@131g----------@142g---------@152g------@159g----------"); - printer().footerlen(3); + reset_header(); + TString sep(132); + sep = ""; + if (_definitiva) + sep << "CHIUSURA - DEFINITIVA - ALLA DATA "; + else + sep << "CHIUSURA - PROVVISORIA - ALLA DATA "; + if (_usosez) + sep << _data_chiusura.string(); + else + sep << _dataud.string(); + sep.center_just(); + set_header(2, "@0g%s", (const char*) sep); + TDate data_stampa(TODAY); + set_header(2,"@0g%10s", (const char*) data_stampa.string()); + sep = ""; + sep << "Pag. @#"; + set_header(2, "@120g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(3, (const char *) sep); + set_header(4,"@0gCodice@9gC.@12gCognome@38gNome@64gData nasc.@75gTel.Abit.@90gTel. Lav.@105gTel.Altro@120gDt.ult.don.@131gData Iscr.@142gTot. don.@152gT.AVIS@159gOp."); + set_header(5,"@0g--------@9g--@12g-------------------------@38g-------------------------@64g----------@75g--------------@90g--------------@105g--------------@120g----------@131g----------@142g---------@152g------@159g----------"); + printer().footerlen(3); } bool TChiusuraPeriodica::user_create() { - _msk = new TMask("at0600a"); - _rel = new TRelation(LF_SOGGETTI); - _rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT"); + _msk = new TMask("at0600a"); + _rel = new TRelation(LF_SOGGETTI); + _rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT"); _rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD); _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); - //cursore ordinamento per sezione+sottogruppo+cognome+nome + //cursore ordinamento per sezione+sottogruppo+cognome+nome _cur = add_cursor(new TCursor(_rel, "", 3)); - _contsan = new TLocalisamfile(LF_CONTSAN); - _idoneita = new TLocalisamfile(LF_IDONEITA); - _scontrolli = new TRecord_array(LF_CONTSAN, CON_PROGCON); - _sidoneita = new TRecord_array(LF_IDONEITA, IDO_PROGIDO); - return TRUE; -} + _contsan = new TLocalisamfile(LF_CONTSAN); + _idoneita = new TLocalisamfile(LF_IDONEITA); + _scontrolli = new TRecord_array(LF_CONTSAN, CON_PROGCON); + _sidoneita = new TRecord_array(LF_IDONEITA, IDO_PROGIDO); + return TRUE; +} -bool TChiusuraPeriodica::user_destroy() +bool TChiusuraPeriodica::user_destroy() { - delete _sidoneita; - delete _scontrolli; - delete _idoneita; - delete _contsan; - delete _rel; - delete _msk; - return TRUE; + delete _sidoneita; + delete _scontrolli; + delete _idoneita; + delete _contsan; + delete _rel; + delete _msk; + return TRUE; } int at0600(int argc, char* argv[]) { - TChiusuraPeriodica a; - a.run(argc, argv, "Chiusura periodica"); - return 0; + TChiusuraPeriodica a; + a.run(argc, argv, "Chiusura periodica"); + return 0; } \ No newline at end of file