From ca68acd0179fbeb8f992e5e5d025143379ea75f3 Mon Sep 17 00:00:00 2001 From: cris Date: Thu, 5 Feb 1998 15:28:06 +0000 Subject: [PATCH] Corretto funzionamento chiusura periodica: non vengono chiusi i dimessi git-svn-id: svn://10.65.10.50/trunk@6127 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- at/at0600.cpp | 207 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 132 insertions(+), 75 deletions(-) diff --git a/at/at0600.cpp b/at/at0600.cpp index d3331366a..492aa9e39 100755 --- a/at/at0600.cpp +++ b/at/at0600.cpp @@ -16,6 +16,8 @@ #include "storico.h" #include "sezioni.h" +#define ALIAS_CTD 700 // categoria donatori + class TChiusuraPeriodica : public TPrintapp { static bool filter_func_chiusura(const TRelation* rel); @@ -26,6 +28,7 @@ class TChiusuraPeriodica : public TPrintapp TDate _data_chiusura; TParagraph_string _operazione; bool _definitiva; + TString16 _codsez, _codsot; protected: virtual bool user_create(); @@ -37,6 +40,7 @@ protected: public: void filtra_sezioni(); + void header_sezione(const TString16 codsez, const TString16 codsot); void crea_intestazione(); TChiusuraPeriodica() : _data_chiusura(TODAY), _operazione("",30) {} }; @@ -64,67 +68,110 @@ void TChiusuraPeriodica::filtra_sezioni() bool TChiusuraPeriodica::preprocess_page(int file, int counter) -{ - _operazione = "Nulla"; - +{ + _operazione = "Non deve essere filtrato"; 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 != "**") + printer().formfeed(); + _codsez = codsez; + _codsot = codsot; + header_sezione(codsez, codsot); + } TLocalisamfile& filesog = current_cursor()->file(); - 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); - - const TString16 catsog = recsog.get(SOG_CATDON); - - - if ((catsog==cat_estinti && cat_estinti.not_empty()) - || (catsog==cat_cancellati && cat_cancellati.not_empty())) - { - const int totdon = recsog.get_int(SOG_TOTDON); - if (totdon >= donemer && donemer != 0) - { - _operazione = "Passaggio a emeriti"; - if (_definitiva) - { - recsog.put(SOG_CATDON,cat_emeriti); - filesog.rewrite(); - } - } - else + 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()) { _operazione = "Cancellato"; if (_definitiva) filesog.remove(); - } - } - else - { - TDate dataultdon = recsog.get(SOG_DATAULTDON); - if (dataultdon.ok()) - { - dataultdon.addyear(intesti); - if (dataultdon < _data_chiusura) - { - _operazione = "Passaggio a estinti"; - if (_definitiva) - { - recsog.put(SOG_CATDON,cat_estinti); - filesog.rewrite(); - } - } - else - _operazione = "Non doveva essere filtrato: data ancora valida"; } - else - _operazione = "Non doveva essere filtrato: data vuota"; - } + 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); + 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); + filesog.rewrite(); + } + } + } + } + } + } + } + } + } return TRUE; } +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; + intestazione << "/"; + intestazione << codsot; + intestazione << " "; + intestazione << densez; + if ((densot.ok())&& (densot.not_empty())) + { + intestazione << "/"; + intestazione << densot; + } + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} void TChiusuraPeriodica::set_page(int file, int cnt) { @@ -132,7 +179,9 @@ void TChiusuraPeriodica::set_page(int file, int cnt) 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,"@65g#a", &_operazione); + set_row(1,"@65g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@76g@n", FLD(LF_SOGGETTI,SOG_TOTDON)); + set_row(1,"@80g#a", &_operazione); } bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel) @@ -141,24 +190,33 @@ bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel) TRectype& recsez = rel->lfile(LF_SEZIONI).curr(); TRectype& recsog = rel->lfile().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 TString16 catsog = recsog.get(SOG_CATDON); - filtrato = ((catsog == cat_estinti && cat_estinti.not_empty()) || - (catsog == cat_cancellati && cat_cancellati.not_empty())); - if (!filtrato && catsog != cat_emeriti) - { - TDate dataultdon = recsog.get(SOG_DATAULTDON); - if (dataultdon.ok()) + 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 { - dataultdon.addyear(intesti); - filtrato = (dataultdon < app()._data_chiusura); - } - } + 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); + } + } + } + } + } return filtrato; } @@ -167,7 +225,9 @@ bool TChiusuraPeriodica::set_print(int) KEY tasto; tasto = _msk->run(); if (tasto == K_ENTER) - { + { + _codsez = "**"; + _codsez = "**"; _definitiva = _msk->get_bool(F_DEFINITIVA); _data_chiusura = _msk->get(F_DATA); reset_files(); @@ -182,27 +242,23 @@ bool TChiusuraPeriodica::set_print(int) return FALSE; } - void TChiusuraPeriodica::crea_intestazione() { reset_header(); - TString sep(132); - TString16 data_stampa; - - sep.fill('-'); - set_header(1, (const char *) sep); + sep = ""; + if (_definitiva) + sep << "CHIUSURA - DEFINITIVA - ALLA DATA "; + else + sep << "CHIUSURA - PROVVISORIA - ALLA DATA "; + sep << _data_chiusura.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. @#"; - sep.right_just(132); - set_header(2,(const char*) sep); - - if (_definitiva) - set_header(2,"@0gCHIUSURA PERIODICA - DEFINITIVA - ALLA DATA"); - else - set_header(2,"@0gCHIUSURA PERIODICA - PROVVISORIA - ALLA DATA"); - data_stampa = _data_chiusura.string(); - set_header(2,"@47g%10s", (const char*) data_stampa); + set_header(2, "@120g%s", (const char*) sep); sep = ""; sep.fill('-'); set_header(3, (const char *) sep); @@ -213,6 +269,7 @@ bool TChiusuraPeriodica::user_create() _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); //cursore ordinamento per sezione+sottogruppo+cognome+nome _cur = add_cursor(new TCursor(_rel, "", 3)); return TRUE;