1996-07-30 14:46:52 +00:00
|
|
|
|
#include <form.h>
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include <mask.h>
|
1996-07-30 14:46:52 +00:00
|
|
|
|
#include <printapp.h>
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
#include <utility.h>
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
|
|
|
|
#include "at1.h"
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include "lf.h" // se non lo metto non riesco a usare gli LF
|
|
|
|
|
|
|
|
|
|
// nomi campi maschera
|
1996-07-30 14:46:52 +00:00
|
|
|
|
#include "at1200a.h"
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
// nomi dei campi
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
|
#include "donaz.h"
|
|
|
|
|
#include "benem.h"
|
|
|
|
|
#include "sezioni.h"
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
class TAttriben_app : public TPrintapp
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
TMask* _msk;
|
|
|
|
|
TRelation* _rel;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
TLocalisamfile* _donaz;
|
|
|
|
|
TLocalisamfile* _benem;
|
|
|
|
|
TRecord_array* _sdonazioni;
|
|
|
|
|
TRecord_array* _sbenemerenze;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
int _cur;
|
|
|
|
|
TDate _data_attribuzione; // data attribuzione benemerenza
|
|
|
|
|
TDate _data_stampa;
|
|
|
|
|
TString16 _tipoben; // tipo benemerenza da assegnare
|
|
|
|
|
int _numdon; // numero donazioni necessarie
|
|
|
|
|
TString16 _codsez, _codsot;
|
|
|
|
|
TParagraph_string _cognome_nome;
|
|
|
|
|
|
|
|
|
|
static bool filter_func_attriben(const TRelation* rel);
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
//virtual TMask& get_mask() { return *_msk; }
|
|
|
|
|
|
1996-07-30 14:46:52 +00:00
|
|
|
|
public:
|
1997-03-20 10:33:28 +00:00
|
|
|
|
void filtra_sezioni();
|
1996-07-30 14:46:52 +00:00
|
|
|
|
void crea_intestazione();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
void header_sezione(const TString16 codsez, const TString16 codsot);
|
|
|
|
|
TAttriben_app() : _data_attribuzione(TODAY), _data_stampa(TODAY), _tipoben(""), _cognome_nome("",25) {}
|
1996-07-30 14:46:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
HIDDEN inline TAttriben_app& app() { return (TAttriben_app&) main_app(); }
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
void TAttriben_app::filtra_sezioni()
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
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 TAttriben_app::preprocess_page(int file, int counter)
|
|
|
|
|
{
|
|
|
|
|
TString80 nome = current_cursor()->curr().get(SOG_COGNOME);
|
|
|
|
|
nome << " ";
|
|
|
|
|
nome << current_cursor()->curr().get(SOG_NOME);
|
|
|
|
|
_cognome_nome = nome;
|
|
|
|
|
|
|
|
|
|
TRectype& recsez = current_cursor()->curr(LF_SEZIONI);
|
|
|
|
|
TLocalisamfile& sogg = current_cursor()->file(LF_SOGGETTI);
|
|
|
|
|
const int totdon = sogg.get_int(SOG_TOTDON);
|
|
|
|
|
// 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))
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
if (_codsez != "**")
|
|
|
|
|
printer().formfeed();
|
|
|
|
|
_codsez = codsez;
|
|
|
|
|
_codsot = codsot;
|
|
|
|
|
header_sezione(codsez, codsot);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
void TAttriben_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,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"######"));
|
|
|
|
|
set_row(1,"@7g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
|
|
|
|
set_row(1,"@10g#a", &_cognome_nome);
|
|
|
|
|
set_row(1,"@36g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
|
|
|
|
set_row(1,"@47g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TAttriben_app::filter_func_attriben(const TRelation* rel)
|
|
|
|
|
{
|
|
|
|
|
bool filtrato;
|
|
|
|
|
// filtro chi non ha gi<67> ricevuto la benemerenza richiesta
|
|
|
|
|
TLocalisamfile ben(LF_BENEM);
|
|
|
|
|
ben.setkey(3);
|
|
|
|
|
TRectype& recben = ben.curr();
|
|
|
|
|
recben.zero();
|
|
|
|
|
recben.put(BEN_CODICE, rel->lfile().curr().get_long(SOG_CODICE));
|
|
|
|
|
recben.put(BEN_TIPOBEN, app()._tipoben);
|
|
|
|
|
filtrato = (ben.read() != NOERR); // se ha gia' la ben. non va filtrato
|
|
|
|
|
// filtro chi ha il numero donazioni giuste
|
|
|
|
|
if (filtrato)
|
|
|
|
|
filtrato = rel->lfile().curr().get_int(SOG_TOTDON) >= app()._numdon;
|
|
|
|
|
return filtrato;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TAttriben_app::header_sezione(const TString16 codsez, const TString16 codsot)
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
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()))
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
intestazione << "/";
|
|
|
|
|
intestazione << densot;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
intestazione.center_just();
|
|
|
|
|
set_header(1,"@0g%s", (const char*) intestazione);
|
|
|
|
|
return;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool TAttriben_app::set_print(int)
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
|
|
|
|
KEY tasto;
|
|
|
|
|
tasto = _msk->run();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
if (tasto == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
_codsez = "**";
|
|
|
|
|
_codsot = "**";
|
|
|
|
|
_data_attribuzione = _msk->get(F_DATA);
|
|
|
|
|
_tipoben = _msk->get(F_TIPOBEN);
|
|
|
|
|
TTable bnz("BNZ");
|
|
|
|
|
bnz.put("CODTAB",(const char*) _tipoben);
|
|
|
|
|
if (bnz.read() == NOERR)
|
|
|
|
|
_numdon = bnz.get_int("I0");
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
reset_files();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
add_file(LF_SOGGETTI);
|
|
|
|
|
filtra_sezioni();
|
|
|
|
|
current_cursor()->setfilter("TOTDON!=0");
|
|
|
|
|
current_cursor()->set_filterfunction(filter_func_attriben,TRUE);
|
|
|
|
|
reset_print();
|
1996-07-30 14:46:52 +00:00
|
|
|
|
crea_intestazione();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
void TAttriben_app::crea_intestazione()
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
reset_header();
|
|
|
|
|
|
|
|
|
|
TString sep(132);
|
|
|
|
|
sep = "ATTRIBUZIONE BENEMERENZA ";
|
|
|
|
|
sep << _tipoben;
|
|
|
|
|
const TString80 descr = _msk->get(F_D_TIPOBEN);
|
|
|
|
|
sep << " ";
|
|
|
|
|
sep << descr;
|
|
|
|
|
sep << " ALLA DATA ";
|
|
|
|
|
TString16 data_stampa = _data_attribuzione.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@47Num.don.");
|
|
|
|
|
set_header(5,"@0g------@7g--@10g-------------------------@36g----------@47g--------");
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool TAttriben_app::user_create()
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
_msk = new TMask("at1200a");
|
|
|
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
|
|
|
_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
|
|
|
|
|
_cur = add_cursor(new TCursor(_rel, "", 3)); //cursore ordinamento per sezione+sottogruppo+codice
|
|
|
|
|
|
|
|
|
|
_donaz = new TLocalisamfile(LF_DONAZ);
|
|
|
|
|
_benem = new TLocalisamfile(LF_BENEM);
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
|
|
|
|
|
_sbenemerenze = new TRecord_array(LF_BENEM, BEN_PROGBEN);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-07-30 14:46:52 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
bool TAttriben_app::user_destroy()
|
1996-07-30 14:46:52 +00:00
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
delete _rel;
|
|
|
|
|
delete _msk;
|
|
|
|
|
delete _donaz;
|
|
|
|
|
delete _benem;
|
|
|
|
|
delete _sdonazioni;
|
|
|
|
|
delete _sbenemerenze;
|
|
|
|
|
return TRUE;
|
1996-07-30 14:46:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int at1200(int argc, char* argv[])
|
|
|
|
|
{
|
1997-03-20 10:33:28 +00:00
|
|
|
|
TAttriben_app a;
|
|
|
|
|
a.run(argc, argv, "Attribuzione benemerenze");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|