diff --git a/cg/cg1200.cpp b/cg/cg1200.cpp index 8c0dbc4f5..96d3a3361 100755 --- a/cg/cg1200.cpp +++ b/cg/cg1200.cpp @@ -26,7 +26,7 @@ enum pw { clienti = 1, fornitori = 2, both = 3 }; bool mask2_reset_fields(TMask_field& mf, KEY k); -class CG1200_App : public TPrintapp +class TPrintclifo_app : public TPrintapp { friend bool mask2_reset_fields(TMask_field& mf, KEY k); @@ -81,7 +81,7 @@ public: const char* descrizione_conto_ric(int,int,long); const char* descrizione_allegato(char,long); - CG1200_App() : TPrintapp(),_piva(18), _cpercip(10), _fax(50), _telex(50), + TPrintclifo_app() : TPrintapp(),_piva(18), _cpercip(10), _fax(50), _telex(50), _name(60), _telefono(90), _indir(70), _localita(90) { _rel = NULL; _pr_type = undefined; _startrow = 2; _startcol = 3; @@ -97,19 +97,19 @@ public: /* -------------------------------------------------------------------- */ -void CG1200_App::process_link(int id, const char* txt) +void TPrintclifo_app::process_link(int id, const char* txt) { TString ss = "1|"; ss << txt; - TMessage fs(cmd2name("cg0","-1"), MSG_LN, ss); + TMessage fs("cg0 -1", MSG_LN, ss); TMailbox m; m.send(fs); TExternal_app cg0("cg0 -1"); if (cg0.run()) beep(); } -const char* CG1200_App::look_tab(const char* tabname, TString& cod, - const char* fld) +const char* TPrintclifo_app::look_tab(const char* tabname, TString& cod, + const char* fld) { TTable tab(tabname); tab.curr().zero(); @@ -119,7 +119,7 @@ const char* CG1200_App::look_tab(const char* tabname, TString& cod, return tab.curr().get(fld); } -const char* CG1200_App::descrizione_conto_ric(int gruppo, int conto, long sottoc) +const char* TPrintclifo_app::descrizione_conto_ric(int gruppo, int conto, long sottoc) { TLocalisamfile pconti(LF_PCON, FALSE); @@ -136,7 +136,7 @@ const char* CG1200_App::descrizione_conto_ric(int gruppo, int conto, long sottoc return tmp; } -const char* CG1200_App::descrizione_allegato(char tipocf,long cod) +const char* TPrintclifo_app::descrizione_allegato(char tipocf,long cod) { TLocalisamfile clifo(LF_CLIFO, FALSE); @@ -153,7 +153,7 @@ const char* CG1200_App::descrizione_allegato(char tipocf,long cod) return tmp; } -bool CG1200_App::preprocess_page(int file, int counter) +bool TPrintclifo_app::preprocess_page(int file, int counter) { TString s; int g_ric,c_ric; @@ -288,7 +288,7 @@ default: return TRUE; } -print_action CG1200_App::postprocess_print(int file, int counter) +print_action TPrintclifo_app::postprocess_print(int file, int counter) { /* static bool more = FALSE; @@ -341,7 +341,7 @@ bool mask_ctrl_handler(TMask_field& mf, KEY k) // set printrows -void CG1200_App::set_page(int file, int counter) +void TPrintclifo_app::set_page(int file, int counter) { switch(_pr_type) { @@ -364,7 +364,7 @@ void CG1200_App::set_page(int file, int counter) } } -void CG1200_App::ultimo_codice(char tipocf) +void TPrintclifo_app::ultimo_codice(char tipocf) { TLocalisamfile clifo(LF_CLIFO,FALSE); @@ -384,7 +384,7 @@ void CG1200_App::ultimo_codice(char tipocf) } } -const char* CG1200_App::compatta_ragsoc(TString& ragsoc,char tipoa) +const char* TPrintclifo_app::compatta_ragsoc(TString& ragsoc,char tipoa) { if (tipoa == 'F') { @@ -402,7 +402,7 @@ const char* CG1200_App::compatta_ragsoc(TString& ragsoc,char tipoa) return tmp; } -void CG1200_App::preprocess_header() +void TPrintclifo_app::preprocess_header() { switch(_pr_type) { @@ -417,7 +417,7 @@ void CG1200_App::preprocess_header() } } -void CG1200_App::header_elenco() +void TPrintclifo_app::header_elenco() { reset_header(); // intestazione @@ -494,7 +494,7 @@ void CG1200_App::header_elenco() set_header(j, (const char *)(TString(132).fill('-'))); } -void CG1200_App::header_rubriche() +void TPrintclifo_app::header_rubriche() { reset_header(); // intestazione @@ -567,7 +567,7 @@ void CG1200_App::header_rubriche() set_header(j++, (const char *)(TString(132).fill('-'))); } -void CG1200_App::set_elenco() +void TPrintclifo_app::set_elenco() { // body set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), @@ -586,7 +586,7 @@ void CG1200_App::set_elenco() set_row(i+5,""); } -void CG1200_App::set_rubriche() +void TPrintclifo_app::set_rubriche() { // body set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO,CLI_TIPOCF), @@ -603,7 +603,7 @@ bool mask2_reset_fields(TMask_field& mf, KEY k) { if (k == K_SPACE) { - CG1200_App& a = (CG1200_App&)main_app(); + TPrintclifo_app& a = (TPrintclifo_app&)main_app(); TMask& m = mf.mask(); m.set(FLD_CGB_STARTROW, a._startrow); m.set(FLD_CGB_STARTCOL, a._startcol); @@ -613,7 +613,7 @@ bool mask2_reset_fields(TMask_field& mf, KEY k) return TRUE; } -void CG1200_App::set_etichette() +void TPrintclifo_app::set_etichette() { int r=_startrow; TString loccf=get_field(LF_CLIFO,CLI_LOCCF); @@ -638,7 +638,7 @@ void CG1200_App::set_etichette() set_row(i,""); } -void CG1200_App::set_vendite(int f, int c) +void TPrintclifo_app::set_vendite(int f, int c) { TString* rigs = new TString(132); @@ -767,7 +767,7 @@ void CG1200_App::set_vendite(int f, int c) delete rigs; } -bool CG1200_App::set_print(int) +bool TPrintclifo_app::set_print(int) { disable_links(); set_multiple_link(FALSE); @@ -808,7 +808,8 @@ bool CG1200_App::set_print(int) // set defaults - mask2.run(); + if (mask2.run() == K_ESC) + return FALSE; _startrow = atoi(mask2.get(FLD_CGB_STARTROW)); _startcol = atoi(mask2.get(FLD_CGB_STARTCOL)); @@ -891,7 +892,7 @@ bool CG1200_App::set_print(int) } -bool CG1200_App::preprocess_print(int file, int counter) +bool TPrintclifo_app::preprocess_print(int file, int counter) { reset_print(); if (_pr_type == undefined) @@ -904,7 +905,7 @@ bool CG1200_App::preprocess_print(int file, int counter) return TRUE; } -bool CG1200_App::user_create() +bool TPrintclifo_app::user_create() { // set relation and cursors _rel = new TRelation(LF_CLIFO); @@ -930,7 +931,7 @@ bool CG1200_App::user_create() return TRUE; } -bool CG1200_App::user_destroy() +bool TPrintclifo_app::user_destroy() { if (_rel) delete _rel; @@ -941,7 +942,7 @@ bool CG1200_App::user_destroy() int cg1200(int argc, char* argv[]) { - CG1200_App app; + TPrintclifo_app app; app.run(argc, argv, "Stampa Clienti/Fornitori"); return 0; } diff --git a/cg/cg5400.cpp b/cg/cg5400.cpp index d9d230b5d..79a211487 100755 --- a/cg/cg5400.cpp +++ b/cg/cg5400.cpp @@ -15,14 +15,19 @@ class TRipristina_stampa : public TApplication { + enum TOperation { restore_reg, restore_inl }; + TOperation _op; + +protected: // TApplication virtual bool create() ; - bool menu(MENU_TAG); - bool do_restore(long firm, const char * reg, int year, int month, - int day, bool giornale); + virtual bool menu(MENU_TAG); + +public: + bool reg_restore(const TString& reg, int year, int month, int day, bool giornale); + bool inl_restore(const TString& lbu, int year, int month); static bool firm_handler(TMask_field& f, KEY key); -public: - TRipristina_stampa() {} + TRipristina_stampa() : _op(restore_reg) {} }; bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key) @@ -31,46 +36,38 @@ bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key) { const long firm = atol(f.get()); - if (firm < 0) + if (firm <= 0) return f.error_box("Codice ditta errato"); else - if (firm == 0) - return f.error_box("La ditta e' obbligatoria"); + if (!prefhndl->exist(firm)) + return f.error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm); else - if (!prefhndl->exist(firm)) - return f.error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm); - else - { - main_app().set_firm(firm); - - TMask_field& r = f.mask().field(F_REG); - r.set_dirty(); - r.on_key(K_TAB); - } + { + main_app().set_firm(firm); + TMask_field& r = f.mask().field(F_REG); + r.set_dirty(); + r.on_key(K_TAB); + } } return TRUE; } -bool TRipristina_stampa::do_restore(long firm, const char * regist, - int year, int month, int day, - bool giornale) +bool TRipristina_stampa::reg_restore(const TString& regist, + int year, int month, int day, + bool giornale) { - CHECK(firm > 0, "Non posso ripristinare sui dati comuni"); - CHECKS(regist && *regist && strlen(regist) <= 3, "Registro errato ", regist); CHECKD(month > 0 && month < 13, "Mese errato ", month); - set_firm(firm); bool ok = TRUE; const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST; TRelation rel(LF_MOV); - TLocalisamfile & mov = rel.lfile(); + TLocalisamfile& mov = rel.lfile(); TTable reg("REG"); - TString16 s; s.format("%04d%s", year, regist); + TString16 s; s.format("%04d%s", year, (const char*)regist); reg.zero(); reg.put("CODTAB", s); - TDate inizio_anno(1, 1, year); if (reg.read(_isequal, _lock) == NOERR) { @@ -159,9 +156,56 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist, return ok; } + +bool TRipristina_stampa::inl_restore(const TString& lib, int year, int month) +{ + TLocalisamfile inl(LF_INDLIB); + + inl.zero(); + inl.put("ANNO", year); + inl.put("CODLIB", lib); + const TRectype filter(inl.curr()); + + bool ok = FALSE; + + // Azzera il flag di stampato sugli indici con mese >= month + for (inl.read(_isgteq); inl.good() && inl.curr() == filter; inl.next()) + if (inl.get_int("MESEREG") >= month && inl.get_bool("STAMPATO")) + { + inl.zero("STAMPATO"); + ok = inl.rewrite() == NOERR; + if (!ok) + { + error_box("Errore di ripristino dell'indice %ld", inl.get_long("NUMREG")); + break; + } + } + + if (ok) // Se e' stato ripristinato almeno un indice e non ci sono stati errori + { + TTable lbu("%LBU"); + lbu.put("CODTAB", format("%4d%s", year, (const char*)lib)); + ok = lbu.read() == NOERR; + if (ok) + { + TDate d(1, month, year); // Riporta la data di ultima stampa + lbu.put("D0", d); + ok = lbu.rewrite() == NOERR; + } + if (!ok) + error_box("Impossibile aggiornare il libro unico %s per l'anno %d", (const char*)lib, year); + } + + return ok; +} + bool TRipristina_stampa::create() { TApplication::create(); + + if (argc() > 2 && stricmp(argv(2), "INL") == 0) + _op = restore_inl; + dispatch_e_menu(BAR_ITEM(1)); return TRUE; } @@ -169,14 +213,18 @@ bool TRipristina_stampa::create() bool TRipristina_stampa::menu(MENU_TAG) { - TMask msk("cg5400a") ; + TMask msk(_op == restore_inl ? "cg5400b" : "cg5400a") ; msk.set_handler(F_FIRM, firm_handler); while (msk.run() == K_ENTER) { const long firm = msk.get_long(F_FIRM); const TString16 reg = msk.get(F_REG); - const bool giornale = msk.get_int(F_TIPO) == 5; + + bool giornale = FALSE; + if (_op == restore_reg) + giornale = msk.get_int(F_TIPO) == 5; + const int year = msk.get_int(giornale ? F_ESER : F_YEAR); const int month = msk.get_int(F_MESE); int day = giornale ? msk.get_int(F_DAY) : 1; @@ -184,18 +232,30 @@ bool TRipristina_stampa::menu(MENU_TAG) if (prefhndl->exist(firm)) { - TString256 mess("Attenzione sara' ripristinata la stampa del registro "); - mess << reg << "\ndell'" << (giornale ? "esercizio " : "anno ") << year + TString256 mess("Attenzione ripristino della stampa de"); + if (_op == restore_reg) + mess << (giornale ? "l giornale" : "l registro"); + else + mess << "gli indici del libro "; + mess << ' ' << reg << "\ndell'" << (giornale ? "esercizio " : "anno ") << year << " della ditta " << firm << " dal " << day << '-' << month << '-' << year; - if (yesno_box((const char *) mess)) + if (yesno_box(mess)) { mess << "\nSi desidera veramente continuare?"; - if (yesno_box((const char *) mess)) - do_restore(firm, reg, year, month, day, giornale); + if (yesno_box(mess)) + { + switch (_op) + { + case restore_inl: + inl_restore(reg, year, month); break; + default: + reg_restore(reg, year, month, day, giornale); break; + } + } } } - else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm); + else error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm); msk.reset(); } return FALSE; diff --git a/cg/cg5400a.uml b/cg/cg5400a.uml index 0d046d807..b9307f26b 100755 --- a/cg/cg5400a.uml +++ b/cg/cg5400a.uml @@ -30,9 +30,32 @@ BEGIN WARNING "Ditta assente" END +NUMBER F_YEAR 4 +BEGIN + PROMPT 4 3 "Anno " + FLAGS "AR" + CHECKTYPE REQUIRED + HELP "Anno IVA da cui ripristinare la stampa" + WARNING "L'anno deve essere specificato" +END + +STRING F_ESER 4 +BEGIN + PROMPT 4 3 "Esercizio " + USE ESC + INPUT CODTAB F_ESER + DISPLAY "Anno esercizio" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio" D1 + OUTPUT F_ESER CODTAB + CHECKTYPE REQUIRED + HELP "Esercizio da cui ripristinare la stampa" + WARNING "Esercizio assente" +END + STRING F_REG 3 BEGIN - PROMPT 4 3 "Registro " + PROMPT 4 5 "Registro " FLAGS "UZ" USE REG SELECT I0<6 INPUT CODTAB[1,4] F_YEAR @@ -52,7 +75,7 @@ END STRING F_DREG 50 BEGIN - PROMPT 22 3 "" + PROMPT 22 5 "" USE REG KEY 2 SELECT I0<6 INPUT S0 F_DREG DISPLAY "Descrizione @50" S0 @@ -74,30 +97,6 @@ BEGIN ITEM "5|Giornale" MESSAGE SHOW,F_ESER|HIDE,F_YEAR|SHOW,F_DAY END -NUMBER F_YEAR 4 -BEGIN - PROMPT 4 5 "Anno " - FLAGS "AR" - CHECKTYPE REQUIRED - HELP "Anno IVA da cui ripristinare la stampa" - WARNING "L' anno deve essere specificato" -END - -STRING F_ESER 4 -BEGIN - PROMPT 4 5 "Esercizio " - USE ESC - INPUT CODTAB F_ESER - DISPLAY "Anno esercizio" CODTAB - DISPLAY "Data inizio esercizio" D0 - DISPLAY "Data fine esercizio" D1 - OUTPUT F_ESER CODTAB - CHECKTYPE REQUIRED - HELP "Esercizio da cui ripristinare la stampa" - WARNING "Esercizio assente" -END - - NUMBER F_DAY 2 BEGIN PROMPT 4 6 "Giorno " diff --git a/cg/cg5400b.uml b/cg/cg5400b.uml new file mode 100755 index 000000000..c12fdde0a --- /dev/null +++ b/cg/cg5400b.uml @@ -0,0 +1,94 @@ +#include "cg5400.h" + +PAGE "Ripristino stampa indici libro unico" -1 -1 78 11 + +NUMBER F_FIRM 5 +BEGIN + PROMPT 4 1 "Ditta " + FLAGS "RF" + USE LF_NDITTE KEY 1 + CHECKTYPE NORMAL + INPUT CODDITTA F_FIRM + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_FIRM CODDITTA + OUTPUT F_DFIRM RAGSOC + HELP "Codice della ditta da cui prelevare i dati" + WARNING "Ditta assente" +END + +STRING F_DFIRM 50 +BEGIN + PROMPT 22 1 "" + USE LF_NDITTE KEY 2 + CHECKTYPE NORMAL + INPUT RAGSOC F_DFIRM + DISPLAY "Ragione sociale @50" RAGSOC + DISPLAY "Codice" CODDITTA + COPY OUTPUT F_FIRM + HELP "Ragione sociale della ditta da cui prelevare i dati" + WARNING "Ditta assente" +END + +NUMBER F_YEAR 4 +BEGIN + PROMPT 4 3 "Anno " + FLAGS "AR" + CHECKTYPE REQUIRED + HELP "Anno IVA" + WARNING "L'anno deve essere specificato" +END + +STRING F_REG 3 +BEGIN + PROMPT 4 5 "Libro unico " + FLAGS "UZ" + USE %LBU + INPUT CODTAB[1,4] F_YEAR + INPUT CODTAB[5,7] F_REG + DISPLAY "Anno" CODTAB[1,4] + DISPLAY "Codice" CODTAB[5,7] + DISPLAY "Descrizione @50" S0 + OUTPUT F_YEAR CODTAB[1,4] + OUTPUT F_REG CODTAB[5,7] + OUTPUT F_DREG S0 + CHECKTYPE REQUIRED + HELP "Codice del libro unico di cui ripristinare la stampa" + WARNING "Libro unico assente" +END + +STRING F_DREG 50 +BEGIN + PROMPT 22 5 "" + USE %LBU KEY 2 + INPUT S0 F_DREG + DISPLAY "Descrizione @50" S0 + DISPLAY "Anno" CODTAB[1,4] + DISPLAY "Codice" CODTAB[5,7] + COPY OUTPUT F_REG + CHECKTYPE NORMAL + HELP "Denominazione del libro di cui ripristinare la stampa" + WARNING "Libro unico assente" +END + +LIST F_MESE 10 +BEGIN + PROMPT 4 7 "Mese " + FLAGS "M" + HELP "Mese da cui ripristinare la stampa degli indici" +END + +BUTTON DLG_OK 9 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_QUIT 9 2 +BEGIN + PROMPT -22 -1 "" + MESSAGE EXIT,K_QUIT +END + +ENDPAGE + +ENDMASK