1998-02-04 13:46:27 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <mask.h>
|
|
|
|
|
#include <printer.h>
|
|
|
|
|
#include <progind.h>
|
2002-10-24 09:09:39 +00:00
|
|
|
|
#include <recarray.h>
|
1998-02-04 13:46:27 +00:00
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <urldefid.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "at3.h"
|
|
|
|
|
|
|
|
|
|
// nomi campi maschera
|
|
|
|
|
#include "at3700a.h"
|
|
|
|
|
|
|
|
|
|
// nomi dei campi
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
|
#include "atstats.h"
|
|
|
|
|
#include "sezioni.h"
|
|
|
|
|
|
|
|
|
|
// classe per la definizione di una riga di statistica
|
|
|
|
|
class TRigaSGruppo : public TObject
|
|
|
|
|
{
|
|
|
|
|
TString16 _gruppo, _rh;
|
|
|
|
|
TArray _valori;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
const TRigaSGruppo& copy(const TRigaSGruppo& riga);
|
|
|
|
|
public:
|
|
|
|
|
const TString16 gruppo() const { return _gruppo; }
|
|
|
|
|
const TString16 rh() const { return _rh; }
|
|
|
|
|
TObject* dup() const { return new TRigaSGruppo(*this); }
|
|
|
|
|
const TRigaSGruppo& operator = (const TRigaSGruppo& riga);
|
|
|
|
|
const real& operator [] (int colonna) const;
|
|
|
|
|
void aggiorna_valore(int colonna, const real& numero) ;
|
|
|
|
|
void azzera_valori();
|
|
|
|
|
// costruttore
|
|
|
|
|
TRigaSGruppo(TString16 gruppo, TString16 rh) {_gruppo = gruppo; _rh = rh;}
|
|
|
|
|
// costruttore di copia
|
|
|
|
|
TRigaSGruppo(const TRigaSGruppo& riga) { copy(riga); }
|
|
|
|
|
virtual ~TRigaSGruppo() {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TRigaSGruppo& TRigaSGruppo::copy(const TRigaSGruppo& riga)
|
|
|
|
|
{
|
|
|
|
|
_gruppo = riga._gruppo;
|
|
|
|
|
_rh = riga._rh;
|
|
|
|
|
_valori = riga._valori;
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRigaSGruppo& TRigaSGruppo::operator = (const TRigaSGruppo& riga)
|
|
|
|
|
{
|
|
|
|
|
copy(riga);
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const real& TRigaSGruppo::operator [] (int colonna) const
|
|
|
|
|
{
|
|
|
|
|
real* valore = (real*)_valori.objptr(colonna);
|
|
|
|
|
if (valore == NULL)
|
|
|
|
|
return ZERO;
|
|
|
|
|
else
|
|
|
|
|
return *valore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRigaSGruppo::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 TRigaSGruppo::azzera_valori()
|
|
|
|
|
{
|
|
|
|
|
_valori.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TStatisticaSog : public TApplication
|
|
|
|
|
{
|
|
|
|
|
TMask* _msk;
|
|
|
|
|
TRelation* _rel;
|
|
|
|
|
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;
|
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
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
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; }
|
|
|
|
|
int data2row(const TString16 gruppo, const TString16 rh);
|
|
|
|
|
bool riepilogo();
|
|
|
|
|
bool stampa();
|
|
|
|
|
bool crea_colonne();
|
|
|
|
|
bool crea_righe();
|
|
|
|
|
void azzera_righe();
|
|
|
|
|
void stampa_sezione(TString16 codsez, TString16 codsot);
|
|
|
|
|
void crea_intestazione();
|
|
|
|
|
public:
|
|
|
|
|
TStatisticaSog() {}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HIDDEN inline TStatisticaSog& app() { return (TStatisticaSog&) main_app(); }
|
|
|
|
|
|
|
|
|
|
int TStatisticaSog::data2row(const TString16 gruppo, const TString16 rh)
|
|
|
|
|
{
|
|
|
|
|
int igruppo = 0;
|
|
|
|
|
int irh = 0;
|
|
|
|
|
if (gruppo == "0")
|
|
|
|
|
igruppo = 1;
|
|
|
|
|
if (gruppo == "A")
|
|
|
|
|
igruppo = 2;
|
|
|
|
|
if (gruppo == "A1")
|
|
|
|
|
igruppo = 3;
|
|
|
|
|
if (gruppo == "A2")
|
|
|
|
|
igruppo = 4;
|
|
|
|
|
if (gruppo == "A1B")
|
|
|
|
|
igruppo = 5;
|
|
|
|
|
if (gruppo == "A2B")
|
|
|
|
|
igruppo = 6;
|
|
|
|
|
if (gruppo == "AB")
|
|
|
|
|
igruppo = 7;
|
|
|
|
|
if (gruppo == "B")
|
|
|
|
|
igruppo = 8;
|
|
|
|
|
if (rh == "POS")
|
|
|
|
|
irh = 1;
|
|
|
|
|
if (rh == "NEG")
|
|
|
|
|
irh = 2;
|
|
|
|
|
return igruppo*10 + irh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::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 TStatisticaSog::crea_righe()
|
|
|
|
|
{
|
|
|
|
|
TString16 gruppo, rh;
|
|
|
|
|
for (int igruppo=0;igruppo<=8;igruppo++)
|
|
|
|
|
{
|
|
|
|
|
switch (igruppo)
|
|
|
|
|
{
|
|
|
|
|
case 0 : gruppo = ""; break;
|
|
|
|
|
case 1 : gruppo = "0"; break;
|
|
|
|
|
case 2 : gruppo = "A"; break;
|
|
|
|
|
case 3 : gruppo = "A1"; break;
|
|
|
|
|
case 4 : gruppo = "A2"; break;
|
|
|
|
|
case 5 : gruppo = "A1B"; break;
|
|
|
|
|
case 6 : gruppo = "A2B"; break;
|
|
|
|
|
case 7 : gruppo = "AB"; break;
|
|
|
|
|
case 8 : gruppo = "B"; break;
|
|
|
|
|
}
|
|
|
|
|
for (int irh=0;irh <=2;irh++)
|
|
|
|
|
{
|
|
|
|
|
switch (irh)
|
|
|
|
|
{
|
|
|
|
|
case 1 : rh = "POS"; break;
|
|
|
|
|
case 2 : rh = "NEG"; break;
|
|
|
|
|
default : rh = " "; break;
|
|
|
|
|
}
|
|
|
|
|
_righe.add(new TRigaSGruppo(gruppo, rh), data2row(gruppo, rh));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _righe.items()>0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::create()
|
|
|
|
|
{
|
|
|
|
|
TApplication::create();
|
|
|
|
|
_msk = new TMask("at3700a");
|
|
|
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
|
|
|
_soggetti = new TLocalisamfile(LF_SOGGETTI);
|
|
|
|
|
_atstats = new TLocalisamfile(LF_ATSTATS);
|
|
|
|
|
_sezioni = new TLocalisamfile(LF_SEZIONI);
|
|
|
|
|
_colonne = new TAssoc_array();
|
2009-05-25 15:22:21 +00:00
|
|
|
|
dispatch_e_menu(BAR_ITEM_ID(1));
|
1998-02-04 13:46:27 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::destroy()
|
|
|
|
|
{
|
1998-08-07 10:04:30 +00:00
|
|
|
|
delete _colonne;
|
|
|
|
|
delete _sezioni;
|
|
|
|
|
delete _atstats;
|
|
|
|
|
delete _soggetti;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
delete _rel;
|
|
|
|
|
delete _msk;
|
|
|
|
|
return TApplication::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::menu(MENU_TAG m)
|
|
|
|
|
{
|
|
|
|
|
TMask& msk = get_mask();
|
|
|
|
|
KEY tasto;
|
|
|
|
|
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);
|
1999-03-08 15:03:47 +00:00
|
|
|
|
_solotot = msk.get_bool(F_SOLOTOT);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
if (riepilogo())
|
|
|
|
|
stampa();
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TStatisticaSog::crea_intestazione()
|
|
|
|
|
{
|
|
|
|
|
TPrintrow row;
|
|
|
|
|
TString256 sep;
|
|
|
|
|
sep = "STATISTICA SOGGETTI PER SESSO, GRUPPO E RH al ";
|
|
|
|
|
sep << _data.string();
|
|
|
|
|
sep.center_just(80);
|
|
|
|
|
row.put(sep);
|
|
|
|
|
row.put("@>", 1);
|
|
|
|
|
row.put("Pag. @#", 70);
|
|
|
|
|
printer().setheaderline(2, row);
|
|
|
|
|
sep = "";
|
1999-02-02 14:43:55 +00:00
|
|
|
|
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-04 13:46:27 +00:00
|
|
|
|
sep.center_just(80);
|
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(3, row);
|
|
|
|
|
sep = "";
|
|
|
|
|
sep << "Gruppo/Rh Sconosciuto Maschi Femmine Non spec. Totale";
|
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(5, row);
|
|
|
|
|
sep = "";
|
1999-01-26 14:23:33 +00:00
|
|
|
|
sep.fill('-',80);
|
1998-02-04 13:46:27 +00:00
|
|
|
|
row.reset();
|
|
|
|
|
row.put(sep);
|
|
|
|
|
printer().setheaderline(6, row);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::stampa()
|
|
|
|
|
{
|
|
|
|
|
if (printer().open())
|
|
|
|
|
{
|
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 gruppo, rh, sesso;
|
|
|
|
|
long last = curstat->items();
|
|
|
|
|
for ( *curstat=0; curstat->pos() < last; ++(*curstat) )
|
|
|
|
|
{
|
|
|
|
|
actsez = curstat->curr().get(ATSS_CODSEZ);
|
|
|
|
|
actsot = curstat->curr().get(ATSS_CODSOT);
|
|
|
|
|
gruppo = curstat->curr().get(ATSS_GRUPPO);
|
|
|
|
|
rh = curstat->curr().get(ATSS_RH);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
TRigaSGruppo& riga = (TRigaSGruppo&)_righe[data2row(gruppo,rh)];
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TStatisticaSog::azzera_righe()
|
|
|
|
|
{
|
|
|
|
|
TString16 gruppo, rh;
|
|
|
|
|
for (int igruppo=0;igruppo<=8;igruppo++)
|
|
|
|
|
{
|
|
|
|
|
switch (igruppo)
|
|
|
|
|
{
|
|
|
|
|
case 0 : gruppo = ""; break;
|
|
|
|
|
case 1 : gruppo = "0"; break;
|
|
|
|
|
case 2 : gruppo = "A"; break;
|
|
|
|
|
case 3 : gruppo = "A1"; break;
|
|
|
|
|
case 4 : gruppo = "A2"; break;
|
|
|
|
|
case 5 : gruppo = "A1B"; break;
|
|
|
|
|
case 6 : gruppo = "A2B"; break;
|
|
|
|
|
case 7 : gruppo = "AB"; break;
|
|
|
|
|
case 8 : gruppo = "B"; break;
|
|
|
|
|
}
|
|
|
|
|
for (int irh=0;irh <=2;irh++)
|
|
|
|
|
{
|
|
|
|
|
switch (irh)
|
|
|
|
|
{
|
|
|
|
|
case 1 : rh = "POS"; break;
|
|
|
|
|
case 2 : rh = "NEG"; break;
|
|
|
|
|
default : rh = " "; break;
|
|
|
|
|
}
|
|
|
|
|
TRigaSGruppo& riga = (TRigaSGruppo&)_righe[data2row(gruppo,rh)];
|
|
|
|
|
riga.azzera_valori();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TStatisticaSog::stampa_sezione(TString16 codsez, TString16 codsot)
|
|
|
|
|
{
|
|
|
|
|
TPrintrow row;
|
|
|
|
|
TString256 rigastampa;
|
1999-01-26 14:23:33 +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:23:33 +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:23:33 +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:23:33 +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:23:33 +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:23:33 +00:00
|
|
|
|
}
|
2000-05-04 14:51:39 +00:00
|
|
|
|
}
|
1999-01-26 14:23:33 +00:00
|
|
|
|
}
|
1999-03-08 15:03:47 +00:00
|
|
|
|
if ((codsez == "ZZ" && codsot == "ZZ" && _sezionistampate != 1) || (codsez != "ZZ"))
|
|
|
|
|
{
|
|
|
|
|
rigastampa.center_just(80);
|
|
|
|
|
row.put(rigastampa);
|
|
|
|
|
printer().setheaderline(1, row);
|
|
|
|
|
|
|
|
|
|
TRigaSGruppo rigatotali(" "," ");
|
|
|
|
|
TString16 valore;
|
|
|
|
|
TString16 gruppo, rh;
|
|
|
|
|
real totalegruppo = ZERO;
|
|
|
|
|
for (int igruppo=0;igruppo<=8;igruppo++)
|
|
|
|
|
{
|
|
|
|
|
switch (igruppo)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
case 0 : gruppo = ""; break;
|
|
|
|
|
case 1 : gruppo = "0"; break;
|
|
|
|
|
case 2 : gruppo = "A"; break;
|
|
|
|
|
case 3 : gruppo = "A1"; break;
|
|
|
|
|
case 4 : gruppo = "A2"; break;
|
|
|
|
|
case 5 : gruppo = "A1B"; break;
|
|
|
|
|
case 6 : gruppo = "A2B"; break;
|
|
|
|
|
case 7 : gruppo = "AB"; break;
|
|
|
|
|
case 8 : gruppo = "B"; break;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
1999-03-08 15:03:47 +00:00
|
|
|
|
for (int irh=0;irh <=2;irh++)
|
1998-02-04 13:46:27 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
switch (irh)
|
|
|
|
|
{
|
|
|
|
|
case 1 : rh = "POS"; break;
|
|
|
|
|
case 2 : rh = "NEG"; break;
|
|
|
|
|
default : rh = " "; break;
|
|
|
|
|
}
|
|
|
|
|
TRigaSGruppo& riga = (TRigaSGruppo&)_righe[data2row(gruppo,rh)];
|
|
|
|
|
row.reset();
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa << gruppo;
|
|
|
|
|
rigastampa << " ";
|
|
|
|
|
rigastampa << rh;
|
|
|
|
|
totalegruppo = ZERO;
|
|
|
|
|
int pos = 21;
|
|
|
|
|
for (int i=0;i<_colonne->items();i++)
|
|
|
|
|
{
|
|
|
|
|
rigatotali.aggiorna_valore(i,riga[i]);
|
|
|
|
|
totalegruppo+=riga[i];
|
|
|
|
|
valore = "";
|
2003-06-23 10:31:12 +00:00
|
|
|
|
valore.format("%8s",riga[i].string(8,0));
|
1999-03-08 15:03:47 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
|
pos = pos+10;
|
|
|
|
|
}
|
|
|
|
|
if (totalegruppo != 0)
|
|
|
|
|
{
|
|
|
|
|
valore = "";
|
2003-06-23 10:31:12 +00:00
|
|
|
|
valore.format("%8s",totalegruppo.string(8,0));
|
1999-03-08 15:03:47 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos+4);
|
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// stampa totali per sezione
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa.fill('-',80);
|
|
|
|
|
row.reset();
|
|
|
|
|
row.put(rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
row.reset();
|
|
|
|
|
rigastampa = "";
|
|
|
|
|
rigastampa = "Totale";
|
|
|
|
|
real totale;
|
|
|
|
|
totale = ZERO;
|
|
|
|
|
int pos = 21;
|
|
|
|
|
for (int i=0;i<_colonne->items();i++)
|
|
|
|
|
{
|
|
|
|
|
totale+=rigatotali[i];
|
|
|
|
|
valore = "";
|
2003-06-23 10:31:12 +00:00
|
|
|
|
valore.format("%8s",rigatotali[i].string(8,0));
|
1999-03-08 15:03:47 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
|
pos = pos+10;
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
valore = "";
|
2003-06-23 10:31:12 +00:00
|
|
|
|
valore.format("%8s",totale.string(8,0));
|
1999-03-08 15:03:47 +00:00
|
|
|
|
rigastampa.overwrite((const char*)valore, pos+4);
|
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
|
printer().print(row);
|
|
|
|
|
printer().formfeed();
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TStatisticaSog::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:23:33 +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 != \"\")");
|
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
|
_cur->setfilter((const char*) filtro, TRUE);
|
2000-05-04 14:51:39 +00:00
|
|
|
|
TString16 codsez, codsot, catdon, catcoll, gruppoazie;
|
1998-02-04 13:46:27 +00:00
|
|
|
|
long numero;
|
|
|
|
|
TString16 gruppo, rh, sesso;
|
1998-05-25 13:23:33 +00:00
|
|
|
|
TDate dataisc, datadim;
|
|
|
|
|
bool catdim, ok;
|
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;
|
|
|
|
|
ok = FALSE;
|
|
|
|
|
if (catdon.not_empty())
|
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");
|
1999-02-02 14:43:55 +00:00
|
|
|
|
datadim = recsog.get_date(SOG_DATADIM);
|
|
|
|
|
ok = ((catcoll == _catdon) && (dataisc <= _data) && (datadim > _data));
|
|
|
|
|
// 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
|
|
|
|
gruppo = recsog.get(SOG_GRUPPOAB0);
|
|
|
|
|
rh = recsog.get(SOG_RHANTID);
|
|
|
|
|
sesso = recsog.get(SOG_SESSO);
|
|
|
|
|
if (sesso.empty())
|
|
|
|
|
sesso = "9";
|
|
|
|
|
if (gruppo == "A1" || gruppo == "A2")
|
|
|
|
|
gruppo = "A";
|
|
|
|
|
if (gruppo == "A1B" || gruppo == "A2B")
|
|
|
|
|
gruppo = "AB";
|
1999-03-08 15:03:47 +00:00
|
|
|
|
if (!_solotot)
|
1998-05-25 13:23:33 +00:00
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
|
stat.zero();
|
1998-05-25 13:23:33 +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);
|
1998-05-25 13:23:33 +00:00
|
|
|
|
stat.put(ATSS_GRUPPO, gruppo);
|
|
|
|
|
stat.put(ATSS_RH, rh);
|
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_GRUPPO, gruppo);
|
|
|
|
|
stat.put(ATSS_RH, rh);
|
|
|
|
|
numero = 1;
|
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
|
stat.write();
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-01-26 14:23:33 +00:00
|
|
|
|
stat.zero();
|
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
|
stat.put(ATSS_SESSO, sesso);
|
|
|
|
|
stat.put(ATSS_GRUPPO, gruppo);
|
|
|
|
|
stat.put(ATSS_RH, rh);
|
|
|
|
|
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_GRUPPO, gruppo);
|
|
|
|
|
stat.put(ATSS_RH, rh);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int at3700(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TStatisticaSog a;
|
|
|
|
|
a.run(argc, argv, "Statistica soggetti per sesso, gruppo e rh");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|