campo-sirio/at/at4600.cpp
alex 797e8900fb Patch level : 4.0 673
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Riportata la versione 3.1 patch 873


git-svn-id: svn://10.65.10.50/trunk@15151 c028cbd2-c16b-5b4b-a496-9718f37d4682
2007-03-30 13:51:17 +00:00

214 lines
5.9 KiB
C++
Executable File
Raw Blame History

#include <mask.h>
#include <printapp.h>
#include <utility.h>
#include "at4.h"
#include "at4600a.h"
// nomi dei campi
#include "soggetti.h"
#include "sezioni.h"
#include "convoc.h"
#include "rconvoc.h"
class TSpostamentoConv : public TPrintapp
{
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);
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);
virtual print_action postprocess_print(int file, int counter);
public:
TMask& app_mask() { return *_msk; }
TSpostamentoConv() {}
};
HIDDEN inline TSpostamentoConv& app() { return (TSpostamentoConv&) main_app(); }
void TSpostamentoConv::set_page(int file, int cnt)
{
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));
set_row(2,"@13g@S", FLD(LF_SOGGETTI,SOG_NOME));
set_row(2,"@50g@S", FLD(LF_RCONVOC,RCV_CHIAMATA));
set_row(3, "");
}
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;
}
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()))
{
TDate& data = app()._data;
app()._contatore++;
app()._spostati++;
if (app()._spostati > app()._quanti)
{
++data;
if (data > app()._spostaal)
data = app()._spostaal;
app()._spostati = 1;
}
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;
}
}
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)
{
_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())
{
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);
}
}
*/
// 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;
reset_files();
add_file(LF_RCONVOC);
reset_print();
return TRUE;
}
else
return FALSE;
}
bool TSpostamentoConv::user_create()
{
_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);
*/
_msk = new TMask("at4600a");
return TRUE;
}
bool TSpostamentoConv::user_destroy()
{
delete _msk;
delete _rel;
return TRUE;
}
int at4600(int argc, char* argv[])
{
TSpostamentoConv a;
a.run(argc, argv, "Spostamento convocazioni");
return 0;
}