Corretto funzionamento chiusura periodica: non vengono chiusi i dimessi
git-svn-id: svn://10.65.10.50/trunk@6127 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fe9fa07d77
commit
ca68acd017
155
at/at0600.cpp
155
at/at0600.cpp
@ -16,6 +16,8 @@
|
|||||||
#include "storico.h"
|
#include "storico.h"
|
||||||
#include "sezioni.h"
|
#include "sezioni.h"
|
||||||
|
|
||||||
|
#define ALIAS_CTD 700 // categoria donatori
|
||||||
|
|
||||||
class TChiusuraPeriodica : public TPrintapp
|
class TChiusuraPeriodica : public TPrintapp
|
||||||
{
|
{
|
||||||
static bool filter_func_chiusura(const TRelation* rel);
|
static bool filter_func_chiusura(const TRelation* rel);
|
||||||
@ -26,6 +28,7 @@ class TChiusuraPeriodica : public TPrintapp
|
|||||||
TDate _data_chiusura;
|
TDate _data_chiusura;
|
||||||
TParagraph_string _operazione;
|
TParagraph_string _operazione;
|
||||||
bool _definitiva;
|
bool _definitiva;
|
||||||
|
TString16 _codsez, _codsot;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool user_create();
|
virtual bool user_create();
|
||||||
@ -37,6 +40,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void filtra_sezioni();
|
void filtra_sezioni();
|
||||||
|
void header_sezione(const TString16 codsez, const TString16 codsot);
|
||||||
void crea_intestazione();
|
void crea_intestazione();
|
||||||
TChiusuraPeriodica() : _data_chiusura(TODAY), _operazione("",30) {}
|
TChiusuraPeriodica() : _data_chiusura(TODAY), _operazione("",30) {}
|
||||||
};
|
};
|
||||||
@ -65,66 +69,109 @@ void TChiusuraPeriodica::filtra_sezioni()
|
|||||||
|
|
||||||
bool TChiusuraPeriodica::preprocess_page(int file, int counter)
|
bool TChiusuraPeriodica::preprocess_page(int file, int counter)
|
||||||
{
|
{
|
||||||
_operazione = "Nulla";
|
_operazione = "Non deve essere filtrato";
|
||||||
|
|
||||||
TRectype& recsez = current_cursor()->curr(LF_SEZIONI);
|
TRectype& recsez = current_cursor()->curr(LF_SEZIONI);
|
||||||
TRectype& recsog = current_cursor()->curr();
|
TRectype& recsog = current_cursor()->curr();
|
||||||
|
// salto pagina se cambio sezione
|
||||||
|
const TString16 codsez = recsog.get(SOG_CODSEZ);
|
||||||
|
const TString16 codsot = recsog.get(SOG_CODSOT);
|
||||||
|
if ((_codsez!=codsez)||(_codsot!=codsot))
|
||||||
|
{
|
||||||
|
if (_codsez != "**")
|
||||||
|
printer().formfeed();
|
||||||
|
_codsez = codsez;
|
||||||
|
_codsot = codsot;
|
||||||
|
header_sezione(codsez, codsot);
|
||||||
|
}
|
||||||
TLocalisamfile& filesog = current_cursor()->file();
|
TLocalisamfile& filesog = current_cursor()->file();
|
||||||
|
|
||||||
const TString16 cat_estinti = recsez.get(SEZ_CATESTI);
|
const TString16 cat_estinti = recsez.get(SEZ_CATESTI);
|
||||||
const TString16 cat_cancellati = recsez.get(SEZ_CATCANC);
|
const TString16 cat_cancellati = recsez.get(SEZ_CATCANC);
|
||||||
const TString16 cat_emeriti = recsez.get(SEZ_CATEMER);
|
const TString16 cat_emeriti = recsez.get(SEZ_CATEMER);
|
||||||
|
|
||||||
const int intesti = recsez.get_int(SEZ_INTESTI);
|
const int intesti = recsez.get_int(SEZ_INTESTI);
|
||||||
const int donemer = recsez.get_int(SEZ_DONEMER);
|
const int donemer = recsez.get_int(SEZ_DONEMER);
|
||||||
|
if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0))
|
||||||
|
{
|
||||||
const TString16 catsog = recsog.get(SOG_CATDON);
|
const TString16 catsog = recsog.get(SOG_CATDON);
|
||||||
|
if (catsog == cat_cancellati && cat_cancellati.not_empty())
|
||||||
|
|
||||||
if ((catsog==cat_estinti && cat_estinti.not_empty())
|
|
||||||
|| (catsog==cat_cancellati && cat_cancellati.not_empty()))
|
|
||||||
{
|
|
||||||
const int totdon = recsog.get_int(SOG_TOTDON);
|
|
||||||
if (totdon >= donemer && donemer != 0)
|
|
||||||
{
|
|
||||||
_operazione = "Passaggio a emeriti";
|
|
||||||
if (_definitiva)
|
|
||||||
{
|
|
||||||
recsog.put(SOG_CATDON,cat_emeriti);
|
|
||||||
filesog.rewrite();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_operazione = "Cancellato";
|
_operazione = "Cancellato";
|
||||||
if (_definitiva)
|
if (_definitiva)
|
||||||
filesog.remove();
|
filesog.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0))
|
||||||
|
{
|
||||||
|
bool dimesso = current_cursor()->curr(-ALIAS_CTD).get_bool("B0");
|
||||||
|
if (!dimesso)
|
||||||
{
|
{
|
||||||
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
||||||
if (dataultdon.ok())
|
if (dataultdon.ok())
|
||||||
{
|
{
|
||||||
dataultdon.addyear(intesti);
|
dataultdon.addyear(intesti);
|
||||||
if (dataultdon < _data_chiusura)
|
if (dataultdon < app()._data_chiusura)
|
||||||
{
|
{
|
||||||
_operazione = "Passaggio a estinti";
|
const int totdon = recsog.get_int(SOG_TOTDON);
|
||||||
|
if (cat_emeriti.not_empty() && donemer!=0 && totdon>donemer)
|
||||||
|
{
|
||||||
|
_operazione = "da";
|
||||||
|
_operazione << " ";
|
||||||
|
_operazione << catsog;
|
||||||
|
_operazione << " a ";
|
||||||
|
_operazione << cat_emeriti;
|
||||||
if (_definitiva)
|
if (_definitiva)
|
||||||
{
|
{
|
||||||
recsog.put(SOG_CATDON,cat_estinti);
|
recsog.put(SOG_CATDON,cat_emeriti);
|
||||||
|
recsog.put(SOG_DATADIM, _data_chiusura);
|
||||||
filesog.rewrite();
|
filesog.rewrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_operazione = "Non doveva essere filtrato: data ancora valida";
|
{
|
||||||
|
if (cat_estinti.not_empty())
|
||||||
|
{
|
||||||
|
_operazione = "da";
|
||||||
|
_operazione << " ";
|
||||||
|
_operazione << catsog;
|
||||||
|
_operazione << " a ";
|
||||||
|
_operazione << cat_estinti;
|
||||||
|
if (_definitiva)
|
||||||
|
{
|
||||||
|
recsog.put(SOG_CATDON,cat_estinti);
|
||||||
|
recsog.put(SOG_DATADIM, _data_chiusura);
|
||||||
|
filesog.rewrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
_operazione = "Non doveva essere filtrato: data vuota";
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TChiusuraPeriodica::header_sezione(const TString16 codsez, const TString16 codsot)
|
||||||
|
{
|
||||||
|
const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ);
|
||||||
|
const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT);
|
||||||
|
TString intestazione(132);
|
||||||
|
intestazione = "Sezione: ";
|
||||||
|
intestazione << codsez;
|
||||||
|
intestazione << "/";
|
||||||
|
intestazione << codsot;
|
||||||
|
intestazione << " ";
|
||||||
|
intestazione << densez;
|
||||||
|
if ((densot.ok())&& (densot.not_empty()))
|
||||||
|
{
|
||||||
|
intestazione << "/";
|
||||||
|
intestazione << densot;
|
||||||
|
}
|
||||||
|
intestazione.center_just();
|
||||||
|
set_header(1,"@0g%s", (const char*) intestazione);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void TChiusuraPeriodica::set_page(int file, int cnt)
|
void TChiusuraPeriodica::set_page(int file, int cnt)
|
||||||
{
|
{
|
||||||
@ -132,7 +179,9 @@ void TChiusuraPeriodica::set_page(int file, int cnt)
|
|||||||
set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON));
|
||||||
set_row(1,"@12g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
|
set_row(1,"@12g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
|
||||||
set_row(1,"@38g@S", FLD(LF_SOGGETTI,SOG_NOME));
|
set_row(1,"@38g@S", FLD(LF_SOGGETTI,SOG_NOME));
|
||||||
set_row(1,"@65g#a", &_operazione);
|
set_row(1,"@65g@ld", FLD(LF_SOGGETTI,SOG_DATAULTDON));
|
||||||
|
set_row(1,"@76g@n", FLD(LF_SOGGETTI,SOG_TOTDON));
|
||||||
|
set_row(1,"@80g#a", &_operazione);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel)
|
bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel)
|
||||||
@ -141,16 +190,22 @@ bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel)
|
|||||||
|
|
||||||
TRectype& recsez = rel->lfile(LF_SEZIONI).curr();
|
TRectype& recsez = rel->lfile(LF_SEZIONI).curr();
|
||||||
TRectype& recsog = rel->lfile().curr();
|
TRectype& recsog = rel->lfile().curr();
|
||||||
|
|
||||||
const TString16 cat_estinti = recsez.get(SEZ_CATESTI);
|
const TString16 cat_estinti = recsez.get(SEZ_CATESTI);
|
||||||
const TString16 cat_cancellati = recsez.get(SEZ_CATCANC);
|
const TString16 cat_cancellati = recsez.get(SEZ_CATCANC);
|
||||||
const TString16 cat_emeriti = recsez.get(SEZ_CATEMER);
|
const TString16 cat_emeriti = recsez.get(SEZ_CATEMER);
|
||||||
const int intesti = recsez.get_int(SEZ_INTESTI);
|
const int intesti = recsez.get_int(SEZ_INTESTI);
|
||||||
|
const int donemer = recsez.get_int(SEZ_DONEMER);
|
||||||
|
if ((cat_estinti.not_empty() && intesti!=0) || cat_cancellati.not_empty() || (cat_emeriti.not_empty() && donemer!=0))
|
||||||
|
{
|
||||||
const TString16 catsog = recsog.get(SOG_CATDON);
|
const TString16 catsog = recsog.get(SOG_CATDON);
|
||||||
filtrato = ((catsog == cat_estinti && cat_estinti.not_empty()) ||
|
if (catsog == cat_cancellati && cat_cancellati.not_empty())
|
||||||
(catsog == cat_cancellati && cat_cancellati.not_empty()));
|
filtrato = TRUE; // da cancellare
|
||||||
if (!filtrato && catsog != cat_emeriti)
|
else
|
||||||
|
{
|
||||||
|
if ((cat_estinti.not_empty() && intesti!=0) || (cat_emeriti.not_empty() && donemer!=0))
|
||||||
|
{
|
||||||
|
const bool dimesso = rel->lfile(-ALIAS_CTD).get_bool("B0");
|
||||||
|
if (!dimesso)
|
||||||
{
|
{
|
||||||
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
||||||
if (dataultdon.ok())
|
if (dataultdon.ok())
|
||||||
@ -159,6 +214,9 @@ bool TChiusuraPeriodica::filter_func_chiusura(const TRelation* rel)
|
|||||||
filtrato = (dataultdon < app()._data_chiusura);
|
filtrato = (dataultdon < app()._data_chiusura);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return filtrato;
|
return filtrato;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +226,8 @@ bool TChiusuraPeriodica::set_print(int)
|
|||||||
tasto = _msk->run();
|
tasto = _msk->run();
|
||||||
if (tasto == K_ENTER)
|
if (tasto == K_ENTER)
|
||||||
{
|
{
|
||||||
|
_codsez = "**";
|
||||||
|
_codsez = "**";
|
||||||
_definitiva = _msk->get_bool(F_DEFINITIVA);
|
_definitiva = _msk->get_bool(F_DEFINITIVA);
|
||||||
_data_chiusura = _msk->get(F_DATA);
|
_data_chiusura = _msk->get(F_DATA);
|
||||||
reset_files();
|
reset_files();
|
||||||
@ -182,27 +242,23 @@ bool TChiusuraPeriodica::set_print(int)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TChiusuraPeriodica::crea_intestazione()
|
void TChiusuraPeriodica::crea_intestazione()
|
||||||
{
|
{
|
||||||
reset_header();
|
reset_header();
|
||||||
|
|
||||||
TString sep(132);
|
TString sep(132);
|
||||||
TString16 data_stampa;
|
sep = "";
|
||||||
|
if (_definitiva)
|
||||||
sep.fill('-');
|
sep << "CHIUSURA - DEFINITIVA - ALLA DATA ";
|
||||||
set_header(1, (const char *) sep);
|
else
|
||||||
|
sep << "CHIUSURA - PROVVISORIA - ALLA DATA ";
|
||||||
|
sep << _data_chiusura.string();
|
||||||
|
sep.center_just();
|
||||||
|
set_header(2, "@0g%s", (const char*) sep);
|
||||||
|
TDate data_stampa(TODAY);
|
||||||
|
set_header(2,"@0g%10s", (const char*) data_stampa.string());
|
||||||
sep = "";
|
sep = "";
|
||||||
sep << "Pag. @#";
|
sep << "Pag. @#";
|
||||||
sep.right_just(132);
|
set_header(2, "@120g%s", (const char*) sep);
|
||||||
set_header(2,(const char*) sep);
|
|
||||||
|
|
||||||
if (_definitiva)
|
|
||||||
set_header(2,"@0gCHIUSURA PERIODICA - DEFINITIVA - ALLA DATA");
|
|
||||||
else
|
|
||||||
set_header(2,"@0gCHIUSURA PERIODICA - PROVVISORIA - ALLA DATA");
|
|
||||||
data_stampa = _data_chiusura.string();
|
|
||||||
set_header(2,"@47g%10s", (const char*) data_stampa);
|
|
||||||
sep = "";
|
sep = "";
|
||||||
sep.fill('-');
|
sep.fill('-');
|
||||||
set_header(3, (const char *) sep);
|
set_header(3, (const char *) sep);
|
||||||
@ -213,6 +269,7 @@ bool TChiusuraPeriodica::user_create()
|
|||||||
_msk = new TMask("at0600a");
|
_msk = new TMask("at0600a");
|
||||||
_rel = new TRelation(LF_SOGGETTI);
|
_rel = new TRelation(LF_SOGGETTI);
|
||||||
_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
|
_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
|
||||||
|
_rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD);
|
||||||
//cursore ordinamento per sezione+sottogruppo+cognome+nome
|
//cursore ordinamento per sezione+sottogruppo+cognome+nome
|
||||||
_cur = add_cursor(new TCursor(_rel, "", 3));
|
_cur = add_cursor(new TCursor(_rel, "", 3));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user