Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 349 git-svn-id: svn://10.65.10.50/trunk@10573 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			394 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			394 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "ba3601.h"
 | |
| 
 | |
| HIDDEN inline Stp_indici_LUnico & a() {return (Stp_indici_LUnico&) main_app(); }
 | |
| 
 | |
| bool Stp_indici_LUnico::user_create()
 | |
| {
 | |
|   _nditte = new TLocalisamfile (LF_NDITTE);
 | |
|   _anag   = new TLocalisamfile (LF_ANAG);
 | |
|   _comuni = new TLocalisamfile (LF_COMUNI);
 | |
|   _indlib = new TLocalisamfile (LF_INDLIB);
 | |
|   _tab_lbu = new TTable (TAB_LBU);
 | |
|   _tab_reg = NULL;
 | |
|   _msk = new TMask("ba3601a"); 
 | |
|   _msk->set_handler(F_CODDITTA, registri_ditta_hnd);
 | |
|   _sort = NULL;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
|                                
 | |
| bool Stp_indici_LUnico::user_destroy()
 | |
| {
 | |
|   delete  _msk;
 | |
|   delete _tab_lbu;
 | |
|   delete _indlib;
 | |
|   delete _nditte;
 | |
|   delete _anag;
 | |
|   delete _comuni;
 | |
|   if (_sort) delete _sort;
 | |
|   if (_tab_reg) delete _tab_reg;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool Stp_indici_LUnico::registri_ditta_hnd(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_TAB && f.mask().is_running())
 | |
|   {  
 | |
|     bool trovato = FALSE;            
 | |
|     long    ditta   = f.mask().get_long(F_CODDITTA);  
 | |
|     if (ditta == 0)
 | |
|       return f.error_box(TR("La ditta e' obbligatoria"));
 | |
|     long    old_dta = a().get_firm();
 | |
|     TString cod_lu  = f.mask().get(F_LIBRO_UNICO1);
 | |
|     if (!prefix().exist(ditta)) return f.error_box(FR("La ditta %ld non ha nessun registro"),ditta);
 | |
|     a().set_firm(ditta);
 | |
|     int anno = f.mask().get_int(F_ANNO);  
 | |
|     TTable reg ("REG");
 | |
|     
 | |
|     reg.zero();
 | |
|     for (reg.first();!reg.eof();reg.next())
 | |
|     {                    
 | |
|       TString codtab  = reg.get("CODTAB");
 | |
|       int     annoreg = atoi(codtab.mid(0,4));
 | |
|       
 | |
|       if (annoreg == anno)
 | |
|       {            
 | |
|         TString cod_lu_reg = reg.get("S6");
 | |
|         if (cod_lu == cod_lu_reg)
 | |
|         {
 | |
|           trovato = TRUE;
 | |
|           break;
 | |
|         }
 | |
|       }
 | |
|     }                  
 | |
|     a().set_firm(old_dta); 
 | |
|     if (!trovato)
 | |
|       return f.error_box(FR("La ditta %ld per l'anno %d non ha registri che vengono stampati sul libro unico"), ditta, anno);
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::ragsoc_ditta(long codditta)
 | |
| {
 | |
| 
 | |
|   _nditte->zero();
 | |
|   _nditte->put(NDT_CODDITTA, codditta);
 | |
|   _nditte->read();
 | |
|   if (_nditte->bad())        
 | |
|     _nditte->zero();
 | |
|   _ragsoc_dta   = _nditte->get(NDT_RAGSOC);
 | |
|   _tipoa_ditta  = _nditte->get_char(NDT_TIPOA);
 | |
|   _codana_ditta = _nditte->get_long(NDT_CODANAGR);
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::dati_anagrafici_ditta()
 | |
| {
 | |
|   _anag->setkey(1);
 | |
|   _anag->zero();
 | |
|   _anag->put(ANA_TIPOA,    _tipoa_ditta);
 | |
|   _anag->put(ANA_CODANAGR, _codana_ditta);
 | |
|   if (_anag->read(_isequal) == NOERR)
 | |
|   { 
 | |
|     _cofi_dta   = _anag->get(ANA_COFI);
 | |
|     _paiv_dta   = _anag->get(ANA_PAIV);
 | |
|     _codcom_dta = _anag->get(ANA_COMRF);    
 | |
|     if (_codcom_dta.not_empty())
 | |
|     {  
 | |
|       _ind_dta    = _anag->get(ANA_INDRF);
 | |
|       _civ_dta    = _anag->get(ANA_CIVRF);
 | |
|       _cap_dta    = _anag->get(ANA_CAPRF);
 | |
|     }                             
 | |
|     else
 | |
|     {
 | |
|       _codcom_dta = _anag->get(ANA_COMRES);
 | |
|       _ind_dta    = _anag->get(ANA_INDRES);
 | |
|       _civ_dta    = _anag->get(ANA_CIVRES);
 | |
|       _cap_dta    = _anag->get(ANA_CAPRES);
 | |
|     }                                 
 | |
|   }
 | |
|   
 | |
|   _comuni->setkey(1);
 | |
|   _comuni->zero();
 | |
|   _comuni->put(COM_COM,   _codcom_dta);
 | |
|   if (_comuni->read(_isequal) == NOERR)
 | |
|   {
 | |
|     _com_dta  = _comuni->get(COM_DENCOM);
 | |
|     _prov_dta = _comuni->get(COM_PROVCOM);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::dati_libro_unico()
 | |
| {
 | |
|   TTable lbu ("%LBU");
 | |
|   TString dep;
 | |
|   dep.format("%4d%-3s", _anno, (const char*) _codlib);
 | |
| 
 | |
|   _tab_lbu->put("CODTAB", (const char*) dep);
 | |
| 
 | |
|   if (_tab_lbu->read(_isequal) == NOERR)
 | |
|   { 
 | |
|     //_stampa_intesta = _tab_lbu->get_bool("B0");          
 | |
|     //_stampa_ind     = _tab_lbu->get_bool("B1");
 | |
|     _tipo_intesta   = _tab_lbu->get_char("S2");
 | |
|     _codana_intesta = _tab_lbu->get_long("I4");
 | |
|     _desc_cod_lib   = _tab_lbu->get     ("S0");
 | |
|   }
 | |
| }                                        
 | |
| 
 | |
| void Stp_indici_LUnico::intestatario()
 | |
| {    
 | |
|   _anag->setkey(1);        
 | |
|   _anag->zero();
 | |
|   _anag->put(ANA_TIPOA,    _tipo_intesta);
 | |
|   _anag->put(ANA_CODANAGR, _codana_intesta);
 | |
| 
 | |
|   if (_anag->read(_isequal) == NOERR)
 | |
|   {   
 | |
|     _cofi   = _anag->get(ANA_COFI);
 | |
|     _paiv   = _anag->get(ANA_PAIV);
 | |
|     _ragsoc = _anag->get(ANA_RAGSOC);
 | |
|     _codcom = _anag->get(ANA_COMRF);
 | |
|     
 | |
|     if (_codcom.not_empty())
 | |
|     {      
 | |
|       _ind    = _anag->get(ANA_INDRF);
 | |
|       _civ    = _anag->get(ANA_CIVRF);
 | |
|       _cap    = _anag->get(ANA_CAPRF);
 | |
|     }                             
 | |
|     else
 | |
|     {
 | |
|       _codcom = _anag->get(ANA_COMRES);
 | |
|       _ind    = _anag->get(ANA_INDRES);
 | |
|       _civ    = _anag->get(ANA_CIVRES);
 | |
|       _cap    = _anag->get(ANA_CAPRES);
 | |
|     }                                 
 | |
|   }
 | |
|   
 | |
|   _comuni->setkey(1);
 | |
|   _comuni->zero();
 | |
|   _comuni->put(COM_COM,   _codcom);
 | |
|   if (_comuni->read(_isequal) == NOERR)
 | |
|   {
 | |
|     _com  = _comuni->get(COM_DENCOM);
 | |
|     _prov = _comuni->get(COM_PROVCOM);
 | |
|   }
 | |
| }
 | |
| 
 | |
| //Crea sort ordina i record della tabella  per mese registrazione,
 | |
| //numero iniziale pagine registro libro unico
 | |
| 
 | |
| void Stp_indici_LUnico::crea_sort()
 | |
| {
 | |
|   TString dep;
 | |
|   int     mese;
 | |
|   long ditta;
 | |
|   
 | |
|   ind_lib lib;
 | |
| 
 | |
|   if (_sort) delete _sort;
 | |
|   _sort = new TSort (sizeof(ind_lib));
 | |
|   
 | |
|   _sort -> addsortkey((char*)&(lib.mese)      - (char*)&(lib.mese),2);
 | |
|   _sort -> addsortkey((char*)&(lib.nini_plib) - (char*)&(lib.mese),5);
 | |
|   _sort->init(); 
 | |
|   set_firm(_ditta);
 | |
|   
 | |
|   if (_tab_reg != NULL) delete _tab_reg;
 | |
|   _tab_reg = new TTable ("REG");
 | |
|   _tab_lbu->zero();
 | |
|   dep.format ("%4d%-3s", _anno, (const char*)_codlib);
 | |
|   _tab_lbu->put("CODTAB", (const char*) dep);
 | |
| 
 | |
|   if (_tab_lbu->read(_isequal) == NOERR)
 | |
|   { 
 | |
|     _indlib->setkey(1);
 | |
|     _indlib->zero();
 | |
|     _indlib->put("ANNO",   _anno);
 | |
|     _indlib->put("CODLIB", (const char*) _codlib);
 | |
| 
 | |
|     TRectype rec (_indlib->curr());
 | |
| 
 | |
|     for (_indlib->read(); !_indlib->eof(); _indlib->next())
 | |
|     {
 | |
|       if (_indlib->curr() > rec)  break;
 | |
|       
 | |
|       mese  = _indlib->get_int("MESEREG");
 | |
|       ditta = _indlib->get_long("CODDITTA");
 | |
| 
 | |
|       if (mese >= _meseda && mese <= _mesea && ditta == _ditta)
 | |
|       {
 | |
|         sprintf (lib.mese,      "%2d", mese);
 | |
|         sprintf (lib.nini_plib, "%5ld", _indlib->get_long("PAGINI"));
 | |
|         lib.nfin_plib = _indlib->get_long("PAGFIN");
 | |
|         sprintf (lib.cod_reg,   "%-3s", (const char*) _indlib->get("CODREG"));
 | |
|         lib.nini_put  = _indlib->get_long("PAGINIUT");
 | |
|         lib.nfin_put  = _indlib->get_long("PAGFINUT");
 | |
|         sprintf (lib.cod_vid,   "%3s", (const char*) _indlib->get("CODVID"));
 | |
|         lib.pag_ann = _indlib->get_bool("ANNULLATE");
 | |
|         _sort->sort ((const char*) &lib);
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|   _sort->endsort();
 | |
| }
 | |
| 
 | |
| bool Stp_indici_LUnico::set_print(int)
 | |
| {
 | |
|   KEY tasto;
 | |
| 
 | |
|   tasto = _msk->run();
 | |
|   _oldditta = get_firm();
 | |
|   if (tasto == K_ENTER) 
 | |
|   {
 | |
|     _ended = FALSE;
 | |
|     _meseprec = "";
 | |
|     _codlib      = _msk->get(F_LIBRO_UNICO1);
 | |
|     _datastampa  = _msk->get_date(F_DATA_STAMPA); 
 | |
|     _meseda      = _msk->get_int (F_MESEDA);
 | |
|     _mesea       = _msk->get_int (F_MESEA);
 | |
|     _anno        = _msk->get_int (F_ANNO);
 | |
|     _ditta       = _msk->get_long(F_CODDITTA);
 | |
|     ragsoc_ditta(_ditta);
 | |
|     dati_anagrafici_ditta();
 | |
|     dati_libro_unico();
 | |
|     intestatario();
 | |
|     crea_sort();
 | |
|     return TRUE;
 | |
|   }
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::descrizione_codreg(const TString& codreg, TString& desc)
 | |
| {
 | |
|   TString16 dep;
 | |
|   dep.format("%4d%-3s", _anno, (const char*)codreg);
 | |
|   
 | |
|   _tab_reg->zero();
 | |
|   _tab_reg->put("CODTAB", dep);
 | |
|   _tab_reg->read();
 | |
| 
 | |
|   if (_tab_reg->bad())
 | |
|     _tab_reg->zero();
 | |
|   desc = _tab_reg->get("S0");
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::compatta_ragsoc(TString& ragsoc)
 | |
| {   
 | |
|   TString app;
 | |
|   
 | |
|   if (_tipo_intesta == 'F')
 | |
|   {
 | |
|     app  = ragsoc.mid(29,20);
 | |
|     app.trim();
 | |
|     ragsoc = ragsoc.mid(0,30);
 | |
|     ragsoc.trim();
 | |
|     ragsoc << ' ' << app; 
 | |
|   }
 | |
| } 
 | |
| 
 | |
| void Stp_indici_LUnico::postclose_print()
 | |
| {
 | |
|   set_firm(_oldditta);
 | |
| }
 | |
| 
 | |
| bool Stp_indici_LUnico::preprocess_page(int file, int counter)
 | |
| { 
 | |
|   reset_print();
 | |
| 
 | |
|   struct ind_lib* lib = (struct ind_lib*)  _sort->retrieve();
 | |
|   if (lib == NULL)
 | |
|   {
 | |
|     _ended = TRUE;
 | |
|     return FALSE;
 | |
|   }
 | |
|     
 | |
|   _mese          = itom(atoi(lib->mese));
 | |
|   if (_mese == _meseprec) _mese = "";
 | |
|   else _meseprec = _mese;
 | |
|   _numini_paglib = atol(lib->nini_plib);
 | |
|   _numfin_paglib = lib->nfin_plib;
 | |
|   _cod_reg       = lib->cod_reg;
 | |
|   descrizione_codreg(_cod_reg,_descrizione);
 | |
|   _cod_vidimaz   = lib->cod_vid;
 | |
|   _numini_pagut  = lib->nini_put;
 | |
|   _numfin_pagut  = lib->nfin_put;
 | |
|   _pag_ann       = lib->pag_ann;
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void Stp_indici_LUnico::set_page(int file, int counter)
 | |
| { 
 | |
|   int i;
 | |
| 
 | |
|   i = 1;
 | |
|   
 | |
|   print_header();
 | |
|   set_row (i,  "@0g#t",     &_mese);
 | |
|   set_row (i,  "@22g#t",    &_cod_vidimaz);
 | |
|   set_row (i,  "@27g#5d",   &_numini_paglib);
 | |
|   set_row (i,  "@35g#5d",   &_numfin_paglib);
 | |
| 
 | |
|   if (_pag_ann && _cod_reg == "")
 | |
|     set_row (i,FR("@53gPAGINE ANNULLATE"));
 | |
|   else
 | |
|   {
 | |
|     set_row (i,"@50g#t",    &_cod_reg);
 | |
|     set_row (i,"@54g#t", &_descrizione);
 | |
|   }
 | |
| 
 | |
|   set_row (i,  "@85g#5d",  &_numini_pagut);
 | |
|   set_row (i,  "@93g#5d",  &_numfin_pagut);
 | |
| }
 | |
| 
 | |
| print_action Stp_indici_LUnico::postprocess_page(int file, int counter)
 | |
| { 
 | |
|   if (_ended) return NEXT_PAGE;
 | |
|   return REPEAT_PAGE;
 | |
| }
 | |
| 
 | |
| 
 | |
| void Stp_indici_LUnico::print_header()
 | |
| { 
 | |
|   TString sep(132);
 | |
|   TString ind(_ind);
 | |
|   
 | |
|   reset_header();
 | |
|   ind << ", " << _civ;
 | |
|   compatta_ragsoc(_ragsoc);
 | |
|   // Dati studio
 | |
|   if (_ragsoc.len() > 50) _ragsoc.cut(50);
 | |
|   set_header (1,FR("Studio  %-50s @60g%s @110g%s @116g%-13s @129g%s"), 
 | |
|        (const char*)_ragsoc, (const char*)ind, (const char*)_cap, (const char*)_com, (const char*)_prov);
 | |
|   sep << FR("Pag. @#");
 | |
|   sep.right_just(132); 
 | |
|   set_header (2,(const char*) sep);
 | |
|   set_header (2,FR("@0gPartita iva %-11s"), (const char*)_paiv);
 | |
|   set_header (2,FR("@26gCodice fiscale %-16s"), (const char*)_cofi);
 | |
|   set_header (2,FR("@105gData  %s"),(const char*) _datastampa.string());
 | |
|   set_header (3,FR("@0gLibro unico : %s %s"), (const char*)_codlib, (const char*)_desc_cod_lib);
 | |
|   set_header (3,FR("@70gANNO %4d"), _anno);
 | |
|   sep.fill('-');
 | |
|   set_header(4, (const char *) sep);
 | |
|   // Dati ditta
 | |
|   ind = _ind_dta;
 | |
|   ind << ", " << _civ_dta;
 | |
|   if (_ragsoc_dta.len() > 45) _ragsoc_dta.cut(45);
 | |
|   set_header(5,FR("Ditta  %05ld %-45s @60g%s @110g%s @116g%-13s @129g%s"),
 | |
|             _ditta,(const char*)_ragsoc_dta,(const char*) ind,(const char*)_cap_dta,
 | |
|             (const char*)_com_dta,(const char*)_prov_dta);
 | |
|   set_header(6,FR("@0gPartita iva %-11s"), (const char*)_paiv_dta);
 | |
|   set_header(6,FR("@26gCodice fiscale %-16s"), (const char*)_cofi_dta);
 | |
|   set_header(7, (const char *) sep);
 | |
|   // Intestazione colone
 | |
|   set_header(8,FR("@20g---- Libro Unico ----"));
 | |
|   set_header(8,FR("@50g------------------------------"));
 | |
|   set_header(8,FR("@81gRegistri della ditta"));
 | |
|   set_header(8,"@102g------------------------------");
 | |
|   set_header (9,FR("Mese @20gVidim. Da pag   A pag @50gCod Descrizione @84gDa pag   A pag"));
 | |
|   set_header (10, (const char *) sep);
 | |
| }
 | |
| 
 | |
| 
 |