diff --git a/ve/ve6800.cpp b/ve/ve6800.cpp index 6667a7433..e68ce833a 100755 --- a/ve/ve6800.cpp +++ b/ve/ve6800.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include "velib04.h" #include "../cg/cgsaldac.h" @@ -77,24 +77,20 @@ bool TContabilizzazione_analitica_mask::on_field_event(TOperable_field& o, TFiel switch (o.dlg()) { case F_CODICE_ELAB: - if (e == fe_modify) + if (e == fe_modify || e == fe_init) { - if (o.empty()) - disable(DLG_ELABORA); - else + const bool full = !o.empty(); + if (full) build_num_sheet(); + enable(DLG_USER, full); + enable(DLG_OK, full && _num_sheet->one_checked()); } break; case DLG_USER: - if (e == fe_button) + if (e == fe_button && _num_sheet->run()) { - if (_num_sheet->run()) - { - if (_num_sheet->checked() != 0) // Hai selezionato qualcosa ? - enable(DLG_ELABORA); // allora abilita il pulsante di conferma - else - disable(DLG_ELABORA); - } + // Hai selezionato qualcosa ? allora abilita il pulsante di conferma + enable(DLG_OK, _num_sheet->one_checked()); } break; default: @@ -108,49 +104,46 @@ void TContabilizzazione_analitica_mask::build_num_sheet() _num_sheet->destroy(); _tipi_doc.destroy(); - TTable num("%NUM"); - TString s1,s2,s3; - - TContabilizzazione_analitica* contanal = new TContabilizzazione_analitica(get(F_CODICE_ELAB)); - if (!contanal->empty()) + const TContabilizzazione_analitica contanal(get(F_CODICE_ELAB)); + if (!contanal.empty()) { TToken_string t; - TString16 tipo; + TString4 tipo; for (int i = 0; i < TElaborazione::_max_tipi_doc_elab; i++) { - tipo = contanal->tipo_iniziale(i); - if (tipo.not_empty()) + tipo = contanal.tipo_iniziale(i); + if (tipo.full()) { t = tipo; - t.add(contanal->stato_iniziale(i)); // Stato iniziale + t.add(contanal.stato_iniziale(i)); // Stato iniziale _tipi_doc.add(t); // Aggiunge questo tipo documento alla lista } } - long pos = 0l; - - for (num.first(); num.good(); num.next(), pos++) // scorre tutte le numerazioni possibili + TString s1,s2,s3; + TTable num("%NUM"); + for (num.first(); num.good(); num.next()) // scorre tutte le numerazioni possibili { TToken_string t,z; t.add(" "); t.add(num.get("CODTAB")); t.add(num.get("S0")); - _num_sheet->add(t); + s2 = num.get("S2"); // reperisce i tipi documento validi per questa numerazione for (int x = 0; x <= s2.len(); x += 4) z.add(s2.mid(x,4)); - bool found = FALSE; + bool found = false; for (int i = _tipi_doc.last(); !found && i >= 0; i--) - found |= (s2.find(((TToken_string &)_tipi_doc[i]).get(0)) >= 0); + found |= s2.find(_tipi_doc.row(i).get(0)) >= 0; if (found) - _num_sheet->enable_row(pos); - else - _num_sheet->disable_row(pos); + _num_sheet->add(t); } + + if (_num_sheet->items() == 1) + _num_sheet->check(0); } - delete contanal; } bool TContabilizzazione_analitica_mask::doc_tipo_stato_ok(const TRectype& doc) @@ -158,13 +151,13 @@ bool TContabilizzazione_analitica_mask::doc_tipo_stato_ok(const TRectype& doc) // differita selezionata { bool found = false; - const TString16 tipo = doc.get(DOC_TIPODOC); + const TString4 tipo = doc.get(DOC_TIPODOC); const char stato = doc.get_char(DOC_STATO); const int items = _tipi_doc.items(); for (int i = 0; i < items && !found; i++) { TToken_string& t = _tipi_doc.row(i); - const TString16 tipox(t.get(0)); + const TString4 tipox(t.get(0)); const char statox = t.get(1)[0]; if (tipo == tipox && stato == statox) found = true; @@ -262,7 +255,7 @@ void TContabilizzazione_analitica_app::contabilize() { p.addstatus(1); // controlla che il tipo documento e lo stato siano coerenti con la ELD selezionata - if (nums.get_pos(cur_rec.get("CODNUM")) >= 0 && _msk->doc_tipo_stato_ok(cur_rec)) + if (nums.get_pos(cur_rec.get(DOC_CODNUM)) >= 0 && _msk->doc_tipo_stato_ok(cur_rec)) { TDocumento* doc = new TDocumento; if (doc->read(doc_cur.curr()) == NOERR) // legge il documento @@ -288,6 +281,7 @@ void TContabilizzazione_analitica_app::contabilize() bool TContabilizzazione_analitica_app::create() { + open_files(LF_TABCOM, LF_TAB, LF_DOC, LF_RIGHEDOC, LF_MOVANA, LF_RMOVANA, 0); _msk = new TContabilizzazione_analitica_mask(); return TSkeleton_application::create(); } @@ -301,14 +295,12 @@ bool TContabilizzazione_analitica_app::destroy() void TContabilizzazione_analitica_app::main_loop() { while (_msk->run() == K_ENTER) - { contabilize(); - } } int ve6800 (int argc, char **argv) { TContabilizzazione_analitica_app a; - a.run(argc,argv,"Contabilizzazione analitica documenti"); + a.run(argc,argv, TR("Contabilizzazione analitica documenti")); return true; } diff --git a/ve/ve6800a.uml b/ve/ve6800a.uml index 56f7d5446..6b0dd7346 100755 --- a/ve/ve6800a.uml +++ b/ve/ve6800a.uml @@ -1,24 +1,6 @@ #include "ve6800a.h" -TOOLBAR "topbar" 0 0 0 2 - -BUTTON DLG_USER 10 2 -BEGIN - PROMPT -12 -1 "~Selezione" - PICTURE TOOL_MULTISEL -END - -BUTTON DLG_ELABORA 10 2 -BEGIN - PROMPT -22 -1 "~Elabora" - PICTURE TOOL_ELABORA -END - -#include - -ENDPAGE - -PAGE "Contabilizzazione Analitica documenti" 0 2 0 0 +PAGE "Contabilizzazione Analitica documenti" -1 -1 78 8 STRING F_CODICE_ELAB 8 BEGIN @@ -73,4 +55,16 @@ END ENDPAGE +TOOLBAR "topbar" 0 0 0 2 + +BUTTON DLG_USER 10 2 +BEGIN + PROMPT -12 -1 "~Selezione" + PICTURE TOOL_MULTISEL +END + +#include + +ENDPAGE + ENDMASK diff --git a/ve/velib04f.cpp b/ve/velib04f.cpp index d24770a05..1c967c691 100755 --- a/ve/velib04f.cpp +++ b/ve/velib04f.cpp @@ -717,10 +717,9 @@ static bool link_handler_ana(int n, const char* nreg) bool TContabilizzazione_analitica::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out, const TDate& data_elab, bool interattivo) { - const TImporto zero; TPrinter& p = printer(); TViswin v(NULL, TR("Contabilizzazione documenti in analitica"), false, true, true); - + _total_docs = 0; p.links().add("Movimento Analitico |r|w", 0); p.setlinkhandler(link_handler_ana); @@ -730,17 +729,37 @@ bool TContabilizzazione_analitica::elabora(TLista_documenti& doc_in, TLista_docu { TAnal_mov mov; if (elabora(doc_in[i], 0, &v, true, mov)) - doc_in[i].stato(get_char("S4")); + { + // Cambia stato al documento elborato con successo + TDocumento& di = doc_in[i]; + di.stato(stato_finale_doc_iniziale()[0]); + if (di.rewrite() == NOERR) + _total_docs++; + else + { + TString msg; + msg << TR("*** Impossibile cambiare stato al documento") + << ' ' << di.get(DOC_ANNO) + << ' ' << di.get(DOC_CODNUM) + << ' ' << di.get(DOC_NDOC); + v.add_line(msg); + } + } else break; } v.close_print(); v.close_modal(); + + if (_total_docs > 0) + { + post_process_input(doc_in); + post_process_output(doc_out); + } + if (v.run() == K_CTRL+'S') // Ho premuto Stampa p.print_txt(v.text()); - post_process_input(doc_in); - post_process_output(doc_out); return true; } diff --git a/ve/velib06.cpp b/ve/velib06.cpp index fa837f3bf..c9451bef8 100755 --- a/ve/velib06.cpp +++ b/ve/velib06.cpp @@ -843,7 +843,7 @@ void TDocumento_mask::cli2mask(bool force_load) set(F_STATOCF, c.get(CLI_STATOCF)); check_field( F_CODINDSP ); } - const TString16 newcodval(get(F_CODVAL)); + const TString4 newcodval(get(F_CODVAL)); short pos = id2pos(F_CAMBIO); if ((pos >= 0) && newcodval.empty())