1997-06-17 15:50:08 +00:00
|
|
|
|
#include <applicat.h>
|
1997-03-20 10:33:28 +00:00
|
|
|
|
#include <mask.h>
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include <msksheet.h>
|
|
|
|
|
#include <printer.h>
|
1997-06-17 15:50:08 +00:00
|
|
|
|
#include <progind.h>
|
2002-10-24 09:09:39 +00:00
|
|
|
|
#include <recarray.h>
|
1997-06-17 15:50:08 +00:00
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <urldefid.h>
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include <utility.h>
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
|
|
|
|
#include "at3.h"
|
|
|
|
|
|
1997-06-17 15:50:08 +00:00
|
|
|
|
// nomi campi maschera
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include "at3100a.h"
|
1997-06-17 15:50:08 +00:00
|
|
|
|
|
|
|
|
|
// nomi dei campi
|
|
|
|
|
#include "soggetti.h"
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include "atstats.h"
|
|
|
|
|
#include "sezioni.h"
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
// classe per la definizione di una riga di statistica
|
|
|
|
|
class TRigaSFascia : public TObject
|
|
|
|
|
{
|
|
|
|
|
int _etaini,_etafin;
|
|
|
|
|
TArray _valori;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
protected:
|
|
|
|
|
const TRigaSFascia& copy(const TRigaSFascia& riga);
|
|
|
|
|
public:
|
|
|
|
|
const int etaini() const { return _etaini; }
|
|
|
|
|
const int etafin() const { return _etafin; }
|
|
|
|
|
TObject* dup() const { return new TRigaSFascia(*this); }
|
|
|
|
|
const TRigaSFascia& operator = (const TRigaSFascia& riga);
|
|
|
|
|
const real& operator [] (int colonna) const;
|
|
|
|
|
void aggiorna_valore(int colonna, const real& numero) ;
|
|
|
|
|
void azzera_valori();
|
|
|
|
|
// costruttore
|
|
|
|
|
TRigaSFascia(int etaini, int etafin) {_etaini = etaini; _etafin = etafin;}
|
|
|
|
|
// costruttore di copia
|
|
|
|
|
TRigaSFascia(const TRigaSFascia& riga) { copy(riga); }
|
|
|
|
|
virtual ~TRigaSFascia() {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TRigaSFascia& TRigaSFascia::copy(const TRigaSFascia& riga)
|
|
|
|
|
{
|
|
|
|
|
_etaini = riga._etaini;
|
|
|
|
|
_etafin = riga._etafin;
|
|
|
|
|
_valori = riga._valori;
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRigaSFascia& TRigaSFascia::operator = (const TRigaSFascia& riga)
|
|
|
|
|
{
|
|
|
|
|
copy(riga);
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const real& TRigaSFascia::operator [] (int colonna) const
|
|
|
|
|
{
|
|
|
|
|
real* valore = (real*)_valori.objptr(colonna);
|
|
|
|
|
if (valore == NULL)
|
|
|
|
|
return ZERO;
|
|
|
|
|
else
|
|
|
|
|
return *valore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRigaSFascia::aggiorna_valore(int colonna, const real& numero)
|
|
|
|
|
{
|
|
|
|
|
real* valore = (real*)_valori.objptr(colonna);
|
|
|
|
|
if (valore == NULL)
|
|
|
|
|
_valori.add(new real(numero), colonna);
|
|
|
|
|
else
|
|
|
|
|
*valore += numero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRigaSFascia::azzera_valori()
|
|
|
|
|
{
|
|
|
|
|
_valori.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TStatSogxEta : public TApplication
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1997-06-17 15:50:08 +00:00
|
|
|
|
TMask* _msk;
|
|
|
|
|
TRelation* _rel;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TCursor* _cur;
|
|
|
|
|
TLocalisamfile* _sezioni;
|
|
|
|
|
TLocalisamfile* _soggetti;
|
|
|
|
|
TLocalisamfile* _atstats;
|
|
|
|
|
TAssoc_array* _colonne;
|
|
|
|
|
TArray _righe;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
TString16 _sezini, _sotini, _sezfin, _sotfin, _gruppoazie;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TString16 _catdon;
|
|
|
|
|
TDate _data;
|
|
|
|
|
TArray _etaini, _etafin;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
bool _solotot, _pergruppo;
|
1999-03-08 15:03:47 +00:00
|
|
|
|
int _sezionistampate;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
protected:
|
1997-06-17 15:50:08 +00:00
|
|
|
|
virtual bool create();
|
|
|
|
|
virtual bool destroy();
|
|
|
|
|
virtual bool menu(MENU_TAG m);
|
|
|
|
|
virtual TMask& get_mask() { return *_msk; }
|
|
|
|
|
virtual TRelation* get_relation() const { return _rel; }
|
1998-02-04 13:46:27 +00:00
|
|
|
|
int data2row(const int eta);
|
|
|
|
|
bool riepilogo();
|
|
|
|
|
bool stampa();
|
|
|
|
|
bool crea_colonne();
|
|
|
|
|
bool crea_righe();
|
|
|
|
|
void azzera_righe();
|
|
|
|
|
void stampa_sezione(TString16 codsez, TString16 codsot);
|
|
|
|
|
void crea_intestazione();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
public:
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TStatSogxEta() {}
|
1997-06-17 15:50:08 +00:00
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
HIDDEN inline TStatSogxEta& app() { return (TStatSogxEta&) main_app(); }
|
|
|
|
|
|
|
|
|
|
int TStatSogxEta::data2row(const int eta)
|
|
|
|
|
{
|
1999-01-26 14:35:45 +00:00
|
|
|
|
int indice = -1;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
for (int i=0; i<_etaini.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
real valore;
|
|
|
|
|
real* val1 = (real*) _etaini.objptr(i);
|
|
|
|
|
valore = *val1;
|
1998-02-06 15:44:00 +00:00
|
|
|
|
int etaini = (int) valore.integer();
|
1998-02-04 13:46:27 +00:00
|
|
|
|
real* val2 = (real*) _etafin.objptr(i);
|
|
|
|
|
valore = *val2;
|
1998-02-06 15:44:00 +00:00
|
|
|
|
int etafin = (int) valore.integer();
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if ((eta >= etaini) && (eta <= etafin))
|
|
|
|
|
indice = i;
|
|
|
|
|
}
|
|
|
|
|
return indice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatSogxEta::crea_colonne()
|
|
|
|
|
{
|
|
|
|
|
_colonne->destroy();
|
|
|
|
|
real contatore(ZERO);
|
|
|
|
|
real* oggetto = new real(contatore);
|
|
|
|
|
const char* indice = "0";
|
|
|
|
|
_colonne->add(indice,(TObject*)oggetto);
|
|
|
|
|
indice = "1"; // maschi
|
|
|
|
|
contatore = contatore+1;
|
|
|
|
|
real* oggetto2 = new real(contatore);
|
|
|
|
|
_colonne->add(indice,(TObject*)oggetto2);
|
|
|
|
|
indice = "2"; // femmine
|
|
|
|
|
contatore = contatore+1;
|
|
|
|
|
real* oggetto3 = new real(contatore);
|
|
|
|
|
_colonne->add(indice,(TObject*)oggetto3);
|
|
|
|
|
indice = "9"; // non spec.
|
|
|
|
|
contatore = contatore+1;
|
|
|
|
|
real* oggetto4 = new real(contatore);
|
|
|
|
|
_colonne->add(indice,(TObject*)oggetto4);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatSogxEta::crea_righe()
|
|
|
|
|
{
|
|
|
|
|
for (int i=0;i<_etaini.items();i++)
|
|
|
|
|
{
|
|
|
|
|
real valore;
|
|
|
|
|
real* val1 = (real*) _etaini.objptr(i);
|
|
|
|
|
valore = *val1;
|
1998-02-06 15:44:00 +00:00
|
|
|
|
int etaini = (int) valore.integer();
|
1998-02-04 13:46:27 +00:00
|
|
|
|
real* val2 = (real*) _etafin.objptr(i);
|
|
|
|
|
valore = *val2;
|
1998-02-06 15:44:00 +00:00
|
|
|
|
int etafin = (int) valore.integer();
|
1998-02-04 13:46:27 +00:00
|
|
|
|
_righe.add(new TRigaSFascia(etaini, etafin), i);
|
|
|
|
|
}
|
|
|
|
|
return _righe.items()>0;
|
|
|
|
|
}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
bool TStatSogxEta::create()
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1997-08-01 14:49:53 +00:00
|
|
|
|
TApplication::create();
|
1997-06-17 15:50:08 +00:00
|
|
|
|
_msk = new TMask("at3100a");
|
|
|
|
|
_rel = new TRelation(LF_SOGGETTI);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
_soggetti = new TLocalisamfile(LF_SOGGETTI);
|
|
|
|
|
_atstats = new TLocalisamfile(LF_ATSTATS);
|
|
|
|
|
_sezioni = new TLocalisamfile(LF_SEZIONI);
|
|
|
|
|
_colonne = new TAssoc_array();
|
1997-06-17 15:50:08 +00:00
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1997-03-20 10:33:28 +00:00
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
bool TStatSogxEta::destroy()
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1998-08-07 10:04:30 +00:00
|
|
|
|
delete _colonne;
|
|
|
|
|
delete _sezioni;
|
|
|
|
|
delete _atstats;
|
|
|
|
|
delete _soggetti;
|
1997-06-17 15:50:08 +00:00
|
|
|
|
delete _rel;
|
|
|
|
|
delete _msk;
|
1997-08-01 14:49:53 +00:00
|
|
|
|
return TApplication::destroy();
|
1997-03-20 10:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
bool TStatSogxEta::menu(MENU_TAG m)
|
1997-06-17 15:50:08 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& msk = get_mask();
|
|
|
|
|
KEY tasto;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
tasto = msk.run();
|
|
|
|
|
if (tasto == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
_sezini = _msk->get(F_SEZINI);
|
|
|
|
|
_sotini = _msk->get(F_SOTINI);
|
|
|
|
|
_sezfin = _msk->get(F_SEZFIN);
|
|
|
|
|
_sotfin = _msk->get(F_SOTFIN);
|
|
|
|
|
_catdon = _msk->get(F_CATDON);
|
|
|
|
|
_data = _msk->get_date(F_DATA);
|
2000-05-04 14:51:39 +00:00
|
|
|
|
_pergruppo = _msk->get_bool(F_PERGRUPPO);
|
|
|
|
|
_gruppoazie = _msk->get(F_GRUPPOAZIE);
|
|
|
|
|
_solotot = msk.get_bool(F_SOLOTOT);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TSheet_field& s = (TSheet_field&)_msk->field(F_FASCIE);
|
|
|
|
|
for (int r=0; r<s.items(); r++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = s.row(r);
|
|
|
|
|
const int etaini = row.get_int(0);
|
|
|
|
|
const int etafin = row.get_int();
|
|
|
|
|
if (etaini != 0 || etafin != 0)
|
|
|
|
|
{
|
|
|
|
|
_etaini.add(new real(etaini),r);
|
|
|
|
|
_etafin.add(new real(etafin),r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (riepilogo())
|
|
|
|
|
stampa();
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
1997-06-17 15:50:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
void TStatSogxEta::crea_intestazione()
|
1997-06-17 15:50:08 +00:00
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TPrintrow row;
|
|
|
|
|
TString256 sep;
|
|
|
|
|
sep = "STATISTICA SOGGETTI PER SESSO E ETA' al ";
|
|
|
|
|
sep << _data.string();
|
1998-02-11 14:43:07 +00:00
|
|
|
|
sep.center_just(120);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
row.put(sep);
|
|
|
|
|
row.put("@>", 1);
|
1998-02-11 14:43:07 +00:00
|
|
|
|
row.put("Pag. @#", 105);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
printer().setheaderline(2, row);
|
1999-02-02 14:43:55 +00:00
|
|
|
|
sep = "";
|
|
|
|
|
if (_catdon.not_empty())
|
|
|
|
|
{
|
|
|
|
|
sep << "Categoria " << _catdon << ' ';
|
2002-10-24 09:09:39 +00:00
|
|
|
|
sep << cache().get("CTD", _catdon).get("S0");
|
1999-02-02 14:43:55 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sep << "Tutte le categorie non dimessi";
|
1998-02-11 14:43:07 +00:00
|
|
|
|
sep.center_just(120);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(3, row);
|
|
|
|
|
sep = "";
|
1998-02-11 14:43:07 +00:00
|
|
|
|
sep << "Fascia di eta' Sconosc. Maschi Femmine Non spec. Totale";
|
1998-02-04 13:46:27 +00:00
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(5, row);
|
1998-02-11 14:43:07 +00:00
|
|
|
|
sep = "";
|
|
|
|
|
sep << " Nro %rel %ass Nro %rel %ass Nro %rel %ass Nro %rel %ass Nro %ass";
|
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(6, row);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
sep = "";
|
1998-02-11 14:43:07 +00:00
|
|
|
|
sep.fill('-',120);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
1998-02-11 14:43:07 +00:00
|
|
|
|
printer().setheaderline(7, row);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatSogxEta::stampa()
|
|
|
|
|
{
|
|
|
|
|
if (printer().open())
|
1997-03-20 10:33:28 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
_sezionistampate = 0;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
crea_intestazione();
|
|
|
|
|
TRelation* relstat = new TRelation(LF_ATSTATS);
|
|
|
|
|
TCursor* curstat = new TCursor(relstat, "", 1);
|
|
|
|
|
TString16 oldsez = "**";
|
|
|
|
|
TString16 oldsot = "**";
|
|
|
|
|
double numero;
|
|
|
|
|
TString16 actsez, actsot;
|
|
|
|
|
TString16 sesso;
|
|
|
|
|
int fascia;
|
|
|
|
|
long last = curstat->items();
|
|
|
|
|
for ( *curstat=0; curstat->pos() < last; ++(*curstat) )
|
|
|
|
|
{
|
|
|
|
|
actsez = curstat->curr().get(ATSS_CODSEZ);
|
|
|
|
|
actsot = curstat->curr().get(ATSS_CODSOT);
|
|
|
|
|
fascia = curstat->curr().get_int(ATSS_FASCIA);
|
|
|
|
|
sesso = curstat->curr().get(ATSS_SESSO);
|
|
|
|
|
if (sesso.empty())
|
|
|
|
|
sesso = "9";
|
|
|
|
|
numero = (double)curstat->curr().get_int(ATSS_NUMERO);
|
|
|
|
|
if (actsez != oldsez || actsot != oldsot)
|
|
|
|
|
{
|
|
|
|
|
if (oldsez != "**" && oldsot != "**")
|
|
|
|
|
{
|
|
|
|
|
stampa_sezione(oldsez,oldsot);
|
|
|
|
|
azzera_righe();
|
|
|
|
|
}
|
|
|
|
|
oldsez = actsez;
|
|
|
|
|
oldsot = actsot;
|
|
|
|
|
}
|
|
|
|
|
TRigaSFascia& riga = (TRigaSFascia&)_righe[fascia];
|
|
|
|
|
real& colonna = (real&)_colonne->find((const char*)sesso);
|
|
|
|
|
real n = numero;
|
1998-02-06 15:44:00 +00:00
|
|
|
|
riga.aggiorna_valore((int) colonna.integer(),n);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
if (oldsez != "**" && oldsot != "**")
|
|
|
|
|
stampa_sezione(oldsez,oldsot);
|
|
|
|
|
delete curstat;
|
|
|
|
|
delete relstat;
|
|
|
|
|
printer().close();
|
|
|
|
|
return TRUE;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
1997-03-20 10:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-02-04 13:46:27 +00:00
|
|
|
|
void TStatSogxEta::azzera_righe()
|
|
|
|
|
{
|
|
|
|
|
for (int i=0;i<_etaini.items();i++)
|
|
|
|
|
{
|
|
|
|
|
TRigaSFascia& riga = (TRigaSFascia&)_righe[i];
|
|
|
|
|
riga.azzera_valori();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TStatSogxEta::stampa_sezione(TString16 codsez, TString16 codsot)
|
|
|
|
|
{
|
|
|
|
|
TPrintrow row;
|
|
|
|
|
TString256 rigastampa;
|
1999-01-26 14:35:45 +00:00
|
|
|
|
if (codsez == "ZZ" && codsot == "ZZ")
|
1999-03-08 15:03:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (_sezionistampate != 1)
|
|
|
|
|
{
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa << "RIEPILOGO TOTALE SEZIONI DA " << _sezini << '/' << _sotini << " A " << _sezfin << '/' << _sotfin;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
if (_pergruppo)
|
|
|
|
|
rigastampa << " - SOLO GRUPPI AZIENDALI";
|
1999-03-08 15:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-01-26 14:35:45 +00:00
|
|
|
|
else
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
_sezionistampate++;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
if (_pergruppo)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
2000-05-04 14:51:39 +00:00
|
|
|
|
rigastampa = "Gruppo aziendale ";
|
|
|
|
|
rigastampa << codsez;
|
1999-01-26 14:35:45 +00:00
|
|
|
|
rigastampa << codsot;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rigastampa = "Sezione: ";
|
|
|
|
|
rigastampa << codsez;
|
|
|
|
|
if (codsot.not_empty())
|
1999-01-26 14:35:45 +00:00
|
|
|
|
{
|
|
|
|
|
rigastampa << "/";
|
2000-05-04 14:51:39 +00:00
|
|
|
|
rigastampa << codsot;
|
|
|
|
|
}
|
|
|
|
|
rigastampa << " ";
|
|
|
|
|
TLocalisamfile sezioni(LF_SEZIONI);
|
|
|
|
|
sezioni.setkey(1);
|
|
|
|
|
sezioni.zero();
|
|
|
|
|
sezioni.put(SEZ_CODSEZ,codsez);
|
|
|
|
|
sezioni.put(SEZ_CODSOT,codsot);
|
|
|
|
|
if (sezioni.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
TString80 den = sezioni.get(SEZ_DENSEZ);
|
1999-01-26 14:35:45 +00:00
|
|
|
|
rigastampa << den;
|
2000-05-04 14:51:39 +00:00
|
|
|
|
den = sezioni.get(SEZ_DENSOT);
|
|
|
|
|
if (den.not_empty())
|
|
|
|
|
{
|
|
|
|
|
rigastampa << "/";
|
|
|
|
|
rigastampa << den;
|
|
|
|
|
}
|
1999-01-26 14:35:45 +00:00
|
|
|
|
}
|
2000-05-04 14:51:39 +00:00
|
|
|
|
}
|
1999-01-26 14:35:45 +00:00
|
|
|
|
}
|
1999-03-08 15:03:47 +00:00
|
|
|
|
if ((codsez == "ZZ" && codsot == "ZZ" && _sezionistampate != 1) || (codsez != "ZZ"))
|
|
|
|
|
{
|
|
|
|
|
rigastampa.center_just(120);
|
|
|
|
|
row.put(rigastampa);
|
|
|
|
|
printer().setheaderline(1, row);
|
|
|
|
|
|
|
|
|
|
real totalegenerale = ZERO;
|
|
|
|
|
for (int t=0;t<_etaini.items();t++)
|
|
|
|
|
{
|
|
|
|
|
TRigaSFascia& riga = (TRigaSFascia&)_righe[t];
|
|
|
|
|
for (int i=0;i<_colonne->items();i++)
|
|
|
|
|
totalegenerale+=riga[i];
|
|
|
|
|
}
|
|
|
|
|
TRigaSFascia rigatotali(0,0);
|
|
|
|
|
TString16 valore;
|
|
|
|
|
real totalefascia = ZERO;
|
|
|
|
|
for (int r=0;r<_etaini.items();r++)
|
|
|
|
|
{
|
|
|
|
|
TRigaSFascia& riga = (TRigaSFascia&)_righe[r];
|
|
|
|
|
row.reset();
|
|
|
|
|
real valreal;
|
|
|
|
|
rigastampa = "da ";
|
|
|
|
|
real* val1 = (real*)_etaini.objptr(r);
|
|
|
|
|
valreal = *val1;
|
|
|
|
|
rigastampa << valreal.string();
|
|
|
|
|
rigastampa << " a ";
|
|
|
|
|
real* val2 = (real*)_etafin.objptr(r);
|
|
|
|
|
valreal = *val2;
|
|
|
|
|
rigastampa << valreal.string();
|
|
|
|
|
rigastampa << " anni";
|
|
|
|
|
totalefascia = ZERO;
|
|
|
|
|
for (int j=0;j<_colonne->items();j++)
|
|
|
|
|
totalefascia+=riga[j];
|
|
|
|
|
// ciclo per stampa
|
|
|
|
|
int pos = 15;
|
|
|
|
|
for (j=0;j<_colonne->items();j++)
|
|
|
|
|
{
|
|
|
|
|
rigatotali.aggiorna_valore(j,riga[j]);
|
1998-02-11 14:43:07 +00:00
|
|
|
|
valore = "";
|
2003-06-19 12:57:18 +00:00
|
|
|
|
valore.format("%8s",riga[j].string(8,0));
|
1998-02-11 14:43:07 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
pos=pos+10;
|
|
|
|
|
if (totalefascia != ZERO)
|
|
|
|
|
{
|
|
|
|
|
real perc = (riga[j]/totalefascia)*100;
|
|
|
|
|
valore = "";
|
|
|
|
|
valore << perc.string(3,2);
|
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
|
}
|
|
|
|
|
pos = pos+6;
|
|
|
|
|
if (totalegenerale != ZERO)
|
|
|
|
|
{
|
|
|
|
|
real perc = (riga[j]/totalegenerale)*100;
|
|
|
|
|
valore = "";
|
|
|
|
|
valore << perc.string(3,2);
|
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
|
}
|
|
|
|
|
pos = pos+6;
|
|
|
|
|
}
|
|
|
|
|
if (totalefascia != ZERO)
|
1998-02-05 07:50:15 +00:00
|
|
|
|
{
|
|
|
|
|
valore = "";
|
2003-06-19 12:57:18 +00:00
|
|
|
|
valore.format("%8s",totalefascia.string(8,0));
|
1998-02-05 07:50:15 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
pos=pos+10;
|
|
|
|
|
if (totalegenerale != ZERO)
|
|
|
|
|
{
|
|
|
|
|
real perc = (totalefascia/totalegenerale)*100;
|
|
|
|
|
valore = "";
|
|
|
|
|
valore << perc.string(3,2);
|
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
|
pos = pos+6;
|
|
|
|
|
}
|
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stampa totali per sezione
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa.fill('-',120);
|
|
|
|
|
row.reset();
|
|
|
|
|
row.put(rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
row.reset();
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa = "Totale";
|
|
|
|
|
real totale;
|
|
|
|
|
totale = ZERO;
|
|
|
|
|
int pos = 15;
|
|
|
|
|
for (int i=0;i<_colonne->items();i++)
|
|
|
|
|
{
|
|
|
|
|
totale+=rigatotali[i];
|
1998-02-04 13:46:27 +00:00
|
|
|
|
valore = "";
|
2003-06-19 12:57:18 +00:00
|
|
|
|
valore.format("%8s",rigatotali[i].string(8,0));
|
1998-02-05 07:50:15 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
pos=pos+16;
|
1998-02-05 07:50:15 +00:00
|
|
|
|
if (totalegenerale != ZERO)
|
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
real perc = (rigatotali[i]/totalegenerale)*100;
|
1998-02-05 07:50:15 +00:00
|
|
|
|
valore = "";
|
|
|
|
|
valore << perc.string(3,2);
|
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
pos = pos+6;
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
valore = "";
|
2003-06-19 12:57:18 +00:00
|
|
|
|
valore.format("%8s",totale.string(8,0));
|
1998-02-04 13:46:27 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
printer().formfeed();
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatSogxEta::riepilogo()
|
|
|
|
|
{
|
|
|
|
|
if (crea_colonne() && crea_righe())
|
|
|
|
|
{
|
|
|
|
|
// cancello i risultati della elaborazione precedente
|
|
|
|
|
TLocalisamfile stat(LF_ATSTATS);
|
|
|
|
|
for (stat.first(); !stat.eof(); stat.next())
|
|
|
|
|
stat.remove();
|
|
|
|
|
stat.setkey(1);
|
|
|
|
|
_cur = new TCursor(_rel, "", 1);
|
|
|
|
|
TString256 filtro = "";
|
|
|
|
|
// filtro per sezione/sottogruppo
|
1999-01-26 14:35:45 +00:00
|
|
|
|
if (_sezini.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (_sotini.not_empty())
|
|
|
|
|
{
|
|
|
|
|
filtro << "(";
|
|
|
|
|
filtro << format("(90->CODSEZ > \"%s\")",(const char*)_sezini);
|
|
|
|
|
filtro << " || ";
|
|
|
|
|
filtro << "(" << format("(90->CODSEZ == \"%s\")",(const char*)_sezini);
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(90->CODSOT >= \"%s\")",(const char*)_sotini);
|
|
|
|
|
filtro << ")";
|
|
|
|
|
filtro << ")";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filtro << format("(90->CODSEZ >= \"%s\")",(const char*)_sezini);
|
|
|
|
|
}
|
|
|
|
|
if (_sezfin.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
|
|
|
|
|
if (_sotfin.not_empty())
|
|
|
|
|
{
|
|
|
|
|
filtro << "(";
|
|
|
|
|
filtro << format("(90->CODSEZ < \"%s\")",(const char*)_sezfin);
|
|
|
|
|
filtro << " || ";
|
|
|
|
|
filtro << "(" << format("(90->CODSEZ == \"%s\")",(const char*)_sezfin);
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(90->CODSOT <= \"%s\")",(const char*)_sotfin);
|
|
|
|
|
filtro << ")";
|
|
|
|
|
filtro << ")";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filtro << format("(90->CODSEZ <= \"%s\")",(const char*)_sezfin);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
2000-05-04 14:51:39 +00:00
|
|
|
|
if (_pergruppo)
|
|
|
|
|
{
|
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
if (_gruppoazie.not_empty())
|
|
|
|
|
filtro << format("(90->GRUPPOAZIE == \"%s\")",(const char*)_gruppoazie);
|
|
|
|
|
else
|
|
|
|
|
filtro << format("(90->GRUPPOAZIE != \"\")");
|
|
|
|
|
}
|
|
|
|
|
_cur->setfilter((const char*) filtro, TRUE);
|
|
|
|
|
TString16 codsez, codsot, catdon, catcoll, gruppoazie;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
long numero;
|
|
|
|
|
TString16 sesso;
|
|
|
|
|
int eta, fascia;
|
1998-05-25 13:23:33 +00:00
|
|
|
|
TDate datanasc, dataisc, datadim;
|
|
|
|
|
bool catdim, ok;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
const int anno = oggi.year();
|
2002-10-24 09:09:39 +00:00
|
|
|
|
catdim = cache().get("CTD", _catdon).get_bool("B0");
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TRectype& recsog = _cur->curr();
|
|
|
|
|
long last = _cur->items();
|
|
|
|
|
TProgind prg (last, "Elaborazione in corso... Prego attendere", FALSE, TRUE, 30);
|
|
|
|
|
for ( *_cur=0; _cur->pos() < last; ++(*_cur) )
|
|
|
|
|
{
|
|
|
|
|
prg.addstatus(1);
|
1998-05-25 13:23:33 +00:00
|
|
|
|
catdon = recsog.get(SOG_CATDON);
|
|
|
|
|
catcoll = "";
|
|
|
|
|
dataisc = NULLDATE;
|
|
|
|
|
datadim = NULLDATE;
|
1999-02-02 14:43:55 +00:00
|
|
|
|
ok = FALSE;
|
1998-05-25 13:23:33 +00:00
|
|
|
|
if (catdon.not_empty())
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1999-02-02 14:43:55 +00:00
|
|
|
|
if (_catdon.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (catdim)
|
|
|
|
|
{
|
|
|
|
|
datadim = recsog.get_date(SOG_DATADIM);
|
|
|
|
|
ok = ((catdon == _catdon) && (datadim <= _data));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dataisc = recsog.get_date(SOG_DATAISC);
|
|
|
|
|
ok = ((catdon == _catdon) && (dataisc <= _data));
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
2002-10-24 09:09:39 +00:00
|
|
|
|
catcoll = cache().get("CTD", catdon).get("S6");
|
|
|
|
|
datadim = recsog.get_date(SOG_DATADIM);
|
|
|
|
|
ok = ((catcoll == _catdon) && (dataisc <= _data) && (datadim > _data));
|
1999-02-02 14:43:55 +00:00
|
|
|
|
// se la categoria collegata <20> vuota occorre esaminare lo storico
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-05-25 13:23:33 +00:00
|
|
|
|
else
|
1999-02-02 14:43:55 +00:00
|
|
|
|
{
|
1998-05-25 13:23:33 +00:00
|
|
|
|
dataisc = recsog.get_date(SOG_DATAISC);
|
1999-02-02 14:43:55 +00:00
|
|
|
|
datadim = recsog.get_date(SOG_DATADIM);
|
2002-10-24 09:09:39 +00:00
|
|
|
|
if (cache().get("CTD", catdon).get_bool("B0"))
|
|
|
|
|
ok = ((dataisc <= _data) && (datadim > _data));
|
|
|
|
|
else
|
|
|
|
|
ok = (dataisc <= _data);
|
1999-02-02 14:43:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-05-25 13:23:33 +00:00
|
|
|
|
if (ok)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
2000-05-04 14:51:39 +00:00
|
|
|
|
if (_pergruppo)
|
|
|
|
|
{
|
|
|
|
|
gruppoazie = recsog.get(SOG_GRUPPOAZIE);
|
|
|
|
|
codsez = gruppoazie.sub(0,2);
|
|
|
|
|
codsot = gruppoazie.sub(2,4);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
codsez = recsog.get(SOG_CODSEZ);
|
|
|
|
|
codsot = recsog.get(SOG_CODSOT);
|
|
|
|
|
}
|
1998-05-25 13:23:33 +00:00
|
|
|
|
datanasc = recsog.get_date(SOG_DATANASC);
|
|
|
|
|
eta = _data.year() - datanasc.year();
|
|
|
|
|
fascia = data2row(eta);
|
|
|
|
|
sesso = recsog.get(SOG_SESSO);
|
|
|
|
|
if (sesso.empty())
|
|
|
|
|
sesso = "9";
|
1999-01-26 14:35:45 +00:00
|
|
|
|
if (fascia != -1)
|
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
if (!_solotot)
|
1999-01-26 14:35:45 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
stat.zero();
|
1999-01-26 14:35:45 +00:00
|
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
stat.put(ATSS_SESSO, sesso);
|
1999-01-26 14:35:45 +00:00
|
|
|
|
stat.put(ATSS_FASCIA, fascia);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
|
numero++;
|
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
|
stat.rewrite();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
|
|
|
|
stat.put(ATSS_SESSO, sesso);
|
|
|
|
|
stat.put(ATSS_FASCIA, fascia);
|
|
|
|
|
numero = 1;
|
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
|
stat.write();
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-01-26 14:35:45 +00:00
|
|
|
|
stat.zero();
|
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
|
stat.put(ATSS_SESSO, sesso);
|
|
|
|
|
stat.put(ATSS_FASCIA, fascia);
|
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
|
numero++;
|
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
|
stat.rewrite();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
|
stat.put(ATSS_SESSO, sesso);
|
|
|
|
|
stat.put(ATSS_FASCIA, fascia);
|
|
|
|
|
numero = 1;
|
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
|
stat.write();
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-05-25 13:23:33 +00:00
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
return (stat.eod() > 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1997-03-20 10:33:28 +00:00
|
|
|
|
int at3100(int argc, char* argv[])
|
|
|
|
|
{
|
1998-02-04 13:46:27 +00:00
|
|
|
|
TStatSogxEta a;
|
|
|
|
|
a.run(argc, argv, "Statistica soggetti per sesso e eta'");
|
1997-06-17 15:50:08 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|