Files correlati :ca3700a.rep, ca3.exe Ricompilazione Demo : [ ] Commento :rendiconto: aggiunto il controllo sui documenti con più righe che venivano sovrascritti tante volte quante erano le righe. Aggiunto controllo sulle date nella maschera della stampa mastrini (come quello della stampa mastrini CG e delle altre stampe di analitica) git-svn-id: svn://10.65.10.50/trunk@13300 c028cbd2-c16b-5b4b-a496-9718f37d4682
1139 lines
34 KiB
C++
Executable File
1139 lines
34 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <execp.h>
|
||
#include <progind.h>
|
||
#include <reprint.h>
|
||
#include <doc.h>
|
||
#include <rdoc.h>
|
||
#include "../cg/cg2103.h"
|
||
#include "../cg/cglib01.h"
|
||
#include "../ve/velib04.h"
|
||
|
||
#include "panapdc.h"
|
||
#include "pconana.h"
|
||
#include "movana.h"
|
||
#include "rmovana.h"
|
||
|
||
#include "ca3.h"
|
||
#include "ca3700.h"
|
||
#include "calib01.h"
|
||
#include "calib02.h"
|
||
|
||
////////////////////////////////////////////////////////
|
||
// MASCHERA
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_rendiconto_ca_mask : public TAutomask
|
||
{
|
||
protected:
|
||
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
const TString& get_report_class() const;
|
||
bool test_compatible_report();
|
||
|
||
bool esistono_riclassificazioni() const;
|
||
void create_sheet();
|
||
int create_sheet_fields(int lf, int& y, short& dlg, bool required);
|
||
|
||
public:
|
||
TPrint_rendiconto_ca_mask();
|
||
virtual ~TPrint_rendiconto_ca_mask() {}
|
||
};
|
||
|
||
const TString& TPrint_rendiconto_ca_mask::get_report_class() const
|
||
{
|
||
TString& classe = get_tmp_string();
|
||
classe = "ca3700a";
|
||
return classe;
|
||
}
|
||
|
||
bool TPrint_rendiconto_ca_mask::test_compatible_report()
|
||
{
|
||
const TString& cls = get_report_class();
|
||
const TString& name = get(F_REPORT);
|
||
bool ok = name.not_empty();
|
||
if (ok)
|
||
{
|
||
TReport rep;
|
||
ok = rep.load(name);
|
||
if (ok)
|
||
{
|
||
const TString& classe = rep.get_class();
|
||
ok = classe == cls;
|
||
}
|
||
}
|
||
if (!ok)
|
||
{
|
||
set(F_REPORT, cls);
|
||
TFilename path = cls;
|
||
path.ext("rep");
|
||
ok = path.custom_path();
|
||
}
|
||
return ok;
|
||
}
|
||
|
||
bool TPrint_rendiconto_ca_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case F_DATAINI:
|
||
case F_DATAFIN:
|
||
if (e == fe_close)
|
||
{
|
||
const int anno = get_int(F_ANNO);
|
||
if (anno > 0) //se viene selezionato un esercizio..
|
||
{
|
||
TEsercizi_contabili esc; //..le date devono essere incluse nell'esercizio selezionato!
|
||
const TDate data = o.get();
|
||
if (!data.empty() && esc.date2esc(data) != anno)
|
||
return error_box(TR("La data deve appartenere all'anno selezionato"));
|
||
}
|
||
else //se l'esercizio <20> vuoto le date diventano obbligatorie!!
|
||
{
|
||
if (o.empty())
|
||
return error_box(TR("La data <20> obbligatoria in quanto manca l'esercizio"));
|
||
}
|
||
}
|
||
break;
|
||
case F_REPORT:
|
||
if (e == fe_button)
|
||
{
|
||
const TString8 lib = get_report_class();
|
||
TFilename path = o.get();
|
||
if (select_custom_file(path, "rep", lib))
|
||
{
|
||
path = path.name();
|
||
path.ext("");
|
||
o.set(path);
|
||
}
|
||
} else
|
||
if (e == fe_close)
|
||
{
|
||
if (!test_compatible_report())
|
||
return error_box(TR("Impossibile trovare un report compatibile"));
|
||
}
|
||
break;
|
||
case F_PRE1:
|
||
case F_PRE2:
|
||
case F_PRE3:
|
||
if ((e == fe_init || e == fe_modify) && o.active())
|
||
{
|
||
const int k = o.dlg()-F_PRE1;
|
||
set(F_PAN1_INI + k, o.get(), 0x2);
|
||
disable(F_PAN1_INI + k);
|
||
disable(F_PANDES1_INI + k);
|
||
|
||
set(F_PAN1_FIN + k, o.get(), 0x2);
|
||
disable(F_PAN1_FIN + k);
|
||
disable(F_PANDES1_FIN + k);
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
int TPrint_rendiconto_ca_mask::create_sheet_fields(int lf, int& y, short& dlg, bool required)
|
||
{
|
||
TSheet_field& sf = sfield(F_RIGHE);
|
||
TMask& sm = sf.sheet_mask();
|
||
|
||
const int h = ca_create_fields(sm, 0, lf, 1, y, dlg, dlg+50);
|
||
|
||
for (int i = 0; i < h; i++)
|
||
{
|
||
TEdit_field& fld = sm.efield(dlg+i);
|
||
int logic = lf;
|
||
if (logic == LF_FASI)
|
||
{
|
||
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
||
if (fasinfo.parent() != 0)
|
||
{
|
||
const TMultilevel_code_info& parinfo = ca_multilevel_code_info(fasinfo.parent());
|
||
if (i < parinfo.levels())
|
||
logic = fasinfo.parent();
|
||
}
|
||
}
|
||
|
||
const char* fieldname = NULL;
|
||
switch(logic)
|
||
{
|
||
case LF_CDC : fieldname = RMOVANA_CODCCOSTO; break;
|
||
case LF_COMMESSE: fieldname = RMOVANA_CODCMS; break;
|
||
case LF_FASI : fieldname = RMOVANA_CODFASE; break;
|
||
default : fieldname = RMOVANA_CODCONTO; break;
|
||
}
|
||
TFieldref* f = (TFieldref*)fld.field();
|
||
f->set_name(fieldname);
|
||
|
||
fld.check_type(required ? CHECK_REQUIRED : CHECK_NORMAL);
|
||
|
||
TEdit_field& dfld = sm.efield(dlg+50+i);
|
||
dfld.set_field(EMPTY_STRING); // Toglie campi che fan saltare gli output!
|
||
}
|
||
|
||
y += h+1;
|
||
dlg += h;
|
||
|
||
return h;
|
||
}
|
||
|
||
void TPrint_rendiconto_ca_mask::create_sheet()
|
||
{
|
||
TSheet_field& sf = sfield(F_RIGHE);
|
||
TMask& sm = sf.sheet_mask();
|
||
sm.hide(-1);
|
||
|
||
const TMultilevel_code_info& fasinfo = ca_multilevel_code_info(LF_FASI);
|
||
|
||
TConfig_anal ini;
|
||
const bool fsc_req = ini.get_bool("FscRequired");
|
||
|
||
int y = 1;
|
||
short dlg = S_CDC1 + 100; // id del primo campo da generare
|
||
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
const TString& level = ini.get("Level", NULL, i+1); // Legge il livello 1 o 2
|
||
if (level == "CDC") // Crea centro di costo
|
||
{
|
||
if (fasinfo.parent() == LF_CDC)
|
||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||
else
|
||
{
|
||
const bool cdc_req = ini.get_bool("CdcRequired");
|
||
create_sheet_fields(LF_CDC, y, dlg, cdc_req);
|
||
}
|
||
} else
|
||
if (level == "CMS") // Crea commessa
|
||
{
|
||
if (fasinfo.parent() == LF_COMMESSE)
|
||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||
else
|
||
{
|
||
const bool cms_req = ini.get_bool("CmsRequired");
|
||
create_sheet_fields(LF_COMMESSE, y, dlg, cms_req);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||
|
||
for (short id = S_CDC12+100; id >= S_CDC1+100; id--)
|
||
{
|
||
const int pos = sm.id2pos(id);
|
||
if (pos >= 0)
|
||
{
|
||
TMask_field& f = sm.fld(pos);
|
||
const int size = f.size();
|
||
const TString& prompt = f.prompt();
|
||
sf.set_column_header(id, prompt);
|
||
sf.set_column_justify(id, f.is_kind_of(CLASS_REAL_FIELD));
|
||
sf.set_column_width(id, (max(3+size, prompt.len()+1)) * CHARX);
|
||
}
|
||
else
|
||
sf.delete_column(id);
|
||
}
|
||
}
|
||
|
||
bool TPrint_rendiconto_ca_mask::esistono_riclassificazioni() const
|
||
{
|
||
TLocalisamfile ric(LF_PANAPDC);
|
||
return ric.first() == NOERR;
|
||
}
|
||
|
||
TPrint_rendiconto_ca_mask::TPrint_rendiconto_ca_mask()
|
||
:TAutomask("ca3700")
|
||
{
|
||
TConfig_anal cfg;
|
||
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
||
|
||
const TMultilevel_code_info& pconana_info = ca_multilevel_code_info(LF_PCONANA);
|
||
const int pconana_levels = pconana_info.levels();
|
||
|
||
int pconana_prefix = cfg.get_int("PdcPrefix");
|
||
if (pconana_prefix >= pconana_levels)
|
||
pconana_prefix = pconana_levels-1;
|
||
|
||
disable(F_PIANO);
|
||
set(F_PIANO, use_pdcc ? "C" : "A");
|
||
|
||
// Controllo se voglio (e posso) usare il conto analitico come prefisso di quello contabile
|
||
const int pref = cfg.get_int("PdcPrefix");
|
||
if (use_pdcc && pref > 0)
|
||
{
|
||
const TMultilevel_code_info& info = ca_multilevel_code_info(LF_PCONANA);
|
||
const int levels = info.levels();
|
||
if (levels >= 2 && pref < levels && esistono_riclassificazioni())
|
||
{
|
||
enable(F_PIANO);
|
||
ca_create_fields(*this, 0, LF_PCONANA, 2, 4, F_PRE1, F_PREDES1, 0x0, PCONANA_CODCONTO);
|
||
|
||
// Nascondi i campi che non fanno parte del prefisso
|
||
for (int i = 0; i < levels; i++)
|
||
{
|
||
if (i < pref)
|
||
{
|
||
field(F_PRE1 + i).check_type(CHECK_REQUIRED);
|
||
field(F_PRE1 + i).set_group(6);
|
||
field(F_PREDES1 + i).set_group(6);
|
||
}
|
||
else
|
||
{
|
||
field(F_PRE1 + i).hide();
|
||
field(F_PREDES1 + i).hide();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
for (int g = 5; g <= 6; g++)
|
||
{
|
||
const int logicnum = g == 5 ? LF_PCON : LF_PCONANA;
|
||
const short da_dlg = g == 5 ? F_PDC1_INI : F_PAN1_INI;
|
||
const short da_des = g == 5 ? F_PDCDES1_INI : F_PANDES1_INI;
|
||
const short a_dlg = g == 5 ? F_PDC1_FIN : F_PAN1_FIN;
|
||
const short a_des = g == 5 ? F_PDCDES1_FIN : F_PANDES1_FIN;
|
||
|
||
const int nfields = ca_create_fields(*this, 0, logicnum, 2, 9, da_dlg, da_des, 0x0, PCONANA_CODCONTO);
|
||
ca_create_fields(*this, 0, logicnum, 2, 14, a_dlg, a_des, 0x0, PCONANA_CODCONTO);
|
||
|
||
for (int i = 0; i < nfields; i++)
|
||
{
|
||
TMask_field& daconto = field(da_dlg + i);
|
||
daconto.set_group(1);
|
||
daconto.set_group(4);
|
||
daconto.set_group(g);
|
||
daconto.check_type(CHECK_SEARCH);
|
||
|
||
field(da_des+i).set_group(4);
|
||
field(da_des+i).set_group(g);
|
||
|
||
TMask_field& aconto = field(a_dlg + i);
|
||
aconto.set_group(2);
|
||
aconto.set_group(4);
|
||
aconto.set_group(g);
|
||
aconto.check_type(CHECK_SEARCH);
|
||
|
||
field(a_des+i).set_group(4);
|
||
field(a_des+i).set_group(g);
|
||
}
|
||
}
|
||
|
||
// creazione dei campi della seconda pagina della maschera (cdc/cms/fasi)
|
||
create_sheet();
|
||
// setta gli handlers a tutti i campi generati della maschera;senza questa chiamata la on_field_event
|
||
// non puo' funzionare sui campi generati!!!
|
||
set_handlers();
|
||
|
||
//la terza pagina ha uno sheet standard e non necessita di metodi per la creazione
|
||
}
|
||
|
||
|
||
///////////////////////////////////////////////////////////////
|
||
// RECORDSET
|
||
///////////////////////////////////////////////////////////////
|
||
#define IMPEGNATO 1
|
||
#define MATURATO 2
|
||
#define FATTURATO 4
|
||
|
||
class TPrint_rendiconto_ca_recordset : public TISAM_recordset
|
||
{
|
||
TExternisamfile* _tmp;
|
||
bool _riclassificato;
|
||
TString _prefix, _da_conto_riclas, _a_conto_riclas;
|
||
|
||
protected:
|
||
int _anno;
|
||
int _tipoconti;
|
||
TDate _dadata, _adata;
|
||
long _danumreg, _anumreg;
|
||
TString _daconto, _aconto, _codcosto, _codcms, _codfas;
|
||
|
||
protected: //da libreria
|
||
virtual const TVariant& get(const char* column_name) const;
|
||
|
||
protected:
|
||
static bool mov_filter(const TRelation* rel);
|
||
bool valid_record(const TRelation& rel) const;
|
||
virtual void set_custom_filter(TCursor& cur) const;
|
||
|
||
void crea_righe_da_rmovana();
|
||
void crea_righe_da_rdoc(const TPrint_rendiconto_ca_mask& msk);
|
||
void crea_trr(const TFilename& trr) const;
|
||
void salva_rmovana(const TRectype& rmovana, const TRectype& movana, const TDocumento* doc);
|
||
real somma_budget(const TString& codconto, const char* tipomovana);
|
||
|
||
|
||
public:
|
||
virtual void set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row);
|
||
|
||
TPrint_rendiconto_ca_recordset(const TString& sql) : TISAM_recordset(sql), _riclassificato(false) { _tmp = NULL;}
|
||
~TPrint_rendiconto_ca_recordset() {}
|
||
};
|
||
|
||
|
||
static const TPrint_rendiconto_ca_recordset* myself = NULL;
|
||
|
||
TPrint_rendiconto_ca_recordset* rendiconto_recordset() { return (TPrint_rendiconto_ca_recordset* ) myself;}
|
||
|
||
void TPrint_rendiconto_ca_recordset::set_custom_filter(TCursor& cur) const
|
||
{
|
||
relation()->replace(_tmp); //sostituisce il vero file rmovana con quello temporaneo
|
||
|
||
//filtro sul file esterno (_tmp, cio<69> 1000) sui conti selezionati sulla maschera
|
||
TRectype darec(cur.curr()), arec(cur.curr()); //curr perch<63> <20> il file externisamfile
|
||
darec.zero();
|
||
arec.zero();
|
||
if (!_riclassificato)
|
||
{
|
||
if (_daconto.not_empty())
|
||
darec.put("CONTO", _daconto);
|
||
if (_aconto.not_empty())
|
||
arec.put("CONTO", _aconto);
|
||
}
|
||
else
|
||
{
|
||
darec.put("CONTO", _da_conto_riclas);
|
||
arec.put("CONTO", _a_conto_riclas);
|
||
}
|
||
|
||
//filtro sulla data(non avendo anche codnum non ho la chiave completa per mettere la data nella setregion)
|
||
TString filtro;
|
||
if (_dadata.ok())
|
||
filtro << "(ANSI(DATA)>=" << _dadata << ")";
|
||
|
||
if (_adata.ok())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(ANSI(DATA)<=" << _adata << ")";
|
||
}
|
||
|
||
cur.setregion(darec, arec);
|
||
cur.setfilter(filtro);
|
||
|
||
myself = this;
|
||
//cur.set_filterfunction(mov_filter, true);
|
||
}
|
||
|
||
//metodo per il calcolo del budget PREVENTIVO o VARIAZIONE (sezione di raggruppamento sul report)
|
||
real TPrint_rendiconto_ca_recordset::somma_budget(const TString& codconto, const char* tipomovana)
|
||
{
|
||
real budget = ZERO;
|
||
|
||
TRelation rel_rmovana(LF_RMOVANA);
|
||
rel_rmovana.add(LF_MOVANA, "NUMREG==NUMREG");
|
||
|
||
//..crea un cursore su rmovana per avere solo i conti di tipo tipomovana, con il codice conto
|
||
//selezionato e la datacomp compresa nell'intervallo date
|
||
TRectype da_rmovana(LF_RMOVANA);
|
||
TRectype a_rmovana(LF_RMOVANA);
|
||
|
||
da_rmovana.put(RMOVANA_CODCONTO, codconto);
|
||
a_rmovana.put(RMOVANA_CODCONTO, codconto);
|
||
|
||
da_rmovana.put(RMOVANA_DATACOMP, _dadata);
|
||
a_rmovana.put(RMOVANA_DATACOMP, _adata);
|
||
|
||
TString filtro;
|
||
filtro << "(107->TIPOMOV==\"" << tipomovana << "\")";
|
||
|
||
TCursor cur_rmovana(&rel_rmovana, filtro, 2, &da_rmovana, &a_rmovana);
|
||
const long rmovana_items = cur_rmovana.items();
|
||
cur_rmovana.freeze();
|
||
|
||
if (rmovana_items > 0)
|
||
{
|
||
const TRectype& movana = rel_rmovana.curr(LF_MOVANA);
|
||
for (cur_rmovana = 0; cur_rmovana.pos() < rmovana_items; ++cur_rmovana)
|
||
{
|
||
if (movana.get_char(MOVANA_SEZIONE) == 'D')
|
||
budget -= movana.get_real(MOVANA_TOTDOC);
|
||
if (movana.get_char(MOVANA_SEZIONE) == 'A')
|
||
budget += movana.get_real(MOVANA_TOTDOC);
|
||
}
|
||
}
|
||
return budget;
|
||
}
|
||
|
||
const TVariant& TPrint_rendiconto_ca_recordset::get(const char* column_name) const
|
||
{
|
||
|
||
if (*column_name == '#')
|
||
{
|
||
if (strcmp(column_name, "#COSTO") == 0)
|
||
{
|
||
TVariant& var = get_tmp_var();
|
||
var = _codcosto;
|
||
return var;
|
||
}
|
||
if (strcmp(column_name, "#COMMESSA") == 0)
|
||
{
|
||
TVariant& var = get_tmp_var();
|
||
var = _codcms;
|
||
return var;
|
||
}
|
||
if (strcmp(column_name, "#FASE") == 0)
|
||
{
|
||
TVariant& var = get_tmp_var();
|
||
var = _codfas;
|
||
return var;
|
||
}
|
||
if (strcmp(column_name, "#PREVENTIVO") == 0)
|
||
{
|
||
TVariant& var = get_tmp_var();
|
||
TString80 conto;
|
||
if (_riclassificato)
|
||
conto = TISAM_recordset::get("CONTOCG").as_string();
|
||
else
|
||
conto = TISAM_recordset::get("CONTO").as_string();
|
||
|
||
var = rendiconto_recordset()->somma_budget(conto, "P");
|
||
return var;
|
||
}
|
||
if (strcmp(column_name, "#VARIAZIONE") == 0)
|
||
{
|
||
TVariant& var = get_tmp_var();
|
||
TString80 conto;
|
||
if (_riclassificato)
|
||
conto = TISAM_recordset::get("CONTOCG").as_string();
|
||
else
|
||
conto = TISAM_recordset::get("CONTO").as_string();
|
||
|
||
var = rendiconto_recordset()->somma_budget(conto, "V");
|
||
return var;
|
||
}
|
||
}
|
||
return TISAM_recordset::get(column_name);
|
||
}
|
||
|
||
//compila i campi da stampare
|
||
void TPrint_rendiconto_ca_recordset::salva_rmovana(const TRectype& rmovana, const TRectype& movana, const TDocumento* doc)
|
||
{
|
||
//tipo movimento CONSUNTIVO
|
||
const char tipomov = movana.get_char(MOVANA_TIPOMOV);
|
||
if (tipomov <= ' ' || tipomov == 'T')
|
||
{
|
||
TRectype& tmpcurr = _tmp->curr();
|
||
tmpcurr.zero();
|
||
TString8 codnum_desc; //codnum da usare sia per compilare il campo "CODNUM"
|
||
codnum_desc.cut(0);
|
||
|
||
// il conto puo' essere analitico o contabile...
|
||
//se <20> compilato l'archivio di collegamento PANAPDC
|
||
//si deve usare come conto il campo codconto del panapdc!!!...
|
||
if (_riclassificato)
|
||
{
|
||
TString conto_riclassificato; //stringa che conterr<72> il conto riclassificato (se sara' trovato)
|
||
|
||
//prende il gruppo dalla riga rmovana in esame
|
||
const int gruppo = atoi(rmovana.get(RMOVANA_CODCONTO).left(3));
|
||
const int conto = atoi(rmovana.get(RMOVANA_CODCONTO).mid(3,3));
|
||
const long sottoconto = atol(rmovana.get(RMOVANA_CODCONTO).mid(6,6));
|
||
|
||
//relazione e cursore su panapdc alla ricerca del conto riclassificato corrispondente
|
||
//alla triade gr/co/sottoc di rmovana
|
||
TRelation rel_panapdc(LF_PANAPDC);
|
||
//servono solamente i record con il gruppo = al gruppo di rmovana
|
||
TRectype da_panapdc(LF_PANAPDC);
|
||
da_panapdc.put(PANAPDC_GRUPPO, gruppo);
|
||
|
||
TString filtro;
|
||
if (_prefix.not_empty())
|
||
filtro << "(CODCONTO[1," << _prefix.len() << "]=='" << _prefix << "')";
|
||
|
||
TCursor cur_panapdc(&rel_panapdc, filtro, 2, &da_panapdc, &da_panapdc);
|
||
const long panapdc_items = cur_panapdc.items();
|
||
cur_panapdc.freeze();
|
||
if (panapdc_items > 0) //se non ci sono record con il gruppo=rmovana.gruppo ed il prefisso voluto->salta l'rmovana
|
||
{
|
||
TRectype& rec_panapdc = cur_panapdc.curr();
|
||
for (cur_panapdc = 0; cur_panapdc.pos() < panapdc_items; ++cur_panapdc)
|
||
{
|
||
int current_conto = rec_panapdc.get_int(PANAPDC_CONTO);
|
||
long current_sottoconto = rec_panapdc.get_long(PANAPDC_SOTTOCONTO);
|
||
|
||
if (current_conto == 0 && current_sottoconto == 0)
|
||
{
|
||
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
|
||
tmpcurr.put("CONTO", conto_riclassificato);
|
||
break; //esce dal casino e passa ai campi successivi
|
||
}
|
||
else if (conto == current_conto && current_sottoconto == 0)
|
||
{
|
||
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
|
||
tmpcurr.put("CONTO", conto_riclassificato);
|
||
break; //esce dal casino e passa ai campi successivi
|
||
}
|
||
else if (conto == current_conto && sottoconto == current_sottoconto)
|
||
{
|
||
conto_riclassificato = rec_panapdc.get(PANAPDC_CODCONTO);
|
||
tmpcurr.put("CONTO", conto_riclassificato);
|
||
break; //esce dal casino e passa ai campi successivi
|
||
}
|
||
} //for sugli elementi del cursore
|
||
} //if panapdc_items > 0
|
||
|
||
//ATTENZIONE! Se era stata operata una selezione sui conti riclassificati nella maschera
|
||
//ed il conto riclassificato attuale non ricade nell'intervallo selezionato il programma
|
||
//non deve aggiungere il record al file!!
|
||
if ((_da_conto_riclas.not_empty() && conto_riclassificato < _da_conto_riclas) ||
|
||
(_a_conto_riclas.not_empty() && conto_riclassificato.compare(_a_conto_riclas, _a_conto_riclas.len()) > 0))
|
||
return;
|
||
|
||
} //if(_riclassificato)
|
||
else //...senn<6E> si usa il normale piano dei conti analitico (cio<69> tutti tranne che il CRPA)
|
||
tmpcurr.put("CONTO", rmovana.get(RMOVANA_CODCONTO)); //conto
|
||
|
||
//in ogni caso riempio il campo conto_cg
|
||
tmpcurr.put("CONTOCG", rmovana.get(RMOVANA_CODCONTO)); //conto_cg
|
||
|
||
//serve un documento da cui ricavare i parametri di stampa
|
||
TDocumento* newdoc = (TDocumento*)doc;
|
||
bool should_delete = false;
|
||
if (newdoc == NULL && movana.get(MOVANA_DNDOC).not_empty())
|
||
{
|
||
const TString4 dacodnum = movana.get(MOVANA_DCODNUM);
|
||
newdoc = new TDocumento('D', movana.get_int(MOVANA_DANNO), dacodnum, movana.get_long(MOVANA_DNDOC));
|
||
should_delete = true; //settato true per cancellare il doc al termine del metodo(senn<6E> addio memoria!)
|
||
}
|
||
const bool dadoc = newdoc != NULL;
|
||
|
||
//i movimenti possono essere normali o generati da documento...
|
||
if (dadoc) //movimento generato da documento
|
||
{
|
||
codnum_desc = movana.get(MOVANA_DCODNUM); //serve anche in fondo al metodo
|
||
tmpcurr.put("CODNUM", codnum_desc); //codnum del documento che origina il movana
|
||
tmpcurr.put("ANNO", movana.get(MOVANA_DANNO)); //anno del doc di origine
|
||
tmpcurr.put("NUMRD", movana.get(MOVANA_DNDOC)); //
|
||
tmpcurr.put("DATA", newdoc->get(DOC_DATADOC)); //data del documento che genera movana..
|
||
} //..non esiste il campo in movana
|
||
else //movimento normale (senza documento)
|
||
{
|
||
tmpcurr.put("CODNUM", "");
|
||
tmpcurr.put("ANNO", movana.get(MOVANA_ANNOES)); //anno del movimento
|
||
tmpcurr.put("NUMRD", movana.get(MOVANA_NUMREG)); //numreg del movana
|
||
tmpcurr.put("DATA", movana.get(MOVANA_DATACOMP)); //data del movana
|
||
}
|
||
|
||
//ricerca del mitico documento padre della riga documento attuale!
|
||
int selettore = 0;
|
||
if (newdoc != NULL)
|
||
{
|
||
tmpcurr.put("NUMDOCRIF", newdoc->get(DOC_NUMDOCRIF)); //docrif del documento originante il movana
|
||
tmpcurr.put("DATADOCRIF", newdoc->get(DOC_DATADOCRIF)); //datadocrif del documento originante il movana
|
||
|
||
const int tipo_documento = newdoc->tipo().tipo();
|
||
int tipo_babbo = TTipo_documento::_altro;
|
||
|
||
TString80 riferimento; //stringa su cui scrivere gli estremi del doc padre (se lo trova!)
|
||
real totale_doc_babbo; //totale del doc padre
|
||
const int rows = newdoc->physical_rows(); //righe del doc attuale
|
||
|
||
for (int i = 1; riferimento.empty() && i <= rows; i++)
|
||
{
|
||
const TRiga_documento& riga = (*newdoc)[i];
|
||
const TRectype* babbo = riga.find_original_rdoc(); //cerca il doc padre della riga doc attuale
|
||
if (babbo != NULL) //se trova il doc padre..
|
||
{
|
||
const TString8 babbo_codnum = babbo->get(RDOC_CODNUM);
|
||
const int anno = babbo->get_int(RDOC_ANNO);
|
||
const long ndoc = babbo->get_long(RDOC_NDOC);
|
||
riferimento << babbo_codnum << '-' << anno << '-' << ndoc;
|
||
TDocumento doc_babbo('D', anno, babbo_codnum, ndoc); //crea una copia del doc padre per prendere..
|
||
tipo_babbo = doc_babbo.tipo().tipo(); //..il tipo documento..
|
||
totale_doc_babbo = doc_babbo.totale_doc(); //..il suo totale
|
||
} //if (babbo != NULL)..
|
||
} //for (int i..
|
||
|
||
/*[Tipo documento] //schema per destinare gli importi nei campi corretti
|
||
O=I**
|
||
B=IM*
|
||
BO=*M*
|
||
FB=**F
|
||
FO=*MF
|
||
F=IMF*/
|
||
switch (tipo_documento)
|
||
{
|
||
case TTipo_documento::_bolla: //bolla B -> IM a meno che non sia bolla da ordine BO -> M
|
||
selettore = MATURATO;
|
||
if (tipo_babbo != TTipo_documento::_ordine)
|
||
selettore |= IMPEGNATO;
|
||
break;
|
||
|
||
case TTipo_documento::_fattura:
|
||
selettore = FATTURATO; //fattura da bolla FB -> F
|
||
if (tipo_babbo == TTipo_documento::_ordine) //fattura da ordine FO -> MF
|
||
{
|
||
selettore |= MATURATO;
|
||
tmpcurr.put("IMPEGNATO", totale_doc_babbo);
|
||
} else
|
||
if (tipo_babbo = TTipo_documento::_altro) //fattura senza padri F -> IMF
|
||
selettore |= (IMPEGNATO | MATURATO);
|
||
break;
|
||
|
||
case TTipo_documento::_ordine:
|
||
selettore = IMPEGNATO;
|
||
break;
|
||
|
||
case TTipo_documento::_altro:
|
||
default:
|
||
break;
|
||
}
|
||
tmpcurr.put("DOCORIG", riferimento);
|
||
} //if(newdoc != NULL)
|
||
|
||
//****modificare il metodo per accelerare
|
||
const char sezione = rmovana.get_char(RMOVANA_SEZIONE);
|
||
|
||
TImporto imp(sezione, rmovana.get_real(RMOVANA_IMPORTO));
|
||
|
||
TCausale caus(movana.get(MOVANA_CODCAUS));
|
||
TipoIVA tipoiva = caus.iva();
|
||
char sezione_normale;
|
||
|
||
if (tipoiva == iva_vendite)
|
||
sezione_normale = 'A';
|
||
else
|
||
if (tipoiva == iva_acquisti)
|
||
sezione_normale = 'D';
|
||
else
|
||
sezione_normale = 'D'; //questo in preparazione di casi futuri
|
||
|
||
imp.normalize(sezione_normale);
|
||
|
||
if (selettore & FATTURATO)
|
||
tmpcurr.put("FATTURATO", imp.valore());
|
||
if (selettore & MATURATO)
|
||
tmpcurr.put("MATURATO", imp.valore());
|
||
if (selettore & IMPEGNATO)
|
||
tmpcurr.put("IMPEGNATO", imp.valore());
|
||
|
||
|
||
//campi comuni a rmovana e rdoc senza particolari operazioni
|
||
TString descr = movana.get(MOVANA_DESCR);
|
||
int pos = descr.find('$'); //solo per il CRPA!
|
||
if (pos > 0)
|
||
{
|
||
descr.ltrim(pos+1);
|
||
descr.trim();
|
||
}
|
||
tmpcurr.put("DESC", descr); //descrizione movana
|
||
tmpcurr.put("NRIGA", rmovana.get(RMOVANA_NUMRIG)); //numero riga
|
||
tmpcurr.put("DESCRIGA", rmovana.get(RMOVANA_DESCR)); //descrizione rmovana
|
||
|
||
int err = _tmp->write(); // aggiunge i record al file temporaneo
|
||
//procedura di controllo della scrittura su file! se il documento <20> gi<67> stato contbilizzato..
|
||
//..sul file temporaneo esiste gi<67> un record con la chiave del record,dovuto al doc,..
|
||
//..che deve essere qui aggiunto!significa che l'intervallo di stati della numerazione selezionato..
|
||
//..nello sheet <20> errato (probabilmente lo stato finale <20> troppo alto)
|
||
if (err != NOERR)
|
||
{
|
||
TString msg;
|
||
msg.format(FR("Errore di scrittura %d sul file temporaneo.\n"), err);
|
||
msg << "Documento " << codnum_desc << " " << descr << " gia' contabilizzato.\nControllare lo stato della numerazione.";
|
||
error_box (msg);
|
||
}
|
||
|
||
if (should_delete)
|
||
delete newdoc;
|
||
} //if (tipomov == ..)
|
||
}
|
||
|
||
//scanning delle righe dei movimenti di analitica
|
||
void TPrint_rendiconto_ca_recordset::crea_righe_da_rmovana()
|
||
{
|
||
|
||
TRelation rel_rmovana(LF_RMOVANA);
|
||
rel_rmovana.add(LF_MOVANA, "NUMREG==NUMREG"); //aggiunge le testate x avere tipi mov e descr
|
||
|
||
//..crea un cursore su rmovana per vedere se i conti selezionati hanno veri movimenti che soddisfano
|
||
//i parametri del filtro sulla maschera. ACHTUNG! Questo filtro ha senso solo se non esiste la
|
||
//riclassificazione!!!
|
||
TRectype da_rmovana(LF_RMOVANA);
|
||
TRectype a_rmovana(LF_RMOVANA);
|
||
if (!_riclassificato)
|
||
{
|
||
da_rmovana.put(RMOVANA_CODCONTO, _daconto);
|
||
a_rmovana.put(RMOVANA_CODCONTO, _aconto);
|
||
}
|
||
|
||
TString filtro;
|
||
|
||
if (_dadata.ok())
|
||
filtro << "(ANSI(DATACOMP)>=" << _dadata.date2ansi() << ")";
|
||
if (_adata.ok())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
|
||
filtro << "(ANSI(DATACOMP)<=" << _adata.date2ansi() << ")";
|
||
}
|
||
|
||
if (_codcosto.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RMOVANA_CODCCOSTO << "==\"" << _codcosto << "\")";
|
||
}
|
||
if (_codcms.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RMOVANA_CODCMS << "==\"" << _codcms << "\")";
|
||
}
|
||
if (_codfas.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RMOVANA_CODFASE << "==\"" << _codfas << "\")";
|
||
}
|
||
|
||
TCursor cur_rmovana(&rel_rmovana, filtro, 2, &da_rmovana, &a_rmovana);
|
||
const long rmovana_items = cur_rmovana.items();
|
||
cur_rmovana.freeze();
|
||
|
||
//scorre le righe movimenti di analitica che soddisfano il filtro
|
||
//il join a movana serve nel caso necessitino dati di testata per la riga in questione
|
||
if (rmovana_items > 0)
|
||
{
|
||
const TRectype& rmovana = cur_rmovana.curr();
|
||
const TRectype& movana = rel_rmovana.curr(LF_MOVANA);
|
||
TProgind pi(rmovana_items, "Scansione righe movimenti...");
|
||
for (cur_rmovana = 0; cur_rmovana.pos() < rmovana_items; ++cur_rmovana)
|
||
{
|
||
pi.addstatus(1);
|
||
salva_rmovana(rmovana, movana, NULL);
|
||
}
|
||
}
|
||
}
|
||
|
||
//scanning delle righe dei documenti
|
||
void TPrint_rendiconto_ca_recordset::crea_righe_da_rdoc(const TPrint_rendiconto_ca_mask& msk)
|
||
{
|
||
TRelation rel_rdoc(LF_RIGHEDOC);
|
||
rel_rdoc.add(LF_DOC, "CODNUM==CODNUM|ANNO==ANNO|PROVV==PROVV|NDOC==NDOC"); //aggiunge le testate
|
||
|
||
TRectype dardoc(LF_RIGHEDOC);
|
||
TRectype ardoc(LF_RIGHEDOC);
|
||
TString filtro_date;
|
||
|
||
dardoc.put(RDOC_PROVV, 'D');
|
||
ardoc.put(RDOC_PROVV, 'D');
|
||
|
||
//se siamo fortunati l'anno si pu<70> trovare cos<6F>..
|
||
int anno = msk.get_int(F_ANNO);
|
||
if (anno > 0)
|
||
{
|
||
dardoc.put(RDOC_ANNO, anno);
|
||
ardoc.put(RDOC_ANNO, anno);
|
||
}
|
||
else
|
||
{
|
||
dardoc.put(RDOC_ANNO, _dadata.year());
|
||
ardoc.put(RDOC_ANNO, _adata.year());
|
||
if (_dadata.year() == _adata.year())
|
||
anno = _dadata.year();
|
||
}
|
||
|
||
if (_dadata.ok())
|
||
filtro_date << "(ANSI(33->DATADOC)>=" << _dadata.date2ansi() << ")";
|
||
if (_adata.ok())
|
||
{
|
||
if (filtro_date.not_empty())
|
||
filtro_date << "&&";
|
||
|
||
filtro_date << "(ANSI(33->DATADOC)<=" << _adata.date2ansi() << ")";
|
||
}
|
||
|
||
TContabilizzazione_analitica cont_anal; //oggetto necessario per contabilizzare il documento in osservazione
|
||
|
||
//deve filtrare per i soli documenti con codnum presente nello sheet dei codnum
|
||
TSheet_field& sheet = msk.sfield(F_RIGHE_NUM);
|
||
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
const TString4 codnum(row->get(0)); //prende il codice numerazione sulla riga
|
||
if (anno > 0) //se c'e' l'anno posso aggiungere codnum perch<63> <20> il campo successivo sulla chiave
|
||
{
|
||
dardoc.put(RDOC_CODNUM, codnum);
|
||
ardoc.put(RDOC_CODNUM, codnum);
|
||
}
|
||
|
||
//aggiunge il filtro per codice numerazione e stato documento
|
||
TString filtro = filtro_date;
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(CODNUM==\"" << codnum << "\")";
|
||
filtro << "&&(33->STATO>=\"" << row->get(2) << "\")";
|
||
filtro << "&&(33->STATO<=\"" << row->get(3) << "\")";
|
||
|
||
//poi deve aggiungere il filtro per cdc/cms/fas
|
||
if (_codcosto.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RDOC_CODCOSTO << "==\"" << _codcosto << "\")";
|
||
}
|
||
if (_codcms.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RDOC_CODCMS << "==\"" << _codcms << "\")";
|
||
}
|
||
if (_codfas.not_empty())
|
||
{
|
||
if (filtro.not_empty())
|
||
filtro << "&&";
|
||
filtro << "(" << RDOC_FASCMS << "==\"" << _codfas << "\")";
|
||
}
|
||
|
||
//il filtro <20> completo;pu<70> eseguire la scansione
|
||
TCursor cur_rdoc(&rel_rdoc, filtro, 1, &dardoc, &ardoc);
|
||
const long rdoc_items = cur_rdoc.items();
|
||
cur_rdoc.freeze();
|
||
|
||
if (rdoc_items > 0)
|
||
{
|
||
TString commento_progind;
|
||
commento_progind << "Scansione righe documenti " << codnum << "...";
|
||
TProgind pi(rdoc_items, commento_progind);
|
||
|
||
//memorizza l'ultimo doc per evitare doppioni in caso di doc con pi<70> righe (rielaborerebbe..
|
||
//..lo stesso documento tante volte quante sono le sue righe!)
|
||
TString old_key;
|
||
//scanning del file dei documenti alla ricerca di quelli che hanno la data ed il CODNUM
|
||
//validi nei filtri impostati dall'utente
|
||
for (cur_rdoc = 0; cur_rdoc.pos() < rdoc_items; ++cur_rdoc)
|
||
{
|
||
pi.addstatus(1);
|
||
const TRectype& curr_doc = cur_rdoc.curr(LF_DOC);
|
||
const TString curr_key = curr_doc.build_key();
|
||
if (curr_key == old_key)
|
||
continue;
|
||
else
|
||
old_key = curr_key;
|
||
|
||
TDocumento doc(curr_doc);
|
||
TAnal_mov mov;
|
||
cont_anal.elabora(doc, 0, NULL, false, mov);
|
||
for (int j = 1; j <= mov.rows(); j++)
|
||
{
|
||
salva_rmovana(mov.body()[j], mov, &doc);
|
||
} //for int j...
|
||
} //for cur_rdoc..
|
||
} //if rdoc_items
|
||
} //FOR_EACH_SHEET_ROW
|
||
|
||
}
|
||
|
||
|
||
void TPrint_rendiconto_ca_recordset::crea_trr(const TFilename& trr) const
|
||
{
|
||
ofstream of(trr);
|
||
of << 1000 << endl;
|
||
of << 15 << endl;
|
||
of << "CONTO|1|20|0|Conto analitico" << endl;
|
||
of << "CODNUM|1|4|0|Numerazione documento" << endl;
|
||
of << "DATA|5|8|0|Data movimento o documento" << endl;
|
||
of << "NUMRD|3|7|0|Numero registrazione o documento" << endl;
|
||
of << "NRIGA|2|3|0|Riga movimento o documento" << endl;
|
||
of << "ANNO|9|4|0|Anno" << endl;
|
||
of << "NUMDOCRIF|1|7|0|Numero documento riferimento" << endl;
|
||
of << "DATADOCRIF|5|8|0|Data documento riferimento" << endl;
|
||
of << "DESC|1|50|0|Descrizione movimento o documento" << endl;
|
||
of << "DESCRIGA|1|50|0|Descrizione riga movimento o documento" << endl;
|
||
of << "DOCORIG|1|20|0|Riferimento ordine/bolla" << endl;
|
||
of << "FATTURATO|4|18|5|Fatturato" << endl;
|
||
of << "MATURATO|4|18|5|Maturato" << endl;
|
||
of << "IMPEGNATO|4|18|5|Impegnato" << endl;
|
||
of << "CONTOCG|1|12|0|Conto contabile" << endl;
|
||
of << 1 << endl;
|
||
of << "CONTO+CODNUM+DATA+NUMRD+NRIGA" << endl;
|
||
}
|
||
|
||
void TPrint_rendiconto_ca_recordset::set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row)
|
||
{
|
||
//se esiste il file temporano con tracciato persomalizzato lo cancella e lo ricrea vuoto
|
||
TFilename trr; //file tracciato record
|
||
trr.tempdir();
|
||
trr.add("rendy");
|
||
TFilename dbf(trr); //file dati
|
||
|
||
trr.ext("trr");
|
||
dbf.ext("dbf");
|
||
|
||
//crea il file .trr in base ai parametri del metodo
|
||
crea_trr(trr);
|
||
|
||
if (_tmp != NULL)
|
||
delete _tmp;
|
||
|
||
_tmp = new TExternisamfile(dbf, trr);
|
||
|
||
//prende un po' di dati dalla maschera...
|
||
_daconto, _aconto, _codcosto = _codcms = _codfas = "";
|
||
if (cms_row >= 0)
|
||
{
|
||
TSheet_field& sf = msk.sfield(F_RIGHE);
|
||
TMask& sm = sf.sheet_mask();
|
||
sf.update_mask(cms_row);
|
||
TRelation rel(LF_RMOVANA);
|
||
sm.autosave(rel);
|
||
_codcosto = rel.curr().get(RMOVANA_CODCCOSTO);
|
||
_codcms = rel.curr().get(RMOVANA_CODCMS);
|
||
_codfas = rel.curr().get(RMOVANA_CODFASE);
|
||
}
|
||
|
||
const char tc = msk.get(F_PIANO)[0]; // Contabile o Analitico?
|
||
const short dlg_da = tc == 'C' ? F_PDC1_INI : F_PAN1_INI;
|
||
const short dlg_al = tc == 'C' ? F_PDC1_FIN : F_PAN1_FIN;
|
||
|
||
//si utilizza la riclassificazione dei conti?
|
||
if (msk.get(F_PIANO) == "A")
|
||
_riclassificato = true;
|
||
else
|
||
_riclassificato = false;
|
||
|
||
//conti non riclassificati
|
||
if (!_riclassificato)
|
||
{
|
||
for (int i = 0; msk.id2pos(dlg_da+i) > 0; i++)
|
||
{
|
||
_daconto << msk.get(dlg_da+i);
|
||
_aconto << msk.get(dlg_al+i);
|
||
}
|
||
}
|
||
else //conti riclassificati
|
||
{
|
||
for (int i = 0; msk.id2pos(dlg_da+i) < 43; i++) //***43 andrebbe sostituito con una condizione + seria
|
||
{
|
||
_da_conto_riclas << msk.get(dlg_da+i);
|
||
_a_conto_riclas << msk.get(dlg_al+i);
|
||
}
|
||
}
|
||
|
||
_dadata = msk.get_date(F_DATAINI);
|
||
_adata = msk.get_date(F_DATAFIN);
|
||
|
||
if (_riclassificato)
|
||
{
|
||
//esiste un prefisso a pi<70> livelli?
|
||
if (msk.get(F_PRE1).not_empty())
|
||
{
|
||
_prefix << msk.get(F_PRE1);
|
||
if (msk.get(F_PRE2).not_empty())
|
||
{
|
||
_prefix << msk.get(F_PRE1);
|
||
if (msk.get(F_PRE3).not_empty())
|
||
_prefix << msk.get(F_PRE3);
|
||
}
|
||
}
|
||
}
|
||
//metodo per riempire il file
|
||
crea_righe_da_rmovana();
|
||
|
||
crea_righe_da_rdoc(msk);
|
||
|
||
}
|
||
|
||
////////////////////////////////////////////////////////
|
||
// REPORT
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_rendiconto_ca_rep : public TAnal_report
|
||
{
|
||
|
||
protected:
|
||
virtual bool set_recordset(const TString& sql);
|
||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||
|
||
public:
|
||
void set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row);
|
||
};
|
||
|
||
bool TPrint_rendiconto_ca_rep::get_usr_val(const TString& name, TVariant& var) const
|
||
{
|
||
return TAnal_report::get_usr_val(name, var);
|
||
}
|
||
|
||
bool TPrint_rendiconto_ca_rep::set_recordset(const TString& sql)
|
||
{
|
||
TPrint_rendiconto_ca_recordset* rs = new TPrint_rendiconto_ca_recordset(sql);
|
||
return TReport::set_recordset(rs);
|
||
}
|
||
|
||
void TPrint_rendiconto_ca_rep::set_filter(const TPrint_rendiconto_ca_mask& msk, int cms_row)
|
||
{
|
||
TPrint_rendiconto_ca_recordset* recset = NULL;
|
||
|
||
const char* query ="USE 1000\nJOIN MOVANA INTO NUMREG==NUMRD\nJOIN RMOVANA INTO NUMREG==NUMRD NUMRIG==NRIGA";
|
||
|
||
recset = new TPrint_rendiconto_ca_recordset(query);
|
||
|
||
recset->set_filter(msk, cms_row);
|
||
TAnal_report::set_recordset(recset);
|
||
}
|
||
|
||
////////////////////////////////////////////////////////
|
||
// APPLICAZIONE
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_rendiconto_ca : public TSkeleton_application
|
||
{
|
||
TPrint_rendiconto_ca_mask * _mask;
|
||
|
||
protected:
|
||
bool create();
|
||
bool destroy();
|
||
|
||
public:
|
||
virtual void main_loop();
|
||
};
|
||
|
||
bool TPrint_rendiconto_ca::create()
|
||
{
|
||
_mask = new TPrint_rendiconto_ca_mask;
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
bool TPrint_rendiconto_ca::destroy()
|
||
{
|
||
delete _mask;
|
||
return TSkeleton_application::destroy();
|
||
}
|
||
|
||
void TPrint_rendiconto_ca::main_loop()
|
||
{
|
||
while (_mask->run() == K_ENTER)
|
||
{
|
||
//costruzione della query x il report in base ai parametri della maschera
|
||
TSheet_field& sheet = _mask->sfield(F_RIGHE);
|
||
const int n_righe_sheet = sheet.items();
|
||
//se lo sheet <20> vuoto aggiunge una riga vuota
|
||
if (n_righe_sheet == 0)
|
||
sheet.insert();
|
||
|
||
//report e book
|
||
TReport_book book; //book dei report
|
||
TString path = _mask->get(F_REPORT);
|
||
if (path.empty())
|
||
path = "ca3700a";
|
||
TPrint_rendiconto_ca_rep rep;
|
||
rep.load(path);
|
||
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
rep.set_filter(*_mask, r);
|
||
book.add(rep);
|
||
}
|
||
|
||
book.print_or_preview(); //stampa il book dei report
|
||
}
|
||
}
|
||
|
||
int ca3700(int argc, char* argv[])
|
||
{
|
||
TPrint_rendiconto_ca a;
|
||
a.run(argc, argv, TR("Stampa rendiconto"));
|
||
return 0;
|
||
}
|