Files correlati : Ricompilazione Demo : [ ] Commento : Stampa ben. per sezione: possibile ora la scelta tra sezione che ha attribuito e sezione di appartenenza attuale git-svn-id: svn://10.65.10.50/trunk@7262 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			352 lines
		
	
	
		
			9.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			352 lines
		
	
	
		
			9.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <form.h>
 | ||
| #include <mask.h>
 | ||
| #include <printapp.h>
 | ||
| #include <utility.h>
 | ||
| 
 | ||
| #include "benem.h"
 | ||
| #include "soggetti.h"
 | ||
| #include "sezioni.h"
 | ||
| #include <comuni.h>
 | ||
| 
 | ||
| #include "at1.h"
 | ||
| #include "at1300a.h"
 | ||
| 
 | ||
| #define ALIAS_BNZ	600
 | ||
| 
 | ||
| #define ALIAS_LCPRES	101		// localita' postale di residenza
 | ||
| #define ALIAS_LCPDOM	100		// localita' postale di domicilio
 | ||
| #define ALIAS_COMRES 	502		// comune di residenza
 | ||
| #define ALIAS_COMDOM 	501		// comune di domicilio
 | ||
| #define ALIAS_COMNAS 	500		// comune di nascita
 | ||
| 
 | ||
| class TStampaBenemerenze : public TPrintapp
 | ||
| {
 | ||
| 	TLocalisamfile*			_sezioni;
 | ||
|   TRelation*					_rel;
 | ||
|   TMask*      				_msk;
 | ||
|   int									_counter;
 | ||
|   int 								_cur;
 | ||
|   char								_tiposta;
 | ||
|   TDate								_dataini, _datafin;
 | ||
| 	TString16						_codsez, _codsot, _sezini, _sotini, _sezfin, _sotfin;
 | ||
| 	bool								_stampa80;  
 | ||
|   TParagraph_string 	_cognome_nome, _dencom;
 | ||
|   TString16						_tipoold;
 | ||
|   int 								_contatore;
 | ||
| 
 | ||
|   
 | ||
| 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:
 | ||
|   void crea_intestazione();
 | ||
|   void header_ben(const TString16 tipoben, const TString16 codsez, const TString16 codsot);
 | ||
|   void footer_ben();
 | ||
|   TMask& app_mask() { return *_msk; }
 | ||
|   TStampaBenemerenze() : _cognome_nome("",35), _dencom("",50) {}
 | ||
| };
 | ||
| 
 | ||
| HIDDEN inline TStampaBenemerenze& app() { return (TStampaBenemerenze&) main_app(); }
 | ||
| 
 | ||
| print_action TStampaBenemerenze::postprocess_print(int file, int counter)
 | ||
| { 
 | ||
| 	if (_contatore > 0)
 | ||
| 		footer_ben();
 | ||
| 	return NEXT_PAGE;
 | ||
| }
 | ||
| 
 | ||
| void TStampaBenemerenze::footer_ben()
 | ||
| {
 | ||
| 	// stampa totale benemerenze
 | ||
| 	reset_footer();
 | ||
| 	TString sep(80);
 | ||
| 	sep.fill('-');
 | ||
| 	set_footer(2, (const char *) sep);
 | ||
| 	set_footer(3,"TOTALE SOGGETTI STAMPATI %d", _contatore);
 | ||
| 	printer().formfeed(); 
 | ||
| 	reset_footer();
 | ||
| }
 | ||
| 
 | ||
| void TStampaBenemerenze::set_page(int file, int cnt)
 | ||
| {
 | ||
| 	set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
 | ||
| 	set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON));
 | ||
| 	set_row(1,"@12g#a", &_cognome_nome);
 | ||
| 	set_row(1,"@38g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
 | ||
| 	set_row(1,"@49g@S", FLD(LF_SOGGETTI,SOG_DOM_INDIR));
 | ||
| 	set_row(1,"@100g@S", FLD(LF_SOGGETTI,SOG_TELABI));
 | ||
| 	set_row(1,"@116g@S", FLD(LF_SOGGETTI,SOG_TELLAV));
 | ||
| 	set_row(2,"@0g@S", FLD(LF_SOGGETTI,SOG_TESSAVIS));
 | ||
| 	set_row(2,"@49g#a", &_dencom);
 | ||
| 	set_row(2,"@116g@S", FLD(LF_SOGGETTI,SOG_TELALT));
 | ||
| 	set_row(3,"@100g@pn", FLD(LF_SOGGETTI,SOG_TOTDON,"###"));
 | ||
| 	set_row(4,"");
 | ||
| }
 | ||
| 
 | ||
| bool TStampaBenemerenze::preprocess_page(int file, int counter)
 | ||
| {
 | ||
| 	TString80 nome = current_cursor()->curr(LF_SOGGETTI).get(SOG_COGNOME);
 | ||
| 	nome << " ";
 | ||
| 	nome << current_cursor()->curr(LF_SOGGETTI).get(SOG_NOME);
 | ||
| 	_cognome_nome = nome;
 | ||
| 	TString256 localita = "";
 | ||
| 	localita << current_cursor()->curr(-ALIAS_LCPDOM).get("S6");
 | ||
| 	if (localita.not_empty() && localita.ok())
 | ||
| 	{
 | ||
| 		localita << " ";
 | ||
| 		localita << current_cursor()->curr(-ALIAS_LCPDOM).get("S0");
 | ||
| 		localita << " - ";		
 | ||
| 	}
 | ||
| 	else
 | ||
| 	{
 | ||
| 		localita = current_cursor()->curr(-ALIAS_COMDOM).get(COM_CAPCOM);
 | ||
| 		localita << " ";
 | ||
| 	}			
 | ||
| 	localita << current_cursor()->curr(-ALIAS_COMDOM).get(COM_DENCOM);
 | ||
| 	localita.trim();
 | ||
| 	_dencom = localita;
 | ||
| 	
 | ||
| 	// salto pagina se cambio punto di rottura
 | ||
| 	const TString16 tiponew = current_cursor()->curr().get(BEN_TIPOBEN);		
 | ||
| 	TString16 codsez, codsot;
 | ||
| 	if (app()._tiposta == 'S')
 | ||
| 	{
 | ||
| 		codsez = current_cursor()->curr(LF_SOGGETTI).get(SOG_CODSEZ);		
 | ||
| 		codsot = current_cursor()->curr(LF_SOGGETTI).get(SOG_CODSOT);		
 | ||
| 	}
 | ||
| 	else		
 | ||
| 	{
 | ||
| 		codsez = current_cursor()->curr().get(BEN_CODSEZ);		
 | ||
| 		codsot = current_cursor()->curr().get(BEN_CODSOT);		
 | ||
| 	}
 | ||
| 	if ((tiponew != _tipoold) || (_codsez!=codsez) || (_codsot!=codsot))
 | ||
| 	{
 | ||
| 		if (_tipoold != "**")
 | ||
| 			footer_ben();
 | ||
| 		_contatore = 0;				
 | ||
| 		_tipoold = tiponew;
 | ||
| 		_codsez = codsez;
 | ||
| 		_codsot = codsot;
 | ||
| 		header_ben(tiponew, _codsez, _codsot);
 | ||
| 	}
 | ||
| 	else
 | ||
| 	if (printer().rows_left() < 4)
 | ||
| 		printer().formfeed();
 | ||
| 	_contatore++;			
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| void TStampaBenemerenze::header_ben(const TString16 tipoben, const TString16 codsez, const TString16 codsot)
 | ||
| {
 | ||
| 	TString intestazione(132);
 | ||
| 	intestazione = "BENEMERENZA ";
 | ||
| 	intestazione << tipoben;
 | ||
| 	intestazione << " ";
 | ||
| 	intestazione << current_cursor()->curr(-ALIAS_BNZ).get("S0");
 | ||
| 	intestazione.center_just(132);	
 | ||
| 	set_header(3,"@0g%s", (const char*) intestazione);
 | ||
| 	TLocalisamfile sezioni(LF_SEZIONI);
 | ||
| 	sezioni.zero();
 | ||
| 	sezioni.put(SEZ_CODSEZ, codsez);
 | ||
| 	sezioni.put(SEZ_CODSOT, codsot);
 | ||
| 	TString80 densez, densot;
 | ||
| 	densez = "";
 | ||
| 	densot = "";
 | ||
| 	if (sezioni.read() == NOERR)
 | ||
| 	{
 | ||
| 		densez = sezioni.get(SEZ_DENSEZ);
 | ||
| 		densot = sezioni.get(SEZ_DENSOT);
 | ||
| 	}		
 | ||
| 	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;
 | ||
| }
 | ||
| 
 | ||
| bool TStampaBenemerenze::set_print(int m)
 | ||
| { 
 | ||
|   KEY tasto;
 | ||
|  	tasto = _msk->run();
 | ||
|  	if (tasto == K_ENTER)
 | ||
|  	{ 
 | ||
|   	_codsez = "**";
 | ||
|   	_codsot = "**"; 	
 | ||
| 		_dataini = _msk->get_date(F_DATAINI);	
 | ||
| 		_datafin = _msk->get_date(F_DATAFIN);	
 | ||
| 		_tiposta = _msk->get(F_TIPOSTA)[0];
 | ||
| 	  TRectype da(LF_BENEM);
 | ||
|   	TRectype a (LF_BENEM);
 | ||
|   	if (_dataini.ok())
 | ||
| 			da.put(BEN_DATABEN, _dataini);
 | ||
|   	if (_datafin.ok())
 | ||
| 			a.put(BEN_DATABEN, _datafin);
 | ||
| 		//TString80 chiave = "94->TIPOBEN|UPPER(90->COGNOME)|UPPER(90->NOME)";
 | ||
| 		TString80 chiave = "";
 | ||
| 		if (_tiposta == 'S')
 | ||
| 			chiave = "90->CODSEZ|90->CODSOT|94->TIPOBEN|UPPER(90->COGNOME)|UPPER(90->NOME)";
 | ||
| 		else
 | ||
| 			chiave = "94->CODSEZ|94->CODSOT|94->TIPOBEN|UPPER(90->COGNOME)|UPPER(90->NOME)";
 | ||
| 	  _cur = add_cursor(new TSorted_cursor(_rel, (const char*) chiave, "", 2, &da, &a));
 | ||
| 		// filtro per sezioni
 | ||
| 	 	_sezini = _msk->get(F_SEZINI);
 | ||
| 	 	_sotini = _msk->get(F_SOTINI);
 | ||
| 	 	_sezfin = _msk->get(F_SEZFIN);
 | ||
| 	 	_sotfin = _msk->get(F_SOTFIN); 
 | ||
| 	 	TString256 filtro = "";
 | ||
| 	 	if (_sezini.not_empty())
 | ||
| 	 	{
 | ||
| 	 		if (_sotini.not_empty())
 | ||
| 	 		{                    
 | ||
| 				if (_tiposta == 'S')
 | ||
| 				{
 | ||
| 		 			filtro << "(";
 | ||
| 		 			filtro << format("(90->CODSEZ > \"%s\")",(const char*)_sezini);
 | ||
| 		 			filtro << " || ";
 | ||
| 		 			filtro << "(" << format("(90->CODSEZ == \"%s\")",(const char*)_sezini);
 | ||
| 		 			filtro << " && ";
 | ||
| 		 			filtro << format("(90->CODSOT >= \"%s\")",(const char*)_sotini);
 | ||
| 		 			filtro << ")";
 | ||
| 		 			filtro << ")";
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{
 | ||
| 		 			filtro << "(";
 | ||
| 		 			filtro << format("(94->CODSEZ > \"%s\")",(const char*)_sezini);
 | ||
| 		 			filtro << " || ";
 | ||
| 		 			filtro << "(" << format("(94->CODSEZ == \"%s\")",(const char*)_sezini);
 | ||
| 		 			filtro << " && ";
 | ||
| 		 			filtro << format("(94->CODSOT >= \"%s\")",(const char*)_sotini);
 | ||
| 		 			filtro << ")";
 | ||
| 		 			filtro << ")";
 | ||
| 				}
 | ||
| 	 		}
 | ||
| 	 		else
 | ||
| 	 		{
 | ||
| 				if (_tiposta == 'S')
 | ||
| 		 			filtro << format("(90->CODSEZ >= \"%s\")",(const char*)_sezini);
 | ||
| 				else		 			
 | ||
| 		 			filtro << format("(94->CODSEZ >= \"%s\")",(const char*)_sezini);
 | ||
| 			}	 			
 | ||
| 	 	}
 | ||
| 	 	if (_sezfin.not_empty())
 | ||
| 	 	{
 | ||
|  			if (filtro.not_empty())
 | ||
|  				filtro << " && "; 
 | ||
| 	 	
 | ||
| 	 		if (_sotfin.not_empty())
 | ||
| 	 		{          
 | ||
| 				if (_tiposta == 'S')
 | ||
| 				{	 				
 | ||
| 		 			filtro << "(";
 | ||
| 		 			filtro << format("(90->CODSEZ < \"%s\")",(const char*)_sezfin);
 | ||
| 		 			filtro << " || ";
 | ||
| 		 			filtro << "(" << format("(90->CODSEZ == \"%s\")",(const char*)_sezfin);
 | ||
| 		 			filtro << " && ";
 | ||
| 		 			filtro << format("(90->CODSOT <= \"%s\")",(const char*)_sotfin);
 | ||
| 		 			filtro << ")";
 | ||
| 		 			filtro << ")";
 | ||
| 				}
 | ||
| 				else
 | ||
| 				{	 				
 | ||
| 		 			filtro << "(";
 | ||
| 		 			filtro << format("(94->CODSEZ < \"%s\")",(const char*)_sezfin);
 | ||
| 		 			filtro << " || ";
 | ||
| 		 			filtro << "(" << format("(94->CODSEZ == \"%s\")",(const char*)_sezfin);
 | ||
| 		 			filtro << " && ";
 | ||
| 		 			filtro << format("(94->CODSOT <= \"%s\")",(const char*)_sotfin);
 | ||
| 		 			filtro << ")";
 | ||
| 		 			filtro << ")";
 | ||
| 				}
 | ||
| 	 		}
 | ||
| 	 		else
 | ||
| 	 		{
 | ||
| 				if (_tiposta == 'S')
 | ||
| 		 			filtro << format("(90->CODSEZ <= \"%s\")",(const char*)_sezfin);
 | ||
| 				else
 | ||
| 		 			filtro << format("(94->CODSEZ <= \"%s\")",(const char*)_sezfin);
 | ||
| 			}	 			
 | ||
| 	 	}
 | ||
| 		current_cursor()->setfilter((const char*) filtro, TRUE);
 | ||
| 		_counter = 0;
 | ||
|  		_tipoold = "**";
 | ||
| 	  reset_files(); 
 | ||
|   	add_file(LF_BENEM);
 | ||
| 		reset_print();
 | ||
| 		printer().footerlen(0);		
 | ||
| 		crea_intestazione();
 | ||
| 		return TRUE;
 | ||
|   }	            
 | ||
|  	else
 | ||
|   	return FALSE;
 | ||
| }
 | ||
| 
 | ||
| void TStampaBenemerenze::crea_intestazione()
 | ||
| {
 | ||
|   reset_header();
 | ||
|   TString sep(132);
 | ||
| 	sep = "STAMPA BENEMERENZE ATTRIBUITE dal ";
 | ||
| 	sep << _dataini;
 | ||
| 	sep << " al ";
 | ||
| 	sep << _datafin;
 | ||
| 	sep.center_just(132);			
 | ||
| 	set_header(2,"@0g%s", (const char*) sep);
 | ||
|  	sep = "Pag. @#";
 | ||
| 	set_header(2, "@110g%s", (const char*) sep);  
 | ||
| 	sep = "";
 | ||
| 	sep.fill('-');
 | ||
| 	set_header(4, (const char *) sep);
 | ||
| 	set_header(5,"@0gCodice@9gC.@12gCognome e nome@38gNato il@49gIndirizzo@100gTelefono abit.@116gTelefono lavoro");
 | ||
| 	set_header(6,"@0gTessera@49gCAP/Localit<69>/Comune/Prov.@116gTelefono altro");
 | ||
| 	set_header(7,"@100gTot.don.");
 | ||
| 	set_header(8,"@0g--------@9g--@12g-------------------------@38g----------@49g--------------------------------------------------@100g---------------@116g---------------");
 | ||
|  	printer().footerlen(3);
 | ||
| }
 | ||
| 
 | ||
| bool TStampaBenemerenze::user_create()
 | ||
| {
 | ||
|   _rel = new TRelation(LF_BENEM);
 | ||
|   _rel->add(LF_SOGGETTI, "CODICE==CODICE");
 | ||
|   _rel->add("BNZ", "CODTAB==TIPOBEN",1,0,ALIAS_BNZ);
 | ||
|   _rel->add("LCP", "CODTAB==RES_CODLOC",1,LF_SOGGETTI,ALIAS_LCPRES);
 | ||
|   _rel->add("LCP", "CODTAB==DOM_CODLOC",1,LF_SOGGETTI,ALIAS_LCPDOM);
 | ||
|   _rel->add(LF_COMUNI, "COM==RES_CODCOM",1,LF_SOGGETTI,ALIAS_COMRES);
 | ||
|   _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,LF_SOGGETTI,ALIAS_COMDOM);
 | ||
|   _rel->add(LF_COMUNI, "COM==COMNASC",1,LF_SOGGETTI,ALIAS_COMNAS);
 | ||
|   //_rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
 | ||
|   _sezioni = new TLocalisamfile(LF_SEZIONI);
 | ||
|   _msk = new TMask("at1300a");
 | ||
|   TConfig config(CONFIG_STUDIO);
 | ||
|   _stampa80 = config.get_bool("Stampa80");
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| bool TStampaBenemerenze::user_destroy()
 | ||
| {
 | ||
|   delete _msk;
 | ||
|   delete _sezioni;
 | ||
|   delete _rel;
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| int at1300(int argc, char* argv[])
 | ||
| {
 | ||
|   TStampaBenemerenze a;
 | ||
|   a.run(argc, argv, "Elenco benemerenze attribuite");
 | ||
|   return 0;
 | ||
| }
 |