318 lines
7.5 KiB
C++
Executable File
318 lines
7.5 KiB
C++
Executable File
#include <form.h>
|
|
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <utility.h>
|
|
#include <lffiles.h>
|
|
|
|
#include "donaz.h"
|
|
#include "soggetti.h"
|
|
#include "sezioni.h"
|
|
|
|
#include "at6.h"
|
|
#include "at6300a.h"
|
|
|
|
#define ALIAS_LDN 100
|
|
|
|
class TControlloDonazioni : public TPrintapp
|
|
{
|
|
TRelation* _rel;
|
|
TMask* _msk;
|
|
int _counter;
|
|
int _cur;
|
|
TDate _dataold, _dataini, _datafin;
|
|
TString16 _tipodon, _luogodon, _luogoold, _sezold;
|
|
TString16 _sezini, _sotini, _tipostampa,_ordinamento;
|
|
|
|
TParagraph_string _cognome_nome;
|
|
|
|
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_data(const TDate data, const TString16 luogo, const TString16 sezione);
|
|
TMask& app_mask() { return *_msk; }
|
|
TControlloDonazioni() : _cognome_nome("",35) {}
|
|
};
|
|
|
|
HIDDEN inline TControlloDonazioni& app() { return (TControlloDonazioni&) main_app(); }
|
|
|
|
void TControlloDonazioni::set_page(int file, int cnt)
|
|
{
|
|
set_row(1,"@0g#D", &_counter);
|
|
set_row(1,"@7g@pn", FLD(LF_DONAZ,DON_ETICHETTA,"#########"));
|
|
set_row(1,"@17g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
|
|
set_row(1,"@26g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS));
|
|
set_row(1,"@34g#a", &_cognome_nome);
|
|
set_row(1,"@70g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
|
set_row(1,"@81g@S", FLD(LF_SOGGETTI,SOG_CODSEZ));
|
|
set_row(1,"@84g@S", FLD(LF_SOGGETTI,SOG_CODSOT));
|
|
set_row(1,"@87g@ld", FLD(LF_DONAZ,DON_DATADON));
|
|
set_row(1,"@98g@S", FLD(LF_DONAZ,DON_TIPODON));
|
|
set_row(1,"@104g@S", FLD(LF_DONAZ, DON_LUOGODON));
|
|
set_row(1,"@110g@S", FLD(LF_SOGGETTI, SOG_GRUPPOAB0));
|
|
set_row(1,"@114g@S", FLD(LF_SOGGETTI, SOG_RHANTID));
|
|
}
|
|
|
|
bool TControlloDonazioni::preprocess_page(int file, int counter)
|
|
{
|
|
// contatore soggetti stampati
|
|
// per ora non c'è
|
|
TString80 nome = current_cursor()->curr(LF_SOGGETTI).get(SOG_COGNOME);
|
|
nome << " ";
|
|
nome << current_cursor()->curr(LF_SOGGETTI).get(SOG_NOME);
|
|
_cognome_nome = nome;
|
|
|
|
// salto pagina se cambio punto di rottura
|
|
switch (_tipostampa[0])
|
|
{
|
|
case 'D':
|
|
{
|
|
const TDate datanew = current_cursor()->curr().get(DON_DATADON);
|
|
if (datanew != _dataold )
|
|
{
|
|
if (_dataold.ok())
|
|
printer().formfeed();
|
|
_dataold = datanew;
|
|
header_data(datanew,"","");
|
|
_counter = 0;
|
|
}
|
|
}
|
|
break;
|
|
case 'L':
|
|
{
|
|
const TString16 luogonew = current_cursor()->curr().get(DON_LUOGODON);
|
|
if (luogonew != _luogoold )
|
|
{
|
|
if (_luogoold != "****")
|
|
printer().formfeed();
|
|
_luogoold = luogonew;
|
|
header_data(NULLDATE,luogonew,"");
|
|
_counter = 0;
|
|
}
|
|
}
|
|
break;
|
|
case 'S':
|
|
{
|
|
TString16 seznew = current_cursor()->curr(LF_SOGGETTI).get(SOG_CODSEZ);
|
|
seznew << "/";
|
|
seznew << current_cursor()->curr(LF_SOGGETTI).get(SOG_CODSOT);
|
|
if (seznew != _sezold )
|
|
{
|
|
if (_sezold != "****")
|
|
printer().formfeed();
|
|
_sezold = seznew;
|
|
header_data(NULLDATE,"",seznew);
|
|
_counter = 0;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
_counter++;
|
|
return TRUE;
|
|
}
|
|
|
|
void TControlloDonazioni::header_data(const TDate data, const TString16 luogo, const TString16 sezione)
|
|
{
|
|
TString intestazione(132);
|
|
intestazione = "STAMPA DI CONTROLLO DONAZIONI ";
|
|
switch (_tipostampa[0])
|
|
{
|
|
case 'D':
|
|
{
|
|
intestazione << "PER DATA ";
|
|
intestazione << data;
|
|
}
|
|
break;
|
|
case 'L':
|
|
{
|
|
intestazione << "PER LUOGO ";
|
|
intestazione << luogo;
|
|
}
|
|
break;
|
|
case 'S':
|
|
{
|
|
intestazione << "PER SEZIONE ";
|
|
intestazione << sezione;
|
|
}
|
|
break;
|
|
}
|
|
intestazione.center_just();
|
|
set_header(1,"@0g%s", (const char*) intestazione);
|
|
intestazione = "Pag. @#";
|
|
set_header(1, "@110g%s", (const char*) intestazione);
|
|
return;
|
|
}
|
|
|
|
bool TControlloDonazioni::set_print(int m)
|
|
{
|
|
KEY tasto;
|
|
tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
_sezini = _msk->get(F_SEZINI);
|
|
_sotini = _msk->get(F_SOTINI);
|
|
_dataini = _msk->get_date(F_DATAINI);
|
|
_datafin = _msk->get_date(F_DATAFIN);
|
|
_tipodon = _msk->get(F_TIPODON);
|
|
_luogodon = _msk->get(F_LUOGODON);
|
|
|
|
_tipostampa = _msk->get(F_TIPOSTAMPA);
|
|
_ordinamento = _msk->get(F_ORDINAMENTO);
|
|
TString80 chiave = "";
|
|
switch (_tipostampa[0])
|
|
{
|
|
case 'D':
|
|
chiave = "92->DATADON|";
|
|
break;
|
|
case 'L':
|
|
chiave = "92->LUOGODON|92->DATADON|";
|
|
break;
|
|
case 'S':
|
|
chiave = "90->CODSEZ|90->CODSOT|92->DATADON|";
|
|
break;
|
|
}
|
|
switch (_ordinamento[0])
|
|
{
|
|
case 'C':
|
|
chiave << "UPPER(90->COGNOME)|UPPER(90->NOME)";
|
|
break;
|
|
case 'I':
|
|
chiave << "92->PROGINS";
|
|
break;
|
|
case 'E':
|
|
chiave << "92->ETICHETTA";
|
|
break;
|
|
}
|
|
TString80 filtro = "";
|
|
// filtro per tipo donazione
|
|
if (_tipodon.not_empty())
|
|
filtro = format("(TIPODON == \"%s\")",(const char*)_tipodon);
|
|
// filtro per luogo donazione
|
|
if (_luogodon.not_empty())
|
|
{
|
|
if (filtro.empty())
|
|
filtro = format("(LUOGODON == \"%s\")",(const char*)_luogodon);
|
|
else
|
|
{
|
|
filtro << " && ";
|
|
filtro << format("(LUOGODON == \"%s\")",(const char*)_luogodon);
|
|
}
|
|
}
|
|
// filtro per sezione/sottogruppo
|
|
if (_sezini.not_empty())
|
|
{
|
|
if (filtro.empty())
|
|
filtro = format("(90->CODSEZ == \"%s\")",(const char*)_sezini);
|
|
else
|
|
{
|
|
filtro << " && ";
|
|
filtro << format("(90->CODSEZ == \"%s\")",(const char*)_sezini);
|
|
}
|
|
if (_sotini.not_empty())
|
|
{
|
|
if (filtro.empty())
|
|
filtro = format("(90->CODSOT == \"%s\")",(const char*)_sotini);
|
|
else
|
|
{
|
|
filtro << " && ";
|
|
filtro << format("(90->CODSOT == \"%s\")",(const char*)_sotini);
|
|
}
|
|
}
|
|
}
|
|
// filtro per data
|
|
TRectype da(LF_DONAZ);
|
|
TRectype a (LF_DONAZ);
|
|
if (_dataini.ok())
|
|
da.put(DON_DATADON, _dataini);
|
|
if (_datafin.ok())
|
|
a.put(DON_DATADON, _datafin);
|
|
_cur = add_cursor(new TSorted_cursor(_rel, (const char*) chiave, "", 2, &da, &a));
|
|
current_cursor()->setfilter((const char*) filtro, TRUE);
|
|
_counter = 0;
|
|
_dataold = NULLDATE;
|
|
_luogoold = "****";
|
|
_sezold = "****";
|
|
reset_files();
|
|
add_file(LF_DONAZ);
|
|
reset_print();
|
|
crea_intestazione();
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void TControlloDonazioni::crea_intestazione()
|
|
{
|
|
reset_header();
|
|
TString sep(132);
|
|
sep = "Selezioni della stampa: ";
|
|
if (_sezini.not_empty())
|
|
{
|
|
sep << "Sez. ";
|
|
sep << _sezini;
|
|
if (_sotini.not_empty())
|
|
{
|
|
sep << "/";
|
|
sep << _sotini;
|
|
}
|
|
sep << "; ";
|
|
}
|
|
if (_dataini.ok())
|
|
{
|
|
sep << "Dal ";
|
|
sep << _dataini.string();
|
|
}
|
|
if (_datafin.ok())
|
|
{
|
|
sep << " Al ";
|
|
sep << _datafin.string();
|
|
}
|
|
if (_dataini.ok() || _datafin.ok())
|
|
sep << "; ";
|
|
if (_tipodon.not_empty())
|
|
{
|
|
sep << "Tipo ";
|
|
sep << _tipodon;
|
|
sep << "; ";
|
|
}
|
|
if (_luogodon.not_empty())
|
|
{
|
|
sep << "Luogo ";
|
|
sep << _luogodon;
|
|
sep << "; ";
|
|
}
|
|
sep.center_just();
|
|
set_header(2,"@0g%s", (const char*) sep);
|
|
set_header(3,"@0gProg.@7gEt.sacca@17gCodice@26gTessera@34gCognome e nome@70gNato il@81gSe/So@87gData don.@98gTipo@104gLuogo@110gGr.@114gRh");
|
|
set_header(4,"@0g------@7g---------@17g--------@26g-------@34g-----------------------------------@70g----------@81g-----@87g----------@98g----@104g-----@110g---@114g---");
|
|
}
|
|
|
|
bool TControlloDonazioni::user_create()
|
|
{
|
|
_rel = new TRelation(LF_DONAZ);
|
|
_rel->add(LF_SOGGETTI, "CODICE==CODICE");
|
|
_rel->add("LDN", "CODTAB==LUOGODON",1,0,ALIAS_LDN);
|
|
_msk = new TMask("at6300a");
|
|
return TRUE;
|
|
}
|
|
|
|
bool TControlloDonazioni::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _rel;
|
|
return TRUE;
|
|
}
|
|
|
|
int at6300(int argc, char* argv[])
|
|
{
|
|
TControlloDonazioni a;
|
|
a.run(argc, argv, "Stampa di controllo donazioni");
|
|
return 0;
|
|
}
|