Files correlati : Ricompilazione Demo : [ ] Commento : tolto controllo inutile (densot.ok()) git-svn-id: svn://10.65.10.50/trunk@9228 c028cbd2-c16b-5b4b-a496-9718f37d4682
397 lines
11 KiB
C++
Executable File
397 lines
11 KiB
C++
Executable File
#include <form.h>
|
|
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include "soggetti.h"
|
|
#include "benem.h"
|
|
#include "donaz.h"
|
|
#include "sezioni.h"
|
|
#include <comuni.h>
|
|
|
|
#include "at1.h"
|
|
#include "at1500a.h"
|
|
|
|
#define ALIAS_BNZ 600 // benemerenze
|
|
#define ALIAS_GAZ 300 // gruppi aziendale
|
|
|
|
class TControlloBenemerenze : public TPrintapp
|
|
{
|
|
static bool filter_func_ctrlben(const TRelation* rel);
|
|
|
|
TRelation* _rel;
|
|
TMask* _msk;
|
|
TLocalisamfile* _benem;
|
|
TRecord_array* _sbenemerenze;
|
|
TAssoc_array _catdon;
|
|
TAssoc_array* _colonne;
|
|
TParagraph_string _cognome_nome, _benemerenza;
|
|
TDate _data_stampa;
|
|
TString16 _lettini, _lettfin;
|
|
TString16 _gruppoazie, _gruppoold;
|
|
bool _pergruppo;
|
|
int _contatore;
|
|
TString16 _codsez, _codsot;
|
|
TString256 _intestazione1, _intestazione2;
|
|
|
|
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 print_action postprocess_print(int file, int counter);
|
|
bool crea_colonne();
|
|
|
|
public:
|
|
void dati_sezione(const TString16 codsez, const TString16 codsot);
|
|
void crea_intestazione();
|
|
void filtra_sezioni();
|
|
void header_gruppo(const TString16 gruppo);
|
|
void footer_gruppo();
|
|
void header_sezione(const TString16 codsez, const TString16 codsot);
|
|
void footer_sezione();
|
|
TMask& app_mask() { return *_msk; }
|
|
|
|
TControlloBenemerenze() : _data_stampa(TODAY), _cognome_nome("",25), _benemerenza("",80) {}
|
|
};
|
|
|
|
HIDDEN inline TControlloBenemerenze& app() { return (TControlloBenemerenze&) main_app(); }
|
|
|
|
bool TControlloBenemerenze::crea_colonne()
|
|
{
|
|
_intestazione1 = "";
|
|
_intestazione2 = "";
|
|
_colonne->destroy();
|
|
TTable bnz("BNZ");
|
|
real contatore(ZERO);
|
|
for (bnz.first(); !bnz.eof(); bnz.next())
|
|
{
|
|
real* oggetto = new real(contatore);
|
|
_colonne->add((const char*)bnz.get("CODTAB"),(TObject*)oggetto);
|
|
TString80 ben = bnz.get("S0");
|
|
const int pos = (int)contatore.integer();
|
|
TString16 ben1 = ben.mid(0,11);
|
|
TString16 ben2= ben.mid(11,11);
|
|
_intestazione1.insert(ben1,pos);
|
|
_intestazione2.insert(ben2,pos);
|
|
contatore+=12;
|
|
}
|
|
return !bnz.empty();
|
|
}
|
|
|
|
void TControlloBenemerenze::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);
|
|
}
|
|
|
|
void TControlloBenemerenze::footer_gruppo()
|
|
{
|
|
// stampa totale soggetti appartenenti al gruppo
|
|
reset_footer();
|
|
TString sep(132);
|
|
sep.fill('-');
|
|
set_footer(2, (const char *) sep);
|
|
set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore);
|
|
printer().formfeed();
|
|
reset_footer();
|
|
}
|
|
|
|
print_action TControlloBenemerenze::postprocess_print(int file, int counter)
|
|
{
|
|
if (_contatore > 0)
|
|
{
|
|
if (_pergruppo)
|
|
footer_gruppo();
|
|
else
|
|
footer_sezione();
|
|
}
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
void TControlloBenemerenze::footer_sezione()
|
|
{
|
|
// stampa totale soggetti appartenenti alla sezione
|
|
reset_footer();
|
|
TString sep(132);
|
|
sep.fill('-');
|
|
set_footer(2, (const char *) sep);
|
|
set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore);
|
|
printer().formfeed();
|
|
reset_footer();
|
|
}
|
|
|
|
void TControlloBenemerenze::header_gruppo(const TString16 gruppo)
|
|
{
|
|
TString intestazione(132);
|
|
intestazione = "GRUPPO AZIENDALE ";
|
|
intestazione << gruppo;
|
|
intestazione << " - ";
|
|
intestazione << current_cursor()->curr(-ALIAS_GAZ).get("S0");
|
|
intestazione.center_just(132);
|
|
set_header(1,"@0g%s", (const char*) intestazione);
|
|
return;
|
|
}
|
|
|
|
void TControlloBenemerenze::set_page(int file, int cnt)
|
|
{
|
|
set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
|
|
set_row(2,"@2g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS));
|
|
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,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON));
|
|
set_row(2,"@41g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###"));
|
|
|
|
set_row(1,"@49g#a",&_benemerenza);
|
|
|
|
set_row(3,"");
|
|
}
|
|
|
|
bool TControlloBenemerenze::filter_func_ctrlben(const TRelation* rel)
|
|
{
|
|
bool filtrato = FALSE;
|
|
TLocalisamfile& sog = rel->lfile();
|
|
// filtro per categorie donatori
|
|
TAssoc_array& categorie = app()._catdon;
|
|
if (categorie.items() != 0)
|
|
{
|
|
const TString16 cat = sog.get(SOG_CATDON);
|
|
filtrato = categorie.is_key((const char*) cat);
|
|
}
|
|
// se non ho selezionato categorie il soggetto va filtrato comunque
|
|
if (app()._catdon.items() == 0)
|
|
filtrato = TRUE;
|
|
// filtro per iniziale cognome
|
|
if (filtrato && (!app()._lettini.blank()) && (!app()._lettfin.blank()))
|
|
{
|
|
TString80 cognome = sog.get(SOG_COGNOME);
|
|
TString16 primalett = cognome.left(15);
|
|
if (!(primalett >= app()._lettini && primalett <= app()._lettfin))
|
|
filtrato = FALSE;
|
|
}
|
|
return filtrato;
|
|
}
|
|
|
|
void TControlloBenemerenze::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.not_empty())
|
|
{
|
|
intestazione << "/";
|
|
intestazione << densot;
|
|
}
|
|
intestazione.center_just(132);
|
|
set_header(1,"@0g%s", (const char*) intestazione);
|
|
return;
|
|
}
|
|
|
|
bool TControlloBenemerenze::preprocess_page(int file, int counter)
|
|
{
|
|
TRectype& recsog = current_cursor()->curr();
|
|
TString80 nome = recsog.get(SOG_COGNOME);
|
|
nome << " ";
|
|
nome << recsog.get(SOG_NOME);
|
|
_cognome_nome = nome;
|
|
TString256 benemerenza = "";
|
|
const long codice = recsog.get_long(SOG_CODICE);
|
|
TRectype* key = new TRectype(LF_BENEM);
|
|
key->put(BEN_CODICE,codice);
|
|
const int err = _sbenemerenze->read(key);
|
|
for (int r=1; r<=_sbenemerenze->rows(); r++)
|
|
{
|
|
const TRectype& riga = _sbenemerenze->row(r);
|
|
const TString16 tipoben = riga.get(BEN_TIPOBEN);
|
|
const TDate databen = riga.get(BEN_DATABEN);
|
|
real& colonna = (real&)_colonne->find((const char*)tipoben);
|
|
benemerenza.insert(databen.string(),(int) colonna.integer());
|
|
}
|
|
_benemerenza = benemerenza;
|
|
// salto pagina se cambio sezione o gruppo aziendale
|
|
if (_pergruppo)
|
|
{
|
|
TString16 grupponew = current_cursor()->curr(LF_SOGGETTI).get(SOG_GRUPPOAZIE);
|
|
if (grupponew != _gruppoold )
|
|
{
|
|
if (_gruppoold != "**")
|
|
footer_gruppo();
|
|
_contatore = 0;
|
|
_gruppoold = grupponew;
|
|
header_gruppo(grupponew);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const TString16 codsez = recsog.get(SOG_CODSEZ);
|
|
const TString16 codsot = recsog.get(SOG_CODSOT);
|
|
if ((_codsez!=codsez)||(_codsot!=codsot))
|
|
{
|
|
if (_codsez != "**")
|
|
footer_sezione();
|
|
_contatore = 0;
|
|
_codsez = codsez;
|
|
_codsot = codsot;
|
|
header_sezione(codsez, codsot);
|
|
}
|
|
}
|
|
if (printer().rows_left()<2)
|
|
printer().formfeed();
|
|
_contatore++;
|
|
return TRUE;
|
|
}
|
|
|
|
bool TControlloBenemerenze::set_print(int m)
|
|
{
|
|
KEY tasto;
|
|
tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
crea_colonne();
|
|
_codsez = "**";
|
|
_codsot = "**";
|
|
_gruppoold = "**";
|
|
_contatore = 0;
|
|
TString80 chiave = "";
|
|
_pergruppo = _msk->get_bool(F_PERGRUPPO);
|
|
if (_pergruppo)
|
|
{
|
|
_gruppoazie = _msk->get(F_GRUPPOAZIE);
|
|
if (_gruppoazie.empty())
|
|
chiave << "90->GRUPPOAZIE|";
|
|
}
|
|
else
|
|
chiave << "90->CODSEZ|90->CODSOT|";
|
|
chiave << "90->TOTDON|90->COGNOME|90->NOME";
|
|
_lettini = _msk->get(F_LETTINI);
|
|
_lettini.left(15);
|
|
_lettfin = _msk->get(F_LETTFIN);
|
|
_lettfin.left(15);
|
|
TString80 filtro = "";
|
|
if (_gruppoazie.not_empty())
|
|
filtro.format("(90->GRUPPOAZIE == \"%s\")",(const char*)_gruppoazie);
|
|
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);
|
|
_catdon.destroy();
|
|
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()->set_filterfunction (filter_func_ctrlben);
|
|
reset_print();
|
|
printer().footerlen(0);
|
|
crea_intestazione();
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void TControlloBenemerenze::crea_intestazione()
|
|
{
|
|
reset_header();
|
|
TString sep(132);
|
|
sep = "STAMPA DI CONTROLLO BENEMERENZE";
|
|
printer().footerlen(5);
|
|
sep.center_just(132);
|
|
set_header(2, "@0g%s", (const char*) sep);
|
|
TString16 data_stampa = _data_stampa.string();
|
|
set_header(2,"@0g%10s", (const char*) data_stampa);
|
|
sep = "";
|
|
sep << "Pag. @#";
|
|
set_header(2, "@110g%s", (const char*) sep);
|
|
sep = "";
|
|
sep.fill('-');
|
|
set_header(3, (const char *) sep);
|
|
|
|
//set_header(4,"@0g Codice@9gC.@12gCognome e nome@38gData nasc.@49g%s", (const char*)_intestazione1);
|
|
set_header(4,"@0g Codice@9gC.@12gCognome e nome@38gUlt. don.@49g%s", (const char*)_intestazione1);
|
|
set_header(5,"@0g Tessera@38gTot.don. @49g%s", (const char*)_intestazione2);
|
|
}
|
|
|
|
bool TControlloBenemerenze::user_create()
|
|
{
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
_rel->add(LF_BENEM, "CODICE==CODICE", 1);
|
|
_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
|
|
_rel->add("BNZ", "CODTAB==TIPOBEN", 1, LF_BENEM, ALIAS_BNZ);
|
|
_rel->add("GAZ", "CODTAB==GRUPPOAZIE",1,0,ALIAS_GAZ);
|
|
_benem = new TLocalisamfile(LF_BENEM);
|
|
_sbenemerenze = new TRecord_array(LF_BENEM,BEN_PROGBEN);
|
|
_colonne = new TAssoc_array();
|
|
add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ","",3));
|
|
_msk = new TMask("at1500a");
|
|
return TRUE;
|
|
}
|
|
|
|
bool TControlloBenemerenze::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _colonne;
|
|
delete _sbenemerenze;
|
|
delete _benem;
|
|
delete _rel;
|
|
return TRUE;
|
|
}
|
|
|
|
int at1500(int argc, char* argv[])
|
|
{
|
|
TControlloBenemerenze a;
|
|
a.run(argc, argv, "Stampa di controllo benemerenze");
|
|
return 0;
|
|
}
|