1997-06-17 15:50:08 +00:00
# include <form.h>
# include <mask.h>
# include <printapp.h>
1997-12-05 16:26:15 +00:00
# include <tabutil.h>
1997-06-17 15:50:08 +00:00
# include <utility.h>
# include "donaz.h"
1997-12-05 16:26:15 +00:00
# include "contsan.h"
1997-06-17 15:50:08 +00:00
# include "soggetti.h"
# include "sezioni.h"
# include "at6.h"
# include "at6300a.h"
1997-12-05 16:26:15 +00:00
# define ALIAS_LDN 400
1997-06-17 15:50:08 +00:00
1997-08-01 14:49:53 +00:00
class TControlloDonazioni : public TPrintapp
1997-06-17 15:50:08 +00:00
{
TRelation * _rel ;
TMask * _msk ;
1997-12-05 16:26:15 +00:00
TLocalisamfile * _contsan ;
int _contatore , _totfinestampa ;
1997-06-17 15:50:08 +00:00
TDate _dataold , _dataini , _datafin ;
TString16 _tipodon , _luogodon , _luogoold , _sezold ;
1998-03-17 09:23:20 +00:00
TString16 _sezini , _sotini , _sezfin , _sotfin ;
TString16 _tipostampa , _ordinamento , _controllo , _prima ;
1998-02-04 13:46:27 +00:00
bool _stampa80 , _primedon , _breve ;
1997-06-17 15:50:08 +00:00
TParagraph_string _cognome_nome ;
1998-03-10 16:32:39 +00:00
TArray _giorni , _mesi , _giornifinale ;
1998-03-05 16:10:04 +00:00
bool _riepfinale ;
1997-06-17 15:50:08 +00:00
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 ) ;
1997-12-05 16:26:15 +00:00
virtual print_action postprocess_print ( int file , int counter ) ;
1997-06-17 15:50:08 +00:00
public :
void crea_intestazione ( ) ;
1997-12-05 16:26:15 +00:00
void header_stampa ( const TDate data , const TString16 luogo , const TString16 sezione , const TString16 sottog ) ;
void footer_stampa ( ) ;
void fine_stampa ( ) ;
1997-06-17 15:50:08 +00:00
TMask & app_mask ( ) { return * _msk ; }
1997-08-01 14:49:53 +00:00
TControlloDonazioni ( ) : _cognome_nome ( " " , 35 ) { }
1997-06-17 15:50:08 +00:00
} ;
1997-08-01 14:49:53 +00:00
HIDDEN inline TControlloDonazioni & app ( ) { return ( TControlloDonazioni & ) main_app ( ) ; }
1997-06-17 15:50:08 +00:00
1997-08-01 14:49:53 +00:00
void TControlloDonazioni : : set_page ( int file , int cnt )
1997-06-17 15:50:08 +00:00
{
1998-02-04 13:46:27 +00:00
if ( _breve )
1997-12-05 16:26:15 +00:00
{
1998-02-04 13:46:27 +00:00
set_row ( 1 , " @0g@ld " , FLD ( LF_DONAZ , DON_DATADON ) ) ;
set_row ( 1 , " @11g@S " , FLD ( LF_DONAZ , DON_LUOGODON ) ) ;
set_row ( 1 , " @20g@S " , FLD ( LF_DONAZ , DON_TIPODON ) ) ;
1997-12-05 16:26:15 +00:00
set_row ( 1 , " @25g#a " , & _cognome_nome ) ;
1998-02-04 13:46:27 +00:00
set_row ( 1 , " @76g@S " , FLD ( LF_SOGGETTI , SOG_CODSEZ ) ) ;
set_row ( 1 , " @79g@S " , FLD ( LF_SOGGETTI , SOG_CODSOT ) ) ;
set_row ( 1 , " @82g@S " , FLD ( LF_SOGGETTI , SOG_GRUPPOAB0 ) ) ;
set_row ( 1 , " @87g@S " , FLD ( LF_SOGGETTI , SOG_RHANTID ) ) ;
set_row ( 1 , " @91g@S " , FLD ( LF_SOGGETTI , SOG_FENOTIPORH ) ) ;
set_row ( 1 , " @98g@S " , FLD ( LF_SOGGETTI , SOG_KELL ) ) ;
set_row ( 1 , " @102g@S " , FLD ( LF_SOGGETTI , SOG_DU ) ) ;
set_row ( 1 , " @106g@pn " , FLD ( LF_DONAZ , DON_ETICHETTA , " ######### " ) ) ;
1998-02-11 15:15:09 +00:00
set_row ( 1 , " @116g#t " , & _prima ) ;
1997-12-05 16:26:15 +00:00
}
else
1998-02-04 13:46:27 +00:00
if ( _stampa80 )
{
set_row ( 1 , " @0g#D " , & _contatore ) ;
set_row ( 1 , " @6g@pn " , FLD ( LF_DONAZ , DON_ETICHETTA , " ######### " ) ) ;
set_row ( 1 , " @16g@pn " , FLD ( LF_SOGGETTI , SOG_CODICE , " ######## " ) ) ;
set_row ( 2 , " @16g@8,rs " , FLD ( LF_SOGGETTI , SOG_TESSAVIS ) ) ;
set_row ( 1 , " @25g#a " , & _cognome_nome ) ;
set_row ( 2 , " @25g@ld " , FLD ( LF_SOGGETTI , SOG_DATANASC ) ) ;
set_row ( 1 , " @61g@S " , FLD ( LF_SOGGETTI , SOG_CODSEZ ) ) ;
set_row ( 2 , " @64g@S " , FLD ( LF_SOGGETTI , SOG_CODSOT ) ) ;
set_row ( 1 , " @64g@ld " , FLD ( LF_DONAZ , DON_DATADON ) ) ;
set_row ( 2 , " @64g@S " , FLD ( LF_DONAZ , DON_TIPODON ) ) ;
set_row ( 1 , " @75g@S " , FLD ( LF_SOGGETTI , SOG_GRUPPOAB0 ) ) ;
set_row ( 2 , " @75g@S " , FLD ( LF_SOGGETTI , SOG_RHANTID ) ) ;
set_row ( 1 , " @79g#t " , & _controllo ) ;
1998-02-11 15:15:09 +00:00
set_row ( 2 , " @79g#t " , & _prima ) ;
1998-02-04 13:46:27 +00:00
}
else
{
set_row ( 1 , " @0g#D " , & _contatore ) ;
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 ) ) ;
set_row ( 1 , " @118g@S " , FLD ( LF_SOGGETTI , SOG_FENOTIPORH ) ) ;
set_row ( 1 , " @125g@S " , FLD ( LF_SOGGETTI , SOG_KELL ) ) ;
set_row ( 1 , " @129g@S " , FLD ( LF_SOGGETTI , SOG_DU ) ) ;
}
1997-06-17 15:50:08 +00:00
}
1997-08-01 14:49:53 +00:00
bool TControlloDonazioni : : preprocess_page ( int file , int counter )
1997-06-17 15:50:08 +00:00
{
TString80 nome = current_cursor ( ) - > curr ( LF_SOGGETTI ) . get ( SOG_COGNOME ) ;
nome < < " " ;
nome < < current_cursor ( ) - > curr ( LF_SOGGETTI ) . get ( SOG_NOME ) ;
_cognome_nome = nome ;
1997-12-05 16:26:15 +00:00
// verifico se ha un controllo sanitario nella data della donazione
TLocalisamfile contsan ( LF_CONTSAN ) ;
contsan . setkey ( 2 ) ;
contsan . zero ( ) ;
contsan . put ( CON_DATACON , current_cursor ( ) - > curr ( ) . get ( DON_DATADON ) ) ;
contsan . put ( CON_CODICE , current_cursor ( ) - > curr ( ) . get ( DON_CODICE ) ) ;
if ( contsan . read ( ) = = NOERR )
_controllo = contsan . get ( CON_TIPOCON ) ;
else
_controllo = " " ;
1998-02-11 15:15:09 +00:00
bool prima = current_cursor ( ) - > curr ( ) . get_bool ( DON_PRIMADON ) ;
if ( prima )
_prima = " X " ;
else
_prima = " " ;
1997-06-17 15:50:08 +00:00
// 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 ( ) )
1997-12-05 16:26:15 +00:00
footer_stampa ( ) ;
1997-06-17 15:50:08 +00:00
_dataold = datanew ;
1997-12-05 16:26:15 +00:00
header_stampa ( datanew , " " , " " , " " ) ;
_contatore = 0 ;
1997-06-17 15:50:08 +00:00
}
}
break ;
case ' L ' :
{
const TString16 luogonew = current_cursor ( ) - > curr ( ) . get ( DON_LUOGODON ) ;
if ( luogonew ! = _luogoold )
{
if ( _luogoold ! = " **** " )
1997-12-05 16:26:15 +00:00
footer_stampa ( ) ;
1997-06-17 15:50:08 +00:00
_luogoold = luogonew ;
1997-12-05 16:26:15 +00:00
header_stampa ( NULLDATE , luogonew , " " , " " ) ;
_contatore = 0 ;
1997-06-17 15:50:08 +00:00
}
}
break ;
case ' S ' :
1997-12-05 16:26:15 +00:00
{
TString16 sezione = current_cursor ( ) - > curr ( LF_SOGGETTI ) . get ( SOG_CODSEZ ) ;
TString16 sottog = current_cursor ( ) - > curr ( LF_SOGGETTI ) . get ( SOG_CODSOT ) ;
TString16 seznew = " " ;
seznew < < sezione ;
1997-06-17 15:50:08 +00:00
seznew < < " / " ;
1997-12-05 16:26:15 +00:00
seznew < < sottog ;
1997-06-17 15:50:08 +00:00
if ( seznew ! = _sezold )
{
if ( _sezold ! = " **** " )
1997-12-05 16:26:15 +00:00
footer_stampa ( ) ;
1997-06-17 15:50:08 +00:00
_sezold = seznew ;
1997-12-05 16:26:15 +00:00
header_stampa ( NULLDATE , " " , sezione , sottog ) ;
_contatore = 0 ;
1997-06-17 15:50:08 +00:00
}
}
break ;
}
1998-03-05 16:10:04 +00:00
if ( _riepfinale )
{
TDate datadon = current_cursor ( ) - > curr ( ) . get ( DON_DATADON ) ;
int giorno = datadon . day ( ) ;
int mese = datadon . month ( ) ;
if ( mese = = _dataini . month ( ) )
{
real * valore = ( real * ) _giorni . objptr ( giorno - 1 ) ;
* valore + = 1 ;
1998-03-10 16:32:39 +00:00
real * valorefinale = ( real * ) _giornifinale . objptr ( giorno - 1 ) ;
* valorefinale + = 1 ;
1998-03-05 16:10:04 +00:00
}
real * valore1 = ( real * ) _mesi . objptr ( mese - 1 ) ;
* valore1 + = 1 ;
if ( ! ( ( datadon > = _dataini ) & & ( datadon < = _datafin ) ) )
return FALSE ;
}
1997-12-05 16:26:15 +00:00
// salto pagina se non ci sono abbastanza righe per il record
if ( ( _stampa80 ) & & ( printer ( ) . rows_left ( ) < 2 ) )
printer ( ) . formfeed ( ) ;
_contatore + + ;
_totfinestampa + + ;
1997-06-17 15:50:08 +00:00
return TRUE ;
}
1997-12-05 16:26:15 +00:00
print_action TControlloDonazioni : : postprocess_print ( int file , int counter )
{
if ( _contatore > 0 )
footer_stampa ( ) ;
1998-02-04 13:46:27 +00:00
if ( _totfinestampa > 0 & & _contatore ! = _totfinestampa )
1997-12-05 16:26:15 +00:00
fine_stampa ( ) ;
return NEXT_PAGE ;
}
void TControlloDonazioni : : footer_stampa ( )
{
// stampa totale soggetti a fine pagina
1998-03-05 16:10:04 +00:00
if ( _contatore > 0 )
{
reset_footer ( ) ;
TString sep ( 80 ) ;
sep . fill ( ' - ' ) ;
set_footer ( 1 , ( const char * ) sep ) ;
1998-03-31 08:02:52 +00:00
if ( _dataini = = _datafin )
set_footer ( 2 , " TOTALE DONAZIONI DEL %s %d " , _dataini . string ( ) , _contatore ) ;
else
{
TString d1 = _dataini . string ( ) ;
TString d2 = _datafin . string ( ) ;
set_footer ( 2 , " TOTALE DONAZIONI DAL %s AL %s %d " , ( const char * ) d1 , ( const char * ) d2 , _contatore ) ;
}
1998-03-05 16:10:04 +00:00
if ( _riepfinale )
{
TString16 valore ;
TString256 rigastampa = " TOTALI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 " ;
set_footer ( 3 , rigastampa ) ;
rigastampa = " GIORNO " ;
int pos = 7 ;
for ( int i = 0 ; i < 31 ; i + + )
{
valore = " " ;
real * numero = ( real * ) _giorni . objptr ( i ) ;
real numero1 = * numero ;
valore . format ( " %3d " , numero1 . integer ( ) ) ;
rigastampa . overwrite ( ( const char * ) valore , pos ) ;
pos = pos + 4 ;
}
set_footer ( 4 , rigastampa ) ;
rigastampa = " TOTALI GEN. FEB. MAR. APR. MAG. GIU. LUG. AGO. SET. OTT. NOV. DIC. TOTALE " ;
set_footer ( 6 , rigastampa ) ;
rigastampa = " MESE " ;
pos = 8 ;
real totale = ZERO ;
for ( int j = 0 ; j < 12 ; j + + )
{
valore = " " ;
real * numero = ( real * ) _mesi . objptr ( j ) ;
real numero1 = * numero ;
totale + = numero1 ;
valore . format ( " %4d " , numero1 . integer ( ) ) ;
rigastampa . overwrite ( ( const char * ) valore , pos ) ;
pos = pos + 5 ;
}
pos = pos + 4 ;
valore = " " ;
valore . format ( " %4d " , totale . integer ( ) ) ;
rigastampa . overwrite ( ( const char * ) valore , pos ) ;
set_footer ( 7 , rigastampa ) ;
_giorni . destroy ( ) ;
_mesi . destroy ( ) ;
for ( i = 0 ; i < 31 ; i + + )
_giorni . add ( new real ( ZERO ) , i ) ;
for ( j = 0 ; j < 12 ; j + + )
_mesi . add ( new real ( ZERO ) , j ) ;
}
printer ( ) . formfeed ( ) ;
reset_footer ( ) ;
}
1997-12-05 16:26:15 +00:00
}
void TControlloDonazioni : : fine_stampa ( )
{
// stampa totale soggetti a fine stampa
reset_footer ( ) ;
printer ( ) . footerlen ( 20 ) ;
TString sep ( 80 ) ;
sep . fill ( ' - ' ) ;
set_footer ( 1 , ( const char * ) sep ) ;
set_footer ( 2 , " DONAZIONI TOTALI STAMPATE %d " , _totfinestampa ) ;
1998-03-10 16:32:39 +00:00
if ( _riepfinale )
{
TString16 valore ;
TString256 rigastampa = " TOTALI 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 " ;
set_footer ( 3 , rigastampa ) ;
rigastampa = " GIORNO " ;
int pos = 7 ;
for ( int i = 0 ; i < 31 ; i + + )
{
valore = " " ;
real * numero = ( real * ) _giornifinale . objptr ( i ) ;
real numero1 = * numero ;
valore . format ( " %3d " , numero1 . integer ( ) ) ;
rigastampa . overwrite ( ( const char * ) valore , pos ) ;
pos = pos + 4 ;
}
set_footer ( 4 , rigastampa ) ;
}
1997-12-05 16:26:15 +00:00
printer ( ) . formfeed ( ) ;
reset_footer ( ) ;
}
void TControlloDonazioni : : header_stampa ( const TDate data , const TString16 luogo , const TString16 sezione , const TString16 sottog )
1997-06-17 15:50:08 +00:00
{
TString intestazione ( 132 ) ;
intestazione = " STAMPA DI CONTROLLO DONAZIONI " ;
switch ( _tipostampa [ 0 ] )
{
case ' D ' :
{
intestazione < < " PER DATA " ;
intestazione < < data ;
}
break ;
case ' L ' :
{
1997-12-05 16:26:15 +00:00
intestazione < < " PER PUNTO DI PRELIEVO " ;
1997-06-17 15:50:08 +00:00
intestazione < < luogo ;
1997-12-05 16:26:15 +00:00
intestazione < < " " ;
TTable ldn ( " LDN " ) ;
ldn . put ( " CODTAB " , luogo ) ;
if ( ldn . read ( ) = = NOERR )
intestazione < < ldn . get ( " S0 " ) ;
1997-06-17 15:50:08 +00:00
}
break ;
case ' S ' :
{
intestazione < < " PER SEZIONE " ;
intestazione < < sezione ;
1997-12-05 16:26:15 +00:00
if ( sottog . not_empty ( ) )
{
intestazione < < " / " ;
intestazione < < sottog ;
}
TLocalisamfile sez ( LF_SEZIONI ) ;
sez . setkey ( 1 ) ;
TRectype & recsez = sez . curr ( ) ;
recsez . zero ( ) ;
recsez . put ( SEZ_CODSEZ , sezione ) ;
recsez . put ( SEZ_CODSOT , sottog ) ;
if ( sez . read ( ) = = NOERR )
{
intestazione < < " " ;
intestazione < < recsez . get ( SEZ_DENSEZ ) ;
TString80 densot = recsez . get ( SEZ_DENSOT ) ;
if ( densot . not_empty ( ) )
{
intestazione < < " / " ;
intestazione < < densot ;
}
}
1997-06-17 15:50:08 +00:00
}
break ;
}
1997-12-05 16:26:15 +00:00
if ( _stampa80 )
intestazione . center_just ( 80 ) ;
else
intestazione . center_just ( 132 ) ;
1997-06-17 15:50:08 +00:00
set_header ( 1 , " @0g%s " , ( const char * ) intestazione ) ;
intestazione = " Pag. @# " ;
1997-12-05 16:26:15 +00:00
if ( _stampa80 )
set_header ( 1 , " @73g%s " , ( const char * ) intestazione ) ;
else
set_header ( 1 , " @110g%s " , ( const char * ) intestazione ) ;
1997-06-17 15:50:08 +00:00
return ;
}
1997-08-01 14:49:53 +00:00
bool TControlloDonazioni : : set_print ( int m )
1997-06-17 15:50:08 +00:00
{
KEY tasto ;
tasto = _msk - > run ( ) ;
if ( tasto = = K_ENTER )
{
_sezini = _msk - > get ( F_SEZINI ) ;
_sotini = _msk - > get ( F_SOTINI ) ;
1998-03-17 09:23:20 +00:00
_sezfin = _msk - > get ( F_SEZFIN ) ;
_sotfin = _msk - > get ( F_SOTFIN ) ;
1997-06-17 15:50:08 +00:00
_dataini = _msk - > get_date ( F_DATAINI ) ;
_datafin = _msk - > get_date ( F_DATAFIN ) ;
_tipodon = _msk - > get ( F_TIPODON ) ;
_luogodon = _msk - > get ( F_LUOGODON ) ;
1997-12-05 16:26:15 +00:00
_primedon = _msk - > get_bool ( F_PRIMEDON ) ;
1998-02-04 13:46:27 +00:00
_breve = _msk - > get_bool ( F_BREVE ) ;
if ( _breve )
_cognome_nome . set_width ( 50 ) ;
1997-06-17 15:50:08 +00:00
_tipostampa = _msk - > get ( F_TIPOSTAMPA ) ;
1997-08-01 14:49:53 +00:00
_ordinamento = _msk - > get ( F_ORDINAMENTO ) ;
1998-03-05 16:10:04 +00:00
_riepfinale = _msk - > get_bool ( F_RIEPFINALE ) ;
1997-06-17 15:50:08 +00:00
TString80 chiave = " " ;
switch ( _tipostampa [ 0 ] )
{
case ' D ' :
1997-08-01 14:49:53 +00:00
chiave = " 92->DATADON| " ;
1997-06-17 15:50:08 +00:00
break ;
case ' L ' :
1997-08-01 14:49:53 +00:00
chiave = " 92->LUOGODON|92->DATADON| " ;
1997-06-17 15:50:08 +00:00
break ;
case ' S ' :
1997-08-01 14:49:53 +00:00
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 " ;
1997-06-17 15:50:08 +00:00
break ;
}
1997-12-05 16:26:15 +00:00
TString256 filtro = " " ;
1997-06-17 15:50:08 +00:00
// 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 ) ;
}
}
1997-12-05 16:26:15 +00:00
if ( _primedon )
{
if ( filtro . empty ( ) )
filtro = format ( " (PRIMADON == \" X \" ) " ) ;
else
{
filtro < < " && " ;
filtro < < format ( " (PRIMADON == \" X \" ) " ) ;
}
}
1998-03-17 09:23:20 +00:00
TString16 inizio = " " ;
inizio < < _sezini ;
inizio < < _sotini ;
TString16 fine = " " ;
fine < < _sezfin ;
fine < < _sotfin ;
1997-06-17 15:50:08 +00:00
// filtro per sezione/sottogruppo
1998-03-17 09:23:20 +00:00
if ( inizio . not_empty ( ) )
1997-06-17 15:50:08 +00:00
{
if ( filtro . empty ( ) )
1998-03-17 09:23:20 +00:00
filtro = format ( " (90->CODSEZ+90->CODSOT >= \" %s \" ) " , ( const char * ) inizio ) ;
1997-06-17 15:50:08 +00:00
else
{
filtro < < " && " ;
1998-03-17 09:23:20 +00:00
filtro < < format ( " (90->CODSEZ+90->CODSOT >= \" %s \" ) " , ( const char * ) inizio ) ;
1997-06-17 15:50:08 +00:00
}
1998-03-17 09:23:20 +00:00
if ( fine . not_empty ( ) )
1997-06-17 15:50:08 +00:00
{
if ( filtro . empty ( ) )
1998-03-17 09:23:20 +00:00
filtro = format ( " (90->CODSEZ+90->CODSOT <= \" %s \" ) " , ( const char * ) fine ) ;
1997-06-17 15:50:08 +00:00
else
{
filtro < < " && " ;
1998-03-17 09:23:20 +00:00
filtro < < format ( " (90->CODSEZ+90->CODSOT <= \" %s \" ) " , ( const char * ) fine ) ;
1997-06-17 15:50:08 +00:00
}
}
}
// filtro per data
TRectype da ( LF_DONAZ ) ;
TRectype a ( LF_DONAZ ) ;
1998-03-05 16:10:04 +00:00
if ( _riepfinale )
{
TDate inizio = _dataini ;
TDate fine = _datafin ;
inizio . set_day ( 1 ) ;
inizio . set_month ( 1 ) ;
fine . set_end_month ( ) ;
da . put ( DON_DATADON , inizio ) ;
a . put ( DON_DATADON , fine ) ;
_giorni . destroy ( ) ;
_mesi . destroy ( ) ;
1998-03-10 16:32:39 +00:00
_giornifinale . destroy ( ) ;
1998-03-05 16:10:04 +00:00
for ( int i = 0 ; i < 31 ; i + + )
1998-03-10 16:32:39 +00:00
{
1998-03-05 16:10:04 +00:00
_giorni . add ( new real ( ZERO ) , i ) ;
1998-03-10 16:32:39 +00:00
_giornifinale . add ( new real ( ZERO ) , i ) ;
}
1998-03-05 16:10:04 +00:00
for ( int j = 0 ; j < 12 ; j + + )
_mesi . add ( new real ( ZERO ) , j ) ;
}
else
{
if ( _dataini . ok ( ) )
da . put ( DON_DATADON , _dataini ) ;
if ( _datafin . ok ( ) )
a . put ( DON_DATADON , _datafin ) ;
}
1997-12-05 16:26:15 +00:00
current_cursor ( ) - > setregion ( da , a ) ;
current_cursor ( ) - > setfilter ( filtro , TRUE ) ;
( ( TSorted_cursor * ) current_cursor ( ) ) - > change_order ( chiave ) ;
_contatore = 0 ;
_totfinestampa = 0 ;
1997-06-17 15:50:08 +00:00
_dataold = NULLDATE ;
_luogoold = " **** " ;
_sezold = " **** " ;
reset_files ( ) ;
add_file ( LF_DONAZ ) ;
reset_print ( ) ;
crea_intestazione ( ) ;
return TRUE ;
}
else
return FALSE ;
}
1997-08-01 14:49:53 +00:00
void TControlloDonazioni : : crea_intestazione ( )
1997-06-17 15:50:08 +00:00
{
reset_header ( ) ;
1997-12-05 16:26:15 +00:00
TString sep ( 132 ) ;
if ( _primedon )
sep = " PRIME DONAZIONI EFFETTUATE " ;
else
{
sep = " Selezioni della stampa: " ;
if ( _sezini . not_empty ( ) )
1997-06-17 15:50:08 +00:00
{
1997-12-05 16:26:15 +00:00
sep < < " Sez. " ;
sep < < _sezini ;
if ( _sotini . not_empty ( ) )
{
sep < < " / " ;
sep < < _sotini ;
}
sep < < " ; " ;
}
}
1997-06-17 15:50:08 +00:00
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 < < " ; " ;
}
1997-12-05 16:26:15 +00:00
if ( _stampa80 )
sep . center_just ( 80 ) ;
else
sep . center_just ( 132 ) ;
1997-06-17 15:50:08 +00:00
set_header ( 2 , " @0g%s " , ( const char * ) sep ) ;
1998-02-04 13:46:27 +00:00
if ( _breve )
{
1998-02-11 15:15:09 +00:00
set_header ( 3 , " @0gData@11gPunto@20gTipo@25gCognome e nome@76gSe/So@82gAB0 Rh/A Fen.Rh Kell Du@106gEtichetta@116g1d " ) ;
set_header ( 4 , " @0g----------@11g-----@20g----@25g--------------------------------------------------@76g-----@82g--- ---- ------ ---- --@106g---------@116g-- " ) ;
1997-12-05 16:26:15 +00:00
}
1998-02-04 13:46:27 +00:00
else
if ( _stampa80 )
{
1998-02-11 15:15:09 +00:00
set_header ( 3 , " @0gProg.@6gEt.sacca@16gCodice@25gCognome e nome@61gSe@64gData don.@75gGr.@79gCo " ) ;
set_header ( 4 , " @16gTessera@25gData nascita@61gSo@64gTipo don.@75gRh@79g1d " ) ;
set_header ( 5 , " @0g-----@6g---------@16g--------@25g-----------------------------------@61g--@64g----------@75g---@79g-- " ) ;
1998-02-04 13:46:27 +00:00
}
else
{
set_header ( 3 , " @0gProg.@7gEt.sacca@17gCodice@26gTessera@34gCognome e nome@70gNato il@81gSe/So@87gData don.@98gTipo@104gLuogo@110gGr.@114gRh@118gFen.Rh@125gKellDu " ) ;
set_header ( 4 , " @0g------@7g---------@17g--------@26g-------@34g-----------------------------------@70g----------@81g-----@87g----------@98g----@104g-----@110g---@114g---@118g------@125g--- --- " ) ;
}
1998-03-05 16:10:04 +00:00
if ( _riepfinale )
printer ( ) . footerlen ( 9 ) ;
else
printer ( ) . footerlen ( 5 ) ;
1997-06-17 15:50:08 +00:00
}
1997-08-01 14:49:53 +00:00
bool TControlloDonazioni : : user_create ( )
1997-06-17 15:50:08 +00:00
{
_rel = new TRelation ( LF_DONAZ ) ;
_rel - > add ( LF_SOGGETTI , " CODICE==CODICE " ) ;
_rel - > add ( " LDN " , " CODTAB==LUOGODON " , 1 , 0 , ALIAS_LDN ) ;
_msk = new TMask ( " at6300a " ) ;
1997-12-05 16:26:15 +00:00
_contsan = new TLocalisamfile ( LF_CONTSAN ) ;
add_cursor ( new TSorted_cursor ( _rel , " " , " " , 2 ) ) ;
TConfig config ( CONFIG_STUDIO ) ;
_stampa80 = config . get_bool ( " Stampa80 " ) ;
1997-06-17 15:50:08 +00:00
return TRUE ;
}
1997-08-01 14:49:53 +00:00
bool TControlloDonazioni : : user_destroy ( )
1997-06-17 15:50:08 +00:00
{
1998-08-07 10:21:20 +00:00
delete _contsan ;
1997-06-17 15:50:08 +00:00
delete _msk ;
delete _rel ;
return TRUE ;
}
int at6300 ( int argc , char * argv [ ] )
{
1997-08-01 14:49:53 +00:00
TControlloDonazioni a ;
1997-06-17 15:50:08 +00:00
a . run ( argc , argv , " Stampa di controllo donazioni " ) ;
return 0 ;
}