Il MI3561 e' corretto in printer.cpp cg3200a.uml Corretto MI3555 sulle ricerche su LF_PICONE git-svn-id: svn://10.65.10.50/trunk@5594 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			3986 lines
		
	
	
		
			115 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3986 lines
		
	
	
		
			115 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <execp.h>
 | |
| #include <mailbox.h>
 | |
| #include <msksheet.h>
 | |
| #include <printapp.h>
 | |
| #include <tabutil.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>
 | |
| 
 | |
| #include "cg3.h"
 | |
| #include "cg3200.h"
 | |
| #include "cglib02.h"
 | |
| #include "cglib03.h"
 | |
| 
 | |
| 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;
 | |
|   TLocalisamfile*    _mov;
 | |
|   TLocalisamfile*    _nditte;
 | |
|   TLocalisamfile*    _unloc;
 | |
|   TLocalisamfile*    _comuni;
 | |
|   TLocalisamfile*    _clifo;
 | |
|   TLocalisamfile*    _caus;
 | |
|   TSaldo*            _sld;
 | |
|   TParagraph_string* _d18,* _d23,* _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,_gruppo,_conto,_numcarat,_stampanum,_numivd,_annoiva;
 | |
|   int _numrig,_natdoc,_tipo,_tipostampa,_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;
 | |
|   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;
 | |
|   bool _stampato,_devi_stampare_footer;
 | |
|  
 | |
|   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,_saldo_progressivi_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 void process_link(int id, const char* txt);
 | |
|       
 | |
|   void set_handlers(TMask* msk) const;
 | |
|   bool mask2sheet();
 | |
|   bool sheet2mask();
 | |
| 
 | |
| public:
 | |
|   //TDate _inizioEs,_fineEs;
 | |
|   
 | |
|   int  date2esc(const TDate& d);   
 | |
|   void ricerca_clifo();
 | |
|   void ricerca_gruppo();
 | |
|   int  ricerca_clifo(int riga);
 | |
|   int  ricerca_gruppo(int riga);
 | |
| 
 | |
|   void calcola_progressivi();
 | |
|   void calcola_progressivi_al(); 
 | |
|   void stampa_progressivi();
 | |
|   int  stampa_progressivi(int start_riga);
 | |
|   void stampa_progre_riporto();
 | |
|   int  stampa_progre_riporto(int start_riga);
 | |
|   void documenti_iva();
 | |
|   void ricerca_regiva();
 | |
|   void descrizione_causale();
 | |
|   void saldi_zero();
 | |
|   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,int);
 | |
|   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, 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;
 | |
| } 
 | |
| 
 | |
| void TMastrini_application::process_link(int id, const char* txt)
 | |
| {                                         
 | |
|   const char* const app = "cg2 -0";
 | |
|   TToken_string ss(10);
 | |
|   ss.add("1");
 | |
|   ss.add(txt);
 | |
|   
 | |
|   TMessage fs(cmd2name(app), MSG_LN, ss);
 | |
|   fs.send();             
 | |
| 
 | |
|   TExternal_app pn(app);
 | |
|   pn.run();
 | |
| } 
 | |
| 
 | |
| bool TMastrini_application::sottoc_handler_ini(TMask_field& f, KEY key)
 | |
| {
 | |
|   const short id  = f.dlg();  
 | |
|   bool warning = FALSE;
 | |
|                                   
 | |
|   const int  gruppo = f.mask().get_int(F_GRUPPOINI);
 | |
|                                     
 | |
|   int  conto;
 | |
|   if (id == F_SOTTOCINI_CONTO)
 | |
|     conto  = f.mask().get_int(F_CONTOINI_CONTO); 
 | |
|   else
 | |
|     if (id == F_SOTTOCINI_CLIENTE)
 | |
|       conto = f.mask().get_int(F_CONTOINI_CLIENTE);
 | |
|     else
 | |
|       if (id == F_SOTTOCINI_FORN)
 | |
|         conto = f.mask().get_int(F_CONTOINI_FORN);     
 | |
| 
 | |
|   const long sottoconto = f.mask().get_long(id);
 | |
|   
 | |
|   if ( key == K_ENTER )
 | |
|   {
 | |
|     if (sottoconto != 0 && conto == 0) 
 | |
|       return f.warning_box("Manca il CONTO");
 | |
| 
 | |
|     if (conto != 0 && gruppo == 0)
 | |
|       return f.warning_box("Manca il GRUPPO");
 | |
|   }
 | |
|                     
 | |
|   if (key == K_TAB && f.mask().is_running())
 | |
|   {
 | |
|     TString ds;
 | |
|     if (id == F_SOTTOCINI_CONTO && (gruppo != 0 || conto != 0 || sottoconto != 0L))
 | |
|     {
 | |
|       TLocalisamfile pconti(LF_PCON);
 | |
|       pconti.zero();
 | |
|       pconti.put(PCN_GRUPPO, gruppo) ;
 | |
|       pconti.put(PCN_CONTO, conto);
 | |
|       pconti.put(PCN_SOTTOCONTO, sottoconto);
 | |
|       pconti.setkey(1);
 | |
|       pconti.read(_isequal, _nolock);
 | |
|       if (pconti.good())
 | |
|       {
 | |
|         ds = pconti.get(PCN_DESCR);
 | |
|         warning = FALSE;
 | |
|       }
 | |
|       else    
 | |
|       {
 | |
|         ds = "";
 | |
|         warning = TRUE;
 | |
|       }
 | |
|       
 | |
|       f.mask().set(F_DESCRINI_CONTO,   ds);
 | |
|       f.mask().set(F_DESCRINI_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRINI_FORN,    ds);              
 | |
|       
 | |
|       if (warning)
 | |
|         return f.warning_box("Sottoconto inesistente");
 | |
|     }
 | |
|     else
 | |
|       if (id == F_SOTTOCINI_CLIENTE || id == F_SOTTOCINI_FORN) 
 | |
|       {
 | |
|         TString rs;
 | |
|         char tipo = id == F_SOTTOCINI_CLIENTE ? 'C' : 'F';
 | |
|         TLocalisamfile clifo (LF_CLIFO);       
 | |
|         if (sottoconto != 0)
 | |
|         {
 | |
|           clifo.zero();
 | |
|           clifo.put(CLI_TIPOCF,tipo); 
 | |
|           clifo.put(CLI_CODCF, sottoconto) ;
 | |
|           clifo.setkey(1);
 | |
|           if (clifo.read(_isequal, _nolock) == NOERR)  
 | |
|           {
 | |
|             rs = clifo.get(CLI_RAGSOC);
 | |
|             warning = FALSE;
 | |
|           }
 | |
|           else
 | |
|           {
 | |
|             rs = "";
 | |
|             warning = TRUE;
 | |
|           }
 | |
|         
 | |
|           f.mask().set(F_DESCRINI_CLIENTE, rs);
 | |
|           f.mask().set(F_DESCRINI_FORN, rs);
 | |
|         
 | |
|           if (warning)
 | |
|             return f.warning_box("Anagrafica inesistente");
 | |
|         }
 | |
|       }
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::sottoc_handler_fine(TMask_field& f, KEY key)
 | |
| {
 | |
|   const short id  = f.dlg();                    
 | |
|   int  conto;
 | |
|   TString    ds;
 | |
|   TString80  rs;                                      
 | |
|   bool       warning;
 | |
|   
 | |
|   const int  gruppo = f.mask().get_int(F_GRUPPOFINE);
 | |
| 
 | |
|   if (id == F_SOTTOCFINE_CONTO)
 | |
|     conto  = f.mask().get_int(F_CONTOFINE_CONTO); 
 | |
|   else
 | |
|     if (id == F_SOTTOCFINE_CLIENTE)
 | |
|       conto = f.mask().get_int(F_CONTOFINE_CLIENTE);
 | |
|     else
 | |
|       if (id == F_SOTTOCFINE_FORN)
 | |
|         conto = f.mask().get_int(F_CONTOFINE_FORN);   
 | |
| 
 | |
|   const long sottoconto = f.mask().get_long(id);          
 | |
| 
 | |
|   if ( key == K_ENTER )
 | |
|   {
 | |
|     if (sottoconto != 0 && conto == 0) 
 | |
|       return f.warning_box("Manca il CONTO");
 | |
| 
 | |
|     if (conto != 0 && gruppo == 0)
 | |
|       return f.warning_box("Manca il GRUPPO");
 | |
|       
 | |
|     if (!app().check_ordine(f,key))
 | |
|       return FALSE;  
 | |
|   }    
 | |
| 
 | |
|   if ( key == K_TAB && f.mask().is_running())
 | |
|   {
 | |
|     if (id == F_SOTTOCFINE_CONTO && (gruppo != 0 || conto != 0 || sottoconto != 0L))
 | |
|     {
 | |
|       TLocalisamfile pconti (LF_PCON);
 | |
|       pconti.zero();
 | |
|       pconti.put(PCN_GRUPPO, gruppo) ;
 | |
|       pconti.put(PCN_CONTO, conto);
 | |
|       pconti.put(PCN_SOTTOCONTO, sottoconto);
 | |
|       pconti.setkey(1);
 | |
|       pconti.read(_isequal, _nolock);
 | |
|       if (pconti.good())
 | |
|       {
 | |
|         ds = pconti.get(PCN_DESCR);
 | |
|         warning = FALSE;
 | |
|       }
 | |
|       else 
 | |
|       {
 | |
|         ds = "";
 | |
|         warning = TRUE;
 | |
|       }
 | |
|         
 | |
|       f.mask().set(F_DESCRFINE_CONTO,   ds);
 | |
|       f.mask().set(F_DESCRFINE_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRFINE_FORN,    ds);
 | |
|       
 | |
|       if (warning)
 | |
|         return f.warning_box("Sottoconto inesistente");
 | |
|     }
 | |
|     else
 | |
|       if (id == F_SOTTOCFINE_CLIENTE || id == F_SOTTOCFINE_FORN) 
 | |
|       {
 | |
|         char tipo = id == F_SOTTOCFINE_CLIENTE ? 'C' : 'F';
 | |
|         TLocalisamfile clifo (LF_CLIFO);       
 | |
|         if (sottoconto != 0)
 | |
|         {
 | |
|           clifo.zero();
 | |
|           clifo.put(CLI_TIPOCF,tipo); 
 | |
|           clifo.put(CLI_CODCF, sottoconto) ;
 | |
|           clifo.setkey(1);
 | |
|           if (clifo.read(_isequal, _nolock) == NOERR)    
 | |
|           {
 | |
|             rs = clifo.get(CLI_RAGSOC);
 | |
|             warning = FALSE;
 | |
|           }
 | |
|           else 
 | |
|           {
 | |
|             rs = "";
 | |
|             warning = TRUE;
 | |
|           }
 | |
|           
 | |
|           f.mask().set(F_DESCRFINE_CLIENTE, rs);
 | |
|           f.mask().set(F_DESCRFINE_FORN,    rs);
 | |
|         
 | |
|           if (warning)
 | |
|             return f.warning_box("Anagrafica inesistente");
 | |
|         }
 | |
|       }
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::gruppo_hnd (TMask_field& f, KEY k)
 | |
| {  
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     int gruppof = f.mask().get_int(F_GRUPPOFINE);
 | |
|     
 | |
|     if (gruppof == 0)
 | |
|       return TRUE;
 | |
|       
 | |
|     int gruppoi = f.mask().get_int(F_GRUPPOINI);
 | |
|     
 | |
|     if (gruppoi > gruppof)
 | |
|       return f.error_box("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())
 | |
|   { 
 | |
|     TMask& m = f.mask();
 | |
|     TLocalisamfile pconti (LF_PCON);
 | |
|     TString ds;                 
 | |
|     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 && m.field(F_DESCRINI_CONTO).empty())
 | |
|     {    
 | |
|       bool warning;       
 | |
|       
 | |
|       char tipomsk = m.get(F_TIPOCF_INI)[0];
 | |
|         
 | |
|       pconti.zero();
 | |
|       pconti.put(PCN_GRUPPO, gruppo) ;
 | |
|       pconti.put(PCN_CONTO,  conto);
 | |
|       pconti.setkey(1);
 | |
|       pconti.read(_isequal, _nolock);
 | |
|       if (pconti.good())
 | |
|       {                          
 | |
|         char tipo = pconti.get_char(PCN_TMCF);
 | |
|         if (tipomsk != tipo)
 | |
|           return f.warning_box("Conto inesistente");
 | |
|           
 | |
|         ds = pconti.get(PCN_DESCR);
 | |
|         warning = FALSE;
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         ds = "";        
 | |
|         warning = TRUE;
 | |
|       }
 | |
|             
 | |
|       m.set(F_DESCRINI_CLIENTE, ds);
 | |
|       m.set(F_DESCRINI_FORN, ds);
 | |
|       m.set(F_DESCRINI_CONTO, ds);  
 | |
|           
 | |
|       if (warning)
 | |
|         return f.warning_box("Conto inesistente");
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       ds = "";
 | |
|       m.set(F_DESCRINI_CLIENTE, ds);
 | |
|       m.set(F_DESCRINI_FORN, ds);
 | |
|       m.set(F_DESCRINI_CONTO, ds);  
 | |
|     }  
 | |
|   }  
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::contof_hnd (TMask_field& f, KEY k)
 | |
| {
 | |
|   const short id  = f.dlg();  
 | |
|    
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     int gruppof = f.mask().get_int(F_GRUPPOFINE);
 | |
|     
 | |
|     if (gruppof == 0)
 | |
|       return TRUE;
 | |
|       
 | |
|     int gruppoi = f.mask().get_int(F_GRUPPOINI);
 | |
|     
 | |
|     if (gruppoi < gruppof)
 | |
|       return TRUE;
 | |
|       
 | |
|     int contof = f.mask().get_int(id);
 | |
|     int contoi; 
 | |
|     
 | |
|     char tipo = f.mask().get(F_TIPOCF_INI)[0];
 | |
|     
 | |
|     if (tipo == '\0')
 | |
|       contoi = f.mask().get_int(F_CONTOINI_CONTO);
 | |
|     else
 | |
|       if (tipo == 'C')
 | |
|         contoi = f.mask().get_int(F_CONTOINI_CLIENTE);
 | |
|       else
 | |
|         if (tipo == 'F')
 | |
|           contoi = f.mask().get_int(F_CONTOINI_FORN);
 | |
|     
 | |
|       
 | |
|     if (contoi > contof)
 | |
|       return f.error_box("Il conto di partenza deve essere inferiore o uguale al conto di arrivo");
 | |
|   }
 | |
|   
 | |
|   if (k == K_TAB && f.focusdirty() && f.mask().is_running())
 | |
|   {  
 | |
|     TLocalisamfile pconti (LF_PCON);
 | |
|     TString ds;                       
 | |
|     int gruppo = f.mask().get_int(F_GRUPPOFINE);
 | |
|     int conto  = f.mask().get_int(id);
 | |
|     if (gruppo != 0 && conto != 0 && f.mask().field(F_DESCRFINE_CONTO).empty())
 | |
|     {    
 | |
|       bool warning;
 | |
|       
 | |
|       char tipomsk = f.mask().get(F_TIPOCF_FINE)[0];        
 | |
|       
 | |
|       pconti.zero();
 | |
|       pconti.put(PCN_GRUPPO, gruppo) ;
 | |
|       pconti.put(PCN_CONTO,  conto);
 | |
|       pconti.setkey(1);
 | |
|       pconti.read(_isequal, _nolock);
 | |
|       if (pconti.good())
 | |
|       {           
 | |
|         char tipo = pconti.get_char(PCN_TMCF);
 | |
|         if (tipomsk != tipo)
 | |
|           return f.warning_box("Conto inesistente");
 | |
|           
 | |
|         ds = pconti.get(PCN_DESCR);
 | |
|         warning = FALSE;
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         ds = "";        
 | |
|         warning = TRUE;
 | |
|       }
 | |
|             
 | |
|       f.mask().set(F_DESCRFINE_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRFINE_FORN, ds);
 | |
|       f.mask().set(F_DESCRFINE_CONTO, ds);  
 | |
|           
 | |
|       if (warning)
 | |
|         return f.warning_box("Conto inesistente");
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       ds = "";
 | |
|       f.mask().set(F_DESCRFINE_CLIENTE, ds);
 | |
|       f.mask().set(F_DESCRFINE_FORN, ds);
 | |
|       f.mask().set(F_DESCRFINE_CONTO, ds);  
 | |
|     }  
 | |
| 
 | |
|   }  
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::check_ordine(TMask_field& f, KEY k)
 | |
| {
 | |
|   const int gruppof = f.mask().get_int(F_GRUPPOFINE);
 | |
|     
 | |
|   if (gruppof == 0)
 | |
|     return TRUE;
 | |
|       
 | |
|   const int gruppoi = f.mask().get_int(F_GRUPPOINI);
 | |
|     
 | |
|   if (gruppoi < gruppof)
 | |
|     return TRUE;
 | |
|     
 | |
|   int contof = f.mask().get_int(F_CONTOFINE_CONTO);
 | |
|   int contoi = f.mask().get_int(F_CONTOINI_CONTO);
 | |
|     
 | |
|   if (contoi < contof)
 | |
|     return TRUE;
 | |
|     
 | |
|   long sottocf = f.mask().get_long(F_SOTTOCFINE_CONTO);
 | |
|   long sottoci = f.mask().get_long(F_SOTTOCINI_CONTO);
 | |
|         
 | |
|   if (sottoci > sottocf)
 | |
|     return f.error_box("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)
 | |
|     return 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;
 | |
|   long  record,sottoc;
 | |
|   int   gruppo,conto;
 | |
|   TDate datareg, datacomp;
 | |
|   TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | |
|  
 | |
|   if (current_cursor()->is_first_match(LF_RMOV))
 | |
|   {
 | |
|     record = rmov.recno();
 | |
|     rmov.zero();
 | |
|     rmov.put(RMV_GRUPPO,     _gruppo);
 | |
|     rmov.put(RMV_CONTO,      _conto);
 | |
|     rmov.put(RMV_SOTTOCONTO, _sottoc);
 | |
|     for (rmov.read(); !rmov.eof() ;rmov.next())
 | |
|     {
 | |
|       int  annoes = rmov.get_int (RMV_ANNOES);
 | |
|       long numreg = rmov.get_long(RMV_NUMREG);
 | |
| 
 | |
|       _mov->setkey(1);
 | |
|       _mov->curr().zero();
 | |
|       _mov->curr().put(MOV_NUMREG,numreg);
 | |
|       _mov->read();
 | |
|       if (_mov->bad())
 | |
|         _mov->zero();
 | |
|       datacomp = (_mov->curr().get(MOV_DATACOMP));
 | |
|       TString provvis (_mov->curr().get(MOV_PROVVIS));
 | |
|         
 | |
|       if (_annomsk == 0)
 | |
|         datareg = rmov.get_date(RMV_DATAREG);
 | |
|       else
 | |
|         datareg = datacomp;
 | |
| 
 | |
|       gruppo = rmov.get_int(RMV_GRUPPO);
 | |
|       conto = rmov.get_int(RMV_CONTO);
 | |
|       sottoc = rmov.get_long(RMV_SOTTOCONTO);
 | |
|       if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc))
 | |
|         break;
 | |
|       else
 | |
|         if ( ((annoes==_annomsk) || (_annomsk==0)) && ((datareg>=_data_ini) && (datareg<=_data_fine)) && (_stampa_mov_prov || provvis.trim().empty()))
 | |
|         {
 | |
|           trovato = TRUE;
 | |
|           break;
 | |
|         }
 | |
|     }
 | |
|     rmov.readat(record);
 | |
|   }
 | |
|   return trovato;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::data_inizio(TMask_field& f, KEY k)
 | |
| {
 | |
|   const TDate data = f.mask().get    (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("La data non appartiene all'esercizio indicato");
 | |
|               return FALSE;
 | |
|         }
 | |
|         else
 | |
|           app()._data_ini = data;
 | |
|       }    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       if (data == botime)
 | |
|         return f.error_box("La data deve essere obbligatoriamente indicata");
 | |
| 
 | |
|       if (app().date2esc(data) == 0)
 | |
|         return f.error_box("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)
 | |
| {
 | |
|   int   annoes;
 | |
|   TDate data, data_ini;
 | |
| 
 | |
|   annoes   = f.mask().get_int(F_ANNO);
 | |
|   data     = f.mask().get    (F_DATAFINE);
 | |
|   data_ini = f.mask().get    (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("La data non appartiene all'esercizio indicato");
 | |
|           return FALSE;
 | |
|         }
 | |
|         else
 | |
|           app()._data_fine = data;
 | |
|       }
 | |
|     }
 | |
|     else
 | |
|       {
 | |
|         if (data == botime)
 | |
|           return f.error_box("La data deve essere obbligatoriamente indicata");
 | |
| 
 | |
|         app()._anno_ghost = app().date2esc(data_ini); 
 | |
|         
 | |
|         if (app()._anno_ghost == 0)
 | |
|           return f.error_box("La data indicata non appartiene ad alcun esercizio");
 | |
|         //app()._inizioes = app()._inizioEs;
 | |
| 
 | |
|         //if (data < app()._inizioEs || data > app()._fineEs)
 | |
|         //{
 | |
|         //  f.error_box("La data non appartiene all'esercizio indicato");
 | |
|         //  return FALSE;
 | |
|         //}
 | |
|         //else
 | |
|         app()._data_fine = data;
 | |
|       }
 | |
| 
 | |
|     if (data < data_ini)
 | |
|     {
 | |
|       f.error_box("La data finale non puo' essere inferiore alla data di partenza");
 | |
|       return FALSE;
 | |
|     }
 | |
| 
 | |
|     
 | |
|   } 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TMastrini_application::saldi_zero()
 | |
| {
 | |
|   TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | |
|   real saldo_dare, saldo_avere;
 | |
|   long record;
 | |
| 
 | |
|   saldo_dare = saldo_avere = 0.0;
 | |
| 
 | |
|   if (current_cursor()->is_first_match(LF_RMOV))
 | |
|   {
 | |
|     record = rmov.recno();
 | |
|   
 | |
|     while (!rmov.eof())
 | |
|     {
 | |
|       long numreg = rmov.get_long(RMV_NUMREG);
 | |
|       _mov->setkey(1);
 | |
|       _mov->curr().zero();
 | |
|       _mov->curr().put(MOV_NUMREG,numreg);
 | |
|       _mov->read();
 | |
|       if (_mov->bad())
 | |
|         _mov->zero();
 | |
|       char provvis = _mov->curr().get_char(MOV_PROVVIS);
 | |
|       int gruppo = atoi(rmov.get(RMV_GRUPPO));
 | |
|       int conto = atoi(rmov.get(RMV_CONTO));
 | |
|       long sottoc = atol(rmov.get(RMV_SOTTOCONTO));
 | |
| 
 | |
|       if ((gruppo == _gruppo)&&(conto == _conto)&&(sottoc == _sottoc)) 
 | |
|       {
 | |
|         if (_stampa_mov_prov || provvis <= ' ')
 | |
|         {
 | |
|           char sezione = rmov.curr().get(RMV_SEZIONE)[0];
 | |
|           real importo = rmov.curr().get_real(RMV_IMPORTO);
 | |
|           if (sezione == 'D')
 | |
|             saldo_dare += importo;
 | |
|           else
 | |
|             saldo_avere += importo;
 | |
|         }                 
 | |
|       }
 | |
|       else break;
 | |
|       rmov.next();
 | |
|     }
 | |
|     rmov.readat(record);
 | |
|   }
 | |
|   _totale_saldo = saldo_dare - saldo_avere;
 | |
| }
 | |
| 
 | |
| 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$[r]#7d$[n]", &_numreg);
 | |
|   else
 | |
|     if (_stampanum == 2)
 | |
|     {
 | |
|       set_row (_rw,"@11g#7d", &_numgio);
 | |
|     }            
 | |
|     
 | |
|   set_row (_rw,"@19g#t", &_datadocs);
 | |
|   set_row (_rw,"@30g#7t", &_numdoc);
 | |
|   set_row (_rw,"@38g#3t", &_codcaus);
 | |
| 
 | |
|   set_row (_rw,"@117g#3t #3t #6t", &_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$[r]#7d$[n]", &_numreg);
 | |
|     set_row (_rw,"@18g/#3d", &_numrig);
 | |
|   }
 | |
|   else if (_stampanum == 2)
 | |
|      set_row (_rw,"@11g#7d", &_numgio);
 | |
|      
 | |
|   set_row (_rw,"@23g#t", &_datadocs);
 | |
|   set_row (_rw,"@34g#7t", &_numdoc);
 | |
|   set_row (_rw,"@42g#3t", &_codcaus);
 | |
| 
 | |
| // Stampa saldo movimenti
 | |
| 
 | |
|   set_row (_rw,"@151g#t", &_saldo_movimenti_str);
 | |
|   set_row (_rw,"@168g#3t #3t #6t", &_g_contr, &_c_contr, &_s_contr);
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_totali132()
 | |
| {
 | |
|   TString sep(132);
 | |
| 
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 2;
 | |
|       
 | |
|   sep.fill('-');                            //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,"@32gTOTALI 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,"@32gTOTALI 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,"@32gTOTALI PROGRESSIVI AL %s", _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;
 | |
| }
 | |
| 
 | |
| 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("@32gTOTALI PERIODO@66g%s@83g%s@100g%s");
 | |
|   r.add(_saldo_periodo.string(_real_picture));     
 | |
|   r.add(_totale_periodo_dare.string(_real_picture));
 | |
|   r.add(_totale_periodo_avere.string(_real_picture));
 | |
|   _lista.add(r);  
 | |
|   r = "";
 | |
| 
 | |
|   r.add("@32gTOTALI PROGRESSIVI@66g%s@83g%s@100g%s");
 | |
|   r.add(_saldo_progre.string(_real_picture));       
 | |
|   r.add(_totprogre_dare.string(_real_picture));
 | |
|   r.add(_totprogre_avere.string(_real_picture));
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
|   
 | |
|   if (_stampaprogre)                         //Progressivi attuali
 | |
|   {
 | |
|     r.add("@32gTOTALI PROGRESSIVI AL@55g%s@66g%s@83g%s@100g%s");
 | |
|     r.add(_ultima_data_reg.string());
 | |
|     r.add(_saldo_progre_al.string(_real_picture));
 | |
|     r.add(_totprogre_dare_al.string(_real_picture));
 | |
|     r.add(_totprogre_avere_al.string(_real_picture));
 | |
|     _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(totale.string(_real_picture));
 | |
|       _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;
 | |
| 
 | |
|   TString sep(198);
 | |
|   sep.fill('-');                            //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,"@32gTOTALI PERIODO@100g%r", &_totale_periodo_dare);
 | |
|   set_row (_rw,"@117g%r", &_totale_periodo_avere);
 | |
|   set_row (_rw++,"@151g%r", &_saldo_movimenti);
 | |
|   set_row (_rw,"@32gTOTALI PROGRESSIVI@100g%r", &_totprogre_dare);
 | |
|   set_row (_rw,"@117g%r", &_totprogre_avere);
 | |
|   set_row (_rw++,"@134g%r", &_saldo_progressivi);
 | |
|   if (_stampaprogre)                          //Progressivi attuali
 | |
|   {
 | |
|     set_row(_rw,"@32gTOTALI PROGRESSIVI AL@55g%s", _ultima_data_reg.string());
 | |
|     set_row (_rw,"@100g%r", &_totprogre_dare_al);
 | |
|     set_row (_rw,"@117g%r", &_totprogre_avere_al); 
 | |
|     set_row (_rw,"@134g%r", &_saldo_progressivi);
 | |
|   }                             
 | |
|   _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;
 | |
| 
 | |
|   r.add("@32gTOTALI PERIODO@100g%s@117g%s@151g%s");
 | |
|   r.add(_totale_periodo_dare.string(_real_picture));
 | |
|   r.add(_totale_periodo_avere.string(_real_picture));
 | |
|   r.add(_saldo_movimenti.string(_real_picture));
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
| 
 | |
|   r.add("@32gTOTALI PROGRESSIVI@100g%s@117g%s@134g%s");
 | |
|   r.add(_totprogre_dare.string(_real_picture));
 | |
|   r.add(_totprogre_avere.string(_real_picture));
 | |
|   r.add(_saldo_progressivi.string(_real_picture));     
 | |
|   _lista.add(r);
 | |
|   r = "";
 | |
|   
 | |
|   if (_stampaprogre)                          //Progressivi attuali
 | |
|   {
 | |
|     r.add("@32gTOTALI PROGRESSIVI AL@55g%s@100g%s@117g%s@134g%s");
 | |
|     r.add(_ultima_data_reg.string());
 | |
|     r.add(_totprogre_dare_al.string(_real_picture));
 | |
|     r.add(_totprogre_avere_al.string(_real_picture));
 | |
|     r.add(_saldo_progressivi.string(_real_picture));    
 | |
|     _lista.add(r);
 | |
|     r = "";
 | |
|   }                 
 | |
| 
 | |
|   if (_stampatotiva)
 | |
|   { 
 | |
|     real totale;
 | |
|     
 | |
|     sep.fill(' ');
 | |
|     r.add("@0g%s");
 | |
|     r.add(sep);  
 | |
|     _lista.add(r);  
 | |
|     r = "";
 | |
| 
 | |
| //  Guy: Real dick programmig!    
 | |
| //    TString fmt ("@0g%s");
 | |
| //    TString fmt1(format("@%dg", _ddociva_len));
 | |
| //    fmt << fmt1 << "%15s";
 | |
|     
 | |
|     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(totale.string(_real_picture));
 | |
|       _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));
 | |
|     
 | |
|     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::setta_riga (int r, TString riga)
 | |
| {                         
 | |
|   TString *p = (TString*)_riga.objptr(r);
 | |
|   if (!p)
 | |
|   {
 | |
|     p = new TString;
 | |
|     _riga.add (p);
 | |
|   }
 | |
|   *p << riga;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::preprocess_page(int file, int counter)
 | |
| { 
 | |
|   TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
 | |
|   long    rec;
 | |
|   TDate   datasucc;
 | |
|   TString datasuccstring,dataregrmovstring;
 | |
|   int     gruppof,contof;
 | |
|   long    sottocf;
 | |
|   TString provvis = "";
 | |
|   int     annoes;
 | |
| 
 | |
|   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++;
 | |
|       }
 | |
|        
 | |
|       _gruppo = atoi(current_cursor()->curr(LF_SALDI).get(SLD_GRUPPO));
 | |
|       _conto  = atoi(current_cursor()->curr(LF_SALDI).get(SLD_CONTO));
 | |
|       _sottoc = atol(current_cursor()->curr(LF_SALDI).get(SLD_SOTTOCONTO)); 
 | |
|       
 | |
|       _cambia_mastrino = TRUE;
 | |
|       
 | |
|       annoes  = atoi(current_cursor()->curr(LF_SALDI).get(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 (_tipostampa == 2)
 | |
|       {
 | |
| //        saldi_zero();
 | |
|         calcola_progressivi();
 | |
|         _totale_saldo = _totprogre_dare_al - _totprogre_avere_al;
 | |
|       }
 | |
| //      else
 | |
| //        _totale_saldo = 1.0;
 | |
|                       
 | |
|       if ((_tipostampa == 1) || (_tipostampa == 2))
 | |
|       {  
 | |
|         if ((_tipostampa == 1 && almeno_un_record()) ||
 | |
|             (_tipostampa == 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
 | |
|         {
 | |
|           _puoi_stampare = FALSE; 
 | |
|           return FALSE;
 | |
|         }                      
 | |
|       }
 | |
|       else
 | |
|         if (_tipostampa == 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:
 | |
|     {
 | |
|      //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
 | |
|       
 | |
|       TLocalisamfile&  rmov = current_cursor()->file(LF_RMOV);
 | |
|            
 | |
|       _numreg = atol (current_cursor()->curr(LF_RMOV).get(RMV_NUMREG));
 | |
|       _numrig = atoi (current_cursor()->curr(LF_RMOV).get(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 = current_cursor()->curr(LF_RMOV).get_real(RMV_IMPORTO);
 | |
|       _importo_str = _importo.string(_real_picture);
 | |
|       _mov->setkey(1);
 | |
|       _mov->curr().zero();
 | |
|       _mov->curr().put(MOV_NUMREG,_numreg);
 | |
|       _mov->read();
 | |
|       if (_mov->bad())
 | |
|         _mov->zero();
 | |
|       _annoes  = _mov->get_int(MOV_ANNOES);
 | |
|       _regiva  = _mov->curr().get(MOV_REG);   
 | |
|       _annoiva = _mov->curr().get_int(MOV_ANNOIVA);
 | |
| 
 | |
|       // Controlla se saldo e' diverso da 0
 | |
| 
 | |
|       if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0.0))
 | |
|       { 
 | |
|         _sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);     
 | |
| 
 | |
|         if (_annomsk == 0)
 | |
|         {
 | |
|           _datareg = (_mov->curr().get(MOV_DATAREG));
 | |
|           _datareg_stampa = _datareg;
 | |
|         }
 | |
|         else
 | |
|           if (_annomsk != 0)
 | |
|           {
 | |
|             _datareg = _mov->curr().get(MOV_DATACOMP);
 | |
|             _datareg_stampa = _mov->curr().get(MOV_DATAREG);
 | |
|           }
 | |
| 
 | |
|         provvis  =  _mov->curr().get(MOV_PROVVIS);
 | |
|   
 | |
|         _dataregs = _datareg_stampa.string();
 | |
| 
 | |
|         if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty())))
 | |
|         {
 | |
|           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, "@131g*");
 | |
|               else
 | |
|                 set_row (_rw, "@197g*");
 | |
| 
 | |
|             if (_stampa_mov_prov  && provvis.trim().not_empty()) 
 | |
|               if (_numcarat == 1)
 | |
|                 set_row(_rw, "@129gP"); 
 | |
|               else
 | |
|                 set_row(_rw, "@195gP");
 | |
|                 
 | |
|             _codcaus = _mov->curr().get(MOV_CODCAUS);
 | |
|             _tipodoc = _mov->curr().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->curr().get(MOV_DATADOC));
 | |
|             _datadocs = _datadoc.string();
 | |
|             _numdoc = _mov->curr().get(MOV_NUMDOC);
 | |
|             descrizione_causale();
 | |
|             _descrizionemov = _mov->curr().get(MOV_DESCR);
 | |
|             _numgio = atol(_mov->curr().get(MOV_NUMGIO));
 | |
| 
 | |
|             _descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR);
 | |
|           
 | |
|             if (_nummast == 1 || _nummast == 3)
 | |
|             {
 | |
|               if (_numcarat == 1)     // Stampa 132 caratteri
 | |
|               {
 | |
|                 if (_descrizione != "")
 | |
|                 {
 | |
|                   *_d23 = (const char*) _descrizione;
 | |
|                   if (_descrizionemov != "")
 | |
|                   {                                    
 | |
|                     *_d18 = (const char*) _descrizionemov;
 | |
|                     set_row(_rw, "@42g#a", _d18);
 | |
|                     set_row(_rw, "@61g#a", _d23);
 | |
|                   }
 | |
|                   else if (_descrizionemov == "")
 | |
|                   { 
 | |
|                     *_d18 = (const char*) _descrcaus;
 | |
|                     set_row(_rw, "@42g#a", _d18);
 | |
|                     set_row(_rw, "@61g#a", _d23);
 | |
|                   }
 | |
|                 }
 | |
|                 else if (_descrizione == "")
 | |
|                        if (_descrizionemov != "")
 | |
|                        {
 | |
|                          *_d23 = (const char*) _descrizionemov;
 | |
|                          *_d18 = (const char*) _descrcaus;
 | |
|                          set_row (_rw,"@42g#a", _d18); 
 | |
|                          set_row (_rw,"@61g#a", _d23);
 | |
|                        }
 | |
|                        else
 | |
|                          if (_descrizionemov == "")
 | |
|                          {
 | |
|                            conto(_gruppocontr,_contocontr,FALSE);
 | |
|                            TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                            TString80 descr_contr = tc.descrizione();    
 | |
|                            //set_row (1,"@42g%.18s", (const char*) _descrcaus); 
 | |
|                            //if (descr_contr != "Sconosciuto")
 | |
|                            //  set_row (1,"@61g%.23s", (const char*) descr_contr);
 | |
|                            *_d18 = (const char*) _descrcaus;
 | |
|                            set_row (_rw,"@42g#a", _d18); 
 | |
|                            if (descr_contr != "Sconosciuto")
 | |
|                            {
 | |
|                              *_d23 = (const char*) descr_contr;
 | |
|                              set_row (_rw,"@61g#a", _d23);
 | |
|                            }
 | |
|                          }  
 | |
|               }
 | |
|               else
 | |
|                 if (_numcarat == 2)     // Stampa 198 caratteri
 | |
|                 {
 | |
|                   if (_descrizione != "")
 | |
|                   {
 | |
|                     *_d30 = (const char*) _descrizione;
 | |
|                     if (_descrizionemov != "")
 | |
|                     {                                    
 | |
|                       *_d23 = (const char*) _descrizionemov;
 | |
|                       set_row (_rw,"@46g#a", _d23);
 | |
|                       set_row (_rw,"@70g#a", _d30);
 | |
|                     }
 | |
|                     else if (_descrizionemov == "")
 | |
|                     { 
 | |
|                       //set_row (1,"@46g%.23s", (const char*) _descrcaus);  
 | |
|                       //set_row (1,"@70g%.30s", (const char*) _descrizione); 
 | |
|                       *_d23 = (const char*) _descrcaus;
 | |
|                       set_row(_rw, "@46g#a", _d23);
 | |
|                       set_row(_rw, "@70g#a", _d30);
 | |
|                     }
 | |
|                   }
 | |
|                   else if (_descrizione == "") 
 | |
|                          if (_descrizionemov != "")
 | |
|                          {
 | |
|                            //set_row (1,"@46g%.23s", (const char*) _descrcaus); 
 | |
|                            //set_row (1,"@70g%.30s", (const char*) _descrizionemov);
 | |
|                            *_d30 = (const char*) _descrizionemov;
 | |
|                            *_d23 = (const char*) _descrcaus;
 | |
|                            set_row (_rw,"@46g#a", _d23); 
 | |
|                            set_row (_rw,"@70g#a", _d30);
 | |
|                          }
 | |
|                          else
 | |
|                            if (_descrizionemov == "")
 | |
|                            {
 | |
|                              conto(_gruppocontr,_contocontr,FALSE);
 | |
|                              TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                              TString descr_contr = tc.descrizione();
 | |
|                              //set_row (1,"@46g%.23s", (const char*) _descrcaus); 
 | |
|                              //if (descr_contr != "Sconosciuto")
 | |
|                              //  set_row (1,"@70g%.30s", (const char*) descr_contr);                       
 | |
|                              *_d23 = (const char*) _descrcaus;
 | |
|                              set_row (_rw,"@46g#a", _d23); 
 | |
|                              if (descr_contr != "Sconosciuto")
 | |
|                              {
 | |
|                               *_d30 = (const char*) descr_contr;
 | |
|                               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 != "")
 | |
|                     d18 = _descrizionemov;
 | |
|                   else if (_descrizionemov == "")
 | |
|                     d18 = _descrcaus;
 | |
|                 }
 | |
|                 else if (_descrizione == "")
 | |
|                        if (_descrizionemov != "")
 | |
|                        {
 | |
|                          d23 = _descrizionemov;
 | |
|                          d18 = _descrcaus;
 | |
|                        }
 | |
|                        else
 | |
|                          if (_descrizionemov == "")
 | |
|                          {
 | |
|                            conto(_gruppocontr,_contocontr,FALSE);
 | |
|                            TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                            TString80 descr_contr = tc.descrizione();    
 | |
|                            d18 = _descrcaus;
 | |
|                            if (descr_contr != "Sconosciuto")
 | |
|                              d23 = descr_contr;
 | |
|                          }  
 | |
|                         
 | |
|                 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 != "")
 | |
|                   {
 | |
|                     d30 = _descrizione;
 | |
|                     if (_descrizionemov != "")
 | |
|                       d23 = _descrizionemov;
 | |
|                     else if (_descrizionemov == "")
 | |
|                       d23 = _descrcaus;
 | |
|                   }
 | |
|                   else if (_descrizione == "") 
 | |
|                          if (_descrizionemov != "")
 | |
|                          {
 | |
|                            d30 = _descrizionemov;
 | |
|                            d23 = _descrcaus;
 | |
|                          }
 | |
|                          else
 | |
|                            if (_descrizionemov == "")
 | |
|                            {
 | |
|                              conto(_gruppocontr,_contocontr,FALSE);
 | |
|                              TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | |
|                              TString descr_contr = tc.descrizione();
 | |
|                              d23 = _descrcaus;
 | |
|                              if (descr_contr != "Sconosciuto")
 | |
|                               d30 = descr_contr;
 | |
|                            }
 | |
|                          
 | |
|                   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  (dep_dare.string(_real_picture));
 | |
|                   TString avere (dep_avere.string(_real_picture));
 | |
|                   if (_numcarat == 1)                  
 | |
|                   {
 | |
|                     set_row (_rw,"@32gA RIPORTO@83g%s", (const char*) dare);
 | |
|                     set_row (_rw,"@100g%s", (const char*) avere);
 | |
|                   }  
 | |
|                   else
 | |
|                     if (_numcarat == 2) 
 | |
|                     {
 | |
|                       set_row (_rw,"@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--;
 | |
| //                return TRUE;  
 | |
|               }
 | |
|               //_riga.destroy();
 | |
|             }  //if (_nummast == 2)
 | |
| 
 | |
|             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
 | |
|                 if (_numcarat == 2)  // Stampa 198 caratteri
 | |
|                 {
 | |
|                   _saldo_progressivi += _importo;
 | |
|                   _saldo_movimenti += _importo;
 | |
|                   set_row (_rw,"@100g%s", (const char*) _importo_str);
 | |
|                 }
 | |
|             }
 | |
|             else if (_sezione == "A")
 | |
|                  {
 | |
|                    _totale_periodo_avere += _importo;
 | |
|                    _riporto_parziale_avere += _importo;
 | |
| 
 | |
|                    if (_numcarat == 1)    // Stampa 132 caratteri
 | |
|                      set_row (_rw,"@100g%s", (const char*) _importo_str);
 | |
|                    else
 | |
|                      if (_numcarat == 2)  // 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_progressivi_str=_saldo_progressivi.string(_real_picture);
 | |
|             _saldo_movimenti_str=_saldo_movimenti.string(_real_picture);
 | |
|             if (_numcarat == 2)
 | |
|             {
 | |
|                ricerca_regiva();
 | |
|               _protiva = atol(_mov->curr().get(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);
 | |
|               dataregrmovstring=_dataregrmov.string();
 | |
| 
 | |
| //Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV
 | |
| 
 | |
|               rec = rmov.recno();
 | |
|               rmov.next();
 | |
|               gruppof = rmov.get_int(RMV_GRUPPO);
 | |
|               contof = rmov.get_int(RMV_CONTO);
 | |
|               sottocf = rmov.get_int(RMV_SOTTOCONTO);
 | |
|               datasucc = rmov.get_date(RMV_DATAREG);
 | |
|               datasuccstring=datasucc.string();
 | |
|               if (((gruppof!=_gruppo)||(contof!=_conto)||(sottocf!=_sottoc))||(rmov.eof()))
 | |
|                 datasucc = ("");
 | |
|               if (datasucc != _dataregrmov)
 | |
|               {
 | |
|                 if (_flag_del_cazzo)
 | |
|                 {
 | |
|                   calcola_progressivi();                             
 | |
|                   _saldo_progressivi += _saldo_progre_prec;    
 | |
|                   set_row (_rw,"@134g%r", &_saldo_progressivi);
 | |
|                   _saldo_progressivi -= _saldo_progre_prec;          
 | |
|                   _flag_del_cazzo = FALSE;
 | |
|                 }  
 | |
|                 else
 | |
|                   set_row (_rw,"@134g%r", &_saldo_progressivi);
 | |
|               }
 | |
| 
 | |
|               rmov.readat(rec);
 | |
|             } 
 | |
|             _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 if (_numcarat == 2)
 | |
|            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 (_tipostampa == 3)
 | |
|       {
 | |
|         reset_print();
 | |
|         if (_numcarat == 1)
 | |
|           stampa_totali132();
 | |
|         else if (_numcarat == 2)
 | |
|                stampa_totali198();
 | |
| 
 | |
|         if (_stampatotiva)     
 | |
|           stampa_totaliiva();
 | |
|       }
 | |
|       else if (_tipostampa == 2)
 | |
|            {
 | |
|              reset_print();
 | |
|              if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|                if (_numcarat == 1)
 | |
|                  stampa_totali132();
 | |
|                else if (_numcarat == 2)
 | |
|                       stampa_totali198();
 | |
|              if (_stampatotiva)      
 | |
|                stampa_totaliiva();
 | |
|        }
 | |
|        else if (_tipostampa == 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
 | |
|             if (_numcarat == 2)
 | |
|               carica_array_totali198(); 
 | |
|         }
 | |
|         
 | |
|         if (_tipostampa == 3)
 | |
|         {
 | |
|           reset_print();
 | |
|           if (_numcarat == 1)
 | |
|             stampa_totali132_II();
 | |
|           else if (_numcarat == 2)
 | |
|                  stampa_totali198_II();
 | |
|         }
 | |
|         else if (_tipostampa == 2)
 | |
|              {
 | |
|                reset_print();
 | |
|                if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|                  if (_numcarat == 1)
 | |
|                    stampa_totali132_II();
 | |
|                  else if (_numcarat == 2)
 | |
|                         stampa_totali198_II();
 | |
|          }
 | |
|          else if (_tipostampa == 1)
 | |
|               {
 | |
|                 reset_print();
 | |
|                 if (_puoi_stampare)
 | |
|                   if (_numcarat == 1)
 | |
|                     stampa_totali132_II();
 | |
|                   else if (_numcarat == 2)
 | |
|                          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
 | |
|               
 | |
|             TString sep = " ";
 | |
|     
 | |
|             for (int i = 0; i < righe_rimaste; i++)
 | |
|               set_row(_rw++,"@0g%s", (const char*) sep);
 | |
|           }
 | |
|         }
 | |
|       }
 | |
| 
 | |
| //    _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)
 | |
|   {                                                             
 | |
|     _msk->reset(F_TIPOCF_INI);
 | |
|     
 | |
|     _msk->reset(F_GRUPPOINI);  
 | |
|     
 | |
|     _msk->reset(F_CONTOINI_CONTO);
 | |
|     _msk->reset(F_CONTOINI_CLIENTE);
 | |
|     _msk->reset(F_CONTOINI_FORN);
 | |
|     
 | |
|     _msk->reset(F_SOTTOCINI_CONTO);
 | |
|     _msk->reset(F_SOTTOCINI_CLIENTE);
 | |
|     _msk->reset(F_SOTTOCINI_FORN); 
 | |
|     
 | |
|     _msk->reset(F_DESCRINI_CONTO);
 | |
|     _msk->reset(F_DESCRINI_CLIENTE);
 | |
|     _msk->reset(F_DESCRINI_FORN);
 | |
|     
 | |
|     _msk->reset(F_TIPOCF_FINE);
 | |
|     
 | |
|     _msk->reset(F_GRUPPOFINE);  
 | |
|     
 | |
|     _msk->reset(F_CONTOFINE_CONTO);
 | |
|     _msk->reset(F_CONTOFINE_CLIENTE);
 | |
|     _msk->reset(F_CONTOFINE_FORN);
 | |
|     
 | |
|     _msk->reset(F_SOTTOCFINE_CONTO);
 | |
|     _msk->reset(F_SOTTOCFINE_CLIENTE);
 | |
|     _msk->reset(F_SOTTOCFINE_FORN);
 | |
|     
 | |
|     _msk->reset(F_DESCRFINE_CONTO);
 | |
|     _msk->reset(F_DESCRFINE_CLIENTE);
 | |
|     _msk->reset(F_DESCRFINE_FORN);
 | |
|   }     
 | |
|   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++;     
 | |
|     TString fmt (format("@%dg", _ddociva_len));
 | |
|     fmt << "%15s";
 | |
|     
 | |
|     if (_stampatotiva)
 | |
|       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 = totale.string(_real_picture);
 | |
|         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()
 | |
| {
 | |
|   _caus->setkey(1);
 | |
|   _caus->curr().zero();
 | |
|   _caus->curr().put(CAU_CODCAUS, _codcaus);
 | |
|   _caus->read();
 | |
|   if (_caus->bad())
 | |
|     _caus->zero();
 | |
|   _descrcaus = _caus->curr().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)
 | |
| {
 | |
|   _puoi_stampare = TRUE;   
 | |
| 
 | |
|   KEY tasto;
 | |
|                    
 | |
|   // 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 = (TSheet_field&)_msk->field(F_SCELTE);
 | |
|       if (sht.items() != 0)
 | |
|         sheet2mask();     // Estrae la prima riga dalla coda di stampa
 | |
|     }  
 | |
|   }  
 | |
|   
 | |
|   _noseparator = _msk->get_bool(F_SEPARATOR);
 | |
|   if (_noseparator)
 | |
|     _real_picture = "################";
 | |
|   else
 | |
|     _real_picture = "####.###.###.###";
 | |
|   set_real_picture(_real_picture);
 | |
| 
 | |
| 
 | |
|   if (tasto == K_ENTER)
 | |
|   {
 | |
|     _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);
 | |
|     _stampanum          = _msk->get_int(F_STAMPANUM);
 | |
|     _stampa_mov_prov    = _msk->get_bool(F_STAMPAMOVPROV); 
 | |
|     _tipostampa         = _msk->get_int(F_TIPOSTAMPA);
 | |
| 
 | |
|     _numcarat           = _msk->get_int(F_NUMCARAT);
 | |
|     _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();
 | |
| 
 | |
|     int formato         = _msk->get_int(F_FORMATO);    // Molto scenografico!
 | |
| 
 | |
|     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);   
 | |
|     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 (_tipostampa)
 | |
|     {
 | |
|       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: ", 'r');
 | |
|    
 | |
|     return TRUE;
 | |
|   }
 | |
|   else
 | |
|     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 (_tipostampa == 3)
 | |
|       crea_intestazione();
 | |
|     else
 | |
|       if (_tipostampa == 2)
 | |
|       {
 | |
|         if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|           crea_intestazione();
 | |
|       }
 | |
|       else if (_tipostampa == 1)
 | |
|              if (_puoi_stampare)
 | |
|                crea_intestazione();
 | |
|   }                
 | |
|   else
 | |
|     if (_nummast == 3 && !_gia_stampata_intestazione)
 | |
|     {
 | |
|       if (_tipostampa == 3)
 | |
|         crea_intestazione();
 | |
|       else
 | |
|         if (_tipostampa == 2)
 | |
|         {
 | |
|           if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | |
|             crea_intestazione();
 | |
|         }
 | |
|         else if (_tipostampa == 1)
 | |
|                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  (dep_dare.string(_real_picture));
 | |
|       TString avere (dep_avere.string(_real_picture));
 | |
|       if (_numcarat == 1)                  
 | |
|       {
 | |
|         set_footer (2,"@32gA RIPORTO@83g%s", (const char*) dare);
 | |
|         set_footer (2,"@100g%s", (const char*) avere);
 | |
|       }  
 | |
|       else
 | |
|         if (_numcarat == 2) 
 | |
|         {
 | |
|           set_footer (2,"@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)
 | |
| {
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
| 
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO, gruppo);
 | |
|   pconti.put(PCN_CONTO , conto);
 | |
|   pconti.read();
 | |
|   if (pconti.bad())
 | |
|     pconti.zero();
 | |
|   
 | |
|   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;
 | |
| 
 | |
|   _nditte->setkey(1);
 | |
|   _nditte->curr().zero();
 | |
|   _nditte->curr().put(NDT_CODDITTA,_codice_ditta);
 | |
|   _nditte->read();
 | |
|   app=_nditte->curr().get_long(NDT_CODDITTA);
 | |
|   _ragsoc=_nditte->curr().get(NDT_RAGSOC);
 | |
|  
 | |
|   _unloc->setkey(1);
 | |
|   _unloc->curr().zero();
 | |
|   _unloc->curr().put(ULC_CODDITTA,app);
 | |
|   _unloc->curr().put(ULC_CODULC,"1");
 | |
|   _unloc->read();
 | |
|   _indulc=_unloc->curr().get(ULC_INDULC);
 | |
|   _civulc=_unloc->curr().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->curr().get(ULC_CAPULC);
 | |
|   _comulc=_unloc->curr().get(ULC_COMULC);
 | |
|  
 | |
|   _comuni->setkey(1);
 | |
|   _comuni->zero();
 | |
|   _comuni->put(COM_COM,_comulc);
 | |
|   _comuni->read();
 | |
|   if  (_comuni->good())
 | |
|   {
 | |
|     _com=_comuni->get(COM_DENCOM);
 | |
|     _prov=_comuni->get(COM_PROVCOM);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     _com="";
 | |
|     _prov="";
 | |
|   }
 | |
| }
 | |
| 
 | |
| // Crea l'intestazione per la stampa a 132 e a 198 caratteri
 | |
| 
 | |
| void TMastrini_application::crea_intestazione()
 | |
| {
 | |
|   TString sep(132),sep1(198); 
 | |
|   sep = "";
 | |
| 
 | |
|   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);
 | |
|     sep ="";
 | |
|     set_header(2,"@1g%s",(const char*) sep);  
 | |
|     //set_header(1,"@126gPag. %2d", _numero_pag++);
 | |
|   }
 | |
|   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);
 | |
|          sep1 ="";
 | |
|          set_header(2,"@1g%s",(const char*) sep1);       
 | |
|          //set_header(1,"@190gPagina %2d", _numero_pag++);
 | |
|        }
 | |
|   if (_nummast != 3)     
 | |
|     _pagina++;
 | |
|   
 | |
|   if (_nummast != 3 || _pagina != np)
 | |
|   {
 | |
|     set_header (1, "@0gDITTA@6g%5ld", _codice_ditta);
 | |
|     set_header (1, "@12g%-.45s", (const char*) _ragsoc);
 | |
|     set_header (1, "@59g%s", (const char*) _indulc);
 | |
|     //set_header (1, "@86g%-.9s", (const char*) _civulc);
 | |
|     set_header (1, "@97g%-.5s", (const char*) _capulc);
 | |
|     set_header (1, "@103g%-.18s", (const char*) _com);
 | |
|     set_header (1, "@122g%-.3s", (const char*) _prov);
 | |
|   }
 | |
|   if (_nummast == 3)
 | |
|     set_header (3, "@0gSottoconto @b%3d %3d %6ld", _gruppo, _conto, _sottoc);
 | |
|   else
 | |
|     set_header (3, "@0gSottoconto %3d %3d %6ld", _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: 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,"Operazione@19gDocumento@117gContro@131gA");
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(7,"@129gM");
 | |
|     set_header (8,"Data");
 | |
|     if (_stampanum < 3)
 | |
|       set_header (8,"@11gnumero");
 | |
|     set_header (8,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@95gDare@111gAvere@117gPartita@131gC");
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(8,"@129gP");
 | |
|     sep.fill('-');
 | |
|     set_header (9, (const char *) sep);
 | |
|   }
 | |
|   else if (_numcarat == 2)
 | |
|   {
 | |
|    sep1.fill('-');                    //Stampa 198 - (sep1(198))      
 | |
|    set_header (6,"@0g%s", (const char*)sep1);
 | |
|    set_header (7,"Operazione@23gData@34gNumero@169gContro@183gReg@190gNumero@197gA");
 | |
|    if (_stampa_mov_prov)
 | |
|      set_header(7,"@195gM");
 | |
|    set_header (8,"Data");
 | |
|    if (_stampanum < 3)
 | |
|      set_header (8,"@11gnumero");
 | |
|    set_header (8,"@23gDocumento@42gCod.Causale@70gDescrizione@112gDare@127gAvere@135gSaldo progre.@152gSaldo movim.@169gPartita@183gIva@189gProtoc.@197gC");
 | |
|    if (_stampa_mov_prov)
 | |
|      set_header(8,"@195gP");
 | |
|    sep1.fill('-');
 | |
|    set_header (9,"@0g%s", (const char*)sep1);
 | |
|   } 
 | |
|        
 | |
|   calcola_progressivi();
 | |
|   _saldo_progressivi += _saldo_progre_prec;          
 | |
|         
 | |
|   if (_stampa_progressivi_si)
 | |
|   {
 | |
|     if (_numcarat == 1)
 | |
|     { 
 | |
|       set_header (10,"@42gPROGRESSIVI PRECEDENTI@66g%s", _saldo_progre_prec.string(_real_picture));
 | |
|       set_header (10,"@83g%s", _progredare.string(_real_picture));
 | |
|       set_header (10,"@100g%s", _progreavere.string(_real_picture));
 | |
|     }
 | |
|     if (_numcarat == 2)
 | |
|     {
 | |
|       set_header (10,"@70gPROGRESSIVI PRECEDENTI@100g%s", _progredare.string(_real_picture));
 | |
|       set_header (10,"@117g%s", _progreavere.string(_real_picture));
 | |
|       set_header (10,"@134g%s", _saldo_progre_prec.string(_real_picture));
 | |
|     }
 | |
|     _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,"@32gA RIPORTO@83g%s", dep_dare.string(_real_picture));
 | |
|         set_header (10,"@100g%s", dep_avere.string(_real_picture));
 | |
|       }
 | |
|       if (_numcarat == 2)
 | |
|       {
 | |
|         set_header (10,"@32gA RIPORTO@100g%s", dep_dare.string(_real_picture));
 | |
|         set_header (10,"@117g%s", dep_avere.string(_real_picture));
 | |
|       }
 | |
|     }  
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|   }
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep ="";
 | |
|     set_header(11,"@1g%s",(const char*) sep);
 | |
|   }
 | |
|   else if (_numcarat == 2)
 | |
|        {
 | |
|          sep1 ="";
 | |
|          set_header(11,"@1g%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 << "Pag. @#";
 | |
|         set_row(r,"@126g%s", (const char*) sep);
 | |
|       }     
 | |
|       else if (_numcarat == 2)
 | |
|       {
 | |
|         sep << "Pagina @#";
 | |
|         set_row(r,"@190g%s", (const char*) sep);
 | |
|       }       
 | |
|     }     
 | |
|   }          
 | |
|   else
 | |
|   {
 | |
|     if (_numcarat == 1)
 | |
|       set_row(r,"@126gPag. %2d", _numero_pag++);
 | |
|     else if (_numcarat == 2)
 | |
|            set_row(r,"@190gPagina %2d", _numero_pag++);
 | |
|   }              
 | |
|   if (_nummast != 3 || _pagina != np)
 | |
|   {
 | |
|     set_row (r, "@0gDITTA@6g%5ld", _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, "@0gSottoconto@12g@b%3d %3d %6ld", _gruppo, _conto, _sottoc);
 | |
|   else
 | |
|     set_row (r, "@0gSottoconto@12g%3d %3d %6ld", _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++,"@1g%s", (const char *) sep);
 | |
|     set_row (r++,"Operazione@19gDocumento@117gContro@131gA");
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(r-1,"@129gM");
 | |
|     set_row (r,"Data");
 | |
|     if (_stampanum < 3)
 | |
|       set_row (r,"@11gnumero");
 | |
|     set_row (r++,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@95gDare@111gAvere@117gPartita@131gC");
 | |
|     if (_stampa_mov_prov)
 | |
|       set_header(r-1,"@129gP");
 | |
|     sep.fill('-');
 | |
|     set_row (r++,"@1g%s", (const char*)sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|    sep1.fill('-');                    //Stampa 198 - (sep1(198))      
 | |
|    set_row (r++,"@0g%s", (const char*)sep1);
 | |
|    set_row (r++,"Operazione@23gData@34gNumero@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,"@23gDocumento@42gCod.Causale@70gDescrizione@112gDare@127gAvere");
 | |
|    set_row (r++,"@135gSaldo progre.@152gSaldo movim.@169gPartita@183gIva@189gProtoc.@197gC");
 | |
|    if (_stampa_mov_prov)
 | |
|      set_row (r-1,"@195gP");
 | |
|    sep1.fill('-');
 | |
|    set_row (r++,"@0g%s", (const char*)sep1);
 | |
|   }   
 | |
|   _pagina = np;       
 | |
|   return r;     
 | |
| }
 | |
|           
 | |
| void TMastrini_application::stampa_progre_riporto()
 | |
| { 
 | |
|   TString sep(132),sep1(198);
 | |
| 
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 1;
 | |
|              
 | |
|   if (_stampa_progressivi_si)
 | |
|   {
 | |
|     stampa_progressivi();
 | |
|     _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_row (_rw,"@32gA RIPORTO@83g%r", &dep_dare);
 | |
|         set_row (_rw++,"@100g%r",&dep_avere);
 | |
|       }
 | |
|       if (_numcarat == 2)
 | |
|       {
 | |
|         set_row (_rw,"@32gA RIPORTO@100g%r", &dep_dare);
 | |
|         set_row (_rw++,"@117g%r", &dep_avere);
 | |
|       }
 | |
|     }     
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|   }
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep ="";
 | |
|     set_row(_rw,"@1g%s",(const char*)sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     sep1 ="";
 | |
|     set_row(_rw,"@1g%s",(const char*)sep1);
 | |
|   }
 | |
| } 
 | |
| 
 | |
| 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,"@32gA RIPORTO@83g%r", &dep_dare);
 | |
|         set_row (r++,"@100g%r", &dep_avere);
 | |
|       }
 | |
|       if (_numcarat == 2)
 | |
|       {
 | |
|         set_row (r,"@32gA RIPORTO@100g%r", &dep_dare);
 | |
|         set_row (r++,"@117g%r", &dep_avere);
 | |
|       }
 | |
|     }     
 | |
|     _riporto_parziale_dare = ZERO;
 | |
|     _riporto_parziale_avere = ZERO;
 | |
|   }
 | |
|   if (_numcarat == 1)
 | |
|   {
 | |
|     sep ="";
 | |
|     set_row(r++,"@1g%s",(const char*) sep);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|    sep1 ="";
 | |
|    set_row(r++,"@1g%s",(const char*) sep1);
 | |
|   }            
 | |
|   return r;
 | |
| } 
 | |
|          
 | |
| void TMastrini_application::calcola_progressivi_al()
 | |
| {
 | |
|   long record,sottoc,annoes;
 | |
|   int  gruppo,conto;
 | |
|   TDate datareg, datacomp;
 | |
|   TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
 | |
|   char sezione;
 | |
|   real importo;       
 | |
|   TDate data;
 | |
| 
 | |
|   _totale_prima_dare  = ZERO;
 | |
|   _totale_prima_avere = ZERO;
 | |
|   
 | |
|   record = rmov.recno(); 
 | |
|   rmov.zero();
 | |
|   rmov.put(RMV_GRUPPO,     _gruppo);
 | |
|   rmov.put(RMV_CONTO,      _conto);
 | |
|   rmov.put(RMV_SOTTOCONTO, _sottoc);
 | |
|   for (rmov.read();!rmov.eof() ;rmov.next())
 | |
|   {
 | |
|     annoes      = rmov.get_int (RMV_ANNOES);
 | |
|     datareg     = rmov.get_date(RMV_DATAREG);
 | |
|     sezione     = rmov.get     (RMV_SEZIONE)[0];
 | |
|     importo     = rmov.get_real(RMV_IMPORTO);
 | |
|     long numreg = rmov.get_long(RMV_NUMREG);
 | |
| 
 | |
|     _mov->setkey(1);
 | |
|     _mov->curr().zero();
 | |
|     _mov->curr().put(MOV_NUMREG,numreg);
 | |
|     _mov->read();
 | |
|     if (_mov->bad())
 | |
|       _mov->zero();
 | |
|     datacomp = (_mov->curr().get(MOV_DATACOMP));
 | |
|     TString provvis (_mov->curr().get(MOV_PROVVIS));
 | |
|     
 | |
|     if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty())))
 | |
|     {
 | |
|       if (_annomsk == 0)
 | |
|       {
 | |
|         datareg = rmov.get_date(RMV_DATAREG); 
 | |
|         data = _inizioes;
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         datareg = datacomp;
 | |
|         data = _data_inizioese;
 | |
|       }  
 | |
| 
 | |
|       gruppo = rmov.get_int(RMV_GRUPPO);
 | |
|       conto  = rmov.get_int(RMV_CONTO);
 | |
|       sottoc = rmov.get_long(RMV_SOTTOCONTO);
 | |
|       if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc))
 | |
|         break;
 | |
|       else if (((annoes==_annomsk)||(_annomsk == 0))&&(datareg >= data)&&(datareg < _data_ini)) //Legge movimenti con data < data iniziale
 | |
|              if (sezione == 'D')
 | |
|                _totale_prima_dare += importo;
 | |
|              else
 | |
|                _totale_prima_avere += importo;
 | |
|     } // if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty())))              
 | |
|   }  
 | |
|   rmov.readat(record);
 | |
| }
 | |
| 
 | |
| void TMastrini_application::calcola_progressivi()
 | |
| {
 | |
|    /* 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, FALSE);
 | |
|    real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
 | |
|    real saldo,progredare_eseprec,progreavere_eseprec,pdarep,paverep,saldoini_attuale,saldofine_attuale;
 | |
|    char salini,salini_attuale,salfine_attuale;
 | |
| 
 | |
|    saldo         = ZERO;
 | |
|    pdarep        = ZERO;
 | |
|    paverep       = ZERO;
 | |
| 
 | |
| // 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);
 | |
| 
 | |
|    TRectype record(saldi.curr());
 | |
|   
 | |
|    for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next())
 | |
|    {             
 | |
|      if (!saldi.get_bool(SLD_FLSCA))
 | |
|      {
 | |
|        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);
 | |
|          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);
 | |
|        }
 | |
| 
 | |
| //Calcola i progressivi dell'esercizio precedente
 | |
| 
 | |
|        if (annoes_saldi == _anno_precedente)
 | |
|        {
 | |
|          pdarep       = saldi.get_real(SLD_PDARE);
 | |
|          paverep      = saldi.get_real(SLD_PAVERE);
 | |
|          
 | |
|          if (_stampa_mov_prov)
 | |
|          {
 | |
|           progredare_eseprec = pdarep + saldi.get_real(SLD_PDAREPRO);
 | |
|           progreavere_eseprec = paverep + saldi.get_real(SLD_PAVEREPRO);
 | |
|          }
 | |
|   
 | |
|          // cerca eventuale record scaricati
 | |
|        }
 | |
|         
 | |
| // Se il saldo dell'esercizio attuale e' diverso da 0 allora significa che
 | |
| // quello corrisponde al saldo finale dell'esercizio precedente. Per ottenere
 | |
| // i progressivi dell'esercizio precedente devo a questo punto sommare i
 | |
| // progressivi dell'esercizio e i progressivi di quelli scaricati, tenendo
 | |
| // conto del flag salini per sapere se il saldo e' dare oppure avere.
 | |
| 
 | |
| /*
 | |
|      if (_annomsk != 0 && _anno_corrente == annoes_saldi)
 | |
|      {
 | |
|        if (saldo != ZERO)
 | |
|        {
 | |
|          if (salini == 'D')
 | |
|          {
 | |
|            progredare_eseprec  = saldo;// + pdarescap + pdarep;
 | |
|            progdare_prec = saldo;
 | |
|          }
 | |
|          else if (salini == 'A')
 | |
|               {
 | |
|                 progreavere_eseprec = saldo;// + paverescap + paverep;
 | |
|                 progavere_prec = saldo;
 | |
|               }
 | |
|        }
 | |
|      }
 | |
| */   
 | |
|      }   // 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 /*&& saldo == ZERO*/)   // Guy: Non capisco perche' sia commentato!
 | |
|    {    
 | |
|      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);
 | |
|        saldi.readat(pos);
 | |
|            
 | |
|        if (saldo> ZERO)
 | |
|        {
 | |
|          progredare_eseprec  = saldo;
 | |
|          progdare_prec = saldo;
 | |
|        }
 | |
|        else if (saldo < ZERO)
 | |
|             {
 | |
|               saldo = -saldo;
 | |
|               progreavere_eseprec = saldo;
 | |
|               progavere_prec = saldo;
 | |
|             }
 | |
|      }
 | |
|    }
 | |
| 
 | |
|    calcola_progressivi_al();
 | |
|   
 | |
| //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 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;       
 | |
|    }
 | |
|    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;       
 | |
|    } 
 | |
| }
 | |
| 
 | |
| void TMastrini_application::stampa_progressivi()
 | |
| {           
 | |
|   if (_nummast == 1 || _nummast == 3)
 | |
|     _rw = 1;
 | |
| 
 | |
|   if (_numcarat == 1)
 | |
|   { 
 | |
|    set_row (_rw,"@42gPROGRESSIVI PRECEDENTI@66g%r", &_saldo_progre_prec);
 | |
|    set_row (_rw,"@83g%r", &_progredare);
 | |
|    set_row (_rw++,"@100g%r", &_progreavere);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     set_row (_rw,"@70gPROGRESSIVI PRECEDENTI@100g%r", &_progredare);
 | |
|     set_row (_rw,"@117g%r", &_progreavere);
 | |
|     set_row (_rw++,"@134g%r", &_saldo_progre_prec);
 | |
|   }
 | |
| }
 | |
| 
 | |
| int TMastrini_application::stampa_progressivi(int start_riga)
 | |
| {                                                           
 | |
|   int r = start_riga;
 | |
|   
 | |
|   if (_numcarat == 1)
 | |
|   { 
 | |
|     set_row (r,"@42gPROGRESSIVI PRECEDENTI@66g%r", &_saldo_progre_prec);
 | |
|     set_row (r,"@83g%r", &_progredare);
 | |
|     set_row (r++,"@100g%r", &_progreavere);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     set_row (r,"@70gPROGRESSIVI PRECEDENTI@100g%r", &_progredare);
 | |
|     set_row (r,"@117g%r", &_progreavere);
 | |
|     set_row (r++,"@134g%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,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep;
 | |
|   TLocalisamfile clifo(LF_CLIFO);
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
|   TString16 dataini,datafine; 
 | |
|   TString   descriz,descriz2;
 | |
|   int     numrivd;
 | |
|   
 | |
|   indcf = "";
 | |
|   
 | |
|   clifo.setkey(1);
 | |
|   clifo.zero();
 | |
|   clifo.put(CLI_TIPOCF, _tmcf);
 | |
|   clifo.put(CLI_CODCF,  _sottoc);
 | |
|   clifo.read();
 | |
|   if (clifo.bad())
 | |
|     clifo.zero();
 | |
|   TConto tc (_gruppo,_conto,_sottoc,_tmcf);
 | |
|   
 | |
|   ragsoc  = tc.descrizione();
 | |
|   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);
 | |
| 
 | |
|   _comuni->setkey(1);
 | |
|   _comuni->zero();
 | |
|   _comuni->put(COM_STATO, statocf);
 | |
|   _comuni->put(COM_COM, comcf);
 | |
|   _comuni->read();
 | |
|   if (_comuni->good())
 | |
|   {
 | |
|     dencom = _comuni->get(COM_DENCOM);
 | |
|     provcom = _comuni->get(COM_PROVCOM);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     //dencom="";
 | |
|     dencom = clifo.get(CLI_LOCCF);
 | |
|     provcom="";
 | |
|   }
 | |
| 
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,     _gruppo);
 | |
|   pconti.put(PCN_CONTO,      _conto);
 | |
|   pconti.read();
 | |
|   _sezivd  = pconti.get_char(PCN_SEZIVD);
 | |
|   _lettivd = pconti.get_char(PCN_LETTIVD);
 | |
|   numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | |
|   _numrivd = itor(numrivd);
 | |
|   _numivd  = pconti.get_int(PCN_NUMIVD);
 | |
| 
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);    
 | |
|  
 | |
|   if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd != "")   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd != "")
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,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, "@rClasse@8g@b%c", _lettivd);
 | |
|   else
 | |
|     set_header(4, "Classe@8g%c", _lettivd);  
 | |
|   set_header(4, "@10g%-8s", (const char*) _numrivd);
 | |
|   if (_numivd != 0)
 | |
|     set_header(4, "@19g%2d", _numivd);
 | |
|   if (descriz2 != "")                              
 | |
|   {
 | |
|     set_header(4,"@23g%-50s",(const char*) descriz2);
 | |
|     set_header(4,"@80g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_header(4,"@23g%-50s",(const char*) descriz);
 | |
|                                        
 | |
|   dataini = _data_ini.string();   
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                         
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@rPeriodo@10g@b%s", (const char*) dataini);
 | |
|       set_header (5, "@22g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "Periodo@10g%s", (const char*) dataini);
 | |
|       set_header (5, "@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                         
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@rComp. da@9g@b%s", (const char*) dataini);
 | |
|       set_header (5, "@20g@ra@22g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "Comp. da@9g%s", (const char*) dataini);
 | |
|       set_header (5, "@20ga@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv);
 | |
|   set_header (5, "@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,"@134g%-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;
 | |
|   TLocalisamfile clifo(LF_CLIFO);
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
|   TString16 dataini,datafine; 
 | |
|   TString   descriz,descriz2;
 | |
|   int     numrivd;
 | |
|   int   r = start;
 | |
|   
 | |
|   indcf = "";
 | |
|   
 | |
|   clifo.setkey(1);
 | |
|   clifo.zero();
 | |
|   clifo.put(CLI_TIPOCF, _tmcf);
 | |
|   clifo.put(CLI_CODCF,  _sottoc);
 | |
|   clifo.read();
 | |
|   if (clifo.bad())
 | |
|     clifo.zero();
 | |
|   TConto tc (_gruppo,_conto,_sottoc,_tmcf);
 | |
|   
 | |
|   ragsoc  = tc.descrizione();
 | |
|   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);
 | |
| 
 | |
|   _comuni->setkey(1);
 | |
|   _comuni->zero();
 | |
|   _comuni->put(COM_STATO, statocf);
 | |
|   _comuni->put(COM_COM, comcf);
 | |
|   _comuni->read();
 | |
|   if (_comuni->good())
 | |
|   {
 | |
|     dencom = _comuni->get(COM_DENCOM);
 | |
|     provcom = _comuni->get(COM_PROVCOM);
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     //dencom="";
 | |
|     dencom=clifo.get(CLI_LOCCF);
 | |
|     provcom="";
 | |
|   }
 | |
| 
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,     _gruppo);
 | |
|   pconti.put(PCN_CONTO,      _conto);
 | |
|   pconti.read();
 | |
|   _sezivd  = pconti.get_char(PCN_SEZIVD);
 | |
|   _lettivd = pconti.get_char(PCN_LETTIVD);
 | |
|   numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | |
|   _numrivd = itor(numrivd);
 | |
|   _numivd  = pconti.get_int(PCN_NUMIVD);
 | |
| 
 | |
|   descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);    
 | |
|  
 | |
|   if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd != "")   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd != "")
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,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, "@rClasse@8g@b%c", _lettivd);
 | |
|   else
 | |
|     set_row(r, "Classe@8g%c", _lettivd);
 | |
|   set_row(r, "@10g%-8s", (const char*) _numrivd);
 | |
|   if (_numivd != 0)
 | |
|     set_row(r, "@19g%2d", _numivd);
 | |
|   if (descriz2 != "")                              
 | |
|   {
 | |
|     set_row(r,"@23g%-50s",(const char*) descriz2);
 | |
|     set_row(r++,"@80g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_row(r++,"@23g%-50s",(const char*) descriz);
 | |
|                                        
 | |
|   dataini = _data_ini.string();   
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                          
 | |
|     if (_nummast == 3)       
 | |
|     {
 | |
|       set_row (r, "@rPeriodo@10g@b%s", (const char*) dataini);
 | |
|       set_row (r, "@22g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "Periodo@10g%s", (const char*) dataini);
 | |
|       set_row (r, "@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                        
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@rComp. da@9g@b%s", (const char*) dataini);
 | |
|       set_row (r, "@20g@ra@22g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "Comp. da@9g%s", (const char*) dataini);
 | |
|       set_row (r, "@20ga@22g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   set_row (r, "@33gP.I.@37g%-11s",(const char*) paiv);
 | |
|   set_row (r, "@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,"@134g%-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)
 | |
| {
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
|   
 | |
|   pconti.setkey(1);
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,     _gruppo);
 | |
|   pconti.put(PCN_CONTO,      _conto); 
 | |
|   if (scelta)
 | |
|     pconti.put(PCN_SOTTOCONTO, _sottoc);
 | |
|   pconti.read();
 | |
|   _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_int (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 != 0)      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd != "")   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd != "")
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,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@rClasse@12g@b%c", _lettivd);
 | |
|   else
 | |
|     set_header(4, "@0gClasse@12g%c", _lettivd);
 | |
|   set_header(4, "@14g%-8s",(const char*) _numrivd); 
 | |
|   if (_numivd != 0)
 | |
|     set_header(4, "@23g%d", _numivd); 
 | |
|   if (descriz2 != "")
 | |
|   {
 | |
|     set_header(4,"@27g%-50s",(const char*) descriz2);
 | |
|     set_header(4,"@80g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_header(4,"@27g%-50s",(const char*) descriz);
 | |
|   
 | |
|   dataini = _data_ini.string();
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   { 
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@rPeriodo@12g@b%s", (const char*) dataini);
 | |
|       set_header (5, "@24g@b%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "Periodo@12g%s", (const char*) dataini);
 | |
|       set_header (5, "@24g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                             
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_header (5, "@rPeriodo di competenza@23g@b%s", (const char*) dataini);
 | |
|       set_header (5, "@35g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_header (5, "Periodo di competenza@23g%s", (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 != 0)      //Ora devo stampare la descrizione del livello della
 | |
|   {                      //classe immediatamente precedente a quello appena
 | |
|    if (_numrivd != "")   //stampato
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | |
|    else
 | |
|      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | |
|   }
 | |
|   else
 | |
|     if (_numrivd != "")
 | |
|       descriz2 = descrizione_classe(_sezivd,_lettivd,0,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@rClasse@12g@b%c", _lettivd);
 | |
|   else
 | |
|     set_row(r, "@0gClasse@12g%c", _lettivd);
 | |
|   set_row(r, "@14g%-8s",(const char*) _numrivd); 
 | |
|   if (_numivd != 0)
 | |
|     set_row(r, "@23g%d", _numivd); 
 | |
|   if (descriz2 != "")
 | |
|   {
 | |
|     set_row(r,"@27g%-50s",(const char*) descriz2);
 | |
|     set_row(r++,"@80g%-50s",(const char*) descriz);                                                  
 | |
|   }
 | |
|   else
 | |
|     set_row(r++,"@27g%-50s",(const char*) descriz);
 | |
|   
 | |
|   dataini = _data_ini.string();
 | |
|   datafine = _data_fine.string();
 | |
| 
 | |
|   if (_annomsk == 0)
 | |
|   {                              
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@rPeriodo@12g@b%s", (const char*) dataini);
 | |
|       set_row (r, "@24g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "Periodo@12g%s", (const char*) dataini);
 | |
|       set_row (r, "@24g%s", (const char*) datafine);
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|   {                        
 | |
|     if (_nummast == 3)
 | |
|     {
 | |
|       set_row (r, "@rPeriodo di competenza@23g@b%s", (const char*) dataini);
 | |
|       set_row (r, "@35g%s@r", (const char*) datafine);    
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       set_row (r, "Periodo di competenza@23g%s", (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, int numero)
 | |
| {
 | |
|   TTable tabivd(TAB_IVD);
 | |
|   TString dep,dep2;
 | |
| 
 | |
|   tabivd.zero();   
 | |
|   if (numr == 0 && numero == 0)
 | |
|     dep = format("%c%c",sezione,lettera);
 | |
|   else                        
 | |
|     if (numero == 0)
 | |
|     {
 | |
|       if (numr != 0)
 | |
|         dep = format("%1c%1c%04d",sezione, lettera, numr);
 | |
|       else
 | |
|         dep = format("%c%c    ",sezione,lettera);
 | |
|      }
 | |
|      else                                         
 | |
|      {
 | |
|        if (numr != 0)
 | |
|          dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero);
 | |
|        else
 | |
|          dep = format("%c%c    %02d",sezione,lettera,numero);
 | |
|      }
 | |
|        
 | |
|   tabivd.put("CODTAB", dep);
 | |
|   tabivd.read();   
 | |
|   dep2 = tabivd.get("CODTAB");
 | |
|   if (dep == dep2)
 | |
|     TMP = tabivd.get("S0");
 | |
|   else
 | |
|     TMP = "";
 | |
|   return TMP;
 | |
| }     
 | |
| 
 | |
| //Ricerca la descrizione relativa al gruppo da stampare
 | |
| 
 | |
| const char* TMastrini_application::descrizione_gruppo()
 | |
| {  
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
| 
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,_gruppo);
 | |
|   if (pconti.read() != NOERR) pconti.zero();
 | |
|   TMP = pconti.get(PCN_DESCR);
 | |
|   return TMP;
 | |
| }
 | |
| 
 | |
| // Ricerca la descrizione relativa al conto da stampare
 | |
| 
 | |
| const char* TMastrini_application::descrizione_conto()
 | |
| { 
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
| 
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,_gruppo);
 | |
|   pconti.put(PCN_CONTO,_conto);
 | |
|   if (pconti.read() != NOERR) pconti.zero();
 | |
|   TMP = pconti.get(PCN_DESCR);
 | |
|   return TMP;
 | |
| }
 | |
| 
 | |
| const char* TMastrini_application::descrizione_sottoconto()
 | |
| { 
 | |
|   TLocalisamfile pconti(LF_PCON);
 | |
| 
 | |
|   pconti.zero();
 | |
|   pconti.put(PCN_GRUPPO,     _gruppo);
 | |
|   pconti.put(PCN_CONTO,      _conto);
 | |
|   pconti.put(PCN_SOTTOCONTO, _sottoc);
 | |
|   if (pconti.read() != NOERR) pconti.zero();
 | |
|   TMP = pconti.get(PCN_DESCR);
 | |
|   return TMP;
 | |
| }
 | |
| 
 | |
| // 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_CONTOINI_CLIENTE,   contoi_hnd);
 | |
|   msk->set_handler(F_CONTOINI_FORN,      contoi_hnd);  
 | |
|   msk->set_handler(F_CONTOFINE_CONTO,    contof_hnd);
 | |
|   msk->set_handler(F_CONTOFINE_CLIENTE,  contof_hnd);
 | |
|   msk->set_handler(F_CONTOFINE_FORN,     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 = (TSheet_field&)_msk->field(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 = (TSheet_field&)_msk->field(F_SCELTE);
 | |
|   bool ok = sht.items() > 0;
 | |
|   if (ok)
 | |
|   {
 | |
|     TString_array& rows = sht.rows_array();
 | |
|     TToken_string& row = rows.row(0);
 | |
|     row.restart();
 | |
| 
 | |
|     short id = F_ANNO;
 | |
|     for (int pos = _msk->id2pos(id); pos >= 0; pos = _msk->id2pos(++id))
 | |
|     {                                   
 | |
|       const char* val = row.get();        
 | |
|       // Scarta i listbox perche azzerano i conti!
 | |
|       if (id != F_TIPOCF_INI && id != F_TIPOCF_FINE)
 | |
|         _msk->fld(pos).set(val);
 | |
|     }
 | |
| 
 | |
|     rows.destroy(0, TRUE);
 | |
|   }
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| bool TMastrini_application::user_create()
 | |
| {
 | |
|   TToken_string exp;
 | |
| 
 | |
|   _rel = new TRelation (LF_SALDI);
 | |
| 
 | |
|   exp.add("GRUPPO=GRUPPO");
 | |
|   exp.add("CONTO=CONTO");
 | |
|   exp.add("SOTTOCONTO=SOTTOCONTO");
 | |
|   _rel->add(LF_RMOV,exp,2,LF_SALDI);
 | |
| 
 | |
|   _cur1=add_cursor(new TCursor(_rel,"FLSCA=\" \"",2)); 
 | |
|   _nditte = new TLocalisamfile (LF_NDITTE);
 | |
|   _unloc  = new TLocalisamfile (LF_UNLOC);
 | |
|   _comuni = new TLocalisamfile (LF_COMUNI);
 | |
|   _mov    = new TLocalisamfile (LF_MOV);
 | |
|   _clifo  = new TLocalisamfile (LF_CLIFO);
 | |
|   _caus   = new TLocalisamfile (LF_CAUSALI);
 | |
|   _tabivd = new TTable (TAB_IVD);
 | |
|   _tabtpd = new TTable (TAB_TPD);
 | |
|   _tabreg = new TTable (TAB_REG);
 | |
|   _sld    = new TSaldo ();
 | |
|   
 | |
|   _d18   = new TParagraph_string ("",18);
 | |
|   _d23   = new TParagraph_string ("",23);
 | |
|   _d30   = new TParagraph_string ("",30);
 | |
|   
 | |
|   _msk = new TMask("cg3200a");     
 | |
|   set_handlers(_msk);
 | |
|   _msk->set_handler(F_MEMORIZZA, memorizza_handler);
 | |
|   
 | |
|   TSheet_field& sht = (TSheet_field&)_msk->field(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 _mov;
 | |
|   delete _nditte;
 | |
|   delete _unloc;
 | |
|   delete _comuni;
 | |
|   delete _clifo;
 | |
|   delete _caus;
 | |
|   delete _tabivd;
 | |
|   delete _tabtpd;
 | |
|   delete _tabreg;
 | |
|   delete _sld;
 | |
|   delete _d18;
 | |
|   delete _d23;
 | |
|   delete _d30;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int cg3200(int argc, char* argv[])
 | |
| {
 | |
|   TMastrini_application a;
 | |
|   a.run(argc, argv, "Stampa Mastrini");
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| 
 |