Patch level : 2.2
Files correlati : ve0 Ricompilazione Demo : [ ] Commento : Aggiunta libreria per gestire stampa di documenti tramite report git-svn-id: svn://10.65.10.50/trunk@13176 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									ec052542f4
								
							
						
					
					
						commit
						ec3e3658a5
					
				@ -160,28 +160,28 @@ DESCRFAS        = S_NORMALE                     //3000
 | 
			
		||||
[DEFAULT]
 | 
			
		||||
 | 
			
		||||
[SHEET]
 | 
			
		||||
Col(1)=FR_CODMAG
 | 
			
		||||
Col(2)=FR_CODDEP
 | 
			
		||||
Col(3)=FR_CODART
 | 
			
		||||
Col(4)=FR_LIV1
 | 
			
		||||
Col(5)=FR_LIV2
 | 
			
		||||
Col(6)=FR_LIV3
 | 
			
		||||
Col(7)=FR_LIV4
 | 
			
		||||
Col(8)=FR_DESCR
 | 
			
		||||
Col(9)=FR_UMQTA
 | 
			
		||||
Col(10)=FR_QTA
 | 
			
		||||
Col(11)=FR_PREZZO
 | 
			
		||||
Col(12)=FR_SCONTO
 | 
			
		||||
Col(13)=FR_PERCPROV
 | 
			
		||||
Col(14)=FR_IMPFISUN
 | 
			
		||||
Col(15)=FR_IMPFISSO
 | 
			
		||||
Col(16)=FR_CODIVA
 | 
			
		||||
Col(17)=FR_ADDIVA
 | 
			
		||||
Col(18)=FR_CAUS
 | 
			
		||||
Col(19)=FR_CODMAGC
 | 
			
		||||
Col(20)=FR_CODDEPC
 | 
			
		||||
Col(21)=FR_CODCMS
 | 
			
		||||
Col(22)=FR_FASCMS
 | 
			
		||||
Col(0)=FR_CODMAG
 | 
			
		||||
Col(1)=FR_CODDEP
 | 
			
		||||
Col(2)=FR_CODART
 | 
			
		||||
Col(3)=FR_LIV1
 | 
			
		||||
Col(4)=FR_LIV2
 | 
			
		||||
Col(5)=FR_LIV3
 | 
			
		||||
Col(6)=FR_LIV4
 | 
			
		||||
Col(7)=FR_DESCR
 | 
			
		||||
Col(8)=FR_UMQTA
 | 
			
		||||
Col(9)=FR_QTA
 | 
			
		||||
Col(10)=FR_PREZZO
 | 
			
		||||
Col(11)=FR_SCONTO
 | 
			
		||||
Col(12)=FR_PERCPROV
 | 
			
		||||
Col(13)=FR_IMPFISUN
 | 
			
		||||
Col(14)=FR_IMPFISSO
 | 
			
		||||
Col(15)=FR_CODIVA
 | 
			
		||||
Col(16)=FR_ADDIVA
 | 
			
		||||
Col(17)=FR_CAUS
 | 
			
		||||
Col(18)=FR_CODMAGC
 | 
			
		||||
Col(19)=FR_CODDEPC
 | 
			
		||||
Col(20)=FR_CODCMS
 | 
			
		||||
Col(21)=FR_FASCMS
 | 
			
		||||
 | 
			
		||||
[RIGHE]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -159,31 +159,31 @@ NOTECLI         = S_NOCHECK                     //2500
 | 
			
		||||
Default(0)=F_CAUSTRASP|VEN
 | 
			
		||||
 | 
			
		||||
[SHEET]
 | 
			
		||||
Col(1)=FR_CODMAG
 | 
			
		||||
Col(2)=FR_CODDEP
 | 
			
		||||
Col(3)=FR_CODART
 | 
			
		||||
Col(4)=FR_LIV1
 | 
			
		||||
Col(5)=FR_LIV2
 | 
			
		||||
Col(6)=FR_LIV3
 | 
			
		||||
Col(7)=FR_LIV4
 | 
			
		||||
Col(8)=FR_DESCR
 | 
			
		||||
Col(9)=FR_UMQTA
 | 
			
		||||
Col(10)=FR_QTA
 | 
			
		||||
Col(11)=FR_PREZZO
 | 
			
		||||
Col(12)=FR_SCONTO
 | 
			
		||||
Col(13)=FR_PERCPROV
 | 
			
		||||
Col(14)=FR_IMPFISUN
 | 
			
		||||
Col(15)=FR_IMPFISSO
 | 
			
		||||
Col(16)=FR_CODIVA
 | 
			
		||||
Col(17)=FR_ADDIVA
 | 
			
		||||
Col(18)=FR_NCOLLI
 | 
			
		||||
Col(19)=FR_PNETTO
 | 
			
		||||
Col(20)=FR_TARA
 | 
			
		||||
Col(21)=FR_CAUS
 | 
			
		||||
Col(22)=FR_CODMAGC
 | 
			
		||||
Col(23)=FR_CODDEPC
 | 
			
		||||
Col(24)=FR_CODCMS
 | 
			
		||||
Col(25)=FR_FASCMS
 | 
			
		||||
Col(0)=FR_CODMAG
 | 
			
		||||
Col(1)=FR_CODDEP
 | 
			
		||||
Col(2)=FR_CODART
 | 
			
		||||
Col(3)=FR_LIV1
 | 
			
		||||
Col(4)=FR_LIV2
 | 
			
		||||
Col(5)=FR_LIV3
 | 
			
		||||
Col(6)=FR_LIV4
 | 
			
		||||
Col(7)=FR_DESCR
 | 
			
		||||
Col(8)=FR_UMQTA
 | 
			
		||||
Col(9)=FR_QTA
 | 
			
		||||
Col(10)=FR_PREZZO
 | 
			
		||||
Col(11)=FR_SCONTO
 | 
			
		||||
Col(12)=FR_PERCPROV
 | 
			
		||||
Col(13)=FR_IMPFISUN
 | 
			
		||||
Col(14)=FR_IMPFISSO
 | 
			
		||||
Col(15)=FR_CODIVA
 | 
			
		||||
Col(16)=FR_ADDIVA
 | 
			
		||||
Col(17)=FR_NCOLLI
 | 
			
		||||
Col(18)=FR_PNETTO
 | 
			
		||||
Col(19)=FR_TARA
 | 
			
		||||
Col(20)=FR_CAUS
 | 
			
		||||
Col(21)=FR_CODMAGC
 | 
			
		||||
Col(22)=FR_CODDEPC
 | 
			
		||||
Col(23)=FR_CODCMS
 | 
			
		||||
Col(24)=FR_FASCMS
 | 
			
		||||
 | 
			
		||||
[RIGHE]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -132,26 +132,26 @@ BLANK           = S_DISABILITATO                //4000
 | 
			
		||||
[DEFAULT]
 | 
			
		||||
 | 
			
		||||
[SHEET]
 | 
			
		||||
Col(1)=FR_CODMAG
 | 
			
		||||
Col(2)=FR_CODDEP
 | 
			
		||||
Col(3)=FR_CODART
 | 
			
		||||
Col(4)=FR_LIV1
 | 
			
		||||
Col(5)=FR_LIV2
 | 
			
		||||
Col(6)=FR_LIV3
 | 
			
		||||
Col(7)=FR_LIV4
 | 
			
		||||
Col(8)=FR_DESCR
 | 
			
		||||
Col(9)=FR_UMQTA
 | 
			
		||||
Col(10)=FR_QTA
 | 
			
		||||
Col(11)=FR_PREZZO
 | 
			
		||||
Col(12)=FR_SCONTO
 | 
			
		||||
Col(13)=FR_PERCPROV
 | 
			
		||||
Col(14)=FR_IMPFISUN
 | 
			
		||||
Col(15)=FR_IMPFISSO
 | 
			
		||||
Col(16)=FR_CODIVA
 | 
			
		||||
Col(17)=FR_ADDIVA
 | 
			
		||||
Col(18)=FR_CAUS
 | 
			
		||||
Col(19)=FR_CODMAGC
 | 
			
		||||
Col(20)=FR_CODDEPC
 | 
			
		||||
Col(0)=FR_CODMAG
 | 
			
		||||
Col(1)=FR_CODDEP
 | 
			
		||||
Col(2)=FR_CODART
 | 
			
		||||
Col(3)=FR_LIV1
 | 
			
		||||
Col(4)=FR_LIV2
 | 
			
		||||
Col(5)=FR_LIV3
 | 
			
		||||
Col(6)=FR_LIV4
 | 
			
		||||
Col(7)=FR_DESCR
 | 
			
		||||
Col(8)=FR_UMQTA
 | 
			
		||||
Col(9)=FR_QTA
 | 
			
		||||
Col(10)=FR_PREZZO
 | 
			
		||||
Col(11)=FR_SCONTO
 | 
			
		||||
Col(12)=FR_PERCPROV
 | 
			
		||||
Col(13)=FR_IMPFISUN
 | 
			
		||||
Col(14)=FR_IMPFISSO
 | 
			
		||||
Col(15)=FR_CODIVA
 | 
			
		||||
Col(16)=FR_ADDIVA
 | 
			
		||||
Col(17)=FR_CAUS
 | 
			
		||||
Col(18)=FR_CODMAGC
 | 
			
		||||
Col(19)=FR_CODDEPC
 | 
			
		||||
 | 
			
		||||
[RIGHE]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										135
									
								
								ve/ve1400.cpp
									
									
									
									
									
								
							
							
						
						
									
										135
									
								
								ve/ve1400.cpp
									
									
									
									
									
								
							@ -6,13 +6,14 @@
 | 
			
		||||
#include <utility.h>
 | 
			
		||||
 | 
			
		||||
#include "velib.h"
 | 
			
		||||
#include "vereplib.h"
 | 
			
		||||
#include "../ba/ba8400.h"
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// Utility
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
bool cod2app(const char* tok, TString& app)
 | 
			
		||||
static bool cod2app(const char* tok, TString& app)
 | 
			
		||||
{
 | 
			
		||||
  if (isalpha(tok[0]) && isalpha(tok[1]) && atoi(tok+2) > 1000)
 | 
			
		||||
  {
 | 
			
		||||
@ -23,7 +24,7 @@ bool cod2app(const char* tok, TString& app)
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool get_xml_attr(const TString& line, const char* attr, TString& value)
 | 
			
		||||
static bool get_xml_attr(const TString& line, const char* attr, TString& value)
 | 
			
		||||
{
 | 
			
		||||
  TString str; str << ' ' << attr << "=\"";
 | 
			
		||||
  const int pos = line.find(str);
 | 
			
		||||
@ -40,7 +41,7 @@ bool get_xml_attr(const TString& line, const char* attr, TString& value)
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool get_xml_child(const TString& line, const char* tag, TString& value)
 | 
			
		||||
static bool get_xml_child(const TString& line, const char* tag, TString& value)
 | 
			
		||||
{
 | 
			
		||||
  TString str; str << '<' << tag << '>';
 | 
			
		||||
  const int pos = line.find(str);
 | 
			
		||||
@ -85,134 +86,6 @@ bool rep2app(const char* name, TString& app, TString& desc)
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_cache
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
class TDocument_cache : TCache
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  virtual TObject* key2obj(const char* key);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  TDocumento& doc(const TRectype& rec);
 | 
			
		||||
 | 
			
		||||
  TDocument_cache() : TCache(23) { }
 | 
			
		||||
  virtual ~TDocument_cache() { }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TObject* TDocument_cache::key2obj(const char* key)
 | 
			
		||||
{
 | 
			
		||||
  TToken_string k(key);
 | 
			
		||||
  const char provv = *k.get(0);
 | 
			
		||||
  const int anno = k.get_int();
 | 
			
		||||
  const TString4 codnum= k.get();
 | 
			
		||||
  const long ndoc = k.get_long();
 | 
			
		||||
  return new TDocumento(provv, anno, codnum, ndoc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TDocumento& TDocument_cache::doc(const TRectype& rec)
 | 
			
		||||
{
 | 
			
		||||
  TToken_string key;
 | 
			
		||||
  key = rec.get(DOC_PROVV);
 | 
			
		||||
  key.add(rec.get(DOC_ANNO));
 | 
			
		||||
  key.add(rec.get(DOC_CODNUM));
 | 
			
		||||
  key.add(rec.get(DOC_NDOC));
 | 
			
		||||
  TDocumento& d =  *(TDocumento*)objptr(key);
 | 
			
		||||
  return d;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_recordset
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
class TDocument_recordset : public TISAM_recordset
 | 
			
		||||
{
 | 
			
		||||
  TDocument_cache _cache;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  virtual const TVariant& get(int logic, const char* field) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  TDocument_recordset(const char* use) : TISAM_recordset(use) { }
 | 
			
		||||
  virtual ~TDocument_recordset() { }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const TVariant& TDocument_recordset::get(int num, const char* field) const
 | 
			
		||||
{
 | 
			
		||||
  const int idx = relation()->log2ind(num);
 | 
			
		||||
  if (idx < 0)
 | 
			
		||||
    return NULL_VARIANT;
 | 
			
		||||
 | 
			
		||||
  const TRectype& rec = relation()->file(idx).curr();
 | 
			
		||||
  const int logic = rec.num();
 | 
			
		||||
  if (logic == LF_DOC || logic == LF_RIGHEDOC)
 | 
			
		||||
  {
 | 
			
		||||
    // Se non e' un campo standard, ma e' calcolato da una formula...
 | 
			
		||||
    if (rec.type(field) == _nullfld) 
 | 
			
		||||
    {
 | 
			
		||||
      const TDocumento& doc = ((TDocument_cache&)_cache).doc(rec);
 | 
			
		||||
      TVariant& var = get_tmp_var();
 | 
			
		||||
      const TFieldref ref(field, logic);
 | 
			
		||||
      if (logic == LF_DOC)
 | 
			
		||||
      {
 | 
			
		||||
        var = ref.read(doc);
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        const int nriga = rec.get_int(RDOC_NRIGA);
 | 
			
		||||
        const TRiga_documento& rdoc = doc[nriga];
 | 
			
		||||
        var = ref.read(rdoc);
 | 
			
		||||
      }
 | 
			
		||||
      return var;     
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return TISAM_recordset::get(num, field);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_report
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
class TDocument_report : public TReport
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  virtual bool set_recordset(const TString& query);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  bool load(const char* name);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool TDocument_report::set_recordset(const TString& query)
 | 
			
		||||
{
 | 
			
		||||
  return TReport::set_recordset(new TDocument_recordset(query));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TDocument_report::load(const char* name)
 | 
			
		||||
{
 | 
			
		||||
  const bool ok = TReport::load(name);
 | 
			
		||||
  if (ok)
 | 
			
		||||
  {
 | 
			
		||||
    // Purtroppo il recordset delle sottosezioni deve essere reimpostato a mano
 | 
			
		||||
    for (int i = 11; i <= 999; i++)
 | 
			
		||||
    {
 | 
			
		||||
      TReport_section* sec = find_section('B', i);
 | 
			
		||||
      if (sec != NULL)
 | 
			
		||||
      {
 | 
			
		||||
        TRecordset* recset = sec->recordset();
 | 
			
		||||
        if (recset != NULL)
 | 
			
		||||
        {
 | 
			
		||||
          const TString use = recset->query_text();
 | 
			
		||||
          recset = new TDocument_recordset(use);
 | 
			
		||||
          sec->set_recordset(recset);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TKlarkKent_mask
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
@ -244,7 +244,7 @@ public:
 | 
			
		||||
  const char  tipocf() const;
 | 
			
		||||
  void  set_defaults(TMask& m) const;
 | 
			
		||||
  const TString_array& keys_descrs();
 | 
			
		||||
  const TString_array& sheet_columns();
 | 
			
		||||
  const TString_array& sheet_columns() const;
 | 
			
		||||
  const TString_array& handlers() const;
 | 
			
		||||
  
 | 
			
		||||
  const TString& mask_name() const { return get("S4");}
 | 
			
		||||
 | 
			
		||||
@ -1444,7 +1444,7 @@ const TTipo_documento& TDocumento::tipo(const char * tipodoc)
 | 
			
		||||
 | 
			
		||||
const TTipo_documento& TDocumento::tipo() const
 | 
			
		||||
{
 | 
			
		||||
  const TString4 tipodoc(get("TIPODOC"));
 | 
			
		||||
  const TString4 tipodoc(get(DOC_TIPODOC));
 | 
			
		||||
  return tipo(tipodoc);
 | 
			
		||||
}  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -99,7 +99,7 @@ const TString& TTipo_documento::riferimento(const TDocumento & doc, TString& rif
 | 
			
		||||
 | 
			
		||||
const TString_array& TTipo_documento::keys_descrs()
 | 
			
		||||
{
 | 
			
		||||
  if (_keys_descrs.items() == 0)
 | 
			
		||||
  if (_keys_descrs.empty())
 | 
			
		||||
  {
 | 
			
		||||
    TString16 var, tiporiga;
 | 
			
		||||
    TFilename pn; profile_name(pn);
 | 
			
		||||
@ -139,18 +139,18 @@ const TString_array& TTipo_documento::keys_descrs()
 | 
			
		||||
  return _keys_descrs;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const TString_array& TTipo_documento::sheet_columns()
 | 
			
		||||
const TString_array& TTipo_documento::sheet_columns() const
 | 
			
		||||
{ 
 | 
			
		||||
  if (_sheet_columns.items() == 0)
 | 
			
		||||
  if (_sheet_columns.empty())
 | 
			
		||||
  {
 | 
			
		||||
    TFilename pn; profile_name(pn);
 | 
			
		||||
    TConfig prof(pn, "SHEET");
 | 
			
		||||
    for (int i = 0; i < MAX_COLUMNS; i++)
 | 
			
		||||
    {
 | 
			
		||||
			const TString & id = prof.get("Col", NULL, i);
 | 
			
		||||
			if (atoi(id) == 0)
 | 
			
		||||
			const TString& id = prof.get("Col", NULL, i);
 | 
			
		||||
      if (atoi(id) <= 0)
 | 
			
		||||
				break;
 | 
			
		||||
      _sheet_columns.add(id);
 | 
			
		||||
      ((TString_array&)_sheet_columns).add(id);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
@ -159,7 +159,7 @@ const TString_array& TTipo_documento::sheet_columns()
 | 
			
		||||
 | 
			
		||||
const TString_array&  TTipo_documento::handlers() const 
 | 
			
		||||
{
 | 
			
		||||
  if (_handlers.items() == 0)
 | 
			
		||||
  if (_handlers.empty())
 | 
			
		||||
  {
 | 
			
		||||
    TString16 chiave;
 | 
			
		||||
    TFilename pn; profile_name(pn);
 | 
			
		||||
@ -178,7 +178,7 @@ const TString_array&  TTipo_documento::handlers() const
 | 
			
		||||
 | 
			
		||||
void TTipo_documento::set_defaults(TMask& m) const
 | 
			
		||||
{
 | 
			
		||||
  if (_defaults.items() == 0) // Carica lo string_array con i defaults
 | 
			
		||||
  if (_defaults.empty()) // Carica lo string_array con i defaults
 | 
			
		||||
  {
 | 
			
		||||
    TFilename pn; profile_name(pn);
 | 
			
		||||
    TConfig prof(pn, "DEFAULT");
 | 
			
		||||
@ -186,8 +186,7 @@ void TTipo_documento::set_defaults(TMask& m) const
 | 
			
		||||
    for(int i = 0; ; i++)
 | 
			
		||||
    {
 | 
			
		||||
			TToken_string s(prof.get("Default", NULL, i));
 | 
			
		||||
 
 | 
			
		||||
			if (s.empty())
 | 
			
		||||
 			if (s.empty())
 | 
			
		||||
				break;
 | 
			
		||||
			const int field = s.get_int();
 | 
			
		||||
     ((TTipo_documento*)this)->_defaults.add(s.get(), field);
 | 
			
		||||
 | 
			
		||||
@ -67,7 +67,7 @@ TDocumento_mask::TDocumento_mask(const char* td)
 | 
			
		||||
    _std_dep = m.standarddep();
 | 
			
		||||
  }
 | 
			
		||||
  _doc.set_tipo(td);
 | 
			
		||||
  const TString mname = _doc.tipo().mask_name();
 | 
			
		||||
  const TString16 mname = _doc.tipo().mask_name();
 | 
			
		||||
  read_mask(mname, 0, MAX_PAGES);
 | 
			
		||||
 | 
			
		||||
  _sheet = &sfield(F_SHEET);      
 | 
			
		||||
@ -401,9 +401,9 @@ void TDocumento_mask::configura_sheet(TSheet_field& sheet)
 | 
			
		||||
{
 | 
			
		||||
  TBit_array to_delete(MAX_COLUMNS);
 | 
			
		||||
  to_delete.set();
 | 
			
		||||
  TTipo_documento& tdoc = (TTipo_documento&) _doc.tipo();
 | 
			
		||||
  const TTipo_documento& tdoc = _doc.tipo();
 | 
			
		||||
  const TString_array& sheet_columns = tdoc.sheet_columns();
 | 
			
		||||
  int ncols = sheet_columns.items();
 | 
			
		||||
  const int ncols = sheet_columns.items();
 | 
			
		||||
 | 
			
		||||
  TToken_string colonne;
 | 
			
		||||
  int i;
 | 
			
		||||
@ -411,7 +411,7 @@ void TDocumento_mask::configura_sheet(TSheet_field& sheet)
 | 
			
		||||
  colonne = "0";
 | 
			
		||||
  for (i = 0; i < ncols; i ++ )
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& sheet_col = (TToken_string&) sheet_columns[i];
 | 
			
		||||
    TToken_string& sheet_col = (TToken_string&)sheet_columns.row(i);
 | 
			
		||||
    const int field_id = sheet_col.get_int(0);
 | 
			
		||||
    const int coltomove = sheet.cid2index(field_id);
 | 
			
		||||
    to_delete.reset(coltomove);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										139
									
								
								ve/vereplib.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										139
									
								
								ve/vereplib.cpp
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,139 @@
 | 
			
		||||
#include <xvt.h>
 | 
			
		||||
 | 
			
		||||
#include "vereplib.h"
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_cache
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
class TDocument_cache : TCache
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  virtual TObject* key2obj(const char* key);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  TDocumento& doc(const TRectype& rec);
 | 
			
		||||
 | 
			
		||||
  TDocument_cache() : TCache(23) { }
 | 
			
		||||
  virtual ~TDocument_cache() { }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TObject* TDocument_cache::key2obj(const char* key)
 | 
			
		||||
{
 | 
			
		||||
  TToken_string k(key);
 | 
			
		||||
  const char provv = *k.get(0);
 | 
			
		||||
  const int anno = k.get_int();
 | 
			
		||||
  const TString4 codnum= k.get();
 | 
			
		||||
  const long ndoc = k.get_long();
 | 
			
		||||
  return new TDocumento(provv, anno, codnum, ndoc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TDocumento& TDocument_cache::doc(const TRectype& rec)
 | 
			
		||||
{
 | 
			
		||||
  TToken_string key;
 | 
			
		||||
  key = rec.get(DOC_PROVV);
 | 
			
		||||
  key.add(rec.get(DOC_ANNO));
 | 
			
		||||
  key.add(rec.get(DOC_CODNUM));
 | 
			
		||||
  key.add(rec.get(DOC_NDOC));
 | 
			
		||||
  TDocumento& d =  *(TDocumento*)objptr(key);
 | 
			
		||||
  return d;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const TDocumento& rec2doc(const TRectype& rec)
 | 
			
		||||
{
 | 
			
		||||
  static TDocument_cache* _cache = NULL;
 | 
			
		||||
  if (_cache == NULL)
 | 
			
		||||
    _cache = new TDocument_cache;
 | 
			
		||||
  return _cache->doc(rec);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_recordset
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
const TVariant& TDocument_recordset::get(int num, const char* field) const
 | 
			
		||||
{
 | 
			
		||||
  const int idx = relation()->log2ind(num);
 | 
			
		||||
  if (idx < 0)
 | 
			
		||||
    return NULL_VARIANT;
 | 
			
		||||
 | 
			
		||||
  const TRectype& rec = relation()->file(idx).curr();
 | 
			
		||||
  const int logic = rec.num();
 | 
			
		||||
 | 
			
		||||
  // Se non e' un campo standard, ma e' calcolato da una formula...
 | 
			
		||||
  if ((logic == LF_DOC || logic == LF_RIGHEDOC) && rec.type(field) == _nullfld)
 | 
			
		||||
  {
 | 
			
		||||
    TVariant& var = get_tmp_var();
 | 
			
		||||
    const TDocumento& doc = rec2doc(rec);
 | 
			
		||||
    
 | 
			
		||||
    if (xvt_str_compare_ignoring_case(field, "SEGNO") == 0)
 | 
			
		||||
    {
 | 
			
		||||
      var = doc.is_nota_credito() ? -UNO : UNO;   
 | 
			
		||||
    } else
 | 
			
		||||
    if (xvt_str_compare_ignoring_case(field, "IS_COSTO") == 0)
 | 
			
		||||
    {
 | 
			
		||||
      var = doc.get_char(DOC_TIPOCF)=='F' ? UNO : ZERO;
 | 
			
		||||
    } else
 | 
			
		||||
    if (xvt_str_compare_ignoring_case(field, "IS_RICAVO") == 0)
 | 
			
		||||
    {
 | 
			
		||||
      var = doc.get_char(DOC_TIPOCF)=='C' ? UNO : ZERO;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      const TFieldref ref(field, logic);
 | 
			
		||||
      if (logic == LF_DOC)
 | 
			
		||||
      {
 | 
			
		||||
        var = ref.read(doc);
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        const int nriga = rec.get_int(RDOC_NRIGA);
 | 
			
		||||
        const TRiga_documento& rdoc = doc[nriga];
 | 
			
		||||
        var = ref.read(rdoc);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return var;     
 | 
			
		||||
  }
 | 
			
		||||
  return TISAM_recordset::get(num, field);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TDocument_recordset::TDocument_recordset(const char* use) 
 | 
			
		||||
                   : TISAM_recordset(use) 
 | 
			
		||||
{ }
 | 
			
		||||
 | 
			
		||||
TDocument_recordset::~TDocument_recordset() 
 | 
			
		||||
{ }
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// TDocument_report
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
bool TDocument_report::set_recordset(const TString& query)
 | 
			
		||||
{
 | 
			
		||||
  return TReport::set_recordset(new TDocument_recordset(query));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TDocument_report::load(const char* name)
 | 
			
		||||
{
 | 
			
		||||
  const bool ok = TReport::load(name);
 | 
			
		||||
  if (ok)
 | 
			
		||||
  {
 | 
			
		||||
    // Purtroppo il recordset delle sottosezioni deve essere reimpostato a mano
 | 
			
		||||
    for (int i = 11; i <= 999; i++)
 | 
			
		||||
    {
 | 
			
		||||
      TReport_section* sec = find_section('B', i);
 | 
			
		||||
      if (sec != NULL)
 | 
			
		||||
      {
 | 
			
		||||
        TRecordset* recset = sec->recordset();
 | 
			
		||||
        if (recset != NULL)
 | 
			
		||||
        {
 | 
			
		||||
          const TString use = recset->query_text();
 | 
			
		||||
          recset = new TDocument_recordset(use);
 | 
			
		||||
          sec->set_recordset(recset);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										33
									
								
								ve/vereplib.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								ve/vereplib.h
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
#ifndef __VEREPLIB_H
 | 
			
		||||
#define __VEREPLIB_H
 | 
			
		||||
 | 
			
		||||
#ifndef __RECPORT_H
 | 
			
		||||
#include <report.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef __VELIB_H
 | 
			
		||||
#include "velib.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
class TDocument_recordset : public TISAM_recordset
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  virtual const TVariant& get(int logic, const char* field) const;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  TDocument_recordset(const char* use);
 | 
			
		||||
  virtual ~TDocument_recordset();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class TDocument_report : public TReport
 | 
			
		||||
{
 | 
			
		||||
protected:
 | 
			
		||||
  virtual bool set_recordset(const TString& query);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  bool load(const char* name);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const TDocumento& rec2doc(const TRectype& rec);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user