Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 766 git-svn-id: svn://10.65.10.50/trunk@14630 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			3789 lines
		
	
	
		
			109 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3789 lines
		
	
	
		
			109 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "cg3.h"
 | |
| #include "cg3200.h"
 | |
| #include "cglib02.h"
 | |
| #include "cglib03.h"
 | |
| 
 | |
| #include <modaut.h>
 | |
| #include <msksheet.h>
 | |
| #include <printapp.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include <clifo.h>
 | |
| #include <pconti.h>
 | |
| #include <mov.h>
 | |
| #include <rmov.h>
 | |
| #include <comuni.h>
 | |
| #include <saldi.h>
 | |
| #include <causali.h>
 | |
| #include <nditte.h>
 | |
| #include <unloc.h>
 | |
| 
 | |
| class TMastrini_record : public TRectype
 | |
| {
 | |
|   TBill _bill;
 | |
|   
 | |
| protected:
 | |
|   virtual const TString& get_str(const char* fieldname) const;
 | |
|   virtual int length(const char* fieldname) const;  
 | |
|   virtual TFieldtypes type(const char* fieldname) const;
 | |
|   
 | |
| public:
 | |
|   TMastrini_record() : TRectype(LF_SALDI) { }
 | |
|   virtual ~TMastrini_record() { }
 | |
| };
 | |
| 
 | |
| const char * num2str(const TString & s)
 | |
| {
 | |
| 	TString & str = get_tmp_string(20);
 | |
| 
 | |
| 	str = s;
 | |
| 	str.trim();
 | |
| 	if (str.len() > 2)
 | |
| 	{
 | |
| 		str = s.left(2);
 | |
| 		const int sub = atoi(s.mid(2));
 | |
| 		switch (sub)
 | |
| 		{
 | |
| 			case 0:
 | |
| 			case 1:
 | |
| 				break;
 | |
| 			case 2:
 | |
| 				str << " bis";
 | |
| 				break;
 | |
| 			case 3:
 | |
| 				str << " ter";
 | |
| 				break;
 | |
| 			case 4:
 | |
| 				str << " quater";
 | |
| 				break;
 | |
| 			case 5:
 | |
| 				str << " quinquies";
 | |
| 				break;
 | |
| 			case 6:
 | |
| 				str << " sexies";
 | |
| 				break;
 | |
| 			default:
 | |
| 				break;
 | |
| 		}
 | |
| 	}
 | |
| 	return (const char *) str;
 | |
| }
 | |
| 
 | |
| const TString& TMastrini_record::get_str(const char* fieldname) const
 | |
| {                                   
 | |
|   if (strcmp(fieldname, RMV_DESCR) == 0)
 | |
|   {          
 | |
|     const int g = atoi(TRectype::get_str(RMV_GRUPPO));
 | |
|     const int c = atoi(TRectype::get_str(RMV_CONTO));
 | |
|     const long s = atol(TRectype::get_str(RMV_SOTTOCONTO));
 | |
|     ((TBill&)_bill).set(g, c, s);
 | |
|     const TString& descr = _bill.descrizione();
 | |
|     return descr;
 | |
|   }
 | |
|   return TRectype::get_str(fieldname);
 | |
| }
 | |
| 
 | |
| int TMastrini_record::length(const char* fieldname) const
 | |
| {
 | |
|   if (strcmp(fieldname, RMV_DESCR) == 0)
 | |
|     return 50;
 | |
|   return TRectype::length(fieldname);
 | |
| }
 | |
| 
 | |
| TFieldtypes TMastrini_record::type(const char* fieldname) const
 | |
| {
 | |
|   if (strcmp(fieldname, RMV_DESCR) == 0)
 | |
|     return _alfafld;
 | |
|   return TRectype::type(fieldname);
 | |
| }
 | |
| 
 | |
| class TMastrini_application : public TPrintapp
 | |
| {
 | |
|   static bool data_inizio (TMask_field& f, KEY k);
 | |
|   static bool data_fine   (TMask_field& f, KEY k);
 | |
|   static bool gruppo_hnd  (TMask_field& f, KEY k);
 | |
|   static bool contoi_hnd  (TMask_field& f, KEY k);
 | |
|   static bool contof_hnd  (TMask_field& f, KEY k);
 | |
|   static bool sottoc_handler_ini  (TMask_field& f, KEY k); 
 | |
|   static bool sottoc_handler_fine (TMask_field& f, KEY k);
 | |
|   
 | |
|   static bool memorizza_handler(TMask_field& f, KEY k);
 | |
|   static bool scelte_notify(TSheet_field& s, int r, KEY k);
 | |
| 
 | |
|   TDociva_array      _b;
 | |
|   TRelation*         _rel;
 | |
|   TMask*             _msk;
 | |
|   TTable*            _tabivd, * _tabtpd, * _tabreg;
 | |
|   TSaldo*            _sld;
 | |
|   TParagraph_string* _d18,* _d22,* _d30;
 | |
|   TArray             _riga, _lista;
 | |
|   
 | |
|   TDate _data_ini,_data_fine,_data_finese,_data_finesesucc,_ultima_data_reg;
 | |
|   TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa,_inizioes;
 | |
|   int _cur1,_cur2,_gruppo,_conto,_numcarat,_stampanum,_annoiva;
 | |
|   int _numrig,_natdoc,_tipo,_selez_mastrini,_g_prec,_c_prec,_numrivd_int;
 | |
|   real _progredare,_progreavere,_totprogre_dare_al,_totprogre_avere_al;
 | |
|   real _totprogre_dare,_totprogre_avere,_importo;
 | |
|   real _riporto_dare,_riporto_avere,_riporto_parziale_dare,_riporto_parziale_avere;
 | |
|   real _totale_periodo_dare,_totale_periodo_avere,_totale_prima_dare,_totale_prima_avere;
 | |
|   real _saldo_periodo,_saldo_progre,_saldo_progre_al,_saldo_progre_prec;
 | |
|   real _saldo_movimenti,_saldo_progressivi,_totale_saldo,_riporto_footer_dare,_riporto_footer_avere;
 | |
|   TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc;
 | |
|   long _codice_ditta,_s_prec;
 | |
|   TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva,_g_contr,_c_contr,_s_contr,_descrcontr,_numivd;
 | |
|   char    _sezivd,_lettivd; 
 | |
|   TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr;
 | |
|   TString _dataregs, _datadocs;
 | |
|   int     _gruppocontr,_contocontr,_nummast,_pagina;
 | |
|   long    _sottocontocontr;
 | |
| 
 | |
|   bool _stampaprogre,_stampatotiva,_stampatot,_stampa_mov_prov, _stampa_cont;
 | |
|   bool _stampato,_devi_stampare_footer;
 | |
|   int _stampa_saldo_des;
 | |
|  
 | |
|   int  _annomsk,_annoesmsk,_annoes,_annomsksucc,_tipo_mask,_anno_ghost;
 | |
|   int  _anno_corrente,_anno_precedente,_indbil,_numero_pag;
 | |
|   long _sottoc,_numreg,_numgio,_protiva;
 | |
|   bool _stampa_progressivi_si,_competenza,/*_inizio_stampa,*/_puoi_stampare,_stampa_footer_si;
 | |
|   bool _cambia_mastrino,_gia_stampata_intestazione;
 | |
|   char _tmcf,_tipo_contr; 
 | |
|   
 | |
|   bool _flag_del_cazzo;
 | |
| 
 | |
|   TDate _dataregrmov;
 | |
|   int  _gruppof,_contof;
 | |
|   long _sottocf;
 | |
|   TString _dataregrmovstring,_importo_str,_saldo_movimenti_str;
 | |
| 
 | |
|   int  _rw, _conta_mastrini, _indice_array, _item, _item_lista, _indice_lista;
 | |
|   int  _ddociva_len;
 | |
| 
 | |
|   bool _noseparator;
 | |
|   TString _real_picture;
 | |
| 
 | |
| protected:
 | |
|   virtual bool user_create() ;
 | |
|   virtual bool user_destroy();
 | |
|   virtual bool set_print(int m);
 | |
|  
 | |
|   virtual bool preprocess_print(int file, int counter);
 | |
|   virtual bool preprocess_page (int,int);
 | |
|   virtual print_action postprocess_page (int,int);
 | |
|   virtual print_action postprocess_print(int,int);
 | |
|   virtual void preprocess_header();   
 | |
|   virtual void preprocess_footer();
 | |
|   virtual void set_page(int,int);
 | |
|   virtual bool process_link(int id, const char* txt);
 | |
|       
 | |
|   void set_handlers(TMask* msk) const;
 | |
|   bool mask2sheet();
 | |
|   bool sheet2mask();
 | |
| 
 | |
|   const char* real2str(const real& r) const;
 | |
|   
 | |
| public:
 | |
|   
 | |
|   int  date2esc(const TDate& d);   
 | |
|   void ricerca_clifo();
 | |
|   void ricerca_gruppo();
 | |
|   int  ricerca_clifo(int riga);
 | |
|   int  ricerca_gruppo(int riga);
 | |
| 
 | |
|   void calcola_progressivi(bool finali = FALSE);
 | |
|   void calcola_progressivi_al(const TDate& data); 
 | |
|   int  stampa_progressivi(int start_riga);
 | |
|   int  stampa_progre_riporto(int start_riga);
 | |
|   void documenti_iva();
 | |
|   void ricerca_regiva();
 | |
|   void descrizione_causale();
 | |
|   int  crea_intestazione(int riga);
 | |
|   void crea_intestazione();
 | |
|   void fai_stampa132();
 | |
|   void fai_stampa198();
 | |
|   void stampa_totali132();
 | |
|   void stampa_totali198();      
 | |
|   void stampa_totali132_II();
 | |
|   void stampa_totali198_II();  
 | |
|   void carica_array_totali132();
 | |
|   void carica_array_totali198();  
 | |
|   void stampa_totaliiva();  
 | |
|   void ricerca_classe_IV(bool scelta);
 | |
|   void data_fine_esercizio(int);
 | |
|   const char* descrizione_gruppo();
 | |
|   const char* descrizione_conto();    
 | |
|   const char* descrizione_sottoconto();
 | |
|   const char* descrizione_classe(char,char,int,const char *);
 | |
|   bool almeno_un_record();
 | |
|   void ricerca_dati_ditta();
 | |
|   void conto(int,int,bool);                       
 | |
|   bool check_ordine(TMask_field& f, KEY k);
 | |
|   
 | |
|   void setta_riga (int r, const TString& riga);              
 | |
|   int  righe_rimaste_da_stampare();
 | |
|   
 | |
|   TMastrini_application() {}
 | |
|   virtual ~TMastrini_application() {}
 | |
| };
 | |
| 
 | |
| inline TMastrini_application& app() { return (TMastrini_application&)main_app(); }
 | |
| 
 | |
| int TMastrini_application::righe_rimaste_da_stampare()
 | |
| {  
 | |
|   int righe_rimaste = 0;
 | |
|                   
 | |
|   if (_nummast == 2)
 | |
|   { 
 | |
|     if (printer().rows_left() != 0)
 | |
|     {
 | |
|       if ( (_conta_mastrini % 2) != 0)
 | |
|       { 
 | |
|         if ( (printer().formlen() % 2) != 0)
 | |
|           righe_rimaste = printer().rows_left() - (printer().formlen() / 2) + 1; //- 33;
 | |
|         else
 | |
|           righe_rimaste = printer().rows_left() - (printer().formlen() / 2); 
 | |
|       }
 | |
|       else
 | |
|         righe_rimaste = printer().rows_left();
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       if ( (_conta_mastrini % 2) != 0)
 | |
|         righe_rimaste = printer().formlen() / 2; //32;
 | |
|       else 
 | |
|       {
 | |
|         if ( (printer().formlen() % 2) != 0)
 | |
|           righe_rimaste = (printer().formlen() / 2) + 1; //33;
 | |
|         else
 | |
|           righe_rimaste = printer().formlen() / 2;
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|  
 | |
|   return righe_rimaste;
 | |
| } 
 | |
| 
 | |
| bool TMastrini_application::process_link(int id, const char* txt)
 | |
| {                                         
 | |
|   TRectype mov(LF_MOV);
 | |
|   mov.put(MOV_NUMREG, txt);
 | |
|   return mov.edit();
 | |
| } 
 | |
| 
 | |
| bool TMastrini_application::sottoc_handler_ini(TMask_field& f, KEY key)
 | |
| {
 | |
|   const TMask& m = f.mask();
 | |
|   const short id  = f.dlg();  
 | |
|                                   
 | |
|   const int gruppo = m.get_int(F_GRUPPOINI);
 | |
|   const int conto = m.get_int(F_CONTOINI_CONTO);
 | |
| 
 | |
|   const long sottoconto = m.get_long(id);
 | |
|   
 | |
|   if ( key == K_ENTER )
 | |
|   {
 | |
|     if (sottoconto != 0 && conto == 0) 
 | |
|       return f.warning_box(TR("Manca il CONTO"));
 | |
| 
 | |
|     if (conto != 0 && gruppo == 0)
 | |
|       return f.warning_box(TR("Manca il GRUPPO"));
 | |
|   }
 | |
| 
 | |
|   if (key == K_TAB && m.is_running())
 | |
|   {
 | |
|     if (id == F_SOTTOCINI_CONTO && (gruppo != 0 || conto != 0 || sottoconto != 0L))
 | |
|     {
 | |
|       TString16 key;
 | |
| 			
 | |
| 			key.format("%d|%d|%ld", gruppo, conto, sottoconto);
 | |
| 			const TRectype & pconti = cache().get(LF_PCON, key);
 | |
| 
 | |
|       if (pconti.empty())
 | |
|         return f.warning_box(TR("Sottoconto inesistente"));
 | |
| 			
 | |
| 			const TString & ds = pconti.get(PCN_DESCR);
 | |
|       
 | |
|       f.mask().set(F_DESCRINI_CONTO,   ds);
 | |
|       f.mask().set(F_DESCRINI_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRINI_FORN,    ds);              
 | |
|       
 | |
|     }
 | |
|     else
 | |
|       if (id == F_SOTTOCINI_CLIENTE || id == F_SOTTOCINI_FORN) 
 | |
|       {
 | |
|         char tipo = id == F_SOTTOCINI_CLIENTE ? 'C' : 'F';
 | |
|         if (sottoconto != 0)
 | |
|         {
 | |
| 		      TString16 key;
 | |
| 					key.format("%c|%ld", tipo, sottoconto);
 | |
| 					const TRectype & clifo = cache().get(LF_CLIFO, key);
 | |
| 					if (clifo.empty())
 | |
|             return f.warning_box(TR("Anagrafica inesistente"));
 | |
|           const TString & rs = clifo.get(CLI_RAGSOC);
 | |
|         
 | |
|           f.mask().set(F_DESCRINI_CLIENTE, rs);
 | |
|           f.mask().set(F_DESCRINI_FORN, rs);
 | |
|         
 | |
|         }
 | |
|       }
 | |
|   }
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::sottoc_handler_fine(TMask_field& f, KEY key)
 | |
| {
 | |
|   const TMask& m = f.mask();
 | |
|   const short id  = f.dlg();                    
 | |
|   TString    ds;
 | |
|   TString80  rs;                                      
 | |
|   
 | |
|   const int gruppo = m.get_int(F_GRUPPOFINE);
 | |
|   const int conto = m.get_int(F_CONTOFINE_CONTO);
 | |
| 
 | |
|   const long sottoconto = m.get_long(id);          
 | |
| 
 | |
|   if ( key == K_ENTER )
 | |
|   {
 | |
|     if (sottoconto != 0 && conto == 0) 
 | |
|       return f.warning_box(TR("Manca il CONTO"));
 | |
| 
 | |
|     if (conto != 0 && gruppo == 0)
 | |
|       return f.warning_box(TR("Manca il GRUPPO"));
 | |
|       
 | |
|     if (!app().check_ordine(f,key))
 | |
|       return FALSE;  
 | |
|   }    
 | |
| 
 | |
|   if ( key == K_TAB && m.is_running())
 | |
|   {
 | |
|     if (id == F_SOTTOCFINE_CONTO && (gruppo != 0 || conto != 0 || sottoconto != 0L))
 | |
|     {
 | |
|       TString16 key;
 | |
| 
 | |
| 			key.format("%d|%d|%ld", gruppo, conto, sottoconto);
 | |
| 			
 | |
| 			const TRectype & pconti = cache().get(LF_PCON, key);
 | |
| 
 | |
|       if (pconti.empty())
 | |
|         return f.warning_box(TR("Sottoconto inesistente"));
 | |
|       const TString & ds = pconti.get(PCN_DESCR);
 | |
|         
 | |
|       f.mask().set(F_DESCRFINE_CONTO,   ds);
 | |
|       f.mask().set(F_DESCRFINE_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRFINE_FORN,    ds);
 | |
|       
 | |
|     }
 | |
|     else
 | |
|       if (id == F_SOTTOCFINE_CLIENTE || id == F_SOTTOCFINE_FORN) 
 | |
|       {
 | |
|         char tipo = id == F_SOTTOCFINE_CLIENTE ? 'C' : 'F';
 | |
|         if (sottoconto != 0)
 | |
|         {
 | |
| 		      TString16 key;
 | |
| 
 | |
| 					key.format("%c|%ld", tipo, sottoconto);
 | |
| 					
 | |
| 					const TRectype & clifo = cache().get(LF_CLIFO, key);
 | |
| 					
 | |
| 					if (clifo.empty())
 | |
|             return f.warning_box(TR("Anagrafica inesistente"));
 | |
|           
 | |
| 					const TString & rs = clifo.get(CLI_RAGSOC);
 | |
|           
 | |
| 					f.mask().set(F_DESCRFINE_CLIENTE, rs);
 | |
|           f.mask().set(F_DESCRFINE_FORN,    rs);
 | |
|         
 | |
|         }
 | |
|       }
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::gruppo_hnd (TMask_field& f, KEY k)
 | |
| {  
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     const TMask& m = f.mask();
 | |
|     int gruppof = m.get_int(F_GRUPPOFINE);
 | |
|     
 | |
|     if (gruppof == 0)
 | |
|       return TRUE;
 | |
|       
 | |
|     int gruppoi = m.get_int(F_GRUPPOINI);
 | |
|     
 | |
|     if (gruppoi > gruppof)
 | |
|       return f.error_box(TR("Il gruppo di partenza deve essere inferiore o uguale al gruppo di arrivo"));
 | |
|   }   
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::contoi_hnd (TMask_field& f, KEY k)
 | |
| { 
 | |
|   if (k == K_TAB && f.focusdirty() && f.mask().is_running())
 | |
|   { 
 | |
|     TMask& m = f.mask();
 | |
|     const short id   = f.dlg();  
 | |
|     const int gruppo = m.get_int(F_GRUPPOINI);
 | |
|     const int conto  = m.get_int(id);
 | |
|     
 | |
|     if (gruppo != 0 && conto != 0)
 | |
|     {    
 | |
|       const char tipomsk = m.get(F_TIPOCF_INI)[0];
 | |
| 
 | |
|       TString16 key;
 | |
| 			key.format("%d|%d|", gruppo, conto);
 | |
| 
 | |
|       const TRectype & pconti = cache().get(LF_PCON, key);
 | |
|       
 | |
| 			if (!pconti.empty())
 | |
|       {                          
 | |
|         char tipo = pconti.get_char(PCN_TMCF);
 | |
|         if (tipomsk != tipo)
 | |
|           return f.warning_box(TR("Conto inesistente"));
 | |
| 			}
 | |
|           
 | |
|       const TString& ds = pconti.get(PCN_DESCR);
 | |
| 			m.set(F_DESCRINI_CLIENTE, ds);
 | |
|       m.set(F_DESCRINI_FORN, ds);
 | |
|       m.set(F_DESCRINI_CONTO, ds);            
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       m.reset(F_DESCRINI_CLIENTE);
 | |
|       m.reset(F_DESCRINI_FORN);
 | |
|       m.reset(F_DESCRINI_CONTO);  
 | |
|     }  
 | |
|   }  
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::contof_hnd (TMask_field& f, KEY k)
 | |
| {
 | |
|   const short id  = f.dlg();  
 | |
|   TMask& m = f.mask();
 | |
|    
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     int gruppof = m.get_int(F_GRUPPOFINE);
 | |
|     
 | |
|     if (gruppof == 0)
 | |
|       return TRUE;
 | |
|       
 | |
| //    char tipo = m.get(F_TIPOCF_INI)[0];
 | |
| 
 | |
|     int gruppoi = m.get_int(F_GRUPPOINI);
 | |
|     
 | |
|     if (gruppoi < gruppof)
 | |
|       return TRUE;
 | |
|       
 | |
|     int contof = m.get_int(id);
 | |
|     int contoi = m.get_int(F_CONTOINI_CONTO); 
 | |
|     
 | |
|     if (contoi > contof)
 | |
|       return f.error_box(TR("Il conto di partenza deve essere inferiore o uguale al conto di arrivo"));
 | |
|   }
 | |
| 
 | |
|   if (k == K_TAB && f.focusdirty() && m.is_running())
 | |
|   {  
 | |
|     TString ds;                       
 | |
|     int gruppo = m.get_int(F_GRUPPOFINE);
 | |
|     int conto  = m.get_int(id);
 | |
|     
 | |
|     if (gruppo != 0 && conto != 0 && m.field(F_DESCRFINE_CONTO).empty())
 | |
|     {    
 | |
|       char tipomsk = m.get(F_TIPOCF_FINE)[0];        
 | |
|       
 | |
|       TString16 key;
 | |
| 			key.format("%d|%d|", gruppo, conto);
 | |
| 
 | |
|       const TRectype & pconti = cache().get(LF_PCON, key);
 | |
| 
 | |
|       if (pconti.empty())
 | |
|         return f.warning_box(TR("Sottoconto inesistente"));
 | |
|       char tipo = pconti.get_char(PCN_TMCF);
 | |
|       if (tipomsk != tipo)
 | |
|         return f.warning_box(TR("Conto inesistente"));
 | |
| 
 | |
|           
 | |
|       const TString & ds = pconti.get(PCN_DESCR);
 | |
|             
 | |
|       m.set(F_DESCRFINE_CLIENTE, ds);
 | |
|       m.set(F_DESCRFINE_FORN, ds);
 | |
|       m.set(F_DESCRFINE_CONTO, ds);  
 | |
|           
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       f.mask().reset(F_DESCRFINE_CLIENTE);
 | |
|       f.mask().reset(F_DESCRFINE_FORN);
 | |
|       f.mask().reset(F_DESCRFINE_CONTO);  
 | |
|     }  
 | |
|   }  
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::check_ordine(TMask_field& f, KEY k)
 | |
| {
 | |
|   const TMask& m = f.mask();
 | |
|   const int gruppof = m.get_int(F_GRUPPOFINE);
 | |
|     
 | |
|   if (gruppof == 0)
 | |
|     return TRUE;
 | |
|       
 | |
|   const int gruppoi = m.get_int(F_GRUPPOINI);
 | |
|     
 | |
|   if (gruppoi < gruppof)
 | |
|     return TRUE;
 | |
|     
 | |
|   int contof = m.get_int(F_CONTOFINE_CONTO);
 | |
|   int contoi = m.get_int(F_CONTOINI_CONTO);
 | |
|     
 | |
|   if (contoi < contof)
 | |
|     return TRUE;
 | |
|     
 | |
|   long sottocf = m.get_long(F_SOTTOCFINE_CONTO);
 | |
|   long sottoci = m.get_long(F_SOTTOCINI_CONTO);
 | |
|         
 | |
|   if (sottoci > sottocf)
 | |
|     return f.error_box(TR("Il sottoconto di partenza deve essere inferiore o uguale al sottoconto di arrivo"));
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
|                                        
 | |
| bool TMastrini_application::memorizza_handler(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_SPACE)
 | |
|   {
 | |
|     if (app().mask2sheet())
 | |
|     {
 | |
|       TMask& m = f.mask();
 | |
|       m.reset(-9);
 | |
|       m.set_focus_field(F_TIPOCF_INI);
 | |
|     }
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::scelte_notify(TSheet_field& s, int r, KEY k)
 | |
| {
 | |
|   bool ok = TRUE;
 | |
|   if (k == K_INS)
 | |
|     ok = FALSE;
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| int TMastrini_application::date2esc(const TDate& d)
 | |
| {                   
 | |
|   TEsercizi_contabili esc;
 | |
|   return esc.date2esc(d);
 | |
| }
 | |
| 
 | |
| //Questa funzione restituisce vero se il record su piano dei conti ha almeno un
 | |
| //record figlio (e che soddisfa la condizione riguardante la data di registr.).
 | |
| //Viene successivamente utilizzata per stampare l'intestazione (e i totali)
 | |
| //oppure no
 | |
| 
 | |
| bool TMastrini_application::almeno_un_record()
 | |
| {
 | |
|   bool  trovato=FALSE;
 | |
|  
 | |
|   if (current_cursor()->is_first_match(LF_RMOV))
 | |
|   {
 | |
|     TLocalisamfile& rmov_file = current_cursor()->file(LF_RMOV);
 | |
|     const TRecnotype record = rmov_file.recno();
 | |
|   
 | |
|     TRelation rel(LF_RMOV);
 | |
|     rel.add(LF_MOV, "NUMREG==NUMREG");
 | |
|     TRectype& rmov = rel.curr();
 | |
|     
 | |
|     rmov.zero();
 | |
|     rmov.put(RMV_GRUPPO,     _gruppo);
 | |
|     rmov.put(RMV_CONTO,      _conto);
 | |
|     rmov.put(RMV_SOTTOCONTO, _sottoc);
 | |
|     TCursor cur(&rel, "", 2, &rmov, &rmov);
 | |
|     const long items = cur.items();
 | |
|     cur.freeze();
 | |
|     for (cur = 0L; cur.pos() < items; ++cur)
 | |
|     {       
 | |
|       const int  annoes = rmov.get_int (RMV_ANNOES);
 | |
|       const long numreg = rmov.get_long(RMV_NUMREG);
 | |
| 
 | |
|       const TRectype & mov = cache().get(LF_MOV, numreg);
 | |
| 
 | |
|       const TDate datacomp = (mov.get_date(MOV_DATACOMP));
 | |
|       const TString16 provvis (mov.get(MOV_PROVVIS));
 | |
| 
 | |
|         
 | |
|       TDate datareg;
 | |
|       if (_annomsk == 0)
 | |
|         datareg = rmov.get_date(RMV_DATAREG);
 | |
|       else
 | |
|         datareg = datacomp;
 | |
| 
 | |
|       if ( ((annoes==_annomsk) || (_annomsk==0)) && ((datareg>=_data_ini) && (datareg<=_data_fine)) && (_stampa_mov_prov || provvis.blank()))
 | |
|       {
 | |
|         trovato = TRUE;
 | |
|         break;
 | |
|       }
 | |
|     }
 | |
|     rmov_file.readat(record);
 | |
|   }
 | |
|   return trovato;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::data_inizio(TMask_field& f, KEY k)
 | |
| {
 | |
|   const TDate data = f.mask().get_date(F_DATAINI);
 | |
|   const int anno = f.mask().get_int(F_ANNO);
 | |
|   app()._annomsk = anno;
 | |
|   
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     if (anno != 0)
 | |
|     {
 | |
|       app().data_fine_esercizio(anno);
 | |
| 
 | |
|       if (data.ok())
 | |
|       {
 | |
|         if (data < app()._data_inizioese || data > app()._data_finese)
 | |
|         {
 | |
|           f.error_box(TR("La data non appartiene all'esercizio indicato"));
 | |
|               return FALSE;
 | |
|         }
 | |
|         else
 | |
|           app()._data_ini = data;
 | |
|       }    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       if (!data.ok())
 | |
|         return f.error_box(TR("La data deve essere obbligatoriamente indicata"));
 | |
| 
 | |
|       if (app().date2esc(data) == 0)
 | |
|         return f.error_box(TR("La data indicata non appartiene ad alcun esercizio"));
 | |
|       else
 | |
|         app()._data_ini = data;
 | |
|     }  
 | |
|   }  
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::data_fine(TMask_field& f, KEY k)
 | |
| {
 | |
|   const TMask& m = f.mask();
 | |
|   int annoes     = m.get_int(F_ANNO);
 | |
|   TDate data     = m.get_date(F_DATAFINE);
 | |
|   TDate data_ini = m.get_date(F_DATAINI);
 | |
|   app()._annomsk = annoes;
 | |
|   
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     if (annoes != 0)
 | |
|     {                  
 | |
|       app().data_fine_esercizio(annoes);
 | |
|       
 | |
|       if (data.ok())
 | |
|       {
 | |
|         if (data < app()._data_inizioese || data > app()._data_finese)
 | |
|         {
 | |
|           f.error_box(TR("La data non appartiene all'esercizio indicato"));
 | |
|           return FALSE;
 | |
|         }
 | |
|         else
 | |
|           app()._data_fine = data;
 | |
|       }
 | |
|     }
 | |
|     else
 | |
|       {
 | |
|         if (data == botime)
 | |
|           return f.error_box(TR("La data deve essere obbligatoriamente indicata"));
 | |
| 
 | |
|         app()._anno_ghost = app().date2esc(data_ini); 
 | |
|         
 | |
|         if (app()._anno_ghost == 0)
 | |
|           return f.error_box(TR("La data indicata non appartiene ad alcun esercizio"));
 | |
|         app()._data_fine = data;
 | |
|       }
 | |
| 
 | |
|     if (data < data_ini)
 | |
|     {
 | |
|       f.error_box(TR("La data finale non puo' essere inferiore alla data di partenza"));
 | |
|       return FALSE;
 | |
|     }
 | |
|   } 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::fai_stampa132()
 | |
| { 
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 1;
 | |
|   else
 | |
|     if (_nummast == 2)
 | |
|     {  
 | |
|       int riga;
 | |
|               
 | |
|       if ( (_conta_mastrini % 2) != 0 )
 | |
|         riga = (printer().formlen() / 2);    //-1
 | |
|       else
 | |
|         riga = printer().formlen();          //-1;
 | |
|         
 | |
|       int app1    = printer().formlen();
 | |
|       int app2    = printer().rows_left();
 | |
|       int cur_row = (app1 - app2);
 | |
|           
 | |
|       if (cur_row == riga) 
 | |
|       {
 | |
|         //_rw += 2;
 | |
|         _rw = crea_intestazione(_rw);
 | |
|         _rw = stampa_progre_riporto(_rw);
 | |
|         
 | |
|         if (_item != 0)  
 | |
|         {
 | |
|           for (int i = _indice_array; i < _item; i++)
 | |
|           {
 | |
|             TString& data = (TString&)_riga[i];
 | |
|     
 | |
|             int g1 = data.find("g",1);
 | |
|             int c1 = data.find("@",g1);
 | |
|             int g2 = data.find("g",c1);
 | |
|               
 | |
|             TString fmt1 = "";
 | |
|             TString fmt2 = "";
 | |
|             TString str1,str2;
 | |
|               
 | |
|             if (g1 != -1)
 | |
|             {
 | |
|               fmt1 = data.sub(0,g1+1);
 | |
|               fmt1 << "%s";
 | |
|               str1 = data.sub(g1+1,c1);
 | |
|             }  
 | |
|             if (c1 != -1)
 | |
|             {
 | |
|               fmt2 = data.sub(c1,g2+1);
 | |
|               fmt2 << "%s";
 | |
|               str2 = data.sub(g2+1);
 | |
|             }
 | |
|               
 | |
|             if (fmt1 != "")
 | |
|               set_row (_rw,fmt1,(const char*) str1);
 | |
|             if (fmt2 != "")
 | |
|               set_row (_rw,fmt2,(const char*) str2);
 | |
|               
 | |
|             _rw++;
 | |
|           }  
 | |
|         }  
 | |
|       }
 | |
|       else
 | |
|         _rw = 1;
 | |
|       
 | |
|       if (_item != 0)  
 | |
|         _riga.destroy();
 | |
|     }
 | |
|     
 | |
|   set_row (_rw,"@0g#t",  &_dataregs);
 | |
|   if (_stampanum == 1)
 | |
|     set_row (_rw,"@11g$[b]#7ld$[n]", &_numreg);
 | |
|   else
 | |
|     if (_stampanum == 2)
 | |
|       set_row (_rw,"@11g#7ld", &_numgio);
 | |
|     
 | |
|   set_row (_rw,"@19g#t", &_datadocs);
 | |
|   set_row (_rw,"@30g#7t", &_numdoc);
 | |
|   set_row (_rw,"@38g#3t", &_codcaus);
 | |
| 
 | |
|   if (_stampa_cont == 1)
 | |
| 		set_row (_rw,"@117g#t #t #t", &_g_contr, &_c_contr, &_s_contr);
 | |
| }
 | |
| 
 | |
| void TMastrini_application::fai_stampa198()
 | |
| {            
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 1;
 | |
|   else
 | |
|     if (_nummast == 2)
 | |
|     {            
 | |
|       int riga;
 | |
|               
 | |
|       if ( (_conta_mastrini % 2) != 0 )
 | |
|         riga = (printer().formlen() / 2);    //-1
 | |
|       else
 | |
|         riga = printer().formlen();          //-1;
 | |
| 
 | |
|       int app1    = printer().formlen();
 | |
|       int app2    = printer().rows_left();
 | |
|       int cur_row = (app1 - app2);
 | |
|           
 | |
|       if (cur_row == riga) 
 | |
|       {
 | |
|         //_rw += 2;
 | |
|         _rw = crea_intestazione(_rw);
 | |
|         _rw = stampa_progre_riporto(_rw);
 | |
|         
 | |
|         if (_item != 0)
 | |
|         {
 | |
|           for (int i = _indice_array; i < _item; i++)
 | |
|           {
 | |
|             TString& data = (TString&)_riga[i];
 | |
|     
 | |
|             int g1 = data.find("g",1);
 | |
|             int c1 = data.find("@",g1);
 | |
|             int g2 = data.find("g",c1);
 | |
|               
 | |
|             TString fmt1 = "";
 | |
|             TString fmt2 = "";
 | |
|             TString str1,str2;
 | |
|               
 | |
|             if (g1 != -1)
 | |
|             {
 | |
|               fmt1 = data.sub(0,g1+1);
 | |
|               fmt1 << "%s";
 | |
|               str1 = data.sub(g1+1,c1);
 | |
|             }  
 | |
|             if (c1 != -1)
 | |
|             {
 | |
|               fmt2 = data.sub(c1,g2+1);
 | |
|               fmt2 << "%s";
 | |
|               str2 = data.sub(g2+1);
 | |
|             }
 | |
|               
 | |
|             if (fmt1 != "")
 | |
|               set_row (_rw,fmt1,(const char*) str1);
 | |
|             if (fmt2 != "")
 | |
|               set_row (_rw,fmt2,(const char*) str2);
 | |
|               
 | |
|             _rw++;
 | |
|           }
 | |
|         }
 | |
|       }
 | |
|       else
 | |
|         _rw = 1;
 | |
|          
 | |
|       if (_item != 0)   
 | |
|         _riga.destroy();  
 | |
|     }
 | |
| 
 | |
|   set_row (_rw,"@0g#t", &_dataregs);
 | |
|   if (_stampanum == 1)            
 | |
|   {
 | |
|     set_row (_rw,"@11g$[b]#7ld$[n]", &_numreg);
 | |
|     set_row (_rw,"@18g/#3d", &_numrig);
 | |
|   }
 | |
|   else if (_stampanum == 2)
 | |
|      set_row (_rw,"@11g#7ld", &_numgio);
 | |
|      
 | |
|   set_row (_rw,"@23g#t", &_datadocs);
 | |
|   set_row (_rw,"@34g#7t", &_numdoc);
 | |
|   set_row (_rw,"@42g#3t", &_codcaus);
 | |
| 
 | |
| // Stampa saldo movimenti / Descrizione contropartita
 | |
|   const TRectype& rmov = current_cursor()->curr(LF_RMOV);
 | |
|   _gruppocontr = rmov.get_int(RMV_GRUPPOC);     
 | |
|   _contocontr = rmov.get_int(RMV_CONTOC);
 | |
|   _sottocontocontr = rmov.get_long(RMV_SOTTOCONTOC);  
 | |
|   _g_contr = rmov.get(RMV_GRUPPOC);
 | |
|   _c_contr = rmov.get(RMV_CONTOC);
 | |
|   _s_contr = rmov.get(RMV_SOTTOCONTOC);
 | |
|   
 | |
|   if (_stampa_saldo_des == 3)
 | |
|   {      
 | |
|     if (_sottocontocontr > 0)
 | |
|     { 
 | |
|       conto(_gruppocontr,_contocontr,FALSE);
 | |
|       TBill tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|       _descrcontr.cut(0);
 | |
|       _descrcontr << _g_contr << ' ' << _c_contr << ' ' << _s_contr << ' ' << tc.descrizione();
 | |
|       _descrcontr.cut(47);
 | |
|       set_row (_rw,"@135g%-48s", (const char*)_descrcontr);
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _descrcontr.cut(0);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     set_row (_rw,"@151g#t", &_saldo_movimenti_str);
 | |
|     set_row (_rw,"@168g#t #t #t", &_g_contr, &_c_contr, &_s_contr);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_totali132()
 | |
| {
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 2;
 | |
|       
 | |
|   const TString sep(132, '_');                   //Stampa 132 - (sep(132))      
 | |
|   set_row(_rw++,"@0g%s", (const char*)sep);
 | |
| 
 | |
|   _totprogre_dare=_progredare+_totale_periodo_dare;
 | |
|   _totprogre_avere=_progreavere+_totale_periodo_avere;
 | |
|   _saldo_periodo = _totale_periodo_dare - _totale_periodo_avere;
 | |
|   _saldo_progre = _totprogre_dare - _totprogre_avere;
 | |
|   _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | |
|   set_row (_rw,"@32g%s", TR("TOTALI PERIODO"));
 | |
|   set_row (_rw,"@66g%r", &_saldo_periodo);
 | |
|   set_row (_rw,"@83g%r", &_totale_periodo_dare);   
 | |
|   set_row (_rw++,"@100g%r", &_totale_periodo_avere);
 | |
|   
 | |
|   set_row (_rw,"@32g%s", TR("TOTALI PROGRESSIVI"));
 | |
|   set_row (_rw,"@66g%r", &_saldo_progre);
 | |
|   set_row (_rw,"@83g%r", &_totprogre_dare);
 | |
|   set_row (_rw++,"@100g%r", &_totprogre_avere);
 | |
|   
 | |
|   if (_stampaprogre)                         //Progressivi attuali
 | |
|   {                                            
 | |
|     set_row (_rw,"@32g%s %s", TR("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string());
 | |
|     set_row (_rw,"@66g%r", &_saldo_progre_al);
 | |
|     set_row (_rw,"@83g%r", &_totprogre_dare_al);
 | |
|     set_row (_rw,"@100g%r", &_totprogre_avere_al);
 | |
|   }                        
 | |
| 
 | |
|   _devi_stampare_footer = FALSE;
 | |
| }
 | |
| 
 | |
| const char* TMastrini_application::real2str(const real& r) const
 | |
| {
 | |
| 	TString & str = get_tmp_string(30);
 | |
|   real2currency(str, r);
 | |
|   return str;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::carica_array_totali132()
 | |
| {
 | |
|   TString sep(132);
 | |
|   TToken_string r(255); 
 | |
|   
 | |
|   if (_nummast == 2)
 | |
|     _rw = 1;
 | |
| 
 | |
|   _totprogre_dare=_progredare+_totale_periodo_dare;
 | |
|   _totprogre_avere=_progreavere+_totale_periodo_avere;
 | |
|   _saldo_periodo = _totale_periodo_dare - _totale_periodo_avere;
 | |
|   _saldo_progre = _totprogre_dare - _totprogre_avere;
 | |
|   _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | |
| 
 | |
|   sep.fill(' ');
 | |
|   r.add("@0g%s");
 | |
|   r.add(sep);  
 | |
|   _lista.add(r);  
 | |
|   r = "";
 | |
|   
 | |
|   sep.fill('_');                            //Stampa 132 - (sep(132))      
 | |
|   r.add("@0g%s");
 | |
|   r.add(sep);
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
| 
 | |
|   r.add("@32g%s@66g%s@83g%s@100g%s");
 | |
|   r.add(TR("TOTALI PERIODO"));
 | |
|   r.add(real2str(_saldo_periodo));     
 | |
|   r.add(real2str(_totale_periodo_dare));
 | |
|   r.add(real2str(_totale_periodo_avere));
 | |
|   _lista.add(r);  
 | |
|   r = "";
 | |
| 
 | |
|   r.add("@32g%s@66g%s@83g%s@100g%s");
 | |
|   r.add(TR("TOTALI PROGRESSIVI"));
 | |
|   r.add(real2str(_saldo_progre));       
 | |
|   r.add(real2str(_totprogre_dare));
 | |
|   r.add(real2str(_totprogre_avere));
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
|   
 | |
|   if (_stampaprogre)                         //Progressivi attuali
 | |
|   {
 | |
|     r.add("@32g%s@55g%s@66g%s@83g%s@100g%s");
 | |
|     r.add(TR("TOTALI PROGRESSIVI AL"));
 | |
|     r.add(_ultima_data_reg.string());
 | |
|     r.add(real2str(_saldo_progre_al));
 | |
|     r.add(real2str(_totprogre_dare_al));
 | |
|     r.add(real2str(_totprogre_avere_al));
 | |
|     _lista.add(r);
 | |
|     r = "";
 | |
|   } 
 | |
|   
 | |
|   if (_stampatotiva)
 | |
|   {         
 | |
|     real totale;
 | |
|     
 | |
|     sep.fill(' ');
 | |
|     r.add("@0g%s");
 | |
|     r.add(sep);  
 | |
|     _lista.add(r);  
 | |
|     r = "";
 | |
| 
 | |
|     TString fmt ("@0g%s");
 | |
|     TString fmt1(format("@%dg", _ddociva_len));
 | |
|     fmt << fmt1 << "%15s";
 | |
| 
 | |
|     for (int j = 0; j < _b.items(); j++)
 | |
|     {
 | |
|       TDociva& riga = (TDociva&)_b[j];
 | |
|       r.add(fmt);
 | |
|       r.add(riga._descrdoc);   
 | |
|       totale = riga._totdociva;
 | |
|       r.add(real2str(totale));
 | |
|       _lista.add(r);
 | |
|       r = "";
 | |
|     }
 | |
| 
 | |
|     _b.destroy();
 | |
|   }
 | |
|   
 | |
|   _indice_lista = 0;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_totali132_II()
 | |
| {                              
 | |
|   int riga,cur_row,diff;
 | |
|   int lim = 0;
 | |
|   
 | |
|   _item_lista = _lista.items();
 | |
|   
 | |
|   if ( (_conta_mastrini % 2) != 0 )
 | |
|   {
 | |
|     riga    = (printer().formlen() / 2);    //- 1;
 | |
|     cur_row = printer().formlen() - printer().rows_left();
 | |
|     diff    = riga - cur_row;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     riga    = printer().formlen();          //- 1;
 | |
|     cur_row = printer().formlen() - printer().rows_left();
 | |
|     diff    = riga - cur_row;
 | |
|   }
 | |
| 
 | |
|   if (_indice_lista == 0 && diff != 0)
 | |
|   {
 | |
|     if (_item_lista > diff)
 | |
|       lim = diff;
 | |
|     else
 | |
|       lim = _item_lista;
 | |
|   }
 | |
|   else  
 | |
|   {
 | |
|     lim = _item_lista;
 | |
|     _rw = 1;
 | |
|     _rw = crea_intestazione(_rw);
 | |
|     _rw = stampa_progre_riporto(_rw);          
 | |
|     if ( (_conta_mastrini % 2) != 0 )
 | |
|     {
 | |
|       riga    = (printer().formlen() / 2);    //- 1;
 | |
|       cur_row = _rw;
 | |
|       diff    = riga - cur_row;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       riga    = printer().formlen();          //- 1;
 | |
|       cur_row = _rw + (printer().formlen() / 2); //32;
 | |
|       diff    = riga - cur_row;
 | |
|     }
 | |
|   }
 | |
|             
 | |
|   for (int i = _indice_lista; i < lim; i++)
 | |
|   {
 | |
|     TToken_string& data = (TToken_string&)_lista[i];
 | |
|   
 | |
|     TString fmt  (data.get(0));
 | |
|     TString arg1 (data.get(1));
 | |
|     TString arg2 (data.get(2));
 | |
|     TString arg3 (data.get(3));
 | |
|     TString arg4 (data.get(4));
 | |
|     
 | |
|     set_row(_rw++,fmt, (const char*) arg1, (const char*) arg2, (const char*) arg3, (const char*) arg4);         
 | |
|     
 | |
|     _indice_lista++;
 | |
|   }                  
 | |
|   
 | |
|   if (_item_lista <= diff)
 | |
|     _lista.destroy();
 | |
|     
 | |
|   _devi_stampare_footer = FALSE;  
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_totali198()
 | |
| {
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 1;
 | |
| 
 | |
|   const TString sep(198, '-'); //Stampa 198 - (sep(198))      
 | |
| 
 | |
|   set_row(_rw,"@0g%s", (const char*)sep);
 | |
| 
 | |
|   _totprogre_dare=_progredare+_totale_periodo_dare;
 | |
|   _totprogre_avere=_progreavere+_totale_periodo_avere;
 | |
| 
 | |
|   set_row (++_rw,"@32g%s@100g%r", TR("TOTALI PERIODO"), &_totale_periodo_dare);
 | |
|   set_row (_rw,"@117g%r", &_totale_periodo_avere);
 | |
|   
 | |
|   set_row (++_rw,"@32g%s@100g%r", TR("TOTALI PROGRESSIVI"), &_totprogre_dare);
 | |
|   set_row (_rw,"@117g%r", &_totprogre_avere);
 | |
|   
 | |
|   // il saldo totale movimenti non viene stampato se stampo le descrizioni delle contropartite
 | |
|   if (_stampa_saldo_des < 3)
 | |
|   {
 | |
|     set_row (_rw,"@135g%r", &_saldo_progressivi);
 | |
|     set_row (_rw,"@151g%r", &_saldo_movimenti);
 | |
|   }
 | |
|   
 | |
|   if (_stampaprogre)                          //Progressivi attuali
 | |
|   {
 | |
|     _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | |
|     set_row(++_rw,"@32g%s@55g%s", TR("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string());
 | |
|     set_row (_rw,"@100g%r", &_totprogre_dare_al);
 | |
|     set_row (_rw,"@117g%r", &_totprogre_avere_al); 
 | |
|     if (_stampa_saldo_des < 3)
 | |
|       set_row (_rw,"@135g%r", &_saldo_progre_al);
 | |
|   }                             
 | |
| 
 | |
|   _devi_stampare_footer = FALSE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::carica_array_totali198()
 | |
| {
 | |
|   TString sep(198);
 | |
|   TToken_string r(255); 
 | |
|   
 | |
|   if (_nummast == 2)
 | |
|     _rw = 1;
 | |
|             
 | |
|   sep.fill(' ');                            //Stampa 132 - (sep(132))      
 | |
|   r.add("@0g%s");
 | |
|   r.add(sep);
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
| 
 | |
|   sep.fill('_');                            //Stampa 132 - (sep(132))      
 | |
|   r.add("@0g%s");
 | |
|   r.add(sep);
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
| 
 | |
|   _totprogre_dare=_progredare+_totale_periodo_dare;
 | |
|   _totprogre_avere=_progreavere+_totale_periodo_avere;
 | |
| 
 | |
|   if (_stampa_saldo_des == 3)
 | |
|     r.add("@32g%s@100g%s@117g%s");
 | |
|   else
 | |
|     r.add("@32g%s@100g%s@117g%s@151g%s");
 | |
|   r.add(TR("TOTALI PERIODO"));
 | |
|   r.add(real2str(_totale_periodo_dare));
 | |
|   r.add(real2str(_totale_periodo_avere));
 | |
|   r.add(real2str(_saldo_movimenti));
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
| 
 | |
|   if (_stampa_saldo_des == 3)
 | |
|     r.add("@32g%s@100g%s@117g%s");
 | |
|   else    
 | |
|     r.add("@32g%s@100g%s@117g%s@135g%s");
 | |
|   r.add(TR("TOTALI PROGRESSIVI"));
 | |
|   r.add(real2str(_totprogre_dare));
 | |
|   r.add(real2str(_totprogre_avere));
 | |
|   r.add(real2str(_saldo_progressivi));     
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
|   
 | |
|   if (_stampaprogre)                          //Progressivi attuali
 | |
|   {
 | |
|     _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | |
|     r.add("@32g%s@55g%s@100g%s@117g%s@135g%s");
 | |
|     r.add(TR("TOTALI PROGRESSIVI AL"));
 | |
|     r.add(_ultima_data_reg.string());
 | |
|     r.add(real2str(_totprogre_dare_al));
 | |
|     r.add(real2str(_totprogre_avere_al));
 | |
|     r.add(real2str(_saldo_progre_al));    
 | |
|     _lista.add(r);
 | |
|     r = "";
 | |
|   }                 
 | |
| 
 | |
|   if (_stampatotiva)
 | |
|   { 
 | |
|     real totale;
 | |
|     
 | |
|     sep.fill(' ');
 | |
|     r.add("@0g%s");
 | |
|     r.add(sep);  
 | |
|     _lista.add(r);  
 | |
|     r = "";
 | |
| 
 | |
|     TString16 fmt;
 | |
|     fmt << "@0g%s@" << _ddociva_len << "g%15s";
 | |
|     
 | |
|     for (int j = 0; j < _b.items(); j++)
 | |
|     {
 | |
|       TDociva& riga = (TDociva&)_b[j];
 | |
|       r.add(fmt);
 | |
|       r.add(riga._descrdoc);   
 | |
|       totale = riga._totdociva;
 | |
|       r.add(real2str(totale));
 | |
|       _lista.add(r);
 | |
|       r = "";
 | |
|     }
 | |
| 
 | |
|     _b.destroy();
 | |
|   }
 | |
|   
 | |
|   _indice_lista = 0;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_totali198_II()
 | |
| {
 | |
|   int riga,cur_row,diff;
 | |
|   int lim = 0;
 | |
|   
 | |
|   _item_lista = _lista.items();
 | |
|   
 | |
|   if ( (_conta_mastrini % 2) != 0 )
 | |
|   {
 | |
|     riga    = (printer().formlen() / 2);    //- 1;
 | |
|     cur_row = printer().formlen() - printer().rows_left();
 | |
|     diff    = riga - cur_row;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     riga    = printer().formlen();          //- 1;
 | |
|     cur_row = printer().formlen() - printer().rows_left();
 | |
|     diff    = riga - cur_row;
 | |
|   }
 | |
| 
 | |
|   if (_indice_lista == 0 && diff != 0)
 | |
|   {
 | |
|     if (_item_lista > diff)
 | |
|       lim = diff;
 | |
|     else
 | |
|       lim = _item_lista;
 | |
|   }
 | |
|   else  
 | |
|   {
 | |
|     lim = _item_lista;
 | |
|     _rw = 1;
 | |
|     _rw = crea_intestazione(_rw);
 | |
|     _rw = stampa_progre_riporto(_rw);          
 | |
|     if ( (_conta_mastrini % 2) != 0 )
 | |
|     {
 | |
|       riga    = (printer().formlen() / 2);    //- 1;
 | |
|       cur_row = _rw;
 | |
|       diff    = riga - cur_row;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       riga    = printer().formlen();          //- 1;
 | |
|       cur_row = _rw + (printer().formlen() / 2);  //32;
 | |
|       diff    = riga - cur_row;
 | |
|     }
 | |
|   }
 | |
|             
 | |
|   for (int i = _indice_lista; i < lim; i++)
 | |
|   {
 | |
|     TToken_string& data = (TToken_string&)_lista[i];
 | |
|   
 | |
|     TString fmt  (data.get(0));
 | |
|     TString arg1 (data.get(1));
 | |
|     TString arg2 (data.get(2));
 | |
|     TString arg3 (data.get(3));
 | |
|     TString arg4 (data.get(4));
 | |
|     TString arg5 (data.get(5));
 | |
|     
 | |
|     set_row(_rw++,fmt, (const char*)arg1, (const char*)arg2, (const char*)arg3, 
 | |
|                        (const char*)arg4, (const char*)arg5);         
 | |
|     
 | |
|     _indice_lista++;
 | |
|   }                  
 | |
|   
 | |
|   if (_item_lista <= diff)
 | |
|     _lista.destroy();           
 | |
| 
 | |
|   _devi_stampare_footer = FALSE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::setta_riga (int r, const TString& riga)
 | |
| {                         
 | |
|   TString* p = (TString*)_riga.objptr(r);
 | |
|   if (p == NULL)
 | |
|     _riga.add(riga);
 | |
|   else  
 | |
|     *p << riga;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::preprocess_page(int file, int counter)
 | |
| { 
 | |
|   if (counter)
 | |
|     return TRUE;
 | |
|   
 | |
|   switch (file)
 | |
|   {
 | |
|   case LF_SALDI:
 | |
|     {
 | |
| // Usati in crea_intestazione()
 | |
|       
 | |
|       _devi_stampare_footer = TRUE;
 | |
|        
 | |
|       if (_nummast == 3 || _nummast == 2)
 | |
|       {
 | |
|         _rw = 0;
 | |
|         _rw++;
 | |
|       }
 | |
|       
 | |
|       const TRectype& saldi = current_cursor()->curr(LF_SALDI);
 | |
|       _gruppo = saldi.get_int(SLD_GRUPPO);
 | |
|       _conto  = saldi.get_int(SLD_CONTO);
 | |
|       _sottoc = saldi.get_long(SLD_SOTTOCONTO); 
 | |
|       
 | |
|       _cambia_mastrino = TRUE;
 | |
|       
 | |
|       const int annoes  = saldi.get_int(SLD_ANNOES);  
 | |
|       conto(_gruppo,_conto,TRUE);
 | |
| 
 | |
|       if (annoes != _anno_corrente && annoes != _anno_precedente)
 | |
|         return FALSE;
 | |
| 
 | |
|       if (_g_prec == _gruppo && _c_prec == _conto && _s_prec == _sottoc)
 | |
|         return FALSE;
 | |
| 
 | |
|       _g_prec = _gruppo;
 | |
|       _c_prec = _conto;
 | |
|       _s_prec = _sottoc;
 | |
| 
 | |
|       _saldo_periodo = ZERO;
 | |
|       _totale_periodo_dare = ZERO;
 | |
|       _totale_periodo_avere = ZERO;
 | |
|       _saldo_progre = ZERO;
 | |
|       _totprogre_dare = ZERO;
 | |
|       _totprogre_avere = ZERO;
 | |
|       _saldo_progre_al = ZERO;
 | |
|       _totprogre_dare_al = ZERO;
 | |
|       _totprogre_avere_al = ZERO;
 | |
|       _progredare = ZERO;
 | |
|       _progreavere = ZERO;
 | |
|       _totale_prima_dare = ZERO;
 | |
|       _totale_prima_avere = ZERO;
 | |
|       _saldo_movimenti = ZERO;
 | |
|       _saldo_progressivi = ZERO;
 | |
|       _saldo_progre_prec = ZERO;
 | |
|       if (_selez_mastrini == 2)
 | |
|       {
 | |
|         calcola_progressivi(TRUE);
 | |
|         _totale_saldo = _saldo_progre_prec;
 | |
|       }
 | |
|                       
 | |
|       if ((_selez_mastrini == 1) || (_selez_mastrini == 2))
 | |
|       {  
 | |
|         if ((_selez_mastrini == 1 && almeno_un_record()) ||
 | |
|             (_selez_mastrini == 2 && _totale_saldo != ZERO))
 | |
|         {                                
 | |
|           _puoi_stampare = TRUE;  
 | |
|           
 | |
|           if (_nummast == 3 || _nummast == 2)  
 | |
|           {                           
 | |
|             int cur_row = printer().formlen() - printer().rows_left();
 | |
|             int diff = printer().formlen() - cur_row;
 | |
|             if (diff <= 13 && diff != 0)
 | |
|               printer().formfeed();
 | |
|               
 | |
|             _rw = crea_intestazione(_rw);
 | |
|             calcola_progressivi();
 | |
|             _saldo_progressivi += _saldo_progre_prec;          
 | |
|             _rw = stampa_progre_riporto(_rw);
 | |
|           }
 | |
|           else
 | |
|           {
 | |
|             calcola_progressivi();
 | |
|             _saldo_progressivi += _saldo_progre_prec;      // Se trovo quel cazzone che ha scritto sto programma...
 | |
|           }
 | |
|         }  
 | |
|         else
 | |
|         {
 | |
|           _puoi_stampare = FALSE; 
 | |
|           return FALSE;
 | |
|         }                      
 | |
|       }
 | |
|       else
 | |
|         if (_selez_mastrini == 3) 
 | |
|         {  
 | |
|           calcola_progressivi();
 | |
|           if (_progredare == ZERO && _progreavere == ZERO && !almeno_un_record())  
 | |
|           { 
 | |
|             _puoi_stampare = FALSE;
 | |
|             return FALSE;
 | |
|           }
 | |
|           else               
 | |
|           {                                
 | |
|             _puoi_stampare = TRUE; 
 | |
|             
 | |
|             if (_nummast == 3 || _nummast == 2)
 | |
|             {                                                        
 | |
|               int cur_row = printer().formlen() - printer().rows_left();            
 | |
|               int diff = printer().formlen() - cur_row;
 | |
|               if (diff <= 13 && diff != 0)
 | |
|                 printer().formfeed();
 | |
|                 
 | |
|               _rw = crea_intestazione(_rw);
 | |
|               _saldo_progressivi += _saldo_progre_prec;
 | |
|               _rw = stampa_progre_riporto(_rw);
 | |
|             }
 | |
|           }
 | |
|         }    
 | |
|       }
 | |
|     break;
 | |
| 
 | |
|     case LF_RMOV:
 | |
|     { 
 | |
|       TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | |
| 
 | |
| 			//Il flag _gia_stampata_intestazione serve nella stampa in continuo, xche'
 | |
|      //sono costretto a richiamare l'intestazione sia nella preprocess_page (per
 | |
|      //i mastrini con intestazione a meta' pagina), sia nella preprocess_header
 | |
|      //per i mastrini che si trovano a cavallo fra una pagina e quella successiva.
 | |
|      //In quest'ultimo caso infatti quando vado a pagina nuova devo stampare l'intestazione
 | |
|      //ma senza il flag rischio di stamparla due volte.
 | |
|      if (_nummast == 3)
 | |
|         _gia_stampata_intestazione = FALSE;  
 | |
|       
 | |
|       if (_nummast == 1 || _nummast == 3)
 | |
|         _rw = 1;
 | |
|         
 | |
|       // Ricerca la contropartita di quel movimento
 | |
|       
 | |
|       _numreg = rmov.get_long(RMV_NUMREG);
 | |
|       _numrig = rmov.get_int(RMV_NUMRIG);
 | |
| 
 | |
|       _gruppocontr = rmov.get_int(RMV_GRUPPOC);     
 | |
|       _contocontr = rmov.get_int(RMV_CONTOC);
 | |
|       _sottocontocontr = rmov.get_long(RMV_SOTTOCONTOC);  
 | |
|       _g_contr = rmov.get(RMV_GRUPPOC);
 | |
|       _c_contr = rmov.get(RMV_CONTOC);
 | |
|       _s_contr = rmov.get(RMV_SOTTOCONTOC);
 | |
|       
 | |
|     // Stampa solo quelli che hanno anno esercizio uguale a quello specificato
 | |
|     // nella maschera. Se non viene specificato li stampa tutti
 | |
| 
 | |
|       _importo = rmov.get_real(RMV_IMPORTO);
 | |
|       _importo_str = real2str(_importo);
 | |
|       const TRectype & mov = cache().get(LF_MOV, _numreg);
 | |
| 
 | |
|       _annoes  = mov.get_int(MOV_ANNOES);
 | |
|       _regiva  = mov.get(MOV_REG);   
 | |
|       _annoiva = mov.get_int(MOV_ANNOIVA);
 | |
| 
 | |
| 
 | |
|       // Controlla se saldo e' diverso da 0
 | |
| 
 | |
|       if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0.0))
 | |
|       { 
 | |
|         _sezione = rmov.get(RMV_SEZIONE);     
 | |
| 
 | |
|         if (_annomsk == 0)
 | |
|         {
 | |
|           _datareg = mov.get(MOV_DATAREG);
 | |
| 
 | |
|           _datareg_stampa = _datareg;
 | |
|         }
 | |
|         else
 | |
|           if (_annomsk != 0)
 | |
|           {
 | |
|             _datareg = mov.get(MOV_DATACOMP);
 | |
|             _datareg_stampa = mov.get(MOV_DATAREG);
 | |
|           }
 | |
| 
 | |
| 
 | |
|         const TString4 provvis = mov.get(MOV_PROVVIS);
 | |
| 
 | |
|   
 | |
|         _dataregs = _datareg_stampa.string();
 | |
| 
 | |
|         if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.blank())))
 | |
|         {
 | |
|           if ((_datareg >= _data_ini) && (_datareg <= _data_fine))
 | |
|           {   
 | |
|             // Determino l' anno di competenza dell' operazione in esame          
 | |
|             int anno = date2esc(_datareg_stampa);
 | |
|             if (anno != _annoes)
 | |
|               if (_numcarat == 1)
 | |
|                 set_row (_rw, "@132g*");
 | |
|               else
 | |
|                 set_row (_rw, "@197g*");
 | |
| 
 | |
|             if (_stampa_mov_prov  && !provvis.blank()) 
 | |
|               if (_numcarat == 1)
 | |
|                 set_row(_rw, "@130gP"); 
 | |
|               else
 | |
|                 set_row(_rw, "@195gP");
 | |
|                 
 | |
|             _codcaus = mov.get(MOV_CODCAUS);
 | |
|             _tipodoc = mov.get(MOV_TIPODOC);
 | |
| 
 | |
|             if (_stampatotiva && (_tmcf == 'C' || _tmcf == 'F'))
 | |
|             {  
 | |
|               if (_tipodoc != "")
 | |
|               {
 | |
|                 documenti_iva();
 | |
|                 _b.add_riga(_descrdociva,_importo, _natdoc);     
 | |
|                 if (_descrdociva.len() > _ddociva_len)
 | |
|                   _ddociva_len = _descrdociva.len();
 | |
|               }
 | |
|             }
 | |
|             _datadoc = (mov.get(MOV_DATADOC));
 | |
| 
 | |
|             _datadocs = _datadoc.string();
 | |
|             _numdoc = mov.get(MOV_NUMDOC);
 | |
| 
 | |
|             descrizione_causale();
 | |
|             _descrizionemov = mov.get(MOV_DESCR);
 | |
|             _numgio = atol(mov.get(MOV_NUMGIO));
 | |
| 
 | |
| 
 | |
|             _descrizione = rmov.get(RMV_DESCR);
 | |
|             
 | |
|             _d18->cut(0); _d22->cut(0); _d30->cut(0);
 | |
|             
 | |
|             if (_nummast == 1 || _nummast == 3)
 | |
|             {
 | |
|               if (_numcarat == 1)     // Stampa 132 caratteri
 | |
|               {
 | |
|                 if (_descrizione != "")
 | |
|                 {
 | |
|                   *_d22 = (const char*) _descrizione;
 | |
|                   if (_descrizionemov != "")
 | |
|                   {                                    
 | |
|                     *_d18 = (const char*) _descrizionemov;
 | |
|                     set_row(_rw, "@42g#a", _d18);
 | |
|                     set_row(_rw, "@61g#a", _d22);
 | |
|                   }
 | |
|                   else if (_descrizionemov == "")
 | |
|                   { 
 | |
|                     *_d18 = (const char*) _descrcaus;
 | |
|                     set_row(_rw, "@42g#a", _d18);
 | |
|                     set_row(_rw, "@61g#a", _d22);
 | |
|                   }
 | |
|                 }
 | |
|                 else if (_descrizione == "")
 | |
|                        if (_descrizionemov != "")
 | |
|                        {
 | |
|                          *_d22 = (const char*) _descrizionemov;
 | |
|                          *_d18 = (const char*) _descrcaus;
 | |
|                          set_row (_rw,"@42g#a", _d18); 
 | |
|                          set_row (_rw,"@61g#a", _d22);
 | |
|                        }
 | |
|                        else
 | |
|                          if (_descrizionemov == "")
 | |
|                          {
 | |
|                            conto(_gruppocontr,_contocontr,FALSE);
 | |
|                            TBill tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                            _descrcontr = tc.descrizione();    
 | |
|                            *_d18 = (const char*) _descrcaus;
 | |
|                            set_row (_rw,"@42g#a", _d18); 
 | |
|                            if (_descrcontr != "Sconosciuto")
 | |
|                            {
 | |
|                              *_d22 = (const char*) _descrcontr;
 | |
|                              set_row (_rw,"@61g#a", _d22);
 | |
|                            }
 | |
|                          }  
 | |
|               }
 | |
|               else
 | |
|                 if (_numcarat == 2)     // Stampa 198 caratteri
 | |
|                 {
 | |
|                   if (_descrizione != "")
 | |
|                   {
 | |
|                     *_d30 = (const char*) _descrizione;
 | |
|                     if (_descrizionemov != "")
 | |
|                     {                                    
 | |
|                       *_d22 = (const char*) _descrizionemov;
 | |
|                       set_row (_rw,"@46g#a", _d22);
 | |
|                       set_row (_rw,"@70g#a", _d30);
 | |
|                     }
 | |
|                     else if (_descrizionemov == "")
 | |
|                     { 
 | |
|                       *_d22 = (const char*) _descrcaus;
 | |
|                       set_row(_rw, "@46g#a", _d22);
 | |
|                       set_row(_rw, "@70g#a", _d30);
 | |
|                     }
 | |
|                   }
 | |
|                   else if (_descrizione == "") 
 | |
|                          if (_descrizionemov.not_empty())
 | |
|                          {
 | |
|                            *_d30 = (const char*) _descrizionemov;
 | |
|                            *_d22 = (const char*) _descrcaus;
 | |
|                            set_row (_rw,"@46g#a", _d22); 
 | |
|                            set_row (_rw,"@70g#a", _d30);
 | |
|                          }
 | |
|                          else
 | |
|                          {
 | |
|                            conto(_gruppocontr,_contocontr,FALSE);
 | |
|                            TBill tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                            _descrcontr = tc.descrizione();
 | |
|                            *_d22 = (const char*) _descrcaus;
 | |
|                            set_row (_rw,"@46g#a", _d22); 
 | |
|                            if (_descrcontr != "Sconosciuto")
 | |
|                            {
 | |
|                              *_d30 = (const char*)_descrcontr;
 | |
|                              set_row (_rw,"@70g#a", _d30);
 | |
|                            }
 | |
|                          }
 | |
|                 }
 | |
|             }  //if (_nummast == 1 || _nummast == 3)
 | |
|           
 | |
|             if (_nummast == 2)
 | |
|             {                       
 | |
|               TString d18,d23,d30;
 | |
|             
 | |
|               if (_numcarat == 1)     // Stampa 132 caratteri
 | |
|               {
 | |
|                 if (_descrizione != "")
 | |
|                 {
 | |
|                   d23 = _descrizione;
 | |
|                   if (_descrizionemov.not_empty())
 | |
|                     d18 = _descrizionemov;
 | |
|                   else
 | |
|                     d18 = _descrcaus;
 | |
|                 }
 | |
|                 else if (_descrizione.empty())
 | |
|                 {
 | |
|                   if (_descrizionemov.not_empty())
 | |
|                   {
 | |
|                     d23 = _descrizionemov;
 | |
|                     d18 = _descrcaus;
 | |
|                   }
 | |
|                   else
 | |
|                   {
 | |
|                     conto(_gruppocontr,_contocontr,FALSE);
 | |
|                     TBill tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                     _descrcontr = tc.descrizione();    
 | |
|                     d18 = _descrcaus;
 | |
|                     if (_descrcontr != "Sconosciuto")
 | |
|                       d23 = _descrcontr;
 | |
|                   }  
 | |
|                 }        
 | |
|                 TParagraph_string d_18 (d18,18);
 | |
|                 int i = 0;  
 | |
|                 const char* str;
 | |
|                 while ( (str = d_18.get()) != NULL)
 | |
|                 { 
 | |
|                   TString stringa;
 | |
|                   stringa << "@42g" << str;
 | |
|                   setta_riga(i,stringa);
 | |
|                   i++;
 | |
|                 }
 | |
|                 
 | |
|                 TParagraph_string d_23 (d23,23);
 | |
|                 i = 0;
 | |
|                 while ( (str = d_23.get()) != NULL)
 | |
|                 {
 | |
|                   TString stringa;
 | |
|                   stringa << "@61g" << str;
 | |
|                   setta_riga(i,stringa);
 | |
|                   i++;
 | |
|                 }           
 | |
|               }
 | |
|               else
 | |
|                 if (_numcarat == 2)     // Stampa 198 caratteri
 | |
|                 {
 | |
|                   if (_descrizione.not_empty())
 | |
|                   {
 | |
|                     d30 = _descrizione;
 | |
|                     if (_descrizionemov != "")
 | |
|                       d23 = _descrizionemov;
 | |
|                     else if (_descrizionemov == "")
 | |
|                       d23 = _descrcaus;
 | |
|                   }
 | |
|                   else
 | |
|                   {
 | |
|                      if (_descrizionemov.not_empty())
 | |
|                      {
 | |
|                        d30 = _descrizionemov;
 | |
|                        d23 = _descrcaus;
 | |
|                      }
 | |
|                      else
 | |
|                      {
 | |
|                        conto(_gruppocontr,_contocontr,FALSE);
 | |
|                        TBill tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                        _descrcontr = tc.descrizione();
 | |
|                        d23 = _descrcaus;
 | |
|                        if (_descrcontr != "Sconosciuto")
 | |
|                         d30 = _descrcontr;
 | |
|                      }
 | |
|                   }       
 | |
|                   TParagraph_string d_23 (d23,23);
 | |
|                   int i = 0;
 | |
|                   const char* str;
 | |
|                   while ( (str = d_23.get()) != NULL)
 | |
|                   { 
 | |
|                     TString stringa;
 | |
|                     stringa << "@46g" << str;
 | |
|                     setta_riga(i,stringa);
 | |
|                     i++;
 | |
|                   }
 | |
|                 
 | |
|                   TParagraph_string d_30 (d30,30);
 | |
|                   i = 0;
 | |
|                   while ( (str = d_30.get()) != NULL)
 | |
|                   {                     
 | |
|                     TString stringa;
 | |
|                     stringa << "@70g" << str;
 | |
|                     setta_riga(i,stringa);
 | |
|                     i++;
 | |
|                   }
 | |
|                 }
 | |
|              
 | |
|               _item = _riga.items();
 | |
|               int riga,cur_row,diff;
 | |
|             
 | |
|               if ( (_conta_mastrini % 2) != 0 )
 | |
|               {   
 | |
|                 int app = 0;
 | |
|                 riga    = (printer().formlen() / 2);
 | |
|                 if (printer().rows_left() == 0)
 | |
|                   app = printer().formlen() - _rw;
 | |
|                 else    
 | |
|                   app = printer().rows_left();
 | |
|                 cur_row = printer().formlen() - app;  
 | |
|                 diff    = riga - cur_row;
 | |
|               }
 | |
|               else
 | |
|               {
 | |
|                 riga    = printer().formlen();          
 | |
|                 cur_row = printer().formlen() - printer().rows_left();
 | |
|                 diff    = riga - cur_row;
 | |
|               }
 | |
|                
 | |
|               bool stampa_riporti;
 | |
|                
 | |
|               int lim = 0;
 | |
|               if (_item >= diff)  
 | |
|               { 
 | |
|                 lim = diff - 1;
 | |
|                 stampa_riporti = TRUE;
 | |
|               }
 | |
|               else 
 | |
|               {
 | |
|                 lim = _item;   
 | |
|                 stampa_riporti = FALSE;
 | |
|               }
 | |
|             
 | |
|               _indice_array = 0;
 | |
|             
 | |
|               int k = _rw;
 | |
|               
 | |
|               for (int i = 0; i < lim; i++)
 | |
|               {
 | |
|                 TString& data = (TString&)_riga[i];
 | |
|               
 | |
|                 int g1 = data.find("g",1);
 | |
|                 int c1 = data.find("@",g1);
 | |
|                 int g2 = data.find("g",c1);
 | |
|               
 | |
|                 TString fmt1 = "";
 | |
|                 TString fmt2 = "";
 | |
|                 TString str1,str2;
 | |
|               
 | |
|                 if (g1 != -1)
 | |
|                 {
 | |
|                   fmt1 = data.sub(0,g1+1);
 | |
|                   fmt1 << "%s";
 | |
|                   str1 = data.sub(g1+1,c1);
 | |
|                 }  
 | |
|                 if (c1 != -1)
 | |
|                 {
 | |
|                   fmt2 = data.sub(c1,g2+1);
 | |
|                   fmt2 << "%s";
 | |
|                   str2 = data.sub(g2+1);
 | |
|                 }
 | |
|               
 | |
|                 if (fmt1 != "")
 | |
|                   set_row (k,fmt1,(const char*) str1);
 | |
|                 if (fmt2 != "")
 | |
|                   set_row (k,fmt2,(const char*) str2);
 | |
|               
 | |
|                 k++;
 | |
|                 _indice_array++;
 | |
|               }
 | |
|               if (stampa_riporti)
 | |
|               { 
 | |
|                 _rw = k;        
 | |
|                 if (lim == 0)
 | |
|                 {
 | |
|                   if (_numcarat == 1)
 | |
|                   {  
 | |
|                     TString app(132);
 | |
|                     app.spaces(); 
 | |
|                     set_row (_rw, "@0g%s", (const char*)app);
 | |
|                   }
 | |
|                   else
 | |
|                   {  
 | |
|                     TString app(198);
 | |
|                     app.spaces(); 
 | |
|                     set_row (_rw, "@0g%s", (const char*)app);
 | |
|                   }
 | |
|                 }
 | |
|                 real dep_dare,dep_avere;
 | |
|                 if (_stampa_footer_si)
 | |
|                 {
 | |
|                   _riporto_footer_dare  = _progredare  + _riporto_parziale_dare;
 | |
|                   _riporto_footer_avere = _progreavere + _riporto_parziale_avere;
 | |
|       
 | |
|                   real imp_d,imp_a;
 | |
|                   imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|                   imp_a = _sezione == "A" ? _importo : ZERO;   
 | |
|                   if (lim != 0)                   
 | |
|                   {
 | |
|                     _riporto_footer_dare  += imp_d;
 | |
|                     _riporto_footer_avere += imp_a;
 | |
|                   }
 | |
|                   dep_dare  = _riporto_footer_dare;
 | |
|                   dep_avere = _riporto_footer_avere;
 | |
|                   
 | |
|                   _stampa_footer_si = FALSE;
 | |
|                 }                           
 | |
|                 else
 | |
|                 {
 | |
|                   _riporto_footer_dare  += _riporto_parziale_dare;
 | |
|                   _riporto_footer_avere += _riporto_parziale_avere;
 | |
| 
 | |
|                   real imp_d,imp_a;
 | |
|                   imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|                   imp_a = _sezione == "A" ? _importo : ZERO;  
 | |
|                   if (lim != 0)
 | |
|                   {
 | |
|                     _riporto_footer_dare  += imp_d;
 | |
|                     _riporto_footer_avere += imp_a;
 | |
|                   }
 | |
|                   dep_dare  = _riporto_footer_dare;
 | |
|                   dep_avere = _riporto_footer_avere;
 | |
|                 }
 | |
|                 
 | |
|                 if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | |
|                 {  
 | |
|                   TString dare  (real2str(dep_dare));
 | |
|                   TString avere (real2str(dep_avere));
 | |
|                   if (_numcarat == 1)                  
 | |
|                   {
 | |
|                     set_row (_rw,FR("@32gA RIPORTO@83g%s"), (const char*) dare);
 | |
|                     set_row (_rw,"@100g%s", (const char*) avere);
 | |
|                   }  
 | |
|                   else
 | |
|                     if (_numcarat == 2) 
 | |
|                     {
 | |
|                       set_row (_rw,FR("@32gA RIPORTO@100g%s"), (const char*) dare);
 | |
|                       set_row (_rw,"@117g%s", (const char*) avere);
 | |
|                     }        
 | |
|                 }                          
 | |
|                 if (lim == 0)
 | |
|                 {
 | |
|                   rmov.prev();
 | |
|                   _riga.destroy();   
 | |
|                   _item = 0;        
 | |
|                   return TRUE;  
 | |
|                 } 
 | |
|                 _rw--;
 | |
|               }
 | |
|               //_riga.destroy();
 | |
|             } 
 | |
|                             
 | |
|             if (_sezione == "D")
 | |
|             {
 | |
|               _totale_periodo_dare += _importo;
 | |
|               _riporto_parziale_dare += _importo;
 | |
|         
 | |
| 
 | |
|               if (_numcarat == 1)    // Stampa 132 caratteri
 | |
|                 set_row (_rw,"@83g%s", (const char*) _importo_str);
 | |
|               else                   // Stampa 198 caratteri
 | |
|               {
 | |
|                 _saldo_progressivi += _importo;
 | |
|                 _saldo_movimenti += _importo;
 | |
|                 set_row (_rw,"@100g%s", (const char*) _importo_str);
 | |
|               }
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|               _totale_periodo_avere += _importo;
 | |
|               _riporto_parziale_avere += _importo;
 | |
|   
 | |
| 
 | |
|               if (_numcarat == 1)    // Stampa 132 caratteri
 | |
|                 set_row (_rw,"@100g%s", (const char*) _importo_str);
 | |
|               else                   // Stampa 198 caratteri 
 | |
|               {
 | |
|                 _saldo_progressivi -= _importo;
 | |
|                 _saldo_movimenti -= _importo;
 | |
|                 set_row (_rw,"@117g%s", (const char*) _importo_str);
 | |
|               }
 | |
|             }
 | |
|            
 | |
|             const int righe_rimaste = printer().rows_left();
 | |
|             _stampato = righe_rimaste >= 1;
 | |
|             
 | |
|             _saldo_movimenti_str=real2str(_saldo_movimenti);
 | |
|             if (_numcarat == 2)
 | |
|             {
 | |
|                ricerca_regiva();
 | |
|               _protiva = mov.get_long(MOV_PROTIVA);
 | |
|               if (_protiva != 0)   
 | |
|                 set_row (_rw,"@191g%5d", _protiva);
 | |
|           
 | |
|               if (_tipo < 3)
 | |
|                 set_row (_rw,"@183g#t" , &_regiva);
 | |
|               _dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG);
 | |
| 
 | |
| //Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV
 | |
| 
 | |
|               if (_stampa_saldo_des < 3) // Stampa saldo (non descrizioni)
 | |
|               {
 | |
|                 bool print_sald = true;
 | |
|                 if (_stampa_saldo_des != 2)  // come dire == 1
 | |
|                 {
 | |
|                   const TRecnotype rec = rmov.recno();
 | |
|                   if (rmov.next() == NOERR)
 | |
|                   {
 | |
|                     const int gruppof = rmov.get_int(RMV_GRUPPO);
 | |
|                     const int contof = rmov.get_int(RMV_CONTO);
 | |
|                     const long sottocf = rmov.get_long(RMV_SOTTOCONTO);
 | |
|                     if (gruppof==_gruppo && contof==_conto && sottocf==_sottoc)
 | |
|                     {
 | |
|                       const TDate datasucc = rmov.get_date(RMV_DATAREG);
 | |
|                       print_sald = datasucc != _dataregrmov;
 | |
|                     }
 | |
|                     rmov.readat(rec);            
 | |
|                   }
 | |
|                 }
 | |
|                 if (print_sald)
 | |
|                 {
 | |
|                   // Nuovo mpode semplificato
 | |
|                   set_row (_rw,"@135g%r", &_saldo_progressivi);
 | |
|                 }
 | |
|               }
 | |
|             }
 | |
|             else 
 | |
|             {
 | |
|                ricerca_regiva();
 | |
|               _protiva = atol(mov.get(MOV_PROTIVA));
 | |
|               if (_protiva != 0)   
 | |
|                 set_row (_rw,"@127g%5d", _protiva);
 | |
|             }
 | |
|             _rw = 1;
 | |
|           
 | |
|             return TRUE;
 | |
|           }
 | |
|           else
 | |
|             return FALSE;         
 | |
|         }
 | |
|         else
 | |
|           return FALSE;
 | |
|       }
 | |
|       else
 | |
|         return FALSE;
 | |
|     break; 
 | |
|     }
 | |
|     default:
 | |
|       break;   
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::set_page(int file, int counter)
 | |
| {
 | |
|   switch (file)
 | |
|   {
 | |
|   case LF_SALDI:
 | |
|     reset_print();
 | |
|     break;
 | |
| 
 | |
|   case LF_RMOV:
 | |
|     reset_print();
 | |
|     if (_numcarat == 1)
 | |
|       fai_stampa132();
 | |
|     else
 | |
|       fai_stampa198();
 | |
|     break;
 | |
|   default:
 | |
|     break;
 | |
|   }
 | |
| }
 | |
| 
 | |
| print_action TMastrini_application::postprocess_page(int file, int counter)
 | |
| {                   
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|   {
 | |
|     if (counter)
 | |
|     { 
 | |
|       if (_nummast == 1)      //Il salto pagina a rottura di mastrino viene
 | |
|         printer().formfeed(); //fatto solo quando seleziono un mastrino per pagina
 | |
|       
 | |
|       reset_print();     // per evitare che stampi di nuovo il totale prec.  
 | |
|       _stampa_progressivi_si  = TRUE;
 | |
|       _stampa_footer_si       = TRUE;
 | |
|       _riporto_dare           = ZERO;
 | |
|       _riporto_avere          = ZERO;   
 | |
|       _riporto_footer_dare    = ZERO;
 | |
|       _riporto_footer_avere   = ZERO;
 | |
|       _riporto_parziale_dare  = ZERO;
 | |
|       _riporto_parziale_avere = ZERO;
 | |
|       _ddociva_len            = 0;
 | |
|       
 | |
|       return NEXT_PAGE;
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|     if (_nummast == 2)
 | |
|     { 
 | |
|       int item_lista = _lista.items();
 | |
|         
 | |
|       if (counter && item_lista == 0)
 | |
|       { 
 | |
|         reset_print();     // per evitare che stampi di nuovo il totale prec.  
 | |
|         _stampa_progressivi_si  = TRUE;  
 | |
|         _stampa_footer_si       = TRUE;
 | |
|         _riporto_dare           = ZERO;
 | |
|         _riporto_avere          = ZERO; 
 | |
|         _riporto_footer_dare    = ZERO;
 | |
|         _riporto_footer_avere   = ZERO;
 | |
|         _riporto_parziale_dare  = ZERO;
 | |
|         _riporto_parziale_avere = ZERO;
 | |
|         _ddociva_len            = 0;
 | |
|         
 | |
|         return NEXT_PAGE;
 | |
|       }
 | |
|     }
 | |
| 
 | |
|   switch (file)
 | |
|   {
 | |
|   case LF_SALDI:
 | |
|   { 
 | |
|     if (_nummast == 1 || _nummast == 3)
 | |
|     {
 | |
|       if (_selez_mastrini == 3)
 | |
|       {
 | |
|         reset_print();
 | |
|         if (_numcarat == 1)
 | |
|           stampa_totali132();
 | |
|         else if (_numcarat == 2)
 | |
|           stampa_totali198();
 | |
| 
 | |
|         if (_stampatotiva)     
 | |
|           stampa_totaliiva();
 | |
|       }
 | |
|       else if (_selez_mastrini == 2)
 | |
|            {
 | |
|              reset_print();
 | |
|              if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|              {
 | |
|                if (_numcarat == 1)
 | |
|                  stampa_totali132();
 | |
|                else
 | |
|                  stampa_totali198();
 | |
|              }
 | |
|              if (_stampatotiva)      
 | |
|                stampa_totaliiva();
 | |
|        }
 | |
|        else if (_selez_mastrini == 1)
 | |
|             {
 | |
|               reset_print();
 | |
|               if (_puoi_stampare)
 | |
|               {
 | |
|                 if (_numcarat == 1)
 | |
|                   stampa_totali132();
 | |
|                 else if (_numcarat == 2)
 | |
|                   stampa_totali198();
 | |
|               }
 | |
| 
 | |
|               if (_stampatotiva)     
 | |
|                 stampa_totaliiva();
 | |
|             }
 | |
|     }
 | |
|     else
 | |
|       if (_nummast == 2)             
 | |
|       {                          
 | |
|         if (!counter)                                                                                   
 | |
|         { 
 | |
|           if (_numcarat == 1)
 | |
|             carica_array_totali132();
 | |
|           else
 | |
|             carica_array_totali198(); 
 | |
|         }
 | |
|         
 | |
|         if (_selez_mastrini == 3)
 | |
|         {
 | |
|           reset_print();
 | |
|           if (_numcarat == 1)
 | |
|             stampa_totali132_II();
 | |
|           else
 | |
|             stampa_totali198_II();
 | |
|         }
 | |
|         else if (_selez_mastrini == 2)
 | |
|              {
 | |
|                reset_print();
 | |
|                if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|                  if (_numcarat == 1)
 | |
|                    stampa_totali132_II();
 | |
|                  else
 | |
|                    stampa_totali198_II();
 | |
|          }
 | |
|          else if (_selez_mastrini == 1)
 | |
|               {
 | |
|                 reset_print();
 | |
|                 if (_puoi_stampare)
 | |
|                   if (_numcarat == 1)
 | |
|                     stampa_totali132_II();
 | |
|                   else
 | |
|                     stampa_totali198_II();
 | |
|               }
 | |
|               
 | |
|         int item_lista = _lista.items();   
 | |
|         
 | |
|         if (item_lista == 0)
 | |
|         {   
 | |
|           int righe_rimaste = righe_rimaste_da_stampare();
 | |
|              
 | |
|           righe_rimaste = righe_rimaste - _rw;  //_rw sono le righe dei totali gia' settate, mentre
 | |
|                                                //righe rimaste conteneva le righe senza quelle dei totali gia' settate
 | |
|           if (righe_rimaste > 0)
 | |
|           {                                
 | |
|             _rw++; //incremento la riga altrimenti copro l'ultimo totale settato con una riga bianca
 | |
|             for (int i = 0; i < righe_rimaste; i++)
 | |
|               set_row(_rw++,"@0g ");
 | |
|           }
 | |
|         }
 | |
|       }
 | |
| 
 | |
| //    _stampa_progressivi_si = TRUE;
 | |
|     return REPEAT_PAGE;
 | |
|   }
 | |
|   case LF_RMOV:  
 | |
|     force_setpage();
 | |
|     break;
 | |
|   default:
 | |
|     break;
 | |
|   }
 | |
|   return NEXT_PAGE;
 | |
| }                                                 
 | |
| 
 | |
| print_action TMastrini_application::postprocess_print(int file, int counter)
 | |
| {  
 | |
|   if (file == LF_SALDI) 
 | |
|   {
 | |
|     reset_print();
 | |
| //    stampa_totali_commessa();
 | |
|     print_one(file);
 | |
|   
 | |
|     _msk->reset(-9);
 | |
|   }
 | |
| 
 | |
|   return NEXT_PAGE;
 | |
| }
 | |
| // Stampa dei totali documenti iva se richiesta
 | |
| 
 | |
| void TMastrini_application::stampa_totaliiva()
 | |
| {
 | |
|   real totale;
 | |
| 
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|   {
 | |
|     _rw = 7;                        
 | |
|     _ddociva_len++;     
 | |
|     
 | |
|     if (_stampatotiva)
 | |
|     {
 | |
|       TString16 fmt; fmt.format("@%dg", _ddociva_len);
 | |
|       fmt << "%15s";
 | |
|       for (int j = 0; j < _b.items(); j++)
 | |
|       {
 | |
|         TDociva& riga = (TDociva&)_b[j];
 | |
|         set_row(_rw+j, "@0g%s",(const char*) riga._descrdoc);   
 | |
|         totale = riga._totdociva;
 | |
|         TString string = real2str(totale);
 | |
|         set_row(_rw+j, fmt, (const char*)string);
 | |
|       }
 | |
|     }
 | |
|     _b.destroy();
 | |
|   } 
 | |
| }
 | |
| 
 | |
| // Ricerca della descrizione relativa al codice causale di MOV.dta
 | |
| // sull'archivio CAUS.dta
 | |
| void TMastrini_application::descrizione_causale()
 | |
| {
 | |
| 	const TRectype & caus = cache().get(LF_CAUSALI, _codcaus);
 | |
| 
 | |
|   _descrcaus = caus.get(CAU_DESCR);
 | |
| }       
 | |
| 
 | |
| // Ricerca sulla tabella dei tipi documento, la descrizione e la natura del
 | |
| // documento, accedendovi tramite il tipo documento trovato su MOV.dta
 | |
| 
 | |
| void TMastrini_application::documenti_iva()
 | |
| {
 | |
|   TString dep;
 | |
|  
 | |
|   _tabtpd->curr().zero();
 | |
|   dep << format ("%2s",(const char*) _tipodoc);
 | |
|   _tabtpd->curr().put("CODTAB", (const char*) dep);
 | |
|   _tabtpd->read();
 | |
|   _descrdociva = _tabtpd->curr().get("S0");
 | |
|   _natdoc = atoi(_tabtpd->curr().get("I0"));
 | |
| }     
 | |
| 
 | |
| void TMastrini_application::ricerca_regiva()
 | |
| {
 | |
|   TString16 dep;
 | |
|   _tabreg->curr().zero();
 | |
|   dep << format("%04d", _annoiva); 
 | |
|   dep << format("%3s" , (const char*) _regiva);
 | |
|   _tabreg->curr().put("CODTAB", (const char*) dep);
 | |
|   _tabreg->read();
 | |
|   _tipo = _tabreg->get_int("I0");
 | |
| }    
 | |
| 
 | |
| bool TMastrini_application::preprocess_print(int file, int counter) 
 | |
| {  
 | |
|   if (file == LF_SALDI)
 | |
|   {
 | |
|     _g_prec = 0;
 | |
|     _c_prec = 0;
 | |
|     _s_prec = 0; 
 | |
|     
 | |
|     _saldo_periodo = ZERO;
 | |
|     _totale_periodo_dare = ZERO;
 | |
|     _totale_periodo_avere = ZERO;
 | |
|     _saldo_progre = ZERO;
 | |
|     _totprogre_dare = ZERO;
 | |
|     _totprogre_avere = ZERO;
 | |
|     _saldo_progre_al = ZERO;
 | |
|     _totprogre_dare_al = ZERO;
 | |
|     _totprogre_avere_al = ZERO;
 | |
|     _progredare = ZERO;
 | |
|     _progreavere = ZERO;
 | |
|     _totale_prima_dare = ZERO;
 | |
|     _totale_prima_avere = ZERO;
 | |
|     _saldo_movimenti = ZERO;
 | |
|     _saldo_progressivi = ZERO;
 | |
|     _saldo_progre_prec = ZERO;
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|     _protiva = 0;
 | |
|      
 | |
|     _flag_del_cazzo = _nummast == 1;
 | |
|  
 | |
|     _stampa_progressivi_si = TRUE; 
 | |
|     _stampa_footer_si      = TRUE;
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::set_print(int m)
 | |
| {
 | |
|   KEY tasto = K_ENTER;
 | |
|   while (tasto == K_ENTER)                    
 | |
|   {
 | |
|     _puoi_stampare = TRUE;   
 | |
|     // Controlla se esistono impostazioni di stampa in coda                 
 | |
|     if (sheet2mask())
 | |
|     {
 | |
|       // Simula l'immediata pressione del tasto stampa senza nemmeno lanciare la maschera
 | |
|       tasto = K_ENTER;
 | |
|     }  
 | |
|     else
 | |
|     {  
 | |
|       tasto = _msk->run();
 | |
|       if (tasto == K_ENTER)
 | |
|       {                                                          
 | |
|         // Se lo sheet e' vuoto allora usa solo la maschera corrente per la stampa,
 | |
|         // altrimenti estrae il primo elemento sovrascrivendo la maschera corrente.
 | |
|         // Questa figata cerca di correggere gli errori MI6185 e MI3592 in una botta
 | |
|         TSheet_field& sht = _msk->sfield(F_SCELTE);
 | |
|         if (sht.items() != 0)
 | |
|           sheet2mask();     // Estrae la prima riga dalla coda di stampa
 | |
|       }  
 | |
|     }  
 | |
|     if (tasto != K_ENTER)
 | |
|       break;
 | |
|     
 | |
|     _noseparator = _msk->get_bool(F_SEPARATOR);
 | |
|     if (_noseparator)
 | |
|       _real_picture = "################";
 | |
|     else
 | |
|       _real_picture = "####.###.###.###";
 | |
|     set_real_picture(_real_picture);
 | |
|     set_magic_currency(TRUE);
 | |
|   
 | |
|     _codice_ditta       = get_firm();
 | |
|     _annomsk            = _msk->get_int(F_ANNO);
 | |
|       
 | |
|     int gruppoini       = _msk->get_int(F_GRUPPOINI);
 | |
|     int contoini        = _msk->get_int(F_CONTOINI_CONTO);
 | |
|     long sottocontoini  = _msk->get_long(F_SOTTOCINI_CONTO);
 | |
|     int gruppofine      = _msk->get_int(F_GRUPPOFINE);
 | |
|     int contofine       = _msk->get_int(F_CONTOFINE_CONTO);
 | |
|     long sottocontofine = _msk->get_long(F_SOTTOCFINE_CONTO);
 | |
|   
 | |
|     _stampaprogre       = _msk->get_bool(F_STAMPAPROGRE);
 | |
|     _stampatotiva       = _msk->get_bool(F_STAMPATOTIVA);
 | |
|     _stampa_cont        = !_msk->get_bool(F_NOT_STAMPA_CONT);
 | |
|     _stampanum          = _msk->get_int(F_STAMPANUM);
 | |
|     _stampa_mov_prov    = _msk->get_bool(F_STAMPAMOVPROV); 
 | |
|     _selez_mastrini         = _msk->get_int(F_SELEZ_STAMPA);
 | |
|   
 | |
|     _numcarat           = _msk->get_int(F_NUMCARAT);
 | |
|     _stampa_saldo_des   = _numcarat==2 ? _msk->get_int(F_SALDO_DES) : 0;
 | |
|     _nummast            = _msk->get_int(F_NUMMAST);
 | |
|     _data_ini           = _msk->get_date(F_DATAINI);
 | |
|     _data_fine          = _msk->get_date(F_DATAFINE);
 | |
|   
 | |
|     TEsercizi_contabili esc;   
 | |
|   
 | |
|     if (_annomsk != 0)
 | |
|       _anno_corrente = _annomsk;
 | |
|     else               
 | |
|     {                                                        
 | |
|       _anno_ghost = esc.date2esc(_data_ini);
 | |
|       _anno_corrente = _anno_ghost;
 | |
|       _inizioes = esc[_anno_ghost].inizio();
 | |
|     }
 | |
|   
 | |
|     data_fine_esercizio(_anno_corrente); // Ricalcola _data_inizioese e _data_finese
 | |
|     if (!_data_ini.ok())  _data_ini  = _data_inizioese;
 | |
|     if (!_data_fine.ok()) _data_fine = _data_finese;
 | |
|          
 | |
|     _anno_precedente = esc.pred(_anno_corrente);
 | |
|   
 | |
|     ricerca_dati_ditta();
 | |
|   
 | |
|     if (_nummast == 1 || _nummast == 3)
 | |
|       printer().footerlen(4);
 | |
|     else                               
 | |
|       printer().footerlen(2);
 | |
|         
 | |
| //Crea il cursore su gruppo, conto e sottoconto del file RMOV
 | |
|   
 | |
|     reset_files();         //resetta l'albero di stampa
 | |
|     add_file(LF_SALDI);
 | |
|     add_file(LF_RMOV,LF_SALDI);   
 | |
|       
 | |
|     if (_msk->get_bool(F_SORTDESC))
 | |
|       select_cursor(_cur2);
 | |
|     else
 | |
|       select_cursor(_cur1);
 | |
|         
 | |
|     TRectype da(LF_SALDI), a(LF_SALDI);       
 | |
|     da.put(SLD_GRUPPO,gruppoini);        
 | |
|     da.put(SLD_CONTO,contoini);
 | |
|     da.put(SLD_SOTTOCONTO,sottocontoini);
 | |
|     a.put(SLD_GRUPPO,gruppofine);        
 | |
|     a.put(SLD_CONTO,contofine);
 | |
|     a.put(SLD_SOTTOCONTO,sottocontofine); 
 | |
|     current_cursor()->setregion(da, a);
 | |
|     if (_stampatotiva)   
 | |
|       _b.destroy();
 | |
|   
 | |
|     //_inizio_stampa   = TRUE;    
 | |
|     _numero_pag      = 1;
 | |
|     if (_nummast == 3)
 | |
|       _pagina = 0;
 | |
|     else      
 | |
|       _pagina          = 1;
 | |
|     _cambia_mastrino = FALSE; 
 | |
|     _rw              = 0;
 | |
|     _conta_mastrini  = 0;
 | |
|     _indice_lista    = 0; 
 | |
|     _ddociva_len     = 0;                                                           
 | |
|                                                                  
 | |
|     _riga.destroy();
 | |
|     _lista.destroy();
 | |
|       
 | |
|     switch (_selez_mastrini)
 | |
|     {
 | |
|       case 1: _totale_saldo = 1.0; break;
 | |
|       case 2: _totale_saldo = 0.0; break;
 | |
|       case 3: _totale_saldo = 1.0; break;
 | |
|       default: break;
 | |
|     }
 | |
|      
 | |
|     enable_print_menu();
 | |
|     enable_link("Collegamento prima nota: ", 'b');
 | |
|     
 | |
|     do 
 | |
| 	    print();
 | |
|     while (need_to_repeat_print());
 | |
|     _msk->reset(-8);
 | |
| 
 | |
|   }
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::data_fine_esercizio(int anno)
 | |
| {
 | |
|   TEsercizi_contabili esc;
 | |
|   _data_inizioese = esc[anno].inizio();
 | |
|   _data_finese    = esc[anno].fine();
 | |
| }
 | |
| 
 | |
| void TMastrini_application::preprocess_header()
 | |
| {                         
 | |
|   if (_nummast == 1)
 | |
|   {
 | |
|     if (_selez_mastrini == 3) // Tutti
 | |
|       crea_intestazione();
 | |
|     else
 | |
|       if (_selez_mastrini == 2) // Con saldo non nullo
 | |
|       {
 | |
|         if ((!_totale_saldo.is_zero()) && (_puoi_stampare))
 | |
|           crea_intestazione();
 | |
|       }
 | |
|       else if (_selez_mastrini == 1)
 | |
|              if (_puoi_stampare)
 | |
|                crea_intestazione();
 | |
|   }                
 | |
|   else
 | |
|     if (_nummast == 3 && !_gia_stampata_intestazione)
 | |
|     {
 | |
|       if (_selez_mastrini == 3) // Tutti
 | |
|         crea_intestazione();
 | |
|       else
 | |
|         if (_selez_mastrini == 2) // Con saldo non nullo
 | |
|         {
 | |
|           if ((!_totale_saldo.is_zero()) && (_puoi_stampare))
 | |
|             crea_intestazione();
 | |
|         }
 | |
|         else if (_selez_mastrini == 1) // Movimentati nel periodo
 | |
|                if (_puoi_stampare)
 | |
|                  crea_intestazione();
 | |
|     }                
 | |
| }  
 | |
| 
 | |
| void TMastrini_application::preprocess_footer()
 | |
| {   
 | |
|   reset_footer();
 | |
|   
 | |
|   if (_nummast != 1 && _nummast != 3)
 | |
|     return;
 | |
|       
 | |
|   if (_devi_stampare_footer)
 | |
|   {                    
 | |
|     real dep_dare,dep_avere;
 | |
|       
 | |
|     if (_stampa_footer_si)
 | |
|     {
 | |
|       _riporto_footer_dare  = _progredare  + _riporto_parziale_dare;
 | |
|       _riporto_footer_avere = _progreavere + _riporto_parziale_avere;
 | |
|       
 | |
|       real imp_d,imp_a;
 | |
|       imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|       imp_a = _sezione == "A" ? _importo : ZERO;
 | |
|       dep_dare  = _stampato ? _riporto_footer_dare  : _riporto_footer_dare - imp_d;
 | |
|       dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a;
 | |
|       
 | |
|       _stampa_footer_si = FALSE;
 | |
|     }                           
 | |
|     else
 | |
|     {
 | |
|       _riporto_footer_dare  += _riporto_parziale_dare;
 | |
|       _riporto_footer_avere += _riporto_parziale_avere;
 | |
| 
 | |
|       real imp_d,imp_a;
 | |
|       imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|       imp_a = _sezione == "A" ? _importo : ZERO;
 | |
|       dep_dare  = _stampato ? _riporto_footer_dare  : _riporto_footer_dare - imp_d;
 | |
|       dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a;
 | |
|     }
 | |
|     
 | |
|     if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | |
|     {     
 | |
|       TString dare  (real2str(dep_dare));
 | |
|       TString avere (real2str(dep_avere));
 | |
|       if (_numcarat == 1)                  
 | |
|       {
 | |
|         set_footer (2,FR("@32gA RIPORTO@83g%s"), (const char*) dare);
 | |
|         set_footer (2,"@100g%s", (const char*) avere);
 | |
|       }  
 | |
|       else
 | |
|         if (_numcarat == 2) 
 | |
|         {
 | |
|           set_footer (2,FR("@32gA RIPORTO@100g%s"), (const char*) dare);
 | |
|           set_footer (2,"@117g%s", (const char*) avere);
 | |
|         }  
 | |
|     }             
 | |
|   }                
 | |
| }  
 | |
| 
 | |
| void TMastrini_application::conto(int gruppo, int conto, bool no_contropartita)
 | |
| {
 | |
| 	TString16 key;
 | |
| 	
 | |
| 	key.format("%d|%d|", gruppo, conto);
 | |
| 	
 | |
| 	const TRectype & pconti = cache().get(LF_PCON, key);
 | |
| 
 | |
| 
 | |
|   if (no_contropartita)
 | |
|   {
 | |
|     _indbil = pconti.get_int(PCN_INDBIL);
 | |
|     _tmcf   = pconti.get_char(PCN_TMCF);
 | |
|   }
 | |
|   else
 | |
|     _tipo_contr = pconti.get_char(PCN_TMCF);
 | |
| }
 | |
| 
 | |
| void TMastrini_application::ricerca_dati_ditta()
 | |
| {
 | |
|   long app;
 | |
| 
 | |
|   const TRectype & nditte = cache().get(LF_NDITTE, _codice_ditta);
 | |
|   
 | |
| 	app = nditte.get_long(NDT_CODDITTA);
 | |
|   _ragsoc = nditte.get(NDT_RAGSOC);
 | |
|  
 | |
|   TString16 key;
 | |
| 	
 | |
| 	key.format("%ld|1", app);
 | |
| 
 | |
| 	const TRectype & unloc = cache().get(LF_UNLOC, key);
 | |
|   
 | |
| 	_indulc= unloc.get(ULC_INDULC);
 | |
|   _civulc= unloc.get(ULC_CIVULC);   
 | |
|   int len = _indulc.len();
 | |
|   if (len <= 31)
 | |
|   {
 | |
|     if (len <= 26)
 | |
|       _indulc << ' ' << _civulc;
 | |
|     else
 | |
|       _indulc << ' ' << _civulc.mid(0,5);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     _indulc = _indulc.mid(0,31);
 | |
|     _indulc << ' ' << _civulc.mid(0,5);
 | |
|   }
 | |
|   _capulc= unloc.get(ULC_CAPULC);
 | |
|   _comulc= unloc.get(ULC_COMULC);
 | |
|  
 | |
| 	key.format("|%s", (const char *) _comulc);
 | |
|   const TRectype& comuni = cache().get(LF_COMUNI, key);
 | |
| 	
 | |
|   _com = comuni.get(COM_DENCOM);
 | |
|   _prov = comuni.get(COM_PROVCOM);
 | |
| }
 | |
| 
 | |
| // Crea l'intestazione per la stampa a 132 e a 198 caratteri
 | |
| 
 | |
| void TMastrini_application::crea_intestazione()
 | |
| {
 | |
|   TString sep(133),sep1(198); 
 | |
|   reset_header();
 | |
|   
 | |
|   int np = get_page_number();
 | |
|   
 | |
|   if (_cambia_mastrino)
 | |
|   { 
 | |
|     if (_nummast != 3)
 | |
|       _pagina = 1;
 | |
|     _cambia_mastrino = FALSE;
 | |
|   }
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       if (_pagina != np)
 | |
|         sep << "Pag. @#";
 | |
|     }     
 | |
|     else
 | |
|       sep << "Pag. " << _pagina;
 | |
|     sep.right_just(132);
 | |
|     set_header(1,(const char*) sep);
 | |
|   }
 | |
|   else if (_numcarat == 2)
 | |
|        {
 | |
|          if (_nummast == 3)
 | |
|          {         
 | |
|            if (_pagina != np)
 | |
|             sep1 << "Pagina @#";
 | |
|          }             
 | |
|          else          
 | |
|            sep1 << "Pagina " << _pagina;
 | |
|          sep1.right_just(198);
 | |
|          set_header(1,(const char*) sep1);
 | |
|        }
 | |
|   if (_nummast != 3)     
 | |
|     _pagina++;
 | |
|   
 | |
|   if (_nummast != 3 || _pagina != np)
 | |
|   {
 | |
|     set_header (1, "@0g%s@6g%5ld", TR("DITTA"), _codice_ditta);
 | |
|     set_header (1, "@12g%-.45s", (const char*) _ragsoc);
 | |
|     set_header (1, "@59g%s", (const char*) _indulc);
 | |
|     set_header (1, "@97g%-.5s", (const char*) _capulc);
 | |
|     set_header (1, "@103g%-.18s", (const char*) _com);
 | |
|     set_header (1, "@122g%-.3s", (const char*) _prov);
 | |
|   }     
 | |
| 
 | |
|   set_header (2, "@122g%s", (const char *) _msk->get(F_DATASTAMPA));
 | |
| 
 | |
|   if (_nummast == 3)
 | |
|     set_header (3, "@0g%s@12g@b%3d %3d %6ld", TR("Sottoconto"), _gruppo, _conto, _sottoc);
 | |
|   else
 | |
|     set_header (3, "@0g%s@12g%3d %3d %6ld", TR("Sottoconto"), _gruppo, _conto, _sottoc);
 | |
|     
 | |
|   switch(_tmcf)  
 | |
|   {
 | |
|   case 'C': _tipo_mask = 1; break;
 | |
|   case 'F': _tipo_mask = 2; break;
 | |
|   default : _tipo_mask = 3; break;
 | |
|   }
 | |
| 
 | |
|   switch (_tipo_mask)
 | |
|   {
 | |
|     case 1: ricerca_clifo();
 | |
|               break;
 | |
|     case 2: ricerca_clifo();
 | |
|               break;
 | |
|     case 3: ricerca_gruppo();
 | |
|               break;
 | |
|     default:  break;
 | |
|   }    
 | |
| 
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep.fill('_');                            //Stampa 132 - (sep(132))      
 | |
|     set_header (6, (const char *) sep);
 | |
|     set_header (7,"%s@19g%s@117g%s@126g%s@132g%s", 
 | |
|                 TR("Operazione"), TR("Documento"), TR("Contro"), TR("Nr"), TR("A"));
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(7,"@130gM");
 | |
|     set_header (8, TR("Data"));
 | |
|     if (_stampanum < 3)
 | |
|       set_header (8,"@11g%s", TR("Numero"));
 | |
|     set_header (8,"@19g%s@30g%s@38g%s@61g%s@95g%s@111g%s@117g%s@126g%s@132g%s",
 | |
|                 TR("Data"), TR("Numero"), TR("Cod.Causale"), TR("Descrizione"),
 | |
|                 TR("Dare"), TR("Avere"), TR("Partita"), TR("Pro"), TR("C"));
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(8,"@130g%s", TR("P"));
 | |
|     sep.fill('_');
 | |
|     set_header (9, (const char *) sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|    sep1.fill('_');                    //Stampa 198 - (sep1(198))      
 | |
|    set_header (6,"@0g%s", (const char*)sep1);
 | |
|    if (_stampa_saldo_des == 3)
 | |
|    {
 | |
|      set_header (7,"%s@23g%s@183g%s@190g%s@197g%s",
 | |
|                  TR("Operazione"), TR("Documento"),
 | |
|                  TR("Reg"), TR("Nr"), TR("A"));
 | |
|    }
 | |
|    else
 | |
|    {
 | |
|      set_header (7,"%s@23g%s@169g%s@183g%s@190g%s@197g%s",
 | |
|                  TR("Operazione"), TR("Documento"), TR("Contro"),
 | |
|                  TR("Reg"), TR("Nr"), TR("A"));
 | |
|    }
 | |
|    if (_stampa_mov_prov)
 | |
|      set_header(7,"@195g%s", TR("M"));
 | |
|    set_header (8,TR("Data"));
 | |
|    if (_stampanum < 3)
 | |
|      set_header (8,"@11g%s", TR("Numero"));
 | |
|      
 | |
|    switch (_stampa_saldo_des)
 | |
|    {
 | |
|    case 1:
 | |
|      set_header (8,"@23g%s@34g%s@42g%s@70g%s@112g%s@127g%s@135g%s@152g%s@169g%s@183g%s@189g%s@197g%s",
 | |
|                  TR("Data"), TR("Numero"), TR("Cod.Causale"), TR("Descrizione"), TR("Dare"), TR("Avere"),
 | |
|                  TR("Saldo progre."), TR("Saldo movim."), TR("Partita"), TR("Iva"), TR("Prot"), TR("C"));
 | |
|      break;
 | |
|    case 2:
 | |
|      set_header (8,"@23g%s@34g%s@42g%s@70g%s@112g%s@127g%s@135g%s@152g%s@169g%s@183g%s@189g%s@197g%s",
 | |
|                  TR("Data"), TR("Numero"), TR("Cod.Causale"), TR("Descrizione"), TR("Dare"), TR("Avere"),
 | |
|                  TR("Saldo scalare"), TR("Saldo movim."), TR("Partita"), TR("Iva"), TR("Prot"), TR("C"));
 | |
|      break;
 | |
|    case 3:
 | |
|      set_header (8,"@23g%s@34g%s@42g%s@70g%s@112g%s@127g%s@135g%s@183g%s@189g%s@197g%s",
 | |
|                  TR("Data"), TR("Numero"), TR("Cod.Causale"), TR("Descrizione"), TR("Dare"), TR("Avere"),
 | |
|                  TR("Contropartita"), TR("Iva"), TR("Prot"), TR("C"));
 | |
|      break;
 | |
|    default:
 | |
|      break;
 | |
|    }
 | |
|                
 | |
|    if (_stampa_mov_prov)
 | |
|      set_header(8,"@195g%s", TR("P"));
 | |
|    sep1.fill('_');
 | |
|    set_header (9,"@0g%s", (const char*)sep1);
 | |
|   } 
 | |
|        
 | |
|   calcola_progressivi();
 | |
| //  _saldo_progressivi += _saldo_progre_prec;      // Se trovo quel cazzone che ha scritto sto programma...
 | |
|         
 | |
|   if (_stampa_progressivi_si)
 | |
|   {
 | |
|     if (_numcarat == 1)
 | |
|     { 
 | |
|       set_header (10,"@42g%s@66g%s", TR("PROGRESSIVI PRECEDENTI"), real2str(_saldo_progre_prec));
 | |
|       set_header (10,"@83g%s", real2str(_progredare));
 | |
|       set_header (10,"@100g%s", real2str(_progreavere));
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (10,"@70g%s@100g%s", TR("PROGRESSIVI PRECEDENTI"), real2str(_progredare));
 | |
|       set_header (10,"@117g%s", real2str(_progreavere));
 | |
|       if (_stampa_saldo_des < 3)
 | |
|         set_header (10,"@135g%s", real2str(_saldo_progre_prec));
 | |
|     }
 | |
|     _riporto_dare = _progredare;
 | |
|     _riporto_avere = _progreavere;
 | |
|     _stampa_progressivi_si = FALSE;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     _riporto_dare += _riporto_parziale_dare;
 | |
|     _riporto_avere += _riporto_parziale_avere;
 | |
| 
 | |
|     real dep_dare,dep_avere,imp_d,imp_a;
 | |
|     imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|     imp_a = _sezione == "A" ? _importo : ZERO;
 | |
|     dep_dare = _stampato ? _riporto_dare : _riporto_dare - imp_d;
 | |
|     dep_avere = _stampato ? _riporto_avere : _riporto_avere - imp_a;
 | |
| 
 | |
|     if (_nummast != 3 || dep_dare != ZERO || dep_avere != 0)
 | |
|     {
 | |
|       if (_numcarat == 1)
 | |
|       {
 | |
|         set_header (10,"@32g%s@83g%s", TR("A RIPORTO"), real2str(dep_dare));
 | |
|         set_header (10,"@100g%s", real2str(dep_avere));
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         set_header (10,"@32g%s@100g%s", TR("A RIPORTO"), real2str(dep_dare));
 | |
|         set_header (10,"@117g%s", real2str(dep_avere));
 | |
|       }
 | |
|     }  
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|   }
 | |
| 
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep ="";
 | |
|     set_header(11,"@0g%s",(const char*) sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     sep1 ="";
 | |
|     set_header(11,"@0g%s",(const char*) sep1);
 | |
|   }
 | |
| 
 | |
|   if (_pagina != np && _nummast == 3)
 | |
|     _pagina = np;       
 | |
| }
 | |
| 
 | |
| int TMastrini_application::crea_intestazione(int start_riga)
 | |
| {
 | |
|   TString   sep(132),sep1(198); 
 | |
|   int       r = start_riga + 2;
 | |
|   sep = "";
 | |
| 
 | |
|   reset_header();
 | |
| 
 | |
|   int np = get_page_number();
 | |
|     
 | |
|   _conta_mastrini++;
 | |
|     
 | |
|   if (_nummast == 3)
 | |
|     _gia_stampata_intestazione = TRUE;
 | |
|       
 | |
|   if (_nummast == 2)
 | |
|     if (_cambia_mastrino)
 | |
|     {
 | |
|       _numero_pag = 1;
 | |
|       _cambia_mastrino = FALSE;
 | |
|     }
 | |
|   if (_nummast == 3)
 | |
|   {
 | |
|     if (_pagina != np)
 | |
|     {
 | |
|       if (_numcarat == 1)
 | |
|       {
 | |
|         sep << FR("Pag. @#");
 | |
|         set_row(r,"@126g%s", (const char*) sep);
 | |
|       }     
 | |
|       else if (_numcarat == 2)
 | |
|       {
 | |
|         sep << FR("Pagina @#");
 | |
|         set_row(r,"@190g%s", (const char*) sep);
 | |
|       }       
 | |
|     }     
 | |
|   }          
 | |
|   else
 | |
|   {
 | |
|     if (_numcarat == 1)
 | |
|       set_row(r,"@126g%s %2d", TR("Pag."), _numero_pag++);
 | |
|     else if (_numcarat == 2)
 | |
|       set_row(r,"@190g%s %2d", TR("Pagina"),_numero_pag++);
 | |
|   }              
 | |
|   if (_nummast != 3 || _pagina != np)
 | |
|   {
 | |
|     set_row (r, "@0g%s@6g%5ld", TR("DITTA"), _codice_ditta);
 | |
|     set_row (r, "@12g%-45s", (const char*) _ragsoc);
 | |
|     set_row (r, "@59g%s", (const char*) _indulc);
 | |
|     //set_row (r, "@86g%-9s", (const char*) _civulc);
 | |
|     set_row (r, "@97g%-5s", (const char*) _capulc);
 | |
|     set_row (r, "@103g%-18s", (const char*) _com);
 | |
|     set_row (r, "@122g%-3s", (const char*) _prov);
 | |
|     r += 2;                 
 | |
|   }   
 | |
|   if (_nummast == 3)
 | |
|     set_row (r, "@0g%s@12g@b%3d %3d %6ld", TR("Sottoconto"), _gruppo, _conto, _sottoc);
 | |
|   else
 | |
|     set_row (r, "@0g%s@12g%3d %3d %6ld", TR("Sottoconto"), _gruppo, _conto, _sottoc);
 | |
|   
 | |
|   if (_tmcf == 'C')                       
 | |
|     _tipo_mask = 1;                       
 | |
|   else if (_tmcf == 'F')                
 | |
|     _tipo_mask = 2;               
 | |
|   else if (_tmcf == '\0')        
 | |
|     _tipo_mask = 3;        
 | |
|   
 | |
|   switch (_tipo_mask)
 | |
|   {
 | |
|     case 1: r = ricerca_clifo(r);
 | |
|               break;
 | |
|     case 2: r = ricerca_clifo(r);
 | |
|               break;
 | |
|     case 3: r = ricerca_gruppo(r);
 | |
|               break;
 | |
|     default:  break;
 | |
|   }    
 | |
|   
 | |
|   r++;
 | |
|   
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep.fill('_');                            //Stampa 132 - (sep(132))      
 | |
|     set_row (r++,"@0g%s", (const char *) sep);
 | |
|     set_row (r++,"%s@19g%s@117g%s@131g%s", TR("Operazione"), TR("Documento"), TR("Contro"), TR("A"));
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(r-1,"@130g%s", TR("M"));
 | |
|     set_row (r, TR("Data"));
 | |
|     if (_stampanum < 3)
 | |
|       set_row (r,"@11g%s", TR("Numero"));
 | |
|     set_row (r++,FR("@19gData@30gNumero@38gCod.Causale@61gDescrizione@95gDare@111gAvere@117gPartita@131gC"));
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(r-1,"@130gP");
 | |
|     sep.fill('_');
 | |
|     set_row (r++,"@0g%s", (const char*)sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|    sep1.fill('_');                    //Stampa 198 - (sep1(198))      
 | |
|    set_row (r++,"@0g%s", (const char*)sep1);
 | |
|    if (_stampa_saldo_des == 2)
 | |
|      set_row (r++,FR("Operazione@23gDocumento@183gReg@190gNumero@197gA"));
 | |
|    else  
 | |
|      set_row (r++,FR("Operazione@23gDocumento@169gContro@183gReg@190gNumero@197gA"));
 | |
|    if (_stampa_mov_prov)
 | |
|      set_row(r-1,"@195gM");
 | |
|    set_row (r,"Data");
 | |
|    if (_stampanum < 3)
 | |
|      set_row (r,"@11gNumero");
 | |
|    set_row (r,FR("@23gData@34gNumero@42gCod.Causale@70gDescrizione@112gDare@127gAvere"));
 | |
|    if (_stampa_saldo_des == 2)
 | |
|      set_row (r++,FR("@135gContropartita@183gIva@189gProt@197gC"));
 | |
|    else  
 | |
|      set_row (r++,FR("@135gSaldo progre.@152gSaldo movim.@169gPartita@183gIva@189gProt@197gC"));
 | |
|    if (_stampa_mov_prov)
 | |
|      set_row (r-1,"@195gP");
 | |
|    sep1.fill('_');
 | |
|    set_row (r++,"@0g%s", (const char*)sep1);
 | |
|   }   
 | |
|   _pagina = np;       
 | |
|   return r;     
 | |
| }
 | |
|           
 | |
| int TMastrini_application::stampa_progre_riporto(int start_riga)
 | |
| { 
 | |
|   TString sep(132),sep1(198);                                  
 | |
|   int r = start_riga;
 | |
|   
 | |
|   if (_stampa_progressivi_si)
 | |
|   {
 | |
|     r = stampa_progressivi(r);
 | |
|     _riporto_dare = _progredare;
 | |
|     _riporto_avere = _progreavere;
 | |
|     _stampa_progressivi_si = FALSE;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     _riporto_dare += _riporto_parziale_dare;
 | |
|     _riporto_avere += _riporto_parziale_avere;
 | |
|     
 | |
|     real dep_dare,dep_avere,imp_d,imp_a;
 | |
|     imp_d = _sezione == "D" ? _importo : ZERO;
 | |
|     imp_a = _sezione == "A" ? _importo : ZERO;
 | |
|     dep_dare = _stampato ? _riporto_dare : _riporto_dare - imp_d;
 | |
|     dep_avere = _stampato ? _riporto_avere : _riporto_avere - imp_a;
 | |
| 
 | |
|     if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | |
|     {
 | |
|       if (_numcarat == 1)
 | |
|       {
 | |
|         set_row (r,"@32g%s@83g%r", TR("A RIPORTO"), &dep_dare);
 | |
|         set_row (r++,"@100g%r", &dep_avere);
 | |
|       }
 | |
|       if (_numcarat == 2)
 | |
|       {
 | |
|         set_row (r,"@32g%s@100g%r", TR("A RIPORTO"), &dep_dare);
 | |
|         set_row (r++,"@117g%r", &dep_avere);
 | |
|       }
 | |
|     }     
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|   }
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep ="";
 | |
|     set_row(r++,"@0g%s",(const char*) sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|    sep1 ="";
 | |
|    set_row(r++,"@0g%s",(const char*) sep1);
 | |
|   }            
 | |
|   return r;
 | |
| } 
 | |
|          
 | |
| void TMastrini_application::calcola_progressivi_al(const TDate& data_fin)
 | |
| {
 | |
|   TLocalisamfile& rmov_file = current_cursor()->file(LF_RMOV);
 | |
|   const TRecnotype record = rmov_file.recno(); 
 | |
| 
 | |
|   _totale_prima_dare  = ZERO;
 | |
|   _totale_prima_avere = ZERO;
 | |
|   
 | |
|   TRelation rel(LF_RMOV);     
 | |
|   rel.add(LF_MOV, "NUMREG==NUMREG");
 | |
|   TRectype& rmov = rel.curr(); 
 | |
| //  const TRectype& mov = rel.curr(LF_MOV); 
 | |
|   
 | |
|   rmov.zero();
 | |
|   rmov.put(RMV_GRUPPO,     _gruppo);
 | |
|   rmov.put(RMV_CONTO,      _conto);
 | |
|   rmov.put(RMV_SOTTOCONTO, _sottoc);
 | |
|   TCursor cur(&rel, "", 2, &rmov, &rmov);
 | |
|   const long items = cur.items();
 | |
|   cur.freeze();
 | |
|   for (cur = 0L; cur.pos() < items; ++cur)
 | |
|   {
 | |
|     const int annoes = rmov.get_int (RMV_ANNOES);
 | |
|     TDate datareg = rmov.get_date(RMV_DATAREG);
 | |
|     const char sezione = rmov.get_char(RMV_SEZIONE);
 | |
|     const real importo = rmov.get_real(RMV_IMPORTO);
 | |
|     long numreg = rmov.get_long(RMV_NUMREG);
 | |
| 
 | |
| 	  const TRectype & mov = cache().get(LF_MOV, numreg);
 | |
|     const TDate datacomp = (mov.get_date(MOV_DATACOMP));
 | |
| 		TDate data;
 | |
|     const TString16 provvis (mov.get(MOV_PROVVIS));
 | |
| 
 | |
| 
 | |
|     if (_stampa_mov_prov || (!_stampa_mov_prov && provvis.blank()))
 | |
|     {
 | |
|       if (_annomsk == 0)
 | |
|       {
 | |
|         datareg = rmov.get_date(RMV_DATAREG); 
 | |
|         data = _inizioes;
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         datareg = datacomp;
 | |
|         data = _data_inizioese;
 | |
|       }  
 | |
| 
 | |
|       const int gruppo = rmov.get_int(RMV_GRUPPO);
 | |
|       const int conto  = rmov.get_int(RMV_CONTO);
 | |
|       const long sottoc = rmov.get_long(RMV_SOTTOCONTO);
 | |
|       if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc))
 | |
|         break;
 | |
|       else 
 | |
|       {
 | |
|         //Legge movimenti con data > inizio esercizio e < data_fin
 | |
|         if (((annoes==_annomsk)||(_annomsk == 0))&&(datareg >= data)&&(datareg <= data_fin)) 
 | |
|           if (sezione == 'D')
 | |
|             _totale_prima_dare += importo;
 | |
|           else
 | |
|             _totale_prima_avere += importo;
 | |
|       }
 | |
|     } // if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty())))              
 | |
|   }  
 | |
|   
 | |
|   // Riposiziona rmov
 | |
|   rmov_file.readat(record);
 | |
| }
 | |
| 
 | |
| void TMastrini_application::calcola_progressivi(bool finali)
 | |
| {
 | |
|    /* fv 20/3/96: aggiustato per nuova struttura saldi - modificata ricerca
 | |
|     * record scaricati e assegnazione dare/avere relativo - Controllare che
 | |
|     * non occorra considerare il saldo di chiusura (SALDOFIN) aggiunto al
 | |
|     * record */
 | |
| 
 | |
|    TLocalisamfile saldi(LF_SALDI);
 | |
|    real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
 | |
|    real saldo,progredare_eseprec,progreavere_eseprec,saldoini_attuale,saldofine_attuale;
 | |
|    char salini,salini_attuale,salfine_attuale;
 | |
| 
 | |
|    saldo         = ZERO;    // saldo = Saldo iniziale (Guy: Ovvio no?)  
 | |
|    
 | |
|   // Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto
 | |
|   // uguali a quelli di rmov per il calcolo dei progressivi precedenti
 | |
|   
 | |
|    saldi.setkey(2);
 | |
|    saldi.zero();
 | |
|    saldi.put(SLD_GRUPPO,     _gruppo);
 | |
|    saldi.put(SLD_CONTO,      _conto);
 | |
|    saldi.put(SLD_SOTTOCONTO, _sottoc);
 | |
|    const TRectype record(saldi.curr());
 | |
|   
 | |
|    for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next())
 | |
|    {             
 | |
|      if (!saldi.get_bool(SLD_FLSCA))
 | |
|      {
 | |
|        const int annoes_saldi = saldi.curr().get_int(SLD_ANNOES);
 | |
|      
 | |
| //Calcola i progressivi dell'esercizio attuale
 | |
|        if (annoes_saldi == _anno_corrente)
 | |
|        {
 | |
|          progdare_attuale  = saldi.get_real(SLD_PDARE);
 | |
|          progavere_attuale = saldi.get_real(SLD_PAVERE);
 | |
|          if (_stampa_mov_prov)
 | |
|          {
 | |
|            progdare_attuale += saldi.get_real(SLD_PDAREPRO);
 | |
|            progavere_attuale += saldi.get_real(SLD_PAVEREPRO);
 | |
|          }
 | |
| 
 | |
|          saldo             = saldi.get_real(SLD_SALDO);
 | |
|          salini            = saldi.get(SLD_FLAGSALINI)[0]; 
 | |
|          _ultima_data_reg  = saldi.get_date(SLD_DATAULMOV);
 | |
|          saldoini_attuale  = saldi.get_real(SLD_SALDO);
 | |
|          salini_attuale    = saldi.get_char(SLD_FLAGSALINI); 
 | |
|          saldofine_attuale = saldi.get_real(SLD_SALDOFIN);
 | |
|          salfine_attuale   = saldi.get_char(SLD_FLAGSALFIN);
 | |
|        }
 | |
|      }   // if (!saldi.get_bool(SLD_FLSCA))
 | |
|    }   // FOR
 | |
|    
 | |
| //Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo
 | |
| // finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil
 | |
|                            
 | |
|    if (_annomsk != 0)
 | |
|    {    
 | |
|      if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5))
 | |
|      {           
 | |
|        const TRecnotype pos = saldi.recno();                                      
 | |
|        // W96SALDI del 18-07-96 saldofin_esprec usa il flag TRUE xche' deve
 | |
|        // considerare anche il saldo finale
 | |
|        saldo = _sld->saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc,TRUE, _stampa_mov_prov);
 | |
|        saldi.readat(pos);
 | |
|            
 | |
|        if (saldo > ZERO)
 | |
|        {
 | |
|          progredare_eseprec  = saldo;
 | |
|          progdare_prec = saldo;
 | |
|        }
 | |
|        else if (saldo < ZERO)
 | |
|        {
 | |
|          saldo = -saldo;
 | |
|          progreavere_eseprec = saldo;
 | |
|          progavere_prec = saldo;
 | |
|        }
 | |
|      }
 | |
|    }
 | |
|    
 | |
|    if (finali)
 | |
|    {
 | |
|      calcola_progressivi_al(_data_fine);
 | |
|    }
 | |
|    else
 | |
|    {
 | |
|      TDate giorno_prima = _data_ini; --giorno_prima;       // CM500429
 | |
|      calcola_progressivi_al(giorno_prima);
 | |
|    }
 | |
|   
 | |
| //Calcolo dei progressivi precedenti: somma di tutti quei movimenti di rmov
 | |
| //che hanno la data di registrazione inferiore alla data di inizio stampa,
 | |
| //dei progressivi dell'anno esercizio precedente, e dei progressivi dei
 | |
| //movimenti scaricati dell'esercizio attuale.
 | |
| 
 | |
|    _progredare  = progredare_eseprec   + _totale_prima_dare;
 | |
|    _progreavere = progreavere_eseprec + _totale_prima_avere;
 | |
|    _saldo_progre_prec = _progredare - _progreavere;
 | |
| 
 | |
| //Calcolo dei progressivi al <ultima data registrazione>  
 | |
| 
 | |
| //Se sulla maschera e' stato selezionato il controllo competenza esercizio
 | |
| //Sommo i progressivi dell'esercizio precedente e quelli dell'esercizio attuale
 | |
| //altrimenti solo quelli dell'esercizio attuale
 | |
| 
 | |
|    if (_annomsk != 0)
 | |
|    {
 | |
|      _totprogre_dare_al     = progdare_attuale  + progdare_prec;
 | |
|      _totprogre_avere_al    = progavere_attuale + progavere_prec;  
 | |
| 
 | |
|      if (salini_attuale == 'D')
 | |
|        _totprogre_dare_al += saldoini_attuale;
 | |
|      else
 | |
|        _totprogre_avere_al += saldoini_attuale;
 | |
|      if (salfine_attuale == 'D')
 | |
|        _totprogre_dare_al += saldofine_attuale;
 | |
|      else
 | |
|        _totprogre_avere_al += saldofine_attuale;       
 | |
|    }
 | |
|    else
 | |
|    {
 | |
|      _totprogre_dare_al = progdare_attuale;
 | |
|      _totprogre_avere_al = progavere_attuale;
 | |
| 
 | |
|      if (salini_attuale == 'D')
 | |
|        _totprogre_dare_al += saldoini_attuale;
 | |
|      else if (salini_attuale == 'A')
 | |
|             _totprogre_avere_al += saldoini_attuale;
 | |
|      if (salfine_attuale == 'D')
 | |
|        _totprogre_dare_al += saldofine_attuale;
 | |
|      else if (salfine_attuale == 'A')
 | |
|        _totprogre_avere_al += saldofine_attuale;       
 | |
|    } 
 | |
| }
 | |
| 
 | |
| int TMastrini_application::stampa_progressivi(int start_riga)
 | |
| {                                                           
 | |
|   int r = start_riga;
 | |
|   
 | |
|   if (_numcarat == 1)
 | |
|   { 
 | |
|     set_row (r,FR("@42gPROGRESSIVI PRECEDENTI@66g%r"), &_saldo_progre_prec);
 | |
|     set_row (r,"@83g%r", &_progredare);
 | |
|     set_row (r++,"@100g%r", &_progreavere);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     set_row (r,FR("@70g%s@100g%r"), TR("PROGRESSIVI PRECEDENTI"), &_progredare);
 | |
|     set_row (r,"@117g%r", &_progreavere);
 | |
|     if (_stampa_saldo_des < 3)
 | |
|       set_row (r++,"@135g%r", &_saldo_progre_prec);
 | |
|   }       
 | |
|          
 | |
|   return r;
 | |
| }
 | |
| 
 | |
| // Se la ricerca selezionata nella maschera e' per clienti, oppure fornitori,  // allora ricerco su CLIFO i relativi dati, e su PCON il relativo gruppo,conto,// sottoconto e IV direttiva CEE
 | |
| 
 | |
| void TMastrini_application::ricerca_clifo()
 | |
| {
 | |
|   TString ragsoc,indcf,capcf,ptel,tel,dencom,dep;
 | |
|   TString4 provcom;
 | |
|   TString16 dataini,datafine,paiv,cofi; 
 | |
|   TString   descriz,descriz2;
 | |
|   int     numrivd;
 | |
|   
 | |
|   TString16 key;
 | |
|   key.format("%c|%ld", _tmcf, _sottoc);
 | |
|   const TRectype & clifo = cache().get(LF_CLIFO, key);
 | |
|   ragsoc  = clifo.get(CLI_RAGSOC); ragsoc.strip_double_spaces();
 | |
|   paiv    = clifo.get(CLI_PAIV);
 | |
|   cofi    = clifo.get(CLI_COFI);
 | |
|   indcf   = clifo.get(CLI_INDCF);
 | |
|   indcf.trim();
 | |
|   indcf << ' ' << clifo.get(CLI_CIVCF);
 | |
|   capcf   = clifo.get(CLI_CAPCF);
 | |
|   ptel    = clifo.get(CLI_PTEL);
 | |
|   tel     = clifo.get(CLI_TEL);
 | |
| 
 | |
|   const TString4 statocf = clifo.get(CLI_STATOCF);
 | |
|   const TString4 comcf   = clifo.get(CLI_COMCF);
 | |
| 	key.format("%s|%s", (const char *) statocf, (const char *) comcf);
 | |
| 	const TRectype & comuni = cache().get(LF_COMUNI, key);
 | |
| 
 | |
|   if (!comuni.empty())
 | |
|   {
 | |
|     dencom = comuni.get(COM_DENCOM);
 | |
|     provcom = comuni.get(COM_PROVCOM);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     dencom = clifo.get(CLI_LOCCF);
 | |
|     provcom="";
 | |
|   }
 | |
| 	
 | |
| 	key.format("%d|%d|", _gruppo, _conto);
 | |
|   
 | |
| 	const TRectype & pconti = cache().get(LF_PCON, key);
 | |
|   _sezivd  = pconti.get_char(PCN_SEZIVD);
 | |
|   _lettivd = pconti.get_char(PCN_LETTIVD);
 | |
|   numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | |
|   _numrivd = itor(numrivd);
 | |
|   _numivd  = pconti.get(PCN_NUMIVD);
 | |
| 
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,numrivd, _numivd);    
 | |
|  
 | |
|   if (_numivd.not_empty())     //Ora devo stampare la descrizione del livello della
 | |
|   {                            //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd.not_empty())   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,"");
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd.not_empty())
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");   
 | |
|     else
 | |
|       descriz2 = "";
 | |
|  
 | |
|   set_header (3,"@27g%-.30s",(const char*) descrizione_gruppo());
 | |
|   set_header (3,"@59g%-.30s",(const char*) descrizione_conto());
 | |
|   set_header (3, "@91g%-.41s",(const char*) ragsoc);
 | |
|   if (_nummast == 3)
 | |
|     set_header (4, "@r%s@8g@b%c", TR("Classe"), _lettivd);
 | |
|   else
 | |
|     set_header (4, "%s@8g%c", TR("Classe") , _lettivd);  
 | |
|   set_header (4, "@10g%-8s", (const char*) _numrivd);
 | |
|   if (_numivd.not_empty())
 | |
|     set_header (4, "@19g%s", num2str(_numivd));
 | |
|   if (descriz2 != "")                              
 | |
|   {
 | |
|     set_header (4,"@30g%-50s",(const char*) descriz2);
 | |
|     set_header (4,"@82g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_header (4,"@30g%-50s",(const char*) descriz);
 | |
|     
 | |
|   dataini = _data_ini.string();   
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                         
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, FR("@rPeriodo@10g@b%s"), (const char*) dataini);
 | |
|       set_header (5, "@22g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, FR("Periodo@10g%s"), (const char*) dataini);
 | |
|       set_header (5, "@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                         
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, FR("@rComp. da@9g@b%s"), (const char*) dataini);
 | |
|       set_header (5, "@20g@ra@22g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, FR("Comp. da@9g%s"), (const char*) dataini);
 | |
|       set_header (5, "@20ga@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   set_header (5, FR("@33gP.I.@37g%-11s"),(const char*) paiv);
 | |
|   set_header (5, FR("@49gCF@52g%-16s"),(const char*) cofi);
 | |
|   set_header (5, "@66g%-.25s",(const char*) indcf);
 | |
|   set_header (5, "@95g%-5s",(const char*) capcf);
 | |
|   set_header (5, "@101g%-.24s",(const char*) dencom);
 | |
|   set_header (5, "@126g%-5s",(const char*) provcom);
 | |
|  
 | |
|   if (_numcarat == 2)
 | |
|   {
 | |
|     set_header (5,"@135g%-4s",(const char*) ptel);
 | |
|     if (tel != "")
 | |
|       set_header (5,"@138g/@139g%-10s",(const char*) tel);
 | |
|   }
 | |
| }
 | |
| 
 | |
| int TMastrini_application::ricerca_clifo(int start)
 | |
| {
 | |
|   TString ragsoc,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep;
 | |
|   TString16 dataini,datafine; 
 | |
|   TString   descriz,descriz2;
 | |
|   int     numrivd;
 | |
|   int   r = start;
 | |
|   
 | |
|   indcf = "";
 | |
|   
 | |
|   TString16 key;
 | |
| 
 | |
|   key.format("%c|%ld", _tmcf, _sottoc);
 | |
| 
 | |
|   const TRectype & clifo = cache().get(LF_CLIFO, key);
 | |
|   
 | |
|   ragsoc  = clifo.get(CLI_RAGSOC); ragsoc.strip_double_spaces();
 | |
|   paiv    = clifo.get(CLI_PAIV);
 | |
|   cofi    = clifo.get(CLI_COFI);
 | |
|   indcf   = clifo.get(CLI_INDCF);
 | |
|   indcf.trim();
 | |
|   indcf << " " << clifo.get(CLI_CIVCF);
 | |
|   capcf   = clifo.get(CLI_CAPCF);
 | |
|   ptel    = clifo.get(CLI_PTEL);
 | |
|   tel     = clifo.get(CLI_TEL);
 | |
|   statocf = clifo.get(CLI_STATOCF);
 | |
|   comcf   = clifo.get(CLI_COMCF);
 | |
| 
 | |
| 	key.format("%s|%s", (const char *) statocf, (const char *) comcf);
 | |
| 
 | |
| 	const TRectype & comuni = cache().get(LF_COMUNI, key);
 | |
| 	
 | |
|   if (!comuni.empty())
 | |
|   {
 | |
|     dencom = comuni.get(COM_DENCOM);
 | |
|     provcom = comuni.get(COM_PROVCOM);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     dencom=clifo.get(CLI_LOCCF);
 | |
|     provcom="";
 | |
|   }
 | |
| 
 | |
|   key.format("%d|%d|", _gruppo, _conto);
 | |
| 
 | |
|   const TRectype & pconti = cache().get(LF_PCON, key);
 | |
|   _sezivd  = pconti.get_char(PCN_SEZIVD);
 | |
|   _lettivd = pconti.get_char(PCN_LETTIVD);
 | |
|   numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | |
|   _numrivd = itor(numrivd);
 | |
|   _numivd  = pconti.get(PCN_NUMIVD);
 | |
| 	
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);    
 | |
|  
 | |
|   if (_numivd.not_empty())      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd.not_empty())   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,"");
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd.not_empty())
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");   
 | |
|     else
 | |
|       descriz2 = "";
 | |
|  
 | |
|   set_row (r,"@27g%-30s",(const char*) descrizione_gruppo());
 | |
|   set_row (r,"@59g%-30s",(const char*) descrizione_conto());
 | |
|   set_row(r++, "@91g%-30s",(const char*) ragsoc);
 | |
|   if (_nummast == 3)                  
 | |
|     set_row(r, "@r%s@8g@b%c", TR("Classe"), _lettivd);
 | |
|   else
 | |
|     set_row(r, "%s@8g%c", TR("Classe"), _lettivd);
 | |
|   set_row(r, "@10g%-8s", (const char*) _numrivd);
 | |
|   if (_numivd.not_empty())
 | |
|     set_row(r, "@19g%s", num2str(_numivd));
 | |
|   if (descriz2.not_empty())                              
 | |
|   {
 | |
|     set_row(r,"@30g%-50s",(const char*) descriz2);
 | |
|     set_row(r++,"@82g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_row(r++,"@30g%-50s",(const char*) descriz);
 | |
|                                        
 | |
|   dataini = _data_ini.string();   
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                          
 | |
|     if (_nummast == 3)       
 | |
|     {
 | |
|       set_row (r, "@r%s@10g@b%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_row (r, "@22g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "%s@10g%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_row (r, "@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                        
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@r%s@9g@b%s", TR("Comp.dal"), (const char*) dataini);
 | |
|       set_row (r, "@20g@r%s@22g@b%s@r", TR("al"), (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "%s@9g%s", TR("Comp.dal"), (const char*) dataini);
 | |
|       set_row (r, "@20g%s@22g%s", TR("al"), (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   set_row (r, FR("@33gP.I.@37g%-11s"),(const char*) paiv);
 | |
|   set_row (r, FR("@49gCF@52g%-16s"),(const char*) cofi);
 | |
|     set_row (r, "@66g%-.25s",(const char*) indcf);
 | |
|   set_row (r, "@95g%-5s",(const char*) capcf);
 | |
|   set_row (r, "@101g%-.24s",(const char*) dencom);
 | |
|   set_row (r, "@126g%-5s",(const char*) provcom);
 | |
|  
 | |
|   if (_numcarat == 2)
 | |
|   {
 | |
|     set_row (r,"@135g%-4s",(const char*) ptel);
 | |
|     if (tel != "")
 | |
|       set_row (r++,"@138g/@139g%-10s",(const char*) tel);
 | |
|   }
 | |
|   return r;
 | |
| }
 | |
| 
 | |
| 
 | |
| // Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto
 | |
| // ricerca i corrispondenti su PCON, con relativa IV direttiva CEE
 | |
| 
 | |
| void TMastrini_application::ricerca_classe_IV(bool scelta)
 | |
| {
 | |
| 	TString16 key;
 | |
|   
 | |
| 	if (scelta)
 | |
|     key.format("%d|%d|%ld", _gruppo, _conto, _sottoc);
 | |
| 	else
 | |
|     key.format("%d|%d|", _gruppo, _conto);
 | |
| 
 | |
|   const TRectype & pconti = cache().get(LF_PCON, key);
 | |
|   _sezivd  = pconti.get_char(PCN_SEZIVD);
 | |
|   _lettivd = pconti.get_char(PCN_LETTIVD);
 | |
|   _numrivd_int  = pconti.get_int (PCN_NUMRIVD); 
 | |
|   _numrivd = itor(_numrivd_int);
 | |
|   _numivd  = pconti.get(PCN_NUMIVD);
 | |
| }
 | |
|  
 | |
| void TMastrini_application::ricerca_gruppo()
 | |
| { 
 | |
|   TString80 descr,descriz,descriz2,dep;
 | |
|   TString dataini,datafine;
 | |
|                            
 | |
|   ricerca_classe_IV (TRUE);    //Esiste a livello di sottoconto
 | |
|   
 | |
|   if (_sezivd == '0')           //Non esiste a livello di sottoconto
 | |
|     ricerca_classe_IV (FALSE);  //Allora la cerco a livello di conto
 | |
|                              
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd);
 | |
|   if (_numivd.not_empty())      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd.not_empty())   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,"");
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd.not_empty())
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");   
 | |
|     else
 | |
|       descriz2 = "";
 | |
| 
 | |
|   set_header(3,"@27g%-.30s",(const char*) descrizione_gruppo());
 | |
|   set_header(3,"@59g%-.30s",(const char*) descrizione_conto());
 | |
| 
 | |
|   set_header(3,"@91g%-.41s",(const char*) descrizione_sottoconto());
 | |
|   if (_nummast == 3)
 | |
|     set_header (4, "@0g@r%s@12g@b%c", TR("Classe"), _lettivd);
 | |
|   else
 | |
|     set_header (4, "@0g%s@12g%c", TR("Classe"), _lettivd);
 | |
|   set_header (4, "@14g%-8s",(const char*) _numrivd); 
 | |
|   if (_numivd.not_empty())
 | |
|     set_header (4, "@23g%s", num2str(_numivd)); 
 | |
|   if (descriz2.not_empty())
 | |
|   {
 | |
|     set_header (4,"@34g%-48s",(const char*) descriz2);
 | |
|     set_header (4,"@82g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_header (4,"@34g%-50s",(const char*) descriz);
 | |
|   
 | |
|   dataini = _data_ini.string();
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   { 
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@r%s@12g@b%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_header (5, "@24g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "%s@12g%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_header (5, "@24g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                             
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@r%s@23g@b%s", TR("Periodo di competenza"), (const char*) dataini);
 | |
|       set_header (5, "@35g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "%s@23g%s", TR("Periodo di competenza"), (const char*) dataini);
 | |
|       set_header (5, "@35g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| int TMastrini_application::ricerca_gruppo(int start)
 | |
| { 
 | |
|   TString80 descr,descriz,descriz2,dep;
 | |
|   TString dataini,datafine;
 | |
|   int   r = start;
 | |
|                            
 | |
|   ricerca_classe_IV (TRUE);    //Esiste a livello di sottoconto
 | |
|   
 | |
|   if (_sezivd == '0')           //Non esiste a livello di sottoconto
 | |
|     ricerca_classe_IV (FALSE);  //Allora la cerco a livello di conto
 | |
|                              
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd);
 | |
|   if (_numivd.not_empty())      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd.not_empty())   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,"");
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd.not_empty())
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,"");   
 | |
|     else
 | |
|       descriz2 = "";
 | |
| 
 | |
|   set_row(r,"@27g%-.30s",(const char*) descrizione_gruppo());
 | |
|   set_row(r,"@59g%-.30s",(const char*) descrizione_conto());
 | |
| 
 | |
|   set_row(r++,"@91g%-.41s",(const char*) descrizione_sottoconto());
 | |
|   if (_nummast == 3)
 | |
|     set_row(r, "@0g@r%s@12g@b%c", TR("Classe"), _lettivd);
 | |
|   else
 | |
|     set_row(r, "@0g%s@12g%c", TR("Classe"), _lettivd);
 | |
|   set_row(r, "@14g%-8s",(const char*) _numrivd); 
 | |
|   if (_numivd.not_empty())
 | |
|     set_row(r, "@23g%-4s", num2str(_numivd)); 
 | |
|   if (descriz2 != "")
 | |
|   {
 | |
|     set_row(r,"@34g%-48s",(const char*) descriz2);
 | |
|     set_row(r++,"@82g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_row(r++,"@34g%-50s",(const char*) descriz);
 | |
|   
 | |
|   dataini = _data_ini.string();
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                              
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@r%s@12g@b%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_row (r, "@24g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "%s@12g%s", TR("Periodo"), (const char*) dataini);
 | |
|       set_row (r, "@24g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                        
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@r%s@23g@b%s", TR("Periodo di competenza"), (const char*) dataini);
 | |
|       set_row (r, "@35g%s@r", (const char*) datafine);    
 | |
| 
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "%s@23g%s", TR("Periodo di competenza"), (const char*) dataini);
 | |
|       set_row (r, "@35g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   return r;
 | |
| }
 | |
| 
 | |
| const char* TMastrini_application::descrizione_classe(char sezione, char lettera, int numr, const char * numero)
 | |
| {
 | |
|   TString16 key;
 | |
| 
 | |
|   if (numr == 0 && numero == 0)
 | |
|     key.format("%c%c",sezione,lettera);
 | |
|   else                        
 | |
|     if (numero == 0)
 | |
| 	    key.format("%c%c%04d",sezione, lettera, numr);
 | |
|     else                                         
 | |
|     {
 | |
|       if (numr != 0)
 | |
|         key.format("%c%c%04d%-4s",sezione, lettera, numr,numero);
 | |
|       else
 | |
|         key.format("%c%c    %-4s",sezione,lettera,numero);
 | |
|     }
 | |
|        
 | |
|   return cache().get("%IVD", key, "S0");
 | |
| }     
 | |
| 
 | |
| //Ricerca la descrizione relativa al gruppo da stampare
 | |
| 
 | |
| const char* TMastrini_application::descrizione_gruppo()
 | |
| {  
 | |
| //	TString16 key;
 | |
| //	key.format("%d", _gruppo);
 | |
| //  return cache().get(LF_PCON, key, PCN_DESCR);
 | |
|   return cache().get(LF_PCON, _gruppo, PCN_DESCR);
 | |
| }
 | |
| 
 | |
| // Ricerca la descrizione relativa al conto da stampare
 | |
| 
 | |
| const char* TMastrini_application::descrizione_conto()
 | |
| { 
 | |
| 	TString8 key;
 | |
| 	key.format("%d|%d", _gruppo, _conto);
 | |
| 
 | |
|   return cache().get(LF_PCON, key, PCN_DESCR);
 | |
| }
 | |
| 
 | |
| const char* TMastrini_application::descrizione_sottoconto()
 | |
| { 
 | |
| 	TString16 key;
 | |
| 	key.format("%d|%d|%ld", _gruppo, _conto, _sottoc);
 | |
| 
 | |
|   return cache().get(LF_PCON, key, PCN_DESCR);
 | |
| }
 | |
| 
 | |
| // Funzione per settare tutti gli handlers della maschera principale
 | |
| // o di quella dello spreadsheet della seconda pagina
 | |
| void TMastrini_application::set_handlers(TMask* msk) const
 | |
| {
 | |
|   msk->set_handler(F_DATAINI,            data_inizio);
 | |
|   msk->set_handler(F_DATAFINE,           data_fine);
 | |
|   msk->set_handler(F_GRUPPOFINE,         gruppo_hnd);
 | |
|   msk->set_handler(F_CONTOINI_CONTO,     contoi_hnd);
 | |
|   msk->set_handler(F_CONTOFINE_CONTO,    contof_hnd);
 | |
| 
 | |
|   msk->set_handler(F_SOTTOCINI_CONTO,    sottoc_handler_ini);
 | |
|   msk->set_handler(F_SOTTOCINI_CLIENTE,  sottoc_handler_ini);
 | |
|   msk->set_handler(F_SOTTOCINI_FORN,     sottoc_handler_ini);
 | |
|   msk->set_handler(F_SOTTOCFINE_CONTO,   sottoc_handler_fine);
 | |
|   msk->set_handler(F_SOTTOCFINE_CLIENTE, sottoc_handler_fine);
 | |
|   msk->set_handler(F_SOTTOCFINE_FORN,    sottoc_handler_fine);
 | |
| }
 | |
| 
 | |
| // Copia i parametri della prima pagina in una nuova riga dello spreadsheet
 | |
| // a meno che non ci siano gia'
 | |
| bool TMastrini_application::mask2sheet()
 | |
| { 
 | |
|   bool ok = _msk->check_fields();
 | |
|   
 | |
|   if (ok)
 | |
|   {
 | |
|     TToken_string row(120);
 | |
|     short id = F_ANNO;
 | |
|     for (int pos = _msk->id2pos(id); pos >= 0; pos = _msk->id2pos(++id))
 | |
|       row.add(_msk->fld(pos).get());
 | |
|     
 | |
|     if (!row.empty_items())
 | |
|     {
 | |
|       TSheet_field& sht = _msk->sfield(F_SCELTE);
 | |
|       TString_array& rows = sht.rows_array();
 | |
|       ok = rows.find(row) < 0; // Aggiunge solo se non c'e' gia'
 | |
|       if (ok)              
 | |
|       {
 | |
|         rows.add(row);
 | |
|         sht.force_update();
 | |
|       }  
 | |
|     }
 | |
|   }
 | |
|   
 | |
|   return ok;  
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::sheet2mask()
 | |
| { 
 | |
|   TSheet_field& sht = _msk->sfield(F_SCELTE);
 | |
|   bool ok = sht.items() > 0;
 | |
|   if (ok)
 | |
|   {
 | |
|     TString_array& rows = sht.rows_array();
 | |
|     TToken_string& row = rows.row(0);
 | |
| 
 | |
|     short id = F_ANNO;
 | |
|     FOR_EACH_TOKEN(row, val)
 | |
|     {
 | |
|       // Scarta i listbox perche' azzerano i conti!
 | |
|       if (id != F_TIPOCF_INI && id != F_TIPOCF_FINE)
 | |
|         _msk->set(id, val);
 | |
|       id++;  
 | |
|     }
 | |
| 
 | |
|     rows.destroy(0, TRUE);
 | |
|   }
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::user_create()
 | |
| {
 | |
|   TToken_string exp;
 | |
| 
 | |
|   _rel = new TRelation(LF_SALDI);
 | |
|   _rel->lfile().set_curr(new TMastrini_record);
 | |
| 
 | |
|   exp.add("GRUPPO=GRUPPO");
 | |
|   exp.add("CONTO=CONTO");
 | |
|   exp.add("SOTTOCONTO=SOTTOCONTO");
 | |
|   _rel->add(LF_RMOV,exp,2,LF_SALDI);
 | |
|   
 | |
|   _rel->add("CMS", "CODTAB==CODCMS", 1, LF_RMOV, 501);
 | |
|   _rel->add("FSC", "CODTAB==FASCMS", 1, LF_RMOV, 502);
 | |
| 
 | |
|   _cur1=add_cursor(new TCursor(_rel,"FLSCA=\" \"",2)); 
 | |
|   open_files(LF_TAB, LF_TABCOM,LF_NDITTE, LF_UNLOC, LF_COMUNI, LF_MOV,
 | |
| 						 LF_CLIFO, LF_CAUSALI, 0);
 | |
|   _cur2=add_cursor(new TSorted_cursor(_rel,"DESCR","FLSCA=\" \"",2)); 
 | |
|   
 | |
|   _tabivd = new TTable (TAB_IVD);
 | |
|   _tabtpd = new TTable (TAB_TPD);
 | |
|   _tabreg = new TTable (TAB_REG);
 | |
|   _sld    = new TSaldo ();
 | |
|   
 | |
|   _d18   = new TParagraph_string ("",18);
 | |
|   _d22   = new TParagraph_string ("",22);
 | |
|   _d30   = new TParagraph_string ("",30);
 | |
|   
 | |
|   _msk = new TMask("cg3200a");     
 | |
|   set_handlers(_msk);
 | |
|   _msk->set_handler(F_MEMORIZZA, memorizza_handler);
 | |
|   
 | |
|   TSheet_field& sht = _msk->sfield(F_SCELTE);
 | |
|   sht.set_notify(scelte_notify);
 | |
|   TMask& sm = sht.sheet_mask();
 | |
|   set_handlers(&sm);
 | |
|     
 | |
|   _gia_stampata_intestazione = FALSE;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::user_destroy()
 | |
| {
 | |
|   delete _msk;
 | |
|   delete _rel;
 | |
|   delete _tabivd;
 | |
|   delete _tabtpd;
 | |
|   delete _tabreg;
 | |
|   delete _sld;
 | |
|   delete _d18;
 | |
|   delete _d22;
 | |
|   delete _d30;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int cg3200(int argc, char* argv[])
 | |
| {
 | |
|   TMastrini_application a;
 | |
|   a.run(argc, argv, TR("Stampa Mastrini"));
 | |
|   return 0;
 | |
| }
 |