Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 766 git-svn-id: svn://10.65.10.50/trunk@14628 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			181 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			181 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <progind.h>
 | |
| #include <relation.h>
 | |
| #include <recarray.h>
 | |
| #include <reprint.h>
 | |
| 
 | |
| #include "../mg/anamag.h"
 | |
| #include <clifo.h>
 | |
| #include <comuni.h>
 | |
| #include <indsp.h>
 | |
| #include <doc.h>
 | |
| #include <rdoc.h> 
 | |
| 
 | |
| #include "pd0350.h"
 | |
| 
 | |
| //////////////////////////////
 | |
| //	APPLICAZIONE
 | |
| //////////////////////////////
 | |
| class TPrint_consegnato_pd0351 : public TSkeleton_application  
 | |
| {
 | |
| 	TExternisamfile* _tmp;
 | |
| 
 | |
| 	virtual bool check_autorization() const {return false;}
 | |
|   virtual const char * extra_modules() const {return "ve";}
 | |
| 
 | |
| protected:
 | |
| 	void crea_trr(const TFilename& trr) const;
 | |
| 	void compila_dati_da_testata(TRectype& rec);
 | |
| 	void fill_tempfile();
 | |
| 	void kill_tempfile();
 | |
| 
 | |
| public:
 | |
| 	virtual void main_loop();
 | |
| };
 | |
| 
 | |
| void TPrint_consegnato_pd0351::crea_trr(const TFilename& trr) const
 | |
| {
 | |
| 	ofstream of(trr);
 | |
| 	of << 1000 << endl;
 | |
| 	of << 11 << endl;
 | |
| 	of << "GRMERC|1|5|0|Codice gruppo merceologico" << endl;
 | |
| 	of << "REGIONE|1|2|0|Regione" << endl;
 | |
| 	of << "PROVINCIA|1|2|0|Provincia" << endl;
 | |
| 	of << "NDOC|3|7|0|Numero documento" << endl;
 | |
| 	of << "NRIGA|2|3|0|Numero riga" << endl;
 | |
| 	of << "DATADOC|5|8|0|Data documento" << endl;
 | |
| 	of << "CODNUM|1|4|0|Numerazione riga documento" << endl;
 | |
| 	of << "ANNO|2|4|0|Anno" << endl;
 | |
| 	of << "PROVV|1|1|0|Documento provvisiorio/definitivo" << endl;
 | |
| 	of << "DESCR|1|50|0|Descrizione articolo" << endl;
 | |
| 	of << "QTA|4|15|5|Quantita'" << endl;
 | |
| 	of << 1 << endl;
 | |
| 	of << "GRMERC+REGIONE+PROVINCIA+NDOC+NRIGA" << endl;
 | |
| }
 | |
| 
 | |
| void TPrint_consegnato_pd0351::compila_dati_da_testata(TRectype& rec)
 | |
| {
 | |
|   TString4 stato, comune;
 | |
| 
 | |
| 	//dalla riga documento ricava la testata
 | |
| 	TToken_string chiave;
 | |
| 	chiave = rec.get(RDOC_PROVV);
 | |
| 	chiave.add(rec.get_int(RDOC_ANNO));
 | |
| 	chiave.add(rec.get(RDOC_CODNUM));
 | |
| 	chiave.add(rec.get_long(RDOC_NDOC));
 | |
| 	const TRectype& rec_doc = cache().get(LF_DOC, chiave);
 | |
| 	//intanto prendiamo datadoc
 | |
| 	rec.put("DATADOC", rec_doc.get_date(DOC_DATADOC));
 | |
| 
 | |
| 	//dalla testata prendiamo indsped
 | |
| 	const TString4 codindsp = rec_doc.get(DOC_CODINDSP);
 | |
| 	if (codindsp.full())
 | |
| 	{
 | |
| 		chiave = rec_doc.get(DOC_TIPOCF);
 | |
| 		chiave.add(rec_doc.get(DOC_CODCF));
 | |
| 		chiave.add(codindsp);
 | |
| 		const TRectype& rec_indsp = cache().get(LF_INDSP, chiave);
 | |
| 		stato = rec_indsp.get(IND_STATO);
 | |
| 		comune = rec_indsp.get(IND_COM);
 | |
| 	}
 | |
| 	if (comune.empty())
 | |
| 	{
 | |
| 		chiave = rec_doc.get(DOC_TIPOCF);
 | |
| 		chiave.add(rec_doc.get(DOC_CODCF));
 | |
| 		const TRectype& rec_clifo = cache().get(LF_CLIFO, chiave);
 | |
| 		stato = rec_clifo.get(CLI_STATOCF);
 | |
| 		comune = rec_clifo.get(CLI_COMCF);
 | |
| 	}
 | |
| 
 | |
| 	//finalmente puo' cercare il comune sul file dedicato
 | |
| 	chiave = stato;
 | |
| 	chiave.add(comune, 1);
 | |
| 	const TRectype& rec_comuni = cache().get(LF_COMUNI, chiave);
 | |
| 	rec.put("PROVINCIA", rec_comuni.get(COM_PROVCOM));
 | |
| 	rec.put("REGIONE", rec_comuni.get(COM_CODREG));
 | |
| }
 | |
| 
 | |
| void TPrint_consegnato_pd0351::fill_tempfile()
 | |
| {
 | |
| 	//se esiste il file temporano con tracciato persomalizzato lo cancella e lo ricrea vuoto
 | |
|   TFilename trr;
 | |
| 	trr.tempdir();
 | |
| 	trr.add("pd0351");
 | |
| 	TFilename dbf(trr);
 | |
|   trr.ext("trr");   
 | |
| 	dbf.ext("dbf");	
 | |
| 	//crea il file .trr in base ai parametri del metodo
 | |
| 	crea_trr(trr);
 | |
| 
 | |
| 	//crea in memoria il nuovo file temporaneo e lo azzera (non si sa mai..)
 | |
| 	_tmp = new TExternisamfile(dbf, trr);
 | |
| 	_tmp->zap();
 | |
| 
 | |
| 	TISAM_recordset rdoc("USE RDOC\nSELECT (TIPORIGA='01')&&(PROVV='D')\nFROM CODNUM='B'\nTO CODNUM='B'");
 | |
| 	TRectype& rec_tmp = _tmp->curr();
 | |
| 
 | |
| 	TProgind pi(rdoc.items(), "Creazione statistiche in corso.Attendere prego...", true, true);
 | |
| 
 | |
| 	for (bool ok = rdoc.move_first(); ok; ok = rdoc.move_next())
 | |
| 	{
 | |
| 		if (!pi.addstatus(1))
 | |
| 			break;
 | |
| 
 | |
| 		const real qta = rdoc.get(RDOC_QTA).as_real();
 | |
| 		if (qta != ZERO)
 | |
| 		{
 | |
| 			rec_tmp.put("QTA", qta);
 | |
| 			rec_tmp.put("CODNUM", rdoc.get(RDOC_CODNUM).as_string());
 | |
| 			rec_tmp.put("ANNO", rdoc.get(RDOC_ANNO).as_string());
 | |
| 			rec_tmp.put("PROVV", rdoc.get(RDOC_PROVV).as_string());
 | |
| 			rec_tmp.put("NDOC", rdoc.get(RDOC_NDOC).as_string());
 | |
| 			rec_tmp.put("NRIGA", rdoc.get(RDOC_NRIGA).as_string());
 | |
| 
 | |
| 			//codice e descrizione gruppo merceologico
 | |
| 			const TString& codartmag = rdoc.get("CODARTMAG").as_string();
 | |
| 			//cerchiamo 'sto gruppo merceologiccco..
 | |
| 			const TString grmerc = cache().get(LF_ANAMAG, codartmag, ANAMAG_GRMERC);
 | |
| 			//..e la sua descrizione
 | |
| 			rec_tmp.put("GRMERC", grmerc);
 | |
| 			rec_tmp.put("DESCR", cache().get("GMC", grmerc, "S0"));
 | |
| 
 | |
| 			//ricava datadoc,comune,provincia,regione,nazione,continente,pianeta...
 | |
| 			compila_dati_da_testata(rec_tmp);
 | |
| 
 | |
| 			//scrive il record sul file
 | |
| 			_tmp->write();
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| void TPrint_consegnato_pd0351::kill_tempfile()
 | |
| {
 | |
| 	delete _tmp;
 | |
| 	_tmp = NULL;
 | |
| }
 | |
| 
 | |
| void TPrint_consegnato_pd0351::main_loop()
 | |
| {
 | |
| 	fill_tempfile();
 | |
| 	bool ok = true;
 | |
| 	while (ok)
 | |
| 	{
 | |
| 		TReport rep;
 | |
| 		ok = rep.load("pd0351_consline");
 | |
| 		if (ok)
 | |
| 		{
 | |
| 			TReport_book book;
 | |
| 			ok = book.add(rep);
 | |
| 			if (ok)
 | |
| 				book.print_or_preview();
 | |
| 		}
 | |
| 	}
 | |
| 	kill_tempfile();
 | |
| }
 | |
| 
 | |
| int pd0350200(int argc, char* argv[])
 | |
| {
 | |
|   TPrint_consegnato_pd0351 a;
 | |
|   a.run(argc, argv, "Stampa consegnato per linea/regione/provincia");
 | |
|   return 0;
 | |
| } |