From df36f2cc2b81258f6e3a4cadb7ba46b72400bb22 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 3 Jan 1996 17:31:54 +0000 Subject: [PATCH] Include mancante in sc2101.cpp piu stato dell' arte dei solleciti git-svn-id: svn://10.65.10.50/trunk@2388 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sc/sc2101.cpp | 1 + sc/sc2400.cpp | 58 +++-- sc/sc2400a.uml | 105 ++++++--- sc/sc2401.cpp | 552 ++++++++++++++++++++++++++++++++++++++---------- sc/sc2401.h | 53 ++++- sc/sc2402.cpp | 6 +- sc/sc2402.h | 2 +- sc/scselect.cpp | 210 ++++++++++++++++-- sc/scselect.h | 6 + sc/scselmsk.h | 2 + 10 files changed, 797 insertions(+), 198 deletions(-) diff --git a/sc/sc2101.cpp b/sc/sc2101.cpp index 6f40b47eb..f42f651da 100755 --- a/sc/sc2101.cpp +++ b/sc/sc2101.cpp @@ -1,4 +1,5 @@ #include +#include #include "sc2101.h" #include "sc2100a.h" diff --git a/sc/sc2400.cpp b/sc/sc2400.cpp index 2a17dbc7a..46627863c 100755 --- a/sc/sc2400.cpp +++ b/sc/sc2400.cpp @@ -29,7 +29,7 @@ class TStampaSol_application: public TApplication { protected: virtual bool create(); virtual bool destroy(); - virtual bool menu(MENU_TAG mt); + virtual bool menu(MENU_TAG m); virtual void on_firm_change(); public: @@ -38,13 +38,14 @@ public: TCursor_sheet &sheet() { return _msk->cur_sheet(); } bool print_selected(); // cicla la stampa sugli elementi selezionati - bool print_sol(); // stampa l'elemento corrente + int print_sol(); // stampa l'elemento corrente TStampaSol_application(); virtual ~TStampaSol_application() {} }; -bool TStampaSol_application::print_selected() { +bool TStampaSol_application::print_selected() +{ TCursor_sheet &s = sheet(); TCursor &c = *s.cursor(); @@ -52,6 +53,7 @@ bool TStampaSol_application::print_selected() { const int key = mask().get_key(); // filtra il cursore del form in mode che diventi uguale al cursor_sheet corrente + // Qui sarebbe bello copiarsi l'indice dell'altro cursore TCursor &fc = *form().cursor(); fc.setkey(key); TRectype filter(LF_CLIFO); @@ -62,15 +64,26 @@ bool TStampaSol_application::print_selected() { long analfabeti = 0; // persone non stampate in quanto aventi lingua errata printer().open(); - + + bool one_printed = FALSE; const long items = c.items(); - for (long i=0; i < items; i++) if (print_all || s.checked(i)) { + for (long i=0; i < items; i++) if (print_all || s.checked(i)) + { +// if (one_printed) +// printer().formfeed(); + fc= i; // muove il cursore alla posizione corrente - const bool ok = print_sol(); - if (!ok) analfabeti++; + const int ret = print_sol(); + if (ret > 0) + one_printed = TRUE; + else + if (ret < 0) + analfabeti++; + } - printer().formfeed(); +// if (one_printed) +// printer().formfeed(); printer().close(); if (analfabeti > 0) { @@ -81,7 +94,8 @@ bool TStampaSol_application::print_selected() { return TRUE; } -bool TStampaSol_application::print_sol() { +int TStampaSol_application::print_sol() +{ TSol_form &f= form(); // preparazione variabili per controllo lingua @@ -91,7 +105,7 @@ bool TStampaSol_application::print_sol() { // controllo lingua ditta corrente if ((f.lingua() == _lingua_ditta && !lincf.empty()) || f.lingua() != _lingua_ditta) ok= (lincf == f.lingua()); - if (!ok) return FALSE; // cliente analfabeta + if (!ok) return -1; // cliente analfabeta // filtra solo le partite del cliente selezionato TLocalisamfile& partite = _file[LF_PARTITE]; @@ -115,11 +129,13 @@ bool TStampaSol_application::print_sol() { { TPartita game(partite.curr()); saldo += game.calcola_saldo_al(FALSE, data_limite_soll); + partite.put(PART_NRIGA, 9999); } saldo.normalize(f.sezione_normale()); if (saldo.valore() < sel_importo) - return TRUE; + return 0; + partite.curr() = filter; } for (int err = partite.read(_isgteq); err == NOERR && partite.curr() == filter; @@ -143,15 +159,15 @@ bool TStampaSol_application::print_sol() { if (one_printed) printer().formfeed(); - - return TRUE; + return one_printed ? 1 : 0; } -bool TStampaSol_application::create() { +bool TStampaSol_application::create() +{ TApplication::create(); _file.open(LF_TABCOM, LF_TAB, LF_CAUSALI, LF_MOV, LF_RMOV, 0); - _file.open(LF_NDITTE, LF_ANAG, LF_COMUNI, 0); + _file.open(LF_NDITTE, LF_ANAG, LF_COMUNI, LF_RFORM, 0); _file.open(LF_CLIFO, LF_PARTITE, LF_SCADENZE, LF_PAGSCA ,0); _msk= new TSol_mask("sc2400a"); @@ -160,26 +176,28 @@ bool TStampaSol_application::create() { return TRUE; } -bool TStampaSol_application::destroy() { +bool TStampaSol_application::destroy() +{ delete _msk; _file.close(); return TApplication::destroy(); } -void TStampaSol_application::on_firm_change() { +void TStampaSol_application::on_firm_change() +{ TApplication::on_firm_change(); TConfig c(CONFIG_DITTA, "cg"); _lingua_ditta= c.get("CodLin"); _gesval= c.get_bool("GesVal"); } -bool TStampaSol_application::menu(MENU_TAG mt) +bool TStampaSol_application::menu(MENU_TAG) { TSol_mask &m= mask(); - while (m.run() == K_ENTER) + while (m.run() != K_QUIT) { - _form= new TSol_form(m, F_DATALIMSOL); + _form= new TSol_form(m, _gesval, F_DATALIMSOL); print_selected(); delete _form; _form= NULL; diff --git a/sc/sc2400a.uml b/sc/sc2400a.uml index b1f0c6dba..294f7c524 100755 --- a/sc/sc2400a.uml +++ b/sc/sc2400a.uml @@ -1,7 +1,7 @@ #include "scselmsk.h" #include "sc2400a.h" -PAGE "Stampa solleciti" -1 -1 68 16 +PAGE "Stampa solleciti" -1 -1 68 17 NUMBER F_CODDITTA 5 BEGIN @@ -21,12 +21,12 @@ END GROUPBOX DLG_NULL 68 7 BEGIN - PROMPT 0 7 "" + PROMPT 0 2 "" END NUMBER F_CODPROF 4 BEGIN - PROMPT 1 8 "Profilo " + PROMPT 1 3 "Profilo " FLAGS "Z" USE LF_FORM INPUT TIPOPROF BASE_EC_PROFILE @@ -38,11 +38,13 @@ BEGIN OUTPUT F_LINPROF CODPROF[5,5] OUTPUT F_DESPROF DESC CHECKTYPE REQUIRED + FIELD ANTICLEAR + WARNING "Codice profilo o lingua errato" END STRING F_LINPROF 1 BEGIN - PROMPT 18 8 "" + PROMPT 18 3 "" USE %LNG INPUT CODTAB F_LINPROF DISPLAY "Codice" CODTAB @@ -53,99 +55,134 @@ END STRING F_DESPROF 50 40 BEGIN - PROMPT 25 8 "" + PROMPT 25 3 "" FLAGS "D" END DATE F_DATALIMSOL BEGIN - PROMPT 1 9 "Data limite sollecito " + PROMPT 1 4 "Data limite sollecito " FLAGS "A" VALIDATE DATE_CMP_FUNC <= F_DATASEND - WARNING "La data limite sollecito non puņ essere superiore alla data di invio" + WARNING "La data limite sollecito deve essere specificata e non puņ essere superiore alla data di invio" CHECKTYPE REQUIRED END NUMBER F_IMPORMIN 18 BEGIN - PROMPT 1 10 "Importo minimo " + PROMPT 1 5 "Importo minimo " END RADIOBUTTON F_RIFIMPMIN 10 BEGIN - PROMPT 45 9 "" + PROMPT 45 4 "" ITEM "P|Partita" ITEM "C|Cliente" END BOOLEAN F_STAMPESP BEGIN - PROMPT 1 11 "Stampa esposizione" + PROMPT 1 6 "Stampa esposizione" END STRING F_LUOGOSEND 50 32 BEGIN - PROMPT 1 12 "Luogo d'invio " + PROMPT 1 7 "Luogo d'invio " END DATE F_DATASEND BEGIN - PROMPT 50 12 "data " + PROMPT 50 7 "Data " FLAGS "A" CHECKTYPE REQUIRED END RADIOBUTTON SC_SORTCF 40 BEGIN - PROMPT 1 2 "Ordinamento" - ITEM "1|Per codice" - ITEM "2|Per ragione sociale" + PROMPT 1 9 "Ordinamento" + ITEM "1|Per codice" MESSAGE HIDE,2@|SHOW,1@ + ITEM "2|Per ragione sociale" MESSAGE HIDE,1@|SHOW,2@ END BUTTON SC_SELECT 10 1 BEGIN - PROMPT 50 3 "~Selezione" + PROMPT 50 10 "~Selezione" END BUTTON SC_RESET 10 1 BEGIN - PROMPT 50 4 "~Azzera" + PROMPT 50 11 "~Azzera" END NUMBER SC_CFCODFR 5 BEGIN - PROMPT 1 6 "Da codice " + PROMPT 1 13 "Da codice " + GROUP 1 +END + +BUTTON SC_CFBUTFR 2 1 +BEGIN + PROMPT 31 13 "" + GROUP 1 + PICTURE 109 END NUMBER SC_CFCODTO 5 BEGIN - PROMPT 36 6 "a codice " + PROMPT 36 13 "a codice " + GROUP 1 END +BUTTON SC_CFBUTTO 2 1 +BEGIN + PROMPT 51 13 "" + PICTURE 109 + GROUP 1 +END + +STRING SC_CFDESFR 50 30 +BEGIN + PROMPT 1 13 "Da ragione sociale " + GROUP 2 + FLAGS "H" +END + +BUTTON SC_CFDESBUTFR 2 1 +BEGIN + PROMPT 51 13 "" + PICTURE 109 + GROUP 2 + FLAGS "H" +END + +STRING SC_CFDESTO 50 30 +BEGIN + PROMPT 2 14 "A ragione sociale " + GROUP 2 + FLAGS "H" +END + +BUTTON SC_CFDESBUTTO 2 1 +BEGIN + PROMPT 51 14 "" + PICTURE 109 + GROUP 2 + FLAGS "H" +END + NUMBER SC_NSEL 3 BEGIN - PROMPT 59 6 "N. " + PROMPT 59 13 "N. " FLAGS "D" END -BUTTON SC_CFBUTFR 2 1 -BEGIN - PROMPT 31 6 "" - PICTURE 109 -END - -BUTTON SC_CFBUTTO 2 1 -BEGIN - PROMPT 51 6 "" - PICTURE 109 -END - -BUTTON DLG_OK 10 2 +BUTTON DLG_PRINT 10 2 BEGIN PROMPT -12 -1 "" + MESSAGE EXIT,K_ENTER END -BUTTON DLG_CANCEL 10 2 +BUTTON DLG_QUIT 10 2 BEGIN PROMPT -22 -1 "" END diff --git a/sc/sc2401.cpp b/sc/sc2401.cpp index f08a097d3..47639b89b 100755 --- a/sc/sc2401.cpp +++ b/sc/sc2401.cpp @@ -1,9 +1,10 @@ #include "../cg/saldacon.h" +#include #include #include #include -#include +#include #include "sc21pec.h" #include "sc2401.h" @@ -40,6 +41,14 @@ const TString &TESSL_mask::get_prof_code() const { return get(F_CODPROF); } +const char *TESSL_mask::get_prof_name() const +{ + TFixed_string tmp(__tmp_string, 16); + tmp = get_prof_code(); + tmp << get_prof_lang(); + return __tmp_string; +} + const TString &TESSL_mask::get_prof_lang() const { return get(F_LINPROF); } @@ -49,7 +58,9 @@ const TString &TESSL_mask::get_prof_lang() const { // TESSL_row /////////////////////////////////////////////////////////// -TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata): _num_prot(0) { +TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata) + : _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE) + { _riga = row.get_int(PART_NRIGA); _rata = rata; @@ -57,6 +68,7 @@ TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto _causale = row.get(PART_CODCAUS); _data_doc = row.get(PART_DATADOC); _num_prot = row.get_long(PART_PROTIVA); + _num_reg = row.get_long(PART_NREG); _importo = imp; _importo.normalize(); _totale = row.get_real(PART_IMPTOTDOC); @@ -64,7 +76,7 @@ TESSL_row::TESSL_row(const TRiga_partite& row, const TDate& data, const TImporto } TESSL_row::TESSL_row(const char* desc, const TImporto& imp) - : _riga(9999), _rata(9999), _num_prot(0), _salvo_buon_fine(FALSE) + : _riga(9999), _rata(9999), _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE) { _descrizione = desc; _importo = imp; _importo.normalize(); @@ -86,20 +98,36 @@ int TESSL_row::compare(const TSortable& s) const return c; } +// Annulla i campi uguali alla riga precedente +void TESSL_row::reset_uguali() +{ + _num_doc = ""; + _data_doc = botime; + _num_prot = 0; + _totale = ZERO; +} + void TESSL_row::set_imp(TForm_item& fi, const real& imp, bool valuta) const { - TString old_picture; + TString old_picture(20); if (valuta) { old_picture = fi.picture(); TString new_picture(20); - new_picture = old_picture; - if (old_picture.find(',') > 0) - new_picture << ".###"; + + if (old_picture.empty()) + { + new_picture = valuta ? ".3" : "."; + } else - new_picture << ",###"; - + { + new_picture = old_picture; + if (old_picture.find(',') > 0) + new_picture << ".###"; + else + new_picture << ",###"; + } fi.set_picture(new_picture); } @@ -111,9 +139,17 @@ void TESSL_row::set_imp(TForm_item& fi, const real& imp, bool valuta) const } } +TESSL_form& TESSL_row::form() const +{ + TESSL_form* f = TESSL_form::_form; + CHECK(f, "NULL form"); + return *f; +} + void TESSL_row::print_on(TPrint_section& body) { TESSL_form& form = (TESSL_form&)body.form(); + const bool valuta = form.in_valuta() && in_valuta(); TForm_item& causale = body.find_field(PEC_CODCAUS); causale.set(_causale); @@ -123,7 +159,14 @@ void TESSL_row::print_on(TPrint_section& body) } TForm_item& descr = body.find_field(PEC_DESCR1); - descr.set(_descrizione); + if (num_reg() > 0) // Riga di partita vera e propria (non totale parziale) + { + TString s(80); s = descr.prompt(); + TESSL_form::_form->change_magic_body(*this, s); + descr.set(s); + } + else + descr.set(_descrizione); TForm_item& datadoc = body.find_field(PEC_DATADOC); datadoc.set(_data_doc.string()); @@ -142,11 +185,14 @@ void TESSL_row::print_on(TPrint_section& body) TForm_item& dare = body.find_field(PEC_DARE); TForm_item& avere = body.find_field(PEC_AVERE); - if (_importo.sezione() == 'D') { - dare.set(imp.string()); + if (_importo.sezione() == 'D') + { + set_imp(dare, imp, valuta); avere.set(""); - } else { - avere.set(imp.string()); + } + else + { + set_imp(avere, imp, valuta); dare.set(""); } @@ -154,13 +200,11 @@ void TESSL_row::print_on(TPrint_section& body) importo_in_lire.set(_importo_lire.string()); TForm_item& scaduto = body.find_field(PEC_SCADUTO); - scaduto.set(_scaduto.string()); + set_imp(scaduto, _scaduto, valuta); TForm_item& esposto = body.find_field(PEC_ESPOSTO); - esposto.set(_esposto.string()); - - TForm_item& sbf = body.find_field(PEC_SBF); - sbf.set(_salvo_buon_fine ? "*" : " "); + set_imp(esposto, _esposto, valuta); + esposto.set_prompt(_salvo_buon_fine ? "*" : " "); TForm_item& cambio = body.find_field(PEC_CAMBIO); cambio.set(_valuta.cambio().string()); @@ -168,7 +212,13 @@ void TESSL_row::print_on(TPrint_section& body) TForm_item& datacambio = body.find_field(PEC_DATACAM); datacambio.set(_valuta.data().string()); - body.update(); + const TString old_prompt(descr.prompt()); + descr.set_prompt(""); // Nasconde temporaneamente il prompt per non stampare i + + body.update(); // crea la vera riga di stampa + + esposto.set_prompt(" "); + descr.set_prompt(old_prompt); // Ripristina il vecchio prompt } static int val_compare(const void* o1, const void* o2) { @@ -188,29 +238,29 @@ static int val_compare(const void* o1, const void* o2) { TImporto TESSL_array::importo(const TPartita& game, const TRectype& pag, bool valuta) const { const int nriga = pag.get_int(PAGSCA_NRIGA); - const TRiga_partite& fat = game.riga(nriga); + const TRiga_partite& fat = game.riga(nriga); // Riga di fattura const bool fat_val = fat.in_valuta(); const int nrigp = pag.get_int(PAGSCA_NRIGP); - const TRiga_partite& sum = game.riga(nrigp); + const TRiga_partite& sum = game.riga(nrigp); // Riga di pagamento const char sez = sum.sezione(); const char* const field = valuta && fat_val ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO; - TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); + TImporto imp(sez, pag.get_real(field)); // Importo base if (!fat_val) - imp.valore() += pag.get_real(PAGSCA_RITENUTE); + imp.valore() += pag.get_real(PAGSCA_RITENUTE); // Sommo le ritenute se sono in lire - if (pag.get_char(PAGSCA_ACCSAL) == 'S') + if (pag.get_char(PAGSCA_ACCSAL) == 'S') // Se il pagamento ha abbuoni o differenze cambio { real abb(pag.get(PAGSCA_ABBUONI)); - if (!valuta && fat_val) + if (!valuta && fat_val) // Se voglio gli abbuoni in lire ma la fattura non lo e' { - const TValuta val(sum); - val.val2lit(abb); - abb += pag.get_real(PAGSCA_DIFFCAM); + const TValuta val(sum); // Leggo il cambio dalla riga di partita + val.val2lit(abb); // Converto in lire gli abbuoni + abb += pag.get_real(PAGSCA_DIFFCAM); // Sommo l'eventuale differenza cambio (gia' in lire) } - imp.valore() += abb; + imp.valore() += abb; // Sommo il tutto all'importo base (sez e' uguale per tutti i valori) } return imp; @@ -294,13 +344,13 @@ TESSL_row& TESSL_array::new_row(const TRiga_partite& row, const TDate& data, con { CHECKD(n > 0, "Numero rata errato: ", n); TESSL_row* riga = new TESSL_row(row, data, imp, n); - add(riga, n); + add(riga); return *riga; } void TESSL_array::add_row(const TRiga_partite& row) { - const bool in_valuta = form().in_valuta(); + const bool in_valuta = form().in_valuta() && row.in_valuta();; real importo_in_lire(ZERO); const char sezione = form().sezione_normale(); @@ -315,9 +365,9 @@ void TESSL_array::add_row(const TRiga_partite& row) TESSL_row& rec = new_row(row, data, rata.importo(in_valuta), r); if (in_valuta) { - TImporto i(rata.importo(FALSE)); - i.normalize(sezione); - rec.importo_in_lire(i.valore()); + TImporto il(rata.importo(FALSE)); + il.normalize(sezione); + rec.importo_in_lire(il.valore()); } if (data <= form().data_limite_scaduto()) { @@ -332,7 +382,7 @@ void TESSL_array::add_row(const TRiga_partite& row) const TDate data(row.get(PART_DATAPAG)); if (data <= form().data_limite_operazione()) { - const TImporto imp(row.importo(in_valuta, 0x1)); + const TImporto imp(row.importo(in_valuta, 0x1)); // Importo pulito senza nient'altro TESSL_row& riga = new_row(row, data, imp, 1); if (in_valuta) { @@ -370,51 +420,45 @@ void TESSL_array::add_row(const TRiga_partite& row) } } + TImporto ritenute(row.importo(FALSE, 0x8)); + if (!ritenute.is_zero()) + { + TESSL_row& r = new_row(row, data, TImporto('D', ZERO), 4); + r.descrizione(form().describe(PEC_RITENUTE)); + if (in_valuta) + { + ritenute.normalize(sezione); + r.importo_in_lire(ritenute.valore()); + } + else + r.importo(ritenute); + } + const TImporto abbuoni(row.importo(in_valuta, 0x2)); if (!abbuoni.is_zero()) { TESSL_row& r = new_row(row, data, abbuoni, 2); - r.descrizione(form().describe(302)); + r.descrizione(form().describe(PEC_ABBUONI)); if (in_valuta) { - TImporto i(row.importo(FALSE, 0x2)); - i.normalize(sezione); - r.importo_in_lire(i.valore()); + TImporto il(row.importo(FALSE, 0x2)); + il.normalize(sezione); + r.importo_in_lire(il.valore()); } } TImporto diffcam(row.importo(FALSE, 0x4)); if (!diffcam.is_zero()) { + TESSL_row& r = new_row(row, data, TImporto('D', ZERO), 3); + r.descrizione(form().describe(PEC_DIFFCAM)); if (in_valuta) { - TESSL_row& r = new_row(row, data, TImporto('D', ZERO), 3); - r.descrizione(form().describe(303)); diffcam.normalize(sezione); r.importo_in_lire(diffcam.valore()); } else - { - TESSL_row& r = new_row(row, data, diffcam, 3); - r.descrizione(form().describe(303)); - } - } - - TImporto ritenute(row.importo(FALSE, 0x8)); - if (!ritenute.is_zero()) - { - if (in_valuta) - { - TESSL_row& r = new_row(row, data, TImporto('D', ZERO), 3); - r.descrizione(form().describe(304)); - ritenute.normalize(sezione); - r.importo_in_lire(ritenute.valore()); - } - else - { - TESSL_row& r = new_row(row, data, ritenute, 3); - r.descrizione(form().describe(304)); - } + r.importo(diffcam); } } } @@ -450,14 +494,33 @@ TESSL_array::TESSL_array(const TPartita& game, const TESSL_form* f) TESSL_form * TESSL_form::_form = NULL; -void TESSL_form:: header_handler(TPrinter& pr) +void TESSL_form::stampa_testata(TPrinter& pr) { - TPrint_section& head = _form->section('H'); - head.reset(); - pr.resetheader(); - + TPrint_section& head = section('H'); + + TForm_item& pagina = head.find_field(PEC_PAGINA); + TString16 pg; pg << int(pr.getcurrentpage()); + pagina.set(pg); + head.update(); - for (word j = 0; j < head.height(); j++) pr.setheaderline(j, head.row(j)); + + const word r = head.height()-1; + TPrintrow& head_row = head.row(r-1); + + TPrint_section& body = section('B'); + for (int f = body.fields()-1; f >= 0; f--) + { + // Leggi lo special e stampalo + TForm_item& fi = body.field(f); + if (fi.shown()) + { + const int x = offset_x() + fi.x() - 1; // Le TPrintrow partono da 0, bestia! + head_row.put(fi.key(), x); + } + } + + for (word j = 0; j <= r; j++) + pr.setheaderline(j, head.row(j)); } static int tot_compare(const void* o1, const void* o2) @@ -465,42 +528,41 @@ static int tot_compare(const void* o1, const void* o2) if (o1 == o2) // Sfrutto una piccola debolezza di qsort: return 0; // ogni tanto confronta oggetti con se stessi - const THash_object* h1 = (const THash_object*)o1; - const THash_object* h2 = (const THash_object*)o2; + const THash_object* h1 = *((const THash_object**)o1); + const THash_object* h2 = *((const THash_object**)o2); return stricmp(h1->key(), h2->key()); } -void TESSL_form::footer_handler(TPrinter& pr) +word TESSL_form::ordina_totali_per_valuta(THash_object* tot[MAXTOT]) { - TPrint_section& foot = _form->section('F'); - pr.resetfooter(); - - const word MAXTOT = 16; - THash_object* tot[MAXTOT]; - // I totali sono in un assoc array disordinato per cui li copio in un array e li ordino // alfabeticamente in base al loro codice valuta - TTotalizer& totali = _form->totali(); - totali.restart(); + TTotalizer& arr = totali(); + arr.restart(); + word num_rip = 0; + for (THash_object* obj = arr.get_hashobj(); + num_rip < MAXTOT && obj != NULL; + obj = arr.get_hashobj()) + tot[num_rip++] = obj; + qsort(tot, num_rip, sizeof(THash_object*), tot_compare); + return num_rip; +} + +void TESSL_form::stampa_riporti(TPrinter& pr) +{ + THash_object* tot[MAXTOT]; + _num_rip = ordina_totali_per_valuta(tot); + + const word maxtot = section('F').height() - 1; + if (_num_rip > maxtot) + _num_rip = maxtot; - word numtot = 0; - for (THash_object* obj = totali.get_hashobj(); - numtot < MAXTOT && obj != NULL; - obj = totali.get_hashobj()) - tot[numtot++] = obj; - qsort(tot, numtot, sizeof(THash_object*), tot_compare); - - const word maxtot = foot.height() / _form->_footer_used; - if (numtot > maxtot) - numtot = maxtot; - - const TString& riporto = _form->describe(301, 'F'); + const TString& riporto = describe(PEC_RIPORTO); TString desc(80); - TPrint_section& body = _form->section('B'); - for (word j = 0; j < numtot; j++) + TPrint_section& body = section('B'); + for (word j = 0; j < _num_rip; j++) { - const word line = j * _form->_footer_used; const TString& key = tot[j]->key(); TTotal& t = (TTotal&)(tot[j]->obj()); @@ -510,14 +572,218 @@ void TESSL_form::footer_handler(TPrinter& pr) TESSL_row rip(desc, t.importo().normalize()); rip.scaduto(t.scaduto()); rip.esposto(t.esposto()); + rip.importo_in_lire(t.importo_lire()); rip.print_on(body); - - for (int fl = 0; fl < _form->_footer_used; fl++) - pr.setfooterline(line, body.row(fl)); + pr.setfooterline(j + 1, body.row(0)); } +} + +int TESSL_form::find_magic(TString& s, TString& magic1, TString& magic2) const +{ + const int pos = s.find('<', 0); + int end; + if (pos >= 0) + { + end = s.find('>', pos); + if (end > pos) + { + int p1 = pos+1; + magic1 = s.mid(p1, 2); + while (isalnum(s[p1])) p1++; + while (p1 < end && !isalnum(s[p1])) p1++; + if (p1 < end) + magic2 = s.mid(p1, 2); + else + magic2.cut(0); + } + else + end = s.len()-1; + + const TString right(s.mid(end+1)); + s.cut(pos); s << right; + } + return pos; +} + +void TESSL_form::change_magic_body(const TESSL_row& row, TString& s) +{ + TString magic1(4), magic2(4), val(50); + int pos; + while ((pos = find_magic(s, magic1, magic2)) >= 0) + { + val.cut(0); + if (magic1 == "PA" || magic2 == "PA") + { + val = row.descrizione(); + if (val.empty()) + val = causali().decode(row.causale()); + } + if (magic1 == "MO" || magic2 == "MO") + { + val = movimenti().decode(row.num_reg()); + } + s.insert(val, pos); + } +} + +void TESSL_form::change_magic_footer(const THash_object& o, TString& s) +{ + TString magic1(4), magic2(4), val(50); + int pos; + while ((pos = find_magic(s, magic1, magic2)) >= 0) + { + val.cut(0); + if (magic1 == "DA") + { + const TDate& d = magic2 == "SC" ? _dls : _dlo; + val = d.string(); + } + if (magic1 == "VA") + val = o.key(); + if (magic1 == "DE") + val = valute().decode(o.key()); + + s.insert(val, pos); + } +} + +void TESSL_form::print_total(int riga, const THash_object& o) +{ + const short MAXID = 4; + const short f_id[MAXID] = { PEC_TSALDO, PEC_TSCADUTO, PEC_TESPOSTO, PEC_TIMPLIRE }; + TString_array prompt(MAXID); + + TPrint_section& foot = section('F'); + + // Sostituisce magic-names nei prompt + TString s(80); + for (int i = 0; i < MAXID; i++) + { + TForm_item& desc_field = foot.find_field(f_id[i]); + if (desc_field.shown()) + { + s = desc_field.prompt(); + prompt.add(s, i); + change_magic_footer(o, s); + desc_field.set_prompt(s); + } + } + + const TTotal& t = (const TTotal&)o.obj(); + const TImporto& imp = t.importo(); + TForm_item& dare = foot.find_field(PEC_DARE); + TForm_item& avere = foot.find_field(PEC_AVERE); + TPrint_section& body = section('B'); + + if (dare.x() <= 0 || avere.x() <= 0) + { + const TForm_item& bdare = body.find_field(PEC_DARE); + dare.x() = bdare.x(); + + const TForm_item& bavere = body.find_field(PEC_AVERE); + avere.x() = bavere.x(); + } + + if (imp.sezione() == 'D') + { + dare.set(imp.valore().string()); + avere.set(""); + } + else + { + dare.set(""); + avere.set(imp.valore().string()); + } + + TForm_item& scaduto = foot.find_field(PEC_SCADUTO); + if (scaduto.x() <= 0) + { + const TForm_item& bscaduto = body.find_field(PEC_SCADUTO); + scaduto.x() = bscaduto.x(); + } + scaduto.set(t.scaduto().string()); + + TForm_item& esposto = foot.find_field(PEC_ESPOSTO); + if (esposto.x() <= 0) + { + const TForm_item& besposto = body.find_field(PEC_ESPOSTO); + esposto.x() = besposto.x(); + } + esposto.set(t.esposto().string()); + + TForm_item& implire = foot.find_field(PEC_IMPLIRE); + if (implire.x() <= 0) + { + const TForm_item& bimplire = body.find_field(PEC_IMPLIRE); + implire.x() = bimplire.x(); + } + implire.set(t.importo_lire().string()); + + foot.update(); + + // Ripristina prompt originari + for (i = 0; i < MAXID; i++) + { + const TString* p = (const TString*)prompt.objptr(i); + if (p) + { + TForm_item& desc_field = foot.find_field(f_id[i]); + desc_field.set_prompt(*p); + } + } + + for (word r = 0; r < _total_rows; r++) + printer().setfooterline(riga + r, foot.row(r)); +} + +void TESSL_form::stampa_pedata(TPrinter& pr) +{ + THash_object* tot[MAXTOT]; + word num_rip = ordina_totali_per_valuta(tot); + + // La prima riga del footer deve essere lasciata libera per la fincatura + // Ogni sottosezione di totale occupa _total_rows righe: per cui devo calcolare + // quanti totali ci stanno nelle righe riservate al footer + const word maxtot = (section('F').height()-1) / _total_rows; + if (num_rip > maxtot) + num_rip = maxtot; + + for (word j = 0; j < num_rip; j++) + print_total(j*_total_rows+1, *tot[j]); +} + +void TESSL_form::ultima_pagina() +{ + set_last_page(TRUE); +} + +void TESSL_form:: header_handler(TPrinter& pr) +{ + pr.resetheader(); + + _form->stampa_testata(pr); +} + +void TESSL_form::footer_handler(TPrinter& pr) +{ + pr.resetfooter(); + if (_form->page(pr) > 0) // Normal page + _form->stampa_riporti(pr); + else // Last page + _form->stampa_pedata(pr); } +void TESSL_form::azzera_totali() +{ + totali().destroy(); // Azzera tutti i riporti + _num_rip = 0; // Azzera il numero di righe di riporto + set_last_page(FALSE); // Azzera il flag di ultima pagina di stampa + + TPrint_section& foot = section('F'); + printer().footerlen(foot.height()); +} + bool TESSL_form::print_game(const TPartita& game) { bool ok = FALSE; @@ -530,7 +796,7 @@ bool TESSL_form::print_game(const TPartita& game) TPrint_section& body = section('B'); TImporto saldo; - real scaduto, esposto; + real scaduto, esposto, implire; // Stampa le righe di partita @@ -542,12 +808,20 @@ bool TESSL_form::print_game(const TPartita& game) TESSL_row& riga = righe.row(r); if (pr.rows_left() < body.height()) + { pr.formfeed(); + for (word nr = 0; nr < _num_rip; nr++) + { + TPrintrow* fl = pr.getfooterline(nr); + CHECKD(fl, "Manca la riga di riporto ", nr); + pr.print(*fl); + } + } const int ri = riga.riga(); const int ra = riga.rata(); if (ri == ultima_riga && ra == ultima_rata+1) - riga.reset_causale(); + riga.reset_uguali(); ultima_riga = ri; ultima_rata = ra; @@ -555,11 +829,12 @@ bool TESSL_form::print_game(const TPartita& game) pr.print(body.row(0)); totali().add(riga.importo(), riga.scaduto(), riga.esposto(), - ZERO, riga.valuta().codice()); + riga.importo_in_lire(), riga.valuta().codice()); saldo += riga.importo(); scaduto += riga.scaduto(); esposto += riga.esposto(); + implire += riga.importo_in_lire(); ok = TRUE; } @@ -567,9 +842,10 @@ bool TESSL_form::print_game(const TPartita& game) { saldo.normalize(); - TESSL_row sld(describe(301), saldo); + TESSL_row sld(describe(PEC_SALDO), saldo); sld.scaduto(scaduto); sld.esposto(esposto); + sld.importo_in_lire(implire); sld.print_on(body); pr.print(body.row(0)); @@ -580,24 +856,55 @@ bool TESSL_form::print_game(const TPartita& game) return ok; } -const TString& TESSL_form::describe(short id, char sez) const +const TString& TESSL_form::describe(short id, char sez, pagetype pt) const { - const TForm_item& fi = find_field(sez, odd_page, id); + const TForm_item& fi = find_field(sez, pt, id); return fi.prompt(); } -TESSL_form::TESSL_form(const TESSL_mask& m, short id_datalim, short id_datascad, +void TESSL_form::init_header(const TMask& m) +{ + TPrint_section& head = section('H'); + + TForm_item& luogo_invio = head.find_field(PEC_LUOGOIN); + luogo_invio.set(m.get(F_LUOGOSEND)); + + TForm_item& data_invio = head.find_field(PEC_DATAIN); + data_invio.set(m.get(F_DATASEND)); + + TForm_item& fi = head.find_field(PEC_MEMO); + if (fi.shown()) + { + TLocalisamfile f(LF_RFORM); + f.put("TIPOPROF", name()); + f.put("CODPROF", code()); + f.put("SEZ", "H"); + f.put("ID", PEC_MEMO); + const int err = f.read(); + if (err == NOERR) + fi.set(f.get("TESTO")); + } + + if (_fincatura) + { + TPrint_section& fink = section('G'); + if (fink.fields() > 0) fink.update(); // Setta il backgroud di stampa + } +} + +TESSL_form::TESSL_form(const TESSL_mask& m, bool gesval, short id_datalim, short id_datascad, short id_giorni_rischio) - :TForm(BASE_EC_PROFILE, m.get_prof_code()), - _causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR) + :TForm(BASE_EC_PROFILE, m.get_prof_name()), + _in_valuta(FALSE), _num_rip(0), _total_rows(0), + _causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR), + _movimenti(LF_MOV, MOV_NUMREG, MOV_DESCR), + _valute("%VAL"), _giorni_rischio(0) { _form = this; - TForm_item& imp_lire = find_field('B', odd_page, PEC_IMPLIRE); - _in_valuta = imp_lire.shown(); // Il profilo e' in valuta se c'e' la colonna importo in lire - _lingua = m.get_prof_lang(); + _who = m.get_who(); TCursor_sheet& cs = m.cur_sheet(); _cursore = cs.cursor(); @@ -615,18 +922,29 @@ TESSL_form::TESSL_form(const TESSL_mask& m, short id_datalim, short id_datascad, TPrinter& pr = printer(); pr.setheaderhandler(header_handler); - pr.headerlen(section('H').height()); + TPrint_section& head = section('H'); + pr.headerlen(head.height()); + + TForm_item& flags = find_field('H', last_page, PEC_FLAGS); + TToken_string f(flags.prompt()); + _in_valuta = gesval && f.get_char(0) == 'X'; // Il profilo e' in valuta se c'e' il flag di valuta + _fincatura = f.get_int(1); + init_header(m); // Set fixed text pr.setfooterhandler(footer_handler); - pr.footerlen(section('F').height()); const TPrint_section& foot = section('F'); pr.footerlen(foot.height()); - for (int i = foot.fields()-1; i >= 0; i--) + _total_rows = 1; + for (word fi = 0; fi < foot.fields(); fi++) { - TForm_item& fi = foot.field(i); - if (fi.y() > _footer_used) - _footer_used = fi.y(); + const TForm_item& item = foot.field(fi); + if (item.shown()) + { + const word y = (word)item.y(); + if (y > _total_rows) + _total_rows = y; + } } } @@ -637,3 +955,5 @@ TESSL_form::~TESSL_form() pr.setfooterhandler(NULL); _form = NULL; } + + diff --git a/sc/sc2401.h b/sc/sc2401.h index 2280d15df..0187ba4d8 100755 --- a/sc/sc2401.h +++ b/sc/sc2401.h @@ -31,12 +31,14 @@ protected: public: const char *get_prof_base() const; const TString &get_prof_code() const; + const char *get_prof_name() const; const TString &get_prof_lang() const; TESSL_mask(const char *name); virtual ~TESSL_mask(); }; - + +class TESSL_form; /////////////////////////////////////////////////////////// // TESSL_row /////////////////////////////////////////////////////////// @@ -54,6 +56,7 @@ class TESSL_row : public TSortable TDate _data_doc; // Data del documento TString _num_doc; // Numero documento long _num_prot; // Protocollo IVA + long _num_reg; // Numero registrazione TImporto _importo; // Importo in valuta real _importo_lire; // Importo in lire real _scaduto; // Importo scaduto @@ -66,11 +69,13 @@ protected: // TSortable virtual int compare(const TSortable& s) const; void set_imp(TForm_item& fi, const real& imp, bool valuta) const; + TESSL_form& form() const; + public: int riga() const { return _riga; } int rata() const { return _rata; } - void reset_causale() { _causale.cut(0); _descrizione.cut(0); } + void reset_uguali(); void descrizione(const char* s) { _descrizione = s; } void importo(const TImporto& i) { _importo = i; } void scaduto(const real& s) { _scaduto = s; } @@ -78,12 +83,16 @@ public: void importo_in_lire(const real& il) { _importo_lire = il; } void salvo_buon_fine(bool sbf) { _salvo_buon_fine = sbf; } + const TString& causale() const { return _causale; } + const TString& descrizione() const { return _descrizione; } + long num_reg() const { return _num_reg; } const TValuta& valuta() const { return _valuta; } const TImporto& importo() const { return _importo; } real importo_in_lire() const { return _importo_lire; } real scaduto() const { return _scaduto; } real esposto() const { return _esposto; } const TDate& data() const { return _data; } + bool in_valuta() const { return _valuta.in_valuta(); } void print_on(TPrint_section& body); @@ -98,40 +107,64 @@ public: class TESSL_form : public TForm { - static TESSL_form* _form; + friend class TESSL_row; + static TESSL_form* _form; + + enum { MAXTOT = 16 }; + TCursor* _cursore; TTotalizer _totali; - TDecoder _causali; // Decodoficatore dei codici causale + TDecoder _causali; // Decodificatore dei codici causale + TDecoder _valute; // Decodificatore dei codici valuta + TDecoder _movimenti; // Decodificatore delle descrizioni dei movimenti + TString _lingua; TDate _dlo, _dls, _dir; int _giorni_rischio; bool _in_valuta; - int _footer_used; // Numero di righe per ogni valuta del footer + int _fincatura; // 0 = nessuna, 1 = testo, 2 = grafica + word _num_rip; // numero di righe usate per i riporti + word _total_rows; // numero di righe usate per i totali char _who; protected: + void init_header(const TMask& m); + word ordina_totali_per_valuta(THash_object* tot[MAXTOT]); + int find_magic(TString& s, TString& magic1, TString& magic2) const; + void change_magic_body(const TESSL_row& o, TString& s); + void change_magic_footer(const THash_object& o, TString& s); + void print_total(int riga, const THash_object& o); + + void stampa_testata(TPrinter& p); + void stampa_pedata(TPrinter& p); + void stampa_riporti(TPrinter& p); + static void header_handler(TPrinter& p); static void footer_handler(TPrinter& p); public: TTotalizer& totali() { return _totali; } TDecoder& causali() { return _causali; } + TDecoder& valute() { return _valute; } + TDecoder& movimenti() { return _movimenti; } const TDate& data_limite_operazione() const { return _dlo; } - const TDate& data_limite_scaduto() const { return _dls; } - int giorni_rischio() const { return _giorni_rischio; } - const TDate& data_inizio_rischio() const { return _dir; } + const TDate& data_limite_scaduto() const { return _dls; } + int giorni_rischio() const { return _giorni_rischio; } + const TDate& data_inizio_rischio() const { return _dir; } const TString& lingua() const { return _lingua; } bool in_valuta() const { return _in_valuta; } - const TString& describe(short id, char sez = 'B') const; + const TString& describe(short id, char sez = 'H', pagetype pt = last_page) const; const char sezione_normale() const { return _who == 'C' ? 'D' : 'A' ; } + void azzera_totali(); + void ultima_pagina(); virtual bool print_game(const TPartita& game); - TESSL_form(const TESSL_mask& m, short id_datalim, short id_datascad = 0, short id_giorni_rischio = 0); + TESSL_form(const TESSL_mask& m, bool gesval, short id_datalim, short id_datascad = 0, short id_giorni_rischio = 0); virtual ~TESSL_form(); }; diff --git a/sc/sc2402.cpp b/sc/sc2402.cpp index 88c247bac..e4e195816 100755 --- a/sc/sc2402.cpp +++ b/sc/sc2402.cpp @@ -20,7 +20,7 @@ TSol_mask::~TSol_mask() {} bool TSol_mask::get_sel_tot_saldo() const { - return get_bool(F_RIFIMPMIN); + return get(F_RIFIMPMIN) == "C"; } real TSol_mask::get_sel_importo() const @@ -48,8 +48,8 @@ TSol_row::TSol_row(const char* desc, const TImporto& imp) // TSol_form: form speciale per solleciti /////////////////////////////////////////////////////////// -TSol_form::TSol_form(const TSol_mask& m, short id_datalim) - :TESSL_form(m, id_datalim) +TSol_form::TSol_form(const TSol_mask& m, bool gesval, short id_datalim) + :TESSL_form(m, gesval, id_datalim) { _sel_tot_saldo = m.get_sel_tot_saldo(); diff --git a/sc/sc2402.h b/sc/sc2402.h index 757356fbc..81fb26689 100755 --- a/sc/sc2402.h +++ b/sc/sc2402.h @@ -61,7 +61,7 @@ protected: public: bool get_sel_tot_saldo() const { return _sel_tot_saldo;} const real & get_sel_importo() const { return _sel_importo; } - TSol_form(const TSol_mask& m, short id_datalim); + TSol_form(const TSol_mask& m, bool gesval, short id_datalim); virtual ~TSol_form() {} }; diff --git a/sc/scselect.cpp b/sc/scselect.cpp index 0b8004472..a92467cce 100755 --- a/sc/scselect.cpp +++ b/sc/scselect.cpp @@ -13,7 +13,7 @@ TSelection_mask::TSelection_mask(const char* name) _cli_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter); _cli_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter); - _cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice", + _cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC", "Selezione clienti per codice", "@1|Codice|Ragione Sociale@50"); _cli_sh_k2 = new TCursor_sheet(_cli_cur_k2, " |RAGSOC|CODCF", "Selezione clienti per ragione sociale", "@1|Ragione Sociale@50|Codice"); @@ -28,7 +28,14 @@ TSelection_mask::TSelection_mask(const char* name) _for_sh_k2 = new TCursor_sheet(_for_cur_k2, " |RAGSOC|CODCF", "Selezione fornitori per ragione sociale", "@1|Ragione Sociale@50|Codice"); } - + else + { + _for_cur_k1 = NULL; + _for_cur_k2 = NULL; + _for_sh_k1 = NULL; + _for_sh_k2 = NULL; + } + set_handler(SC_CLIFO, rclifo_handler); set_handler(SC_SORTCF, rsortcf_handler); set_handler(SC_CFBUTFR, bfrom_handler); @@ -37,14 +44,21 @@ TSelection_mask::TSelection_mask(const char* name) set_handler(SC_RESET, breset_handler); set_handler(SC_CFCODFR, ffrom_handler); set_handler(SC_CFCODTO, fto_handler); + set_handler(SC_CFDESFR, fdfrom_handler); + set_handler(SC_CFDESTO, fdto_handler); + set_handler(SC_CFDESBUTFR, bdfrom_handler); + set_handler(SC_CFDESBUTTO, bdto_handler); } TSelection_mask::~TSelection_mask() -{ - delete _for_sh_k2; - delete _for_sh_k1; - delete _for_cur_k2; - delete _for_cur_k1; +{ + if (_for_sh_k1 != NULL) + { + delete _for_sh_k2; + delete _for_sh_k1; + delete _for_cur_k2; + delete _for_cur_k1; + } delete _cli_sh_k2; delete _cli_sh_k1; @@ -82,6 +96,8 @@ void TSelection_mask::reset_sheets() } reset(SC_CFCODFR); reset(SC_CFCODTO); + reset(SC_CFDESFR); + reset(SC_CFDESTO); reset(SC_NSEL); } @@ -134,15 +150,68 @@ void TSelection_mask::select_clifo_range(long from, long to) else c.uncheck(i); - if (cod == from) cod1ok = TRUE; - if (cod == to) cod2ok = TRUE; +// if (cod == from) cod1ok = TRUE; +// if (cod == to) cod2ok = TRUE; } - if (!cod1ok) from = firs; - if (!cod2ok) to = last; + if (get(SC_CFCODFR).not_empty()) +// if (!cod1ok) + set(SC_CFCODFR, firs); + if (get(SC_CFCODTO).not_empty()) +// if (!cod2ok) + set(SC_CFCODTO, last); - set(SC_CFCODFR, from); - set(SC_CFCODTO, to); + set(SC_NSEL, c.checked()); +} + +void TSelection_mask::select_des_clifo_range(const TString& from, const TString & to) +{ + TCursor_sheet& c = cur_sheet(); + const long items = c.items(); + const int key = get_key(); + CHECK(key == 2, "La chiave deve essere la 2"); + TString s_from(from), s_to(to); + + if (s_to.empty() && items) + s_to = c.row(items-1).get(1); + s_from.upper(); + s_to.upper(); + + if (s_from > s_to) // Controlla limiti + { + const TString tmp(s_to); + s_to = s_from; + s_from = tmp; + set(SC_CFDESFR, to); + set(SC_CFDESTO, from); + } + + TString last; + TString firs; + + for (long i = 0; i < items; i++) + { + TToken_string& tt = c.row(i); + TString s(tt.get(1)); + s.upper(); + const bool add = s_from <= s && s_to >= s; + + if (add) + { + c.check(i); + if (firs.empty()) + firs = tt.get(1); + last = tt.get(1); + } + else + c.uncheck(i); + } + + + if (get(SC_CFDESFR).not_empty()) + set(SC_CFDESFR, firs); + if (get(SC_CFDESTO).not_empty()) + set(SC_CFDESTO, last); set(SC_NSEL, c.checked()); } @@ -176,6 +245,37 @@ void TSelection_mask::set_clifo_limits() set(SC_NSEL, nsel); } +void TSelection_mask::set_des_clifo_limits() +{ + TString first, last; + long nsel = 0; + + TCursor_sheet& c = cur_sheet(); + const long items = c.items(); + const int key = get_key(); + CHECK(key == 2, "La chiave deve essere la 2"); + + for (int i = 0; i < items; i++) if (c.checked(i)) + { + TToken_string& t = c.row(i); + const TString des(t.get(1)); + if (first.empty()) + { + first = last = des; + } + else + { + if (first > des) first = des; + if (last < des) last = des; + } + + nsel++; + } + set(SC_CFDESFR, first); + set(SC_CFDESTO, last); + set(SC_NSEL, nsel); +} + // handlers bool TSelection_mask::bfrom_handler(TMask_field& f, KEY k) { @@ -255,6 +355,85 @@ bool TSelection_mask::fto_handler(TMask_field& f, KEY k) return TRUE; } +bool TSelection_mask::bdfrom_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TSelection_mask& m = (TSelection_mask&)f.mask(); + TCursor_sheet& c = m.cur_sheet(); + + c.disable_check(); + if (c.run() == K_ENTER) + { + TToken_string& t = c.row(c.selected()); + const TString des1(t.get(3 - m.get_key())); + const TString des2 = m.get(SC_CFDESTO); + m.set(SC_CFDESFR, des1); + m.select_des_clifo_range(des1, des2); + } + } + return TRUE; +} + +bool TSelection_mask::bdto_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TSelection_mask& m = (TSelection_mask&)f.mask(); + TCursor_sheet& c = m.cur_sheet(); + + c.disable_check(); + if (c.run() == K_ENTER) + { + TToken_string& t = c.row(c.selected()); + const TString des1(m.get(SC_CFDESFR)); + const TString des2(t.get(3 - m.get_key())); + m.set(SC_CFDESTO, des2); + m.select_des_clifo_range(des1, des2); + } + } + return TRUE; +} + +bool TSelection_mask::fdfrom_handler(TMask_field& f, KEY k) +{ + TSelection_mask& m = (TSelection_mask&)f.mask(); + + if (k == K_TAB && f.focusdirty()) + { + const TString des1(f.get()); + const TString des2(m.get(SC_CFDESTO)); + m.select_des_clifo_range(des1, des2); + } + else + if (k == K_F9) + { + TMask_field& f = m.field(SC_CFDESBUTFR); + f.on_hit(); + } + + return TRUE; +} + +bool TSelection_mask::fdto_handler(TMask_field& f, KEY k) +{ + TSelection_mask& m = (TSelection_mask&)f.mask(); + + if (k == K_TAB && f.focusdirty()) + { + const TString des2(f.get()); + const TString des1(m.get(SC_CFDESFR)); + m.select_des_clifo_range(des1, des2); + } + else + if (k == K_F9) + { + TMask_field& f = m.field(SC_CFDESBUTTO); + f.on_hit(); + } + return TRUE; +} + bool TSelection_mask::breset_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -273,7 +452,10 @@ bool TSelection_mask::bselect_handler(TMask_field& f, KEY k) TCursor_sheet& c = m.cur_sheet(); c.enable_check(); c.run(); - m.set_clifo_limits(); + if (m.get_key() == 2) + m.set_des_clifo_limits(); + else + m.set_clifo_limits(); } return TRUE; } diff --git a/sc/scselect.h b/sc/scselect.h index 5acad17eb..5c04cdebc 100755 --- a/sc/scselect.h +++ b/sc/scselect.h @@ -38,7 +38,9 @@ protected: // TMask protected: void select_clifo_range(long from, long to); + void select_des_clifo_range(const TString & from, const TString & to); void set_clifo_limits(); + void set_des_clifo_limits(); void set_who(char w) { _who = w; } void set_key (int k) { _key = k; } @@ -54,6 +56,10 @@ protected: static bool bselect_handler(TMask_field& f, KEY k); static bool rclifo_handler(TMask_field& f, KEY k); static bool rsortcf_handler(TMask_field& f, KEY k); + static bool bdfrom_handler(TMask_field& f, KEY k); + static bool bdto_handler(TMask_field& f, KEY k); + static bool fdfrom_handler(TMask_field& f, KEY k); + static bool fdto_handler(TMask_field& f, KEY k); public: TCursor_sheet& cur_sheet() const; diff --git a/sc/scselmsk.h b/sc/scselmsk.h index a4fe61ad9..f5f180855 100755 --- a/sc/scselmsk.h +++ b/sc/scselmsk.h @@ -21,6 +21,8 @@ #define SC_PCONCODTO3 318 #define SC_PCONBUTFR 319 #define SC_PCONBUTTO 320 +#define SC_CFDESBUTFR 319 +#define SC_CFDESBUTTO 320 #define BASE_EC_PROFILE "PEC"