diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 8e10ec384..3a15f161b 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -1082,8 +1082,8 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key) { const long max = app()._lastreg+1; - _skip_giornale_check = FALSE; - _skip_bollato_check = FALSE; + app()._skip_giornale_check = FALSE; + app()._skip_bollato_check = FALSE; if (num < max) { @@ -1094,16 +1094,16 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key) if (mov.get_bool("STAMPATO")) { - ok = yesnobox("Il movimento e' gia' stato stampato sul libro giornale:\n" - "si desidera continuare ugualmente"); - _skip_giornale_check = ok; + ok = yesno_box("Il movimento e' gia' stato stampato sul libro giornale:\n" + "si desidera continuare ugualmente"); + app()._skip_giornale_check = ok; } if (ok && mov.get_bool("REGST")) { - ok = yesnobox("Il movimento e' gia' stato stampato sul bollato:\n" - "si desidera continuare ugualmente"); - _skip_bollato_check = ok; + ok = yesno_box("Il movimento e' gia' stato stampato sul bollato:\n" + "si desidera continuare ugualmente"); + app()._skip_bollato_check = ok; } if (ok) @@ -1207,7 +1207,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) const long numreg = m.get_long(F_NUMREG); const bool error = numreg == 0 || numreg > app()._lastreg; - if (!_skip_giornale_check) + if (!app()._skip_giornale_check) { const TLibro_giornale& gio = app().giornale(); if (dr < gio.last_print()) @@ -1239,7 +1239,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key) m.field(F_CODREG).on_hit(); } - if (!_skip_bollato_check) + if (!app()._skip_bollato_check) { if (dr < reg.last_print()) { diff --git a/cg/cg3500.cpp b/cg/cg3500.cpp index 7f4ebc485..7a21f4a5c 100755 --- a/cg/cg3500.cpp +++ b/cg/cg3500.cpp @@ -3,11 +3,11 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/cg/cg4.cpp b/cg/cg4.cpp index 8ab1467a4..a5af8bb16 100755 --- a/cg/cg4.cpp +++ b/cg/cg4.cpp @@ -1,5 +1,7 @@ #include #include + +#define __MAIN__ #include "cg4.h" const char* const usage = "Errore - uso : %s -{0|1|2|3|4|5}"; diff --git a/cg/cg4.h b/cg/cg4.h index 6abc039d1..fd6ac8d10 100755 --- a/cg/cg4.h +++ b/cg/cg4.h @@ -1,6 +1,10 @@ #ifndef __CG4_H #define __CG4_H +#ifndef __STRINGS_H +#include +#endif + int cg4100(int argc, char* argv[]); int cg4200(int argc, char* argv[]); int cg4300(int argc, char* argv[]); @@ -8,5 +12,15 @@ int cg4400(int argc, char* argv[]); int cg4500(int argc, char* argv[]); int cg4600(int argc, char* argv[]); +#ifdef __MAIN__ +#define extern +#endif + +extern TString256 TMP; + +#ifdef __MAIN__ +#undef extern +#endif + #endif // __CG4_H diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index 80fdd9ea2..854fcb80d 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -5,8 +5,6 @@ #include "cg4400a.h" #include "cg4400b.h" -static TString256 TMP; - inline CG4400_application& app() { return (CG4400_application&)main_app(); } bool CG4400_application::filter_func (const TRelation * r) @@ -287,14 +285,14 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) int last_mese = 13; int mese; - app().__firm = app().TApplication::get_firm(); + app().__firm = app().get_firm(); for (int i = 0; i < app()._ditte->items(); i++) { long ditta = app()._ditte->row(i).get_long(1); if (prefhndl->exist(ditta)) { - app().TApplication::set_firm(ditta); + app().set_firm(ditta); if (cod.not_empty()) { ok = app().look_reg(i,anno,codlib,fino_a_mese,cod,&mese,ditta); @@ -305,7 +303,7 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k) } if (mese != 0 && mese < fino_a_mese - 1) //indipendentemente se si tratta di una ditta selezionata oppure no { - app().TApplication::set_firm(app().__firm); + app().set_firm(app().__firm); return error_box("Ditta %ld: Stampare i registri dei mesi precedenti", ditta); } } diff --git a/cg/cg5400.cpp b/cg/cg5400.cpp index aa5070b8c..44c3f46a2 100755 --- a/cg/cg5400.cpp +++ b/cg/cg5400.cpp @@ -74,6 +74,9 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist, reg.zero(); reg.put("CODTAB", s); + + + TDate inizio_anno(1, 1, year); if (reg.read(_isequal, _lock) == NOERR) { TDate dlast(reg.get_date("D3")); @@ -90,11 +93,15 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist, } TDate wd(esc.get_date("D0")); - + inizio_anno = wd; + + // Determina il corretto anno solare dell'esercizio: se il giorno di inizio esercizio + // e successivo alla data di ripristino allora mi trovo nell'anno solare successivo year = wd.year(); - if (wd.month() > month) + if (wd.month() > month || (wd.month() == month && wd.day() > day)) year++; - } + } + const int ld = TDate::last_day(month, year); if (day > ld) day = ld; TDate d(day, month, year); @@ -126,16 +133,21 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist, { p.addstatus(1); mov.read(_isequal, _lock); - mov.zero(fieldname); + mov.zero(fieldname); // Azzera flag STAMPATO o REGST ok = (mov.rewrite() == NOERR); if (!ok) error_box("Errore nell'aggiornamento del movimento %ld.\n Errore n. %d", mov.get_long(MOV_NUMREG), mov.status()); } + --d; - reg.put("D3", d); + if (d > inizio_anno) // Aggiorna data ultima stampa + reg.put("D3", d); + else + reg.zero("D3"); + if (giornale) - reg.put("I6", last_num); + reg.put("I6", last_num); // Aggiorna ultima pagina giornale ok = (reg.rewrite() == NOERR); if (!ok) error_box("Errore nell'aggiornamento del registro %s.\n Errore n. %d",