diff --git a/ca/ca3700.cpp b/ca/ca3700.cpp index e7cf59e21..3765ce64b 100755 --- a/ca/ca3700.cpp +++ b/ca/ca3700.cpp @@ -21,16 +21,14 @@ //////////////////////////////////////////////////////// // MASCHERA //////////////////////////////////////////////////////// -class TPrint_rendiconto_ca_mask : public TAutomask +class TPrint_rendiconto_ca_mask : public TAnal_report_mask { protected: - bool on_field_event(TOperable_field& o, TField_event e, long jolly); + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); const TString& get_report_class() const; bool test_compatible_report(); bool esistono_riclassificazioni() const; - void create_sheet(); - int create_sheet_fields(int lf, int& y, short& dlg, bool required); public: TPrint_rendiconto_ca_mask(); @@ -136,112 +134,9 @@ bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event default: break; } - return true; + return TAnal_report_mask::on_field_event(o, e, jolly); } -int TPrint_rendiconto_ca_mask::create_sheet_fields(int lf, int& y, short& dlg, bool required) -{ - TSheet_field& sf = sfield(F_RIGHE); - TMask& sm = sf.sheet_mask(); - - const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, dlg+50); - - for (int i = 0; i < h; i++) - { - TEdit_field& fld = sm.efield(dlg+i); - int logic = lf; - if (logic == LF_FASI) - { - const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI); - if (fasinfo.parent() != 0) - { - const TMultilevel_code_info& parinfo = ca_multilevel_code_info(fasinfo.parent()); - if (i < parinfo.levels()) - logic = fasinfo.parent(); - } - } - - const char* fieldname = NULL; - switch(logic) - { - case LF_CDC : fieldname = RMOVANA_CODCCOSTO; break; - case LF_COMMESSE: fieldname = RMOVANA_CODCMS; break; - case LF_FASI : fieldname = RMOVANA_CODFASE; break; - default : fieldname = RMOVANA_CODCONTO; break; - } - TFieldref* f = (TFieldref*)fld.field(); - f->set_name(fieldname); - - fld.check_type(required ? CHECK_REQUIRED : CHECK_NORMAL); - - TEdit_field& dfld = sm.efield(dlg+50+i); - dfld.set_field(EMPTY_STRING); // Toglie campi che fan saltare gli output! - } - - y += h+1; - dlg += h; - - return h; -} - -void TPrint_rendiconto_ca_mask::create_sheet() -{ - TSheet_field& sf = sfield(F_RIGHE); - TMask& sm = sf.sheet_mask(); - sm.hide(-1); - - const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI); - - TConfig_anal ini; -// const bool fsc_req = ini.get_bool("FscRequired"); - - int y = 1; - short dlg = S_CDC1 + 100; // id del primo campo da generare - - for (int i = 0; i < 2; i++) - { - const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2 - if (level == "CDC") // Crea centro di costo - { - if (fasinfo.parent() == LF_CDC) - create_sheet_fields(LF_FASI, y, dlg, false); //fsc_req); - else - { - const bool cdc_req = ini.get_bool("CdcRequired"); - create_sheet_fields(LF_CDC, y, dlg, cdc_req); - } - } else - if (level == "CMS") // Crea commessa - { - if (fasinfo.parent() == LF_COMMESSE) - create_sheet_fields(LF_FASI, y, dlg, false); //fsc_req); - else - { - const bool cms_req = ini.get_bool("CmsRequired"); - create_sheet_fields(LF_COMMESSE, y, dlg, cms_req); - } - } - } - - if (fasinfo.levels() > 0 && fasinfo.parent() <= 0) - create_sheet_fields(LF_FASI, y, dlg, false); //fsc_req); - - for (short id = S_CDC12+100; id >= S_CDC1+100; id--) - { - const int pos = sm.id2pos(id); - if (pos >= 0) - { - TMask_field& f = sm.fld(pos); - const int size = f.size(); - const TString& prompt = f.prompt(); - sf.set_column_header(id, prompt); - sf.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD)); - sf.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX); - } - else - sf.delete_column(id); - } -} bool TPrint_rendiconto_ca_mask::esistono_riclassificazioni() const { @@ -250,7 +145,7 @@ bool TPrint_rendiconto_ca_mask::esistono_riclassificazioni() const } TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask() - :TAutomask("ca3700") + :TAnal_report_mask("ca3700") { TConfig_anal cfg; const bool use_pdcc = cfg.get_bool("UsePdcc"); @@ -328,7 +223,7 @@ TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask() } // creazione dei campi della seconda pagina della maschera (cdc/cms/fasi) - create_sheet(); + create_sheet(F_RIGHE); // setta gli handlers a tutti i campi generati della maschera;senza questa chiamata la on_field_event // non puo' funzionare sui campi generati!!! set_handlers(); diff --git a/ca/ca3700.h b/ca/ca3700.h index 895e021c4..2e2dfc2cd 100755 --- a/ca/ca3700.h +++ b/ca/ca3700.h @@ -47,19 +47,5 @@ //sheet di pagina 2 #define F_RIGHE 260 -//elementi dello sheet con CdC/Cms/Fas (pag.2) -#define S_CDC1 101 -#define S_CDC2 102 -#define S_CDC3 103 -#define S_CDC4 104 -#define S_CDC5 105 -#define S_CDC6 106 -#define S_CDC7 107 -#define S_CDC8 108 -#define S_CDC9 109 -#define S_CDC10 110 -#define S_CDC11 111 -#define S_CDC12 112 - #endif // __CA3700_H diff --git a/ca/calib02.cpp b/ca/calib02.cpp index d27fa0516..2d5ab9f8b 100755 --- a/ca/calib02.cpp +++ b/ca/calib02.cpp @@ -878,3 +878,113 @@ const TSaldanal& ca_saldo(const TAnal_bill& bill, const TDate& dal, const TDate& cache = new TSaldi_cache; return cache->saldo(bill, dal, al, tipi); } + + +//////////////////////////////////////////////////////// +// TAnal_report_mask +//////////////////////////////////////////////////////// + +bool TAnal_report_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + return true; +} + +int TAnal_report_mask::create_sheet_fields(short sheet_id, int lf, int& y, short& dlg) +{ + TSheet_field& sf = sfield(sheet_id); + TMask& sm = sf.sheet_mask(); + + const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, dlg+50); + + for (int i = 0; i < h; i++) + { + TEdit_field& fld = sm.efield(dlg+i); + int logic = lf; + if (logic == LF_FASI) + { + const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI); + if (fasinfo.parent() != 0) + { + const TMultilevel_code_info& parinfo = ca_multilevel_code_info(fasinfo.parent()); + if (i < parinfo.levels()) + logic = fasinfo.parent(); + } + } + + const char* fieldname = NULL; + switch(logic) + { + case LF_CDC : fieldname = RMOVANA_CODCCOSTO; break; + case LF_COMMESSE: fieldname = RMOVANA_CODCMS; break; + case LF_FASI : fieldname = RMOVANA_CODFASE; break; + default : fieldname = RMOVANA_CODCONTO; break; + } + TFieldref* f = (TFieldref*)fld.field(); + f->set_name(fieldname); + + fld.check_type(CHECK_SEARCH); //search e non normal perchè nelle.. + //..stampe non si vuole la fase legata alla commessa/cdc + + TEdit_field& dfld = sm.efield(dlg+50+i); + dfld.set_field(EMPTY_STRING); // Toglie campi che fan saltare gli output! + } + + y += h+1; + dlg += h; + + return h; +} + +void TAnal_report_mask::create_sheet(short sheet_id) +{ + TSheet_field& sf = sfield(sheet_id); + TMask& sm = sf.sheet_mask(); + sm.hide(-1); + + const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI); + + TConfig_anal ini; + + int y = 1; + short dlg = S_CDC1 + 100; // id del primo campo da generare + + for (int i = 0; i < 2; i++) + { + const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2 + if (level == "CDC") // Crea centro di costo + { + if (fasinfo.parent() == LF_CDC) + create_sheet_fields(sheet_id, LF_FASI, y, dlg); + else + create_sheet_fields(sheet_id, LF_CDC, y, dlg); + + } else + if (level == "CMS") // Crea commessa + { + if (fasinfo.parent() == LF_COMMESSE) + create_sheet_fields(sheet_id, LF_FASI, y, dlg); + else + create_sheet_fields(sheet_id, LF_COMMESSE, y, dlg); + } + } + + if (fasinfo.levels() > 0 && fasinfo.parent() <= 0) + create_sheet_fields(sheet_id, LF_FASI, y, dlg); + + for (short id = S_CDC12+100; id >= S_CDC1+100; id--) + { + const int pos = sm.id2pos(id); + if (pos >= 0) + { + TMask_field& f = sm.fld(pos); + const int size = f.size(); + const TString& prompt = f.prompt(); + sf.set_column_header(id, prompt); + sf.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD)); + sf.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX); + } + else + sf.delete_column(id); + } +} + diff --git a/ca/calib02.h b/ca/calib02.h index 7c1e199a1..7bc34b7b7 100755 --- a/ca/calib02.h +++ b/ca/calib02.h @@ -127,4 +127,36 @@ protected: // protected is safer public: // meglio pubic? }; + +/////////////////////////////////////////////////////////// +// TAnal_rapport_mask +/////////////////////////////////////////////////////////// + +//elementi dello sheet di selezione CdC/Cms/Fas +#define S_CDC1 101 +#define S_CDC2 102 +#define S_CDC3 103 +#define S_CDC4 104 +#define S_CDC5 105 +#define S_CDC6 106 +#define S_CDC7 107 +#define S_CDC8 108 +#define S_CDC9 109 +#define S_CDC10 110 +#define S_CDC11 111 +#define S_CDC12 112 + + +class TAnal_report_mask : public TAutomask +{ +protected: + void create_sheet(short sheet_id); + int create_sheet_fields(short sheet_id, int lf, int& y, short& dlg); + + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TAnal_report_mask(const char* name) : TAutomask(name) {} +}; + #endif