Stampa colonne su più pagine
git-svn-id: svn://10.65.10.50/trunk@5327 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ed5d76acdb
commit
6f3dcd713d
620
sv/sv1200.cpp
620
sv/sv1200.cpp
@ -17,6 +17,20 @@
|
|||||||
#include "..\pr\agenti.h"
|
#include "..\pr\agenti.h"
|
||||||
#include "..\ve\clifor.h"
|
#include "..\ve\clifor.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define LARG_COLCODICE 49
|
||||||
|
#define POS_PRIMACOL 51
|
||||||
|
#define PICTURE_VALORI "###.###.###.##@"
|
||||||
|
#define LARG_COLVAL 16
|
||||||
|
#define PICTURE_QUANTITA "###.###.##@,@##"
|
||||||
|
#define LARG_COLQTA 16
|
||||||
|
#define PICTURE_PERCENT "###@,@"
|
||||||
|
#define LARG_COLPERC 8
|
||||||
|
|
||||||
|
#define PICTURE (selmask().get(F_TIPODATO)[0] =='V'? PICTURE_VALORI:PICTURE_QUANTITA)
|
||||||
|
|
||||||
|
|
||||||
|
#define FORMWIDTH 150
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TPeriodo
|
// TPeriodo
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -295,7 +309,7 @@ class TStampa_stat : public TPrint_application
|
|||||||
{
|
{
|
||||||
enum { MAX_ROWS = 8 }; // numero massimo di raggruppamenti
|
enum { MAX_ROWS = 8 }; // numero massimo di raggruppamenti
|
||||||
|
|
||||||
enum { LINEA_DATI='D', LINEA_CONFRONTI='C', LINEA_TARGET='T'}; // codici per le righe
|
enum { LINEA_DATI='D', LINEA_RAFFRONTI='R', LINEA_TARGET='T'}; // codici per le righe
|
||||||
|
|
||||||
TMask * _msk,*_print_msk;
|
TMask * _msk,*_print_msk;
|
||||||
|
|
||||||
@ -306,7 +320,7 @@ class TStampa_stat : public TPrint_application
|
|||||||
TRecord_cache *_magazz,*_tipodoc,*_catven,*_zone,*_ums;
|
TRecord_cache *_magazz,*_tipodoc,*_catven,*_zone,*_ums;
|
||||||
TLocalisamfile * _umart,*_anamag,*_clifor,*_agenti;
|
TLocalisamfile * _umart,*_anamag,*_clifor,*_agenti;
|
||||||
|
|
||||||
TLocalisamfile * _outstat;
|
//TLocalisamfile * _outstat;
|
||||||
|
|
||||||
TToken_string _key;
|
TToken_string _key;
|
||||||
TString _last_key;
|
TString _last_key;
|
||||||
@ -314,14 +328,25 @@ class TStampa_stat : public TPrint_application
|
|||||||
|
|
||||||
bool _ragg_per_um;
|
bool _ragg_per_um;
|
||||||
|
|
||||||
TStat_cache * _cache;
|
TStat_cache * _cache; // cache R/W per le statistiche
|
||||||
|
|
||||||
int _last_lev_grp;
|
int _last_lev_grp, // livello dell'ultimo raggruppamento incontrato
|
||||||
TArray _group_recs;
|
_liv_riga; // livello della riga
|
||||||
|
TArray _group_recs; // array dei record dei raggruppamenti
|
||||||
|
int _indent[MAX_ROWS];// array delle posizione di indentazione
|
||||||
|
real _tot_riga[SVS_NUMCOLONNE]; //array dei totali degli "anni" della riga
|
||||||
|
int _colpage, // numero di pagina ripetuta per contenere in larghezza tutte le colonne
|
||||||
|
_last_page; // ultima pagina della "prima copia"
|
||||||
|
int _largcol, // larghezza di una colonna
|
||||||
|
_numcol_dati, // numero di colonne contenenti dati
|
||||||
|
_numcol, // numero totale di colonne (dati+totali)
|
||||||
|
_pagewidth, // larghezza di una pagina
|
||||||
|
_col_anno ; // numero di colonne che formano un "Anno" (=periodo di rif.)
|
||||||
|
bool _st_totr; // flag stampa totali di riga
|
||||||
|
bool _st_totc; // flag stampa totali di colonna
|
||||||
|
static TString s_park; // stringa di lavoro
|
||||||
|
TString wrk_row; // stringa di lavoro per le righe di stampa
|
||||||
private:
|
private:
|
||||||
const TString& partkey_name(const char *lev_code) ;
|
|
||||||
const TString& get_part(const char *lev_code, TSVriep_record & rieprec) const;
|
|
||||||
const TString& get_descrpart(const char *lev_code, TSVriep_record &rieprec);
|
|
||||||
|
|
||||||
void set_ragg_per_um();
|
void set_ragg_per_um();
|
||||||
|
|
||||||
@ -355,14 +380,21 @@ protected:
|
|||||||
virtual bool user_destroy();
|
virtual bool user_destroy();
|
||||||
virtual bool set_print(int i);
|
virtual bool set_print(int i);
|
||||||
virtual void set_page(int file, int count);
|
virtual void set_page(int file, int count);
|
||||||
|
|
||||||
|
virtual print_action postprocess_print(int file, int counter);
|
||||||
virtual bool preprocess_page(int file, int counter);
|
virtual bool preprocess_page(int file, int counter);
|
||||||
virtual print_action postprocess_page(int file, int counter);
|
virtual print_action postprocess_page(int file, int counter);
|
||||||
virtual void preprocess_header();
|
virtual void preprocess_header();
|
||||||
virtual void preprocess_footer();
|
virtual void preprocess_footer();
|
||||||
|
virtual void postclose_print() ;
|
||||||
|
|
||||||
virtual void on_config_change();
|
virtual void on_config_change();
|
||||||
|
|
||||||
void set_rows_colonne(int &row, TString & r, TRectype &strec);
|
int handle_levchange(int row,const int level);
|
||||||
|
int set_header_colonne(int row);
|
||||||
|
int set_rows_colonne(int row, TRectype &strec);
|
||||||
|
void set_row_atpos(char section,int row,const char * f,int pos);
|
||||||
|
void reset_grplevels();
|
||||||
|
|
||||||
bool test_field(const TString& cod, TMask_field& f) const;
|
bool test_field(const TString& cod, TMask_field& f) const;
|
||||||
|
|
||||||
@ -374,184 +406,431 @@ protected:
|
|||||||
bool recalc_period();
|
bool recalc_period();
|
||||||
|
|
||||||
TString& build_key(const TRectype& rec);
|
TString& build_key(const TRectype& rec);
|
||||||
|
|
||||||
|
|
||||||
|
const TString& nome_colonna1(int c);
|
||||||
|
const TString& nome_colonna2(int c);
|
||||||
|
const TString& nome_totale(int t);
|
||||||
|
const TString& partkey_name(const char *lev_code) ;
|
||||||
|
const TString& get_part(TString & lev_code, TSVriep_record & rieprec) const;
|
||||||
|
const TString& get_descrpart(const char *lev_code, TSVriep_record &rieprec);
|
||||||
|
void adjust_record(TRectype &strec, int from) const;
|
||||||
|
const int numlevels()
|
||||||
|
{return selmask().sfield(F_CHIAVE).items();}
|
||||||
public:
|
public:
|
||||||
TMask& selmask() { return *_msk; }
|
TMask& selmask() { return *_msk; }
|
||||||
TMask& printmask() { return *_print_msk; }
|
TMask& printmask() { return *_print_msk; }
|
||||||
virtual bool menu(MENU_TAG);
|
virtual bool menu(MENU_TAG);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TString TStampa_stat::s_park(' ',25); //
|
||||||
|
|
||||||
inline TStampa_stat& app() { return (TStampa_stat&)main_app(); }
|
inline TStampa_stat& app() { return (TStampa_stat&)main_app(); }
|
||||||
|
|
||||||
|
print_action TStampa_stat::postprocess_print(int file, int count)
|
||||||
|
{
|
||||||
|
reset_footer();
|
||||||
|
reset_header();
|
||||||
|
_last_page=get_page_number();
|
||||||
|
_colpage++;
|
||||||
|
//printer().formfeed();
|
||||||
|
return TPrint_application::postprocess_print(file,count);
|
||||||
|
}
|
||||||
bool TStampa_stat::preprocess_page(int file, int count)
|
bool TStampa_stat::preprocess_page(int file, int count)
|
||||||
{
|
{
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
return TPrint_application::preprocess_page(file,count);
|
return TPrint_application::preprocess_page(file,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_action TStampa_stat::postprocess_page(int file, int count)
|
print_action TStampa_stat::postprocess_page(int file, int count)
|
||||||
{
|
{
|
||||||
if (!file)
|
reset_print();
|
||||||
{
|
|
||||||
return (_outstat->next()==NOERR) ? REPEAT_PAGE : NEXT_PAGE;
|
|
||||||
}
|
|
||||||
return TPrint_application::postprocess_page(file,count);
|
return TPrint_application::postprocess_page(file,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TStampa_stat::set_print(int i)
|
bool TStampa_stat::set_print(int i)
|
||||||
{
|
{
|
||||||
_outstat->first();
|
|
||||||
bool ok=printmask().run() != K_QUIT;
|
bool ok=printmask().run() != K_QUIT;
|
||||||
|
|
||||||
|
_st_totr=printmask().get_bool(F_STTOTALIRIGA);
|
||||||
|
_st_totc=printmask().get_bool(F_STTOTALICOL);
|
||||||
|
_col_anno =selmask().get_int(F_COL_ANNO); //numero di colonne che formano un "Anno"
|
||||||
|
_largcol = (_st_totr ? LARG_COLPERC : 0 ) + (selmask().get(F_TIPODATO)[0]=='V' ? LARG_COLVAL : LARG_COLQTA); // valori o quantità
|
||||||
|
_numcol_dati = selmask().get_int(F_PERIODO);
|
||||||
|
_numcol = _numcol_dati+int((_numcol_dati -1)/_col_anno+1);
|
||||||
|
_pagewidth=POS_PRIMACOL+int((FORMWIDTH-POS_PRIMACOL)/_largcol)*_largcol;
|
||||||
|
|
||||||
|
// reset delle variabili per la gestione di gruppi ai vari livelli
|
||||||
|
_colpage=1;
|
||||||
|
_last_page=0;
|
||||||
|
reset_grplevels();
|
||||||
|
// setta header e footer
|
||||||
|
int row=0;
|
||||||
|
|
||||||
|
reset_header();
|
||||||
|
reset_footer();
|
||||||
|
printer().footerlen(2);
|
||||||
|
|
||||||
return (ok);
|
return (ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LARG_COLCODICE 49
|
int TStampa_stat::set_header_colonne(int row) // to remove
|
||||||
#define POS_PRIMACOL 50
|
{
|
||||||
#define PICTURE_VALORI "###.###.###.###"
|
return 0;
|
||||||
#define LARG_COLVAL 16
|
}
|
||||||
#define PICTURE_QUANTITA "###.###.###,###"
|
|
||||||
#define LARG_COLQTA 16
|
|
||||||
#define PICTURE_PERCENT "###.###.###,##"
|
|
||||||
#define LARG_COLPERC 7
|
|
||||||
|
|
||||||
#define PICTURE (*selmask().get(F_TIPODATO)=='V'? PICTURE_VALORI:PICTURE_QUANTITA)
|
void TStampa_stat::postclose_print()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TStampa_stat::preprocess_footer()
|
||||||
|
{
|
||||||
|
wrk_row.fill('_',_pagewidth);
|
||||||
|
set_row_atpos('F',1,wrk_row,0);
|
||||||
|
wrk_row.format("Pagina @#",get_page_number()-_last_page*(_colpage-1));
|
||||||
|
set_row_atpos('F',2,wrk_row,(_colpage-1)*_pagewidth+(_pagewidth-9)/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TStampa_stat::preprocess_header()
|
||||||
|
{
|
||||||
|
int bkg=0,row=0,lastrow;
|
||||||
|
|
||||||
|
// *****************
|
||||||
|
// header
|
||||||
|
set_header(++row,"");
|
||||||
|
if (selmask().get(F_DESCR).empty())
|
||||||
|
set_row_atpos('H',++row,"@bStampa statistiche ",0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wrk_row.format("@bStampa statistica '%s'",(const char *)selmask().get(F_DESCR));
|
||||||
|
set_row_atpos('H',++row,(const char *)wrk_row,0);
|
||||||
|
wrk_row.format("dal %s al %s ",(const char *)selmask().get(F_DATAINI),(const char *)selmask().get(F_DATAFIN));
|
||||||
|
set_row_atpos('H',row,(const char *)wrk_row,40);
|
||||||
|
}
|
||||||
|
set_header(++row,"");
|
||||||
|
set_row_atpos('H',++row," Codice Descrizione",0);
|
||||||
|
lastrow=row;
|
||||||
|
for (int c=0; c < _numcol; c++) // colonne
|
||||||
|
{
|
||||||
|
if (_st_totr && (((c)%_col_anno)==0 || c== _numcol_dati) )
|
||||||
|
{
|
||||||
|
set_row_atpos('H',row,nome_totale(int(c/_col_anno)),POS_PRIMACOL+c*_largcol+_largcol/2 );
|
||||||
|
} else {
|
||||||
|
wrk_row=nome_colonna1(c);
|
||||||
|
set_row_atpos('H',row,wrk_row,POS_PRIMACOL+c*_largcol+(_largcol-wrk_row.len())/2 );
|
||||||
|
wrk_row=nome_colonna2(c);
|
||||||
|
if (wrk_row.not_empty())
|
||||||
|
{
|
||||||
|
lastrow=row+1;
|
||||||
|
set_row_atpos('H',row+1,wrk_row,POS_PRIMACOL+c*_largcol+(_largcol-wrk_row.len())/2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_st_totr)
|
||||||
|
{
|
||||||
|
lastrow=row+1;
|
||||||
|
set_row_atpos('H',row+1," Perc.",POS_PRIMACOL+(c+1)*_largcol-LARG_COLPERC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row=lastrow;
|
||||||
|
set_header(++row,"");
|
||||||
|
// *****************
|
||||||
|
// background
|
||||||
|
wrk_row.format("P0W1l(1,1,%d,1)l(1,3,%d,3)l(1,%d,%d,%d)",_pagewidth,_pagewidth,row,_pagewidth,row);
|
||||||
|
row++;
|
||||||
|
for (c=0; c < _numcol; c++) // colonne
|
||||||
|
{
|
||||||
|
// background
|
||||||
|
//wrk_row << "l(" << POS_PRIMACOL+c*_largcol << ",4," ;
|
||||||
|
//wrk_row << POS_PRIMACOL+c*_largcol << ',' << (int)printer().rows() << ')';
|
||||||
|
}
|
||||||
|
set_background(wrk_row);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TString& TStampa_stat::nome_colonna1(int c)
|
||||||
|
{
|
||||||
|
const TDate din=selmask().get(F_DATAINI); // data iniziale
|
||||||
|
const char code_freq=selmask().get(F_MULTIPLO)[0];
|
||||||
|
const int numero=selmask().get_int(F_NUMERO); // numero di periodi in una col
|
||||||
|
const TFrequenza_statistiche freq = char2frequency(code_freq);
|
||||||
|
const int start=date2period(din,freq); // periodo della prima colonna
|
||||||
|
const int lastp=last_period(din,freq); // numero di periodi in un anno
|
||||||
|
|
||||||
|
if (code_freq==selmask().get(F_FREQUENZA)[0])
|
||||||
|
{
|
||||||
|
// numerico; può essere un qualsiasi multiplo della freq
|
||||||
|
s_park.format("%s %d-%d %d",(const char *)char2freqname(code_freq),1+(start+c*numero-1)%lastp , 1+(start+(c+1)*numero-2)%lastp,din.year());
|
||||||
|
} else {
|
||||||
|
switch (code_freq)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
s_park.format("%d^%s",1+(start+c-1)%lastp,(const char *)char2freqname(code_freq));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s_park;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TString& TStampa_stat::nome_colonna2(int c)
|
||||||
|
{
|
||||||
|
const TDate din=selmask().get(F_DATAINI); // data iniziale
|
||||||
|
const char code_freq=selmask().get(F_MULTIPLO)[0];
|
||||||
|
const TFrequenza_statistiche freq = char2frequency(code_freq);
|
||||||
|
const int lastp=last_period(din,freq); // numero di periodi in un anno
|
||||||
|
const int start=date2period(din,freq); // periodo della prima colonna
|
||||||
|
s_park="";
|
||||||
|
{
|
||||||
|
switch (code_freq)
|
||||||
|
{
|
||||||
|
case 'G': // giorno
|
||||||
|
case 'A': // anno
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
s_park.format(" anno %d",din.year()+int((start+c-1)/lastp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s_park;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TString& TStampa_stat::nome_totale(int c)
|
||||||
|
{
|
||||||
|
s_park = "Totale ";
|
||||||
|
s_park << c+1;
|
||||||
|
return s_park;
|
||||||
|
}
|
||||||
|
|
||||||
void TStampa_stat::set_page(int file, int count)
|
void TStampa_stat::set_page(int file, int count)
|
||||||
{
|
{
|
||||||
// prepara la pagina di stampa
|
// prepara la pagina di stampa
|
||||||
const int max_rows=selmask().sfield(F_CHIAVE).items();
|
TRectype & strec=current_cursor()->curr();
|
||||||
TRectype & strec=_outstat->curr();
|
|
||||||
const int level=strec.get_int(SVS_LIVELLO);
|
const int level=strec.get_int(SVS_LIVELLO);
|
||||||
|
|
||||||
TString r;
|
|
||||||
int row=0;
|
int row=0;
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// gestione totali di raggruppamento
|
// gestione totali di raggruppamento
|
||||||
while (level!=max_rows && level>_last_lev_grp)
|
row = handle_levchange(row, level);
|
||||||
{
|
|
||||||
// ho lasciato un livello "basso"
|
|
||||||
TRectype & rec_grp1=(TRectype &)_group_recs[_last_lev_grp+1];
|
|
||||||
TRectype & rec_grp2=(TRectype &)_group_recs[_last_lev_grp+2];
|
|
||||||
const int lencode=rec_grp2.get(SVS_CODICE).len();
|
|
||||||
r << "@" << (max_rows-_last_lev_grp)*2 <<"g";
|
|
||||||
r << "Totale " << partkey_name(rec_grp1.get(SVS_LEVCODE));
|
|
||||||
r << " " << rec_grp1.get(SVS_CODICE).mid(lencode);
|
|
||||||
set_rows_colonne(row, r ,rec_grp1);
|
|
||||||
_last_lev_grp++;
|
|
||||||
r = "";
|
|
||||||
}
|
|
||||||
if (_last_lev_grp!=strec.get_int(SVS_LIVELLO))
|
|
||||||
_last_lev_grp=strec.get_int(SVS_LIVELLO);
|
|
||||||
if (level>0)
|
if (level>0)
|
||||||
{
|
{
|
||||||
// salva i record dei livelli di raggruppamento
|
// salva i record dei livelli di raggruppamento
|
||||||
if (level==max_rows)
|
if (level==numlevels())
|
||||||
strec.put(SVS_CODICE,"");
|
strec.put(SVS_CODICE,"");
|
||||||
_group_recs.add(strec,level);
|
_group_recs.add(strec,level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************
|
// *****************
|
||||||
// gestione delle "righe"
|
// gestione delle "righe"
|
||||||
if (level != max_rows && *strec.get(SVS_TIPO)==LINEA_DATI)
|
if (level != numlevels() &&
|
||||||
|
printmask().get_bool(F_FLAGSTOTALI+numlevels()-level))
|
||||||
|
{
|
||||||
|
TString r;
|
||||||
|
|
||||||
|
switch (*strec.get(SVS_TIPO))
|
||||||
|
{
|
||||||
|
case LINEA_DATI:
|
||||||
|
if (level >= _liv_riga)
|
||||||
{
|
{
|
||||||
TRectype & _rec_grp=(TRectype &)_group_recs[level+1];
|
TRectype & _rec_grp=(TRectype &)_group_recs[level+1];
|
||||||
const int lencode=_rec_grp.get(SVS_CODICE).len();
|
const int lencode=_rec_grp.get(SVS_CODICE).len();
|
||||||
r << "@" << (max_rows-level)*2 <<"g";
|
adjust_record(strec,lencode);
|
||||||
r << partkey_name(strec.get(SVS_LEVCODE));
|
r << TString(partkey_name(strec.get(SVS_LEVCODE))).upper(0,0);
|
||||||
r << " " << strec.get(SVS_CODICE).mid(lencode);
|
r << ' ' << strec.get(SVS_CODICE).mid(lencode);
|
||||||
if (level==0)
|
r << ' ' << strec.get(SVS_DESCR);
|
||||||
{
|
set_row_atpos('R',++row,(const char *)r,_indent[level]);
|
||||||
set_rows_colonne(row, r,strec);
|
}
|
||||||
} else {
|
if (level == _liv_riga)
|
||||||
reset_row(++row);
|
row = set_rows_colonne(row, strec);
|
||||||
set_row(row,(const char *)r);
|
break;
|
||||||
|
case LINEA_RAFFRONTI:
|
||||||
|
if (printmask().get_bool(F_STRAFFRONTO))
|
||||||
|
if (level == _liv_riga)
|
||||||
|
row = set_rows_colonne(++row, strec);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// *****************
|
// *****************
|
||||||
// separatore di righe
|
// totale generale e break di livello
|
||||||
if (printmask().get_bool(F_STRAFFRONTO))
|
if (current_cursor()->pos() == current_cursor()->items()-1)
|
||||||
{
|
{
|
||||||
reset_row(++row);
|
handle_levchange(row, numlevels());
|
||||||
set_row(row,"");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fa le set row per la "riga" contenente i valori delle colonne di statistica
|
// fa le set row per la "riga" contenente i valori delle colonne di statistica
|
||||||
void TStampa_stat::set_rows_colonne(int &row,TString & r, TRectype &strec)
|
int TStampa_stat::set_rows_colonne(int row,TRectype &strec)
|
||||||
{
|
{
|
||||||
//**********
|
static TRectype last_data(LF_SVSTAT);
|
||||||
// setta le colonne
|
TString colname,r_totc;
|
||||||
TString colname,r1;
|
real col_value;
|
||||||
int largcolonna = *selmask().get(F_TIPODATO)=='V' ? LARG_COLVAL : LARG_COLQTA; // valori o quantità
|
bool aggiungi_perc=TRUE;
|
||||||
const int max_rows=selmask().sfield(F_CHIAVE).items();
|
int col=0; // contatore di colonna corrente
|
||||||
const bool sttotriga=printmask().get_bool(F_STTOTALIRIGA);
|
int position; // posizione fisica della colonna corrente
|
||||||
const int numcolonne = selmask().get_bool(F_PERIODO);
|
// **********
|
||||||
for (int col=0; col < numcolonne; col++) // colonne
|
// setta i totali di colonne
|
||||||
|
if (strec.get_char(SVS_TIPO)==LINEA_DATI ||
|
||||||
|
strec.get_char(SVS_TIPO)==LINEA_RAFFRONTI && printmask().get(F_TIPORAFFRONTO)[0]==AS_VALUE)
|
||||||
{
|
{
|
||||||
colname << SVS_COLNAME << col;
|
for (col=0; col < _numcol_dati; col++)
|
||||||
r << "@" << POS_PRIMACOL+col*(sttotriga ? largcolonna+LARG_COLPERC : largcolonna) <<"g";
|
{
|
||||||
r1=r;
|
colname =SVS_COLNAME;
|
||||||
switch (*printmask().get(F_TIPORAFFRONTO))
|
colname << col;
|
||||||
|
if (col%_col_anno==0)
|
||||||
|
_tot_riga[int(col/_col_anno)]=0;
|
||||||
|
_tot_riga[int(col/_col_anno)]+=strec.get_real(colname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// **********
|
||||||
|
// setta le colonne
|
||||||
|
col=0;
|
||||||
|
for (int c=0; c < _numcol_dati; c++)
|
||||||
|
{
|
||||||
|
colname =SVS_COLNAME;
|
||||||
|
colname << c;
|
||||||
|
position = POS_PRIMACOL+col*_largcol;
|
||||||
|
switch (strec.get_char(SVS_TIPO))
|
||||||
|
{
|
||||||
|
case LINEA_DATI:
|
||||||
|
last_data=strec;
|
||||||
|
set_row_atpos('R',row,strec.get_real(colname).string(PICTURE),position);
|
||||||
|
break;
|
||||||
|
case LINEA_RAFFRONTI:
|
||||||
|
switch (printmask().get(F_TIPORAFFRONTO)[0])
|
||||||
{
|
{
|
||||||
case AS_VALUE:
|
case AS_VALUE:
|
||||||
r << strec.get_real(colname).string(PICTURE);
|
set_row_atpos('R',row, strec.get_real(colname).string(PICTURE),position);
|
||||||
break;
|
break;
|
||||||
case AS_DIFF:
|
case AS_DIFF:
|
||||||
r << strec.get_real(colname).string(PICTURE);
|
r_totc= "+";
|
||||||
|
r_totc << PICTURE;
|
||||||
|
set_row_atpos('R',row,real(last_data.get_real(colname)-strec.get_real(colname)).string(r_totc),position);
|
||||||
break;
|
break;
|
||||||
|
//?!?! aggiungi_perc=FALSE;
|
||||||
case AS_PERC:
|
case AS_PERC:
|
||||||
r << strec.get_real(colname).string(PICTURE_PERCENT);
|
position = POS_PRIMACOL+col*_largcol+(_largcol-LARG_COLPERC);
|
||||||
|
if (!strec.get_real(colname).is_zero())
|
||||||
|
set_row_atpos('R',row,real(100*last_data.get_real(colname)/strec.get_real(colname)).string(PICTURE_PERCENT),position);
|
||||||
|
aggiungi_perc=FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LINEA_TARGET: // v2.0
|
||||||
|
set_row_atpos('R',row,strec.get_real(colname).string(PICTURE),position);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// colonna con la percentuale rispetto al totale di riga
|
// colonna con la percentuale rispetto al totale di riga
|
||||||
if (sttotriga)
|
if (_st_totr && aggiungi_perc && !_tot_riga[int(c/_col_anno)].is_zero())
|
||||||
{
|
{
|
||||||
r << "@" << POS_PRIMACOL+col*(largcolonna+LARG_COLPERC)+largcolonna <<"g";
|
set_row_atpos('R',row,real(strec.get_real(colname)/_tot_riga[int(c/_col_anno)]*100.0).string(PICTURE_PERCENT),POS_PRIMACOL+(col+1)*_largcol-LARG_COLPERC);
|
||||||
r << real(strec.get_real(colname)/strec.get_real(SVS_TOTALERIGA)*100.0).string(PICTURE_PERCENT);
|
|
||||||
r << "%%";
|
|
||||||
}
|
}
|
||||||
// riga con i totali di colonna
|
// riga con i totali di colonna
|
||||||
if (printmask().get_bool(F_STTOTALICOL))
|
if (_st_totc && aggiungi_perc )
|
||||||
{
|
{
|
||||||
TRectype & _rec_totale=(TRectype &)_group_recs[max_rows];
|
TRectype & _rec_totale=(TRectype &)_group_recs[numlevels()];
|
||||||
if (!_rec_totale.get_real(colname).is_zero())
|
if (!_rec_totale.get_real(colname).is_zero())
|
||||||
{
|
{
|
||||||
r1 << real(strec.get_real(colname)/_rec_totale.get_real(colname)*100.0).string(PICTURE_PERCENT);
|
r_totc=real(strec.get_real(colname)/_rec_totale.get_real(colname)*100.0).string(PICTURE_PERCENT);
|
||||||
r1 << "%%";
|
set_row_atpos('R',row+1,(const char *)r_totc,POS_PRIMACOL+col*_largcol+_largcol-LARG_COLPERC);
|
||||||
|
} else {
|
||||||
|
// aggiunge comunque una riga vuota per la spaziatura
|
||||||
|
set_row_atpos('R',row+1,"",0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// colonna con il totale di un "anno"
|
||||||
// colonna totale di riga
|
if (_st_totr && aggiungi_perc && (((c+1)%_col_anno)==0 || c== _numcol_dati-1))
|
||||||
if (sttotriga)
|
|
||||||
{
|
{
|
||||||
r << "@" << POS_PRIMACOL+numcolonne*(largcolonna+LARG_COLPERC) <<"g";
|
col++;
|
||||||
r << strec.get_real(SVS_TOTALERIGA).string(PICTURE);
|
set_row_atpos('R',row,(const char *)_tot_riga[int(c/_col_anno)].string(PICTURE),POS_PRIMACOL+col*_largcol);
|
||||||
r << "@" << POS_PRIMACOL+numcolonne*(largcolonna+LARG_COLPERC)+largcolonna <<"g";
|
set_row_atpos('R',row,(const char *)real(100).string(PICTURE_PERCENT),POS_PRIMACOL+col*_largcol+_largcol-LARG_COLPERC);
|
||||||
r << real(100).string(PICTURE_PERCENT);
|
|
||||||
r << "%%";
|
|
||||||
}
|
}
|
||||||
// *****************
|
col++;
|
||||||
// stampa la riga
|
}
|
||||||
reset_row(++row);
|
if (_st_totc)
|
||||||
set_row(row,(const char *)r);
|
++row;
|
||||||
// *****************
|
return row;
|
||||||
// stampa totale di colonna
|
}
|
||||||
if (printmask().get_bool(F_STTOTALICOL))
|
|
||||||
|
// fa le set row per la "riga" contenente i valori delle colonne di statistica
|
||||||
|
void TStampa_stat::set_row_atpos(char section,int row,const char * f,int pos)
|
||||||
|
{
|
||||||
|
static TString256 ss;
|
||||||
|
int l=strlen(f);
|
||||||
|
ss.cut(0);
|
||||||
|
if (pos <= _colpage*_pagewidth)
|
||||||
{
|
{
|
||||||
reset_row(++row);
|
const int firstpos=(_colpage-1)*_pagewidth;
|
||||||
set_row(row,(const char *)r1);
|
if (pos+l >= firstpos)
|
||||||
|
{
|
||||||
|
// there's something to print in this page!
|
||||||
|
if (pos+l > _colpage*_pagewidth)
|
||||||
|
{
|
||||||
|
l=_colpage*_pagewidth-pos;
|
||||||
|
repeat_print();
|
||||||
|
}
|
||||||
|
ss.format("@%03dg",max(pos, firstpos ) % _pagewidth);
|
||||||
|
if (pos< firstpos)
|
||||||
|
ss.overwrite(f+firstpos-pos,5);
|
||||||
|
else
|
||||||
|
ss.overwrite(f,5);
|
||||||
|
ss.cut(5+l); // !?!? this cause trouble if special couples are used at the middle of the string:
|
||||||
|
// "@b" or "%%" can be split into two non-significant chars
|
||||||
|
}
|
||||||
|
//else : too much to the left: already printed!
|
||||||
|
}
|
||||||
|
else //: too much to the right: will be printed next time!
|
||||||
|
repeat_print();
|
||||||
|
switch (section)
|
||||||
|
{
|
||||||
|
case 'R': set_row(row,ss); break;
|
||||||
|
case 'H': set_header(row,ss); break;
|
||||||
|
case 'F': set_footer(row,ss); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stampa i totali ad ogni break di livello
|
||||||
|
int TStampa_stat::handle_levchange(int row,const int level)
|
||||||
|
{
|
||||||
|
while (level>_last_lev_grp)
|
||||||
|
{
|
||||||
|
// ho lasciato un livello "basso"
|
||||||
|
_last_lev_grp++;
|
||||||
|
if (_last_lev_grp > _liv_riga && printmask().get_bool(F_FLAGSTOTALI+numlevels()-_last_lev_grp))
|
||||||
|
{
|
||||||
|
TRectype & rec_grp1=(TRectype &)_group_recs[_last_lev_grp];
|
||||||
|
int lencode=0;
|
||||||
|
if (_last_lev_grp < numlevels())
|
||||||
|
{
|
||||||
|
TRectype & rec_grp2=(TRectype &)_group_recs[_last_lev_grp+1];
|
||||||
|
lencode=rec_grp2.get(SVS_CODICE).len();
|
||||||
|
}
|
||||||
|
adjust_record(rec_grp1,lencode);
|
||||||
|
wrk_row.fill('-',_largcol*_numcol);
|
||||||
|
set_row_atpos('R',++row,(const char *)wrk_row,POS_PRIMACOL);
|
||||||
|
wrk_row ="Totale ";
|
||||||
|
wrk_row << partkey_name(rec_grp1.get(SVS_LEVCODE));
|
||||||
|
wrk_row << ' ' << rec_grp1.get(SVS_CODICE).mid(lencode);
|
||||||
|
wrk_row << ' ' << rec_grp1.get(SVS_DESCR);
|
||||||
|
//wrk_row.cut(LARG_COLCODICE); there are also @ chars!
|
||||||
|
set_row_atpos('R',++row,(const char *)wrk_row,_indent[_last_lev_grp]);
|
||||||
|
row = set_rows_colonne(row, rec_grp1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_last_lev_grp!=level)
|
||||||
|
_last_lev_grp=level;
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
void TStampa_stat::preprocess_header()
|
void TStampa_stat::reset_grplevels()
|
||||||
{}
|
{
|
||||||
|
_last_lev_grp=numlevels();
|
||||||
void TStampa_stat::preprocess_footer()
|
_group_recs.destroy();
|
||||||
{}
|
int pos=0;
|
||||||
|
for (int l=0; l <=numlevels() ; l++)
|
||||||
|
{
|
||||||
|
if (printmask().get_bool(F_FLAGSTOTALI+l))
|
||||||
|
{
|
||||||
|
_indent[numlevels()-l]=2*pos++;
|
||||||
|
_liv_riga=numlevels()-l;
|
||||||
|
} else
|
||||||
|
_indent[numlevels()-l]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TStampa_stat::user_create()
|
bool TStampa_stat::user_create()
|
||||||
@ -568,10 +847,12 @@ bool TStampa_stat::user_create()
|
|||||||
_msk->set_handler(F_DATARAF, dataraf_handler);
|
_msk->set_handler(F_DATARAF, dataraf_handler);
|
||||||
_msk->set_handler(F_CHIAVE, chiave_handler);
|
_msk->set_handler(F_CHIAVE, chiave_handler);
|
||||||
_msk->sfield(F_CHIAVE).set_notify(chiave_notify);
|
_msk->sfield(F_CHIAVE).set_notify(chiave_notify);
|
||||||
|
|
||||||
TMask& sm = _msk->sfield(F_CHIAVE).sheet_mask();
|
TMask& sm = _msk->sfield(F_CHIAVE).sheet_mask();
|
||||||
sm.set_handler(S_CAMPO, campo_handler);
|
sm.set_handler(S_CAMPO, campo_handler);
|
||||||
|
|
||||||
|
_print_msk= new TMask("sv1200b");
|
||||||
|
|
||||||
|
// files
|
||||||
_files.add(new TLocalisamfile(LF_SVRIEP));
|
_files.add(new TLocalisamfile(LF_SVRIEP));
|
||||||
_files.add(new TLocalisamfile(LF_SVSTAT));
|
_files.add(new TLocalisamfile(LF_SVSTAT));
|
||||||
|
|
||||||
@ -592,13 +873,13 @@ bool TStampa_stat::user_create()
|
|||||||
_clifor = new TLocalisamfile(LF_CLIFO);
|
_clifor = new TLocalisamfile(LF_CLIFO);
|
||||||
_agenti = new TLocalisamfile(LF_AGENTI);
|
_agenti = new TLocalisamfile(LF_AGENTI);
|
||||||
|
|
||||||
_outstat = new TLocalisamfile(LF_SVSTAT);
|
//_outstat = new TLocalisamfile(LF_SVSTAT);
|
||||||
// cursore di stampa
|
// cursore di stampa
|
||||||
add_file(LF_SVSTAT);
|
add_file(LF_SVSTAT);
|
||||||
//add_cursor(new TCursor(new TRelation(LF_SVSTAT)));
|
add_cursor(new TCursor(new TRelation(LF_SVSTAT)));
|
||||||
|
|
||||||
// impone force setpage
|
// impone force setpage
|
||||||
force_setpage();
|
//force_setpage();
|
||||||
set_real_picture("");
|
set_real_picture("");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -607,7 +888,7 @@ bool TStampa_stat::user_create()
|
|||||||
bool TStampa_stat::user_destroy()
|
bool TStampa_stat::user_destroy()
|
||||||
{
|
{
|
||||||
delete _msk;
|
delete _msk;
|
||||||
if (_print_msk) delete _print_msk;
|
delete _print_msk;
|
||||||
|
|
||||||
delete _liv_art;
|
delete _liv_art;
|
||||||
delete _liv_giac;
|
delete _liv_giac;
|
||||||
@ -619,7 +900,7 @@ bool TStampa_stat::user_destroy()
|
|||||||
delete _anamag;
|
delete _anamag;
|
||||||
delete _clifor;
|
delete _clifor;
|
||||||
delete _agenti;
|
delete _agenti;
|
||||||
delete _outstat;
|
//delete _outstat;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,20 +1036,20 @@ void TStampa_stat::set_frequency()
|
|||||||
default :break;
|
default :break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString tmp;
|
//TString tmp;
|
||||||
for (const char* cod = codes.get(0); cod; cod = codes.get())
|
for (const char* cod = codes.get(0); cod; cod = codes.get())
|
||||||
{
|
{
|
||||||
tmp = cod;
|
//tmp = cod;
|
||||||
const int pos = std_codes.get_pos(tmp);
|
//const int pos = std_codes.get_pos(tmp);
|
||||||
CHECK(pos >= 0, "Invalid frequency char");
|
//CHECK(pos >= 0, "Invalid frequency char");
|
||||||
tmp = std_descr.get(pos);
|
//std_descr.get(pos);
|
||||||
descr.add(tmp);
|
descr.add(char2freqname(cod[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
multiplo.replace_items(codes, descr);
|
multiplo.replace_items(codes, descr);
|
||||||
|
|
||||||
// setta la durata dell'anno
|
// setta la durata dell'anno
|
||||||
m.set(F_COL_ANNO, last_period(1992,_stats.frequency()));
|
//m.set(F_COL_ANNO, last_period(1992,_stats.frequency()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,14 +1106,16 @@ TString& TStampa_stat::build_key(const TRectype& rec)
|
|||||||
return _last_key;
|
return _last_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TStampa_stat::update_file(const char * key, const char *lev_code,const char tipo, const int level, const int col, TSVriep_record& curr)
|
void TStampa_stat::update_file(const char * key, const char *lev_code,const char tipo_dato, const int level, const int col, TSVriep_record& curr)
|
||||||
{
|
{
|
||||||
CHECK(col>=0,"Le colonne partono da 0");
|
CHECK(col>=0,"Le colonne partono da 0");
|
||||||
|
|
||||||
static TRectype statrec(LF_SVSTAT);
|
static TRectype statrec(LF_SVSTAT);
|
||||||
TToken_string cachekey(key);
|
TToken_string cachekey(key);
|
||||||
cachekey.rtrim();
|
cachekey.rtrim(); // necessario perché la chiave sia buona per l'hash table
|
||||||
cachekey.add(tipo);
|
if (cachekey.blank())
|
||||||
|
cachekey.add(" ");
|
||||||
|
cachekey.add(tipo_dato);
|
||||||
statrec = _cache->get(cachekey);
|
statrec = _cache->get(cachekey);
|
||||||
if (_cache->io_result()!=NOERR)
|
if (_cache->io_result()!=NOERR)
|
||||||
{
|
{
|
||||||
@ -840,12 +1123,12 @@ void TStampa_stat::update_file(const char * key, const char *lev_code,const char
|
|||||||
statrec.put(SVS_CODICE,key);
|
statrec.put(SVS_CODICE,key);
|
||||||
statrec.put(SVS_LEVCODE,lev_code);
|
statrec.put(SVS_LEVCODE,lev_code);
|
||||||
statrec.put(SVS_LIVELLO,level);
|
statrec.put(SVS_LIVELLO,level);
|
||||||
statrec.put(SVS_TIPO,tipo);
|
statrec.put(SVS_TIPO,tipo_dato);
|
||||||
if (_msk->get(F_TIPODATO)=="Q")
|
if (_msk->get(F_TIPODATO)=="Q")
|
||||||
statrec.put(SVS_UMQTA,curr.get(SVR_UMQTA));
|
statrec.put(SVS_UMQTA,curr.get(SVR_UMQTA));
|
||||||
}
|
}
|
||||||
if (*lev_code== 'T') // totale generale
|
if (*lev_code== 'T') // totale generale
|
||||||
statrec.put(SVS_DESCR,"Totale generale");
|
statrec.put(SVS_DESCR,"");
|
||||||
else
|
else
|
||||||
statrec.put(SVS_DESCR,get_descrpart(lev_code,curr).left(SVS_LEN_DESCR));
|
statrec.put(SVS_DESCR,get_descrpart(lev_code,curr).left(SVS_LEN_DESCR));
|
||||||
put_column(statrec,col,curr);
|
put_column(statrec,col,curr);
|
||||||
@ -865,7 +1148,7 @@ void TStampa_stat::put_column(TRectype & statrec,int col,TSVriep_record& rieprec
|
|||||||
{
|
{
|
||||||
r+=rieprec.get_real(SVR_VALORE);
|
r+=rieprec.get_real(SVR_VALORE);
|
||||||
statrec.put(colname,r);
|
statrec.put(colname,r);
|
||||||
statrec.put(SVS_TOTALERIGA,statrec.get_real(SVS_TOTALERIGA)+rieprec.get_real(SVR_VALORE));
|
//statrec.put(SVS_TOTALERIGA,statrec.get_real(SVS_TOTALERIGA)+rieprec.get_real(SVR_VALORE));
|
||||||
} else {
|
} else {
|
||||||
if (statrec.get(SVR_UMQTA).not_empty())
|
if (statrec.get(SVR_UMQTA).not_empty())
|
||||||
{
|
{
|
||||||
@ -875,7 +1158,7 @@ void TStampa_stat::put_column(TRectype & statrec,int col,TSVriep_record& rieprec
|
|||||||
{
|
{
|
||||||
r+=rieprec.get_real(SVR_QUANTITA)*fc;
|
r+=rieprec.get_real(SVR_QUANTITA)*fc;
|
||||||
statrec.put(colname,r);
|
statrec.put(colname,r);
|
||||||
statrec.put(SVS_TOTALERIGA,statrec.get_real(SVS_TOTALERIGA)+rieprec.get_real(SVR_QUANTITA)*fc);
|
//statrec.put(SVS_TOTALERIGA,statrec.get_real(SVS_TOTALERIGA)+rieprec.get_real(SVR_QUANTITA)*fc);
|
||||||
}
|
}
|
||||||
} // no UM ? no valid data!
|
} // no UM ? no valid data!
|
||||||
}
|
}
|
||||||
@ -964,10 +1247,11 @@ void TStampa_stat::invalid_columns(TRectype & statrec)
|
|||||||
sprintf(colname,"%s%d",SVS_COLNAME,col);
|
sprintf(colname,"%s%d",SVS_COLNAME,col);
|
||||||
statrec.put(colname,0);
|
statrec.put(colname,0);
|
||||||
}
|
}
|
||||||
statrec.put(SVS_TOTALERIGA,0);
|
//statrec.put(SVS_TOTALERIGA,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// funzione di filtro del cursore
|
||||||
bool TStampa_stat::filtro_chiavi(TSVriep_record &curr)
|
bool TStampa_stat::filtro_chiavi(TSVriep_record &curr)
|
||||||
{
|
{
|
||||||
TSheet_field & s_chiave = selmask().sfield(F_CHIAVE);
|
TSheet_field & s_chiave = selmask().sfield(F_CHIAVE);
|
||||||
@ -982,7 +1266,10 @@ bool TStampa_stat::filtro_chiavi(TSVriep_record &curr)
|
|||||||
|
|
||||||
code_campo=s_chiave.cell(l,s_chiave.cid2index(S_CAMPO));
|
code_campo=s_chiave.cell(l,s_chiave.cid2index(S_CAMPO));
|
||||||
if (code_campo=="C") // cliente/fornitore ha in testa il TIPOCF
|
if (code_campo=="C") // cliente/fornitore ha in testa il TIPOCF
|
||||||
|
{
|
||||||
|
// ok &= curr.get_char(SVR_TIPOCF)==; !?!?! manca la selezione dei soli cli o for
|
||||||
val_intero=atoi(get_part(code_campo,curr)+1);
|
val_intero=atoi(get_part(code_campo,curr)+1);
|
||||||
|
}
|
||||||
else if (code_campo=="G") // agente è numerico
|
else if (code_campo=="G") // agente è numerico
|
||||||
val_intero=atoi(get_part(code_campo,curr));
|
val_intero=atoi(get_part(code_campo,curr));
|
||||||
else
|
else
|
||||||
@ -1027,12 +1314,11 @@ void TStampa_stat::set_ragg_per_um()
|
|||||||
void TStampa_stat::genera_file()
|
void TStampa_stat::genera_file()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
TString key; // chiave per il record del file statistiche
|
||||||
const TMask& m = selmask();
|
const TMask& m = selmask();
|
||||||
const char alg=m.get(F_TIPOCALC)[0];
|
const char alg=m.get(F_TIPOCALC)[0];
|
||||||
const int columns = m.get_int(F_PERIODO); //numero di colonne osservate
|
const int first_col = - (alg=='M' ? _col_anno-1:0); // prima colonna dati da osservare
|
||||||
const int col_anno =m.get_int(F_COL_ANNO); //numero di colonne che formano un "Anno"
|
const int first_raffr = -m.get_int(F_RAFFRONTO)- (alg=='M' ? _col_anno-1:0);// prima colonna dati da confrontare
|
||||||
const int first_col = - (alg=='M' ? col_anno-1:0); // prima colonna dati da osservare
|
|
||||||
const int first_raffr = -m.get_int(F_RAFFRONTO)- (alg=='M' ? col_anno-1:0);// prima colonna dati da confrontare
|
|
||||||
const int first_data = first_raffr ; // prima colonna dati
|
const int first_data = first_raffr ; // prima colonna dati
|
||||||
TSheet_field & s_chiave = m.sfield(F_CHIAVE);
|
TSheet_field & s_chiave = m.sfield(F_CHIAVE);
|
||||||
|
|
||||||
@ -1074,35 +1360,35 @@ void TStampa_stat::genera_file()
|
|||||||
const TPeriodo periodo(fr_anno, fr_periodo);
|
const TPeriodo periodo(fr_anno, fr_periodo);
|
||||||
const int col = _freq.period2column(periodo);
|
const int col = _freq.period2column(periodo);
|
||||||
|
|
||||||
if (col >= first_data && col < columns)
|
if (col >= first_data && col < _numcol_dati)
|
||||||
{
|
{
|
||||||
standardize_um(curr); //!?!? eventualmente sarebbe utile forzare l'uso della standard se è una riga non comprendente l'articolo
|
standardize_um(curr); //!?!? eventualmente sarebbe utile forzare l'uso della standard se è una riga non comprendente l'articolo
|
||||||
// costruisce il file statistiche...
|
// costruisce il file statistiche...
|
||||||
TString key,um;
|
key.cut(0);
|
||||||
for (int l=0; l< num_liv_output; l++)
|
for (int l=0; l< num_liv_output; l++)
|
||||||
{
|
{
|
||||||
static TString lev_code;
|
static TString lev_code;
|
||||||
lev_code=s_chiave.cell(l,s_chiave.cid2index(S_CAMPO));
|
lev_code=s_chiave.cell(l,s_chiave.cid2index(S_CAMPO));
|
||||||
key << get_part(lev_code,curr);
|
key << get_part(lev_code,curr);
|
||||||
// setta il ragne in base all'algoritmo (Valori/progressivi/mobili)
|
// setta il range in base all'algoritmo (Valori/progressivi/mobili)
|
||||||
const int range=(alg=='V'? col : alg=='P' ? ((1+int(col/col_anno))*col_anno-1) : (col+col_anno-1));
|
const int range=(alg=='V'? col : alg=='P' ? ((1+int(col/_col_anno))*_col_anno-1) : (col+_col_anno-1));
|
||||||
if (col>=first_col) // periodo da osservare
|
if (col>=first_col) // periodo da osservare
|
||||||
{
|
{
|
||||||
if (l==0)
|
if (l==0)
|
||||||
for (int c=max(col,0);c <= range ; c++)
|
for (int c=max(col,0);c <= range ; c++)
|
||||||
update_file(" Totale","T",LINEA_DATI,num_liv_output,c,curr);
|
update_file(" ","T",LINEA_DATI,num_liv_output,c,curr);
|
||||||
if (*s_chiave.cell(l,s_chiave.cid2index(S_TOTALE))=='X')
|
if (*s_chiave.cell(l,s_chiave.cid2index(S_TOTALE))=='X')
|
||||||
for (int c=max(col,0);c <= range ; c++)
|
for (int c=max(col,0);c <= range ; c++)
|
||||||
update_file(key,lev_code,LINEA_DATI,num_liv_output-l-1,c,curr);
|
update_file(key,lev_code,LINEA_DATI,num_liv_output-l-1,c,curr);
|
||||||
}
|
}
|
||||||
if (first_raffr !=first_col && col >= first_raffr && col<=first_raffr+columns) // periodo da confrontare
|
if (first_raffr !=first_col && col >= first_raffr && col<=first_raffr+_numcol_dati) // periodo da confrontare
|
||||||
{
|
{
|
||||||
if (l==0)
|
if (l==0)
|
||||||
for (int c=max(col,0); c <= range; c++)
|
for (int c=max(col,0); c <= range; c++)
|
||||||
update_file(" Totale","T",LINEA_CONFRONTI, num_liv_output , c -first_raffr,curr);
|
update_file(" Totale","T",LINEA_RAFFRONTI, num_liv_output , c -first_raffr,curr);
|
||||||
if (*s_chiave.cell(l,s_chiave.cid2index(S_TOTALE))=='X')
|
if (*s_chiave.cell(l,s_chiave.cid2index(S_TOTALE))=='X')
|
||||||
for (int c=max(col,0); c <= range; c++)
|
for (int c=max(col,0); c <= range; c++)
|
||||||
update_file(key,lev_code,LINEA_CONFRONTI,num_liv_output-l-1, c -first_raffr , curr);
|
update_file(key,lev_code,LINEA_RAFFRONTI,num_liv_output-l-1, c -first_raffr , curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1117,21 +1403,29 @@ void TStampa_stat::set_printmask()
|
|||||||
{
|
{
|
||||||
TMask &mp=selmask();
|
TMask &mp=selmask();
|
||||||
|
|
||||||
if (_print_msk) delete _print_msk;
|
|
||||||
_print_msk= new TMask("sv1200b");
|
|
||||||
|
|
||||||
const nlivelli=mp.sfield(F_CHIAVE).items();
|
const nlivelli=mp.sfield(F_CHIAVE).items();
|
||||||
TString80 nomeliv;
|
TString80 nomeliv;
|
||||||
for (int f=0; f<nlivelli; f++)
|
printmask().field(F_FLAGSTOTALI).set("X");
|
||||||
|
for (int f=0; f<MAX_ROWS; f++)
|
||||||
|
{
|
||||||
|
TMask_field & flfl=printmask().field(F_FLAGSTOTALI+f+1);
|
||||||
|
if (f<nlivelli)
|
||||||
{
|
{
|
||||||
nomeliv="Stampa totale ";
|
nomeliv="Stampa totale ";
|
||||||
nomeliv << partkey_name(mp.sfield(F_CHIAVE).cell(f,mp.sfield(F_CHIAVE).cid2index(S_CAMPO)));
|
nomeliv << partkey_name(mp.sfield(F_CHIAVE).cell(f,mp.sfield(F_CHIAVE).cid2index(S_CAMPO)));
|
||||||
printmask().add_boolean(F_FLAGSTOTALI+f, 0 ,nomeliv,2+36*int(f/(18-Y_FLAGSTOTALI)),Y_FLAGSTOTALI+(f% (18-Y_FLAGSTOTALI)));
|
flfl.set_prompt(nomeliv);
|
||||||
|
flfl.show();
|
||||||
|
flfl.set("X");
|
||||||
|
} else
|
||||||
|
flfl.hide();
|
||||||
}
|
}
|
||||||
if (mp.get_date(F_DATARAF).empty())
|
if (mp.get_date(F_DATARAF).empty())
|
||||||
{
|
{
|
||||||
printmask().field(F_STRAFFRONTO).disable();
|
printmask().field(F_STRAFFRONTO).hide();
|
||||||
printmask().field(F_TIPORAFFRONTO).disable();
|
printmask().field(F_TIPORAFFRONTO).hide();
|
||||||
|
} else {
|
||||||
|
printmask().field(F_STRAFFRONTO).show();
|
||||||
|
printmask().field(F_TIPORAFFRONTO).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,7 +1470,10 @@ const TString& TStampa_stat::partkey_name(const char *lev_code)
|
|||||||
park="categoria di vendita";
|
park="categoria di vendita";
|
||||||
break;
|
break;
|
||||||
case 'C': // cliente / fornitore
|
case 'C': // cliente / fornitore
|
||||||
park="cliente";
|
park="cliente ";
|
||||||
|
break;
|
||||||
|
case 'F': // cliente / fornitore
|
||||||
|
park="fornitore";
|
||||||
break;
|
break;
|
||||||
case 'G': // agente
|
case 'G': // agente
|
||||||
park="agente";
|
park="agente";
|
||||||
@ -1190,6 +1487,9 @@ const TString& TStampa_stat::partkey_name(const char *lev_code)
|
|||||||
case 'U': // unità di misura
|
case 'U': // unità di misura
|
||||||
park="unita' di misura";
|
park="unita' di misura";
|
||||||
break;
|
break;
|
||||||
|
case 'T': // totale generale
|
||||||
|
park="generale";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fatal_box("ai chent recognaiz the code of the key part!");
|
fatal_box("ai chent recognaiz the code of the key part!");
|
||||||
return "";
|
return "";
|
||||||
@ -1198,12 +1498,25 @@ const TString& TStampa_stat::partkey_name(const char *lev_code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const TString& TStampa_stat::get_part(const char *lev_code, TSVriep_record &rieprec) const
|
void TStampa_stat::adjust_record(TRectype &strec, int from) const
|
||||||
|
{
|
||||||
|
char lev_code=strec.get_char(SVS_LEVCODE);
|
||||||
|
if (lev_code=='F' || lev_code=='C')
|
||||||
|
{
|
||||||
|
TString &s =(TString &)strec.get(SVS_CODICE).mid(from);
|
||||||
|
lev_code=s.shift();
|
||||||
|
strec.put(SVS_CODICE,s);
|
||||||
|
strec.put(SVS_LEVCODE,lev_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const TString& TStampa_stat::get_part(TString & lev_code, TSVriep_record &rieprec) const
|
||||||
{
|
{
|
||||||
static TString park(' ',25);
|
static TString park(' ',25);
|
||||||
|
|
||||||
int lev_code_num=atoi(lev_code+1);
|
int lev_code_num=atoi(lev_code+1);
|
||||||
switch (*lev_code)
|
switch (lev_code[0])
|
||||||
{
|
{
|
||||||
case 'D': // tipo documento
|
case 'D': // tipo documento
|
||||||
return rieprec.get(SVR_TIPODOC);
|
return rieprec.get(SVR_TIPODOC);
|
||||||
@ -1225,8 +1538,10 @@ const TString& TStampa_stat::get_part(const char *lev_code, TSVriep_record &riep
|
|||||||
case 'V': // cat. vendita
|
case 'V': // cat. vendita
|
||||||
park=rieprec.get(SVR_CATVEN);
|
park=rieprec.get(SVR_CATVEN);
|
||||||
return park.rpad(3);
|
return park.rpad(3);
|
||||||
|
case 'F': // cliente / fornitore
|
||||||
case 'C': // cliente / fornitore
|
case 'C': // cliente / fornitore
|
||||||
park.format("%c%6d",rieprec.get_char(SVR_TIPOCF),rieprec.get_int(SVR_CODCF));
|
lev_code[0]=rieprec.get_char(SVR_TIPOCF);
|
||||||
|
park.format("%c%6d",lev_code[0],rieprec.get_int(SVR_CODCF));
|
||||||
return park;
|
return park;
|
||||||
case 'G': // agente
|
case 'G': // agente
|
||||||
park.format("%5d",rieprec.get_int(SVR_CODAG));
|
park.format("%5d",rieprec.get_int(SVR_CODAG));
|
||||||
@ -1269,6 +1584,7 @@ const TString& TStampa_stat::get_descrpart(const char *lev_code, TSVriep_record
|
|||||||
return _liv_giac->group_descr(rieprec.get(SVR_GIAC),lev_code_num);
|
return _liv_giac->group_descr(rieprec.get(SVR_GIAC),lev_code_num);
|
||||||
case 'V': // cat. vendita
|
case 'V': // cat. vendita
|
||||||
return _catven->get(rieprec.get(SVR_CATVEN)).get("S0");
|
return _catven->get(rieprec.get(SVR_CATVEN)).get("S0");
|
||||||
|
case 'F': // cliente
|
||||||
case 'C': // cliente
|
case 'C': // cliente
|
||||||
{
|
{
|
||||||
_clifor->put(CLI_TIPOCF,rieprec.get_char(SVR_TIPOCF));
|
_clifor->put(CLI_TIPOCF,rieprec.get_char(SVR_TIPOCF));
|
||||||
@ -1339,6 +1655,8 @@ bool TStampa_stat::multiplo_handler(TMask_field& f, KEY k)
|
|||||||
m.set(F_NUMERO, n);
|
m.set(F_NUMERO, n);
|
||||||
m.disable(F_NUMERO);
|
m.disable(F_NUMERO);
|
||||||
}
|
}
|
||||||
|
// setta la durata dell'anno
|
||||||
|
m.set(F_COL_ANNO, last_period(1992,freq));
|
||||||
app().recalc_period();
|
app().recalc_period();
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user