diff --git a/ci/ci0600.cpp b/ci/ci0600.cpp index 189c6ddb4..1c49ae72f 100755 --- a/ci/ci0600.cpp +++ b/ci/ci0600.cpp @@ -169,24 +169,48 @@ void TDef_risoatt_msk::riempi_sheet() get_anal_fields(codcosto, codcms, codfase); TString query; - query << "USE " << LF_RILORE << "\n"; + query << "USE " << LF_RILORE << "\n" ; + + TString select; if (risoatt.full()) - query << "SELECT (BETWEEN(" << RILORE_TIPORA << ",\"" << risoatt << "\",\"" << risoatt << "\"))"; + select << "(BETWEEN(" << RILORE_TIPORA << ",\"" << risoatt << "\",\"" << risoatt << "\"))"; if (codice.full()) - query << "&&(BETWEEN(" << RILORE_CODICE << ",\"" << codice << "\",\"" << codice << "\"))"; - if (anno.full()) - query << "&&(BETWEEN(" << RILORE_ANNO << ",\"" << anno << "\",\"" << anno << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODICE << ",\"" << codice << "\",\"" << codice << "\"))"; + } + if (anno > 0) + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_ANNO << ",\"" << anno << "\",\"" << anno << "\"))"; + } if (mese.full()) - query << "&&(BETWEEN(" << RILORE_MESE << ",\"" << mese << "\",\"" << mese << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(MESE,\"" << mese << "\",\"" << mese << "\"))"; + } if (tpora.full()) - query << "&&(BETWEEN(" << RILORE_TPORA << ",\"" << tpora << "\",\"" << tpora << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_TPORA << ",\"" << tpora << "\",\"" << tpora << "\"))"; + } if (codcosto.full()) - query << "&&(BETWEEN(" << RILORE_CODCOSTO << ",\"" << codcosto << "\",\"" << codcosto << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODCOSTO << ",\"" << codcosto << "\",\"" << codcosto << "\"))"; + } if (codcms.full()) - query << "&&(BETWEEN(" << RILORE_CODCMS << ",\"" << codcms << "\",\"" << codcms << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODCMS << ",\"" << codcms << "\",\"" << codcms << "\"))"; + } if (codfase.full()) - query << "&&(BETWEEN(" << RILORE_CODFASE << ",\"" << codfase << "\",\"" << codfase << "\"))"; - query << "\n"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODFASE << ",\"" << codfase << "\",\"" << codfase << "\"))"; + } + if (select.full()) + query << "SELECT " << select << "\n"; TString fromto = RILORE_TIPO "=\"D\""; if(risoatt != 'T') @@ -236,7 +260,6 @@ void TDef_risoatt_msk::riempi_sheet() riga.add(rilore.costo().string(), sheet.cid2index(S_COSTO)); } - sheet.force_update(); } @@ -586,7 +609,6 @@ TDef_risoatt_msk::TDef_risoatt_msk() s.delete_column(id); } _qtaore = 0; - } //////////////////////////////////////// diff --git a/ci/ci2100.cpp b/ci/ci2100.cpp index 448dc38d4..ef912b402 100755 --- a/ci/ci2100.cpp +++ b/ci/ci2100.cpp @@ -11,6 +11,7 @@ #include "cilib.h" #include "ci2100a.h" #include "rilore.h" +#include "../ca/calib01.h" #include "../ve/velib.h" //////////////////////////////////////////// @@ -303,7 +304,7 @@ void TRilevamento_prev_msk::carica_default() sheet.destroy(); const TDate da(1, get_date(F_DADATA).month(), get_date(F_DADATA).year()); - TDate a = da; a.set_day(a.last_day(da.month(), a.year())); + TDate a = da; a.set_end_month(); //riempio lo sheet con i dati che soddisfano il filtro preparato prima for(bool ok = def.move_first(); ok; ok = def.move_next()) @@ -337,8 +338,8 @@ void TRilevamento_prev_msk::riempi_sheet() //leggo dalla maschera i campi chiave di ricerca const int anno = get_date(F_DADATA).year(); const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT); - TString4 damese; damese.format("%02d", get_date(F_DADATA).month()); - TString4 amese; amese.format("%02d", get_date(F_ADATA).month()); + TString4 damese; damese.format("%02d", get_date(F_DADATA).month()); if (damese == "00") damese = "01"; + TString4 amese; amese.format("%02d", get_date(F_ADATA).month()); if (amese == "00") amese = "12"; const TString4 tpora = get(F_TPORA); TString80 codcosto; TString80 codcms; @@ -355,23 +356,45 @@ void TRilevamento_prev_msk::riempi_sheet() get_anal_fields(codcosto, codcms, codfase); TString query; - query << "USE " << LF_RILORE << "\n"; + query << "USE " << LF_RILORE << "\n" ; + + TString select; if (risoatt.full()) - query << "SELECT (BETWEEN(" << RILORE_TIPORA << ",\"" << risoatt << "\",\"" << risoatt << "\"))"; + select << "(BETWEEN(" << RILORE_TIPORA << ",\"" << risoatt << "\",\"" << risoatt << "\"))"; if (codice.full()) - query << "&&(BETWEEN(" << RILORE_CODICE << ",\"" << codice << "\",\"" << codice << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODICE << ",\"" << codice << "\",\"" << codice << "\"))"; + } if (anno > 0) - query << "&&(BETWEEN(" << RILORE_ANNO << ",\"" << anno << "\",\"" << anno << "\"))"; - query << "(BETWEEN(MESE,\"" << damese << "\",\"" << amese << "\"))&&"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_ANNO << ",\"" << anno << "\",\"" << anno << "\"))"; + } + if (select.full()) select << "&&"; + select << "(BETWEEN(MESE,\"" << damese << "\",\"" << amese << "\"))"; if (tpora.full()) - query << "&&(BETWEEN(" << RILORE_TPORA << ",\"" << tpora << "\",\"" << tpora << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_TPORA << ",\"" << tpora << "\",\"" << tpora << "\"))"; + } if (codcosto.full()) - query << "&&(BETWEEN(" << RILORE_CODCOSTO << ",\"" << codcosto << "\",\"" << codcosto << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODCOSTO << ",\"" << codcosto << "\",\"" << codcosto << "\"))"; + } if (codcms.full()) - query << "&&(BETWEEN(" << RILORE_CODCMS << ",\"" << codcms << "\",\"" << codcms << "\"))"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODCMS << ",\"" << codcms << "\",\"" << codcms << "\"))"; + } if (codfase.full()) - query << "&&(BETWEEN(" << RILORE_CODFASE << ",\"" << codfase << "\",\"" << codfase << "\"))"; - query << "\n"; + { + if (select.full()) select << "&&"; + select << "(BETWEEN(" << RILORE_CODFASE << ",\"" << codfase << "\",\"" << codfase << "\"))"; + } + if (select.full()) + query << "SELECT " << select << "\n"; TString fromto = RILORE_TIPO "=\"P\" "; if(risoatt != 'T') @@ -422,6 +445,7 @@ void TRilevamento_prev_msk::riempi_sheet() riga.add(rilore.qtaore(), sheet.cid2index(S_QTAORE)); riga.add(rilore.costo().string(), sheet.cid2index(S_COSTO)); } + sheet.force_update(); } //NUOVA_RIGA: metodo che aggiunge una riga allo sheet @@ -646,6 +670,12 @@ bool TRilevamento_prev_msk::on_field_event(TOperable_field& f, TField_event e, l send_key(K_SPACE, DLG_NEWREC); return false; } + case S_CODRIS: + case S_CODATT: + case S_DADATA: + case S_TPORA: + if (e == fe_modify) + f.mask().set(S_COSTO, proponi_costo(f.mask()).string()); default: break; } return true; @@ -658,6 +688,119 @@ void TRilevamento_prev_msk::esegui() const TRilevamento_prev_msk::TRilevamento_prev_msk() : TAutomask("ci2100a") { + const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI); + TConfig& ini = ca_config(); + TSheet_field & s = sfield(F_SHEET); + TMask & sm = s.sheet_mask(); + int y = 3; + int sy = 8; + short dlg = F_ANAL; // id del primo campo da generare + short sdlg = S_CDC1 + 100; // id del primo campo da generare + + _cdc_sid = _cdc_lid = _cms_sid = _cms_lid = _fase_sid = _fase_lid = -1; + _scdc_sid = _scdc_lid = _scms_sid = _scms_lid = _sfase_sid = _sfase_lid = -1; + + 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) + { + int h = ca_multilevel_code_info(LF_CDC).levels(); + const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100); + y += 2; + _cdc_sid = dlg; + _cdc_lid = dlg + h - 1; + _fase_sid = _cdc_lid + 1; + _fase_lid = dlg + h1 - 1; + dlg += h1; + const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50); + sy += 2; + _scdc_sid = sdlg; + _scdc_lid = sdlg + h - 1; + _sfase_sid = _scdc_lid + 1; + _sfase_lid = sdlg + sh - 1; + sdlg += sh; + } + else + { + const int h = ca_create_fields_compact(*this, 0, LF_CDC, 2, y++, dlg, dlg + 100); + _cdc_sid = dlg; + _cdc_lid = dlg + h - 1; + dlg += h; + const int sh = ca_create_fields_compact(sm, 0, LF_CDC, 2, sy++, sdlg, sdlg + 50); + _scdc_sid = sdlg; + _scdc_lid = sdlg + sh - 1; + sdlg += h; + } + } + else + if (level == "CMS") // Crea commessa + { + if (fasinfo.parent() == LF_COMMESSE) + { + int h = ca_multilevel_code_info(LF_COMMESSE).levels(); + const int h1 = ca_create_fields_compact(*this, 0, LF_FASI, 2, y, dlg, dlg + 100); + y += 2; + _cms_sid = dlg; + _cms_lid = dlg + h - 1; + _fase_sid = _cms_lid + 1; + _fase_lid = dlg + h1 - 1; + dlg += h1; + const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy, sdlg, sdlg + 50); + sy += 2; + _scms_sid = sdlg; + _scms_lid = sdlg + h - 1; + _sfase_sid = _scms_lid + 1; + _sfase_lid = sdlg + sh - 1; + sdlg += sh; + } + else + { + const int h = ca_create_fields_compact(*this, 0, LF_COMMESSE, 2, y++, dlg, dlg + 100); + _cms_sid = dlg; + _cms_lid = dlg + h - 1; + dlg += h; + const int sh = ca_create_fields_compact(sm, 0, LF_COMMESSE, 2, sy++, sdlg, sdlg + 50); + _scms_sid = sdlg; + _scms_lid = sdlg + sh - 1; + sdlg += sh; + } + } + } + if (fasinfo.levels() > 0 && fasinfo.parent() <= 0) + { + const int h = ca_create_fields_compact(*this, 0, LF_FASI, 2, y++, dlg, dlg + 100); + _fase_sid = dlg; + _fase_lid = dlg + h - 1; + dlg += h; + const int sh = ca_create_fields_compact(sm, 0, LF_FASI, 2, sy++, sdlg, sdlg + 50); + _sfase_sid = sdlg; + _sfase_lid = sdlg + sh - 1; + sdlg += h; + } + + 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(); + TString prompt = f.prompt(); + + if (prompt.blank()) + prompt = ((TEditable_field &)f).get_warning(); + s.set_column_header(id, prompt); + s.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD)); + s.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX); + s.enable_column(id); + } + else + s.delete_column(id); + } _qtaore = 0; } diff --git a/ci/ci2100a.h b/ci/ci2100a.h index 149d1ddc0..164c0fb5c 100755 --- a/ci/ci2100a.h +++ b/ci/ci2100a.h @@ -8,14 +8,13 @@ #define F_DESRIS 307 #define F_CODATT 308 #define F_DESATT 309 -#define F_CODCOSTO 310 -#define F_CODCMS 311 -#define F_CODFASE 312 -#define F_SHEET 313 +#define F_ANAL 310 +#define F_SHEET 330 #define DLG_RESET 400 #define DLG_CERCA 401 #define DLG_DEFAULT 402 +#define F_DESANAL 410 #define S_RISOATT 101 #define S_CODRIS 102 diff --git a/ci/ci2100a.uml b/ci/ci2100a.uml index 8e57e9ed2..9ede44a47 100755 --- a/ci/ci2100a.uml +++ b/ci/ci2100a.uml @@ -63,7 +63,7 @@ BEGIN OUTPUT F_TPORA CODTAB END -RADIOBUTTON F_RISOATT 1 12 +LISTBOX F_RISOATT 1 12 BEGIN PROMPT 2 2 "@bTipo " ITEM "T|Tutti" @@ -140,9 +140,6 @@ BEGIN ITEM "Dal@10" ITEM "Al@10" ITEM "Tipo\nOra@5" - ITEM "Centro di\nCosto@20" - ITEM "Codice\nCommessa@20" - ITEM "Codice\nFase@10" ITEM "CDC1" ITEM "CDC2" ITEM "CDC3" @@ -170,9 +167,9 @@ BEGIN PROMPT 1 1 "@bRisorsa - Attrezzatura" END -RADIOBUTTON S_RISOATT 1 74 +RADIOBUTTON S_RISOATT 1 70 BEGIN - PROMPT 2 2 "@bTipo: " + PROMPT 2 2 "@bTipo " FIELD CODTAB[0,1] ITEM "R|Risorsa" MESSAGE SHOW,1@|HIDE,2@|RESET,2@