1997-12-05 16:26:15 +00:00
|
|
|
|
#include <mask.h>
|
|
|
|
|
#include <printapp.h>
|
|
|
|
|
#include <utility.h>
|
2002-10-25 12:46:31 +00:00
|
|
|
|
#include <lffiles.h>
|
1997-12-05 16:26:15 +00:00
|
|
|
|
|
|
|
|
|
#include "at4.h"
|
|
|
|
|
#include "at4600a.h"
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
// nomi dei campi
|
|
|
|
|
#include "soggetti.h"
|
|
|
|
|
#include "sezioni.h"
|
|
|
|
|
#include "convoc.h"
|
|
|
|
|
#include "rconvoc.h"
|
1997-12-05 16:26:15 +00:00
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
class TSpostamentoConv : public TPrintapp
|
1997-12-05 16:26:15 +00:00
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
TRelation* _rel;
|
|
|
|
|
TMask* _msk;
|
|
|
|
|
int _cur;
|
|
|
|
|
TLocalisamfile* _rconvoc;
|
|
|
|
|
TLocalisamfile* _soggetti;
|
|
|
|
|
TDate _dataini, _datafin, _spostadal, _spostaal;
|
|
|
|
|
TString16 _punto,_tipo, _sezione, _sottog;
|
|
|
|
|
int _quanti; // numero di convocazioni per giorni
|
|
|
|
|
int _spostati; // contatore dei soggetti spostati per giorno
|
|
|
|
|
int _nonspostati; // donatori di sezioni non selezianate che hanno la convocazione che corrisponde alle selezioni fatte
|
|
|
|
|
int _contatore;
|
|
|
|
|
TDate _data; // data a cui spostare
|
|
|
|
|
bool _stampa;
|
|
|
|
|
//static bool filter_func_stconvoc(const TRelation* rel);
|
|
|
|
|
|
1997-12-05 16:26:15 +00:00
|
|
|
|
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);
|
1999-01-26 14:14:43 +00:00
|
|
|
|
virtual print_action postprocess_print(int file, int counter);
|
2002-10-25 12:46:31 +00:00
|
|
|
|
|
1997-12-05 16:26:15 +00:00
|
|
|
|
public:
|
|
|
|
|
TMask& app_mask() { return *_msk; }
|
2002-10-25 12:46:31 +00:00
|
|
|
|
TSpostamentoConv() {}
|
1997-12-05 16:26:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
HIDDEN inline TSpostamentoConv& app() { return (TSpostamentoConv&) main_app(); }
|
1997-12-05 16:26:15 +00:00
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
void TSpostamentoConv::set_page(int file, int cnt)
|
|
|
|
|
{
|
1997-12-05 16:26:15 +00:00
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"#########"));
|
|
|
|
|
set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
|
|
|
|
set_row(1,"@13g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
|
|
|
|
|
set_row(1,"@39g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
|
|
|
|
|
set_row(1,"@50g@ld", FLD(LF_RCONVOC,RCV_DATACONV));
|
1997-12-05 16:26:15 +00:00
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
set_row(2,"@13g@S", FLD(LF_SOGGETTI,SOG_NOME));
|
|
|
|
|
set_row(2,"@50g@S", FLD(LF_RCONVOC,RCV_CHIAMATA));
|
|
|
|
|
|
|
|
|
|
set_row(3, "");
|
1997-12-05 16:26:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
print_action TSpostamentoConv::postprocess_print(int file, int counter)
|
|
|
|
|
{
|
|
|
|
|
//if (_contatore > 0)
|
|
|
|
|
_msk->set(F_SPOSTATI,_contatore);
|
|
|
|
|
//if (_nonspostati > 0)
|
|
|
|
|
_msk->set(F_NONSPOSTATI,_nonspostati);
|
|
|
|
|
return NEXT_PAGE;
|
1997-12-05 16:26:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
bool TSpostamentoConv::preprocess_page(int file, int counter)
|
|
|
|
|
{
|
|
|
|
|
TString16 sez = current_cursor()->file(LF_SOGGETTI).get(SOG_CODSEZ);
|
|
|
|
|
TString16 sot = current_cursor()->file(LF_SOGGETTI).get(SOG_CODSOT);
|
|
|
|
|
if ((sez == app()._sezione || app()._sezione.blank()) && (sot == app()._sottog || app()._sottog.blank()))
|
1997-12-05 16:26:15 +00:00
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
TDate& data = app()._data;
|
|
|
|
|
app()._contatore++;
|
|
|
|
|
app()._spostati++;
|
|
|
|
|
if (app()._spostati > app()._quanti)
|
|
|
|
|
{
|
|
|
|
|
++data;
|
|
|
|
|
if (data > app()._spostaal)
|
|
|
|
|
data = app()._spostaal;
|
|
|
|
|
app()._spostati = 1;
|
1999-01-26 14:14:43 +00:00
|
|
|
|
}
|
2002-10-25 12:46:31 +00:00
|
|
|
|
current_cursor()->curr().put(RCV_DATACONV,data);
|
|
|
|
|
current_cursor()->file().setkey(1);
|
|
|
|
|
const int err = current_cursor()->file().rewrite();
|
|
|
|
|
current_cursor()->file().setkey(2);
|
|
|
|
|
current_cursor()->curr(LF_SOGGETTI).put(SOG_DATACONV,data);
|
|
|
|
|
TDate dataultsol = current_cursor()->curr(LF_SOGGETTI).get_date(SOG_DATAULTSOL);
|
|
|
|
|
if (dataultsol == data)
|
|
|
|
|
current_cursor()->curr(LF_SOGGETTI).put(SOG_DATAULTSOL,data);
|
|
|
|
|
current_cursor()->file(LF_SOGGETTI).rewrite();
|
|
|
|
|
return app()._stampa;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app()._nonspostati++;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
1997-12-05 16:26:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
bool TSpostamentoConv::set_print(int m)
|
|
|
|
|
{
|
|
|
|
|
_stampa = FALSE;
|
|
|
|
|
KEY tasto = F_AZZERA;
|
|
|
|
|
while (tasto == F_AZZERA)
|
|
|
|
|
{
|
|
|
|
|
tasto = _msk->run();
|
|
|
|
|
if (tasto == F_AZZERA)
|
|
|
|
|
_msk->reset();
|
|
|
|
|
}
|
|
|
|
|
if (tasto == F_STAMPA)
|
|
|
|
|
_stampa = TRUE;
|
|
|
|
|
if (tasto != K_QUIT)
|
1999-01-26 14:14:43 +00:00
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
_dataini = _msk->get(F_DATAINI);
|
|
|
|
|
_datafin = _msk->get(F_DATAFIN);
|
|
|
|
|
_punto = _msk->get(F_PUNTO);
|
|
|
|
|
_tipo = _msk->get(F_TIPO);
|
|
|
|
|
_sezione = _msk->get(F_CODSEZ);
|
|
|
|
|
_sottog = _msk->get(F_CODSOT);
|
|
|
|
|
_spostadal = _msk->get(F_SPOSTADAL);
|
|
|
|
|
_spostaal = _msk->get(F_SPOSTAAL);
|
|
|
|
|
_contatore = 0;
|
|
|
|
|
_nonspostati = 0;
|
|
|
|
|
TString256 filtro = "(116->STAMPATO != \"X\")";
|
|
|
|
|
// filtro per punto di prelievo
|
|
|
|
|
if (_punto.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(115->PUNTO == \"%s\")",(const char*)_punto);
|
|
|
|
|
}
|
|
|
|
|
// filtro per tipo
|
|
|
|
|
if (_tipo.not_empty())
|
1999-01-26 14:14:43 +00:00
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(115->TIPO == \"%s\")",(const char*)_tipo);
|
|
|
|
|
}
|
|
|
|
|
// filtro per sezione/sottogruppo
|
|
|
|
|
/*
|
|
|
|
|
if (_sezione.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(90->CODSEZ == \"%s\")",(const char*)_sezione);
|
|
|
|
|
if (_sottog.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (filtro.not_empty())
|
|
|
|
|
filtro << " && ";
|
|
|
|
|
filtro << format("(90->CODSOT == \"%s\")",(const char*)_sottog);
|
|
|
|
|
}
|
1999-01-26 14:14:43 +00:00
|
|
|
|
}
|
2002-10-25 12:46:31 +00:00
|
|
|
|
*/
|
|
|
|
|
// filtro per data
|
|
|
|
|
TRectype da(LF_RCONVOC);
|
|
|
|
|
TRectype a (LF_RCONVOC);
|
|
|
|
|
if (_dataini.ok())
|
|
|
|
|
da.put(RCV_DATACONV, _dataini);
|
|
|
|
|
if (_datafin.ok())
|
|
|
|
|
a.put(RCV_DATACONV, _datafin);
|
|
|
|
|
_cur = add_cursor(new TCursor(_rel,"", 2, &da, &a));
|
|
|
|
|
// non posso metterlo nel costruttore del tcursor perch<63>
|
|
|
|
|
// non c'<27> la possibilit<69> di specificare il parametro TRUE che c'<27>
|
|
|
|
|
// nella setfilter
|
|
|
|
|
current_cursor()->setfilter((const char*) filtro, TRUE);
|
|
|
|
|
current_cursor()->freeze();
|
|
|
|
|
const int giorni = (int)(_spostaal-_spostadal)+1; // giorni su cui suddividere la chiamata
|
|
|
|
|
_quanti = ((int)(current_cursor()->items())/giorni)+1; // quanti donatori per giorno
|
|
|
|
|
if (_quanti < 1)
|
|
|
|
|
_quanti = 1;
|
|
|
|
|
_spostati = 0;
|
|
|
|
|
_data = _spostadal;
|
1997-12-05 16:26:15 +00:00
|
|
|
|
reset_files();
|
2002-10-25 12:46:31 +00:00
|
|
|
|
add_file(LF_RCONVOC);
|
|
|
|
|
reset_print();
|
1997-12-05 16:26:15 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
bool TSpostamentoConv::user_create()
|
1997-12-05 16:26:15 +00:00
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
_rel = new TRelation(LF_RCONVOC);
|
|
|
|
|
_rel->add(LF_SOGGETTI, "CODICE==CODICE");
|
|
|
|
|
_rel->add(LF_CONVOC, "NUMERO==NUMERO");
|
|
|
|
|
/*
|
|
|
|
|
_rel->add("LCP", "CODTAB==DOM_CODLOC",1,LF_SOGGETTI,ALIAS_LCP);
|
|
|
|
|
_rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,LF_SOGGETTI);
|
|
|
|
|
// per stampare la denominazione della sezione nell'intestazione
|
|
|
|
|
_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT",1,LF_SOGGETTI);
|
|
|
|
|
*/
|
1997-12-05 16:26:15 +00:00
|
|
|
|
_msk = new TMask("at4600a");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 12:46:31 +00:00
|
|
|
|
bool TSpostamentoConv::user_destroy()
|
1997-12-05 16:26:15 +00:00
|
|
|
|
{
|
|
|
|
|
delete _msk;
|
|
|
|
|
delete _rel;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int at4600(int argc, char* argv[])
|
|
|
|
|
{
|
2002-10-25 12:46:31 +00:00
|
|
|
|
TSpostamentoConv a;
|
|
|
|
|
a.run(argc, argv, "Spostamento convocazioni");
|
1997-12-05 16:26:15 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|