1998-02-04 13:46:27 +00:00
|
|
|
#include <applicat.h>
|
|
|
|
#include <mask.h>
|
|
|
|
#include <printer.h>
|
|
|
|
#include <progind.h>
|
|
|
|
#include <real.h>
|
|
|
|
#include <relation.h>
|
|
|
|
#include <tabutil.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include "at3.h"
|
|
|
|
|
|
|
|
// nomi campi maschera
|
|
|
|
#include "at3300a.h"
|
|
|
|
|
|
|
|
// nomi dei campi
|
|
|
|
#include "soggetti.h"
|
|
|
|
#include "atstats.h"
|
|
|
|
#include "sezioni.h"
|
|
|
|
|
|
|
|
// classe per la definizione di una riga di statistica
|
|
|
|
class TRigaSxCat : public TObject
|
|
|
|
{
|
|
|
|
TString16 _catdon;
|
|
|
|
TArray _valori;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const TRigaSxCat& copy(const TRigaSxCat& riga);
|
|
|
|
public:
|
|
|
|
const TString16 catdon() const { return _catdon; }
|
|
|
|
TObject* dup() const { return new TRigaSxCat(*this); }
|
|
|
|
const TRigaSxCat& operator = (const TRigaSxCat& riga);
|
|
|
|
const real& operator [] (int colonna) const;
|
|
|
|
void aggiorna_valore(int colonna, const real& numero) ;
|
|
|
|
void azzera_valori();
|
|
|
|
// costruttore
|
|
|
|
TRigaSxCat(TString16 catdon) {_catdon = catdon;}
|
|
|
|
// costruttore di copia
|
|
|
|
TRigaSxCat(const TRigaSxCat& riga) { copy(riga); }
|
|
|
|
virtual ~TRigaSxCat() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
const TRigaSxCat& TRigaSxCat::copy(const TRigaSxCat& riga)
|
|
|
|
{
|
|
|
|
_catdon = riga._catdon;
|
|
|
|
_valori = riga._valori;
|
|
|
|
return (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const TRigaSxCat& TRigaSxCat::operator = (const TRigaSxCat& riga)
|
|
|
|
{
|
|
|
|
copy(riga);
|
|
|
|
return (*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const real& TRigaSxCat::operator [] (int colonna) const
|
|
|
|
{
|
|
|
|
real* valore = (real*)_valori.objptr(colonna);
|
|
|
|
if (valore == NULL)
|
|
|
|
return ZERO;
|
|
|
|
else
|
|
|
|
return *valore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRigaSxCat::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 TRigaSxCat::azzera_valori()
|
|
|
|
{
|
|
|
|
_valori.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
class TStatSogxCat : public TApplication
|
|
|
|
{
|
|
|
|
TMask* _msk;
|
|
|
|
TRelation* _rel;
|
|
|
|
TCursor* _cur;
|
|
|
|
TLocalisamfile* _sezioni;
|
|
|
|
TLocalisamfile* _soggetti;
|
|
|
|
TLocalisamfile* _atstats;
|
|
|
|
TAssoc_array* _colonne;
|
|
|
|
TAssoc_array* _categorie;
|
|
|
|
TArray _righe;
|
2000-05-04 14:51:39 +00:00
|
|
|
TString16 _sezini, _sotini, _sezfin, _sotfin, _gruppoazie;
|
1998-02-04 13:46:27 +00:00
|
|
|
TDate _dataini, _datafin;
|
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 catdon);
|
|
|
|
bool riepilogo();
|
|
|
|
bool stampa();
|
|
|
|
bool crea_colonne();
|
|
|
|
bool crea_righe();
|
|
|
|
void azzera_righe();
|
|
|
|
void stampa_sezione(TString16 codsez, TString16 codsot);
|
|
|
|
void crea_intestazione();
|
|
|
|
public:
|
|
|
|
TStatSogxCat() {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
HIDDEN inline TStatSogxCat& app() { return (TStatSogxCat&) main_app(); }
|
|
|
|
|
|
|
|
int TStatSogxCat::data2row(const TString16 catdon)
|
|
|
|
{
|
|
|
|
real& indicer = (real&)_categorie->find((const char*) catdon);
|
1998-02-06 15:44:00 +00:00
|
|
|
return ((int) indicer.integer());
|
1998-02-04 13:46:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::crea_colonne()
|
|
|
|
{
|
|
|
|
_colonne->destroy();
|
|
|
|
real contatore(ZERO);
|
|
|
|
real* oggetto = new real(contatore);
|
|
|
|
const char* indice = "N"; // nuovi
|
|
|
|
_colonne->add(indice,(TObject*)oggetto);
|
|
|
|
indice = "T"; // totale
|
|
|
|
contatore = contatore+1;
|
|
|
|
real* oggetto2 = new real(contatore);
|
|
|
|
_colonne->add(indice,(TObject*)oggetto2);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::crea_righe()
|
|
|
|
{
|
|
|
|
TTable ctd("CTD");
|
|
|
|
TString16 catdon = "**";
|
|
|
|
int indice = 0;
|
|
|
|
_categorie->destroy();
|
|
|
|
real* oggetto1 = new real(indice);
|
|
|
|
_categorie->add((const char*) catdon, (TObject*) oggetto1);
|
|
|
|
_righe.add(new TRigaSxCat(catdon), indice);
|
|
|
|
for (ctd.first(); !ctd.eof(); ctd.next())
|
|
|
|
{
|
|
|
|
indice++;
|
|
|
|
catdon = ctd.get("CODTAB");
|
|
|
|
_righe.add(new TRigaSxCat(catdon), indice);
|
|
|
|
real* oggetto = new real(indice);
|
|
|
|
_categorie->add((const char*) catdon,(TObject*) oggetto);
|
|
|
|
}
|
|
|
|
return _righe.items()>0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::create()
|
|
|
|
{
|
|
|
|
TApplication::create();
|
|
|
|
_msk = new TMask("at3300a");
|
|
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
|
|
_soggetti = new TLocalisamfile(LF_SOGGETTI);
|
|
|
|
_atstats = new TLocalisamfile(LF_ATSTATS);
|
|
|
|
_sezioni = new TLocalisamfile(LF_SEZIONI);
|
|
|
|
_colonne = new TAssoc_array();
|
|
|
|
_categorie = new TAssoc_array();
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::destroy()
|
|
|
|
{
|
1998-08-07 10:04:30 +00:00
|
|
|
delete _categorie;
|
|
|
|
delete _colonne;
|
|
|
|
delete _sezioni;
|
|
|
|
delete _atstats;
|
|
|
|
delete _soggetti;
|
1998-02-04 13:46:27 +00:00
|
|
|
delete _rel;
|
|
|
|
delete _msk;
|
|
|
|
return TApplication::destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::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);
|
|
|
|
_dataini = _msk->get_date(F_DATAINI);
|
|
|
|
_datafin = _msk->get_date(F_DATAFIN);
|
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 TStatSogxCat::crea_intestazione()
|
|
|
|
{
|
|
|
|
TPrintrow row;
|
|
|
|
TString256 sep;
|
|
|
|
sep = "STATISTICA SOGGETTI PER CATEGORIA";
|
|
|
|
sep.center_just(80);
|
|
|
|
row.put(sep);
|
|
|
|
row.put("@>", 1);
|
|
|
|
row.put("Pag. @#", 70);
|
|
|
|
printer().setheaderline(2, row);
|
|
|
|
sep = "dal ";
|
|
|
|
sep << _dataini.string();
|
|
|
|
sep << " al ";
|
|
|
|
sep << _datafin.string();
|
|
|
|
sep.center_just(80);
|
|
|
|
row.reset();
|
|
|
|
row.put(sep);
|
|
|
|
printer().setheaderline(3, row);
|
|
|
|
sep = "";
|
|
|
|
sep << "Categoria Nuovi Totale";
|
|
|
|
row.reset();
|
|
|
|
row.put(sep);
|
|
|
|
printer().setheaderline(5, row);
|
|
|
|
sep = "";
|
1999-01-26 14:33:12 +00:00
|
|
|
sep.fill('-',80);
|
1998-02-04 13:46:27 +00:00
|
|
|
row.reset();
|
|
|
|
row.put(sep);
|
|
|
|
printer().setheaderline(6, row);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::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, numero2;
|
|
|
|
TString16 actsez, actsot;
|
|
|
|
TString16 catdon;
|
|
|
|
long last = curstat->items();
|
|
|
|
for ( *curstat=0; curstat->pos() < last; ++(*curstat) )
|
|
|
|
{
|
|
|
|
actsez = curstat->curr().get(ATSS_CODSEZ);
|
|
|
|
actsot = curstat->curr().get(ATSS_CODSOT);
|
|
|
|
catdon = curstat->curr().get(ATSS_CATDON);
|
2000-03-03 11:47:59 +00:00
|
|
|
numero = (double)curstat->curr().get_long(ATSS_NUMERO);
|
|
|
|
numero2 = (double)curstat->curr().get_long(ATSS_NUMERO2);
|
1998-02-04 13:46:27 +00:00
|
|
|
if (actsez != oldsez || actsot != oldsot)
|
|
|
|
{
|
|
|
|
if (oldsez != "**" && oldsot != "**")
|
|
|
|
{
|
|
|
|
stampa_sezione(oldsez,oldsot);
|
|
|
|
azzera_righe();
|
|
|
|
}
|
|
|
|
oldsez = actsez;
|
|
|
|
oldsot = actsot;
|
|
|
|
}
|
|
|
|
if (catdon.empty())
|
|
|
|
catdon = "**";
|
|
|
|
TRigaSxCat& riga = (TRigaSxCat&)_righe[data2row(catdon)];
|
|
|
|
const char* indicen = "N";
|
|
|
|
real& colonnan = (real&)_colonne->find(indicen);
|
|
|
|
real n = numero;
|
1998-02-06 15:44:00 +00:00
|
|
|
riga.aggiorna_valore((int) colonnan.integer(),n);
|
1998-02-04 13:46:27 +00:00
|
|
|
const char* indicet = "T";
|
|
|
|
real& colonnat = (real&)_colonne->find(indicet);
|
|
|
|
n = numero2;
|
1998-02-06 15:44:00 +00:00
|
|
|
riga.aggiorna_valore((int) colonnat.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 TStatSogxCat::azzera_righe()
|
|
|
|
{
|
|
|
|
TString16 catdon = "**";
|
|
|
|
int indice = data2row(catdon);
|
|
|
|
TRigaSxCat& riga = (TRigaSxCat&)_righe[indice];
|
|
|
|
riga.azzera_valori();
|
|
|
|
TTable ctd("CTD");
|
|
|
|
for (ctd.first(); !ctd.eof(); ctd.next())
|
|
|
|
{
|
|
|
|
catdon = ctd.get("CODTAB");
|
|
|
|
indice = data2row(catdon);
|
|
|
|
TRigaSxCat& riga = (TRigaSxCat&)_righe[indice];
|
|
|
|
riga.azzera_valori();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TStatSogxCat::stampa_sezione(TString16 codsez, TString16 codsot)
|
|
|
|
{
|
|
|
|
TPrintrow row;
|
|
|
|
TString256 rigastampa;
|
1999-01-26 14:33:12 +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:33:12 +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:33:12 +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:33:12 +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:33:12 +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:33:12 +00:00
|
|
|
}
|
2000-05-04 14:51:39 +00:00
|
|
|
}
|
1999-01-26 14:33:12 +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);
|
|
|
|
|
|
|
|
TRigaSxCat rigatotali(" ");
|
|
|
|
TString16 valore;
|
|
|
|
TString16 catdon;
|
|
|
|
|
|
|
|
TTable ctd("CTD");
|
|
|
|
for (ctd.first(); !ctd.eof(); ctd.next())
|
|
|
|
{
|
|
|
|
TString16 catdon = ctd.get("CODTAB");
|
|
|
|
TRigaSxCat& riga = (TRigaSxCat&)_righe[data2row(catdon)];
|
|
|
|
row.reset();
|
|
|
|
rigastampa = "";
|
|
|
|
rigastampa << catdon;
|
|
|
|
rigastampa << " ";
|
|
|
|
rigastampa << ctd.get("S0");
|
|
|
|
int pos = 41;
|
|
|
|
const char* indicen = "N";
|
|
|
|
real& colonnan = (real&)_colonne->find(indicen);
|
|
|
|
rigatotali.aggiorna_valore((int) colonnan.integer(),riga[(int) colonnan.integer()]);
|
|
|
|
valore = "";
|
2000-03-03 11:47:59 +00:00
|
|
|
valore.format("%8ld",riga[(int) colonnan.integer()].integer());
|
1999-03-08 15:03:47 +00:00
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
pos = pos+8;
|
|
|
|
const char* indicet = "T";
|
|
|
|
real& colonnat = (real&)_colonne->find(indicet);
|
|
|
|
rigatotali.aggiorna_valore((int) colonnat.integer(),riga[(int) colonnat.integer()]);
|
|
|
|
valore = "";
|
2000-03-03 11:47:59 +00:00
|
|
|
// valore.format("%8ld",riga[(int) colonnat.integer()].integer());
|
|
|
|
valore = riga[(int) colonnat.integer()].string("####.###");
|
1999-03-08 15:03:47 +00:00
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
pos = pos+8;
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
printer().print(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
// stampa totali per sezione
|
|
|
|
rigastampa = "";
|
|
|
|
rigastampa.fill('-',80);
|
|
|
|
row.reset();
|
|
|
|
row.put(rigastampa);
|
|
|
|
printer().print(row);
|
1998-02-04 13:46:27 +00:00
|
|
|
row.reset();
|
|
|
|
rigastampa = "";
|
1999-03-08 15:03:47 +00:00
|
|
|
rigastampa = "Totale";
|
1998-02-04 13:46:27 +00:00
|
|
|
int pos = 41;
|
|
|
|
const char* indicen = "N";
|
|
|
|
real& colonnan = (real&)_colonne->find(indicen);
|
|
|
|
valore = "";
|
2000-03-03 11:47:59 +00:00
|
|
|
valore.format("%8ld",rigatotali[(int) colonnan.integer()].integer());
|
1998-02-04 13:46:27 +00:00
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
pos = pos+8;
|
|
|
|
const char* indicet = "T";
|
|
|
|
real& colonnat = (real&)_colonne->find(indicet);
|
|
|
|
valore = "";
|
2000-03-03 11:47:59 +00:00
|
|
|
valore.format("%8ld",rigatotali[(int) colonnat.integer()].integer());
|
1998-02-04 13:46:27 +00:00
|
|
|
rigastampa.overwrite((const char*)valore, pos);
|
|
|
|
pos = pos+8;
|
|
|
|
row.put((const char*) rigastampa);
|
|
|
|
printer().print(row);
|
1999-03-08 15:03:47 +00:00
|
|
|
printer().formfeed();
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TStatSogxCat::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:33:12 +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, gruppoazie;
|
1998-02-04 13:46:27 +00:00
|
|
|
long numero,numero2;
|
1998-05-15 14:31:53 +00:00
|
|
|
TString16 catdon, cati, catd;
|
1998-02-04 13:46:27 +00:00
|
|
|
TDate dataisc, datadim;
|
1998-05-15 14:31:53 +00:00
|
|
|
bool nuovoi, totalei, nuovod, totaled;
|
1998-02-04 13:46:27 +00:00
|
|
|
TTable ctd("CTD");
|
|
|
|
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-15 14:31:53 +00:00
|
|
|
nuovoi = FALSE;
|
|
|
|
totalei = FALSE;
|
|
|
|
nuovod = FALSE;
|
|
|
|
totaled = FALSE;
|
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-02-04 13:46:27 +00:00
|
|
|
catdon = recsog.get(SOG_CATDON);
|
1998-05-15 14:31:53 +00:00
|
|
|
cati = "";
|
|
|
|
catd = "";
|
1998-02-04 13:46:27 +00:00
|
|
|
if (catdon.not_empty())
|
|
|
|
{
|
|
|
|
ctd.put("CODTAB",catdon);
|
|
|
|
if (ctd.read() == NOERR)
|
|
|
|
{
|
|
|
|
bool dimissione = ctd.get_bool("B0");
|
|
|
|
if (dimissione)
|
1998-05-15 14:31:53 +00:00
|
|
|
{
|
|
|
|
catd = catdon;
|
1998-02-04 13:46:27 +00:00
|
|
|
datadim = recsog.get_date(SOG_DATADIM);
|
1998-05-15 14:31:53 +00:00
|
|
|
nuovod = (datadim >= _dataini && datadim <= _datafin);
|
|
|
|
totaled = (datadim <= _datafin);
|
|
|
|
cati = ctd.get("S6");
|
|
|
|
dataisc = recsog.get_date(SOG_DATAISC);
|
|
|
|
nuovoi = (dataisc >= _dataini && dataisc <= _datafin);
|
1998-05-25 13:23:33 +00:00
|
|
|
totalei = (dataisc <= _datafin && datadim > _datafin);
|
1998-05-15 14:31:53 +00:00
|
|
|
}
|
|
|
|
else
|
1998-02-04 13:46:27 +00:00
|
|
|
{
|
1998-05-15 14:31:53 +00:00
|
|
|
cati = catdon;
|
1998-02-04 13:46:27 +00:00
|
|
|
dataisc = recsog.get_date(SOG_DATAISC);
|
1998-05-15 14:31:53 +00:00
|
|
|
nuovoi = (dataisc >= _dataini && dataisc <= _datafin);
|
|
|
|
totalei = (dataisc <= _datafin);
|
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
}
|
1998-05-15 14:31:53 +00:00
|
|
|
}
|
|
|
|
if (cati.not_empty())
|
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
if (!_solotot)
|
1998-05-15 14:31:53 +00:00
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
stat.zero();
|
1998-05-15 14:31:53 +00:00
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
1999-03-08 15:03:47 +00:00
|
|
|
stat.put(ATSS_CATDON, cati);
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
{
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
numero2 = stat.get_long(ATSS_NUMERO2);
|
|
|
|
if (nuovoi)
|
|
|
|
numero++;
|
|
|
|
if (totalei)
|
|
|
|
numero2++;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.rewrite();
|
|
|
|
}
|
1998-05-15 14:31:53 +00:00
|
|
|
else
|
1999-03-08 15:03:47 +00:00
|
|
|
{
|
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
|
|
|
stat.put(ATSS_CATDON, cati);
|
|
|
|
if (nuovoi)
|
|
|
|
numero = 1;
|
|
|
|
else
|
|
|
|
numero = 0;
|
|
|
|
if (totalei)
|
|
|
|
numero2 = 1;
|
|
|
|
else
|
|
|
|
numero2 = 0;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.write();
|
|
|
|
}
|
|
|
|
}
|
1999-01-26 14:33:12 +00:00
|
|
|
stat.zero();
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
stat.put(ATSS_CATDON, cati);
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
{
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
numero2 = stat.get_long(ATSS_NUMERO2);
|
|
|
|
if (nuovoi)
|
|
|
|
numero++;
|
|
|
|
if (totalei)
|
|
|
|
numero2++;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.rewrite();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
stat.put(ATSS_CATDON, cati);
|
|
|
|
if (nuovoi)
|
|
|
|
numero = 1;
|
|
|
|
else
|
|
|
|
numero = 0;
|
|
|
|
if (totalei)
|
|
|
|
numero2 = 1;
|
|
|
|
else
|
|
|
|
numero2 = 0;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.write();
|
|
|
|
}
|
1998-05-15 14:31:53 +00:00
|
|
|
}
|
|
|
|
if (catd.not_empty())
|
1999-03-08 15:03:47 +00:00
|
|
|
{
|
|
|
|
if (!_solotot)
|
1998-05-15 14:31:53 +00:00
|
|
|
{
|
1999-03-08 15:03:47 +00:00
|
|
|
stat.zero();
|
1998-05-15 14:31:53 +00:00
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
1999-03-08 15:03:47 +00:00
|
|
|
stat.put(ATSS_CATDON, catd);
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
{
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
numero2 = stat.get_long(ATSS_NUMERO2);
|
|
|
|
if (nuovod)
|
|
|
|
numero++;
|
|
|
|
if (totaled)
|
|
|
|
numero2++;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.rewrite();
|
|
|
|
}
|
1998-05-15 14:31:53 +00:00
|
|
|
else
|
1999-03-08 15:03:47 +00:00
|
|
|
{
|
|
|
|
stat.put(ATSS_CODSEZ, codsez);
|
|
|
|
stat.put(ATSS_CODSOT, codsot);
|
|
|
|
stat.put(ATSS_CATDON, catd);
|
|
|
|
if (nuovod)
|
|
|
|
numero = 1;
|
|
|
|
else
|
|
|
|
numero = 0;
|
|
|
|
if (totaled)
|
|
|
|
numero2 = 1;
|
|
|
|
else
|
|
|
|
numero2 = 0;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.write();
|
|
|
|
}
|
|
|
|
}
|
1999-01-26 14:33:12 +00:00
|
|
|
stat.zero();
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
stat.put(ATSS_CATDON, catd);
|
|
|
|
if (stat.read() == NOERR)
|
|
|
|
{
|
|
|
|
numero = stat.get_long(ATSS_NUMERO);
|
|
|
|
numero2 = stat.get_long(ATSS_NUMERO2);
|
|
|
|
if (nuovod)
|
|
|
|
numero++;
|
|
|
|
if (totaled)
|
|
|
|
numero2++;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.rewrite();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stat.put(ATSS_CODSEZ, "ZZ");
|
|
|
|
stat.put(ATSS_CODSOT, "ZZ");
|
|
|
|
stat.put(ATSS_CATDON, catd);
|
|
|
|
if (nuovod)
|
|
|
|
numero = 1;
|
|
|
|
else
|
|
|
|
numero = 0;
|
|
|
|
if (totaled)
|
|
|
|
numero2 = 1;
|
|
|
|
else
|
|
|
|
numero2 = 0;
|
|
|
|
stat.put(ATSS_NUMERO, numero);
|
|
|
|
stat.put(ATSS_NUMERO2, numero2);
|
|
|
|
stat.write();
|
|
|
|
}
|
1998-05-15 14:31:53 +00:00
|
|
|
}
|
1998-02-04 13:46:27 +00:00
|
|
|
}
|
|
|
|
return (stat.eod() > 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int at3300(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TStatSogxCat a;
|
|
|
|
a.run(argc, argv, "Statistica soggetti per categoria");
|
|
|
|
return 0;
|
|
|
|
}
|