diff --git a/ba/ba3.h b/ba/ba3.h index 835fb400e..96d885814 100755 --- a/ba/ba3.h +++ b/ba/ba3.h @@ -1,17 +1,6 @@ #ifndef __BA3_H #define __BA3_H -#ifdef MAIN -#define extern -#endif - -#ifdef MAIN -#undef extern -#endif - -const MAXSTR = 128; -static char __tmp [MAXSTR]; - int ba3100(int argc, char* argv[]); int ba3200(int argc, char* argv[]); int ba3300(int argc, char* argv[]); @@ -19,5 +8,6 @@ int ba3400(int argc, char* argv[]); int ba3500(int argc, char* argv[]); int ba3600(int argc, char* argv[]); int ba3700(int argc, char* argv[]); +int ba3800(int argc, char* argv[]); #endif // __BA3_H diff --git a/ba/ba3600.cpp b/ba/ba3600.cpp index ae2aec6e2..b74511c64 100755 --- a/ba/ba3600.cpp +++ b/ba/ba3600.cpp @@ -1,492 +1,487 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "ba3.h" -#include "ba3600.h" - -#define ALIAS 50 - -extern char __tmp [MAXSTR]; -static TFixed_string tmp(__tmp, MAXSTR); - -const int TABLBU = (int)TTable::name2log("%LBU"); -const int TABINL = (int)TTable::name2log("%INL"); - -class BA3600_application : public TPrintapp -{ - struct ind_lib - { - char mese[3]; - char anno[5]; - char nini_plib[6]; - long num_riga; - long nfin_plib; - long codditta; - char cod_reg[4]; - long nini_put; - long nfin_put; - char cod_vid[4]; - bool stamp_bol; - bool pag_ann; - }; - - TMask* _msk; - TTable* _tab_inl; - TTable* _tab_lbu; - TTable* _tab_reg; - TLocalisamfile* _nditte; - TSort* _sort; - TProgind* _prog; - ind_lib* _lib; - const char* _buff; - - TDate _datastampa; - int _tipo_stampa, _meseda, _mesea; - long _anno, _numini_paglib, _numfin_paglib, _numini_pagut, _numfin_pagut; - long _codditta, _pag_fin, _num_riga, _nfin_plib_prec; - TString _cod_lib, _rag_soc, _cod_reg, _descrizione, _cod_vidimaz; - TString _cod_lib_stampa, _stamp_bollato_str; - bool _stamp_bollato, _pag_ann, _pag_fuori_sequenza; - -public: - - bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; } - void user_create() ; - void user_destroy(); - bool set_print(int); - - virtual bool preprocess_page (int,int); - virtual print_action postprocess_page (int,int); - - virtual void preprocess_header(); - virtual void set_page(int,int); - - void init_sort(); - void crea_sort(); - bool preprocess_prova(int); - bool preprocess_bollato(); - void crea_intestazione(); - const char* ragsoc_ditta(long); - const char* descrizione_codreg(TString&); - void setta_righe_prova(); - void setta_righe_bollato(); - - BA3600_application() {} -}; - -void BA3600_application::init_sort() -{ - _lib = new ind_lib; - _sort = new TSort (sizeof(ind_lib)); - - _sort -> addsortkey((char*)&(_lib->mese) - (char*)&(_lib->mese),2); - _sort -> addsortkey((char*)&(_lib->anno) - (char*)&(_lib->anno),4); - _sort -> addsortkey((char*)&(_lib->nini_plib) - (char*)&(_lib->nini_plib),5); - _sort->init(); -} - -//Crea sort ordina i record della tabella %INL per mese registrazione, anno -//registrazione e numero iniziale pagine registro libro unico - -void BA3600_application::crea_sort() -{ - long anno,numini_paglib,numfin_paglib,codditta,numini_pagut,numfin_pagut; - TString cod_reg,cod_vidimaz,dep,app; - long mese, ultimo_mese; - bool stamp_bollato = FALSE; - bool pagine_ann = FALSE; - bool stampato = FALSE; - mese = 0; - ultimo_mese = 0; - - init_sort(); - - _tab_lbu->zero(); -// TString dep (format ("%4d%-3s", _anno, (const char*) _cod_lib)); -// sprintf(__tmp, "%4d", _anno); -// strcat (__tmp, _cod_lib); - dep = format ("%4d", _anno); - dep << format ("%-3s", (const char*) _cod_lib); - _tab_lbu->put("CODTAB", (const char*) dep); - - if (_tab_lbu->read(_isequal) == NOERR) - { - _tab_inl->zero(); - app = format("%4d" , _anno); - app << format("%-3s", (const char*) _cod_lib); - _tab_inl->put("CODTAB", (const char*) app); - - TRectype rec (_tab_inl->curr()); - - for (_tab_inl->read(); !_tab_inl->eof(); _tab_inl->next()) - { - if (_tab_inl->curr() > rec) break; - - mese = _tab_inl->get_int("I1"); - - if (((_tipo_stampa == 1) && (mese >= _meseda) && (mese <= _mesea)) || - ((_tipo_stampa == 2) && (mese == _mesea))) - { - TRecfield num_riga (_tab_inl->curr(),"CODTAB",7,12); - anno = _tab_inl->get_long("I0"); - numini_paglib = _tab_inl->get_long("I2"); - numfin_paglib = _tab_inl->get_long("I3"); - codditta = _tab_inl->get_long("I4"); - cod_reg = _tab_inl->get("S0"); - cod_vidimaz = _tab_inl->get("S1"); - numini_pagut = _tab_inl->get_long("I5"); - numfin_pagut = _tab_inl->get_long("I6"); - stamp_bollato = _tab_inl->get_bool("B0"); - pagine_ann = _tab_inl->get_bool("B1"); - -//Se tipo_stampa = 1 (stampa di prova) stampo ugualmente. Se tipo_stampa = 2 -// (stampa su bollato), stampo solamente se il flag di stampa su bollato e' -// FALSE. - - if ((_tipo_stampa == 1) || ((_tipo_stampa == 2) && (!stamp_bollato))) - { - ultimo_mese = mese; - stampato = TRUE; - sprintf (_lib->mese, "%2d", mese); - sprintf (_lib->anno, "%4d", anno); - sprintf (_lib->nini_plib, "%5d", numini_paglib); - _lib->num_riga = long(num_riga); - _lib->nfin_plib = numfin_paglib; - _lib->codditta = codditta; - sprintf (_lib->cod_reg, "%3s", (const char*) cod_reg); - _lib->nini_put = numini_pagut; - _lib->nfin_put = numfin_pagut; - sprintf (_lib->cod_vid, "%3s", (const char*) cod_vidimaz); - _lib->stamp_bol = stamp_bollato; - _lib->pag_ann = pagine_ann; - _sort->sort ((const char*) _lib); - -//Se si tratta di una stampa su bollato e il flag "stampa su bollato" indica -//che non e' mai stato stampato su bollato (flag = FALSE), allora devo stampare -//il record della tabella %INL, e contemporaneamente aggiornare il flag, per -//evitare di ristampare successivamente su bollato - - if (_tipo_stampa == 2) - { - _tab_inl->put("B0", "X"); - _tab_inl->rewrite(); - } - } - } - } - _sort->endsort(); - } - -// Se si tratta di una stampa su libro bollato, aggiorno sulla tabella %LBU // l' ultimo mese stampato, l' ultima pagina stampata e il flag che indica se -// quel record e' stato stampato su bollato - - if ((_tipo_stampa == 2) && (stampato)) // stampato e' il flag che mi dice - { //se almeno un record, nella stampa - _tab_lbu->put("I0", ultimo_mese); //su bollato, va in stampa. In caso - _tab_lbu->put("I1", numfin_paglib); //contrario non avrebbe senso - _tab_lbu->rewrite(); //aggiornare %LBU. ES:tutti i record - } //di quel mese sono gia stati stampati -} //su bollato (flag = TRUE). - -bool BA3600_application::set_print(int) -{ - KEY tasto; - - tasto = _msk->run(); - - if (tasto == K_ENTER) - { - _tipo_stampa = _msk->get_int(F_TIPO_STAMPA); - - if (_tipo_stampa == 1) - { - _cod_lib = _msk->get(F_LIBRO_UNICO1); - _datastampa = (_msk->get(F_DATA_STAMPA)); - _meseda = _msk->get_int(F_MESEDA); - _mesea = _msk->get_int(F_MESEA); - _anno = _msk->get_long(F_ANNOA); - } - else if (_tipo_stampa == 2) - { - _cod_lib = _msk->get(F_LIBRO_UNICO2); - _mesea = _msk->get_int(F_STAMPA_MESE); - _anno = _msk->get_long(F_STAMPA_ANNO); - _cod_lib_stampa = _msk->get(F_CODLIB_STAMPA); - _pag_fin = _msk->get_long(F_PAGFINALE); - } - - _pag_fuori_sequenza = FALSE; - - crea_sort(); - - crea_intestazione(); - - return TRUE; - } - return FALSE; -} - -/********* -bool BA3600_application::preprocess_page(int file, int counter) -{ - if (_tipo_stampa == 1) - { - if (preprocess_prova(counter)) - return TRUE; - else - return FALSE; - } - else if (_tipo_stampa == 2) - { - if (preprocess_bollato()) - return TRUE; - else - return FALSE; - } - - return TRUE; -} -***********/ - -bool BA3600_application::preprocess_page(int file, int counter) -{ - struct ind_lib* lib = (struct ind_lib*) _buff; - long nini_plib; - - reset_print(); - - _buff = _sort->retrieve(); - - if (_buff != NULL) - { - lib = (struct ind_lib*) _buff; - - _numini_paglib = atoi(lib->nini_plib); - _numfin_paglib = lib->nfin_plib; - _codditta = lib->codditta; - _rag_soc = ragsoc_ditta(_codditta); - _cod_reg = lib->cod_reg; - _descrizione = descrizione_codreg(_cod_reg); - _cod_vidimaz = lib->cod_vid; - _numini_pagut = lib->nini_put; - _numfin_pagut = lib->nfin_put; - _num_riga = lib->num_riga; - _stamp_bollato = lib->stamp_bol; - _pag_ann = lib->pag_ann; -// _stamp_bollato_str = _stamp_bollato.string(); - -//Il controllo di pagine fuori sequenza viene sempre effettuato, tranne che per -//il primo record. - - if (counter) - { - nini_plib = _numini_paglib - 1; - if (_nfin_plib_prec != nini_plib) - _pag_fuori_sequenza = TRUE; - else - _pag_fuori_sequenza = FALSE; - } - - _nfin_plib_prec = _numfin_paglib; - - return TRUE; - } - else - return FALSE; - - return TRUE; -} - -/******* -bool BA3600_application::preprocess_bollato() -{ - -} -******/ - -void BA3600_application::set_page(int file, int counter) -{ - if (_tipo_stampa == 1) - setta_righe_prova(); - else if (_tipo_stampa == 2) - setta_righe_bollato(); -} - -void BA3600_application::setta_righe_prova() -{ - int i; - - i = 1; - - if (_pag_fuori_sequenza) - set_row (i++,"@10gPAGINE FUORI SEQUENZA"); - - set_row (i,"@1g#t", &_cod_lib); - set_row (i,"@6g#5d", &_numini_paglib); - set_row (i,"@13g#5d", &_numfin_paglib); - set_row (i,"@21g#5d", &_codditta); - set_row (i,"@27g#.41t", &_rag_soc); - set_row (i,"@69g#t", &_cod_reg); - set_row (i,"@73g#.31t", &_descrizione); - set_row (i,"@105g#t", &_cod_vidimaz); - set_row (i,"@111g#5d", &_numini_pagut); - set_row (i,"@117g#5d", &_numfin_pagut); - set_row (i,"@124g#5d", &_num_riga); - set_row (i,"@130g#t", &_stamp_bollato_str); -} - -void BA3600_application::setta_righe_bollato() -{ - int i; - - i = 1; - - if (_pag_fuori_sequenza) - set_row (i++,"@10gPAGINE FUORI SEQUENZA"); - - set_row (i,"@1g#t", &_cod_lib); - set_row (i,"@6g#5d", &_numini_paglib); - set_row (i,"@13g#5d", &_numfin_paglib); - if ((_pag_ann) && (_codditta == 0)) - set_row (i,"@27gPAGINE ANNULLATE"); - else - { - set_row (i,"@21g#5d", &_codditta); - set_row (i,"@27g#.41t", &_rag_soc); - } - if ((_pag_ann) && (_cod_reg == "")) - set_row (i,"@73gPAGINE ANNULLATE"); - else - { - set_row (i,"@69g#t", &_cod_reg); - set_row (i,"@73g#.31t", &_descrizione); - } - set_row (i,"@105g#t", &_cod_vidimaz); - set_row (i,"@111g#5d", &_numini_pagut); - set_row (i,"@117g#5d", &_numfin_pagut); - set_row (i,"@124g#5d", &_num_riga); - set_row (i,"@130g#t", &_stamp_bollato_str); -} - -print_action BA3600_application::postprocess_page(int file, int counter) -{ - if (_buff == NULL) - return NEXT_PAGE; - - return REPEAT_PAGE; -} - -const char* BA3600_application::ragsoc_ditta(long codditta) -{ - TLocalisamfile nditte(LF_NDITTE); - - nditte.zero(); - nditte.put(NDT_CODDITTA, codditta); - nditte.read(); - if (nditte.bad()) - nditte.zero(); - tmp = nditte.get(NDT_RAGSOC); - return (__tmp); -} - -const char* BA3600_application::descrizione_codreg(TString& codreg) -{ - TString dep; - - _tab_reg->zero(); - dep = format("%4d", _anno); - dep << format("%-3s", (const char*) codreg); - _tab_reg->put("CODTAB", dep); - _tab_reg->read(); - if (_tab_reg->bad()) - _tab_reg->zero(); - tmp = _tab_reg->get("S0"); - return (__tmp); -} - -void BA3600_application::preprocess_header() -{ -} - -void BA3600_application::crea_intestazione() -{ - TString datastampastr; - TString sep(132); - - reset_header(); - - set_header (1,"Studio"); - - sep << "Pag. @#"; - sep.right_just(132); - set_header (2,(const char*) sep); - - datastampastr = _datastampa.string(); - - set_header (2,"@0gPartita iva"); - set_header (2,"@30gCodice fiscale"); - if (_tipo_stampa == 1) - { - set_header (2,"@75gLIBRO UNICO DI PROVA"); - set_header (2,"@105gData@110g%s",(const char*) datastampastr); - } - else - if (_tipo_stampa == 2) - { - TString mese = itom(_mesea); - set_header (2,"@75gmese di ", (const char*) mese); - set_header (2,"@92g%4d", _anno); - } - - set_header (3,"@0gLibro unico :"); - sep.fill('-'); //Stampa 132 - (sep(132)) - set_header (4, (const char *) sep); - set_header (5,"@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente@126gNum.@131gF"); - set_header (6,"@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate@126greg.@131g8"); - set_header (7, (const char *) sep); -} - -void BA3600_application::user_create() -{ - _nditte = new TLocalisamfile (LF_NDITTE); - - _tab_inl = new TTable (TAB_INL); - _tab_lbu = new TTable (TAB_LBU); - _tab_reg = new TTable (TAB_REG); - - _msk = new TMask("ba3600a"); -} - -void BA3600_application::user_destroy() -{ - delete _msk; - - delete _tab_inl; - delete _tab_lbu; - delete _tab_reg; - delete _nditte; -} - -int ba3600 (int argc, char* argv[]) -{ - - BA3600_application a; - - a.run(argc, argv, "Stampa indici registro libro unico"); - - return 0; -} - - - +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ba3.h" +#include "ba3600.h" + +#define ALIAS 50 + +static TString256 tmp; + +const int TABLBU = (int)TTable::name2log("%LBU"); +const int TABINL = (int)TTable::name2log("%INL"); + +class BA3600_application : public TPrintapp +{ + struct ind_lib + { + char mese[3]; + char anno[5]; + char nini_plib[6]; + long num_riga; + long nfin_plib; + long codditta; + char cod_reg[4]; + long nini_put; + long nfin_put; + char cod_vid[4]; + bool stamp_bol; + bool pag_ann; + }; + + TMask* _msk; + TTable* _tab_inl; + TTable* _tab_lbu; + TTable* _tab_reg; + TLocalisamfile* _nditte; + TSort* _sort; + TProgind* _prog; + ind_lib* _lib; + const char* _buff; + + TDate _datastampa; + int _tipo_stampa, _meseda, _mesea; + long _anno, _numini_paglib, _numfin_paglib, _numini_pagut, _numfin_pagut; + long _codditta, _pag_fin, _num_riga, _nfin_plib_prec; + TString _cod_lib, _rag_soc, _cod_reg, _descrizione, _cod_vidimaz; + TString _cod_lib_stampa, _stamp_bollato_str; + bool _stamp_bollato, _pag_ann, _pag_fuori_sequenza; + +public: + + bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; } + void user_create() ; + void user_destroy(); + bool set_print(int); + + virtual bool preprocess_page (int,int); + virtual print_action postprocess_page (int,int); + + virtual void preprocess_header(); + virtual void set_page(int,int); + + void init_sort(); + void crea_sort(); + bool preprocess_prova(int); + bool preprocess_bollato(); + void crea_intestazione(); + const char* ragsoc_ditta(long); + const char* descrizione_codreg(TString&); + void setta_righe_prova(); + void setta_righe_bollato(); + + BA3600_application() {} +}; + +void BA3600_application::init_sort() +{ + _lib = new ind_lib; + _sort = new TSort (sizeof(ind_lib)); + + _sort -> addsortkey((char*)&(_lib->mese) - (char*)&(_lib->mese),2); + _sort -> addsortkey((char*)&(_lib->anno) - (char*)&(_lib->anno),4); + _sort -> addsortkey((char*)&(_lib->nini_plib) - (char*)&(_lib->nini_plib),5); + _sort->init(); +} + +//Crea sort ordina i record della tabella %INL per mese registrazione, anno +//registrazione e numero iniziale pagine registro libro unico + +void BA3600_application::crea_sort() +{ + long anno,numini_paglib,numfin_paglib,codditta,numini_pagut,numfin_pagut; + TString cod_reg,cod_vidimaz,dep,app; + long mese, ultimo_mese; + bool stamp_bollato = FALSE; + bool pagine_ann = FALSE; + bool stampato = FALSE; + mese = 0; + ultimo_mese = 0; + + init_sort(); + + _tab_lbu->zero(); + // TString dep (format ("%4d%-3s", _anno, (const char*) _cod_lib)); + // sprintf(__tmp, "%4d", _anno); + // strcat (__tmp, _cod_lib); + dep = format ("%4d", _anno); + dep << format ("%-3s", (const char*) _cod_lib); + _tab_lbu->put("CODTAB", (const char*) dep); + + if (_tab_lbu->read(_isequal) == NOERR) + { + _tab_inl->zero(); + app = format("%4d" , _anno); + app << format("%-3s", (const char*) _cod_lib); + _tab_inl->put("CODTAB", (const char*) app); + + TRectype rec (_tab_inl->curr()); + + for (_tab_inl->read(); !_tab_inl->eof(); _tab_inl->next()) + { + if (_tab_inl->curr() > rec) break; + + mese = _tab_inl->get_int("I1"); + + if (((_tipo_stampa == 1) && (mese >= _meseda) && (mese <= _mesea)) || + ((_tipo_stampa == 2) && (mese == _mesea))) + { + TRecfield num_riga (_tab_inl->curr(),"CODTAB",7,12); + anno = _tab_inl->get_long("I0"); + numini_paglib = _tab_inl->get_long("I2"); + numfin_paglib = _tab_inl->get_long("I3"); + codditta = _tab_inl->get_long("I4"); + cod_reg = _tab_inl->get("S0"); + cod_vidimaz = _tab_inl->get("S1"); + numini_pagut = _tab_inl->get_long("I5"); + numfin_pagut = _tab_inl->get_long("I6"); + stamp_bollato = _tab_inl->get_bool("B0"); + pagine_ann = _tab_inl->get_bool("B1"); + + //Se tipo_stampa = 1 (stampa di prova) stampo ugualmente. Se tipo_stampa = 2 + // (stampa su bollato), stampo solamente se il flag di stampa su bollato e' + // FALSE. + + if ((_tipo_stampa == 1) || ((_tipo_stampa == 2) && (!stamp_bollato))) + { + ultimo_mese = mese; + stampato = TRUE; + sprintf (_lib->mese, "%2d", mese); + sprintf (_lib->anno, "%4d", anno); + sprintf (_lib->nini_plib, "%5d", numini_paglib); + _lib->num_riga = long(num_riga); + _lib->nfin_plib = numfin_paglib; + _lib->codditta = codditta; + sprintf (_lib->cod_reg, "%3s", (const char*) cod_reg); + _lib->nini_put = numini_pagut; + _lib->nfin_put = numfin_pagut; + sprintf (_lib->cod_vid, "%3s", (const char*) cod_vidimaz); + _lib->stamp_bol = stamp_bollato; + _lib->pag_ann = pagine_ann; + _sort->sort ((const char*) _lib); + + //Se si tratta di una stampa su bollato e il flag "stampa su bollato" indica + //che non e' mai stato stampato su bollato (flag = FALSE), allora devo stampare + //il record della tabella %INL, e contemporaneamente aggiornare il flag, per + //evitare di ristampare successivamente su bollato + + if (_tipo_stampa == 2) + { + _tab_inl->put("B0", "X"); + _tab_inl->rewrite(); + } + } + } + } + _sort->endsort(); + } + + // Se si tratta di una stampa su libro bollato, aggiorno sulla tabella %LBU // l' ultimo mese stampato, l' ultima pagina stampata e il flag che indica se + // quel record e' stato stampato su bollato + + if ((_tipo_stampa == 2) && (stampato)) // stampato e' il flag che mi dice + { //se almeno un record, nella stampa + _tab_lbu->put("I0", ultimo_mese); //su bollato, va in stampa. In caso + _tab_lbu->put("I1", numfin_paglib); //contrario non avrebbe senso + _tab_lbu->rewrite(); //aggiornare %LBU. ES:tutti i record + } //di quel mese sono gia stati stampati +} //su bollato (flag = TRUE). + +bool BA3600_application::set_print(int) +{ + KEY tasto; + + tasto = _msk->run(); + + if (tasto == K_ENTER) + { + _tipo_stampa = _msk->get_int(F_TIPO_STAMPA); + + if (_tipo_stampa == 1) + { + _cod_lib = _msk->get(F_LIBRO_UNICO1); + _datastampa = (_msk->get(F_DATA_STAMPA)); + _meseda = _msk->get_int(F_MESEDA); + _mesea = _msk->get_int(F_MESEA); + _anno = _msk->get_long(F_ANNOA); + } + else if (_tipo_stampa == 2) + { + _cod_lib = _msk->get(F_LIBRO_UNICO2); + _mesea = _msk->get_int(F_STAMPA_MESE); + _anno = _msk->get_long(F_STAMPA_ANNO); + _cod_lib_stampa = _msk->get(F_CODLIB_STAMPA); + _pag_fin = _msk->get_long(F_PAGFINALE); + } + + _pag_fuori_sequenza = FALSE; + + crea_sort(); + + crea_intestazione(); + + return TRUE; + } + return FALSE; +} + +/********* + bool BA3600_application::preprocess_page(int file, int counter) + { + if (_tipo_stampa == 1) + { + if (preprocess_prova(counter)) + return TRUE; + else + return FALSE; + } + else if (_tipo_stampa == 2) + { + if (preprocess_bollato()) + return TRUE; + else + return FALSE; + } + + return TRUE; + } + ***********/ + +bool BA3600_application::preprocess_page(int file, int counter) +{ + struct ind_lib* lib = (struct ind_lib*) _buff; + long nini_plib; + + reset_print(); + + _buff = _sort->retrieve(); + + if (_buff != NULL) + { + lib = (struct ind_lib*) _buff; + + _numini_paglib = atoi(lib->nini_plib); + _numfin_paglib = lib->nfin_plib; + _codditta = lib->codditta; + _rag_soc = ragsoc_ditta(_codditta); + _cod_reg = lib->cod_reg; + _descrizione = descrizione_codreg(_cod_reg); + _cod_vidimaz = lib->cod_vid; + _numini_pagut = lib->nini_put; + _numfin_pagut = lib->nfin_put; + _num_riga = lib->num_riga; + _stamp_bollato = lib->stamp_bol; + _pag_ann = lib->pag_ann; + // _stamp_bollato_str = _stamp_bollato.string(); + + //Il controllo di pagine fuori sequenza viene sempre effettuato, tranne che per + //il primo record. + + if (counter) + { + nini_plib = _numini_paglib - 1; + if (_nfin_plib_prec != nini_plib) + _pag_fuori_sequenza = TRUE; + else + _pag_fuori_sequenza = FALSE; + } + + _nfin_plib_prec = _numfin_paglib; + + return TRUE; + } + else + return FALSE; + + return TRUE; +} + +/******* + bool BA3600_application::preprocess_bollato() + { + + } + ******/ + +void BA3600_application::set_page(int file, int counter) +{ + if (_tipo_stampa == 1) + setta_righe_prova(); + else if (_tipo_stampa == 2) + setta_righe_bollato(); +} + +void BA3600_application::setta_righe_prova() +{ + int i; + + i = 1; + + if (_pag_fuori_sequenza) + set_row (i++,"@10gPAGINE FUORI SEQUENZA"); + + set_row (i,"@1g#t", &_cod_lib); + set_row (i,"@6g#5d", &_numini_paglib); + set_row (i,"@13g#5d", &_numfin_paglib); + set_row (i,"@21g#5d", &_codditta); + set_row (i,"@27g#.41t", &_rag_soc); + set_row (i,"@69g#t", &_cod_reg); + set_row (i,"@73g#.31t", &_descrizione); + set_row (i,"@105g#t", &_cod_vidimaz); + set_row (i,"@111g#5d", &_numini_pagut); + set_row (i,"@117g#5d", &_numfin_pagut); + set_row (i,"@124g#5d", &_num_riga); + set_row (i,"@130g#t", &_stamp_bollato_str); +} + +void BA3600_application::setta_righe_bollato() +{ + int i; + + i = 1; + + if (_pag_fuori_sequenza) + set_row (i++,"@10gPAGINE FUORI SEQUENZA"); + + set_row (i,"@1g#t", &_cod_lib); + set_row (i,"@6g#5d", &_numini_paglib); + set_row (i,"@13g#5d", &_numfin_paglib); + if ((_pag_ann) && (_codditta == 0)) + set_row (i,"@27gPAGINE ANNULLATE"); + else + { + set_row (i,"@21g#5d", &_codditta); + set_row (i,"@27g#.41t", &_rag_soc); + } + if ((_pag_ann) && (_cod_reg == "")) + set_row (i,"@73gPAGINE ANNULLATE"); + else + { + set_row (i,"@69g#t", &_cod_reg); + set_row (i,"@73g#.31t", &_descrizione); + } + set_row (i,"@105g#t", &_cod_vidimaz); + set_row (i,"@111g#5d", &_numini_pagut); + set_row (i,"@117g#5d", &_numfin_pagut); + set_row (i,"@124g#5d", &_num_riga); + set_row (i,"@130g#t", &_stamp_bollato_str); +} + +print_action BA3600_application::postprocess_page(int file, int counter) +{ + if (_buff == NULL) + return NEXT_PAGE; + + return REPEAT_PAGE; +} + +const char* BA3600_application::ragsoc_ditta(long codditta) +{ + TLocalisamfile nditte(LF_NDITTE); + + nditte.zero(); + nditte.put(NDT_CODDITTA, codditta); + nditte.read(); + if (nditte.bad()) + nditte.zero(); + tmp = nditte.get(NDT_RAGSOC); + return tmp; +} + +const char* BA3600_application::descrizione_codreg(TString& codreg) +{ + TString16 dep; + + _tab_reg->zero(); + dep = format("%4d", _anno); + dep << format("%-3s", (const char*) codreg); + _tab_reg->put("CODTAB", dep); + _tab_reg->read(); + if (_tab_reg->bad()) + _tab_reg->zero(); + tmp = _tab_reg->get("S0"); + return tmp; +} + +void BA3600_application::preprocess_header() +{ +} + +void BA3600_application::crea_intestazione() +{ + TString datastampastr; + TString sep(132); + + reset_header(); + + set_header (1,"Studio"); + + sep << "Pag. @#"; + sep.right_just(132); + set_header (2,(const char*) sep); + + datastampastr = _datastampa.string(); + + set_header (2,"@0gPartita iva"); + set_header (2,"@30gCodice fiscale"); + if (_tipo_stampa == 1) + { + set_header (2,"@75gLIBRO UNICO DI PROVA"); + set_header (2,"@105gData@110g%s",(const char*) datastampastr); + } + else + if (_tipo_stampa == 2) + { + TString mese = itom(_mesea); + set_header (2,"@75gmese di ", (const char*) mese); + set_header (2,"@92g%4d", _anno); + } + + set_header (3,"@0gLibro unico :"); + sep.fill('-'); //Stampa 132 - (sep(132)) + set_header (4, (const char *) sep); + set_header (5,"@0gCod.@6gNumero@13gpagine@21gCodice@69gCod.@104gCodice@111gN.pag.@118gutente@126gNum.@131gF"); + set_header (6,"@0gLibro@8gda@16ga@21gditta@28gDenominazione@69greg.@74gDescrizione@104gvidim.@112gutilizzate@126greg.@131g8"); + set_header (7, (const char *) sep); +} + +void BA3600_application::user_create() +{ + _nditte = new TLocalisamfile (LF_NDITTE); + + _tab_inl = new TTable (TAB_INL); + _tab_lbu = new TTable (TAB_LBU); + _tab_reg = new TTable (TAB_REG); + + _msk = new TMask("ba3600a"); +} + +void BA3600_application::user_destroy() +{ + delete _msk; + + delete _tab_inl; + delete _tab_lbu; + delete _tab_reg; + delete _nditte; +} + +int ba3600 (int argc, char* argv[]) +{ + + BA3600_application a; + + a.run(argc, argv, "Stampa indici registro libro unico"); + + return 0; +} + + + diff --git a/ba/ba3800.cpp b/ba/ba3800.cpp index f353bef54..6d4b911d7 100755 --- a/ba/ba3800.cpp +++ b/ba/ba3800.cpp @@ -1,3 +1,1839 @@ +<<<<<<< ba3800.cpp +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ba3.h" + +//#include "ba3800.h" +const char* const TAB_IVD = "%ivd"; +#define F_DATASTAMPA 101 + +static TString256 tmp; + +class BA3800_application : public TPrintapp +{ + struct bil_ivd + { + char sez; + char let; + char numr[5]; + char num[4]; + char gruppo[4]; + char conto[4]; + char sottoc[8]; + }; + + bil_ivd* _bil; + TTable* _tabivd; + TLocalisamfile* _nditte; + TLocalisamfile* _comuni; + TLocalisamfile* _unloc; + TLocalisamfile* _anag; + TLocalisamfile* _pconti; + TLocalisamfile* _clifo; + TParagraph_string _descr; + const char* _buff; + TSort* _sort; + + TDate _datastampa; + bool _diffprod_fatto,_risimp_fatto; + TString _numr_tot,_num_tot,_numr,_numr_da_stamp,_num_da_stamp,_numr_stamp,_num_stamp;; + char _sez_da_stamp,_let_da_stamp,_sez_stamp,_let_stamp,_sez_tot,_let_tot,_let,_sez; + int _cont_let,_cont_numr,_cont_num,_cont_gcs,_num,_i; + bool _reset_righe_stampa,_statopatr_no_stamp,_sbilancio_ordine; + bool _totale_attivita_gia_stampato,_totale_passivita_gia_stampato; + bool _sbilancio_patr_gia_stampato,_attivo_o_passivo; + TString _causale_ap, _causale_chi, _totale; + char _liv; + +public: + + bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; } + void user_create() ; + void user_destroy(); + virtual bool set_print(int); + + virtual bool preprocess_page (int,int); + virtual print_action postprocess_page (int,int); + virtual void postclose_print (); + + virtual void set_page(int,int); + + void intestazione_ditta(); + void intestazione_studio(); + void stampa_totali_studio(); + void stampa_totali_ditta(); + bool preprocess_ditta(int); + bool preprocess_studio(int); + + void setta_righe_studio(const char*); + void setta_righe_ditta(const char*); + void totale_numero_arabo(); + void totale_numero_romano(); + void totale_lettera(); + void init_sort(); + void crea_sort_tabella(); + void crea_sort_piano_conti(); + void scrivi_record(const TString&,const TString&,const TString&,int,int,int,long); + void riempi_record(const TString&,const TString&,const TString&,int,int,int,long); + void set_bil_key(bil_ivd* b, char sezione, char lettera, + const char* numero_romano, int numero, + bool conti_ordine = TRUE, int conto = 0, + int gruppo = 0, long sottoconto = 0L); + const char* descrizione_lettera(char, char); + const char* descrizione_numeroromano(char, char, int); + const char* descrizione_numero(char, char, int, int); + const char* descrizione_sottoconto(int, int, long); + void setta_righe_descr(TParagraph_string&,const TString&,const TString&); + + BA3800_application(char livello) : _liv(toupper(livello)), _descr("", 40) {} +}; + +void BA3800_application::postclose_print() +{ + if (_liv == 'D') + delete _sort; +} + +void BA3800_application::set_bil_key(bil_ivd* b, char sezione, char lettera, + const char* numero_romano, int numero, + bool conti_ordine, int gruppo, int conto, + long sottoconto) + +{ + b->sez = sezione; + + //Se esiste solamente la sezione,significa che e' un conto d'ordine + //Forzo la lettera della classe a Z, per ottenere, grazie + //all'ordinamento del sort, i record dei conti d'ordine per ultimi + + b->let = (conti_ordine && lettera == '\0' && sezione < '3') ? 'Z' : lettera; + strcpy(b->numr, numero_romano); + sprintf(b->num , "%2d", numero); + if (gruppo < 0) + { + strcpy(b->gruppo, "999"); + strcpy(b->conto, "999"); + strcpy(b->sottoc, "999999"); + } + else + if (gruppo == 0) + { + strcpy(b->gruppo, " "); + strcpy(b->conto, " "); + strcpy(b->sottoc, " "); + } + else + { + sprintf(b->gruppo , "%3d", gruppo); + sprintf(b->conto , "%3d", conto); + sprintf(b->sottoc , "%6ld", sottoconto); + } +} + +void BA3800_application::scrivi_record(const TString& sez, + const TString& let, const TString& numerorom,int numero, + int g,int c,long s) +{ + + //Se esiste solamente la sezione,significa che e' un conto d'ordine + //Forzo la lettera della classe a Z, per ottenere, grazie + //all'ordinamento del sort, i record dei conti d'ordine per ultimi + + set_bil_key(_bil, sez[0], let[0], numerorom, numero, TRUE, g, c, s); + _sort->sort ((const char*) _bil); +} + +void BA3800_application::riempi_record(const TString& sez, + const TString& let, const TString& numerorom,int numero, + int g,int c,long s) +{ + set_bil_key(_bil, sez[0], let[0], numerorom, numero, FALSE, g, c, s); + _sort->sort ((const char*) _bil); +} + +void BA3800_application::crea_sort_tabella() +{ + TRecnotype recno_prec=0l, recno_curr=0l; + TString codtab_prec; + TTable tabivd(TAB_IVD); + TRecfield codtab_curr(tabivd.curr(),"CODTAB"); + TRecfield sezione (tabivd.curr(),"CODTAB",0,0); + TRecfield lettera (tabivd.curr(),"CODTAB",1,1); + TRecfield numerorom (tabivd.curr(),"CODTAB",2,5); + TRecfield numero (tabivd.curr(),"CODTAB",6,7); + int preclen; + bool FINITO=FALSE; + + tabivd.first(); + codtab_prec = tabivd.get("CODTAB"); + + // Compilo tanti record quante sono le classi IV direttiva trovate sulla + // tabella %IVD, usando dei gruppi, conti e sottoconti fittizi. Successivamente + // nel caso di stampa completa verranno stampati anche questi record; nel caso + // di stampa non completa non verranno stampati. + + do + { + recno_prec = tabivd.recno(); + tabivd.next(); + if (tabivd.eof()) + { + tabivd.zero(); + FINITO=TRUE; + } + recno_curr = tabivd.recno(); + preclen = codtab_prec.len(); + if (!strncmp(codtab_curr,codtab_prec,preclen)) + codtab_prec = (const char *)codtab_curr; + else + { + tabivd.readat(recno_prec); + const char sez = *((const char*) sezione); + const char let = *((const char*) lettera); + TString16 nrom((const char*)numerorom); + const int nu = (int) numero; + + set_bil_key(_bil, sez, let,(const char*)nrom, nu, FALSE,-1); + _sort->sort ((const char*) _bil); + tabivd.readat(recno_curr); + codtab_prec = (const char *)codtab_curr; + } + } while (!FINITO); +} + +// Passo al sort tutti i record presenti su piano dei conti, aventi la classe +// IV direttiva CEE. + +void BA3800_application::crea_sort_piano_conti() +{ + TLocalisamfile pconti(LF_PCON); + TString sez,let,numerorom; + TString sez_conto,let_conto,numr_conto; + int num_conto, indbil; + char sezione,lettera,tmcf; + int numero,g,c; + long s; + bool classe_conto = FALSE; + bool conto_dettagliato = FALSE; + bool stsottbil; + c = 0; + num_conto = 0; + tmcf = ' '; + indbil = 0; + + for (pconti.first(); !pconti.eof(); pconti.next()) + { + // _prog->addstatus(1); + g = pconti.get_int (PCN_GRUPPO); + c = pconti.get_int (PCN_CONTO); + s = pconti.get_long(PCN_SOTTOCONTO); + sez = pconti.get(PCN_SEZIVD); + let = pconti.get(PCN_LETTIVD); + sezione = sez[0]; + lettera = let[0]; + numerorom = pconti.get(PCN_NUMRIVD); + numero = pconti.get_int (PCN_NUMIVD); + + // Se si tratta di un conto e contiene la classe, allora lo passo al sort. + // Gli eventuali sottoconti avranno la stessa classe. + + if ((g != 0) && (c != 0) && (s == 0)) + { + stsottbil = pconti.get_bool(PCN_STSOTTBIL); + tmcf = pconti.get (PCN_TMCF)[0]; + indbil = pconti.get_int (PCN_INDBIL); + + //Se sono nello stesso gruppo, ma ho un conto diverso da quello precedentemente + //analizzato, e se questi contiene la classe IV dir. CEE, + //allore devo controllare se va dettagliato (STSOTTBIL) + + if (sez != "0") + { + if (!stsottbil || tmcf == 'C' || tmcf == 'F') + conto_dettagliato = FALSE; + else + conto_dettagliato = TRUE; + + sez_conto = sez; + + if (let != "") + let_conto = let; + else + if ((sez == "1")||(sez == "2")) + let_conto = "Z"; + else + let_conto = let; + + numr_conto = numerorom; + num_conto = numero; + + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,0); + + classe_conto = TRUE; + } + else + { + classe_conto = FALSE; // Metto conto dettagliato = TRUE perche' potrebbero esserci dei sottoconti + conto_dettagliato = TRUE; // di questo conto che hanno la classe e quindi vanno stampati. + } + } + + // Se si tratta di un sottoconto e contiene la classe, allora lo passo al sort. + + if ((g != 0) && (c != 0) && (s != 0)) + { + // classe_conto indica se il conto precedentemente letto conteneva + // la classe. In caso affermativo anche questo sottoconto appena + // letto avra' la stessa classe del conto. + + if (classe_conto) + { + if (conto_dettagliato) + riempi_record(sez_conto,let_conto,numr_conto,num_conto,g,c,s); + } + else + if (sez != "0") + riempi_record(sez,let,numerorom,numero,g,c,s); + } + } +} + +bool BA3800_application::set_print(int) +{ + TMask msk("ba3800a"); + + const KEY tasto = msk.run(); + + if (tasto == K_ENTER) + { + _datastampa = msk.get(F_DATASTAMPA); + + _cont_let = 0; + _cont_numr = 0; + _cont_num = 0; + _cont_gcs = 0; + + _totale = "XXXXXXXXXXX"; + + _sez_stamp = ' '; + _let_stamp = ' '; + _numr_stamp = ""; + _num_stamp = ""; + _sez_tot = ' '; + _let_tot = ' '; + _numr_tot = ""; + _num_tot = ""; + + _statopatr_no_stamp = TRUE; + _diffprod_fatto = TRUE; + _risimp_fatto = TRUE; + _totale_attivita_gia_stampato = FALSE; + _totale_passivita_gia_stampato = FALSE; + _sbilancio_ordine = FALSE; + _sbilancio_patr_gia_stampato = FALSE; + _attivo_o_passivo = FALSE; + + if (_liv == 'S') + intestazione_studio(); + else + if (_liv == 'D') + { + init_sort(); + crea_sort_tabella(); + crea_sort_piano_conti(); + _sort->endsort(); + + intestazione_ditta(); + + delete _bil; + } + + return TRUE; + } + return FALSE; +} + +void BA3800_application::totale_numero_arabo() +{ + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } +} + +void BA3800_application::totale_numero_romano() +{ + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } +} + +void BA3800_application::totale_lettera() +{ + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } +} + +void BA3800_application::stampa_totali_studio() +{ + bool gia_stampato_conto_ord = FALSE; + TString16 diff_prod; + TString16 ris_imp; + + diff_prod.format("%c%c",'9','B'); + ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + + _num = atoi(_num_tot); + _numr = _numr_tot; + _let = _let_tot; + + if (_tabivd->eof()) + { + _num_tot = ""; + _numr_tot = ""; + _let_tot = ' '; + _sez_tot = ' '; + } + + if (_num_da_stamp!=_num_tot) + { + totale_numero_arabo(); + + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + + if (classe > ris_imp && _risimp_fatto) + { + if (_num_tot == "20" || _num_tot == "21") + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i++,"@86g%s", (const char*) _totale); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%s", (const char*) _totale); + _risimp_fatto = FALSE; + } + } + } + + _cont_gcs = 0; + } + if (_numr_da_stamp!=_numr_tot) + { + totale_numero_arabo(); + totale_numero_romano(); + _cont_gcs = 0; + _cont_num = 0; + } + if (_let_da_stamp!=_let_tot) + { + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp); + + totale_numero_arabo(); + totale_numero_romano(); + + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let_stamp == 'D') + set_row (_i,"@4gTotale delle rettifiche"); + else + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + else + if (_sez_stamp != '9') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i++,"@86g%s", (const char*) _totale); + else + if (_sez_stamp != '9') + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + + if (classe > diff_prod && _diffprod_fatto) + { + if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + _diffprod_fatto = FALSE; + } + } + } + else + { + totale_numero_arabo(); + totale_numero_romano(); + totale_lettera(); + } + + _cont_gcs = 0; + _cont_num = 0; + _cont_numr = 0; + } + if (_sez_da_stamp != _sez_tot) + { + totale_numero_arabo(); + totale_numero_romano(); + + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + } + if (_sez_stamp == '1') + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if (_sez_stamp == '2') //&& (_let_stamp != 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if (_sez_stamp == '2') + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if (_sez_stamp == '9') + { + if (_tabivd->eof()) + { + if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)//Solo se esiste una delle due lettere + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + _diffprod_fatto = FALSE; + } + if (_risimp_fatto) + { + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + _cont_gcs = 0; + _cont_num = 0; + _cont_numr = 0; + _cont_let = 0; + } +} + +void BA3800_application::stampa_totali_ditta() +{ + bool gia_stampato_conto_ord = FALSE; + TString16 diff_prod; + TString16 ris_imp; + + diff_prod.format("%c%c",'9','B'); + ris_imp.format ("%c%c%8s%2s",'9','E',"","21"); + + _num = atoi(_num_tot); + _numr = _numr_tot; + _let = _let_tot; + + if (_buff == NULL) + { + _num_tot = ""; + _numr_tot = ""; + _let_tot = ' '; + _sez_tot = ' '; + } + + if ((_sez_stamp == '1' || _sez_stamp == '2') && _let_stamp != 'Z') + _attivo_o_passivo = TRUE; + + if (_num_da_stamp!=_num_tot) + { + if (_let_stamp != 'Z') + { + if (_sez_stamp != '5') + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + } + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s", _sez_da_stamp,_let_da_stamp,(const char*)_numr_da_stamp,(const char*)_num_da_stamp); + + if (classe > ris_imp && _risimp_fatto) + { + if (_num_tot == "20" || _num_tot == "21") + { + set_row (_i,"@4gTotale delle partite straordinarie"); + set_row (_i++,"@86g%s", (const char*) _totale); + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%s", (const char*) _totale); + _risimp_fatto = FALSE; + } + } + } + + _cont_gcs = 0; + } + if (_numr_da_stamp!=_numr_tot) + { + if (_let_stamp != 'Z') + { + if (_sez_stamp != '5') + { + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + } + } + _cont_gcs = 0; + _cont_num = 0; + } + if (_let_da_stamp!=_let_tot) + { + if (_sez_stamp == '9') + { + TString16 classe; + + classe.format("%c%c%8s%2s",_sez_stamp,_let_stamp,(const char*)_numr_stamp,(const char*)_num_stamp); + + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let_stamp == 'D') + set_row (_i,"@4gTotale delle rettifiche"); + else + if (_let != ' ') + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + else + if (_sez_stamp != '9') + set_row (_i,"@3gTotale@10g%c@12g)", _let); + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + set_row (_i++,"@86g%s", (const char*) _totale); + else + if (_sez_stamp != '9') + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + + if (classe > diff_prod && _diffprod_fatto) + { + if (_let_tot == 'A' || _let_tot == 'B') //Solo se esiste una delle due lettere + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*)_totale); + _diffprod_fatto = FALSE; + } + } + } + else + { + if (_let_stamp != 'Z') + { + if (_sez_stamp != '5') + { + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + } + } + + if ((_sez_stamp == '1')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + _totale_attivita_gia_stampato = TRUE; + } + + if ((_sez_stamp == '2')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + _totale_passivita_gia_stampato = TRUE; + } + + if ((_sez_stamp == '1')&&(_let_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); + set_row (_i++,"@86g%s", (const char*) _totale); + gia_stampato_conto_ord = TRUE; + } + + if ((_sez_stamp == '2')&&(_let_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); + set_row (_i++,"@86g%s", (const char*) _totale); + _i++; + gia_stampato_conto_ord = TRUE; + if (!_attivo_o_passivo) + { + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%s", (const char*) _totale); + _sbilancio_ordine = TRUE; + _sbilancio_patr_gia_stampato = TRUE; + } + } + } + _cont_gcs = 0; + _cont_num = 0; + _cont_numr = 0; + } + if (_sez_da_stamp != _sez_tot) + { + if (_let_stamp != 'Z') + { + if (_sez_stamp != '5') + { + if (_cont_gcs != 0)//(_cont_gcs >= 2) + { + //Fai il totale del numero arabo e stampalo + if (_num != 0) + { + set_row (_i,"@18gTotale@25g%2d@27g)", _num); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_num != 0)//(_cont_num >= 2) + { + //Fai il totale del numero romano e stampalo + int numeror = atoi(_numr); + TString numrom = itor(numeror); + if (numrom != "") + { + set_row (_i,"@14gTotale@21g%s", (const char*) numrom); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_cont_numr != 0)//(_cont_numr >= 2) + { + //Fai il totale della lettera e stampalo + if (_let != ' ') + { + if (_sez_stamp == '9' && _let_stamp != 'E') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + else + if (_sez_stamp != '9') + { + set_row (_i,"@3gTotale@10g%c@12g)", _let); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + } + } + } + + if (!_totale_attivita_gia_stampato) + if ((_sez_stamp == '1') && (_let_stamp != 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE ATTIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if (!_totale_passivita_gia_stampato) + if ((_sez_stamp == '2') && (_let_stamp != 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE PASSIVO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if (!gia_stampato_conto_ord) + { + if (_sez_stamp == '2') + { + if (!_sbilancio_patr_gia_stampato) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++,"@86g%s", (const char*) _totale); + _sbilancio_patr_gia_stampato = TRUE; + } + } + if ((_sez_stamp == '1')&&(_let_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE CONTI D' ORDINE ATTIVI"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + + if ((_sez_stamp == '2')&&(_let_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE CONTI D' ORDINE PASSIVI"); + set_row (_i++,"@86g%s", (const char*) _totale); + _i++; + if (!_sbilancio_ordine) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%s", (const char*) _totale); + _sbilancio_ordine = TRUE; + } + } + } + + if (_sez_stamp == '2') + { + char app = ' '; + if (!_sbilancio_patr_gia_stampato) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO STATO PATRIMONIALE"); + set_row (_i,"@0gSBILANCIO (ATTIVO - PASSIVO)"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + if (!_sbilancio_ordine) + { + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gSALDO CONTI D' ORDINE"); + set_row (_i,"@0gSBILANCIO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + if (_sez_stamp == '5') + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gTOTALE CONTI D' ORDINE"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + if (_sez_stamp == '9') + { + if (_tabivd->eof()) + { + if ((_let_stamp == 'A' || _let_stamp == 'B') && _diffprod_fatto)//Solo se esiste una delle due lettere + { + set_row (_i++,"@4gDifferenza tra valore e costi della produzione@86g%s", (const char*) _totale); + _diffprod_fatto = FALSE; + } + if (_risimp_fatto) + { + set_row (_i,"@4gRisultato prima delle imposte"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + } + + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i,"@0gRISULTATO CONTO ECONOMICO"); + set_row (_i++,"@86g%s", (const char*) _totale); + } + _cont_gcs = 0; + _cont_num = 0; + _cont_numr = 0; + _cont_let = 0; + } +} + +print_action BA3800_application::postprocess_page(int file, int counter) +{ + if (_liv == 'S') + { + if (_sez_da_stamp != _sez_stamp) + { + if (_sez_da_stamp == '9') + { + reset_print(); + _i = 1; + setta_righe_studio("CONTO ECONOMICO"); + _reset_righe_stampa = FALSE; + } + } + + set_auto_ff(FALSE); + + if (_tabivd->eof()) + return NEXT_PAGE; + } + else + if (_liv == 'D') + { + struct bil_ivd* bil = (struct bil_ivd*) _buff; + + bil = (struct bil_ivd*) _buff; + + if (_sez_da_stamp != _sez_stamp) + { + if (_sez_da_stamp == '5') + { + reset_print(); + _i = 1; + setta_righe_ditta("CONTI D' ORDINE"); + _reset_righe_stampa = FALSE; + } + if (_sez_da_stamp == '9') + { + reset_print(); + _i = 1; + setta_righe_ditta("CONTO ECONOMICO"); + _reset_righe_stampa = FALSE; + } + } + + set_auto_ff(FALSE); + + if (_buff == NULL) + return NEXT_PAGE; + } + + return REPEAT_PAGE; +} + +bool BA3800_application::preprocess_page(int file, int counter) +{ + if (_liv == 'S') + { + if (preprocess_studio(counter)) + return TRUE; + else + return FALSE; + } + else if (_liv == 'D') + { + if (preprocess_ditta(counter)) + return TRUE; + else + return FALSE; + } + + return TRUE; +} + + +bool BA3800_application::preprocess_studio(int counter) +{ + bool fai = TRUE; + TString saldostr,saldo_rafstr; + bool conto_dettagliato = TRUE; + + if (counter == 0) + { + _tabivd->setkey(1); + _tabivd->zero(); + _tabivd->first(); + reset_print(); + _i = 1; + } + else + _tabivd->next(); + + if (_reset_righe_stampa) + { + reset_print(); + _i = 1; + } + else + _reset_righe_stampa = TRUE; + + if (counter) + { + _sez_stamp = _sez_da_stamp; + _let_stamp = _let_da_stamp; + _numr_stamp = _numr_da_stamp; + _num_stamp = _num_da_stamp; + _sez_tot = _sez_da_stamp; + _let_tot = _let_da_stamp; + _numr_tot = _numr_da_stamp; + _num_tot = _num_da_stamp; + } + + if (_tabivd->eof()) + { + stampa_totali_studio(); + _sez_da_stamp = ' '; + _sez_stamp = ' '; + return TRUE; + } + + if (!_tabivd->eof()) + { + TString16 codtab; + + // _classe_da_stampare = format ("%1c%1c%8s%2d",bil->sez,bil->let,(const char*) bil->numr,bil->num); + + codtab = _tabivd->get("CODTAB"); + _sez_da_stamp = *(codtab.mid(0,1)); + _let_da_stamp = *(codtab.mid(1,1)); + _numr_da_stamp = codtab.mid(2,4); + _numr_da_stamp.ltrim(); + _num_da_stamp = codtab.mid(6,2); + _num_da_stamp.ltrim(); + + if (counter) + stampa_totali_studio(); + + return TRUE; + } + else + return FALSE; +} + +bool BA3800_application::preprocess_ditta(int counter) +{ + struct bil_ivd* bil = (struct bil_ivd*) _buff; + int g,c; + long s; + bool conto_dettagliato = TRUE; + + if (!counter) + { + reset_print(); + _i = 1; + } + + if (_reset_righe_stampa) + { + reset_print(); + _i = 1; + } + else + _reset_righe_stampa = TRUE; + + if (counter) + { + _sez_stamp = bil->sez; + _let_stamp = bil->let; + _numr_stamp = bil->numr; + _numr_stamp.ltrim(); + _num_stamp = bil->num; + _num_stamp.ltrim(); + _sez_tot = bil->sez; + _let_tot = bil->let; + _numr_tot = bil->numr; + _numr_tot.ltrim(); + _num_tot = bil->num; + _num_tot.ltrim(); + } + + _buff = _sort->retrieve(); + + if (_buff == NULL) + { + stampa_totali_ditta(); + _sez_da_stamp = ' '; + _sez_stamp = ' '; + return TRUE; + } + + if (_buff != NULL) + { + bil = (struct bil_ivd*) _buff; + _sez_da_stamp = bil->sez; + _let_da_stamp = bil->let; + _numr_da_stamp = bil->numr; + _numr_da_stamp.ltrim(); + _num_da_stamp = bil->num; + _num_da_stamp.ltrim(); + g = atoi(bil->gruppo); + c = atoi(bil->conto); + s = atol(bil->sottoc); + + if (counter) + stampa_totali_ditta(); + + return TRUE; + } + else + return FALSE; +} + +void BA3800_application::set_page(int file, int counter) +{ + if (_liv == 'S') + { + if (_sez_da_stamp != _sez_stamp) + { + if ((_sez_da_stamp=='1')||((_sez_da_stamp=='2')&&(_statopatr_no_stamp))) + { + setta_righe_studio ("STATO PATRIMONIALE"); + _statopatr_no_stamp = FALSE; + } + if (_sez_da_stamp == '2') + setta_righe_studio(""); + if (_sez_da_stamp == '9') + set_auto_ff(TRUE); + } + else + { + if (!_tabivd->eof()) + setta_righe_studio(""); + } + } + else if (_liv == 'D') + { + if (_sez_da_stamp != _sez_stamp) + { + if ((_sez_da_stamp=='1')||((_sez_da_stamp=='2')&&(_statopatr_no_stamp))) + { + setta_righe_ditta ("STATO PATRIMONIALE"); + _statopatr_no_stamp = FALSE; + } + if (_sez_da_stamp == '2') + setta_righe_ditta(""); + if ((_sez_da_stamp == '5') || (_sez_da_stamp == '9')) + set_auto_ff(TRUE); + } + else + { + if (_buff != NULL) + setta_righe_ditta(""); + } + } +} + +void BA3800_application::setta_righe_studio(const char * titolo) +{ + int numeror, numero; + TString numrom; + TString descr_let,descr_numr,descr_num; + bool stampa_classe = TRUE; + TString lettera = "@1g)@3g%s"; + TString lettera2 = "@3g%s"; + TString numr = "@12g-@14g%s"; + TString numr2 = "@14g%s"; + TString num = "@15g)@18g%s"; + TString num2 = "@18g%s"; + numeror = atoi(_numr_da_stamp); + numrom = itor(numeror); + numero = atoi(_num_da_stamp); + + + descr_let = descrizione_lettera(_sez_da_stamp,_let_da_stamp); + descr_numr = descrizione_numeroromano(_sez_da_stamp,_let_da_stamp,numeror); + descr_num = descrizione_numero(_sez_da_stamp,_let_da_stamp,numeror,numero); + + //Se la classe prelevata dal record corrente del sort e' diversa dalla classe + //prelevata dal record precedente, allora stampo la nuova classe con i relativi + //sottoconti. In caso contrario continuo a stampare solo i sottoconti. + + if (_sez_da_stamp != _sez_stamp) + { + set_row (_i++,"@0g%s", titolo); + char app = ' '; + set_row(_i++,"@0g%c", app); + + if (_sez_da_stamp == '1') + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gATTIVO"); + set_row (_i++,"@0g%c", app); + } + else + if (_sez_da_stamp == '2') + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gPASSIVO"); + set_row(_i++,"@0g%c", app); + } + + if (stampa_classe) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9')) + { + _cont_let = 1; + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 1; + + if (_let_da_stamp != ' ') + { + set_row(_i,"@0g%c", _let_da_stamp); + _descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera,lettera2); + // set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + } + if (numrom != "") + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr,numr2); + // set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + } + if (numero != 0) + { + set_row(_i,"@13g%s", (const char*) _num_da_stamp); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + // set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + } + else + if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp)) + { + if (stampa_classe) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 1; + if (_let_da_stamp != ' ') + { + set_row(_i,"@0g%c", _let_da_stamp); + _descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera,lettera2); + // set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + } + if (numrom != "") + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + } + if (numero != 0) + { + set_row(_i,"@13g%s", (const char*) _num_da_stamp); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + } + else + if ((_numr_da_stamp!=_numr_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + _cont_num = 1; + _cont_gcs = 1; + if (numrom != "") + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + } + if (numero != 0) + { + set_row(_i,"@13g%s", (const char*) _num_da_stamp); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + else + if ((_num_da_stamp!=_num_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)&&(_numr_da_stamp==_numr_stamp)) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + set_row(_i,"@13g%s", (const char*) _num_da_stamp); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + _cont_gcs = 1; + } + } +} + +void BA3800_application::setta_righe_ditta(const char* titolo) +{ + struct bil_ivd* bil = (struct bil_ivd*) _buff; + int numeror, numero, gruppo, conto; + char sezione,lettera; + long sottoc; + TString numrom,numr; + TString descr_let,descr_numr,descr_num,descr_sottoc,descr_classe; + bool stampa_classe = TRUE; + TString lettera1 = "@1g)@3g%s"; + TString lettera2 = "@3g%s"; + TString numr1 = "@12g-@14g%s"; + TString numr2 = "@14g%s"; + TString num = "@15g)@18g%s"; + TString num2 = "@18g%s"; + + sezione = bil->sez; + lettera = bil->let; + numr = bil->numr; + // numr.ltrim(); + numeror = atoi(bil->numr); + numrom = itor(numeror); + numero = atoi(bil->num); + // num = bil->num; + gruppo = atoi(bil->gruppo); + conto = atoi(bil->conto); + sottoc = atoi(bil->sottoc); + descr_let = descrizione_lettera(sezione,lettera); + descr_numr = descrizione_numeroromano(sezione,lettera,numeror); + descr_num = descrizione_numero(sezione,lettera,numeror,numero); + descr_sottoc = descrizione_sottoconto(gruppo,conto,sottoc); + + //Se la classe prelevata dal record corrente del sort e' diversa dalla classe + //prelevata dal record precedente, allora stampo la nuova classe con i relativi + //sottoconti. In caso contrario continuo a stampare solo i sottoconti. + + if (_sez_da_stamp != _sez_stamp) + { + set_row (_i++,"@0g%s", titolo); + char app = ' '; + set_row(_i++,"@0g%c", app); + + if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,"@0g%c", app); + stampa_classe = FALSE; + } + else + if ((_sez_da_stamp == '1')&&(_let_da_stamp != 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gATTIVO"); + set_row (_i++,"@0g%c", app); + } + + if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row(_i++,"@0g%c", app); + stampa_classe = FALSE; + } + else + if ((_sez_da_stamp == '2')&&(_let_da_stamp != 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gPASSIVO"); + set_row(_i++,"@0g%c", app); + } + + if (stampa_classe) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp== '9')) + { + //set_row(_i++,"@0g%s", (const char*) _descr_sez); + _cont_let = 1; + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 1; + + if (lettera != ' ') + { + set_row(_i,"@0g%c", bil->let); + _descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera1,lettera2); + //set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + } + if (numrom != "") + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + } + if (numero != 0) + { + set_row(_i,"@13g%s", bil->num); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + } + else + if ((_let_da_stamp!=_let_stamp)&&(_sez_da_stamp==_sez_stamp)) + { + if ((_sez_da_stamp == '1')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row (_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE ATTIVI"); + set_row (_i++,"@0g%c", app); + stampa_classe = FALSE; + } + if ((_sez_da_stamp == '2')&&(_let_da_stamp == 'Z')) + { + char app = ' '; + set_row(_i++,"@0g%c", app); + set_row (_i++,"@0gCONTI D' ORDINE PASSIVI"); + set_row(_i++,"@0g%c", app); + stampa_classe = FALSE; + } + if (stampa_classe) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + set_row(_i,"@0g%c", bil->let); + _descr = (const char*) descr_let; + setta_righe_descr(_descr,lettera1,lettera2); + //set_row(_i++,"@1g)@3g%s", (const char*) descr_let); + //_cont_let += 1; + _cont_numr = 1; + _cont_num = 1; + _cont_gcs = 1; + + if (numrom != "") + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + } + if (numero != 0) + { + set_row(_i,"@13g%s", bil->num); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + } + else + if ((_numr_da_stamp!=_numr_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + set_row(_i,"@3g%8s", (const char*) numrom); + _descr = (const char*) descr_numr; + setta_righe_descr(_descr,numr1,numr2); + //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); + //_cont_numr += 1; + //_cont_numr = 1; + _cont_num = 1; + _cont_gcs = 1; + + if (numero != 0) + { + set_row(_i,"@13g%s", bil->num); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + } + } + } + else + if ((_num_da_stamp!=_num_stamp)&&(_sez_da_stamp==_sez_stamp)&&(_let_da_stamp==_let_stamp)&&(_numr_da_stamp==_numr_stamp)) + { + if ((_sez_da_stamp=='1')||(_sez_da_stamp=='2')||(_sez_da_stamp=='9')) + { + set_row(_i,"@13g%s", bil->num); + _descr = (const char*) descr_num; + setta_righe_descr(_descr,num,num2); + //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); + //_cont_num += 1; + _cont_gcs = 1; + } + } + if (bil->gruppo[0] != 'Z') + { + _cont_gcs += 1; + set_row (_i,"@18g%s", bil->gruppo); + set_row (_i,"@22g%s", bil->conto); + set_row (_i,"@26g%s", bil->sottoc); + set_row (_i,"@33g%s", (const char*) descr_sottoc); + set_row (_i,"@86g%s", (const char*) _totale); + _i++; + } +} + +void BA3800_application::setta_righe_descr(TParagraph_string& str,const TString& formato,const TString& formato2) +{ + const char* r; + int i = 1; + + while ((r = str.get()) != NULL) + { + if (i == 1) + set_row (_i,formato, r); + else + if (i > 1) + set_row (_i,formato2,r); + _i++; + i++; + } +} + +void BA3800_application::intestazione_ditta() +{ + TString datastampastr; + TString sep(132),sep1(147); + + TString app(8); + TLocalisamfile nditte (LF_NDITTE); + TLocalisamfile comuni (LF_COMUNI); + TLocalisamfile unloc (LF_UNLOC); + TLocalisamfile anag (LF_ANAG); + TString codice_ditta,ragsoc,indulc,civulc,capulc,com,prov,comulc; + TString cofi,paiv,tipoa,codanagr; + + reset_header(); + + nditte.setkey(1); + codice_ditta << get_firm(); + nditte.zero(); + nditte.put(NDT_CODDITTA,codice_ditta); + nditte.read(); + app = nditte.get(NDT_CODDITTA); + ragsoc = nditte.get(NDT_RAGSOC); + tipoa = nditte.get(NDT_TIPOA); + codanagr = nditte.get(NDT_CODANAGR); + + unloc.setkey(1); + unloc.zero(); + unloc.put(ULC_CODDITTA,app); + unloc.put(ULC_CODULC,"1"); + unloc.read(); + indulc = unloc.get(ULC_INDULC); + civulc = unloc.get(ULC_CIVULC); + capulc = unloc.get(ULC_CAPULC); + comulc = unloc.get(ULC_COMULC); + + comuni.setkey(1); + comuni.zero(); + comuni.put(COM_COM,comulc); + comuni.read(); + com = comuni.get(COM_DENCOM); + prov = comuni.get(COM_PROVCOM); + + anag.setkey(2); + anag.zero(); + anag.put(ANA_TIPOA,tipoa); + anag.put(ANA_CODANAGR,codanagr); + anag.read(); + cofi = anag.curr().get(ANA_COFI); + paiv = anag.curr().get(ANA_PAIV); + + set_header (1, "@0gDITTA@6g%-5s", (const char*) codice_ditta); + set_header (1, "@12g%-45s", (const char*) ragsoc); + set_header (1, "@59g%-25s", (const char*) indulc); + set_header (1, "@86g%-9s", (const char*) civulc); + set_header (1, "@97g%-5s", (const char*) capulc); + set_header (1, "@103g%-25s", (const char*) com); + set_header (1, "@129g%-3s", (const char*) prov); + + sep << "Pag. @#"; + sep.right_just(132); + set_header(2,(const char*) sep); + + datastampastr = _datastampa.string(); + + set_header (2,"@0gPartita iva@12g%-11s", (const char*) paiv); + set_header (2,"@30gCodice fiscale@45g%-16s", (const char*) cofi); + set_header (2,"@105gData@110g%s",(const char*) datastampastr); + set_header (3,"@0gSTAMPA TABELLA IV DIRETTIVA"); + + sep.fill('-'); //Stampa 132 - (sep(132)) + set_header (4, (const char *) sep); +} + +void BA3800_application::intestazione_studio() +{ + TString sep(132); + TString datastampastr; + + reset_header(); + + sep << "Pag. @#"; + sep.right_just(132); + set_header(1,(const char*) sep); + + set_header (1,"@0gStudio"); + //set_header (1,"Nome dello studio"); + + datastampastr = _datastampa.string(); + + set_header (1,"@105gData@110g%s",(const char*) datastampastr); + set_header (2,"@0gSTAMPA TABELLA IV DIRETTIVA"); + + sep.fill('-'); //Stampa 132 - (sep(132)) + set_header (3, (const char *) sep); +} + +const char* BA3800_application::descrizione_lettera(char sezione, char lettera) +{ + TTable tabivd(TAB_IVD); + TString dep, dep2; + + tabivd.zero(); + dep = format("%1c%1c", sezione, lettera); + tabivd.put("CODTAB", dep); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; + return tmp; +} + +const char* BA3800_application::descrizione_numeroromano(char sezione, char lettera, int numr) +{ + TTable tabivd(TAB_IVD); + TString dep, dep2; + + tabivd.zero(); + if (numr != 0) + dep = format("%1c%1c%04d", sezione, lettera, numr); + else + dep = format("%c%c ", sezione, lettera); + + tabivd.put("CODTAB", dep); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; + return tmp; +} + +const char* BA3800_application::descrizione_numero(char sezione, char lettera, int numr, int numero) +{ + TTable tabivd(TAB_IVD); + TString dep,dep2; + + tabivd.zero(); + if (numr != 0) + dep = format("%1c%1c%04d%02d",sezione, lettera, numr, numero); + else + dep = format("%c%c %02d",sezione,lettera,numero); + tabivd.put("CODTAB", dep); + tabivd.read(); + dep2 = tabivd.get("CODTAB"); + if (dep == dep2) + tmp = tabivd.get("S0"); + else + tmp = ""; + return tmp; +} + +const char* BA3800_application::descrizione_sottoconto(int gruppo, int conto, long sottoc) +{ + TLocalisamfile pconti (LF_PCON); + + pconti.zero(); + pconti.put(PCN_GRUPPO , gruppo); + if (conto != 0) + pconti.put(PCN_CONTO , conto ); + if (sottoc != 0) + pconti.put(PCN_SOTTOCONTO, sottoc); + pconti.read(); + if (pconti.bad()) + pconti.zero(); + tmp = pconti.get(PCN_DESCR); + return tmp; +} + +void BA3800_application::init_sort() +{ + _bil = new bil_ivd; + _sort = new TSort (sizeof(bil_ivd)); + + _sort -> addsortkey ((char*)&(_bil->sez) - (char*)&(_bil->sez),1); + _sort -> addsortkey ((char*)&(_bil->let) - (char*)&(_bil->sez),1); + _sort -> addsortkey ((char*)&(_bil->numr) - (char*)&(_bil->sez),4); + _sort -> addsortkey ((char*)&(_bil->num) - (char*)&(_bil->sez),2); + _sort -> addsortkey ((char*)&(_bil->gruppo) - (char*)&(_bil->sez),3); + _sort -> addsortkey ((char*)&(_bil->conto) - (char*)&(_bil->sez),3); + _sort -> addsortkey ((char*)&(_bil->sottoc) - (char*)&(_bil->sez),6); + _sort->init(); +} + +void BA3800_application::user_create() +{ + _nditte = new TLocalisamfile (LF_NDITTE); + _comuni = new TLocalisamfile (LF_COMUNI); + _unloc = new TLocalisamfile (LF_UNLOC); + _anag = new TLocalisamfile (LF_ANAG); + _pconti = new TLocalisamfile (LF_PCON); + _clifo = new TLocalisamfile (LF_CLIFO); + + _tabivd = new TTable (TAB_IVD); +} + +void BA3800_application::user_destroy() +{ + delete _tabivd; + delete _nditte; + delete _comuni; + delete _unloc; + delete _anag; + delete _pconti; + delete _clifo; +} + +int ba3800 (int argc, char* argv[]) +{ + BA3800_application a(*argv[2]); + a.run(argc, argv, "Stampa Tabella IV Direttiva CEE"); + return 0; +} + + + +======= #include #include #include @@ -1846,3 +3682,4 @@ int ba3800 (int argc, char* argv[]) +>>>>>>> 1.2 diff --git a/ba/prassi.mnu b/ba/prassi.mnu index 8a0e0d861..aa4f480ca 100755 --- a/ba/prassi.mnu +++ b/ba/prassi.mnu @@ -73,7 +73,7 @@ 6|Codici Attivita'|ba3 -1 %ais 6|Libri sociali|ba3 -1 %itl 6|Banche|ba3 -1 %ban -6|IV direttiva CEE|ba3 -1 %ivd +6|IV direttiva CEE|ba3 -7 6|Valute|ba3 -1 %val 6|Lingue|ba3 -1 %lng 7|Tabelle ditta|2