17948962eb
git-svn-id: svn://10.65.10.50/trunk@5702 c028cbd2-c16b-5b4b-a496-9718f37d4682
265 lines
7.6 KiB
C++
Executable File
265 lines
7.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"
|
||
|
||
// nomi campi maschera
|
||
#include "at1200a.h"
|
||
|
||
// nomi dei campi
|
||
#include "soggetti.h"
|
||
#include "donaz.h"
|
||
#include "benem.h"
|
||
#include "sezioni.h"
|
||
|
||
#define ALIAS_GAZ 300
|
||
|
||
class TAttribuzioneBenemerenze : public TPrintapp
|
||
{
|
||
TMask* _msk;
|
||
TRelation* _rel;
|
||
TLocalisamfile* _donaz;
|
||
TLocalisamfile* _benem;
|
||
TRecord_array* _sdonazioni;
|
||
TRecord_array* _sbenemerenze;
|
||
TAssoc_array _catdon;
|
||
TString16 _gruppoazie, _gruppoold;
|
||
TDate _dataela, _datapre;
|
||
bool _anchegruppi;
|
||
TString16 _tipoben; // tipo benemerenza da assegnare
|
||
bool _definitiva;
|
||
int _numdon; // numero donazioni necessarie
|
||
TDate _data_stampa;
|
||
TString16 _codsez, _codsot;
|
||
TParagraph_string _cognome_nome;
|
||
int _contatore;
|
||
|
||
static bool filter_func_attriben(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 crea_intestazione();
|
||
void header_sezione(const TString16 codsez, const TString16 codsot);
|
||
TAttribuzioneBenemerenze() : _data_stampa(TODAY), _cognome_nome("",25) {}
|
||
};
|
||
|
||
HIDDEN inline TAttribuzioneBenemerenze& app() { return (TAttribuzioneBenemerenze&) main_app(); }
|
||
|
||
bool TAttribuzioneBenemerenze::preprocess_page(int file, int counter)
|
||
{
|
||
TRectype& recsez = current_cursor()->curr(LF_SEZIONI);
|
||
TRectype& recsog = current_cursor()->curr();
|
||
TLocalisamfile& filesog = current_cursor()->file();
|
||
|
||
|
||
TString80 nome = recsog.get(SOG_COGNOME);
|
||
nome << " ";
|
||
nome << recsog.get(SOG_NOME);
|
||
_cognome_nome = nome;
|
||
|
||
const int totdon = recsog.get_int(SOG_TOTDON);
|
||
// salto pagina se cambio sezione
|
||
const TString16 codsez = recsog.get(SOG_CODSEZ);
|
||
const TString16 codsot = recsog.get(SOG_CODSOT);
|
||
if ((_codsez!=codsez)||(_codsot!=codsot))
|
||
{
|
||
if (_codsez != "**")
|
||
printer().formfeed();
|
||
_codsez = codsez;
|
||
_codsot = codsot;
|
||
header_sezione(codsez, codsot);
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
void TAttribuzioneBenemerenze::set_page(int file, int cnt)
|
||
{
|
||
set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
|
||
set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
||
set_row(1,"@12g#a", &_cognome_nome);
|
||
set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
||
set_row(1,"@49g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###"));
|
||
}
|
||
|
||
bool TAttribuzioneBenemerenze::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 TAttribuzioneBenemerenze::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 TAttribuzioneBenemerenze::set_print(int)
|
||
{
|
||
KEY tasto;
|
||
tasto = _msk->run();
|
||
if (tasto == K_ENTER)
|
||
{
|
||
_codsez = "**";
|
||
_codsot = "**";
|
||
_gruppoold = "**";
|
||
_contatore = 0;
|
||
TString80 chiave = "";
|
||
_dataela = _msk->get(F_DATAELA);
|
||
_datapre = _msk->get(F_DATAPRE);
|
||
_gruppoazie = _msk->get(F_GRUPPOAZIE);
|
||
_anchegruppi = _msk->get_bool(F_ANCHEGRUPPI);
|
||
_tipoben = _msk->get(F_TIPOBEN);
|
||
_definitiva = _msk->get_bool(F_DEFINITIVA);
|
||
if (_gruppoazie.not_empty())
|
||
chiave << "90->GRUPPOAZIE|UPPER(90->COGNOME)|UPPER(90->NOME)";
|
||
else
|
||
chiave = "90->CODSEZ|90->CODSOT|UPPER(90->COGNOME)|UPPER(90->NOME)";
|
||
TString80 filtro = "";
|
||
if (_gruppoazie.not_empty())
|
||
filtro.format("(90->GRUPPOAZIE == \"%s\")",(const char*)_gruppoazie);
|
||
else
|
||
if (!_anchegruppi)
|
||
filtro.format("(90->GRUPPOAZIE == \"\")");
|
||
// filtro per 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);
|
||
current_cursor()->setfilter(filtro, TRUE);
|
||
((TSorted_cursor*)current_cursor())->change_order(chiave);
|
||
reset_files();
|
||
add_file(LF_SOGGETTI);
|
||
const TString16 catpri = _msk->get(F_CAT1);
|
||
const TString16 catsec = _msk->get(F_CAT2);
|
||
const TString16 catter = _msk->get(F_CAT3);
|
||
const TString16 catqua = _msk->get(F_CAT4);
|
||
const TString16 catqui = _msk->get(F_CAT5);
|
||
const TString16 catses = _msk->get(F_CAT6);
|
||
if (catpri.not_empty() && catpri.ok())
|
||
_catdon.add((const char*) catpri);
|
||
if (catsec.not_empty() && catsec.ok())
|
||
_catdon.add((const char*) catsec);
|
||
if (catter.not_empty() && catter.ok())
|
||
_catdon.add((const char*) catter);
|
||
if (catqua.not_empty() && catqua.ok())
|
||
_catdon.add((const char*) catqua);
|
||
if (catqui.not_empty() && catqui.ok())
|
||
_catdon.add((const char*) catqui);
|
||
if (catses.not_empty() && catses.ok())
|
||
_catdon.add((const char*) catses);
|
||
current_cursor()->setfilter("TOTDON!=0");
|
||
current_cursor()->set_filterfunction(filter_func_attriben,TRUE);
|
||
reset_print();
|
||
crea_intestazione();
|
||
return TRUE;
|
||
}
|
||
else
|
||
return FALSE;
|
||
}
|
||
|
||
void TAttribuzioneBenemerenze::crea_intestazione()
|
||
{
|
||
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 = _dataela.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------@9g--@12g-------------------------@38g----------@49g--------");
|
||
}
|
||
|
||
bool TAttribuzioneBenemerenze::user_create()
|
||
{
|
||
_msk = new TMask("at1200a");
|
||
_rel = new TRelation(LF_SOGGETTI);
|
||
_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
|
||
_rel->add("GAZ", "CODTAB==GRUPPOAZIE",1,0,ALIAS_GAZ);
|
||
add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ","",3));
|
||
_donaz = new TLocalisamfile(LF_DONAZ);
|
||
_benem = new TLocalisamfile(LF_BENEM);
|
||
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
|
||
_sbenemerenze = new TRecord_array(LF_BENEM, BEN_PROGBEN);
|
||
return TRUE;
|
||
}
|
||
|
||
bool TAttribuzioneBenemerenze::user_destroy()
|
||
{
|
||
delete _rel;
|
||
delete _msk;
|
||
delete _donaz;
|
||
delete _benem;
|
||
delete _sdonazioni;
|
||
delete _sbenemerenze;
|
||
return TRUE;
|
||
}
|
||
|
||
int at1200(int argc, char* argv[])
|
||
{
|
||
TAttribuzioneBenemerenze a;
|
||
a.run(argc, argv, "Attribuzione benemerenze");
|
||
return 0;
|
||
} |