diff --git a/ci/ci2200.cpp b/ci/ci2200.cpp index 9d40c36aa..96de4be68 100755 --- a/ci/ci2200.cpp +++ b/ci/ci2200.cpp @@ -1,10 +1,13 @@ #include #include -#include +//#include #include #include #include #include +#include +#include +#include #include #include @@ -18,6 +21,250 @@ #include "../ca/cfcms.h" #include "../ve/velib.h" +////////////////////////////////////////////// +// Albero +////////////////////////////////////////////// +class TRil_tree : public TBidirectional_tree +{ + typedef enum { _normal, _holiday, _full } _type; + TString_array _content; + _type _t[64]; + int _curr_node; + TString4 _dett; + int _month; + TEsercizi_contabili _es; + + +protected: + void highlight(const TString & query, int mese, int anno); + +public: + bool update_content(const TString & query, const TString & dett, int month, int year); + virtual bool goto_root(); + virtual bool goto_firstson() { return false; } + virtual bool goto_rbrother(); + virtual bool goto_node(const TString &id); + virtual bool could_have_son() const { return false; } + virtual bool has_son() const { return false; } + virtual bool has_rbrother() const; + virtual TObject* curr_node() const; + const int pos() const { return _curr_node;} + const TString &id() const { return *(TString *)curr_node(); } + virtual void node2id(const TObject* obj, TString& id) const; + + virtual bool has_root() const; + virtual bool has_father() const { return false; } + virtual bool has_lbrother() const; + virtual bool goto_father() { return false; } + virtual bool goto_lbrother(); + virtual bool get_description(TString& desc) const { desc = _content.row(_curr_node); return true;} + virtual TImage* image(bool selected) const; + +public: + TRil_tree() : _curr_node(0), _dett("") {} +}; + + +bool TRil_tree::has_root() const +{ + return _content.items() > 0L; +} + +bool TRil_tree::goto_root() +{ + bool ok = has_root(); + if (ok) + _curr_node = 0L; + return ok; +} + +bool TRil_tree::has_rbrother() const +{ + return _curr_node < _content.items() -1; +} + +bool TRil_tree::goto_rbrother() +{ + bool ok = has_rbrother(); + if (ok) + _curr_node++; + return ok; +} + +bool TRil_tree::has_lbrother() const +{ + return _curr_node > 0L; +} + +bool TRil_tree::goto_lbrother() +{ + bool ok = has_lbrother(); + if (ok) + _curr_node--; + return ok; +} + +bool TRil_tree::goto_node(const TString &id) +{ + const long pos = atol(id); + const bool ok = pos >= 0 && pos < _content.items(); + if (ok) + _curr_node = pos; + return ok; +} + +TObject* TRil_tree::curr_node() const +{ + bool ok = has_root(); + if (ok) + return (TObject*)&_content[_curr_node]; + return (TObject*) &EMPTY_STRING; + +} +void TRil_tree::highlight(const TString & query, int mese, int anno) +{ + if (_dett == "A") + { + TBit_array full_years; + TISAM_recordset recset(query); + + for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + { + const int es = recset.get(RILORE_ANNO).as_int(); + + full_years.set(es); + } + for (int i = 0; i < _content.items(); i++) + _t[i] = full_years[atoi(id())] ? _full : _normal; + } + else + if (_dett == "M") + { + TBit_array full_months; + TISAM_recordset recset(query); + + for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + { + const int mese = recset.get(RILORE_MESE).as_int(); + + full_months.set(mese); + } + + for (int i = 0; i <= 11; i++) + _t[i] = full_months[i + 1] ? _full : _normal; } + else + if (_dett == "G") + { + TDate day(1, mese, anno); + TDate last(day); last.set_end_month(); + TBit_array full_days; + TISAM_recordset recset(query); + + //scorro il recordset, aggiungo una riga allo sheet per ogni chiave analitica che trovo e coloro di blu + //tutte le celle che corrispondono a una data interessata da qualcosa + for (bool ok = recset.move_first(); ok; ok = recset.move_next()) + { + const int day = recset.get(RILORE_GIORNO).as_int(); + + full_days.set(day); + } + + for(; day <= last; ++day) + { + const int i = day.day(); + if (full_days[i]) + _t[i - 1] = _full; + else + _t[i - 1] = day.is_holiday() ? _holiday : _normal; + } + } +} + +bool TRil_tree::update_content(const TString & query, const TString & dett, int month, int year) +{ + bool updated = false; + + if (dett == "G") + { + if (_dett != dett || _month != month) + { + _dett = dett; + _month = month; + _content.destroy(); + TDate day(1, month, year); + TDate last(day); last.set_end_month(); + + for (; day <= last; ++day) + { + const int i = day.day(); + _content.add(format("%d", i)); + _t[i - 1] = day.is_holiday() ? _holiday : _normal; + } + updated = true; + } + } + else + if (_dett != dett) + { + _dett = dett; + _month = month; + _content.destroy(); + if (_dett == "M") + { + for (int month = 1; month < 13; month++) + { + _content.add(itom(month)); + _t[month] = _normal; + } + } + else + if (_dett == "A") + { + int i = 0; + for (int codes = _es.first(); codes != 0; codes = _es.next(codes)) + { + _content.add(format("%d", codes)); + _t[i++] = _normal; + } + } + updated = true; + } + if (updated) + goto_root(); + highlight(query, month, year); + return updated; +} + +void TRil_tree::node2id(const TObject* obj, TString& id) const +{ + FOR_EACH_ARRAY_ITEM(_content, r, o) + if (o == obj) + { + id.cut(0) << r; + break; + } +} + +TImage* TRil_tree::image(bool selected) const +{ + switch (_t[_curr_node]) + { + case _normal: + return get_res_icon(ICO_DAY_WORK); + break; + case _holiday: + return get_res_icon(ICO_DAY_HOLY); + break; + case _full: + return get_res_icon(ICO_DAY_FULL); + break; + default: + break; + } + return get_res_icon(10201); +} + + //////////////////////////////////////////// //// CLASSE TRilevamento_cons_msk //// //////////////////////////////////////////// @@ -35,10 +282,6 @@ class TRilevamento_cons_msk : public TAutomask int _anno; int _mese; int _giorno; - int _first_ex; - int _n_ex; - int _es_array[32]; - TEsercizi_contabili _es; TString _numcn; TString _tipocn; TToken_string _last_key; @@ -51,13 +294,11 @@ protected: void get_anal_fields(TString & cdc, TString & cms, TString & fase); void get_row_anal_fields(TToken_string & row, TString & cdc, TString & cms, TString & fase); void put_row_anal_fields(TToken_string & row, const TString & cdc, const TString & cms, const TString & fase); - void carica_default(); - void update_day(); + const char * content_query(); + void update_tree(); void update_disp(); void update_prev(); - void riempi_calendario(const TString & query); void update_column(short sid, const bool full); - void riempi_risoatt(char tipo = 'C'); void nuova_riga(); void azzera_riga(TSheet_field& sheet); void azzera_tutto(TSheet_field& sheet); @@ -66,7 +307,7 @@ protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); public: - void riempi_sheet(); + void riempi_sheet(char tipo = 'C'); TRilevamento_cons_msk(); }; @@ -251,191 +492,26 @@ void TRilevamento_cons_msk::put_row_anal_fields(TToken_string & row, const TStri } } -void TRilevamento_cons_msk::carica_default() -{ - //leggo dalla maschera i campi chiave di ricerca - const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT); - const TString4 tpora = get(F_TPORA); - TString80 codcosto; - TString80 codcms; - TString16 codfase; - TString16 codice; - TString query; - TString select; - - update_day(); - switch(get(F_RISOATT)[0]) - { - case 'R': codice = get(F_CODRIS); break; - case 'A': codice = get(F_CODATT); break; - default: break; - } - get_anal_fields(codcosto, codcms, codfase); - - query << "USE " << LF_RILORE << " KEY 2\n" ; - if (risoatt.full()) - select << "(" << RILORE_TIPORA << "==\"" << risoatt << "\")"; - if (codice.full()) - { - if (select.full()) select << "&&"; - select << "(" << RILORE_CODICE << "==\"" << codice << "\")"; - } - if (tpora.full()) - { - if (select.full()) select << "&&"; - select << "(" << RILORE_TPORA << "==\"" << tpora << "\")"; - } - if (codcosto.full()) - { - if (select.full()) select << "&&"; - select << "(" << RILORE_CODCOSTO << "==\"" << codcosto << "\")"; - } - if (codcms.full()) - { - if (select.full()) select << "&&"; - select << "(" << RILORE_CODCMS << "==\"" << codcms << "\")"; - } - if (codfase.full()) - { - if (select.full()) select << "&&"; - select << "(" << RILORE_CODFASE << "==\"" << codfase << "\")"; - } - if (select.full()) - query << "SELECT " << select << "\n"; - - TString fromto = RILORE_TIPO "=\"D\" "; - - if (_anno > 0) - { - fromto << " " << RILORE_ANNO << "=" << _anno << " "; - if (_mese > 0) - fromto << RILORE_MESE << "=" << _mese << " "; - } - riempi_risoatt('D'); -} - //RIEMPI_CALENDARIO: coloro le celle dello sheet calendario secondo le festività e i giorni occupati -void TRilevamento_cons_msk::riempi_calendario(const TString & query) -{ - TSheet_field& calendario = sfield(F_CALENDARIO); - const TString4 dett = get(F_INTERVALLO); - - update_day(); - calendario.destroy(-1, false); - if (dett == "A") - { - TBit_array full_years; - TISAM_recordset recset(query); - - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) - { - const int anno = recset.get(RILORE_ANNO).as_int(); - - full_years.set(anno); - } - for (int i = 0; i < _n_ex; i++) - { - TToken_string & row = calendario.row(i); - COLOR back = NORMAL_BACK_COLOR; - COLOR fore = NORMAL_COLOR; - - if (full_years[_es_array[i]]) - { - back = COLOR_DKBLUE; // coloro di blu le date con registrazioni - fore = COLOR_WHITE; // coloro di blu le date con registrazioni - } - calendario.set_back_and_fore_color(back, fore, i - 1, 0); - row.add(_es_array[i]); - } - } - else - if (dett == "M") - { - TBit_array full_months; - TISAM_recordset recset(query); - - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) - { - const int mese = recset.get(RILORE_MESE).as_int(); - - full_months.set(mese); - } - - for (int i = 1; i <= 12; i++) - { - TToken_string & row = calendario.row(i - 1); - COLOR back = NORMAL_BACK_COLOR; - COLOR fore = NORMAL_COLOR; - - if (full_months[i]) - { - back = COLOR_DKBLUE; // coloro di blu le date con registrazioni - fore = COLOR_WHITE; // coloro di blu le date con registrazioni - } - calendario.set_back_and_fore_color(back, fore, i - 1, 0); - row.add(itom(i)); - } - } - else - if (dett == "G") - { - TDate d(1, _mese, _anno); d.set_end_month(); - const int end_month = d.day(); - TBit_array fulldays; - TISAM_recordset recset(query); - - //scorro il recordset, aggiungo una riga allo sheet per ogni chiave analitica che trovo e coloro di blu - //tutte le celle che corrispondono a una data interessata da qualcosa - for (bool ok = recset.move_first(); ok; ok = recset.move_next()) - { - const int day = recset.get(RILORE_GIORNO).as_int(); - - fulldays.set(day); - } - - for(int i = 1; i <= end_month; i++) - { - TToken_string & row = calendario.row(i - 1); - COLOR back = NORMAL_BACK_COLOR; - COLOR fore = NORMAL_COLOR; - - if (fulldays[i]) - { - back = COLOR_DKBLUE; // coloro di blu le date con registrazioni - fore = COLOR_WHITE; // coloro di blu le date con registrazioni - } - else - if (TDate(i, _mese, _anno).is_holiday()) - { - back = COLOR_DKRED; // coloro di rosso le festività - fore = COLOR_WHITE; // coloro di rosso le festività - } - calendario.set_back_and_fore_color(back, fore, i - 1, 0); - row.add(i); - } - } - calendario.force_update(); -} - void TRilevamento_cons_msk::update_column(short sid, bool full) { TSheet_field& sf = sfield(F_SHEET); if (full) sf.set_column_width(sid, 0); -// sf.set_column_width(column, !full ? (max(3 + f.size(), len + 1) * CHARX) : 0); } -void TRilevamento_cons_msk::riempi_risoatt(char tipo) +void TRilevamento_cons_msk::riempi_sheet(char tipo) { + TSheet_field& sheet = sfield(F_SHEET); TMask & sm = sheet.sheet_mask(); + if (sheet.items() > 0 && sheet.dirty() && yesno_box("Vuoi salvare le modifiche")) registra(); sheet.destroy(); - update_day(); - //leggo dalla maschera i campi chiave di ricerca +//leggo dalla maschera i campi chiave di ricerca const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT); const TString4 tpora = get(F_TPORA); TString80 codcosto; @@ -451,7 +527,6 @@ void TRilevamento_cons_msk::riempi_risoatt(char tipo) case 'A': codice = get(F_CODATT); break; default: break; } - update_disp(); get_anal_fields(codcosto, codcms, codfase); sheet.set_columns_order(); update_column(S_RISOATT, risoatt.full()); @@ -513,16 +588,17 @@ void TRilevamento_cons_msk::riempi_risoatt(char tipo) if (select.full()) query << "SELECT " << select << "\n"; + const TString & dett = get(F_INTERVALLO); TString fromto = RILORE_TIPO; fromto << "=\"" << tipo << "\""; if (_anno > 0) { fromto << " " << RILORE_ANNO << "=" << _anno << " "; - if (_mese > 0) + if (dett != "A") { fromto << RILORE_MESE << "=" << _mese << " "; - if (tipo == 'C') + if (dett != "M" && tipo == 'C') fromto << RILORE_GIORNO << "=" << _giorno << " "; } } @@ -557,12 +633,49 @@ void TRilevamento_cons_msk::riempi_risoatt(char tipo) riga.add(tipo == 'D' ? 0 : rilore.get(RILORE_ID), sheet.cid2index(S_ID)); sheet.check_row(sheet.items() - 1); - sheet.select(sheet.items() - 1); - update_prev(); } + if (sheet.items() > 0) + { + sheet.select(0); + update_disp(); + update_prev(); + } sheet.force_update(); } +void TRilevamento_cons_msk::update_tree() +{ + const TString & dett = get(F_INTERVALLO); + + if (dett == "G") + { + _anno = get_int(F_ANNO); + _mese = get_int(F_MESE); + _giorno = 1; + } + else + if (dett == "M") + { + _anno = get_int(F_ANNO); + _mese = 1; + _giorno = 1; + } + else + if (dett == "A") + { + _anno = TDate(TODAY).year(); + _mese = 1; + _giorno = 1; + } + TTree_field & cal = tfield(F_CALENDARIO); + TRil_tree * tree = (TRil_tree *) cal.tree(); + + tree->update_content(content_query(), get(F_INTERVALLO), _mese, _anno); + cal.force_update(); + cal.tree()->goto_root(); + +} + void TRilevamento_cons_msk::update_disp() { TSheet_field & sf = sfield(F_SHEET); @@ -598,17 +711,18 @@ void TRilevamento_cons_msk::update_disp() } } - if (codice.full()) + TDate day(_giorno, _mese, _anno); + TString chiave; + + chiave.cut(0) << risoatt << codice.rpad(field(F_CODRIS).size()) << day.string(ANSI) << tpora; + real * val = (real *)_oredisp.objptr(chiave); + + if (val != NULL) + set(F_OREDIS, *val); + else { - TString chiave(risoatt); - TDate day(_giorno, _mese, _anno); - - chiave << codice.rpad(field(F_CODRIS).size()) << day.string(ANSI) << tpora; - real * val = (real *)_oredisp.objptr(chiave); - - if (val != NULL) - set(F_OREDIS, *val); - else + real oredisp; + if (codice.full()) { TString query; @@ -634,13 +748,12 @@ void TRilevamento_cons_msk::update_disp() query << "TO CODTAB=\"" << tochiave << "\"\n"; TISAM_recordset def(query); - real oredisp; for(bool ok = def.move_first(); ok; ok = def.move_next()) oredisp += def.cursor()->curr().get_real("R1"); - set(F_OREDIS, oredisp); - _oredisp.add(chiave, oredisp); } + set(F_OREDIS, oredisp); + _oredisp.add(chiave, oredisp); } real orecons; @@ -741,9 +854,7 @@ void TRilevamento_cons_msk::update_prev() } } -//RIEMPI_SHEET: metodo che riempie lo sheet in base ai campi chiave -//compilati sulla maschera -void TRilevamento_cons_msk::riempi_sheet() +const char * TRilevamento_cons_msk::content_query() { //leggo dalla maschera i campi chiave di ricerca const TString4 risoatt = get(F_RISOATT) == "T" ? "" : get(F_RISOATT); @@ -752,10 +863,9 @@ void TRilevamento_cons_msk::riempi_sheet() TString80 codcms; TString16 codfase; TString16 codice; - TString query; TString select; + TString & query = get_tmp_string(256); - update_day(); switch(get(F_RISOATT)[0]) { case 'R': codice = get(F_CODRIS); break; @@ -798,17 +908,17 @@ void TRilevamento_cons_msk::riempi_sheet() query << "SELECT " << select << "\n"; TString fromto = RILORE_TIPO "=\"C\""; + const TString & dett = get(F_INTERVALLO); - if (_anno > 0) + if (dett != "A") { fromto << " " << RILORE_ANNO << "=" << _anno << " "; - if (_mese > 0) + if (dett != "M") fromto << RILORE_MESE << "=" << _mese << " "; } query << "FROM " << fromto << "\n" << "TO " << fromto; - riempi_calendario(query); - riempi_risoatt(); + return query; } //NUOVA_RIGA: metodo che aggiunge una riga allo sheet @@ -845,7 +955,7 @@ void TRilevamento_cons_msk::nuova_riga() sheet.select(r); sheet.check_row(r); riga.add(proponi_costo(riga), sheet.cid2index(S_COSTO)); - sheet.force_update(); + sheet.force_update(r); } //AZZERA_RIGA: metodo che azzera il valore unitario della riga selezionata void TRilevamento_cons_msk::azzera_riga(TSheet_field& sheet) @@ -872,11 +982,8 @@ void TRilevamento_cons_msk::azzera_tutto(TSheet_field& sheet) void TRilevamento_cons_msk::registra() { TDoc_cache ca; - TSheet_field& calendario = sfield(F_CALENDARIO); TSheet_field& sheet = sfield(F_SHEET); TRilevamento_ore rilroa; - const int mese = get_int(F_MESE); - const int anno = get_int(F_ANNO); TString80 codcosto; TString80 codcms; TString16 codfase; @@ -917,8 +1024,8 @@ void TRilevamento_cons_msk::registra() { rilroa.put(RILORE_TIPO, "C"); rilroa.put(RILORE_ID, id); - rilroa.put(RILORE_ANNO, anno); - rilroa.put(RILORE_MESE, mese); + rilroa.put(RILORE_ANNO, _anno); + rilroa.put(RILORE_MESE, _mese); rilroa.put(RILORE_GIORNO, _giorno); rilroa.put(RILORE_TIPORA, tipora); rilroa.put(RILORE_CODICE, codice); @@ -935,12 +1042,12 @@ void TRilevamento_cons_msk::registra() if (_numcn.full() && _tipocn.full()) { TDoc_key oldkey(rilroa); - const long ndoc = date2ndoc(TDate(_giorno, mese, anno)); + const long ndoc = date2ndoc(TDate(_giorno, _mese, _anno)); if (oldkey.provv() != 'D') { oldkey.set_provv(); - oldkey.set_anno(anno); + oldkey.set_anno(_anno); oldkey.set_codnum(_numcn); oldkey.set_ndoc(ndoc); } @@ -950,7 +1057,7 @@ void TRilevamento_cons_msk::registra() int docrow = olddoc.id2rownum(rilroa.get_long(RILORE_IDRIGA)); TDoc_key key(olddoc); - if (found && (key.anno() != anno || ndoc != olddoc.get_long(DOC_NDOC))) + if (found && (key.anno() != _anno || ndoc != olddoc.get_long(DOC_NDOC))) { if (docrow > 0) olddoc.destroy_row(docrow, true); @@ -961,7 +1068,7 @@ void TRilevamento_cons_msk::registra() TDocumento & doc = ca.doc(key); doc.set_tipo(_tipocn); - doc.put(DOC_DATADOC, TDate(_giorno, mese, anno)); + doc.put(DOC_DATADOC, TDate(_giorno, _mese, _anno)); TSpesa_prest risatt(codice, tipora); @@ -1010,48 +1117,23 @@ void TRilevamento_cons_msk::registra() ca.destroy(); sheet.destroy(); riempi_sheet(); + tfield(F_CALENDARIO).force_update(); } else error_box(FR("Errore %d in scrittura"), err); } -void TRilevamento_cons_msk::update_day() -{ - const int row = sfield(F_CALENDARIO).selected(); - const TString4 dett = get(F_INTERVALLO); - - if (dett == "G") - { - _anno = get_int(F_ANNO); - _mese = get_int(F_MESE); - _giorno = row +1; - } - else - if (dett == "M") - { - _anno = get_int(F_ANNO); - _mese = row + 1; - _giorno = 1; - } - else - if (dett == "A") - { - _anno = _es_array[row]; - _mese = 1; - _giorno = 1; - } -} - //ON_FIELD_EVENT: metodo che gestisce gli eventi sui vari campi della maschera bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, long jolly) { const short dlg = f.dlg(); if (e == fe_modify) { - if (dlg == _cdc_lid || dlg == _cms_lid || dlg == _fase_lid) + if (dlg >= S_CDC1 && dlg <= S_CDC12) + { riempi_sheet(); - if (dlg == _scdc_lid || dlg == _scms_lid || dlg == _sfase_lid) update_prev(); + } } if (f.dlg() == _scms_lid) { @@ -1088,10 +1170,11 @@ bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, l { case DLG_DEFAULT: if(e == fe_button) - carica_default(); + riempi_sheet('D'); break; case DLG_CERCA: if(e == fe_button) + update_tree(); riempi_sheet(); break; case DLG_SAVEREC: @@ -1099,16 +1182,32 @@ bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, l registra(); case F_ANNO: case F_MESE: + if (e == fe_modify) + update_tree(); + break; case F_RISOATT: case F_CODRIS: case F_CODATT: case F_TPORA: if (e == fe_modify) - riempi_sheet(); + riempi_sheet(); break; case F_CALENDARIO: - if (e == se_enter) - riempi_risoatt(); + if (e == fe_modify) + { + const TString & dett = get(F_INTERVALLO); + + if (dett == "A") + _anno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node())); + else + if (dett == "M") + _mese = ((TRil_tree *) tfield(F_CALENDARIO).tree())->pos() + 1; + else + _giorno = atoi(*((TString *) ((TRil_tree *) tfield(F_CALENDARIO).tree())->curr_node())); + + + riempi_sheet(); + } break; case F_SHEET: if (e == se_notify_add) @@ -1123,22 +1222,25 @@ bool TRilevamento_cons_msk::on_field_event(TOperable_field& f, TField_event e, l case F_INTERVALLO: if (e == fe_modify) { - const TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS"); + const TString & dett = f.get(); + if (dett == "A") { - reset(F_ANNO); - disable(F_ANNO); - reset(F_MESE); - disable(F_MESE); + hide(F_ANNO); + hide(F_MESE); } else - { if (dett == "M") { - reset(F_MESE); - disable(F_MESE); + show(F_ANNO); + hide(F_MESE); } - } + else + { + show(F_ANNO); + show(F_MESE); + } + update_tree(); riempi_sheet(); } break; @@ -1296,14 +1398,16 @@ TRilevamento_cons_msk::TRilevamento_cons_msk() else s.delete_column(id); } - const TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS"); - TSheet_field & sc = sfield(F_CALENDARIO); - - _n_ex = 0; - for (int codes = _es.first(); codes != 0; codes = _es.next(codes)) - _es_array[_n_ex++] = codes; + TString4 dett = ini_get_string(CONFIG_DITTA, "ci", "DETTCONS"); + if (dett.blank()) + dett = "G"; + if (dett == "A") + { disable(F_INTERVALLO); + hide(F_ANNO); + hide(F_MESE); + } else { if (dett == "M") @@ -1311,10 +1415,22 @@ TRilevamento_cons_msk::TRilevamento_cons_msk() TList_field & f = lfield(F_INTERVALLO); f.delete_item("G"); + hide(F_MESE); } - set(F_ANNO, TDate(TODAY).year()); } + set(F_ANNO, TDate(TODAY).year()); set(F_INTERVALLO, dett); + + TTree_field & tc = tfield(F_CALENDARIO); + TRil_tree * t = new TRil_tree(); + + tc.set_tree(t); + _giorno = 1; + _mese = get_int(F_MESE); + _anno = get_int(F_ANNO); + update_tree(); + tc.force_update(); + riempi_sheet(); _numcn = ini_get_string(CONFIG_DITTA, "ci", "CODNUMCN"); _tipocn = ini_get_string(CONFIG_DITTA, "ci", "TIPODOCCN"); } @@ -1334,7 +1450,6 @@ void TRilevamento_cons_app::main_loop() { open_files(LF_DOC, LF_RIGHEDOC, LF_RILORE, 0); TRilevamento_cons_msk msk; - msk.riempi_sheet(); while (msk.run() != K_QUIT) ; } diff --git a/ci/ci2200a.uml b/ci/ci2200a.uml index b954cd768..b60dbf53d 100755 --- a/ci/ci2200a.uml +++ b/ci/ci2200a.uml @@ -134,19 +134,18 @@ BEGIN FLAG "D" END -SPREADSHEET F_CALENDARIO 10 0 +TREE F_CALENDARIO 10 14 BEGIN PROMPT 1 8 "" - ITEM "@4" END -SPREADSHEET F_SHEET 85 0 +SPREADSHEET F_SHEET 65 0 BEGIN PROMPT 15 8 "" ITEM "Canc" ITEM "Tipo" ITEM "Codice@16" - ITEM "Tipo\nOra@5" + ITEM "T.Ora@5" ITEM "CDC1" ITEM "CDC2" ITEM "CDC3" @@ -160,7 +159,7 @@ BEGIN ITEM "CDC11" ITEM "CDC12" ITEM "Ore@7" - ITEM "Listino" + ITEM "Listino" ITEM "Costo@6" ITEM "Ore Prev." ITEM "CUP@15" @@ -172,26 +171,6 @@ END ENDPAGE ENDMASK -PAGE "Calendario" -1 -1 78 6 - -STRING F_CONT 20 -BEGIN - PROMPT 2 2 " " -END - -ENDPAGE - -TOOLBAR "" 0 0 0 2 - -BUTTON DLG_CANCEL 2 2 -BEGIN - PROMPT 4 1 "Annulla" - PICTURE TOOL_CANCEL -END - -ENDPAGE -ENDMASK - PAGE "Riga consuntivo" -1 -1 78 17 GROUPBOX DLG_NULL 76 16 @@ -448,4 +427,4 @@ BEGIN END ENDPAGE -ENDMASK \ No newline at end of file +ENDMASK diff --git a/include/treectrl.cpp b/include/treectrl.cpp index 3e8e8a19a..93caf5a38 100755 --- a/include/treectrl.cpp +++ b/include/treectrl.cpp @@ -356,7 +356,8 @@ void TTree_window::set_tree(TTree* tree) // Memorizza la posizione dell'albero per dopo ... TString curr; tree->curr_id(curr); create_children(NULL); // Rigenera i figli della radice - tree->goto_node(curr); // Riporta la selezione sul nodo memorizzato + if (tree->goto_node(curr)) // Riporta la selezione sul nodo memorizzato + select_current(); } } @@ -597,8 +598,9 @@ void TTree_field::set_tree(TTree* tree) { TTree_window& tv = tree_win(); tv.set_tree(tree); - tv.select_current(); } +void TTree_field::force_update() +{ set_tree(tree()); } void TTree_window::force_update() { set_tree(tree()); } diff --git a/include/treectrl.h b/include/treectrl.h index 6ee366e48..56ec3d42e 100755 --- a/include/treectrl.h +++ b/include/treectrl.h @@ -58,6 +58,7 @@ protected: // TWindowed_field public: TTree* tree() const; void set_tree(TTree* t); + virtual void force_update(); void hide_leaves(bool yes = true); void show_leaves(bool yes = true) { hide_leaves(!yes); }