diff --git a/at/at0700.cpp b/at/at0700.cpp index 2eb6c63f9..a84f40877 100755 --- a/at/at0700.cpp +++ b/at/at0700.cpp @@ -12,6 +12,7 @@ #define ALIAS_TCS 200 #define ALIAS_CTD 700 #define FINE_SOSPENSIONE "FS" +#define SOSPENSIONE "SO" // nomi campi maschera #include "at0700a.h" @@ -297,19 +298,26 @@ bool TSbloccoSospesi::filter_func_sbloccosospesi(const TRelation* rel) const TString16 statopros = recsog.get(SOG_PROS_STATO); const TString16 statosi = recsog.get(SOG_STATOSI); const TString16 statoaf = recsog.get(SOG_STATOAF); - - TDate datafine(NULLDATE); - if (statopros == FINE_SOSPENSIONE) - datafine = recsog.get_date(SOG_DATA_PROS); - TDate datafinesi(NULLDATE); - TDate datafineaf(NULLDATE); - if (statosi == "SO") - datafinesi = recsog.get_date(SOG_FINESOSSI); - if (statoaf == "SO") - datafineaf = recsog.get_date(SOG_FINESOSAF); - filtrato = (datafine.ok()) && (datafine <= app()._data_sblocco) && (statopros == FINE_SOSPENSIONE); - if ((!filtrato) && (datafinesi.ok() || datafineaf.ok())) - filtrato = ((datafinesi.ok() && (datafinesi <= app()._data_sblocco)) || (datafineaf.ok() && (datafineaf <= app()._data_sblocco))); + filtrato = ((statosi == SOSPENSIONE) || (statoaf == SOSPENSIONE)); + if (app()._tiposo.not_empty()) + filtrato = filtrato || ((stato == app()._tiposo) && (statopros == FINE_SOSPENSIONE)); + else + filtrato = filtrato || ((rel->lfile(-ALIAS_TCS).get("S6") == "S") && (statopros == FINE_SOSPENSIONE)); + if (filtrato) + { + TDate datafine(NULLDATE); + if (statopros == FINE_SOSPENSIONE) + datafine = recsog.get_date(SOG_DATA_PROS); + TDate datafinesi(NULLDATE); + TDate datafineaf(NULLDATE); + if (statosi == "SO") + datafinesi = recsog.get_date(SOG_FINESOSSI); + if (statoaf == "SO") + datafineaf = recsog.get_date(SOG_FINESOSAF); + filtrato = (datafine.ok()) && (datafine <= app()._data_sblocco) && (statopros == FINE_SOSPENSIONE); + if ((!filtrato) && (datafinesi.ok() || datafineaf.ok())) + filtrato = ((datafinesi.ok() && (datafinesi <= app()._data_sblocco)) || (datafineaf.ok() && (datafineaf <= app()._data_sblocco))); + } } return filtrato; } @@ -352,11 +360,16 @@ bool TSbloccoSospesi::set_print(int) _anchedimessi = _msk->get_bool(F_ANCHEDIMESSI); _persezione = _msk->get_bool(F_PERSEZIONE); _contatore = 0; - _totale = 0; + _totale = 0; + filtra_sezioni(); + if (_persezione) + ((TSorted_cursor*)current_cursor())->change_order("90->CODSEZ|90->CODSOT|90->COGNOME|90->NOME|90->DATANASC"); + else + ((TSorted_cursor*)current_cursor())->change_order("90->COGNOME|90->NOME|90->DATANASC"); reset_files(); add_file(LF_SOGGETTI); - filtra_sezioni(); // filtro per tipo sospensione + /* TString256 filtro = ""; if (_tiposo.not_empty()) filtro.format("(((STATO == \"%s\") && (PROS_STATO == \"FS\"))",(const char*)_tiposo); @@ -364,6 +377,7 @@ bool TSbloccoSospesi::set_print(int) filtro << "(((TCS->S6 == \"S\") && (PROS_STATO == \"FS\"))"; filtro << " || (STATOSI == \"SO\") || (STATOAF == \"SO\"))"; current_cursor()->setfilter(filtro, TRUE); + */ current_cursor()->set_filterfunction(filter_func_sbloccosospesi,TRUE); reset_print(); crea_intestazione(); @@ -410,7 +424,7 @@ bool TSbloccoSospesi::user_create() _rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS); _rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD); //cursore ordinamento per sezione+sottogruppo+cognome+nome - _cur = add_cursor(new TCursor(_rel, "", 3)); + add_cursor(new TSorted_cursor(_rel,"","",3)); _contsan = new TLocalisamfile(LF_CONTSAN); _idoneita = new TLocalisamfile(LF_IDONEITA); _scontrolli = new TRecord_array(LF_CONTSAN, CON_PROGCON); @@ -427,12 +441,12 @@ bool TSbloccoSospesi::user_create() bool TSbloccoSospesi::user_destroy() { + delete _sidoneita; + delete _scontrolli; + delete _idoneita; + delete _contsan; delete _rel; delete _msk; - delete _contsan; - delete _idoneita; - delete _scontrolli; - delete _sidoneita; return TRUE; }