267 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			267 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Stampa Listini/Contratti/Offerte in modo sintetico
 | ||
| // sarebbe da intendere come la vera ed unica stampa condizioni di vendita.
 | ||
| // Quella precedente realizzata in ve3200.cpp viene cmq mantenuta anke per motivi storici
 | ||
| 
 | ||
| #include <applicat.h>
 | ||
| #include <form.h>
 | ||
| #include <mask.h>
 | ||
| #include <printer.h>
 | ||
| 
 | ||
| #include "ve3300.h"
 | ||
| #include "veconf.h"
 | ||
| 
 | ||
| //////////////////////////////////////////////////////////
 | ||
| // Form
 | ||
| //////////////////////////////////////////////////////////
 | ||
| class TLCO_form : public TForm
 | ||
| {
 | ||
| protected:
 | ||
|   virtual bool validate(TForm_item &, TToken_string &); // gestione dei messaggi estesi nei campi
 | ||
| public:
 | ||
|   TLCO_form(const char* name) ;
 | ||
|   virtual ~TLCO_form() {}
 | ||
| };
 | ||
| 
 | ||
| bool TLCO_form::validate(TForm_item &cf, TToken_string &s)
 | ||
| {
 | ||
|   const TString code(s.get(0)); 
 | ||
|   TString valore;
 | ||
|   const TRelation* rel = cf.form().relation();
 | ||
|   TLocalisamfile& rcondv = rel->lfile(LF_RCONDV);
 | ||
|   TLocalisamfile& condv  = rel->lfile(LF_CONDV);
 | ||
|   const int ndec = condv.get_int("DECIMALI");
 | ||
|   
 | ||
|   if (code == "_DESCRIZIONE")
 | ||
|   {
 | ||
|     const char tiporiga = rcondv.get_char("TIPORIGA");
 | ||
|     TLocalisamfile& anamag = rel->lfile(LF_ANAMAG);
 | ||
|     TLocalisamfile& gmc    = rel->lfile(-101);
 | ||
|     TLocalisamfile& rfa    = rel->lfile(-102);
 | ||
|     if (tiporiga == 'A')
 | ||
|       valore = anamag.get("DESCR");
 | ||
|     else
 | ||
|       if (tiporiga == 'R')
 | ||
|         valore = rfa.get("S0");
 | ||
|       else
 | ||
|         valore = gmc.get("S0");
 | ||
|   }
 | ||
|   else
 | ||
|     if (code == "_QTAFROM")
 | ||
|     {
 | ||
|       // Legge la riga precedente, controllando che sia dello scaglione
 | ||
|       // precedente a questo. Se si prende la sua qta limite e vi aggiunge un
 | ||
|       // decimale specificato da LF_CONDV->DECIMALI (funziona anche per le unita')
 | ||
|       // Se non esiste la riga prec vale 0
 | ||
|       TRectype rec(rcondv.curr());
 | ||
|       rcondv.prev();
 | ||
|       real r = rcondv.good() && rcondv.curr().same_key(rec, 1, 1)  ? rcondv.get_real("QLIM") : ZERO;
 | ||
|       if (r != ZERO)
 | ||
|         r += exp10(((real)-ndec));
 | ||
|       valore = r.string(15,ndec);
 | ||
|       rcondv.next();
 | ||
|     }
 | ||
|     else
 | ||
|       if (code == "_QTATO")
 | ||
|         valore  = rcondv.get_real("QLIM").string(15,ndec);
 | ||
|   cf.set(valore);
 | ||
|   return TForm::validate(cf, s);
 | ||
| }
 | ||
| 
 | ||
| TLCO_form::TLCO_form(const char* name) : TForm(name)
 | ||
| {
 | ||
|   set_magic_currency(TRUE);
 | ||
| }
 | ||
| 
 | ||
| //////////////////////////////////////////////////////////
 | ||
| // Applicazione
 | ||
| //////////////////////////////////////////////////////////
 | ||
| class TStampa_LCO_sintetica : public TSkeleton_application
 | ||
| {
 | ||
|   TMask*        _mask;
 | ||
|   TLCO_form*    _form;
 | ||
|   TString16 _condven,
 | ||
|             _tipocf,
 | ||
|             _cod,
 | ||
|             _catven;
 | ||
|   long      _codcf;
 | ||
|   bool _codlis_catven, // booleano di abilitazione della categoria di vendita nella chiave dei listini
 | ||
|        _codcon_codcf,  // booleano di abilitazione del codice cliente/fornitore nella chiave dei contratti
 | ||
|        _gest_um, 
 | ||
|        _gest_sca, 
 | ||
|        _extended;
 | ||
|   
 | ||
| protected:
 | ||
|   virtual bool create(void);
 | ||
|   virtual bool destroy(void);
 | ||
|   virtual void main_loop() ;
 | ||
|   
 | ||
| public:
 | ||
|   TStampa_LCO_sintetica() {}
 | ||
|   virtual ~TStampa_LCO_sintetica() {}
 | ||
| };
 | ||
| 
 | ||
| bool TStampa_LCO_sintetica::create()
 | ||
| {
 | ||
|   _mask = new TMask("ve3300a");
 | ||
|   _form = new TLCO_form("ve3300a");
 | ||
|   
 | ||
|   bool gotcha = FALSE;
 | ||
|   int indice = 0;
 | ||
|   _condven= "*";
 | ||
|   if (argc()>2) 
 | ||
|     _condven= argv(2);
 | ||
|   else
 | ||
|   {
 | ||
|     TMask choose("ve3200");
 | ||
|     if (choose.run() == K_ENTER) 
 | ||
|       _condven = choose.get(F_TIPOCV);
 | ||
|   }
 | ||
|   _condven.upper();
 | ||
|   TConfig prassid(CONFIG_DITTA, "ve");
 | ||
|   _mask->set(F_TIPO, _condven); // settaggio del campo di tipo archivio
 | ||
|   switch (_condven[0])
 | ||
|   {
 | ||
|     case 'L': // listini
 | ||
|       indice = A_LISTINI;
 | ||
|       if (!(prassid.get_bool("GES", NULL, indice))) 
 | ||
|         error_box("L'archivio Listini non <20> abilitato");
 | ||
|       else 
 | ||
|       {
 | ||
|         _codlis_catven= prassid.get_bool("GESLISCV");
 | ||
|         gotcha= TRUE;
 | ||
|       }
 | ||
|       _mask->set_caption("Stampa Listini");
 | ||
|       _mask->hide(F_C_COD);
 | ||
|       _mask->hide(F_C_TIPOCF);
 | ||
|       _mask->hide(F_C_CODCF);
 | ||
|       _mask->hide(F_O_COD);
 | ||
|       if (!_codlis_catven) 
 | ||
|         _mask->disable(F_L_CATVEN); // disabilita condizionalmente le categorie di vendita
 | ||
|       break;
 | ||
|     case 'C': // contratti
 | ||
|       indice= A_CONTRATTI;
 | ||
|       if (!(prassid.get_bool("GES", NULL, indice))) 
 | ||
|         error_box("L'archivio Contratti non <20> abilitato");
 | ||
|       else
 | ||
|       {
 | ||
|         _codcon_codcf= prassid.get_bool("GESCONCC");
 | ||
|         gotcha= TRUE;
 | ||
|       }
 | ||
|       _mask->set_caption("Stampa Contratti");
 | ||
|       _mask->hide(F_L_COD);
 | ||
|       _mask->hide(F_L_CATVEN);
 | ||
|       _mask->hide(F_O_COD);
 | ||
|       if (!_codcon_codcf) 
 | ||
|       { // disabilita condizionalmente i clienti/fornitori
 | ||
|         _mask->disable(F_C_TIPOCF);
 | ||
|         _mask->disable(F_C_CODCF);
 | ||
|       }
 | ||
|       break;
 | ||
|     case 'O': // offerte
 | ||
|       indice= A_OFFERTE;
 | ||
|       if (!(prassid.get_bool("GES", NULL, indice))) 
 | ||
|         error_box("L'archivio Offerte non <20> abilitato");
 | ||
|       else
 | ||
|         gotcha= TRUE;
 | ||
|       _mask->set_caption("Stampa Offerte");
 | ||
|       _mask->hide(F_L_COD); // settaggio dei campi da eliminare
 | ||
|       _mask->hide(F_L_CATVEN);
 | ||
|       _mask->hide(F_C_TIPOCF);
 | ||
|       _mask->hide(F_C_CODCF);
 | ||
|       _mask->hide(F_C_COD);
 | ||
|       break;    
 | ||
|     default:
 | ||
|       error_box("Indicare l'archivio sulla linea di comando (L, C o O) oppure selezionarla dalla maschera di partenza");
 | ||
|       break;
 | ||
|   }
 | ||
|   if (gotcha) 
 | ||
|   { 
 | ||
|     _gest_um  = prassid.get_bool("GESUM", NULL, indice);
 | ||
|     _gest_sca = prassid.get_bool("GESSCA", NULL, indice);
 | ||
|   }
 | ||
|   
 | ||
|   return (gotcha && TSkeleton_application::create());
 | ||
| }
 | ||
| 
 | ||
| bool TStampa_LCO_sintetica::destroy()
 | ||
| {
 | ||
|   delete _form;
 | ||
|   delete _mask;
 | ||
|   
 | ||
|   return TSkeleton_application::destroy();
 | ||
| }
 | ||
| 
 | ||
| void TStampa_LCO_sintetica::main_loop()
 | ||
| {
 | ||
|   while (_mask->run()!=K_QUIT)
 | ||
|   {
 | ||
|     _extended = _mask->get_bool(F_EXTENDED);
 | ||
|     _catven   = _mask->get(F_L_CATVEN);
 | ||
|     _tipocf   = _condven[0] == 'C' ? _mask->get(F_C_TIPOCF) : "";
 | ||
|     _codcf    = _mask->get_long(F_C_CODCF);
 | ||
|     const char cv = _condven[0];
 | ||
|     if (cv == 'L')
 | ||
|       _cod = _mask->get(F_L_COD);
 | ||
|     else
 | ||
|       if (cv == 'C')
 | ||
|         _cod = _mask->get(F_C_COD);
 | ||
|       else
 | ||
|         _cod = _mask->get( F_O_COD);
 | ||
|     
 | ||
|     TCursor* cur = _form->cursor();
 | ||
|     
 | ||
|     TRectype from (LF_CONDV);
 | ||
|     from.put("TIPO", _condven);
 | ||
|     from.put("CATVEN", _catven);
 | ||
|     from.put("TIPOCF", _tipocf);
 | ||
|     from.put("CODCF", _codcf);
 | ||
|     from.put("COD", _cod);
 | ||
|     TRectype to(from);
 | ||
|     
 | ||
|     cur->setregion(from, to);
 | ||
| 
 | ||
|     // Spengi la luz...
 | ||
|     _form->find_field('H', odd_page, 5).show(cv == 'L');
 | ||
|     _form->find_field('H', odd_page, 6).show(cv == 'C');
 | ||
|     _form->find_field('H', odd_page, 7).show(cv == 'C');
 | ||
| 
 | ||
|     _form->find_field('B', odd_page, 9).show(_extended);
 | ||
|     _form->find_field('B', odd_page, 10).show(_extended);
 | ||
|     _form->find_field('B', odd_page, 11).show(_extended);
 | ||
|     _form->find_field('B', odd_page, 109).show(_extended);
 | ||
|     _form->find_field('B', odd_page, 110).show(_extended);
 | ||
|     _form->find_field('B', odd_page, 111).show(_extended);
 | ||
|     
 | ||
|     _form->find_field('B', odd_page, 3).show(_gest_um);
 | ||
|     _form->find_field('B', odd_page, 103).show(_gest_um);
 | ||
| 
 | ||
|     _form->find_field('B', odd_page, 4).show(_gest_sca);
 | ||
|     _form->find_field('B', odd_page, 5).show(_gest_sca);
 | ||
|     _form->find_field('B', odd_page, 104).show(_gest_sca);
 | ||
|     _form->find_field('B', odd_page, 105).show(_gest_sca);
 | ||
|     
 | ||
|     const int hh = 7;
 | ||
|     const int fl = printer().formlen();
 | ||
|     int rows[4];         // Righe orizzontali
 | ||
|     rows[0] = hh-2;
 | ||
|     rows[1] = hh;
 | ||
|     rows[2] = fl-1;
 | ||
|     rows[3] = 0;
 | ||
|     _form->genera_intestazioni(odd_page, hh-1);
 | ||
|     _form->genera_fincatura(odd_page, hh-2, fl-1, rows);
 | ||
|     
 | ||
|     // stampa
 | ||
|     if (_form->cursor()->items() > 0)
 | ||
|       _form->print();
 | ||
|   }
 | ||
| }
 | ||
| 
 | ||
| int ve3300(int argc, char **argv) 
 | ||
| {
 | ||
|   TStampa_LCO_sintetica a;
 | ||
|   
 | ||
|   a.run(argc, argv, "Stampa condizioni vendita");
 | ||
|   return 0;
 | ||
| }
 | ||
| 
 |