Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@21807 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									bb5905b448
								
							
						
					
					
						commit
						a43ea43565
					
				
							
								
								
									
										104
									
								
								ha/ha2100.cpp
									
									
									
									
									
								
							
							
						
						
									
										104
									
								
								ha/ha2100.cpp
									
									
									
									
									
								
							@ -5,6 +5,7 @@
 | 
				
			|||||||
#include <recset.h>
 | 
					#include <recset.h>
 | 
				
			||||||
#include <reputils.h>
 | 
					#include <reputils.h>
 | 
				
			||||||
#include <textset.h>
 | 
					#include <textset.h>
 | 
				
			||||||
 | 
					#include <utility.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <doc.h>
 | 
					#include <doc.h>
 | 
				
			||||||
#include <rdoc.h>
 | 
					#include <rdoc.h>
 | 
				
			||||||
@ -17,23 +18,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const char* const APPNAME = TR("Esselunga: generazione file Privat"); 
 | 
					const char* const APPNAME = TR("Esselunga: generazione file Privat"); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
// TEsselunga_recordset: serve per potre scrivere il primo record che e' diverso dagli altri
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					 | 
				
			||||||
class TEsselunga_recordset : public TAS400_recordset
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
protected:
 | 
					 | 
				
			||||||
  //esportazione
 | 
					 | 
				
			||||||
  void add_field(const char* name, const char* tipo, int pos, int len);
 | 
					 | 
				
			||||||
  void insert_field(const char* name, const char* tipo, int pos, int len);
 | 
					 | 
				
			||||||
  void add_eol_field();
 | 
					 | 
				
			||||||
  //importazione
 | 
					 | 
				
			||||||
  void add_trc_field(const char* tr, const char* name, const char* tipo, int pos, int len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	TEsselunga_recordset(const int rec_length);
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
// TAutomask
 | 
					// TAutomask
 | 
				
			||||||
///////////////////////////////////////////////////////////
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
@ -119,7 +103,7 @@ public:
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TPrivat_recordset::TPrivat_recordset()
 | 
					TPrivat_recordset::TPrivat_recordset()
 | 
				
			||||||
: TAS400_recordset("AS400(51)")
 | 
					: TAS400_recordset("AS400(53)")
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	create_field("CDC",				-1, 3,  _intfld);		// centro di costo
 | 
						create_field("CDC",				-1, 3,  _intfld);		// centro di costo
 | 
				
			||||||
	create_field("CODART",		-1, 6,  _longfld);	  // codice articolo
 | 
						create_field("CODART",		-1, 6,  _longfld);	  // codice articolo
 | 
				
			||||||
@ -130,6 +114,7 @@ TPrivat_recordset::TPrivat_recordset()
 | 
				
			|||||||
	create_field("QTACONS",		-1, 7,  _realfld);		// qta consegnata
 | 
						create_field("QTACONS",		-1, 7,  _realfld);		// qta consegnata
 | 
				
			||||||
	create_field("QTARESA",	  -1, 7,  _realfld);		// qta resa
 | 
						create_field("QTARESA",	  -1, 7,  _realfld);		// qta resa
 | 
				
			||||||
	create_field("CODDIP",		-1, 1,  _alfafld);		// codice dipendenza
 | 
						create_field("CODDIP",		-1, 1,  _alfafld);		// codice dipendenza
 | 
				
			||||||
 | 
						create_field("FINE-REC",  -1, 2, _alfafld, true, TVariant("\r\n")); // a capo
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///////////////////////////////////////
 | 
					///////////////////////////////////////
 | 
				
			||||||
@ -141,7 +126,8 @@ protected:
 | 
				
			|||||||
  long genera_recordset(const TMask& mask, TISAM_recordset& recset);
 | 
					  long genera_recordset(const TMask& mask, TISAM_recordset& recset);
 | 
				
			||||||
  void elabora(const TMask& mask);
 | 
					  void elabora(const TMask& mask);
 | 
				
			||||||
  void check_date(const TDate& datafine, TDate& dataini);
 | 
					  void check_date(const TDate& datafine, TDate& dataini);
 | 
				
			||||||
  long check_cliente(const long codcf);
 | 
					  long check_cliente(const long codcf, const TString4 dipendenza);
 | 
				
			||||||
 | 
						TFilename scrivi_testata(const TMask& mask);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  virtual void main_loop();
 | 
					  virtual void main_loop();
 | 
				
			||||||
@ -202,22 +188,45 @@ long THardy_esselunga::genera_recordset(const TMask& mask, TISAM_recordset& recs
 | 
				
			|||||||
  recset.set_var("#DATAFIN", datafin);
 | 
					  recset.set_var("#DATAFIN", datafin);
 | 
				
			||||||
  return recset.items();
 | 
					  return recset.items();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					TFilename THardy_esselunga::scrivi_testata(const TMask& mask)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const TString4 dipendenza = mask.get(F_DIPENDENZA);
 | 
				
			||||||
 | 
						TConfig config(CONFIG_DITTA, "ha");
 | 
				
			||||||
 | 
						TFilename file_privat = config.get("Esselunga_Path");
 | 
				
			||||||
 | 
						if (dipendenza[0] == 'D')
 | 
				
			||||||
 | 
							file_privat.add("CDMI");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							file_privat.add("CDFI");
 | 
				
			||||||
 | 
						file_privat.ext("txt");
 | 
				
			||||||
 | 
					  ofstream file_output(file_privat);
 | 
				
			||||||
 | 
						TString record(260);
 | 
				
			||||||
 | 
						// tipo record/filler/tot_record/progr_record
 | 
				
			||||||
 | 
						record = "PVT*?*001001";
 | 
				
			||||||
 | 
						// nome del file
 | 
				
			||||||
 | 
						record << file_privat.name();
 | 
				
			||||||
 | 
						// identificativo mittente
 | 
				
			||||||
 | 
						record.overwrite(config.get("Esselunga_PIvaEsselunga"), 85);
 | 
				
			||||||
 | 
						record.overwrite(config.get("Esselunga_TipoEmissione"), 120);
 | 
				
			||||||
 | 
						// identificativo destinatario
 | 
				
			||||||
 | 
						record.overwrite(config.get("Esselunga_PIvaHardy"), 138);
 | 
				
			||||||
 | 
						record.overwrite(config.get("Esselunga_TipoEmissione"), 173);
 | 
				
			||||||
 | 
						// formato (Ascii)
 | 
				
			||||||
 | 
						record.overwrite("A", 191);
 | 
				
			||||||
 | 
						// identificativo univoco del documento
 | 
				
			||||||
 | 
						record.overwrite("0000000000000001", 243);
 | 
				
			||||||
 | 
					  file_output << record << endl;
 | 
				
			||||||
 | 
					  file_output.close();
 | 
				
			||||||
 | 
						return file_privat;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void THardy_esselunga::elabora(const TMask& mask)
 | 
					void THardy_esselunga::elabora(const TMask& mask)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	TLog_report log;
 | 
						TLog_report log;
 | 
				
			||||||
	// lettura dei dati fissi da configurazione
 | 
						// lettura dei dati fissi da configurazione
 | 
				
			||||||
	TConfig config(CONFIG_DITTA, "ha");
 | 
						TConfig config(CONFIG_DITTA, "ha");
 | 
				
			||||||
	const TString16 piva_esselunga = config.get("Esselunga_PIvaEsselunga");
 | 
					 | 
				
			||||||
	const TString16 piva_hardy = config.get("Esselunga_PIvaHardy");
 | 
					 | 
				
			||||||
	const TString16 cod_hardy = config.get("Esselunga_CodHardy");
 | 
						const TString16 cod_hardy = config.get("Esselunga_CodHardy");
 | 
				
			||||||
	const TString16 tipo_emissione = config.get("Esselunga_TipoEmissione");
 | 
					 | 
				
			||||||
	const TString4 dipendenza = mask.get(F_DIPENDENZA);
 | 
						const TString4 dipendenza = mask.get(F_DIPENDENZA);
 | 
				
			||||||
	TFilename file_privat = config.get("Esselunga_Path");
 | 
						TFilename file_privat = scrivi_testata(mask);
 | 
				
			||||||
	if (dipendenza[0] == 'D')
 | 
					 | 
				
			||||||
		file_privat.add("CDMI");
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		file_privat.add("CDFI");
 | 
					 | 
				
			||||||
  TISAM_recordset recset("");
 | 
					  TISAM_recordset recset("");
 | 
				
			||||||
  const long items = genera_recordset(mask, recset);
 | 
					  const long items = genera_recordset(mask, recset);
 | 
				
			||||||
  if (items == 0)
 | 
					  if (items == 0)
 | 
				
			||||||
@ -242,33 +251,46 @@ void THardy_esselunga::elabora(const TMask& mask)
 | 
				
			|||||||
				TString80 codart_esselunga = ""; // decodifica tramite cache()
 | 
									TString80 codart_esselunga = ""; // decodifica tramite cache()
 | 
				
			||||||
				privat.new_rec("");
 | 
									privat.new_rec("");
 | 
				
			||||||
				privat.set("CDC", TVariant(codcf_esselunga));
 | 
									privat.set("CDC", TVariant(codcf_esselunga));
 | 
				
			||||||
				/*
 | 
									privat.set("CODART", rigadoc->get(RDOC_CODART));
 | 
				
			||||||
				privat.set("CODART",		
 | 
									privat.set("CODFORN",	cod_hardy);	
 | 
				
			||||||
				privat.set("CODFORN",		
 | 
									//privat.set("TIPOBOLLA", 
 | 
				
			||||||
				privat.set("TIPOBOLLA", 
 | 
									//privat.set("NUMBOLLA",	
 | 
				
			||||||
				privat.set("NUMBOLLA",	
 | 
									privat.set("DATABOLLA", recset.get(DOC_DATADOC));
 | 
				
			||||||
				privat.set("DATABOLLA", 
 | 
									privat.set("QTACONS", rigadoc->get(RDOC_QTA));		
 | 
				
			||||||
				privat.set("QTACONS",		
 | 
									//privat.set("QTARESA",);  
 | 
				
			||||||
				privat.set("QTARESA",	  
 | 
					 | 
				
			||||||
				*/
 | 
					 | 
				
			||||||
				privat.set("CODDIP", TVariant(dipendenza));
 | 
									privat.set("CODDIP", TVariant(dipendenza));
 | 
				
			||||||
			} //FOR_EACH...
 | 
								} //FOR_EACH...
 | 
				
			||||||
			delete doc;
 | 
								delete doc;
 | 
				
			||||||
		} // if check_cliente...
 | 
							} // if check_cliente...
 | 
				
			||||||
  } //for (bool ok = recset.move_first()...
 | 
					  } //for (bool ok = recset.move_first()...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //se elaborazione definitiva -> cambia lo stato ai documenti di vendita elaborati, mettendolo uguale..
 | 
						TFilename tempfile;
 | 
				
			||||||
  //..a quello deciso in configurazione
 | 
						tempfile.temp();
 | 
				
			||||||
  const bool definitivo = mask.get_bool(F_DEFINITIVO);
 | 
						privat.save_as(tempfile, fmt_text);
 | 
				
			||||||
 | 
						fcopy(tempfile, file_privat, true);
 | 
				
			||||||
 | 
						// memorizzo su campo virtuale che il doc. e' stato inviato
 | 
				
			||||||
 | 
						const bool definitivo = mask.get_bool(F_DEFINITIVO);
 | 
				
			||||||
  if (definitivo)
 | 
					  if (definitivo)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  log.print_or_preview();
 | 
					  log.print_or_preview();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
long THardy_esselunga::check_cliente(const long codcf)
 | 
					long THardy_esselunga::check_cliente(const long codcf, const TString4 dipendenza)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return true;
 | 
						long codcf_hardy = -1;
 | 
				
			||||||
 | 
						TString key;
 | 
				
			||||||
 | 
						key.format("%ld", codcf);
 | 
				
			||||||
 | 
						const TRectype rec_cliente = cache().get("&CEL", key);
 | 
				
			||||||
 | 
						const bool invio = rec_cliente.get_bool("B0");
 | 
				
			||||||
 | 
						if (invio)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							const char dip_cliente = rec_cliente.get("S1")[0];
 | 
				
			||||||
 | 
							if (dip_cliente == dipendenza[0])
 | 
				
			||||||
 | 
								codcf_hardy = rec_cliente.get_long("I0");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return codcf_hardy;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void THardy_esselunga::main_loop()
 | 
					void THardy_esselunga::main_loop()
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user