e1594fd672
git-svn-id: svn://10.65.10.50/trunk@4223 c028cbd2-c16b-5b4b-a496-9718f37d4682
247 lines
6.6 KiB
C++
Executable File
247 lines
6.6 KiB
C++
Executable File
#include <form.h>
|
|
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include "at1.h"
|
|
#include "lf.h" // se non lo metto non riesco a usare gli LF
|
|
#include "atlib.h"
|
|
|
|
#define ALIAS_TCS 200
|
|
#define FINE_SOSPENSIONE "FS"
|
|
|
|
// nomi campi maschera
|
|
#include "at1300a.h"
|
|
|
|
// nomi dei campi
|
|
#include "soggetti.h"
|
|
#include "contsan.h"
|
|
#include "sezioni.h"
|
|
|
|
class TSbloccoSO_app : public TPrintapp
|
|
{
|
|
TMask* _msk;
|
|
TRelation* _rel;
|
|
|
|
TLocalisamfile* _contsan;
|
|
TRecord_array* _scontrolli;
|
|
|
|
int _cur;
|
|
TDate _data_sblocco; // data scadenza sospensione fino a _data_sblocco
|
|
TDate _data_stampa;
|
|
TString16 _tiposo; // tipo sospesione da sbloccare
|
|
TString16 _codsez, _codsot;
|
|
|
|
static bool filter_func_sbloccoSO(const TRelation* rel);
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual bool set_print(int m);
|
|
virtual void set_page(int file, int cnt);
|
|
virtual bool preprocess_page(int file, int counter);
|
|
|
|
public:
|
|
void filtra_sezioni();
|
|
void crea_intestazione();
|
|
void header_sezione(const TString16 codsez, const TString16 codsot);
|
|
TSbloccoSO_app() : _data_sblocco(TODAY), _data_stampa(TODAY), _tiposo("") {}
|
|
};
|
|
|
|
HIDDEN inline TSbloccoSO_app& app() { return (TSbloccoSO_app&) main_app(); }
|
|
|
|
void TSbloccoSO_app::filtra_sezioni()
|
|
{
|
|
const TString16 sezini = _msk->get(F_SEZINI);
|
|
const TString16 sotini = _msk->get(F_SOTINI);
|
|
const TString16 sezfin = _msk->get(F_SEZFIN);
|
|
const TString16 sotfin = _msk->get(F_SOTFIN);
|
|
TRectype da(LF_SOGGETTI);
|
|
TRectype a(LF_SOGGETTI);
|
|
if (sezini.not_empty())
|
|
da.put(SOG_CODSEZ, sezini);
|
|
if (sotini.not_empty())
|
|
da.put(SOG_CODSOT, sotini);
|
|
if (sezfin.not_empty())
|
|
a.put(SOG_CODSEZ, sezfin);
|
|
if (sotfin.not_empty())
|
|
a.put(SOG_CODSOT, sotfin);
|
|
current_cursor()->setregion(da, a);
|
|
}
|
|
|
|
bool TSbloccoSO_app::preprocess_page(int file, int counter)
|
|
{
|
|
TRectype& recsog = current_cursor()->curr();
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
long codice = recsog.get_long(SOG_CODICE);
|
|
key->put(CON_CODICE, codice);
|
|
int err = _scontrolli->read(key);
|
|
int progcon = _scontrolli->rows()+1;
|
|
TRectype& reccon = _contsan->curr();
|
|
reccon.zero();
|
|
reccon.put(CON_CODICE, codice);
|
|
reccon.put(CON_PROGCON, progcon);
|
|
reccon.put(CON_DATACON, _data_stampa);
|
|
reccon.put(CON_TIPOCON, FINE_SOSPENSIONE);
|
|
_scontrolli->add_row(reccon);
|
|
_scontrolli->rewrite();
|
|
con_reord(recsog, _scontrolli);
|
|
current_cursor()->file().rewrite();
|
|
|
|
// salto pagina se cambio sezione
|
|
const TString16 codsez = current_cursor()->curr().get(SOG_CODSEZ);
|
|
const TString16 codsot = current_cursor()->curr().get(SOG_CODSOT);
|
|
if ((_codsez!=codsez)||(_codsot!=codsot))
|
|
{
|
|
if (_codsez != "**")
|
|
printer().formfeed();
|
|
_codsez = codsez;
|
|
_codsot = codsot;
|
|
header_sezione(codsez, codsot);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TSbloccoSO_app::set_page(int file, int cnt)
|
|
{
|
|
set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"######"));
|
|
set_row(1,"@7g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
|
set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
|
|
set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME));
|
|
set_row(1,"@61g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
|
}
|
|
|
|
bool TSbloccoSO_app::filter_func_sbloccoSO(const TRelation* rel)
|
|
{
|
|
bool filtrato = FALSE;
|
|
TRectype& recsog = rel->lfile().curr();
|
|
TRectype* key = new TRectype(LF_CONTSAN);
|
|
long codice = recsog.get_long(SOG_CODICE);
|
|
key->put(CON_CODICE, codice);
|
|
int err = app()._scontrolli->read(key);
|
|
if (err == NOERR)
|
|
{
|
|
TString16 stato = recsog.get(SOG_STATO);
|
|
TDate datastato = recsog.get(SOG_DATASTATO);
|
|
for (int r=1; r<=app()._scontrolli->rows(); r++)
|
|
{
|
|
const TRectype& riga = app()._scontrolli->row(r);
|
|
TString16 tipo = riga.get(CON_TIPOCON);
|
|
TDate datatipo = riga.get(CON_DATACON);
|
|
if (tipo == stato && datatipo == datastato)
|
|
{
|
|
TString16 prosstipo = riga.get(CON_PROSSTIPO);
|
|
if (modstato_tcs(prosstipo) == 'F')
|
|
{
|
|
TDate datafine = riga.get(CON_PROSSDATA);
|
|
filtrato = datafine <= app()._data_sblocco;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return filtrato;
|
|
}
|
|
|
|
void TSbloccoSO_app::header_sezione(const TString16 codsez, const TString16 codsot)
|
|
{
|
|
const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ);
|
|
const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT);
|
|
TString intestazione(132);
|
|
intestazione = "Sezione: ";
|
|
intestazione << codsez;
|
|
intestazione << "/";
|
|
intestazione << codsot;
|
|
intestazione << " ";
|
|
intestazione << densez;
|
|
if ((densot.ok())&& (densot.not_empty()))
|
|
{
|
|
intestazione << "/";
|
|
intestazione << densot;
|
|
}
|
|
intestazione.center_just();
|
|
set_header(1,"@0g%s", (const char*) intestazione);
|
|
return;
|
|
}
|
|
|
|
bool TSbloccoSO_app::set_print(int)
|
|
{
|
|
KEY tasto;
|
|
tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_codsez = "**";
|
|
_codsot = "**";
|
|
_data_sblocco = _msk->get(F_DATA);
|
|
_tiposo = _msk->get(F_TIPO);
|
|
reset_files();
|
|
add_file(LF_SOGGETTI);
|
|
filtra_sezioni();
|
|
// filtro per tipo sospensione
|
|
if (_tiposo.not_empty())
|
|
current_cursor()->setfilter(format("STATO == \"%s\"",(const char*)_tiposo));
|
|
else
|
|
current_cursor()->setfilter("TCS->S6 == \"S\"", TRUE);
|
|
current_cursor()->set_filterfunction(filter_func_sbloccoSO,TRUE);
|
|
reset_print();
|
|
crea_intestazione();
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void TSbloccoSO_app::crea_intestazione()
|
|
{
|
|
reset_header();
|
|
|
|
TString sep(132);
|
|
sep = "SBLOCCO SOSPESI ";
|
|
sep << _tiposo;
|
|
sep << " FINO ALLA DATA ";
|
|
TString16 data_stampa = _data_sblocco.string();
|
|
sep << data_stampa;
|
|
sep.center_just();
|
|
set_header(2, "@0g%s", (const char*) sep);
|
|
data_stampa = _data_stampa.string();
|
|
set_header(2,"@0g%10s", (const char*) data_stampa);
|
|
sep = "";
|
|
sep << "Pag. @#";
|
|
set_header(2, "@120g%s", (const char*) sep);
|
|
|
|
sep = "";
|
|
sep.fill('-');
|
|
set_header(3, (const char *) sep);
|
|
set_header(4,"@0gCod.@7gC.@10gCognome e nome@36gNato il");
|
|
set_header(5,"@0g------@7g--@10g-------------------------@36g----------");
|
|
}
|
|
|
|
bool TSbloccoSO_app::user_create()
|
|
{
|
|
_msk = new TMask("at1300a");
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
|
|
_rel->add("TCS", "CODTAB==STATO",1,0,ALIAS_TCS);
|
|
_cur = add_cursor(new TCursor(_rel, "", 3)); //cursore ordinamento per sezione+sottogruppo+codice
|
|
|
|
_contsan = new TLocalisamfile(LF_CONTSAN);
|
|
_scontrolli = new TRecord_array(LF_CONTSAN, CON_PROGCON);
|
|
return TRUE;
|
|
}
|
|
|
|
bool TSbloccoSO_app::user_destroy()
|
|
{
|
|
delete _rel;
|
|
delete _msk;
|
|
delete _contsan;
|
|
delete _scontrolli;
|
|
return TRUE;
|
|
}
|
|
|
|
int at1300(int argc, char* argv[])
|
|
{
|
|
TSbloccoSO_app a;
|
|
a.run(argc, argv, "Sblocco sospesi");
|
|
return 0;
|
|
} |