diff --git a/sc/sc2200.cpp b/sc/sc2200.cpp index 4354dae6b..899c0834b 100755 --- a/sc/sc2200.cpp +++ b/sc/sc2200.cpp @@ -80,7 +80,6 @@ class TStampaScadenzario : public TPrintapp _cur2, _cur3, _cur4, _cur41, // piu' avanti spiega tutto. _cur5, _cur6, _cur7; TSelection_ext_mask *_m; - //TBit_array _cs; TBit_array costruito da TSelectionMask TPartita *_p; // Oggetto partita corrente. Viene ricaricato ad ogni cambio partita, // ovvero ogni volta che la rata corrente cambia i "connotati" TLocalisamfile *_caus, *_partite, *_pagsca; // File delle causali, serve per reperire le descrizioni, nel caso non ci siano sul file parite @@ -174,36 +173,10 @@ bool filter_func(const TRelation *r) bool rt = FALSE; // e' abilitato il flag; se non e' saldata va sempre bene. TLocalisamfile* scad = &(r->lfile(LF_SCADENZE)); bool saldata = scad->get_bool(SCAD_PAGATA); - TCursor_sheet_recno& cs = app()._m->cur_sheet(); - TCursor* c = cs.cursor(); - TRecnotype n; - switch (app()._tipost) - { - case tutti: - n=scad->recno(); - break; - case clienti: - case fornitori: - { - TLocalisamfile * clifo = &(r->lfile(LF_CLIFO)); - n=clifo->recno(); - } - break; - case altri: - { - TLocalisamfile * pcon = &(r->lfile(LF_PCON)); - n=pcon->recno(); - } - default: - break; - } if (!saldata || (saldata && app()._ratesald)) { - // Questo dovrebbe fungere da filtro sulla selezione Cli/Fo - PConti - Scadenze. - // Might It be a good idea? - if (cs.rec_checked(n)) - rt=TRUE; + rt=TRUE; } return rt; } @@ -368,7 +341,9 @@ void TStampaScadenzario::calcola_pagamenti(real& imp_scad, int riga, int rata) break; } } - totalep.normalize(); scdz.normalize(); + char norm = 'D'; + if (_tipost == fornitori) norm = 'A'; + totalep.normalize(norm); scdz.normalize(norm); _w_imp_pag = totalep.valore(); imp_scad = scdz.valore(); real a,b; @@ -431,6 +406,16 @@ bool TStampaScadenzario::preprocess_page(int file, int counter) } if (file == LF_SCADENZE && !_end_printed) { + TCursor_sheet& cs = _m->cur_sheet(); // Sheet di selezione (CLI/FO/PCON) + TCursor* c = cs.cursor(); + TRectype& rec = c->curr(); + if (_tipost == clienti || _tipost == fornitori) + rec = current_cursor()->curr(LF_CLIFO); + else + if (_tipost == altri) + rec = current_cursor()->curr(LF_PCON); + if (!cs.checked(c->read(_isequal))) // Se non e' stato selezionato salta alla prossima scdz + return FALSE; _descrizione->restart(); if (scad_changed(tipoc,gruppo,conto,codcf,annop,nump)) { @@ -779,14 +764,6 @@ bool TStampaScadenzario::set_print(int) _end_printed = FALSE; reset_files(); reset_print(); - //TCursor_sheet& c = _m->cur_sheet(); - //const long items = c.items(); - //_cs.reset(); - // for (long i = 0; i < items; i++) - // { Now sets TBit_array for filter_func!!! - // if (c.checked(i)) - // _cs.set(c.cursor()->recno(i)); - //} // Inizializza i membri necessari al calcolo totali nel caso sia stato scelto l'ordine // primario secondo la data di scadenza. if (_m->get_who() == 'P') _tipost = altri; diff --git a/sc/sc2201.cpp b/sc/sc2201.cpp index dede3b3ce..d62a03648 100755 --- a/sc/sc2201.cpp +++ b/sc/sc2201.cpp @@ -22,9 +22,9 @@ TSelection_ext_mask::TSelection_ext_mask(const char* name) : TSelection_mask(nam _pcon_cur_k2 = new TCursor(_pcon_rel, "", 2); - _pcon_sh_k1 = new TCursor_sheet_recno(_pcon_cur_k1, " |GRUPPO|CONTO|SOTTOCONTO|DESCR", "Selezione conti per gruppo/conto/sottoconto", + _pcon_sh_k1 = new TCursor_sheet(_pcon_cur_k1, " |GRUPPO|CONTO|SOTTOCONTO|DESCR", "Selezione conti per gruppo/conto/sottoconto", "@1|Gruppo|Conto|Sottoconto|Descrizione@50"); - _pcon_sh_k2 = new TCursor_sheet_recno(_pcon_cur_k2, " |DESCR|GRUPPO|CONTO|SOTTOCONTO", "Selezione conti per descrizione", + _pcon_sh_k2 = new TCursor_sheet(_pcon_cur_k2, " |DESCR|GRUPPO|CONTO|SOTTOCONTO", "Selezione conti per descrizione", "@1|Descrizione@50|Gruppo|Conto|Sottoconto"); set_handler(SC_CLIFO, rpcon_handler); // Redefined handler... @@ -46,24 +46,22 @@ TSelection_ext_mask::~TSelection_ext_mask() delete _pcon_rel; } -TCursor_sheet_recno& TSelection_ext_mask::cur_sheet() +TCursor_sheet& TSelection_ext_mask::cur_sheet() { - TCursor_sheet_recno* cs; + TCursor_sheet* cs; if (get_key() == 1) cs = get_who() == 'P' ? _pcon_sh_k1 : NULL; else cs = get_who() == 'P' ? _pcon_sh_k2 : NULL; if (get_who() != 'P') return TSelection_mask::cur_sheet(); - CHECK(cs, "Can't use a NULL TCursor_sheet_recno"); + CHECK(cs, "Can't use a NULL TCursor_sheet"); return *cs; } void TSelection_ext_mask::reset_sheets() { _pcon_sh_k1->uncheck(-1); - _pcon_sh_k1->rec_uncheck(-1); _pcon_sh_k2->uncheck(-1); - _pcon_sh_k2->rec_uncheck(-1); TSelection_mask::reset_sheets(); reset(SC_PCONCODFR1); reset(SC_PCONCODFR2); @@ -73,13 +71,57 @@ void TSelection_ext_mask::reset_sheets() reset(SC_PCONCODTO3); } -void TSelection_ext_mask::select_pcon_range(int grf, int cof,long sof,int grt,int cot, long sot) +void TSelection_ext_mask::select_pcon_range(const char* des,int grt, int cot, long sot) { - TCursor_sheet_recno& c = cur_sheet(); + TCursor_sheet& c = cur_sheet(); + const long items = c.items(); + const int key = get_key(); + + TCursor* crs = c.cursor(); + TRectype& rec = crs->file().curr(); + TString desl; + rec.zero(); + rec.put(PCN_DESCR,des); + const TRecnotype start = crs->read(_isgteq); + int grf = rec.get_int(PCN_GRUPPO); + int cof = rec.get_int(PCN_CONTO); + long sof = rec.get_long(PCN_SOTTOCONTO); + rec.zero(); + if (grt==0 && cot==0 && sot==0) + { + TToken_string& t = c.row(items-1); + desl = t.get_int(1); + } + rec.put(PCN_DESCR,desl); + TRectype recx(rec); + TRecnotype end = crs->read(_isgteq); + if (rec != recx) + { + end--; + (*crs)-=1; + } + grt = rec.get_int(PCN_GRUPPO); + cot = rec.get_int(PCN_CONTO); + sot = rec.get_long(PCN_SOTTOCONTO); + c.uncheck(-1); + for (long i = start; i <= end; i++) + //if (!c.checked(i)) + c.check(i); + set(SC_PCONCODFR1, grf); + set(SC_PCONCODFR2, cof); + set(SC_PCONCODFR3, sof); + set(SC_PCONCODTO1, grt); + set(SC_PCONCODTO2, cot); + set(SC_PCONCODTO3, sot); + set(SC_NSEL, c.checked()); +} + +void TSelection_ext_mask::select_pcon_range(int grf, int cof,long sof,int grt,int cot, long sot) +{ + TCursor_sheet& c = cur_sheet(); const long items = c.items(); const int key = get_key(); - long nsel = get_long(SC_NSEL); TCursor* crs = c.cursor(); TRectype& rec = crs->file().curr(); rec.zero(); @@ -111,63 +153,62 @@ void TSelection_ext_mask::select_pcon_range(int grf, int cof,long sof,int grt,in grt = rec.get_int(PCN_GRUPPO); cot = rec.get_int(PCN_CONTO); sot = rec.get_long(PCN_SOTTOCONTO); + c.uncheck(-1); for (long i = start; i <= end; i++) - { - if (!c.checked(i)) - { + //if (!c.checked(i)) c.check(i); - c.rec_check(i); - nsel++; - } - } set(SC_PCONCODFR1, grf); set(SC_PCONCODFR2, cof); set(SC_PCONCODFR3, sof); set(SC_PCONCODTO1, grt); set(SC_PCONCODTO2, cot); set(SC_PCONCODTO3, sot); - set(SC_NSEL, nsel); + set(SC_NSEL, c.checked()); } void TSelection_ext_mask::set_pcon_limits() { int gf=0,gl=0,cf=0,cl=0; - long sf=0,sl=0; + long sf=0L,sl=0L; - TCursor_sheet_recno& c = cur_sheet(); + TCursor_sheet& c = cur_sheet(); const long items = c.items(); const int key = get_key(); - bool found = FALSE; + long first = -1, last = -1; + long nsel = 0L; - for (long i = 0; i < items && !found; i++) + // Ricerca veloce di estremi (vale solo su GR/CO/SO) + for (long i = 0; i < items; i++) if (c.checked(i)) { - TToken_string& t = c.row(i); - gf = t.get_int(key); - cf = t.get_int(key+1); - sf = t.get_long(key+2); - found = TRUE; + if (first == -1) + first = i; + nsel ++; } - if (found) //Optimization... If nothing was found previously skip this test. - { - found = FALSE; - for (long j = (items-1); j >= 0 && !found; j--) - { + if (first != -1) //Optimization... If nothing was found previously skip this test. + for (long j = (items-1); j >= 0 ; j--) if (c.checked(j)) - { - TToken_string& t = c.row(j); - gl = t.get_int(key); - cl = t.get_int(key+1); - sl = t.get_long(key+2); - found = TRUE; - } - } - } - if (gf > gl || (gf==gl && cf > cl) || (gf==gl && cf==cl && sf>sl)) + if (last == -1) + { + last = j; + break; + } + if (first!= -1 && last != -1) // Something selected? { - int t1 = gf,t2 = cf;long t3 = sf; - gf=gl;cf=cl;sf=sl; - gl=t1;cl=t2;sl=t3; + TToken_string fitem(c.row(first)); + TToken_string litem(c.row(last)); + gf = fitem.get_int(key); + cf = fitem.get_int(key+1); + sf = fitem.get_long(key+2); + gl = litem.get_int(key); + cl = litem.get_int(key+1); + sl = litem.get_long(key+2); + if (gf > gl || (gf==gl && cf > cl) || (gf==gl && cf==cl && sf>sl)) + { // Swap them... + int t1 = gf,t2 = cf;long t3 = sf; + gf=gl;cf=cl;sf=sl; + gl=t1;cl=t2;sl=t3; + } } set(SC_PCONCODFR1, gf); set(SC_PCONCODFR2, cf); @@ -175,7 +216,7 @@ void TSelection_ext_mask::set_pcon_limits() set(SC_PCONCODTO1, gl); set(SC_PCONCODTO2, cl); set(SC_PCONCODTO3, sl); - set(SC_NSEL, c.checked()); + set(SC_NSEL, nsel); } bool TSelection_ext_mask::bfrompcon_handler(TMask_field& f, KEY k) @@ -183,7 +224,7 @@ bool TSelection_ext_mask::bfrompcon_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TSelection_ext_mask& m = (TSelection_ext_mask&)f.mask(); - TCursor_sheet_recno& c = m.cur_sheet(); + TCursor_sheet& c = m.cur_sheet(); const int key = m.get_key(); c.disable_check(); if (c.run() == K_ENTER) @@ -200,7 +241,10 @@ bool TSelection_ext_mask::bfrompcon_handler(TMask_field& f, KEY k) m.set(SC_PCONCODFR1, grf); m.set(SC_PCONCODFR2, cof); m.set(SC_PCONCODFR3, sof); - m.select_pcon_range(grf,cof,sof,grt,cot,sot); + if (m.get_key() == 2) + m.select_pcon_range(t.get(1),grt,cot,sot); + else + m.select_pcon_range(grf,cof,sof,grt,cot,sot); } } return TRUE; @@ -211,7 +255,7 @@ bool TSelection_ext_mask::btopcon_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TSelection_ext_mask& m = (TSelection_ext_mask&)f.mask(); - TCursor_sheet_recno& c = m.cur_sheet(); + TCursor_sheet& c = m.cur_sheet(); const int key = m.get_key(); c.disable_check(); if (c.run() == K_ENTER) @@ -222,13 +266,16 @@ bool TSelection_ext_mask::btopcon_handler(TMask_field& f, KEY k) grt =t.get_int(key); cot =t.get_int(key+1); sot =t.get_long(key+2); - grf = m.get_int(SC_PCONCODTO1); - cof = m.get_int(SC_PCONCODTO2); - sof = m.get_long(SC_PCONCODTO3); - m.set(SC_PCONCODFR1, grt); - m.set(SC_PCONCODFR2, cot); - m.set(SC_PCONCODFR3, sot); - m.select_pcon_range(grf,cof,sof,grt,cot,sot); + grf = m.get_int(SC_PCONCODFR1); + cof = m.get_int(SC_PCONCODFR2); + sof = m.get_long(SC_PCONCODFR3); + m.set(SC_PCONCODTO1, grt); + m.set(SC_PCONCODTO2, cot); + m.set(SC_PCONCODTO3, sot); + if (m.get_key() == 2) + m.select_pcon_range(t.get(1),grt,cot,sot); + else + m.select_pcon_range(grf,cof,sof,grt,cot,sot); } } return TRUE; @@ -300,7 +347,7 @@ bool TSelection_ext_mask::bselectpcon_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TSelection_ext_mask& m = (TSelection_ext_mask&)f.mask(); - TCursor_sheet_recno& c = m.cur_sheet(); + TCursor_sheet& c = m.cur_sheet(); c.enable_check(); c.run(); if (m.get_who() =='P') @@ -316,7 +363,10 @@ bool TSelection_ext_mask::rpcon_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TSelection_ext_mask& m = (TSelection_ext_mask&)f.mask(); - m.set_who(f.get()[0]); + char who = f.get()[0]; + m.set_who(who); + if (who == 'P') + m.set_key(1); m.reset_sheets(); } return TRUE; diff --git a/sc/sc2201.h b/sc/sc2201.h index c3933b3f7..14d836c39 100755 --- a/sc/sc2201.h +++ b/sc/sc2201.h @@ -11,11 +11,12 @@ class TSelection_ext_mask : public TSelection_mask TCursor* _pcon_cur_k1; TCursor* _pcon_cur_k2; - TCursor_sheet_recno* _pcon_sh_k1; - TCursor_sheet_recno* _pcon_sh_k2; + TCursor_sheet* _pcon_sh_k1; + TCursor_sheet* _pcon_sh_k2; protected: void select_pcon_range(int grf, int cof,long sof,int grt,int cot, long sot); + void select_pcon_range(const char* des,int grt,int cot, long sot); void set_pcon_limits(); virtual void reset_sheets(); @@ -29,7 +30,7 @@ protected: static bool rsortpcon_handler(TMask_field& f, KEY k); public: - virtual TCursor_sheet_recno& cur_sheet(); + virtual TCursor_sheet& cur_sheet(); TSelection_ext_mask(const char* name); virtual ~TSelection_ext_mask(); diff --git a/sc/sc2300.cpp b/sc/sc2300.cpp index a63f32ede..e310e7af9 100755 --- a/sc/sc2300.cpp +++ b/sc/sc2300.cpp @@ -70,7 +70,6 @@ class TStampaScaduto : public TPrintapp int _cur1, _cur2, // Identificatori dei cursori di lavoro... _cur3, _cur4; - //TBit_array _cs; TSelection_ext_mask *_m; TLocalisamfile *_scad,*_pagsca; tipo_st _tipost; // Tipo di stampa impostato @@ -118,29 +117,10 @@ inline TStampaScaduto& app() {return (TStampaScaduto&)main_app();} bool fil_function(const TRelation *r) { TLocalisamfile* part = &(r->lfile(LF_PARTITE)); - TRecnotype n; int nriga = part->get_int(PART_NRIGA); bool rt = FALSE; - TCursor_sheet_recno& cs = app()._m->cur_sheet(); - TCursor* c = cs.cursor(); - switch (app()._tipost) - { - case clienti: - case fornitori: - { - TLocalisamfile * clifo = &(r->lfile(LF_CLIFO)); - n=clifo->recno(); - } - break; - case altri: - { - TLocalisamfile * pcon = &(r->lfile(LF_PCON)); - n=pcon->recno(); - } - default:break; - } - if (nriga == 1 && cs.rec_checked(n)) + if (nriga == 1) rt=TRUE; return rt; } @@ -254,14 +234,16 @@ void TStampaScaduto::compute_all(TPartita& p) } if ((tipomov==3 || tipomov==5) && _tipost==clienti && _gcr!=0) { - TDate data_pag(sum.get_date("DATAPAG")); // This will be PART_DATAPAG + TDate data_pag(sum.get_date(PART_DATAPAG)); // This will be PART_DATAPAG int tipo_pag = rs.get_int(SCAD_TIPOPAG); if (tipo_pag!=1 && tipo_pag!=8 && tipo_pag!= 9 && data_pag.ok()) //Incasso tramite effetto if (data_pag >= _limbf && data_pag <= _limscad) bf += TImporto(sez,pg.get_real(field)); } - } - pag.normalize(); scd.normalize(); bf.normalize(); + } + char norm='D'; + if (_tipost == fornitori) norm = 'A'; + pag.normalize(norm); scd.normalize(norm); bf.normalize(norm); real res,a,b; a = pag.valore(); b = scd.valore(); buonf = bf.valore(); if (_uns > 0.0) // Rettifica i pagamenti con i non assegnati { @@ -367,6 +349,17 @@ bool TStampaScaduto::preprocess_page(int file, int counter) if (file == LF_PARTITE) { + TCursor_sheet& cs = _m->cur_sheet(); // Sheet di selezione (CLI/FO/PCON) + TCursor* c = cs.cursor(); + TRectype& rec = c->curr(); + if (_tipost == clienti || _tipost == fornitori) + rec = current_cursor()->curr(LF_CLIFO); + else + if (_tipost == altri) + rec = current_cursor()->curr(LF_PCON); + if (!cs.checked(c->read(_isequal))) // Se non e' stato selezionato salta alla prossima part + return FALSE; + int nriga = 1; if (_tipost == clienti || _tipost == fornitori) {