Files correlati : at4.exe Ricompilazione Demo : [ ] Commento : sistemato stampa etichette e cartoline su A4 git-svn-id: svn://10.65.10.50/trunk@11644 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			611 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			611 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <form.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include "soggetti.h"
 | 
						|
#include "sezioni.h"
 | 
						|
 | 
						|
#include "at4.h"
 | 
						|
#include "at4300a.h"
 | 
						|
#include "at4100b.h"
 | 
						|
#include "at4100c.h"
 | 
						|
#include "atlib.h"
 | 
						|
 | 
						|
#define ALIAS_TABLCP	100			// alias tabella località postali
 | 
						|
#define ALIAS_TABTCS	200			// alias tabella tipi/esiti controlli sanitari
 | 
						|
#define	ALIAS_TABCTD	700			// alias tabella categorie donatori
 | 
						|
 | 
						|
#define STATO_IDONEO  'I'			// IDONEITA'
 | 
						|
#define STATO_FINESO	'F'			// FINE SOSPENSIONE
 | 
						|
// tpi di stampa
 | 
						|
enum ts { undefined = 0, elencocon = 1, elencorit = 2, etichette = 3, cartoline = 4, sms = 5 };
 | 
						|
 | 
						|
// definizione form per etichette e cartoline
 | 
						|
class TConv_form : public TForm
 | 
						|
{
 | 
						|
public:
 | 
						|
	
 | 
						|
	virtual TCursor* cursor() const;
 | 
						|
	virtual TRelation* relation() const;
 | 
						|
	TPrint_section& get_body() { return section('B'); } ;
 | 
						|
  TConv_form(): TForm() {};
 | 
						|
  TConv_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "")
 | 
						|
    						: TForm(form,code,editlevel,desc) {};
 | 
						|
  virtual ~TConv_form() {};
 | 
						|
};
 | 
						|
 | 
						|
class TStampaConvocazioni : public TPrintapp
 | 
						|
{
 | 
						|
  static bool filter_func_conv(const TRelation* rel);
 | 
						|
 | 
						|
  TRelation*        _rel;
 | 
						|
  TMask*            _msk;
 | 
						|
  TConv_form*				_form_eti;	// per etichette
 | 
						|
  TConv_form*				_form_car;	// per cartoline
 | 
						|
  TDate 						_data_stampa;      
 | 
						|
  ts								_tipostampa;
 | 
						|
	TString16					_codsez, _codsot, _orario, _datacart;
 | 
						|
	TString80					_invitoper, _data, _presso1, _presso2, _presso3, _presso4;
 | 
						|
	TString80					_note, _intest1, _intest2, _intest3, _intest4;
 | 
						|
  TDate							_dataconv;
 | 
						|
  bool 							_usasez;
 | 
						|
  long 							_intmin, _intmax, _intmincon;
 | 
						|
  TParagraph_string _cognome_nome;
 | 
						|
  int								_numconv;
 | 
						|
  bool 							_definitiva;
 | 
						|
	int								_etlarghezza, _etcolonne;
 | 
						|
  int								_contatore, _totfinestampa;
 | 
						|
  int 						  _caxpag, _cabordoini, _cabordofin, _ncartoline;
 | 
						|
	bool 							_provastampa;
 | 
						|
	  
 | 
						|
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);
 | 
						|
  //virtual print_action postprocess_page (int file, int counter);
 | 
						|
  ts dati_cartoline();
 | 
						|
 | 
						|
public:
 | 
						|
  void crea_intestazione();
 | 
						|
  void filtra_sezioni();
 | 
						|
  void header_sezione(const TString16 codsez, const TString16 codsot);
 | 
						|
  void footer_sezione();
 | 
						|
  void fine_stampa();
 | 
						|
  void dati_sezione(const TString16 codsez, const TString16 codsot);
 | 
						|
  TStampaConvocazioni() : _data_stampa(TODAY), _cognome_nome("",25) {}
 | 
						|
};
 | 
						|
 | 
						|
HIDDEN inline TStampaConvocazioni& app() { return (TStampaConvocazioni&) main_app(); }
 | 
						|
 | 
						|
TCursor* TConv_form::cursor() const { return app().current_cursor(); }
 | 
						|
 | 
						|
TRelation* TConv_form::relation() const { return cursor()->relation(); }
 | 
						|
 | 
						|
ts TStampaConvocazioni::dati_cartoline()
 | 
						|
{
 | 
						|
	TMask msk("at4100b");
 | 
						|
 	if (msk.run() == K_ENTER) 
 | 
						|
 	{ 
 | 
						|
 		_invitoper = msk.get(F_INVITOPER);
 | 
						|
 		_data			 = msk.get(F_DATA);
 | 
						|
 		_presso1   = msk.get(F_PRESSO1);
 | 
						|
 		_presso2   = msk.get(F_PRESSO2);
 | 
						|
 		_presso3   = msk.get(F_PRESSO3);
 | 
						|
 		_presso4   = msk.get(F_PRESSO4);
 | 
						|
 		_datacart  = msk.get(F_DATACART);
 | 
						|
 		_orario  	 = msk.get(F_ORARIO);
 | 
						|
 		_note   	 = msk.get(F_NOTE);
 | 
						|
 		_usasez		 = msk.get_bool(F_USASEZ);
 | 
						|
 		return cartoline;
 | 
						|
 	}
 | 
						|
 	else
 | 
						|
 		return undefined;
 | 
						|
}
 | 
						|
 | 
						|
void TStampaConvocazioni::set_page(int file, int cnt)
 | 
						|
{               
 | 
						|
	switch (_tipostampa)
 | 
						|
	{
 | 
						|
	case elencocon:
 | 
						|
	case elencorit:
 | 
						|
	{
 | 
						|
		reset_row(1);						
 | 
						|
		reset_row(2);						
 | 
						|
		reset_row(3);						
 | 
						|
		set_row(1,"@0g@S", 	FLD(LF_SOGGETTI,SOG_CODCL));
 | 
						|
		// stampare il numero convocazione
 | 
						|
		set_row(1,"@7g#3d", &_numconv);
 | 
						|
		set_row(1,"@11g#a", &_cognome_nome);
 | 
						|
		set_row(1,"@37g@ld",FLD(LF_SOGGETTI,SOG_DATANASC));
 | 
						|
		set_row(1,"@48g@S", FLD(LF_SOGGETTI,SOG_GRUPPOAB0));
 | 
						|
		set_row(1,"@52g@S", FLD(LF_SOGGETTI,SOG_RHANTID));
 | 
						|
		set_row(1,"@56g@S", FLD(LF_SOGGETTI,SOG_KELL));
 | 
						|
		set_row(1,"@60g@S", FLD(LF_SOGGETTI,SOG_FENOTIPORH));
 | 
						|
		set_row(1,"@67g@S", FLD(LF_SOGGETTI,SOG_DU));
 | 
						|
		set_row(1,"@71g@ld",FLD(LF_SOGGETTI,SOG_DATAULTDON));
 | 
						|
		set_row(1,"@82g@S", FLD(LF_SOGGETTI,SOG_TIPOULTDON));
 | 
						|
		set_row(1,"@85g@ld",FLD(LF_SOGGETTI,SOG_DATAPROSSI));
 | 
						|
		set_row(2,"@0g@S", 	FLD(LF_SOGGETTI,SOG_TESSAVIS));
 | 
						|
		set_row(2,"@37g@S", FLD(LF_SOGGETTI,SOG_CATDON));
 | 
						|
		set_row(2,"@71g@ld",FLD(LF_SOGGETTI,SOG_DATAULTID));
 | 
						|
		set_row(2,"@82g@S", FLD(LF_SOGGETTI,SOG_TIPOULTID));
 | 
						|
		set_row(2,"@85g@pn",FLD(LF_SOGGETTI,SOG_INTSI,"###"));
 | 
						|
		set_row(1,"@96g@S", FLD(LF_SOGGETTI,SOG_TELABI));
 | 
						|
		set_row(1,"@111g@S", FLD(LF_SOGGETTI,SOG_TELALT));
 | 
						|
		set_row(2,"@96g@S", FLD(LF_SOGGETTI,SOG_TELLAV));
 | 
						|
		set_row(3,"");
 | 
						|
	}
 | 
						|
	break;
 | 
						|
	case etichette:
 | 
						|
	{
 | 
						|
		TPrint_section& corpo = _form_eti->get_body();
 | 
						|
		for (int r=1;r<=_etcolonne;r++)
 | 
						|
		{                     
 | 
						|
			if (current_cursor()->pos()<current_cursor()->items())
 | 
						|
			{ 
 | 
						|
				force_setpage(TRUE);
 | 
						|
				corpo.update();
 | 
						|
				for (word i = 0; i < corpo.height(); i++)
 | 
						|
				{
 | 
						|
					TPrintrow& riga = corpo.row(i);
 | 
						|
					TString256 riga1 = riga.row();
 | 
						|
					riga1.cut(_etlarghezza);
 | 
						|
					int colonna = ((r-1)*_etlarghezza);
 | 
						|
					TString16 formato;
 | 
						|
					formato << '@' << colonna << "g";
 | 
						|
					riga1.insert(formato,0);
 | 
						|
					set_row(i+1,riga1);
 | 
						|
				}
 | 
						|
				if (r < _etcolonne)  			
 | 
						|
					++(*current_cursor());
 | 
						|
			}					
 | 
						|
		}				
 | 
						|
	} 
 | 
						|
	break;
 | 
						|
	case cartoline:
 | 
						|
	{
 | 
						|
		TPrint_section& corpo = _form_car->get_body();
 | 
						|
		const TString16 codsez = current_cursor()->curr().get(SOG_CODSEZ);		
 | 
						|
		const TString16 codsot = current_cursor()->curr().get(SOG_CODSOT);		
 | 
						|
		if ((_codsez!=codsez)||(_codsot!=codsot))
 | 
						|
		{
 | 
						|
			_codsez = codsez;
 | 
						|
			_codsot = codsot;
 | 
						|
			dati_sezione(codsez, codsot);
 | 
						|
			corpo.reset();
 | 
						|
		  TForm_item& intest1 = corpo.find_field(CAR_INTEST1);
 | 
						|
		  intest1.set(_intest1);
 | 
						|
		  TForm_item& intest2 = corpo.find_field(CAR_INTEST2);
 | 
						|
		  intest2.set(_intest2);
 | 
						|
		  TForm_item& intest3 = corpo.find_field(CAR_INTEST3);
 | 
						|
		  intest3.set(_intest3);
 | 
						|
		  TForm_item& intest4 = corpo.find_field(CAR_INTEST4);
 | 
						|
		  intest4.set(_intest4);
 | 
						|
		  TForm_item& invito = corpo.find_field(CAR_INVITOPER);
 | 
						|
  		invito.set(_invitoper);
 | 
						|
		  TForm_item& data = corpo.find_field(CAR_DATA);
 | 
						|
  		data.set(_data);
 | 
						|
		  TForm_item& presso1 = corpo.find_field(CAR_PRESSO1);
 | 
						|
  		presso1.set(_presso1);
 | 
						|
		  TForm_item& presso2 = corpo.find_field(CAR_PRESSO2);
 | 
						|
  		presso2.set(_presso2);
 | 
						|
		  TForm_item& presso3 = corpo.find_field(CAR_PRESSO3);
 | 
						|
  		presso3.set(_presso3);
 | 
						|
		  TForm_item& presso4 = corpo.find_field(CAR_PRESSO4);
 | 
						|
  		presso4.set(_presso4);
 | 
						|
		  TForm_item& orario = corpo.find_field(CAR_ORARIO);
 | 
						|
  		orario.set(_orario);
 | 
						|
		  TForm_item& datacart = corpo.find_field(CAR_DATACART);
 | 
						|
  		datacart.set(_datacart);
 | 
						|
		  TForm_item& note = corpo.find_field(CAR_NOTE);
 | 
						|
  		note.set(_note);
 | 
						|
		}           
 | 
						|
		/*
 | 
						|
		corpo.update();
 | 
						|
 		for (word i = 0; i < corpo.height(); i++)
 | 
						|
 		{
 | 
						|
 			TPrintrow& riga = corpo.row(i);
 | 
						|
 			set_row(i+1,riga);
 | 
						|
		}  			
 | 
						|
		force_setpage(TRUE);	// serve perchè alla prossima etichetta rifaccia la setpage
 | 
						|
														// altrimenti stampa sempre la stessa etichetta
 | 
						|
		*/
 | 
						|
		corpo.update();
 | 
						|
		word primariga = 0;
 | 
						|
		word ultimariga = corpo.height(); 	
 | 
						|
		if (_caxpag > 0)
 | 
						|
		{
 | 
						|
			if (_ncartoline % _caxpag == 0) // numero cartoline per pagina
 | 
						|
				primariga = _cabordoini;						// bordo iniziale
 | 
						|
			if (_ncartoline % _caxpag == _caxpag-1) // numero cartoline per pagina - 1
 | 
						|
				ultimariga -= _cabordofin;						// bordo finale
 | 
						|
		}		
 | 
						|
		int nriga = 1;
 | 
						|
		for (word i = primariga; i < ultimariga; i++)
 | 
						|
		{
 | 
						|
			TPrintrow& riga = corpo.row(i);
 | 
						|
			set_row(nriga++,riga);
 | 
						|
		}  			
 | 
						|
		force_setpage(TRUE);
 | 
						|
		_ncartoline++;
 | 
						|
	}
 | 
						|
	break;
 | 
						|
	case sms:
 | 
						|
	{
 | 
						|
		set_row(1,"@0g@S,", FLD(LF_SOGGETTI,SOG_TELALT));
 | 
						|
		set_row(1,"@16g@S,", FLD(LF_SOGGETTI,SOG_COGNOME));
 | 
						|
		set_row(1,"@43g@S,", FLD(LF_SOGGETTI,SOG_NOME));
 | 
						|
		set_row(1,"@70g@ld", FLD(LF_SOGGETTI,SOG_DATANASC));
 | 
						|
	}
 | 
						|
	break;
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
void TStampaConvocazioni::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.not_empty())
 | 
						|
	{
 | 
						|
		intestazione << "/";
 | 
						|
		intestazione << densot;
 | 
						|
	}		
 | 
						|
	intestazione.center_just();
 | 
						|
	set_header(1,"@0g%s", (const char*) intestazione);
 | 
						|
	return;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampaConvocazioni::filter_func_conv (const TRelation* rel)
 | 
						|
{
 | 
						|
  const TRectype& sog = rel->curr();
 | 
						|
  const TDate	dataprossi = sog.get_date(SOG_DATAPROSSI);
 | 
						|
	const char stato = rel->curr(-ALIAS_TABTCS).get_char("S6");
 | 
						|
	const bool dimesso = rel->curr(-ALIAS_TABCTD).get_bool("B0");
 | 
						|
  TDate dataconv = sog.get_date(SOG_DATACONV);
 | 
						|
  const int totdon = sog.get_int(SOG_TOTDON);
 | 
						|
  const int numconv = sog.get_int(SOG_NUMCONV);
 | 
						|
  if (dataprossi.ok())
 | 
						|
	{                                              
 | 
						|
		// intervallo tra data convocazione e data pross. si
 | 
						|
  	long intconvsi = app()._dataconv - dataprossi;  
 | 
						|
  	// intervallo tra data convocazione e data ultima convocazione 
 | 
						|
  	long intultconvsi = app()._dataconv - dataconv;
 | 
						|
  	// verifico se si tratta di soggetto nuovo, con 0 donazioni
 | 
						|
  	if ((totdon == 0) && (numconv == 0))
 | 
						|
  	{
 | 
						|
		  const TDate dataultid = sog.get_date(SOG_DATAULTID);
 | 
						|
			long intervallo = app()._dataconv - dataultid;
 | 
						|
			// convoco solo se è passato l'intervallo minimo di convocazione
 | 
						|
			if (intervallo >= app()._intmincon) 
 | 
						|
				return TRUE;
 | 
						|
			else
 | 
						|
				return FALSE;				
 | 
						|
		}  	
 | 
						|
		else
 | 
						|
  		if ((intconvsi >= 0) && (intconvsi < app()._intmax) && (intultconvsi > app()._intmin) && 
 | 
						|
         ((stato == STATO_IDONEO) || (stato == STATO_FINESO)) && (!dimesso)) 
 | 
						|
  			return TRUE;
 | 
						|
  		else          
 | 
						|
  			return FALSE;
 | 
						|
	} 	
 | 
						|
  else
 | 
						|
  	// non ha la data di prossima donazione SI
 | 
						|
  	return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
print_action TStampaConvocazioni::postprocess_page(int file, int counter)
 | 
						|
{
 | 
						|
	if (_tipostampa==cartoline && _provastampa)
 | 
						|
	{
 | 
						|
		if (yesno_box("Verificare la posizione di stampa.\nSi puo' procedere con la stampa?"))
 | 
						|
		{                    
 | 
						|
			_provastampa = FALSE;
 | 
						|
			return NEXT_PAGE;	
 | 
						|
		}
 | 
						|
		else
 | 
						|
			return REPEAT_PAGE;
 | 
						|
	}	  
 | 
						|
	else
 | 
						|
		return NEXT_PAGE;
 | 
						|
}
 | 
						|
*/
 | 
						|
 | 
						|
void TStampaConvocazioni::footer_sezione()
 | 
						|
{
 | 
						|
	// stampa totale soggetti a fine pagina
 | 
						|
	reset_footer();
 | 
						|
	TString sep(80);
 | 
						|
	sep.fill('-');
 | 
						|
	set_footer(1, (const char *) sep);
 | 
						|
	set_footer(2,"TOTALE PER SEZIONE %d", _contatore);
 | 
						|
	printer().formfeed(); 
 | 
						|
	reset_footer();
 | 
						|
}
 | 
						|
 | 
						|
void TStampaConvocazioni::fine_stampa()
 | 
						|
{
 | 
						|
	// stampa totale soggetti a fine stampa
 | 
						|
	
 | 
						|
	reset_footer();
 | 
						|
 	printer().footerlen(20);
 | 
						|
	TString sep(80);
 | 
						|
	sep.fill('-');
 | 
						|
	set_footer(1, (const char *) sep);
 | 
						|
 	const TString16 sezini = _msk->get(F_SEZINI);
 | 
						|
 	const TString16 sotini = _msk->get(F_SOTINI);
 | 
						|
 	const TString16 sezfin = _msk->get(F_SEZFIN);
 | 
						|
 	const TString16 sotfin = _msk->get(F_SOTFIN);
 | 
						|
	set_footer(3,"Da sezione/sottogruppo %s/%s", (const char*) sezini, (const char*) sotini);
 | 
						|
	set_footer(4," a sezione/sottogruppo %s/%s", (const char*) sezfin, (const char*) sotfin);
 | 
						|
	set_footer(6,"TOTALE GENERALE %d", _totfinestampa);
 | 
						|
 | 
						|
	TString16 data_stampa = _data_stampa.string();
 | 
						|
	set_footer(8,"Stampato il %10s", (const char*) data_stampa);
 | 
						|
	printer().formfeed();
 | 
						|
	reset_footer();
 | 
						|
}
 | 
						|
 | 
						|
print_action TStampaConvocazioni::postprocess_print(int file, int counter)
 | 
						|
{ 
 | 
						|
	if (_tipostampa==elencocon || _tipostampa==elencorit)
 | 
						|
	{
 | 
						|
		if (_contatore > 0)
 | 
						|
			footer_sezione();
 | 
						|
		if (_totfinestampa > 0 && _contatore != _totfinestampa)
 | 
						|
			fine_stampa();				
 | 
						|
	}	
 | 
						|
	return NEXT_PAGE;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampaConvocazioni::preprocess_page(int file, int counter)
 | 
						|
{
 | 
						|
	TRectype& recsog = current_cursor()->curr();
 | 
						|
	if (_tipostampa==sms)
 | 
						|
	{
 | 
						|
		TString& telalt = (TString&) recsog.get(SOG_TELALT);
 | 
						|
		if (telalt.empty())
 | 
						|
			return FALSE;
 | 
						|
	}	
 | 
						|
	if (_tipostampa==elencocon || _tipostampa==elencorit)
 | 
						|
	{
 | 
						|
		const TString16 codsez = recsog.get(SOG_CODSEZ);		
 | 
						|
		const TString16 codsot = recsog.get(SOG_CODSOT);		
 | 
						|
		TString80 nome = recsog.get(SOG_COGNOME);
 | 
						|
		nome << " ";
 | 
						|
		nome << recsog.get(SOG_NOME);
 | 
						|
		_cognome_nome = nome;
 | 
						|
		// salto pagina se cambio sezione
 | 
						|
		if ((_codsez!=codsez)||(_codsot!=codsot))
 | 
						|
		{
 | 
						|
			if ((_codsez != "**") && (_contatore > 0))
 | 
						|
				footer_sezione();
 | 
						|
			_contatore = 0;	
 | 
						|
			_codsez = codsez;
 | 
						|
			_codsot = codsot;
 | 
						|
			header_sezione(codsez, codsot);
 | 
						|
		}
 | 
						|
		else
 | 
						|
		if (printer().rows_left() < 3)
 | 
						|
			printer().formfeed();
 | 
						|
	}
 | 
						|
	if (_tipostampa==etichette)		
 | 
						|
		if (printer().rows_left() < _form_eti->get_body().height())
 | 
						|
			printer().formfeed();
 | 
						|
	TString80 nome = recsog.get(SOG_COGNOME);
 | 
						|
	nome << " ";
 | 
						|
	nome << recsog.get(SOG_NOME);
 | 
						|
	_cognome_nome = nome;
 | 
						|
	_numconv = recsog.get_int(SOG_NUMCONV);
 | 
						|
	_numconv++;
 | 
						|
	if (_definitiva)
 | 
						|
	{
 | 
						|
		recsog.put(SOG_NUMCONV, _numconv);
 | 
						|
  	recsog.put(SOG_DATACONV,app()._dataconv);
 | 
						|
		current_cursor()->file().rewrite();
 | 
						|
	}
 | 
						|
	if (_numconv > 4)
 | 
						|
	{
 | 
						|
		if (_tipostampa==cartoline || _tipostampa==etichette || _tipostampa==elencocon)
 | 
						|
		{
 | 
						|
			if (_tipostampa==cartoline)
 | 
						|
				_ncartoline--;
 | 
						|
			return FALSE;
 | 
						|
		}	
 | 
						|
		else
 | 
						|
		{
 | 
						|
			_contatore++;
 | 
						|
			_totfinestampa++;
 | 
						|
			return TRUE;			
 | 
						|
		}			
 | 
						|
	}
 | 
						|
	else
 | 
						|
		if (_tipostampa==elencorit)
 | 
						|
			return FALSE;
 | 
						|
		else			
 | 
						|
		{
 | 
						|
  		_contatore++;
 | 
						|
			_totfinestampa++;
 | 
						|
  		return TRUE;
 | 
						|
		}  		
 | 
						|
}
 | 
						|
 | 
						|
void TStampaConvocazioni::filtra_sezioni()
 | 
						|
{
 | 
						|
 	const TString16 sezini = _msk->get(F_SEZINI);
 | 
						|
 	const TString16 sotini = _msk->get(F_SOTINI);
 | 
						|
 	const TString16 sezfin = _msk->get(F_SEZFIN);
 | 
						|
 	const TString16 sotfin = _msk->get(F_SOTFIN);
 | 
						|
  TRectype da(LF_SOGGETTI);
 | 
						|
  TRectype a(LF_SOGGETTI);   
 | 
						|
  if (sezini.not_empty())
 | 
						|
		da.put(SOG_CODSEZ, sezini);
 | 
						|
  if (sotini.not_empty())
 | 
						|
		da.put(SOG_CODSOT, sotini);
 | 
						|
  if (sezfin.not_empty())
 | 
						|
		a.put(SOG_CODSEZ, sezfin);
 | 
						|
  if (sotfin.not_empty())
 | 
						|
		a.put(SOG_CODSOT, sotfin);
 | 
						|
	current_cursor()->setregion(da, a);
 | 
						|
}	
 | 
						|
void TStampaConvocazioni::dati_sezione(const TString16 codsez, const TString16 codsot)
 | 
						|
{
 | 
						|
	_intest1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ1);
 | 
						|
	_intest2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ2);
 | 
						|
	_intest3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ3);
 | 
						|
	_intest4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_INTESTAZ4);
 | 
						|
	if (_usasez)
 | 
						|
	{
 | 
						|
		if (_presso1.blank())
 | 
						|
		{
 | 
						|
			_presso1 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE1);
 | 
						|
			_presso2 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE2);
 | 
						|
			_presso3 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE3);
 | 
						|
			_presso4 = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVSEDE4);
 | 
						|
		}			
 | 
						|
		if (_orario.blank())
 | 
						|
			_orario = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVORA);
 | 
						|
		if (_note.blank())
 | 
						|
			_note = current_cursor()->curr(LF_SEZIONI).get(SEZ_CONVNOTE);
 | 
						|
	}
 | 
						|
	return;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampaConvocazioni::set_print(int)
 | 
						|
{           
 | 
						|
  TPrinter& p = printer();
 | 
						|
	p.read_configuration();
 | 
						|
	_tipostampa = undefined;
 | 
						|
  KEY tasto;
 | 
						|
  tasto = _msk->run();
 | 
						|
	switch (tasto)               
 | 
						|
	{
 | 
						|
		case F_ELENCOCON:
 | 
						|
			_tipostampa = elencocon;
 | 
						|
		break;		
 | 
						|
		case F_ELENCORIT:
 | 
						|
			_tipostampa = elencorit;
 | 
						|
		break;		
 | 
						|
	  case F_ETICHETTE:
 | 
						|
  		_tipostampa = (configura_stampante(p, "AT_ETICHETTE", "etichette")) ? etichette : undefined;
 | 
						|
		break;  	
 | 
						|
		case F_CARTOLINE:
 | 
						|
	  	_tipostampa = (configura_stampante(p, "AT_CARTOLINE", "cartoline")) ? dati_cartoline() : undefined;
 | 
						|
		break;			
 | 
						|
	  case F_SMS:
 | 
						|
  		_tipostampa = (configura_stampante(p, "AT_SMS", "invio SMS")) ? sms : undefined;
 | 
						|
  	break;
 | 
						|
	}
 | 
						|
  if (_tipostampa != undefined)
 | 
						|
  {
 | 
						|
		_codsez = "**";
 | 
						|
  	_codsot = "**";
 | 
						|
  	_contatore = 0;
 | 
						|
  	_totfinestampa = 0;
 | 
						|
  	_provastampa = TRUE;
 | 
						|
		_ncartoline  = 0;
 | 
						|
		reset_files(); 
 | 
						|
    add_file(LF_SOGGETTI);
 | 
						|
		_dataconv = _msk->get(F_DATACONV);
 | 
						|
		_intmin = _msk->get_int(F_INTMIN);
 | 
						|
		_intmax = _msk->get_int(F_INTMAX);
 | 
						|
		_intmincon = _msk->get_int(F_INTMINCON);
 | 
						|
		_definitiva = _msk->get_bool(F_DEFINITIVA);
 | 
						|
    // filtro per sezioni selezionati
 | 
						|
	  filtra_sezioni();
 | 
						|
		// filtro su non esclusi, idonei e categorie non dimessi
 | 
						|
		// questo filtro non funziona perchè non funziona il riconoscimento dell'alias 
 | 
						|
		// nelle espressioni; sarebbe molto bello averlo a disposizione!
 | 
						|
		//current_cursor()->setfilter("((ESCLUSO == \"\") && (-100->B0!=\"X\") && ((-200->S6 == \"I\") || (-200->S6 == \"F\")))", TRUE);
 | 
						|
		// filtro su non esclusi
 | 
						|
		current_cursor()->setfilter("(ESCLUSO == \"\")", TRUE);
 | 
						|
   	// filtro su data e altri filtri che non posso mettere nella setfilter
 | 
						|
    current_cursor()->set_filterfunction (filter_func_conv, TRUE);
 | 
						|
    reset_print();
 | 
						|
		printer().footerlen(0);
 | 
						|
    crea_intestazione();
 | 
						|
    return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
void TStampaConvocazioni::crea_intestazione()
 | 
						|
{
 | 
						|
  reset_header();
 | 
						|
  if (_tipostampa==elencocon || _tipostampa==elencorit)
 | 
						|
  {
 | 
						|
  	TString sep(132);
 | 
						|
  	if (_tipostampa==elencocon)
 | 
						|
  		sep = "ELENCO CONVOCATI elaborato il ";
 | 
						|
		else  		
 | 
						|
  		sep = "ELENCO RITARDATARI elaborato il ";
 | 
						|
 		sep << _dataconv.string();
 | 
						|
		sep.center_just();
 | 
						|
  	set_header(2, "@0g%s", (const char*) sep);
 | 
						|
  	TString16 data_stampa = _data_stampa.string();
 | 
						|
  	set_header(2,"@0g%10s", (const char*) data_stampa);
 | 
						|
  	sep = "";
 | 
						|
  	sep << "Pag. @#";
 | 
						|
  	set_header(2, "@120g%s", (const char*) sep);  
 | 
						|
  	sep = "";
 | 
						|
  	sep.fill('-');
 | 
						|
  	set_header(3, (const char *) sep);
 | 
						|
	  set_header(5,"@0gCod.CL@7gNC@11gCognome e nome@37gNato il@48gGr.@52gRh@55gKell@60gFen.Rh@67gDu@71gUltima donaz.@85gData pros.@96gTel. abitaz.@111gTelefono altro");
 | 
						|
	  set_header(6,"@0gTess.@37gCat.don@71gUltima idon.@85gInt.SI@96gTelefono lav.");  
 | 
						|
	  set_header(7,"@0g------@7g---@11g-------------------------@37g----------@48g--- --- --- ------ --@71g---------- --@85g---------- --@96g--------------@111g---------------");
 | 
						|
	 	printer().footerlen(3);
 | 
						|
	}	  
 | 
						|
}
 | 
						|
 | 
						|
bool TStampaConvocazioni::user_create()
 | 
						|
{
 | 
						|
  _rel = new TRelation(LF_SOGGETTI);
 | 
						|
  _rel->add("TCS", "CODTAB==STATO",    1, 0, ALIAS_TABTCS);	// per verificare che sia IDONEO
 | 
						|
  _rel->add("CTD", "CODTAB==CATDON",   1, 0, ALIAS_TABCTD);		// per verificare che sia DONATORE NON DIMESSO
 | 
						|
  _rel->add("LCP", "CODTAB==DOM_CODLOC", 1, 0, ALIAS_TABLCP);		// per verificare che sia DONATORE NON DIMESSO
 | 
						|
  _rel->add(LF_COMUNI, "COM==DOM_CODCOM");
 | 
						|
  _rel->add(LF_SEZIONI, "CODSEZ==CODSEZ|CODSOT==CODSOT");
 | 
						|
  add_cursor(new TCursor(_rel, "", 3));
 | 
						|
  _msk = new TMask("at4300a");
 | 
						|
  TConfig config(CONFIG_STUDIO);
 | 
						|
  TString16 etformato = config.get("EtFormato");
 | 
						|
  _etlarghezza = config.get_int("EtLarghezza");
 | 
						|
  _etcolonne = config.get_int("EtColonne");
 | 
						|
  _form_eti = new TConv_form(etformato);	
 | 
						|
  
 | 
						|
  TString16 caformato = config.get("CaFormato");
 | 
						|
  _form_car = new TConv_form(caformato);
 | 
						|
  _caxpag = config.get_int("CaPerPag");
 | 
						|
  _cabordoini = config.get_int("CaBordoIni"); 
 | 
						|
  _cabordofin = config.get_int("CaBordoFin"); 
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampaConvocazioni::user_destroy()
 | 
						|
{
 | 
						|
  delete _form_car;
 | 
						|
  delete _form_eti;
 | 
						|
  delete _msk;
 | 
						|
  delete _rel;
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int at4300(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TStampaConvocazioni a;
 | 
						|
  a.run(argc, argv, "Convocazioni per sezione");
 | 
						|
  return 0;
 | 
						|
}
 |