Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 1.7 aga patch 102 sul main trunk git-svn-id: svn://10.65.10.50/trunk@9769 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			596 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			596 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | ||
| #include <form.h>
 | ||
| #include <printer.h>
 | ||
| #include <recarray.h>
 | ||
| #include <utility.h>
 | ||
| 
 | ||
| #include "..\cg\cglib01.h"
 | ||
| #include "ce3.h"
 | ||
| #include "ce3200a.h"
 | ||
| #include "ce3200.h"
 | ||
| #include "celib.h"
 | ||
| #include "cespi.h"
 | ||
| #include "movce.h"
 | ||
| 
 | ||
| //-----FORM--------------------------------------------------------------------------------------//
 | ||
| 
 | ||
| class TForm_schedacesp : public TForm_cespiti
 | ||
| {
 | ||
| 
 | ||
| public:
 | ||
|   virtual bool validate(TForm_item &cf, TToken_string &s);
 | ||
|   void set_testata() {set_header(1,TRUE);}
 | ||
|   void set_pedata() {set_footer(1,FALSE); set_footer(1,TRUE);}
 | ||
|   TForm_schedacesp();
 | ||
|   TPrint_section& get_rigauno() {return section('B', first_page);}
 | ||
|   TPrint_section& get_rigadue() {return section('B', odd_page);}
 | ||
|   TPrint_section& get_rigadueven() {return section('B', even_page);}
 | ||
|   TPrint_section& get_rigatre() {return section('B', last_page);}
 | ||
|   TPrint_section& get_rigatot() {return section('F', odd_page);}
 | ||
|   TPrint_section& get_footer() {return section('F', first_page);}
 | ||
|   virtual ~TForm_schedacesp();
 | ||
| };
 | ||
|   
 | ||
| TForm_schedacesp::TForm_schedacesp() :TForm_cespiti ("ce3200a")            //costruttore con relazione..
 | ||
| {
 | ||
| } 
 | ||
| 
 | ||
| TForm_schedacesp::~TForm_schedacesp()
 | ||
| { 
 | ||
| }
 | ||
| 
 | ||
| bool TForm_schedacesp::validate(TForm_item &cf, TToken_string &s)
 | ||
| {
 | ||
|   return TForm_cespiti::validate(cf,s);   //richiama la validate standard della classe genitore (TForm_cespiti)
 | ||
| }
 | ||
| 
 | ||
| //-----AUTOMASK---------------------------------------------------------------------------------//
 | ||
|   
 | ||
| class TStampastorico_mask : public TAutomask
 | ||
| {
 | ||
|   TRelation * _rel;
 | ||
|   TCursor * _cur;
 | ||
| 
 | ||
| protected:
 | ||
|   bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | ||
| public:
 | ||
| 
 | ||
|   TStampastorico_mask();
 | ||
|   
 | ||
|   virtual ~TStampastorico_mask(){};
 | ||
| };
 | ||
|   
 | ||
| TStampastorico_mask::TStampastorico_mask() :TAutomask ("ce3200a")
 | ||
| {
 | ||
|   ditta_cespiti().init_mask(* this);
 | ||
| }  
 | ||
|   
 | ||
| bool TStampastorico_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | ||
| { 
 | ||
|   switch (o.dlg())
 | ||
|   {
 | ||
|   case F_CATCESP:
 | ||
|   case F_DESCRCAT:
 | ||
|     return ditta_cespiti().on_category_event(o, e, jolly);      //ultimo ritrovato per selezionare la categoria (da celib)
 | ||
|   case F_SITFISC :
 | ||
|     if (e == fe_close)
 | ||
|     {
 | ||
|       if (!get_bool(F_SITFISC) && !get_bool(F_SITCIV) && !get_bool(F_SITGEST))
 | ||
|         return error_box("Selezionare almeno una delle Situazioni da stampare");
 | ||
|     }
 | ||
|     break;
 | ||
|   default: break;
 | ||
|   }  
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| //-----SKELETON APPLICATION------------------------------------------------------------------------------------------//
 | ||
| 
 | ||
| class TStampa_storico : public TSkeleton_application
 | ||
| {
 | ||
|   TStampastorico_mask * _mask;
 | ||
|   TForm_schedacesp * _form;
 | ||
|   bool _ammvenduti;
 | ||
| 
 | ||
| protected:
 | ||
|   virtual bool create();
 | ||
|   virtual bool destroy();
 | ||
|   virtual void main_loop();
 | ||
| 
 | ||
|   void print_header( const int tipo );
 | ||
|   void print_footer();
 | ||
|   void print_percespite( const int tipo );
 | ||
|   void stampa_rigauno( bool errore );
 | ||
| 
 | ||
| public:
 | ||
|   TStampa_storico() {}
 | ||
| };
 | ||
| 
 | ||
| 
 | ||
| bool TStampa_storico::create()
 | ||
| {
 | ||
|   open_files(LF_CESPI, LF_SALCE, LF_AMMCE, LF_MOVCE, LF_AMMMV, 0);
 | ||
|   _mask = new TStampastorico_mask;
 | ||
|   _form = new TForm_schedacesp();
 | ||
|   
 | ||
|   return TSkeleton_application::create();
 | ||
| }
 | ||
| 
 | ||
| bool TStampa_storico::destroy()
 | ||
| {
 | ||
|   delete _mask;
 | ||
|   delete _form;
 | ||
|   return TSkeleton_application::destroy();
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| void TStampa_storico::print_header( const int tipo )
 | ||
| {  
 | ||
|   _form->find_field('H', odd_page, FF_CODDITTA).set(_mask->get(F_CODDITTA));
 | ||
|   _form->find_field('H', odd_page, FF_DESCRDITTA).set(_mask->get(F_DESCRDITTA));
 | ||
|   _form->find_field('H', odd_page, FF_GRUPPO).set(_mask->get(F_GRUPPO));
 | ||
|   _form->find_field('H', odd_page, FF_D_GRUPPO).set(_mask->get(F_D_GRUPPO));                 
 | ||
|   _form->find_field('H', odd_page, FF_SPECIE).set(_mask->get(F_SPECIE));
 | ||
|   _form->find_field('H', odd_page, FF_D_SPECIE).set(_mask->get(F_D_SPECIE));
 | ||
|   TDate inies = _mask->get(F_INIZIO_ES);
 | ||
|   --inies;
 | ||
|   _form->find_field('H', odd_page, FF_DATASIT).set(inies.string());
 | ||
|   
 | ||
|   switch(tipo)      //in base al(ai) tipo(i) di situazione cambia una riga dell'header
 | ||
|   {
 | ||
|   case 1:
 | ||
|     _form->find_field('H', odd_page, FF_SITUAZIONE).set("fiscale");
 | ||
|     break;
 | ||
|   case 2:
 | ||
|     _form->find_field('H', odd_page, FF_SITUAZIONE).set("civilistica");
 | ||
|     break;
 | ||
|   case 3:
 | ||
|     _form->find_field('H', odd_page, FF_SITUAZIONE).set("gestionale");
 | ||
|     break;
 | ||
|   }  
 | ||
|   _form->set_testata();
 | ||
| }
 | ||
| 
 | ||
| void TStampa_storico::print_footer()
 | ||
| {
 | ||
|   _form->set_pedata();
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| void TStampa_storico::stampa_rigauno( bool errore)
 | ||
| {        
 | ||
|   TRectype& recsalce = _form->cursor()->curr(LF_SALCE);
 | ||
|   TDate datasaldo = _form->cursor()->curr(-102).get_date("D0");
 | ||
|   real numele = recsalce.get_real("NUMELE");
 | ||
|   
 | ||
|   TPrint_section& section1 = _form->get_rigauno();          //preparazione stampa riga dettaglio 1
 | ||
|   TDate dtcomp = _form->cursor()->curr(LF_CESPI).get_date("DTCOMP");
 | ||
|   section1.reset();
 | ||
|               
 | ||
|   if ((datasaldo >= dtcomp && numele > 0) || (datasaldo == dtcomp && numele == 0))    //datasaldo >= data acquisto
 | ||
|   {
 | ||
|     section1.find_field(FF_DATAUNO).set(datasaldo);
 | ||
|     section1.find_field(FF_DESCRUNO).set("Ripresa saldi");
 | ||
|     section1.find_field(FF_NUMELEUNO).set(_form->cursor()->curr(LF_SALCE).get("NUMELE"));
 | ||
|     real sum = recsalce.get_real("CSTO");
 | ||
|     sum -= recsalce.get_real("VNONAMM");
 | ||
|     sum += recsalce.get_real("RIV75");
 | ||
|     sum += recsalce.get_real("RIV83");
 | ||
|     sum += recsalce.get_real("RIV90");
 | ||
|     sum += recsalce.get_real("RIV91");
 | ||
|     sum += recsalce.get_real("RIVGF");
 | ||
|     section1.find_field(FF_VALOREUNO).set(sum.string());
 | ||
|     sum = 0;
 | ||
|     TRectype& recammce = _form->cursor()->curr(LF_AMMCE);
 | ||
|     sum = recammce.get_real("QNOR");
 | ||
|     sum += recammce.get_real("QANT");
 | ||
|     sum += recammce.get_real("QACC");
 | ||
|     section1.find_field(FF_FONDIUNO).set(sum.string());
 | ||
|   }
 | ||
|   else                                                            // se datasaldo < data acquisto sono sbagliate le date
 | ||
|   {
 | ||
|     section1.find_field(FF_DESCRUNO).set("Date non congruenti sui saldi iniziali");
 | ||
|     errore = TRUE;
 | ||
|   }
 | ||
|           
 | ||
|   section1.update(); 
 | ||
|   for (word i = 0; i < section1.height(); i++)        // stampa le righe tipo 1 (solo nel caso che dtmov != dtcomp)
 | ||
|     printer().print(section1.row(i));                 // in caso contrario passa semplicemente alle righe tipo 2
 | ||
| 
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| void TStampa_storico::print_percespite( const int tipo)
 | ||
| { 
 | ||
|   bool ho_stampato_qualcosa = FALSE;
 | ||
|   print_header(tipo);    // stampa l'intestazione;tipo si riferisce al tipo di situazione da stampare
 | ||
|   print_footer();        //stampa data e pagenumber
 | ||
|   
 | ||
|   const int esercizio = _mask->get_int(F_ESERCIZIO);
 | ||
|   
 | ||
|   const long pos = _form->cursor()->pos();                       //memorizza posizione cursore
 | ||
|   
 | ||
|   TRectype& recammce = _form->cursor()->curr(LF_AMMCE);          //scelta dei tipi ammort. su AMMCE
 | ||
|   bool continua = _form->cursor()->is_first_match(LF_AMMCE);
 | ||
|   while (recammce.get_int("TPAMM") != tipo && continua)
 | ||
|     continua = _form->cursor()->next_match(LF_AMMCE); 
 | ||
|     
 | ||
|   TRectype& recammmv = _form->cursor()->curr(LF_AMMMV);          //scelta dei tipi ammort. su AMMMV
 | ||
|   continua = _form->cursor()->is_first_match(LF_AMMMV);
 | ||
|   while (recammmv.get_int("TPAMM") != tipo && continua)
 | ||
|   continua = _form->cursor()->next_match(LF_AMMMV);  
 | ||
| 
 | ||
|  
 | ||
|   TPrint_section& sectot = _form->get_rigatot();               //resetta il totale elementi,valore,fondo amm.
 | ||
|   sectot.find_field(FF_TOTELEM).set("");                       
 | ||
|   sectot.find_field(FF_TOTVALORE).set("");
 | ||
|   sectot.find_field(FF_TOTAMMO).set("");
 | ||
|   
 | ||
|   TRectype& recmovce = _form->cursor()->curr(LF_MOVCE);                      // riga dettaglio 2
 | ||
|   TRelation& rel = *_form->relation();
 | ||
| 
 | ||
|   
 | ||
|   if (rel.is_first_match(LF_MOVCE)) 
 | ||
|   { 
 | ||
|     bool errore = FALSE;                  //variabile che indica se le date del cespite sono congruenti per essere stampate
 | ||
|     
 | ||
|     TDate dtmov = _form->cursor()->curr(-105).get_date("DTMOV");
 | ||
|     TDate dtcomp = _form->cursor()->curr(LF_CESPI).get_date("DTCOMP");
 | ||
|     
 | ||
|     TEsercizi_contabili esc;
 | ||
|     const TDate& inies = esc[esercizio].inizio();
 | ||
|     
 | ||
|     if (dtmov < inies)
 | ||
|     {
 | ||
|     
 | ||
|       if (dtmov != dtcomp)                 //la riga tipo 1 va scritta solo se dtmov != dtcomp (in caso contrario <20> una tipo 2)
 | ||
|       {
 | ||
|         stampa_rigauno( errore );        
 | ||
|         ho_stampato_qualcosa = TRUE; 
 | ||
|         errore = !rel.next_match(LF_MOVCE);
 | ||
|       }
 | ||
|     }
 | ||
|     
 | ||
|       
 | ||
|     if (!errore) do                                    //se non c'<27> incongruenza di date procede alla stampa righe 2
 | ||
|     { 
 | ||
|     
 | ||
|       TDate datamov = rel.curr(LF_MOVCE).get("DTMOV");
 | ||
|       if (datamov >= inies) break;
 | ||
|       
 | ||
|       bool ammven = FALSE;  
 | ||
|       if (_ammvenduti)                                             // caso in cui la ditta ha "ammort. su venduti" = SI
 | ||
|       {                                                            // controlla su %tmc se il movimento <20> una vendita
 | ||
|         TString16 tipomov = recmovce.get("CODMOV");
 | ||
|         const TRectype& tmc = cache().get("%TMC" , tipomov);
 | ||
|         ammven = tmc.get_bool("B4");
 | ||
|       } 
 | ||
|       
 | ||
|         real aliqnor = recammmv.get_real("PENOR");
 | ||
|         real aliqant = recammmv.get_real("PEANT");
 | ||
|         real aliqacc = recammmv.get_real("PEACC");
 | ||
|         
 | ||
|       if (ammven)                                                     // se <20> un movimento di vendita...
 | ||
|       {          
 | ||
|         TPrint_section& section2ven = _form->get_rigadueven();  
 | ||
|           
 | ||
|         if (_form->cursor()->curr(LF_MOVCE).get_char("SEGNO")=='-')   //controlla se c'<27> il - in movce
 | ||
|         {
 | ||
|           section2ven.find_field(FF_SEGNO).set("-1");
 | ||
|         } 
 | ||
|         else  
 | ||
|         {
 | ||
|           section2ven.find_field(FF_SEGNO).set("1");
 | ||
|         }
 | ||
|           
 | ||
|         int r = 1;
 | ||
|         if (aliqnor != ZERO)
 | ||
|         {                           
 | ||
|           section2ven.find_field(FF_VPENOR).show();
 | ||
|           section2ven.find_field(FF_VPENOR).y() = r+1;            
 | ||
|           section2ven.find_field(FF_VALINOR).show();
 | ||
|           section2ven.find_field(FF_VALINOR).y() = r+1;
 | ||
|           section2ven.find_field(FF_VQNOR).show();
 | ||
|           section2ven.find_field(FF_VQNOR).y() = r+1;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2ven.find_field(FF_VPENOR).hide();
 | ||
|           section2ven.find_field(FF_VALINOR).hide();
 | ||
|           section2ven.find_field(FF_VQNOR).hide();
 | ||
|         }
 | ||
|         if (aliqant != ZERO)
 | ||
|         {                           
 | ||
|           section2ven.find_field(FF_VPEANT).show();
 | ||
|           section2ven.find_field(FF_VPEANT).y() = r+1;
 | ||
|           section2ven.find_field(FF_VALIANT).show();
 | ||
|           section2ven.find_field(FF_VALIANT).y() = r+1;
 | ||
|           section2ven.find_field(FF_VQANT).show();
 | ||
|           section2ven.find_field(FF_VQANT).y() = r+1;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2ven.find_field(FF_VPEANT).hide();
 | ||
|           section2ven.find_field(FF_VALIANT).hide();
 | ||
|           section2ven.find_field(FF_VQANT).hide();
 | ||
|         }
 | ||
|         if (aliqacc != ZERO)
 | ||
|         {                             
 | ||
|           section2ven.find_field(FF_VPEACC).show();
 | ||
|           section2ven.find_field(FF_VPEACC).y() = r+1;
 | ||
|           section2ven.find_field(FF_VALIACC).show();
 | ||
|           section2ven.find_field(FF_VALIACC).y() = r+1;
 | ||
|           section2ven.find_field(FF_VQACC).show();
 | ||
|           section2ven.find_field(FF_VQACC).y() = r+1;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2ven.find_field(FF_VPEACC).hide();
 | ||
|           section2ven.find_field(FF_VALIACC).hide();
 | ||
|           section2ven.find_field(FF_VQACC).hide();
 | ||
|         }
 | ||
|           
 | ||
|         section2ven.update();
 | ||
|         for (int i = 0; i < r; i++)               // stampa le righe 2 con i movimenti vendita
 | ||
|           printer().print(section2ven.row(i));
 | ||
|         ho_stampato_qualcosa = TRUE;
 | ||
|       }
 | ||
|       else                                                           // se <20> un movimento NON di vendita...
 | ||
|       { 
 | ||
|         TPrint_section& section2 = _form->get_rigadue();
 | ||
|         
 | ||
|         if (_form->cursor()->curr(LF_MOVCE).get_char("SEGNO")=='-')   //controlla se c'<27> il - in movce (es. sono le rettifiche su acquisti)
 | ||
|         {
 | ||
|           section2.find_field(FF_SEGNO).set("-1");
 | ||
|         } 
 | ||
|         else  
 | ||
|         {
 | ||
|           section2.find_field(FF_SEGNO).set("1");
 | ||
|         }
 | ||
|                                                          //decide quante righe stampare in base al numero di aliquote presenti
 | ||
|         int r = 1;
 | ||
|         if (aliqnor != ZERO)
 | ||
|         {                           
 | ||
|           section2.find_field(FF_PENOR).show();
 | ||
|           section2.find_field(FF_PENOR).y() = r;            
 | ||
|           section2.find_field(FF_ALINOR).show();
 | ||
|           section2.find_field(FF_ALINOR).y() = r;
 | ||
|           section2.find_field(FF_QNOR).show();
 | ||
|           section2.find_field(FF_QNOR).y() = r;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2.find_field(FF_PENOR).hide();
 | ||
|           section2.find_field(FF_ALINOR).hide();
 | ||
|           section2.find_field(FF_QNOR).hide();
 | ||
|         }
 | ||
|         if (aliqant != ZERO)
 | ||
|         {                           
 | ||
|           section2.find_field(FF_PEANT).show();
 | ||
|           section2.find_field(FF_PEANT).y() = r;
 | ||
|           section2.find_field(FF_ALIANT).show();
 | ||
|           section2.find_field(FF_ALIANT).y() = r;
 | ||
|           section2.find_field(FF_QANT).show();
 | ||
|           section2.find_field(FF_QANT).y() = r;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2.find_field(FF_PEANT).hide();
 | ||
|           section2.find_field(FF_ALIANT).hide();
 | ||
|           section2.find_field(FF_QANT).hide();
 | ||
|         }
 | ||
|         if (aliqacc != ZERO)
 | ||
|         {                             
 | ||
|           section2.find_field(FF_PEACC).show();
 | ||
|           section2.find_field(FF_PEACC).y() = r;
 | ||
|           section2.find_field(FF_ALIACC).show();
 | ||
|           section2.find_field(FF_ALIACC).y() = r;
 | ||
|           section2.find_field(FF_QACC).show();
 | ||
|           section2.find_field(FF_QACC).y() = r;
 | ||
|           r++;
 | ||
|         }
 | ||
|         else
 | ||
|         {
 | ||
|           section2.find_field(FF_PEACC).hide();
 | ||
|           section2.find_field(FF_ALIACC).hide();
 | ||
|           section2.find_field(FF_QACC).hide();
 | ||
|         }  
 | ||
|             
 | ||
|         section2.update();        
 | ||
|         for (int i = 0; i < r; i++)               // stampa le righe con tutti i movimenti (righe tipo 2)        
 | ||
|           printer().print(section2.row(i));
 | ||
|         ho_stampato_qualcosa = TRUE;
 | ||
|       } 
 | ||
| 
 | ||
|          
 | ||
|     } while (rel.next_match(LF_MOVCE)); 
 | ||
|     
 | ||
|     
 | ||
|     if (!errore)
 | ||
|     {
 | ||
|       TDate dataelim = _form->cursor()->curr(LF_CESPI).get_date("DTALIEN");
 | ||
|       TDate datafinees = _form->cursor()->curr(-102).get_date("D1");
 | ||
|       if (dataelim.empty() || dataelim > datafinees)            // qui ci va l'if con la condizione di scrittura riga3
 | ||
|       {                   
 | ||
|         TRectype& recsalce = _form->cursor()->curr(LF_SALCE);
 | ||
|         bool continua = _form->cursor()->is_first_match(LF_SALCE);;
 | ||
|         while (recsalce.get_int("TPSALDO") != 2 && continua)
 | ||
|           continua = _form->cursor()->next_match(LF_SALCE); 
 | ||
|                                                             
 | ||
|         real aliqnort = recammce.get_real("PNOR");
 | ||
|         real aliqantt = recammce.get_real("PANT");
 | ||
|         real aliqacct = recammce.get_real("PACC");
 | ||
|         
 | ||
|         real qnort = recammce.get_real("QNOR");
 | ||
|         real qantt = recammce.get_real("QANT");
 | ||
|         real qacct = recammce.get_real("QACC");  
 | ||
|         
 | ||
|         bool scrivo_unarigatre = FALSE;
 | ||
|           
 | ||
|         TPrint_section& section3 = _form->get_rigatre(); 
 | ||
|                                                           //controllo sulla scrittura di pi<70> righe causa diverse aliquote
 | ||
|         int r = 1;
 | ||
|           if (aliqnort != ZERO || qnort != ZERO)
 | ||
|           {                           
 | ||
|             section3.find_field(FF_TPNOR).show();
 | ||
|             section3.find_field(FF_TPNOR).y() = r;            
 | ||
|             section3.find_field(FF_TALINOR).show();
 | ||
|             section3.find_field(FF_TALINOR).y() = r;
 | ||
|             section3.find_field(FF_TQNOR).show();
 | ||
|             section3.find_field(FF_TQNOR).y() = r;
 | ||
|             r++;
 | ||
|             scrivo_unarigatre = TRUE;
 | ||
|           }
 | ||
|           else
 | ||
|           {
 | ||
|             section3.find_field(FF_TPNOR).hide();
 | ||
|             section3.find_field(FF_TALINOR).hide();
 | ||
|             section3.find_field(FF_TQNOR).hide();
 | ||
|           }
 | ||
|           if (aliqantt != ZERO || qantt != ZERO)
 | ||
|           {                           
 | ||
|             section3.find_field(FF_TPANT).show();
 | ||
|             section3.find_field(FF_TPANT).y() = r;
 | ||
|             section3.find_field(FF_TALIANT).show();
 | ||
|             section3.find_field(FF_TALIANT).y() = r;
 | ||
|             section3.find_field(FF_TQANT).show();
 | ||
|             section3.find_field(FF_TQANT).y() = r;
 | ||
|             r++;
 | ||
|             scrivo_unarigatre = TRUE;
 | ||
|           }
 | ||
|           else
 | ||
|           {
 | ||
|             section3.find_field(FF_TPANT).hide();
 | ||
|             section3.find_field(FF_TALIANT).hide();
 | ||
|             section3.find_field(FF_TQANT).hide();
 | ||
|           }
 | ||
|           if (aliqacct != ZERO || qacct != ZERO)
 | ||
|           {                             
 | ||
|             section3.find_field(FF_TPACC).show();
 | ||
|             section3.find_field(FF_TPACC).y() = r;
 | ||
|             section3.find_field(FF_TALIACC).show();
 | ||
|             section3.find_field(FF_TALIACC).y() = r;
 | ||
|             section3.find_field(FF_TQACC).show();
 | ||
|             section3.find_field(FF_TQACC).y() = r;
 | ||
|             r++;
 | ||
|             scrivo_unarigatre = TRUE;
 | ||
|           }
 | ||
|           else
 | ||
|           {
 | ||
|             section3.find_field(FF_TPACC).hide();
 | ||
|             section3.find_field(FF_TALIACC).hide();
 | ||
|             section3.find_field(FF_TQACC).hide();
 | ||
|           }
 | ||
|         
 | ||
|         if (scrivo_unarigatre)                        //stampa la riga3 solo se ha trovato almeno una cosa da stampare
 | ||
|         {
 | ||
|           TDate inies = _mask->get(F_INIZIO_ES);
 | ||
|           --inies;
 | ||
|           _form->find_field('B', last_page, FF_DATASIT).set(inies.string());
 | ||
|         
 | ||
|           section3.update();
 | ||
|           for (int i = 0; i < r ; i++)               // stampa riga tipo 3
 | ||
|             printer().print(section3.row(i));
 | ||
|           ho_stampato_qualcosa = TRUE;
 | ||
|         }
 | ||
|         
 | ||
|       }
 | ||
|       
 | ||
|       if (ho_stampato_qualcosa)                              //controlla se ha stampato qualcosa (riga1, righe2, riga3)..
 | ||
|       {
 | ||
|         sectot.update();
 | ||
|         for (word i = 0; i < sectot.height(); i++)           //..e in caso affermativo stampa riga totale
 | ||
|           printer().print(sectot.row(i));
 | ||
|       }
 | ||
|       
 | ||
|     }  
 | ||
| 
 | ||
|     
 | ||
|   }
 | ||
|   else                               //<2F> l'else di if(rel.is_first_match(LF_MOVCE)):
 | ||
|   {                                  //serve nel caso il cespite non abbia movimenti ma solo saldi
 | ||
|     bool errore = FALSE;             
 | ||
|     stampa_rigauno( errore );        
 | ||
|     ho_stampato_qualcosa = TRUE;  
 | ||
|   }
 | ||
|   
 | ||
|   if (ho_stampato_qualcosa)
 | ||
|     printer().formfeed();          //salta una pagina alla fine della scheda
 | ||
|   *_form->cursor() = pos;           //riposiziona il cursore
 | ||
| }
 | ||
| 
 | ||
| 
 | ||
| void TStampa_storico::main_loop()
 | ||
| { 
 | ||
|   _mask->set(F_SITFISC,"X");
 | ||
|   while (_mask->run() == K_ENTER)
 | ||
|   { 
 | ||
|     TRectype rec(LF_CESPI);
 | ||
|     TString filtro;
 | ||
|     TCursor& cursore = *_form->cursor();
 | ||
|     const int esercizio = _mask->get_int(F_ESERCIZIO);        //controlla il booleano _ammvenduti nell'esercizio corrente
 | ||
|     TString80 key; key.format("%04d",esercizio);
 | ||
|     const TRectype& cce = cache().get("CCE", key); 
 | ||
|     _ammvenduti = cce.get_bool("B3");
 | ||
|     
 | ||
|     const int r = _mask->get_int(F_TIPOSTAMPA);     //in base al tipo di stampa selezionato setta il cursore
 | ||
|     switch (r)
 | ||
|     {
 | ||
|     case 0:
 | ||
|       cursore.setkey(1);                             // setta la chiave (nel caso si fosse scelta in precedenza la 2)
 | ||
|       if (!_mask->field(F_CODCESP).empty())
 | ||
|         rec.put("IDCESPITE", _mask->get(F_CODCESP));
 | ||
|       filtro.format("(CODCGRA==%d)&&(CODSPA==\"%s\")", _mask->get_int(F_GRUPPO), (const char *) _mask->get(F_SPECIE));
 | ||
|       break;
 | ||
|           
 | ||
|     case 1:
 | ||
|       cursore.setkey(2);                            // setta la chiave 2      
 | ||
|       rec.put("CODCGRA", _mask->get_int(F_GRUPPO));
 | ||
|       rec.put("CODSPA", _mask->get(F_SPECIE));
 | ||
|       if (!_mask->field(F_CATCESP).empty())
 | ||
|         rec.put("CODCAT", _mask->get_int(F_CATCESP));
 | ||
|       break;
 | ||
|       
 | ||
|     case 2:                                           
 | ||
|       cursore.setkey(1);
 | ||
|       filtro.format("(CODCGRA==%d)&&(CODSPA==\"%s\")", _mask->get_int(F_GRUPPO), (const char *) _mask->get(F_SPECIE)); 
 | ||
|       if (!_mask->field(F_IMPCESP).empty())
 | ||
|         filtro << format("&&(CODIMP==\"%s\")", (const char *) _mask->get(F_IMPCESP));   //estende il filtro con il campo CODIMP
 | ||
|       break;
 | ||
|     default:
 | ||
|       break;
 | ||
|     }
 | ||
|     cursore.setregion(rec,rec,0x2);  
 | ||
|     cursore.setfilter(filtro,TRUE);
 | ||
|     
 | ||
|     long num = cursore.items();
 | ||
|     cursore.freeze();
 | ||
|     printer().open();
 | ||
| 
 | ||
|     for (cursore=0; cursore.pos()<num; ++cursore)
 | ||
|     { 
 | ||
|       if (_mask->get_bool(F_SITFISC))
 | ||
|         print_percespite(1);  
 | ||
|       if (_mask->get_bool(F_SITCIV))
 | ||
|         print_percespite(2);  
 | ||
|       if (_mask->get_bool(F_SITGEST))
 | ||
|         print_percespite(3);  
 | ||
|     }
 | ||
|     printer().close();
 | ||
|     cursore.freeze(FALSE);
 | ||
|   } 
 | ||
| }
 | ||
|     
 | ||
| 
 | ||
|    
 | ||
| int ce3200(int argc, char* argv[])
 | ||
| { 
 | ||
|   TStampa_storico a;
 | ||
|   a.run(argc,argv,"Stampa schede cespiti");
 | ||
|   return 0;
 | ||
| } |