207 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			207 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <mask.h>
 | |
| #include <form.h>
 | |
| #include <printapp.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "at0.h"
 | |
| #include "lf.h"				// se non lo metto non riesco a usare gli LF
 | |
| 
 | |
| // nomi campi maschera
 | |
| #include "at0300a.h"
 | |
|           
 | |
| // nomi dei campi
 | |
| #include "soggetti.h"
 | |
| #include "donaz.h"
 | |
| #include "contsan.h"
 | |
| #include "benem.h"
 | |
| #include "storico.h"
 | |
| #include "sezioni.h"
 | |
| 
 | |
| class TChiusura_app : public TPrintapp
 | |
| {
 | |
|   static bool filter_func_chiusura(const TRelation *);
 | |
| 
 | |
| 	TMask*						_msk;
 | |
| 	TRelation*   			_rel;
 | |
| 
 | |
| 	int 							_cur;	
 | |
| 	TDate							_data_chiusura;
 | |
|   TParagraph_string	_operazione;
 | |
| 	
 | |
| 	
 | |
| 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 TMask& get_mask() { return *_msk; }
 | |
| 	
 | |
| public:
 | |
|   void filtra_sezioni();
 | |
|   void crea_intestazione();
 | |
| 	TChiusura_app() : _data_chiusura(TODAY), _operazione("",30) {}
 | |
| };
 | |
| 
 | |
| HIDDEN inline TChiusura_app& app() { return (TChiusura_app&) main_app(); }
 | |
| 
 | |
| void TChiusura_app::filtra_sezioni()
 | |
| {
 | |
|  	TString sezini = _msk->get(F_SEZINI);
 | |
|  	TString sotini = _msk->get(F_SOTINI);
 | |
|  	TString sezfin = _msk->get(F_SEZFIN);
 | |
|  	TString sotfin = _msk->get(F_SOTFIN);
 | |
|   TLocalisamfile& fl = current_cursor()->file(LF_SOGGETTI);
 | |
|   TRectype da(fl.curr());
 | |
|   TRectype a(fl.curr());   
 | |
|   da.zero();
 | |
|   a.zero();
 | |
|   if ((sezini.not_empty()) && (sezini.ok()))
 | |
| 		da.put(SOG_CODSEZ, sezini);
 | |
|   if ((sotini.not_empty()) && (sotini.ok()))    	
 | |
| 		da.put(SOG_CODSOT, sotini);
 | |
|   if ((sezfin.not_empty()) && (sezfin.ok()))
 | |
| 		a.put(SOG_CODSEZ, sezfin);
 | |
|   if ((sotfin.not_empty()) && (sotfin.ok()))    	
 | |
| 		a.put(SOG_CODSOT, sotfin);
 | |
| 	current_cursor()->setregion(da, a);
 | |
| }	
 | |
| 
 | |
| bool TChiusura_app::preprocess_page(int file, int counter)
 | |
| {
 | |
| 	_operazione = "Nulla";	
 | |
| 	TString cat_estinti = current_cursor()->curr(LF_SEZIONI).get(SEZ_CATESTI);
 | |
| 	TString cat_cancellati = current_cursor()->curr(LF_SEZIONI).get(SEZ_CATCANC);
 | |
| 	int intesti = current_cursor()->curr(LF_SEZIONI).get_int(SEZ_INTESTI);
 | |
| 	int donemer = current_cursor()->curr(LF_SEZIONI).get_int(SEZ_DONEMER);
 | |
| 
 | |
| 	TString catsog = current_cursor()->curr().get(SOG_CATDON);
 | |
| 	if ((catsog==cat_estinti) || (catsog==cat_cancellati))
 | |
| 	{
 | |
| 		int totdon = current_cursor()->curr().get_int(SOG_TOTDON);
 | |
| 		if (totdon >= donemer)
 | |
| 			_operazione = "Passaggio a emeriti";
 | |
| 		else
 | |
| 			_operazione = "Cancellato";
 | |
| 	}
 | |
| 	else
 | |
| 	{                                   
 | |
| 		TDate dataultdon = current_cursor()->curr().get(SOG_DATAULTDON);
 | |
| 		if (dataultdon.ok())
 | |
| 		{
 | |
| 			dataultdon.addyear(intesti);
 | |
| 			TMask& msk = app().get_mask();
 | |
| 			//TDate data_chiusura = msk.get(F_DATA);
 | |
| 			if (dataultdon < _data_chiusura)
 | |
| 				_operazione = "Passaggio a estinti";
 | |
| 			else
 | |
| 				_operazione = "Non doveva essere filtrato: data ancora valida";
 | |
| 		}
 | |
| 		else
 | |
| 			_operazione = "Non doveva essere filtrato: data vuota";
 | |
| 	}
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TChiusura_app::set_page(int file, int cnt)
 | |
| { 
 | |
| 	set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"######"));
 | |
| 	set_row(1,"@7g@S", FLD(LF_SOGGETTI,SOG_CATDON));
 | |
| 	set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
 | |
| 	set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME));
 | |
| 	set_row(1,"@63g#a", &_operazione);
 | |
| }
 | |
| 
 | |
| bool TChiusura_app::filter_func_chiusura(const TRelation * rel)
 | |
| {   
 | |
| 	bool filtrato = FALSE;
 | |
| 	
 | |
| 	TString cat_estinti = rel->lfile(LF_SEZIONI).curr().get(SEZ_CATESTI);
 | |
| 	TString cat_cancellati = rel->lfile(LF_SEZIONI).curr().get(SEZ_CATCANC);
 | |
| 	int intesti = rel->lfile(LF_SEZIONI).curr().get_int(SEZ_INTESTI);
 | |
| 	
 | |
| 	TString catsog = rel->lfile().curr().get(SOG_CATDON);
 | |
| 	if ((catsog==cat_estinti) || (catsog==cat_cancellati))
 | |
| 		filtrato = TRUE;
 | |
| 	if (!filtrato)		
 | |
| 	{                                   
 | |
| 		TDate dataultdon = rel->lfile().curr().get(SOG_DATAULTDON);
 | |
| 		if (dataultdon.ok())
 | |
| 		{
 | |
| 			dataultdon.addyear(intesti);
 | |
| 			TMask& msk = app().get_mask();
 | |
| 			TDate data_chiusura = msk.get(F_DATA);
 | |
| 			if (dataultdon < data_chiusura)
 | |
| 				filtrato = TRUE;
 | |
| 		}				
 | |
| 	}
 | |
| 	return filtrato;
 | |
| }
 | |
| 
 | |
| bool TChiusura_app::set_print(int)
 | |
| {
 | |
|   KEY tasto;
 | |
|   tasto = _msk->run();
 | |
| 	if (tasto == K_ENTER)
 | |
| 	{  	
 | |
| 		_data_chiusura = _msk->get(F_DATA);
 | |
|     reset_files(); 
 | |
|     add_file(LF_SOGGETTI);
 | |
| 		filtra_sezioni();
 | |
| 		current_cursor()->set_filterfunction(filter_func_chiusura,TRUE);
 | |
| 		reset_print();		
 | |
|     crea_intestazione();
 | |
|     return TRUE;
 | |
|   }
 | |
|   else
 | |
|     return FALSE;
 | |
| }
 | |
| 
 | |
| 
 | |
| void TChiusura_app::crea_intestazione()
 | |
| {
 | |
| 	reset_header();
 | |
| 	
 | |
| 	TString sep(132);
 | |
| 	TString data_stampa;
 | |
|   
 | |
| 	sep.fill('-');
 | |
| 	set_header(1, (const char *) sep);
 | |
| 	sep = "";
 | |
| 	sep << "Pag. @#";
 | |
| 	sep.right_just(132); 
 | |
| 	set_header(2,(const char*) sep);  
 | |
|   
 | |
| 	set_header(2,"@0gCHIUSURA ANNUALE ALLA DATA");
 | |
| 	data_stampa = _data_chiusura.string();
 | |
| 	set_header(2,"@30g%10s", (const char*) data_stampa);
 | |
|   
 | |
| 	sep = "";
 | |
| 	sep.fill('-');
 | |
| 	set_header(3, (const char *) sep);
 | |
| }
 | |
| 
 | |
| bool TChiusura_app::user_create()
 | |
| {
 | |
| 	_msk = new TMask("at0300a");
 | |
| 	_rel = new TRelation(LF_SOGGETTI);
 | |
| 	_rel->add(LF_SEZIONI,"CODSEZ==CODSEZ|CODSOT==CODSOT");
 | |
| 
 | |
|   _cur = add_cursor(new TCursor(_rel, "", 3));	//cursore ordinamento per sezione+sottogruppo+codice
 | |
| 	return TRUE;
 | |
| }	
 | |
| 
 | |
| bool TChiusura_app::user_destroy()	
 | |
| {
 | |
| 	delete _rel;
 | |
| 	delete _msk;
 | |
| 	return TRUE;
 | |
| }
 | |
| 
 | |
| int at0300(int argc, char* argv[])
 | |
| {
 | |
| 	TChiusura_app a;
 | |
| 	a.run(argc, argv, "Chiusura annuale");
 | |
| 	return 0;
 | |
| } |