diff --git a/m770/771100.cpp b/m770/771100.cpp index ece441413..9506366f4 100755 --- a/m770/771100.cpp +++ b/m770/771100.cpp @@ -42,7 +42,8 @@ class TDati_anagrafici : public TApplication static bool fisica_handler(TMask_field&, KEY); static bool giuridica_handler(TMask_field&, KEY); static bool anagrafica_handler(TMask_field&, KEY); - static bool anagr_dich_handler(TMask_field&, KEY); + static bool anagr_dich_handler(TMask_field&, KEY); + // bottone ditta in DatiCAAF static bool DCditta_handler(TMask_field&, KEY); TMask* _msk; @@ -94,6 +95,7 @@ TDati_anagrafici::TDati_anagrafici(char anagrafica) : _titolo(50), _ana(toupper( HIDDEN TDati_anagrafici& app() { return (TDati_anagrafici &) main_app(); } + bool TDati_anagrafici::codditta_hnd(TMask_field& f, KEY k) { if (k == K_TAB && !(f.mask().is_running()) ) @@ -124,15 +126,15 @@ bool TDati_anagrafici::attivita_handler(TMask_field& m, KEY k) body << "1" << "|"; body << m.mask().get(F_CODDITTA) << "|"; -// body << m.mask().get(F_ATTIV) << "|"; -// body << m.mask().get(F_ATTIV); + body << m.mask().get(F_ATTIV) << "|"; + body << m.mask().get(F_ATTIV); - TMessage msg(cmd2name(appname), MSG_LN, (const char*) body); - - TMailbox mb; - mb.send(msg); + TMessage msg(appname, MSG_LN, (const char*) body); + msg.send(); + TExternal_app a(appname); - a.run(); + a.run(); + m.set_focus(); xvt_statbar_set(""); @@ -154,7 +156,7 @@ bool TDati_anagrafici::DCditta_handler(TMask_field& f, KEY k) body.add(lDittaCaaf); // ditta per il campo codice ditta body.add(lDittaCaaf); // ditta per il secondo campo codice ditta TString16 cmd("ba4 -2"); - TMessage msg(cmd2name(cmd), MSG_LN, (const char*) body); + TMessage msg(cmd, MSG_LN, (const char*) body); msg.send(); TExternal_app a(cmd); a.run(); @@ -512,15 +514,19 @@ bool TDati_anagrafici::create() if (Rappresentante()) { _msk = new TMask ("771100c"); - _msk->set_handler(F_FISICA, fisica_handler); + _msk->set_handler(F_FISICA, fisica_handler); + } if (ScrittureContabili()) { _msk = new TMask ("771100d"); - _msk->set_handler(F_ANAGR, indirizzo); - _msk->set_handler(F_ATTIVITA, attivita_handler); - _msk->set_handler(F_ANAGRAFICA, anagrafica_handler); + _msk->set_handler(F_ANAGR, indirizzo); + _msk->set_handler(F_ATTIVITA, attivita_handler); + _msk->set_handler(F_FISICA, anagrafica_handler); + _msk->set_handler(F_GIURIDICA,anagrafica_handler); + _msk->disable(DLG_SAVEREC); + _msk->disable(DLG_CANCEL); } if (DatiCAAF()) @@ -528,8 +534,7 @@ bool TDati_anagrafici::create() _msk = new TMask ("771100e"); _msk->set_handler(F_ANAGR, niscraa); _msk->set_handler(F_GIURIDICA, giuridica_handler); - _msk->set_handler(F_DITTACAAF, ditta_caaf); -// bottone ditte + _msk->set_handler(F_DITTACAAF, ditta_caaf); _msk->set_handler(DCF_DITTA, DCditta_handler); } @@ -574,7 +579,12 @@ bool TDati_anagrafici::main_loop() { _rel->lfile().put("CODDITTA", _codditta); _rel->read(); - _msk->autoload(*_rel); + _msk->autoload(*_rel); + + // controllo se indicato rappresentante + if (Rappresentante() && (_msk->get_long(F_ANAGR) == 0L)) + message_box("Il rappresentante non e' stato indicato."); + tasto = _msk->run(); switch (tasto) diff --git a/m770/771100.h b/m770/771100.h index 77dcac0b7..9cfd646b5 100755 --- a/m770/771100.h +++ b/m770/771100.h @@ -65,8 +65,7 @@ #define F_PROVCS 261 #define F_PTELCS 262 #define F_TELCS 263 -#define F_ATTIVITA 264 -#define F_ANAGRAFICA 265 +#define F_ATTIVITA 264 // Campi maschera dati CAAF 771100e.uml diff --git a/m770/771100c.uml b/m770/771100c.uml index c41588755..154ed32fd 100755 --- a/m770/771100c.uml +++ b/m770/771100c.uml @@ -1,22 +1,16 @@ // 771100c.uml - Dati rappresentante #include "771100.h" -// -// Lista modifiche -// -// 2.4.96 Aggiunto numero di telefono -// - TOOLBAR "" 0 20 0 2 BUTTON F_FISICA 10 2 BEGIN - PROMPT -14 -1 "~Fisiche" + PROMPT -14 -1 "F~isiche" END BUTTON DLG_SAVEREC 10 2 BEGIN -PROMPT -24 -1 "" +PROMPT -24 -1 "~Registra" MESSAGE EXIT,K_SAVE PICTURE BMP_SAVEREC PICTURE BMP_SAVERECDN @@ -36,7 +30,7 @@ END ENDPAGE -PAGE "Dati relativi al rappresentante" -1 -1 78 18 +PAGE "Rappresentante" -1 -1 78 18 GROUPBOX DLG_NULL 78 4 BEGIN @@ -64,11 +58,10 @@ END NUMBER F_ANAGR 5 BEGIN PROMPT 1 4 "Codice rappresentante " - FLAGS "D" - USE LF_NDITTE - INPUT CODDITTA F_CODDITTA - FIELD LF_NDITTE->RAPPR - CHECKTYPE NORMAL + FLAGS "D" + USE LF_NDITTE + INPUT CODDITTA F_CODDITTA + FIELD LF_NDITTE->RAPPR JOIN LF_ANAG INTO CODANAGR=RAPPR TIPOA="F" JOIN LF_ANAGFIS TO LF_ANAG INTO CODANAGR=CODANAGR JOIN LF_COMUNI TO LF_ANAGFIS INTO COM==COMNASC @@ -94,47 +87,9 @@ BEGIN OUTPUT F_DOMFISC LF_ANAG->VARSLORES OUTPUT F_ANAGR LF_ANAGFIS->CODANAGR OUTPUT F_PTELRF LF_ANAG->PTELRF - OUTPUT F_TELRF LF_ANAG->TELRF + OUTPUT F_TELRF LF_ANAG->TELRF END -/* -NUMBER F_ANAGR 5 -BEGIN - PROMPT 1 4 "Codice rappresentante " - USE LF_ANAGFIS KEY 1 - INPUT CODANAGR F_ANAGR - JOIN LF_ANAG TO LF_ANAGFIS INTO CODANAGR=CODANAGR TIPOA="F" - JOIN LF_COMUNI TO LF_ANAGFIS INTO COM==COMNASC - JOIN LF_COMUNI TO LF_ANAG ALIAS 1 INTO COM==COMRES - JOIN LF_COMUNI TO LF_ANAG ALIAS 2 INTO COM==COMRF - DISPLAY "Codice" CODANAGR - DISPLAY "Ragione Sociale@50" LF_ANAG->RAGSOC - OUTPUT F_COFI LF_ANAG->COFI - OUTPUT F_COGNOME LF_ANAG->RAGSOC[1,30] - OUTPUT F_NOME LF_ANAG->RAGSOC[31,50] - OUTPUT F_SESSO SESSO - OUTPUT F_DATANASC DATANASC - OUTPUT F_COMNASC LF_COMUNI->DENCOM - OUTPUT F_PROVNASC LF_COMUNI->PROVCOM - OUTPUT F_INDRES LF_ANAG->INDRES - OUTPUT F_CIVRES LF_ANAG->CIVRES - OUTPUT F_CAPRES LF_ANAG->CAPRES - OUTPUT F_INDRF LF_ANAG->INDRF - OUTPUT F_CIVRF LF_ANAG->CIVRF - OUTPUT F_CAPRF LF_ANAG->CAPRF - OUTPUT F_COMRES 1@->DENCOM - OUTPUT F_PROVRES 1@->PROVCOM - OUTPUT F_COMRF 2@->DENCOM - OUTPUT F_PROVRF 2@->PROVCOM - OUTPUT F_DOMFISC LF_ANAG->VARSLORES - OUTPUT F_ANAGR LF_ANAGFIS->CODANAGR - OUTPUT F_PTELRF LF_ANAG->PTELRF - OUTPUT F_TELRF LF_ANAG->TELRF - FIELD LF_BASE->RAPPR - CHECKTYPE NORMAL - FLAGS "R" -END -*/ STRING F_COFI 16 BEGIN PROMPT 1 5 "Codice fiscale " diff --git a/m770/771100d.uml b/m770/771100d.uml index a92121a1b..bd4c5cd7e 100755 --- a/m770/771100d.uml +++ b/m770/771100d.uml @@ -2,11 +2,16 @@ TOOLBAR "" 0 20 0 2 -BUTTON F_ANAGRAFICA 10 2 +BUTTON F_FISICA 10 2 BEGIN - PROMPT -15 -1 "~Anagrafica" + PROMPT -15 -1 "F~isiche" END - + +BUTTON F_GIURIDICA 10 2 +BEGIN + PROMPT -15 -1 "~Giuridiche" +END + BUTTON F_ATTIVITA 10 2 BEGIN PROMPT -25 -1 "~Attività" @@ -81,7 +86,9 @@ LIST ASCF_TIPOA 9 BEGIN PROMPT 1 5 "Tipo persona " ITEMS "G|Societa'" + MESSAGE HIDE,F_FISICA|SHOW,F_GIURIDICA ITEMS "F|Fisica" + MESSAGE SHOW,F_FISICA|HIDE,F_GIURIDICA FLAGS "D" END diff --git a/m770/771100g.uml b/m770/771100g.uml index ca4c09f08..e0c943f20 100755 --- a/m770/771100g.uml +++ b/m770/771100g.uml @@ -8,14 +8,15 @@ BUTTON F_BTN_GIURIDICA 10 2 BEGIN PROMPT -14 -1 "~Giuridiche" END + BUTTON F_BTN_FISICA 10 2 BEGIN -PROMPT -14 -1 "~Fisiche" +PROMPT -14 -1 "F~isiche" END BUTTON DLG_SAVEREC 10 2 BEGIN -PROMPT -24 -1 "" +PROMPT -24 -1 "~Registra" MESSAGE EXIT,K_SAVE PICTURE BMP_SAVEREC PICTURE BMP_SAVERECDN diff --git a/m770/771230e.uml b/m770/771230e.uml index b163b157d..7ae1e81d7 100755 --- a/m770/771230e.uml +++ b/m770/771230e.uml @@ -21,7 +21,7 @@ END NUMBER F_CODDITTA 5 BEGIN PROMPT 3 1 "Ditta " - FLAGS "GRD" + FLAGS "GRDP" KEY 1 CHECKTYPE REQUIRED USE LF_NDITTE KEY 1 @@ -33,13 +33,13 @@ END STRING F_RAGDITTA 50 BEGIN PROMPT 17 1 "Ragione " - FLAGS "D" + FLAGS "DP" END NUMBER F_ANNODIC 4 BEGIN PROMPT 52 3 "Anno dichiarazione " - FLAGS "DR" + FLAGS "DRP" END TEXT DLG_NULL diff --git a/m770/771230i.uml b/m770/771230i.uml index f898d0127..9c16b517d 100755 --- a/m770/771230i.uml +++ b/m770/771230i.uml @@ -27,7 +27,7 @@ END NUMBER F_CODDITTA 5 BEGIN PROMPT 3 1 "Ditta " - FLAGS "GRD" + FLAGS "GRDP" KEY 1 CHECKTYPE REQUIRED USE LF_NDITTE KEY 1 @@ -39,13 +39,13 @@ END STRING F_RAGDITTA 50 BEGIN PROMPT 17 1 "Ragione " - FLAGS "D" + FLAGS "DP" END NUMBER F_ANNODIC 4 BEGIN PROMPT 52 3 "Anno dichiarazione " - FLAGS "DR" + FLAGS "DRP" END TEXT DLG_NULL @@ -103,7 +103,7 @@ END NUMBER F_CODANAGRCOM 5 BEGIN - PROMPT 15 8 "" + PROMPT 16 8 "" USE LF_ANAG INPUT TIPOA F_TIPOA SELECT INPUT CODANAGR F_CODANAGRCOM diff --git a/m770/771230m.uml b/m770/771230m.uml index 05a68172c..fdf19ee76 100755 --- a/m770/771230m.uml +++ b/m770/771230m.uml @@ -13,7 +13,7 @@ END NUMBER PE1F_CODDITTA 5 BEGIN PROMPT 3 1 "Ditta " - FLAGS "GRD" + FLAGS "GRDP" KEY 1 CHECKTYPE REQUIRED USE LF_NDITTE KEY 1 @@ -25,7 +25,7 @@ END STRING PE1F_RAGDITTA 50 BEGIN PROMPT 17 1 "Ragione " - FLAGS "D" + FLAGS "DP" END STRING PE1F_CODCAUS 2 diff --git a/m770/771231.cpp b/m770/771231.cpp index 7b59d7296..0c172373e 100755 --- a/m770/771231.cpp +++ b/m770/771231.cpp @@ -88,8 +88,7 @@ class TQuadroF : public TRelation_application void init_mask (TMask&); void fill_ss(TMask& m); void riempi_prospetto(TMask& m, const char prosp); - int re_write(const TMask& m, bool re); - int elimina(); + int re_write(const TMask& m, bool re); public: TString16 _quadro, _aliq_caus; @@ -162,7 +161,7 @@ void TQuadroF::init_insert_mode (TMask& m) void TQuadroF::init_modify_mode (TMask& m) { - m.disable(DLG_DELREC); // disabilito Elimina nella toolbar +// m.disable(DLG_DELREC); // disabilito Elimina nella toolbar } void TQuadroF::init_query_mode (TMask& m) @@ -656,43 +655,27 @@ int TQuadroF::re_write(const TMask& m, bool re) } else return err_b; -} - -int TQuadroF::elimina() -{ - int err; - - // eliminazione righe del quadro - TRectype& recrf = _rf->curr(); - recrf.zero(); - recrf.put("CODDITTA",_codditta); - _rf->setkey(1); - for (err = _rf->read(_isequal, _lock); // stato iniziale - err == NOERR; // condizione di uscita - err = _rf->read(_isequal, _lock)) // incremento - { - _rf->remove(); // eliminazione riga quadro - } - if (err == _iskeynotfound) - _rf->reread(); - return err; } bool TQuadroF::remove() { bool ok, ok_a, ok_b, ok_c, ok_d; ok = TRelation_application::remove(); - ok_b = _prosp_b->remove(); + ok_b = _prosp_b->remove() == NOERR; + _prosp_b->destroy_rows(); if (_quadro == "F") { - ok_a = _prosp_a->remove(); - ok_c = _prosp_c->remove(); - ok_d = _prosp_d->remove(); - return ok && ok_a && ok_b && ok_c && ok_d; + ok_a = _prosp_a->remove() == NOERR; + _prosp_a->destroy_rows(); + ok_c = _prosp_c->remove() == NOERR; + _prosp_c->destroy_rows(); + ok_d = _prosp_d->remove() == NOERR; + _prosp_d->destroy_rows(); + return _registra = ok && ok_a && ok_b && ok_c && ok_d; } else - return ok && ok_b; + return _registra = ok && ok_b; } bool TQuadroF::a_notify(TSheet_field& s, int r, KEY k) diff --git a/m770/771232.cpp b/m770/771232.cpp index 99034b318..c1d4429bb 100755 --- a/m770/771232.cpp +++ b/m770/771232.cpp @@ -128,7 +128,7 @@ void TQuadroG::init_insert_mode (TMask& m) void TQuadroG::init_modify_mode (TMask& m) { - m.disable(DLG_DELREC); + } void TQuadroG::init_query_mode (TMask& m) @@ -303,6 +303,7 @@ bool TQuadroG::user_create() _msk->disable(DLG_DELREC); // disabilito Elimina nella toolbar _msk->disable(DLG_FINDREC); // disabilito Ricerca nella toolbar _msk->set_handler(DLG_DISTINTA, exec_distinta); + _msk->set_handler(mainmsk_handler); TSheet_field& p1 = (TSheet_field&) _msk->field(F_P1); p1.set_notify(p1_notify); p1.sheet_mask().set_handler(NUM_AZ, calc_amm); @@ -670,8 +671,8 @@ int TQuadroG::rewrite(const TMask& m) bool TQuadroG::remove() { - const bool ok = TRelation_application::remove(); - return ok; + _registra = TRelation_application::remove(); + return _registra; } bool TQuadroG::p1_notify(TSheet_field& s, int r, KEY k) @@ -773,3 +774,12 @@ bool TQuadroG::pIII_notify(TSheet_field& s, int r, KEY k) return TRUE; } +bool TQuadroG::mainmsk_handler(TMask& m, KEY k) +{ + if (k == K_ESC) + { + TOperable_field& f = m.focus_field(); + m.set_focus_field(f.dlg()); + } + return TRUE; +} \ No newline at end of file diff --git a/m770/771232.h b/m770/771232.h index 8fb0f6a47..27031bd42 100755 --- a/m770/771232.h +++ b/m770/771232.h @@ -31,7 +31,8 @@ class TQuadroG : public TRelation_application static bool pIII_notify(TSheet_field& s, int r, KEY k); static bool calc_amm(TMask_field& f, KEY k); static bool exec_distinta(TMask_field& f, KEY k); - static void update_totals(TSheet_field& f, int ss); + static void update_totals(TSheet_field& f, int ss); + static bool mainmsk_handler(TMask& m, KEY k); protected: virtual bool user_create(); virtual bool user_destroy(); @@ -113,8 +114,9 @@ class TQuadroG1 : public TRelation_application TString16 _quadro; TString80 _title; bool _registra; - static bool p1_notify(TSheet_field& s, int r, KEY k); - static void update_totals(TSheet_field& f); + static bool p1_notify(TSheet_field& s, int r, KEY k); + static void update_totals(TSheet_field& f); + static bool mainmsk_handler(TMask& m, KEY k); protected: virtual bool user_create(); virtual bool user_destroy(); diff --git a/m770/771234a.h b/m770/771234a.h index e252965f0..ba4c955ba 100755 --- a/m770/771234a.h +++ b/m770/771234a.h @@ -188,4 +188,4 @@ #define F_DATADELIB 293 #define F_DATADISTR 294 - +#define DLG_AZZERA 295 diff --git a/m770/771234b.uml b/m770/771234b.uml index 8f614e587..52a24c380 100755 --- a/m770/771234b.uml +++ b/m770/771234b.uml @@ -50,9 +50,9 @@ BEGIN PROMPT -23 -1 "" END -BUTTON DLG_NULL 9 2 +BUTTON DLG_AZZERA 9 2 BEGIN - PROMPT -33 -1 "Azzera" + PROMPT -33 -1 "A~zzera" MESSAGE RESET,1@ END diff --git a/m770/771234c.uml b/m770/771234c.uml index d28507d32..2cac5834a 100755 --- a/m770/771234c.uml +++ b/m770/771234c.uml @@ -53,9 +53,9 @@ BEGIN PROMPT -23 -1 "" END -BUTTON DLG_NULL 9 2 +BUTTON DLG_AZZERA 9 2 BEGIN - PROMPT -33 -1 "Azzera" + PROMPT -33 -1 "A~zzera" MESSAGE RESET,1@ END diff --git a/m770/774200.cpp b/m770/774200.cpp index 681ba1e38..8d9ebf5c9 100755 --- a/m770/774200.cpp +++ b/m770/774200.cpp @@ -1,2209 +1,2205 @@ -// 774200.cpp - Calcolo riporti dei Quadri -// -// Per l'interfaccia vedere 774200.h. -// Il metodo pubblico che fa tutto il lavoro dalla gestione di -// un singolo quadro e' set(). -// -// 774 -1 D : riporto sul quadro I del dichiarante -// -// 774 -1 S : livello di studio oppure -// richiamare la funzione set all' interno -// di ogni programma di gestione quadri. -// -// ATTENZIONE: -// Se si aggiungono o tolgono quadri in build_fill_string() -// bisogna cambiare il numero dei quadri. -// -// 15.3.96 Allungata la stringa QCOMP per far spazio ai quadri A1-2-3 -// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "774200.h" -#include "quadroa.h" -#include "quadroa3.h" -#include "quadrob.h" -#include "quadrob1.h" -#include "dipend.h" -#include "quadroh.h" -#include "quadroc.h" -#include "quadrod.h" -#include "quadrod1.h" -#include "quadroe.h" -#include "quadroe1.h" -#include "prospe1.h" -#include "quadroe2.h" -#include "quadrif.h" -#include "quadrog.h" -#include "quadrogd.h" -#include "quadrog1.h" -#include "774200a.h" -#include "77lib.h" - -// Costanti -#define TIPOQUA "TIPOQUA" - -// NB Tutte da spostare in lffiles -#define LF_RIGHEF2 100 -#define LF_RIGHEF1 99 -#define LF_RIGHEF 98 -#define LF_QUAGD 101 - -// inizializzato in TRiporti::set() - usato in filter_func() -HIDDEN TRiporti* this_riporti = NULL; - -HIDDEN TString80 __tmp; - -// Costanti usate per il calcolo dei fogli compilati -HIDDEN const int QE2_FISICHE_PER_FOGLIO = 16; -HIDDEN const int QE2_NOFISICHE_PER_FOGLIO = 9; -HIDDEN const int QGD_FISICHE_PER_FOGLIO = 5; -HIDDEN const int QGD_NOFISICHE_PER_FOGLIO = 6; -HIDDEN const int QD1_FISICHE_PER_FOGLIO = 24; -HIDDEN const int QD1_NOFISICHE_PER_FOGLIO = 8; -HIDDEN const int QD_FISICHE_PER_FOGLIO = 18; -HIDDEN const int QD_NOFISICHE_PER_FOGLIO = 6; -HIDDEN const int QE_FISICHE_PER_FOGLIO = 26; -HIDDEN const int QE_NOFISICHE_PER_FOGLIO = 8; -HIDDEN const int QE1_PERCIPIENTI_PER_FOGLIO = 25; -HIDDEN const int QE1_RIGHE_PROSPETTO = 17; - -HIDDEN long fogli_compilati(const long fisiche, const long nofisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio); -HIDDEN const char* build_fill_string(TString& qcomp); - -class TRiporta_quadri : public TApplication -{ - char _liv; - TRiporti* _riporta; - TMask* _msk; - int _anno_dic; - static bool codditta_handler(TMask_field& f, KEY k); - public: - virtual bool create(); - virtual bool menu(MENU_TAG m); - virtual bool destroy(); - - TRiporti& riporta() { return *_riporta; } - - TRiporta_quadri(char livello) : _liv(toupper(livello)) {} - ~TRiporta_quadri() {} -}; - -TRiporta_quadri& app() { return (TRiporta_quadri&)main_app(); } - -bool TRiporta_quadri::codditta_handler(TMask_field& f, KEY k) -{ - if (k == K_TAB && !(f.mask().is_running()) ) - { - TString16 codditta; - codditta << get_firm_770(); - - if (codditta != "0") - { - f.set(codditta); - f.check(); - } - } - return TRUE; -} - -bool TRiporta_quadri::menu(MENU_TAG m) -{ - if (m == BAR_ITEM(1)) - if (_liv == 'D') - { - TConfig conf(CONFIG_STUDIO); - _anno_dic = (int)conf.get_long(ANNO_SEL, NULL); - _msk->set(F_ANNODIC, _anno_dic); - KEY tast = _msk->run(); - if (tast != K_ENTER) - return FALSE; - const int annod = (int)_msk->get_long(F_ANNODIC); - _riporta->riporti_dich(get_firm_770(), annod); - message_box("Generazione riporti terminata"); - } - return FALSE; -} - -bool TRiporta_quadri::create() -{ - TApplication::create(); - _riporta = new TRiporti; - _msk = new TMask("774200a"); - _msk->set_handler(F_CODDITTA, codditta_handler); - dispatch_e_menu (BAR_ITEM(1)); - return TRUE; -} - -bool TRiporta_quadri::destroy() -{ - delete _riporta; - delete _msk; - return TApplication::destroy(); -} - -int riporti_dich(int argc, char* argv[]) -{ - TRiporta_quadri a(*argv[2]); - a.run(argc, argv, "Generazione riporti"); - return 0; -} - -const char* build_fill_string(TString& qcomp) -{ -// NB cambiare qui il numero dei quadri - const int NUM_QUADRI = 25; // sono 26 posizioni perche' parte da 0 - const int agg = NUM_QUADRI - qcomp.len(); - __tmp.cut(agg); - __tmp.fill(' ', agg); - return __tmp; -} - -void TRiporti::setta_flag_quadri_comp(const long codditta, const int quadro, const bool almeno_una_riga, TLocalisamfile& basebis, const long dich) -{ -/* - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, codditta); - if (basebis.read(_isequal, _lock) == NOERR) - { */ - TString qcomp(basebis.get(BSE_QCOMP)); - TString dep(build_fill_string(qcomp)); - qcomp << dep; - - if (almeno_una_riga) - qcomp[(int)quadro] = 'X'; - else - qcomp[(int)quadro] = ' '; - - basebis.put(BSE_QCOMP, qcomp); - basebis.rewrite(); -/* } - else - warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati"); -*/ -// -// Setta flag quadri compilati del dichiarante; cio' va fatto in 3 casi: -// -// 1. dalla gestione dei singoli quadri di una ditta "estinta". -// 2. dal prg "Riporti" del dichiarante. -// 3. dalla gestione dei quadri del dichiarante stesso. -// - const long codic = sogg_estinto(codditta); - const long ha_dichiarante = dich ? dich : codic; - const bool sono_dichiarante = sogg_dic(codditta); - - if (ha_dichiarante || sono_dichiarante) - { - const long lRecno=basebis.recno(); - basebis.setkey(1); - basebis.zero(); - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSE_CODDITTA, sono_dichiarante ? codditta : ha_dichiarante); - if (basebis.read(_isequal, _lock) == NOERR) - { - TString qcomp(basebis.get(BSE_QCOMP)); - TString dep(build_fill_string(qcomp)); - qcomp << dep; - - if (almeno_una_riga) - qcomp[(int)quadro] = 'X'; - else - qcomp[(int)quadro] = ' '; - - basebis.put(BSE_QCOMP, qcomp); - basebis.rewrite(); - basebis.readat(lRecno); - } - else - warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati"); - } -} - -void TRiporti::setta_flag_quadro_I(const long codditta, const long dich) -{ - bool compilato = FALSE; - TLocalisamfile base (LF_BASE); - TLocalisamfile basebis (LF_BASEBIS); - - base.setkey(1); - base.zero(); - base.put(BSE_CODDITTA, codditta); - base.read(_isequal, _lock); - - basebis.setkey(1); - basebis.zero(); - basebis.put(BSB_CODDITTA, codditta); - basebis.read(_isequal, _lock); - - TString qcomp(basebis.get(BSE_QCOMP)); - TString dep(build_fill_string(qcomp)); - qcomp << dep; -// TString qcomp (format("%25s", (const char*) app)); - -// I campi del quadro I sono in parte su base in parte su basebis - for (int i = 0; i < CAMPI_IB1; i++) - if (base.get_real(_campi_I1[i]) != ZERO) - { - compilato = TRUE; - break; - } - base.reread(_unlock); - - if (!compilato) - { -/* TLocalisamfile basebis (LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSB_CODDITTA, codditta); - basebis.read();*/ - for (int i = 0; i < CAMPI_IB2; i++) - if (basebis.get_real(_campi_I2[i]) != ZERO) - { - compilato = TRUE; - break; - } - } - - if (compilato) - qcomp[(int)I] = 'X'; - else - qcomp[(int)I] = ' '; - - basebis.put(BSE_QCOMP, qcomp); - basebis.rewrite(); -} - - -HIDDEN bool filter_func (const TRelation * rel) -{ - int anno,annod; - annod = this_riporti->_annodic; - anno = rel->lfile().get_int(QUH_H1ANNO); - return anno == annod; -} - -bool TRiporti::riporti_dich(const long dich, const int anno) -{ - long codditta=0L; - long codic=0L; - -// Crea il record I "globale" se non c'e' - enter_dichiar_770(dich, anno, TRUE); - - TLocalisamfile base(LF_BASE); - base.setkey(2); - base.zero(); - base.put("CODDIC", (long)dich); -// TRectype dep(base.curr()); - -// 1. Riporto dai quadri degli estinti al quadro I globale del dichiarante - for (base.read(); !base.eof(); base.next()) - { - codic = base.get_long("CODDIC"); - if (codic != dich) break; -// if (base.curr() > dep) break; - codditta = base.get_long("CODDITTA"); - if (codditta == dich) continue; // scarta il dichiarante stesso - set("*", anno, codditta, dich); - } - -// 2. Somma del quadro I "locale" del dichiarante a quello globale - riporta_I_globale(dich); - - return TRUE; -} - -bool TRiporti::riporta_I_globale(const long dich) -{ - int ret1, ret2; - long c0nfcom, c0nlass, d0nfcom, d0nlaut, d1nfcom, d1nper; - long e0nfcom, e0nper, e1nfcom, e1nper; - real h0codlav, h0coldip; - real c0snsrit, c0rope, c0actot, d0actot, d0snsrit, d0rope, d1tacor, d1snsrit; - real d1rope, e0aimp, e0snsrit, e0rope, e1scor, e1bcom, e1rope, e1acom; - real e1bcom2, e1rope2; - long cc0nfcom, cc0nlass, dd0nfcom, dd0nlaut, dd1nfcom, dd1nper; - long ee0nfcom, ee0nper, ee1nfcom, ee1nper; - real ee0snsrit, ee0rope, ee0aimp, hh0codlav, hh0coldip; - real cc0snsrit, cc0rope, cc0actot, dd0actot, dd0snsrit, dd0rope, dd1tacor; - real dd1snsrit, dd1rope; - real ee1scor, ee1bcom, ee1rope, ee1acom, ee1bcom2, ee1rope2; - - c0nfcom = c0nlass = d0nfcom = d0nlaut = d1nfcom = d1nper = 0; - e1nfcom = e1nper = 0; - - h0codlav = h0coldip = ZERO; - c0snsrit = c0rope = c0actot = d0actot = ZERO; - d0snsrit = d0rope = d1tacor = ZERO; - e1scor = e1bcom = e1rope = ZERO; - e1acom = e1bcom2 = e1rope2 = ZERO; - -// 1. Lettura quadro I "locale" del dichiarante - TLocalisamfile base(LF_BASE); - TLocalisamfile basebis(LF_BASEBIS); - base.zero(); - base.put("CODDITTA", dich); - if (base.read() != NOERR) return FALSE; - basebis.zero(); - basebis.put("CODDITTA", dich); - if (basebis.read() != NOERR) return FALSE; - - d1nfcom = base.get_int(BSE_D1NFCOM); - d1nper = base.get_int(BSE_D1NPER); - d1tacor = base.get_real(BSE_D1TACOR); - d1snsrit = base.get_real(BSE_D1SNSRIT); - d1rope = base.get_real(BSE_D1ROPE); - e1nfcom = basebis.get_int(BSB_E1NFCOM); - e1nper = basebis.get_int(BSB_E1NPER); - e1scor = basebis.get_real(BSB_E1SCOR); - e1bcom = basebis.get_real(BSB_E1BCOM); - e1rope = basebis.get_real(BSB_E1ROPE); - e1acom = basebis.get_int(BSB_E1ACOM); - e1bcom2 = basebis.get_real(BSB_E1BCOM2); - e1rope2 = basebis.get_real(BSB_E1ROPE2); - - e0nfcom = basebis.get_int(BSB_E0NFCOM); - e0nper = basebis.get_int(BSB_E0NPER); - e0aimp = basebis.get_real(BSB_E0AIMP); - e0snsrit = basebis.get_real(BSB_E0SNSRIT); - e0rope = basebis.get_real(BSB_E0ROPE); - - h0codlav = basebis.get_real(BSB_H0CODLAV); - h0coldip = basebis.get_real(BSB_H0COLDIP); - c0nfcom = base.get_int(BSE_C0NFCOM); - c0nlass = base.get_int(BSE_C0NLASS); - c0actot = base.get_real(BSE_C0ACTOT); - c0snsrit = base.get_real(BSE_C0SNSRIT); - c0rope = base.get_real(BSE_C0ROPE); - - d0nfcom = base.get_int(BSE_D0NFCOM); - d0nlaut = base.get_int(BSE_D0NLAUT); - d0actot = base.get_real(BSE_D0ACTOT); - d0snsrit = base.get_real(BSE_D0SNSRIT); - d0rope = base.get_real(BSE_D0ROPE); - -// 2. Riporto nel quadro I globale - base.zero(); -// base.setkey(2); - base.put(TIPOQUA, COD_QUA_I_DIC); - base.put("CODDITTA", (long)dich); - TRectype dep(base.curr()); - ret1 = base.read(); - if (ret1 == _iskeynotfound) - { - base.curr() = dep; - base.write(); - } - basebis.zero(); - basebis.put(TIPOQUA, COD_QUA_I_DIC); - basebis.put("CODDITTA", (long)dich); - TRectype dep2(basebis.curr()); - ret2 = basebis.read(); - if (ret2 == _iskeynotfound) - { - basebis.curr() = dep2; - basebis.write(); - } - - dd1nfcom = base.get_int(BSE_D1NFCOM); - dd1nper = base.get_int(BSE_D1NPER); - dd1tacor = base.get_real(BSE_D1TACOR); - dd1snsrit = base.get_real(BSE_D1SNSRIT); - dd1rope = base.get_real(BSE_D1ROPE); - ee1nfcom = basebis.get_int(BSB_E1NFCOM); - ee1nper = basebis.get_int(BSB_E1NPER); - ee1scor = basebis.get_real(BSB_E1SCOR); - ee1bcom = basebis.get_real(BSB_E1BCOM); - ee1rope = basebis.get_real(BSB_E1ROPE); - ee1acom = basebis.get_int(BSB_E1ACOM); - ee1bcom2 = basebis.get_real(BSB_E1BCOM2); - ee1rope2 = basebis.get_real(BSB_E1ROPE2); - - ee0nfcom = basebis.get_int(BSB_E0NFCOM); - ee0nper = basebis.get_int(BSB_E0NPER); - ee0aimp = basebis.get_real(BSB_E0AIMP); - ee0snsrit = basebis.get_real(BSB_E0SNSRIT); - ee0rope = basebis.get_real(BSB_E0ROPE); - - hh0codlav = basebis.get_real(BSB_H0CODLAV); - hh0coldip = basebis.get_real(BSB_H0COLDIP); - cc0nfcom = base.get_int(BSE_C0NFCOM); - cc0nlass = base.get_int(BSE_C0NLASS); - cc0actot = base.get_real(BSE_C0ACTOT); - cc0snsrit = base.get_real(BSE_C0SNSRIT); - cc0rope = base.get_real(BSE_C0ROPE); - - dd0nfcom = base.get_int(BSE_D0NFCOM); - dd0nlaut = base.get_int(BSE_D0NLAUT); - dd0actot = base.get_real(BSE_D0ACTOT); - dd0snsrit = base.get_real(BSE_D0SNSRIT); - dd0rope = base.get_real(BSE_D0ROPE); - - d1nfcom += dd1nfcom ; - d1nper += dd1nper ; - d1tacor += dd1tacor ; - d1snsrit += dd1snsrit ; - d1rope += dd1rope ; - e1nfcom += ee1nfcom ; - e1nper += ee1nper ; - e1scor += ee1scor ; - e1bcom += ee1bcom ; - e1rope += ee1rope ; - e1acom += ee1acom ; - e1bcom2 += ee1bcom2 ; - e1rope2 += ee1rope2 ; - e0nfcom += ee0nfcom ; - e0nper += ee0nper ; - e0aimp += ee0aimp ; - e0snsrit += ee0snsrit ; - e0rope += ee0rope ; - h0codlav += hh0codlav ; - h0coldip += hh0coldip ; - c0nfcom += cc0nfcom ; - c0nlass += cc0nlass ; - c0actot += cc0actot ; - c0snsrit += cc0snsrit ; - c0rope += cc0rope ; - d0nfcom += dd0nfcom ; - d0nlaut += dd0nlaut ; - d0actot += dd0actot ; - d0snsrit += dd0snsrit ; - d0rope += dd0rope ; - - base.put(BSE_D1NFCOM, d1nfcom); - base.put(BSE_D1NPER, d1nper); - base.put(BSE_D1TACOR, d1tacor); - base.put(BSE_D1SNSRIT, d1snsrit); - base.put(BSE_D1ROPE, d1rope); - basebis.put(BSB_E1NFCOM, e1nfcom); - basebis.put(BSB_E1NPER, e1nper); - basebis.put(BSB_E1SCOR, e1scor); - basebis.put(BSB_E1BCOM, e1bcom); - basebis.put(BSB_E1ROPE, e1rope); - basebis.put(BSB_E1ACOM, e1acom); - basebis.put(BSB_E1BCOM2, e1bcom2); - basebis.put(BSB_E1ROPE2, e1rope2); - - basebis.put(BSB_E0NFCOM, e0nfcom); - basebis.put(BSB_E0NPER, e0nper); - basebis.put(BSB_E0AIMP, e0aimp); - basebis.put(BSB_E0SNSRIT, e0snsrit); - basebis.put(BSB_E0ROPE, e0rope); - - basebis.put(BSB_H0CODLAV, h0codlav); - basebis.put(BSB_H0COLDIP, h0coldip); - base.put(BSE_C0NFCOM, c0nfcom); - base.put(BSE_C0NLASS, c0nlass); - base.put(BSE_C0ACTOT, c0actot); - base.put(BSE_C0SNSRIT, c0snsrit); - base.put(BSE_C0ROPE, c0rope); - - base.put(BSE_D0NFCOM, d0nfcom); - base.put(BSE_D0NLAUT, d0nlaut); - base.put(BSE_D0ACTOT, d0actot); - base.put(BSE_D0SNSRIT, d0snsrit); - base.put(BSE_D0ROPE, d0rope); - - ret1 = base.rewrite(); - ret2 = basebis.rewrite(); - - return TRUE; -} - -// Calcola i riporti dai quadri al quadro I per la ditta codditta. -// Esegue i riporti anche su dichiarante se specificato -bool TRiporti::set(const TString& quadro, int anno, const long codditta, const long dichiarante) -{ - TString16 filt; - TRelation* rel; - TCursor* cur; - long codditta_dich = 0L; - - _codditta = codditta ? codditta : get_firm_770(); - _annodic = anno ? anno : anno_770(); - _quadro = quadro; - - this_riporti = this; - - if (quadro == "A" || quadro == "*") - { - rel = new TRelation (LF_QUAA); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_A(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "A1" || quadro == "*") - { - rel = new TRelation (LF_QUAA1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_A1(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "A2" || quadro == "*") - { - rel = new TRelation (LF_QUAA2); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_A2(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "A3" || quadro == "*") - { - rel = new TRelation (LF_QUAA3); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_A3(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "B" || quadro == "*") - { - rel = new TRelation (LF_QUAB); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_B(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "B1" || quadro == "*") - { - rel = new TRelation (LF_QUAB1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_B1(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "H" || quadro == "*") - { - rel = new TRelation (LF_QUAH); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - cur->set_filterfunction (filter_func); - calcola_riporti_H(cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "C" || quadro == "*") - { - rel = new TRelation (LF_QUAC); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_C (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "D" || quadro == "*") - { - rel = new TRelation (LF_QUAD); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_D (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "D1" || quadro == "*") - { - rel = new TRelation (LF_QUAD1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_D1 (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "E" || quadro == "*") - { - rel = new TRelation (LF_QUAE); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_E (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "E1" || quadro == "*") - { - rel = new TRelation (LF_QUAE1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_E1 (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "E2" || quadro == "*") - { - rel = new TRelation (LF_QUAE2); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_E2 (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "F" || quadro == "*") - { - rel = new TRelation (LF_QUAF); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_F (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "F1" || quadro == "*") - { - rel = new TRelation (LF_QUAF1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_F1 (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "F2" || quadro == "*") - { - rel = new TRelation (LF_QUAF2); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_F2 (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "G" || quadro == "*") - { - rel = new TRelation (LF_QUAG); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_G (cur, dichiarante); - delete cur; delete rel; - } - - if (quadro == "G1" || quadro == "*") - { - rel = new TRelation (LF_QUAG1); - filt.format("CODDITTA=%ld", _codditta); - cur = new TCursor(rel,filt,1); - calcola_riporti_G1 (cur, dichiarante); - delete cur; delete rel; - } - setta_flag_quadro_I(_codditta); - return TRUE; -} - -const int NUM_DIP_A = 9; - -void TRiporti::calcola_riporti_A(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real totale,somme,ritenute; - bool almeno_una_riga = FALSE; - long dipendenti,num_rec; - - real a0cobb,a0cnet,a0eprev,a0iitra,a0cter,a0timp,a0ilor,a0tdet,a0rter,a0rdat; - real a0erit,a0carr,a0aarr,a0darr,a0rarr,a0cinps,a0ciiaut,a0crimpras,a0incdet; - - a0cobb = ZERO; a0cnet = ZERO; a0eprev = ZERO; a0iitra = ZERO; a0cter = ZERO; - a0timp = ZERO; a0ilor = ZERO; a0tdet = ZERO; a0rter = ZERO; a0rdat = ZERO; - a0erit = ZERO; a0carr = ZERO; a0aarr = ZERO; a0darr = ZERO; a0rarr = ZERO; - a0cinps = ZERO; a0ciiaut = ZERO; a0crimpras = a0incdet = ZERO; - - dipendenti = 0; - num_rec = 0; - - (*cur) = 0L; - - TRecnotype items = cur->items(); - TString scritta(60); - - scritta.format("Calcolo riporti del quadro A per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - long coddipp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - progn.addstatus(1); - - long coddip = cur->curr().get_long(QUA_CODIP); - - bool compilato = FALSE; - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - for (int i = 0; i < CAMPI_A; i++) - if (cur->curr().get_real(_campi_A[i]) != ZERO) - { - compilato = TRUE; - break; - } - - if (!compilato) - continue; - - num_rec++; - - if (coddip != coddipp) - if (!is_erede(_codditta,coddip)) - dipendenti++; - - coddipp = coddip; - - int causa = cur->curr().get_int (QUA_CAUSA); - TString codfis = cur->curr().get (QUA_CODFISDL); - char retcon = cur->curr().get_char(QUA_RETCON); - - if (retcon != 'B' && codfis.empty()) - { - a0cobb += cur->curr().get_real(QUA_COBBDIP); - a0cnet += cur->curr().get_real(QUA_COMPNETTI); - a0eprev += cur->curr().get_real(QUA_AIENTIPREV); - a0iitra += cur->curr().get_real(QUA_TOTIMP); -// a0cter += cur->curr().get_real(QUA_CCTAMMCONT) + cur->curr().get_real(QUA_CCTAMNACON); - a0cter += cur->curr().get_real(QUA_CCTAMMCONT); - a0timp += cur->curr().get_real(QUA_TOTIMP2); - a0ilor += cur->curr().get_real(QUA_ICTOTIMP); - a0tdet += cur->curr().get_real(QUA_TOTDET); - a0rter += cur->curr().get_real(QUA_AMRIOT); - a0rdat += cur->curr().get_real(QUA_AMRIODL); - a0erit += cur->curr().get_real(QUA_ECCRITRIMB); - a0carr += cur->curr().get_real("COBBDIP2"); // cas.46 - a0aarr += cur->curr().get_real(QUA_AMMIMP); - a0darr += cur->curr().get_real(QUA_DETIMPOS); - a0rarr += cur->curr().get_real(QUA_RITESEG); - a0incdet += cur->curr().get_real("INCDETFC"); // cas.38 - } - } - - long fogli = num_rec / NUM_DIP_A; - if (num_rec % NUM_DIP_A) - fogli++; - - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal,_lock) == NOERR) - { - base.put(BSE_A0NFCOM, fogli); - base.put(BSE_A0NLDIP, (long)dipendenti); - base.put(BSE_A0COBB, a0cobb); - base.put(BSE_A0CNET, a0cnet); - base.put(BSE_A0EPREV, a0eprev); - base.put(BSE_A0IITRA, a0iitra); - base.put(BSE_A0CTER, a0cter); - base.put(BSE_A0TIMP, a0timp); - base.put(BSE_A0ILOR, a0ilor); - base.put(BSE_A0TDET, a0tdet); - base.put(BSE_A0RTER, a0rter); - base.put(BSE_A0RDAT, a0rdat); - base.put(BSE_A0ERIT, a0erit); - base.put(BSE_A0CARR, a0carr); - base.put(BSE_A0AARR, a0aarr); - base.put(BSE_A0DARR, a0darr); - base.put(BSE_A0RARR, a0rarr); - base.put("A0INCDET", a0incdet); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, A, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti A"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -const int NUM_DIPENDENTI_MODULO_A3 = 35; - -void TRiporti::calcola_riporti_A3(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - bool almeno_una_riga = FALSE; - long dipendenti=0L, num_rec=0L; - real a3rept10=ZERO,a3rept12=ZERO; - - (*cur) = 0L; - TRecnotype items = cur->items(); - TString scritta(60); - scritta.format("Calcolo riporti del quadro A3 per la ditta %ld", _codditta); - TProgind progn(items, scritta, FALSE, TRUE); -// fogli per l'elenco delle trasf. - int iFogliTrasf=0; - int iDipTrasf=0; - - for (int i = 0; i < items; i++, ++(*cur)) - { - progn.addstatus(1); - const long coddip = cur->curr().get_long(QUA_CODIP); - const long nprog = cur->curr().get_long(QUA_NPROG); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - -// Non conta quelli con redditto corrisposto = ZERO - if ((cur->curr().get_real(QA3_REDCOR16) == ZERO) && (cur->curr().get_real(QA3_REDCOR18) == ZERO)) - continue; - -// nprog=2 se e' il record della trasformata. Conto i dip.con trasf. per -// contare i fogli - if (nprog == 2) - iDipTrasf++; - - dipendenti++; - - a3rept10 += cur->curr().get_real(QA3_REDCOR16); - a3rept12 += cur->curr().get_real(QA3_REDCOR18); - } - - long fogli = dipendenti / NUM_DIPENDENTI_MODULO_A3; - if (dipendenti % NUM_DIPENDENTI_MODULO_A3) - fogli++; - iFogliTrasf = iDipTrasf / NUM_DIPENDENTI_MODULO_A3; - if (iDipTrasf % NUM_DIPENDENTI_MODULO_A3) - iFogliTrasf++; - fogli += iFogliTrasf; - - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal,_lock) == NOERR) - { - base.put(BSE_A3NFCOM, fogli); - base.put(BSE_A3NUMPER, (long)dipendenti); - base.put(BSE_A3REPT10, a3rept10); - base.put(BSE_A3REPT12, a3rept12); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, A3, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti A3"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_A1(TCursor* cur, const long dich) -{ - bool almeno_una_riga = FALSE; - - (*cur) = 0L; - - TRecnotype items = cur->items(); - TString scritta(60); - - scritta.format("Calcolo riporti del quadro A1 per la ditta %ld", _codditta); - -// da attivare qualora anche il quadro A1 effettui riporti su quadro I -// TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 0; i < items; i++, ++(*cur)) - { - -// da attivare qualora anche il quadro A1 effettui riporti su quadro I -// progn.addstatus(1); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - } - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, A1, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti A1"); -} - -void TRiporti::calcola_riporti_A2(TCursor* cur, const long dich) -{ - bool almeno_una_riga = FALSE; - (*cur) = 0L; - TRecnotype items = cur->items(); - TString scritta(60); - scritta.format("Calcolo riporti del quadro A2 per la ditta %ld", _codditta); - -// da attivare qualora anche il quadro A2 effettui riporti su quadro I -// TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 0; i < items; i++, ++(*cur)) - { -// da attivare qualora anche il quadro A2 effettui riporti su quadro I -// progn.addstatus(1); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - } - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, A2, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti A2"); -} - -void TRiporti::calcola_riporti_H(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - real ritdat,ritlav; - bool almeno_una_riga = FALSE; - - ritdat = ZERO; - ritlav = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); -// if (items == 0L) return; - TString scritta(60); - scritta.format("Calcolo riporti del quadro H per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 0; i < items; i++, ++(*cur)) - { - ritdat += cur->curr().get_real(QUH_H1DAT); - ritlav += cur->curr().get_real(QUH_H1LAV); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_H0CODLAV, ritdat); - basebis.put(BSB_H0COLDIP, ritlav); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, H, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -const int NUM_PERC_C = 36; - -void TRiporti::calcola_riporti_C(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real totale,somme,ritenute,rTotCSSN; - bool almeno_una_riga = FALSE; - long percipienti=0L; - - totale = ZERO; - somme = ZERO; - ritenute = ZERO; - rTotCSSN = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); -// if (items == 0L) return; - TString scritta(60); - scritta.format("Calcolo riporti del quadro C per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - char tipoa = cur->curr().get_char(QUC_TIPOA); - long codanagr = cur->curr().get_long(QUC_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - totale += cur->curr().get_real(QUC_TOTALE); - somme += cur->curr().get_real(QUC_SOMME); - ritenute += cur->curr().get_real(QUC_RITENUTE); - rTotCSSN += cur->curr().get_real(QUC_CONTSSN); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - long fogli = percipienti / NUM_PERC_C; - if (percipienti % NUM_PERC_C) - fogli++; - - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal,_lock) == NOERR) - { - base.put(BSE_C0NFCOM, fogli); - base.put(BSE_C0NLASS, (long)percipienti); - base.put(BSE_C0ACTOT, totale); - base.put(BSE_C0SNSRIT, somme); - base.put(BSE_C0ROPE, ritenute); - base.put(BSE_C0CONTSSN, rTotCSSN); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, C, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti C"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_D(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real totale,somme,ritenute; - bool almeno_una_riga = FALSE; - int percipienti; - int fisiche,giuridiche; - - percipienti = 0; - fisiche = 0; - giuridiche = 0; - - totale = ZERO; - somme = ZERO; - ritenute = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); -// if (items == 0L) return; - TString scritta(60); - scritta.format("Calcolo riporti del quadro D per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - char tipoa = cur->curr().get_char(QUD_TIPOA); - long codanagr = cur->curr().get_long(QUD_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - if (tipoa == 'F') - fisiche++; - else - if (tipoa == 'G') - giuridiche++; - - totale += cur->curr().get_real(QUD_TOTALE); - somme += cur->curr().get_real(QUD_SOMME); - ritenute += cur->curr().get_real(QUD_IMPORTO); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - const long fogli = fogli_compilati(fisiche,giuridiche,QD_FISICHE_PER_FOGLIO,QD_NOFISICHE_PER_FOGLIO); - - base.setkey(1); - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal,_lock) == NOERR) - { - base.put(BSE_D0NFCOM, fogli); - base.put(BSE_D0NLAUT, (long)percipienti); - base.put(BSE_D0ACTOT, totale); - base.put(BSE_D0SNSRIT, somme); - base.put(BSE_D0ROPE, ritenute); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, D, almeno_una_riga, basebis, dich); - else - warning_box("Lock fallito in calcola_riporti D"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_D1(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real totale,somme,importo; - bool almeno_una_riga = FALSE; - int percipienti,fisiche,giuridiche; - - percipienti = 0; - fisiche = 0; - giuridiche = 0; - - totale = ZERO; - somme = ZERO; - importo = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); - TString scritta(60); - scritta.format("Calcolo riporti del quadro D1 per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - char tipoa = cur->curr().get_char(QD1_TIPOA); - long codanagr = cur->curr().get_long(QD1_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - if (tipoa == 'F') - fisiche++; - else - if (tipoa == 'G') - giuridiche++; - - totale += cur->curr().get_real(QD1_TOTALE); - somme += (cur->curr().get_real(QD1_QUOTAPRO)) + (cur->curr().get_real(QD1_SPESEANT)); - importo += cur->curr().get_real(QD1_IMPORTO); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - const long fogli = fogli_compilati(fisiche,giuridiche,QD1_FISICHE_PER_FOGLIO,QD1_NOFISICHE_PER_FOGLIO); - - base.setkey(1); - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal,_lock) == NOERR) - { - base.put(BSE_D1NFCOM, fogli); - base.put(BSE_D1NPER, (long)percipienti); - base.put(BSE_D1TACOR, totale); - base.put(BSE_D1SNSRIT, somme); - base.put(BSE_D1ROPE, importo); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, D1, almeno_una_riga,basebis,dich); - else - warning_box("Lock fallito in calcola_riporti D1"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_E(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - real imponibile,somme,ritenute; - bool almeno_una_riga = FALSE; - int percipienti,fisiche,giuridiche; - - percipienti = 0; - fisiche = 0; - giuridiche = 0; - - imponibile = ZERO; - somme = ZERO; - ritenute = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); -// if (items == 0L) return; - TString scritta(60); - scritta.format("Calcolo riporti del quadro E per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - char tipoa = cur->curr().get_char(QUE_TIPOA); - long codanagr = cur->curr().get_long(QUE_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - if (tipoa == 'F') - fisiche++; - else - if (tipoa == 'G') - giuridiche++; - - imponibile += cur->curr().get_real(QUE_IMPONIBILE); - somme += cur->curr().get_real(QUE_SOMME); - ritenute += cur->curr().get_real(QUE_IMPORTO); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - const long fogli = fogli_compilati(fisiche,giuridiche,QE_FISICHE_PER_FOGLIO,QE_NOFISICHE_PER_FOGLIO); - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal,_lock) == NOERR) - { - basebis.put(BSB_E0NFCOM, fogli); - basebis.put(BSB_E0NPER, (long)percipienti); - basebis.put(BSB_E0AIMP, imponibile); - basebis.put(BSB_E0SNSRIT, somme); - basebis.put(BSB_E0ROPE, ritenute); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, E, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_E1(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - TRelation* relp; - TCursor* curp; - TString16 filt; - real ammontare,somme,ritenute; - real comp,impo,rite; - bool almeno_una_riga = FALSE; - int percipienti,righep; - - percipienti = 0; - righep = 0; - - ammontare = ZERO; - somme = ZERO; - ritenute = ZERO; - - comp = ZERO; - impo = ZERO; - rite = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); -// if (items == 0L) return; - TString scritta(60); - scritta.format("Calcolo riporti del quadro E1 per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - char tipoa = cur->curr().get_char(QE1_TIPOA); - long codanagr = cur->curr().get_long(QE1_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - ammontare += cur->curr().get_real(QE1_AMMONTARE); - somme += cur->curr().get_real(QE1_SOMME); - ritenute += cur->curr().get_real(QE1_IMPORTO); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - relp = new TRelation (LF_PROSPE1); - filt.format("CODDITTA=%ld", _codditta); - curp = new TCursor(relp,filt,1); - (*curp) = 0L; - TRecnotype itemp = curp->items(); - scritta.format("Calcolo riporti del prospetto del quadro E1 per la ditta %ld", _codditta); - TProgind prognp(itemp, scritta, FALSE, TRUE); - - for (int j = 0; j < itemp; j++, ++(*curp)) - { - righep++; - - comp += curp->curr().get_real(PRE_COMPENSO); - impo += curp->curr().get_real(PRE_IMPONIBILE); - rite += curp->curr().get_real(PRE_RITENUTA); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - prognp.addstatus(1); - } - - delete curp; - delete relp; - - const long fogli = fogli_compilati(percipienti,righep,QE1_PERCIPIENTI_PER_FOGLIO,QE1_RIGHE_PROSPETTO); - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_E1NFCOM, fogli); - basebis.put(BSB_E1NPER, (long)percipienti); - basebis.put(BSB_E1SCOR, somme); - basebis.put(BSB_E1BCOM, ammontare ); - basebis.put(BSB_E1ROPE, ritenute ); - basebis.put(BSB_E1ACOM, comp); - basebis.put(BSB_E1BCOM2, impo); - basebis.put(BSB_E1ROPE2, rite); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, E1, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_E2(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - long fisiche, no_fisiche; - long fogli_comp; - real soggrit, rope; - real comp,impo,rite; - bool almeno_una_riga = FALSE; - double percipienti; - - fisiche = no_fisiche = fogli_comp = 0L; - percipienti = 0.00; - - soggrit = ZERO; - rope = ZERO; - - comp = ZERO; - impo = ZERO; - rite = ZERO; - - (*cur) = 0L; - - TRecnotype items = cur->items(); - TString scritta(60); - scritta.format("Calcolo riporti del quadro E2 per la ditta %ld", _codditta); - - TProgind progn(items, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < items; i++, ++(*cur)) - { - const char tipoa = cur->curr().get_char(QE2_TIPOA); - const long codanagr = cur->curr().get_long(QE2_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - if (tipoa == 'F') - fisiche++; - else - no_fisiche++; - - soggrit += cur->curr().get_real(QE2_SOGGRIT); - rope += cur->curr().get_real(QE2_ROPE); - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - fogli_comp = fogli_compilati(fisiche,no_fisiche,QE2_FISICHE_PER_FOGLIO,QE2_NOFISICHE_PER_FOGLIO); - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_E2NFCOM, fogli_comp); - basebis.put(BSB_E2NPER, (long)percipienti); - basebis.put(BSB_E2SSRIT, soggrit); - basebis.put(BSB_E2ROPE, rope ); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, E2, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_F(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - TLocalisamfile* rf; - TRecord_array* _prosp_a, *_prosp_b, *_prosp_c, *_prosp_d; - real a_sogrit, a_rope, a_totacc, f_rope, e_rope, f_sogrit, e_sogrit; - real b_sogrit, b_rope, c_sogrit, c_rope, d_sogrit, d_rope; - real i20_1, i20_2, i20_3, i20_4, i20_5, i20_6, i21_1, i21_2, i21_3; - bool almeno_una_riga = FALSE; - - a_sogrit = a_rope = a_totacc = ZERO; - b_sogrit = b_rope = c_sogrit = c_rope = d_sogrit = d_rope = ZERO; - f_rope = e_rope = f_sogrit = e_sogrit = ZERO; - i20_1 = i20_2 = i20_3 = i20_4 = i20_5 = i20_6 = i21_1 = i21_2 = i21_3 = ZERO; - - (*cur) = 0L; - TRecnotype items = cur->items(); - - TString scritta(60); - scritta.format("Calcolo riporti del quadro F per la ditta %ld", _codditta); - - i20_4 = cur->curr().get_real(QF0_A1); - i20_5 = cur->curr().get_real(QF0_A2); - i20_6 = cur->curr().get_real(QF0_A3); - i21_1 = cur->curr().get_real(QF0_A4); - e_sogrit = cur->curr().get_real(QF0_ESOGRIT); - f_sogrit = cur->curr().get_real(QF0_FSOGRIT); - e_rope = cur->curr().get_real(QF0_EROPE); - f_rope = cur->curr().get_real(QF0_FROPE); - -// Per stabilire se il quadro e' stato compilato verifica anche i campi -// fuori dagli spreadsheet - almeno_una_riga = i20_4 != ZERO || i20_5 != ZERO || i20_6 != ZERO || - i21_1 != ZERO || e_sogrit != ZERO || f_sogrit != ZERO || e_rope != ZERO || - f_rope != ZERO; - - rf = new TLocalisamfile(LF_RIGHEF); - - TRectype dep(rf->curr()); - dep.zero(); - dep.put("CODDITTA", _codditta); - dep.put("TIPOPRO", "A"); - _prosp_a = new TRecord_array(dep, "NPROG"); - _prosp_a->read(dep); - dep.put("TIPOPRO", "B"); - _prosp_b = new TRecord_array(dep, "NPROG"); - _prosp_b->read(dep); - dep.put("TIPOPRO", "C"); - _prosp_c = new TRecord_array(dep, "NPROG"); - _prosp_c->read(dep); - dep.put("TIPOPRO", "D"); - _prosp_d = new TRecord_array(dep, "NPROG"); - _prosp_d->read(dep); - - items = _prosp_a->last_row() + _prosp_b->last_row() + _prosp_c->last_row() + _prosp_d->last_row(); - TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 1; i <= _prosp_a->last_row(); i++) - { - TRectype& r = _prosp_a->row(i, TRUE); - a_sogrit += r.get_real(RQF0_SOGRIT); - a_rope += r.get_real(RQF0_ROPE); - a_totacc += r.get_real(RQF0_TOTACC); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - i20_1 = a_sogrit; - i20_2 = a_rope; - i20_3 = a_totacc; - - for (i = 1; i <= _prosp_b->last_row(); i++) - { - TRectype& r = _prosp_b->row(i, TRUE); - b_sogrit += r.get_real(RQF0_SOGRIT); - b_rope += r.get_real(RQF0_ROPE); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - - for (i = 1; i <= _prosp_c->last_row(); i++) - { - TRectype& r = _prosp_c->row(i, TRUE); - c_sogrit += r.get_real(RQF0_SOGRIT); - c_rope += r.get_real(RQF0_ROPE); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - - for (i = 1; i <= _prosp_d->last_row(); i++) - { - TRectype& r = _prosp_d->row(i, TRUE); - d_sogrit += r.get_real(RQF0_SOGRIT); - d_rope += r.get_real(RQF0_ROPE); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - - i21_2 += b_sogrit + c_sogrit + d_sogrit + e_sogrit + f_sogrit; - i21_3 += b_rope + c_rope + d_rope + e_rope + f_rope; - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_F0SRITA, i20_1); - basebis.put(BSB_F0ROPEA, i20_2); - basebis.put(BSB_F0TACCA, i20_3); - basebis.put(BSB_F0EDACCA, i20_4); - basebis.put(BSB_F0ERIMA, i20_5); - basebis.put(BSB_F0SSVA, i20_6); - basebis.put(BSB_F0ROPEVA, i21_1); - basebis.put(BSB_F0SSRITBF, i21_2); - basebis.put(BSB_F0ROPEBF, i21_3); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, F, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_F1(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - TLocalisamfile* rf; - TRecord_array* _prosp_b; - real b_sogrit, b_rope; - real i22_1, i22_2; - real f1a1=ZERO, f1a2=ZERO; - bool almeno_una_riga = FALSE; - - b_sogrit = b_rope = ZERO; - i22_1 = i22_2 = ZERO; - - (*cur) = 0L; - TRecnotype items = cur->items(); - - TString scritta(60); - scritta.format("Calcolo riporti del quadro F-1 per la ditta %ld", _codditta); - - TLocalisamfile f1(LF_QUAF1); - f1.zero(); - f1.put("CODDITTA", _codditta); - f1.read(); - f1a1 = f1.get_real("F1_A1"); - f1a2 = f1.get_real("F1_A2"); - almeno_una_riga = (f1a1 != ZERO) || (f1a2 != ZERO); - - rf = new TLocalisamfile(LF_RIGHEF1); - - TRectype dep(rf->curr()); - dep.zero(); - dep.put("CODDITTA", _codditta); - dep.put("TIPOPRO", "B"); - _prosp_b = new TRecord_array(dep, "NPROG"); - _prosp_b->read(dep); - - items = _prosp_b->last_row(); - TProgind progn(items, scritta, FALSE, TRUE); - - i22_1 = cur->curr().get_real(QF1_A1); - i22_2 = cur->curr().get_real(QF1_A2); - - for (int i = 1; i <= _prosp_b->last_row(); i++) - { - TRectype& r = _prosp_b->row(i, TRUE); - b_sogrit += r.get_real(RQF1_SOGRIT); - b_rope += r.get_real(RQF1_ROPE); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - - i22_1 += b_sogrit; - i22_2 += b_rope; - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_F1SSRIT, i22_1); - basebis.put(BSB_F1ROPE, i22_2); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, F1, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -void TRiporti::calcola_riporti_F2(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - TLocalisamfile* rf; - TRecord_array* _prosp_b; - real b_sogrit, b_rope; - real i23_1, i23_2; - bool almeno_una_riga = FALSE; - - b_sogrit = b_rope = ZERO; - i23_1 = i23_2 = ZERO; - - (*cur) = 0L; - TRecnotype items = cur->items(); - - TString scritta(60); - scritta.format("Calcolo riporti del quadro F-2 per la ditta %ld", _codditta); - - rf = new TLocalisamfile(LF_RIGHEF2); - - TRectype dep(rf->curr()); - dep.zero(); - dep.put("CODDITTA", _codditta); - dep.put("TIPOPRO", "B"); - _prosp_b = new TRecord_array(dep, "NPROG"); - _prosp_b->read(dep); - - items = _prosp_b->last_row(); - TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 1; i <= _prosp_b->last_row(); i++) - { - TRectype& r = _prosp_b->row(i, TRUE); - b_sogrit += r.get_real(RQF2_SOGRIT); - b_rope += r.get_real(RQF2_ROPE); - if (!almeno_una_riga) almeno_una_riga = TRUE; - progn.addstatus(1); - } - - i23_1 += b_sogrit; - i23_2 += b_rope; - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_F2SSRIT, i23_1); - basebis.put(BSB_F2ROPE, i23_2); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, F2, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - -// -// fogli_compilati -// -// Determina il numero di fogli compilati: -// Divide il numero di persone (F o G) trovate per il numero -// di posti previsto nel modulo. -// Se il resto e' diverso da 0 conta un foglio in piu' -// -long fogli_compilati(const long fisiche, const long no_fisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio) -{ - long fogli_compilati=0L, fogli_fisiche=0L, fogli_nofisiche=0L; - - if (fisiche > 0L) - { - fogli_fisiche = fisiche / fisiche_x_foglio; - if (fisiche % fisiche_x_foglio) - fogli_fisiche += 1; - } - - if (no_fisiche > 0L) - { - fogli_nofisiche = no_fisiche / nofisiche_x_foglio; - if (no_fisiche % nofisiche_x_foglio) - fogli_nofisiche += 1; - } - fogli_compilati = fogli_fisiche > fogli_nofisiche ? fogli_fisiche : fogli_nofisiche; - return fogli_compilati; -} - -void TRiporti::calcola_riporti_G(TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - real b_sogrit, b_rope; - real i24_1, i24_2, i24_3, i24_4, i24_5, i24_6; - real i24_7, i24_8, i24_9, i24_10, i24_11, i24_12; - real i24_13, i25_4; - bool almeno_una_riga=FALSE, almeno_una_riga_distinta=FALSE,almeno_una_riga_prospetti=FALSE; - long fogli_comp = 0L, percipienti=0L; - TRelation* relp; - TCursor* curp; - int fisiche = 0, no_fisiche = 0; - TString filt(20); - - i24_1 = i24_2 = i24_3 = i24_4 = i24_5 = i24_6 = ZERO; - i24_7 = i24_8 = i24_9 = i24_10 = i24_11 = i24_12 = ZERO; - i24_13 = ZERO; - i25_4 = ZERO; - - (*cur) = 0L; - TRecnotype items = cur->items(); - -// Legge quadro G - i24_2 = cur->curr().get_real(QG_P1NUMQT); - i24_3 = cur->curr().get_real(QG_P1AMMT); - i24_4 = cur->curr().get_real(QG_P2VALT); - i24_5 = cur->curr().get_real(QG_P22TOT); - i24_6 = cur->curr().get_real(QG_P33TOT); - i24_7 = cur->curr().get_real(QG_P35TOT); - i24_8 = cur->curr().get_real(QG_P36TOT); - i24_9 = cur->curr().get_real(QG_P37TOT); - almeno_una_riga_prospetti = i24_2 != ZERO || i24_3 != ZERO - || i24_4 != ZERO - || i24_5 != ZERO || i24_6 != ZERO || i24_7 != ZERO - || i24_8 != ZERO || i24_9 != ZERO; - - TString scritta(60); -// scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta); - -// Scorre quadrogd (distinta) - relp = new TRelation (LF_QUAGD); - filt.format("CODDITTA=%ld", _codditta); - curp = new TCursor(relp,filt,1); - (*curp) = 0L; - TRecnotype ItemDistinta = curp->items(); - scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta); - TProgind progn(ItemDistinta, scritta, FALSE, TRUE); - - char tipoap = 'Z'; - long codanagrp = -1; - - for (int i = 0; i < ItemDistinta; i++, ++(*curp)) - { - const char tipoa = curp->curr().get_char(QGD_TIPOA); - const long codanagr = curp->curr().get_long(QGD_CODANAGR); - - if ( (tipoa != tipoap) || (codanagr != codanagrp) ) - percipienti++; - - tipoap = tipoa; - codanagrp = codanagr; - - if (tipoa == 'F') - fisiche++; - else - no_fisiche++; - - i24_11 += curp->curr().get_real(QGD_UTSPETT); - i24_12 += curp->curr().get_real(QGD_UTPAG); - i24_13 += curp->curr().get_real(QGD_ROPE); - i25_4 += curp->curr().get_real(QGD_ROPESPET); - - almeno_una_riga_distinta = TRUE; - - progn.addstatus(1); - } - -// E' compilato se c'e' qualcosa nel G o nella distinta fax 15.7.96 p.1 - almeno_una_riga = almeno_una_riga_prospetti || almeno_una_riga_distinta; - - fogli_comp = fogli_compilati(fisiche,no_fisiche,QGD_FISICHE_PER_FOGLIO,QGD_NOFISICHE_PER_FOGLIO); -// Considera anche la parte del G (prospetti 1-2-3-4) - if (almeno_una_riga_prospetti && fogli_comp==0) - fogli_comp++; - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_G0NFCOM, (long)fogli_comp); - basebis.put(BSB_G0NPER, (long)percipienti); - basebis.put(BSB_G0USPE, i24_11); - basebis.put(BSB_G0UPAG, i24_12); - basebis.put(BSB_G0ROPE, i24_13); - basebis.put(BSB_G0NAZI1, i24_2); - basebis.put(BSB_G0UDEN1, i24_3); - basebis.put(BSB_G0UNAT1, i24_4); - basebis.put(BSB_G0IUTI2, i24_5); - basebis.put(BSB_G0USRIT3, i24_6); - basebis.put(BSB_G0RACC3, i24_7); - basebis.put(BSB_G0RIMP3, i24_8); - basebis.put(BSB_G0UNSRIT3, i24_9); - basebis.put(BSB_G0RITSPET, i25_4); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, G, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); -} - - -void TRiporti::calcola_riporti_G1 (TCursor* cur, const long dich) -{ - TLocalisamfile basebis (LF_BASEBIS); - real i27_1, i27_2, i27_3, i27_4, i27_5; - bool almeno_una_riga = FALSE; - - i27_1 = i27_2 = i27_3 = i27_4 = i27_5 = ZERO; - (*cur) = 0L; - TRecnotype items = cur->items(); - - i27_1 = cur->curr().get_real(QG1_P12TOT); - i27_2 = cur->curr().get_real(QG1_P13TOT); - i27_3 = cur->curr().get_real(QG1_P15TOT); - i27_4 = cur->curr().get_real(QG1_P16TOT); - i27_5 = cur->curr().get_real(QG1_P17TOT); - - almeno_una_riga = (i27_1 != ZERO) || (i27_2 != ZERO) || (i27_3 != ZERO) || - (i27_4 != ZERO) || (i27_5 != ZERO); - TString scritta(60); - scritta.format("Calcolo riporti del quadro G-1 per la ditta %ld", _codditta); - TProgind progn(items, scritta, FALSE, TRUE); - - basebis.setkey(1); - basebis.zero(); - if (dich) - { - basebis.put("TIPOQUA", COD_QUA_I_DIC); - basebis.put(BSB_CODDITTA, dich); - } - else - basebis.put(BSB_CODDITTA, _codditta); - - if (basebis.read(_isequal, _lock) == NOERR) - { - basebis.put(BSB_G1UCOR, i27_1); - basebis.put(BSB_G1USRIT, i27_2); - basebis.put(BSB_G1RACC, i27_3); - basebis.put(BSB_G1RIMP, i27_4); - basebis.put(BSB_G1UNSRIT, i27_5); - basebis.rewrite(); - setta_flag_quadri_comp(_codditta, G1, almeno_una_riga,basebis,dich); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); - - progn.addstatus(1); -} - -HIDDEN const int QB_NUMPERC_PER_FOGLIO = 16; - -void TRiporti::calcola_riporti_B (TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real c3,c4,c5,c6,c7,c8,c9,c10; - real tc3,tc4,tc5,tc6,tc7,tc8,tc9,tc10; - int c2=0; - long c1=0L; - bool almeno_una_riga = FALSE; - int NumPerc=0; - long fogli_comp=0L; - TBit_array baGiaVisto; - - c3=c4=c5=c6=c7=c8=c9=c10=ZERO; - tc3=tc5=tc6=tc7=tc8=tc9=tc10=ZERO; - (*cur) = 0L; - TRecnotype items = cur->items(); - almeno_una_riga = items > 0L; - - TString scritta(60); - scritta.format("Calcolo riporti del quadro B per la ditta %ld", _codditta); - TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 0; i < items; i++, ++(*cur)) - { - const long codditta = cur->curr().get_long(QB_CODDITTA); - const long coddip = cur->curr().get_long(QB_CODDIP); - - if (!baGiaVisto[coddip]) - { - baGiaVisto.set(coddip); - if (!is_erede(codditta, coddip)) - NumPerc++; - } - - c3 = cur->curr().get_real(QB_C20); - c4 = cur->curr().get_real(QB_C24); - c5 = cur->curr().get_real(QB_C25); - c6 = cur->curr().get_real(QB_C26); - c7 = cur->curr().get_real(QB_C27); - c8 = cur->curr().get_real(QB_C36); - c9 = cur->curr().get_real(QB_C37); - c10 = cur->curr().get_real(QB_C43); - - tc3 += c3; - tc4 += c4; - tc5 += c5; - tc6 += c6; - tc7 += c7; - tc8 += c8; - tc9 += c9; - tc10 += c10; - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - fogli_comp = fogli_compilati(items,0L,QB_NUMPERC_PER_FOGLIO,0); - - c1 = fogli_comp; - c2 = NumPerc; - - base.setkey(1); - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal, _lock) == NOERR) - { - base.put(I8_1,c1); - base.put(I8_2,(long)c2); - base.put(I8_3,tc3); - base.put(I8_4,tc4); - base.put(I8_5,tc5); - base.put(I8_6,tc6); - base.put(I9_7,tc7); - base.put(I9_8,tc8); - base.put(I9_9,tc9); - base.put(I9_10,tc10); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, B, almeno_una_riga,basebis,dich); - else - warning_box("Lock fallito in calcola_riporti B"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); - - progn.addstatus(1); -} - -HIDDEN const int QB1_NUMPERC_PER_FOGLIO = 14; - -void TRiporti::calcola_riporti_B1(TCursor* cur, const long dich) -{ - TLocalisamfile base (LF_BASE); - real c3,c4,c5; - real tc3,tc4,tc5; - int c2=0; - bool almeno_una_riga = FALSE; - int NumPerc=0; - long fogli_comp=0L, c1=0L; - - c3=c4=c5=ZERO; - tc3=tc4=tc5=ZERO; - (*cur) = 0L; - TRecnotype items = cur->items(); - almeno_una_riga = items > 0L; - - TString scritta(60); - scritta.format("Calcolo riporti del quadro B-1 per la ditta %ld", _codditta); - TProgind progn(items, scritta, FALSE, TRUE); - - for (int i = 0; i < items; i++, ++(*cur)) - { - c3 = cur->curr().get_real(QB1_C11); - c4 = cur->curr().get_real(QB1_C12); - c5 = cur->curr().get_real(QB1_C18); - - tc3 += c3; - tc4 += c4; - tc5 += c5; - - NumPerc++; - - if (!almeno_una_riga) - almeno_una_riga = TRUE; - - progn.addstatus(1); - } - - fogli_comp = fogli_compilati(items,0L,QB1_NUMPERC_PER_FOGLIO,0); - - c1 = fogli_comp; -// c2 = items; - - base.setkey(1); - base.zero(); - if (dich) - { - base.put("TIPOQUA", COD_QUA_I_DIC); - base.put(BSE_CODDITTA, dich); - } - else - base.put(BSE_CODDITTA, _codditta); - - if (base.read(_isequal, _lock) == NOERR) - { - base.put(I11_1,c1); - base.put(I11_2,(long)items); - base.put(I11_3,tc3); - base.put(I11_4,tc4); - base.put(I11_5,tc5); - base.rewrite(); - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, _codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(_codditta, B1, almeno_una_riga,basebis,dich); - else - warning_box("Lock fallito in calcola_riporti B1"); - } - else - warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); - - progn.addstatus(1); -} - - -void TRiporti::set_compilato(const long codditta, const int posquadro, const bool compilato) -{ - TLocalisamfile basebis(LF_BASEBIS); - basebis.setkey(1); - basebis.zero(); - basebis.put(BSE_CODDITTA, codditta); - if (basebis.read(_isequal, _lock) == NOERR) - setta_flag_quadri_comp(codditta,posquadro,compilato,basebis); - else - warning_box("Lock fallito in set_compilato"); -} - +// 774200.cpp - Calcolo riporti dei Quadri +// +// Per l'interfaccia vedere 774200.h. +// Il metodo pubblico che fa tutto il lavoro dalla gestione di +// un singolo quadro e' set(). +// +// 774 -1 D : riporto sul quadro I del dichiarante +// +// 774 -1 S : livello di studio oppure +// richiamare la funzione set all' interno +// di ogni programma di gestione quadri. +// +// ATTENZIONE: +// Se si aggiungono o tolgono quadri in build_fill_string() +// bisogna cambiare il numero dei quadri. +// +// 15.3.96 Allungata la stringa QCOMP per far spazio ai quadri A1-2-3 +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "774200.h" +#include "quadroa.h" +#include "quadroa3.h" +#include "quadrob.h" +#include "quadrob1.h" +#include "dipend.h" +#include "quadroh.h" +#include "quadroc.h" +#include "quadrod.h" +#include "quadrod1.h" +#include "quadroe.h" +#include "quadroe1.h" +#include "prospe1.h" +#include "quadroe2.h" +#include "quadrif.h" +#include "quadrog.h" +#include "quadrogd.h" +#include "quadrog1.h" +#include "774200a.h" +#include "77lib.h" + +// Costanti +#define TIPOQUA "TIPOQUA" + +// NB Tutte da spostare in lffiles +#define LF_RIGHEF2 100 +#define LF_RIGHEF1 99 +#define LF_RIGHEF 98 +#define LF_QUAGD 101 + +// inizializzato in TRiporti::set() - usato in filter_func() +HIDDEN TRiporti* this_riporti = NULL; + +HIDDEN TString80 __tmp; + +// Costanti usate per il calcolo dei fogli compilati +HIDDEN const int QE2_FISICHE_PER_FOGLIO = 16; +HIDDEN const int QE2_NOFISICHE_PER_FOGLIO = 9; +HIDDEN const int QGD_FISICHE_PER_FOGLIO = 5; +HIDDEN const int QGD_NOFISICHE_PER_FOGLIO = 6; +HIDDEN const int QD1_FISICHE_PER_FOGLIO = 24; +HIDDEN const int QD1_NOFISICHE_PER_FOGLIO = 8; +HIDDEN const int QD_FISICHE_PER_FOGLIO = 18; +HIDDEN const int QD_NOFISICHE_PER_FOGLIO = 6; +HIDDEN const int QE_FISICHE_PER_FOGLIO = 26; +HIDDEN const int QE_NOFISICHE_PER_FOGLIO = 8; +HIDDEN const int QE1_PERCIPIENTI_PER_FOGLIO = 25; +HIDDEN const int QE1_RIGHE_PROSPETTO = 17; + +HIDDEN long fogli_compilati(const long fisiche, const long nofisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio); +HIDDEN const char* build_fill_string(TString& qcomp); + +class TRiporta_quadri : public TApplication +{ + char _liv; + TRiporti* _riporta; + TMask* _msk; + int _anno_dic; + static bool codditta_handler(TMask_field& f, KEY k); + public: + virtual bool create(); + virtual bool menu(MENU_TAG m); + virtual bool destroy(); + + TRiporti& riporta() { return *_riporta; } + + TRiporta_quadri(char livello) : _liv(toupper(livello)) {} + ~TRiporta_quadri() {} +}; + +TRiporta_quadri& app() { return (TRiporta_quadri&)main_app(); } + +bool TRiporta_quadri::codditta_handler(TMask_field& f, KEY k) +{ + if (k == K_TAB && !(f.mask().is_running()) ) + { + TString16 codditta; + codditta << get_firm_770(); + + if (codditta != "0") + { + f.set(codditta); + f.check(); + } + } + return TRUE; +} + +bool TRiporta_quadri::menu(MENU_TAG m) +{ + if (m == BAR_ITEM(1)) + if (_liv == 'D') + { + TConfig conf(CONFIG_STUDIO); + _anno_dic = (int)conf.get_long(ANNO_SEL, NULL); + _msk->set(F_ANNODIC, _anno_dic); + KEY tast = _msk->run(); + if (tast != K_ENTER) + return FALSE; + const int annod = (int)_msk->get_long(F_ANNODIC); + _riporta->riporti_dich(get_firm_770(), annod); + message_box("Generazione riporti terminata"); + } + return FALSE; +} + +bool TRiporta_quadri::create() +{ + TApplication::create(); + _riporta = new TRiporti; + _msk = new TMask("774200a"); + _msk->set_handler(F_CODDITTA, codditta_handler); + dispatch_e_menu (BAR_ITEM(1)); + return TRUE; +} + +bool TRiporta_quadri::destroy() +{ + delete _riporta; + delete _msk; + return TApplication::destroy(); +} + +int riporti_dich(int argc, char* argv[]) +{ + TRiporta_quadri a(*argv[2]); + a.run(argc, argv, "Generazione riporti"); + return 0; +} + +const char* build_fill_string(TString& qcomp) +{ +// NB cambiare qui il numero dei quadri + const int NUM_QUADRI = 25; // sono 26 posizioni perche' parte da 0 + const int agg = NUM_QUADRI - qcomp.len(); + __tmp.cut(agg); + __tmp.fill(' ', agg); + return __tmp; +} + +void TRiporti::setta_flag_quadri_comp(const long codditta, const int quadro, const bool almeno_una_riga, TLocalisamfile& basebis, const long dich) +{ +/* + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, codditta); + if (basebis.read(_isequal, _lock) == NOERR) + { */ + TString qcomp(basebis.get(BSE_QCOMP)); + TString dep(build_fill_string(qcomp)); + qcomp << dep; + + if (almeno_una_riga) + qcomp[(int)quadro] = 'X'; + else + qcomp[(int)quadro] = ' '; + + basebis.put(BSE_QCOMP, qcomp); + basebis.rewrite(); +/* } + else + warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati"); +*/ +// +// Setta flag quadri compilati del dichiarante; cio' va fatto in 3 casi: +// +// 1. dalla gestione dei singoli quadri di una ditta "estinta". +// 2. dal prg "Riporti" del dichiarante. +// 3. dalla gestione dei quadri del dichiarante stesso. +// + const long codic = sogg_estinto(codditta); + const long ha_dichiarante = dich ? dich : codic; + const bool sono_dichiarante = sogg_dic(codditta); + + if (ha_dichiarante || sono_dichiarante) + { + const long lRecno=basebis.recno(); + basebis.setkey(1); + basebis.zero(); + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSE_CODDITTA, sono_dichiarante ? codditta : ha_dichiarante); + if (basebis.read(_isequal, _lock) == NOERR) + { + TString qcomp(basebis.get(BSE_QCOMP)); + TString dep(build_fill_string(qcomp)); + qcomp << dep; + + if (almeno_una_riga) + qcomp[(int)quadro] = 'X'; + else + qcomp[(int)quadro] = ' '; + + basebis.put(BSE_QCOMP, qcomp); + basebis.rewrite(); + basebis.readat(lRecno); + } + else + warning_box("Dichiarazione non presente: impossibile registrare il campo Quadri compilati"); + } +} + +void TRiporti::setta_flag_quadro_I(const long codditta, const long dich) +{ + bool compilato = FALSE; + TLocalisamfile base (LF_BASE); + TLocalisamfile basebis (LF_BASEBIS); + + base.setkey(1); + base.zero(); + base.put(BSE_CODDITTA, codditta); + base.read(_isequal, _lock); + + basebis.setkey(1); + basebis.zero(); + basebis.put(BSB_CODDITTA, codditta); + basebis.read(_isequal, _lock); + + TString qcomp(basebis.get(BSE_QCOMP)); + TString dep(build_fill_string(qcomp)); + qcomp << dep; +// TString qcomp (format("%25s", (const char*) app)); + +// I campi del quadro I sono in parte su base in parte su basebis + for (int i = 0; i < CAMPI_IB1; i++) + if (base.get_real(_campi_I1[i]) != ZERO) + { + compilato = TRUE; + break; + } + base.reread(_unlock); + + if (!compilato) + { +/* TLocalisamfile basebis (LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSB_CODDITTA, codditta); + basebis.read();*/ + for (int i = 0; i < CAMPI_IB2; i++) + if (basebis.get_real(_campi_I2[i]) != ZERO) + { + compilato = TRUE; + break; + } + } + + if (compilato) + qcomp[(int)I] = 'X'; + else + qcomp[(int)I] = ' '; + + basebis.put(BSE_QCOMP, qcomp); + basebis.rewrite(); +} + + +HIDDEN bool filter_func (const TRelation * rel) +{ + int anno,annod; + annod = this_riporti->_annodic; + anno = rel->lfile().get_int(QUH_H1ANNO); + return anno == annod; +} + +bool TRiporti::riporti_dich(const long dich, const int anno) +{ + long codditta=0L; + long codic=0L; + +// Crea il record I "globale" se non c'e' + enter_dichiar_770(dich, anno, TRUE); + + TLocalisamfile base(LF_BASE); + base.setkey(2); + base.zero(); + base.put("CODDIC", (long)dich); +// TRectype dep(base.curr()); + +// 1. Riporto dai quadri degli estinti al quadro I globale del dichiarante + for (base.read(); !base.eof(); base.next()) + { + codic = base.get_long("CODDIC"); + if (codic != dich) break; +// if (base.curr() > dep) break; + codditta = base.get_long("CODDITTA"); + if (codditta == dich) continue; // scarta il dichiarante stesso + set("*", anno, codditta, dich); + } + +// 2. Somma del quadro I "locale" del dichiarante a quello globale + riporta_I_globale(dich); + + return TRUE; +} + +bool TRiporti::riporta_I_globale(const long dich) +{ + int ret1, ret2; + long c0nfcom, c0nlass, d0nfcom, d0nlaut, d1nfcom, d1nper; + long e0nfcom, e0nper, e1nfcom, e1nper; + real h0codlav, h0coldip; + real c0snsrit, c0rope, c0actot, d0actot, d0snsrit, d0rope, d1tacor, d1snsrit; + real d1rope, e0aimp, e0snsrit, e0rope, e1scor, e1bcom, e1rope, e1acom; + real e1bcom2, e1rope2; + long cc0nfcom, cc0nlass, dd0nfcom, dd0nlaut, dd1nfcom, dd1nper; + long ee0nfcom, ee0nper, ee1nfcom, ee1nper; + real ee0snsrit, ee0rope, ee0aimp, hh0codlav, hh0coldip; + real cc0snsrit, cc0rope, cc0actot, dd0actot, dd0snsrit, dd0rope, dd1tacor; + real dd1snsrit, dd1rope; + real ee1scor, ee1bcom, ee1rope, ee1acom, ee1bcom2, ee1rope2; + + c0nfcom = c0nlass = d0nfcom = d0nlaut = d1nfcom = d1nper = 0; + e1nfcom = e1nper = 0; + + h0codlav = h0coldip = ZERO; + c0snsrit = c0rope = c0actot = d0actot = ZERO; + d0snsrit = d0rope = d1tacor = ZERO; + e1scor = e1bcom = e1rope = ZERO; + e1acom = e1bcom2 = e1rope2 = ZERO; + +// 1. Lettura quadro I "locale" del dichiarante + TLocalisamfile base(LF_BASE); + TLocalisamfile basebis(LF_BASEBIS); + base.zero(); + base.put("CODDITTA", dich); + if (base.read() != NOERR) return FALSE; + basebis.zero(); + basebis.put("CODDITTA", dich); + if (basebis.read() != NOERR) return FALSE; + + d1nfcom = base.get_int(BSE_D1NFCOM); + d1nper = base.get_int(BSE_D1NPER); + d1tacor = base.get_real(BSE_D1TACOR); + d1snsrit = base.get_real(BSE_D1SNSRIT); + d1rope = base.get_real(BSE_D1ROPE); + e1nfcom = basebis.get_int(BSB_E1NFCOM); + e1nper = basebis.get_int(BSB_E1NPER); + e1scor = basebis.get_real(BSB_E1SCOR); + e1bcom = basebis.get_real(BSB_E1BCOM); + e1rope = basebis.get_real(BSB_E1ROPE); + e1acom = basebis.get_int(BSB_E1ACOM); + e1bcom2 = basebis.get_real(BSB_E1BCOM2); + e1rope2 = basebis.get_real(BSB_E1ROPE2); + + e0nfcom = basebis.get_int(BSB_E0NFCOM); + e0nper = basebis.get_int(BSB_E0NPER); + e0aimp = basebis.get_real(BSB_E0AIMP); + e0snsrit = basebis.get_real(BSB_E0SNSRIT); + e0rope = basebis.get_real(BSB_E0ROPE); + + h0codlav = basebis.get_real(BSB_H0CODLAV); + h0coldip = basebis.get_real(BSB_H0COLDIP); + c0nfcom = base.get_int(BSE_C0NFCOM); + c0nlass = base.get_int(BSE_C0NLASS); + c0actot = base.get_real(BSE_C0ACTOT); + c0snsrit = base.get_real(BSE_C0SNSRIT); + c0rope = base.get_real(BSE_C0ROPE); + + d0nfcom = base.get_int(BSE_D0NFCOM); + d0nlaut = base.get_int(BSE_D0NLAUT); + d0actot = base.get_real(BSE_D0ACTOT); + d0snsrit = base.get_real(BSE_D0SNSRIT); + d0rope = base.get_real(BSE_D0ROPE); + +// 2. Riporto nel quadro I globale + base.zero(); +// base.setkey(2); + base.put(TIPOQUA, COD_QUA_I_DIC); + base.put("CODDITTA", (long)dich); + TRectype dep(base.curr()); + ret1 = base.read(); + if (ret1 == _iskeynotfound) + { + base.curr() = dep; + base.write(); + } + basebis.zero(); + basebis.put(TIPOQUA, COD_QUA_I_DIC); + basebis.put("CODDITTA", (long)dich); + TRectype dep2(basebis.curr()); + ret2 = basebis.read(); + if (ret2 == _iskeynotfound) + { + basebis.curr() = dep2; + basebis.write(); + } + + dd1nfcom = base.get_int(BSE_D1NFCOM); + dd1nper = base.get_int(BSE_D1NPER); + dd1tacor = base.get_real(BSE_D1TACOR); + dd1snsrit = base.get_real(BSE_D1SNSRIT); + dd1rope = base.get_real(BSE_D1ROPE); + ee1nfcom = basebis.get_int(BSB_E1NFCOM); + ee1nper = basebis.get_int(BSB_E1NPER); + ee1scor = basebis.get_real(BSB_E1SCOR); + ee1bcom = basebis.get_real(BSB_E1BCOM); + ee1rope = basebis.get_real(BSB_E1ROPE); + ee1acom = basebis.get_int(BSB_E1ACOM); + ee1bcom2 = basebis.get_real(BSB_E1BCOM2); + ee1rope2 = basebis.get_real(BSB_E1ROPE2); + + ee0nfcom = basebis.get_int(BSB_E0NFCOM); + ee0nper = basebis.get_int(BSB_E0NPER); + ee0aimp = basebis.get_real(BSB_E0AIMP); + ee0snsrit = basebis.get_real(BSB_E0SNSRIT); + ee0rope = basebis.get_real(BSB_E0ROPE); + + hh0codlav = basebis.get_real(BSB_H0CODLAV); + hh0coldip = basebis.get_real(BSB_H0COLDIP); + cc0nfcom = base.get_int(BSE_C0NFCOM); + cc0nlass = base.get_int(BSE_C0NLASS); + cc0actot = base.get_real(BSE_C0ACTOT); + cc0snsrit = base.get_real(BSE_C0SNSRIT); + cc0rope = base.get_real(BSE_C0ROPE); + + dd0nfcom = base.get_int(BSE_D0NFCOM); + dd0nlaut = base.get_int(BSE_D0NLAUT); + dd0actot = base.get_real(BSE_D0ACTOT); + dd0snsrit = base.get_real(BSE_D0SNSRIT); + dd0rope = base.get_real(BSE_D0ROPE); + + d1nfcom += dd1nfcom ; + d1nper += dd1nper ; + d1tacor += dd1tacor ; + d1snsrit += dd1snsrit ; + d1rope += dd1rope ; + e1nfcom += ee1nfcom ; + e1nper += ee1nper ; + e1scor += ee1scor ; + e1bcom += ee1bcom ; + e1rope += ee1rope ; + e1acom += ee1acom ; + e1bcom2 += ee1bcom2 ; + e1rope2 += ee1rope2 ; + e0nfcom += ee0nfcom ; + e0nper += ee0nper ; + e0aimp += ee0aimp ; + e0snsrit += ee0snsrit ; + e0rope += ee0rope ; + h0codlav += hh0codlav ; + h0coldip += hh0coldip ; + c0nfcom += cc0nfcom ; + c0nlass += cc0nlass ; + c0actot += cc0actot ; + c0snsrit += cc0snsrit ; + c0rope += cc0rope ; + d0nfcom += dd0nfcom ; + d0nlaut += dd0nlaut ; + d0actot += dd0actot ; + d0snsrit += dd0snsrit ; + d0rope += dd0rope ; + + base.put(BSE_D1NFCOM, d1nfcom); + base.put(BSE_D1NPER, d1nper); + base.put(BSE_D1TACOR, d1tacor); + base.put(BSE_D1SNSRIT, d1snsrit); + base.put(BSE_D1ROPE, d1rope); + basebis.put(BSB_E1NFCOM, e1nfcom); + basebis.put(BSB_E1NPER, e1nper); + basebis.put(BSB_E1SCOR, e1scor); + basebis.put(BSB_E1BCOM, e1bcom); + basebis.put(BSB_E1ROPE, e1rope); + basebis.put(BSB_E1ACOM, e1acom); + basebis.put(BSB_E1BCOM2, e1bcom2); + basebis.put(BSB_E1ROPE2, e1rope2); + + basebis.put(BSB_E0NFCOM, e0nfcom); + basebis.put(BSB_E0NPER, e0nper); + basebis.put(BSB_E0AIMP, e0aimp); + basebis.put(BSB_E0SNSRIT, e0snsrit); + basebis.put(BSB_E0ROPE, e0rope); + + basebis.put(BSB_H0CODLAV, h0codlav); + basebis.put(BSB_H0COLDIP, h0coldip); + base.put(BSE_C0NFCOM, c0nfcom); + base.put(BSE_C0NLASS, c0nlass); + base.put(BSE_C0ACTOT, c0actot); + base.put(BSE_C0SNSRIT, c0snsrit); + base.put(BSE_C0ROPE, c0rope); + + base.put(BSE_D0NFCOM, d0nfcom); + base.put(BSE_D0NLAUT, d0nlaut); + base.put(BSE_D0ACTOT, d0actot); + base.put(BSE_D0SNSRIT, d0snsrit); + base.put(BSE_D0ROPE, d0rope); + + ret1 = base.rewrite(); + ret2 = basebis.rewrite(); + + return TRUE; +} + +// Calcola i riporti dai quadri al quadro I per la ditta codditta. +// Esegue i riporti anche su dichiarante se specificato +bool TRiporti::set(const TString& quadro, int anno, const long codditta, const long dichiarante) +{ + TString16 filt; + TRelation* rel; + TCursor* cur; + long codditta_dich = 0L; + + _codditta = codditta ? codditta : get_firm_770(); + _annodic = anno ? anno : anno_770(); + _quadro = quadro; + + this_riporti = this; + + if (quadro == "A" || quadro == "*") + { + rel = new TRelation (LF_QUAA); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_A(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "A1" || quadro == "*") + { + rel = new TRelation (LF_QUAA1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_A1(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "A2" || quadro == "*") + { + rel = new TRelation (LF_QUAA2); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_A2(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "A3" || quadro == "*") + { + rel = new TRelation (LF_QUAA3); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_A3(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "B" || quadro == "*") + { + rel = new TRelation (LF_QUAB); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_B(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "B1" || quadro == "*") + { + rel = new TRelation (LF_QUAB1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_B1(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "H" || quadro == "*") + { + rel = new TRelation (LF_QUAH); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + cur->set_filterfunction (filter_func); + calcola_riporti_H(cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "C" || quadro == "*") + { + rel = new TRelation (LF_QUAC); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_C (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "D" || quadro == "*") + { + rel = new TRelation (LF_QUAD); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_D (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "D1" || quadro == "*") + { + rel = new TRelation (LF_QUAD1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_D1 (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "E" || quadro == "*") + { + rel = new TRelation (LF_QUAE); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_E (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "E1" || quadro == "*") + { + rel = new TRelation (LF_QUAE1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_E1 (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "E2" || quadro == "*") + { + rel = new TRelation (LF_QUAE2); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_E2 (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "F" || quadro == "*") + { + rel = new TRelation (LF_QUAF); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_F (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "F1" || quadro == "*") + { + rel = new TRelation (LF_QUAF1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_F1 (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "F2" || quadro == "*") + { + rel = new TRelation (LF_QUAF2); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_F2 (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "G" || quadro == "*") + { + rel = new TRelation (LF_QUAG); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_G (cur, dichiarante); + delete cur; delete rel; + } + + if (quadro == "G1" || quadro == "*") + { + rel = new TRelation (LF_QUAG1); + filt.format("CODDITTA=%ld", _codditta); + cur = new TCursor(rel,filt,1); + calcola_riporti_G1 (cur, dichiarante); + delete cur; delete rel; + } + setta_flag_quadro_I(_codditta); + return TRUE; +} + +const int NUM_DIP_A = 9; + +void TRiporti::calcola_riporti_A(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real totale,somme,ritenute; + bool almeno_una_riga = FALSE; + long dipendenti,num_rec; + + real a0cobb,a0cnet,a0eprev,a0iitra,a0cter,a0timp,a0ilor,a0tdet,a0rter,a0rdat; + real a0erit,a0carr,a0aarr,a0darr,a0rarr,a0cinps,a0ciiaut,a0crimpras,a0incdet; + + a0cobb = ZERO; a0cnet = ZERO; a0eprev = ZERO; a0iitra = ZERO; a0cter = ZERO; + a0timp = ZERO; a0ilor = ZERO; a0tdet = ZERO; a0rter = ZERO; a0rdat = ZERO; + a0erit = ZERO; a0carr = ZERO; a0aarr = ZERO; a0darr = ZERO; a0rarr = ZERO; + a0cinps = ZERO; a0ciiaut = ZERO; a0crimpras = a0incdet = ZERO; + + dipendenti = 0; + num_rec = 0; + + (*cur) = 0L; + + TRecnotype items = cur->items(); + TString scritta(60); + + scritta.format("Calcolo riporti del quadro A per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + long coddipp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + progn.addstatus(1); + + long coddip = cur->curr().get_long(QUA_CODIP); + + bool compilato = FALSE; + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + for (int i = 0; i < CAMPI_A; i++) + if (cur->curr().get_real(_campi_A[i]) != ZERO) + { + compilato = TRUE; + break; + } + + if (!compilato) + continue; + + num_rec++; + + if (coddip != coddipp) + if (!is_erede(_codditta,coddip)) + dipendenti++; + + coddipp = coddip; + + int causa = cur->curr().get_int (QUA_CAUSA); + TString codfis = cur->curr().get (QUA_CODFISDL); + char retcon = cur->curr().get_char(QUA_RETCON); + + if (retcon != 'B' && codfis.empty()) + { + a0cobb += cur->curr().get_real(QUA_COBBDIP); + a0cnet += cur->curr().get_real(QUA_COMPNETTI); + a0eprev += cur->curr().get_real(QUA_AIENTIPREV); + a0iitra += cur->curr().get_real(QUA_TOTIMP); +// a0cter += cur->curr().get_real(QUA_CCTAMMCONT) + cur->curr().get_real(QUA_CCTAMNACON); + a0cter += cur->curr().get_real(QUA_CCTAMMCONT); + a0timp += cur->curr().get_real(QUA_TOTIMP2); + a0ilor += cur->curr().get_real(QUA_ICTOTIMP); + a0tdet += cur->curr().get_real(QUA_TOTDET); + a0rter += cur->curr().get_real(QUA_AMRIOT); + a0rdat += cur->curr().get_real(QUA_AMRIODL); + a0erit += cur->curr().get_real(QUA_ECCRITRIMB); + a0carr += cur->curr().get_real("COBBDIP2"); // cas.46 + a0aarr += cur->curr().get_real(QUA_AMMIMP); + a0darr += cur->curr().get_real(QUA_DETIMPOS); + a0rarr += cur->curr().get_real(QUA_RITESEG); + a0incdet += cur->curr().get_real("INCDETFC"); // cas.38 + } + } + + long fogli = num_rec / NUM_DIP_A; + if (num_rec % NUM_DIP_A) + fogli++; + + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal,_lock) == NOERR) + { + base.put(BSE_A0NFCOM, fogli); + base.put(BSE_A0NLDIP, (long)dipendenti); + base.put(BSE_A0COBB, a0cobb); + base.put(BSE_A0CNET, a0cnet); + base.put(BSE_A0EPREV, a0eprev); + base.put(BSE_A0IITRA, a0iitra); + base.put(BSE_A0CTER, a0cter); + base.put(BSE_A0TIMP, a0timp); + base.put(BSE_A0ILOR, a0ilor); + base.put(BSE_A0TDET, a0tdet); + base.put(BSE_A0RTER, a0rter); + base.put(BSE_A0RDAT, a0rdat); + base.put(BSE_A0ERIT, a0erit); + base.put(BSE_A0CARR, a0carr); + base.put(BSE_A0AARR, a0aarr); + base.put(BSE_A0DARR, a0darr); + base.put(BSE_A0RARR, a0rarr); + base.put("A0INCDET", a0incdet); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, A, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti A"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +const int NUM_DIPENDENTI_MODULO_A3 = 35; + +void TRiporti::calcola_riporti_A3(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + bool almeno_una_riga = FALSE; + long dipendenti=0L, num_rec=0L; + real a3rept10=ZERO,a3rept12=ZERO; + + (*cur) = 0L; + TRecnotype items = cur->items(); + TString scritta(60); + scritta.format("Calcolo riporti del quadro A3 per la ditta %ld", _codditta); + TProgind progn(items, scritta, FALSE, TRUE); +// fogli per l'elenco delle trasf. + int iFogliTrasf=0; + int iDipTrasf=0; + + for (int i = 0; i < items; i++, ++(*cur)) + { + progn.addstatus(1); + const long coddip = cur->curr().get_long(QUA_CODIP); + const long nprog = cur->curr().get_long(QUA_NPROG); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + +// Non conta quelli con redditto corrisposto = ZERO + if ((cur->curr().get_real(QA3_REDCOR16) == ZERO) && (cur->curr().get_real(QA3_REDCOR18) == ZERO)) + continue; + +// nprog=2 se e' il record della trasformata. Conto i dip.con trasf. per +// contare i fogli + if (nprog == 2) + iDipTrasf++; + + dipendenti++; + + a3rept10 += cur->curr().get_real(QA3_REDCOR16); + a3rept12 += cur->curr().get_real(QA3_REDCOR18); + } + + long fogli = dipendenti / NUM_DIPENDENTI_MODULO_A3; + if (dipendenti % NUM_DIPENDENTI_MODULO_A3) + fogli++; + iFogliTrasf = iDipTrasf / NUM_DIPENDENTI_MODULO_A3; + if (iDipTrasf % NUM_DIPENDENTI_MODULO_A3) + iFogliTrasf++; + fogli += iFogliTrasf; + + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal,_lock) == NOERR) + { + base.put(BSE_A3NFCOM, fogli); + base.put(BSE_A3NUMPER, (long)dipendenti); + base.put(BSE_A3REPT10, a3rept10); + base.put(BSE_A3REPT12, a3rept12); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, A3, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti A3"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_A1(TCursor* cur, const long dich) +{ + bool almeno_una_riga = FALSE; + + (*cur) = 0L; + + TRecnotype items = cur->items(); + TString scritta(60); + + scritta.format("Calcolo riporti del quadro A1 per la ditta %ld", _codditta); + +// da attivare qualora anche il quadro A1 effettui riporti su quadro I +// TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 0; i < items; i++, ++(*cur)) + { + +// da attivare qualora anche il quadro A1 effettui riporti su quadro I +// progn.addstatus(1); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + } + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, A1, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti A1"); +} + +void TRiporti::calcola_riporti_A2(TCursor* cur, const long dich) +{ + bool almeno_una_riga = FALSE; + (*cur) = 0L; + TRecnotype items = cur->items(); + TString scritta(60); + scritta.format("Calcolo riporti del quadro A2 per la ditta %ld", _codditta); + +// da attivare qualora anche il quadro A2 effettui riporti su quadro I +// TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 0; i < items; i++, ++(*cur)) + { +// da attivare qualora anche il quadro A2 effettui riporti su quadro I +// progn.addstatus(1); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + } + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, A2, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti A2"); +} + +void TRiporti::calcola_riporti_H(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + real ritdat,ritlav; + bool almeno_una_riga = FALSE; + + ritdat = ZERO; + ritlav = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); +// if (items == 0L) return; + TString scritta(60); + scritta.format("Calcolo riporti del quadro H per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 0; i < items; i++, ++(*cur)) + { + ritdat += cur->curr().get_real(QUH_H1DAT); + ritlav += cur->curr().get_real(QUH_H1LAV); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_H0CODLAV, ritdat); + basebis.put(BSB_H0COLDIP, ritlav); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, H, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +const int NUM_PERC_C = 36; + +void TRiporti::calcola_riporti_C(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real totale,somme,ritenute,rTotCSSN; + bool almeno_una_riga = FALSE; + long percipienti=0L; + + totale = ZERO; + somme = ZERO; + ritenute = ZERO; + rTotCSSN = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); +// if (items == 0L) return; + TString scritta(60); + scritta.format("Calcolo riporti del quadro C per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + char tipoa = cur->curr().get_char(QUC_TIPOA); + long codanagr = cur->curr().get_long(QUC_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + totale += cur->curr().get_real(QUC_TOTALE); + somme += cur->curr().get_real(QUC_SOMME); + ritenute += cur->curr().get_real(QUC_RITENUTE); + rTotCSSN += cur->curr().get_real(QUC_CONTSSN); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + long fogli = percipienti / NUM_PERC_C; + if (percipienti % NUM_PERC_C) + fogli++; + + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal,_lock) == NOERR) + { + base.put(BSE_C0NFCOM, fogli); + base.put(BSE_C0NLASS, (long)percipienti); + base.put(BSE_C0ACTOT, totale); + base.put(BSE_C0SNSRIT, somme); + base.put(BSE_C0ROPE, ritenute); + base.put(BSE_C0CONTSSN, rTotCSSN); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, C, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti C"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_D(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real totale,somme,ritenute; + bool almeno_una_riga = FALSE; + int percipienti; + int fisiche,giuridiche; + + percipienti = 0; + fisiche = 0; + giuridiche = 0; + + totale = ZERO; + somme = ZERO; + ritenute = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); +// if (items == 0L) return; + TString scritta(60); + scritta.format("Calcolo riporti del quadro D per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + char tipoa = cur->curr().get_char(QUD_TIPOA); + long codanagr = cur->curr().get_long(QUD_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + if (tipoa == 'F') + fisiche++; + else + if (tipoa == 'G') + giuridiche++; + + totale += cur->curr().get_real(QUD_TOTALE); + somme += cur->curr().get_real(QUD_SOMME); + ritenute += cur->curr().get_real(QUD_IMPORTO); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + const long fogli = fogli_compilati(fisiche,giuridiche,QD_FISICHE_PER_FOGLIO,QD_NOFISICHE_PER_FOGLIO); + + base.setkey(1); + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal,_lock) == NOERR) + { + base.put(BSE_D0NFCOM, fogli); + base.put(BSE_D0NLAUT, (long)percipienti); + base.put(BSE_D0ACTOT, totale); + base.put(BSE_D0SNSRIT, somme); + base.put(BSE_D0ROPE, ritenute); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, D, almeno_una_riga, basebis, dich); + else + warning_box("Lock fallito in calcola_riporti D"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_D1(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real totale,somme,importo; + bool almeno_una_riga = FALSE; + int percipienti,fisiche,giuridiche; + + percipienti = 0; + fisiche = 0; + giuridiche = 0; + + totale = ZERO; + somme = ZERO; + importo = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); + TString scritta(60); + scritta.format("Calcolo riporti del quadro D1 per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + char tipoa = cur->curr().get_char(QD1_TIPOA); + long codanagr = cur->curr().get_long(QD1_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + if (tipoa == 'F') + fisiche++; + else + if (tipoa == 'G') + giuridiche++; + + totale += cur->curr().get_real(QD1_TOTALE); + somme += (cur->curr().get_real(QD1_QUOTAPRO)) + (cur->curr().get_real(QD1_SPESEANT)); + importo += cur->curr().get_real(QD1_IMPORTO); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + const long fogli = fogli_compilati(fisiche,giuridiche,QD1_FISICHE_PER_FOGLIO,QD1_NOFISICHE_PER_FOGLIO); + + base.setkey(1); + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal,_lock) == NOERR) + { + base.put(BSE_D1NFCOM, fogli); + base.put(BSE_D1NPER, (long)percipienti); + base.put(BSE_D1TACOR, totale); + base.put(BSE_D1SNSRIT, somme); + base.put(BSE_D1ROPE, importo); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, D1, almeno_una_riga,basebis,dich); + else + warning_box("Lock fallito in calcola_riporti D1"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_E(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + real imponibile,somme,ritenute; + bool almeno_una_riga = FALSE; + int percipienti,fisiche,giuridiche; + + percipienti = 0; + fisiche = 0; + giuridiche = 0; + + imponibile = ZERO; + somme = ZERO; + ritenute = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); +// if (items == 0L) return; + TString scritta(60); + scritta.format("Calcolo riporti del quadro E per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + char tipoa = cur->curr().get_char(QUE_TIPOA); + long codanagr = cur->curr().get_long(QUE_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + if (tipoa == 'F') + fisiche++; + else + if (tipoa == 'G') + giuridiche++; + + imponibile += cur->curr().get_real(QUE_IMPONIBILE); + somme += cur->curr().get_real(QUE_SOMME); + ritenute += cur->curr().get_real(QUE_IMPORTO); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + const long fogli = fogli_compilati(fisiche,giuridiche,QE_FISICHE_PER_FOGLIO,QE_NOFISICHE_PER_FOGLIO); + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal,_lock) == NOERR) + { + basebis.put(BSB_E0NFCOM, fogli); + basebis.put(BSB_E0NPER, (long)percipienti); + basebis.put(BSB_E0AIMP, imponibile); + basebis.put(BSB_E0SNSRIT, somme); + basebis.put(BSB_E0ROPE, ritenute); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, E, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_E1(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + TRelation* relp; + TCursor* curp; + TString16 filt; + real ammontare,somme,ritenute; + real comp,impo,rite; + bool almeno_una_riga = FALSE; + int percipienti,righep; + + percipienti = 0; + righep = 0; + + ammontare = ZERO; + somme = ZERO; + ritenute = ZERO; + + comp = ZERO; + impo = ZERO; + rite = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); +// if (items == 0L) return; + TString scritta(60); + scritta.format("Calcolo riporti del quadro E1 per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + char tipoa = cur->curr().get_char(QE1_TIPOA); + long codanagr = cur->curr().get_long(QE1_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + ammontare += cur->curr().get_real(QE1_AMMONTARE); + somme += cur->curr().get_real(QE1_SOMME); + ritenute += cur->curr().get_real(QE1_IMPORTO); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + relp = new TRelation (LF_PROSPE1); + filt.format("CODDITTA=%ld", _codditta); + curp = new TCursor(relp,filt,1); + (*curp) = 0L; + TRecnotype itemp = curp->items(); + scritta.format("Calcolo riporti del prospetto del quadro E1 per la ditta %ld", _codditta); + TProgind prognp(itemp, scritta, FALSE, TRUE); + + for (int j = 0; j < itemp; j++, ++(*curp)) + { + righep++; + + comp += curp->curr().get_real(PRE_COMPENSO); + impo += curp->curr().get_real(PRE_IMPONIBILE); + rite += curp->curr().get_real(PRE_RITENUTA); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + prognp.addstatus(1); + } + + delete curp; + delete relp; + + const long fogli = fogli_compilati(percipienti,righep,QE1_PERCIPIENTI_PER_FOGLIO,QE1_RIGHE_PROSPETTO); + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_E1NFCOM, fogli); + basebis.put(BSB_E1NPER, (long)percipienti); + basebis.put(BSB_E1SCOR, somme); + basebis.put(BSB_E1BCOM, ammontare ); + basebis.put(BSB_E1ROPE, ritenute ); + basebis.put(BSB_E1ACOM, comp); + basebis.put(BSB_E1BCOM2, impo); + basebis.put(BSB_E1ROPE2, rite); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, E1, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_E2(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + long fisiche, no_fisiche; + long fogli_comp; + real soggrit, rope; + real comp,impo,rite; + bool almeno_una_riga = FALSE; + double percipienti; + + fisiche = no_fisiche = fogli_comp = 0L; + percipienti = 0.00; + + soggrit = ZERO; + rope = ZERO; + + comp = ZERO; + impo = ZERO; + rite = ZERO; + + (*cur) = 0L; + + TRecnotype items = cur->items(); + TString scritta(60); + scritta.format("Calcolo riporti del quadro E2 per la ditta %ld", _codditta); + + TProgind progn(items, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < items; i++, ++(*cur)) + { + const char tipoa = cur->curr().get_char(QE2_TIPOA); + const long codanagr = cur->curr().get_long(QE2_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + if (tipoa == 'F') + fisiche++; + else + no_fisiche++; + + soggrit += cur->curr().get_real(QE2_SOGGRIT); + rope += cur->curr().get_real(QE2_ROPE); + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + fogli_comp = fogli_compilati(fisiche,no_fisiche,QE2_FISICHE_PER_FOGLIO,QE2_NOFISICHE_PER_FOGLIO); + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_E2NFCOM, fogli_comp); + basebis.put(BSB_E2NPER, (long)percipienti); + basebis.put(BSB_E2SSRIT, soggrit); + basebis.put(BSB_E2ROPE, rope ); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, E2, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_F(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + TLocalisamfile* rf; + TRecord_array* _prosp_a, *_prosp_b, *_prosp_c, *_prosp_d; + real a_sogrit, a_rope, a_totacc, f_rope, e_rope, f_sogrit, e_sogrit; + real b_sogrit, b_rope, c_sogrit, c_rope, d_sogrit, d_rope; + real i20_1, i20_2, i20_3, i20_4, i20_5, i20_6, i21_1, i21_2, i21_3; + bool almeno_una_riga = FALSE; + + a_sogrit = a_rope = a_totacc = ZERO; + b_sogrit = b_rope = c_sogrit = c_rope = d_sogrit = d_rope = ZERO; + f_rope = e_rope = f_sogrit = e_sogrit = ZERO; + i20_1 = i20_2 = i20_3 = i20_4 = i20_5 = i20_6 = i21_1 = i21_2 = i21_3 = ZERO; + + (*cur) = 0L; + TRecnotype items = cur->items(); + + TString scritta(60); + scritta.format("Calcolo riporti del quadro F per la ditta %ld", _codditta); + + i20_4 = cur->curr().get_real(QF0_A1); + i20_5 = cur->curr().get_real(QF0_A2); + i20_6 = cur->curr().get_real(QF0_A3); + i21_1 = cur->curr().get_real(QF0_A4); + e_sogrit = cur->curr().get_real(QF0_ESOGRIT); + f_sogrit = cur->curr().get_real(QF0_FSOGRIT); + e_rope = cur->curr().get_real(QF0_EROPE); + f_rope = cur->curr().get_real(QF0_FROPE); + +// Per stabilire se il quadro e' stato compilato verifica anche i campi +// fuori dagli spreadsheet + almeno_una_riga = i20_4 != ZERO || i20_5 != ZERO || i20_6 != ZERO || + i21_1 != ZERO || e_sogrit != ZERO || f_sogrit != ZERO || e_rope != ZERO || + f_rope != ZERO; + + rf = new TLocalisamfile(LF_RIGHEF); + + TRectype dep(rf->curr()); + dep.zero(); + dep.put("CODDITTA", _codditta); + dep.put("TIPOPRO", "A"); + _prosp_a = new TRecord_array(dep, "NPROG"); + _prosp_a->read(dep); + dep.put("TIPOPRO", "B"); + _prosp_b = new TRecord_array(dep, "NPROG"); + _prosp_b->read(dep); + dep.put("TIPOPRO", "C"); + _prosp_c = new TRecord_array(dep, "NPROG"); + _prosp_c->read(dep); + dep.put("TIPOPRO", "D"); + _prosp_d = new TRecord_array(dep, "NPROG"); + _prosp_d->read(dep); + + items = _prosp_a->last_row() + _prosp_b->last_row() + _prosp_c->last_row() + _prosp_d->last_row(); + TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 1; i <= _prosp_a->last_row(); i++) + { + TRectype& r = _prosp_a->row(i, TRUE); + a_sogrit += r.get_real(RQF0_SOGRIT); + a_rope += r.get_real(RQF0_ROPE); + a_totacc += r.get_real(RQF0_TOTACC); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + i20_1 = a_sogrit; + i20_2 = a_rope; + i20_3 = a_totacc; + + for (i = 1; i <= _prosp_b->last_row(); i++) + { + TRectype& r = _prosp_b->row(i, TRUE); + b_sogrit += r.get_real(RQF0_SOGRIT); + b_rope += r.get_real(RQF0_ROPE); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + + for (i = 1; i <= _prosp_c->last_row(); i++) + { + TRectype& r = _prosp_c->row(i, TRUE); + c_sogrit += r.get_real(RQF0_SOGRIT); + c_rope += r.get_real(RQF0_ROPE); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + + for (i = 1; i <= _prosp_d->last_row(); i++) + { + TRectype& r = _prosp_d->row(i, TRUE); + d_sogrit += r.get_real(RQF0_SOGRIT); + d_rope += r.get_real(RQF0_ROPE); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + + i21_2 += b_sogrit + c_sogrit + d_sogrit + e_sogrit + f_sogrit; + i21_3 += b_rope + c_rope + d_rope + e_rope + f_rope; + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_F0SRITA, i20_1); + basebis.put(BSB_F0ROPEA, i20_2); + basebis.put(BSB_F0TACCA, i20_3); + basebis.put(BSB_F0EDACCA, i20_4); + basebis.put(BSB_F0ERIMA, i20_5); + basebis.put(BSB_F0SSVA, i20_6); + basebis.put(BSB_F0ROPEVA, i21_1); + basebis.put(BSB_F0SSRITBF, i21_2); + basebis.put(BSB_F0ROPEBF, i21_3); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, F, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_F1(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + TLocalisamfile* rf; + TRecord_array* _prosp_b; + real b_sogrit, b_rope; + real i22_1, i22_2; + real f1a1=ZERO, f1a2=ZERO; + bool almeno_una_riga = FALSE; + + b_sogrit = b_rope = ZERO; + i22_1 = i22_2 = ZERO; + + (*cur) = 0L; + TRecnotype items = cur->items(); + + TString scritta(60); + scritta.format("Calcolo riporti del quadro F-1 per la ditta %ld", _codditta); + + f1a1 = cur->curr().get_real("F1_A1"); + f1a2 = cur->curr().get_real("F1_A2"); + almeno_una_riga = (f1a1 != ZERO) || (f1a2 != ZERO); + + rf = new TLocalisamfile(LF_RIGHEF1); + + TRectype dep(rf->curr()); + dep.zero(); + dep.put("CODDITTA", _codditta); + dep.put("TIPOPRO", "B"); + _prosp_b = new TRecord_array(dep, "NPROG"); + _prosp_b->read(dep); + + items = _prosp_b->last_row(); + TProgind progn(items, scritta, FALSE, TRUE); + + i22_1 = cur->curr().get_real(QF1_A1); + i22_2 = cur->curr().get_real(QF1_A2); + + for (int i = 1; i <= _prosp_b->last_row(); i++) + { + TRectype& r = _prosp_b->row(i, TRUE); + b_sogrit += r.get_real(RQF1_SOGRIT); + b_rope += r.get_real(RQF1_ROPE); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + + i22_1 += b_sogrit; + i22_2 += b_rope; + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_F1SSRIT, i22_1); + basebis.put(BSB_F1ROPE, i22_2); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, F1, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +void TRiporti::calcola_riporti_F2(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + TLocalisamfile* rf; + TRecord_array* _prosp_b; + real b_sogrit, b_rope; + real i23_1, i23_2; + bool almeno_una_riga = FALSE; + + b_sogrit = b_rope = ZERO; + i23_1 = i23_2 = ZERO; + + (*cur) = 0L; + TRecnotype items = cur->items(); + + TString scritta(60); + scritta.format("Calcolo riporti del quadro F-2 per la ditta %ld", _codditta); + + rf = new TLocalisamfile(LF_RIGHEF2); + + TRectype dep(rf->curr()); + dep.zero(); + dep.put("CODDITTA", _codditta); + dep.put("TIPOPRO", "B"); + _prosp_b = new TRecord_array(dep, "NPROG"); + _prosp_b->read(dep); + + items = _prosp_b->last_row(); + TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 1; i <= _prosp_b->last_row(); i++) + { + TRectype& r = _prosp_b->row(i, TRUE); + b_sogrit += r.get_real(RQF2_SOGRIT); + b_rope += r.get_real(RQF2_ROPE); + if (!almeno_una_riga) almeno_una_riga = TRUE; + progn.addstatus(1); + } + + i23_1 += b_sogrit; + i23_2 += b_rope; + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_F2SSRIT, i23_1); + basebis.put(BSB_F2ROPE, i23_2); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, F2, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + +// +// fogli_compilati +// +// Determina il numero di fogli compilati: +// Divide il numero di persone (F o G) trovate per il numero +// di posti previsto nel modulo. +// Se il resto e' diverso da 0 conta un foglio in piu' +// +long fogli_compilati(const long fisiche, const long no_fisiche, const int fisiche_x_foglio, const int nofisiche_x_foglio) +{ + long fogli_compilati=0L, fogli_fisiche=0L, fogli_nofisiche=0L; + + if (fisiche > 0L) + { + fogli_fisiche = fisiche / fisiche_x_foglio; + if (fisiche % fisiche_x_foglio) + fogli_fisiche += 1; + } + + if (no_fisiche > 0L) + { + fogli_nofisiche = no_fisiche / nofisiche_x_foglio; + if (no_fisiche % nofisiche_x_foglio) + fogli_nofisiche += 1; + } + fogli_compilati = fogli_fisiche > fogli_nofisiche ? fogli_fisiche : fogli_nofisiche; + return fogli_compilati; +} + +void TRiporti::calcola_riporti_G(TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + real b_sogrit, b_rope; + real i24_1, i24_2, i24_3, i24_4, i24_5, i24_6; + real i24_7, i24_8, i24_9, i24_10, i24_11, i24_12; + real i24_13, i25_4; + bool almeno_una_riga=FALSE, almeno_una_riga_distinta=FALSE,almeno_una_riga_prospetti=FALSE; + long fogli_comp = 0L, percipienti=0L; + TRelation* relp; + TCursor* curp; + int fisiche = 0, no_fisiche = 0; + TString filt(20); + + i24_1 = i24_2 = i24_3 = i24_4 = i24_5 = i24_6 = ZERO; + i24_7 = i24_8 = i24_9 = i24_10 = i24_11 = i24_12 = ZERO; + i24_13 = ZERO; + i25_4 = ZERO; + + (*cur) = 0L; + TRecnotype items = cur->items(); + +// Legge quadro G + i24_2 = cur->curr().get_real(QG_P1NUMQT); + i24_3 = cur->curr().get_real(QG_P1AMMT); + i24_4 = cur->curr().get_real(QG_P2VALT); + i24_5 = cur->curr().get_real(QG_P22TOT); + i24_6 = cur->curr().get_real(QG_P33TOT); + i24_7 = cur->curr().get_real(QG_P35TOT); + i24_8 = cur->curr().get_real(QG_P36TOT); + i24_9 = cur->curr().get_real(QG_P37TOT); + almeno_una_riga_prospetti = i24_2 != ZERO || i24_3 != ZERO + || i24_4 != ZERO + || i24_5 != ZERO || i24_6 != ZERO || i24_7 != ZERO + || i24_8 != ZERO || i24_9 != ZERO; + + TString scritta(60); +// scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta); + +// Scorre quadrogd (distinta) + relp = new TRelation (LF_QUAGD); + filt.format("CODDITTA=%ld", _codditta); + curp = new TCursor(relp,filt,1); + (*curp) = 0L; + TRecnotype ItemDistinta = curp->items(); + scritta.format("Calcolo riporti del quadro G per la ditta %ld", _codditta); + TProgind progn(ItemDistinta, scritta, FALSE, TRUE); + + char tipoap = 'Z'; + long codanagrp = -1; + + for (int i = 0; i < ItemDistinta; i++, ++(*curp)) + { + const char tipoa = curp->curr().get_char(QGD_TIPOA); + const long codanagr = curp->curr().get_long(QGD_CODANAGR); + + if ( (tipoa != tipoap) || (codanagr != codanagrp) ) + percipienti++; + + tipoap = tipoa; + codanagrp = codanagr; + + if (tipoa == 'F') + fisiche++; + else + no_fisiche++; + + i24_11 += curp->curr().get_real(QGD_UTSPETT); + i24_12 += curp->curr().get_real(QGD_UTPAG); + i24_13 += curp->curr().get_real(QGD_ROPE); + i25_4 += curp->curr().get_real(QGD_ROPESPET); + + almeno_una_riga_distinta = TRUE; + + progn.addstatus(1); + } + +// E' compilato se c'e' qualcosa nel G o nella distinta fax 15.7.96 p.1 + almeno_una_riga = almeno_una_riga_prospetti || almeno_una_riga_distinta; + + fogli_comp = fogli_compilati(fisiche,no_fisiche,QGD_FISICHE_PER_FOGLIO,QGD_NOFISICHE_PER_FOGLIO); +// Considera anche la parte del G (prospetti 1-2-3-4) + if (almeno_una_riga_prospetti && fogli_comp==0) + fogli_comp++; + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_G0NFCOM, (long)fogli_comp); + basebis.put(BSB_G0NPER, (long)percipienti); + basebis.put(BSB_G0USPE, i24_11); + basebis.put(BSB_G0UPAG, i24_12); + basebis.put(BSB_G0ROPE, i24_13); + basebis.put(BSB_G0NAZI1, i24_2); + basebis.put(BSB_G0UDEN1, i24_3); + basebis.put(BSB_G0UNAT1, i24_4); + basebis.put(BSB_G0IUTI2, i24_5); + basebis.put(BSB_G0USRIT3, i24_6); + basebis.put(BSB_G0RACC3, i24_7); + basebis.put(BSB_G0RIMP3, i24_8); + basebis.put(BSB_G0UNSRIT3, i24_9); + basebis.put(BSB_G0RITSPET, i25_4); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, G, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); +} + + +void TRiporti::calcola_riporti_G1 (TCursor* cur, const long dich) +{ + TLocalisamfile basebis (LF_BASEBIS); + real i27_1, i27_2, i27_3, i27_4, i27_5; + bool almeno_una_riga = FALSE; + + i27_1 = i27_2 = i27_3 = i27_4 = i27_5 = ZERO; + (*cur) = 0L; + TRecnotype items = cur->items(); + + i27_1 = cur->curr().get_real(QG1_P12TOT); + i27_2 = cur->curr().get_real(QG1_P13TOT); + i27_3 = cur->curr().get_real(QG1_P15TOT); + i27_4 = cur->curr().get_real(QG1_P16TOT); + i27_5 = cur->curr().get_real(QG1_P17TOT); + + almeno_una_riga = (i27_1 != ZERO) || (i27_2 != ZERO) || (i27_3 != ZERO) || + (i27_4 != ZERO) || (i27_5 != ZERO); + TString scritta(60); + scritta.format("Calcolo riporti del quadro G-1 per la ditta %ld", _codditta); + TProgind progn(items, scritta, FALSE, TRUE); + + basebis.setkey(1); + basebis.zero(); + if (dich) + { + basebis.put("TIPOQUA", COD_QUA_I_DIC); + basebis.put(BSB_CODDITTA, dich); + } + else + basebis.put(BSB_CODDITTA, _codditta); + + if (basebis.read(_isequal, _lock) == NOERR) + { + basebis.put(BSB_G1UCOR, i27_1); + basebis.put(BSB_G1USRIT, i27_2); + basebis.put(BSB_G1RACC, i27_3); + basebis.put(BSB_G1RIMP, i27_4); + basebis.put(BSB_G1UNSRIT, i27_5); + basebis.rewrite(); + setta_flag_quadri_comp(_codditta, G1, almeno_una_riga,basebis,dich); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); + + progn.addstatus(1); +} + +HIDDEN const int QB_NUMPERC_PER_FOGLIO = 16; + +void TRiporti::calcola_riporti_B (TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real c3,c4,c5,c6,c7,c8,c9,c10; + real tc3,tc4,tc5,tc6,tc7,tc8,tc9,tc10; + int c2=0; + long c1=0L; + bool almeno_una_riga = FALSE; + int NumPerc=0; + long fogli_comp=0L; + TBit_array baGiaVisto; + + c3=c4=c5=c6=c7=c8=c9=c10=ZERO; + tc3=tc5=tc6=tc7=tc8=tc9=tc10=ZERO; + (*cur) = 0L; + TRecnotype items = cur->items(); + almeno_una_riga = items > 0L; + + TString scritta(60); + scritta.format("Calcolo riporti del quadro B per la ditta %ld", _codditta); + TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 0; i < items; i++, ++(*cur)) + { + const long codditta = cur->curr().get_long(QB_CODDITTA); + const long coddip = cur->curr().get_long(QB_CODDIP); + + if (!baGiaVisto[coddip]) + { + baGiaVisto.set(coddip); + if (!is_erede(codditta, coddip)) + NumPerc++; + } + + c3 = cur->curr().get_real(QB_C20); + c4 = cur->curr().get_real(QB_C24); + c5 = cur->curr().get_real(QB_C25); + c6 = cur->curr().get_real(QB_C26); + c7 = cur->curr().get_real(QB_C27); + c8 = cur->curr().get_real(QB_C36); + c9 = cur->curr().get_real(QB_C37); + c10 = cur->curr().get_real(QB_C43); + + tc3 += c3; + tc4 += c4; + tc5 += c5; + tc6 += c6; + tc7 += c7; + tc8 += c8; + tc9 += c9; + tc10 += c10; + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + fogli_comp = fogli_compilati(items,0L,QB_NUMPERC_PER_FOGLIO,0); + + c1 = fogli_comp; + c2 = NumPerc; + + base.setkey(1); + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal, _lock) == NOERR) + { + base.put(I8_1,c1); + base.put(I8_2,(long)c2); + base.put(I8_3,tc3); + base.put(I8_4,tc4); + base.put(I8_5,tc5); + base.put(I8_6,tc6); + base.put(I9_7,tc7); + base.put(I9_8,tc8); + base.put(I9_9,tc9); + base.put(I9_10,tc10); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, B, almeno_una_riga,basebis,dich); + else + warning_box("Lock fallito in calcola_riporti B"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); + + progn.addstatus(1); +} + +HIDDEN const int QB1_NUMPERC_PER_FOGLIO = 14; + +void TRiporti::calcola_riporti_B1(TCursor* cur, const long dich) +{ + TLocalisamfile base (LF_BASE); + real c3,c4,c5; + real tc3,tc4,tc5; + int c2=0; + bool almeno_una_riga = FALSE; + int NumPerc=0; + long fogli_comp=0L, c1=0L; + + c3=c4=c5=ZERO; + tc3=tc4=tc5=ZERO; + (*cur) = 0L; + TRecnotype items = cur->items(); + almeno_una_riga = items > 0L; + + TString scritta(60); + scritta.format("Calcolo riporti del quadro B-1 per la ditta %ld", _codditta); + TProgind progn(items, scritta, FALSE, TRUE); + + for (int i = 0; i < items; i++, ++(*cur)) + { + c3 = cur->curr().get_real(QB1_C11); + c4 = cur->curr().get_real(QB1_C12); + c5 = cur->curr().get_real(QB1_C18); + + tc3 += c3; + tc4 += c4; + tc5 += c5; + + NumPerc++; + + if (!almeno_una_riga) + almeno_una_riga = TRUE; + + progn.addstatus(1); + } + + fogli_comp = fogli_compilati(items,0L,QB1_NUMPERC_PER_FOGLIO,0); + + c1 = fogli_comp; +// c2 = items; + + base.setkey(1); + base.zero(); + if (dich) + { + base.put("TIPOQUA", COD_QUA_I_DIC); + base.put(BSE_CODDITTA, dich); + } + else + base.put(BSE_CODDITTA, _codditta); + + if (base.read(_isequal, _lock) == NOERR) + { + base.put(I11_1,c1); + base.put(I11_2,(long)items); + base.put(I11_3,tc3); + base.put(I11_4,tc4); + base.put(I11_5,tc5); + base.rewrite(); + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, _codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(_codditta, B1, almeno_una_riga,basebis,dich); + else + warning_box("Lock fallito in calcola_riporti B1"); + } + else + warning_box("Dichiarazione non presente. Impossibile registrare i riporti"); + + progn.addstatus(1); +} + + +void TRiporti::set_compilato(const long codditta, const int posquadro, const bool compilato) +{ + TLocalisamfile basebis(LF_BASEBIS); + basebis.setkey(1); + basebis.zero(); + basebis.put(BSE_CODDITTA, codditta); + if (basebis.read(_isequal, _lock) == NOERR) + setta_flag_quadri_comp(codditta,posquadro,compilato,basebis); + else + warning_box("Lock fallito in set_compilato"); +} + diff --git a/m770/776100.cpp b/m770/776100.cpp index 103b1b636..156ae0776 100755 --- a/m770/776100.cpp +++ b/m770/776100.cpp @@ -25,7 +25,7 @@ HIDDEN TString80 __tmp; HIDDEN const int NUM_QUADRI = 26; -HIDDEN const int QUADRO_L = 30; +HIDDEN const int QUADRO_L = 27; typedef enum { grassetto=0, sottolineato, piano } stile; @@ -38,7 +38,8 @@ class TManutenzione_quadri : public TApplication TLocalisamfile* _base, *_basebis; int _anno_dic; bool _soci; - long _codditta, _coddic; + long _codditta, _coddic; + TString _qcomp_prev; protected: virtual bool create(); @@ -192,7 +193,10 @@ bool TManutenzione_quadri::create() _base = new TLocalisamfile(LF_BASE); _basebis = new TLocalisamfile(LF_BASEBIS); _rel = new TRelation(LF_BASE); - _rel->add(LF_BASEBIS, "CODDITTA=CODDITTA"); + _rel->add(LF_BASEBIS, "CODDITTA=CODDITTA"); + + // inizializza stato precedente quadri per ottimizzazione enphasize + _qcomp_prev.spaces(NUM_QUADRI+1); load_mask(0); dispatch_e_menu (BAR_ITEM(1)); @@ -327,36 +331,50 @@ void TManutenzione_quadri::inibith(TString& qric, TMask& m) } // -// Metto in grassetto i quadri gia' compilati +// Metto in grassetto i quadri gia' compilati +// ma solo quelli variati dal ciclo precedente // Il quadro L non ha il flag di compilato sul base. -// -void TManutenzione_quadri::enphasize(TString& qcomp, TMask& m) +void TManutenzione_quadri::enphasize(TString& qcomp,TMask& m) { - int start_dlg = DLG_NULL_A; - const char* prompt; - const int L = 19; - int dlg = 0; + int start_dlg = DLG_NULL_A; + const char* prompt; + const int L = 19; + int dlg = 0; + char qcompL; + // quadri fino al quadro L non compreso for (int i = 0; i < L; i++) { - dlg = start_dlg + (i * 2); - prompt = make_prompt(i, qcomp[i] == 'X' ? grassetto : piano); - m.field(dlg).set_prompt(prompt); - } - - prompt = esiste_record_L(get_firm_770(), _anno_dic) ? - make_prompt(QUADRO_L, grassetto) : - make_prompt(QUADRO_L, piano); - - dlg = start_dlg + (i * 2); - m.field(dlg).set_prompt(prompt); + if (qcomp[i] != _qcomp_prev[i]) + { + dlg = start_dlg + (i * 2); + prompt = make_prompt(i, qcomp[i] == 'X' ? grassetto : piano); + m.field(dlg).set_prompt(prompt); + _qcomp_prev[i] = qcomp[i]; + } + } + // quadro L + qcompL = esiste_record_L(get_firm_770(), _anno_dic) ? 'X' : ' '; + if (qcompL != _qcomp_prev[QUADRO_L]) + { + dlg = start_dlg + (i * 2); + prompt = make_prompt(QUADRO_L, qcompL == 'X' ? grassetto : piano); + m.field(dlg).set_prompt(prompt); + _qcomp_prev[QUADRO_L] = qcompL; + } + + // rimanenti quadri for (i = L+1; i < NUM_QUADRI; i++) { - int dlg = start_dlg + (i * 2); -// Controlla qcomp[i-1] perche' in QCOMP non c'e' il flag del quadro L - prompt = make_prompt(i-1, qcomp[i-1] == 'X' ? grassetto : piano); - m.field(dlg).set_prompt(prompt); + // Controlla qcomp[i-1] perche' in QCOMP non c'e' il flag del quadro L + if (qcomp[i-1] != _qcomp_prev[i-1]) + { + int dlg = start_dlg + (i * 2); + prompt = make_prompt(i-1, qcomp[i-1] == 'X' ? grassetto : piano); + m.field(dlg).set_prompt(prompt); + _qcomp_prev[i-1] = qcomp[i-1]; + } } } @@ -478,7 +496,7 @@ void TManutenzione_quadri::init_menu(TMask& m) int rt = _basebis->read(); qcomp = _basebis->get("QCOMP"); qric = _basebis->get("QSUPPRIC"); - + if (qcomp == "") qcomp.spaces(); if (qric == "") qric.spaces(); diff --git a/m770/776100b.uml b/m770/776100b.uml index d7be66093..8b4d2a493 100755 --- a/m770/776100b.uml +++ b/m770/776100b.uml @@ -1060,7 +1060,7 @@ BEGIN PROMPT 39 ROW4 "" PICTURE 123 MESSAGE RUN,772MOD,-4,E,D|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END @@ -1076,7 +1076,7 @@ BEGIN PROMPT 39 ROW5 "" PICTURE 123 MESSAGE RUN,772MOD,-4,E1,D|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END @@ -1092,7 +1092,7 @@ BEGIN PROMPT 39 ROW6 "" PICTURE 123 MESSAGE RUN,772MOD,-4,E2,D|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END // Fine terza colonna @@ -1110,7 +1110,7 @@ BEGIN PROMPT 58 ROW1 "" PICTURE 123 // MESSAGE RUN,771MOD,-1|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END @@ -1126,7 +1126,7 @@ BEGIN PROMPT 58 ROW2 "" PICTURE 123 // MESSAGE RUN,771MOD,-1|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END @@ -1142,7 +1142,7 @@ BEGIN PROMPT 58 ROW3 "" PICTURE 123 // MESSAGE RUN,771MOD,-1|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END @@ -1174,7 +1174,7 @@ BEGIN PROMPT 58 ROW5 "" PICTURE 123 // MESSAGE RUN,771MOD,-1|K_TAB,RILEGGI_QUADRI - FLAGS "H" + FLAGS "HD" GROUP MENU_STAMPEDICH END diff --git a/m770/776300.cpp b/m770/776300.cpp index d14be1a24..f5ae7fc42 100755 --- a/m770/776300.cpp +++ b/m770/776300.cpp @@ -1,483 +1,482 @@ -// 776300.cpp - Selezione dichiarazioni per menu' stampe -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "776300a.h" -#include "77lib.h" - -class TSelezioneDich : public TConfig_application -{ - TString16 _section; - TBit_array _selected; - TArray_sheet* _ditte, * _ditte_sel; - TArray _nomiditte; - TArray _old_ditte; - TConfig* _user_cnf, * _studio_cnf; - int _n_ditte; - int _anno_dic; - TRelation* _nditte; - long _da_cod, _a_cod; - bool _builded_nomiditte; - - void build_nomiditte(); - void build_ditte_sheet(); - void build_ditte_sel_sheet(); - bool is_in (long codditta); - void init_sheet(); - void check_all_dic(); - - public: - void set_choice_limits(TMask& m); - long select_firm_range(long from, long to); - long set_previous_firm_range(); -// handlers & handlers - static bool to_ditt_handler (TMask_field&, KEY); - static bool fr_ditt_handler (TMask_field&, KEY); - static bool to_butt_handler (TMask_field&, KEY); - static bool fr_butt_handler (TMask_field&, KEY); - static bool mask_select (TMask_field&, KEY); - static bool mask_azzera (TMask_field&, KEY); -// Seleziona tutte le dic - static bool tutte_handler (TMask_field&, KEY); -// Mostra solo le selezionate - static bool dicsel_handler (TMask_field&, KEY); - - virtual bool preprocess_config (TMask& mask, TConfig& config); - virtual bool postprocess_config (TMask& mask, TConfig& config); -// virtual bool postprocess_config_changed(const char* par, const char* var,const char* oldv, const char* newv); - - virtual bool user_create(); - virtual bool user_destroy(); - virtual bool firm_change_enabled() const; - TSelezioneDich() : TConfig_application(CONFIG_USER) , - _a_cod(0L), _da_cod(0L) {} - virtual ~TSelezioneDich() {} -}; - -HIDDEN TSelezioneDich& app() { return (TSelezioneDich&) main_app(); } - -bool TSelezioneDich::user_create() -{ - const char* edit_mask = "776300a"; - _section = name(); - _section.cut(2); - -// Forza la scrittura del file in partenza -// (onde evitare di vedere il messaggio "Nessun parametro da configurare" e di dover -// rientrare). - TConfig* tmp = new TConfig(CONFIG_USER, _section); - tmp->get("EdMask", _section, -1, edit_mask); - delete tmp; - - _user_cnf = new TConfig(CONFIG_USER, _section); - _user_cnf->get("EdMask", _section, -1, edit_mask); - - _studio_cnf = new TConfig(CONFIG_STUDIO); - - _nditte = new TRelation(LF_NDITTE); - _nditte->add(LF_BASE,"CODDITTA=CODDITTA"); - - _ditte = new TArray_sheet(11, 1, 67, 20, "Seleziona dichiarazioni", - "@1|Cod.@5|Ragione Sociale@50"); - - _ditte_sel = new TArray_sheet(11, 1, 67, 20, "Dichiarazioni selezionate", - "@1|Cod.@5|Ragione Sociale@50", 0); - - _builded_nomiditte = FALSE; - - return TRUE; -} - -bool TSelezioneDich::user_destroy() -{ - delete _ditte; - delete _ditte_sel; - delete _nditte; - delete _user_cnf; - delete _studio_cnf; - return TRUE; -} - -bool TSelezioneDich::firm_change_enabled() const -{ - return FALSE; -} - -void TSelezioneDich::init_sheet() -{ - _n_ditte = 0l; - _old_ditte.destroy(); - - if (!_builded_nomiditte) - { - build_nomiditte(); - _builded_nomiditte = TRUE; - } - -// Legge ditte selezionate dal CONFIG_USER e mette nell'array _old_ditte - long codditta = 0L; - int i = 0; - TString16 cods; - while ((codditta = _user_cnf->get_long(DITTE_SEL, _section, i++)) != 0L) - { -// Salvo il primo e l'ultimo codice ditta per settare i campi in maschera - if (_da_cod == 0L) _da_cod = codditta; - _a_cod = codditta; - - cods.format("%5ld", codditta); - _old_ditte.add(cods); - } - - build_ditte_sheet(); -} - -bool TSelezioneDich::preprocess_config (TMask& m, TConfig& config) -{ - init_sheet(); - -// Setto l'anno dichiarazione con quello preso dai parametri di studio -// ma SOLO SE non gia' compilato nei par. utente - _anno_dic = (int)_user_cnf->get_long(ANNO_SEL, _section); - if (_anno_dic == 0) - _anno_dic = (int)_studio_cnf->get_long(ANNO_SEL, _section); - - m.set(F_ANNODIC, _anno_dic); - -// const long l = select_firm_range(_da_cod, _a_cod); -// Evidenzia le ditte precedentemente selezionate. Legge _old_ditte - const long l = set_previous_firm_range(); - - set_choice_limits(m); - m.field(F_SELECT).set(format("%ld", l)); - - m.set_handler (DLG_SELECT_2, mask_select); - m.set_handler (F_ANNULLA, mask_azzera); - m.set_handler (A_CODICE, to_ditt_handler); - m.set_handler (DA_CODICE, fr_ditt_handler); - m.set_handler (F_TUTTE, tutte_handler); - m.set_handler (F_DICSEL, dicsel_handler); - - return TRUE; -} - -bool TSelezioneDich::is_in (long codditta) -{ - for (int i=0; i<_old_ditte.items(); i++) - if (codditta == atol((TString&)_old_ditte[i])) - return TRUE; - return FALSE; -} - -bool TSelezioneDich::postprocess_config (TMask& m, TConfig& config) -{ - if (m.last_key() == K_ENTER) - { - const int anno_dic = m.get_int(F_ANNODIC); - const long selec = _ditte->checked(); - const long items = _ditte->items(); - - TProgind prg(items, "Registrazione in corso\nAttendere prego...", FALSE, TRUE); - -// Registro l'anno dic. nei parametri utente - _user_cnf->set(ANNO_SEL, anno_dic); - -// Compatto l'array delle ditte nel .ini - int ditte_in_ini = 0; - - long codditta = 0L; - for (int i = 0; i < items; i++) - { - if (_selected[i]) - { - TToken_string& d = (TToken_string&)_nomiditte[i]; - codditta = d.get_long(1); - _user_cnf->set(DITTE_SEL, codditta, _section, TRUE, ditte_in_ini); - ditte_in_ini++ ; - } - prg.addstatus(1); - } - -// Segno l'ultima ditta nel .ini - _user_cnf->set(DITTE_SEL, "", _section, TRUE, ditte_in_ini); -// Reset dei due codici ditta "Da" "A" - _a_cod = _da_cod = 0L; - } - return TRUE; -} - -bool TSelezioneDich::mask_select (TMask_field& f, KEY k) -{ - if (k == K_SPACE) - { - app()._ditte->enable_check(); - // seleziona e aggiungi alle gia' selezionate - if (app()._ditte->run() == K_ENTER) - { - for (long j = 0l; j < app()._ditte->items(); j++) - app()._selected.set(j, app()._ditte->checked(j)); - app().set_choice_limits(f.mask()); - } - } - return TRUE; -} - -bool TSelezioneDich::mask_azzera (TMask_field& f, KEY k) -{ - if (k == K_SPACE) - { - app()._selected.reset(); - f.mask().reset(F_SELECT); - f.mask().reset(DA_CODICE); - f.mask().reset(A_CODICE); - app()._ditte->check(-1, FALSE); - } - return TRUE; -} - -// --------------------------- handlers per selezione ditte - -bool TSelezioneDich::to_ditt_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask(); - if (key == K_F9) - { - app().to_butt_handler(f, K_SPACE); - } - if (key == K_TAB && f.focusdirty()) - { - const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); - app().set_choice_limits(m); - m.field(F_SELECT).set(format("%ld", l)); - } - return TRUE; -} - -bool TSelezioneDich::fr_ditt_handler(TMask_field& f, KEY key) -{ - TMask& m = f.mask(); - if (key == K_F9) - { - app().fr_butt_handler(f, K_SPACE); - } - else if (key == K_TAB && f.focusdirty()) - { - const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); - app().set_choice_limits(m); - m.field(F_SELECT).set(format("%ld", l)); - } - return TRUE; -} - -bool TSelezioneDich::to_butt_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - TArray_sheet* sh = app()._ditte; - TMask& m = f.mask(); - - sh->disable_check(); - if (sh->run() == K_ENTER) - { - app().select_firm_range(m.get_long(DA_CODICE),sh->row(sh->selected()).get_long(1)); - app().set_choice_limits(m); - } - } - return TRUE; -} - -bool TSelezioneDich::fr_butt_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - TMask& m = f.mask(); - TArray_sheet* sh = app()._ditte; - - sh->disable_check(); - if (sh->run() == K_ENTER) - { - app().select_firm_range(sh->row(sh->selected()).get_long(1), m.get_long(A_CODICE)); - app().set_choice_limits(m); - } - } - return TRUE; -} - -void TSelezioneDich::check_all_dic() -{ - for (int i = 0; i < _ditte->items(); i++) - _ditte->check(i); -} - -bool TSelezioneDich::tutte_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - const bool checked = (f.get() == "X"); - - if (checked) - { - app().check_all_dic(); - app().select_firm_range(0L,0L); - app().set_choice_limits(f.mask()); - } - } - return TRUE; -} - -bool TSelezioneDich::dicsel_handler(TMask_field& f, KEY key) -{ - if (key == K_SPACE) - { - app().build_ditte_sel_sheet(); - app()._ditte_sel->run(); - } - return TRUE; -} - -void TSelezioneDich::set_choice_limits(TMask& m) -{ - long first = -1l, last = -1l; - for (int i = 0; i < _ditte->items(); i++) - { - if (_selected[i]) - { - long dit = _ditte->row(i).get_long(1); - if (first == -1l) first = dit; - if (last < dit) last = dit; - } - } - if (first != -1) m.field(DA_CODICE).set(format("%ld",first)); - if (last != -1) m.field(A_CODICE).set(format("%ld",last)); - m.set(F_SELECT, _selected.ones()); -} - -// Legge da _old_ditte le ditte selezionate e le evidenzia -long TSelezioneDich::set_previous_firm_range() -{ - const long items = _old_ditte.items(); - for (int i=0; i < items; i++) - { - const long codditta = atol((TString&)_old_ditte[i]); - - for (int dit=0; dit < _ditte->items(); dit++) - { - TToken_string& d = _ditte->row(dit); - const long cod = d.get_long(1); - - if (codditta == cod) - { - _selected.set(dit); - _ditte->check(dit); - break; - } -/************************ - else - { - _selected.set(dit,FALSE); - _ditte->uncheck(dit); - } -**************************/ - } - } - return _selected.ones(); -} - -long TSelezioneDich::select_firm_range(long from, long to) -{ - if (to == 0l) to = 99999L; - for (int i = 0; i < _ditte->items(); i++) - { - if (_ditte->row_disabled(i)) - continue; - - TToken_string& d = _ditte->row(i); - - const long cod = d.get_long(1); - if (cod >= from && cod <= to) - { - _selected.set(i); - _ditte->check(i); - } - else - { - _selected.set(i,FALSE); - _ditte->uncheck(i); - } - } - return _selected.ones(); -} - -// 23/6/95 - Scelta ditte solo tra quelle che hanno dichiarazione -void TSelezioneDich::build_nomiditte() -{ - _nomiditte.destroy(); - // ricostruire _nomiditte e rifare build_ditte_sheet - TRectype& dt = _nditte->curr(); - TProgind prg(dt.items(), "Lettura ditte in corso\nAttendere prego...", FALSE, TRUE); - - for (_nditte->first(); !_nditte->eof(); _nditte->next()) - { - prg.addstatus(1); - _n_ditte++; - TToken_string* d = new TToken_string(64); - d->add(" "); // spazio per la selezione - d->add(dt.get("CODDITTA")); - d->add(dt.get("RAGSOC")); - _nomiditte.add(d); - } -} - -void TSelezioneDich::build_ditte_sheet() -{ - long codditta = 0L; - // build sheet - _ditte->destroy(); - for (int i = 0; i < _nomiditte.items(); i++) - { - TToken_string* d = new TToken_string(64); - *d = (TToken_string&)_nomiditte[i]; - codditta = d->get_long(1); - - const long pos = _ditte->add(d); -// Metto check se selezionata o era nei parametri precedenti - if (_selected[i] || is_in(codditta)) - _ditte->check(pos); - } -} - -// Costruisce un array sheet copiando da nomiditte solo quelle -// gia' selezionate -void TSelezioneDich::build_ditte_sel_sheet() -{ - long codditta = 0L; - // build sheet - _ditte_sel->destroy(); - for (int i = 0; i < _nomiditte.items(); i++) - { - TToken_string* d = new TToken_string(64); - *d = (TToken_string&)_nomiditte[i]; - codditta = d->get_long(1); - -// se selezionata o era nei parametri precedenti - if (_selected[i]) - { - const long pos = _ditte_sel->add(d); -// _ditte_sel->check(pos); - } - } -} - -int SelezioneDichiarazioni(int argc, char* argv[]) -{ - TSelezioneDich app; - app.run(argc, argv, "Selezione dichiarazione"); - return 0; -} - +// 776300.cpp - Selezione dichiarazioni per menu' stampe +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "776300a.h" +#include "77lib.h" + +class TSelezioneDich : public TConfig_application +{ + TString16 _section; + TBit_array _selected; + TArray_sheet* _ditte, * _ditte_sel; + TArray _nomiditte; + TArray _old_ditte; + TConfig* _user_cnf, * _studio_cnf; + int _n_ditte; + int _anno_dic; + TRelation* _nditte; + long _da_cod, _a_cod; + bool _builded_nomiditte; + + void build_nomiditte(); + void build_ditte_sheet(); + void build_ditte_sel_sheet(); + bool is_in (long codditta); + void init_sheet(); + void check_all_dic(); + + public: + void set_choice_limits(TMask& m); + long select_firm_range(long from, long to); + long set_previous_firm_range(); +// handlers & handlers + static bool to_ditt_handler (TMask_field&, KEY); + static bool fr_ditt_handler (TMask_field&, KEY); + static bool to_butt_handler (TMask_field&, KEY); + static bool fr_butt_handler (TMask_field&, KEY); + static bool mask_select (TMask_field&, KEY); + static bool mask_azzera (TMask_field&, KEY); +// Seleziona tutte le dic + static bool tutte_handler (TMask_field&, KEY); +// Mostra solo le selezionate + static bool dicsel_handler (TMask_field&, KEY); + + virtual bool preprocess_config (TMask& mask, TConfig& config); + virtual bool postprocess_config (TMask& mask, TConfig& config); +// virtual bool postprocess_config_changed(const char* par, const char* var,const char* oldv, const char* newv); + + virtual bool user_create(); + virtual bool user_destroy(); + virtual bool firm_change_enabled() const; + TSelezioneDich() : TConfig_application(CONFIG_USER) , + _a_cod(0L), _da_cod(0L) {} + virtual ~TSelezioneDich() {} +}; + +HIDDEN TSelezioneDich& app() { return (TSelezioneDich&) main_app(); } + +bool TSelezioneDich::user_create() +{ + const char* edit_mask = "776300a"; + _section = name(); + _section.cut(2); + +// Forza la scrittura del file in partenza +// (onde evitare di vedere il messaggio "Nessun parametro da configurare" e di dover +// rientrare). + TConfig* tmp = new TConfig(CONFIG_USER, _section); + tmp->get("EdMask", _section, -1, edit_mask); + delete tmp; + + _user_cnf = new TConfig(CONFIG_USER, _section); + _user_cnf->get("EdMask", _section, -1, edit_mask); + + _studio_cnf = new TConfig(CONFIG_STUDIO); + + _nditte = new TRelation(LF_NDITTE); + _nditte->add(LF_BASE,"CODDITTA=CODDITTA"); + + _ditte = new TArray_sheet(11, 1, 67, 20, "Seleziona dichiarazioni", + "@1|Cod.@5|Ragione Sociale@50"); + + _ditte_sel = new TArray_sheet(11, 1, 67, 20, "Dichiarazioni selezionate", + "Cod.@5|Ragione Sociale@50", 0x10); + + _builded_nomiditte = FALSE; + + return TRUE; +} + +bool TSelezioneDich::user_destroy() +{ + delete _ditte; + delete _ditte_sel; + delete _nditte; + delete _user_cnf; + delete _studio_cnf; + return TRUE; +} + +bool TSelezioneDich::firm_change_enabled() const +{ + return FALSE; +} + +void TSelezioneDich::init_sheet() +{ + _n_ditte = 0l; + _old_ditte.destroy(); + + if (!_builded_nomiditte) + { + build_nomiditte(); + _builded_nomiditte = TRUE; + } + +// Legge ditte selezionate dal CONFIG_USER e mette nell'array _old_ditte + long codditta = 0L; + int i = 0; + TString16 cods; + while ((codditta = _user_cnf->get_long(DITTE_SEL, _section, i++)) != 0L) + { +// Salvo il primo e l'ultimo codice ditta per settare i campi in maschera + if (_da_cod == 0L) _da_cod = codditta; + _a_cod = codditta; + + cods.format("%5ld", codditta); + _old_ditte.add(cods); + } + + build_ditte_sheet(); +} + +bool TSelezioneDich::preprocess_config (TMask& m, TConfig& config) +{ + init_sheet(); + +// Setto l'anno dichiarazione con quello preso dai parametri di studio +// ma SOLO SE non gia' compilato nei par. utente + _anno_dic = (int)_user_cnf->get_long(ANNO_SEL, _section); + if (_anno_dic == 0) + _anno_dic = (int)_studio_cnf->get_long(ANNO_SEL, _section); + + m.set(F_ANNODIC, _anno_dic); + +// const long l = select_firm_range(_da_cod, _a_cod); +// Evidenzia le ditte precedentemente selezionate. Legge _old_ditte + const long l = set_previous_firm_range(); + + set_choice_limits(m); + m.field(F_SELECT).set(format("%ld", l)); + + m.set_handler (DLG_SELECT_2, mask_select); + m.set_handler (F_ANNULLA, mask_azzera); + m.set_handler (A_CODICE, to_ditt_handler); + m.set_handler (DA_CODICE, fr_ditt_handler); + m.set_handler (F_TUTTE, tutte_handler); + m.set_handler (F_DICSEL, dicsel_handler); + + return TRUE; +} + +bool TSelezioneDich::is_in (long codditta) +{ + for (int i=0; i<_old_ditte.items(); i++) + if (codditta == atol((TString&)_old_ditte[i])) + return TRUE; + return FALSE; +} + +bool TSelezioneDich::postprocess_config (TMask& m, TConfig& config) +{ + if (m.last_key() == K_ENTER) + { + const int anno_dic = m.get_int(F_ANNODIC); + const long selec = _ditte->checked(); + const long items = _ditte->items(); + + TProgind prg(items, "Registrazione in corso\nAttendere prego...", FALSE, TRUE); + +// Registro l'anno dic. nei parametri utente + _user_cnf->set(ANNO_SEL, anno_dic); + +// Compatto l'array delle ditte nel .ini + int ditte_in_ini = 0; + + long codditta = 0L; + for (int i = 0; i < items; i++) + { + if (_selected[i]) + { + TToken_string& d = (TToken_string&)_nomiditte[i]; + codditta = d.get_long(1); + _user_cnf->set(DITTE_SEL, codditta, _section, TRUE, ditte_in_ini); + ditte_in_ini++ ; + } + prg.addstatus(1); + } + +// Segno l'ultima ditta nel .ini + _user_cnf->set(DITTE_SEL, "", _section, TRUE, ditte_in_ini); +// Reset dei due codici ditta "Da" "A" + _a_cod = _da_cod = 0L; + } + return TRUE; +} + +bool TSelezioneDich::mask_select (TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + app()._ditte->enable_check(); + // seleziona e aggiungi alle gia' selezionate + if (app()._ditte->run() == K_ENTER) + { + for (long j = 0l; j < app()._ditte->items(); j++) + app()._selected.set(j, app()._ditte->checked(j)); + app().set_choice_limits(f.mask()); + } + } + return TRUE; +} + +bool TSelezioneDich::mask_azzera (TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + app()._selected.reset(); + f.mask().reset(F_SELECT); + f.mask().reset(DA_CODICE); + f.mask().reset(A_CODICE); + app()._ditte->check(-1, FALSE); + } + return TRUE; +} + +// --------------------------- handlers per selezione ditte + +bool TSelezioneDich::to_ditt_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask(); + if (key == K_F9) + { + app().to_butt_handler(f, K_SPACE); + } + if (key == K_TAB && f.focusdirty()) + { + const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().set_choice_limits(m); + m.field(F_SELECT).set(format("%ld", l)); + } + return TRUE; +} + +bool TSelezioneDich::fr_ditt_handler(TMask_field& f, KEY key) +{ + TMask& m = f.mask(); + if (key == K_F9) + { + app().fr_butt_handler(f, K_SPACE); + } + else if (key == K_TAB && f.focusdirty()) + { + const long l = app().select_firm_range(m.get_long(DA_CODICE), m.get_long(A_CODICE)); + app().set_choice_limits(m); + m.field(F_SELECT).set(format("%ld", l)); + } + return TRUE; +} + +bool TSelezioneDich::to_butt_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TArray_sheet* sh = app()._ditte; + TMask& m = f.mask(); + + sh->disable_check(); + if (sh->run() == K_ENTER) + { + app().select_firm_range(m.get_long(DA_CODICE),sh->row(sh->selected()).get_long(1)); + app().set_choice_limits(m); + } + } + return TRUE; +} + +bool TSelezioneDich::fr_butt_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + TMask& m = f.mask(); + TArray_sheet* sh = app()._ditte; + + sh->disable_check(); + if (sh->run() == K_ENTER) + { + app().select_firm_range(sh->row(sh->selected()).get_long(1), m.get_long(A_CODICE)); + app().set_choice_limits(m); + } + } + return TRUE; +} + +void TSelezioneDich::check_all_dic() +{ + for (int i = 0; i < _ditte->items(); i++) + _ditte->check(i); +} + +bool TSelezioneDich::tutte_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + const bool checked = (f.get() == "X"); + + if (checked) + { + app().check_all_dic(); + app().select_firm_range(0L,0L); + app().set_choice_limits(f.mask()); + } + } + return TRUE; +} + +bool TSelezioneDich::dicsel_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + app().build_ditte_sel_sheet(); + app()._ditte_sel->run(); + } + return TRUE; +} + +void TSelezioneDich::set_choice_limits(TMask& m) +{ + long first = -1l, last = -1l; + for (int i = 0; i < _ditte->items(); i++) + { + if (_selected[i]) + { + long dit = _ditte->row(i).get_long(1); + if (first == -1l) first = dit; + if (last < dit) last = dit; + } + } + if (first != -1) m.field(DA_CODICE).set(format("%ld",first)); + if (last != -1) m.field(A_CODICE).set(format("%ld",last)); + m.set(F_SELECT, _selected.ones()); +} + +// Legge da _old_ditte le ditte selezionate e le evidenzia +long TSelezioneDich::set_previous_firm_range() +{ + const long items = _old_ditte.items(); + for (int i=0; i < items; i++) + { + const long codditta = atol((TString&)_old_ditte[i]); + + for (int dit=0; dit < _ditte->items(); dit++) + { + TToken_string& d = _ditte->row(dit); + const long cod = d.get_long(1); + + if (codditta == cod) + { + _selected.set(dit); + _ditte->check(dit); + break; + } +/************************ + else + { + _selected.set(dit,FALSE); + _ditte->uncheck(dit); + } +**************************/ + } + } + return _selected.ones(); +} + +long TSelezioneDich::select_firm_range(long from, long to) +{ + if (to == 0l) to = 99999L; + for (int i = 0; i < _ditte->items(); i++) + { + if (_ditte->row_disabled(i)) + continue; + + TToken_string& d = _ditte->row(i); + + const long cod = d.get_long(1); + if (cod >= from && cod <= to) + { + _selected.set(i); + _ditte->check(i); + } + else + { + _selected.set(i,FALSE); + _ditte->uncheck(i); + } + } + return _selected.ones(); +} + +// 23/6/95 - Scelta ditte solo tra quelle che hanno dichiarazione +void TSelezioneDich::build_nomiditte() +{ + _nomiditte.destroy(); + // ricostruire _nomiditte e rifare build_ditte_sheet + TRectype& dt = _nditte->curr(); + TProgind prg(dt.items(), "Lettura ditte in corso\nAttendere prego...", FALSE, TRUE); + + for (_nditte->first(); !_nditte->eof(); _nditte->next()) + { + prg.addstatus(1); + _n_ditte++; + TToken_string* d = new TToken_string(64); + d->add(" "); // spazio per la selezione + d->add(dt.get("CODDITTA")); + d->add(dt.get("RAGSOC")); + _nomiditte.add(d); + } +} + +void TSelezioneDich::build_ditte_sheet() +{ + long codditta = 0L; + // build sheet + _ditte->destroy(); + for (int i = 0; i < _nomiditte.items(); i++) + { + TToken_string* d = new TToken_string(64); + *d = (TToken_string&)_nomiditte[i]; + codditta = d->get_long(1); + + const long pos = _ditte->add(d); +// Metto check se selezionata o era nei parametri precedenti + if (_selected[i] || is_in(codditta)) + _ditte->check(pos); + } +} + +// Costruisce un array sheet copiando da nomiditte solo quelle +// gia' selezionate +void TSelezioneDich::build_ditte_sel_sheet() +{ + + // build sheet + _ditte_sel->destroy(); + for (int i = 0; i < _nomiditte.items(); i++) + { + // copia da quelle selezionate + TToken_string* d = new TToken_string(64); + *d = (TToken_string&)_nomiditte[i]; + // elimina il token riservato alla selezione + d->destroy(0); + + // se selezionata o era nei parametri precedenti + if (_selected[i]) + const long pos = _ditte_sel->add(d); + } +} + +int SelezioneDichiarazioni(int argc, char* argv[]) +{ + TSelezioneDich app; + app.run(argc, argv, "Selezione dichiarazione"); + return 0; +} + diff --git a/m770/776300a.uml b/m770/776300a.uml index 3b0affa81..76873ce0a 100755 --- a/m770/776300a.uml +++ b/m770/776300a.uml @@ -60,7 +60,7 @@ END STRING F_SELECT 5 BEGIN PROMPT 2 8 "Dichiarazioni selezionate " - FLAGS "D" + FLAGS "DR" END NUMBER F_ANNODIC 4 diff --git a/m770/77g1.cpp b/m770/77g1.cpp index c85bbc411..9c867b3ed 100755 --- a/m770/77g1.cpp +++ b/m770/77g1.cpp @@ -32,8 +32,7 @@ void TQuadroG1::init_insert_mode (TMask& m) void TQuadroG1::init_modify_mode (TMask& m) { -// init_mask(m); - m.disable(DLG_DELREC); + } int TQuadroG1::read(TMask& m) @@ -98,6 +97,7 @@ bool TQuadroG1::user_create() _msk->disable(DLG_NEWREC); // disabilito Nuovo nella toolbar _msk->disable(DLG_DELREC); // disabilito Elimina nella toolbar _msk->disable(DLG_FINDREC); // disabilito Ricerca nella toolbar + _msk->set_handler(mainmsk_handler); TSheet_field& p1 = (TSheet_field&) _msk->field(F_PI); p1.set_notify(p1_notify); return TRUE; @@ -250,8 +250,8 @@ int TQuadroG1::rewrite(const TMask& m) bool TQuadroG1::remove() { - const bool ok = TRelation_application::remove(); - return ok; + _registra = TRelation_application::remove(); + return _registra; } bool TQuadroG1::p1_notify(TSheet_field& s, int r, KEY k) @@ -276,4 +276,13 @@ bool TQuadroG1::p1_notify(TSheet_field& s, int r, KEY k) } return TRUE; } - + +bool TQuadroG1::mainmsk_handler(TMask& m, KEY k) +{ + if (k == K_ESC) + { + TOperable_field& f = m.focus_field(); + m.set_focus_field(f.dlg()); + } + return TRUE; +} diff --git a/m770/77qn.uml b/m770/77qn.uml index ae9808d0d..655418f26 100755 --- a/m770/77qn.uml +++ b/m770/77qn.uml @@ -46,8 +46,8 @@ BEGIN DISPLAY "N°" NPROG DISPLAY "Mese" MESERIF DISPLAY "Anno" ANNORIF - DISPLAY "Imposta rimborsata" IMPOSTA - DISPLAY "Compensi per l'assistenza" COMPENSI + DISPLAY "Imposta rimborsata" IMPOSTA + DISPLAY "Compensi per l'assistenza" COMPENSI OUTPUT QNF_NPROG NPROG OUTPUT QNF_COMPENSI COMPENSI OUTPUT QNF_IMPOSTA IMPOSTA diff --git a/m770/77qp.uml b/m770/77qp.uml index 514324441..460337791 100755 --- a/m770/77qp.uml +++ b/m770/77qp.uml @@ -53,11 +53,11 @@ BEGIN INPUT NPROG QPF_NPROG DISPLAY "N°" NPROG DISPLAY "Imposta versata" IMPOSTA - DISPLAY "Data versamento" DATAVERS - DISPLAY "Tipo" TIPOVERS - DISPLAY "Codice tributo" CODTRIB DISPLAY "Interessi dipendente" INTERDIP DISPLAY "Interessi datore di lavoro" INTERDAT + DISPLAY "Tipo" TIPOVERS + DISPLAY "Codice tributo" CODTRIB + DISPLAY "Data versamento" DATAVERS DISPLAY "Serie/ABI" SERIE DISPLAY "Numero/Bollettino/CAB" NUMERO OUTPUT QPF_NPROG NPROG diff --git a/m770/77qq.uml b/m770/77qq.uml index 63a1f5bb5..ef0abcef3 100755 --- a/m770/77qq.uml +++ b/m770/77qq.uml @@ -45,11 +45,11 @@ BEGIN INPUT NPROG QQF_NPROG DISPLAY "N°" NPROG DISPLAY "Mese" MESEPAG - DISPLAY "Anno" ANNOPAG - DISPLAY "Cod.reg." CODREG - DISPLAY "Interessi o soprattasse" INTERESSI + DISPLAY "Anno" ANNOPAG DISPLAY "Contributo versato" CONTVERS DISPLAY "Contributo rimborsato" CONTRIMB + DISPLAY "Interessi o soprattasse" INTERESSI + DISPLAY "Cod.reg." CODREG OUTPUT QQF_NPROG NPROG OUTPUT QQF_CONTRIMB CONTRIMB OUTPUT QQF_CONTVERS CONTVERS diff --git a/m770/77qr.uml b/m770/77qr.uml index 330780d16..2ce82f967 100755 --- a/m770/77qr.uml +++ b/m770/77qr.uml @@ -46,8 +46,8 @@ BEGIN DISPLAY "N°" NPROG DISPLAY "Mese" MESERIF DISPLAY "Anno" ANNORIF - DISPLAY "Imposta rimborsata" IMPRIMB - DISPLAY "Compensi per l'assistenza" COMPENSI + DISPLAY "Imposta rimborsata" IMPRIMB + DISPLAY "Compensi per l'assistenza" COMPENSI OUTPUT QRF_NPROG NPROG OUTPUT QRF_COMPENSI COMPENSI OUTPUT QRF_IMPOSTA IMPRIMB diff --git a/m770/77qs.uml b/m770/77qs.uml index 5a7895c93..57b495c7c 100755 --- a/m770/77qs.uml +++ b/m770/77qs.uml @@ -53,11 +53,11 @@ BEGIN INPUT NPROG QSF_NPROG DISPLAY "N°" NPROG DISPLAY "Imposta versata" IMPOSTA - DISPLAY "Data versamento" DATAVERS - DISPLAY "Tipo" TIPOVERS - DISPLAY "Codice tributo" CODTRIB DISPLAY "Interessi dipendente" INTERDIP DISPLAY "Interessi datore di lavoro" INTERDAT + DISPLAY "Tipo" TIPOVERS + DISPLAY "Codice tributo" CODTRIB + DISPLAY "Data versamento" DATAVERS DISPLAY "Serie/ABI" SERIE DISPLAY "Numero/Bollettino/CAB" NUMERO OUTPUT QSF_NPROG NPROG diff --git a/m770/77qt.uml b/m770/77qt.uml index 83b24c247..900274edf 100755 --- a/m770/77qt.uml +++ b/m770/77qt.uml @@ -45,11 +45,11 @@ BEGIN INPUT NPROG QTF_NPROG DISPLAY "N°" NPROG DISPLAY "Mese" MESEPAG - DISPLAY "Anno" ANNOPAG - DISPLAY "Cod.reg." CODREG - DISPLAY "Interessi o soprattasse" INTERESSI + DISPLAY "Anno" ANNOPAG DISPLAY "Contributo versato" CONTVERS DISPLAY "Contributo rimborsato" CONTRIMB + DISPLAY "Interessi o soprattasse" INTERESSI + DISPLAY "Cod.reg." CODREG OUTPUT QTF_NPROG NPROG OUTPUT QTF_CONTRIMB CONTRIMB OUTPUT QTF_CONTVERS CONTVERS diff --git a/m770/batbca7.h b/m770/batbca7.h index a2a676f34..820735426 100755 --- a/m770/batbca7.h +++ b/m770/batbca7.h @@ -1,27 +1,27 @@ // batbca7.h - Tabella causali 770 -#define F_CODCAUS 100 -#define F_CODTRIB 101 -#define F_DESCR1 102 -#define F_QUADRAT 103 -#define F_QUADRCE2 104 -#define F_ASSRIT 105 -#define F_IC 106 -#define F_CT 107 -#define F_PERASS 108 -#define F_PERRIT 109 -#define F_ARTBIL 110 -#define F_DESCR2 111 -#define F_CODQUA 112 - -// Aggiunte 96 -#define TCF_CAUSD 113 -#define TCF_CAUSD1 114 -#define TCF_BINPS 115 -#define TCF_PERCINPS 116 -#define TCF_ASSIMPINPS 117 -#define TCF_COMMINPS 118 -#define TCF_PERCASSPREV 119 +#define F_CODCAUS 100 +#define F_CODTRIB 101 +#define F_DESCR1 102 +#define F_QUADRAT 103 +#define F_QUADRCE2 104 +#define F_ASSRIT 105 +#define F_IC 106 +#define F_CT 107 +#define F_PERASS 108 +#define F_PERRIT 109 +#define F_ARTBIL 110 +#define F_DESCR2 111 +#define F_CODQUA 112 +#define TCF_CAUSD 113 +#define TCF_CAUSD1 114 +#define TCF_BINPS 115 +#define TCF_PERCINPS 116 +#define TCF_ASSIMPINPS 117 +#define TCF_COMMINPS 118 +#define TCF_PERCASSPREV 119 +#define TCF_CAUSD_DESCR 120 +#define TCF_CAUSD1_DESCR 121 #define G_INPS 10 #define INPS_GROUP 7 diff --git a/m770/batbca7.uml b/m770/batbca7.uml index 8732b1fc4..a4f58c782 100755 --- a/m770/batbca7.uml +++ b/m770/batbca7.uml @@ -17,10 +17,11 @@ BEGIN HELP "Inserire il codice della causale" USE %CA7 INPUT CODTAB F_CODCAUS - DISPLAY "Codice causale " CODTAB - DISPLAY "Codice tributo " I0 + DISPLAY "Cod.caus." CODTAB + DISPLAY "Cod.trib." I0 + DISPLAY "Art.bil." I3 + DISPLAY "Quadro " S1 DISPLAY "Descrizione @60" S0 - DISPLAY "Codice quadro " S1 OUTPUT F_CODCAUS CODTAB OUTPUT F_DESCR2 S0 OUTPUT F_CODTRIB I0 @@ -151,7 +152,7 @@ BEGIN FIELD LF_TABCOM->S1 END -STRING F_DESCR1 35 +STRING F_DESCR1 60 35 BEGIN PROMPT 1 4 "Descrizione " HELP "Inserire la descrizione della causale" @@ -171,45 +172,67 @@ BEGIN MESSAGE COPY,F_DESCR1,1,22 END -LISTBOX TCF_CAUSD 1 62 -BEGIN +STRING TCF_CAUSD 1 +BEGIN PROMPT 1 5 "Causale D " - ITEM "|" - ITEM "A|A prestaz. di lav. aut. ... nell’es. arti o prof. abituale" - ITEM "B|B prestaz. rese da amministratori, sindaci e revisori..." - ITEM "C|C prestaz. rese da collaboratori a giornali, riviste, ..." - ITEM "D|D prestaz. rese da partecipanti a collegi e commissioni" - ITEM "E|E prestaz. rese dagli sportivi con contratto di lav. autonomo" - ITEM "F|F prestaz. ... di rapp. di coll. coord. e c. diversi dai prec" - ITEM "G|G utiliz. economica, da parte dell’autore o dell’inventore..." - ITEM "H|H utili ... da contratti di associazione in partecipazioni..." - ITEM "I|I utili ... ai soci promot. e/o fond. delle soc. di capitale" - ITEM "L|L per la levata di protesti cambiari da parte dei segretar..." - ITEM "M|M utiliz. economica, ... di soggetto diverso dall’autore o..." - ITEM "N|N indennità corrisp. per la cessaz. di rapporti di coll..." - ITEM "P|P indennità corrisp. per la cessaz. dei rapporti di agenzia" - ITEM "Q|Q indennità corrisp. per la cessaz. da funzioni notarili" - ITEM "R|R indennità corrisp. per la cessaz. di attività sportiva prof" - ITEM "S|S indennità di trasf. o di rimborso forfettario di spese..." - ITEM "T|T altro titolo diverso dai precedenti" + SHEET "Codice|Descrizione@60" + INPUT TCF_CAUSD + ITEM " | " + ITEM "A|prestaz. di lav. aut. ... nell’es. arti o prof. abituale" + ITEM "B|prestaz. rese da amministratori, sindaci e revisori..." + ITEM "C|prestaz. rese da collaboratori a giornali, riviste, ..." + ITEM "D|prestaz. rese da partecipanti a collegi e commissioni" + ITEM "E|prestaz. rese dagli sportivi con contratto di lav. autonomo" + ITEM "F|prestaz. ... di rapp. di coll. coord. e c. diversi dai prec" + ITEM "G|utiliz. economica, da parte dell’autore o dell’inventore..." + ITEM "H|utili ... da contratti di associazione in partecipazioni..." + ITEM "I|utili ... ai soci promot. e/o fond. delle soc. di capitale" + ITEM "L|per la levata di protesti cambiari da parte dei segretar..." + ITEM "M|utiliz. economica, ... di soggetto diverso dall’autore o..." + ITEM "N|indennità corrisp. per la cessaz. di rapporti di coll..." + ITEM "P|indennità corrisp. per la cessaz. dei rapporti di agenzia" + ITEM "Q|indennità corrisp. per la cessaz. da funzioni notarili" + ITEM "R|indennità corrisp. per la cessaz. di attività sportiva prof" + ITEM "S|indennità di trasf. o di rimborso forfettario di spese..." + ITEM "T|altro titolo diverso dai precedenti" + OUTPUT TCF_CAUSD + OUTPUT TCF_CAUSD_DESCR FIELD LF_TABCOM->S2 FLAGS "D" GROUP GR_CAUDD1 END -LISTBOX TCF_CAUSD1 1 62 -BEGIN +STRING TCF_CAUSD_DESCR 60 +BEGIN + PROMPT 16 5 "" + FLAGS "D" + GROUP GR_CAUDD1 +END + +STRING TCF_CAUSD1 1 +BEGIN PROMPT 1 6 "Causale D1 " - ITEM "|" - ITEM "A|A Agente o rappresentante di commercio monomadatario" - ITEM "B|B Agente o rappresentate plurimandatario" - ITEM "C|C Commissionario" - ITEM "D|D Mediatore" - ITEM "E|E Procacciatore d'affari" - ITEM "F|F Per somme assoggettate a ritenuta a titolo d'imposta" + SHEET "Codice|Descrizione@60" + INPUT TCF_CAUSD1 + ITEM " | " + ITEM "A|Agente o rappresentante di commercio monomadatario" + ITEM "B|Agente o rappresentate plurimandatario" + ITEM "C|Commissionario" + ITEM "D|Mediatore" + ITEM "E|Procacciatore d'affari" + ITEM "F|Per somme assoggettate a ritenuta a titolo d'imposta" + OUTPUT TCF_CAUSD1 + OUTPUT TCF_CAUSD1_DESCR FIELD LF_TABCOM->S3 FLAGS "D" - GROUP GR_CAUDD1 + GROUP GR_CAUDD1 +END + +STRING TCF_CAUSD1_DESCR 60 +BEGIN + PROMPT 16 6 "" + FLAGS "D" + GROUP GR_CAUDD1 END BOOLEAN F_ASSRIT diff --git a/m770/batbcaf.uml b/m770/batbcaf.uml index c570c225a..32bf4ec9b 100755 --- a/m770/batbcaf.uml +++ b/m770/batbcaf.uml @@ -14,10 +14,13 @@ BEGIN USE %CAF CHECKTYPE REQUIRED INPUT CODTAB F_CODCAAF - DISPLAY "Codice CAA " CODTAB - DISPLAY "Denominazione@50" S0 + DISPLAY "Cod.CAA " CODTAB + DISPLAY "Denominazione@50" S0 + DISPLAY "Codice fiscale@11" S1 + DISPLAY "N.iscr.albo" I1 OUTPUT F_CODCAAF CODTAB - KEY 1 + KEY 1 + FLAGS "RZ" END STRING F_DENOM 50 diff --git a/m770/batbent.uml b/m770/batbent.uml index c8b09bfef..16bad9c35 100755 --- a/m770/batbent.uml +++ b/m770/batbent.uml @@ -16,19 +16,20 @@ BEGIN USE %ENT CHECKTYPE REQUIRED INPUT CODTAB F_CODENTE - DISPLAY "Codice Ente " CODTAB - DISPLAY "Descrizione@60 " S0 + DISPLAY "Cod.Ente" CODTAB + DISPLAY "Denominazione@60 " S0 OUTPUT F_CODENTE CODTAB OUTPUT F_DESCR S0 - KEY 1 + KEY 1 + FLAGS "RZ" END STRING F_DESCR 60 BEGIN - PROMPT 4 3 "Descrizione " + PROMPT 4 3 "Denominazione " FIELD LF_TABCOM->S0 HELP "Inserire la descrizione dell' Ente" - WARNING "Manca la descrizione" + WARNING "Manca la denominazione" CHECKTYPE REQUIRED END diff --git a/m770/generic.cpp b/m770/generic.cpp index 3530793d9..b7fa2414e 100755 --- a/m770/generic.cpp +++ b/m770/generic.cpp @@ -746,11 +746,9 @@ bool TGeneric_application::menu(MENU_TAG) TMask m(_maskname); -// if (m.id2pos(F_CODDITTA) > 0) -// m.set_handler(F_CODDITTA, codditta77_handler); - k = m.run(); - if (k == K_QUIT) stop_run(); + + if (k == K_QUIT || k == K_ESC) stop_run(); return k != K_QUIT; } diff --git a/m770/menu_st.uml b/m770/menu_st.uml index 75fc3516e..8c6a4ef42 100755 --- a/m770/menu_st.uml +++ b/m770/menu_st.uml @@ -9,7 +9,6 @@ BEGIN GROUP 1 END -// Il menu' viene richiamato nell'handler di questo bottone BUTTON B_SELDIC 1 1 BEGIN PROMPT 1 3 "" @@ -255,7 +254,8 @@ BUTTON B_E 1 1 BEGIN PROMPT 39 ROW4 "" PICTURE 123 - MESSAGE RUN,772MOD,-4,E,S + MESSAGE RUN,772MOD,-4,E,S + FLAG "D" GROUP 1 END @@ -269,7 +269,8 @@ BUTTON B_E1 1 1 BEGIN PROMPT 39 ROW5 "" PICTURE 123 - MESSAGE RUN,772MOD,-4,E1,S + MESSAGE RUN,772MOD,-4,E1,S + FLAG "D" GROUP 1 END @@ -284,6 +285,7 @@ BEGIN PROMPT 39 ROW6 "" PICTURE 123 MESSAGE RUN,772MOD,-4,E2,S + FLAG "D" GROUP 1 END // Fine terza colonna @@ -300,6 +302,7 @@ BEGIN PROMPT 58 ROW1 "" PICTURE 123 // MESSAGE RUN,771MOD,-1 + FLAG "D" GROUP 1 END @@ -314,6 +317,7 @@ BEGIN PROMPT 58 ROW2 "" PICTURE 123 // MESSAGE RUN,771MOD,-1 + FLAG "D" GROUP 1 END @@ -328,6 +332,7 @@ BEGIN PROMPT 58 ROW3 "" PICTURE 123 // MESSAGE RUN,771MOD,-1 + FLAG "D" GROUP 1 END @@ -356,6 +361,7 @@ BEGIN PROMPT 58 ROW5 "" PICTURE 123 // MESSAGE RUN,771MOD,-1 + FLAG "D" GROUP 1 END @@ -374,9 +380,9 @@ BEGIN END // Fine QUARTA colonna -BUTTON DLG_QUIT 20 2 -BEGIN - PROMPT -12 -1 "Fine" +BUTTON DLG_CANCEL 20 2 +BEGIN + PROMPT -22 -1 "Menu precedente" END ENDPAGE