2002-09-09 14:10:14 +00:00
# include <applicat.h>
# include <automask.h>
# include <form.h>
# include <printer.h>
# include <recarray.h>
# include <utility.h>
# include "cm0.h"
# include "cm0100a.h"
# include "cm0100.h"
2005-05-16 23:44:23 +00:00
# include "mov.h"
2002-09-09 14:10:14 +00:00
# include "rmov.h"
# include "pconti.h"
2003-12-01 10:39:19 +00:00
///////////////////////////////////////////////////////////
// TForm_contixcdc
///////////////////////////////////////////////////////////
2002-09-09 14:10:14 +00:00
class TForm_contixcdc : public TForm
{
2005-05-16 23:44:23 +00:00
static TForm_contixcdc * _cur_form ;
static void conti_header_handler ( TPrinter & p ) ;
2002-09-09 14:10:14 +00:00
public :
virtual bool validate ( TForm_item & cf , TToken_string & s ) ;
2005-05-16 23:44:23 +00:00
void set_testata ( ) ;
2003-12-01 10:39:19 +00:00
void set_pedata ( ) { set_footer ( 1 , false ) ; set_footer ( 1 , true ) ; }
TPrint_section & get_section ( char s , pagetype pos ) ;
2002-09-09 14:10:14 +00:00
2003-12-01 08:54:14 +00:00
TForm_contixcdc ( ) ;
2002-09-09 14:10:14 +00:00
virtual ~ TForm_contixcdc ( ) ;
} ;
2005-05-16 23:44:23 +00:00
TForm_contixcdc * TForm_contixcdc : : _cur_form = NULL ;
void TForm_contixcdc : : conti_header_handler ( TPrinter & p )
{
TForm_contixcdc & f = * _cur_form ;
if ( f . firstpage_is_lastpage ( ) )
{
f . set_background ( 1 , TRUE ) ;
f . set_header ( 1 , TRUE ) ;
f . set_footer ( 0 , FALSE ) ;
}
else
{
const word page = f . page ( p ) ;
f . set_background ( page , TRUE ) ;
f . set_header ( 1 , TRUE ) ;
f . set_footer ( page , FALSE ) ;
}
}
void TForm_contixcdc : : set_testata ( )
{
set_header ( 1 , false ) ; set_header ( 1 , true ) ;
_cur_form = this ;
printer ( ) . setheaderhandler ( conti_header_handler ) ; // Setta handlers
}
2003-12-01 10:39:19 +00:00
TPrint_section & TForm_contixcdc : : get_section ( char s , pagetype pos )
2002-09-09 14:10:14 +00:00
{
2003-12-01 10:39:19 +00:00
if ( ! exist ( s , pos ) )
{
s = ' B ' ;
pos = odd_page ;
}
return section ( s , pos ) ;
2002-09-09 14:10:14 +00:00
}
2003-12-01 10:39:19 +00:00
2002-09-09 14:10:14 +00:00
bool TForm_contixcdc : : validate ( TForm_item & cf , TToken_string & s )
{
2002-10-23 14:14:55 +00:00
const TString code ( s . get ( 0 ) ) ; // prende il primo parametro, il codice del messaggio
TString valore ;
if ( code = = " _DITTA " )
{
// lettura dei dati della ditta
// sintassi: _DITTA,{<campo relazione>|<macro>}
// dove: <campo relazione> <20> un riferimento alla relazione di gestione dei dati della ditta (es. 113@->DENCOM <20> la denominazione del comune di residenza della ditta)
// <macro> <20> uno delle macro seguenti:
// !RAGSOC ragione sociale
// !IND indirizzo (fiscale se c'<27> , oppure di residenza)
// !NUM numero civico (fiscale se c'<27> , oppure di residenza)
// !CAP CAP (fiscale se c'<27> , oppure di residenza)
// !COM comune (fiscale se c'<27> , oppure di residenza)
// !PROV provincia (fiscale se c'<27> , oppure di residenza)
// !IVA partita iva
// !CF codice fiscale
// !TEL numero di telefono (con prefisso)
// !FAX numero di fax (con prefisso)
// !REGSOC numero di registrazione presso il Tribunale
// !CCIAA numero di registrazione presso la camera di commercio
2003-05-14 10:26:51 +00:00
2002-10-23 14:14:55 +00:00
TString in ( s . get ( ) ) ;
if ( in [ 0 ] ! = ' ! ' )
{
2003-05-14 10:26:51 +00:00
const TRectype & firm = cache ( ) . get ( LF_NDITTE , main_app ( ) . get_firm ( ) ) ;
cf . set ( firm . get ( in ) ) ;
2002-10-23 14:14:55 +00:00
return TRUE ;
}
else
return TForm : : validate ( cf , s ) ; // se il codice del messaggio non <20> identificato viene passato alla funzione standard
} // fine _DITTA
return TForm : : validate ( cf , s ) ; // se il codice del messaggio non <20> identificato viene passato alla funzione standard
2002-09-09 14:10:14 +00:00
}
2003-12-01 10:39:19 +00:00
TForm_contixcdc : : TForm_contixcdc ( ) : TForm ( " cm0100a " ) //costruttore
{
}
TForm_contixcdc : : ~ TForm_contixcdc ( ) //distruttore
{
}
///////////////////////////////////////////////////////////
// TContixcdc_mask
///////////////////////////////////////////////////////////
2002-09-09 14:10:14 +00:00
class TContixcdc_mask : public TAutomask
{
TRelation * _rel ;
TCursor * _cur ;
protected :
bool on_field_event ( TOperable_field & o , TField_event e , long jolly ) ;
public :
TContixcdc_mask ( ) ;
virtual ~ TContixcdc_mask ( ) { } ;
} ;
TContixcdc_mask : : TContixcdc_mask ( ) : TAutomask ( " cm0100a " )
{
}
bool TContixcdc_mask : : on_field_event ( TOperable_field & o , TField_event e , long jolly )
{
switch ( o . dlg ( ) )
{
case F_DACDC :
case F_ACDC :
if ( e = = fe_modify )
{
const bool on = ! ( field ( F_DACDC ) . empty ( ) & & field ( F_ACDC ) . empty ( ) ) ;
if ( ! on )
{
reset ( F_DAFSC ) ;
reset ( F_AFSC ) ;
}
enable ( F_DAFSC , on ) ;
enable ( F_AFSC , on ) ;
}
break ;
2002-10-23 14:14:55 +00:00
case F_DATAINI :
if ( e = = fe_modify | | e = = fe_close )
{
2003-10-13 14:51:28 +00:00
TDate dataini ( get ( F_DATAINI ) ) ;
2003-11-17 15:32:07 +00:00
if ( dataini . ok ( ) & & ! field ( F_ANNO ) . empty ( ) )
2002-10-23 14:14:55 +00:00
{
2003-11-17 15:32:07 +00:00
const TDate datainies = cache ( ) . get ( " ESC " , get ( F_ANNO ) , " D0 " ) ;
2002-10-23 14:14:55 +00:00
if ( dataini < datainies & & datainies . ok ( ) )
2003-05-14 10:26:51 +00:00
return error_box ( TR ( " La data iniziale non pu<70> essere precedente alla data inizio esercizio %s " ) , ( const char * ) datainies . string ( ) ) ;
2002-10-23 14:14:55 +00:00
}
}
2005-05-16 23:44:23 +00:00
if ( e = = fe_close )
{
const int annoes = get_int ( F_ANNO ) ;
const TDate dataini = get ( F_DATAINI ) ;
if ( annoes = = 0 & & ! dataini . ok ( ) )
return error_box ( TR ( " Data iniziale obbligatoria se anno esercizio non specificato " ) ) ;
}
2002-10-23 14:14:55 +00:00
break ;
case F_DATAFIN :
if ( e = = fe_modify | | fe_close )
{
2003-10-13 14:51:28 +00:00
TDate datafin ( get ( F_DATAFIN ) ) ;
2003-11-17 15:32:07 +00:00
if ( datafin . ok ( ) & & ! field ( F_ANNO ) . empty ( ) )
2002-10-23 14:14:55 +00:00
{
2003-11-17 15:32:07 +00:00
const TDate datafines = cache ( ) . get ( " ESC " , get ( F_ANNO ) , " D1 " ) ;
if ( datafin > datafines & & datafines . ok ( ) )
return error_box ( FR ( " La data finale non pu<70> essere successiva alla data fine esercizio %s " ) , ( const char * ) datafines . string ( ) ) ;
2002-10-23 14:14:55 +00:00
}
}
2005-05-16 23:44:23 +00:00
if ( e = = fe_close )
{
const int annoes = get_int ( F_ANNO ) ;
const TDate datafin = get ( F_DATAFIN ) ;
if ( annoes = = 0 & & ! datafin . ok ( ) )
return error_box ( TR ( " Data finale obbligatoria se anno esercizio non specificato " ) ) ;
}
2002-10-23 14:14:55 +00:00
break ;
2002-09-09 14:10:14 +00:00
default : break ;
}
return TRUE ;
}
struct TTotali : public TObject
{
2002-10-23 14:14:55 +00:00
TImporto _tot_progprec , _tot_periodo , _tot_saldoatt ;
2002-09-09 14:10:14 +00:00
void azzera ( ) ;
TTotali & operator + = ( const TTotali & t ) ;
} ;
void TTotali : : azzera ( )
{
_tot_progprec = 0 ;
_tot_periodo = 0 ;
2002-10-23 14:14:55 +00:00
_tot_saldoatt = 0 ;
2002-09-09 14:10:14 +00:00
}
TTotali & TTotali : : operator + = ( const TTotali & t )
{
_tot_progprec + = t . _tot_progprec ;
_tot_periodo + = t . _tot_periodo ;
2002-10-23 14:14:55 +00:00
_tot_saldoatt + = t . _tot_saldoatt ;
2002-09-09 14:10:14 +00:00
return * this ; //ritorna se stesso, quindi i valori dei totali
}
class TContixCdc : public TSkeleton_application
{
2002-10-23 14:14:55 +00:00
TContixcdc_mask * _mask ;
TForm_contixcdc * _form ;
2002-09-09 14:10:14 +00:00
int _codes ;
TDate _dataini , _datafin ;
2003-12-01 10:39:19 +00:00
TTotali _t_conto , _t_sottoc , _t_fsc , _t_cms ; //sono i tre set di totali (gruppo/conto, sottoconto, commessa)
2002-09-09 14:10:14 +00:00
int _currgruppo , _currconto , _oldgruppo , _oldconto ;
long _currsottoc , _oldsottoc ;
TString _currcms , _currfsc , _oldcms , _oldfsc ;
2003-11-17 15:32:07 +00:00
bool _saltopagina , _headercms , _headerfsc ;
bool _stampa_totconti , _stampa_totcms , _stampa_dettagli ;
2002-09-09 14:10:14 +00:00
protected :
virtual bool create ( ) ;
virtual bool destroy ( ) ;
virtual void main_loop ( ) ;
void print_sottoc ( ) ;
2002-10-23 14:14:55 +00:00
void print_footer_gruppo ( ) ;
void print_footer_cms ( ) ;
void print_header_cms ( ) ;
void print_footer_fsc ( ) ;
void print_header_fsc ( ) ;
2002-09-09 14:10:14 +00:00
void set_intestazione ( ) ;
2003-12-01 10:39:19 +00:00
void fill_importo ( const TImporto & imp , pagetype pt , short id_imp , short id_sez ) ;
void fill_body ( pagetype pt , const TTotali & tot ) ; //riempie il campo body con tutti i totali
void set_field ( pagetype pt , int id , const real & val ) ; //mette in un campo del body odd un valore numerico
void set_field ( pagetype pt , int id , const char * val ) ; //mette in un campo del body odd una stringa
2003-10-13 14:51:28 +00:00
void aggiorna_totali ( const TImporto & importo , const TDate & data ) ;
2002-09-09 14:10:14 +00:00
2003-12-01 10:39:19 +00:00
void print_special_section ( char type , pagetype pos ) ;
void print_body ( pagetype pt ) ; //stampa effettivamente il body
2002-09-09 14:10:14 +00:00
public :
TContixCdc ( ) { }
} ;
bool TContixCdc : : create ( )
{
_mask = new TContixcdc_mask ;
_form = new TForm_contixcdc ;
2003-08-08 12:32:44 +00:00
open_files ( LF_TAB , LF_PCON , LF_RMOV , 0 ) ;
2002-09-09 14:10:14 +00:00
return TSkeleton_application : : create ( ) ;
}
bool TContixCdc : : destroy ( )
{
delete _mask ;
delete _form ;
return TSkeleton_application : : destroy ( ) ;
}
void TContixCdc : : print_sottoc ( )
2002-10-23 14:14:55 +00:00
{
2005-05-16 23:44:23 +00:00
if ( ! _t_sottoc . _tot_periodo . is_zero ( ) | | ! _t_sottoc . _tot_progprec . is_zero ( ) )
2002-09-09 14:10:14 +00:00
{
2002-10-23 14:14:55 +00:00
if ( _headercms )
{
print_header_cms ( ) ;
_headercms = FALSE ;
}
if ( _headerfsc )
{
print_header_fsc ( ) ;
_headerfsc = FALSE ;
}
2002-09-09 14:10:14 +00:00
TString16 key ;
key . format ( " %d|%d|%ld " , _oldgruppo , _oldconto , _oldsottoc ) ;
const TRectype & pcon = cache ( ) . get ( LF_PCON , key ) ;
2003-12-01 10:39:19 +00:00
set_field ( odd_page , FR_GRUPPO , _oldgruppo ) ;
set_field ( odd_page , FR_CONTO , _oldconto ) ;
set_field ( odd_page , FR_SOTTOC , _oldsottoc ) ;
set_field ( odd_page , FR_D_SOTTOC , pcon . get ( PCN_DESCR ) ) ;
fill_body ( odd_page , _t_sottoc ) ;
2003-11-17 15:32:07 +00:00
if ( _stampa_dettagli )
2003-12-01 10:39:19 +00:00
print_body ( odd_page ) ;
_t_conto + = _t_sottoc ;
2002-10-23 14:14:55 +00:00
_t_fsc + = _t_sottoc ;
_t_cms + = _t_sottoc ;
}
2002-09-09 14:10:14 +00:00
_oldsottoc = _currsottoc ;
_t_sottoc . azzera ( ) ;
}
2002-10-23 14:14:55 +00:00
void TContixCdc : : print_footer_gruppo ( )
2002-09-09 14:10:14 +00:00
{
2003-12-01 10:39:19 +00:00
if ( ! _t_conto . _tot_periodo . is_zero ( ) & & _stampa_totconti )
2002-10-23 14:14:55 +00:00
{
TString16 key ;
key . format ( " %d|%d " , _oldgruppo , _oldconto ) ;
TString tmp ;
const TRectype & pcon = cache ( ) . get ( LF_PCON , key ) ;
2003-12-01 10:39:19 +00:00
set_field ( first_page , FR_GRUPPO , _oldgruppo ) ;
set_field ( first_page , FR_CONTO , _oldconto ) ;
set_field ( first_page , FR_SOTTOC , " " ) ;
set_field ( first_page , FR_D_SOTTOC , pcon . get ( PCN_DESCR ) ) ;
fill_body ( first_page , _t_conto ) ;
print_body ( first_page ) ;
2002-10-23 14:14:55 +00:00
}
_oldgruppo = _currgruppo ;
_oldconto = _currconto ;
2003-12-01 10:39:19 +00:00
_t_conto . azzera ( ) ;
2002-09-09 14:10:14 +00:00
}
2002-10-23 14:14:55 +00:00
void TContixCdc : : print_footer_cms ( )
2002-09-09 14:10:14 +00:00
{
2003-11-17 15:32:07 +00:00
if ( ! _t_cms . _tot_periodo . is_zero ( ) & & _stampa_totcms )
2002-10-23 14:14:55 +00:00
{
TString tmp ;
2003-11-17 15:32:07 +00:00
tmp . format ( FR ( " TOTALE COMMESSA %s " ) , ( const char * ) _oldcms ) ;
2003-12-01 10:39:19 +00:00
set_field ( last_page , FR_GRUPPO , " " ) ;
set_field ( last_page , FR_CONTO , " " ) ;
set_field ( last_page , FR_SOTTOC , " " ) ;
set_field ( last_page , FR_D_SOTTOC , tmp ) ;
fill_body ( last_page , _t_cms ) ;
print_body ( last_page ) ;
2002-10-23 14:14:55 +00:00
if ( _saltopagina )
printer ( ) . formfeed ( ) ;
}
_t_cms . azzera ( ) ;
_oldcms = _currcms ;
_headercms = TRUE ;
2002-09-09 14:10:14 +00:00
}
2002-10-23 14:14:55 +00:00
void TContixCdc : : print_footer_fsc ( )
2002-09-09 14:10:14 +00:00
{
2002-10-23 14:14:55 +00:00
if ( ! _t_fsc . _tot_periodo . is_zero ( ) )
{
TString tmp ;
2003-05-14 10:26:51 +00:00
tmp . format ( FR ( " TOTALE FASE %s " ) , ( const char * ) _oldfsc ) ;
2003-12-01 10:39:19 +00:00
set_field ( even_page , FR_D_SOTTOC , tmp ) ;
fill_body ( even_page , _t_fsc ) ;
print_body ( even_page ) ;
2002-10-23 14:14:55 +00:00
}
_oldfsc = _currfsc ;
_t_fsc . azzera ( ) ;
_headerfsc = TRUE ;
2002-09-09 14:10:14 +00:00
}
2002-10-23 14:14:55 +00:00
void TContixCdc : : print_header_cms ( )
2002-09-09 14:10:14 +00:00
{
2003-12-15 14:07:37 +00:00
TPrint_section & h = _form - > get_section ( ' H ' , odd_page ) ;
h . find_field ( FR_CMS ) . set ( _oldcms ) ;
h . find_field ( FR_D_CMS ) . set ( cache ( ) . get ( " CMS " , _oldcms ) . get ( " S0 " ) ) ;
2003-12-01 10:39:19 +00:00
print_special_section ( ' H ' , odd_page ) ;
2002-09-09 14:10:14 +00:00
}
2002-10-23 14:14:55 +00:00
void TContixCdc : : print_header_fsc ( )
2002-09-09 14:10:14 +00:00
{
2003-12-15 14:07:37 +00:00
TPrint_section & h = _form - > get_section ( ' H ' , last_page ) ;
h . find_field ( FR_FSC ) . set ( _oldfsc ) ;
h . find_field ( FR_D_FSC ) . set ( cache ( ) . get ( " FSC " , _oldfsc ) . get ( " S0 " ) ) ;
2003-12-01 10:39:19 +00:00
print_special_section ( ' H ' , last_page ) ;
2002-09-09 14:10:14 +00:00
}
void TContixCdc : : set_intestazione ( )
{
// scrive l'header first, contenente i dati della ditta e dell'esercizio e le selezioni di stampa
2003-12-15 14:07:37 +00:00
TPrint_section & h = _form - > get_section ( ' H ' , first_page ) ;
h . find_field ( FR_ESERCIZIO ) . set ( _mask - > get ( F_ANNO ) ) ;
h . find_field ( FR_DATAINI ) . set ( _mask - > get ( F_DATAINI ) ) ;
h . find_field ( FR_DATAFIN ) . set ( _mask - > get ( F_DATAFIN ) ) ;
h . find_field ( FR_DACDC ) . set ( _mask - > get ( F_DACDC ) ) ;
h . find_field ( FR_DAFSC ) . set ( _mask - > get ( F_DAFSC ) ) ;
h . find_field ( FR_ACDC ) . set ( _mask - > get ( F_ACDC ) ) ;
h . find_field ( FR_AFSC ) . set ( _mask - > get ( F_AFSC ) ) ;
2002-09-09 14:10:14 +00:00
_form - > set_testata ( ) ;
2003-12-01 10:39:19 +00:00
_form - > set_pedata ( ) ;
2002-09-09 14:10:14 +00:00
}
2003-12-01 10:39:19 +00:00
void TContixCdc : : print_special_section ( char type , pagetype pos )
2002-09-09 14:10:14 +00:00
{
2003-12-01 10:39:19 +00:00
TPrint_section & sec = _form - > get_section ( type , pos ) ;
2002-09-09 14:10:14 +00:00
sec . update ( ) ;
if ( sec . height ( ) > printer ( ) . rows_left ( ) )
printer ( ) . formfeed ( ) ;
for ( word i = 0 ; i < sec . height ( ) ; i + + ) // stampa le righe del body
printer ( ) . print ( sec . row ( i ) ) ;
}
2003-12-01 10:39:19 +00:00
void TContixCdc : : print_body ( pagetype pos )
{
print_special_section ( ' B ' , pos ) ;
2005-05-16 23:44:23 +00:00
_form - > set_testata ( ) ;
2003-12-01 10:39:19 +00:00
}
void TContixCdc : : set_field ( pagetype pos , int id , const real & val )
2002-09-09 14:10:14 +00:00
{
2003-12-01 10:39:19 +00:00
TPrint_section & ps = _form - > get_section ( ' B ' , pos ) ;
ps . find_field ( id ) . set ( val . string ( ) ) ;
2002-09-09 14:10:14 +00:00
}
2003-12-01 10:39:19 +00:00
void TContixCdc : : set_field ( pagetype pos , int id , const char * val )
2002-09-09 14:10:14 +00:00
{
2003-12-01 10:39:19 +00:00
TPrint_section & ps = _form - > get_section ( ' B ' , pos ) ;
ps . find_field ( id ) . set ( val ) ;
2002-09-09 14:10:14 +00:00
}
2003-12-01 10:39:19 +00:00
void TContixCdc : : fill_importo ( const TImporto & importo , pagetype pos , short id_imp , short id_sez )
2003-10-13 14:51:28 +00:00
{
if ( ! importo . is_zero ( ) )
{
TImporto imp ( importo ) ;
imp . normalize ( ) ;
2003-12-01 10:39:19 +00:00
set_field ( pos , id_imp , imp . valore ( ) ) ;
2003-10-13 14:51:28 +00:00
char sez [ 2 ] = { imp . sezione ( ) , ' \0 ' } ;
2003-12-01 10:39:19 +00:00
set_field ( pos , id_sez , sez ) ;
2003-10-13 14:51:28 +00:00
}
else
{
2003-12-01 10:39:19 +00:00
set_field ( pos , id_imp , " " ) ;
set_field ( pos , id_sez , " " ) ;
2003-10-13 14:51:28 +00:00
}
}
2003-12-01 10:39:19 +00:00
void TContixCdc : : fill_body ( pagetype pos , const TTotali & tot )
2002-09-09 14:10:14 +00:00
{
2002-10-23 14:14:55 +00:00
// riempie il body odd, contenente i totali; lo fa chiamando la set_field per ogni campo
2003-12-01 10:39:19 +00:00
fill_importo ( tot . _tot_progprec , pos , FR_PROGPREC , FR_SEGNO_PROGPREC ) ;
fill_importo ( tot . _tot_periodo , pos , FR_PERIODO , FR_SEGNO_PERIODO ) ;
2003-10-13 14:51:28 +00:00
TImporto tempval = tot . _tot_progprec ; tempval + = tot . _tot_periodo ;
2003-12-01 10:39:19 +00:00
fill_importo ( tempval , pos , FR_PROG , FR_SEGNO_PROG ) ;
2003-10-13 14:51:28 +00:00
2003-12-01 10:39:19 +00:00
fill_importo ( tot . _tot_saldoatt , pos , FR_SALDOATT , FR_SEGNO_SALDOATT ) ;
2002-09-09 14:10:14 +00:00
}
2003-10-13 14:51:28 +00:00
void TContixCdc : : aggiorna_totali ( const TImporto & importo , const TDate & data )
2002-09-09 14:10:14 +00:00
{
if ( data < _dataini )
_t_sottoc . _tot_progprec + = importo ;
2002-10-23 14:14:55 +00:00
else if ( data < = _datafin )
2002-09-09 14:10:14 +00:00
_t_sottoc . _tot_periodo + = importo ;
2002-10-23 14:14:55 +00:00
_t_sottoc . _tot_saldoatt + = importo ;
2002-09-09 14:10:14 +00:00
}
void TContixCdc : : main_loop ( )
{
2003-11-17 15:32:07 +00:00
_mask - > set ( F_DETTAGLI , " X " ) ; // Attiva stampa dettagli
2003-08-08 12:32:44 +00:00
_mask - > set ( F_TOTCONTI , " X " ) ; // Attiva stampa totali per conto
2003-11-17 15:32:07 +00:00
_mask - > set ( F_TOTCMS , " X " ) ; // Attiva stampa totali per commessa
2003-08-08 12:32:44 +00:00
2002-09-09 14:10:14 +00:00
while ( _mask - > run ( ) = = K_ENTER )
{
_codes = _mask - > get_int ( F_ANNO ) ; // esercizio
_dataini = _mask - > get_date ( F_DATAINI ) ; // data iniziale
_datafin = _mask - > get_date ( F_DATAFIN ) ; // data finale
2003-11-17 15:32:07 +00:00
if ( _dataini . empty ( ) & & ! _mask - > field ( F_ANNO ) . empty ( ) )
2002-10-23 14:14:55 +00:00
_dataini = cache ( ) . get ( " ESC " , _mask - > get ( F_ANNO ) ) . get_date ( " D0 " ) ;
2003-11-17 15:32:07 +00:00
if ( _datafin . empty ( ) & & ! _mask - > field ( F_ANNO ) . empty ( ) )
2002-10-23 14:14:55 +00:00
_datafin = cache ( ) . get ( " ESC " , _mask - > get ( F_ANNO ) ) . get_date ( " D1 " ) ;
TString80 dacdc = _mask - > get ( F_DACDC ) ; // cdc/commessa iniziale
TString80 dafsc = _mask - > get ( F_DAFSC ) ; // fase iniziale
TString80 acdc = _mask - > get ( F_ACDC ) ; // cdc/commessa finale
TString80 afsc = _mask - > get ( F_AFSC ) ; // fase finale
2002-09-09 14:10:14 +00:00
TRelation relrmov ( LF_RMOV ) ;
2005-05-16 23:44:23 +00:00
if ( _codes > 0 )
relrmov . add ( LF_MOV , " NUMREG==NUMREG " ) ; //aggiunge le testate per avere la datacomp
2002-09-09 14:10:14 +00:00
TString filtro = " " ;
2003-11-17 15:32:07 +00:00
if ( _codes > 0 )
2002-09-09 14:10:14 +00:00
filtro . format ( " ANNOES==%d " , _codes ) ;
if ( dacdc . not_empty ( ) )
{
if ( filtro . not_empty ( ) )
filtro < < " && " ;
filtro < < " (CODCMS>= \" " < < dacdc < < " \" ) " ;
}
if ( dafsc . not_empty ( ) )
{
if ( filtro . not_empty ( ) )
filtro < < " && " ;
filtro < < " (FASCMS>= \" " < < dafsc < < " \" ) " ;
}
if ( acdc . not_empty ( ) )
{
if ( filtro . not_empty ( ) )
filtro < < " && " ;
filtro < < " (CODCMS<= \" " < < acdc < < " \" ) " ;
}
if ( afsc . not_empty ( ) )
{
if ( filtro . not_empty ( ) )
filtro < < " && " ;
filtro < < " (FASCMS<= \" " < < afsc < < " \" ) " ;
}
if ( filtro . empty ( ) )
filtro . format ( " (CODCMS!= \" \" ) " ) ;
else
if ( dacdc . empty ( ) & & acdc . empty ( ) )
filtro < < " && " < < " (CODCMS!= \" \" ) " ;
TRectype darec ( LF_RMOV ) , arec ( LF_RMOV ) ;
darec . put ( RMV_GRUPPO , _mask - > get_int ( F_GRUPPOINI ) ) ;
darec . put ( RMV_CONTO , _mask - > get_int ( F_CONTOINI ) ) ;
darec . put ( RMV_SOTTOCONTO , _mask - > get_long ( F_SOTTOCINI ) ) ;
arec . put ( RMV_GRUPPO , _mask - > get_int ( F_GRUPPOFIN ) ) ;
arec . put ( RMV_CONTO , _mask - > get_int ( F_CONTOFIN ) ) ;
arec . put ( RMV_SOTTOCONTO , _mask - > get_long ( F_SOTTOCFIN ) ) ;
2002-10-23 14:14:55 +00:00
TString ordin = " GRUPPO|CONTO|SOTTOCONTO|DATAREG|NUMREG|NUMRIG " ;
bool ctrlfsc = TRUE ;
if ( dafsc . empty ( ) & & afsc . empty ( ) )
{
ctrlfsc = FALSE ;
ordin . insert ( " CODCMS| " ) ;
}
else
ordin . insert ( " CODCMS|FASCMS| " ) ;
2002-09-09 14:10:14 +00:00
TSorted_cursor sortcur ( & relrmov , ordin , filtro , 2 , & darec , & arec ) ;
sortcur . setregion ( darec , arec ) ;
sortcur . setfilter ( filtro , TRUE ) ;
long num = sortcur . items ( ) ;
sortcur . freeze ( ) ;
printer ( ) . open ( ) ;
set_intestazione ( ) ;
TRectype currrec ( LF_RMOV ) ;
_oldcms = " @@ " ;
2002-10-23 14:14:55 +00:00
_oldfsc = ( ctrlfsc ) ? " @@ " : " " ;
2002-09-09 14:10:14 +00:00
_oldsottoc = - 1 ;
_oldgruppo = - 1 ;
_oldconto = - 1 ;
_t_cms . azzera ( ) ;
_t_fsc . azzera ( ) ;
2003-12-01 10:39:19 +00:00
_t_conto . azzera ( ) ;
2002-09-09 14:10:14 +00:00
_t_sottoc . azzera ( ) ;
2002-10-23 14:14:55 +00:00
_headercms = TRUE ;
_headerfsc = ( ctrlfsc ) ? TRUE : FALSE ;
2003-08-08 12:32:44 +00:00
_saltopagina = _mask - > get_bool ( F_SALTOPAGINA ) ; // salto pagina a fine commessa
2003-11-17 15:32:07 +00:00
_stampa_dettagli = _mask - > get_bool ( F_DETTAGLI ) ;
2003-08-08 12:32:44 +00:00
_stampa_totconti = _mask - > get_bool ( F_TOTCONTI ) ;
2003-11-17 15:32:07 +00:00
_stampa_totcms = _mask - > get_bool ( F_TOTCMS ) ;
2003-08-08 12:32:44 +00:00
2002-09-09 14:10:14 +00:00
for ( sortcur = 0 ; sortcur . pos ( ) < num ; + + sortcur ) //scansione su tutte le righe di movimento
{
const TRectype rmovrec = sortcur . curr ( ) ;
2005-05-17 16:39:01 +00:00
_currcms = rmovrec . get ( " CODCMS " ) ;
_currfsc = ( ctrlfsc ) ? rmovrec . get ( " FASCMS " ) : " " ;
2002-09-09 14:10:14 +00:00
_currsottoc = rmovrec . get_long ( RMV_SOTTOCONTO ) ;
_currgruppo = rmovrec . get_int ( RMV_GRUPPO ) ;
_currconto = rmovrec . get_int ( RMV_CONTO ) ;
2005-05-16 23:44:23 +00:00
2003-10-13 14:51:28 +00:00
const TImporto importo ( rmovrec . get_char ( RMV_SEZIONE ) , rmovrec . get_real ( RMV_IMPORTO ) ) ;
2002-10-23 14:14:55 +00:00
if ( ( _oldcms ! = _currcms ) | | ( _oldfsc ! = _currfsc ) | | ( _oldgruppo ! = _currgruppo ) | | ( _oldconto ! = _currconto ) | | ( _oldsottoc ! = _currsottoc ) )
2002-09-09 14:10:14 +00:00
{
2002-10-23 14:14:55 +00:00
print_sottoc ( ) ;
2002-09-09 14:10:14 +00:00
if ( ( _oldcms ! = _currcms ) | | ( _oldfsc ! = _currfsc ) | | ( _oldgruppo ! = _currgruppo ) | | ( _oldconto ! = _currconto ) )
{
2002-10-23 14:14:55 +00:00
print_footer_gruppo ( ) ;
2002-09-09 14:10:14 +00:00
if ( ( _oldcms ! = _currcms ) | | ( _oldfsc ! = _currfsc ) )
2002-10-23 14:14:55 +00:00
{
if ( ctrlfsc )
print_footer_fsc ( ) ;
if ( _oldcms ! = _currcms )
print_footer_cms ( ) ;
2002-09-09 14:10:14 +00:00
}
}
}
2005-05-16 23:44:23 +00:00
TDate data ;
if ( _codes > 0 )
data = relrmov . curr ( LF_MOV ) . get_date ( MOV_DATACOMP ) ;
else
data = rmovrec . get_date ( RMV_DATAREG ) ;
aggiorna_totali ( importo , data ) ;
} //fine for
2002-10-23 14:14:55 +00:00
if ( num > 0 )
2002-09-09 14:10:14 +00:00
{
print_sottoc ( ) ;
2002-10-23 14:14:55 +00:00
print_footer_gruppo ( ) ;
if ( ctrlfsc )
print_footer_fsc ( ) ;
print_footer_cms ( ) ;
2003-12-01 10:39:19 +00:00
printer ( ) . formfeed ( ) ;
2002-09-09 14:10:14 +00:00
}
printer ( ) . close ( ) ;
}
}
int cm0100 ( int argc , char * argv [ ] )
{
TContixCdc a ;
2003-05-14 10:26:51 +00:00
a . run ( argc , argv , TR ( " Stampa conti per CDC/Commessa " ) ) ;
2002-09-09 14:10:14 +00:00
return 0 ;
}