Files correlati : Ricompilazione Demo : [ ] Commento :corretta chiamata dei BAR_ITEM con BAR_ITEM_ID git-svn-id: svn://10.65.10.50/trunk@18337 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			2751 lines
		
	
	
		
			70 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			2751 lines
		
	
	
		
			70 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "77stq.h" 
 | |
| #include "77stba.h"
 | |
| #include "77stqab.h"
 | |
| #include "77stqc.h"
 | |
| 
 | |
| // Quadro D
 | |
| #define POS_DITTA      120
 | |
| #define QD_PAGINE        4
 | |
| 
 | |
| #define QD_RIGHE_PRIMA   5
 | |
| #define QD_RIGHE_SECONDA 6
 | |
| #define QD_RIGHE_TERZA   6
 | |
| #define QD_RIGHE_QUARTA  5 
 | |
| // 
 | |
| // Lista modifiche
 | |
| //
 | |
| // 3.4.96 Nella stampa per Modulaser, aggiunto all'inizio un comando per settare
 | |
| //      il font della stampante a 17cpi (v.riga 176)
 | |
| // 
 | |
| 
 | |
| const char* get_ragsoc_anagr(char tipo, long codanagr)
 | |
| {
 | |
|   TLocalisamfile anagr (LF_ANAG);
 | |
|   anagr.put(ANA_TIPOA,    tipo);
 | |
|   anagr.put(ANA_CODANAGR, codanagr);
 | |
|   if (anagr.read() == NOERR)
 | |
|     __dep80 = anagr.get(ANA_RAGSOC);
 | |
|   else
 | |
|     __dep80 = "";
 | |
|     
 | |
|   return __dep80;  
 | |
| }
 | |
| 
 | |
| const char* get_ragsoc(const long codditta)
 | |
| {
 | |
|   TLocalisamfile ndt(LF_NDITTE);
 | |
|   ndt.put("CODDITTA", codditta);
 | |
|   if (ndt.read() == NOERR)
 | |
|     __dep80=ndt.get("RAGSOC");
 | |
|   else
 | |
|     __dep80="";
 | |
|   return __dep80;
 | |
| }
 | |
| 
 | |
| const char* get_printer_name()
 | |
| {             
 | |
|   TPrinter& pr = printer();
 | |
|   __dep80 = (const char*)(pr.get_printrcd()+4);
 | |
|   switch (pr.printtype())
 | |
|   {
 | |
|   case screenvis  : __dep80 << " (visualizzazione)"; break;
 | |
|   case fileprinter: __dep80 << " (su file)"; break;
 | |
|   default         : break;
 | |
|   }
 | |
|   return __dep80;
 | |
| }
 | |
| 
 | |
| int TDicForm::prima_riga(PaginaQuadro p) const
 | |
| {
 | |
|   return p == PRIMA ? 9 : 8;
 | |
| }
 | |
| 
 | |
| void TDicForm::set_cofi_dic(const char* cofi)
 | |
| { 
 | |
|   _cofi_dic = cofi;                   
 | |
| // salva il cod.dich. (serve per modulaser)  
 | |
|   _codditta_dic = sogg_estinto(_codditta);  
 | |
| }
 | |
| 
 | |
| void TDicForm::set_cursor(TCursor* cur) 
 | |
| {  
 | |
|   CHECK(cur, "NULL cursor in TDicForm");
 | |
|   _cur = cur; 
 | |
| } 
 | |
| 
 | |
| TDicForm::TDicForm(const char* form, const char* quadro) 
 | |
|         : TForm(form), _quadro(quadro), _prog(NULL), _cur(NULL), _anno(0)
 | |
| {
 | |
|   _can_print_tot_fis = _can_print_tot_nofis = FALSE;
 | |
|   _GiaStampatiFis = _GiaStampatiNoFis = _GiaMessoStartDoc = FALSE;
 | |
|   _GiaPosizionato = _posiziona = _modulaser = FALSE;          
 | |
|   _LastDitta = _EndPrintDitta = _PaginaPosizionamento = FALSE;
 | |
|   ClearFlagModulaser();
 | |
| }
 | |
| 
 | |
| long TDicForm::filtra(const long codditta)
 | |
| {
 | |
|   _codditta=codditta;
 | |
| 
 | |
| /* 
 | |
| // Dick Programming ON
 | |
|   TString filtr(24); 
 | |
|   filtr.format("CODDITTA=%ld", codditta);
 | |
|   _cur->setfilter(filtr, TRUE);   
 | |
| // Dick Programming OFF
 | |
| */         
 | |
| 
 | |
| // Dicky Programming ON
 | |
|   TRectype filtr(_cur->curr());
 | |
|   filtr.zero();
 | |
|   filtr.put("CODDITTA", codditta);
 | |
|   _cur->setregion(filtr, filtr);
 | |
|   _cur->setfilter("", TRUE);          // Update dei figli per ordinare per ragsoc
 | |
| // Dicky Programming OFF
 | |
| 
 | |
|   const long items = _cur->items();
 | |
|   return items;
 | |
| }
 | |
| 
 | |
| 
 | |
| bool TDicForm::InitPrint(const long codditta)
 | |
| {
 | |
|   _codditta = codditta;
 | |
|   _RigaCorr = 0;  
 | |
|   
 | |
|   TPrinter& pr = printer();
 | |
|   _posiziona=pr.printtype()==winprinter;
 | |
| //  if (_posiziona && !_GiaPosizionato && pr.printtype() == winprinter)  
 | |
|   if (_posiziona && !_GiaPosizionato && pr.printtype() == winprinter) 
 | |
|   {
 | |
|     posiziona();
 | |
| #ifdef DBG
 | |
|     if (!yesno_box("Proseguire con la stampa ?"))
 | |
|       return FALSE;
 | |
| #endif
 | |
|   }
 | |
|   
 | |
|   const bool was_open = pr.isopen();
 | |
|   
 | |
|   set_last_page(FALSE);   
 | |
|   set_curr_page(PRIMA);
 | |
|   
 | |
|   if (!was_open && !pr.open())
 | |
|     return FALSE;
 | |
|   do_events();
 | |
| 
 | |
|   _Items = filtra(codditta);
 | |
|   
 | |
|   if (_prog) 
 | |
|   {
 | |
|     delete _prog;
 | |
|     _prog = NULL;
 | |
|   }  
 | |
| 
 | |
|   if (_Items == 0L) // Se non ci sono record non stampa
 | |
|     return FALSE;
 | |
|   
 | |
|   _cur->freeze();   // Friggo il cursore durante la stampa
 | |
|   
 | |
|   if (pr.printtype() != screenvis)
 | |
|   {
 | |
|     TString msg(60);
 | |
|     msg.format("Elaborazione ditta %ld in corso...", codditta);
 | |
|     _prog = new TProgind(_Items, msg, FALSE,TRUE);
 | |
|   }
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TDicForm::close_print()
 | |
| {
 | |
|   if (_prog)
 | |
|   {
 | |
|     delete _prog;
 | |
|     _prog = NULL;
 | |
|   }  
 | |
|   _cur->freeze(FALSE);  // Ormai il cursore e' fritto al punto giusto
 | |
| }
 | |
| 
 | |
| bool TDicForm::print(const long codditta, const long NumFis, const long NumNoFis)
 | |
| {  
 | |
|   bool StabilitaInesistenzaNoFis = FALSE;
 | |
|   bool StabilitaInesistenzaFis = FALSE;  
 | |
|   long CtrFis   = NumFis;
 | |
|   long CtrNoFis = NumNoFis;
 | |
|   long PtrFis = -1L, PtrNoFis=-1L;
 | |
|   TPrinter& pr = printer();
 | |
|     
 | |
|   _CtrFisStampati = _CtrNoFisStampati = 0;
 | |
|   _finite_fis = _finite_nofis = FALSE;
 | |
|   _GiaStampatiFis = _GiaStampatiNoFis = FALSE;
 | |
|   _EndPrintDitta = FALSE;  // Vero se stampato l'ultimo record
 | |
|   bool LastRecord = FALSE; // Vero se letto l'ultimo record
 | |
| 
 | |
|   _PaginaCorrente = PRIMA;      
 | |
|   
 | |
|   if (!InitPrint(codditta))
 | |
|     return FALSE;
 | |
|   
 | |
|   TCursor* cur = cursor();
 | |
|   
 | |
|   while (!_EndPrintDitta)
 | |
|   {
 | |
|     for (int pagina=1; pagina <= QD_PAGINE; pagina++, next_page(pr))
 | |
|     {
 | |
|       pr.formlen(QD_FORMLEN);             
 | |
|     
 | |
|       if (_PaginaCorrente == PRIMA)
 | |
|       {                      
 | |
|         if (_modulaser) ClearFlagModulaser();
 | |
|         attiva_totali('F');
 | |
| 
 | |
|         for (int righe=0; righe < QD_RIGHE_PRIMA; righe++)
 | |
|         {
 | |
| // Stampa intestazione, solo sul primo foglio.
 | |
|           if (!righe)    
 | |
|           {
 | |
|             (*cur) = PtrFis >= 0L ? PtrFis : 0L;
 | |
|             stampa_testata(pr);
 | |
|           }
 | |
|         
 | |
|           if (_finite_fis || StabilitaInesistenzaFis)
 | |
|             break;
 | |
|           
 | |
| // La prima volta si deve posizionare sul primo record di p.f.
 | |
|           if (PtrFis<0L && !StabilitaInesistenzaFis)
 | |
|           {
 | |
|             bool Trovato = FALSE;
 | |
| 
 | |
|             while (!Trovato)
 | |
|             {
 | |
|               const long ditta = cur->curr().get_long(QUD_CODDITTA);
 | |
|               if (ditta != codditta)
 | |
|                 break;
 | |
|               const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
|               if (tipo != 'G')
 | |
|               {
 | |
|                 PtrFis = cur->pos();
 | |
|                 Trovato = TRUE;
 | |
|                 break;
 | |
|               } 
 | |
|               else
 | |
|                 ++(*cur);            
 | |
|             }                                        
 | |
|             StabilitaInesistenzaFis = _finite_fis = !Trovato;
 | |
|           }
 | |
| 
 | |
|           if (StabilitaInesistenzaFis)
 | |
|             break;
 | |
|          
 | |
|           (*cur) = PtrFis;
 | |
|           const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
|       
 | |
|           if (tipo != 'F')      
 | |
|             break;
 | |
|           else
 | |
|           {
 | |
|             CtrFis--;
 | |
|             if (CtrFis == 0L) _finite_fis = TRUE;
 | |
|             set_body(pr, 'F');
 | |
| // La stampa e' finita se ho STAMPATO l'ultimo record
 | |
|             LastRecord = cur->pos() >= _Items-1;
 | |
| //            _EndPrintDitta = LastRecord;
 | |
|             if (!LastRecord)
 | |
|             {
 | |
|               ++(*cur);
 | |
|               PtrFis = cur->pos();
 | |
|               LastRecord = cur->pos() >= _Items-1;
 | |
|             }
 | |
|           }
 | |
|         }   // for righe..
 | |
|         PtrFis = cur->pos();
 | |
|       }
 | |
| 
 | |
|       if (_PaginaCorrente == SECONDA)
 | |
|       {
 | |
| // Reset del flag di pagina con posiz.      
 | |
|         if (_posiziona && _PaginaPosizionamento) _PaginaPosizionamento = FALSE;
 | |
|         for (int righe=0; righe < QD_RIGHE_SECONDA; righe++)
 | |
|         {
 | |
|           if (!righe)
 | |
|             fill_page(pr, HEADER_SECONDA);
 | |
|           
 | |
|           if (_finite_fis || StabilitaInesistenzaFis)
 | |
|             break;
 | |
| 
 | |
|           (*cur) = PtrFis;
 | |
|           const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
| 
 | |
|           if (tipo != 'F')      
 | |
|             break;
 | |
|           else
 | |
|           {
 | |
|             CtrFis--;
 | |
|             if (CtrFis == 0L) _finite_fis = TRUE;
 | |
|             set_body(pr, 'F');
 | |
|             LastRecord = cur->pos() >= _Items-1;                    
 | |
| //            _EndPrintDitta = LastRecord;
 | |
|             if (!LastRecord)
 | |
|             {
 | |
|               ++(*cur);
 | |
|               PtrFis     = cur->pos();
 | |
|               LastRecord = cur->pos() >= _Items-1;          
 | |
|             }
 | |
|           }
 | |
|         }          
 | |
|         PtrFis = cur->pos();
 | |
|       }
 | |
| 
 | |
|       if (_PaginaCorrente == TERZA)
 | |
|       { 
 | |
|         for (int righe=0; righe < QD_RIGHE_TERZA; righe++)
 | |
|         {
 | |
|           if (!righe)
 | |
|           {
 | |
|             fill_page(pr, HEADER_TERZA);
 | |
|             _CtrFisStampati = 0;  // conta quelli che stampo sulla terza                    
 | |
|           }
 | |
| 
 | |
|           if (_finite_fis || StabilitaInesistenzaFis)
 | |
|             break;
 | |
| 
 | |
|           (*cur) = PtrFis;
 | |
|           const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
| 
 | |
|           if (tipo != 'F')      
 | |
|             break;
 | |
|           else
 | |
|           {
 | |
|             CtrFis--;                            
 | |
|             if (CtrFis == 0L) _finite_fis = TRUE;          
 | |
|             set_body(pr, 'F');
 | |
|             LastRecord = cur->pos() >= _Items-1;                    
 | |
| //            _EndPrintDitta = LastRecord;  
 | |
|             _CtrFisStampati++;
 | |
|             if (!LastRecord)
 | |
|             {
 | |
|               ++(*cur);                      
 | |
|               PtrFis     = cur->pos();
 | |
|               LastRecord = cur->pos() >= _Items-1;          
 | |
|             }
 | |
|           }
 | |
|         }          
 | |
|         PtrFis = cur->pos();
 | |
|       }
 | |
| 
 | |
|       if (_PaginaCorrente == QUARTA)
 | |
|       {  
 | |
|         attiva_totali('G');
 | |
|         for (int righe=0; righe < QD_RIGHE_QUARTA; righe++)
 | |
|         {
 | |
|           if (!righe)
 | |
|             _CtrNoFisStampati = 0;
 | |
| 
 | |
| // All'inizio salta le righe in alto
 | |
|           if (!righe)
 | |
|             fill_page(pr, HEADER_QUARTA);
 | |
| 
 | |
|           if (_finite_nofis || StabilitaInesistenzaNoFis)
 | |
|             break;
 | |
| 
 | |
| // La prima volta si deve posizionare sul primo record di p.g.
 | |
|           if (PtrNoFis<0L && !StabilitaInesistenzaNoFis)
 | |
|           {
 | |
|             bool Trovato = FALSE;
 | |
|             bool eof = FALSE;
 | |
|             (*cur) = PtrFis-1 > 0L ? PtrFis-1 : 0L;  // parti dall'inizio
 | |
|             while (!Trovato && !eof)
 | |
|             {
 | |
|               eof = cur->pos() >= _Items-1;                    
 | |
|               const long ditta = cur->curr().get_long(QUD_CODDITTA);
 | |
|               if (ditta != codditta)
 | |
|                 break;
 | |
|               const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
|               if (tipo != 'F')
 | |
|               {
 | |
|                 PtrNoFis = cur->pos();
 | |
|                 Trovato = TRUE;
 | |
|                 break;
 | |
|               }
 | |
|               else
 | |
|                 ++(*cur);            
 | |
|             }                                        
 | |
|             StabilitaInesistenzaNoFis = _finite_nofis = !Trovato;
 | |
|           }
 | |
|         
 | |
|           if (StabilitaInesistenzaNoFis)
 | |
|             break;
 | |
|         
 | |
|           (*cur) = PtrNoFis;
 | |
|           const char tipo = cur->curr().get(QUD_TIPOA)[0];
 | |
| 
 | |
|           if (tipo != 'G')      
 | |
|             break;
 | |
|           else
 | |
|           {
 | |
|             CtrNoFis--;                          
 | |
|             if (CtrNoFis == 0L) 
 | |
|               _finite_nofis = TRUE;          
 | |
|             set_body(pr, 'G'); 
 | |
|             LastRecord     = cur->pos() >= _Items-1;                    
 | |
| //            _EndPrintDitta = LastRecord;
 | |
|             _CtrNoFisStampati++;   
 | |
|             if (!LastRecord)
 | |
|             {
 | |
|               ++(*cur);
 | |
|               PtrNoFis   = cur->pos();
 | |
|               LastRecord = cur->pos() >= _Items-1;          
 | |
|             }
 | |
|           }
 | |
|         }          
 | |
|         PtrNoFis = cur->pos();
 | |
|         _EndPrintDitta = _finite_fis && _finite_nofis;
 | |
|       } 
 | |
|       
 | |
|     }  // for pagina..
 | |
|   }  // while !_EndPrintDitta   
 | |
|   close_print();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| 
 | |
| void TDicForm::ClearFlagModulaser()
 | |
| {
 | |
|   for (int i=0; i<=QD_PAGINE; i++)
 | |
|     _GiaMessoStartPage[i] = FALSE;
 | |
| }
 | |
| 
 | |
| bool TDicForm::ultima_fis()
 | |
| {
 | |
|   return _can_print_tot_fis && _finite_fis && !_GiaStampatiFis;   
 | |
| }
 | |
| 
 | |
| bool TDicForm::ultima_nofis()
 | |
| {
 | |
|   return _can_print_tot_nofis && _finite_nofis && !_GiaStampatiNoFis;
 | |
| }
 | |
|                                    
 | |
| void TDicForm::inc_curr_page()
 | |
| {                      
 | |
|   if (_PaginaCorrente == PRIMA)
 | |
|     _PaginaCorrente = SECONDA;
 | |
|   else
 | |
|     if (_PaginaCorrente == SECONDA)
 | |
|       _PaginaCorrente = TERZA;
 | |
|     else
 | |
|       if (_PaginaCorrente == TERZA)
 | |
|         _PaginaCorrente = QUARTA; 
 | |
|       else
 | |
|         if (_PaginaCorrente == QUARTA)
 | |
|           _PaginaCorrente = PRIMA;
 | |
| }
 | |
| 
 | |
| const char* TDicForm::BuildModulaserStartPage()
 | |
| {
 | |
|   __dep16="<VK>*";
 | |
|   if (_quadro=="Base")
 | |
|     __dep16<<"1";
 | |
|   else if (_quadro=="A")
 | |
|     __dep16<<"2";        
 | |
|   else if (_quadro=="AB")
 | |
|     __dep16<<"3";  
 | |
|   else if (_quadro=="A1")
 | |
|     __dep16<<"4";
 | |
|   else if (_quadro=="A2")
 | |
|     __dep16<<"5";
 | |
|   else if (_quadro=="A3")
 | |
|     __dep16<<"6";
 | |
|   else if (_quadro=="B")
 | |
|     __dep16<<"7";
 | |
|   else if (_quadro=="B1")
 | |
|     __dep16<<"8";
 | |
|   else if (_quadro=="C")
 | |
|     __dep16<<"9";
 | |
|   else if (_quadro=="D")
 | |
|     __dep16<<"10";      
 | |
|   else if (_quadro=="DB")
 | |
|     __dep16<<"11";  
 | |
|   else if (_quadro=="D1")
 | |
|     __dep16<<"12";
 | |
|   else if (_quadro=="E")
 | |
|     __dep16<<"13";
 | |
|   else if (_quadro=="E1")
 | |
|     __dep16<<"14";
 | |
|   else if (_quadro=="E2")
 | |
|     __dep16<<"15";
 | |
|   else if (_quadro=="F")
 | |
|     __dep16<<"16";
 | |
|   else if (_quadro=="F1")
 | |
|     __dep16<<"17";
 | |
|   else if (_quadro=="F2")
 | |
|     __dep16<<"18";
 | |
|   else if (_quadro=="G")
 | |
|     __dep16<<"19";
 | |
|   else if (_quadro=="G1")
 | |
|     __dep16<<"20";
 | |
|   else if (_quadro=="H")
 | |
|     __dep16<<"21";
 | |
|   else if (_quadro=="N")
 | |
|     __dep16<<"22";
 | |
|   else if (_quadro=="U")
 | |
|     __dep16<<"23";
 | |
|   else if (_quadro=="L")
 | |
|     __dep16<<"24";  
 | |
| 
 | |
|   __dep16<<"*";
 | |
|   return __dep16;
 | |
| }
 | |
| 
 | |
| void TDicForm::put_modulaser(TPrintrow& row, ModulaserKey Cmd, int page)
 | |
| {
 | |
|   TString riga(80);
 | |
|   
 | |
|   switch (Cmd)
 | |
|   {
 | |
|     case VEGASTARTDOC:
 | |
|       if (!_GiaMessoStartDoc)
 | |
|       {
 | |
|           riga = "\xf";   // Printer escape: font 17cpi
 | |
|           riga << VK_STARTDOC;
 | |
|           _GiaMessoStartDoc = TRUE;
 | |
|       }
 | |
|       break;
 | |
|     case VEGASTARTDITTA:
 | |
|       {
 | |
|         riga = "<VK>$";
 | |
|         TString cofi(16);            
 | |
|         TString ragsoc(50);        
 | |
| // Legge il codice fisc.e la rag.soc. del sogg.dich. oppure della ditta corrente              
 | |
|         if (_tipo_ditta == estinto)        
 | |
|         {
 | |
|           cofi = _cofi_dic;
 | |
|           ragsoc = get_ragsoc(_codditta_dic);
 | |
|         }
 | |
|         else    
 | |
|         {    
 | |
|           cofi = cod_fis(_codditta);
 | |
|           ragsoc = get_ragsoc(_codditta);  
 | |
|         }
 | |
|         riga << cofi;     // Cod.Fiscale     
 | |
|         riga << "$00/";    // Cod.Studio/ 
 | |
|         if (_tipo_ditta == estinto)        
 | |
|           riga << _codditta_dic;    // Cod.Cliente        
 | |
|         else
 | |
|           riga << _codditta;
 | |
|         riga << "$";
 | |
|         riga << ragsoc;   // RagSoc
 | |
|       }
 | |
|       break;
 | |
|     case VEGASTARTPAGE:
 | |
|       riga = BuildModulaserStartPage();
 | |
|       riga << page;                                     
 | |
|       _GiaMessoStartPage[page] = TRUE;
 | |
|       break;
 | |
|     case VEGAENDDOC:
 | |
|       riga << VK_ENDDOC;
 | |
|       break;      
 | |
|     default:
 | |
|       break;
 | |
|   }        
 | |
|   riga.rtrim();
 | |
|   riga << '\r';
 | |
|   row.put(riga);
 | |
| }                  
 | |
| 
 | |
| 
 | |
| bool TDicForm::PaginaPosizionamento() const
 | |
| {
 | |
|   return _PaginaPosizionamento && curr_page() == PRIMA;
 | |
| }
 | |
| 
 | |
| int TDicForm::dic_form_len() const
 | |
| {                       
 | |
| //  if (curr_page() == PRIMA && _PaginaPosizionamento && !_GiaPosizionato) 
 | |
|   if (curr_page() == PRIMA && _PaginaPosizionamento)
 | |
|     return QD_FORMLEN-HEADER_PRIMA_NOPOS;
 | |
|   else
 | |
|     return QD_FORMLEN;
 | |
| }
 | |
| 
 | |
| // Stampa "righe" righe vuote. Se righe e' -1 fa un formfeed mettendo
 | |
| // il codice ditta sull'ultima riga
 | |
| void TDicForm::fill_page(TPrinter& pr, const int righe)
 | |
| {
 | |
|   TPrintrow row;   
 | |
|   PaginaQuadro pagina = curr_page();
 | |
|   
 | |
| // form feed
 | |
|   if (righe < 0)
 | |
|   {
 | |
|     const int stop = dic_form_len();
 | |
|     for (int i = _RigaCorr; i < stop; i++)
 | |
|     {
 | |
|       if (i == 0)
 | |
|         if (_modulaser)
 | |
|         {
 | |
|           if (pagina == PRIMA)
 | |
|             put_modulaser(row, VEGASTARTDITTA);
 | |
|           if (!_GiaMessoStartPage[pagina])
 | |
|             put_modulaser(row, VEGASTARTPAGE, pagina);
 | |
|         }
 | |
|       // Sull'ultima riga metto il codice ditta 
 | |
|       if (i == stop - 1)
 | |
|       {
 | |
|         
 | |
|         if (_modulaser && EndJob() && ultima_pagina()) // Se siamo in ultima pagina...
 | |
|           put_modulaser(row, VEGAENDDOC); // Aggiunge la VegaKey di fine Documento, separata da \r
 | |
|         TString16 ditta; ditta << _codditta;
 | |
|         row.put(ditta, POS_DITTA);        
 | |
|       }                           
 | |
|       
 | |
|       pr.print(row);                     
 | |
|       row.reset();        
 | |
|     }
 | |
|     _RigaCorr = 0;
 | |
|     return;
 | |
|   }    
 | |
|   else      // righe > 0           
 | |
|   {
 | |
|     for (int i=0; i < righe; i++)
 | |
|     {
 | |
|       if (_RigaCorr == 0)
 | |
|       {
 | |
|         if (_modulaser)
 | |
|         {
 | |
|           if (pagina == PRIMA)
 | |
|             put_modulaser(row, VEGASTARTDITTA);
 | |
|           if (!_GiaMessoStartPage[pagina])
 | |
|             put_modulaser(row, VEGASTARTPAGE, pagina);
 | |
|         }
 | |
|       }
 | |
|       else
 | |
|         row.reset();
 | |
|       
 | |
|       pr.print(row);
 | |
|       row.reset();
 | |
|       _RigaCorr++;
 | |
|     }
 | |
|   }  
 | |
| }
 | |
| 
 | |
| void TDicForm::jump_to_line(TPrinter& pr, const int lin)
 | |
| {
 | |
|   if (_RigaCorr > lin)           
 | |
|     fill_page(pr, -1);
 | |
|   fill_page(pr, lin - _RigaCorr);
 | |
| }
 | |
| 
 | |
| 
 | |
| int TDicForm::firma_dichiarante()
 | |
| { 
 | |
|   TPrint_section& footer = section('F', last_page);
 | |
|   TForm_item& firma = footer.find_field(FIRMADIC);  
 | |
|   
 | |
|   const int y = firma.y()-1;
 | |
| 
 | |
|   TString cognome = firma.get();
 | |
|   if (cognome.len() > 30 && cognome[29] == ' ')
 | |
|   {
 | |
|     TString nome = cognome.mid(30, -1);
 | |
|     cognome.cut(30); cognome.trim();
 | |
|     cognome << ' ' << nome;
 | |
|     firma.set(cognome);
 | |
|         
 | |
|     footer.row(y).reset();
 | |
|     footer.row(y).put(cognome, firma.x()-1);   
 | |
|   }  
 | |
|   
 | |
|   return y;
 | |
| }
 | |
| 
 | |
| void TDicForm::attiva_totali(char tipo)
 | |
| {
 | |
|   TPrint_section& foot = section('F', last_page);  
 | |
|   for (int f = foot.fields()-1; f >= 0; f--)
 | |
|   {                
 | |
|     TForm_item& item = foot.field(f);
 | |
|     if (tipo == 'F')
 | |
|     {
 | |
|       _tot_giu.add(item.get(), f);
 | |
|       if (_tot_fis.items())
 | |
|         item.set(_tot_fis.row(f));
 | |
|       else
 | |
|         item.set("");  
 | |
|     } 
 | |
|     else
 | |
|     {
 | |
|       _tot_fis.add(item.get(), f);
 | |
|       if (_tot_giu.items())
 | |
|         item.set(_tot_giu.row(f));
 | |
|       else
 | |
|         item.set("");  
 | |
|     } 
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDicForm::stampa_totali(TPrinter& pr, bool tot, bool fir)
 | |
| { 
 | |
|   TPrint_section& totali = section('F', last_page);
 | |
|   totali.update();
 | |
|   
 | |
|   const int y = firma_dichiarante();
 | |
|   for (int i = 0; i <= y; i++)
 | |
|   {               
 | |
|     TPrintrow& row = totali.row(i);
 | |
|     if ((i < y && !tot) || (i == y && !fir))
 | |
|       row.reset();
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDicForm::stampa_testata(TPrinter& pr)
 | |
| {
 | |
|   TPrint_section& head = section('H', first_page);
 | |
|   const word r = head.height()-1;
 | |
|   TPrintrow& head_row = head.row(r-1);                    
 | |
| 
 | |
| // Setta il numero di pagina e poi lo incrementa
 | |
|   TForm_item& nf = head.find_field(H_NUM_FOGLIO);          
 | |
|   TString fstr(10); fstr << _num_foglio;
 | |
|   nf.set(fstr);      
 | |
|   _num_foglio++;
 | |
|   
 | |
| // Setta il cod.fis. del dichiarante se necessario
 | |
|   if (tipo_ditta() == estinto)
 | |
|   {
 | |
|     TForm_item& cfd = head.find_field(H_COFI_DIC);
 | |
|     cfd.set(_cofi_dic);
 | |
|   }  
 | |
| // Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
 | |
| // senza le righe del posizionamento...)
 | |
|   int righedasaltare=HEADER_PRIMA_NOPOS;
 | |
|   head.update();  
 | |
|   for (word j = 0; j <= r; j++)
 | |
|   {
 | |
|     if (j==0)
 | |
|     {        
 | |
|       if (_modulaser)
 | |
|       {
 | |
|         TPrintrow& r = head.row(j);
 | |
|         if (!_GiaMessoStartDoc)
 | |
|           put_modulaser(r, VEGASTARTDOC);     
 | |
|         put_modulaser(r, VEGASTARTDITTA);
 | |
|         put_modulaser(r, VEGASTARTPAGE, 1);
 | |
|         pr.print(r);
 | |
|         _RigaCorr++;
 | |
|         r.reset();
 | |
|         righedasaltare--;
 | |
|       }
 | |
|       if (!PaginaPosizionamento())
 | |
|         fill_page(pr, righedasaltare);
 | |
|     }    
 | |
|     TPrintrow& row = head.row(j);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDicForm::next_page(TPrinter& pr)
 | |
| {
 | |
|   fill_page(pr, -1);   // formfeed "adattato"  
 | |
|   inc_curr_page();
 | |
| }
 | |
| 
 | |
| void TDicForm::azzera_totali()
 | |
| {
 | |
|   TPrint_section& foot = section('F', last_page);  
 | |
|   foot.reset();
 | |
|   for (int f = foot.fields()-1; f >= 0; f--)
 | |
|     foot.field(f).set("");
 | |
|     
 | |
|   _tot_fis.destroy();
 | |
|   _tot_giu.destroy();
 | |
| }
 | |
| 
 | |
| void TDicForm::set_body(TPrinter& pr, const char tipo)
 | |
| {
 | |
|   TPrint_section& body = section('B', odd_page);
 | |
|   body.reset();
 | |
|   body.update();       
 | |
| 
 | |
|   const int body_righe = body.height();
 | |
|   for (int i = 0; i < body_righe; i++)
 | |
|   {           
 | |
|     TPrintrow& row = body.row(i);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   }
 | |
|   if (usa_progind())
 | |
|     progind()->addstatus(1);
 | |
| }
 | |
| 
 | |
| void TDicForm::posiziona()
 | |
| {
 | |
|   _GiaPosizionato = TRUE;
 | |
|   _PaginaPosizionamento = TRUE;
 | |
|   
 | |
|   if (printer().is_generic())
 | |
|     arrange_form();
 | |
| }
 | |
| 
 | |
| ////////////////////////////////////////////////////////////////////////////////////////////
 | |
| //  
 | |
| //                                        TStDicArray                                                                                    
 | |
| //
 | |
| // Array delle ditte da stampare. Contiene una riga per ogni ditta che si vuole stampare
 | |
| // Il formato della riga e': 
 | |
| //   codditta|estinti|numfis|numnofis|ultimafis|ultimanofis  
 | |
| //
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| TToken_string& TStDicArray::operator[](int i) const
 | |
| { 
 | |
|   return ((TString_array&)_store).row(i);
 | |
| }
 | |
| 
 | |
| void TStDicArray::set_ultima_con_fis(const int index, const bool ultima_fis)
 | |
| {  
 | |
|   TToken_string riga((TString&)_store[index]);
 | |
|   riga.add(ultima_fis, 4);
 | |
|   _store.add(riga,index);
 | |
| }
 | |
| 
 | |
| void TStDicArray::set_ultima_con_nofis(const int index, const bool ultima_nofis)
 | |
| {  
 | |
|   TToken_string riga((TString&)_store[index]);
 | |
|   riga.add(ultima_nofis, 5);
 | |
|   _store.add(riga,index);
 | |
| }
 | |
| 
 | |
| void TStDicArray::set_flag_tipi(const int index, const bool ultima_fis, const bool ultima_nofis)
 | |
| {
 | |
|   TToken_string riga((TString&)_store[index]);
 | |
|   riga.add(ultima_fis,4);
 | |
|   riga.add(ultima_nofis,5);
 | |
|   _store[index] = riga;
 | |
| }
 | |
| 
 | |
| void TStDicArray::set_ctr_tipi(const int index, const int num_fis, const int num_nofis)
 | |
| {
 | |
|   TToken_string riga((TString&)_store[index]);
 | |
|   riga.add(num_fis,2);
 | |
|   riga.add(num_nofis,3);
 | |
|   _store[index] = riga;
 | |
| }
 | |
| 
 | |
| void TStDicArray::set(const int index, const TipoDitta tipo, const int num_fis, const int num_nofis,
 | |
|                       bool ultima_con_fis, bool ultima_con_nofis, const char* cofi_dic)
 | |
| {
 | |
|   TToken_string riga((TString&)_store[index]);
 | |
|   riga.add(tipo,1);
 | |
|   riga.add(num_fis,2);
 | |
|   riga.add(num_nofis,3);
 | |
|   riga.add(ultima_con_fis,4);
 | |
|   riga.add(ultima_con_nofis,5);
 | |
|   TString codfis(20); codfis = cofi_dic ? cofi_dic : "";
 | |
|   riga.add((const char*)codfis,6);
 | |
|   _store[index] = riga;
 | |
| }            
 | |
| 
 | |
| void TStDicArray::add(const long codditta, const TipoDitta tipo, const int num_fis, const int num_nofis,
 | |
|              bool ultima_con_fis, bool ultima_con_nofis, const char* cfdic)
 | |
| {
 | |
|   TString key(40);
 | |
| // Il formato della riga e': codditta|estinti|numfis|numnofis|ultimafis|ultimanofis  
 | |
|   key.format("%ld|%d|%d|%d|%d|%d|%s", codditta, tipo, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis, cfdic ? cfdic : "");
 | |
|   _store.add(key);
 | |
| }
 | |
| 
 | |
| //////////////////////////////////////////////////////////////////////////////////////////
 | |
| //                        TStampaQuadro
 | |
| //////////////////////////////////////////////////////////////////////////////////////////
 | |
| TStampaQuadro::TStampaQuadro(const char* quad, char liv)
 | |
|               : _quadro(quad), _livello(liv)
 | |
| { 
 | |
|   _title = "Stampa Quadro "; _title << _quadro;
 | |
| } 
 | |
| 
 | |
| // La maschera e' uguale per tutti i quadri
 | |
| const char* TStampaQuadro::mask_name() const
 | |
| {
 | |
|   return "77STQD";
 | |
| }
 | |
| 
 | |
| const char* TStampaQuadro::form_name() const
 | |
| {
 | |
|   __dep16 = "77Q";
 | |
|   __dep16 << _quadro;
 | |
|   return __dep16;
 | |
| }
 | |
| 
 | |
| bool TStampaQuadro::setprint_handler(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_SPACE)
 | |
|   {
 | |
|     TPrinter& pr = printer();
 | |
|     if (pr.set()) // Aggiorna la stampante
 | |
|     {
 | |
|       f.mask().set(F_CURRPRINTER, get_printer_name());
 | |
|     }
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TStampaQuadro::create()
 | |
| {
 | |
|   TApplication::create();
 | |
| 
 | |
|   _section = name(); 
 | |
|   _section.cut(2); 
 | |
|   _cnf = new TConfig(CONFIG_USER, _section);
 | |
| 
 | |
|   _m = new TMask(mask_name()); 
 | |
|   _m->set_caption(taitol());
 | |
|   _m->set_handler(DLG_SETPRINT, setprint_handler);
 | |
| 
 | |
|   if (singola_ditta())
 | |
|   {
 | |
|     _codditta = get_firm_770();  
 | |
|     _m->set(F_CODDITTA, _codditta);
 | |
|   } 
 | |
|   else
 | |
|   {
 | |
|     _m->set(F_TEXT, "Ditte selezionate");
 | |
|     _m->show(F_TEXT);
 | |
|   }
 | |
| 
 | |
|   user_create();
 | |
|   
 | |
|   dispatch_e_menu(BAR_ITEM_ID(1));  
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TStampaQuadro::destroy()
 | |
| { 
 | |
|   user_destroy();
 | |
| 
 | |
|   delete _m;
 | |
|   delete _cnf;
 | |
|   return TApplication::destroy();
 | |
| }
 | |
| 
 | |
| void TStampaQuadro::on_config_change()
 | |
| { 
 | |
|   TConfig conf(singola_ditta() ? CONFIG_STUDIO : CONFIG_USER);
 | |
|   _anno_dic = (int)conf.get_long(ANNO_SEL, _section); 
 | |
| }
 | |
| 
 | |
| bool TStampaQuadro::menu(MENU_TAG)
 | |
| {
 | |
|   KEY k;
 | |
|   TPrinter& pr = printer();
 | |
|   _m->set(F_ANNO, _anno_dic);
 | |
|   
 | |
|   _m->set(F_CURRPRINTER, get_printer_name());
 | |
|   disable_menu_item(M_FILE_PG_SETUP);  
 | |
|   
 | |
|   while ((k = _m->run()) == K_ENTER) 
 | |
|   {
 | |
|     const bool modulaser = _m->get_bool(F_MODULASER);
 | |
|     const bool append    = _m->get_bool(F_APPENDFILE);
 | |
|     // Se e' selezionata la stampa per modulaser (flag + stampa su file)
 | |
|     // setta il flag per la stampa in coda al file selezionato
 | |
|     pr.set_append(modulaser && pr.printtype() == fileprinter && append);
 | |
|     print(modulaser);
 | |
|   }  
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void TStampaQuadro::fill_estinti(const long CodDic)
 | |
| { 
 | |
|   int NumFisiche=0, NumNoFisiche=0;
 | |
|   TString CodFiDic(20);
 | |
|     
 | |
| // Salva il cod.fis. del dichiarante
 | |
|   CodFiDic = cod_fis(CodDic);
 | |
| 
 | |
|   if (conta_tipi_per())        
 | |
|   {
 | |
|     conta_tipiper(CodDic, _quadro, &NumFisiche, &NumNoFisiche);      
 | |
|     _ditte.add(CodDic, dichiarante, NumFisiche, NumNoFisiche);
 | |
|   } 
 | |
|   else                                                        
 | |
|     _ditte.add(CodDic, dichiarante);
 | |
|   
 | |
|   const int index_dich = _ditte.curr_index();
 | |
|   bool gia_trovata_ultima_fis = FALSE;
 | |
|   bool gia_trovata_ultima_nofis = FALSE;
 | |
|   int index = index_dich;
 | |
| 
 | |
| // Leggo gli estinti
 | |
|   TLocalisamfile base(LF_BASE);
 | |
|   base.setkey(2);
 | |
|   base.zero();   
 | |
|   base.put(BSE_CODDIC, (long)CodDic);
 | |
|   TRectype dep(base.curr()); 
 | |
| 
 | |
|   for (base.read(); !base.eof(); base.next())
 | |
|   {
 | |
|     if (base.curr() > dep)
 | |
|       break;
 | |
| 
 | |
| // Scarta il record del quadro I "globale" del dichiarante            
 | |
|     const char tipoqua = base.get(BSE_TIPOQUA)[0];
 | |
|     if (tipoqua == COD_QUA_I_DIC)
 | |
|       continue;
 | |
| 
 | |
|     const long DittaEstinta = base.get_long(BSE_CODDITTA);
 | |
| 
 | |
|     if (conta_tipi_per())
 | |
|     {
 | |
|       conta_tipiper(DittaEstinta, _quadro, &NumFisiche, &NumNoFisiche);
 | |
|       _ditte.add(DittaEstinta, estinto, NumFisiche, NumNoFisiche, FALSE, FALSE, CodFiDic);
 | |
|     }
 | |
|     else
 | |
|       _ditte.add(DittaEstinta, estinto, 0L, 0L, FALSE, FALSE, CodFiDic);    
 | |
| 
 | |
|     if (conta_tipi_per())
 | |
|     {
 | |
|       // Determina se con questa ditta finiscono le persone f. o g.
 | |
|       if (NumFisiche == 0 && !gia_trovata_ultima_fis) 
 | |
|       {
 | |
|         _ditte.set_ultima_con_fis(index, TRUE);
 | |
|         gia_trovata_ultima_fis = TRUE;
 | |
|       }
 | |
|    
 | |
|       if (NumNoFisiche == 0 && !gia_trovata_ultima_nofis)          
 | |
|       {
 | |
|         _ditte.set_ultima_con_nofis(index, TRUE);
 | |
|         gia_trovata_ultima_nofis = TRUE;
 | |
|       }
 | |
|     }
 | |
|     index++;
 | |
|   }
 | |
| 
 | |
|   if (conta_tipi_per())
 | |
|   {
 | |
| // Finiti gli estinti. L'ultima ditta deve avere i totali se non gia' trovati
 | |
|     if (!gia_trovata_ultima_fis)
 | |
|       _ditte.set_ultima_con_fis(index, TRUE);        
 | |
| 
 | |
|     if (!gia_trovata_ultima_nofis)
 | |
|       _ditte.set_ultima_con_nofis(index, TRUE);        
 | |
|   }
 | |
| }
 | |
| 
 | |
| // _ditte e' fatto di righe siffatte:
 | |
| // codditta, flag 2 dichiarante, 1 normale, 0 estinto, num_fis, num_nofis, ultima_con_fis, ultima_con_nofis
 | |
| 
 | |
| bool TStampaQuadro::print_quadro(const int OffsetDitta, const bool modulaser)
 | |
| {
 | |
|   TDicForm* ff = get_form();
 | |
|   int start=0, last=0;
 | |
| // Setta formlen prima di printer.open per avere la lunghezza giusta nel caso di 
 | |
| // stampa a video
 | |
|   printer().formlen(QD_FORMLEN);               
 | |
|   bool ok = printer().open();
 | |
| 
 | |
|   ff->set_cursor(get_cursor());
 | |
|   ff->azzera_totali();
 | |
|   ff->set_modulaser(modulaser);
 | |
|   
 | |
| // Dice se deve eseguire il posizionamento del foglio.
 | |
| // Se stampa piu' ditte va eseguito solo sulla prima
 | |
| // Occhio a non spostarlo nel ciclo.
 | |
|   ff->set_posiziona(TRUE);
 | |
|     
 | |
|   if (OffsetDitta >= 0)
 | |
|   {
 | |
|     start = OffsetDitta;
 | |
|     last = OffsetDitta;  
 | |
|   }
 | |
|   else
 | |
|     last = _ditte.items() - 1;
 | |
|     
 | |
|   for (int i = start; i <= last; i++)
 | |
|   {
 | |
|     TString CoFiDic(20);
 | |
|     TToken_string riga(ditte()[i]);
 | |
|     const long codditta = atol(riga.get(0));
 | |
|     const TipoDitta  tipo = (TipoDitta)riga.get_int(1);
 | |
|     const long fis      = riga.get_long(2);
 | |
|     const long nofis    = riga.get_long(3);
 | |
|     const bool LastFis  = riga.get_int(4) != 0;
 | |
|     const bool LastNoFis = riga.get_int(5) != 0;
 | |
| 
 | |
| // I gruppi dich-estinti hanno totali comuni  
 | |
| // Si presume che nell'array vengano messi nell'ordine dich-estinti
 | |
|     if (tipo == normale || tipo == dichiarante)
 | |
|       ff->azzera_totali();
 | |
| 
 | |
|     if (tipo == estinto)
 | |
|       CoFiDic = riga.get(6);
 | |
| 
 | |
|     if (conta_tipi_per())
 | |
|     {      
 | |
| // Se e' un dichiarante i totali vanno sull'estinto in cui finiscono o le F o le G
 | |
|       const bool StampaTotaliFis = tipo == normale || 
 | |
|                                   (tipo == estinto && LastFis);
 | |
| 
 | |
|       const bool StampaTotaliNoFis = tipo == normale || 
 | |
|                                     (tipo == estinto && LastNoFis);
 | |
| 
 | |
| // Dice al form se e' questa ditta e' l'ultima con f. o g.
 | |
|       ff->can_print_tot_fis(StampaTotaliFis);
 | |
|       ff->can_print_tot_nofis(StampaTotaliNoFis);
 | |
|     }
 | |
| 
 | |
| // Dice al form che tipo di ditta si stampa
 | |
|     ff->set_tipo_ditta(tipo);
 | |
| 
 | |
| // Numera i fogli a partire da 1 per ogni ditta normale e da 1 e di seguito negli estinti
 | |
| // per i sogg. dichiaranti
 | |
|     if (tipo == normale || tipo == dichiarante)
 | |
|       ff->set_num_foglio(1);
 | |
|       
 | |
| // Se la ditta e' estinta dice al form il cod.fis. del dichiarante
 | |
|     if (tipo == estinto)
 | |
|       ff->set_cofi_dic(CoFiDic);
 | |
| 
 | |
| // Dice al form che e' l'ultima ditta
 | |
|     if (i == last)
 | |
|       ff->set_last_ditta(TRUE);
 | |
|       
 | |
|     ff->print(codditta, fis, nofis);
 | |
|   }   
 | |
|   
 | |
|   ff->set_last_ditta(FALSE);
 | |
|   printer().close();
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| void TStampaQuadro::print(const bool modulaser)
 | |
| {
 | |
|   int NumFisiche=0, NumNoFisiche=0;
 | |
| 
 | |
|   _ditte.destroy();  // Pulisce l'array delle ditte
 | |
|   
 | |
|   if (singola_ditta())           
 | |
|   {
 | |
|     if (sogg_estinto(_codditta))
 | |
|     {
 | |
|       warning_box("La ditta %ld e' un soggetto estinto", _codditta);
 | |
|       return;
 | |
|     }
 | |
| 
 | |
| // Se e' un dichiarante va a prendere tutti i suoi estinti.
 | |
|     bool dich = sogg_dic(_codditta);
 | |
|     if (dich)             
 | |
|       fill_estinti(_codditta);    
 | |
|     else
 | |
|     {                                                                    
 | |
|       if (conta_tipi_per())
 | |
|       {
 | |
|         conta_tipiper(_codditta, _quadro, &NumFisiche, &NumNoFisiche);            
 | |
|         _ditte.add(_codditta, normale, NumFisiche, NumNoFisiche);      
 | |
|       }
 | |
|       else
 | |
|         _ditte.add(_codditta, normale);            
 | |
|     }
 | |
|   }
 | |
|   else    // stampa ditte selezionate
 | |
|   {     
 | |
| // Costruisco un'array delle ditte da stampare. 
 | |
| // Tolgo i sogg. estinti, e dopo un dichiarante metto tutti i suoi estinti.
 | |
|     long codditta_prec = get_firm_770();
 | |
|     long codditta = 0L;
 | |
|     int i=0;
 | |
|     while ((codditta = _cnf->get_long(DITTE_SEL, _section, i++)) != 0L) 
 | |
|     {  
 | |
|       if (sogg_estinto(codditta))
 | |
|         continue;
 | |
| 
 | |
| // Se e' un dichiarante va a prendere tutti i suoi estinti.
 | |
|       bool dich = sogg_dic(codditta);
 | |
|       if (dich)             
 | |
|         fill_estinti(codditta);
 | |
|       else
 | |
|       {                                                                    
 | |
|         if (conta_tipi_per())
 | |
|         {
 | |
|           conta_tipiper(codditta, _quadro, &NumFisiche, &NumNoFisiche);            
 | |
|           _ditte.add(codditta, normale, NumFisiche, NumNoFisiche);      
 | |
|         }
 | |
|         else                                                            
 | |
|           _ditte.add(codditta, normale);              
 | |
|       }
 | |
|     }  
 | |
|     set_firm_770(codditta_prec);
 | |
|   }
 | |
|   
 | |
|   TCursor* cur = get_cursor();
 | |
|   if (cur != NULL)
 | |
|   {
 | |
|     TRectype filtr(cur->curr());
 | |
|     
 | |
|     for (int i = _ditte.items() - 1; i >= 0; i--)
 | |
|     {
 | |
|       filtr.zero();
 | |
|       filtr.put("CODDITTA", _ditte[i].get_long(0));
 | |
|       cur->setregion(filtr, filtr);
 | |
|       cur->setfilter("", TRUE);          // Update dei figli per ordinare per ragsoc
 | |
|       if (cur->items() > 0L)
 | |
|         break;
 | |
|       else
 | |
|         _ditte.remove(i);
 | |
|     }
 | |
|   }
 | |
|   print_quadro(-1, modulaser);
 | |
| }
 | |
| 
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| //
 | |
| //                                     STAMPA QUADRO D
 | |
| //
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| void TQuadroD::stampa_testata(TPrinter& pr)
 | |
| {
 | |
|   TPrint_section& head = section('H', first_page);
 | |
|   const word r = head.height();
 | |
| 
 | |
| // Setta il numero di pagina e poi lo incrementa
 | |
|   TForm_item& nf = head.find_field(H_NUM_FOGLIO);          
 | |
|   TString fstr(10); fstr << _num_foglio;
 | |
|   nf.set(fstr);      
 | |
|   _num_foglio++;
 | |
|   
 | |
| // Setta il cod.fis. del dichiarante se necessario
 | |
|   if (tipo_ditta() == estinto)
 | |
|   {
 | |
|     TForm_item& cfd = head.find_field(H_COFI_DIC);
 | |
|     cfd.set(_cofi_dic);
 | |
|   }  
 | |
| // Righe da saltare nelle prime pag. dei moduli successivi al primo (che' son
 | |
| // senza le righe del posizionamento...)
 | |
|   head.update();  
 | |
|   for (word j = 0; j < r; j++)
 | |
|   {
 | |
|     TPrintrow& row = head.row(j);
 | |
|     if (j==0 && _modulaser)
 | |
|     {        
 | |
|       if (!_GiaMessoStartDoc)
 | |
|         put_modulaser(row, VEGASTARTDOC);     
 | |
|       put_modulaser(row, VEGASTARTDITTA);
 | |
|       put_modulaser(row, VEGASTARTPAGE, 1);
 | |
|     }    
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   }
 | |
| }
 | |
| 
 | |
| 
 | |
| int TQuadroD::elementi_pagina(PaginaQuadro p) const
 | |
| {
 | |
|   const int righe[4] = { 5, 6, 6, 5 };
 | |
|   return righe[p - PRIMA];
 | |
| }
 | |
| 
 | |
| void TQuadroD::set_body(TPrinter& pr)
 | |
| {
 | |
|   TCursor& cur = *cursor();    
 | |
|   TPrint_section& body = section('B', odd_page);
 | |
|   bool advance_cur = TRUE;
 | |
|   
 | |
|   if (cur.pos() >= cur.items())
 | |
|   {                  
 | |
|     _EndPrintDitta = TRUE;
 | |
|     body.reset();
 | |
|   }  
 | |
|   else  
 | |
|   {
 | |
|     advance_cur = preprocess_body(cur);
 | |
|     body.update();
 | |
|   }  
 | |
| 
 | |
|   const int body_righe = body.height();
 | |
|   for (int i=0; i < body_righe; i++)
 | |
|   {                   
 | |
|     TPrintrow& row = body.row(i);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   } 
 | |
|   
 | |
|   if (advance_cur && !_EndPrintDitta)
 | |
|   {
 | |
|     if (usa_progind())
 | |
|       progind()->addstatus(1);
 | |
|     ++cur;
 | |
|     _EndPrintDitta = cur.pos() >= _Items;
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool TQuadroD::on_prima(TCursor& cur)
 | |
| { 
 | |
|   TPrinter& pr = printer();
 | |
|   stampa_testata(pr); 
 | |
|   for (int righe = elementi_pagina(PRIMA); righe > 0; righe--)
 | |
|     set_body(pr);  
 | |
|   return _EndPrintDitta;
 | |
| }
 | |
| 
 | |
| bool TQuadroD::on_seconda(TCursor& cur)
 | |
| { 
 | |
|   TPrinter& pr = printer();
 | |
| 
 | |
|   TPrint_section& head = section('H', 2);
 | |
|   const word r = head.height();
 | |
|   fill_page(pr, r);
 | |
|   
 | |
|   for (int righe=elementi_pagina(SECONDA); righe > 0; righe--)
 | |
|     set_body(pr);  
 | |
| 
 | |
|   return _EndPrintDitta;
 | |
| }
 | |
| 
 | |
| bool TQuadroD::on_terza(TCursor& cur)
 | |
| { 
 | |
|   TPrinter& pr = printer();
 | |
|   
 | |
|   TPrint_section& head = section('H', 3);
 | |
|   const word r = head.height();
 | |
|   fill_page(pr, r);
 | |
| 
 | |
|   for (int righe=elementi_pagina(TERZA); righe > 0; righe--)
 | |
|     set_body(pr);  
 | |
|   return _EndPrintDitta;
 | |
| }
 | |
| 
 | |
| bool TQuadroD::on_quarta(TCursor& cur)
 | |
| {
 | |
|   TPrinter& pr = printer();
 | |
| 
 | |
|   TPrint_section& head = section('H', 0);
 | |
|   const word r = head.height();
 | |
|   fill_page(pr, r);
 | |
| 
 | |
|   for (int righe=elementi_pagina(_PaginaCorrente); righe > 0; righe--)
 | |
|     set_body(pr);  
 | |
|   
 | |
|   on_firma();
 | |
|   
 | |
|   return _EndPrintDitta;
 | |
| }
 | |
| 
 | |
| void TQuadroD::on_firma()
 | |
| {
 | |
|   TPrinter& pr = printer();
 | |
|   stampa_totali(pr, TRUE, TRUE);    // Stampa solo la firma
 | |
| }
 | |
| 
 | |
| bool TQuadroD::print(const long codditta, const long NumFis, const long NumNoFis)
 | |
| {  
 | |
|   if (!InitPrint(codditta))
 | |
|     return FALSE;
 | |
|   
 | |
|   _EndPrintDitta = FALSE;  
 | |
|   
 | |
|   TPrinter& pr  = printer();
 | |
| 
 | |
|   TCursor& cur = *cursor();
 | |
|   cur = 0;
 | |
|   
 | |
|   if (!preprocess_print(cur))
 | |
|     return FALSE;
 | |
|   
 | |
| #ifdef DBG      
 | |
|   if (pr.isgraphics())
 | |
|   {
 | |
|     for (int p = 1; p <= numero_pagine(); p++)
 | |
|     { 
 | |
|       word page = word(p);
 | |
|       if (p == 4)
 | |
|         page = 0;
 | |
|       set_background(page, TRUE);
 | |
|     }  
 | |
|   }      
 | |
| #endif          
 | |
|   
 | |
|   while (!_EndPrintDitta && pr.isopen())
 | |
|   {
 | |
|     _PaginaCorrente = PRIMA; // Qui e' garantito anche per form con 1 o 2 pagine 
 | |
|     pr.formlen(dic_form_len());                     
 | |
| 
 | |
|     for (int pagina=1; pagina <= numero_pagine(); pagina++, next_page(pr))
 | |
|     {
 | |
|       switch(_PaginaCorrente)
 | |
|       {
 | |
|       case PRIMA  : 
 | |
|         if (_modulaser) 
 | |
|           ClearFlagModulaser();
 | |
|         _EndPrintDitta = on_prima(cur); 
 | |
|         break;
 | |
|       case SECONDA: 
 | |
|         // Reset del flag di pagina con posiz.      
 | |
|         if (_posiziona && _PaginaPosizionamento) 
 | |
|           _PaginaPosizionamento = FALSE;
 | |
|         _EndPrintDitta = on_seconda(cur); 
 | |
|         break;
 | |
|       case TERZA  : 
 | |
|         _EndPrintDitta = on_terza(cur); 
 | |
|         break;
 | |
|       case QUARTA : 
 | |
|         _EndPrintDitta = on_quarta(cur); 
 | |
|         break;
 | |
|       default: CHECKD(0, "Invalid form page ", _PaginaCorrente); break;  
 | |
|       }
 | |
|     }  // for pagina..
 | |
|   }  // while !_EndPrintDitta   
 | |
|   close_print();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| TStampaQuadroD::TStampaQuadroD(const char* quadro, char liv) 
 | |
|               : TStampaQuadro(quadro, liv)
 | |
| {
 | |
| }
 | |
| 
 | |
| bool TStampaQuadroD::user_create()
 | |
| {   
 | |
|   _form = new TQuadroD("77QD", quadro());
 | |
|                                                                 
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
| 
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| bool TStampaQuadroD::user_destroy()
 | |
| {
 | |
|   delete _form;
 | |
|   delete _cur;
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO B
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| class TQuadroB : public TQuadroD
 | |
| {
 | |
|   TDipendenti _dipendenti; // Ogni erede deve essere collegato al proprio defunto
 | |
|   int         _pos;        // Indice per scandire i dipendenti nel giusto ordine (defunti->eredi...)
 | |
| 
 | |
| protected:            
 | |
|   virtual int  numero_pagine() const { return 4; }
 | |
|   virtual int  elementi_pagina(PaginaQuadro p) const;
 | |
|   virtual void set_body(TPrinter& pr);
 | |
|   virtual bool preprocess_print(TCursor& cur);
 | |
| public:
 | |
| 
 | |
|   TQuadroB(const char* form, const char* quadro)  : TQuadroD(form, quadro) {}
 | |
|   virtual ~TQuadroB() {} 
 | |
| };      
 | |
| 
 | |
| int TQuadroB::elementi_pagina(PaginaQuadro p) const
 | |
| {
 | |
|   const int righe[4] = { 4, 5, 5, 4 };
 | |
|   return righe[p - PRIMA];
 | |
| }
 | |
| 
 | |
| void TQuadroB::set_body(TPrinter& pr)
 | |
| {
 | |
|   TCursor& cur = *cursor();    
 | |
|   TPrint_section& body = section('B', odd_page);
 | |
|   bool advance_cur = TRUE;
 | |
|   
 | |
|   if (_pos >= _dipendenti.items())
 | |
|   {                  
 | |
|     _EndPrintDitta = TRUE;
 | |
|     body.reset();
 | |
|   }  
 | |
|   else  
 | |
|   {
 | |
|     advance_cur = preprocess_body(cur);
 | |
|     body.update();
 | |
|   }  
 | |
| 
 | |
|   const int body_righe = body.height();
 | |
|   for (int i=0; i < body_righe; i++)
 | |
|   {                   
 | |
|     TPrintrow& row = body.row(i);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   } 
 | |
|   
 | |
|   if (advance_cur && !_EndPrintDitta)
 | |
|   {
 | |
|     if (usa_progind())
 | |
|       progind()->addstatus(1);
 | |
|     ++_pos;
 | |
|     _EndPrintDitta = _pos >= _dipendenti.items();
 | |
|     if (!_EndPrintDitta)
 | |
|       cur = _dipendenti[_pos].pos();
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool TQuadroB::preprocess_print(TCursor& cur)
 | |
| { 
 | |
|   _dipendenti.destroy();
 | |
|   
 | |
|   const long items = _dipendenti.fill(cur);
 | |
|   
 | |
|   if (items <= 0)
 | |
|     return FALSE;
 | |
|   if (usa_progind()) 
 | |
|     progind()->addstatus(cur.items()-items);  // Segna come elaborati tutti gli ignorati
 | |
|   _pos = 0;
 | |
|   cur = _dipendenti[_pos].pos();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| class TStampaQuadroB : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroB(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroB() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroB::user_create()
 | |
| {   
 | |
|   _form = new TQuadroB("77QB", quadro());
 | |
|   TString sortkey(80);
 | |
|   sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP|NPROG", LF_DIPEND, LF_DIPEND);
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
| 
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO D Bis
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| // Derivo dal D che ha gli stessi elementi per pagina
 | |
| 
 | |
| class TStampaQuadroDbis : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroDbis(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroDbis() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroDbis::user_create()
 | |
| {   
 | |
|   _form = new TQuadroD("77QDB", quadro());
 | |
|                                                                 
 | |
|   const char* sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
| 
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO D1
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| // Derivo dal D ma devo ridefinire gli elementi per pagina
 | |
| 
 | |
| class TQuadroD1 : public TQuadroD
 | |
| {
 | |
| protected:                                                                        
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const;
 | |
|   
 | |
| public:
 | |
|   TQuadroD1(const char* form, const char* quadro) : TQuadroD(form, quadro) { }
 | |
|   virtual ~TQuadroD1() { }
 | |
| };
 | |
| 
 | |
| int TQuadroD1::elementi_pagina(PaginaQuadro p) const
 | |
| {
 | |
|   const int righe[4] = { 6, 7, 7, 7 };
 | |
|   return righe[p - PRIMA];
 | |
| }
 | |
| 
 | |
| class TStampaQuadroD1 : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroD1(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroD1() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroD1::user_create()
 | |
| {   
 | |
|   _form = new TQuadroD1("77QD1", quadro());
 | |
|                                                                 
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
| 
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO E
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
|                                    
 | |
| // Derivo dal D 
 | |
|                                    
 | |
| class TStampaQuadroE : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroE(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroE() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroE::user_create()
 | |
| {   
 | |
|   _form = new TQuadroD1("77QE", quadro());
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO E1
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| // Derivo dal D ma devo ridefinire gli elementi per pagina e il prospetto finale
 | |
| 
 | |
| class TQuadroE1 : public TQuadroD
 | |
| {
 | |
| protected:                                                                        
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const;
 | |
|   
 | |
| public:
 | |
|   TQuadroE1(const char* form, const char* quadro) : TQuadroD(form, quadro) { }
 | |
|   virtual ~TQuadroE1() { }
 | |
| };
 | |
| 
 | |
| int TQuadroE1::elementi_pagina(PaginaQuadro p) const
 | |
| {
 | |
|   const int righe[4] = { 6, 7, 7, 5 };
 | |
|   return righe[p - PRIMA];
 | |
| }
 | |
| 
 | |
| class TStampaQuadroE1 : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroE1(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroE1() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroE1::user_create()
 | |
| {   
 | |
|   _form = new TQuadroE1("77QE1", quadro());
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO E2
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| // Questo mitico quadro ha solo 2 pagine
 | |
| 
 | |
| class TQuadroE2 : public TQuadroD
 | |
| {
 | |
| protected:     
 | |
|   virtual int numero_pagine() const { return 2; }
 | |
|   virtual bool ultima_pagina() const { return _PaginaCorrente == SECONDA; }
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const { return p == PRIMA ? 6 : 7; }
 | |
|   virtual bool on_seconda(TCursor& cur);
 | |
|   
 | |
| public:
 | |
|   TQuadroE2(const char* form, const char* quadro) : TQuadroD(form, quadro) { }
 | |
|   virtual ~TQuadroE2() { }
 | |
| };
 | |
| 
 | |
| bool TQuadroE2::on_seconda(TCursor& cur)
 | |
| {
 | |
|   bool end = TQuadroD::on_seconda(cur);
 | |
|   on_firma();
 | |
|   return end;
 | |
| }
 | |
| 
 | |
| class TStampaQuadroE2 : public TStampaQuadroD
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroE2(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroE2() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroE2::user_create()
 | |
| {   
 | |
|   _form = new TQuadroE2("77QE2", quadro());
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| //////////////////////////////////////////////////////////////////////////////////
 | |
| // Quadro F
 | |
| //////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| #define QF_PROSPETTI   8 // Dalla A alla H
 | |
| 
 | |
| class TQuadroF : public TQuadroD
 | |
| {
 | |
|     static int _start[];
 | |
|     int       _ptr[QF_PROSPETTI];     // 0 = A ... 7 = B  :puntatori alle righe dei prospetti
 | |
|     TArray    _prospetti;  // Array di TRecord_array (uno per prospetto)   
 | |
| 
 | |
|     bool    stampa_prospetto(const char p, TPrinter& pr);
 | |
|     virtual bool preprocess_print(TCursor& cur);
 | |
|     virtual int numero_pagine() const { return 1; }
 | |
|     virtual bool ultima_pagina() const { return _PaginaCorrente == PRIMA; }
 | |
|     virtual int elementi_pagina(PaginaQuadro p) const { return 1; } // 1 solo body!
 | |
|     virtual bool on_prima(TCursor& cur);    
 | |
|   public:
 | |
|     TQuadroF(const char* form, const char* quadro)  : TQuadroD(form, quadro) {}
 | |
|     virtual ~TQuadroF() {} 
 | |
| };
 | |
| 
 | |
| int TQuadroF::_start[] = {1, 17, 33,49,53,55,57,59};
 | |
| 
 | |
| bool TQuadroF::preprocess_print(TCursor& cur)
 | |
| { 
 | |
|   _prospetti.destroy(); // Azzera i prospetti
 | |
|   
 | |
|   for (int i=0; i < QF_PROSPETTI; i++)
 | |
|     _ptr[i] = 1;
 | |
| 
 | |
|   // Carica i prospetti
 | |
|   const long codditta = cur.file(LF_RIGHEF).get_long("CODDITTA");
 | |
|   TRectype dep(cur.file(LF_RIGHEF).curr());
 | |
|   dep.zero();                
 | |
|   dep.put("CODDITTA", codditta);
 | |
|   dep.put("TIPOPRO", "A");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "B");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "C");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "D");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "E");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "F");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "G");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   dep.put("TIPOPRO", "H");
 | |
|   _prospetti.add(new TRecord_array(dep, "NPROG"));
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TQuadroF::stampa_prospetto(const char p, TPrinter& pr)
 | |
| {
 | |
|   const int      index = p - 'A';
 | |
|   const int      start = _start[index];
 | |
|   int&           ptr   = _ptr[index];
 | |
|   TRecord_array& prosp = (TRecord_array&) _prospetti[index];
 | |
|   const int      last  = prosp.last_row();
 | |
|   const bool     d_h   = p >= 'D' && p <= 'H';
 | |
|   const bool     a_d   = p >= 'A' && p <= 'D';
 | |
|   const int      max   = d_h ? 1 : 4; // Numero di righe per prospetto (4 per A,B,C)
 | |
|   TPrint_section& sez  = section('B', 1);
 | |
|   TString dep;
 | |
| 
 | |
|   for (int i = 0; i < max; ptr++, i++)
 | |
|   {                                           
 | |
|       
 | |
|     TRectype& r = prosp.row(ptr, TRUE);
 | |
|     dep = r.get(QUF_CODCAUS);                 
 | |
| 
 | |
|     const int fc0 = start + i;
 | |
|     TForm_item& c0 = sez.find_field(fc0);
 | |
|     c0.set(p == 'D' ? r.get(QUF_IMPCAMB) : (d_h ? r.get(QUF_SOGRIT) : get_desc_cau(dep)));
 | |
|     
 | |
|     const int fc1 = fc0 + max;     
 | |
|     TForm_item& c1 = sez.find_field(fc1);    
 | |
|     c1.set(r.get(a_d ? QUF_SOGRIT : QUF_ROPE));    
 | |
| 
 | |
|     if (a_d)
 | |
|     {
 | |
|       const int fc2 = fc1 + max;     
 | |
|       TForm_item& c2 = sez.find_field(fc2);    
 | |
|       c2.set(r.get(QUF_ALIQUOTA));    
 | |
|   
 | |
|       const int fc3 = fc2 + max;     
 | |
|       TForm_item& c3 = sez.find_field(fc3);    
 | |
|       c3.set(r.get(QUF_ROPE));    
 | |
|     }
 | |
|   }
 | |
|   const int res = last - ptr + 1;    
 | |
|   return res <= 0 ? TRUE : FALSE;  // Ritorna TRUE se non vi sono piu' elementi per questo prospetto
 | |
| }
 | |
| 
 | |
| bool TQuadroF::on_prima(TCursor& cur)
 | |
| {  
 | |
|   bool EndPrint=TRUE;
 | |
|   TPrinter& pr = printer();
 | |
|   TPrint_section& sez  = section('B', 1);
 | |
| 
 | |
|   stampa_testata(pr); 
 | |
| 
 | |
|   for (char p = 'A'; p <= 'H'; p ++)
 | |
|     EndPrint &= stampa_prospetto(p,pr);
 | |
|         
 | |
|   sez.update();
 | |
| 
 | |
|   const int rr = sez.height()-1;
 | |
|   for (int i=0; i < rr; i++)
 | |
|   {
 | |
|     pr.print(sez.row(i));
 | |
|     _RigaCorr++;
 | |
|   }
 | |
|   
 | |
|   on_firma();
 | |
|   
 | |
|   if (usa_progind())
 | |
|     progind()->addstatus(1);
 | |
|  
 | |
|   return EndPrint;
 | |
| }
 | |
| 
 | |
| class TStampaQuadroF : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|     virtual bool user_create();
 | |
| public:
 | |
|     TStampaQuadroF(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) { }
 | |
| };
 | |
| 
 | |
| 
 | |
| bool TStampaQuadroF::user_create()
 | |
| {
 | |
|   _form = new TQuadroF("77QF", quadro());
 | |
|   _cur = new TCursor(_form->TForm::relation());
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // QUADRO F1
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
|                                    
 | |
| // Derivo da E2 (e' uguale !)
 | |
|                                    
 | |
| class TQuadroF1 : public TQuadroE2
 | |
| {
 | |
| public:
 | |
|   TQuadroF1(const char* form, const char* quadro) : TQuadroE2(form, quadro) { }
 | |
|   virtual ~TQuadroF1() { }
 | |
| };
 | |
| 
 | |
| class TStampaQuadroF1 : public TStampaQuadroE2
 | |
| {      
 | |
| protected:
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroF1(const char* quadro, char livel) : TStampaQuadroE2(quadro, livel) { }
 | |
|   virtual ~TStampaQuadroF1() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroF1::user_create()
 | |
| {   
 | |
|   _form = new TQuadroF1("77QF1", quadro());
 | |
|   _cur = new TCursor(_form->TForm::relation());
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| //////////////////////////////////////////////////////////////
 | |
| //                QUADRO F2
 | |
| //////////////////////////////////////////////////////////////
 | |
| 
 | |
| // Questo ha solo una pagina
 | |
| 
 | |
| class TQuadroF2 : public TQuadroD
 | |
| {                          
 | |
| protected:     
 | |
|   virtual int numero_pagine() const { return 1; }
 | |
|   virtual bool ultima_pagina() const { return _PaginaCorrente == PRIMA; }
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const { return 22; }
 | |
|   virtual bool on_prima(TCursor& cur);
 | |
| public:  
 | |
|   TQuadroF2(const char* form, const char* quadro) : TQuadroD(form, quadro) { }
 | |
|   virtual ~TQuadroF2() { }
 | |
| };      
 | |
| 
 | |
| bool TQuadroF2::on_prima(TCursor& cur)
 | |
| {
 | |
|   bool end = TQuadroD::on_prima(cur);
 | |
|   on_firma();
 | |
|   return end;
 | |
| }
 | |
| 
 | |
| class TStampaQuadroF2 : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroF2(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) {}
 | |
|   virtual ~TStampaQuadroF2() {}
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroF2::user_create()
 | |
| {
 | |
|   _form = new TQuadroF2("77QF2", quadro());
 | |
|   _cur = new TCursor(_form->TForm::relation());
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| //
 | |
| // Quadro G                                                                                
 | |
| //
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TQuadroG : public TQuadroD
 | |
| {
 | |
|   TArray _prospetti;     // relazioni dei prospetti
 | |
|   TArray _cursori;       // cursori dei prospetti 1 e 2
 | |
|   TCursor* _saved_cur;   // Cursore temporaneo
 | |
| 
 | |
| protected:
 | |
|   virtual bool InitPrint(const long codditta);
 | |
|   virtual int elementi_pagina(PaginaQuadro pag) const;
 | |
|   
 | |
|   virtual bool on_prima(TCursor& cur);
 | |
|   virtual bool on_seconda(TCursor& cur);
 | |
|   virtual bool on_terza(TCursor& cur);
 | |
|   virtual bool on_quarta(TCursor& cur);
 | |
| 
 | |
| protected:     
 | |
|   bool test_fine_sezione(int prosp, int sez) const;
 | |
|   bool test_fine_prospetto(int prosp) const;
 | |
|   bool test_fine_distinta() const;
 | |
|   bool test_fine_stampa() const;
 | |
| 
 | |
| public:                 
 | |
|   TCursor& cursore(int prosp, int sez) const;
 | |
|   void set_tmp_cur(int prosp, int sez);
 | |
|   void print_body(TPrint_section& body, bool force = FALSE);
 | |
|   void stampa_sezione(int sez);
 | |
| 
 | |
|   TQuadroG();
 | |
|   virtual ~TQuadroG();
 | |
| };
 | |
| 
 | |
| TQuadroG::TQuadroG() : TQuadroD("77QG", "G")
 | |
| {
 | |
|   TString filter(32);
 | |
|   for (int prosp = 1; prosp <= 2; prosp++)
 | |
|   {
 | |
|     for (int sez = 1; sez <= 2; sez++)
 | |
|     {                      
 | |
|       filter.cut(0);
 | |
|       filter << "(PROSPETTO=" << prosp << ")&&(SEZIONE=" << sez << ')';
 | |
|       
 | |
|       TRelation* rel = new TRelation(LF_QUAGP);
 | |
|       TCursor* cur = new TCursor(rel, filter);
 | |
|       _prospetti.add(rel);
 | |
|       _cursori.add(cur);
 | |
|     }
 | |
|   }
 | |
|   
 | |
|   _saved_cur = NULL;
 | |
| }
 | |
| 
 | |
| TQuadroG::~TQuadroG() 
 | |
| { } 
 | |
| 
 | |
| bool TQuadroG::InitPrint(const long codditta)
 | |
| {
 | |
|   bool ok = TQuadroD::InitPrint(codditta);
 | |
|   
 | |
|   TRectype filter(LF_QUAGP);
 | |
|   filter.put("CODDITTA", codditta);
 | |
|   for (int c = _cursori.last(); c >= 0; c--)
 | |
|   {
 | |
|     TCursor& cur = (TCursor&)_cursori[c];
 | |
|     cur.setregion(filter, filter);
 | |
|     ok |= (cur.items() > 0);
 | |
|     cur = 0;
 | |
|   }
 | |
| 
 | |
|   return ok;
 | |
| }
 | |
|  
 | |
| int TQuadroG::elementi_pagina(PaginaQuadro p) const
 | |
| {
 | |
|   const int righe[4] = { 0, 0, 6, 7 };
 | |
|   return righe[p - PRIMA];
 | |
| }
 | |
| 
 | |
| TCursor& TQuadroG::cursore(int prosp, int sez) const
 | |
| {
 | |
|   const int c = (prosp - 1) * 2 + (sez - 1);
 | |
|   return (TCursor&)_cursori[c];
 | |
| } 
 | |
| 
 | |
| void TQuadroG::set_tmp_cur(int prosp, int sez)
 | |
| {                    
 | |
|   if (prosp == 1 || prosp == 2)
 | |
|   {
 | |
|     CHECK(_saved_cur == NULL, "Already saved cursor");
 | |
|     _saved_cur = cursor();
 | |
|     set_cursor(&cursore(prosp, sez));
 | |
|   }
 | |
|   else
 | |
|   {                   
 | |
|     CHECK(_saved_cur, "No saved cursor");
 | |
|     set_cursor(_saved_cur);
 | |
|     _saved_cur = NULL;
 | |
|   }  
 | |
| }
 | |
|  
 | |
| bool TQuadroG::test_fine_sezione(int prosp, int sez) const
 | |
| {
 | |
|   TCursor& cur = cursore(prosp, sez);
 | |
|   const long items = cur.items();
 | |
|   bool fine = items == 0 || cur.pos() >= items;
 | |
|   return fine;
 | |
| }
 | |
| 
 | |
| bool TQuadroG::test_fine_prospetto(int prosp) const
 | |
| {                              
 | |
|   bool fine;
 | |
|   switch(prosp)
 | |
|   {
 | |
|   case 1 :
 | |
|   case 2 : fine = test_fine_sezione(prosp, 1) && test_fine_sezione(prosp, 2); break;
 | |
|   case 3 : fine = _num_foglio > 2; break;
 | |
|   default: fine = cursor()->pos() >= cursor()->items(); break; // distinta
 | |
|   }
 | |
|   return fine;
 | |
| } 
 | |
| 
 | |
| bool TQuadroG::test_fine_distinta() const
 | |
| {
 | |
|   return test_fine_prospetto(4);
 | |
| }
 | |
| 
 | |
| bool TQuadroG::test_fine_stampa() const
 | |
| {
 | |
|   bool fine = TRUE;
 | |
|   if (fine) fine = test_fine_prospetto(1);
 | |
|   if (fine) fine = test_fine_prospetto(2);
 | |
|   if (fine) fine = test_fine_distinta();
 | |
|   return fine;
 | |
| }      
 | |
| 
 | |
| void TQuadroG::print_body(TPrint_section& body, bool force)
 | |
| {
 | |
|   TPrinter& pr = printer(); 
 | |
|   if (force || cursor()->pos() < cursor()->items())
 | |
|     body.update();       
 | |
|   else
 | |
|     body.reset();
 | |
|   const int body_righe = body.height();
 | |
|   for (int i=0; i < body_righe; i++)
 | |
|   {                   
 | |
|     TPrintrow& row = body.row(i);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   } 
 | |
| } 
 | |
| 
 | |
| // Stampa le sezioni 1 e 2 del prospetto 2
 | |
| void TQuadroG::stampa_sezione(int sez)
 | |
| {                 
 | |
|   TPrinter& pr = printer();
 | |
|   TPrint_section& body = section('F', odd_page);
 | |
|   
 | |
|   set_tmp_cur(2, sez);
 | |
|   TCursor& cur = cursore(2, sez);
 | |
|   
 | |
|   TArray record0;       // record dell'aliquota 0 del prospetto 2
 | |
|   
 | |
|   for (int riga = 1; riga <= 9; riga++)
 | |
|   {                                 
 | |
|     bool printed = FALSE;
 | |
|     bool advance = FALSE;
 | |
|     TRectype& curr = cur.curr();
 | |
|     
 | |
|     if (riga <= 5 && cur.pos() < 5)
 | |
|     {                  
 | |
|       TForm_item& utiliap = body.find_field(1);
 | |
|       TForm_item& utili   = body.find_field(2);
 | |
|       TForm_item& utiliac = body.find_field(8);
 | |
|       if (riga == 1)
 | |
|       {            
 | |
|         const TRectype& curr = _saved_cur->curr(LF_QUAG);
 | |
|         utiliap.set(curr.get(sez == 1 ? "UTILIAP21" : "UTILIAP22"));
 | |
|         utili.set(curr.get(sez == 1 ? "UTILI21" : "UTILI22"));
 | |
|         utiliac.set(curr.get(sez == 1 ? "UTILIAC21" : "UTILIAC22"));
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         utiliap.set("");
 | |
|         utili.set("");
 | |
|         utiliac.set("");
 | |
|       }
 | |
|       
 | |
|       TForm_item& aliquota = body.find_field(5); aliquota.hide();
 | |
|       TForm_item& titolo = body.find_field(6); titolo.hide();
 | |
| 
 | |
|       print_body(body);       
 | |
|       printed = advance = TRUE;
 | |
|     }
 | |
|     
 | |
|     if (riga == 6 && cur.pos() == 5)  
 | |
|     {
 | |
|       record0.add(curr, sez);           // memorizza riga con aliquota 0
 | |
|       ++cur;                            // passa alla prossima da stampare
 | |
|     }
 | |
|     
 | |
|     if (riga >= 6 && riga <= 8)  
 | |
|     {
 | |
|       TForm_item& aliquota = body.find_field(5); aliquota.show();
 | |
|       TForm_item& titolo = body.find_field(6); titolo.show();
 | |
|       print_body(body);
 | |
|       printed = advance = TRUE;
 | |
|     }
 | |
|     
 | |
|     if (riga == 9)
 | |
|     {             
 | |
|       if (record0.objptr(sez))
 | |
|       {                     
 | |
|         const TRectype old(curr);
 | |
|         curr = (const TRectype&)record0[sez];
 | |
|         TForm_item& aliquota = body.find_field(5); aliquota.hide();
 | |
|         TForm_item& titolo = body.find_field(6); titolo.hide();
 | |
|         print_body(body, TRUE);  
 | |
|         curr = old;
 | |
|         record0.destroy(sez);
 | |
|         printed = TRUE;
 | |
|       }
 | |
|     }
 | |
| 
 | |
|     if (!printed)
 | |
|       fill_page(pr, 1);
 | |
|     if (advance)
 | |
|       ++cur;
 | |
|   }
 | |
| 
 | |
|   set_tmp_cur(0, 0);
 | |
| }
 | |
| 
 | |
| bool TQuadroG::on_prima(TCursor&)
 | |
| {          
 | |
|   TPrinter& pr = printer();
 | |
|   stampa_testata(pr); 
 | |
|   {
 | |
|     TPrint_section& body = section('H', odd_page);
 | |
|     set_tmp_cur(1, 1);
 | |
|     TCursor& cur = cursore(1, 1);
 | |
|     for (int riga = 0; riga < 3; riga++, ++cur)
 | |
|       print_body(body);
 | |
|     set_tmp_cur(0, 0);
 | |
|   }
 | |
|   fill_page(pr, 1);
 | |
|   {
 | |
|     TPrint_section& prima_riga = section('B', first_page);
 | |
|     print_body(prima_riga);
 | |
|   
 | |
|     TPrint_section& body = section('H', even_page);
 | |
|     set_tmp_cur(1, 2);
 | |
|     TCursor& cur = cursore(1, 2);
 | |
|     for (int riga = 0; riga < 3; riga++, ++cur)
 | |
|       print_body(body);
 | |
|     set_tmp_cur(0, 0);
 | |
|   }
 | |
|   fill_page(pr, 5);
 | |
|   { 
 | |
|     stampa_sezione(1);
 | |
|   }
 | |
|   fill_page(pr, 3);
 | |
|   {
 | |
|     stampa_sezione(2);    
 | |
|   }
 | |
|     
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TQuadroG::on_seconda(TCursor& cur)
 | |
| {   
 | |
|   if (!test_fine_prospetto(3))
 | |
|   {                      
 | |
|     fill_page(printer(), 8);
 | |
|     TPrint_section& body3 = section('B', even_page);
 | |
|     print_body(body3);
 | |
|   }
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TQuadroG::on_terza(TCursor& cur)
 | |
| {
 | |
|   if (!test_fine_distinta())
 | |
|   {            
 | |
|     TPrinter& pr = printer();
 | |
|     fill_page(pr, 13);
 | |
|     for (int righe=elementi_pagina(TERZA); righe > 0; righe--)
 | |
|       set_body(pr);  
 | |
|   }  
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TQuadroG::on_quarta(TCursor& cur)
 | |
| {
 | |
|   TPrinter& pr = printer();
 | |
|   fill_page(pr, 5);
 | |
|   for (int righe=elementi_pagina(QUARTA); righe > 0; righe--)
 | |
|     set_body(pr);  
 | |
|   on_firma();  
 | |
|   return test_fine_stampa();
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // 
 | |
| //                                         STAMPA QUADRO G
 | |
| //
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TStampaQuadroG : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroG(char livel) : TStampaQuadroD("G", livel) { }
 | |
|   virtual ~TStampaQuadroG() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroG::user_create()
 | |
| {
 | |
|   _form = new TQuadroG;
 | |
|   const char* const sortkey = "CODDITTA|216@->RAGSOC|TIPOA|CODANAGR";
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| //
 | |
| // Quadro G1
 | |
| //
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TQuadroG1 : public TQuadroD
 | |
| {          
 | |
|   TArray _fissi;
 | |
| 
 | |
| protected:
 | |
|   virtual int numero_pagine() const { return 1; }
 | |
|   virtual bool ultima_pagina() const { return TRUE; }
 | |
|   
 | |
|   virtual bool on_prima(TCursor& cur);
 | |
| 
 | |
| public:                 
 | |
|   void print_body(TPrint_section& body);
 | |
| 
 | |
|   TQuadroG1() : TQuadroD("77QG1", "G1") {}
 | |
|   virtual ~TQuadroG1() {}
 | |
| };      
 | |
| 
 | |
| void TQuadroG1::print_body(TPrint_section& body)
 | |
| {
 | |
|   TPrinter& pr = printer(); 
 | |
|   
 | |
|   body.update();       
 | |
|   const int body_righe = body.height();
 | |
|   for (int i=0; i < body_righe; i++)
 | |
|   {                   
 | |
|     TPrintrow& row = body.row(i);
 | |
|     pr.print(row);
 | |
|     _RigaCorr++;
 | |
|   } 
 | |
| } 
 | |
| 
 | |
| bool TQuadroG1::on_prima(TCursor& cur)
 | |
| {                      
 | |
|   TPrint_section& body = section('B', odd_page);
 | |
|   
 | |
|   TPrinter& pr = printer();
 | |
|   stampa_testata(pr);        // Salta da sola fino alla prima riga
 | |
|   
 | |
|   const double aliquote[3] = { 10, 12.5, 0.0 };
 | |
|   const int    righeali[3] = { 1, 2, 4 };
 | |
|   
 | |
|   bool eof = cur.pos() >= _Items;
 | |
|   
 | |
|   TRectype& rec = cur.curr();
 | |
|   for (int riga = 1; riga <= 4; riga++)
 | |
|   {                  
 | |
|     bool used = FALSE;
 | |
|     
 | |
|     if (!eof)
 | |
|     {
 | |
|       if (cur.pos() < 3)
 | |
|       {
 | |
|         const real aliquota = rec.get("ALIQUOTA");
 | |
|         for (int a = 0; a < 3; a++)
 | |
|         { 
 | |
|           const int& row = righeali[a];
 | |
|           if (aliquota == aliquote[a] && _fissi.objptr(row) == NULL)
 | |
|           {   
 | |
|             rec.zero("ALIQUOTA");    // Non deve essere stampata
 | |
|             _fissi.add(rec, row); 
 | |
|             
 | |
|             if (aliquota.is_zero())
 | |
|             {
 | |
|               ++cur;
 | |
|               used = eof = cur.pos() >= _Items;
 | |
|             }  
 | |
|             else
 | |
|               used = TRUE;
 | |
|             break;
 | |
|           }  
 | |
|         }
 | |
|       }  
 | |
|       if (!used && _fissi.objptr(3) == NULL)
 | |
|       {                   
 | |
|         _fissi.add(rec, 3);
 | |
|         used = TRUE;
 | |
|       }  
 | |
|     }
 | |
|       
 | |
|     if (_fissi.objptr(riga))            // Esiste un record per questa riga?
 | |
|     {                 
 | |
|       rec = (const TRectype&)_fissi[riga];    // Aggiorna record del cursore
 | |
|       print_body(body);
 | |
|       _fissi.destroy(riga);
 | |
|     }
 | |
|     else  
 | |
|       fill_page(pr, 2);
 | |
|     
 | |
|     if (used)
 | |
|     {
 | |
|       ++cur;
 | |
|       eof = cur.pos() >= _Items;
 | |
|     }  
 | |
|   }  
 | |
| 
 | |
|   jump_to_line(pr, 48);
 | |
|   stampa_totali(pr, FALSE, TRUE);    // Stampa solo la firma
 | |
|   
 | |
|   bool fine = eof && _fissi.objptr(3) == NULL;
 | |
|   return fine;
 | |
| }  
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| // 
 | |
| //                                         STAMPA QUADRO G-1
 | |
| //
 | |
| /////////////////////////////////////////////////////////////////////////////////////////////
 | |
| class TStampaQuadroG1 : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroG1(char livel)  : TStampaQuadroD("G1", livel) { }
 | |
|   virtual ~TStampaQuadroG1() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroG1::user_create()
 | |
| {
 | |
|   _form = new TQuadroG1;
 | |
|   _cur = new TCursor(_form->TForm::relation());
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| // Quadro B1
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TQuadroB1 : public TQuadroD
 | |
| {          
 | |
| protected:
 | |
|   virtual int numero_pagine() const { return 2; }
 | |
|   virtual bool ultima_pagina() const { return _PaginaCorrente == SECONDA; }
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const { return p == PRIMA ? 7 : 9; }
 | |
|   virtual bool on_seconda(TCursor& cur) { return TQuadroD::on_quarta(cur); }
 | |
|   
 | |
| public:                 
 | |
|   TQuadroB1() : TQuadroD("77QB1", "B1") {}
 | |
|   virtual ~TQuadroB1() {}
 | |
| };      
 | |
| 
 | |
| class TStampaQuadroB1 : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroB1(char livel)  : TStampaQuadroD("B1", livel) { }
 | |
|   virtual ~TStampaQuadroB1() { }
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroB1::user_create()
 | |
| {
 | |
|   _form = new TQuadroB1;
 | |
|   TString sortkey(80);
 | |
|   sortkey.format("CODDITTA|%d->COGNOME|%d->NOME|CODDIP|NPROG", LF_DIPEND, LF_DIPEND);
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(),sortkey);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| //////////////////////////////////////////////////////////////
 | |
| //                QUADRO H
 | |
| //////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TQuadroH : public TQuadroD
 | |
| {  
 | |
| protected:    
 | |
|   virtual int numero_pagine() const { return 2; }
 | |
|   virtual bool ultima_pagina() const { return _PaginaCorrente == SECONDA; }
 | |
|   virtual int elementi_pagina(PaginaQuadro p) const { return p == PRIMA ? 23 : 25; }
 | |
|   virtual bool on_seconda(TCursor& cur);
 | |
|   virtual long filtra(const long codditta);
 | |
|   
 | |
| public:  
 | |
|   TQuadroH(const char* form, const char* quadro) : TQuadroD(form, quadro) { }
 | |
|   virtual ~TQuadroH() { } 
 | |
| };      
 | |
| 
 | |
| long TQuadroH::filtra(const long codditta)
 | |
| {
 | |
|   CHECK(anno(),"Year must be set to print this form");
 | |
|   TString filtr(32); 
 | |
|   filtr.format("(CODDITTA=%ld)&&(H1ANNO=%d)", codditta, anno());
 | |
|   cursor()->setfilter(filtr, TRUE);   
 | |
|   const long items = cursor()->items();
 | |
|   return items;
 | |
| }      
 | |
| bool TQuadroH::on_seconda(TCursor& cur)
 | |
| {
 | |
|   bool end = TQuadroD::on_seconda(cur);
 | |
|   on_firma();
 | |
|   return end;
 | |
| }
 | |
| 
 | |
| class TStampaQuadroH : public TStampaQuadroD
 | |
| {
 | |
| protected:    
 | |
|   virtual bool menu(MENU_TAG m);
 | |
|   virtual bool user_create();
 | |
| 
 | |
| public:
 | |
|   TStampaQuadroH(const char* quadro, char livel) : TStampaQuadroD(quadro, livel) {}
 | |
|   virtual ~TStampaQuadroH() {}
 | |
| };
 | |
| 
 | |
| bool TStampaQuadroH::user_create()
 | |
| {
 | |
|   _form = new TQuadroH("77QH", quadro());                                                                
 | |
|   TString sortkey(80);
 | |
| //  sortkey.format("CODDITTA|H1ANNO|H1ENTE"); 
 | |
|   sortkey.format("CODDITTA|H1ENTE");    // Considera solo in 1995
 | |
|   _cur = new TSorted_cursor(_form->TForm::relation(), sortkey);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TStampaQuadroH::menu(MENU_TAG m)
 | |
| {
 | |
|   _form->set_anno(anno_dic());
 | |
|   return TStampaQuadroD::menu(m);
 | |
| }
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////
 | |
| // Busta
 | |
| /////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| class TBusta : public TDicForm
 | |
| {
 | |
| protected:  
 | |
|   virtual bool print(const long codditta, const long, const long);
 | |
|   virtual int   prima_riga(PaginaQuadro p) const;  
 | |
|   virtual int   dic_form_len() const;
 | |
|   virtual void  next_page(TPrinter& pr) { fill_page(pr, -1); }    
 | |
| public:  
 | |
|   TBusta(const char* form, const char* quadro) : TDicForm(form, quadro) { }
 | |
|   virtual ~TBusta() { } 
 | |
| };      
 | |
| 
 | |
| bool get_alleg_730(const long codditta)
 | |
| {
 | |
|   TLocalisamfile base(LF_BASE);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA",(long)codditta);
 | |
|   if (base.read()==NOERR)
 | |
|   {
 | |
|     const long allegA=base.get_long("N730ALLA");
 | |
|     const long allegA2=base.get_long("N730ALLA2");
 | |
|     return allegA || allegA2;
 | |
|   }
 | |
|   else
 | |
|     return FALSE;
 | |
| }
 | |
| 
 | |
| HIDDEN const int _BUSTA_ALL730 = 8; 
 | |
| HIDDEN int HEADER_PRIMA_NOPOS_BUSTA = 3;
 | |
| 
 | |
| int TBusta::dic_form_len() const
 | |
| {
 | |
|   if (_PaginaPosizionamento)
 | |
|     return 56-HEADER_PRIMA_NOPOS_BUSTA;
 | |
|   else
 | |
|     return 56;
 | |
| }
 | |
| 
 | |
| int TBusta::prima_riga(PaginaQuadro p) const
 | |
| {
 | |
|   if (_PaginaPosizionamento)
 | |
|     return 1;
 | |
|   else
 | |
|     return 1+HEADER_PRIMA_NOPOS_BUSTA;
 | |
| } 
 | |
| 
 | |
| bool TBusta::print(const long codditta, const long, const long)
 | |
| {     
 | |
|   const bool ok = InitPrint(codditta);
 | |
|   if (ok)
 | |
|   {   
 | |
|     // set flag allegati MOD.730 e MOD.730-3
 | |
|     TForm_item& all730 = find_field('B', odd_page, _BUSTA_ALL730);
 | |
|     const bool bAlleg730 = get_alleg_730(codditta); 
 | |
|     all730.set(bAlleg730 ? "X" : "");    
 | |
|                                          
 | |
|     TPrinter& pr=printer();                                         
 | |
|     TPrint_section& body = section('B', odd_page);
 | |
|     const int body_righe = body.height();
 | |
|     TCursor* cur=cursor();
 | |
|     bool finito=FALSE;    
 | |
|     (*cur)=0L; 
 | |
|     pr.formlen(dic_form_len());
 | |
|     jump_to_line(pr,prima_riga(PRIMA));    
 | |
|     while (!finito)   
 | |
|     {
 | |
|       body.reset();
 | |
|       body.update();       
 | |
|       for (int i=0; i < body_righe; i++)
 | |
|       {
 | |
|         pr.print(body.row(i));
 | |
|         _RigaCorr++;
 | |
|       }
 | |
|       next_page(pr); 
 | |
|       
 | |
|       if (usa_progind())
 | |
|         progind()->addstatus(1);
 | |
|       ++(*cur);               
 | |
|       finito= cur->pos() >= cur->items()-1;
 | |
|       _PaginaPosizionamento=FALSE;      
 | |
|       pr.formlen(dic_form_len());
 | |
|     }
 | |
|     close_print();  
 | |
|   }  
 | |
|   return ok;  
 | |
| }
 | |
| 
 | |
| class TStampaBusta : public TStampaQuadro
 | |
| { 
 | |
|   TDicForm* _form;
 | |
| 
 | |
| protected:  // TStampaQuadro  
 | |
|   virtual bool user_create();
 | |
|   virtual bool user_destroy();
 | |
|   virtual bool conta_tipi_per() const { return FALSE; }  
 | |
|   virtual TDicForm* get_form() const { return _form; }
 | |
|   virtual TCursor* get_cursor() const { return _form->TForm::cursor(); }
 | |
|   virtual bool print_quadro(const int OffsetDitta, const bool modulaser);
 | |
| 
 | |
| public:
 | |
|   TStampaBusta(const char* quadro, char livel);
 | |
|   virtual ~TStampaBusta() { }
 | |
| };
 | |
| 
 | |
| TStampaBusta::TStampaBusta(const char* quadro, char livel) 
 | |
|             : TStampaQuadro(quadro, livel), _form(NULL)
 | |
| { 
 | |
|   set_taitol("Stampa buste"); 
 | |
| }
 | |
| 
 | |
| bool TStampaBusta::user_create()
 | |
| {
 | |
|   _form = new TBusta("77Busta", quadro());
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TStampaBusta::user_destroy()
 | |
| {
 | |
|   delete _form;
 | |
|   _form = NULL;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TStampaBusta::print_quadro(const int OffsetDitta, const bool modulaser)
 | |
| {
 | |
|   TDicForm* ff = get_form();
 | |
|   ff->set_cursor(get_cursor());
 | |
| 
 | |
|   // Setta formlen prima di printer.open per avere la lunghezza giusta nel caso di stampa a video     
 | |
|   printer().formlen(ff->height());               
 | |
|   bool ok = printer().open();
 | |
| 
 | |
|   ff->set_modulaser(modulaser);
 | |
|   
 | |
|   ff->set_arrange(FALSE);
 | |
|   ff->set_posiziona(TRUE);
 | |
|     
 | |
|   int start = 0, last = 0;
 | |
|   if (OffsetDitta >= 0)
 | |
|   {
 | |
|     start = OffsetDitta;
 | |
|     last = OffsetDitta;  
 | |
|   }
 | |
|   else
 | |
|     last = ditte().items() - 1;
 | |
|     
 | |
|   for (int i = start; i <= last; i++)
 | |
|   {
 | |
|     TToken_string& riga  = ditte()[i];
 | |
|     const long codditta  = riga.get_long(0);
 | |
|     const TipoDitta tipo = (TipoDitta)riga.get_int();
 | |
|     if (tipo != estinto)
 | |
|       ff->print(codditta, 0, 0);
 | |
|   }                       
 | |
|   
 | |
|   printer().close();
 | |
|   return ok;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| //
 | |
| // BASE
 | |
| //
 | |
| ///////////////////////////////////////////////////////////////////////////////////////////
 | |
| 
 | |
| /////////////////////////////////////////////////////////////////////////////////
 | |
| //
 | |
| //  MAIN
 | |
| //
 | |
| //  Uso:
 | |
| //         772mod -4 [QUADRO] [ LIVELLO {S|D} ]
 | |
| //
 | |
| /////////////////////////////////////////////////////////////////////////////////
 | |
| int stampa_quadro(int argc, char* argv[])
 | |
| {
 | |
|   if (argc >= 4)
 | |
|   {
 | |
|     const TFixed_string quadro(argv[2]);
 | |
|     const char livello = *argv[3];
 | |
|     
 | |
|     TStampaQuadro* app = NULL;
 | |
| 
 | |
|     if (quadro[0] == 'A')
 | |
|     {                        
 | |
|       switch (toupper(quadro[1]))
 | |
|       {
 | |
|       case 'B': app = new TStampaQuadroAbis(quadro, livello); break;
 | |
|       case '1': app = new TStampaQuadroA1(quadro, livello); break; 
 | |
|       case '2': app = new TStampaQuadroA2(quadro, livello); break; 
 | |
|       case '3': app = new TStampaQuadroA3(quadro, livello); break;
 | |
|       default : app = new TStampaQuadroA(quadro, livello);  break;
 | |
|       }  
 | |
|     } else 
 | |
|     if (quadro[0] == 'B')
 | |
|     { 
 | |
|       switch (toupper(quadro[1]))
 | |
|       {        
 | |
|       case '1': app = new TStampaQuadroB1(livello); break;
 | |
|       case 'A': app = new TStampaBase(livello); break;
 | |
|       case 'U': app = new TStampaBusta(quadro, livello); break;
 | |
|       default : app = new TStampaQuadroB(quadro, livello); break;
 | |
|       }
 | |
|     } else 
 | |
|     if ( quadro == "C" )
 | |
|     {
 | |
|       app = new TStampaQuadroC(quadro, livello);
 | |
|     } else 
 | |
|     if ( quadro[0] == 'D' )
 | |
|     {                         
 | |
|       switch(toupper(quadro[1]))
 | |
|       {
 | |
|       case 'B': app = new TStampaQuadroDbis(quadro, livello); break;
 | |
|       case '1': app = new TStampaQuadroD1(quadro, livello); break;
 | |
|       default : app = new TStampaQuadroD(quadro, livello); break;
 | |
|       }
 | |
|     } else 
 | |
|     if ( quadro[0] == 'E' )
 | |
|     {                         
 | |
|       switch(quadro[1])
 | |
|       {
 | |
|       case '1': app = new TStampaQuadroE1(quadro, livello); break;
 | |
|       case '2': app = new TStampaQuadroE2(quadro, livello); break;
 | |
|       default : app = new TStampaQuadroE(quadro, livello); break;
 | |
|       }
 | |
|     } else 
 | |
|     if (quadro == "F")
 | |
|     {
 | |
|       app = new TStampaQuadroF(quadro, livello);    
 | |
|     } else 
 | |
|      if (quadro == "F1")
 | |
|     {
 | |
|       app = new TStampaQuadroF1(quadro, livello);    
 | |
|     } else 
 | |
|     if (quadro == "F2")
 | |
|     {
 | |
|       app = new TStampaQuadroF2(quadro, livello);
 | |
|     } else 
 | |
|    if (quadro == "G")
 | |
|     {
 | |
|       app = new TStampaQuadroG(livello);    
 | |
|     } else 
 | |
|     if (quadro == "G1")
 | |
|     {
 | |
|       app = new TStampaQuadroG1(livello);    
 | |
|     } else
 | |
|     if (quadro == "H")
 | |
|     {
 | |
|       app = new TStampaQuadroH(quadro, livello);    
 | |
|     } else 
 | |
|     if (quadro == "L")
 | |
|     {
 | |
|       app = new TStampaQuadroAggL(quadro, livello);    
 | |
|     } else 
 | |
|     if (quadro == "N")
 | |
|     {
 | |
|       app = new TStampaQuadroAggN(quadro, livello);    
 | |
|     } else 
 | |
|     if (quadro == "S")
 | |
|     {
 | |
|       app = new TStampaAlleSoci("Allegato Soci", livello);    
 | |
|     }
 | |
| 
 | |
|     if (app != NULL)
 | |
|     {
 | |
|       app->run(argc, argv, app->taitol());
 | |
|       delete app;
 | |
|     }  
 | |
|   }
 | |
|   
 | |
|   return 0;
 | |
| }
 |