Alessandro Bonazzi
784ec2bba4
Files correlati : ca3.exe ca3100.msk ca3200.msk ca3300.msk ca3600.msk ca3700.msk ca3700b.rep ca3800.msk ca3900.msk Commento : Ripristinata l'esportazione sintetica del rendiconto corretta la selezione dei report era possibile selezionare un report non compatibile
420 lines
11 KiB
C++
Executable File
420 lines
11 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <defmask.h>
|
||
#include <execp.h>
|
||
#include <repapp.h>
|
||
|
||
#include "commesse.h"
|
||
#include "cdc.h"
|
||
#include "fasi.h"
|
||
#include "movana.h"
|
||
#include "rmovana.h"
|
||
|
||
#include "ca3.h"
|
||
#include "ca3100.h"
|
||
#include "calib01.h"
|
||
#include "calib02.h"
|
||
#include "camask.h"
|
||
|
||
////////////////////////////////////////////////////////
|
||
// MASCHERA
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_movimenti_ca_mask : public TAnal_report_mask
|
||
{
|
||
protected:
|
||
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
void create_page2();
|
||
int create_page2_sheet(int lf, int& y, short& dlg, bool required);
|
||
|
||
public:
|
||
virtual const TString & get_report_class() const;
|
||
TPrint_movimenti_ca_mask();
|
||
virtual ~TPrint_movimenti_ca_mask() {}
|
||
};
|
||
|
||
const TString & TPrint_movimenti_ca_mask::get_report_class() const
|
||
{
|
||
TString classe = TAnal_report_mask::get_report_class();
|
||
const int stp = get_int(F_TIPOSTAMPA);
|
||
|
||
classe.cut(6);
|
||
classe << (stp == 1 ? 'a' : 'b'); // tipo di report da usare
|
||
return get_tmp_string() = classe;
|
||
}
|
||
|
||
bool TPrint_movimenti_ca_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case F_TIPOSTAMPA:
|
||
if (e == fe_modify || e == fe_init)
|
||
set_report_class();
|
||
break;
|
||
case F_DATAINI:
|
||
case F_DATAFIN:
|
||
if (e == fe_close)
|
||
{
|
||
const TString& anno = get(F_ANNO);
|
||
if (anno.not_empty()) //se l'anno esercizio esiste...
|
||
{
|
||
const TRectype& esc = cache().get("ESC", anno);
|
||
const TDate datainiesc = esc.get("D0");
|
||
const TDate datafinesc = esc.get("D1");
|
||
if (o.empty())
|
||
{
|
||
const TDate dataesc = o.dlg() == F_DATAINI ? datainiesc : datafinesc;
|
||
o.set(dataesc.string());
|
||
}
|
||
else
|
||
{
|
||
const TDate d = o.get();
|
||
if (d < datainiesc || d > datafinesc)
|
||
return error_box(TR("La data deve essere compresa nell'esercizio selezionato"));
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
TPrint_movimenti_ca_mask::TPrint_movimenti_ca_mask()
|
||
:TAnal_report_mask("ca3100")
|
||
{
|
||
TConfig& cfg = ca_config();
|
||
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
||
|
||
const int logicnum = use_pdcc ? LF_PCON : LF_PCONANA;
|
||
|
||
// creazione dei campi della seconda pagina della maschera
|
||
create_sheet(F_RIGHE);
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// RECORDSET
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TPrint_movimenti_ca_recordset : public TISAM_recordset
|
||
{
|
||
int _anno, _tipoord;
|
||
TDate _dadata, _adata;
|
||
char _tipomov;
|
||
long _danumreg, _anumreg;
|
||
TString4 _dacaus, _acaus;
|
||
TString _codcosto, _codcms, _codfas, _contsep;
|
||
|
||
protected:
|
||
const TVariant& get(const char* column_name) const;
|
||
static bool mov_filter(const TRelation* rel);
|
||
bool valid_record(const TRelation& rel) const;
|
||
virtual void set_custom_filter(TCursor& cur) const;
|
||
|
||
public:
|
||
void set_filter(const TPrint_movimenti_ca_mask& msk, int cms_row);
|
||
TPrint_movimenti_ca_recordset(const TString& sql) : TISAM_recordset(sql) { }
|
||
};
|
||
|
||
static const TPrint_movimenti_ca_recordset* myself = nullptr;
|
||
|
||
//metodo per riconoscere se il record corrente soddisfa i filtri della maschera...strafighissimo!
|
||
bool TPrint_movimenti_ca_recordset::valid_record(const TRelation& rel) const
|
||
{
|
||
//prima controlla la testata...
|
||
const TRectype& mov = rel.curr(LF_MOVANA);
|
||
const TRectype& rmov = rel.curr(LF_RMOVANA);
|
||
|
||
switch (_tipoord)
|
||
{
|
||
case 1: //controllo sul numreg
|
||
{
|
||
const long numreg = mov.get_long(MOVANA_NUMREG);
|
||
const int nr = rmov.get_int(RMOVANA_NUMRIG);
|
||
|
||
if (nr > 1)
|
||
int i = 1;
|
||
if (!between(numreg, _danumreg, _anumreg))
|
||
return false;
|
||
}
|
||
break;
|
||
case 2: //controllo sulle date
|
||
{
|
||
const TDate data = mov.get(_anno > 0 ? MOVANA_DATACOMP : MOVANA_DATAREG);
|
||
|
||
if (!data.between(_dadata, _adata))
|
||
return false;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
const TString& codcaus = mov.get(MOVANA_CODCAUS);
|
||
if (codcaus < _dacaus || (_acaus.not_empty() && codcaus > _acaus))
|
||
return false;
|
||
|
||
if (_tipomov > ' ')
|
||
{
|
||
char tipomov = mov.get_char(MOVANA_TIPOMOV);
|
||
//attenzione! i movimenti normali non hanno 'N' in TIPOMOV, ma solo il carattere terminatore di stringa!
|
||
//quindi se il valore di TIPOMOV <20> < spazio -> il movimento <20> di tipo normale
|
||
if (tipomov <= ' ')
|
||
tipomov = 'N';
|
||
if (tipomov != _tipomov)
|
||
return false;
|
||
}
|
||
//..poi le righe (devono comparire solo le righe con cdc/cms/fsc che appaiono nello sheet)
|
||
if (_codcosto.full() && !rmov.get(RMOVANA_CODCCOSTO).starts_with(_codcosto))
|
||
return false;
|
||
if (_codcms.full() && !rmov.get(RMOVANA_CODCMS).starts_with(_codcms))
|
||
return false;
|
||
if (_codfas.full() && !rmov.get(RMOVANA_CODFASE).starts_with(_codfas))
|
||
return false;
|
||
if (_contsep.full() && _contsep != mov.get(MOVANA_CONTSEP))
|
||
return false;
|
||
return true;
|
||
}
|
||
|
||
const TVariant& TPrint_movimenti_ca_recordset::get(const char* column_name) const
|
||
{
|
||
const TFixed_string fld(column_name);
|
||
|
||
if (fld == "#COSTO")
|
||
return get_tmp_var() = _codcosto;
|
||
else
|
||
if (fld == "#COMMESSA")
|
||
return get_tmp_var() = _codcms;
|
||
else
|
||
if (fld == "#FASE")
|
||
return get_tmp_var() = _codfas;
|
||
else
|
||
if (fld == "#CONTSEP")
|
||
return get_tmp_var() = _contsep;
|
||
return TISAM_recordset::get(column_name);
|
||
}
|
||
|
||
bool TPrint_movimenti_ca_recordset::mov_filter(const TRelation* rel)
|
||
{
|
||
return myself->valid_record(*rel);
|
||
}
|
||
|
||
void TPrint_movimenti_ca_recordset::set_custom_filter(TCursor& cur) const
|
||
{
|
||
myself = this;
|
||
cur.set_filterfunction(mov_filter, true);
|
||
}
|
||
|
||
//metodo per caricare i valori nel recordset dalla maschera...fighissimo!!
|
||
void TPrint_movimenti_ca_recordset::set_filter(const TPrint_movimenti_ca_mask& msk, int cms_row)
|
||
{
|
||
_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);
|
||
}
|
||
|
||
_tipoord = msk.get_int(F_TIPOSTAMPA);
|
||
|
||
//stabilisce il tipo di data di ordinamento del recordset
|
||
_anno = msk.get_int(F_ANNO);
|
||
|
||
if (_anno > 0)
|
||
set_var("#DATAORD", MOVANA_DATACOMP, true);
|
||
else
|
||
set_var("#DATAORD", MOVANA_DATAREG, true);
|
||
|
||
_dadata = msk.get_date(F_DATAINI);
|
||
_adata = msk.get_date(F_DATAFIN);
|
||
|
||
_danumreg = msk.get_long(F_NUMEROINI);
|
||
_anumreg = msk.get_long(F_NUMEROFIN);
|
||
|
||
_dacaus = msk.get(F_CAUSALEINI);
|
||
_acaus = msk.get(F_CAUSALEFIN);
|
||
|
||
_tipomov = msk.get(F_TIPOMOV)[0];
|
||
_contsep = msk.get(F_CONTSEP);
|
||
}
|
||
|
||
////////////////////////////////////////////////////////
|
||
// REPORT
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_movimenti_ca_rep : public TAnal_report
|
||
{
|
||
int _anno, _tipoord;
|
||
TDate _dadata, _adata;
|
||
long _danumreg, _anumreg;
|
||
|
||
protected:
|
||
virtual bool set_recordset(const TString& sql);
|
||
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||
virtual const char * get_excel_header_section() { return get_class() == "ca3100a" ? "H0|H1|H2" : "H0|H2|H3"; }
|
||
virtual void set_dbase_fixed_fields(bool on = true);
|
||
|
||
public:
|
||
void set_filter(const TPrint_movimenti_ca_mask& msk, int cms_row);
|
||
};
|
||
|
||
bool TPrint_movimenti_ca_rep::get_usr_val(const TString& name, TVariant& var) const
|
||
{
|
||
if (name == "#ESERCIZIO")
|
||
{
|
||
var.set(_anno);
|
||
return true;
|
||
}
|
||
else
|
||
if (name == "#DADATA")
|
||
{
|
||
var.set(_dadata);
|
||
return true;
|
||
}
|
||
else
|
||
if (name == "#ADATA")
|
||
{
|
||
var.set(_adata);
|
||
return true;
|
||
}
|
||
else
|
||
if (name == "#DANUMREG")
|
||
{
|
||
var.set(_danumreg);
|
||
return true;
|
||
}
|
||
else
|
||
if (name == "#ANUMREG")
|
||
{
|
||
var.set(_anumreg);
|
||
return true;
|
||
}
|
||
return TAnal_report::get_usr_val(name, var);
|
||
}
|
||
|
||
bool TPrint_movimenti_ca_rep::set_recordset(const TString& sql)
|
||
{
|
||
TPrint_movimenti_ca_recordset* rs = new TPrint_movimenti_ca_recordset(sql);
|
||
return TReport::set_recordset(rs);
|
||
}
|
||
|
||
void TPrint_movimenti_ca_rep::set_dbase_fixed_fields(bool on)
|
||
{
|
||
field("B1.201")->show(on);
|
||
field("B1.202")->show(on);
|
||
}
|
||
|
||
void TPrint_movimenti_ca_rep::set_filter(const TPrint_movimenti_ca_mask& msk, int cms_row)
|
||
{
|
||
_anno = msk.get_int(F_ANNO);
|
||
_tipoord = msk.get_int(F_TIPOSTAMPA);
|
||
_dadata = msk.get_date(F_DATAINI);
|
||
_adata = msk.get_date(F_DATAFIN);
|
||
_danumreg = msk.get_long(F_NUMEROINI);
|
||
_anumreg = msk.get_long(F_NUMEROFIN);
|
||
TPrint_movimenti_ca_recordset* rs = (TPrint_movimenti_ca_recordset*)recordset();
|
||
rs->set_filter(msk, cms_row);
|
||
}
|
||
|
||
|
||
////////////////////////////////////////////////////////
|
||
// APPLICAZIONE
|
||
////////////////////////////////////////////////////////
|
||
class TPrint_movimenti_ca : public TReport_application
|
||
{
|
||
TPrint_movimenti_ca_mask * _mask;
|
||
TPrint_movimenti_ca_rep * _rep;
|
||
|
||
protected:
|
||
virtual const char * extra_modules() const {return "cm";} //funziona anche con autorizzazione CM
|
||
virtual TReport & get_report(const TAutomask & m);
|
||
virtual TTrec * get_dbase_recdesc(TReport & rep, const TAutomask & mask);
|
||
virtual TAutomask & get_mask();
|
||
virtual void execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type & type);
|
||
virtual const char * output_name(const TAutomask & mask, const TReport & rep) const { return "lmov"; }
|
||
// @cmember Distruzione dei dati dell'utente
|
||
virtual bool user_destroy();
|
||
|
||
public:
|
||
TPrint_movimenti_ca() : _mask(nullptr), _rep(nullptr) {}
|
||
~TPrint_movimenti_ca() {}
|
||
};
|
||
|
||
TReport & TPrint_movimenti_ca::get_report(const TAutomask & m)
|
||
{
|
||
if (_rep == nullptr)
|
||
_rep = new TPrint_movimenti_ca_rep;
|
||
_rep->load(_mask->get(DLG_REPORT));
|
||
return * _rep;
|
||
}
|
||
|
||
TTrec * TPrint_movimenti_ca::get_dbase_recdesc(TReport & rep, const TAutomask & mask)
|
||
{
|
||
TTrec * desc = new TTrec;
|
||
TToken_string def;
|
||
TRectype cms(LF_COMMESSE);
|
||
TRectype fasi(LF_FASI);
|
||
TRectype cdc(LF_CDC);
|
||
TRectype rmovana(LF_RMOVANA);
|
||
TRectype movana(LF_MOVANA);
|
||
const int tipostampa = mask.get_int(F_TIPOSTAMPA);
|
||
|
||
desc->add_fielddef(rmovana.rec_des(), RMOVANA_NUMRIG);
|
||
desc->add_fielddef(cdc.rec_des(), CDC_CODCOSTO);
|
||
desc->add_fielddef(cms.rec_des(), COMMESSE_CODCMS);
|
||
desc->add_fielddef(fasi.rec_des(), FASI_CODFASE);
|
||
desc->add_fielddef(rmovana.rec_des(), RMOVANA_CODCONTO);
|
||
desc->add_fielddef(rmovana.rec_des(), RMOVANA_DESCR);
|
||
desc->add_fielddef(movana.rec_des(), MOVANA_TIPOMOV);
|
||
desc->add_fielddef("DARE", _realfld, 18, 2);
|
||
desc->add_fielddef("AVERE", _realfld, 18, 2);
|
||
desc->add_fielddef(movana.rec_des(), MOVANA_NUMREG);
|
||
desc->add_fielddef(movana.rec_des(), MOVANA_CONTSEP);
|
||
|
||
TToken_string keydef(MOVANA_NUMREG, '+');
|
||
|
||
keydef.add(RMOVANA_NUMRIG);
|
||
|
||
desc->add_keydef(keydef, true);
|
||
return desc;
|
||
}
|
||
|
||
TAutomask & TPrint_movimenti_ca::get_mask()
|
||
{
|
||
if (_mask == nullptr)
|
||
_mask = new TPrint_movimenti_ca_mask;
|
||
return *_mask;
|
||
}
|
||
|
||
void TPrint_movimenti_ca::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type & type)
|
||
{
|
||
//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();
|
||
FOR_EACH_SHEET_ROW(sheet, r, row)
|
||
{
|
||
((TPrint_movimenti_ca_rep &) rep).set_filter((TPrint_movimenti_ca_mask &) mask, r);
|
||
book.add(rep, type);
|
||
}
|
||
}
|
||
|
||
bool TPrint_movimenti_ca::user_destroy()
|
||
{
|
||
safe_delete(_mask);
|
||
safe_delete(_rep);
|
||
return TReport_application::user_destroy();
|
||
}
|
||
|
||
int ca3100(int argc, char* argv[])
|
||
{
|
||
TPrint_movimenti_ca a;
|
||
a.run(argc, argv, TR("Stampa movimenti"));
|
||
return 0;
|
||
} |