Reso autoimatizzabile ricalcolo statistiche

git-svn-id: svn://10.65.10.50/branches/R_10_00@22766 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-12-04 16:47:00 +00:00
parent 6dc48175f8
commit d993d1a9fa
2 changed files with 91 additions and 75 deletions

View File

@ -483,7 +483,6 @@ protected:
TString& build_key(const TRectype& rec); TString& build_key(const TRectype& rec);
const TString& nome_colonna1(int c, TString& nome); const TString& nome_colonna1(int c, TString& nome);
const TString& nome_colonna2(int c, TString& nome); const TString& nome_colonna2(int c, TString& nome);
const TString& nome_totale(int t, TString& nome); const TString& nome_totale(int t, TString& nome);
@ -498,8 +497,6 @@ public:
TMask& printmask() const { return *_print_msk; } TMask& printmask() const { return *_print_msk; }
TMask& expmask() const { return *_export_msk; } TMask& expmask() const { return *_export_msk; }
virtual bool menu(MENU_TAG); virtual bool menu(MENU_TAG);
TStampa_stat() {}
virtual ~TStampa_stat() { }
}; };
inline TStampa_stat& app() { return (TStampa_stat&)main_app(); } inline TStampa_stat& app() { return (TStampa_stat&)main_app(); }
@ -827,33 +824,33 @@ const TString& TStampa_stat::nome_colonna2(int c, TString& s_park)
if (freq == maskfreq && numero > 1 && maskfreq==fs_giornaliera) if (freq == maskfreq && numero > 1 && maskfreq==fs_giornaliera)
{ {
TDate dto(app()._freq.column_last_day(c)); const TDate dto = app()._freq.column_last_day(c);
s_park.format(FR("Al %s"),(const char *)dto.string()); s_park.format(FR("Al %s"),(const char *)dto.string());
} }
else else
{ {
switch (freq) switch (freq)
{
case fs_giornaliera:
{ {
case fs_giornaliera: TDate d = din; d += c*numero;
{ s_park.format("%s",(const char *)d.string());
TDate d = din; d += c*numero;
s_park.format("%s",(const char *)d.string());
}
break;
case fs_annuale:
break;
case fs_mensile:
s_park.format("%d",din.year()+int((start+c-1)/lastp));
break;
case fs_settimanale:
case fs_quindicinale:
case fs_bimestrale:
case fs_trimestrale:
case fs_quadrimestrale:
case fs_semestrale:
s_park.format(FR(" anno %d"),din.year()+int((start+c-1)/lastp));
break;
} }
break;
case fs_mensile:
s_park.format("%d",din.year()+int((start+c-1)/lastp));
break;
case fs_settimanale:
case fs_quindicinale:
case fs_bimestrale:
case fs_trimestrale:
case fs_quadrimestrale:
case fs_semestrale:
s_park.format(FR(" anno %d"),din.year()+int((start+c-1)/lastp));
break;
default:
break;
}
} }
return s_park; return s_park;
} }
@ -948,12 +945,14 @@ void TStampa_stat::set_page(int file, int count)
strec.zero(SVS_CODICE); strec.zero(SVS_CODICE);
switch (tipo_riga) switch (tipo_riga)
{ {
case LINEA_DATI: case LINEA_DATI:
_group_recs.add(strec,level); _group_recs.add(strec,level);
break; break;
case LINEA_RAFFRONTI: case LINEA_RAFFRONTI:
_group_recs_raff.add(strec,level); _group_recs_raff.add(strec,level);
break; break;
default:
break;
} }
} }
// ***************** // *****************
@ -963,32 +962,34 @@ void TStampa_stat::set_page(int file, int count)
{ {
switch (tipo_riga) switch (tipo_riga)
{ {
case LINEA_DATI: case LINEA_DATI:
if (level >= _liv_riga) if (level >= _liv_riga)
{
_save_code = strec.get(SVS_CODICE);
set_descr(row);
}
if (level == _liv_riga)
row = set_rows_colonne(row, strec);
break;
case LINEA_RAFFRONTI:
if (printmask().get_bool(F_STRAFFRONTO))
{
if (_save_code != strec.get(SVS_CODICE))
{ {
_save_code = strec.get(SVS_CODICE); TRectype stempty(LF_SVSTAT);
stempty.put(SVS_CODICE,strec.get(SVS_CODICE));
stempty.put(SVS_LEVCODE,strec.get(SVS_LEVCODE));
stempty.put(SVS_LIVELLO,strec.get(SVS_LIVELLO));
stempty.put(SVS_TIPO,strec.get(SVS_TIPO));
set_descr(row); set_descr(row);
row = set_rows_colonne(row, stempty);
} }
if (level == _liv_riga) if (level == _liv_riga)
row = set_rows_colonne(row, strec); row = set_rows_colonne(++row, strec);
break; }
case LINEA_RAFFRONTI: break;
if (printmask().get_bool(F_STRAFFRONTO)) default:
{ break;
if (_save_code != strec.get(SVS_CODICE))
{
TRectype stempty(LF_SVSTAT);
stempty.put(SVS_CODICE,strec.get(SVS_CODICE));
stempty.put(SVS_LEVCODE,strec.get(SVS_LEVCODE));
stempty.put(SVS_LIVELLO,strec.get(SVS_LIVELLO));
stempty.put(SVS_TIPO,strec.get(SVS_TIPO));
set_descr(row);
row = set_rows_colonne(row, stempty);
}
if (level == _liv_riga)
row = set_rows_colonne(++row, strec);
}
break;
} }
} }
// ***************** // *****************
@ -1187,7 +1188,6 @@ int TStampa_stat::set_rows_colonne(int row, const TRectype &strec)
return row; return row;
} }
void TStampa_stat::set_filled_row(char section,int row,char c,int pos,int len) void TStampa_stat::set_filled_row(char section,int row,char c,int pos,int len)
{ {
const int MAX=100; // limite massimo per una singola set_row; 5 char per costruire la goto const int MAX=100; // limite massimo per una singola set_row; 5 char per costruire la goto
@ -1202,8 +1202,6 @@ void TStampa_stat::set_filled_row(char section,int row,char c,int pos,int len)
set_row_atpos(section,row,(const char *)_wrk_row,pos); set_row_atpos(section,row,(const char *)_wrk_row,pos);
} }
// 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_row_atpos(char section,int nrow,const char * f,int pos) void TStampa_stat::set_row_atpos(char section,int nrow,const char * f,int pos)
{ {
@ -1234,9 +1232,10 @@ void TStampa_stat::set_row_atpos(char section,int nrow,const char * f,int pos)
repeat_print(); repeat_print();
switch (section) switch (section)
{ {
case 'R': set_row(nrow,ss); break; case 'R': set_row(nrow,ss); break;
case 'H': set_header(nrow,ss); break; case 'H': set_header(nrow,ss); break;
case 'F': set_footer(nrow,ss); break; case 'F': set_footer(nrow,ss); break;
default : break;
} }
} }
@ -1699,9 +1698,7 @@ void TStampa_stat::update_file(const char * key, const char *lev_code,const char
statrec->put(SVS_DESCR,""); statrec->put(SVS_DESCR,"");
else else
{ {
TString descr(get_descrpart(lev_code,curr,fld, row)); TString descr = safe_string(get_descrpart(lev_code,curr,fld, row));
for (int pos = descr.find('%'); pos >=0; pos = descr.find('%', pos + 2))
descr.insert("%", pos);
if (descr.len() > SVS_LEN_DESCR) if (descr.len() > SVS_LEN_DESCR)
descr.cut(SVS_LEN_DESCR); descr.cut(SVS_LEN_DESCR);
statrec->put(SVS_DESCR, descr); statrec->put(SVS_DESCR, descr);
@ -1814,8 +1811,8 @@ const real TStampa_stat::fc_um(const TRectype& statrec,const TSVriep_record& rie
} }
else else
{ {
error_box("L'articolo '%s' non ha l'unita' di misura %s\n" error_box(FR("L'articolo '%s' non ha l'unità di misura %s\n"
"ma esistono statistiche che la utilizzano ugualmente", "ma esistono statistiche che la utilizzano ugualmente"),
(const char*)art, (const char*)um); (const char*)art, (const char*)um);
} }
} }
@ -1839,7 +1836,7 @@ const real TStampa_stat::fc_um(const TRectype& statrec,const TSVriep_record& rie
void TStampa_stat::invalid_columns(TRectype& statrec) void TStampa_stat::invalid_columns(TRectype& statrec)
{ {
statrec.zero(SVS_UMQTA); statrec.zero(SVS_UMQTA);
TString16 colname; TString8 colname;
for (int col = 0; col < SVS_NUMCOLONNE; col++) for (int col = 0; col < SVS_NUMCOLONNE; col++)
{ {
colname.format("%C%d", SVS_QTACOLNAME, col); colname.format("%C%d", SVS_QTACOLNAME, col);
@ -2134,7 +2131,7 @@ void TStampa_stat::adjust_record(TRectype &strec, int from) const
if (lev_code==CHR_CLIFOR) if (lev_code==CHR_CLIFOR)
{ {
TString codprec = strec.get(SVS_CODICE).left(from); TString codprec = strec.get(SVS_CODICE).left(from);
TString& s = (TString&)strec.get(SVS_CODICE).mid(from); TString s = strec.get(SVS_CODICE).mid(from);
while ((lev_code=s.shift())==' '); while ((lev_code=s.shift())==' ');
codprec << s; codprec << s;
strec.put(SVS_LEVCODE, lev_code); strec.put(SVS_LEVCODE, lev_code);
@ -2145,7 +2142,7 @@ void TStampa_stat::adjust_record(TRectype &strec, int from) const
if (from) if (from)
{ {
TString codprec=strec.get(SVS_CODICE).left(from); TString codprec=strec.get(SVS_CODICE).left(from);
TString& s = (TString&)strec.get(SVS_CODICE).mid(from); TString s = strec.get(SVS_CODICE).mid(from);
while ((lev_code=s.shift())==' '); while ((lev_code=s.shift())==' ');
codprec << lev_code << s; codprec << lev_code << s;
strec.put(SVS_CODICE,codprec); strec.put(SVS_CODICE,codprec);
@ -2590,7 +2587,7 @@ bool TStampa_stat::filename_handler(TMask_field& f, KEY k)
TFilename path(fn.path()); TFilename path(fn.path());
path.rtrim(1); // Toglie la slash dal path path.rtrim(1); // Toglie la slash dal path
if (!path.exist()) if (!path.exist())
return f.error_box(FR("Directory %s non trovato"),(const char *)path); return f.error_box(FR("Cartella %s non trovata"),(const char *)path);
else else
if (fn.exist()) if (fn.exist())
return f.yesno_box(FR("File %s esistente: sovrascrivo"), (const char*)fn); return f.yesno_box(FR("File %s esistente: sovrascrivo"), (const char*)fn);

View File

@ -137,7 +137,12 @@ void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
const long items = cur.items(); const long items = cur.items();
cur.freeze(); cur.freeze();
TProgind pi(items, TR("Ricalcolo statistiche"), false, true); TString msg; msg << TR("Ricalcolo statistiche");
if (dfr.ok())
msg << TR(" dal ") << dfr;
if (dto.ok())
msg << TR(" al ") << dto;
TProgind pi(items, msg, false, true);
long records = 0; long records = 0;
_agg.reset(); _agg.reset();
@ -186,17 +191,31 @@ void TRicalcolo_stats::main_loop()
{ {
calcola_data_minima(); calcola_data_minima();
TMask m("sv2100a"); if (argc() >= 3 && _stricmp(argv(2), "-A") == 0)
m.set_handler(F_FROMDATE, datein_handler);
m.set(F_FROMDATE, _datamin);
while (m.run() == K_ENTER)
{ {
const TDate dfr(m.get(F_FROMDATE)); const TDate dto(TODAY);
const TDate dto(m.get(F_TODATE)); TDate dfr = dto;
dfr.set_day(1);
dfr.addmonth(-12);
if (dfr < _datamin)
dfr = _datamin;
if (kill_stats(dfr, dto)) if (kill_stats(dfr, dto))
calc_stats(dfr, dto); calc_stats(dfr, dto);
} }
else
{
TMask m("sv2100a");
m.set_handler(F_FROMDATE, datein_handler);
m.set(F_FROMDATE, _datamin);
while (m.run() == K_ENTER)
{
const TDate dfr(m.get(F_FROMDATE));
const TDate dto(m.get(F_TODATE));
if (kill_stats(dfr, dto))
calc_stats(dfr, dto);
}
}
} }
int sv2100(int argc, char* argv[]) int sv2100(int argc, char* argv[])