Corretti errori ripristino stampa registri

git-svn-id: svn://10.65.10.50/trunk@985 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-02-09 14:42:56 +00:00
parent 500260ae16
commit 6215837eea
3 changed files with 102 additions and 106 deletions

View File

@ -5,11 +5,9 @@
#include "cg4400a.h" #include "cg4400a.h"
#include "cg4400b.h" #include "cg4400b.h"
static TString256 TMP; inline TReg_print& app() { return (TReg_print&)main_app(); }
inline CG4400_application& app() { return (CG4400_application&)main_app(); } bool TReg_print::filter_func (const TRelation * r)
bool CG4400_application::filter_func (const TRelation * r)
{ {
TLocalisamfile& mov = r->lfile(LF_MOV); TLocalisamfile& mov = r->lfile(LF_MOV);
TString16 codreg = mov.get(MOV_REG); TString16 codreg = mov.get(MOV_REG);
@ -53,19 +51,19 @@ HIDDEN int compare_fields(const TObject** o1, const TObject** o2)
return strcmp(campo1, campo2); return strcmp(campo1, campo2);
} }
bool CG4400_application::stampa_totali_finali() bool TReg_print::stampa_totali_finali()
{ {
TConfig conf(CONFIG_DITTA); TConfig conf(CONFIG_DITTA);
return conf.get_bool("StTfFr"); return conf.get_bool("StTfFr");
} }
bool CG4400_application::stampa_datareg() bool TReg_print::stampa_datareg()
{ {
TConfig conf(CONFIG_STUDIO); TConfig conf(CONFIG_STUDIO);
return conf.get_bool("NoDtRg"); return conf.get_bool("NoDtRg");
} }
bool CG4400_application::mask_select (TMask_field& f, KEY k) bool TReg_print::mask_select (TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{ {
@ -81,7 +79,7 @@ bool CG4400_application::mask_select (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool CG4400_application::mask_azzera (TMask_field& f, KEY k) bool TReg_print::mask_azzera (TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{ {
@ -95,7 +93,7 @@ bool CG4400_application::mask_azzera (TMask_field& f, KEY k)
} }
/* /*
bool CG4400_application::mask_firm_to (TMask_field& f, KEY k) bool TReg_print::mask_firm_to (TMask_field& f, KEY k)
{ {
if (k == K_TAB && f.focusdirty()) if (k == K_TAB && f.focusdirty())
{ {
@ -123,7 +121,7 @@ bool CG4400_application::mask_azzera (TMask_field& f, KEY k)
} }
*/ */
bool CG4400_application::mask_tipo_stampa(TMask_field& f, KEY k) bool TReg_print::mask_tipo_stampa(TMask_field& f, KEY k)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
@ -138,7 +136,7 @@ bool CG4400_application::mask_tipo_stampa(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool CG4400_application::mask_mese (TMask_field& f, KEY k) bool TReg_print::mask_mese (TMask_field& f, KEY k)
{ {
const short id = f.dlg(); const short id = f.dlg();
int mese; int mese;
@ -182,7 +180,7 @@ bool CG4400_application::mask_mese (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool CG4400_application::look_reg(int i, int anno, TString& codlib, int m, const char* cod, int* umese, long ditta) bool TReg_print::look_reg(int i, int anno, TString& codlib, int m, const char* cod, int* umese, long ditta)
{ {
TString16 y; TString16 y;
@ -224,7 +222,7 @@ bool CG4400_application::look_reg(int i, int anno, TString& codlib, int m, const
return FALSE; return FALSE;
} }
bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese, long ditta) bool TReg_print::look_regs(int anno, TString& codlib, int m, int* umese, long ditta)
{ {
int a, tipo; int a, tipo;
TString16 codtab; TString16 codtab;
@ -264,7 +262,7 @@ bool CG4400_application::look_regs(int anno, TString& codlib, int m, int* umese,
return TRUE; return TRUE;
} }
bool CG4400_application::mask_libun (TMask_field& f, KEY k) bool TReg_print::mask_libun (TMask_field& f, KEY k)
{ {
if ( k == K_ENTER ) if ( k == K_ENTER )
{ {
@ -325,7 +323,7 @@ bool CG4400_application::mask_libun (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool CG4400_application::mask_cod (TMask_field& f, KEY k) bool TReg_print::mask_cod (TMask_field& f, KEY k)
{ {
TTable TabLbu ("%LBU"); TTable TabLbu ("%LBU");
TString codtab; TString codtab;
@ -358,7 +356,7 @@ bool CG4400_application::mask_cod (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool CG4400_application::mask_data (TMask_field& f, KEY k) bool TReg_print::mask_data (TMask_field& f, KEY k)
{ {
if (k == K_TAB && f.mask().is_running()) if (k == K_TAB && f.mask().is_running())
{ {
@ -381,7 +379,7 @@ bool CG4400_application::mask_data (TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
const char * CG4400_application::descr_doc() const char * TReg_print::descr_doc()
{ {
TTable tab_tpd("%TPD"); TTable tab_tpd("%TPD");
TString codtab(format("%-2s",(const char*) _tipodoc)); TString codtab(format("%-2s",(const char*) _tipodoc));
@ -396,7 +394,7 @@ const char * CG4400_application::descr_doc()
return TMP; return TMP;
} }
const char * CG4400_application::descr_iva(const char * cod) const char * TReg_print::descr_iva(const char * cod)
{ {
TTable tab_iva("%IVA"); TTable tab_iva("%IVA");
TString codtab(format ("%-4s", cod)); TString codtab(format ("%-4s", cod));
@ -411,7 +409,7 @@ const char * CG4400_application::descr_iva(const char * cod)
return TMP; return TMP;
} }
const char * CG4400_application::tipo_attivita() const char * TReg_print::tipo_attivita()
{ {
TLocalisamfile attiv (LF_ATTIV); TLocalisamfile attiv (LF_ATTIV);
@ -424,7 +422,7 @@ const char * CG4400_application::tipo_attivita()
return TMP; return TMP;
} }
const char * CG4400_application::desc_attivita() const char * TReg_print::desc_attivita()
{ {
TTable attiv ("%AIS"); TTable attiv ("%AIS");
@ -437,7 +435,7 @@ const char * CG4400_application::desc_attivita()
return TMP; return TMP;
} }
TRectype& CG4400_application::ricerca_cf(char tipocf, long codcf) TRectype& TReg_print::ricerca_cf(char tipocf, long codcf)
{ {
_clifo->zero(); _clifo->zero();
_clifo->put(CLI_TIPOCF, tipocf); _clifo->put(CLI_TIPOCF, tipocf);
@ -449,7 +447,7 @@ TRectype& CG4400_application::ricerca_cf(char tipocf, long codcf)
return _clifo->curr(); return _clifo->curr();
} }
TRectype& CG4400_application::ricerca_occ(const char * occ) TRectype& TReg_print::ricerca_occ(const char * occ)
{ {
TLocalisamfile occas (LF_OCCAS); TLocalisamfile occas (LF_OCCAS);
occas.zero(); occas.zero();
@ -461,7 +459,7 @@ TRectype& CG4400_application::ricerca_occ(const char * occ)
return occas.curr(); return occas.curr();
} }
bool CG4400_application::year_handler(TMask_field& f, KEY key) bool TReg_print::year_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.focusdirty()) if (key == K_TAB && f.focusdirty())
{ {
@ -474,7 +472,7 @@ bool CG4400_application::year_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
void CG4400_application::build_ditte_sheet() void TReg_print::build_ditte_sheet()
{ {
// build sheet // build sheet
_ditte->destroy(); _ditte->destroy();
@ -495,7 +493,7 @@ void CG4400_application::build_ditte_sheet()
// --------------------------- handlers per selezione ditte // --------------------------- handlers per selezione ditte
bool CG4400_application::to_ditt_handler(TMask_field& f, KEY key) bool TReg_print::to_ditt_handler(TMask_field& f, KEY key)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
if (key == K_F9) if (key == K_F9)
@ -511,7 +509,7 @@ bool CG4400_application::to_ditt_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
bool CG4400_application::fr_ditt_handler(TMask_field& f, KEY key) bool TReg_print::fr_ditt_handler(TMask_field& f, KEY key)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
if (key == K_F9) if (key == K_F9)
@ -527,7 +525,7 @@ bool CG4400_application::fr_ditt_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
bool CG4400_application::to_butt_handler(TMask_field& f, KEY key) bool TReg_print::to_butt_handler(TMask_field& f, KEY key)
{ {
if (key == K_SPACE) if (key == K_SPACE)
{ {
@ -544,7 +542,7 @@ bool CG4400_application::to_butt_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
bool CG4400_application::fr_butt_handler(TMask_field& f, KEY key) bool TReg_print::fr_butt_handler(TMask_field& f, KEY key)
{ {
if (key == K_SPACE) if (key == K_SPACE)
{ {
@ -561,24 +559,30 @@ bool CG4400_application::fr_butt_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
void CG4400_application::set_choice_limits(TMask& m) void TReg_print::set_choice_limits(TMask& m)
{ {
long first = -1l, last = -1l; long first = -1l, last = -1l;
for (int i = 0; i < _ditte->items(); i++) for (int i = 0; i < _ditte->items(); i++)
{ {
if (_selected[i]) if (_selected[i])
{ {
long dit = _ditte->row(i).get_long(1); const long dit = _ditte->row(i).get_long(1);
if (first == -1l) first = dit; if (first == -1l) first = dit;
if (last < dit) last = dit; if (last < dit) last = dit;
} }
} }
if (first != -1) m.field(DA_CODICE).set(format("%ld",first)); if (first != -1)
if (last != -1) m.field(A_CODICE).set(format("%ld",last)); {
m.set(DA_CODICE, first);
app().set_firm(first);
}
if (last != -1)
m.set(A_CODICE, last);
m.set(F_SELECT, _selected.ones()); m.set(F_SELECT, _selected.ones());
} }
long CG4400_application::select_firm_range(long from, long to) long TReg_print::select_firm_range(long from, long to)
{ {
if (to == 0l) to = 99999L; if (to == 0l) to = 99999L;
for (int i = 0; i < _ditte->items(); i++) for (int i = 0; i < _ditte->items(); i++)
@ -606,7 +610,7 @@ long CG4400_application::select_firm_range(long from, long to)
return _selected.ones(); return _selected.ones();
} }
void CG4400_application::build_nomiditte(TProgind* pnd) void TReg_print::build_nomiditte(TProgind* pnd)
{ {
_nomiditte.destroy(); _nomiditte.destroy();
// ricostruire _nomiditte e rifare build_ditte_sheet // ricostruire _nomiditte e rifare build_ditte_sheet
@ -635,7 +639,7 @@ void CG4400_application::build_nomiditte(TProgind* pnd)
TApplication::set_firm(__firm); TApplication::set_firm(__firm);
} }
bool CG4400_application::user_create() bool TReg_print::user_create()
{ {
TProgind* pnd = NULL; TProgind* pnd = NULL;
@ -695,7 +699,7 @@ bool CG4400_application::user_create()
return TRUE; return TRUE;
} }
bool CG4400_application::user_destroy() bool TReg_print::user_destroy()
{ {
delete _ditte; delete _ditte;
delete _nditte; delete _nditte;
@ -723,7 +727,7 @@ bool CG4400_application::user_destroy()
return TRUE; return TRUE;
} }
void CG4400_application::calcola_progressivi() void TReg_print::calcola_progressivi()
{ {
TTable pim ("PIM"); TTable pim ("PIM");
TString80 chiave; TString80 chiave;
@ -834,7 +838,7 @@ void CG4400_application::calcola_progressivi()
} }
} }
int CG4400_application::riga_rmoviva() int TReg_print::riga_rmoviva()
{ {
TString codiva; TString codiva;
real impo, impos; real impo, impos;
@ -884,8 +888,8 @@ int CG4400_application::riga_rmoviva()
return nrec; return nrec;
} }
int CG4400_application::setta_riga(int r, const TRigaiva& riga, real& tot1, int TReg_print::setta_riga(int r, const TRigaiva& riga, real& tot1,
real& tot2, real& tot3, real& tot4) real& tot2, real& tot3, real& tot4)
{ {
set_row(r, "%4s", (const char*)riga._codiva); set_row(r, "%4s", (const char*)riga._codiva);
TString descr = descr_iva(riga._codiva); TString descr = descr_iva(riga._codiva);
@ -906,7 +910,7 @@ int CG4400_application::setta_riga(int r, const TRigaiva& riga, real& tot1,
return r; return r;
} }
bool CG4400_application::controlla_liquidazione() bool TReg_print::controlla_liquidazione()
{ {
TTable lim ("LIM"); TTable lim ("LIM");
TTable pim ("PIM"); TTable pim ("PIM");
@ -977,7 +981,7 @@ bool CG4400_application::controlla_liquidazione()
//controlla che i movimenti con anno data di registrazione < dell'anno indicato a video siano stati gia' stampati in forma definitiva*/ //controlla che i movimenti con anno data di registrazione < dell'anno indicato a video siano stati gia' stampati in forma definitiva*/
//questo controllo viene fatto solo per stampa di bollato (non su libro unico) //questo controllo viene fatto solo per stampa di bollato (non su libro unico)
bool CG4400_application::controlla_mov() bool TReg_print::controlla_mov()
{ {
TLocalisamfile mov (LF_MOV); TLocalisamfile mov (LF_MOV);
bool ok = TRUE; bool ok = TRUE;
@ -1007,7 +1011,7 @@ bool CG4400_application::controlla_mov()
return ok; return ok;
} }
bool CG4400_application::cerca_libro_gio(TString& datas) bool TReg_print::cerca_libro_gio(TString& datas)
{ {
TString app(4); TString app(4);
app = format("%04d", _annoes); app = format("%04d", _annoes);
@ -1036,7 +1040,7 @@ bool CG4400_application::cerca_libro_gio(TString& datas)
return TRUE; return TRUE;
} }
void CG4400_application::cerca_reg(const TString& c, byte* t) void TReg_print::cerca_reg(const TString& c, byte* t)
{ {
TString16 cod = ""; TString16 cod = "";
@ -1047,7 +1051,7 @@ void CG4400_application::cerca_reg(const TString& c, byte* t)
*t = _tabreg->get_int ("I0"); *t = _tabreg->get_int ("I0");
} }
bool CG4400_application::ventilazione(const char* iva) bool TReg_print::ventilazione(const char* iva)
{ {
TTable tabiva ("%IVA"); TTable tabiva ("%IVA");
TString16 chiave = ""; TString16 chiave = "";
@ -1062,7 +1066,7 @@ bool CG4400_application::ventilazione(const char* iva)
return FALSE; return FALSE;
} }
int CG4400_application::stampa_prospetto() int TReg_print::stampa_prospetto()
{ {
TString riga(_stampa_width); TString riga(_stampa_width);
int r=1, rr=0; int r=1, rr=0;
@ -1158,7 +1162,7 @@ int CG4400_application::stampa_prospetto()
} }
//la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti //la stampa "tipi di indetraibilita'" viene fatta solo per gli acquisti
int CG4400_application::stampa_acquisti(int row) int TReg_print::stampa_acquisti(int row)
{ {
real tot_imponib, tot_imposta, tot_imponibp, tot_impostap; real tot_imponib, tot_imposta, tot_imponibp, tot_impostap;
row+=2; row+=2;
@ -1246,7 +1250,7 @@ int CG4400_application::stampa_acquisti(int row)
} }
/* /*
void CG4400_application::set_page_tot_reg() void TReg_print::set_page_tot_reg()
{ {
TString16 codivaprec = ""; TString16 codivaprec = "";
int row=0, rr=0; int row=0, rr=0;
@ -1332,7 +1336,7 @@ int CG4400_application::stampa_acquisti(int row)
} }
*/ */
void CG4400_application::set_page_tot_reg() void TReg_print::set_page_tot_reg()
{ {
int rr=0; int rr=0;
@ -1395,7 +1399,7 @@ void CG4400_application::set_page_tot_reg()
stampa_plafonds(rr); stampa_plafonds(rr);
} }
void CG4400_application::stampa_plafonds(int r) void TReg_print::stampa_plafonds(int r)
{ {
TTable pla ("PLA"); TTable pla ("PLA");
TTable ppa ("PPA"); TTable ppa ("PPA");
@ -1536,7 +1540,7 @@ void CG4400_application::stampa_plafonds(int r)
} }
} }
real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese, TTable& ppa, const char* tipo) real TReg_print::stampa_valori_plafonds(const real& r1, const int mese, TTable& ppa, const char* tipo)
{ {
real r, si8, se8; real r, si8, se8;
TString80 chiave; TString80 chiave;
@ -1570,7 +1574,7 @@ real CG4400_application::stampa_valori_plafonds(const real& r1, const int mese,
return r; return r;
} }
bool CG4400_application::compila_reg(const TMask& m) bool TReg_print::compila_reg(const TMask& m)
{ {
int anno; int anno;
TString16 codtab = ""; TString16 codtab = "";
@ -1677,7 +1681,7 @@ bool CG4400_application::compila_reg(const TMask& m)
return TRUE; return TRUE;
} }
bool CG4400_application::compila_lib() bool TReg_print::compila_lib()
{ {
TTable tab_lib ("%LBU"); TTable tab_lib ("%LBU");
TString16 cod; TString16 cod;
@ -1694,7 +1698,7 @@ bool CG4400_application::compila_lib()
return FALSE; return FALSE;
} }
bool CG4400_application::preprocess_print(int file, int counter) bool TReg_print::preprocess_print(int file, int counter)
{ {
if (file == LF_MOV) if (file == LF_MOV)
{ {
@ -1716,7 +1720,7 @@ bool CG4400_application::preprocess_print(int file, int counter)
return TRUE; return TRUE;
} }
bool CG4400_application::preprocess_page(int file, int counter) bool TReg_print::preprocess_page(int file, int counter)
{ {
if (file == LF_MOV) if (file == LF_MOV)
{ {
@ -2004,7 +2008,7 @@ bool CG4400_application::preprocess_page(int file, int counter)
return TRUE; return TRUE;
} }
void CG4400_application::aggiorna_reg() void TReg_print::aggiorna_reg()
{ {
TString16 codtab; TString16 codtab;
TTable Tabreg ("REG"); TTable Tabreg ("REG");
@ -2108,7 +2112,7 @@ void CG4400_application::aggiorna_reg()
} }
} }
void CG4400_application::aggiorna_lib() void TReg_print::aggiorna_lib()
{ {
TString16 cod = ""; TString16 cod = "";
TTable lbu ("%LBU"); TTable lbu ("%LBU");
@ -2124,7 +2128,7 @@ void CG4400_application::aggiorna_lib()
} }
} }
bool CG4400_application::stampo_liquidazione(int mese) bool TReg_print::stampo_liquidazione(int mese)
{ {
if (_tipo_stampa == 1) if (_tipo_stampa == 1)
{ {
@ -2144,7 +2148,7 @@ bool CG4400_application::stampo_liquidazione(int mese)
return FALSE; return FALSE;
} }
void CG4400_application::stampa_vidi() void TReg_print::stampa_vidi()
{ {
TTable TabInl ("%INL"); TTable TabInl ("%INL");
TTable TabVid ("VID"); TTable TabVid ("VID");
@ -2204,7 +2208,7 @@ void CG4400_application::stampa_vidi()
printer().close(); printer().close();
} }
print_action CG4400_application::postprocess_page (int file, int counter) print_action TReg_print::postprocess_page (int file, int counter)
{ {
if (file == LF_MOV) if (file == LF_MOV)
{ {
@ -2268,7 +2272,7 @@ print_action CG4400_application::postprocess_page (int file, int counter)
return NEXT_PAGE; return NEXT_PAGE;
} }
bool CG4400_application::set_print(int n) bool TReg_print::set_print(int n)
{ {
TMask m ("cg4400a"); TMask m ("cg4400a");
int giorni_del_mese; int giorni_del_mese;
@ -2370,7 +2374,7 @@ bool CG4400_application::set_print(int n)
return FALSE; return FALSE;
} }
bool CG4400_application::look_lia() bool TReg_print::look_lia()
{ {
TString16 y; y << _annoes; TString16 y; y << _annoes;
@ -2384,13 +2388,13 @@ bool CG4400_application::look_lia()
return ok; return ok;
} }
void CG4400_application::clear_stliq() void TReg_print::clear_stliq()
{ {
for (int i=0; i < 12; i++) for (int i=0; i < 12; i++)
_st_liq[i] = FALSE; _st_liq[i] = FALSE;
} }
bool CG4400_application::stampa_registri_IVA(const TMask& m) bool TReg_print::stampa_registri_IVA(const TMask& m)
{ {
bool ok = FALSE; bool ok = FALSE;
for (int i = 0; i < _ditte->items(); i++) for (int i = 0; i < _ditte->items(); i++)
@ -2679,7 +2683,7 @@ bool CG4400_application::stampa_registri_IVA(const TMask& m)
} }
void CG4400_application::stampa_liq_mesi_succ() void TReg_print::stampa_liq_mesi_succ()
{ {
int da = _datareg.month() + 1; int da = _datareg.month() + 1;
int a = _data_a.month(); int a = _data_a.month();
@ -2708,7 +2712,7 @@ void CG4400_application::stampa_liq_mesi_succ()
if (printer().isopen()) printer().close(); if (printer().isopen()) printer().close();
} }
void CG4400_application::send_message(char tipo, const TFilename& nome, int mese) void TReg_print::send_message(char tipo, const TFilename& nome, int mese)
{ {
//const char* const app = "cg4a -2 -icon"; //const char* const app = "cg4a -2 -icon";
const char* const app = "cg4a -2"; const char* const app = "cg4a -2";
@ -2729,7 +2733,7 @@ void CG4400_application::send_message(char tipo, const TFilename& nome, int mese
pn.run(); pn.run();
} }
bool CG4400_application::set_ditte(TMask& m) bool TReg_print::set_ditte(TMask& m)
{ {
/* /*
_selected.reset(); _selected.reset();
@ -2748,7 +2752,7 @@ bool CG4400_application::set_ditte(TMask& m)
return tasto == K_ENTER; return tasto == K_ENTER;
} }
TRectype& CG4400_application::look_comuni (const char * cod) TRectype& TReg_print::look_comuni (const char * cod)
{ {
_com->zero(); _com->zero();
_com->put(COM_COM, cod); _com->put(COM_COM, cod);
@ -2759,7 +2763,7 @@ TRectype& CG4400_application::look_comuni (const char * cod)
return _com->curr(); return _com->curr();
} }
void CG4400_application::get_dati_ditta() void TReg_print::get_dati_ditta()
{ {
TLocalisamfile nditte(LF_NDITTE); TLocalisamfile nditte(LF_NDITTE);
TLocalisamfile anag(LF_ANAG); TLocalisamfile anag(LF_ANAG);
@ -2828,7 +2832,7 @@ void CG4400_application::get_dati_ditta()
} }
} }
int CG4400_application::stampa_intestazione() int TReg_print::stampa_intestazione()
{ {
int r = 1; int r = 1;
TString codice_ditta; TString codice_ditta;
@ -2854,7 +2858,7 @@ int CG4400_application::stampa_intestazione()
return r; return r;
} }
void CG4400_application::preprocess_header() void TReg_print::preprocess_header()
{ {
int r=1; int r=1;
char cor, nd1, nd2; char cor, nd1, nd2;
@ -3018,7 +3022,7 @@ if (_stampa_ind_comp && !_intesta_vidi)
int cg4400 (int argc, char * argv[]) int cg4400 (int argc, char * argv[])
{ {
CG4400_application a; TReg_print a;
a.run(argc, argv, "Stampa registri IVA"); a.run(argc, argv, "Stampa registri IVA");
return 0; return 0;
} }

View File

@ -28,7 +28,7 @@
const int TABREG = (int)TTable::name2log("REG"); const int TABREG = (int)TTable::name2log("REG");
class CG4400_application : public TPrintapp class TReg_print : public TPrintapp
{ {
TCursor * _cur; TCursor * _cur;
TRelation *_rel, *_nditte; TRelation *_rel, *_nditte;
@ -132,8 +132,8 @@ protected:
public: public:
CG4400_application() : TPrintapp(), _ditte(NULL), _selected(10000), _nomiditte(100) {} TReg_print() : TPrintapp(), _ditte(NULL), _selected(10000), _nomiditte(100) {}
virtual ~CG4400_application() {} virtual ~TReg_print() {}
}; };

View File

@ -15,18 +15,14 @@
class TRipristina_stampa : public TApplication class TRipristina_stampa : public TApplication
{ {
TMask* _msk;
long _default_firm;
virtual bool create() ; virtual bool create() ;
virtual bool destroy() ;
bool menu(MENU_TAG); bool menu(MENU_TAG);
bool do_restore(long firm, const char * reg, int year, int month, bool do_restore(long firm, const char * reg, int year, int month,
int day, bool giornale); int day, bool giornale);
static bool firm_handler(TMask_field& f, KEY key); static bool firm_handler(TMask_field& f, KEY key);
public: public:
TRipristina_stampa() : _msk(NULL) {} TRipristina_stampa() {}
}; };
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key) bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
@ -45,8 +41,7 @@ bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
return f.error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm); return f.error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm);
else else
{ {
if (main_app().get_firm() != firm) main_app().set_firm(firm);
main_app().set_firm(firm);
TMask_field& r = f.mask().field(F_REG); TMask_field& r = f.mask().field(F_REG);
r.set_dirty(); r.set_dirty();
@ -60,12 +55,12 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist,
int year, int month, int day, int year, int month, int day,
bool giornale) bool giornale)
{ {
bool ok = TRUE;
CHECK(firm > 0, "Non posso ripristinare sui dati comuni"); CHECK(firm > 0, "Non posso ripristinare sui dati comuni");
CHECKS(regist && *regist && strlen(regist) <= 3, "Registro errato ", regist); CHECKS(regist && *regist && strlen(regist) <= 3, "Registro errato ", regist);
CHECKD(month > 0 && month < 13, "Mese errato ", month); CHECKD(month > 0 && month < 13, "Mese errato ", month);
set_firm(firm); set_firm(firm);
bool ok = TRUE;
const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST; const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST;
TRelation rel(LF_MOV); TRelation rel(LF_MOV);
TLocalisamfile & mov = rel.lfile(); TLocalisamfile & mov = rel.lfile();
@ -87,10 +82,7 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist,
esc.zero(); esc.zero();
esc.put("CODTAB", format("%04d", year)); esc.put("CODTAB", format("%04d", year));
if (esc.read() != NOERR) if (esc.read() != NOERR)
{
set_firm(_default_firm);
return error_box("Esercizio %s assente", year); return error_box("Esercizio %s assente", year);
}
TDate wd(esc.get_date("D0")); TDate wd(esc.get_date("D0"));
inizio_anno = wd; inizio_anno = wd;
@ -141,10 +133,16 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist,
} }
--d; --d;
if (d > inizio_anno) // Aggiorna data ultima stampa if (d > inizio_anno) // Aggiorna data ultima stampa
reg.put("D3", d); {
reg.put("D3", d); // Data ultima stampa
reg.put("I4", d.month()-1); // Ultimo mese di stampa liquidazione
}
else else
{
reg.zero("D3"); reg.zero("D3");
reg.zero("I4");
}
ok = (reg.rewrite() == NOERR); ok = (reg.rewrite() == NOERR);
if (!ok) if (!ok)
@ -154,36 +152,30 @@ bool TRipristina_stampa::do_restore(long firm, const char * regist,
else else
ok = error_box("Impossibile leggere il registro %s anno %s", (const char *) regist, (const char *) year); ok = error_box("Impossibile leggere il registro %s anno %s", (const char *) regist, (const char *) year);
set_firm(_default_firm);
return ok; return ok;
} }
bool TRipristina_stampa::create() bool TRipristina_stampa::create()
{ {
TApplication::create(); TApplication::create();
_msk = new TMask("cg5400a") ;
_msk->set_handler(F_FIRM, firm_handler);
_default_firm = get_firm();
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool TRipristina_stampa::destroy()
{
if (_msk != NULL) delete _msk;
return TApplication::destroy();
}
bool TRipristina_stampa::menu(MENU_TAG) bool TRipristina_stampa::menu(MENU_TAG)
{ {
while (_msk->run() == K_ENTER) TMask msk("cg5400a") ;
msk.set_handler(F_FIRM, firm_handler);
while (msk.run() == K_ENTER)
{ {
const long firm = _msk->get_long(F_FIRM); const long firm = msk.get_long(F_FIRM);
const TString16 reg = _msk->get(F_REG); const TString16 reg = msk.get(F_REG);
const bool giornale = _msk->get_int(F_TIPO) == 5; const bool giornale = msk.get_int(F_TIPO) == 5;
const int year = _msk->get_int(giornale ? F_ESER : F_YEAR); const int year = msk.get_int(giornale ? F_ESER : F_YEAR);
const int month = _msk->get_int(F_MESE); const int month = msk.get_int(F_MESE);
int day = giornale ? _msk->get_int(F_DAY) : 1; int day = giornale ? msk.get_int(F_DAY) : 1;
if (day < 1) day = 1; if (day < 1) day = 1;
if (prefhndl->exist(firm)) if (prefhndl->exist(firm))
@ -194,13 +186,13 @@ bool TRipristina_stampa::menu(MENU_TAG)
if (yesno_box((const char *) mess)) if (yesno_box((const char *) mess))
{ {
mess << "\nSi desidera veramente continuare"; mess << "\nSi desidera veramente continuare?";
if (yesno_box((const char *) mess)) if (yesno_box((const char *) mess))
do_restore(firm, reg, year, month, day, giornale); do_restore(firm, reg, year, month, day, giornale);
} }
} }
else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm); else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
_msk->reset(); msk.reset();
} }
return FALSE; return FALSE;
} }