Files correlati : or1.exe Ricompilazione Demo : [ ] Commento : Bug 0000136 Implementare la gestione multilingua git-svn-id: svn://10.65.10.50/trunk@12090 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1069 lines
		
	
	
		
			32 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1069 lines
		
	
	
		
			32 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Stampa ordini
 | ||
| #include <applicat.h>
 | ||
| #include <mask.h>
 | ||
| #include <printer.h>
 | ||
| #include "orlib.h"
 | ||
| #include "or1100ap.h"
 | ||
| 
 | ||
| // Tipi di stampa per selezionare il form
 | ||
| enum tipo_stampa {
 | ||
|   numero,   // or1100a.frm
 | ||
|   clifo,    // or1100bp.frm
 | ||
|   agente,   // or1100c.frm
 | ||
|   articolo, // or1100d.frm
 | ||
|   datacons  // or1100ep.frm
 | ||
| };
 | ||
| 
 | ||
| // Tipi di ordinamento
 | ||
| enum tipo_ord {
 | ||
|   num_doc,   // ordinamento per numero documento
 | ||
|   data_doc   // ordinamento per data documento
 | ||
| };
 | ||
| 
 | ||
| // Applicazione di stampa
 | ||
| 
 | ||
| class TStampa_ordini : public TSkeleton_application
 | ||
| {
 | ||
|   TMask          * _m;
 | ||
|   TOrdine_form   * _frm;
 | ||
|   TTable         * _fcg;
 | ||
|   tipo_stampa _tipo;
 | ||
|   TCodgiac_livelli *_codgiac;
 | ||
|   TAssoc_array     _tipi_riga; // Cache dei tipi riga attivati: tipo M, S, P, C, O D
 | ||
|   TString     _codnum;
 | ||
|   int         _anno;
 | ||
|   char        _provv, _tipocf,
 | ||
|               _TEA_ord, _TEA_rord; // Tipi ordini/righe 'T'utti/'E'vasi/'A'perti
 | ||
|   tipo_ord    _order;
 | ||
|   bool        _detail_rows, _detail_doc, _detail_cli, _detail_mag, _detail_dep,
 | ||
|               _pr_spese, _pr_prest, _pr_sconti, _pr_omaggi, _pr_descr,
 | ||
|               _opz_valore, _opz_prezzo, _opz_residuo, _opz_giacenza,
 | ||
|               _force_evase;
 | ||
|   int         _detail_level; //0..4    0 = Articoli 4 = FCG #4 Maximum detail level
 | ||
|   TString     _from_age, _to_age,
 | ||
|               _from_art, _to_art,
 | ||
|               _from_cat, _to_cat,
 | ||
|               _from_mag, _to_mag,
 | ||
|               _from_dep, _to_dep;
 | ||
|   TString_array
 | ||
|               _from_giac, _to_giac;
 | ||
|   long        _from_ndoc, _to_ndoc,
 | ||
|               _from_cf,   _to_cf;
 | ||
|   TDate       _from_date, _to_date,
 | ||
|               _from_cons, _to_cons;
 | ||
|   TArray _file;
 | ||
| 
 | ||
| protected:
 | ||
|   static bool stato_handler(TMask_field& f, KEY k);
 | ||
|   static bool detail_handler(TMask_field& f, KEY k);
 | ||
|   virtual bool create(); 
 | ||
|   virtual bool destroy(); 
 | ||
|   virtual void main_loop();
 | ||
|   void set_totvaluta_items();
 | ||
|   void filter_for_number();
 | ||
|   void filter_for_clifo_agent();
 | ||
|   void filter_for_articolo();
 | ||
| public:  
 | ||
|   TStampa_ordini() {};
 | ||
|   virtual ~TStampa_ordini() {};
 | ||
| };
 | ||
| 
 | ||
| inline TStampa_ordini& app() { return (TStampa_ordini&) main_app();}
 | ||
| 
 | ||
| bool TStampa_ordini::stato_handler(TMask_field& f, KEY k)
 | ||
| {
 | ||
|   if (f.to_check(k))
 | ||
|   {
 | ||
|     TMask& m = f.mask();
 | ||
|     const char v = f.get()[0];
 | ||
|     const bool b = m.get_bool(F_DETTAGLIO);
 | ||
|     if (v == 'E' && b) // Se si seleziona la stampa degli ordini totalmente evasi ha senso stampare solo le righe evase, cioe' tutte
 | ||
|     {
 | ||
|       m.set(F_STATORORD, "T");
 | ||
|       m.disable(F_STATORORD);
 | ||
|     }
 | ||
|     else
 | ||
|       if (b) // Qualsiasi altro tipo di stampa dettaglio righe puo' essere selezionata
 | ||
|         m.enable(F_STATORORD);
 | ||
|   }
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| bool TStampa_ordini::detail_handler(TMask_field& f, KEY k)
 | ||
| {
 | ||
|   if (k == K_SPACE)
 | ||
|   {
 | ||
|     TMask& m = f.mask();
 | ||
|     const bool b = m.get_bool(F_DETTAGLIO);
 | ||
|     const tipo_stampa tipo = (tipo_stampa) m.get_int(F_TIPO);
 | ||
|     
 | ||
|     if (tipo != numero)
 | ||
|     {
 | ||
|       m.enable(-GR_DETAIL,b);
 | ||
|       m.enable(F_STATOORD,!b);
 | ||
|       m.reset(-GR_PRINT);
 | ||
|       m.disable(-GR_PRINT);
 | ||
|       //if (tipo != articolo)
 | ||
|       //  m.set(F_DETAIL_BY_DOC, !b ? "" : "X");
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|       m.enable(-GR_ART,b);
 | ||
|       m.enable(-GR_MAG,b);
 | ||
|       m.enable(-GR_PRINT, b);
 | ||
|       m.enable(F_STATORORD,b);
 | ||
|       m.enable(F_DETAIL_BY_DOC, b);
 | ||
|       //m.enable(F_STATOORD);
 | ||
|     }
 | ||
|     m.enable(F_STATOORD,!b);
 | ||
|     if (tipo != articolo)
 | ||
|       m.set(F_DETAIL_BY_DOC, !b ? "" : "X");
 | ||
|     if (!b)
 | ||
|     {
 | ||
|       m.reset(F_FORCE_EVASE);
 | ||
|       m.disable(F_FORCE_EVASE);
 | ||
|     }            
 | ||
|     m.enable(-GR_CATMER,b && tipo == clifo);
 | ||
|   }
 | ||
|   return TRUE;
 | ||
| }
 | ||
| 
 | ||
| bool TStampa_ordini::create()
 | ||
| {
 | ||
|   open_files(LF_OCCAS, LF_CLIFO, LF_INDSP, LF_CFVEN, LF_UMART, LF_MAG, LF_STOMAG, LF_MOVMAG, LF_RMOVMAG,  LF_RIGHEDOC, 0);
 | ||
|   _m = new TMask ("or1100ap");
 | ||
|   //_m->set_handler(F_STATOORD, stato_handler);
 | ||
|   _m->set_handler(F_DETTAGLIO, detail_handler);
 | ||
|   _fcg = new TTable("FCG");
 | ||
|   _codgiac = new  TCodgiac_livelli;
 | ||
|   if (!_codgiac->enabled())
 | ||
|   {
 | ||
|     _m->disable(F_DETAIL_LEV);
 | ||
|     _m->hide(-GR_GIAC);
 | ||
|   }
 | ||
|   
 | ||
|   short id = F_GIAC1;
 | ||
|   for (_fcg->first(); _fcg->good(); _fcg->next(), id+=4)
 | ||
|     _m->set(id, _fcg->get("CODTAB"));
 | ||
| 
 | ||
|   // Carica i tipi riga dalla tabella TRI
 | ||
|   TTable tri ("%TRI");
 | ||
|   for (tri.first(); !tri.eof(); tri.next())
 | ||
|   {
 | ||
|     TString* ss = new TString(tri.get("CODTAB"));
 | ||
|     _tipi_riga.add(tri.get("S7"), ss);
 | ||
|   }
 | ||
|   
 | ||
|   return TSkeleton_application::create();
 | ||
| }
 | ||
| 
 | ||
| bool TStampa_ordini::destroy()
 | ||
| {
 | ||
|   delete _m;
 | ||
|   delete _fcg;
 | ||
|   delete _codgiac;
 | ||
|   return TSkeleton_application::destroy();
 | ||
| }
 | ||
| 
 | ||
| // Abilita disabilita i campi per i totali in valuta presenti alla fine del body
 | ||
| // per quel che riguarda le stampe per cli/fo/agenti/articoli
 | ||
| void TStampa_ordini::set_totvaluta_items()
 | ||
| {
 | ||
|   TString16 sec_name;
 | ||
|   
 | ||
|   for (int i = 1; i<=4; i++)
 | ||
|   {
 | ||
|     sec_name = "TOTVAL";
 | ||
|     sec_name << i;
 | ||
|     TForm_subsection& asec = (TForm_subsection&)_frm->find_field('B', odd_page, sec_name);
 | ||
|     short id = BODY_TOTVALORD + ((i-1) * 10);
 | ||
|     asec.printsection().find_field(id).show(_opz_valore);
 | ||
|     asec.printsection().find_field(id + 1).show(_opz_valore);
 | ||
|   }
 | ||
| }
 | ||
| 
 | ||
| void TStampa_ordini::filter_for_number()
 | ||
| {
 | ||
|   CHECK(_frm, "Form non valido");
 | ||
|   
 | ||
|   TCursor* cur = _frm->cursor();
 | ||
|   
 | ||
|   cur->setkey(_order == num_doc ?  1 : 3); // Selezione per numero doc o data emissione
 | ||
|           
 | ||
|   TRectype f(LF_DOC), t(LF_DOC);
 | ||
|   TString filter_expr,s, lev_str, mag_str;
 | ||
|   
 | ||
|   filter_expr << "(TIPOCF==\"" << _tipocf << "\")";
 | ||
|   if (_order == num_doc)
 | ||
|   {
 | ||
|     f.put(DOC_PROVV, _provv);
 | ||
|     f.put(DOC_ANNO, _anno);
 | ||
|     f.put(DOC_CODNUM, _codnum);
 | ||
|     t = f;
 | ||
|     f.put(DOC_NDOC, _from_ndoc);
 | ||
|     t.put(DOC_NDOC, _to_ndoc);
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     f.put(DOC_DATADOC, _from_date);
 | ||
|     t.put(DOC_DATADOC, _to_date);
 | ||
|     filter_expr << " && (PROVV==\"" << _provv << "\")";
 | ||
|     if (_anno != 0)
 | ||
|       filter_expr << " && (ANNO==\"" << _anno << "\")";
 | ||
|     filter_expr << " && (CODNUM==\"" << _codnum << "\")";
 | ||
|   }
 | ||
|   cur->setregion(f,t);
 | ||
|   
 | ||
|   // Imposta l'ordine CODNUM+ANNO+PROVV+NDOC+CODART+LIVELLO+CODMAG+DATACONS
 | ||
|   // nel caso si voglia il dettaglio all'interno del singolo documento, per liv.giac e cod.mag.
 | ||
|   // In tal caso viene sostituito LF_RIGHEDOC nella relazione con un TSortedfile siffatto
 | ||
|   if (_detail_rows && !_detail_doc)
 | ||
|   {
 | ||
|     s << "CODNUM|ANNO|PROVV|NDOC|CODART|";
 | ||
|     
 | ||
|     if (_detail_level > 0)
 | ||
|       lev_str.format("LIVELLO[1,%d]",_codgiac->packed_length(_detail_level));
 | ||
|     if (_detail_mag)
 | ||
|       mag_str.format("CODMAG[1,3]");
 | ||
|     if (_detail_dep)
 | ||
|       mag_str.format("CODMAG");
 | ||
|     
 | ||
|     if (lev_str.not_empty())
 | ||
|       s << lev_str << "|";
 | ||
|     if (mag_str.not_empty())
 | ||
|       s <<  mag_str << "|";
 | ||
|     s << "DATACONS";
 | ||
|     
 | ||
|     TSortedfile *rdoc = new TSortedfile(LF_RIGHEDOC,NULL,s,"",1);
 | ||
|     cur->relation()->replace(rdoc,1,"CODNUM==CODNUM|ANNO==ANNO|PROVV==PROVV|NDOC==NDOC");
 | ||
| 
 | ||
|     TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "RIGHEART");
 | ||
|     ssec.enable(); 
 | ||
|     TString cond(ssec.condition());
 | ||
|     if (lev_str.not_empty())
 | ||
|       cond << "+" << lev_str;
 | ||
|     if (mag_str.not_empty())
 | ||
|       cond << "+" << mag_str;
 | ||
|     ssec.setcondition(cond, _strexpr);
 | ||
|   }
 | ||
|   
 | ||
|   if (_TEA_ord == 'E')
 | ||
|     filter_expr << " && (DOCEVASO==\"X\")";
 | ||
|   else
 | ||
|     if (_TEA_ord == 'A')
 | ||
|       filter_expr << " && (DOCEVASO!=\"X\")";
 | ||
| 
 | ||
|   if (!_detail_rows)
 | ||
|   {
 | ||
|     // In caso di dettaglio per righe non va settato il filtro per dataconsegnain quanto
 | ||
|     // gi<67> impostato sulla sottosezione (vedi sotto)
 | ||
|     if (_from_cons.ok())
 | ||
|     {
 | ||
|       filter_expr << "&&";
 | ||
|       s.format("(ANSI(DATACONS)>=\"%s\")", 
 | ||
|                    (const char*)_from_cons.string(ANSI));
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     if (_to_cons.ok())  
 | ||
|     {
 | ||
|       filter_expr << "&&";
 | ||
|       s.format("(ANSI(DATACONS)<=\"%s\")", 
 | ||
|                    (const char*)_to_cons.string(ANSI));
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|   }
 | ||
|   
 | ||
|   cur->setfilter(filter_expr);
 | ||
|   
 | ||
|   if (_detail_rows)
 | ||
|   {
 | ||
|     for (short i = BODY_COL_7; i<=BODY_COL_12; i++)
 | ||
|       _frm->find_field('B', odd_page, i).show();
 | ||
|     _frm->find_field('B', odd_page, "DET").show(); // Visualizza la sottosezione
 | ||
|     TForm_subsection& ssec = (TForm_subsection&)_frm->find_field('B', odd_page, "RIGHE"); // Sottosezione padre
 | ||
|     
 | ||
|     // Applica filtri alla sezione
 | ||
|     TString cond;
 | ||
|     
 | ||
|     // Aggiunge filtro sui tipi di riga
 | ||
|     s.format("((%d->TIPORIGA==\"%s\")", LF_RIGHEDOC, (const char*)(TString&)_tipi_riga["M"]);
 | ||
|     cond << s;
 | ||
| 
 | ||
|     if (_pr_spese)
 | ||
|     {
 | ||
|       s.format("||(%d->TIPORIGA==\"%s\")", LF_RIGHEDOC,(const char*)(TString&)_tipi_riga["S"]);
 | ||
|       cond << s;
 | ||
|     }
 | ||
| 
 | ||
|     if (_pr_prest)
 | ||
|     {
 | ||
|       s.format("||(%d->TIPORIGA==\"%s\")", LF_RIGHEDOC,(const char*)(TString&)_tipi_riga["P"]);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     
 | ||
|     if (_pr_sconti)
 | ||
|     {
 | ||
|       s.format("||(%d->TIPORIGA==\"%s\")", LF_RIGHEDOC,(const char*)(TString&)_tipi_riga["C"]);
 | ||
|       cond << s;
 | ||
|     }
 | ||
| 
 | ||
|     if (_pr_omaggi)
 | ||
|     {
 | ||
|       s.format("||(%d->TIPORIGA==\"%s\")", LF_RIGHEDOC,(const char*)(TString&)_tipi_riga["O"]);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     
 | ||
|     if (_pr_descr)
 | ||
|     {
 | ||
|       s.format("||(%d->TIPORIGA==\"%s\")", LF_RIGHEDOC,(const char*)(TString&)_tipi_riga["D"]);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     
 | ||
|     cond << ")";
 | ||
|     
 | ||
|     // TBI: stampa righe di sconto testata od esenzione. Siccome non sono righe fisiche
 | ||
|     // credo sara' necessario implementarle con un messaggio nella validate...
 | ||
|         
 | ||
|     // Applica il filtro per righe evase/aperte
 | ||
|     s = "";
 | ||
|     if (_TEA_rord == 'E')
 | ||
|      s.format("&&(%d->RIGAEVASA==\"X\")",LF_RIGHEDOC);
 | ||
|     else
 | ||
|     if (_TEA_rord == 'A')
 | ||
|      s.format("&&(%d->RIGAEVASA!=\"X\")",LF_RIGHEDOC);
 | ||
|     
 | ||
|     cond << s;
 | ||
|     
 | ||
|     s = "";
 | ||
|     if (_force_evase)
 | ||
|       s.format("&&(%d->QTAEVASA != %d->QTA)", LF_RIGHEDOC, LF_RIGHEDOC);
 | ||
|     cond << s;
 | ||
|     
 | ||
|     // Setta i range per la data di consegna
 | ||
|     if (_from_cons.ok())
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(ANSI(%d->DATACONS)>=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_from_cons.string(ANSI));
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     if (_to_cons.ok())  
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(ANSI(%d->DATACONS)<=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_to_cons.string(ANSI));
 | ||
|       cond << s;
 | ||
|     }
 | ||
| 
 | ||
|     // Setta i range per il codice magazzino
 | ||
|     if (_from_mag.not_empty())
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(%d->CODMAG>=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_from_mag);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     if (_to_mag.not_empty())
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(%d->CODMAG<=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_to_mag);
 | ||
|       cond << s;
 | ||
|     }
 | ||
| 
 | ||
|     // Setta i range per il codice articolo
 | ||
|     if (_from_art.not_empty())
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(%d->CODART>=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_from_art);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     if (_to_art.not_empty())
 | ||
|     {
 | ||
|       if (cond.not_empty())
 | ||
|         cond << "&&";
 | ||
|       s.format("(%d->CODART<=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_to_art);
 | ||
|       cond << s;
 | ||
|     }
 | ||
|     
 | ||
|     s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC);
 | ||
|     cond << s;
 | ||
|     
 | ||
|     if (cond.not_empty())
 | ||
|       ssec.setcondition(cond, _strexpr);
 | ||
|     
 | ||
|     if (!_detail_doc)
 | ||
|     {
 | ||
|       TForm_subsection& ss = (TForm_subsection&)_frm->find_field('B', odd_page, "RIGHE");
 | ||
|       TPrint_section&   ps = ss.printsection();
 | ||
|       for (short j = BODY_COL_1; j <= BODY_COL_12; j++)
 | ||
|       {
 | ||
|         ps.find_field(j + 100).disable();
 | ||
|         ps.find_field(j + 400).enable();
 | ||
|       }
 | ||
|     }
 | ||
|   }
 | ||
|   
 | ||
|   // Abilitazione intestazioni di colonna
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_5).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_6).show(_opz_valore);
 | ||
|   _frm->find_field('F', last_page, BODY_COL_5+200).show(_opz_valore);
 | ||
|   _frm->find_field('F', last_page, BODY_COL_6+200).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_10).show(_opz_prezzo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_11).show(_opz_residuo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_12).show(_opz_giacenza);
 | ||
|   
 | ||
|   // Abilitazione delle righe
 | ||
|   const short id = !_detail_doc && _detail_rows ? 400 : 100;
 | ||
|   TForm_subsection& ssec = (TForm_subsection&)_frm->find_field('B', odd_page, "RIGHE"); // Sottosezione padre
 | ||
|   ssec.printsection().find_field(BODY_COL_5  + id).show(_opz_valore);
 | ||
|   ssec.printsection().find_field(BODY_COL_6  + id).show(_opz_valore);
 | ||
|   ssec.printsection().find_field(BODY_COL_10 + id).show(_opz_prezzo);
 | ||
|   ssec.printsection().find_field(BODY_COL_11 + id).show(_opz_residuo);
 | ||
|   ssec.printsection().find_field(BODY_COL_12 + id).show(_opz_giacenza);
 | ||
| }
 | ||
| 
 | ||
| void TStampa_ordini::filter_for_clifo_agent()
 | ||
| {
 | ||
|   CHECK(_frm, "Form non valido");
 | ||
|   
 | ||
|   const bool is_for_cli = _tipo == clifo;
 | ||
|   
 | ||
|   TString s, ws,lev_str, mag_str;
 | ||
|   TSorted_cursor* cur = (TSorted_cursor*)_frm->cursor();
 | ||
|   
 | ||
|   if (_detail_rows && !_detail_doc) // Cambia l'ordinamento se si vuol dettagliare per articolo e non per documento
 | ||
|   {
 | ||
|     if (_detail_level > 0)
 | ||
|       lev_str.format("LIVELLO[1,%d]",_codgiac->packed_length(_detail_level));
 | ||
|     if (_detail_mag)
 | ||
|       mag_str.format("CODMAG[1,3]");
 | ||
|     if (_detail_dep)
 | ||
|       mag_str.format("CODMAG");
 | ||
|     
 | ||
|     if (!is_for_cli)
 | ||
|       s.format("%d->CODAG|",LF_DOC);
 | ||
|     if (is_for_cli || _detail_cli)
 | ||
|     {
 | ||
|       ws.format("%d->TIPOCF|%d->CODCF|%d->OCFPI|",LF_DOC, LF_DOC, LF_DOC);
 | ||
|       s << ws;
 | ||
|     }
 | ||
|     s << "CODART|";
 | ||
|     if (lev_str.not_empty())
 | ||
|       s << lev_str << "|";
 | ||
|     if (mag_str.not_empty())
 | ||
|       s <<  mag_str << "|";
 | ||
|     s << "DATACONS";
 | ||
|     cur->change_order(s);
 | ||
|   }
 | ||
|   //Mo setto li filtri, altrimenti stampa tutto er file de' righe documento
 | ||
|   TRectype f(LF_RIGHEDOC), t(LF_RIGHEDOC);
 | ||
|   TString filter_expr;
 | ||
|   
 | ||
|   f.put(DOC_CODNUM, _codnum);
 | ||
|   if (_anno != 0)
 | ||
|   {
 | ||
|     f.put(DOC_PROVV, _provv);
 | ||
|     f.put(DOC_ANNO, _anno);
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     s.format("(PROVV==\"%c\")&&", _provv);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   
 | ||
|   t = f;
 | ||
|   cur->setregion(f,t); // This is the region...
 | ||
| 
 | ||
|   s.format("(%d->TIPOCF==\"",LF_DOC);
 | ||
|   filter_expr << s << _tipocf << "\")"; // Nel caso di stampa per agenti e' sempre "C"
 | ||
|   
 | ||
|   s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC);
 | ||
|   filter_expr << s;
 | ||
|   
 | ||
|   // Filtro su Cli/Fo   od agente
 | ||
|   if (is_for_cli)
 | ||
|   {
 | ||
|     if (_from_cf > 0L)
 | ||
|     {
 | ||
|       s.format("&&(STR(NUM(%d->CODCF)>=%ld))", LF_DOC, _from_cf);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     
 | ||
|     if (_to_cf > 0L)
 | ||
|     {
 | ||
|       s.format("&&(STR(NUM(%d->CODCF)<=%ld))", LF_DOC, _to_cf);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     if (_from_age.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->CODAG>=\"%s\")", LF_DOC, (const char*)_from_age);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     
 | ||
|     if (_to_age.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->CODAG<=\"%s\")", LF_DOC, (const char*)_to_age);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|   }
 | ||
|   
 | ||
|   
 | ||
|   // Filtro sulla data ordine...
 | ||
|   if (_from_date.ok())
 | ||
|   {
 | ||
|     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC,
 | ||
|                  (const char*)_from_date.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   if (_to_date.ok())
 | ||
|   {
 | ||
|     s.format("&&(ANSI(%d->DATADOC)<=\"%s\")", LF_DOC,
 | ||
|                  (const char*)_to_date.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   } 
 | ||
|                                                
 | ||
|   // Filtro sulla data consegna...
 | ||
|   if (_from_cons.ok())
 | ||
|   {
 | ||
|     s.format("&&(ANSI(DATACONS)>=\"%s\")", 
 | ||
|                  (const char*)_from_cons.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   if (_to_cons.ok())  
 | ||
|   {
 | ||
|     s.format("&&(ANSI(DATACONS)<=\"%s\")", 
 | ||
|                  (const char*)_to_cons.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
| 
 | ||
|   if (_detail_rows)
 | ||
|   {
 | ||
|     // Setta i range per il codice articolo
 | ||
|     if (_from_art.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->CODART>=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_from_art);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     if (_to_art.not_empty())
 | ||
|     {
 | ||
|       filter_expr << "&&";
 | ||
|       s.format("(%d->CODART<=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_to_art);
 | ||
|       filter_expr << s;
 | ||
|     } 
 | ||
|     
 | ||
|     //Setta i range per la categoria merceologica
 | ||
|     if (_from_cat.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->GRMERC[1,3]>=\"%s\")",LF_ANAMAG, (const char*)_from_cat);
 | ||
|       filter_expr << s;
 | ||
|     } 
 | ||
|     if (_to_cat.not_empty())
 | ||
|     {
 | ||
|       filter_expr << "&&";
 | ||
|       s.format("(%d->GRMERC[1,3]<=\"%s\")",LF_ANAMAG, (const char*)_to_cat);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     
 | ||
|     // Setta i range per i livelli di giacenza (da 1 a 4)
 | ||
|     if (_detail_level > 0)
 | ||
|       for (int lev=1, index=0; lev <= _detail_level; lev++)
 | ||
|       {
 | ||
|         if (!_codgiac->enabled(lev))
 | ||
|           continue;
 | ||
|         TString& from = (TString&) _from_giac[index];
 | ||
|         TString& to   = (TString&) _to_giac[index++];
 | ||
|         const int starts = _codgiac->code_start(lev);
 | ||
|         const int ends   = starts+_codgiac->code_length(lev);
 | ||
|         if (from.not_empty())
 | ||
|         {
 | ||
|           s.format("&&(%d->LIVELLO[%d,%d]>=\"%s\")",
 | ||
|             LF_RIGHEDOC,starts,ends,(const char*)from);
 | ||
|           filter_expr << s;
 | ||
|         }
 | ||
|         if (to.not_empty())
 | ||
|         {
 | ||
|           s.format("&&(%d->LIVELLO[%d,%d]<=\"%s\")", 
 | ||
|             LF_RIGHEDOC,starts,ends,(const char*)to);
 | ||
|           filter_expr << s;
 | ||
|         }
 | ||
|       }
 | ||
|     // Setta i range per il codice magazzino (deposito incluso)
 | ||
|     if (_from_mag.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->CODMAG>=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_from_mag);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|     if (_to_mag.not_empty())
 | ||
|     {
 | ||
|       s.format("&&(%d->CODMAG<=\"%s\")", 
 | ||
|                    LF_RIGHEDOC, (const char*)_to_mag);
 | ||
|       filter_expr << s;
 | ||
|     }
 | ||
|   }
 | ||
|   
 | ||
|   s = "";
 | ||
|   if (!_detail_rows)
 | ||
|   {
 | ||
|     if (_TEA_ord == 'E')
 | ||
|       s.format("&&(%d->DOCEVASO==\"X\")",LF_DOC);
 | ||
|     else
 | ||
|       if (_TEA_ord == 'A')
 | ||
|         s.format("&&(%d->DOCEVASO!=\"X\")",LF_DOC);
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     if (_TEA_rord == 'E')
 | ||
|      s.format("&&(%d->RIGAEVASA==\"X\")",LF_RIGHEDOC);
 | ||
|     else
 | ||
|     if (_TEA_rord == 'A')
 | ||
|      s.format("&&(%d->RIGAEVASA!=\"X\")",LF_RIGHEDOC);
 | ||
| 
 | ||
|     if (_force_evase)
 | ||
|       s << "&&(" << LF_RIGHEDOC << ">QTAEVASA != " << LF_RIGHEDOC << "->QTA)";
 | ||
|   } 
 | ||
|    
 | ||
|   if (s.not_empty())
 | ||
|     filter_expr << s;
 | ||
| 
 | ||
|   cur->setfilter(filter_expr,TRUE,2);
 | ||
|   
 | ||
|   // Alla fine setta i campi da vedere
 | ||
|   if (!is_for_cli && _detail_cli)
 | ||
|   {
 | ||
|   // Solo stampa per agenti: se si e' settato il distinguo per clienti
 | ||
|   // mostra l'intestazione prima di ogni cambio cliente
 | ||
|     TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "HCLIENTI");
 | ||
|     ssec.enable();
 | ||
|   }
 | ||
|   
 | ||
|   if (!_detail_rows || _detail_doc) // Stampa distinguendo per documento e non per righe articolo...
 | ||
|   {
 | ||
|     TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "DOCUMENTI");
 | ||
|     if (!is_for_cli)
 | ||
|       ssec.enable(); // Se stampa per agenti e dettaglia documenti per cliente  abilita la sezione
 | ||
|     else
 | ||
|     { // Se stampa per cli/fo abilita i campi corrispondenti al distinguo per documento (valuta, residuo evaso ecc...)
 | ||
|       ssec.printsection().find_field(BODY_COL_1 + 100).show();
 | ||
|       for (short id = BODY_COL_2 + 100; id <= (BODY_COL_6 + 100); id++)
 | ||
|          ssec.printsection().find_field(id).enable();
 | ||
|     }
 | ||
|     // Deve essere abilitata ma nascosta, per eseguire i raggruppamenti sulle righe
 | ||
|     TForm_subsection& dsec = (TForm_subsection&) _frm->find_field('B', odd_page, "RIGHEDOC");
 | ||
|     dsec.enable();  
 | ||
|     dsec.hide(); 
 | ||
|   }
 | ||
| 
 | ||
|   // In qualsiasi caso va fatta questa abilitazione                                         
 | ||
|   bool is_art = _detail_rows && !_detail_doc;                                                                                                 
 | ||
|   
 | ||
|   ((TForm_subsection&) _frm->find_field('B', odd_page, "DOCUMENTI")).printsection().find_field(BODY_COL_5 + 100).enable(_opz_valore && !is_art);
 | ||
|   ((TForm_subsection&) _frm->find_field('B', odd_page, "DOCUMENTI")).printsection().find_field(BODY_COL_6 + 100).enable(_opz_valore && !is_art);
 | ||
|   
 | ||
|   if (_detail_rows) // Stampa dettaglio righe...
 | ||
|   {
 | ||
|     for (short i = BODY_COL_7; i<=BODY_COL_12; i++)
 | ||
|       _frm->find_field('B', odd_page, i).show(); // Aggiunge le colonne di dettaglio
 | ||
|     // dulcis in fundo (Dulcinea mia adorata), si abilita la sezione RIGHEART
 | ||
|     // anziche' RIGHEDOC nel qual caso sia stato specificato il raggruppamento per Articoli (e sotto-opzioni)
 | ||
|     if (!_detail_doc) // Se la stampa deve distinguere e dettagliare per articoli e non per documenti...
 | ||
|     {
 | ||
|       TString cond;
 | ||
|       TForm_item& ff = _frm->find_field('B', odd_page, "RIGHEDOC");
 | ||
|       ff.y() = 1;
 | ||
|       
 | ||
|       if (!is_for_cli) // Abilita la sottosezione principale se stampa per agenti
 | ||
|       {
 | ||
|         TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "ARTCLI");
 | ||
|         ssec.enable();
 | ||
|         ssec.printsection().find_field(BODY_COL_5  + 400).enable(_opz_valore);
 | ||
|         ssec.printsection().find_field(BODY_COL_6  + 400).enable(_opz_valore);
 | ||
|         ssec.printsection().find_field(BODY_COL_10 + 400).enable(_opz_prezzo);
 | ||
|         ssec.printsection().find_field(BODY_COL_11 + 400).enable(_opz_residuo);
 | ||
|         ssec.printsection().find_field(BODY_COL_12 + 400).enable(_opz_giacenza);
 | ||
|         
 | ||
|         if (_detail_cli) // Se e' abilitata la distinzione per clienti setta l'espressione di raggruppamento
 | ||
|         {
 | ||
|           cond = ssec.condition();
 | ||
|           cond << "+" << LF_CLIFO << "->TIPOCF+" << LF_CLIFO << "->CODCF+" << LF_DOC << "->OCFPI";
 | ||
|           ssec.setcondition(cond, _strexpr);
 | ||
|         }
 | ||
|       }
 | ||
|       
 | ||
|       // Setta la condizione di raggruppamento principale per articoli (comune alla stampa per cli/fo e per agenti)
 | ||
|       TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "RIGHEART");
 | ||
|       ssec.enable(); 
 | ||
|       cond = ssec.condition();
 | ||
|       if (lev_str.not_empty())
 | ||
|         cond << "+" << lev_str;
 | ||
|       if (mag_str.not_empty())
 | ||
|         cond << "+" << mag_str;
 | ||
|       ssec.setcondition(cond, _strexpr);
 | ||
|       
 | ||
|       if (is_for_cli)
 | ||
|       { // I seguenti campi non necessitano di abilitazione se la stampa e' per agente
 | ||
|         TForm_subsection& dsec = (TForm_subsection&) _frm->find_field('B', odd_page, "DOCUMENTI");
 | ||
|         for (short id = BODY_COL_1 + 400; id <= (BODY_COL_12 + 400); id++)
 | ||
|            dsec.printsection().find_field(id).enable();
 | ||
|         dsec.printsection().find_field(BODY_COL_5  + 400).enable(_opz_valore);
 | ||
|         dsec.printsection().find_field(BODY_COL_6  + 400).enable(_opz_valore);
 | ||
|         dsec.printsection().find_field(BODY_COL_10 + 400).enable(_opz_prezzo);
 | ||
|         dsec.printsection().find_field(BODY_COL_11 + 400).enable(_opz_residuo);
 | ||
|         dsec.printsection().find_field(BODY_COL_12 + 400).enable(_opz_giacenza);
 | ||
|       }
 | ||
|     }
 | ||
|     else
 | ||
|     {
 | ||
|       _frm->find_field('B', odd_page, "RIGHEDOC").enable(); // Abilita la sezione di dettaglio righe PER DOCUMENTO
 | ||
|       TForm_subsection& rd = (TForm_subsection&) _frm->find_field('B', odd_page, "RIGHEDOC");
 | ||
|       rd.printsection().find_field(BODY_COL_5  + 200).enable(_opz_valore);
 | ||
|       rd.printsection().find_field(BODY_COL_6  + 200).enable(_opz_valore);
 | ||
|       rd.printsection().find_field(BODY_COL_10 + 200).enable(_opz_prezzo);
 | ||
|       rd.printsection().find_field(BODY_COL_11 + 200).enable(_opz_residuo);
 | ||
|       rd.printsection().find_field(BODY_COL_12 + 200).enable(_opz_giacenza);
 | ||
|     }
 | ||
|   }
 | ||
|   // Abilitazione intestazioni di colonna
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_5).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_6).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_10).show(_opz_prezzo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_11).show(_opz_residuo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_12).show(_opz_giacenza);  
 | ||
| 
 | ||
|   set_totvaluta_items();
 | ||
| }
 | ||
| 
 | ||
| void TStampa_ordini::filter_for_articolo()
 | ||
| {
 | ||
|   CHECK(_frm, "Form non valido");
 | ||
|   
 | ||
|   TString s, ws,lev_str, mag_str;
 | ||
|   TSorted_cursor* cur = (TSorted_cursor*)_frm->cursor();
 | ||
| 
 | ||
|   if (_detail_level > 0)
 | ||
|     lev_str.format("LIVELLO[1,%d]",_codgiac->packed_length(_detail_level));
 | ||
|   if (_detail_mag)
 | ||
|     mag_str.format("CODMAG[1,3]");
 | ||
|   if (_detail_dep)
 | ||
|     mag_str.format("CODMAG");
 | ||
|     
 | ||
|   s << "CODART|";
 | ||
|   if (lev_str.not_empty())
 | ||
|     s << lev_str << "|";
 | ||
|   if (mag_str.not_empty())
 | ||
|     s <<  mag_str << "|";
 | ||
|   s << "DATACONS";
 | ||
|   cur->change_order(s); // Setta l'ordine 
 | ||
| 
 | ||
|   
 | ||
|   TRectype f(LF_RIGHEDOC), t(LF_RIGHEDOC);
 | ||
|   TString filter_expr;
 | ||
|   
 | ||
|   f.put(DOC_CODNUM, _codnum);
 | ||
|   f.put(RDOC_CODART, _from_art);
 | ||
|   if (_anno != 0)
 | ||
|   {
 | ||
|     f.put(DOC_PROVV, _provv);
 | ||
|     f.put(DOC_ANNO, _anno);
 | ||
|   }
 | ||
|   else
 | ||
|   {
 | ||
|     s.format("(PROVV==\"%c\") &&", _provv);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   
 | ||
|   t = f;
 | ||
|   t.put(RDOC_CODART, _to_art);
 | ||
|   cur->setkey(2); // Questa chiave rende piu' veloce la costruzione se indicato un range di articoli
 | ||
|   cur->setregion(f,t); // This is the region...
 | ||
| 
 | ||
|   s.format("(%d->TIPOCF==\"",LF_DOC);
 | ||
|   filter_expr << s << _tipocf << "\")"; // Nel caso di stampa per agenti e' sempre "C"
 | ||
|   
 | ||
|   s.format("&&(%d->CODART!=\"\")", LF_RIGHEDOC);
 | ||
|   filter_expr << s;
 | ||
| 
 | ||
|   // Filtro su Cli/Fo
 | ||
|   if (_from_cf > 0L)
 | ||
|   {
 | ||
|     s.format("&&(STR(NUM(%d->CODCF)>=%ld))", LF_DOC, _from_cf);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|     
 | ||
|   if (_to_cf > 0L)
 | ||
|   {
 | ||
|     s.format("&&(STR(NUM(%d->CODCF)<=%ld))", LF_DOC, _to_cf);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   // Filtro sulla data ordine...
 | ||
|   if (_from_date.ok())
 | ||
|   {                                             
 | ||
|     s.format("&&(ANSI(%d->DATADOC)>=\"%s\")", LF_DOC,
 | ||
|                  (const char*)_from_date.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   if (_to_date.ok())
 | ||
|   {
 | ||
|     s.format("&&(ANSI(%d->DATADOC)<=\"%s\")", LF_DOC,
 | ||
|                  (const char*)_to_date.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   } 
 | ||
|                                                
 | ||
|   // Filtro sulla data consegna...
 | ||
|   if (_from_cons.ok())
 | ||
|   {
 | ||
|     s.format("&&(ANSI(DATACONS)>=\"%s\")", 
 | ||
|                  (const char*)_from_cons.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   if (_to_cons.ok())  
 | ||
|   {
 | ||
|     s.format("&&(ANSI(DATACONS)<=\"%s\")", 
 | ||
|                  (const char*)_to_cons.string(ANSI));
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   
 | ||
|   // Setta i range per i livelli di giacenza (da 1 a 4)
 | ||
|   if (_detail_level > 0)
 | ||
|     for (int lev=1, index=0; lev <= _detail_level; lev++)
 | ||
|     {
 | ||
|       if (!_codgiac->enabled(lev))
 | ||
|         continue;
 | ||
|       TString& from = (TString&) _from_giac[index];
 | ||
|       TString& to   = (TString&) _to_giac[index++];
 | ||
|       const int starts = _codgiac->code_start(lev);
 | ||
|       const int ends   = starts+_codgiac->code_length(lev);
 | ||
|       if (from.not_empty())
 | ||
|       {
 | ||
|         s.format("&&(%d->LIVELLO[%d,%d]>=\"%s\")",
 | ||
|           LF_RIGHEDOC,starts,ends,(const char*)from);
 | ||
|         filter_expr << s;
 | ||
|       }
 | ||
|       if (to.not_empty())
 | ||
|       {
 | ||
|         s.format("&&(%d->LIVELLO[%d,%d]<=\"%s\")", 
 | ||
|           LF_RIGHEDOC,starts,ends,(const char*)to);
 | ||
|         filter_expr << s;
 | ||
|       }
 | ||
|     }
 | ||
|   // Setta i range per il codice magazzino (deposito incluso)
 | ||
|   if (_from_mag.not_empty())
 | ||
|   {
 | ||
|     s.format("&&(%d->CODMAG>=\"%s\")", 
 | ||
|                  LF_RIGHEDOC, (const char*)_from_mag);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
|   if (_to_mag.not_empty())
 | ||
|   {
 | ||
|     s.format("&&(%d->CODMAG<=\"%s\")", 
 | ||
|                  LF_RIGHEDOC, (const char*)_to_mag);
 | ||
|     filter_expr << s;
 | ||
|   }
 | ||
| 
 | ||
|   s = "";
 | ||
|   if (_TEA_rord == 'E')
 | ||
|    s.format("&&(%d->RIGAEVASA==\"X\")",LF_RIGHEDOC);
 | ||
|   else
 | ||
|   if (_TEA_rord == 'A')
 | ||
|    s.format("&&(%d->RIGAEVASA!=\"X\")",LF_RIGHEDOC);
 | ||
| 
 | ||
|   if (s.not_empty())
 | ||
|     filter_expr << s;
 | ||
| 
 | ||
| 
 | ||
|   cur->setfilter(filter_expr,TRUE,2);       // Setta il filtro e serra i ranghi
 | ||
| 
 | ||
|   // Setta la condizione di raggruppamento principale per articoli 
 | ||
|   TForm_subsection& ssec = (TForm_subsection&) _frm->find_field('B', odd_page, "ARTMAIN");
 | ||
|   ssec.enable(); 
 | ||
|   s = ssec.condition();
 | ||
|   if (lev_str.not_empty())
 | ||
|     s << "+" << lev_str;
 | ||
|   if (mag_str.not_empty())
 | ||
|     s << "+" << mag_str;
 | ||
|   ssec.setcondition(s, _strexpr);
 | ||
|   
 | ||
|   for (short id = BODY_COL_1 + 400; id <= (BODY_COL_12 + 400); id++)
 | ||
|      _frm->find_field('B',odd_page,id).enable();
 | ||
| 
 | ||
|   // Abilitazione intestazioni di colonna
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_5).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_6).show(_opz_valore);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_10).show(_opz_prezzo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_11).show(_opz_residuo);
 | ||
|   _frm->find_field('B', odd_page, BODY_COL_12).show(_opz_giacenza);  
 | ||
| 
 | ||
|   // Abilitazione intestazioni di riga
 | ||
|   TForm_subsection& asec = (TForm_subsection&)_frm->find_field('B', odd_page, "ARTMAIN"); // Sottosezione padre
 | ||
|   asec.printsection().find_field(BODY_COL_5  + 400).show(_opz_valore);
 | ||
|   asec.printsection().find_field(BODY_COL_6  + 400).show(_opz_valore);
 | ||
|   asec.printsection().find_field(BODY_COL_10 + 400).show(_opz_prezzo);
 | ||
|   asec.printsection().find_field(BODY_COL_11 + 400).show(_opz_residuo);
 | ||
|   asec.printsection().find_field(BODY_COL_12 + 400).show(_opz_giacenza);
 | ||
|   
 | ||
|   set_totvaluta_items();
 | ||
| }
 | ||
| 
 | ||
| void TStampa_ordini::main_loop()
 | ||
| {
 | ||
|   TString form_name;
 | ||
| 
 | ||
|   while (_m->run()!=K_QUIT)
 | ||
|   {
 | ||
|     // selezione tipo di stampa per il form appropriato
 | ||
|     _tipo   =  (tipo_stampa) _m->get_int(F_TIPO);
 | ||
|     _codnum = _m->get(F_CODNUM);
 | ||
|     _provv  = _m->get(F_PROVV)[0];
 | ||
|     _anno   = _m->get_int(F_ANNO);
 | ||
|     _order  = _m->get(F_DATA_O_NUM)[0] == 'N' ? num_doc : data_doc;
 | ||
|     _from_ndoc = _m->get_long(F_NDOCFROM);
 | ||
|     _to_ndoc   = _m->get_long(F_NDOCTO);
 | ||
|     _from_date = _m->get_date(F_EMISFROM);
 | ||
|     _to_date   = _m->get_date(F_EMISTO);
 | ||
|     _from_cons = _m->get_date(F_CONSFROM);
 | ||
|     _to_cons   = _m->get_date(F_CONSTO);
 | ||
|     _from_age  = _m->get(F_AGEFROM);
 | ||
|     _to_age    = _m->get(F_AGETO);
 | ||
|     _from_cf   = _m->get_long(F_CFFROM);
 | ||
|     _to_cf     = _m->get_long(F_CFTO);
 | ||
|     _from_mag  = _m->get(F_MAGFROM);
 | ||
|     _to_mag    = _m->get(F_MAGTO);
 | ||
|     _from_dep  = _m->get(F_DEPFROM);
 | ||
|     _to_dep    = _m->get(F_DEPTO);
 | ||
|     if (_from_mag.not_empty())
 | ||
|       _from_mag.left_just(3);
 | ||
|     if (_to_mag.not_empty())
 | ||
|       _to_mag.left_just(3);
 | ||
|     _from_mag << _from_dep;
 | ||
|     _to_mag << _to_dep;
 | ||
|     
 | ||
|     _from_art    = _m->get(F_ARTFROM);
 | ||
|     _to_art      = _m->get(F_ARTTO);
 | ||
|     _from_cat    = _m->get(F_CATMERFROM);
 | ||
|     _to_cat      = _m->get(F_CATMERTO);
 | ||
|     
 | ||
|     _from_giac.destroy();
 | ||
|     _to_giac.destroy();
 | ||
|     _from_giac.add(_m->get(F_GIAC1_FROM),0);
 | ||
|     _to_giac.add(_m->get(F_GIAC1_TO),0);
 | ||
|     _from_giac.add(_m->get(F_GIAC2_FROM),1);
 | ||
|     _to_giac.add(_m->get(F_GIAC2_TO),1);
 | ||
|     _from_giac.add(_m->get(F_GIAC3_FROM),2);
 | ||
|     _to_giac.add(_m->get(F_GIAC3_TO),2);
 | ||
|     _from_giac.add(_m->get(F_GIAC4_FROM),3);
 | ||
|     _to_giac.add(_m->get(F_GIAC4_TO),3);
 | ||
|     
 | ||
|     if (!_from_date.ok())
 | ||
|       _from_date = botime;
 | ||
|     if (!_to_date.ok())
 | ||
|       _to_date = eotime;
 | ||
|     _tipocf        = _m->get(F_TIPOCF)[0];
 | ||
|     _detail_rows   = _m->get_bool(F_DETTAGLIO);
 | ||
|     _detail_doc    = _m->get_bool(F_DETAIL_BY_DOC);
 | ||
|     _detail_cli    = _m->get_bool(F_DETAIL_BY_CLI);
 | ||
|     _detail_mag    = _m->get_bool(F_DETAIL_MAG);
 | ||
|     _detail_dep    = _m->get_bool(F_DETAIL_DEP);
 | ||
|     _detail_level  = _m->get_int(F_DETAIL_LEV);
 | ||
|     
 | ||
|     _pr_spese      = _m->get_bool(F_PRINTSPESE);
 | ||
|     _pr_prest      = _m->get_bool(F_PRINTPREST);
 | ||
|     _pr_sconti     = _m->get_bool(F_PRINTSCONTI);
 | ||
|     _pr_omaggi     = _m->get_bool(F_PRINTOMAGGI);
 | ||
|     _pr_descr      = _m->get_bool(F_PRINTDESCR);
 | ||
|     
 | ||
|     _opz_valore    = _m->get_bool(F_OPZ_VALORE);
 | ||
|     _opz_prezzo    = _m->get_bool(F_OPZ_PREZZO);
 | ||
|     _opz_residuo   = _m->get_bool(F_OPZ_RESIDUO);
 | ||
|     _opz_giacenza  = _m->get_bool(F_OPZ_GIACENZA);
 | ||
|     
 | ||
|     _force_evase   = _m->get_bool(F_FORCE_EVASE);
 | ||
| 
 | ||
|     _TEA_ord     = _m->get(F_STATOORD)[0];
 | ||
|     _TEA_rord    = _m->get(F_STATORORD)[0];
 | ||
|     
 | ||
|     switch (_tipo)
 | ||
|     {
 | ||
|       case clifo:
 | ||
|         form_name = "or1100bp";
 | ||
|         break;
 | ||
|       case agente:
 | ||
|         form_name = "or1100c";
 | ||
|         break;
 | ||
|       case articolo: 
 | ||
|         form_name = "or1100d";
 | ||
|         break;
 | ||
|       case datacons: 
 | ||
|         form_name = "or1100ep";
 | ||
|         break;
 | ||
|       default:
 | ||
|         form_name = "or1100a";
 | ||
|         break;
 | ||
|     }
 | ||
|     
 | ||
|     _frm = new TOrdine_form(form_name);
 | ||
|     _frm->set_options(_detail_level, _detail_mag, _detail_dep);
 | ||
|     // Selezione cursore & filtro
 | ||
|     switch (_tipo)
 | ||
|     {
 | ||
|       case clifo:
 | ||
|       case agente:
 | ||
|       case datacons:
 | ||
|         filter_for_clifo_agent();
 | ||
|         break;
 | ||
|       case articolo:
 | ||
|         filter_for_articolo();
 | ||
|         break;
 | ||
|       default:
 | ||
|         filter_for_number();
 | ||
|         break;
 | ||
|     }
 | ||
|     
 | ||
|     
 | ||
|     const int hh = 6;
 | ||
|     const int fl = printer().formlen();
 | ||
|     
 | ||
|     int rows[4];         // Righe orizzontali
 | ||
|     rows[0] = hh-2;
 | ||
|     rows[1] = hh;
 | ||
|     rows[2] = fl;
 | ||
|     rows[3] = 0;
 | ||
|     _frm->genera_intestazioni(odd_page, hh-1);
 | ||
|     _frm->genera_fincatura(odd_page, hh-2, fl, rows);
 | ||
|     
 | ||
|     // Crea il cursore
 | ||
|     if (_frm->cursor()->items() > 0)
 | ||
|     {
 | ||
|       // Sostituzione curr del cursore
 | ||
|       TCursor* cur = _frm->cursor();
 | ||
|       TDocumento *doc = new TDocumento; // Don't delete!
 | ||
|   
 | ||
|       cur->file(LF_DOC).set_curr(doc);
 | ||
|       cur->file(LF_RIGHEDOC).set_curr(new TRiga_documento(doc));// Don't delete!
 | ||
| 
 | ||
|       // stampa
 | ||
|       _frm->print();
 | ||
|     }
 | ||
|     delete _frm;
 | ||
|   }
 | ||
| }
 | ||
| 
 | ||
| int or1100(int argc, char** argv)
 | ||
| {
 | ||
|   TStampa_ordini a;
 | ||
|   a.run(argc,argv,TR("Stampa ordini"));
 | ||
|   return 0;
 | ||
| }
 |