Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@19853 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2009-12-30 15:45:28 +00:00
parent fa58a9b356
commit dd926b6e6a
6 changed files with 243 additions and 61 deletions

View File

@ -13,6 +13,7 @@
#define ALIAS_LCPDOM 100 // localita' postale di domicilio
#define ALIAS_COMDOM 501 // comune di domicilio
#define ALIAS_CTD 700 // categoria donatori
#define ALIAS_GAZ 300 // gruppi aziendale
#define ISCRITTI 'I'
enum ts { undefined = 0, elenco = 1, etichette = 2, stampasufile = 3, completo = 4 };
@ -43,6 +44,8 @@ class TStampaIscritti : public TPrintapp
ts _tipostampa;
int _contatore, _totale;
TString16 _codsez, _codsot;
TString16 _gruppoazie, _gruppoold;
bool _pergruppo;
char _tipo_iscdim; // iscritti o dimessi
TDate _dataini, _datafin;
int _etlarghezza, _etcolonne;
@ -64,6 +67,8 @@ public:
void filtra_sezioni();
void header_sezione(const TString16 codsez, const TString16 codsot);
void footer_sezione();
void header_gruppo(const TString16 gruppo);
void footer_gruppo();
void fine_stampa();
TMask& app_mask() { return *_msk; }
TStampaIscritti() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",30) {}
@ -217,17 +222,32 @@ bool TStampaIscritti::preprocess_page(int file, int counter)
localita << ' ' << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM);
localita.trim();
_dencom = localita;
// salto pagina se cambio sezione
const TString16 codsez = recsog.get(SOG_CODSEZ);
const TString16 codsot = recsog.get(SOG_CODSOT);
if ((_codsez!=codsez)||(_codsot!=codsot))
// salto pagina se cambio sezione o gruppo
if (_pergruppo)
{
if (_codsez != "**")
footer_sezione();
_contatore = 0;
_codsez = codsez;
_codsot = codsot;
header_sezione(codsez, codsot);
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 (_tipostampa==etichette)
@ -283,7 +303,12 @@ bool TStampaIscritti::preprocess_page(int file, int counter)
print_action TStampaIscritti::postprocess_print(int file, int counter)
{
if (_contatore > 0)
{
if (_pergruppo)
footer_gruppo();
else
footer_sezione();
}
fine_stampa();
return NEXT_PAGE;
}
@ -303,6 +328,22 @@ void TStampaIscritti::footer_sezione()
}
}
void TStampaIscritti::footer_gruppo()
{
// stampa totale soggetti appartenenti alla sezione
if (_tipostampa==elenco || _tipostampa==completo)
{
reset_footer();
TString sep(80);
sep.fill('-');
set_footer(2, (const char *) sep);
set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore);
printer().formfeed();
reset_footer();
}
}
void TStampaIscritti::fine_stampa()
{
// stampa totale soggetti a fine stampa
@ -342,6 +383,19 @@ void TStampaIscritti::header_sezione(const TString16 codsez, const TString16 cod
return;
}
void TStampaIscritti::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(80);
set_header(1,"@0g%s", (const char*) intestazione);
return;
}
bool TStampaIscritti::set_print(int m)
{
TPrinter& p = printer();
@ -356,6 +410,7 @@ bool TStampaIscritti::set_print(int m)
_tipostampa = elenco;
_codsez = "**";
_codsot = "**";
_gruppoold = "**";
_contatore = 0;
_totale = 0;
}
@ -365,6 +420,7 @@ bool TStampaIscritti::set_print(int m)
_tipostampa = completo;
_codsez = "**";
_codsot = "**";
_gruppoold = "**";
_contatore = 0;
_totale = 0;
}
@ -412,14 +468,30 @@ bool TStampaIscritti::set_print(int m)
_attuale = _msk->get_bool(F_ATTUALE);
bool notiziario = _msk->get_bool(F_NOTIZIARIO);
_numdon = _msk->get_int(F_NUMDON);
_pergruppo = _msk->get_bool(F_PERGRUPPO);
TString256 chiave = "";
if (_pergruppo)
{
_gruppoazie = _msk->get(F_GRUPPOAZIE);
if (_gruppoazie.empty())
chiave << "90->GRUPPOAZIE|UPPER(90->COGNOME)|UPPER(90->NOME)";
}
TString256 filtro = "";
if (_pergruppo)
{
if (_gruppoazie.not_empty())
filtro.format("(90->GRUPPOAZIE == \"%s\")",(const char*)_gruppoazie);
else
filtro.format("(90->GRUPPOAZIE != \"\")");
}
if (notiziario)
{
TString80 filtro;
filtro = "(90->NOTIZIARIO == \"X\")";
current_cursor()->setfilter(filtro, TRUE);
}
else
current_cursor()->setfilter("", TRUE);
if (filtro.not_empty())
filtro = "(90->NOTIZIARIO == \"X\")";
}
current_cursor()->setfilter(filtro, FALSE);
((TSorted_cursor*)current_cursor())->change_order(chiave);
current_cursor()->set_filterfunction(filter_func_iscritti, TRUE);
reset_print();
printer().footerlen(0);
@ -486,9 +558,9 @@ bool TStampaIscritti::user_create()
_rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD);
_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
_rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPDOM);
_rel->add("GAZ", "CODTAB==GRUPPOAZIE",1,0,ALIAS_GAZ);
_rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMDOM);
add_cursor(new TCursor(_rel, "", 3));
add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ|SOG_CODSOT","",3));
_msk = new TMask("at2600a");
TConfig config(CONFIG_STUDIO);
TString16 etformato = config.get("EtFormato");
@ -506,9 +578,8 @@ bool TStampaIscritti::user_create()
iscrtrr.ext("trr");
}
_fileiscr = new TExternisamfile(iscrname, iscrtrr, false);
return true;
_fileiscr = new TExternisamfile(iscrname, iscrtrr, FALSE);
return TRUE;
}
bool TStampaIscritti::user_destroy()
@ -525,4 +596,4 @@ int at2600(int argc, char* argv[])
TStampaIscritti a;
a.run(argc, argv, "Iscritti/dimessi");
return 0;
}
}

View File

@ -29,6 +29,10 @@
#define F_ATTUALE 304 // flag per stampare solo soggetti che sono ancora attualmente nella situazione richiesta (i/d)
#define F_NUMDON 305 // soggetti che hanno almeno tot donazioni
#define F_NOTIZIARIO 306 // soggetti che vogliono il notiziario
#define F_PERGRUPPO 307
#define F_GRUPPOAZIE 308
#define F_D_GRUPPOAZIE 309
#define F_ELENCO 401
#define F_COMPLETO 402

View File

@ -13,10 +13,9 @@ BUTTON F_COMPLETO 2 2
BEGIN
PROMPT 2 1 "~Completo"
MESSAGE EXIT,F_COMPLETO
PICTURE TOOL_PRINTSCHEDE
PICTURE TOOL_PRINTRUBRICA
END
BUTTON F_ETICHETTE 2 2
BEGIN
PROMPT 3 1 "~Etichette"
@ -24,11 +23,18 @@ BEGIN
PICTURE TOOL_PRINTETICH
END
BUTTON F_LETTERE 2 2
BEGIN
PROMPT 4 1 "~Lettere"
MESSAGE EXIT,F_LETTERE
PICTURE TOOL_PRINTSCHEDE
END
BUTTON F_FILE 2 2
BEGIN
PROMPT 4 1 "~File"
PROMPT 5 1 "~File"
MESSAGE EXIT,F_FILE
PICTURE TOOL_EDIT
PICTURE TOOL_NEWREC
END
#include <helpbar.h>
@ -320,6 +326,42 @@ BEGIN
PROMPT 2 15 "Numero minimo donazioni "
END
BOOLEAN F_PERGRUPPO
BEGIN
PROMPT 2 17 "Stampa per gruppo aziendale"
MESSAGE TRUE ENABLE,F_GRUPPOAZIE|ENABLE,F_D_GRUPPOAZIE
MESSAGE FALSE RESET,F_GRUPPOAZIE|RESET,F_D_GRUPPOAZIE|DISABLE,F_GRUPPOAZIE|DISABLE,F_D_GRUPPOAZIE
END
STRING F_GRUPPOAZIE 4
BEGIN
PROMPT 35 17 ""
FLAGS "U"
USE GAZ
INPUT CODTAB F_GRUPPOAZIE
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_GRUPPOAZIE CODTAB
OUTPUT F_D_GRUPPOAZIE S0
CHECKTYPE NORMAL
WARNING "Codice gruppo aziendale non presente"
HELP "Gruppo aziendale di appartenenza"
END
STRING F_D_GRUPPOAZIE 30
BEGIN
PROMPT 43 17 ""
FLAGS "U"
USE GAZ KEY 2
INPUT S0 F_D_GRUPPOAZIE
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
COPY OUTPUT F_GRUPPOAZIE
CHECKTYPE NORMAL
WARNING "Gruppo aziendale non presente"
HELP "Gruppo aziendale di appartenenza"
END
ENDPAGE
ENDMASK

View File

@ -88,13 +88,14 @@ class TStampaPerCategorie : public TPrintapp
int _schxpag, _lenpage, _etnlarghezza, _etncolonne;
int _etlarghezza, _etcolonne, _etrighe, _etbordoini, _etbordofin, _netichette;
int _caxpag, _cabordoini, _cabordofin, _ncartoline;
bool _stampa80, _etictot, _formfeed;
bool _stampa80, _etictot;
protected:
virtual bool user_create();
virtual bool user_destroy();
virtual bool set_print(int m);
virtual void set_page(int file, int cnt);
bool filepers_put(const char* nomecampo, const char* valore);
virtual bool preprocess_page (int file, int counter);
virtual print_action postprocess_print(int file, int counter);
ts dati_cartolina();
@ -112,12 +113,28 @@ public:
TStampaPerCategorie() : _data_stampa(TODAY), _cognome_nome("",25), _dencom("",30), _benemerenza("",11) {}
};
HIDDEN inline TStampaPerCategorie& app() { return (TStampaPerCategorie&) main_app(); }
TCursor* TEti_percat_form::cursor() const { return app().current_cursor(); }
TRelation* TEti_percat_form::relation() const { return cursor()->relation(); }
static int compare_benem(const TObject** o1, const TObject** o2)
{
TRectype* r1 = (TRectype*)*o1;
TRectype* r2 = (TRectype*)*o2;
const TString b1(r1->get(BEN_TIPOBEN));
const TString b2(r2->get(BEN_TIPOBEN));
int b=0;
if (b1>b2) b=+1;
else
if (b1<b2) b=-1;
return b;
}
void TStampaPerCategorie::dati_sezione(const TString16 codsez, const TString16 codsot)
{
_intest1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ1);
@ -653,6 +670,16 @@ void TStampaPerCategorie::header_sezione(const TString16 codsez, const TString16
return;
}
bool TStampaPerCategorie::filepers_put(const char* nomecampo, const char* valore)
{
TRectype& curr_rec = _filepers->curr();
if (!curr_rec.exist(nomecampo))
return false;
curr_rec.put(nomecampo, valore);
return true;
}
bool TStampaPerCategorie::preprocess_page(int file, int counter)
{
TRectype& recsog = current_cursor()->curr();
@ -675,9 +702,9 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
// cerco ultima benemerenza
TString80 benemerenza = "";
const long codice = recsog.get_long(SOG_CODICE);
//TRectype* key = new TRectype(LF_BENEM);
TRectype key = TRectype(LF_BENEM);
//key->put(BEN_CODICE,codice);
key.put(BEN_CODICE,codice);
const int err = _sbenemerenze->read(key);
if (err == NOERR)
@ -685,6 +712,10 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
const int ultima = _sbenemerenze->rows();
if (ultima != 0)
{
//sorting delle benemerenze (necessario in quanto alcuni stupidissimi volontari sono riusciti a mettere le benemerenze..
//..in ordine sparso!!!
_sbenemerenze->sort(compare_benem);
const TString16 codben = _sbenemerenze->row(ultima).get(BEN_TIPOBEN);
benemerenza << cache().get("BNZ", codben).get("S0");
}
@ -727,7 +758,7 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
if (((_tipostampa==sintetico) && ((_stampa80 && printer().rows_left()<4) || (printer().rows_left()<3))) || (printer().rows_left()<6 && _tipostampa==completo))
printer().formfeed();
}
if (_tipostampa==etichette && _etrighe == 0)
if (_tipostampa==etichette && _etrighe == 0)
if (printer().rows_left() < _form_eti->get_body().height())
printer().formfeed();
if (_tipostampa==notiziario && _etrighe == 0)
@ -860,6 +891,7 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
_file->put("COGNOME",recsog.get(SOG_COGNOME));
_file->put("NOME",recsog.get(SOG_NOME));
}
_file->put("DATANASC", recsog.get_date(SOG_DATANASC));
_file->put("SPOSATA",recsog.get(SOG_COGNOME_SP));
_file->put("INDIRIZZO",recsog.get(SOG_DOM_INDIR));
_file->put("PRESSO",recsog.get(SOG_DOM_DISTRI));
@ -880,18 +912,19 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
if (_tipostampa==filepers)
{
_filepers->zero();
_filepers->put("ASSOCIAZ",current_cursor()->curr(LF_SEZIONI).get("DENSEZ"));
_filepers->put("DATANASC",recsog.get(SOG_DATANASC));
_filepers->put("CATDON",recsog.get(SOG_CATDON));
_filepers->put("TESSAVIS",recsog.get(SOG_TESSAVIS));
_filepers->put("GRUPPOAB0",recsog.get(SOG_GRUPPOAB0));
_filepers->put("KELL",recsog.get(SOG_KELL));
_filepers->put("RHANTID",recsog.get(SOG_RHANTID));
_filepers->put("SESSO", ((recsog.get(SOG_SESSO)[0] =='1') ? 'M' : 'F'));
_filepers->put("COGNOME",recsog.get(SOG_COGNOME));
_filepers->put("NOME",recsog.get(SOG_NOME));
_filepers->put("INDIRIZZO",recsog.get(SOG_DOM_INDIR));
_filepers->put("CAP",recsog.get(SOG_DOM_CAP));
filepers_put("ASSOCIAZ", current_cursor()->curr(LF_SEZIONI).get("DENSEZ"));
filepers_put("DATANASC",recsog.get(SOG_DATANASC));
filepers_put("CATDON",recsog.get(SOG_CATDON));
filepers_put("TESSAVIS",recsog.get(SOG_TESSAVIS));
filepers_put("GRUPPOAB0",recsog.get(SOG_GRUPPOAB0));
filepers_put("KELL",recsog.get(SOG_KELL));
filepers_put("RHANTID",recsog.get(SOG_RHANTID));
const char* sesso = recsog.get(SOG_SESSO)[0] =='1' ? "M" : "F";
filepers_put("SESSO", sesso);
filepers_put("COGNOME",recsog.get(SOG_COGNOME));
filepers_put("NOME",recsog.get(SOG_NOME));
filepers_put("INDIRIZZO",recsog.get(SOG_DOM_INDIR));
filepers_put("CAP",recsog.get(SOG_DOM_CAP));
TString80 localita = "";
if (recsog.get(SOG_DOM_CODLOC).not_empty())
localita << current_cursor()->curr(-ALIAS_LCPDOM).get("S0");
@ -899,7 +932,7 @@ bool TStampaPerCategorie::preprocess_page(int file, int counter)
localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM);
localita << ' ' << current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM);
localita.trim();
_filepers->put("LOCALITA",localita);
filepers_put("LOCALITA",localita);
_filepers->write();
do_events();
}
@ -975,7 +1008,6 @@ bool TStampaPerCategorie::set_print(int m)
_contatore = 0;
_netichette = 0;
_ncartoline = 0;
_formfeed = FALSE;
TString256 chiave = "";
_pergruppo = _msk->get_bool(F_PERGRUPPO);
_perfamiglie = _msk->get_bool(F_PERFAMIGLIE);
@ -1155,19 +1187,19 @@ void TStampaPerCategorie::crea_intestazione()
{
TPrint_section& testata = _form_per->get_head();
testata.update();
for (word i = 0; i < testata.height(); i++)
for (word i=0; i<testata.height(); i++)
{
TPrintrow& riga = testata.row(i);
TString256 riga1 = riga.row();
set_header(i + 1,riga1);
set_header(i+1,riga1);
}
TPrint_section& piede = _form_per->get_foot();
piede.update();
for (word j = 0; j < piede.height(); j++)
for (int i = 0; i < piede.height(); i++)
{
TPrintrow& riga = piede.row(j);
TPrintrow& riga = piede.row(i);
TString256 riga1 = riga.row();
set_footer(j + 1,riga1);
set_footer(i+1,riga1);
}
}
if (_tipostampa==sintetico)
@ -1239,23 +1271,35 @@ bool TStampaPerCategorie::user_create()
add_cursor(new TSorted_cursor(_rel,"SOG_CODSEZ|SOG_CODSOT","",3));
_msk = new TMask("at2700a");
TFilename filename = "at2700";
//attenzione: i files at2700a e at2700b, se si desiderano personalizzati, richiedono il tracciato record modificato..
//..in Custom; questo perchè le varie sezioni possono volere campi diversi; il max dei campi è quello che si trova..
//..nei trr ufficiali; la gestione dei campi mancanti è fatta dalla filepers_put() al momento della scrittura vera..
//..e propria dei files
//stampa indirizzi su file
TFilename filename = "at2700a";
filename.ext("dbf");
TFilename filetrr = "at2700";
TFilename filetrr = "at2700a";
filetrr.ext("trr");
if (!filetrr.custom_path())
{
filetrr = "recdesc/at2700";
filetrr = "recdesc/at2700a";
filetrr.ext("trr");
}
_file = new TExternisamfile(filename, filetrr, FALSE);
_file = new TExternisamfile(filename, filetrr, false);
TFilename namepers("at2700");
//stampa file personalizzato
TFilename namepers = "at2700b";
namepers.ext("dbf");
if (namepers.exist())
_filepers = new TExternisamfile(namepers);
else
_filepers = NULL;
TFilename perstrr = "at2700b";
perstrr.ext("trr");
if (!perstrr.custom_path())
{
perstrr = "recdesc/at2700b";
perstrr.ext("trr");
}
_filepers = new TExternisamfile(namepers, perstrr, false);
TConfig config(CONFIG_STUDIO);
TString16 etformato = config.get("EtFormato");

View File

@ -47,7 +47,7 @@ class TFrequenza : public TPrintapp
int _cur;
TParagraph_string _cognome_nome, _dencom, _numdonsog, _dataultdon;
TDate _data_stampa;
TDate _dataini,_datafin;
TDate _dataini,_datafin, _dnini, _dnfin;
int _numdon;
TString16 _tipodon1, _tipodon2, _tipodon3, _tipodon4, _tipodon5, _tipodon;
ts _tipostampa;
@ -181,11 +181,29 @@ void TFrequenza::set_page(int file, int cnt)
bool TFrequenza::filter_func_freq(const TRelation* rel)
{
const TDate datanulla(NULLDATE);
bool filtrato = TRUE;
TLocalisamfile& sog = rel->lfile();
// filtro per sesso
if (app()._sesso != 'I')
filtrato = (sog.get(SOG_SESSO)[0] == app()._sesso);
// filtro per data nascita
if (filtrato)
{
if (app()._dnini != datanulla)
{
const TDate datanasc = sog.get_date(SOG_DATANASC);
filtrato = datanasc >= app()._dnini;
}
}
if (filtrato)
{
if (app()._dnfin != datanulla)
{
const TDate datanasc = sog.get_date(SOG_DATANASC);
filtrato = datanasc <= app()._dnfin;
}
}
// filtro per categorie
if (filtrato)
{
@ -205,7 +223,6 @@ bool TFrequenza::filter_func_freq(const TRelation* rel)
numdon = sog.get_int(SOG_TOTDON);
else
{
const TDate datanulla(NULLDATE);
if (app()._dataini == datanulla)
numdon = sog.get_int(SOG_DONPRECSI) + sog.get_int(SOG_DONPRECAF);
const long codice = sog.get_long(SOG_CODICE);
@ -486,6 +503,8 @@ bool TFrequenza::set_print(int m)
if (catses.not_empty())
_categorie.add((const char*) catses);
_sesso = _msk->get(F_SESSO)[0];
_dnini = _msk->get(F_DNINI);
_dnfin = _msk->get(F_DNFIN);
const char ordina = _msk->get(F_ORDINA)[0];
TString256 chiave = "";
switch (ordina)

View File

@ -39,7 +39,9 @@
#define F_D_TIPODON5 314
#define F_SESSO 351
#define F_ORDINA 352
#define F_DNINI 352
#define F_DNFIN 353
#define F_ORDINA 354
#define F_ELENCO 401
#define F_ETICHETTE 402