Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : STampa tessere complessive: possibilita' di stampare l'elenco dei soggetti da tesserare git-svn-id: svn://10.65.10.50/trunk@6693 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7017b9be2f
commit
ef213ae14f
217
at/at4500.cpp
217
at/at4500.cpp
@ -16,6 +16,8 @@
|
||||
#define ALIAS_COMNAS 500
|
||||
#define ALIAS_LCP 100
|
||||
|
||||
enum ts { undefined = 0, elenco = 1, tessere = 2 };
|
||||
|
||||
// definizione form per tessere associative
|
||||
class TTessere_form : public TForm
|
||||
{
|
||||
@ -41,6 +43,9 @@ class TStampaTessere : public TPrintapp
|
||||
int _cur;
|
||||
TDate _data_stampa, _datault;
|
||||
TString _riepilogodon;
|
||||
ts _tipostampa;
|
||||
TString16 _codsez, _codsot;
|
||||
int _contatore, _totfinestampa;
|
||||
|
||||
static bool filter_func_auto(const TRelation* rel);
|
||||
|
||||
@ -50,9 +55,14 @@ protected:
|
||||
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);
|
||||
|
||||
public:
|
||||
void crea_intestazione();
|
||||
void filtra_sezioni();
|
||||
void footer_sezione();
|
||||
void fine_stampa();
|
||||
void header_sezione(const TString16 codsez, const TString16 codsot);
|
||||
TMask& app_mask() { return *_msk; }
|
||||
TStampaTessere() : _data_stampa(TODAY), _riepilogodon(35) {}
|
||||
};
|
||||
@ -83,6 +93,81 @@ HIDDEN bool printer_handler(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TStampaTessere::header_sezione(const TString16 codsez, const TString16 codsot)
|
||||
{
|
||||
TPrintrow row;
|
||||
TString256 intestazione;
|
||||
const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ);
|
||||
const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT);
|
||||
intestazione = "Sezione: ";
|
||||
intestazione << codsez;
|
||||
if (codsot.not_empty())
|
||||
{
|
||||
intestazione << "/";
|
||||
intestazione << codsot;
|
||||
}
|
||||
intestazione << " ";
|
||||
intestazione << densez;
|
||||
if (densot.not_empty())
|
||||
{
|
||||
intestazione << "/";
|
||||
intestazione << densot;
|
||||
}
|
||||
//intestazione.center_just();
|
||||
//set_header(1,"@0g%s", (const char*) intestazione);
|
||||
row.put((const char*) intestazione);
|
||||
printer().print(row);
|
||||
row.reset();
|
||||
printer().print(row);
|
||||
row.put("@8gCognome@34gNome@60gData nasc.@71gTessera",1);
|
||||
printer().print(row);
|
||||
row.put("@8g-------------------------@34g-------------------------@60g----------@71g-------",1);
|
||||
printer().print(row);
|
||||
return;
|
||||
}
|
||||
|
||||
void TStampaTessere::footer_sezione()
|
||||
{
|
||||
// stampa totale soggetti a fine pagina
|
||||
TPrintrow row;
|
||||
TString rigastampa = "";
|
||||
row.reset();
|
||||
printer().print(row);
|
||||
rigastampa.format("TOTALE SOGGETTI PER SEZIONE %d", _contatore);
|
||||
row.put((const char*) rigastampa);
|
||||
printer().print(row);
|
||||
row.reset();
|
||||
printer().print(row);
|
||||
}
|
||||
|
||||
void TStampaTessere::fine_stampa()
|
||||
{
|
||||
// stampa totale soggetti a fine stampa
|
||||
TPrintrow row;
|
||||
TString rigastampa = "";
|
||||
rigastampa.fill('-',80);
|
||||
row.put((const char*) rigastampa);
|
||||
printer().print(row);
|
||||
row.reset();
|
||||
printer().print(row);
|
||||
rigastampa.format("TOTALE SOGGETTI DA TESSERARE %d", _totfinestampa);
|
||||
row.put((const char*) rigastampa);
|
||||
printer().print(row);
|
||||
printer().formfeed();
|
||||
}
|
||||
|
||||
print_action TStampaTessere::postprocess_print(int file, int counter)
|
||||
{
|
||||
if (_tipostampa == elenco)
|
||||
{
|
||||
if (_contatore > 0)
|
||||
footer_sezione();
|
||||
if (_totfinestampa > 0 && _contatore != _totfinestampa)
|
||||
fine_stampa();
|
||||
}
|
||||
return NEXT_PAGE;
|
||||
}
|
||||
|
||||
void TStampaTessere::filtra_sezioni()
|
||||
{
|
||||
const TString16 sezini = _msk->get(F_SEZINI);
|
||||
@ -104,18 +189,33 @@ void TStampaTessere::filtra_sezioni()
|
||||
|
||||
void TStampaTessere::set_page(int file, int cnt)
|
||||
{
|
||||
TPrint_section& corpo = _form_pag->get_body();
|
||||
corpo.reset();
|
||||
TForm_item& rigadon = corpo.find_field(TES_RIGADON1);
|
||||
rigadon.set(_riepilogodon);
|
||||
corpo.update();
|
||||
for (word i = 0; i < corpo.height(); i++)
|
||||
switch (_tipostampa)
|
||||
{
|
||||
TPrintrow& riga = corpo.row(i);
|
||||
set_row(i+1,riga);
|
||||
}
|
||||
force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage
|
||||
// altrimenti stampa sempre la stessa etichetta
|
||||
case tessere:
|
||||
{
|
||||
TPrint_section& corpo = _form_pag->get_body();
|
||||
corpo.reset();
|
||||
TForm_item& rigadon = corpo.find_field(TES_RIGADON1);
|
||||
rigadon.set(_riepilogodon);
|
||||
corpo.update();
|
||||
for (word i = 0; i < corpo.height(); i++)
|
||||
{
|
||||
TPrintrow& riga = corpo.row(i);
|
||||
set_row(i+1,riga);
|
||||
}
|
||||
force_setpage(TRUE); // serve perchè alla prossima etichetta rifaccia la setpage
|
||||
// altrimenti stampa sempre la stessa etichetta
|
||||
}
|
||||
break;
|
||||
case elenco:
|
||||
{
|
||||
set_row(1,"@8g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
|
||||
set_row(1,"@34g@S", FLD(LF_SOGGETTI,SOG_NOME));
|
||||
set_row(1,"@60g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
||||
set_row(1,"@71g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool TStampaTessere::filter_func_auto(const TRelation* rel)
|
||||
@ -143,41 +243,68 @@ bool TStampaTessere::filter_func_auto(const TRelation* rel)
|
||||
bool TStampaTessere::preprocess_page(int file, int counter)
|
||||
{
|
||||
TLocalisamfile& sogg = current_cursor()->file(LF_SOGGETTI);
|
||||
|
||||
const int totdon = sogg.get_int(SOG_TOTDON);
|
||||
const TDate dataultima = sogg.get(SOG_DATAULTDON);
|
||||
_riepilogodon = "";
|
||||
if (totdon != 0)
|
||||
{
|
||||
_riepilogodon = "Donazioni fino al ";
|
||||
_riepilogodon << dataultima.string();
|
||||
_riepilogodon << " n.";
|
||||
_riepilogodon << totdon;
|
||||
}
|
||||
if (_aggiorna)
|
||||
if (_tipostampa == elenco)
|
||||
{
|
||||
sogg.put(SOG_T_STAMPATA,TRUE);
|
||||
sogg.rewrite();
|
||||
const TString16 codsez = sogg.get(SOG_CODSEZ);
|
||||
const TString16 codsot = sogg.get(SOG_CODSOT);
|
||||
// salto pagina se cambio sezione
|
||||
if ((_codsez!=codsez)||(_codsot!=codsot))
|
||||
{
|
||||
if (_codsez != "**")
|
||||
footer_sezione();
|
||||
_codsez = codsez;
|
||||
_codsot = codsot;
|
||||
header_sezione(codsez, codsot);
|
||||
_contatore = 0;
|
||||
}
|
||||
_contatore++;
|
||||
_totfinestampa++;
|
||||
}
|
||||
if (_tipostampa == tessere)
|
||||
{
|
||||
const int totdon = sogg.get_int(SOG_TOTDON);
|
||||
const TDate dataultima = sogg.get(SOG_DATAULTDON);
|
||||
_riepilogodon = "";
|
||||
if (totdon != 0)
|
||||
{
|
||||
_riepilogodon = "Donazioni fino al ";
|
||||
_riepilogodon << dataultima.string();
|
||||
_riepilogodon << " n.";
|
||||
_riepilogodon << totdon;
|
||||
}
|
||||
if (_aggiorna)
|
||||
{
|
||||
sogg.put(SOG_T_STAMPATA,TRUE);
|
||||
sogg.rewrite();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TStampaTessere::set_print(int m)
|
||||
{
|
||||
_tipostampa = undefined;
|
||||
KEY tasto;
|
||||
tasto = _msk->run();
|
||||
if (tasto == K_ENTER)
|
||||
switch (tasto)
|
||||
{
|
||||
case F_ELENCO:
|
||||
_tipostampa = elenco;
|
||||
break;
|
||||
case F_TESSERE:
|
||||
_tipostampa = tessere;
|
||||
break;
|
||||
}
|
||||
if (_tipostampa != undefined)
|
||||
{
|
||||
_codsez = "**";
|
||||
_codsot = "**";
|
||||
reset_files();
|
||||
add_file(LF_SOGGETTI);
|
||||
filtra_sezioni();
|
||||
_numdon = _msk->get_int(F_NUMDON);
|
||||
_aggiorna = _msk->get_bool(F_AGGIORNA);
|
||||
_datault = _msk->get_date(F_DATAULT);
|
||||
//const char* filtro = format("(NUM(TOTDON>=%i)) && (T_STAMPATA!=\"X\")",_numdon);
|
||||
//const char* filtro = format("T_STAMPATA!=\"X\"");
|
||||
//const char* filtro = format("TOTDON>=%i",_numdon);
|
||||
//current_cursor()->setfilter(filtro);
|
||||
_categorie.destroy();
|
||||
const TString16 catpri = _msk->get(F_CAT1);
|
||||
const TString16 catsec = _msk->get(F_CAT2);
|
||||
@ -198,7 +325,10 @@ bool TStampaTessere::set_print(int m)
|
||||
if (catses.not_empty() && catses.ok())
|
||||
_categorie.add((const char*) catses);
|
||||
current_cursor()->set_filterfunction (filter_func_auto, TRUE);
|
||||
_contatore = 0;
|
||||
_totfinestampa = 0;
|
||||
reset_print();
|
||||
crea_intestazione();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@ -211,7 +341,6 @@ bool TStampaTessere::user_create()
|
||||
_rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM);
|
||||
_rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS);
|
||||
_rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCP);
|
||||
_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
|
||||
_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
|
||||
//cursore ordinamento per sezione+sottogruppo+cognome+nome
|
||||
_cur = add_cursor(new TCursor(_rel, "", 3));
|
||||
@ -224,6 +353,32 @@ bool TStampaTessere::user_create()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TStampaTessere::crea_intestazione()
|
||||
{
|
||||
reset_header();
|
||||
if (_tipostampa == elenco)
|
||||
{
|
||||
TString sep(80);
|
||||
sep = "ELENCO SOGGETTI DA TESSERARE";
|
||||
sep.center_just(80);
|
||||
set_header(1, "@0g%s", (const char*) sep);
|
||||
TString16 data_stampa = _data_stampa.string();
|
||||
set_header(1,"@0g%10s", (const char*) data_stampa);
|
||||
sep = "";
|
||||
sep << "Pag. @#";
|
||||
set_header(1, "@72g%s", (const char*) sep);
|
||||
sep = "";
|
||||
sep.fill('-');
|
||||
set_header(2, (const char *) sep);
|
||||
set_header(3, "");
|
||||
/*
|
||||
set_header(4,"@0gCognome@26gNome@52gData nasc.@63gTessera");
|
||||
set_header(5,"@0g-------------------------@26g-------------------------@52g----------@63g-------");
|
||||
printer().footerlen(3);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
bool TStampaTessere::user_destroy()
|
||||
{
|
||||
delete _msk;
|
||||
|
@ -27,4 +27,6 @@
|
||||
#define F_DATAULT 302
|
||||
#define F_AGGIORNA 303
|
||||
|
||||
#define F_PRINTER 401
|
||||
#define F_ELENCO 401
|
||||
#define F_TESSERE 402
|
||||
#define F_PRINTER 403
|
||||
|
@ -2,20 +2,26 @@
|
||||
|
||||
TOOLBAR "" 0 20 0 2
|
||||
|
||||
BUTTON DLG_PRINT 9 2
|
||||
BUTTON F_ELENCO 9 2
|
||||
BEGIN
|
||||
PROMPT -13 -11 "~Stampa"
|
||||
MESSAGE EXIT,K_ENTER
|
||||
PROMPT -14 -11 "~Elenco"
|
||||
MESSAGE EXIT,F_ELENCO
|
||||
END
|
||||
|
||||
BUTTON F_TESSERE 9 2
|
||||
BEGIN
|
||||
PROMPT -24 -11 "~Tessere"
|
||||
MESSAGE EXIT,F_TESSERE
|
||||
END
|
||||
|
||||
BUTTON F_PRINTER 19 2
|
||||
BEGIN
|
||||
PROMPT -23 -11 "Imposta stampante"
|
||||
PROMPT -34 -11 "Imposta stampante"
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 9 2
|
||||
BEGIN
|
||||
PROMPT -33 -11 ""
|
||||
PROMPT -44 -11 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
Loading…
x
Reference in New Issue
Block a user