219 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			219 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <mask.h>
 | 
						||
#include <form.h>
 | 
						||
#include <printapp.h>
 | 
						||
 | 
						||
#include "lf.h"
 | 
						||
#include "soggetti.h"
 | 
						||
#include "sezioni.h"
 | 
						||
#include <comuni.h>
 | 
						||
 | 
						||
#include "at3.h"
 | 
						||
#include "at3200a.h"
 | 
						||
 | 
						||
#define ALIAS_COMRES 100 
 | 
						||
#define ALIAS_COMNAS 200 
 | 
						||
 | 
						||
enum ts { undefined = 0, tessere = 1, pagine = 2 };
 | 
						||
 | 
						||
// definizione form per pagine anagrafiche
 | 
						||
class TTessere_form : public TForm
 | 
						||
{
 | 
						||
public:
 | 
						||
	
 | 
						||
	virtual TCursor* cursor() const;
 | 
						||
	virtual TRelation* relation() const;
 | 
						||
	TPrint_section& get_body() { return section('B'); } ;
 | 
						||
  TTessere_form(): TForm() {};
 | 
						||
  TTessere_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "")
 | 
						||
    						: TForm(form,code,editlevel,desc) {};
 | 
						||
  virtual ~TTessere_form() {};
 | 
						||
};
 | 
						||
 | 
						||
class TTessere_application : public TPrintapp
 | 
						||
{
 | 
						||
  TRelation*			_rel;
 | 
						||
  TMask*      		_msk;
 | 
						||
  TTessere_form*	_form_pag;
 | 
						||
  
 | 
						||
  int 						_cur1, _cur2, _cur3, _cur4;
 | 
						||
  TDate 					_data_stampa;
 | 
						||
	ts 	      			_tipo_stampa;
 | 
						||
	TString					_riepilogodon;
 | 
						||
 | 
						||
  static bool filter_func_tessere(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);
 | 
						||
 | 
						||
public:
 | 
						||
  void crea_intestazione();
 | 
						||
  TMask& app_mask() { return *_msk; }
 | 
						||
  TTessere_application() : _data_stampa(TODAY), _riepilogodon(50) {}
 | 
						||
};
 | 
						||
 | 
						||
HIDDEN inline TTessere_application& app() { return (TTessere_application&) main_app(); }
 | 
						||
 | 
						||
TCursor* TTessere_form::cursor() const { return app().current_cursor(); }
 | 
						||
 | 
						||
TRelation* TTessere_form::relation() const { return cursor()->relation(); }
 | 
						||
 | 
						||
void TTessere_application::set_page(int file, int cnt)
 | 
						||
{
 | 
						||
	// costruzione pagine
 | 
						||
	switch (_tipo_stampa)
 | 
						||
	{
 | 
						||
		case pagine:
 | 
						||
		{
 | 
						||
			TPrint_section& corpo = _form_pag->get_body();
 | 
						||
			corpo.reset();
 | 
						||
			corpo.update();
 | 
						||
  		for (int i = 0; i < corpo.items(); i++)
 | 
						||
  		{
 | 
						||
  			TPrintrow& riga = corpo.row(i);
 | 
						||
  			set_row(i+1,"%s",riga.row());
 | 
						||
			}  			
 | 
						||
			force_setpage(TRUE);	// serve perch<63> alla prossima etichetta rifaccia la setpage
 | 
						||
														// altrimenti stampa sempre la stessa etichetta
 | 
						||
		}
 | 
						||
		break;
 | 
						||
		case tessere:
 | 
						||
		{           
 | 
						||
  		TString16 data_stampa = _data_stampa.string();
 | 
						||
			set_row(3, "@30g@S",       FLD(LF_SEZIONI,SEZ_DENSEZ));
 | 
						||
			set_row(4, "@30g@S",       FLD(LF_SEZIONI,SEZ_DENSOT));
 | 
						||
			set_row(9,"@33g%s@1j@pn",  "Cod. prov.",FLD(LF_SOGGETTI,SOG_CODICE,"#########"));
 | 
						||
			set_row(12,"@37g@10ls",    FLD(LF_SOGGETTI,SOG_TESSAVIS));
 | 
						||
  		set_row(14,"@45g%10s", 		 (const char*) data_stampa);
 | 
						||
			set_row(16,"@8g@ls@1j@ls", FLD(LF_SOGGETTI,SOG_COGNOME), FLD(LF_SOGGETTI,SOG_NOME));
 | 
						||
			set_row(18,"@8g@ls@1j@2s", FLD(-ALIAS_COMNAS,COM_DENCOM),FLD(-ALIAS_COMNAS,COM_PROVCOM));
 | 
						||
			set_row(18,"@45g@ld",      FLD(LF_SOGGETTI,SOG_DATANASC));
 | 
						||
			set_row(20,"@10g@ls@1j@2s",FLD(-ALIAS_COMRES,COM_DENCOM),FLD(-ALIAS_COMRES,COM_PROVCOM));
 | 
						||
			set_row(20,"@45g@15ls",    FLD(LF_SOGGETTI,SOG_TELABI));
 | 
						||
			set_row(22,"@2g@50ls",     FLD(LF_SOGGETTI,SOG_DOM_INDIR));
 | 
						||
			set_row(24,"@10g@16ls",    FLD(LF_SOGGETTI,SOG_CF));
 | 
						||
			set_row(28,"@4g@4ls",			 FLD(LF_SOGGETTI,SOG_GRUPPOAB0));
 | 
						||
			set_row(28,"@17g@3ls",     FLD(LF_SOGGETTI,SOG_RHANTID));
 | 
						||
			set_row(28,"@30g@6ls",		 FLD(LF_SOGGETTI,SOG_FENOTIPORH));
 | 
						||
			set_row(28,"@48g@3ls",		 FLD(LF_SOGGETTI,SOG_KELL));
 | 
						||
			set_row(28,"@58g@3ls",		 FLD(LF_SOGGETTI,SOG_DU));
 | 
						||
			set_row(32,"@4g@20ls",		 FLD(LF_SOGGETTI,SOG_DOCID));
 | 
						||
			set_row(41,"@4g#t", 			 &_riepilogodon);
 | 
						||
			set_row(72,"");
 | 
						||
		}
 | 
						||
		break;
 | 
						||
	}					
 | 
						||
}
 | 
						||
 | 
						||
bool TTessere_application::preprocess_page(int file, int counter)
 | 
						||
{
 | 
						||
	// contatore soggetti stampati 
 | 
						||
	// per ora non c'<27>
 | 
						||
	int totdon = current_cursor()->curr(LF_SOGGETTI).get_int(SOG_TOTDON);
 | 
						||
	TDate dataultima = current_cursor()->curr(LF_SOGGETTI).get(SOG_DATAULTDON);
 | 
						||
 | 
						||
	_riepilogodon = "";
 | 
						||
	if (totdon != 0)	
 | 
						||
	{	
 | 
						||
		_riepilogodon = "Donazioni effettuate fino al ";
 | 
						||
		_riepilogodon << dataultima.string();
 | 
						||
		_riepilogodon << " n.ro ";
 | 
						||
		_riepilogodon << totdon;
 | 
						||
	}	
 | 
						||
  return TRUE;
 | 
						||
}
 | 
						||
 | 
						||
bool TTessere_application::set_print(int m)
 | 
						||
{ 
 | 
						||
	_tipo_stampa = undefined;
 | 
						||
  KEY tasto;
 | 
						||
  tasto = _msk->run();
 | 
						||
  switch (tasto)
 | 
						||
  {
 | 
						||
  case F_TESSERE:
 | 
						||
  	_tipo_stampa = tessere;
 | 
						||
  	break;
 | 
						||
  case F_PAGINE:
 | 
						||
  	_tipo_stampa = pagine;	
 | 
						||
  	break;
 | 
						||
  }	
 | 
						||
	if (_tipo_stampa != undefined)
 | 
						||
  {
 | 
						||
    reset_files(); 
 | 
						||
    add_file(LF_SOGGETTI);
 | 
						||
    
 | 
						||
		reset_print();
 | 
						||
		crea_intestazione();
 | 
						||
    return TRUE;
 | 
						||
  }
 | 
						||
  else
 | 
						||
    return FALSE;
 | 
						||
}
 | 
						||
 | 
						||
void TTessere_application::crea_intestazione()
 | 
						||
{
 | 
						||
  TString256 sep(132);
 | 
						||
  TString16 data_stampa;
 | 
						||
  
 | 
						||
  reset_header();
 | 
						||
  
 | 
						||
  if (_tipo_stampa == pagine)
 | 
						||
	{  
 | 
						||
  	sep.fill('-');
 | 
						||
  	set_header(1, (const char *) sep);
 | 
						||
  	sep = "";
 | 
						||
  	sep << "Pag. @#";
 | 
						||
  	sep.right_just(132); 
 | 
						||
  	set_header(2,(const char*) sep);  
 | 
						||
  
 | 
						||
  	set_header(2,"@0gSTAMPA PAGINE ANAGRAFICHE@64gDATA");
 | 
						||
  	data_stampa = _data_stampa.string();
 | 
						||
  	set_header(2,"@69g%10s", (const char*) data_stampa);
 | 
						||
  
 | 
						||
  	sep = "";
 | 
						||
  	sep.fill('-');
 | 
						||
  	set_header(3, (const char *) sep);
 | 
						||
	}  	
 | 
						||
}
 | 
						||
 | 
						||
bool TTessere_application::user_create()
 | 
						||
{
 | 
						||
  _rel = new TRelation(LF_SOGGETTI);
 | 
						||
  _rel->add(LF_COMUNI, "COM==COMNASC",1,0,ALIAS_COMNAS);
 | 
						||
  _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMRES);
 | 
						||
  _rel->add("LCP", "CODTAB==DOM_CODLOC");
 | 
						||
  _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
 | 
						||
 | 
						||
  _cur1 = add_cursor(new TCursor(_rel, "", 1));	//cursore ordinamento per codice
 | 
						||
  _cur2 = add_cursor(new TCursor(_rel, "", 2));	//cursore ordinamento per cognome e nome
 | 
						||
  _cur3 = add_cursor(new TCursor(_rel, "", 3));	//cursore ordinamento per sezione+sottogruppo+codice
 | 
						||
  _cur4 = add_cursor(new TCursor(_rel, "", 4));	//cursore ordinamento per sezione+sottogruppo+cognome e nome
 | 
						||
 | 
						||
  _msk = new TMask("at3200a");
 | 
						||
  
 | 
						||
  _form_pag = new TTessere_form("AT_PAGIN");	// dovr<76> esserci PAGINE
 | 
						||
  
 | 
						||
  return TRUE;
 | 
						||
}
 | 
						||
 | 
						||
bool TTessere_application::user_destroy()
 | 
						||
{
 | 
						||
  delete _msk;
 | 
						||
  delete _rel;
 | 
						||
  delete _form_pag;
 | 
						||
  return TRUE;
 | 
						||
}
 | 
						||
 | 
						||
int at3200(int argc, char* argv[])
 | 
						||
{
 | 
						||
 | 
						||
  TTessere_application a;
 | 
						||
 | 
						||
  a.run(argc, argv, "Stampa tessere e pagine");
 | 
						||
 | 
						||
  return 0;
 | 
						||
}
 |