Files correlati : Ricompilazione Demo : [ ] Commento : Programmi vari per AVIS (non a menu) git-svn-id: svn://10.65.10.50/trunk@6399 c028cbd2-c16b-5b4b-a496-9718f37d4682
241 lines
6.4 KiB
C++
Executable File
241 lines
6.4 KiB
C++
Executable File
#include <mask.h>
|
||
#include <printapp.h>
|
||
#include <recarray.h>
|
||
//#include <utility.h>
|
||
|
||
#include "at7.h"
|
||
#include "atlib.h"
|
||
#include "at7800a.h"
|
||
|
||
// nomi dei campi
|
||
#include "soggetti.h"
|
||
#include "contsan.h"
|
||
#include "idoneita.h"
|
||
#include "sezioni.h"
|
||
|
||
class TRiminiRO_app : public TPrintapp
|
||
{
|
||
TMask* _msk;
|
||
TRelation* _rel;
|
||
TLocalisamfile* _contsan;
|
||
TRecord_array* _scontrolli;
|
||
TLocalisamfile* _idoneita;
|
||
TRecord_array* _sidoneita;
|
||
int _cur;
|
||
TDate _datarif;
|
||
|
||
protected:
|
||
virtual bool user_create();
|
||
virtual bool user_destroy();
|
||
virtual bool set_print(int m);
|
||
virtual void set_page(int file, int cnt);
|
||
virtual bool preprocess_page(int file, int counter);
|
||
|
||
public:
|
||
void filtra_sezioni();
|
||
TRiminiRO_app() {}
|
||
};
|
||
|
||
HIDDEN inline TRiminiRO_app& app() { return (TRiminiRO_app&) main_app(); }
|
||
|
||
void TRiminiRO_app::filtra_sezioni()
|
||
{
|
||
const TString16 sezini = _msk->get(F_SEZINI);
|
||
const TString16 sotini = _msk->get(F_SOTINI);
|
||
const TString16 sezfin = _msk->get(F_SEZFIN);
|
||
const TString16 sotfin = _msk->get(F_SOTFIN);
|
||
TRectype da(LF_SOGGETTI);
|
||
TRectype a (LF_SOGGETTI);
|
||
if (sezini.not_empty())
|
||
da.put(SOG_CODSEZ, sezini);
|
||
if (sotini.not_empty())
|
||
da.put(SOG_CODSOT, sotini);
|
||
if (sezfin.not_empty())
|
||
a.put(SOG_CODSEZ, sezfin);
|
||
if (sotfin.not_empty())
|
||
a.put(SOG_CODSOT, sotfin);
|
||
current_cursor()->setregion(da, a);
|
||
}
|
||
|
||
bool TRiminiRO_app::preprocess_page(int file, int counter)
|
||
{
|
||
bool rewrite = FALSE;
|
||
TRectype& recsog = current_cursor()->curr();
|
||
const long codice = recsog.get_long(SOG_CODICE);
|
||
TRectype* keyc = new TRectype(LF_CONTSAN);
|
||
keyc->put(CON_CODICE, codice);
|
||
int err = _scontrolli->read(keyc);
|
||
if (err == NOERR)
|
||
{
|
||
TDate primocon(NULLDATE);
|
||
TString16 tipocon;
|
||
int numido = 0;
|
||
int numcon = 0;
|
||
for (int c=1; c<=_scontrolli->rows(); c++)
|
||
{
|
||
TRectype& riga = _scontrolli->row(c, TRUE);
|
||
tipocon = riga.get(CON_TIPOCON);
|
||
TDate datacon = riga.get_date(CON_DATACON);
|
||
// mi segno la data del primo controllo per inserire una PI
|
||
// il giorno prima nei donatori che non hanno l'idoneita'
|
||
if (c==1)
|
||
primocon = datacon;
|
||
// se il controllo <20> avvenuto prima della data di riferimento
|
||
if (datacon <= _datarif)
|
||
{
|
||
if (tipocon == "RO")
|
||
{
|
||
numcon++;
|
||
riga.put(CON_TIPOCON,"R1");
|
||
riga.put(CON_IDON1," ");
|
||
riga.put(CON_IDON2," ");
|
||
riga.put(CON_IDON3," ");
|
||
riga.put(CON_IDON4," ");
|
||
riga.put(CON_INTSI,0);
|
||
riga.put(CON_INTAF,0);
|
||
}
|
||
if (tipocon == "ID")
|
||
{
|
||
TString16 motivo = riga.get(CON_MOTIVO);
|
||
TString80 responsab = riga.get(CON_RESPONSAB);
|
||
if (motivo.empty() && responsab.empty())
|
||
{
|
||
numcon++;
|
||
riga.put(CON_TIPOCON,"V1");
|
||
riga.put(CON_IDON1," ");
|
||
riga.put(CON_IDON2," ");
|
||
riga.put(CON_IDON3," ");
|
||
riga.put(CON_IDON4," ");
|
||
riga.put(CON_INTSI,0);
|
||
riga.put(CON_INTAF,0);
|
||
}
|
||
}
|
||
}
|
||
tipocon = riga.get(CON_TIPOCON);
|
||
if ((tipocon == "ID") || (tipocon == "RO") || (tipocon == "PI"))
|
||
{
|
||
numido++;
|
||
if (!((riga.get(CON_IDON1) == "PL") || (riga.get(CON_IDON2) == "PL") || (riga.get(CON_IDON3) == "PL") || (riga.get(CON_IDON4) == "PL")))
|
||
riga.put(CON_INTAF,0);
|
||
if ((riga.get(CON_IDON1).empty()) && (riga.get(CON_IDON2).empty()) && (riga.get(CON_IDON3).empty()) && (riga.get(CON_IDON4).empty()))
|
||
{
|
||
riga.put(CON_IDON1, "SI");
|
||
riga.put(CON_INTSI, recsog.get(SOG_INTSI));
|
||
if (recsog.get_int(SOG_INTSI) == 0)
|
||
riga.put(CON_INTSI, 94);
|
||
}
|
||
}
|
||
}
|
||
if ((numido == 0) && (numcon > 0))
|
||
{
|
||
--primocon;
|
||
TRectype riga(LF_CONTSAN);
|
||
riga.put(CON_CODICE, codice);
|
||
riga.put(CON_PROGCON, 1);
|
||
riga.put(CON_DATACON, primocon);
|
||
riga.put(CON_TIPOCON, "PI");
|
||
riga.put(CON_IDON1, recsog.get(SOG_IDON1));
|
||
riga.put(CON_IDON2, recsog.get(SOG_IDON2));
|
||
riga.put(CON_IDON3, recsog.get(SOG_IDON3));
|
||
riga.put(CON_IDON4, recsog.get(SOG_IDON4));
|
||
riga.put(CON_INTSI, recsog.get(SOG_INTSI));
|
||
riga.put(CON_INTAF, recsog.get(SOG_INTAF));
|
||
riga.put(CON_RESPONSAB, "CONVERSIONE");
|
||
if (!((riga.get(CON_IDON1) == "PL") || (riga.get(CON_IDON2) == "PL") || (riga.get(CON_IDON3) == "PL") || (riga.get(CON_IDON4) == "PL")))
|
||
riga.put(CON_INTAF,0);
|
||
_scontrolli->insert_row(riga);
|
||
}
|
||
if ((numcon > 0) || (numido > 0))
|
||
_scontrolli->rewrite();
|
||
}
|
||
TRectype* keyi = new TRectype(LF_IDONEITA);
|
||
keyi->put(IDO_CODICE, codice);
|
||
int erri = _sidoneita->read(keyi);
|
||
if ((err == NOERR || erri == NOERR) && (_scontrolli->rows() > 0 || _sidoneita->rows() > 0))
|
||
{
|
||
con_reord(recsog,_scontrolli, _sidoneita);
|
||
rewrite = TRUE;
|
||
}
|
||
if (rewrite)
|
||
current_cursor()->file().rewrite();
|
||
return rewrite;
|
||
}
|
||
|
||
void TRiminiRO_app::set_page(int file, int cnt)
|
||
{
|
||
set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
|
||
}
|
||
|
||
|
||
bool TRiminiRO_app::set_print(int)
|
||
{
|
||
KEY tasto;
|
||
tasto = _msk->run();
|
||
if (tasto == K_ENTER)
|
||
{
|
||
_datarif = _msk->get_date(F_DATARIF);
|
||
TRectype da(LF_SOGGETTI);
|
||
TRectype a(LF_SOGGETTI);
|
||
const TString16 sezini = _msk->get(F_SEZINI);
|
||
const TString16 sotini = _msk->get(F_SOTINI);
|
||
const TString16 sezfin = _msk->get(F_SEZFIN);
|
||
const TString16 sotfin = _msk->get(F_SOTFIN);
|
||
const long codini = _msk->get_long(F_CODINI);
|
||
const long codfin = _msk->get_long(F_CODFIN);
|
||
if ((codini != 0) || (codfin != 0))
|
||
{
|
||
da.zero();
|
||
a.zero();
|
||
if (codini != 0)
|
||
da.put(SOG_CODICE, codini);
|
||
if (codfin != 0)
|
||
a.put(SOG_CODICE, codfin);
|
||
TString filtro;
|
||
if ((sezini == sezfin) && (sotini == sotfin))
|
||
filtro << SOG_CODSEZ << " == \"" << sezini << "\"";
|
||
else
|
||
filtro = "";
|
||
_cur = add_cursor(new TCursor(_rel,filtro, 1, &da, &a));
|
||
}
|
||
else
|
||
{
|
||
_cur = add_cursor(new TCursor(_rel,"", 3));
|
||
filtra_sezioni();
|
||
}
|
||
reset_files();
|
||
add_file(LF_SOGGETTI);
|
||
reset_print();
|
||
return TRUE;
|
||
}
|
||
else
|
||
return FALSE;
|
||
}
|
||
|
||
bool TRiminiRO_app::user_create()
|
||
{
|
||
_msk = new TMask("at7800a");
|
||
_rel = new TRelation(LF_SOGGETTI);
|
||
_contsan = new TLocalisamfile(LF_CONTSAN);
|
||
_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
|
||
_idoneita = new TLocalisamfile(LF_IDONEITA);
|
||
_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
|
||
return TRUE;
|
||
}
|
||
|
||
bool TRiminiRO_app::user_destroy()
|
||
{
|
||
delete _rel;
|
||
delete _msk;
|
||
delete _scontrolli;
|
||
delete _contsan;
|
||
delete _sidoneita;
|
||
delete _idoneita;
|
||
return TRUE;
|
||
}
|
||
|
||
int at7800(int argc, char* argv[])
|
||
{
|
||
TRiminiRO_app a;
|
||
a.run(argc, argv, "Correzione controlli RO");
|
||
return 0;
|
||
} |