diff --git a/ba/ba0.cpp b/ba/ba0.cpp index 8a5ebcde6..08ef6cd7a 100755 --- a/ba/ba0.cpp +++ b/ba/ba0.cpp @@ -315,6 +315,7 @@ bool TMenu_application::create() return TRUE; } + bool TMenu_application::menu(MENU_TAG) { int refarray[256]; @@ -330,31 +331,30 @@ bool TMenu_application::menu(MENU_TAG) { TToken_string& row = (TToken_string&)_menu[m]; const TFilename option(row.get(2)); + if (option.not_empty()) { + bool ok = TRUE; const int l = atoi(option); if (l > 0) { - const char* flags = row.get(); - if (flags && strchr(flags, 'F') != NULL) + const TString16 flags(row.get()); + if (flags.find('F') >= 0) + _ditta_asked = ok = set_firm(); + if (ok) { - set_firm(); - _ditta_asked = TRUE; + refarray[i++] = _level; + if (l < _max) _level = l; } - refarray[i++] = _level; - if (l < _max) _level = l; } else - { + { TExternal_app a(option); const TString& module = option.left(2); if (module == "ba") _ditta_asked = FALSE; else if (module == "cg" && !_ditta_asked) - { - set_firm(); - _ditta_asked = TRUE; - } - a.run(); + _ditta_asked = ok = set_firm(); + if (ok) a.run(); } } } diff --git a/ba/ba3800.cpp b/ba/ba3800.cpp index 6d4b911d7..eba827e81 100755 --- a/ba/ba3800.cpp +++ b/ba/ba3800.cpp @@ -1,26 +1,23 @@ -<<<<<<< ba3800.cpp -#include #include #include +#include #include #include -#include #include +#include +#include -#include -#include #include #include -#include #include +#include +#include +#include #include "ba3.h" +#include "ba3800.h" -//#include "ba3800.h" -const char* const TAB_IVD = "%ivd"; -#define F_DATASTAMPA 101 - -static TString256 tmp; +TString256 tmp; class BA3800_application : public TPrintapp { @@ -106,1844 +103,6 @@ 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "ba3.h" -#include "ba3800.h" - -extern char __tmp [MAXSTR]; -static TFixed_string tmp(__tmp, MAXSTR); - -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; - TMask* _msk; - 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, _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(const char* livello) : _liv(livello) {} -}; - -void BA3800_application::postclose_print() -{ - if (_liv == "DITTA") - delete _sort; -} void BA3800_application::set_bil_key(bil_ivd* b, char sezione, char lettera, const char* numero_romano, int numero, @@ -1969,9 +128,9 @@ void BA3800_application::set_bil_key(bil_ivd* b, char sezione, char lettera, else if (gruppo == 0) { - strcpy(b->gruppo, "AAA"); - strcpy(b->conto, "AAA"); - strcpy(b->sottoc, "AAAAAA"); + strcpy(b->gruppo, " "); + strcpy(b->conto, " "); + strcpy(b->sottoc, " "); } else { @@ -2150,14 +309,14 @@ void BA3800_application::crea_sort_piano_conti() } bool BA3800_application::set_print(int) -{ - KEY tasto; +{ + TMask msk("ba3800a"); - tasto = _msk->run(); + const KEY tasto= msk.run(); if (tasto == K_ENTER) { - _datastampa = (_msk->get(F_DATASTAMPA)); + _datastampa = msk.get(F_DATASTAMPA); _cont_let = 0; _cont_numr = 0; @@ -2184,12 +343,10 @@ bool BA3800_application::set_print(int) _sbilancio_patr_gia_stampato = FALSE; _attivo_o_passivo = FALSE; - _liv.upper(); - - if (_liv == "STUDIO") + if (_liv == 'S') intestazione_studio(); else - if (_liv == "DITTA") + if (_liv == 'D') { init_sort(); crea_sort_tabella(); @@ -2826,7 +983,7 @@ void BA3800_application::stampa_totali_ditta() print_action BA3800_application::postprocess_page(int file, int counter) { - if (_liv == "STUDIO") + if (_liv == 'S') { if (_sez_da_stamp != _sez_stamp) { @@ -2845,7 +1002,7 @@ print_action BA3800_application::postprocess_page(int file, int counter) return NEXT_PAGE; } else - if (_liv == "DITTA") + if (_liv == 'D') { struct bil_ivd* bil = (struct bil_ivd*) _buff; @@ -2880,14 +1037,14 @@ print_action BA3800_application::postprocess_page(int file, int counter) bool BA3800_application::preprocess_page(int file, int counter) { - if (_liv == "STUDIO") + if (_liv == 'S') { if (preprocess_studio(counter)) return TRUE; else return FALSE; } - else if (_liv == "DITTA") + else if (_liv == 'D') { if (preprocess_ditta(counter)) return TRUE; @@ -3038,7 +1195,7 @@ bool BA3800_application::preprocess_ditta(int counter) void BA3800_application::set_page(int file, int counter) { - if (_liv == "STUDIO") + if (_liv == 'S') { if (_sez_da_stamp != _sez_stamp) { @@ -3058,7 +1215,7 @@ void BA3800_application::set_page(int file, int counter) setta_righe_studio(""); } } - else if (_liv == "DITTA") + else if (_liv == 'D') { if (_sez_da_stamp != _sez_stamp) { @@ -3139,21 +1296,21 @@ void BA3800_application::setta_righe_studio(const char * titolo) if (_let_da_stamp != ' ') { set_row(_i,"@0g%c", _let_da_stamp); - *_descr = (const char*) descr_let; + _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; + _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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); // set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3173,21 +1330,21 @@ void BA3800_application::setta_righe_studio(const char * titolo) if (_let_da_stamp != ' ') { set_row(_i,"@0g%c", _let_da_stamp); - *_descr = (const char*) descr_let; + _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; + _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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3204,14 +1361,14 @@ void BA3800_application::setta_righe_studio(const char * titolo) if (numrom != "") { set_row(_i,"@3g%8s", (const char*) numrom); - *_descr = (const char*) descr_numr; + _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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3223,7 +1380,7 @@ void BA3800_application::setta_righe_studio(const char * titolo) 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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); _cont_gcs = 1; @@ -3320,21 +1477,21 @@ void BA3800_application::setta_righe_ditta(const char* titolo) if (lettera != ' ') { set_row(_i,"@0g%c", bil->let); - *_descr = (const char*) descr_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; + _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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3365,7 +1522,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) 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; + _descr = (const char*) descr_let; setta_righe_descr(_descr,lettera1,lettera2); //set_row(_i++,"@1g)@3g%s", (const char*) descr_let); //_cont_let += 1; @@ -3376,14 +1533,14 @@ void BA3800_application::setta_righe_ditta(const char* titolo) if (numrom != "") { set_row(_i,"@3g%8s", (const char*) numrom); - *_descr = (const char*) descr_numr; + _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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3396,7 +1553,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) 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; + _descr = (const char*) descr_numr; setta_righe_descr(_descr,numr1,numr2); //set_row(_i++,"@12g-@14g%s", (const char*) descr_numr); //_cont_numr += 1; @@ -3407,7 +1564,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) if (numero != 0) { set_row(_i,"@13g%s", bil->num); - *_descr = (const char*) descr_num; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); } @@ -3419,7 +1576,7 @@ void BA3800_application::setta_righe_ditta(const char* titolo) 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; + _descr = (const char*) descr_num; setta_righe_descr(_descr,num,num2); //set_row(_i++,"@15g)@18g%s", (const char*) descr_num); //_cont_num += 1; @@ -3438,12 +1595,12 @@ void BA3800_application::setta_righe_ditta(const char* titolo) } } -void BA3800_application::setta_righe_descr(TParagraph_string* str,const TString& formato,const TString& formato2) +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) + while ((r = str.get()) != NULL) { if (i == 1) set_row (_i,formato, r); @@ -3565,7 +1722,7 @@ const char* BA3800_application::descrizione_lettera(char sezione, char lettera) tmp = tabivd.get("S0"); else tmp = ""; - return (__tmp); + return tmp; } const char* BA3800_application::descrizione_numeroromano(char sezione, char lettera, int numr) @@ -3586,7 +1743,7 @@ const char* BA3800_application::descrizione_numeroromano(char sezione, char lett tmp = tabivd.get("S0"); else tmp = ""; - return (__tmp); + return tmp; } const char* BA3800_application::descrizione_numero(char sezione, char lettera, int numr, int numero) @@ -3606,7 +1763,7 @@ const char* BA3800_application::descrizione_numero(char sezione, char lettera, i tmp = tabivd.get("S0"); else tmp = ""; - return (__tmp); + return tmp; } const char* BA3800_application::descrizione_sottoconto(int gruppo, int conto, long sottoc) @@ -3623,7 +1780,7 @@ const char* BA3800_application::descrizione_sottoconto(int gruppo, int conto, lo if (pconti.bad()) pconti.zero(); tmp = pconti.get(PCN_DESCR); - return (__tmp); + return tmp; } void BA3800_application::init_sort() @@ -3651,16 +1808,10 @@ void BA3800_application::user_create() _clifo = new TLocalisamfile (LF_CLIFO); _tabivd = new TTable (TAB_IVD); - - _descr = new TParagraph_string ("",40); - - _msk = new TMask("ba3800a"); } void BA3800_application::user_destroy() { - delete _msk; - delete _tabivd; delete _nditte; delete _comuni; @@ -3668,18 +1819,14 @@ void BA3800_application::user_destroy() delete _anag; delete _pconti; delete _clifo; - delete _descr; } int ba3800 (int argc, char* argv[]) { - BA3800_application a(argv[2]); + BA3800_application a(*argv[2]); a.run(argc, argv, "Stampa Tabella IV Direttiva CEE"); return 0; } - - ->>>>>>> 1.2