From 2382115d55d81eb5dbb64626028e4d105a7e6f19 Mon Sep 17 00:00:00 2001 From: cris Date: Thu, 31 Oct 2002 09:13:52 +0000 Subject: [PATCH] Patch level : at Files correlati : Ricompilazione Demo : [ ] Commento : riorganizzazione storica at git-svn-id: svn://10.65.10.50/trunk@10588 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- at/at7.cpp | 4 +- at/at7.h | 17 +- at/at7100.cpp | 500 +++++++++++++++++++++++++++++++--------- at/at7100.h | 7 + at/at7100a.h | 31 +++ at/at7200.cpp | 572 ++++++++++++++++++++++++++++++++++----------- at/at7200a.h | 23 ++ at/at7300.cpp | 627 ++++++++++++++++++++++++++++++++++++++++---------- at/at7300a.h | 22 ++ at/at7400.cpp | 418 +++++++++++++++++++++++++++------ at/at7400a.h | 10 + at/at7500.cpp | 598 +++++++++++++++++++++++++++++++++++------------ at/at7500a.h | 38 +++ at/at7600.cpp | 516 +++++++++++++++++++++++++++++++---------- at/at7700.cpp | 407 ++++++++++++++++++++++++-------- at/at7700a.h | 39 ++++ at/at7800.cpp | 532 +++++++++++++++++++++++++++--------------- 17 files changed, 3344 insertions(+), 1017 deletions(-) create mode 100755 at/at7100.h create mode 100755 at/at7100a.h create mode 100755 at/at7200a.h create mode 100755 at/at7300a.h create mode 100755 at/at7400a.h create mode 100755 at/at7500a.h create mode 100755 at/at7700a.h diff --git a/at/at7.cpp b/at/at7.cpp index 0fbb88693..6f80a5324 100755 --- a/at/at7.cpp +++ b/at/at7.cpp @@ -4,7 +4,7 @@ #include "at7.h" -#define usage "Error - usage : %s -{0|1|2|3|4|5|6|7|8}" +#define usage "Error - usage : %s -{0|1|2|3|4|5|6|7}" int main(int argc,char** argv) @@ -30,8 +30,6 @@ int main(int argc,char** argv) rt = at7700(argc,argv) ; break; case 7: rt = at7800(argc,argv) ; break; - case 8: - rt = at7900(argc,argv) ; break; default: error_box(usage, argv[0]) ; break; } diff --git a/at/at7.h b/at/at7.h index db6cd2ad9..7b5c60bac 100755 --- a/at/at7.h +++ b/at/at7.h @@ -1,15 +1,14 @@ #ifndef __AT7_H #define __AT7_H -int at7100(int argc, char* argv[]); -int at7200(int argc, char* argv[]); -int at7300(int argc, char* argv[]); -int at7400(int argc, char* argv[]); -int at7500(int argc, char* argv[]); -int at7600(int argc, char* argv[]); -int at7700(int argc, char* argv[]); -int at7800(int argc, char* argv[]); -int at7900(int argc, char* argv[]); +int at7100(int argc, char* argv[]); //stampa tessere associative complessive +int at7200(int argc, char* argv[]); // stampa tessere associative complessive +int at7300(int argc, char* argv[]); // stampe singole +int at7400(int argc, char* argv[]); // stampe per codice +int at7500(int argc, char* argv[]); // stampa soggetti selezionabili per dati statistici +int at7600(int argc, char* argv[]); // stampa per consenso +int at7700(int argc, char* argv[]); // stampa soggetti non domiciliati nel comune di sezione +int at7800(int argc, char* argv[]); // stampa soggetti incompleti #endif // __AT7_H diff --git a/at/at7100.cpp b/at/at7100.cpp index 99a8ea366..64ba3df2d 100755 --- a/at/at7100.cpp +++ b/at/at7100.cpp @@ -1,149 +1,427 @@ +#include #include +#include #include -#include #include -#include + +#include "soggetti.h" +#include "sezioni.h" +#include "atopera.h" +#include "atropera.h" +#include #include "at7.h" +#include "at7100a.h" -// nomi dei campi -#include "soggetti.h" +#include "at7100.h" +#define ALIAS_COMDOM 501 +#define ALIAS_COMNAS 500 +#define ALIAS_LCP 100 -#define ALIAS_LCPD 100 -#define ALIAS_LCPR 200 -#define ALIAS_COMD 300 -#define ALIAS_COMR 400 +enum ts { undefined = 0, elenco = 1, tessere = 2 }; -class TAggiornaCAP : public TPrintapp +// definizione form per tessere associative +class TTessere_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - bool _scrivi; - - static bool filter_func_cap(const TRelation* rel); - -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); - public: - TAggiornaCAP() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TTessere_form(): TForm() {}; + TTessere_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TTessere_form() {}; }; -HIDDEN inline TAggiornaCAP& app() { return (TAggiornaCAP&) main_app(); } +class TStampaTessere : public TPrintapp +{ + TRelation* _rel; + TMask* _msk; + TAssoc_array _categorie; + TTessere_form* _form_pag; + int _numdon; + bool _aggiorna; + int _cur; + TDate _data_stampa, _datault; + TString _riepilogodon; + ts _tipostampa; + TString16 _codsez, _codsot; + int _contatore, _totfinestampa, _progope; + bool _sttess2; + int _numdon2; + TString16 _catini2, _catfin2; -bool TAggiornaCAP::filter_func_cap(const TRelation* rel) + static bool filter_func_auto(const TRelation* rel); + +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 print_action postprocess_print(int file, int counter); + +public: + void crea_intestazione(); + void filtra_sezioni(); + void footer_sezione(); + void fine_stampa(); + void header_sezione(const TString16 codsez, const TString16 codsot); + TMask& app_mask() { return *_msk; } + TStampaTessere() : _data_stampa(TODAY), _riepilogodon(35) {} +}; + +HIDDEN inline TStampaTessere& app() { return (TStampaTessere&) main_app(); } + +TCursor* TTessere_form::cursor() const { return app().current_cursor(); } + +TRelation* TTessere_form::relation() const { return cursor()->relation(); } + +void TStampaTessere::header_sezione(const TString16 codsez, const TString16 codsot) { - bool filtrato = FALSE; - TString16 cap; - TString16 loc; - TString16 capcom; - TRectype recsog = rel->lfile().curr(); - cap = recsog.get(SOG_DOM_CAP); - loc = recsog.get(SOG_DOM_CODLOC); - if (loc.empty()) - capcom = rel->lfile(-ALIAS_COMD).get("CAPCOM"); - else - capcom = rel->lfile(-ALIAS_LCPD).get("S6"); - if (capcom.not_empty() && cap != capcom) - filtrato = TRUE; - - cap = recsog.get(SOG_RES_CAP); - loc = recsog.get(SOG_RES_CODLOC); - if (loc.empty()) - capcom = rel->lfile(-ALIAS_COMR).get("CAPCOM"); - else - capcom = rel->lfile(-ALIAS_LCPR).get("S6"); - if (capcom.not_empty() && cap != capcom) - filtrato = TRUE; - return filtrato; + TPrintrow row; + TString256 intestazione; + const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ); + const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT); + 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); + row.put((const char*) intestazione); + printer().print(row); + row.reset(); + printer().print(row); + row.put("@8gCognome@34gNome@60gData nasc.@71gTessera@78gUld.donaz.@89gTot.",1); + printer().print(row); + row.put("@8g-------------------------@34g-------------------------@60g----------@71g-------@78g----------@89g----",1); + printer().print(row); + return; } -bool TAggiornaCAP::preprocess_page(int file, int counter) +void TStampaTessere::footer_sezione() +{ + // stampa totale soggetti a fine pagina + TPrintrow row; + TString rigastampa = ""; + row.reset(); + printer().print(row); + rigastampa.format("TOTALE SOGGETTI PER SEZIONE %d", _contatore); + row.put((const char*) rigastampa); + printer().print(row); + row.reset(); + printer().print(row); +} + +void TStampaTessere::fine_stampa() +{ + // stampa totale soggetti a fine stampa + TPrintrow row; + TString rigastampa = ""; + rigastampa.fill('-',80); + row.put((const char*) rigastampa); + printer().print(row); + row.reset(); + printer().print(row); + rigastampa.format("TOTALE SOGGETTI DA TESSERARE %d", _totfinestampa); + row.put((const char*) rigastampa); + printer().print(row); + printer().formfeed(); +} + +print_action TStampaTessere::postprocess_print(int file, int counter) { - bool rew = FALSE; - TString16 cap; - TString16 loc; - TString16 capcom; - TRectype& recsog = current_cursor()->curr(); - cap = recsog.get(SOG_DOM_CAP); - loc = recsog.get(SOG_DOM_CODLOC); - if (loc.empty()) - capcom = current_cursor()->file(-ALIAS_COMD).get("CAPCOM"); - else - capcom = current_cursor()->file(-ALIAS_LCPD).get("S6"); - if (capcom.not_empty() && (cap != capcom)) - recsog.put(SOG_DOM_CAP, capcom); - cap = recsog.get(SOG_RES_CAP); - loc = recsog.get(SOG_RES_CODLOC); - if (loc.empty()) - capcom = current_cursor()->file(-ALIAS_COMR).get("CAPCOM"); - else - capcom = current_cursor()->file(-ALIAS_LCPR).get("S6"); - if (capcom.not_empty() && (cap != capcom)) - recsog.put(SOG_RES_CAP, capcom); - if (_scrivi) - current_cursor()->file().rewrite(); + if (_tipostampa == elenco) + { + if (_contatore > 0) + footer_sezione(); + if (_totfinestampa > 0 && _contatore != _totfinestampa) + fine_stampa(); + } + return NEXT_PAGE; +} + +void TStampaTessere::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); + TRectype da(LF_SOGGETTI); + TRectype a(LF_SOGGETTI); + if (sezini.not_empty()) + da.put(SOG_CODSEZ, sezini); + if (sotini.not_empty()) + da.put(SOG_CODSOT, sotini); + if (sezfin.not_empty()) + a.put(SOG_CODSEZ, sezfin); + if (sotfin.not_empty()) + a.put(SOG_CODSOT, sotfin); + current_cursor()->setregion(da, a); +} + +void TStampaTessere::set_page(int file, int cnt) +{ + switch (_tipostampa) + { + case tessere: + { + TPrint_section& corpo = _form_pag->get_body(); + corpo.reset(); + TForm_item& rigadon = corpo.find_field(TES_RIGADON1); + rigadon.set(_riepilogodon); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case elenco: + { + set_row(1,"@8g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(1,"@34g@S", FLD(LF_SOGGETTI,SOG_NOME)); + set_row(1,"@60g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@71g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@78g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@89g@pn", FLD(LF_SOGGETTI,SOG_TOTDON, "###")); + } + break; + } +} + +bool TStampaTessere::filter_func_auto(const TRelation* rel) +{ + bool filtrato = TRUE; + TLocalisamfile& sog = rel->lfile(); + filtrato = !(sog.get_bool(SOG_T_STAMPATA)); + if (filtrato) + filtrato = (sog.get_int(SOG_TOTDON) >= app()._numdon); + if (filtrato) + filtrato = (sog.get_date(SOG_DATAULTDON) > app()._datault); + if (filtrato) + { + // filtro per categorie + TAssoc_array& categorie = app()._categorie; + if (categorie.items() != 0) + { + const TString16 cat = sog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + } + return filtrato; +} + +bool TStampaTessere::preprocess_page(int file, int counter) +{ + TLocalisamfile& sogg = current_cursor()->file(LF_SOGGETTI); + if (_tipostampa == elenco) + { + const TString16 codsez = sogg.get(SOG_CODSEZ); + const TString16 codsot = sogg.get(SOG_CODSOT); + // salto pagina se cambio sezione + if ((_codsez!=codsez)||(_codsot!=codsot)) + { + if (_codsez != "**") + footer_sezione(); + _codsez = codsez; + _codsot = codsot; + header_sezione(codsez, codsot); + _contatore = 0; + } + _contatore++; + _totfinestampa++; + } + if (_tipostampa == tessere) + { + const int totdon = sogg.get_int(SOG_TOTDON); + const TDate dataultima = sogg.get(SOG_DATAULTDON); + _riepilogodon = ""; + if (totdon != 0) + { + _riepilogodon = "Donazioni fino al "; + _riepilogodon << dataultima.string(); + _riepilogodon << " n."; + _riepilogodon << totdon; + } + if (_aggiorna) + { + sogg.put(SOG_T_STAMPATA,TRUE); + TString16 catdon = sogg.get(SOG_CATDON); + if ((totdon >= _numdon2) && (catdon == _catini2) && _sttess2) + sogg.put(SOG_CATDON, _catfin2); + sogg.rewrite(); + } + } + if (_aggiorna) + { + TLocalisamfile atropera(LF_ATROPERA); + atropera.zero(); + atropera.put(ROP_PROGOPE, _progope); + atropera.put(ROP_CODICE, sogg.get(SOG_CODICE)); + atropera.write(); + } return TRUE; } -void TAggiornaCAP::set_page(int file, int cnt) +bool TStampaTessere::set_print(int m) { - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME)); - set_row(1,"@62g@S", FLD(LF_SOGGETTI,SOG_CODSEZ)); - set_row(1,"@67g@S", FLD(LF_SOGGETTI,SOG_DOM_CAP)); - set_row(1,"@74g@S", FLD(LF_SOGGETTI,SOG_RES_CAP)); - set_row(1,"@81g@ld", FLD(LF_SOGGETTI,SOG_DATAULTAGG)); - set_row(1,"@92g@S", FLD(LF_SOGGETTI,SOG_UTENULTAGG)); -} - -bool TAggiornaCAP::set_print(int) -{ + TPrinter& p = printer(); + p.read_configuration(); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { - _scrivi = !_msk->get_bool(102); + switch (tasto) + { + case F_ELENCO: + _tipostampa = elenco; + break; + case F_TESSERE: + { + _tipostampa = tessere; + p.read_configuration("AT_TESSERE"); + p.set_printtype(winprinter); + if (p.set()) + message_box("Stampante configurata per stampa tessere"); + else + { + _tipostampa = undefined; + message_box("Operazione di stampa tessere annullata"); + } + } + break; + } + if (_tipostampa != undefined) + { + _codsez = "**"; + _codsot = "**"; reset_files(); add_file(LF_SOGGETTI); - if (_msk->get_bool(101)) - current_cursor()->setfilter("(90->DOM_CODLOC != \"\")", TRUE); - current_cursor()->set_filterfunction (filter_func_cap, FALSE); - reset_print(); + filtra_sezioni(); + _numdon = _msk->get_int(F_NUMDON); + _aggiorna = _msk->get_bool(F_AGGIORNA); + _datault = _msk->get_date(F_DATAULT); + _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); + current_cursor()->set_filterfunction (filter_func_auto, TRUE); + _contatore = 0; + _totfinestampa = 0; + if (_aggiorna) + { + TLocalisamfile atopera(LF_ATOPERA); + atopera.last(); + _progope = atopera.get_int(OPE_PROGOPE); + _progope++; + atopera.zero(); + atopera.put(OPE_PROGOPE, _progope); + atopera.put(OPE_CODSEZ,_msk->get(F_SEZINI)); + atopera.put(OPE_CODSOT,_msk->get(F_SOTINI)); + atopera.put(OPE_CODSEZ2,_msk->get(F_SEZFIN)); + atopera.put(OPE_CODSOT2,_msk->get(F_SOTFIN)); + atopera.put(OPE_DATA1,_data_stampa); + atopera.put(OPE_DATA2,_datault); + atopera.put(OPE_NUMERO1,_numdon); + atopera.put(OPE_UTENTE,user()); + atopera.put(OPE_TIPOOPE,'T'); + atopera.write(); + } + reset_print(); + printer().footerlen(0); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TAggiornaCAP::user_create() +bool TStampaTessere::user_create() { - _msk = new TMask("at7100a"); - _rel = new TRelation(LF_SOGGETTI); - _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPD); - _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMD); - _rel->add("LCP", "CODTAB==RES_CODLOC",1,0,ALIAS_LCPR); - _rel->add(LF_COMUNI, "COM==RES_CODCOM",1,0,ALIAS_COMR); - _cur = add_cursor(new TCursor(_rel, "", 1)); - return TRUE; -} + _rel = new TRelation(LF_SOGGETTI); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM); + _rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCP); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + //cursore ordinamento per sezione+sottogruppo+cognome+nome + _cur = add_cursor(new TCursor(_rel, "", 3)); + _msk = new TMask("at7100a"); + TConfig config(CONFIG_STUDIO); + _numdon2 = config.get_int("NumDon2"); + _catini2 = config.get("CatIni2"); + _catfin2 = config.get("CatFin2"); + _sttess2 = config.get_bool("StTess2"); + _form_pag = new TTessere_form("ATTESSER"); + return TRUE; +} -bool TAggiornaCAP::user_destroy() +void TStampaTessere::crea_intestazione() { - delete _rel; - delete _msk; - return TRUE; + reset_header(); + if (_tipostampa == elenco) + { + TString sep(80); + sep = "ELENCO SOGGETTI DA TESSERARE"; + sep.center_just(80); + set_header(1, "@0g%s", (const char*) sep); + TString16 data_stampa = _data_stampa.string(); + set_header(1,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(1, "@72g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(2, (const char *) sep); + set_header(3, ""); + /* + set_header(4,"@0gCognome@26gNome@52gData nasc.@63gTessera"); + set_header(5,"@0g-------------------------@26g-------------------------@52g----------@63g-------"); + printer().footerlen(3); + */ + } +} + +bool TStampaTessere::user_destroy() +{ + delete _form_pag; + delete _msk; + delete _rel; + return TRUE; } int at7100(int argc, char* argv[]) { - TAggiornaCAP a; - a.run(argc, argv, "Aggiornamento CAP su indirizzi"); - return 0; -} \ No newline at end of file + TStampaTessere a; + a.run(argc, argv, "Stampa tessere associative complessive"); + return 0; +} diff --git a/at/at7100.h b/at/at7100.h new file mode 100755 index 000000000..a7002293b --- /dev/null +++ b/at/at7100.h @@ -0,0 +1,7 @@ +// stampa tessere associative +// definizione campi del form + +#define TES_RIGADON1 25 +#define TES_RIGADON2 26 +#define TES_RIGADON3 27 +#define TES_RIGADON4 28 \ No newline at end of file diff --git a/at/at7100a.h b/at/at7100a.h new file mode 100755 index 000000000..90a6d6d50 --- /dev/null +++ b/at/at7100a.h @@ -0,0 +1,31 @@ +// stampa tessere associative +// definizione campi per maschera di selezione + +#define F_SEZINI 101 +#define F_D_SEZINI 102 +#define F_SOTINI 103 +#define F_D_SOTINI 104 +#define F_SEZFIN 105 +#define F_D_SEZFIN 106 +#define F_SOTFIN 107 +#define F_D_SOTFIN 108 + +#define F_CAT1 201 +#define F_D_CAT1 202 +#define F_CAT2 203 +#define F_D_CAT2 204 +#define F_CAT3 205 +#define F_D_CAT3 206 +#define F_CAT4 207 +#define F_D_CAT4 208 +#define F_CAT5 209 +#define F_D_CAT5 210 +#define F_CAT6 211 +#define F_D_CAT6 212 + +#define F_NUMDON 301 +#define F_DATAULT 302 +#define F_AGGIORNA 303 + +#define F_ELENCO 401 +#define F_TESSERE 402 diff --git a/at/at7200.cpp b/at/at7200.cpp index 06c1dabeb..e06040e99 100755 --- a/at/at7200.cpp +++ b/at/at7200.cpp @@ -1,159 +1,469 @@ +#include #include +#include #include -#include -#include #include -#include + +#include "soggetti.h" +#include "sezioni.h" +#include #include "at7.h" +#include "at7200a.h" -// nomi dei campi -#include "soggetti.h" -#include "donaz.h" -#include "storico.h" +#include "at7100.h" +#define ALIAS_COMDOM 501 +#define ALIAS_COMNAS 500 +#define ALIAS_LCP 100 -class TPrimaDon : public TPrintapp +enum ts { undefined = 0, elenco = 1, tessere = 2 }; + +// definizione form per tessere associative +class TTessereS_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - TLocalisamfile* _donaz; - TRecord_array* _sdonazioni; - TLocalisamfile* _storico; - TRecord_array* _sstorico; - -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); - public: - TPrimaDon() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TTessereS_form(): TForm() {}; + TTessereS_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TTessereS_form() {}; }; -HIDDEN inline TPrimaDon& app() { return (TPrimaDon&) main_app(); } - -bool TPrimaDon::preprocess_page(int file, int counter) -{ - bool rewrite = FALSE; - TRectype& recsog = current_cursor()->curr(); - const TString sezsog = recsog.get(SOG_CODSEZ); - const TString sotsog = recsog.get(SOG_CODSOT); - const TDate dataisc = recsog.get_date(SOG_DATAISC); - const long codice = recsog.get_long(SOG_CODICE); - TRectype* keys = new TRectype(LF_STORICO); - keys->put(STO_CODICE, codice); - int errs = _sstorico->read(keys); - TRectype* keyd = new TRectype(LF_DONAZ); - keyd->put(DON_CODICE, codice); - int errd = _sdonazioni->read(keyd); - if ((errd == NOERR) && (_sdonazioni->rows()>0)) - { - /* - for (int d=1; d<=_sdonazioni->rows(); d++) - { - TRectype& riga = _sdonazioni->row(d, TRUE); - TString16 codsez = riga.get(DON_CODSEZ); - TString16 codsot = riga.get(DON_CODSOT); - TDate datadon = riga.get_date(DON_DATADON); - if (codsez.empty() && codsot.empty()) - { - if (_sstorico->rows()>0) - { - for (int s=1; s<=_sstorico->rows(); s++) - { - TRectype& rigas = _sstorico->row(s, TRUE); - TDate dataisc = rigas.get_date(STO_DATAISC); - TDate datadim = rigas.get_date(STO_DATADIM); - if ((datadon >= dataisc) && ( (datadon <= datadim) || (datadim.empty()) )) - { - riga.put(DON_CODSEZ,rigas.get(STO_CODSEZ)); - riga.put(DON_CODSOT,rigas.get(STO_CODSOT)); - s = _sstorico->rows()+1; - rewrite = TRUE; - } - } - } - else - { - if (datadon >= dataisc) - { - riga.put(DON_CODSEZ, sezsog); - riga.put(DON_CODSOT, sotsog); - } - } - } - } - */ - TDate dataprisi = recsog.get(SOG_DATAPRISI); - TDate datapriaf = recsog.get(SOG_DATAPRIAF); - TRectype& riga = _sdonazioni->row(1, TRUE); - TDate datadon = riga.get(DON_DATADON); - if (datadon==dataprisi || datadon==datapriaf) - { - rewrite = TRUE; - riga.put(DON_PRIMADON, TRUE); - } - else - if ((!dataprisi.ok()) && (!datapriaf.ok())) - { - rewrite = TRUE; - riga.put(DON_PRIMADON, TRUE); - } - if (rewrite) - _sdonazioni->rewrite(); - } - return rewrite; -} - -void TPrimaDon::set_page(int file, int cnt) -{ - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); -} - -bool TPrimaDon::set_print(int) +class TStampaTessereS : public TPrintapp { + TRelation* _rel; + TIsamtempfile* _sogtmp; + TMask* _msk; + TTessereS_form* _form_pag; + TAssoc_array _asoggetti; + int _numdon; + bool _aggiorna; + int _cur; + TDate _data_stampa; + ts _tipostampa; + TString _riepilogodon; + int _totfinestampa; + bool _sttess2; + int _numdon2; + TString16 _catini2, _catfin2; + +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 print_action postprocess_print(int file, int counter); + + static void add_rows_soggetti(TSheet_field& s, int count = 10, int start = 1); + static bool soggetti_notify(TSheet_field& s, int r, KEY k); + static bool nome_handler(TMask_field& f, KEY k); + static bool codice_handler(TMask_field& f, KEY k); + +public: + void crea_intestazione(); + void filtra_codici(); + void fine_stampa(); + TMask& app_mask() { return *_msk; } + TStampaTessereS() : _data_stampa(TODAY), _riepilogodon(35) {} +}; + +HIDDEN inline TStampaTessereS& app() { return (TStampaTessereS&) main_app(); } + +TCursor* TTessereS_form::cursor() const { return app().current_cursor(); } + +TRelation* TTessereS_form::relation() const { return cursor()->relation(); } + +void TStampaTessereS::add_rows_soggetti(TSheet_field& s, int count, int start) +{ + if (start == 1) + s.destroy(); + for (int r=start; rfirst(); !_sogtmp->eof(); _sogtmp->next()) + _sogtmp->remove(); + TSheet_field& s = (TSheet_field&)_msk->field(F_SOGGETTI); + for (int r=0; r < s.items(); r++) + { + TToken_string& row = s.row(r); + const long codice = row.get_long(0); + if (codice != 0) + { + TLocalisamfile soggetti(LF_SOGGETTI); + soggetti.setkey(1); + soggetti.zero(); + soggetti.put(SOG_CODICE,codice); + if (soggetti.read() == NOERR) + _sogtmp->write(soggetti.curr()); + } + } +} + +void TStampaTessereS::set_page(int file, int cnt) +{ + switch (_tipostampa) + { + case tessere: + { + TPrint_section& corpo = _form_pag->get_body(); + corpo.reset(); + TForm_item& rigadon = corpo.find_field(TES_RIGADON1); + rigadon.set(_riepilogodon); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case elenco: + { + set_row(1,"@0g@S", FLD(LF_SOGGETTI,SOG_CODSEZ)); + set_row(1,"@2g@S", FLD(LF_SOGGETTI,SOG_CODSOT)); + set_row(1,"@5g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(1,"@31g@S", FLD(LF_SOGGETTI,SOG_NOME)); + set_row(1,"@57g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@68g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@75g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@86g@pn", FLD(LF_SOGGETTI,SOG_TOTDON, "###")); + set_row(1,"@90g@S", FLD(LF_SOGGETTI,SOG_PUNTORACC)); + } + break; + } + /* + TPrint_section& corpo = _form_pag->get_body(); + corpo.update(); + //TForm_item& rigadon = corpo.find_field(TES_RIGADON1); + //rigadon.set(_riepilogodon); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + */ +} + +bool TStampaTessereS::preprocess_page(int file, int counter) +{ + if (_tipostampa == tessere) + { + TLocalisamfile& sogg = current_cursor()->file(LF_SOGGETTI); + const int totdon = sogg.get_int(SOG_TOTDON); + const TDate dataultima = sogg.get(SOG_DATAULTDON); + _riepilogodon = ""; + if (totdon != 0) + { + _riepilogodon = "Donazioni fino al "; + _riepilogodon << dataultima.string(); + _riepilogodon << " n."; + _riepilogodon << totdon; + } + if (_aggiorna) + { + // se non faccio cosi' non mi registra le variazioni!!!! + // provato come in at7100.cpp ma non va + // forse perche' la relazione e' su un'altro file principale???? + TLocalisamfile filesogg(LF_SOGGETTI); + filesogg.setkey(1); + filesogg.zero(); + filesogg.put(SOG_CODICE, sogg.get_long(SOG_CODICE)); + if (filesogg.read() == NOERR) + { + filesogg.put(SOG_T_STAMPATA,TRUE); + TString16 catdon = filesogg.get(SOG_CATDON); + const int totdon = filesogg.get_int(SOG_TOTDON); + if ((totdon >= _numdon2) && (catdon == _catini2) && _sttess2) + filesogg.put(SOG_CATDON, _catfin2); + filesogg.rewrite(); + } + } + } + else + _totfinestampa++; + return TRUE; +} + +bool TStampaTessereS::set_print(int m) +{ + TPrinter& p = printer(); + p.read_configuration(); + TSheet_field& s = (TSheet_field&)_msk->field(F_SOGGETTI); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { + switch (tasto) + { + case F_ELENCO: + _tipostampa = elenco; + break; + case F_TESSERE: + { + _tipostampa = tessere; + p.read_configuration("AT_TESSERE"); + p.set_printtype(winprinter); + if (p.set()) + message_box("Stampante configurata per stampa tessere"); + else + { + _tipostampa = undefined; + message_box("Operazione di stampa tessere annullata"); + } + } + break; + case F_AZZERA: + { + TSheet_field& s = (TSheet_field&)_msk->field(F_SOGGETTI); + s.destroy(); + s.force_update(); + if (s.items()==0) + add_rows_soggetti(s,50); + } + break; + } + if (tasto==F_AZZERA) + return TRUE; + if (_tipostampa != undefined) + { reset_files(); add_file(LF_SOGGETTI); - reset_print(); + _asoggetti.destroy(); + for (int r=0; r < s.items(); r++) + { + TToken_string& row = s.row(r); + const long codice = row.get_long(0); + const char* scodice = row.get(0); + if (codice != 0) + _asoggetti.add(scodice); + } + if (_asoggetti.items() != 0) + { + _aggiorna = _msk->get_bool(F_AGGIORNA); + filtra_codici(); + } + _totfinestampa = 0; + reset_print(); + printer().footerlen(0); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TPrimaDon::user_create() +void TStampaTessereS::crea_intestazione() { - _msk = new TMask("at7200a"); - _rel = new TRelation(LF_SOGGETTI); - _donaz = new TLocalisamfile(LF_DONAZ); - _storico = new TLocalisamfile(LF_STORICO); - _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); - _sstorico = new TRecord_array(LF_STORICO,STO_PROGSTO); - _cur = add_cursor(new TCursor(_rel, "", 1)); - return TRUE; -} + reset_header(); + if (_tipostampa == elenco) + { + TString sep(94); + sep = "ELENCO TESSERE RICHIESTE"; + sep.center_just(94); + set_header(1, "@0g%s", (const char*) sep); + TString16 data_stampa = _data_stampa.string(); + set_header(1,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(1, "@86g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(2, (const char *) sep); + set_header(3,"@0gSeSo@5gCognome@31gNome@57gData nasc.@68gTess.@75gUlt.don.@86gTot Punto"); + set_header(4,"@0g----@5g-------------------------@31g-------------------------@57g----------@68g------@75g----------@86g--- -----"); + printer().footerlen(3); + set_row(1,"@0g@S", FLD(LF_SOGGETTI,SOG_CODSEZ)); + set_row(1,"@2g@S", FLD(LF_SOGGETTI,SOG_CODSOT)); + set_row(1,"@5g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(1,"@31g@S", FLD(LF_SOGGETTI,SOG_NOME)); + set_row(1,"@57g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@68g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@75g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@86g@pn", FLD(LF_SOGGETTI,SOG_TOTDON, "###")); + set_row(1,"@90g@S", FLD(LF_SOGGETTI,SOG_PUNTORACC)); + } +} -bool TPrimaDon::user_destroy() -{ - delete _sstorico; - delete _sdonazioni; - delete _storico; - delete _donaz; - delete _rel; - delete _msk; - return TRUE; +void TStampaTessereS::fine_stampa() +{ + // stampa totale soggetti a fine stampa + TPrintrow row; + TString rigastampa = ""; + rigastampa.fill('-',94); + row.put((const char*) rigastampa); + printer().print(row); + row.reset(); + printer().print(row); + rigastampa.format("TOTALE TESSERE RICHIESTE %d", _totfinestampa); + row.put((const char*) rigastampa); + printer().print(row); + printer().formfeed(); +} + +print_action TStampaTessereS::postprocess_print(int file, int counter) +{ + if (_tipostampa == elenco) + { + if (_totfinestampa>0) + fine_stampa(); + } + return NEXT_PAGE; +} + +bool TStampaTessereS::user_create() +{ + _sogtmp = new TIsamtempfile(LF_SOGGETTI,NULL,TRUE,TRUE); + _rel = new TRelation(_sogtmp); + _rel->add(LF_SOGGETTI, "CODICE==CODICE"); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM); + _rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCP); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + //cursore ordinamento per sezione+sottogruppo+cognome+nome + _cur = add_cursor(new TCursor(_rel, "", 3)); + _msk = new TMask("at7200a"); + TConfig config(CONFIG_STUDIO); + _numdon2 = config.get_int("NumDon2"); + _catini2 = config.get("CatIni2"); + _catfin2 = config.get("CatFin2"); + _sttess2 = config.get_bool("StTess2"); + _form_pag = new TTessereS_form("ATTESSER"); + TSheet_field& ss = (TSheet_field&)_msk->field(F_SOGGETTI); + add_rows_soggetti(ss,50); + ss.set_notify(soggetti_notify); + ss.sheet_mask().set_handler(F_S_NOME,nome_handler); + ss.sheet_mask().set_handler(F_S_CODICE,codice_handler); + return TRUE; +} + +bool TStampaTessereS::soggetti_notify(TSheet_field& s, int r, KEY k) +{ + bool ok = TRUE; + switch (k) + { + case K_INS: + // richiesta inserimento riga + break; + case K_DEL: + case K_CTRL+K_DEL: + // avvenuta cancellazione riga + break; + case K_SPACE: + // inizio modifica riga + break; + case K_TAB: + // entrata riga + { + static bool entering = TRUE; + if (entering) + { + entering = FALSE; + if ((r == s.items()-1) && (r == s.first_empty())) + app().add_rows_soggetti(s,10,r+1); + TToken_string& row = s.row(r); + if (row.empty_items()) + s.select(r,1,FALSE); + entering = TRUE; + } + } + break; + case K_ENTER: + // uscita da riga modificata + case K_CTRL+K_TAB: + // uscita riga + { + TToken_string& row = s.row(r); + const long codsog = row.get_long(0); + if (codsog != 0) + for (int i=s.items()-1; i>=0; i--) + { + if (i != r) + { + TToken_string& row = s.row(i); + if (codsog == row.get_long(0)) + return s.sheet_mask().field(F_S_CODICE).error_box("Soggetto gia' inserito"); + } + } + else + { + const char* cognome = row.get(1); + if ((cognome != NULL) && (cognome != "\0")) + s.sheet_mask().field(F_S_NOME).set_focusdirty(); + } + } + break; + } + return ok; +} + +bool TStampaTessereS::nome_handler(TMask_field& f, KEY k) +{ + bool ok = TRUE; + if (f.to_check(k)) + { + TMask& m = f.mask(); + long codsog = m.get_long(F_S_CODICE); + if (codsog == 0) + f.on_key(K_F9); + } + return ok; +} + +bool TStampaTessereS::codice_handler(TMask_field& f, KEY k) +{ + bool ok = TRUE; + if (f.to_check(k)) + { + TMask& m = f.mask(); + long codsog = m.get_long(F_S_CODICE); + if (codsog != 0) + { + TLocalisamfile sog(LF_SOGGETTI); + sog.setkey(1); + sog.zero(); + sog.put(SOG_CODICE, codsog); + int err = sog.read(); + if (err == NOERR) + { + m.set(F_S_COGNOME, sog.get(SOG_COGNOME)); + m.set(F_S_NOME, sog.get(SOG_NOME)); + m.set(F_S_DATANASC, sog.get(SOG_DATANASC)); + m.set(F_S_TESSAVIS, sog.get(SOG_TESSAVIS)); + m.set(F_S_CODSEZ, sog.get(SOG_CODSEZ)); + m.set(F_S_CODSOT, sog.get(SOG_CODSOT)); + m.set(F_S_CATDON, sog.get(SOG_CATDON)); + } + else + ok = FALSE; // codice non esistente + } + } + return ok; +} + +bool TStampaTessereS::user_destroy() +{ + delete _form_pag; + delete _msk; + delete _rel; + delete _sogtmp; + //printer().read_configuration(); + return TRUE; } int at7200(int argc, char* argv[]) { - TPrimaDon a; - a.run(argc, argv, "Marca prime donazioni"); - return 0; -} \ No newline at end of file + TStampaTessereS a; + a.run(argc, argv, "Stampa tessere singole"); + return 0; +} diff --git a/at/at7200a.h b/at/at7200a.h new file mode 100755 index 000000000..bb82c59cb --- /dev/null +++ b/at/at7200a.h @@ -0,0 +1,23 @@ +// stampa tessere associative singole +// definizione campi per maschera di selezione + +#define F_AGGIORNA 101 +#define F_SOGGETTI 102 + +#define F_ELENCO 401 +#define F_TESSERE 402 +#define F_AZZERA 403 + +// pagina soggetti +#define F_S_CODICE 101 +#define F_S_COGNOME 102 +#define F_S_NOME 103 +#define F_S_DATANASC 104 +#define F_S_CODSEZ 105 +#define F_S_CODSOT 106 +#define F_S_CATDON 107 +#define F_S_TESSAVIS 108 +#define F_S_DENSEZ 211 +#define F_S_DENSOT 212 +#define F_S_DESC_CATDON 213 + diff --git a/at/at7300.cpp b/at/at7300.cpp index b0e9a4796..73280e8aa 100755 --- a/at/at7300.cpp +++ b/at/at7300.cpp @@ -1,152 +1,527 @@ -#include +#include +#include #include -#include #include #include -#include -#include "at7.h" +#include "soggetti.h" +#include "donaz.h" +#include "benem.h" +#include "sezioni.h" +#include + +#include "at7.h" +#include "at4100b.h" +#include "at4100c.h" +#include "at7300a.h" +//#include "at4500.h" #include "atlib.h" - -// nomi dei campi -#include "soggetti.h" -#include "contsan.h" -#include "idoneita.h" -class TBologna90 : public TPrintapp +#define ALIAS_CTD 700 // categoria donatori +#define ALIAS_CTN1 701 // categoria non donatori 1 +#define ALIAS_CTN2 702 // categoria non donatori 2 + +#define ALIAS_TCS 200 // tipi/esiti controlli sanitari +#define ALIAS_LDN 400 // punti di prelievo +#define ALIAS_LDNDON 401 // punti di prelievo + +#define ALIAS_LCPDOM 100 // localita' postale di domicilio +#define ALIAS_COMDOM 501 // comune di domicilio +#define ALIAS_COMNAS 500 // comune di nascita + +#define ALIAS_BNZ 600 // benemerenze + +enum ts { undefined=0, schede=1, etichette=2, cartoline=3, donazioni=4 }; + +// definizione form per tessere associative +class TSingole_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - TLocalisamfile* _contsan; - TRecord_array* _scontrolli; - TLocalisamfile* _idoneita; - TRecord_array* _sidoneita; - -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); - public: - TBologna90() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TSingole_form(): TForm() {}; + TSingole_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TSingole_form() {}; }; -HIDDEN inline TBologna90& app() { return (TBologna90&) main_app(); } - -bool TBologna90::preprocess_page(int file, int counter) -{ - bool rewrite = FALSE; - TRectype& recsog = current_cursor()->curr(); - const int intaf = recsog.get_int(SOG_INTAF); - if (intaf != 0 && intaf != 45) - { - recsog.put(SOG_INTAF, 45); - const long codice = recsog.get_long(SOG_CODICE); - TRectype* keyc = new TRectype(LF_CONTSAN); - keyc->put(CON_CODICE, codice); - int err = _scontrolli->read(keyc); - TRectype* keyi = new TRectype(LF_IDONEITA); - keyi->put(IDO_CODICE, codice); - int erri = _sidoneita->read(keyi); - if ((err == NOERR || erri == NOERR) && (_scontrolli->rows() > 0 || _sidoneita->rows() > 0)) - { - for (int c=1; c<=_scontrolli->rows(); c++) - { - TRectype& riga = _scontrolli->row(c, TRUE); - int intaf = riga.get_int(CON_INTAF); - if (intaf != 0 && intaf != 45) - riga.put(CON_INTAF, 45); - } - for (int r=1; r<=_sidoneita->rows(); r++) - { - TRectype& riga = _sidoneita->row(r, TRUE); - const TString16 tipoido = riga.get(IDO_TIPOIDO); - if (tipoido == "AF") - { - int intaf = riga.get_int(IDO_INTERVALLO); - if (intaf != 0 && intaf != 45) - riga.put(CON_INTAF, 45); - } - } - _scontrolli->rewrite(); - _sidoneita->rewrite(); - con_reord(recsog,_scontrolli, _sidoneita); - //ido_reord(recsog,_sidoneita); - rewrite = TRUE; - } - } - if (rewrite) - current_cursor()->file().rewrite(); - return rewrite; -} - -void TBologna90::set_page(int file, int cnt) -{ - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - //set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - //set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME)); -} - -bool TBologna90::set_print(int) +class TStampeSingole : public TPrintapp { + TRelation* _rel; + TIsamtempfile* _sogtmp; + TLocalisamfile* _donaz; + TLocalisamfile* _benem; + TRecord_array* _sdonazioni; + TRecord_array* _sbenemerenze; + TMask* _msk; + TSingole_form* _form_sch; + TSingole_form* _form_car; + TSingole_form* _form_eti; + TSingole_form* _form_don; + TAssoc_array _asoggetti; + ts _tipostampa; + int _cur; + TDate _data_stampa; + TString16 _codsez, _codsot, _orario, _datacart; + TString80 _invitoper, _data, _presso1, _presso2, _presso3, _presso4; + TString80 _note, _intest1, _intest2, _intest3, _intest4; + bool _usomodo, _usasez; + int _etlarghezza, _etcolonne, _schxpag, _lenpage; + +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 print_action postprocess_print(int file, int counter); + ts dati_cartolina(); + + static void add_rows_soggetti(TSheet_field& s, int count = 10, int start = 1); + static bool soggetti_notify(TSheet_field& s, int r, KEY k); + static bool nome_handler(TMask_field& f, KEY k); + static bool codice_handler(TMask_field& f, KEY k); + +public: + void filtra_codici(); + void dati_sezione(const TString16 codsez, const TString16 codsot); + + TMask& app_mask() { return *_msk; } + TStampeSingole() : _data_stampa(TODAY) {} +}; + +HIDDEN inline TStampeSingole& app() { return (TStampeSingole&) main_app(); } + +TCursor* TSingole_form::cursor() const { return app().current_cursor(); } + +TRelation* TSingole_form::relation() const { return cursor()->relation(); } + +HIDDEN bool printer_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMask& m = f.mask(); + if (!m.query_mode()) + { + TString16 config; + config << "CARTOLINE"; + + TPrinter& p = printer(); + p.set_printtype(normprinter); // Force configuration update + p.read_configuration(config); + if (p.set()) + f.message_box("Stampante configurata per stampa cartoline"); + } + } + return TRUE; +} + +void TStampeSingole::dati_sezione(const TString16 codsez, const TString16 codsot) +{ + _intest1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ1); + _intest2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ2); + _intest3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ3); + _intest4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ4); + if (_usasez) + { + if (_presso1.blank()) + { + _presso1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE1); + _presso2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE2); + _presso3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE3); + _presso4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE4); + } + if (_orario.blank()) + _orario = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVORA); + if (_note.blank()) + _note = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVNOTE); + } + return; +} + + +ts TStampeSingole::dati_cartolina() +{ + TMask msk("at4100b"); + if (msk.run() == K_ENTER) + { + _invitoper = msk.get(F_INVITOPER); + _data = msk.get(F_DATA); + _presso1 = msk.get(F_PRESSO1); + _presso2 = msk.get(F_PRESSO2); + _presso3 = msk.get(F_PRESSO3); + _presso4 = msk.get(F_PRESSO4); + _datacart = msk.get(F_DATACART); + _orario = msk.get(F_ORARIO); + _note = msk.get(F_NOTE); + _usasez = msk.get_bool(F_USASEZ); + return cartoline; + } + else + return undefined; +} + +void TStampeSingole::add_rows_soggetti(TSheet_field& s, int count, int start) +{ + if (start == 1) + s.destroy(); + for (int r=start; rfirst(); !_sogtmp->eof(); _sogtmp->next()) + _sogtmp->remove(); + TSheet_field& s = (TSheet_field&)_msk->field(F_SOGGETTI); + for (int r=0; r < s.items(); r++) + { + TToken_string& row = s.row(r); + const long codice = row.get_long(0); + if (codice != 0) + { + TLocalisamfile soggetti(LF_SOGGETTI); + soggetti.setkey(1); + soggetti.zero(); + soggetti.put(SOG_CODICE,codice); + if (soggetti.read() == NOERR) + _sogtmp->write(soggetti.curr()); + } + } +} + +void TStampeSingole::set_page(int file, int cnt) +{ + switch (_tipostampa) + { + case etichette: + { + TPrint_section& corpo = _form_eti->get_body(); + for (int r=1;r<=_etcolonne;r++) + { + if (current_cursor()->pos()items()) + { + force_setpage(TRUE); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + TString256 riga1 = riga.row(); + riga1.cut(_etlarghezza); + int colonna = ((r-1)*_etlarghezza); + TString16 formato; + formato << '@' << colonna << "g"; + riga1.insert(formato,0); + set_row(i+1,riga1); + } + if (r < _etcolonne) + ++(*current_cursor()); + } + } + } + break; + case schede: + { + TPrint_section& corpo = _form_sch->get_body(); + corpo.update_and_print(printmode_normal, TRUE); + force_setpage(TRUE); + } + break; + case donazioni: + { + TPrint_section& corpo = _form_don->get_body(); + corpo.update_and_print(printmode_normal, TRUE); + force_setpage(TRUE); + } + break; + case cartoline: + { + TPrint_section& corpo = _form_car->get_body(); + const TString16 codsez = current_cursor()->curr().get(SOG_CODSEZ); + const TString16 codsot = current_cursor()->curr().get(SOG_CODSOT); + if ((_codsez!=codsez)||(_codsot!=codsot)) + { + _codsez = codsez; + _codsot = codsot; + dati_sezione(codsez, codsot); + corpo.reset(); + TForm_item& intest1 = corpo.find_field(CAR_INTEST1); + intest1.set(_intest1); + TForm_item& intest2 = corpo.find_field(CAR_INTEST2); + intest2.set(_intest2); + TForm_item& intest3 = corpo.find_field(CAR_INTEST3); + intest3.set(_intest3); + TForm_item& intest4 = corpo.find_field(CAR_INTEST4); + intest4.set(_intest4); + TForm_item& invito = corpo.find_field(CAR_INVITOPER); + invito.set(_invitoper); + TForm_item& data = corpo.find_field(CAR_DATA); + data.set(_data); + TForm_item& presso1 = corpo.find_field(CAR_PRESSO1); + presso1.set(_presso1); + TForm_item& presso2 = corpo.find_field(CAR_PRESSO2); + presso2.set(_presso2); + TForm_item& presso3 = corpo.find_field(CAR_PRESSO3); + presso3.set(_presso3); + TForm_item& presso4 = corpo.find_field(CAR_PRESSO4); + presso4.set(_presso4); + TForm_item& orario = corpo.find_field(CAR_ORARIO); + orario.set(_orario); + TForm_item& datacart = corpo.find_field(CAR_DATACART); + datacart.set(_datacart); + TForm_item& note = corpo.find_field(CAR_NOTE); + note.set(_note); + } + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); + } + break; + } +} + +bool TStampeSingole::preprocess_page(int file, int counter) +{ + if (_tipostampa==etichette) + if (printer().rows_left() < _form_eti->get_body().height()) + printer().formfeed(); + return TRUE; +} + +print_action TStampeSingole::postprocess_print(int file, int counter) +{ + if ((_tipostampa == schede) && (_schxpag > 1)) + printer().formlen(_lenpage); + return NEXT_PAGE; +} + +bool TStampeSingole::set_print(int m) +{ + TPrinter& p = printer(); + p.read_configuration(); + TSheet_field& s = (TSheet_field&)_msk->field(F_SOGGETTI); + s.destroy(); + s.force_update(); + if (s.items()==0) + add_rows_soggetti(s,50); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { - /* - TRectype da(LF_SOGGETTI); - TRectype a(LF_SOGGETTI); - const long codini = _msk->get_long(F_CODINI); - const long codfin = _msk->get_long(F_CODFIN); - da.zero(); - a.zero(); - if (codini != 0) - da.put(SOG_CODICE, codini); - if (codfin != 0) - a.put(SOG_CODICE, codfin); - current_cursor()->setregion(da,a); - */ - //current_cursor()->setfilter(format("STATO == \"RF\"")); - - reset_files(); + switch (tasto) + { + case F_CARTOLINE: + _tipostampa=cartoline; + break; + case F_SCHEDE: + _tipostampa=schede; + if (_schxpag > 1) + printer().formlen(_lenpage/_schxpag); + break; + case F_ETICHETTE: + _tipostampa = (configura_stampante(p, "AT_ETICHETTE", "etichette")) ? etichette : undefined; + break; + case F_DONAZIONI: + _tipostampa=donazioni; + break; + } + if (_tipostampa != undefined) + { + if (_tipostampa == cartoline) + dati_cartolina(); + reset_files(); add_file(LF_SOGGETTI); - reset_print(); + _asoggetti.destroy(); + for (int r=0; r < s.items(); r++) + { + TToken_string& row = s.row(r); + const long codice = row.get_long(0); + const char* scodice = row.get(0); + if (codice != 0) + _asoggetti.add(scodice); + } + if (_asoggetti.items() != 0) + filtra_codici(); + reset_print(); return TRUE; } else - return FALSE; + return FALSE; } -bool TBologna90::user_create() +bool TStampeSingole::user_create() { - _msk = new TMask("at7300a"); - _rel = new TRelation(LF_SOGGETTI); - _contsan = new TLocalisamfile(LF_CONTSAN); - _scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON); - _idoneita = new TLocalisamfile(LF_IDONEITA); - _sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO); - _cur = add_cursor(new TCursor(_rel, "", 1)); - long items = _rel->lfile().items(); - return TRUE; -} + _sogtmp = new TIsamtempfile(LF_SOGGETTI,NULL,TRUE,TRUE); + _rel = new TRelation(_sogtmp); + _rel->add(LF_SOGGETTI, "CODICE==CODICE"); + _rel->add(LF_DONAZ, "CODICE==CODICE", 1); + _rel->add("LDN", "CODTAB==LUOGODON",1,LF_DONAZ, ALIAS_LDNDON); + _rel->add(LF_BENEM, "CODICE==CODICE", 1); + _rel->add("BNZ", "CODTAB==TIPOBEN", 1, LF_BENEM, ALIAS_BNZ); + _rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD); + _rel->add("CTN", "CODTAB==CATNOND1",1,0,ALIAS_CTN1); + _rel->add("CTN", "CODTAB==CATNOND2",1,0,ALIAS_CTN2); + _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); + _rel->add("LDN", "CODTAB==PUNTORACC",1,0,ALIAS_LDN); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPDOM); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM); + _rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + _rel->add(LF_MEDICI, "CODMED==CODMED"); + _donaz = new TLocalisamfile(LF_DONAZ); + _benem = new TLocalisamfile(LF_BENEM); + _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); + _sbenemerenze = new TRecord_array(LF_BENEM,BEN_PROGBEN); -bool TBologna90::user_destroy() + _cur = add_cursor(new TCursor(_rel, "", 2)); + _msk = new TMask("at7300a"); + //Modificato il form per le cartoline in ATCARTO2 da ATCARTO1 da Marco il 14/09/99 + _form_car = new TSingole_form("ATCARTO2"); + _form_don = new TSingole_form("ATDDONAZ"); + TConfig config(CONFIG_STUDIO); + TString16 etformato = config.get("EtFormato"); + _etlarghezza = config.get_int("EtLarghezza"); + _etcolonne = config.get_int("EtColonne"); + _form_eti = new TSingole_form(etformato); + TString16 schformato = config.get("SchFormato"); + _schxpag = config.get_int("SchXPag"); + _form_sch = new TSingole_form(schformato); + _lenpage = printer().formlen(); + TSheet_field& ss = (TSheet_field&)_msk->field(F_SOGGETTI); + ss.set_notify(soggetti_notify); + ss.sheet_mask().set_handler(F_S_NOME,nome_handler); + ss.sheet_mask().set_handler(F_S_CODICE,codice_handler); + return TRUE; +} + +bool TStampeSingole::soggetti_notify(TSheet_field& s, int r, KEY k) +{ + bool ok = TRUE; + switch (k) + { + case K_INS: + // richiesta inserimento riga + break; + case K_DEL: + case K_CTRL+K_DEL: + // avvenuta cancellazione riga + break; + case K_SPACE: + // inizio modifica riga + break; + case K_TAB: + // entrata riga + { + static bool entering = TRUE; + if (entering) + { + entering = FALSE; + if ((r == s.items()-1) && (r == s.first_empty())) + app().add_rows_soggetti(s,10,r+1); + TToken_string& row = s.row(r); + if (row.empty_items()) + s.select(r,1,FALSE); + entering = TRUE; + } + } + break; + case K_ENTER: + // uscita da riga modificata + case K_CTRL+K_TAB: + // uscita riga + { + TToken_string& row = s.row(r); + const long codsog = row.get_long(0); + if (codsog != 0) + for (int i=s.items()-1; i>=0; i--) + { + if (i != r) + { + TToken_string& row = s.row(i); + if (codsog == row.get_long(0)) + return s.sheet_mask().field(F_S_CODICE).error_box("Soggetto gia' inserito"); + } + } + else + { + const char* cognome = row.get(1); + if ((cognome != NULL) && (cognome != "\0")) + s.sheet_mask().field(F_S_NOME).set_focusdirty(); + } + } + break; + } + return ok; +} + +bool TStampeSingole::nome_handler(TMask_field& f, KEY k) { - delete _sidoneita; - delete _idoneita; - delete _scontrolli; - delete _contsan; - delete _rel; - delete _msk; - return TRUE; + bool ok = TRUE; + if (f.to_check(k)) + { + TMask& m = f.mask(); + long codsog = m.get_long(F_S_CODICE); + if (codsog == 0) + f.on_key(K_F9); + } + return ok; +} + +bool TStampeSingole::codice_handler(TMask_field& f, KEY k) +{ + bool ok = TRUE; + if (f.to_check(k)) + { + TMask& m = f.mask(); + long codsog = m.get_long(F_S_CODICE); + if (codsog != 0) + { + TLocalisamfile sog(LF_SOGGETTI); + sog.setkey(1); + sog.zero(); + sog.put(SOG_CODICE, codsog); + int err = sog.read(); + if (err == NOERR) + { + m.set(F_S_COGNOME, sog.get(SOG_COGNOME)); + m.set(F_S_NOME, sog.get(SOG_NOME)); + m.set(F_S_DATANASC, sog.get(SOG_DATANASC)); + m.set(F_S_TESSAVIS, sog.get(SOG_TESSAVIS)); + m.set(F_S_CODSEZ, sog.get(SOG_CODSEZ)); + m.set(F_S_CODSOT, sog.get(SOG_CODSOT)); + m.set(F_S_CATDON, sog.get(SOG_CATDON)); + } + else + ok = FALSE; // codice non esistente + } + } + return ok; +} + +bool TStampeSingole::user_destroy() +{ + delete _form_sch; + delete _form_eti; + delete _form_don; + delete _form_car; + delete _msk; + delete _sbenemerenze; + delete _sdonazioni; + delete _benem; + delete _donaz; + delete _rel; + delete _sogtmp; + return TRUE; } int at7300(int argc, char* argv[]) { - TBologna90 a; - a.run(argc, argv, "Bologna: intaf = 90"); - return 0; -} \ No newline at end of file + TStampeSingole a; + a.run(argc, argv, "Stampe singole"); + return 0; +} diff --git a/at/at7300a.h b/at/at7300a.h new file mode 100755 index 000000000..2a745b1dc --- /dev/null +++ b/at/at7300a.h @@ -0,0 +1,22 @@ +// stampa etichette/cartoline/schede anagrafiche/dettaglio donazioni singole +// definizione campi per maschera di selezione + +#define F_SOGGETTI 101 +#define F_CARTOLINE 401 +#define F_ETICHETTE 402 +#define F_SCHEDE 403 +#define F_DONAZIONI 404 + +// pagina soggetti +#define F_S_CODICE 101 +#define F_S_COGNOME 102 +#define F_S_NOME 103 +#define F_S_DATANASC 104 +#define F_S_CODSEZ 105 +#define F_S_CODSOT 106 +#define F_S_CATDON 107 +#define F_S_TESSAVIS 108 +#define F_S_DENSEZ 211 +#define F_S_DENSOT 212 +#define F_S_DESC_CATDON 213 + diff --git a/at/at7400.cpp b/at/at7400.cpp index 97f9dcaca..901b80653 100755 --- a/at/at7400.cpp +++ b/at/at7400.cpp @@ -1,103 +1,371 @@ +#include #include #include -#include +#include #include -#include -#include "at7.h" +#include "soggetti.h" +#include "donaz.h" +#include "benem.h" +#include "sezioni.h" +#include -// nomi dei campi -#include "soggetti.h" +#include "at7.h" +#include "at4100b.h" +#include "at4100c.h" +#include "at7400a.h" +//#include "at4500.h" +#include "atlib.h" -#define ALIAS_LCPD 100 -#define ALIAS_LCPR 200 -#define ALIAS_COMD 300 -#define ALIAS_COMR 400 +#define ALIAS_CTD 700 // categoria donatori +#define ALIAS_CTN1 701 // categoria non donatori 1 +#define ALIAS_CTN2 702 // categoria non donatori 2 -class TCermes : public TPrintapp +#define ALIAS_TCS 200 // tipi/esiti controlli sanitari +#define ALIAS_LDN 400 // punti di prelievo +#define ALIAS_LDNDON 401 // punti di prelievo + +#define ALIAS_LCPDOM 100 // localita' postale di domicilio +#define ALIAS_COMDOM 501 // comune di domicilio +#define ALIAS_COMNAS 500 // comune di nascita + +#define ALIAS_BNZ 600 // benemerenze + +enum ts { undefined=0, schede=1, etichette=2, cartoline=3, donazioni=4 }; + +// definizione form per tessere associative +class TPerCodice_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - TString16 _cermes, _vuoto; - -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); - public: - TCermes() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TPerCodice_form(): TForm() {}; + TPerCodice_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TPerCodice_form() {}; }; -HIDDEN inline TCermes& app() { return (TCermes&) main_app(); } - -bool TCermes::preprocess_page(int file, int counter) -{ - bool rew = FALSE; - TString16 cap; - TString16 loc; - TString16 com; - TRectype& recsog = current_cursor()->curr(); - TString16 codcom = recsog.get(SOG_COMNASC); - if (codcom == _cermes) - { - recsog.put(SOG_COMNASC,_vuoto); - rew = TRUE; - } - if (rew) - current_cursor()->file().rewrite(); - return rew; -} - -void TCermes::set_page(int file, int cnt) -{ - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME)); -} - -bool TCermes::set_print(int) +class TStampePerCodice : public TPrintapp { + TRelation* _rel; + TLocalisamfile* _donaz; + TLocalisamfile* _benem; + TRecord_array* _sdonazioni; + TRecord_array* _sbenemerenze; + TMask* _msk; + TPerCodice_form* _form_sch; + TPerCodice_form* _form_car; + TPerCodice_form* _form_eti; + TPerCodice_form* _form_don; + ts _tipostampa; + int _cur; + TDate _data_stampa; + TString16 _codsez, _codsot, _orario, _datacart; + TString80 _invitoper, _data, _presso1, _presso2, _presso3, _presso4; + TString80 _note, _intest1, _intest2, _intest3, _intest4; + bool _usomodo, _usasez; + int _etlarghezza, _etcolonne, _schxpag, _lenpage; + +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 print_action postprocess_print(int file, int counter); + ts dati_cartolina(); + +public: + void dati_sezione(const TString16 codsez, const TString16 codsot); + + TMask& app_mask() { return *_msk; } + TStampePerCodice() : _data_stampa(TODAY) {} +}; + +HIDDEN inline TStampePerCodice& app() { return (TStampePerCodice&) main_app(); } + +TCursor* TPerCodice_form::cursor() const { return app().current_cursor(); } + +TRelation* TPerCodice_form::relation() const { return cursor()->relation(); } + +HIDDEN bool printer_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMask& m = f.mask(); + if (!m.query_mode()) + { + TString16 config; + config << "CARTOLINE"; + + TPrinter& p = printer(); + p.set_printtype(normprinter); // Force configuration update + p.read_configuration(config); + if (p.set()) + f.message_box("Stampante configurata per stampa cartoline"); + } + } + return TRUE; +} + +void TStampePerCodice::dati_sezione(const TString16 codsez, const TString16 codsot) +{ + _intest1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ1); + _intest2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ2); + _intest3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ3); + _intest4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ4); + if (_usasez) + { + if (_presso1.blank()) + { + _presso1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE1); + _presso2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE2); + _presso3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE3); + _presso4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE4); + } + if (_orario.blank()) + _orario = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVORA); + if (_note.blank()) + _note = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVNOTE); + } + return; +} + + +ts TStampePerCodice::dati_cartolina() +{ + TMask msk("at4100b"); + if (msk.run() == K_ENTER) + { + _invitoper = msk.get(F_INVITOPER); + _data = msk.get(F_DATA); + _presso1 = msk.get(F_PRESSO1); + _presso2 = msk.get(F_PRESSO2); + _presso3 = msk.get(F_PRESSO3); + _presso4 = msk.get(F_PRESSO4); + _datacart = msk.get(F_DATACART); + _orario = msk.get(F_ORARIO); + _note = msk.get(F_NOTE); + _usasez = msk.get_bool(F_USASEZ); + return cartoline; + } + else + return undefined; +} + +void TStampePerCodice::set_page(int file, int cnt) +{ + switch (_tipostampa) + { + case etichette: + { + TPrint_section& corpo = _form_eti->get_body(); + for (int r=1;r<=_etcolonne;r++) + { + if (current_cursor()->pos()items()) + { + force_setpage(TRUE); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + TString256 riga1 = riga.row(); + riga1.cut(_etlarghezza); + int colonna = ((r-1)*_etlarghezza); + TString16 formato; + formato << '@' << colonna << "g"; + riga1.insert(formato,0); + set_row(i+1,riga1); + } + if (r < _etcolonne) + ++(*current_cursor()); + } + } + } + break; + case schede: + { + TPrint_section& corpo = _form_sch->get_body(); + corpo.update_and_print(printmode_normal, TRUE); + force_setpage(TRUE); + } + break; + case donazioni: + { + TPrint_section& corpo = _form_don->get_body(); + corpo.update_and_print(printmode_normal,TRUE); + force_setpage(TRUE); + } + break; + case cartoline: + { + TPrint_section& corpo = _form_car->get_body(); + const TString16 codsez = current_cursor()->curr().get(SOG_CODSEZ); + const TString16 codsot = current_cursor()->curr().get(SOG_CODSOT); + if ((_codsez!=codsez)||(_codsot!=codsot)) + { + _codsez = codsez; + _codsot = codsot; + dati_sezione(codsez, codsot); + corpo.reset(); + TForm_item& intest1 = corpo.find_field(CAR_INTEST1); + intest1.set(_intest1); + TForm_item& intest2 = corpo.find_field(CAR_INTEST2); + intest2.set(_intest2); + TForm_item& intest3 = corpo.find_field(CAR_INTEST3); + intest3.set(_intest3); + TForm_item& intest4 = corpo.find_field(CAR_INTEST4); + intest4.set(_intest4); + TForm_item& invito = corpo.find_field(CAR_INVITOPER); + invito.set(_invitoper); + TForm_item& data = corpo.find_field(CAR_DATA); + data.set(_data); + TForm_item& presso1 = corpo.find_field(CAR_PRESSO1); + presso1.set(_presso1); + TForm_item& presso2 = corpo.find_field(CAR_PRESSO2); + presso2.set(_presso2); + TForm_item& presso3 = corpo.find_field(CAR_PRESSO3); + presso3.set(_presso3); + TForm_item& presso4 = corpo.find_field(CAR_PRESSO4); + presso4.set(_presso4); + TForm_item& orario = corpo.find_field(CAR_ORARIO); + orario.set(_orario); + TForm_item& datacart = corpo.find_field(CAR_DATACART); + datacart.set(_datacart); + TForm_item& note = corpo.find_field(CAR_NOTE); + note.set(_note); + } + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + } + break; + } +} + +print_action TStampePerCodice::postprocess_print(int file, int counter) +{ + if ((_tipostampa == schede) && (_schxpag > 1)) + printer().formlen(_lenpage); + return NEXT_PAGE; +} + +bool TStampePerCodice::preprocess_page(int file, int counter) +{ + if (_tipostampa==etichette) + if (printer().rows_left() < _form_eti->get_body().height()) + printer().formfeed(); + return TRUE; +} + +bool TStampePerCodice::set_print(int m) +{ + TPrinter& p = printer(); + p.read_configuration(); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { + switch (tasto) + { + case F_CARTOLINE: + _tipostampa=cartoline; + break; + case F_SCHEDE: + _tipostampa=schede; + if (_schxpag > 1) + printer().formlen(_lenpage/_schxpag); + break; + case F_ETICHETTE: + _tipostampa = (configura_stampante(p, "AT_ETICHETTE", "etichette")) ? etichette : undefined; + break; + case F_DONAZIONI: + _tipostampa=donazioni; + break; + } + if (_tipostampa != undefined) + { + if (_tipostampa == cartoline) + dati_cartolina(); + const long codini = _msk->get_long(F_CODINI); + const long codfin = _msk->get_long(F_CODFIN); + TRectype da(LF_SOGGETTI); + TRectype a(LF_SOGGETTI); + if (codini!=0) + da.put(SOG_CODICE, codini); + if (codfin!=0) + a.put(SOG_CODICE, codfin); + current_cursor()->setregion(da, a); reset_files(); add_file(LF_SOGGETTI); - reset_print(); + reset_print(); return TRUE; } else - return FALSE; + return FALSE; } -bool TCermes::user_create() +bool TStampePerCodice::user_create() { - _msk = new TMask("at7400a"); - _rel = new TRelation(LF_SOGGETTI); - _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPD); - _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMD); - _rel->add("LCP", "CODTAB==RES_CODLOC",1,0,ALIAS_LCPR); - _rel->add(LF_COMUNI, "COM==RES_CODCOM",1,0,ALIAS_COMR); - _cur = add_cursor(new TCursor(_rel, "", 1)); - _cermes = "A022"; - _vuoto = " "; - return TRUE; -} + _rel = new TRelation(LF_SOGGETTI); + _rel->add(LF_DONAZ, "CODICE==CODICE", 1); + _rel->add("LDN", "CODTAB==LUOGODON",1,LF_DONAZ, ALIAS_LDNDON); + _rel->add(LF_BENEM, "CODICE==CODICE", 1); + _rel->add("BNZ", "CODTAB==TIPOBEN", 1, LF_BENEM, ALIAS_BNZ); + _rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD); + _rel->add("CTN", "CODTAB==CATNOND1",1,0,ALIAS_CTN1); + _rel->add("CTN", "CODTAB==CATNOND2",1,0,ALIAS_CTN2); + _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); + _rel->add("LDN", "CODTAB==PUNTORACC",1,0,ALIAS_LDN); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPDOM); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM); + _rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + _rel->add(LF_MEDICI, "CODMED==CODMED"); + _donaz = new TLocalisamfile(LF_DONAZ); + _benem = new TLocalisamfile(LF_BENEM); + _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); + _sbenemerenze = new TRecord_array(LF_BENEM,BEN_PROGBEN); -bool TCermes::user_destroy() + _cur = add_cursor(new TCursor(_rel, "", 1)); + _msk = new TMask("at7400a"); + //Modificato il form per le cartoline in ATCARTO2 da ATCARTO1 da Marco il 14/09/99 + _form_car = new TPerCodice_form("ATCARTO2"); + _form_don = new TPerCodice_form("ATDDONAZ"); + TConfig config(CONFIG_STUDIO); + TString16 etformato = config.get("EtFormato"); + _etlarghezza = config.get_int("EtLarghezza"); + _etcolonne = config.get_int("EtColonne"); + _form_eti = new TPerCodice_form(etformato); + TString16 schformato = config.get("SchFormato"); + _schxpag = config.get_int("SchXPag"); + _form_sch = new TPerCodice_form(schformato); + _lenpage = printer().formlen(); + return TRUE; +} + +bool TStampePerCodice::user_destroy() { - delete _rel; - delete _msk; - return TRUE; + delete _form_sch; + delete _form_eti; + delete _form_don; + delete _form_car; + delete _msk; + delete _sbenemerenze; + delete _sdonazioni; + delete _benem; + delete _donaz; + delete _rel; + return TRUE; } int at7400(int argc, char* argv[]) { - TCermes a; - a.run(argc, argv, "Correzione nati a CERMES"); - return 0; -} \ No newline at end of file + TStampePerCodice a; + a.run(argc, argv, "Stampe per codice"); + return 0; +} diff --git a/at/at7400a.h b/at/at7400a.h new file mode 100755 index 000000000..11ea2abf0 --- /dev/null +++ b/at/at7400a.h @@ -0,0 +1,10 @@ +// stampa etichette/cartoline/scehde/dettaglio donazioni per codice +// definizione campi per maschera di selezione + + +#define F_CODINI 101 // da codice +#define F_CODFIN 102 // a codice +#define F_CARTOLINE 401 +#define F_ETICHETTE 402 +#define F_SCHEDE 403 +#define F_DONAZIONI 404 diff --git a/at/at7500.cpp b/at/at7500.cpp index e946afe74..822ec2b1b 100755 --- a/at/at7500.cpp +++ b/at/at7500.cpp @@ -1,179 +1,477 @@ +#include #include #include -#include -#include #include -#include + +#include "soggetti.h" +#include "sezioni.h" +#include #include "at7.h" +#include "at7500a.h" +#include "atlib.h" -// nomi dei campi -#include "soggetti.h" -#include "storico.h" -#include "donaz.h" +#define ALIAS_LCPDOM 100 +#define ALIAS_TCS 200 -class TAggiornaDon : public TPrintapp +enum ts { undefined=0, sintetico=1, completo=2, etichette=3, lettere=4 }; + +// definizione form per etichette +class TEti_profess_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - TLocalisamfile* _donaz; - TLocalisamfile* _storico; - TRecord_array* _sdonazioni; - TRecord_array* _sstorico; - -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); - public: - TAggiornaDon() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TEti_profess_form(): TForm() {}; + TEti_profess_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TEti_profess_form() {}; }; -HIDDEN inline TAggiornaDon& app() { return (TAggiornaDon&) main_app(); } - -bool TAggiornaDon::preprocess_page(int file, int counter) -{ - bool rewrite = FALSE; - TRectype& recsog = current_cursor()->curr(); - const TDate dataisc = recsog.get(SOG_DATAISC); - const TDate datadim = recsog.get(SOG_DATADIM); - const long codice = recsog.get_long(SOG_CODICE); - const TString16 codsez = recsog.get(SOG_CODSEZ); - const TString16 codsot = recsog.get(SOG_CODSOT); - TRectype* keys = new TRectype(LF_STORICO); - keys->put(SOG_CODICE, codice); - int errs = _sstorico->read(keys); - TRectype* keyd = new TRectype(LF_DONAZ); - keyd->put(DON_CODICE, codice); - int errd = _sdonazioni->read(keyd); - if (errd == NOERR) - { - TDate datadon; - for (int r=1; r<=_sdonazioni->rows(); r++) - { - TRectype& riga = _sdonazioni->row(r, TRUE); - datadon = riga.get(DON_DATADON); - if (dataisc.ok()) - // ha la data iscrizione - { - if (datadon >= dataisc) - // la data donazione è superiore alla data iscrizione - if (datadim.ok()) - // ha la data dimisssione - if (datadon <= datadim) - // la data donazione è inferiore alla data dimissione - { - riga.put(DON_CODSEZ, codsez); - riga.put(DON_CODSOT, codsot); - rewrite = TRUE; - } - else - // la data donazione è superiore alla data dimissione - { - // c'è un errore, quindi uso sezione/sottogruppo del soggetto - riga.put(DON_CODSEZ, codsez); - riga.put(DON_CODSOT, codsot); - rewrite = TRUE; - } - else - // non ha data dimissione - { - riga.put(DON_CODSEZ, codsez); - riga.put(DON_CODSOT, codsot); - rewrite = TRUE; - } - else - // la data donazione è inferiore alla data iscrizione - { - bool trovato = FALSE; - for (int l=1; l<=_sstorico->rows(); l++) - { - const TRectype& rigas = _sstorico->row(l); - const TDate data1 = rigas.get(STO_DATAISC); - const TDate data2 = rigas.get(STO_DATADIM); - if ((datadon >= data1) && (datadon <= data2)) - { - trovato = TRUE; - riga.put(DON_CODSEZ, rigas.get(STO_CODSEZ)); - riga.put(DON_CODSOT, rigas.get(STO_CODSOT)); - rewrite = TRUE; - } - } - if (!trovato) - // non ha trovato nello storico un periodo corrispondente alla data donazione - { - riga.put(DON_CODSEZ, codsez); - riga.put(DON_CODSOT, codsot); - rewrite = TRUE; - } - } - } - else - // non ha la data di iscrizione - { - riga.put(DON_CODSEZ, codsez); - riga.put(DON_CODSOT, codsot); - rewrite = TRUE; - } - } - if (rewrite) - _sdonazioni->rewrite(); - } - return rewrite; -} - -void TAggiornaDon::set_page(int file, int cnt) -{ - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - //set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - //set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME)); -} - -bool TAggiornaDon::set_print(int) +class TStampaProfess : public TPrintapp { + TRelation* _rel; + TMask* _msk; + TEti_profess_form* _form_eti; + TEti_profess_form* _form_let; + TAssoc_array _categorie; + TParagraph_string _cognome_nome, _dencom; + TDate _data_stampa; + ts _tipostampa; + TString16 _codsez, _codsot; + int _etlarghezza, _etcolonne, _contatore, _totale; + TString16 _condocc, _posprof, _ramoatt, _profess, _luogolav; + + static bool filter_func_profess(const TRelation* rel); + +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 print_action postprocess_print(int file, int counter); + +public: + void crea_intestazione(); + void filtra_sezioni(); + void header_sezione(const TString16 codsez, const TString16 codsot); + void footer_sezione(); + void fine_stampa(); + TMask& app_mask() { return *_msk; } + TStampaProfess() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",30) {} +}; + +HIDDEN inline TStampaProfess& app() { return (TStampaProfess&) main_app(); } + +TCursor* TEti_profess_form::cursor() const { return app().current_cursor(); } + +TRelation* TEti_profess_form::relation() const { return cursor()->relation(); } + +void TStampaProfess::fine_stampa() +{ + // stampa totale soggetti a fine stampa + if (_tipostampa==sintetico || _tipostampa==completo) + { + reset_footer(); + TString sep(80); + 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 TStampaProfess::footer_sezione() +{ + // stampa totale soggetti appartenenti alla sezione + if (_tipostampa==sintetico || _tipostampa==completo) + { + reset_footer(); + TString sep(80); + sep.fill('-'); + set_footer(2, (const char *) sep); + set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore); + printer().formfeed(); + reset_footer(); + } +} + +void TStampaProfess::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); + TRectype da(LF_SOGGETTI); + TRectype a (LF_SOGGETTI); + if (sezini.not_empty()) + da.put(SOG_CODSEZ, sezini); + if (sotini.not_empty()) + da.put(SOG_CODSOT, sotini); + if (sezfin.not_empty()) + a.put(SOG_CODSEZ, sezfin); + if (sotfin.not_empty()) + a.put(SOG_CODSOT, sotfin); + current_cursor()->setregion(da, a); +} + +void TStampaProfess::set_page(int file, int cnt) +{ + // costruzione etichette + switch (_tipostampa) + { + case etichette: + { + TPrint_section& corpo = _form_eti->get_body(); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case lettere: + { + TPrint_section& corpo = _form_let->get_body(); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case sintetico: + { + set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); + set_row(1,"@12g#a", &_cognome_nome); + set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@49g@6,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@56g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@67g@S", FLD(LF_SOGGETTI,SOG_TIPOULTDON)); + set_row(2,""); + } + break; + case completo: + { + set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(2,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(3,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_CATDON)); + + set_row(1,"@9g@S",FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(2,"@9g@S",FLD(LF_SOGGETTI,SOG_NOME)); + set_row(3,"@9g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + + set_row(1,"@35g@S", FLD(LF_SOGGETTI,SOG_DOM_INDIR)); + set_row(2,"@35g#a", &_dencom); + + set_row(1,"@66g@S", FLD(LF_SOGGETTI,SOG_TELABI)); + set_row(2,"@66g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); + set_row(3,"@66g@S", FLD(LF_SOGGETTI,SOG_TELALT)); + + set_row(1,"@82gGr @S", FLD(LF_SOGGETTI,SOG_GRUPPOAB0)); + set_row(2,"@82gRh @S", FLD(LF_SOGGETTI,SOG_RHANTID)); + set_row(3,"@82gFe @S", FLD(LF_SOGGETTI,SOG_FENOTIPORH)); + set_row(4,"@82gKe @S", FLD(LF_SOGGETTI,SOG_KELL)); + set_row(5,"@82gDu @S", FLD(LF_SOGGETTI,SOG_DU)); + + set_row(1,"@94g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(2,"@94g@S", FLD(LF_SOGGETTI,SOG_TIPOULTDON)); + set_row(4,"@94g@pn", FLD(LF_SOGGETTI,SOG_TOTDON)); + + set_row(6,""); + } + break; + } +} + +bool TStampaProfess::filter_func_profess(const TRelation* rel) +{ + bool filtrato = TRUE; + TRectype recsog = rel->lfile().curr(); + // filtro per categorie + TAssoc_array& categorie = app()._categorie; + if (categorie.items() != 0) + { + const TString16 cat = recsog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + return filtrato; +} + +bool TStampaProfess::preprocess_page(int file, int counter) +{ + if ((_tipostampa==sintetico) || (_tipostampa==completo)) + { + TRectype& recsog = current_cursor()->curr(); + TString80 nome = recsog.get(SOG_COGNOME); + nome << ' '; + nome << recsog.get(SOG_NOME); + _cognome_nome = nome; + TString256 localita = ""; + localita << recsog.get(SOG_DOM_CAP); + localita << ' '; + if (recsog.get(SOG_DOM_CODLOC).not_empty()) + localita << current_cursor()->curr(-ALIAS_LCPDOM).get("S0"); + else + localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM); + localita << ' ' << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM); + localita.trim(); + _dencom = localita; + // 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); + } + } + if (_tipostampa==etichette) + if (printer().rows_left() < _form_eti->get_body().height()) + printer().formfeed(); + _contatore++; + _totale++; + return TRUE; +} + +print_action TStampaProfess::postprocess_print(int file, int counter) +{ + if (_contatore > 0) + footer_sezione(); + fine_stampa(); + return NEXT_PAGE; +} + +void TStampaProfess::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; + } + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} + +bool TStampaProfess::set_print(int m) +{ + TPrinter& p = printer(); + p.read_configuration(); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { + switch (tasto) + { + case F_SINTETICO: + { + _tipostampa = sintetico; + _codsez = _codsot = "**"; + _contatore = 0; + _totale = 0; + } + break; + case F_COMPLETO: + { + _tipostampa = completo; + _codsez = _codsot = "**"; + _contatore = 0; + _totale = 0; + } + break; + case F_ETICHETTE: + _tipostampa = (configura_stampante(p, "AT_ETICHETTE", "etichette")) ? etichette : undefined; + break; + case F_LETTERE: + _tipostampa = lettere; + break; + } + if (_tipostampa != undefined) + { reset_files(); add_file(LF_SOGGETTI); - reset_print(); + // filtro per sezioni selezionate + filtra_sezioni(); + _condocc = _msk->get(F_CONDOCC); + _posprof = _msk->get(F_POSPROF); + _ramoatt = _msk->get(F_RAMOATT); + _profess = _msk->get(F_PROFESS); + _luogolav = _msk->get(F_LUOGOLAV); + TString256 filtro = ""; + TString80 filtrotmp =""; + // filtro per condocc + if (_condocc.not_empty()) + filtro.format("(CONDOCC == \"%s\")",(const char*)_condocc); + // filtro per posprof + if (_posprof.not_empty()) + { + filtrotmp.format("(POSPROF == \"%s\")",(const char*)_posprof); + if (filtro.not_empty()) + filtro << " && "; + filtro << filtrotmp; + } + // filtro per ramoatt + if (_ramoatt.not_empty()) + { + filtrotmp.format("(RAMOATT == \"%s\")",(const char*)_ramoatt); + if (filtro.not_empty()) + filtro << " && "; + filtro << filtrotmp; + } + // filtro per profess + if (_profess.not_empty()) + { + filtrotmp.format("(PROFESS == \"%s\")",(const char*)_profess); + if (filtro.not_empty()) + filtro << " && "; + filtro << filtrotmp; + } + // filtro per luogolav + if (_luogolav.not_empty()) + { + filtrotmp.format("(POSPROF == \"%s\")",(const char*)_luogolav); + if (filtro.not_empty()) + filtro << " && "; + filtro << filtrotmp; + } + // filtro per categorie + _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); + current_cursor()->setfilter(filtro, TRUE); + current_cursor()->set_filterfunction(filter_func_profess); + reset_print(); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TAggiornaDon::user_create() +void TStampaProfess::crea_intestazione() { - _msk = new TMask("at7500a"); - _rel = new TRelation(LF_SOGGETTI); - _donaz = new TLocalisamfile(LF_DONAZ); - _storico = new TLocalisamfile(LF_STORICO); - _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); - _sstorico = new TRecord_array(LF_STORICO,STO_PROGSTO); - _cur = add_cursor(new TCursor(_rel, "", 1)); - return TRUE; -} + reset_header(); + if (_tipostampa==sintetico || _tipostampa==completo) + { + TString sep(132); + sep = "STAMPA "; + if (_condocc.not_empty()) + sep << "PER COND.OCC. " << _condocc; + if (_posprof.not_empty()) + sep << "PER POS.PROF. " << _posprof; + if (_ramoatt.not_empty()) + sep << "PER RAMO ATT. " << _ramoatt; + if (_profess.not_empty()) + sep << "PER PROFESSIONE " << _profess; + if (_luogolav.not_empty()) + sep << "PER LUOGO LAV. " << _luogolav; + sep.center_just(); + set_header(2, "@0g%s", (const char*) sep); + const TString16 data_stampa = _data_stampa.string(); + set_header(2,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(2, "@120g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(3, (const char *) sep); + if (_tipostampa==sintetico) + { + sep.fill('-',100); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gC.@12gCognome e nome@38gNato il@49gTess.@56gData/Tipo u.d."); + set_header(6,"@0g--------@9g--@12g-------------------------@38g----------@49g------@56g---------- --@70g--------"); + } + else + { + sep.fill('-'); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gCognome@35gIndirizzo@66gTel.abitazione@82gTipiz@94gUlt.donaz."); + set_header(6,"@0gTessera@9gNome@66gTel.lavoro@82gzazione@94gTipo"); + set_header(7,"@0gCateg.@9gData nascita@66gTel.altro"); + set_header(8,"@94gTot.don."); + set_header(10,"@0g--------@9g-------------------------@35g------------------------------@66g--------------@82g------------@94g----------@105g--------"); + } + printer().footerlen(3); + } +} -bool TAggiornaDon::user_destroy() +bool TStampaProfess::user_create() { - delete _sstorico; - delete _sdonazioni; - delete _storico; - delete _donaz; - delete _rel; - delete _msk; - return TRUE; + _rel = new TRelation(LF_SOGGETTI); + _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPDOM); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM"); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + add_cursor(new TCursor(_rel,"", 3)); + _msk = new TMask("at7500a"); + TConfig config(CONFIG_STUDIO); + TString16 etformato = config.get("EtFormato"); + _etlarghezza = config.get_int("EtLarghezza"); + _etcolonne = config.get_int("EtColonne"); + _form_eti = new TEti_profess_form(etformato); + _form_let = new TEti_profess_form("ATLETTER"); + return TRUE; +} + +bool TStampaProfess::user_destroy() +{ + delete _form_let; + delete _form_eti; + delete _msk; + delete _rel; + return TRUE; } int at7500(int argc, char* argv[]) { - TAggiornaDon a; - a.run(argc, argv, "Aggiornamento sez./sot. su archivio donazioni"); - return 0; -} \ No newline at end of file + TStampaProfess a; + a.run(argc, argv, "Soggetti selezionabili per dati statistici"); + return 0; +} diff --git a/at/at7500a.h b/at/at7500a.h new file mode 100755 index 000000000..c7693fb9e --- /dev/null +++ b/at/at7500a.h @@ -0,0 +1,38 @@ +// stampa soggetti per dati statistici (vari) +// definizione campi per maschera di selezione + +#define F_SEZINI 101 +#define F_D_SEZINI 102 +#define F_SOTINI 103 +#define F_D_SOTINI 104 +#define F_SEZFIN 105 +#define F_D_SEZFIN 106 +#define F_SOTFIN 107 +#define F_D_SOTFIN 108 + +#define F_CAT1 201 +#define F_D_CAT1 202 +#define F_CAT2 203 +#define F_D_CAT2 204 +#define F_CAT3 205 +#define F_D_CAT3 206 +#define F_CAT4 207 +#define F_D_CAT4 208 +#define F_CAT5 209 +#define F_D_CAT5 210 +#define F_CAT6 211 +#define F_D_CAT6 212 + +#define F_CONDOCC 301 +#define F_POSPROF 302 +#define F_RAMOATT 303 +#define F_TITSTUD 304 +#define F_PROFESS 305 +#define F_DESC_PROFESS 306 +#define F_LUOGOLAV 307 +#define F_DESC_LUOGOLAV 308 + +#define F_SINTETICO 401 +#define F_COMPLETO 402 +#define F_ETICHETTE 403 +#define F_LETTERE 404 diff --git a/at/at7600.cpp b/at/at7600.cpp index 8568a3852..83af4d1fd 100755 --- a/at/at7600.cpp +++ b/at/at7600.cpp @@ -1,48 +1,77 @@ +#include #include #include -#include -#include #include -#include + +#include "soggetti.h" +#include "sezioni.h" +#include #include "at7.h" +#include "at7600a.h" #include "atlib.h" -#include "at7600a.h" - -// nomi dei campi -#include "soggetti.h" -#include "contsan.h" -#include "idoneita.h" -#include "donaz.h" -#include "sezioni.h" -class TRiordinaControlli : public TPrintapp +#define ALIAS_LCPDOM 100 +#define ALIAS_TCS 200 + +enum ts { undefined=0, sintetico=1, completo=2, etichette=3, lettere=4 }; + +// definizione form per etichette +class TEti_consenso_form : public TForm { - TMask* _msk; - TRelation* _rel; - int _cur; - TLocalisamfile* _contsan; - TRecord_array* _scontrolli; - TLocalisamfile* _idoneita; - TRecord_array* _sidoneita; - TLocalisamfile* _donaz; - TRecord_array* _sdonazioni; - -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); - public: - void filtra_sezioni(); - TRiordinaControlli() {} + + virtual TCursor* cursor() const; + virtual TRelation* relation() const; + TPrint_section& get_body() { return section('B'); } ; + TEti_consenso_form(): TForm() {}; + TEti_consenso_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "") + : TForm(form,code,editlevel,desc) {}; + virtual ~TEti_consenso_form() {}; }; -HIDDEN inline TRiordinaControlli& app() { return (TRiordinaControlli&) main_app(); } +class TStampaConsenso : public TPrintapp +{ + TRelation* _rel; + TMask* _msk; + TEti_consenso_form* _form_eti; + TEti_consenso_form* _form_let; + TAssoc_array _categorie; + TParagraph_string _cognome_nome, _dencom; + TDate _data_stampa; + ts _tipostampa; + TString16 _codsez, _codsot; + int _etlarghezza, _etcolonne, _totale, _contatore; + char _consenso; -void TRiordinaControlli::filtra_sezioni() + static bool filter_func_consenso(const TRelation* rel); + +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 print_action postprocess_print(int file, int counter); + +public: + void crea_intestazione(); + void filtra_sezioni(); + void header_sezione(const TString16 codsez, const TString16 codsot); + void footer_sezione(); + void fine_stampa(); + + TMask& app_mask() { return *_msk; } + TStampaConsenso() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",30) {} +}; + +HIDDEN inline TStampaConsenso& app() { return (TStampaConsenso&) main_app(); } + +TCursor* TEti_consenso_form::cursor() const { return app().current_cursor(); } + +TRelation* TEti_consenso_form::relation() const { return cursor()->relation(); } + +void TStampaConsenso::filtra_sezioni() { const TString16 sezini = _msk->get(F_SEZINI); const TString16 sotini = _msk->get(F_SOTINI); @@ -61,108 +90,353 @@ void TRiordinaControlli::filtra_sezioni() current_cursor()->setregion(da, a); } - -bool TRiordinaControlli::preprocess_page(int file, int counter) -{ - bool rewrite = FALSE; - TRectype& recsog = current_cursor()->curr(); - const long codice = recsog.get_long(SOG_CODICE); - TRectype* keyc = new TRectype(LF_CONTSAN); - keyc->put(CON_CODICE, codice); - int err = _scontrolli->read(keyc); - TRectype* keyi = new TRectype(LF_IDONEITA); - keyi->put(IDO_CODICE, codice); - int erri = _sidoneita->read(keyi); - TRectype* keyd = new TRectype(LF_DONAZ); - keyd->put(DON_CODICE, codice); - int errd = _sdonazioni->read(keyd); - - //if ((err == NOERR || erri == NOERR) && (_scontrolli->rows() > 0 || _sidoneita->rows() > 0)) - if (err == NOERR || erri == NOERR || errd == NOERR) - { - calcola_donazioni_lib(recsog, _sdonazioni); - rewrite = TRUE; - } - if (rewrite) - current_cursor()->file().rewrite(); - return rewrite; -} - -void TRiordinaControlli::set_page(int file, int cnt) -{ - set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); -} - -bool TRiordinaControlli::set_print(int) +void TStampaConsenso::set_page(int file, int cnt) { + // costruzione etichette + switch (_tipostampa) + { + case etichette: + { + TPrint_section& corpo = _form_eti->get_body(); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case lettere: + { + TPrint_section& corpo = _form_let->get_body(); + corpo.update(); + for (word i = 0; i < corpo.height(); i++) + { + TPrintrow& riga = corpo.row(i); + set_row(i+1,riga); + } + force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage + // altrimenti stampa sempre la stessa etichetta + } + break; + case sintetico: + { + set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); + set_row(1,"@12g#a", &_cognome_nome); + set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@49g@6,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@56g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(1,"@67g@S", FLD(LF_SOGGETTI,SOG_TIPOULTDON)); + set_row(1,"@70g@S", FLD(LF_SOGGETTI,SOG_CONSENSO)); + set_row(2,""); + } + break; + case completo: + { + set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(2,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(3,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_CATDON)); + + set_row(1,"@9g@S",FLD(LF_SOGGETTI,SOG_COGNOME)); + set_row(2,"@9g@S",FLD(LF_SOGGETTI,SOG_NOME)); + set_row(3,"@9g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + + set_row(1,"@35g@S", FLD(LF_SOGGETTI,SOG_DOM_INDIR)); + set_row(2,"@35g#a", &_dencom); + + set_row(1,"@66g@S", FLD(LF_SOGGETTI,SOG_TELABI)); + set_row(2,"@66g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); + set_row(3,"@66g@S", FLD(LF_SOGGETTI,SOG_TELALT)); + + set_row(1,"@82gGr @S", FLD(LF_SOGGETTI,SOG_GRUPPOAB0)); + set_row(2,"@82gRh @S", FLD(LF_SOGGETTI,SOG_RHANTID)); + set_row(3,"@82gFe @S", FLD(LF_SOGGETTI,SOG_FENOTIPORH)); + set_row(4,"@82gKe @S", FLD(LF_SOGGETTI,SOG_KELL)); + set_row(5,"@82gDu @S", FLD(LF_SOGGETTI,SOG_DU)); + + set_row(1,"@94g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(2,"@94g@S", FLD(LF_SOGGETTI,SOG_TIPOULTDON)); + set_row(4,"@94g@pn", FLD(LF_SOGGETTI,SOG_TOTDON)); + + set_row(1,"@105g@S", FLD(LF_SOGGETTI,SOG_CONSENSO)); + + set_row(6,""); + } + break; + } +} + +bool TStampaConsenso::filter_func_consenso(const TRelation* rel) +{ + bool filtrato = TRUE; + TRectype recsog = rel->lfile().curr(); + // filtro per categorie + TAssoc_array& categorie = app()._categorie; + if (categorie.items() != 0) + { + const TString16 cat = recsog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + return filtrato; +} + +bool TStampaConsenso::preprocess_page(int file, int counter) +{ + if ((_tipostampa==sintetico) || (_tipostampa==completo)) + { + TRectype& recsog = current_cursor()->curr(); + TString80 nome = recsog.get(SOG_COGNOME); + nome << ' '; + nome << recsog.get(SOG_NOME); + _cognome_nome = nome; + TString256 localita = ""; + localita << recsog.get(SOG_DOM_CAP); + localita << ' '; + if (recsog.get(SOG_DOM_CODLOC).not_empty()) + localita << current_cursor()->curr(-ALIAS_LCPDOM).get("S0"); + else + localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM); + localita << ' ' << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM); + localita.trim(); + _dencom = localita; + // 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); + } + } + if (_tipostampa==etichette) + if (printer().rows_left() < _form_eti->get_body().height()) + printer().formfeed(); + _contatore++; + _totale++; + return TRUE; +} + +print_action TStampaConsenso::postprocess_print(int file, int counter) +{ + if (_contatore > 0) + footer_sezione(); + fine_stampa(); + return NEXT_PAGE; +} + +void TStampaConsenso::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; + } + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} + +void TStampaConsenso::footer_sezione() +{ + // stampa totale soggetti appartenenti alla sezione + if (_tipostampa==sintetico || _tipostampa==completo) + { + reset_footer(); + TString sep(80); + sep.fill('-'); + set_footer(2, (const char *) sep); + set_footer(3,"TOTALE SOGGETTI PER SEZIONE %d", _contatore); + printer().formfeed(); + reset_footer(); + } +} + +void TStampaConsenso::fine_stampa() +{ + // stampa totale soggetti a fine stampa + if (_tipostampa==sintetico || _tipostampa==completo) + { + reset_footer(); + TString sep(80); + 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(); + } +} + +bool TStampaConsenso::set_print(int m) +{ + TPrinter& p = printer(); + p.read_configuration(); + _tipostampa = undefined; KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { - TRectype da(LF_SOGGETTI); - TRectype a(LF_SOGGETTI); - const long codini = _msk->get_long(F_CODINI); - const long codfin = _msk->get_long(F_CODFIN); - if ((codini != 0) || (codfin != 0)) - { - da.zero(); - a.zero(); - if (codini != 0) - da.put(SOG_CODICE, codini); - if (codfin != 0) - a.put(SOG_CODICE, codfin); - _cur = add_cursor(new TCursor(_rel,"", 1, &da, &a)); - } - else - { - _cur = add_cursor(new TCursor(_rel,"", 3)); - filtra_sezioni(); - } - TString256 filtro = ""; - //filtro = "(90->STATO==\"ID\") && ((90->STATOSI==\"SO\") || (90->STATOAF==\"SO\"))"; - //filtro = "(90->CATDON==\"01\") || (90->CATDON==\"04\") || (90->CATDON==\"07\")"; - filtro = "(90->TIPOULTDON!=\"SI\") && (90->TIPOULTDON!=\"SN\") && (90->TIPOULTDON!=\"PL\") && (90->TIPOULTDON!=\"PN\") && (90->TIPOULTDON!=\"PP\") && (90->TIPOULTDON!=\"PI\")"; - current_cursor()->setfilter((const char*) filtro, TRUE); - - reset_files(); + switch (tasto) + { + case F_SINTETICO: + { + _tipostampa = sintetico; + _codsez = _codsot = "**"; + _totale = _contatore = 0; + } + break; + case F_COMPLETO: + { + _tipostampa = completo; + _codsez = _codsot = "**"; + _totale = _contatore = 0; + } + break; + case F_ETICHETTE: + _tipostampa = (configura_stampante(p, "AT_ETICHETTE", "etichette")) ? etichette : undefined; + break; + case F_LETTERE: + _tipostampa = lettere; + break; + } + if (_tipostampa != undefined) + { + reset_files(); add_file(LF_SOGGETTI); - reset_print(); + // filtro per sezioni selezionate + filtra_sezioni(); + _consenso = _msk->get(F_CONSENSO)[0]; + TString filtro; + // filtro per consenso + if (_consenso=='S') + current_cursor()->setfilter("(90->CONSENSO==\"X\")", TRUE); + else + if (_consenso=='N') + current_cursor()->setfilter("(90->CONSENSO!=\"X\")", TRUE); + // filtro per categorie + _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); + current_cursor()->set_filterfunction(filter_func_consenso); + reset_print(); + printer().footerlen(0); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TRiordinaControlli::user_create() +void TStampaConsenso::crea_intestazione() { - _msk = new TMask("at7600a"); - _rel = new TRelation(LF_SOGGETTI); - _contsan = new TLocalisamfile(LF_CONTSAN); - _scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON); - _idoneita = new TLocalisamfile(LF_IDONEITA); - _sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO); - _donaz = new TLocalisamfile(LF_DONAZ); - _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); - long items = _rel->lfile().items(); - return TRUE; -} + reset_header(); + if (_tipostampa==sintetico || _tipostampa==completo) + { + TString sep(132); + sep = "SOGGETTI PER CONSENSO "; + if (_consenso=='S') + sep << "Si"; + else + if (_consenso=='N') + sep << "No"; + else + sep << "Indifferente"; + sep.center_just(); + set_header(2, "@0g%s", (const char*) sep); + const TString16 data_stampa = _data_stampa.string(); + set_header(2,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(2, "@120g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(3, (const char *) sep); + if (_tipostampa==sintetico) + { + sep.fill('-',100); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gC.@12gCognome e nome@38gNato il@49gTess.@56gData/Tipo u.d.@70Consenso"); + set_header(6,"@0g--------@9g--@12g-------------------------@38g----------@49g------@56g---------- --@70g--------"); + } + else + { + sep.fill('-'); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gCognome@35gIndirizzo@66gTel.abitazione@82gTipiz@94gUlt.donaz.@105gConsenso"); + set_header(6,"@0gTessera@9gNome@66gTel.lavoro@82gzazione@94gTipo"); + set_header(7,"@0gCateg.@9gData nascita@66gTel.altro"); + set_header(8,"@94gTot.don."); + set_header(10,"@0g--------@9g-------------------------@35g------------------------------@66g--------------@82g------------@94g----------@105g--------"); + } + printer().footerlen(3); + } +} -bool TRiordinaControlli::user_destroy() +bool TStampaConsenso::user_create() { - delete _sdonazioni; - delete _donaz; - delete _sidoneita; - delete _idoneita; - delete _scontrolli; - delete _contsan; - delete _rel; - delete _msk; - return TRUE; + _rel = new TRelation(LF_SOGGETTI); + _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPDOM); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM"); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + add_cursor(new TCursor(_rel,"", 3)); + _msk = new TMask("at7600a"); + TConfig config(CONFIG_STUDIO); + TString16 etformato = config.get("EtFormato"); + _etlarghezza = config.get_int("EtLarghezza"); + _etcolonne = config.get_int("EtColonne"); + _form_eti = new TEti_consenso_form(etformato); + _form_let = new TEti_consenso_form("ATLETTER"); + return TRUE; +} + +bool TStampaConsenso::user_destroy() +{ + delete _form_let; + delete _form_eti; + delete _msk; + delete _rel; + return TRUE; } int at7600(int argc, char* argv[]) { - TRiordinaControlli a; - a.run(argc, argv, "Riordina controlli"); - return 0; -} \ No newline at end of file + TStampaConsenso a; + a.run(argc, argv, "Soggetti per consenso"); + return 0; +} diff --git a/at/at7700.cpp b/at/at7700.cpp index 7d0abfae2..a444a7c08 100755 --- a/at/at7700.cpp +++ b/at/at7700.cpp @@ -1,135 +1,342 @@ +#include #include #include -#include -#include -#include -#include + +#include "soggetti.h" +#include "sezioni.h" +#include #include "at7.h" +#include "at7700a.h" -#include "atlib.h" - -// nomi dei campi -#include "soggetti.h" -#include "contsan.h" -#include "donaz.h" - +#define ALIAS_LCP 100 #define ALIAS_TCS 200 -class TProblemiStato : public TPrintapp +class TStampaNonDom : public TPrintapp { - TMask* _msk; - TRelation* _rel; - int _cur; - TLocalisamfile* _soggetti; - TLocalisamfile* _contsan; - TLocalisamfile* _donaz; - TRecord_array* _scontrolli; - TRecord_array* _sdonazioni; - + static bool filter_func_nondom(const TRelation* rel); + + TRelation* _rel; + TMask* _msk; + TAssoc_array _catdon; + TAssoc_array _catnondon; + TParagraph_string _cognome_nome, _dencom; + TDate _data_stampa; + TString16 _codsez, _codsot, _codcom; + TString16 _tipostampa; + int _contatore; + 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); + public: - TProblemiStato() {} + void crea_intestazione(); + void filtra_sezioni(); + void header_sezione(const TString16 codsez, const TString16 codsot); + void header_comune(const TString16 codcom); + void footer_stampa(); + TMask& app_mask() { return *_msk; } + + TStampaNonDom() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",50) {} }; -HIDDEN inline TProblemiStato& app() { return (TProblemiStato&) main_app(); } +HIDDEN inline TStampaNonDom& app() { return (TStampaNonDom&) main_app(); } -bool TProblemiStato::preprocess_page(int file, int counter) -{ - bool rew = FALSE; - TRectype& recsog = current_cursor()->curr(); - const long codice = recsog.get_long(SOG_CODICE); - TString16 idon1 = recsog.get(SOG_IDON1); - if (idon1.empty()) - { - rew = TRUE; - TRectype* key = new TRectype(LF_CONTSAN); - key->put(CON_CODICE, codice); - int err = _scontrolli->read(key); - if (err == NOERR) - { - for (int r=1; r<=_scontrolli->rows(); r++) - { - TRectype& riga = _scontrolli->row(r, TRUE); - TString16 tipocon = riga.get(CON_TIPOCON); - const char stato = modstato_tcs(tipocon); - if (stato == 'I' || stato == 'F') - { - int numdonsi = recsog.get_int(SOG_TOTDONSI); - int numdonaf = recsog.get_int(SOG_TOTDONAF); - if (numdonsi != 0) - riga.put(CON_IDON1, "SI"); - if (numdonaf != 0) - riga.put(CON_IDON2, "PL"); - else - if (numdonaf != 0) - riga.put(CON_IDON1, "PL"); - } - } - _scontrolli->rewrite(); - //con_reord(recsog,_scontrolli, _sidoneita); - current_cursor()->file().rewrite(); - } - } - return rew; -} +void TStampaNonDom::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); + TRectype da(LF_SOGGETTI); + TRectype a(LF_SOGGETTI); + if (sezini.not_empty()) + da.put(SOG_CODSEZ, sezini); + if (sotini.not_empty()) + da.put(SOG_CODSOT, sotini); + if (sezfin.not_empty()) + a.put(SOG_CODSEZ, sezfin); + if (sotfin.not_empty()) + a.put(SOG_CODSOT, sotfin); + current_cursor()->setregion(da, a); +} -void TProblemiStato::set_page(int file, int cnt) -{ +void TStampaNonDom::set_page(int file, int cnt) +{ set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); - set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME)); - set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME)); + set_row(2,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); + set_row(1,"@12g#a", &_cognome_nome); + set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(2,"@38g@S", FLD(LF_SOGGETTI,SOG_CODSEZ)); + set_row(2,"@41g@S", FLD(LF_SOGGETTI,SOG_CODSOT)); + set_row(1,"@49g@S", FLD(LF_SOGGETTI,SOG_DOM_INDIR)); + set_row(1,"@100g@S", FLD(LF_SOGGETTI,SOG_TELABI)); + set_row(1,"@116g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); + set_row(2,"@49g#a", &_dencom); + set_row(2,"@116g@S", FLD(LF_SOGGETTI,SOG_TELALT)); + set_row(3,""); } -bool TProblemiStato::set_print(int) +bool TStampaNonDom::filter_func_nondom(const TRelation* rel) +{ + bool filtrato = FALSE; + TRectype& recsog = rel->curr(); + TRectype& recsez = rel->curr(LF_SEZIONI); + // filtro per categorie + TAssoc_array& categorie = app()._catdon; + if (categorie.items() != 0) + { + const TString16 cat = recsog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + if (!filtrato) + { + // filtro per categorie non donatori + TAssoc_array& categorie = app()._catnondon; + if (categorie.items() != 0) + { + const TString16 cat1 = recsog.get(SOG_CATNOND1); + const TString16 cat2 = recsog.get(SOG_CATNOND2); + filtrato = (categorie.is_key((const char*) cat1) || categorie.is_key((const char*) cat2)) ; + } + } + if (app()._catdon.items() == 0 && app()._catnondon.items() == 0) + filtrato = TRUE; + if (filtrato) + { + TString16 comsez = recsez.get(SEZ_COM); + TString16 comsog = recsog.get(SOG_DOM_CODCOM); + filtrato = ((comsez != comsog) && comsez.not_empty() && comsog.not_empty()); + } + return filtrato; +} + +void TStampaNonDom::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.not_empty()) + { + intestazione << '/'; + intestazione << densot; + } + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} + +void TStampaNonDom::header_comune(const TString16 codcom) +{ + TString80 dencom = current_cursor()->curr(LF_COMUNI).get(COM_DENCOM); + dencom << ' '; + dencom << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM); + TString intestazione(132); + intestazione = "Comune: "; + intestazione << codcom; + intestazione << ' '; + intestazione << dencom; + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} + +void TStampaNonDom::footer_stampa() +{ + // stampa totale soggetti a fine pagina + if (_contatore > 0) + { + reset_footer(); + TString sep(80); + sep.fill('-'); + set_footer(1, (const char *) sep); + set_footer(2,"TOTALE %d", _contatore); + printer().formfeed(); + reset_footer(); + } +} + +bool TStampaNonDom::preprocess_page(int file, int counter) +{ + TRectype& recsog = current_cursor()->curr(); + TString80 nome = recsog.get(SOG_COGNOME); + nome << ' '; + nome << recsog.get(SOG_NOME); + _cognome_nome = nome; + TString256 localita = ""; + localita << current_cursor()->curr(-ALIAS_LCP).get("S6"); + if (localita.not_empty()) + { + localita << ' '; + localita << current_cursor()->curr(-ALIAS_LCP).get("S0"); + localita << " - "; + } + else + { + localita = current_cursor()->curr(LF_COMUNI).get(COM_CAPCOM); + localita << ' '; + } + localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM); + localita << ' '; + localita << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM); + localita.trim(); + _dencom = localita; + // salto pagina se cambio sezione o comune + if (_tipostampa == "01") + { + const TString16 codsez = recsog.get(SOG_CODSEZ); + const TString16 codsot = recsog.get(SOG_CODSOT); + if ((_codsez!=codsez)||(_codsot!=codsot)) + { + if (_codsez != "**") + //printer().formfeed(); + footer_stampa(); + _contatore = 0; + _codsez = codsez; + _codsot = codsot; + header_sezione(codsez, codsot); + } + } + else + { + const TString16 codcom = recsog.get(SOG_DOM_CODCOM); + if (_codcom!=codcom) + { + if (_codcom != "**") + //printer().formfeed(); + footer_stampa(); + _contatore = 0; + _codcom = codcom; + header_comune(codcom); + } + } + _contatore++; + if (printer().rows_left()<3) + printer().formfeed(); + return TRUE; +} + +bool TStampaNonDom::set_print(int m) { KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { + if (tasto == K_ENTER) + { + _contatore = 0; + _codsez = "**"; + _codsot = "**"; + _codcom = "****"; + _tipostampa = _msk->get(F_TIPOSTAMPA); + TString80 chiave = ""; + if (_tipostampa == "01") + chiave = "90->CODSEZ|90->CODSOT|90->COGNOME|90->NOME"; + else + chiave = "90->DOM_CODCOM|90->COGNOME|90->NOME"; reset_files(); add_file(LF_SOGGETTI); - reset_print(); - current_cursor()->setfilter("((TCS->S6 == \"I\") || (TCS->S6 == \"F\"))", TRUE); + filtra_sezioni(); + _catdon.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()) + _catdon.add((const char*) catpri); + if (catsec.not_empty()) + _catdon.add((const char*) catsec); + if (catter.not_empty()) + _catdon.add((const char*) catter); + if (catqua.not_empty()) + _catdon.add((const char*) catqua); + if (catqui.not_empty()) + _catdon.add((const char*) catqui); + if (catses.not_empty()) + _catdon.add((const char*) catses); + _catnondon.destroy(); + const TString16 catnpri = _msk->get(F_CATN1); + const TString16 catnsec = _msk->get(F_CATN2); + const TString16 catnter = _msk->get(F_CATN3); + const TString16 catnqua = _msk->get(F_CATN4); + const TString16 catnqui = _msk->get(F_CATN5); + const TString16 catnses = _msk->get(F_CATN6); + if (catnpri.not_empty()) + _catnondon.add((const char*) catnpri); + if (catnsec.not_empty()) + _catnondon.add((const char*) catnsec); + if (catnter.not_empty()) + _catnondon.add((const char*) catnter); + if (catnqua.not_empty()) + _catnondon.add((const char*) catnqua); + if (catnqui.not_empty()) + _catnondon.add((const char*) catnqui); + if (catnses.not_empty()) + _catnondon.add((const char*) catnses); + current_cursor()->set_filterfunction (filter_func_nondom,TRUE); + ((TSorted_cursor*)current_cursor())->change_order(chiave); + reset_print(); + printer().footerlen(0); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TProblemiStato::user_create() +void TStampaNonDom::crea_intestazione() { - _msk = new TMask("at7700a"); - _rel = new TRelation(LF_SOGGETTI); - _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); - _contsan = new TLocalisamfile(LF_CONTSAN); - _donaz = new TLocalisamfile(LF_DONAZ); - _scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON); - _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); - _cur = add_cursor(new TCursor(_rel, "", 1)); - return TRUE; -} + reset_header(); + TString sep(132); + sep = "STAMPA SOGGETTI NON DOMICILIATI NEL COMUNE DELLA SEZIONE"; + sep.center_just(); + set_header(2, "@0g%s", (const char*) sep); + TString16 data_stampa = _data_stampa.string(); + set_header(2,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(2, "@120g%s", (const char*) sep); + sep = ""; + sep.fill('-'); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gC.@12gCognome e nome@38gNato il@49gIndirizzo@100gTelefono abit.@116gTelefono lavoro"); + set_header(6,"@0gTessera@38gSe/So@49gCAP/Località/Comune/Prov.@116gTelefono altro"); + set_header(7,"@0g--------@9g--@12g-------------------------@38g----------@49g--------------------------------------------------@100g---------------@116g---------------"); + printer().footerlen(3); +} -bool TProblemiStato::user_destroy() +bool TStampaNonDom::user_create() { - delete _sdonazioni; - delete _scontrolli; - delete _donaz; - delete _contsan; - delete _rel; - delete _msk; - return TRUE; + _rel = new TRelation(LF_SOGGETTI); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCP); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM"); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + add_cursor(new TSorted_cursor(_rel,"","",3)); + _msk = new TMask("at7700a"); + return TRUE; +} + +bool TStampaNonDom::user_destroy() +{ + delete _msk; + delete _rel; + return TRUE; } int at7700(int argc, char* argv[]) { - TProblemiStato a; - a.run(argc, argv, "Soggetti con problemi sullo stato"); - return 0; -} \ No newline at end of file + TStampaNonDom a; + a.run(argc, argv, "Soggetti non domiciliati nel comune di sez."); + return 0; +} diff --git a/at/at7700a.h b/at/at7700a.h new file mode 100755 index 000000000..9a807179c --- /dev/null +++ b/at/at7700a.h @@ -0,0 +1,39 @@ +// stampa elenco soggetti non domiciliati nel comune della sezione +// definizione campi per maschera di selezione + +#define F_SEZINI 101 +#define F_D_SEZINI 102 +#define F_SOTINI 103 +#define F_D_SOTINI 104 +#define F_SEZFIN 105 +#define F_D_SEZFIN 106 +#define F_SOTFIN 107 +#define F_D_SOTFIN 108 + +#define F_CAT1 201 +#define F_D_CAT1 202 +#define F_CAT2 203 +#define F_D_CAT2 204 +#define F_CAT3 205 +#define F_D_CAT3 206 +#define F_CAT4 207 +#define F_D_CAT4 208 +#define F_CAT5 209 +#define F_D_CAT5 210 +#define F_CAT6 211 +#define F_D_CAT6 212 + +#define F_CATN1 301 +#define F_D_CATN1 302 +#define F_CATN2 303 +#define F_D_CATN2 304 +#define F_CATN3 305 +#define F_D_CATN3 306 +#define F_CATN4 307 +#define F_D_CATN4 308 +#define F_CATN5 309 +#define F_D_CATN5 310 +#define F_CATN6 311 +#define F_D_CATN6 312 + +#define F_TIPOSTAMPA 401 diff --git a/at/at7800.cpp b/at/at7800.cpp index 925ec5703..9dfabe396 100755 --- a/at/at7800.cpp +++ b/at/at7800.cpp @@ -1,52 +1,59 @@ +#include #include #include -#include -//#include + +#include "soggetti.h" +#include "sezioni.h" +#include #include "at7.h" -#include "atlib.h" -#include "at7800a.h" - -// nomi dei campi -#include "soggetti.h" -#include "contsan.h" -#include "idoneita.h" -#include "sezioni.h" +#include "at7800a.h" -class TRiminiRO_app : public TPrintapp +#define ALIAS_LCP 100 +#define ALIAS_TCS 200 + +class TStampaIncompleti : public TPrintapp { - TMask* _msk; - TRelation* _rel; - TLocalisamfile* _contsan; - TRecord_array* _scontrolli; - TLocalisamfile* _idoneita; - TRecord_array* _sidoneita; - int _cur; - TDate _datarif; + static bool filter_func_incompleti(const TRelation* rel); + TRelation* _rel; + TMask* _msk; + TAssoc_array _catdon; + TAssoc_array _catnondon; + TParagraph_string _cognome_nome, _dencom; + TDate _data_stampa; + TString16 _codsez, _codsot, _altridati; + bool _indirizzo, _datanasc, _categoria, _sezione, _gruppoab0; + bool _rhantid, _tessera, _telabi, _cf, _incompleto, _comune; + bool _sottog, _sesso; + 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); + public: + void crea_intestazione(); void filtra_sezioni(); - TRiminiRO_app() {} + void header_sezione(const TString16 codsez, const TString16 codsot); + TMask& app_mask() { return *_msk; } + + TStampaIncompleti() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",50) {} }; -HIDDEN inline TRiminiRO_app& app() { return (TRiminiRO_app&) main_app(); } +HIDDEN inline TStampaIncompleti& app() { return (TStampaIncompleti&) main_app(); } -void TRiminiRO_app::filtra_sezioni() +void TStampaIncompleti::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); TRectype da(LF_SOGGETTI); - TRectype a (LF_SOGGETTI); - if (sezini.not_empty()) + TRectype a(LF_SOGGETTI); + if (sezini.not_empty()) da.put(SOG_CODSEZ, sezini); if (sotini.not_empty()) da.put(SOG_CODSOT, sotini); @@ -57,185 +64,328 @@ void TRiminiRO_app::filtra_sezioni() current_cursor()->setregion(da, a); } -bool TRiminiRO_app::preprocess_page(int file, int counter) -{ - bool rewrite = FALSE; - TRectype& recsog = current_cursor()->curr(); - const long codice = recsog.get_long(SOG_CODICE); - TRectype* keyc = new TRectype(LF_CONTSAN); - keyc->put(CON_CODICE, codice); - int err = _scontrolli->read(keyc); - if (err == NOERR) - { - TDate primocon(NULLDATE); - TString16 tipocon; - int numido = 0; - int numcon = 0; - for (int c=1; c<=_scontrolli->rows(); c++) - { - TRectype& riga = _scontrolli->row(c, TRUE); - tipocon = riga.get(CON_TIPOCON); - TDate datacon = riga.get_date(CON_DATACON); - // mi segno la data del primo controllo per inserire una PI - // il giorno prima nei donatori che non hanno l'idoneita' - if (c==1) - primocon = datacon; - // se il controllo è avvenuto prima della data di riferimento - if (datacon <= _datarif) - { - if (tipocon == "RO") - { - numcon++; - riga.put(CON_TIPOCON,"R1"); - riga.put(CON_IDON1," "); - riga.put(CON_IDON2," "); - riga.put(CON_IDON3," "); - riga.put(CON_IDON4," "); - riga.put(CON_INTSI,0); - riga.put(CON_INTAF,0); - } - if (tipocon == "ID") - { - TString16 motivo = riga.get(CON_MOTIVO); - TString80 responsab = riga.get(CON_RESPONSAB); - if (motivo.empty() && responsab.empty()) - { - numcon++; - riga.put(CON_TIPOCON,"V1"); - riga.put(CON_IDON1," "); - riga.put(CON_IDON2," "); - riga.put(CON_IDON3," "); - riga.put(CON_IDON4," "); - riga.put(CON_INTSI,0); - riga.put(CON_INTAF,0); - } - } - } - tipocon = riga.get(CON_TIPOCON); - if ((tipocon == "ID") || (tipocon == "RO") || (tipocon == "PI")) - { - numido++; - if (!((riga.get(CON_IDON1) == "PL") || (riga.get(CON_IDON2) == "PL") || (riga.get(CON_IDON3) == "PL") || (riga.get(CON_IDON4) == "PL"))) - riga.put(CON_INTAF,0); - if ((riga.get(CON_IDON1).empty()) && (riga.get(CON_IDON2).empty()) && (riga.get(CON_IDON3).empty()) && (riga.get(CON_IDON4).empty())) - { - riga.put(CON_IDON1, "SI"); - riga.put(CON_INTSI, recsog.get(SOG_INTSI)); - if (recsog.get_int(SOG_INTSI) == 0) - riga.put(CON_INTSI, 94); - } - } - } - if ((numido == 0) && (numcon > 0)) - { - --primocon; - TRectype riga(LF_CONTSAN); - riga.put(CON_CODICE, codice); - riga.put(CON_PROGCON, 1); - riga.put(CON_DATACON, primocon); - riga.put(CON_TIPOCON, "PI"); - riga.put(CON_IDON1, recsog.get(SOG_IDON1)); - riga.put(CON_IDON2, recsog.get(SOG_IDON2)); - riga.put(CON_IDON3, recsog.get(SOG_IDON3)); - riga.put(CON_IDON4, recsog.get(SOG_IDON4)); - riga.put(CON_INTSI, recsog.get(SOG_INTSI)); - riga.put(CON_INTAF, recsog.get(SOG_INTAF)); - riga.put(CON_RESPONSAB, "CONVERSIONE"); - if (!((riga.get(CON_IDON1) == "PL") || (riga.get(CON_IDON2) == "PL") || (riga.get(CON_IDON3) == "PL") || (riga.get(CON_IDON4) == "PL"))) - riga.put(CON_INTAF,0); - _scontrolli->insert_row(riga); - } - if ((numcon > 0) || (numido > 0)) - _scontrolli->rewrite(); - } - TRectype* keyi = new TRectype(LF_IDONEITA); - keyi->put(IDO_CODICE, codice); - int erri = _sidoneita->read(keyi); - if ((err == NOERR || erri == NOERR) && (_scontrolli->rows() > 0 || _sidoneita->rows() > 0)) - { - con_reord(recsog,_scontrolli, _sidoneita); - rewrite = TRUE; - } - if (rewrite) - current_cursor()->file().rewrite(); - return rewrite; -} - -void TRiminiRO_app::set_page(int file, int cnt) -{ +void TStampaIncompleti::set_page(int file, int cnt) +{ set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########")); + set_row(2,"@0g@8,rs", FLD(LF_SOGGETTI,SOG_TESSAVIS)); + set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON)); + set_row(1,"@12g#a", &_cognome_nome); + set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC)); + set_row(1,"@49g@S", FLD(LF_SOGGETTI,SOG_DOM_INDIR)); + set_row(2,"@49g#a", &_dencom); + set_row(1,"@100g@S", FLD(LF_SOGGETTI,SOG_TELABI)); + set_row(2,"@100g@S", FLD(LF_SOGGETTI,SOG_TELLAV)); + set_row(3,"@100g@S", FLD(LF_SOGGETTI,SOG_TELALT)); + set_row(1,"@116g@ld", FLD(LF_SOGGETTI,SOG_DATAISC)); + set_row(2,"@116g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON)); + set_row(4,""); } +bool TStampaIncompleti::filter_func_incompleti(const TRelation* rel) +{ + bool filtrato = FALSE; + bool incompleto = FALSE; + TLocalisamfile& sog = rel->lfile(); + // filtro per categorie + TAssoc_array& categorie = app()._catdon; + if (categorie.items() != 0) + { + const TString16 cat = sog.get(SOG_CATDON); + filtrato = categorie.is_key((const char*) cat); + } + if (!filtrato) + { + // filtro per categorie non donatori + TAssoc_array& categorie = app()._catnondon; + if (categorie.items() != 0) + { + const TString16 cat1 = sog.get(SOG_CATNOND1); + const TString16 cat2 = sog.get(SOG_CATNOND2); + filtrato = (categorie.is_key((const char*) cat1) || categorie.is_key((const char*) cat2)) ; + } + } + if (app()._catdon.items() == 0 && app()._catnondon.items() == 0) + filtrato = TRUE; + incompleto = app()._incompleto; + if (filtrato && app()._indirizzo && !incompleto) + { + TString80 indirizzo = sog.get(SOG_DOM_INDIR); + //TString16 codcom = sog.get(SOG_DOM_CODCOM); + //incompleto = (indirizzo.empty() || codcom.empty()); + incompleto = indirizzo.empty(); + } + if (filtrato && app()._comune && !incompleto) + { + TString16 codcom = sog.get(SOG_DOM_CODCOM); + incompleto = codcom.empty(); + } + if (filtrato && app()._datanasc && !incompleto) + { + TDate datanasc = sog.get(SOG_DATANASC); + incompleto = (datanasc.empty()); + } + if (filtrato && app()._categoria && !incompleto) + { + TString16 catdon = sog.get(SOG_CATDON); + TString16 catnond1 = sog.get(SOG_CATNOND1); + TString16 catnond2 = sog.get(SOG_CATNOND2); + incompleto = (catdon.empty() && catnond1.empty() && catnond2.empty()); + } + if (filtrato && app()._sezione && !incompleto) + { + TString16 codsez = sog.get(SOG_CODSEZ); + incompleto = codsez.empty(); + } + if (filtrato && app()._sottog && !incompleto) + { + TString16 codsot = sog.get(SOG_CODSOT); + incompleto = codsot.empty(); + } + if (filtrato && app()._gruppoab0 && !incompleto) + { + TString16 gruppoab0 = sog.get(SOG_GRUPPOAB0); + incompleto = gruppoab0.empty(); + } + if (filtrato && app()._rhantid && !incompleto) + { + TString16 rhantid = sog.get(SOG_RHANTID); + incompleto = rhantid.empty(); + } + if (filtrato && app()._tessera && !incompleto) + { + TString16 tessera = sog.get(SOG_TESSAVIS); + incompleto = tessera.empty(); + } + if (filtrato && app()._telabi && !incompleto) + { + TString16 telabi = sog.get(SOG_TELABI); + incompleto = telabi.empty(); + } + if (filtrato && app()._cf && !incompleto) + { + TString16 cf = sog.get(SOG_CF); + incompleto = cf.empty(); + } + if (filtrato && app()._sesso && !incompleto) + { + TString16 sesso = sog.get(SOG_SESSO); + incompleto = (sesso.empty()) || (sesso[0] == '0'); + } + if ((filtrato) && (app()._altridati.not_empty()) && (!incompleto)) + { + TString80 str = sog.get(app()._altridati); + incompleto = str.empty(); + } + + filtrato = (filtrato && incompleto); + return filtrato; +} -bool TRiminiRO_app::set_print(int) +void TStampaIncompleti::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.not_empty()) + { + intestazione << "/"; + intestazione << densot; + } + intestazione.center_just(); + set_header(1,"@0g%s", (const char*) intestazione); + return; +} + +bool TStampaIncompleti::preprocess_page(int file, int counter) +{ + TRectype& recsog = current_cursor()->curr(); + TString80 nome = recsog.get(SOG_COGNOME); + nome << " "; + nome << recsog.get(SOG_NOME); + _cognome_nome = nome; + TString256 localita = ""; + localita = recsog.get(SOG_DOM_CAP); + localita << ' '; + if (recsog.get(SOG_DOM_CODLOC).not_empty()) + { + localita << current_cursor()->curr(-ALIAS_LCP).get("S0"); + localita << " - "; + } + localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM); + localita.trim(); + _dencom = localita; + // 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); + } + if (printer().rows_left()<4) + printer().formfeed(); + return TRUE; +} + +bool TStampaIncompleti::set_print(int m) { KEY tasto; tasto = _msk->run(); - if (tasto == K_ENTER) - { - _datarif = _msk->get_date(F_DATARIF); - TRectype da(LF_SOGGETTI); - TRectype a(LF_SOGGETTI); - 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 long codini = _msk->get_long(F_CODINI); - const long codfin = _msk->get_long(F_CODFIN); - if ((codini != 0) || (codfin != 0)) - { - da.zero(); - a.zero(); - if (codini != 0) - da.put(SOG_CODICE, codini); - if (codfin != 0) - a.put(SOG_CODICE, codfin); - TString filtro; - if ((sezini == sezfin) && (sotini == sotfin)) - filtro << SOG_CODSEZ << " == \"" << sezini << "\""; - else - filtro = ""; - _cur = add_cursor(new TCursor(_rel,filtro, 1, &da, &a)); - } - else - { - _cur = add_cursor(new TCursor(_rel,"", 3)); - filtra_sezioni(); - } - reset_files(); + if (tasto == K_ENTER) + { + _codsez = "**"; + _codsot = "**"; + reset_files(); add_file(LF_SOGGETTI); - reset_print(); + filtra_sezioni(); + _catdon.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()) + _catdon.add((const char*) catpri); + if (catsec.not_empty()) + _catdon.add((const char*) catsec); + if (catter.not_empty()) + _catdon.add((const char*) catter); + if (catqua.not_empty()) + _catdon.add((const char*) catqua); + if (catqui.not_empty()) + _catdon.add((const char*) catqui); + if (catses.not_empty()) + _catdon.add((const char*) catses); + _catnondon.destroy(); + const TString16 catnpri = _msk->get(F_CATN1); + const TString16 catnsec = _msk->get(F_CATN2); + const TString16 catnter = _msk->get(F_CATN3); + const TString16 catnqua = _msk->get(F_CATN4); + const TString16 catnqui = _msk->get(F_CATN5); + const TString16 catnses = _msk->get(F_CATN6); + if (catnpri.not_empty()) + _catnondon.add((const char*) catnpri); + if (catnsec.not_empty()) + _catnondon.add((const char*) catnsec); + if (catnter.not_empty()) + _catnondon.add((const char*) catnter); + if (catnqua.not_empty()) + _catnondon.add((const char*) catnqua); + if (catnqui.not_empty()) + _catnondon.add((const char*) catnqui); + if (catnses.not_empty()) + _catnondon.add((const char*) catnses); + _indirizzo = _msk->get_bool(F_INDIRIZZO); + _comune = _msk->get_bool(F_COMUNE); + _datanasc = _msk->get_bool(F_DATANASC); + _categoria = _msk->get_bool(F_CATEGORIA); + _sezione = _msk->get_bool(F_SEZIONE); + _sottog = _msk->get_bool(F_SOTTOG); + _gruppoab0 = _msk->get_bool(F_GRUPPOAB0); + _rhantid = _msk->get_bool(F_RHANTID); + _tessera = _msk->get_bool(F_TESSERA); + _telabi = _msk->get_bool(F_TELABI); + _cf = _msk->get_bool(F_CF); + _sesso = _msk->get_bool(F_SESSO); + _altridati = _msk->get(F_ALTRIDATI); + _incompleto = !(_incompleto || app()._indirizzo || app()._datanasc || + app()._categoria || app()._sezione || app()._gruppoab0 || + app()._rhantid || app()._tessera || app()._telabi || + app()._cf || app()._comune || app()._sottog || app()._sesso + || app()._altridati.not_empty()); + current_cursor()->set_filterfunction (filter_func_incompleti); + reset_print(); + crea_intestazione(); return TRUE; } else return FALSE; } -bool TRiminiRO_app::user_create() +void TStampaIncompleti::crea_intestazione() { - _msk = new TMask("at7800a"); - _rel = new TRelation(LF_SOGGETTI); - _contsan = new TLocalisamfile(LF_CONTSAN); - _scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON); - _idoneita = new TLocalisamfile(LF_IDONEITA); - _sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO); - return TRUE; -} + reset_header(); + TString sep(132); + sep = "STAMPA DI CONTROLLO SOGGETTI INCOMPLETI"; + sep.center_just(); + set_header(2, "@0g%s", (const char*) sep); + TString16 data_stampa = _data_stampa.string(); + set_header(2,"@0g%10s", (const char*) data_stampa); + sep = ""; + sep << "Pag. @#"; + set_header(2, "@120g%s", (const char*) sep); + sep = "DATI MANCANTI: "; + if (_indirizzo) + sep << "Indirizzo dom.- "; + if (_datanasc) + sep << "Data nascita - "; + if (_gruppoab0) + sep << "Gruppo AB0 - "; + if (_rhantid) + sep << "Rh/AntiD - "; + if (_sezione) + sep << "Sesione - "; + if (_categoria) + sep << "Categoria - "; + if (_tessera) + sep << "Tess.AVIS - "; + if (_telabi) + sep << "Tel.abit. - "; + if (_cf) + sep << "Cod.fiscale - "; + if (_comune) + sep << "Comune dom. - "; + if (_sottog) + sep << "Sottog. - "; + if (_sesso) + sep << "Sesso - "; + if (_altridati.not_empty()) + { + TList_field& list = (TList_field&)app_mask().field(F_ALTRIDATI); + sep << list.raw2win(list.get()); + } + sep.center_just(); + set_header(3, (const char *) sep); + sep = ""; + sep.fill('-'); + set_header(4, (const char *) sep); + set_header(5,"@0gCodice@9gC.@12gCognome e nome@38gNato il@49gIndirizzo@100gTelefono abit.@116gData iscr."); + set_header(6,"@0gTessera@49gCAP/Località/Comune/Prov.@100gTelefono lavoro@116gUlt. don."); + set_header(7,"@100gTelefono altro"); + set_header(8,"@0g--------@9g--@12g-------------------------@38g----------@49g--------------------------------------------------@100g---------------@116g----------"); +} -bool TRiminiRO_app::user_destroy() +bool TStampaIncompleti::user_create() { - delete _sidoneita; - delete _idoneita; - delete _scontrolli; - delete _contsan; - delete _rel; - delete _msk; - return TRUE; + _rel = new TRelation(LF_SOGGETTI); + _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCP); + _rel->add(LF_COMUNI, "COM==DOM_CODCOM"); + _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT"); + add_cursor(new TCursor(_rel, "", 3)); + _msk = new TMask("at7800a"); + return TRUE; +} + +bool TStampaIncompleti::user_destroy() +{ + delete _msk; + delete _rel; + return TRUE; } int at7800(int argc, char* argv[]) { - TRiminiRO_app a; - a.run(argc, argv, "Correzione controlli RO"); - return 0; -} \ No newline at end of file + TStampaIncompleti a; + a.run(argc, argv, "Stampa di controllo soggetti incompleti"); + return 0; +}