diff --git a/at/at4300.cpp b/at/at4300.cpp index b99eeb485..bbd9b6692 100755 --- a/at/at4300.cpp +++ b/at/at4300.cpp @@ -146,7 +146,17 @@ void TStampaConvocazioni::set_page(int file, int cnt) for (int r=1;r<=_etcolonne;r++) { if (current_cursor()->pos()items()) - { + { + bool avanza = TRUE; + while (avanza) + { + if (current_cursor()->pos()items()) + avanza = !(preprocess_page(file, cnt)); + else + avanza = FALSE; + if (avanza) + ++(*current_cursor()); + } force_setpage(TRUE); corpo.update(); for (word i = 0; i < corpo.height(); i++) @@ -161,7 +171,17 @@ void TStampaConvocazioni::set_page(int file, int cnt) set_row(i+1,riga1); } if (r < _etcolonne) - ++(*current_cursor()); + { + bool avanza = TRUE; + while (avanza) + { + ++(*current_cursor()); + if (current_cursor()->pos()items()) + avanza = !(preprocess_page(file, cnt)); + else + avanza = FALSE; + } + } } } } diff --git a/at/at9300.cpp b/at/at9300.cpp index 5ebd1100a..a97704141 100755 --- a/at/at9300.cpp +++ b/at/at9300.cpp @@ -41,6 +41,9 @@ class TProv2com: public TSkeleton_application TLocalisamfile* _soggetti; TRecord_array* _sdonazioni; // sheet donazioni TRecord_array* _scontrolli; // sheet controlli + TRecord_array* _sidoneita; // sheet idoneita + TRecord_array* _sbenem; // sheet benemerenze + TRecord_array* _sstorico; // sheet storico long _lastcod; bool _print_header; @@ -51,6 +54,8 @@ protected: void agg_anagrafica(const TRectype& recsog, const bool aggiorna); void agg_donazione(const TRectype& recsog, const TRectype& recdon); void agg_controllo(const TRectype& recsog, const TRectype& reccon); + void agg_benemerenza(const TRectype& recsog, const TRectype& recben); + void agg_storico(const TRectype& recsog, const TRectype& recsto); void transfer(); void print_line(const TString& message=""); @@ -60,7 +65,7 @@ public: virtual ~TProv2com() {} }; -static int compare_date(const TObject** o1, const TObject** o2) +static int compare_date_con(const TObject** o1, const TObject** o2) { const TRectype& s1 = *((TRectype*)*o1); const TRectype& s2 = *((TRectype*)*o2); @@ -75,6 +80,36 @@ static int compare_date(const TObject** o1, const TObject** o2) return d; } +static int compare_date_ben(const TObject** o1, const TObject** o2) +{ + const TRectype& s1 = *((TRectype*)*o1); + const TRectype& s2 = *((TRectype*)*o2); + + const TDate d1(s1.get(BEN_DATABEN)); + const TDate d2(s2.get(BEN_DATABEN)); + + int d=0; + if (d1>d2) d=+1; + else + if (d1d2) d=+1; + else + if (d1get(campo, "SOGGETTI")[0]; + char operazione = _configfile->get(campo, "SOGGETTI")[0]; + if (operazione == ' ') + operazione = X_IGNORA; TString esterno = recsog.get(campo); TString interno = rec.get(campo); if (esterno != interno) @@ -404,7 +447,8 @@ void TProv2com::agg_donazione(const TRectype& recsog, const TRectype& recdon) rec.put(SOG_UTENULTAGG, "PROV"); _soggetti->rewrite(rec); if (!_print_header) - { + { + print_line(); print_line(intestazione); _print_header = TRUE; } @@ -454,15 +498,20 @@ void TProv2com::agg_controllo(const TRectype& recsog, const TRectype& reccon) recnew.put(CON_CODICE, rec.get_long(SOG_CODICE)); recnew.put(CON_PROGCON, _scontrolli->rows()+1); _scontrolli->add_row(recnew); - _scontrolli->sort(compare_date); + _scontrolli->sort(compare_date_con); _scontrolli->rewrite(); - calcola_donazioni_lib(rec, _sdonazioni); + TRectype* keyi = new TRectype(LF_IDONEITA); + keyi->put(IDO_CODICE, rec.get(SOG_CODICE)); + err = _sidoneita->read(keyi); + con_reord(rec, _scontrolli, _sidoneita); + don_datepross(rec); TDate oggi(TODAY); rec.put(SOG_DATAULTAGG, oggi); rec.put(SOG_UTENULTAGG, "PROV"); _soggetti->rewrite(rec); if (!_print_header) - { + { + print_line(); print_line(intestazione); _print_header = TRUE; } @@ -473,6 +522,113 @@ void TProv2com::agg_controllo(const TRectype& recsog, const TRectype& reccon) } } +void TProv2com::agg_benemerenza(const TRectype& recsog, const TRectype& recben) +{ + TString intestazione = ""; + TString message = ""; + const TString80 cognome = recsog.get(SOG_COGNOME); + const TString80 nome = recsog.get(SOG_NOME); + const TDate datanasc = recsog.get_date(SOG_DATANASC); + _soggetti->setkey(2); + TRectype& rec = _rel->curr(); + rec.zero(); + rec.put(SOG_COGNOME, cognome); + rec.put(SOG_NOME, nome); + rec.put(SOG_DATANASC, datanasc); + intestazione = cognome; + intestazione << " "; + intestazione << nome; + intestazione << " "; + intestazione << datanasc.string(); + if (_soggetti->read(rec)==NOERR) + { + const TString16& tipoben = recben.get(BEN_TIPOBEN); + TLocalisamfile benem(LF_BENEM); + benem.setkey(3); + benem.zero(); + benem.put(BEN_CODICE, rec.get(SOG_CODICE)); + benem.put(BEN_TIPOBEN, tipoben); + if (benem.read()==NOERR) + { + // esiste gia la benemerenza + } + else + { + TRectype* key = new TRectype(LF_BENEM); + key->put(BEN_CODICE, rec.get(SOG_CODICE)); + int err = _sbenem->read(key); + TRectype recnew(recben); + recnew.put(BEN_CODICE, rec.get_long(SOG_CODICE)); + recnew.put(BEN_PROGBEN, _sbenem->rows()+1); + _sbenem->add_row(recnew); + _sbenem->sort(compare_date_ben); + _sbenem->rewrite(); + TDate oggi(TODAY); + rec.put(SOG_DATAULTAGG, oggi); + rec.put(SOG_UTENULTAGG, "PROV"); + _soggetti->rewrite(rec); + if (!_print_header) + { + print_line(); + print_line(intestazione); + _print_header = TRUE; + } + message.format(" INSERITA BENEMERENZA %s", (const char*) tipoben); + print_line(message); + } + } +} + +void TProv2com::agg_storico(const TRectype& recsog, const TRectype& recsto) +{ + TString intestazione = ""; + TString message = ""; + const TString80 cognome = recsog.get(SOG_COGNOME); + const TString80 nome = recsog.get(SOG_NOME); + const TDate datanasc = recsog.get_date(SOG_DATANASC); + _soggetti->setkey(2); + TRectype& rec = _rel->curr(); + rec.zero(); + rec.put(SOG_COGNOME, cognome); + rec.put(SOG_NOME, nome); + rec.put(SOG_DATANASC, datanasc); + intestazione = cognome; + intestazione << " "; + intestazione << nome; + intestazione << " "; + intestazione << datanasc.string(); + if (_soggetti->read(rec)==NOERR) + { + TRectype recnew(recsto); + recnew.put(STO_CODICE, rec.get_long(SOG_CODICE)); + TRectype* key = new TRectype(LF_STORICO); + key->put(STO_CODICE, rec.get(SOG_CODICE)); + int err = _sstorico->read(key); + const int progsto = recsto.get_int(STO_PROGSTO); + TLocalisamfile storico(LF_STORICO); + storico.setkey(1); + storico.zero(); + storico.put(STO_CODICE, rec.get(SOG_CODICE)); + storico.put(STO_PROGSTO, progsto); + if (storico.read()!=NOERR) + recnew.put(STO_PROGSTO, _sstorico->rows()+1); + _sstorico->add_row(recnew); + _sstorico->sort(compare_date_sto); + _sstorico->rewrite(); + TDate oggi(TODAY); + rec.put(SOG_DATAULTAGG, oggi); + rec.put(SOG_UTENULTAGG, "PROV"); + _soggetti->rewrite(rec); + if (!_print_header) + { + print_line(); + print_line(intestazione); + _print_header = TRUE; + } + message.format(" INSERITA RIGA DI STORICO"); + print_line(message); + } +} int at9300(int argc, char* argv[]) {