cg6900.h Aggiunto flag spedizione provvisori cgtrcpc.ini Aggiunto campo PROVVIS git-svn-id: svn://10.65.10.50/trunk@4935 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1996 lines
		
	
	
		
			50 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1996 lines
		
	
	
		
			50 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Invio contabilita'
 | |
| 
 | |
| #include "cg6900.h"
 | |
| #include "cg6900a.h"
 | |
| 
 | |
| TInv_cont::TInv_cont(char mov) : _scelta(toupper(mov))
 | |
| {
 | |
|   switch (_scelta)
 | |
|   {       
 | |
|   case 'S':
 | |
|     _titolo = "Invio a Sistema";
 | |
|     break;
 | |
|   case 'P':
 | |
|     _titolo = "Invio a PC";
 | |
|     break;    
 | |
|   default:
 | |
|     break;
 | |
|   }
 | |
| }
 | |
|                                    
 | |
| bool TInv_cont::messaggio_hnd(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_TAB)
 | |
|     return message_box("Rilevato STATO DI RIPARTENZA: il trasferimento ripartira' automaticamente");
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
|                                    
 | |
| bool TInv_cont::main_loop()
 | |
| {                     
 | |
|   TString str;
 | |
|   bool ripartenza = FALSE;
 | |
|   
 | |
|   if (!esiste_tabella_studio()) return FALSE;
 | |
|   
 | |
|   if (!esegui_controlli()) return FALSE;
 | |
|   
 | |
|   TMask* msk = new TMask("cg6900a");
 | |
|   KEY tasto;
 | |
|   
 | |
|   if (_ditta != 0)       
 | |
|   {
 | |
|     msk->set(F_DITTAINV, _ditta);
 | |
|     msk->disable(F_DITTAINV);
 | |
|     codifica_ditta(*msk);
 | |
|     msk->set(F_NUMULINV, _num);
 | |
|     msk->set(F_DATAULIN, _data.string());
 | |
|     msk->set(F_STATO,    _stato);
 | |
|     
 | |
|     TString uselab = _tras_file.ult_file();
 | |
|     TString chiave = _tras_file.key();
 | |
|     msk->set(F_USELAB,   uselab);
 | |
|     msk->set(F_CHIAVE,   chiave);
 | |
|     msk->set(F_DATALIM,  _data.string());
 | |
|     msk->disable(F_DATALIM);
 | |
|     
 | |
|     if (_scelta == 'S' && _ditta > 9999)
 | |
|     {
 | |
|       msk->show(F_DITTAAS); 
 | |
|       msk->disable(F_DITTAAS);
 | |
|       long ditta = atol(_control_rec.sub(300,304));
 | |
|       msk->set(F_DITTAAS, ditta);
 | |
|     }                            
 | |
|     else
 | |
|       msk->hide(F_DITTAAS);
 | |
|     
 | |
|     ripartenza = TRUE;
 | |
|   }
 | |
|   
 | |
|   msk->disable(F_NUMULINV);
 | |
|   msk->disable(F_DATAULIN);
 | |
|   msk->disable(F_STATO);
 | |
|   msk->disable(F_USELAB);
 | |
|   msk->disable(F_CHIAVE);
 | |
| 
 | |
|   if (!ripartenza)
 | |
|     msk->set_handler(F_DITTAINV, setta_maschera_hnd);
 | |
|   else
 | |
|     msk->set_handler(F_NUMULINV, messaggio_hnd);  
 | |
|   
 | |
|   tasto = msk->run();
 | |
|   
 | |
|   if (tasto != K_ENTER)
 | |
|   {
 | |
|     delete msk;
 | |
|     return FALSE;
 | |
|   }
 | |
|   
 | |
|   _dittaAS = msk->get_long(F_DITTAAS); //Se la ditta per l'invio ad AS non viene compilata perche' trattasi di invio a PC
 | |
|   if (_dittaAS == 0)                  //o perche' il codice e' di 4, gli assegno la ditta corrente. Nel caso di invio a
 | |
|     _dittaAS = _ditta;                //PC non servirebbe il codice aggiuntivo, ma lo metto ugualmente per avere una situazione analoga
 | |
|               
 | |
| // Nel caso di invio PC --> SISTEMA eseguo prima la
 | |
| // Lista controllo archivi per rilevare eventuali
 | |
| // differenze.
 | |
|   
 | |
|   long ditta = msk->get_long(F_DITTAINV);
 | |
|   set_firm(ditta);
 | |
| 
 | |
|   TConfig conf(CONFIG_DITTA);           
 | |
|   TString std = conf.get("FlStInv");
 | |
|   
 | |
|   if (_scelta == 'S' && std != "D")
 | |
|   {  
 | |
|      TString appname = "cg6 -8 L";
 | |
|      TString corpo   = "";
 | |
|      
 | |
|      TDate data = msk->get(F_DATALIM);
 | |
|      
 | |
|      corpo << data.string();
 | |
|   
 | |
|      TMessage mess (appname,"",(const char*)corpo);
 | |
|      TMailbox mb;
 | |
|      mb.send(mess);
 | |
|      
 | |
|      TExternal_app a (appname);
 | |
|      a.run();
 | |
|      
 | |
|      TMailbox m;
 | |
|      TMessage* msg = m.next_s("");
 | |
|      int subj;
 | |
|      
 | |
|      if (msg != NULL)
 | |
|      {
 | |
|        subj = atoi(msg->body());
 | |
|        if (subj)
 | |
|        {
 | |
|          delete msk;
 | |
|          return FALSE;
 | |
|        }
 | |
|      }
 | |
|   }  
 | |
|   
 | |
|   _datalimsk = msk->get(F_DATALIM);
 | |
|   
 | |
|   if (!ripartenza)
 | |
|   {                            
 | |
|     crea_marker(*msk);                 //Crea il record con le informazioni sul marker                 
 | |
|     setta_parametri_record(*msk,"F");  //Aggiorna parametri contabili ditta           
 | |
|     setta_tabella_studio(*msk);        //Aggiorna la tabella studio per invio
 | |
|     setta_tabella_ditta(*msk,"F");     //Aggiorna la tabella ditta per invio
 | |
|     crea_record_controllo(*msk);       //Crea il record di controllo sul file header
 | |
|   }                
 | |
|   else
 | |
|   { 
 | |
|     TString str,app;
 | |
|     
 | |
|     int num = msk->get_int(F_NUMULINV);
 | |
|     TString data (msk->get(F_DATALIM));
 | |
|     if (_scelta == 'S')
 | |
|     {
 | |
|       app = riconverti(data,FALSE);
 | |
|       str.format("%03d%6s", num, (const char*) app);
 | |
|       aggiorna_marker(str,14);
 | |
|     }
 | |
|     else
 | |
|       if (_scelta == 'P')
 | |
|       {
 | |
|         app = riconverti(data,TRUE);
 | |
|         str.format("%03d%8s", num, (const char*) app);
 | |
|         aggiorna_marker(str,15);      
 | |
|       }
 | |
|   }
 | |
| 
 | |
|   apri_file_temp();
 | |
|     
 | |
|   if (!invio_tempfile(*msk))
 | |
|   {
 | |
|     delete msk;
 | |
|     return FALSE;
 | |
|   }
 | |
|   
 | |
| //  calcola_totale_record();
 | |
| //  str.format("%06ld", _tot_rec);
 | |
| 
 | |
|   if (_scelta == 'S')
 | |
|   {                             
 | |
| //    aggiorna_marker(str,23);  
 | |
|     
 | |
|     _trasf = ""; 
 | |
|     _trasf = firm2dir(0);
 | |
|     _trasf << "\\trasfer"; 
 | |
|     fremove(_trasf);
 | |
|     _tras_file.open(_trasf,TRUE);
 | |
|                             
 | |
| //    if (std != "D")
 | |
|       invio_contabilita();              //Costruisce il trasfer nella directory comune
 | |
|     
 | |
|     TMask* mask = new TMask("cg6900b");
 | |
|     KEY k;
 | |
|     TString floppy,percorso;
 | |
|     int     num_disk;
 | |
|     
 | |
|     bool ok        = FALSE;
 | |
|     bool abbandona = FALSE;
 | |
|     do
 | |
|     {
 | |
|       k = mask->run();
 | |
|       
 | |
|       if (k != K_ENTER) 
 | |
|       {
 | |
|         abbandona = TRUE;
 | |
|         break;
 | |
|       }
 | |
|       floppy   = mask->get(F_FLOPPY); 
 | |
|       num_disk = calcola_numero_dischi(*mask,floppy);
 | |
|       percorso = mask->get(F_PATH);     
 | |
|       if (percorso.not_empty())  
 | |
|       {
 | |
|         floppy << ":/" << percorso;
 | |
|         if (fexist(floppy)) 
 | |
|           ok = TRUE;
 | |
|         else
 | |
|           message_box("Il percorso indicato non e' corretto");  
 | |
|       }
 | |
|       else
 | |
|         ok = TRUE;  // Se scelgo il dischetto non eseguo il controllo sulla correttezza del path
 | |
|     }
 | |
|     while (!ok);
 | |
|       
 | |
|     if (!abbandona)
 | |
|     {  
 | |
|       str.format("%02d", num_disk);
 | |
|       aggiorna_marker(str,29);
 | |
| 
 | |
|       const TFilename from(_trasf);          // File da splittare
 | |
| 
 | |
|       TFilename work;   
 | |
|       if (percorso.not_empty())
 | |
|         work << floppy << "/" << from.name();
 | |
|       else
 | |
|         work << floppy << ":/" << from.name();   // File su dischetto
 | |
|     
 | |
|       FILE* i = fopen(from, "rb");                                             
 | |
|     
 | |
|       if (i == NULL) return error_box("Impossibile aprire il file '%s'", from);
 | |
|       
 | |
|       const char* message;
 | |
|       if (floppy == "A" || floppy == "B")
 | |
|         message = "Trasferimento su dischetti in corso... Prego attendere";
 | |
|       else
 | |
|         message = "Trasferimento in corso... Prego attendere";
 | |
|         
 | |
|       TProgind w(_dim_tot, message, TRUE, TRUE, 60);
 | |
|       
 | |
|       bool continua = TRUE;
 | |
|       for (int j = 0; j < num_disk; j++)
 | |
|       {
 | |
|         continua = scrivi_disco(floppy,j+1,work,i,w);
 | |
|       }
 | |
|       fclose(i);
 | |
|       
 | |
|       if (!continua) return FALSE;  // Nel caso in cui l'utente decida di annulla re l'operazione
 | |
|       
 | |
|       setta_tabella_studio(*msk,FALSE);    //Aggiorna la tabella studio per invio
 | |
|       setta_tabella_ditta(*msk," ",FALSE); //Aggiorna la tabella ditta per invio
 | |
|       setta_parametri_record(*msk," ");    //Aggiorna parametri contabili ditta           
 | |
|     
 | |
|       _tras_file.open(_header);
 | |
|       leggi_record_controllo();
 | |
|       TString record(1024);  
 | |
|       record.spaces();
 | |
|       _control_rec.overwrite(record,0);
 | |
|       _tras_file.write_control_rec(_control_rec,1024);
 | |
| 
 | |
|       chiudi_file_temp();      
 | |
|     }                
 | |
|     else
 | |
|     {
 | |
|       delete msk;
 | |
|       delete mask;
 | |
|       return FALSE;
 | |
|     }
 | |
|     delete mask;
 | |
|   }
 | |
|   else
 | |
|     if (_scelta == 'P')
 | |
|     {
 | |
|       _trasf = ""; 
 | |
|       _trasf = firm2dir(0);
 | |
|       _trasf << "\\trasfer"; 
 | |
|       fremove(_trasf);
 | |
|       _tras_file.open(_trasf,TRUE);
 | |
|                             
 | |
|       invio_contabilita_PC(); //Costruisce il trasfer nella directory comune
 | |
|     
 | |
|       TMask* mask = new TMask("cg6900b");
 | |
|       KEY k;
 | |
|       TString floppy,percorso;
 | |
|       int     num_disk;
 | |
| 
 | |
|       bool ok        = FALSE; 
 | |
|       bool abbandona = FALSE;
 | |
|       do
 | |
|       {
 | |
|         k = mask->run();
 | |
|       
 | |
|         if (k != K_ENTER)
 | |
|         {      
 | |
|           abbandona = TRUE;
 | |
|           break;
 | |
|         }        
 | |
|         floppy   = mask->get(F_FLOPPY);
 | |
|         num_disk = calcola_numero_dischi(*mask,floppy);   
 | |
|         percorso = mask->get(F_PATH);   
 | |
|         if (percorso.not_empty())  
 | |
|         {
 | |
|           floppy << ":/" << percorso;  
 | |
|           if (fexist(floppy)) 
 | |
|             ok = TRUE;
 | |
|           else
 | |
|             message_box("Il percorso indicato non e' corretto");  
 | |
|         }
 | |
|         else
 | |
|           ok = TRUE;  // Se scelgo il dischetto non eseguo il controllo sulla correttezza del path
 | |
|       }
 | |
|       while (!ok);
 | |
| 
 | |
|       if (!abbandona)
 | |
|       {  
 | |
|         str.format("%02d", num_disk);
 | |
|         aggiorna_marker(str,32);
 | |
| 
 | |
|         const TFilename from(_trasf);          // File da splittare
 | |
| 
 | |
|         TFilename work;   
 | |
|         if (percorso.not_empty())
 | |
|           work << floppy << "/" << from.name();   // File su dischetto
 | |
|         else
 | |
|           work << floppy << ":/" << from.name();   // File su dischetto
 | |
|     
 | |
|         FILE* i = fopen(from, "rb");                                             
 | |
|     
 | |
|         if (i == NULL) return error_box("Impossibile aprire il file '%s'", from);
 | |
| 
 | |
|         const char* message;
 | |
|         if (floppy == "A" || floppy == "B")
 | |
|           message = "Trasferimento su dischetti in corso... Prego attendere";
 | |
|         else
 | |
|           message = "Trasferimento in corso... Prego attendere";
 | |
|     
 | |
|         TProgind w(_dim_tot, message, TRUE, TRUE, 60);
 | |
|         
 | |
|         bool continua = TRUE;
 | |
|         for (int j = 0; j < num_disk; j++)
 | |
|         {
 | |
|           continua = scrivi_disco(floppy,j+1,work,i,w);
 | |
|         }
 | |
|         fclose(i);
 | |
|         
 | |
|         if (!continua) return FALSE;    // Nel caso in cui l'utente decida di annullare l'operazione
 | |
|         
 | |
|         setta_tabella_studio(*msk,FALSE);    //Aggiorna la tabella studio per invio
 | |
|         setta_tabella_ditta(*msk," ",FALSE); //Aggiorna la tabella ditta per invio
 | |
|         setta_parametri_record(*msk," ");    //Aggiorna parametri contabili ditta           
 | |
|     
 | |
|         _tras_file.open(_header);
 | |
|         leggi_record_controllo();
 | |
|         TString record(1024);  
 | |
|         record.spaces();
 | |
|         _control_rec.overwrite(record,0);
 | |
|         _tras_file.write_control_rec(_control_rec,1024);
 | |
| 
 | |
|         chiudi_file_temp();      
 | |
|       }                
 | |
|       else
 | |
|       {
 | |
|         delete msk;
 | |
|         delete mask;
 | |
|         return FALSE;
 | |
|       }
 | |
|       delete mask;
 | |
|     }
 | |
|                        
 | |
|   _tras_file.remove_all(FALSE);                        
 | |
|   fremove(_marker);
 | |
|   _trasf = ""; 
 | |
|   _trasf = firm2dir(0);
 | |
|   _trasf << "\\trasfer";  
 | |
|   fremove(_trasf);
 | |
|   
 | |
|   delete msk;
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TInv_cont::create()
 | |
| {
 | |
|   TApplication::create();
 | |
|   
 | |
|   _caus     = new TLocalisamfile (LF_CAUSALI);
 | |
|   _rcaus    = new TLocalisamfile (LF_RCAUSALI);
 | |
|   _clifo    = new TLocalisamfile (LF_CLIFO);
 | |
|   _pcon     = new TLocalisamfile (LF_PCON);
 | |
|   _mov      = new TLocalisamfile (LF_MOV);
 | |
|   _rmov     = new TLocalisamfile (LF_RMOV);
 | |
|   _rmoviva  = new TLocalisamfile (LF_RMOVIVA);       
 | |
|   _occas    = new TLocalisamfile (LF_OCCAS);
 | |
|   _part     = new TLocalisamfile (LF_PARTITE);
 | |
|   _scad     = new TLocalisamfile (LF_SCADENZE);
 | |
|   _pagsca   = new TLocalisamfile (LF_PAGSCA);       
 | |
|   _comuni   = new TLocalisamfile (LF_COMUNI);       
 | |
| 
 | |
|   dispatch_e_menu (BAR_ITEM(1));
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TInv_cont::destroy()
 | |
| {                                           
 | |
|   delete _caus;
 | |
|   delete _rcaus;
 | |
|   delete _clifo;
 | |
|   delete _pcon;
 | |
|   delete _mov;
 | |
|   delete _rmov;
 | |
|   delete _rmoviva;
 | |
|   delete _occas;  
 | |
|   delete _part;
 | |
|   delete _scad;
 | |
|   delete _pagsca;
 | |
|   delete _comuni;
 | |
| 
 | |
|   return TApplication::destroy();
 | |
| }                                
 | |
| 
 | |
| void TInv_cont::apri_file_temp()
 | |
| { 
 | |
|   _tras_file.open(_header);
 | |
|   leggi_record_controllo();
 | |
|   _sigle = _tras_file.sigle_file();
 | |
|   _sigle.trim();
 | |
|   
 | |
|   for (int i = 0; i < _sigle.len(); i++)
 | |
|   {                       
 | |
|     TString80 tmp;
 | |
|     char sigla = _sigle[i];
 | |
|     
 | |
|     if (sigla == 'W')
 | |
|     {
 | |
|       TString80 tmpcaus = "%";
 | |
|       tmpcaus << firm2dir(0);
 | |
|       tmpcaus << "\\" << TEMP_CAUS;          
 | |
|       tmp = tmpcaus.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _tcaus    = new TIsamtempfile(LF_CAUSALI, tmpcaus, FALSE);  
 | |
|       else
 | |
|         _tcaus    = new TIsamtempfile(LF_CAUSALI, tmpcaus, TRUE);  
 | |
|       TString80 tmprcaus = "%";
 | |
|       tmprcaus << firm2dir(0);
 | |
|       tmprcaus << "\\" << TEMP_RCAUS;
 | |
|       tmp = tmprcaus.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _trcaus   = new TIsamtempfile(LF_RCAUSALI, tmprcaus, FALSE);
 | |
|       else
 | |
|         _trcaus   = new TIsamtempfile(LF_RCAUSALI, tmprcaus, TRUE);
 | |
|     }
 | |
|     if (sigla == 'A')
 | |
|     {
 | |
|       TString80 tmpclifo = "%";
 | |
|       tmpclifo << firm2dir(0);
 | |
|       tmpclifo << "\\" << TEMP_CLIFO;
 | |
|       tmp = tmpclifo.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _tclifo    = new TIsamtempfile(LF_CLIFO, tmpclifo, FALSE);
 | |
|       else
 | |
|         _tclifo    = new TIsamtempfile(LF_CLIFO, tmpclifo, TRUE);
 | |
|     }
 | |
|     if (sigla == 'P')
 | |
|     {
 | |
|       TString80 tmppcon = "%";
 | |
|       tmppcon << firm2dir(0);
 | |
|       tmppcon << "\\" << TEMP_PCON;
 | |
|       tmp = tmppcon.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))                                 
 | |
|         _tpcon    = new TIsamtempfile(LF_PCON, tmppcon, FALSE);
 | |
|       else
 | |
|         _tpcon    = new TIsamtempfile(LF_PCON, tmppcon, TRUE);
 | |
|     }
 | |
|     if (sigla == 'Z')
 | |
|     {
 | |
|       TString80 tmpmov = "%";
 | |
|       tmpmov << firm2dir(0);
 | |
|       tmpmov << "\\" << TEMP_MOV;
 | |
|       tmp = tmpmov.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _tmov     = new TIsamtempfile(LF_MOV, tmpmov, FALSE);
 | |
|       else
 | |
|         _tmov     = new TIsamtempfile(LF_MOV, tmpmov, TRUE);
 | |
|       TString80 tmprmov = "%";
 | |
|       tmprmov << firm2dir(0);
 | |
|       tmprmov << "\\" << TEMP_RMOV;
 | |
|       tmp = tmprmov.mid(1);
 | |
|       tmp << ".dbf"; 
 | |
|       if (fexist(tmp))
 | |
|         _trmov    = new TIsamtempfile(LF_RMOV, tmprmov, FALSE);
 | |
|       else
 | |
|         _trmov    = new TIsamtempfile(LF_RMOV, tmprmov, TRUE);
 | |
|     }
 | |
|     if (sigla == 'U')
 | |
|     {
 | |
|       TString80 tmpriva = "%";
 | |
|       tmpriva << firm2dir(0);
 | |
|       tmpriva << "\\" << TEMP_RMOVIVA;
 | |
|       tmp = tmpriva.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _triva    = new TIsamtempfile(LF_RMOVIVA, tmpriva, FALSE);
 | |
|       else
 | |
|         _triva    = new TIsamtempfile(LF_RMOVIVA, tmpriva, TRUE);
 | |
|       TString80 tmpoccas = "%";
 | |
|       tmpoccas << firm2dir(0);
 | |
|       tmpoccas << "\\" << TEMP_OCC;
 | |
|       tmp = tmpoccas.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _toccas   = new TIsamtempfile(LF_OCCAS, tmpoccas, FALSE);
 | |
|       else
 | |
|         _toccas   = new TIsamtempfile(LF_OCCAS, tmpoccas, TRUE);
 | |
|     }
 | |
|     if (sigla == 'B')
 | |
|     {
 | |
|       TString80 tmppart = "%";
 | |
|       tmppart << firm2dir(0);
 | |
|       tmppart << "\\" << TEMP_PART;
 | |
|       tmp = tmppart.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _tpart    = new TIsamtempfile(LF_PARTITE, tmppart, FALSE);
 | |
|       else
 | |
|         _tpart    = new TIsamtempfile(LF_PARTITE, tmppart, TRUE);
 | |
|       TString80 tmpscad = "%";
 | |
|       tmpscad << firm2dir(0);
 | |
|       tmpscad << "\\" << TEMP_SCAD;
 | |
|       tmp = tmpscad.mid(1);
 | |
|       tmp << ".dbf"; 
 | |
|       if (fexist(tmp))
 | |
|         _tscad    = new TIsamtempfile(LF_SCADENZE, tmpscad, FALSE);
 | |
|       else
 | |
|         _tscad    = new TIsamtempfile(LF_SCADENZE, tmpscad, TRUE);
 | |
|       TString80 tmppagsca = "%";
 | |
|       tmppagsca << firm2dir(0);
 | |
|       tmppagsca << "\\" << TEMP_PAGSCA;
 | |
|       tmp = tmppagsca.mid(1);
 | |
|       tmp << ".dbf";
 | |
|       if (fexist(tmp))
 | |
|         _tpagsca  = new TIsamtempfile(LF_PAGSCA, tmppagsca, FALSE);
 | |
|       else
 | |
|         _tpagsca  = new TIsamtempfile(LF_PAGSCA, tmppagsca, TRUE);
 | |
|     }    
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::chiudi_file_temp()
 | |
| {
 | |
|   for (int i = 0; i < _sigle.len(); i++)
 | |
|   {
 | |
|     char sigla = _sigle[i];
 | |
| 
 | |
|     if (sigla == 'W')
 | |
|     {
 | |
|       delete _tcaus;
 | |
|       delete _trcaus;
 | |
|     }
 | |
|     if (sigla == 'A')
 | |
|       delete _tclifo;
 | |
|     if (sigla == 'P')
 | |
|       delete _tpcon;
 | |
|     if (sigla == 'Z')
 | |
|     {
 | |
|       delete _tmov;
 | |
|       delete _trmov;
 | |
|     }
 | |
|     if (sigla == 'U')
 | |
|     {
 | |
|       delete _triva;
 | |
|       delete _toccas;
 | |
|     }
 | |
|     if (sigla == 'B')
 | |
|     {
 | |
|       delete _tpart;
 | |
|       delete _tscad;
 | |
|       delete _tpagsca;
 | |
|     }    
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::leggi_record_controllo()
 | |
| {
 | |
|   _tras_file.read_control_rec();
 | |
|   _control_rec = _tras_file.record();
 | |
| }
 | |
| 
 | |
| bool TInv_cont::esiste_tabella_studio()
 | |
| {
 | |
|   TTable ins ("%INS");
 | |
|   
 | |
|   ins.zero();        
 | |
|   
 | |
|   if (ins.first() == NOERR)
 | |
|   {
 | |
|     if (ins.empty())
 | |
|       return error_box("Codice STUDIO NON ATTIVATO in tabella invii");
 | |
|     else
 | |
|     { 
 | |
|       _nome_simbolico = ins.get("S0");
 | |
|       long ditta = ins.get_long("I0");
 | |
|       if (ditta != 0)
 | |
|       {
 | |
|         _esiste_ditta = TRUE;
 | |
|         _ditta = ditta;
 | |
|       }
 | |
|       else
 | |
|       {             
 | |
|         _esiste_ditta = FALSE;
 | |
|         _ditta = 0;
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|   else
 | |
|     return error_box("Codice STUDIO NON ATTIVATO in tabella invii");  
 | |
|   
 | |
|   return TRUE;  
 | |
| }  
 | |
| 
 | |
| bool TInv_cont::leggi_header()
 | |
| { 
 | |
|   _header = ""; 
 | |
|   _header = firm2dir(0);
 | |
|   _header << HEADER;
 | |
|   
 | |
|   _tras_file.open(_header);
 | |
|   
 | |
|   if (_tras_file.exist())           
 | |
|   {  
 | |
|     if (_tras_file.read_control_rec())
 | |
|     {
 | |
|       _control_rec = _tras_file.record();
 | |
|       if (!record_controllo())
 | |
|         return FALSE;
 | |
|     }
 | |
|     else
 | |
|       return FALSE;
 | |
|   } 
 | |
|   else
 | |
|     return FALSE;
 | |
|   
 | |
|   return TRUE; 
 | |
| }
 | |
| 
 | |
| bool TInv_cont::record_controllo()
 | |
| {
 | |
|   TString tiporecord = _control_rec.sub(0,2);
 | |
|   
 | |
|   if (tiporecord != " 1")
 | |
|     return FALSE;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TInv_cont::esegui_controlli()
 | |
| {  
 | |
|   _esiste_record = leggi_header();
 | |
|   
 | |
|   if (!controlli()) return FALSE;
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TInv_cont::setta_parametri_record(TMask& m,const TString& flag)
 | |
| {  
 | |
|   TConfig conf (CONFIG_DITTA);
 | |
|   conf.set("FlStInv", flag);
 | |
| }
 | |
| 
 | |
| bool TInv_cont::controlli()
 | |
| { 
 | |
|   if (!_esiste_ditta && !_esiste_record) return TRUE; //Mi trovo in una condizione normale
 | |
|   
 | |
|   if (_esiste_ditta && !_esiste_record)
 | |
|     return error_box("Rilevato stato di ripartenza con dati contradditori: programma interrotto");
 | |
|   
 | |
|   if (!_esiste_ditta && _esiste_record)
 | |
|     return error_box("Rilevato stato di ripartenza con dati contradditori: programma interrotto");
 | |
|   
 | |
|   if (_esiste_ditta && _esiste_record)
 | |
|   {
 | |
|     if (!sub_controlli())
 | |
|       return error_box("Rilevato stato di ripartenza con dati contradditori: programma interrotto");
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }   
 | |
| 
 | |
| bool TInv_cont::sub_controlli()
 | |
| {
 | |
|   long ditta_trasfer = _tras_file.ditta();
 | |
|   
 | |
|   if (_ditta == ditta_trasfer)
 | |
|   {
 | |
|     if (!prefix().exist(_ditta))
 | |
|       return FALSE;
 | |
|     
 | |
|     if (!tabella_ditta())
 | |
|       return FALSE;
 | |
|   }          
 | |
|   else
 | |
|     return FALSE;
 | |
| 
 | |
|   if (!controlla_stato_invio())  
 | |
|     return FALSE;
 | |
|   
 | |
|   if (!numero_data())
 | |
|     return FALSE;    
 | |
|   
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| bool TInv_cont::tabella_ditta()
 | |
| {
 | |
|   TTable ind ("%IND");
 | |
|   TString dep;
 | |
|   
 | |
|   dep.format("%05ld", _ditta);
 | |
|   
 | |
|   ind.zero();
 | |
|   ind.put("CODTAB", dep);
 | |
|   if (ind.read() == NOERR) 
 | |
|   {
 | |
|     _stato = ind.get("S6");
 | |
|     _num   = ind.get_int("I0");
 | |
|     _data  = ind.get_date("D0");
 | |
|     
 | |
|     _files = "";
 | |
|     if (ind.get_bool("B0") && (_caus->items() != 0) )
 | |
|       _files << "W";
 | |
|     
 | |
|     if (ind.get_bool("B1") && (_clifo->items() != 0) )
 | |
|       _files << "A";
 | |
|     
 | |
|     if (ind.get_bool("B2") && (_pcon->items() != 0) )
 | |
|       _files << "P";        
 | |
|     
 | |
|     if (ind.get_bool("B3") && (_mov->items() != 0) )
 | |
|       _files << "Z";
 | |
|     
 | |
|     if (ind.get_bool("B4") && (_rmoviva->items() != 0) )
 | |
|       _files << "U";
 | |
|     
 | |
|     if (ind.get_bool("B5") && (_part->items() != 0) )
 | |
|       _files << "B";
 | |
|       
 | |
|     _flag_provvis = ind.get_bool("B6");  
 | |
|       
 | |
|     _flag_bollato = ind.get_bool("B7");
 | |
| 
 | |
|     // Compila l'array contenente le causali di corrispondenza per l'invio extracontabile      
 | |
|     dep = "";
 | |
|     TString s5(ind.get("S5"));
 | |
|     _tab_cau.destroy();
 | |
|     _tab_cau.add(s5.mid(0,3)); 
 | |
|     _tab_cau.add(s5.mid(3,3));
 | |
|     _tab_cau.add(s5.mid(6,3));
 | |
|     _tab_cau.add(dep); // corrisponde al tipo dell'abbuono.
 | |
|     _tab_cau.add(s5.mid(9,3));
 | |
|     _tab_cau.add(s5.mid(12,3));
 | |
|     _cpg_nc = ind.get("S7"); // condizione pagamento (rimessa diretta) per le note di credito
 | |
|     
 | |
|     return TRUE;
 | |
|   }  
 | |
|   
 | |
|   return FALSE;  
 | |
| }
 | |
| 
 | |
| bool TInv_cont::controlla_stato_invio()
 | |
| { 
 | |
|   set_firm(_ditta);
 | |
|   
 | |
|   TConfig conf(CONFIG_DITTA);           
 | |
|   _std = conf.get("FlStInv");
 | |
|   
 | |
|   if (_stato != _std)
 | |
|     return FALSE;
 | |
|   else
 | |
|   {                  
 | |
|     TString uselab = _tras_file.ult_file();
 | |
|     
 | |
|     if (_stato == "D" && uselab != "")
 | |
|       return FALSE;
 | |
|   }                
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TInv_cont::numero_data()
 | |
| {                                        
 | |
|   int num = _tras_file.nultras();
 | |
|   TString str = _tras_file.dataultras();
 | |
|   TDate data (str);
 | |
|   
 | |
|   if (_num != num || data != _data)
 | |
|     return FALSE;
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TInv_cont::codifica_ditta(TMask& m)
 | |
| {
 | |
|   TLocalisamfile ditte (LF_NDITTE);
 | |
|   
 | |
|   long ditta = m.get_long(F_DITTAINV);
 | |
|   
 | |
|   ditte.setkey(1);
 | |
|   ditte.zero();
 | |
|   ditte.put(NDT_CODDITTA, ditta);
 | |
|   if (ditte.read() == NOERR)
 | |
|   {
 | |
|     TString ragsoc = ditte.get(NDT_RAGSOC);
 | |
|     m.set(F_RAGSOC, ragsoc);
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool TInv_cont::setta_maschera_hnd(TMask_field& f, KEY k)
 | |
| {
 | |
|   if ( (k == K_TAB || k == K_ENTER) && f.mask().is_running())
 | |
|   {    
 | |
|     long& d = app()._ditta;
 | |
|     d = f.mask().get_long(F_DITTAINV);
 | |
|     if (d == 0L) return TRUE;
 | |
|     if (!prefix().exist(d))
 | |
|       return error_box("La ditta indicata non e' abilitata alla contabilita'");
 | |
| 
 | |
|     if (!app().tabella_ditta())
 | |
|       return error_box("La ditta indicata non e' presente sulla tabella ditta per invio");
 | |
|    
 | |
|     if (app()._stato != "")
 | |
|       return error_box("Rilevato STATO DI RIPARTENZA NON RECUPERABILE sulla ditta richiesta");
 | |
|     
 | |
|     f.mask().set(F_DITTAINV, d);
 | |
|     app().codifica_ditta(f.mask());
 | |
|     f.mask().set(F_NUMULINV, app()._num);
 | |
|     f.mask().set(F_DATAULIN, app()._data.string());
 | |
|     f.mask().set(F_STATO,    app()._stato);
 | |
|                                      
 | |
|     long ditta = atol(f.get());
 | |
|     
 | |
|     if (app()._scelta == 'S' && ditta > 9999)
 | |
|       f.mask().show(F_DITTAAS);            
 | |
|     else
 | |
|       f.mask().hide(F_DITTAAS);
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TInv_cont::crea_marker(TMask& m)
 | |
| {
 | |
|   TString str;
 | |
|   
 | |
|   _marker = ""; 
 | |
|   _marker = firm2dir(0);
 | |
|   _marker << "\\marker";
 | |
|   
 | |
|   FILE* i;
 | |
| 
 | |
|   const word size = 64;
 | |
|   TString buffer(size); 
 | |
|   buffer.spaces();
 | |
|   
 | |
|   if ( (i = fopen(_marker,"w+t")) != NULL)
 | |
|   { 
 | |
|     if (_scelta == 'S')
 | |
|     {
 | |
|       str.format("%-10s", (const char*)_nome_simbolico);
 | |
|       buffer.overwrite(str,0);
 | |
|       long ditta = m.get_long(F_DITTAINV); 
 | |
|       if (ditta > 9999)
 | |
|         ditta = _dittaAS;
 | |
|       str = format("%04d", ditta);
 | |
|       buffer.overwrite(str,10);
 | |
|       int num = m.get_int(F_NUMULINV);
 | |
|       num++;
 | |
|       str = format("%03d", num);
 | |
|       buffer.overwrite(str,14);
 | |
|       TString data (m.get(F_DATALIM));
 | |
|       str = riconverti(data,FALSE);
 | |
|       buffer.overwrite(str,17);               
 | |
|     }
 | |
|     else
 | |
|       if (_scelta == 'P')
 | |
|       {
 | |
|         str = format("%-10s", (const char*) _nome_simbolico);
 | |
|         buffer.overwrite(str,0);
 | |
|         long ditta = m.get_long(F_DITTAINV);
 | |
|         str = format("%05ld", ditta);
 | |
|         buffer.overwrite(str,10);
 | |
|         int num = m.get_int(F_NUMULINV);
 | |
|         num++;
 | |
|         str = format("%03d", num);
 | |
|         buffer.overwrite(str,15);
 | |
|         TString data (m.get(F_DATALIM));
 | |
|         str = riconverti(data,TRUE);
 | |
|         buffer.overwrite(str,18);      
 | |
|       }
 | |
|       
 | |
|     buffer.cut(64); //Sicurezza: le stringhe dimensionate in realta' sono
 | |
|                     //leggermente piu' lunghe della dimensione specificata
 | |
|     const word scritti = fwrite((char*)(const char*)buffer,sizeof(char),size,i);
 | |
|     
 | |
|     fclose(i);
 | |
|   }    
 | |
| }
 | |
| 
 | |
| void TInv_cont::aggiorna_marker(TString& token, int pos)
 | |
| {   
 | |
|   TString str;
 | |
|   
 | |
|   _marker = ""; 
 | |
|   _marker = firm2dir(0);
 | |
|   _marker << "\\marker";
 | |
|   
 | |
|   FILE* i;
 | |
| 
 | |
|   const word size = 64;
 | |
|   TString buffer(size); 
 | |
|   //buffer.spaces();
 | |
|   
 | |
|   if ( (i = fopen(_marker,"r+t")) != NULL)
 | |
|   { 
 | |
|     const word letti = fread((char*)(const char*)buffer,sizeof(char),size,i);
 | |
|     buffer.overwrite(token,pos);
 | |
| 
 | |
|     buffer.cut(64); //Sicurezza: le stringhe dimensionate in realta' sono
 | |
|                     //leggermente piu' lunghe della dimensione specificata    
 | |
|     fseek(i, 0L, SEEK_SET);
 | |
|     const word scritti = fwrite((char*)(const char*)buffer,sizeof(char),size,i);
 | |
|     
 | |
|     fclose(i);
 | |
|   }    
 | |
| }
 | |
| 
 | |
| void TInv_cont::calcola_totale_record()
 | |
| {
 | |
|   _tras_file.open(_header);
 | |
|   leggi_record_controllo();
 | |
|   
 | |
|   TString sigle = _tras_file.sigle_file();
 | |
|   sigle.trim();
 | |
|   
 | |
|   _tot_rec = 0;
 | |
|   
 | |
|   for (int i = 0; i < sigle.len(); i++)
 | |
|   {
 | |
|     long tot_rec = atol(_control_rec.mid((i * 6) + 95,6));
 | |
|     _tot_rec += tot_rec;
 | |
|   }             
 | |
|   _tot_rec += 1;
 | |
| }
 | |
| 
 | |
| void TInv_cont::setta_tabella_studio(TMask& m,bool flag_ditta)
 | |
| {
 | |
|   TTable ins ("%INS");
 | |
|   TString dep;
 | |
|   long ditta;
 | |
|   
 | |
|   if (flag_ditta)
 | |
|     ditta = m.get_long(F_DITTAINV);
 | |
|   else
 | |
|     ditta = 0;
 | |
|   
 | |
|   dep.format("%-3s", (const char*) "INS");
 | |
|   
 | |
|   ins.zero();
 | |
|   ins.put("CODTAB", dep);
 | |
|   if (ins.read() == NOERR)
 | |
|   {
 | |
|     ins.put("I0", ditta);
 | |
|     ins.rewrite();
 | |
|   }
 | |
|   else
 | |
|     warning_box("Tabella studio per invio NON AGGIORNATA");
 | |
| }
 | |
| 
 | |
| void TInv_cont::setta_tabella_ditta(TMask& m,const char* flag, bool comp)
 | |
| {
 | |
|   TTable ind ("%IND");
 | |
|   TString dep;
 | |
|   
 | |
|   long ditta = m.get_long(F_DITTAINV);
 | |
|   
 | |
|   dep.format("%05ld", ditta);
 | |
|   
 | |
|   ind.zero();
 | |
|   ind.put("CODTAB", dep);
 | |
|   if (ind.read() == NOERR) 
 | |
|   {                    
 | |
|     int num = m.get_int(F_NUMULINV);
 | |
|     num++;
 | |
|     TDate data (m.get(F_DATALIM)); 
 | |
|     
 | |
|     ind.put("S6", flag);                                
 | |
|     if (comp)
 | |
|     {
 | |
|       ind.put("I0", (long)num);
 | |
|       ind.put("D0", data);
 | |
|     }
 | |
|     ind.rewrite();
 | |
|   }  
 | |
|   else
 | |
|     warning_box("Tabella ditta per invio NON AGGIORNATA");  
 | |
| }
 | |
| 
 | |
| void TInv_cont::crea_record_controllo(TMask& m)
 | |
| {            
 | |
|   int size = 1024;
 | |
|   TString buffer(1024);
 | |
|   TString str;
 | |
|   
 | |
|   if (_tras_file.exist())
 | |
|     _tras_file.open(_header);
 | |
|   else 
 | |
|   {
 | |
|     _tras_file.open(_header,TRUE);   //Metto il parametro TRUE (che di default e' FALSE), perche' voglio creare un file che non e' ancore esistente
 | |
|     
 | |
|     buffer.spaces();   
 | |
|     buffer.overwrite(" 1",0);                             //Tipo record
 | |
|     
 | |
|     str = format("%-10s", (const char*) _nome_simbolico);
 | |
|     buffer.overwrite(str,60);                             //Nome studio
 | |
|     
 | |
|     long ditta = m.get_long(F_DITTAINV);
 | |
|     str = format("%05ld", ditta);
 | |
|     buffer.overwrite(str,70);                             //Ditta inviante
 | |
|     
 | |
|     int num = m.get_int(F_NUMULINV);
 | |
|     num++;
 | |
|     str = format("%03d", num);
 | |
|     buffer.overwrite(str,75);                             //Numero progr. invio
 | |
|     
 | |
|     TString data (m.get(F_DATALIM));
 | |
|     str = riconverti(data,TRUE);
 | |
|     buffer.overwrite(str,78);                             //Data limite invio
 | |
|     
 | |
|     str = format("%-9s", (const char*) _files);
 | |
|     buffer.overwrite(str,86);
 | |
|     
 | |
|     str = _files.sub(0,1);
 | |
|     buffer.overwrite(str,240); 
 | |
|     
 | |
|     str = "";
 | |
|     str.format("%054d", 0);
 | |
|     buffer.overwrite(str,95); 
 | |
|     
 | |
|     if (_scelta == 'S')
 | |
|     {
 | |
|       str.format("%04ld", _dittaAS);
 | |
|       buffer.overwrite(str,301);
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       str.format("%05ld", _dittaAS);
 | |
|       buffer.overwrite(str,301);    
 | |
|     }
 | |
|     
 | |
|     if (!_tras_file.write_control_rec(buffer, size))   
 | |
|       warning_box("Il record di controllo del file trasfer non e' stato aggiornato correttamente");
 | |
|   }  
 | |
|   _tras_file.close();  
 | |
| } 
 | |
| 
 | |
| const char* TInv_cont::cerca_provincia(const TString& comcf)
 | |
| {
 | |
|   TLocalisamfile comuni(LF_COMUNI);
 | |
|   
 | |
|   comuni.setkey(1);
 | |
|   comuni.zero();
 | |
|   comuni.put(COM_COM, comcf);
 | |
|   if (comuni.read() == NOERR)
 | |
|     TEMP = comuni.get(COM_PROVCOM);
 | |
|   else
 | |
|     TEMP = "";
 | |
| 
 | |
|   return TEMP;
 | |
| }
 | |
| 
 | |
| bool TInv_cont::invio_tempfile(TMask& m)
 | |
| {
 | |
|   char    uselab;
 | |
|   TString record(256),key,nrec;
 | |
|   int     posiz,i;
 | |
|   char    sigla;               
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   
 | |
|   uselab = (_tras_file.ult_file())[0];
 | |
|   
 | |
|   if (uselab == '\0')            //Significa che sono in caso di ripartenza ma ho
 | |
|     return TRUE;                //gia' trasferito tutti gli archivi e devo solo fare la copia su dischi
 | |
|   
 | |
|   posiz  = _files.find(uselab); //Ritorna la posizione della sigla all'interno della schiera
 | |
|   key    = _tras_file.key(); 
 | |
|   key.trim();                 
 | |
|   nrec   = _tras_file.nrec_file();
 | |
|   
 | |
|   for (i = posiz; i < _files.len();i++)
 | |
|   {                 
 | |
|     sigla    = _files[i];
 | |
|     _numrec  = atol(nrec.mid(i * 6,6));
 | |
|     
 | |
|     switch (sigla)        
 | |
|     {
 | |
|     case 'W': 
 | |
|         causali2tempfile(key,m);
 | |
|       break;
 | |
|       
 | |
|     case 'A':
 | |
|         clifo2tempfile(key,m);
 | |
|       break;
 | |
|       
 | |
|     case 'P':
 | |
|         pcon2tempfile(key,m);
 | |
|       break;
 | |
|       
 | |
|     case 'Z':
 | |
|         movPN2tempfile(key,m);
 | |
|       break;
 | |
|       
 | |
|     case 'U':
 | |
|         movIVA2tempfile(key,m);
 | |
|       break;
 | |
|       
 | |
|     case 'B':
 | |
|         movSC2tempfile(key,m);
 | |
|       break;
 | |
| 
 | |
|     default:
 | |
|       break;
 | |
|     };             
 | |
|     key = "";
 | |
|   }                    
 | |
| 
 | |
|   // Finito di trasferire tutti gli archivi pulisco la sigla ultimo file da elaborare  
 | |
|   _tras_file.open(_header);
 | |
|   leggi_record_controllo();
 | |
|   _control_rec.overwrite(" ",240);
 | |
|   _tras_file.write_control_rec(_control_rec,1024);
 | |
|   _tras_file.close();
 | |
| 
 | |
|   setta_tabella_ditta(m,"D",FALSE);
 | |
|   setta_parametri_record(m,"D");  
 | |
|   
 | |
|   return TRUE;
 | |
| }                         
 | |
| 
 | |
| void TInv_cont::causali2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   int     size = 1024;
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|                                          
 | |
|   long items = _caus->items();
 | |
|   _prog = new TProgind(items,"Invio tabella causali in corso... Prego attendere.",FALSE);
 | |
|   
 | |
|   _caus->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _caus->first();
 | |
|   else
 | |
|   {             
 | |
|     TString causale (key.mid(0,3));
 | |
|     _caus->zero();
 | |
|     _caus->put(CAU_CODCAUS, causale);
 | |
|     _caus->read();
 | |
|   }
 | |
|   
 | |
|   for(; !_caus->eof(); _caus->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|                                
 | |
|     TString codcaus = _caus->get(CAU_CODCAUS);
 | |
|     
 | |
|     _tcaus->curr() = _caus->curr(); 
 | |
|     
 | |
|     if (_tcaus->read() == NOERR)  // Esiste la testata
 | |
|     {
 | |
|       scrivi_righe_causali(codcaus,'W');
 | |
|             
 | |
|       _tcaus->zero();
 | |
|       _tcaus->curr() = _caus->curr();
 | |
|       _tcaus->rewrite();
 | |
|     }  
 | |
|     else
 | |
|     {
 | |
|       scrivi_righe_causali(codcaus,'W');
 | |
|             
 | |
|       _tcaus->zero();
 | |
|       _tcaus->curr() = _caus->curr();
 | |
|       _tcaus->write();
 | |
|     }
 | |
|           
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%3s",(const char*) codcaus);      
 | |
|     _control_rec.overwrite("W",240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
| 
 | |
|     _tras_file.write_control_rec(_control_rec,size);
 | |
|   }
 | |
|   delete _prog;
 | |
|   
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
| 
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
|   
 | |
| //  setta_tabella_ditta(m,"D",FALSE);
 | |
| //  setta_parametri_record(m,"D");  
 | |
| }
 | |
| 
 | |
| void TInv_cont::cancella_righe_causali(TString& codcaus)
 | |
| {
 | |
|   _trcaus->setkey(1);
 | |
|   _trcaus->zero();
 | |
|   _trcaus->put(RCA_CODCAUS, codcaus);
 | |
|   TRectype rcau (LF_RCAUSALI);
 | |
|   rcau = _trcaus->curr();
 | |
|   for (_trcaus->read(); !_trcaus->eof(); _trcaus->next())
 | |
|   {
 | |
|     if (_trcaus->curr() > rcau) break;
 | |
|     
 | |
|     _trcaus->remove();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::scrivi_righe_causali(TString& codcaus, char uselab)
 | |
| {
 | |
|   cancella_righe_causali(codcaus);
 | |
|                                    
 | |
|   _rcaus->setkey(1);
 | |
|   _rcaus->zero();
 | |
|   _rcaus->put(RCA_CODCAUS, codcaus);
 | |
|   TRectype rcau (LF_RCAUSALI);                               
 | |
|   rcau = _rcaus->curr();
 | |
|   for (_rcaus->read(); !_rcaus->eof(); _rcaus->next())
 | |
|   {
 | |
|     if (_rcaus->curr() > rcau) break;
 | |
|       
 | |
|     _trcaus->curr() = _rcaus->curr();
 | |
|     _trcaus->write();
 | |
|       
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%3s",(const char*) codcaus);
 | |
|     TString sigla (format("%c", uselab));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
|     _tras_file.write_control_rec(_control_rec,1024);      
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::clifo2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   int     size = 1024;
 | |
|   
 | |
|   _tras_file.open(_header);
 | |
|     
 | |
|   long items = _clifo->items();
 | |
|   _prog = new TProgind(items,"Invio Clienti / Fornitori in corso... Prego attendere.",FALSE);
 | |
|                                        
 | |
|   _clifo->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _clifo->first();
 | |
|   else
 | |
|   {         
 | |
|     char tipo   = (key.mid(0,1))[0];     
 | |
|     long codice = atol(key.mid(1,6));
 | |
|     _clifo->zero();
 | |
|     _clifo->put(CLI_TIPOCF, tipo);
 | |
|     _clifo->put(CLI_CODCF,  codice);
 | |
|     _clifo->read();
 | |
|   }
 | |
|   
 | |
|   for(; !_clifo->eof(); _clifo->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|     
 | |
|     char tipocf = _clifo->get_char(CLI_TIPOCF);                            
 | |
|     long codcf  = _clifo->get_long(CLI_CODCF);
 | |
|     
 | |
|     _tclifo->curr() = _clifo->curr(); 
 | |
|     
 | |
|     if (_tclifo->read() == NOERR)  // Esiste gia' il cliente
 | |
|     {
 | |
|       _tclifo->zero();
 | |
|       _tclifo->curr() = _clifo->curr();
 | |
|       _tclifo->rewrite();
 | |
|     }  
 | |
|     else
 | |
|     {
 | |
|       _tclifo->zero();
 | |
|       _tclifo->curr() = _clifo->curr();
 | |
|       _tclifo->write();
 | |
|     }
 | |
|           
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%c%06ld", tipocf, codcf);      
 | |
|     TString sigla (format("%c", 'A'));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
| 
 | |
|     _tras_file.write_control_rec(_control_rec,size);          
 | |
|   }     
 | |
|   delete _prog;  
 | |
| 
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
| 
 | |
| //  setta_tabella_ditta(m,"D",FALSE);
 | |
| //  setta_parametri_record(m,"D");  
 | |
| }
 | |
| 
 | |
| 
 | |
| void TInv_cont::pcon2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   int     size = 1024;
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|   
 | |
|   long items = _pcon->items();
 | |
|   _prog = new TProgind(items,"Invio Piano dei Conti in corso... Prego attendere.",FALSE);
 | |
|                                        
 | |
|   _pcon->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _pcon->first();
 | |
|   else
 | |
|   {             
 | |
|     int  gruppo = atoi(key.mid(0,3));
 | |
|     int  conto  = atoi(key.mid(3,3));
 | |
|     long sottoc = atol(key.mid(6,6));
 | |
|     
 | |
|     _pcon->zero();
 | |
|     _pcon->put(PCN_GRUPPO, gruppo);
 | |
|     if (conto != 0)
 | |
|       _pcon->put(PCN_CONTO, conto);
 | |
|     if (sottoc != 0)
 | |
|       _pcon->put(PCN_SOTTOCONTO, sottoc);
 | |
|     _pcon->read();
 | |
|   }
 | |
|   
 | |
|   for(; !_pcon->eof(); _pcon->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|     
 | |
|     int  g = _pcon->get_int (PCN_GRUPPO);
 | |
|     int  c = _pcon->get_int (PCN_CONTO);
 | |
|     long s = _pcon->get_long(PCN_SOTTOCONTO);
 | |
|     
 | |
|     _tpcon->curr() = _pcon->curr(); 
 | |
|     
 | |
|     if (_tpcon->read() == NOERR)  // Esiste gia' il cliente
 | |
|     {
 | |
|       _tpcon->zero();
 | |
|       _tpcon->curr() = _pcon->curr();
 | |
|       _tpcon->rewrite();
 | |
|     }  
 | |
|     else
 | |
|     {
 | |
|       _tpcon->zero();
 | |
|       _tpcon->curr() = _pcon->curr();
 | |
|       _tpcon->write();
 | |
|     }
 | |
| 
 | |
|     leggi_record_controllo();
 | |
|     TString16 chiave;
 | |
|     chiave.format("%3d%3d%6ld", g, c, s);      
 | |
|     TString sigla (format("%c", 'P'));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
| 
 | |
|     _tras_file.write_control_rec(_control_rec,size);
 | |
|   }     
 | |
|   delete _prog;  
 | |
| 
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
| 
 | |
| //  setta_tabella_ditta(m,"D",FALSE);
 | |
| //  setta_parametri_record(m,"D");  
 | |
| }
 | |
| 
 | |
| void TInv_cont::primanota_inviata(long numreg)
 | |
| {
 | |
|   _mov->setkey(1);
 | |
|   _mov->zero();
 | |
|   _mov->put(MOV_NUMREG, numreg);
 | |
|   if (_mov->read() == NOERR)
 | |
|   {
 | |
|     _mov->put(MOV_INVIATO, "X");
 | |
|     if (_flag_bollato)
 | |
|       _mov->put(MOV_STAMPATO, "X");
 | |
|       
 | |
|     _mov->rewrite();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::scrivi_righePN(long numreg)
 | |
| {
 | |
|   int     size = 1024;    
 | |
|                    
 | |
|   _tras_file.open(_header);
 | |
|                                    
 | |
|   _rmov->setkey(1);
 | |
|   _rmov->zero();
 | |
|   _rmov->put(RMV_NUMREG, numreg);
 | |
|   TRectype rmov (LF_RMOV);                               
 | |
|   rmov = _rmov->curr();
 | |
|   for (_rmov->read(); !_rmov->eof(); _rmov->next())
 | |
|   {
 | |
|     if (_rmov->curr() > rmov) break;
 | |
|       
 | |
|     _trmov->zero();                               
 | |
|     _trmov->curr() = _rmov->curr();
 | |
|     _trmov->write();    
 | |
|   } 
 | |
| }
 | |
| 
 | |
| void TInv_cont::movPN2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   int size = 1024;                                       
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|   
 | |
|   long items = _mov->items();
 | |
|   _prog = new TProgind(items,"Invio movimenti di Primanota in corso... Prego attendere.",FALSE);
 | |
| 
 | |
|   _mov->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _mov->first();
 | |
|   else
 | |
|   {             
 | |
|     long numreg = atol(key.mid(0,7));
 | |
|     _mov->zero();
 | |
|     _mov->put(MOV_NUMREG, numreg);
 | |
|     _mov->read();
 | |
|   }
 | |
|   
 | |
|   for(; !_mov->eof(); _mov->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|     if ( _mov->get_bool(MOV_INVIATO) ) 
 | |
|       continue; 
 | |
| 
 | |
|     if (_mov->get_char(MOV_PROVVIS) > ' ') 
 | |
|     {
 | |
|       if (_scelta == 'S' || !_flag_provvis)
 | |
|         continue;
 | |
|     }
 | |
| 
 | |
|     TDate datareg (_mov->get_date(MOV_DATAREG)); 
 | |
|     if (datareg > _datalimsk ) 
 | |
|       continue; 
 | |
|     
 | |
|     const long nreg = _mov->get_long(MOV_NUMREG);
 | |
| 
 | |
|     _tmov->curr() = _mov->curr();
 | |
|     
 | |
|     if (_tmov->read() == NOERR)  
 | |
|     {                  
 | |
|       _tmov->zero();
 | |
|       _tmov->curr() = _mov->curr();
 | |
|       _tmov->rewrite();
 | |
|       
 | |
|       scrivi_righePN(nreg);
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _tmov->zero();
 | |
|       _tmov->curr() = _mov->curr();
 | |
|       _tmov->write();
 | |
|       
 | |
|       scrivi_righePN(nreg);
 | |
|     }
 | |
|           
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%07ld", nreg);      
 | |
|     TString sigla (format("%c", 'Z'));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
|     _tras_file.write_control_rec(_control_rec,size);
 | |
|     
 | |
|     primanota_inviata(nreg);
 | |
|   }                                
 | |
|   delete _prog;  
 | |
| 
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
|   
 | |
| //  setta_tabella_ditta(m,"D",FALSE);
 | |
| //  setta_parametri_record(m,"D");  
 | |
| }
 | |
| 
 | |
| bool TInv_cont::occasionali(const TString& cfpi)
 | |
| {  
 | |
|   TString chiave;
 | |
|   
 | |
|   _occas->setkey(1);
 | |
|   _occas->zero();
 | |
|   _occas->put("CFPI", cfpi);
 | |
|   _occas->read();
 | |
| 
 | |
|   _toccas->zero();
 | |
|   _toccas->curr() = _occas->curr();
 | |
|   
 | |
|   if (_toccas->read() == NOERR)
 | |
|   { 
 | |
|     _toccas->zero();
 | |
|     _toccas->curr() = _occas->curr();
 | |
|     _toccas->rewrite();               
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     _toccas->zero();
 | |
|     _toccas->curr() = _occas->curr();
 | |
|     _toccas->write();
 | |
|   }
 | |
| 
 | |
|   return TRUE;  
 | |
| }
 | |
| 
 | |
| void TInv_cont::iva_inviata(long numreg)
 | |
| {
 | |
|   _mov->setkey(1);
 | |
|   _mov->zero();
 | |
|   _mov->put(MOV_NUMREG, numreg);
 | |
|   if (_mov->read() == NOERR)
 | |
|   {
 | |
|     _mov->put(MOV_INVIVA, "X");
 | |
|     if (_flag_bollato)
 | |
|       _mov->put(MOV_REGST, "X");
 | |
|     
 | |
|     _mov->rewrite();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::movIVA2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   TString ocfpi;
 | |
|   TDate   datareg;
 | |
|   bool    inviva;
 | |
|   bool    provvis;  
 | |
|   int     size = 1024;
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|                                          
 | |
|   long items = _rmoviva->items();
 | |
|   _prog = new TProgind(items,"Invio movimenti Iva in corso... Prego attendere.",FALSE);
 | |
| 
 | |
|   _rmoviva->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _rmoviva->first();
 | |
|   else
 | |
|   {             
 | |
|     long numreg = atol(key.mid(0,7));
 | |
|     _rmoviva->zero();
 | |
|     _rmoviva->put(RMI_NUMREG, numreg);
 | |
|     _rmoviva->put(RMI_NUMRIG, 1);
 | |
|     _rmoviva->read();
 | |
|   }
 | |
| 
 | |
|   long nreg_p = -1;
 | |
|   
 | |
|   for(; !_rmoviva->eof(); _rmoviva->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|                                
 | |
|     const long nreg = _rmoviva->get_long(RMI_NUMREG);
 | |
| 
 | |
|     if (nreg != nreg_p)
 | |
|     {
 | |
|       _mov->setkey(1);
 | |
|       _mov->zero();
 | |
|       _mov->put(MOV_NUMREG, nreg);
 | |
|       if (_mov->read() == NOERR)
 | |
|       {
 | |
|         datareg = _mov->get_date(MOV_DATAREG);
 | |
|         inviva  = _mov->get_bool(MOV_INVIVA);        
 | |
|         ocfpi   = _mov->get     (MOV_OCFPI);
 | |
|         provvis = _mov->get_char(MOV_PROVVIS) > ' ';
 | |
|       } 
 | |
|     }
 | |
|     else
 | |
|       inviva = FALSE;
 | |
|    
 | |
|     // Controlla data limite invio
 | |
|     if ( inviva || datareg > _datalimsk ) 
 | |
|       continue;
 | |
|     
 | |
|     // Controlla se deve inviare i movimenti provvisori
 | |
|     if (provvis && (_scelta == 'S' || !_flag_provvis))
 | |
|       continue;
 | |
|     
 | |
|     if (ocfpi.not_empty())
 | |
|       occasionali(ocfpi);
 | |
|                                                      
 | |
|     _triva->zero();
 | |
|     _triva->curr() = _rmoviva->curr();
 | |
|     
 | |
|     if (_triva->read() == NOERR) 
 | |
|     {                            
 | |
|       _triva->zero();
 | |
|       _triva->curr() = _rmoviva->curr();
 | |
|       _triva->rewrite();             
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _triva->zero();
 | |
|       _triva->curr() = _rmoviva->curr();
 | |
|       _triva->write();    
 | |
|     }  
 | |
|           
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%07ld", nreg);      
 | |
|     TString sigla (format("%c", 'U'));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
| 
 | |
|     _tras_file.write_control_rec(_control_rec,size);          
 | |
|     
 | |
|     if (nreg != nreg_p)
 | |
|       iva_inviata(nreg);
 | |
|     
 | |
|     nreg_p = nreg;
 | |
|   }                                
 | |
|   delete _prog;  
 | |
| 
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
|   
 | |
| //  setta_tabella_ditta(m,"D",FALSE);
 | |
| //  setta_parametri_record(m,"D");  
 | |
| }
 | |
| 
 | |
| void TInv_cont::SC_inviato(char tipo,int gruppo,int conto,long sottoc,
 | |
|                            int anno,TString& numpart,int nriga)
 | |
| {
 | |
|   _part->setkey(1);
 | |
|   _part->zero();
 | |
|   _part->put(PART_TIPOCF,     tipo);
 | |
|   _part->put(PART_GRUPPO,     gruppo);
 | |
|   _part->put(PART_CONTO,      conto);
 | |
|   _part->put(PART_SOTTOCONTO, sottoc);
 | |
|   _part->put(PART_ANNO,       anno);
 | |
|   _part->put(PART_NUMPART,    numpart);
 | |
|   _part->put(PART_NRIGA,      nriga);
 | |
| 
 | |
|   if (_part->read() == NOERR)
 | |
|   {
 | |
|     _part->put(PART_INVIATA, "X");
 | |
|     _part->rewrite();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::movSC2tempfile(TString& key, TMask& m)
 | |
| {
 | |
|   int     size = 1024;                                       
 | |
| 
 | |
|   _tras_file.open(_header);
 | |
|   
 | |
|   long items = _part->items();
 | |
|   _prog = new TProgind(items,"Invio movimenti di Saldaconto in corso... Prego attendere.",FALSE);
 | |
| 
 | |
|   _part->setkey(1);
 | |
|                     
 | |
|   if (key.empty())
 | |
|     _part->first();
 | |
|   else
 | |
|   { 
 | |
|     char    tipo    = key.mid(0,1)[0];
 | |
|     int     gruppo  = atoi(key.mid(1,3));
 | |
|     int     conto   = atoi(key.mid(4,3));
 | |
|     long    sottoc  = atol(key.mid(7,6));
 | |
|     int     anno    = atoi(key.mid(13,4));
 | |
|     TString numpart = key.mid(17,7);
 | |
|     int     nriga   = atoi(key.mid(24,4));        
 | |
|     _part->zero();
 | |
|     _part->put(PART_TIPOCF,     tipo);
 | |
|     _part->put(PART_GRUPPO,     gruppo);
 | |
|     _part->put(PART_CONTO,      conto);
 | |
|     _part->put(PART_SOTTOCONTO, sottoc);
 | |
|     _part->put(PART_ANNO,       anno);
 | |
|     _part->put(PART_NUMPART,    numpart);
 | |
|     _part->put(PART_NRIGA,      nriga);
 | |
|     _part->read();
 | |
|   }
 | |
|   
 | |
|   for(; !_part->eof(); _part->next())
 | |
|   { 
 | |
|     _prog->addstatus(1);
 | |
|                                
 | |
|     char    tipo    = _part->get_char(PART_TIPOCF);
 | |
|     int     gruppo  = _part->get_int (PART_GRUPPO);
 | |
|     int     conto   = _part->get_int (PART_CONTO);
 | |
|     long    sottoc  = _part->get_long(PART_SOTTOCONTO);
 | |
|     int     anno    = _part->get_int (PART_ANNO);
 | |
|     TString numpart = _part->get     (PART_NUMPART);
 | |
|     int     nriga   = _part->get_int (PART_NRIGA);        
 | |
|     int     tipomov = _part->get_int (PART_TIPOMOV);
 | |
|     
 | |
|     if (nriga == 9999) continue;
 | |
|       
 | |
|     TDate datareg (_part->get_date(PART_DATAREG)); 
 | |
|     
 | |
|     if ( _part->get_bool(PART_INVIATA) || datareg > _datalimsk ) continue; 
 | |
|     
 | |
|     _tpart->curr() = _part->curr();
 | |
|     
 | |
|     if (_tpart->read() == NOERR)  
 | |
|     {                  
 | |
|       _tpart->zero();
 | |
|       _tpart->curr() = _part->curr();
 | |
|       _tpart->rewrite();
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _tpart->zero();
 | |
|       _tpart->curr() = _part->curr();
 | |
|       _tpart->write();
 | |
|     }
 | |
|     
 | |
|     if (tipomov == 1)
 | |
|       scrivi_righeSCAD(tipo,gruppo,conto,sottoc,anno,numpart,nriga);
 | |
|     else  
 | |
|       scrivi_righePAGSCA(tipo,gruppo,conto,sottoc,anno,numpart,nriga);
 | |
|           
 | |
|     leggi_record_controllo();
 | |
|     TString chiave;
 | |
|     chiave.format("%c%03d%03d%06ld%04d%7s%04d", tipo,gruppo,conto,sottoc,anno,(const char*)numpart,nriga);      
 | |
|     TString sigla (format("%c", 'B'));
 | |
|     _control_rec.overwrite(sigla,240);
 | |
|     _control_rec.overwrite(chiave,241);
 | |
|     _tras_file.write_control_rec(_control_rec,size);
 | |
|     
 | |
|     SC_inviato(tipo,gruppo,conto,sottoc,anno,numpart,nriga);
 | |
|   }                                
 | |
|   delete _prog;  
 | |
| 
 | |
|   //Inizializzo l'ultima sigla file elaborato su trasfer con la sigla del file successivo da inviare
 | |
|   //e inizializzo la chiave, altrimenti se si blocca l'invio subito dopo aver finito un file si rischia di 
 | |
|   //ritrasferire l'ultimo record quando si riparte; inoltre non si riesce a inviare il file successivo perche'
 | |
|   //la chiave e' compilata con i dati del file precedente.
 | |
|   
 | |
|   leggi_record_controllo();
 | |
|   TString chiave,app,sigla;
 | |
|   app.format("%-60s", (const char*) chiave);
 | |
|   char sigla_p = _tras_file.ult_file()[0];
 | |
|   int posiz    = _files.find(sigla_p);
 | |
|   TString nuova_sigla = " ";
 | |
|   if (posiz < _files.len())
 | |
|     nuova_sigla = _files.mid(posiz+1,1);
 | |
|   
 | |
|   _control_rec.overwrite(nuova_sigla,240);
 | |
|   _control_rec.overwrite(app,241);
 | |
|   _tras_file.write_control_rec(_control_rec,size);
 | |
|   _tras_file.close();
 | |
| }
 | |
| 
 | |
| void TInv_cont::scrivi_righeSCAD(char tipocf,int gruppo,int conto,long sottoc,
 | |
|                                  int anno,TString& numpart,int nriga)
 | |
| {
 | |
|   _scad->zero();
 | |
|   _scad->put(SCAD_TIPOCF,     tipocf);
 | |
|   if (gruppo != 0)
 | |
|     _scad->put(SCAD_GRUPPO,     gruppo);
 | |
|   if (conto != 0)
 | |
|     _scad->put(SCAD_CONTO,      conto);
 | |
|   if (sottoc != 0)
 | |
|     _scad->put(SCAD_SOTTOCONTO, sottoc);
 | |
|   _scad->put(SCAD_ANNO,       anno);
 | |
|   _scad->put(SCAD_NUMPART,    numpart);
 | |
|   _scad->put(SCAD_NRIGA,      nriga);  
 | |
|     
 | |
|   TRectype scad (_scad->curr());
 | |
|     
 | |
|   for (_scad->read(_isgteq); !_scad->eof(); _scad->next())
 | |
|   { 
 | |
|     TString rec  = scad.get(SCAD_NUMPART);
 | |
|     TString file = _scad->get(SCAD_NUMPART);
 | |
|                                                    
 | |
|     if (_scad->curr() != scad || file != rec) break;
 | |
| 
 | |
|     _tscad->curr() = _scad->curr();
 | |
|     
 | |
|     if (_tscad->read() == NOERR)  
 | |
|     {                  
 | |
|       _tscad->zero();
 | |
|       _tscad->curr() = _scad->curr();
 | |
|       _tscad->rewrite();
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _tscad->zero();
 | |
|       _tscad->curr() = _scad->curr();
 | |
|       _tscad->write();
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TInv_cont::scrivi_righePAGSCA(char tipocf,int gruppo,int conto,long sottoc,
 | |
|                                    int anno,TString& numpart,int nriga)                                 
 | |
| {
 | |
|   _pagsca->zero();
 | |
|   _pagsca->put(PAGSCA_TIPOC,      tipocf);  
 | |
|   if (gruppo != 0)
 | |
|     _pagsca->put(PAGSCA_GRUPPO,     gruppo);
 | |
|   if (conto != 0)
 | |
|     _pagsca->put(PAGSCA_CONTO,      conto);
 | |
|   if (sottoc != 0)
 | |
|     _pagsca->put(PAGSCA_SOTTOCONTO, sottoc);
 | |
|   _pagsca->put(PAGSCA_ANNO,       anno);
 | |
|   _pagsca->put(PAGSCA_NUMPART,    numpart);
 | |
|     
 | |
|   TRectype pagsca (_pagsca->curr());
 | |
|     
 | |
|   for (_pagsca->read(_isgteq); !_pagsca->eof(); _pagsca->next())
 | |
|   {                                               
 | |
|     int nrigp = _pagsca->get_int(PAGSCA_NRIGP);         
 | |
|                 
 | |
|     TString rec  = pagsca.get(PAGSCA_NUMPART);
 | |
|     TString file = _pagsca->get(PAGSCA_NUMPART);
 | |
|                
 | |
|     if (_pagsca->curr() != pagsca || file != rec) break;
 | |
|         
 | |
|     if (nriga != nrigp) continue;
 | |
| 
 | |
|     _tpagsca->curr() = _pagsca->curr();
 | |
|     
 | |
|     if (_tpagsca->read() == NOERR)  
 | |
|     {                  
 | |
|       _tpagsca->zero();
 | |
|       _tpagsca->curr() = _pagsca->curr();
 | |
|       _tpagsca->rewrite();
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       _tpagsca->zero();
 | |
|       _tpagsca->curr() = _pagsca->curr();
 | |
|       _tpagsca->write();
 | |
|     }
 | |
|   }
 | |
| }
 | |
|                                   
 | |
| bool TInv_cont::menu(MENU_TAG m)
 | |
| {
 | |
|   if (m == BAR_ITEM(1))
 | |
|     return main_loop(); 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| int cg6900 (int argc, char* argv[])
 | |
| {         
 | |
|   switch (*argv[2])
 | |
|   {
 | |
|     case 'S':
 | |
|     {
 | |
|       TInv_cont* main_app = new TInv_cont(*argv[2]);       
 | |
|       main_app->run(argc, argv,main_app->_titolo);
 | |
|       delete main_app;
 | |
|     }
 | |
|     break;
 | |
|     case 'P':
 | |
|     {
 | |
|       TInv_cont* main_app = new TInv_cont(*argv[2]);       
 | |
|       main_app->run(argc, argv,main_app->_titolo);
 | |
|       delete main_app;
 | |
|     }
 | |
|     break;
 | |
|     case 'L':
 | |
|     {   
 | |
|       TLista_archivi* a = new TLista_archivi;       
 | |
|       a->run(argc, argv,"Lista controllo archivi");
 | |
|       delete a;
 | |
|     }         
 | |
|     break;
 | |
|     case 'R':
 | |
|     {   
 | |
|       TRip_flag* a = new TRip_flag;       
 | |
|       a->run(argc, argv,"Ripristino flag movimenti");
 | |
|       delete a;
 | |
|     }         
 | |
|     break;
 | |
|     case 'C':
 | |
|     {   
 | |
|       TCanc_file_invio* a = new TCanc_file_invio;       
 | |
|       a->run(argc, argv,"Eliminazione file invio");
 | |
|       delete a;
 | |
|     }         
 | |
|     break;
 | |
| 
 | |
|     default:
 | |
|     break;
 | |
|   }
 | |
| 
 | |
|   return TRUE;
 | |
| }
 |