Files correlati : ca3.exe ca3200a.rep Commento: La stampa mastrini di tutte le commesse suddivisa per commessa non stampava nulla
742 lines
22 KiB
C++
Executable File
742 lines
22 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <defmask.h>
|
|
#include <execp.h>
|
|
#include <progind.h>
|
|
#include <repapp.h>
|
|
|
|
#include "../cg/cglib.h"
|
|
|
|
#include "commesse.h"
|
|
#include "cdc.h"
|
|
#include "fasi.h"
|
|
#include "pconana.h"
|
|
#include "movana.h"
|
|
#include "rmovana.h"
|
|
|
|
#include "ca3.h"
|
|
#include "ca3200.h"
|
|
#include "calib01.h"
|
|
#include "calib02.h"
|
|
#include "camask.h"
|
|
|
|
////////////////////////////////////////////////////////
|
|
// MASCHERA
|
|
////////////////////////////////////////////////////////
|
|
class TPrint_mastrini_ca_mask : public TAnal_report_mask
|
|
{
|
|
protected:
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
virtual const TString & get_report_class() const;
|
|
TPrint_mastrini_ca_mask();
|
|
virtual ~TPrint_mastrini_ca_mask() {}
|
|
};
|
|
|
|
const TString & TPrint_mastrini_ca_mask::get_report_class() const
|
|
{
|
|
TString classe = TAnal_report_mask::get_report_class();
|
|
const bool per_conto = get_bool(F_PERCONTO);
|
|
|
|
classe.cut(6);
|
|
classe << (per_conto ? 'b' : 'a'); // tipo di report da usare
|
|
return get_tmp_string() = classe;
|
|
}
|
|
|
|
bool TPrint_mastrini_ca_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case F_PERCONTO:
|
|
if (e == fe_modify || e == fe_init)
|
|
set_report_class();
|
|
break;
|
|
case F_ANNO:
|
|
if (e == fe_modify && !o.empty())
|
|
{
|
|
TEsercizi_contabili esc;
|
|
TDate inies, fines;
|
|
if (esc.code2range(atoi(o.get()), inies, fines))
|
|
{
|
|
set(F_DATAINI, inies);
|
|
set(F_DATAFIN, fines);
|
|
}
|
|
}
|
|
break;
|
|
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 è vuoto le date diventano obbligatorie!!
|
|
{
|
|
if (o.empty())
|
|
return error_box(TR("La data è obbligatoria in quanto manca l'esercizio"));
|
|
}
|
|
}
|
|
break;
|
|
default: break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
TPrint_mastrini_ca_mask::TPrint_mastrini_ca_mask()
|
|
: TAnal_report_mask("ca3200")
|
|
{
|
|
TConfig& cfg = ca_config();
|
|
const bool use_pdcc = cfg.get_bool("UsePdcc");
|
|
|
|
const int logicnum = use_pdcc ? LF_PCON : LF_PCONANA;
|
|
const int nfields = ca_create_fields(*this, 1, logicnum, 2, 4, F_CDC1_INI, F_DES1_INI, 0x0, "#DACONTO");
|
|
ca_create_fields(*this, 1, logicnum, 2, 10, F_CDC1_FIN, F_DES1_FIN, 0x0, "#ACONTO");
|
|
|
|
for (int i = 0; i < nfields; i++)
|
|
{
|
|
TMask_field& daconto = field(F_CDC1_INI + i);
|
|
daconto.set_group(1);
|
|
daconto.check_type(CHECK_NORMAL);
|
|
TMask_field& aconto = field(F_CDC1_FIN + i);
|
|
aconto.set_group(2);
|
|
aconto.check_type(CHECK_NORMAL);
|
|
}
|
|
// creazione dei campi della seconda pagina della maschera
|
|
create_sheet(F_RIGHE);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// RECORDSET PRINCIPALE (caso standard: conti movimentati)
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
class TPrint_mastrini_ca_recordset : public TISAM_recordset
|
|
{
|
|
protected:
|
|
int _anno;
|
|
int _tipoconti;
|
|
int _tipimov;
|
|
TDate _dadata, _adata;
|
|
long _danumreg, _anumreg;
|
|
TString _daconto, _aconto, _codcosto, _codcms, _codfas, _contsep;
|
|
|
|
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;
|
|
const TImporto& saldo_iniziale(const char* conto) const;
|
|
|
|
public:
|
|
virtual void set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row);
|
|
TPrint_mastrini_ca_recordset(const TString& sql) : TISAM_recordset(sql) { }
|
|
};
|
|
|
|
static const TPrint_mastrini_ca_recordset* myself = NULL;
|
|
|
|
//metodo per riconoscere se il record corrente soddisfa i filtri della maschera...strafighissimo!
|
|
bool TPrint_mastrini_ca_recordset::valid_record(const TRelation& rel) const
|
|
{
|
|
//prima controlla la testata...
|
|
const TRectype& mov = rel.curr(LF_MOVANA);
|
|
|
|
const char tipomov = mov.get_char(MOVANA_TIPOMOV);
|
|
int tipomov_int = 0;
|
|
switch (tipomov)
|
|
{
|
|
case 'P': tipomov_int = 2; break;
|
|
case 'V': tipomov_int = 4; break;
|
|
default : tipomov_int = 1; break;
|
|
}
|
|
if ((_tipimov & tipomov_int) == 0)
|
|
return false;
|
|
|
|
//aggiunta 01/12/08; se non si specifica l'esercizio si DEVE tener conto della DATAREG e non della DATACOMP; quindi..
|
|
//..deve effettuare tale controllo e controllare se la datareg rientra nell'intervallo di date selezionato sulla maschera
|
|
if (_anno <= 0)
|
|
{
|
|
const TDate datareg = mov.get_date(MOVANA_DATAREG);
|
|
if (_dadata.ok() && datareg < _dadata)
|
|
return false;
|
|
if (_adata.ok() && datareg > _adata)
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
const TDate datacomp = mov.get_date(MOVANA_DATACOMP);
|
|
if (_dadata.ok() && datacomp < _dadata)
|
|
return false;
|
|
if (_adata.ok() && datacomp > _adata)
|
|
return false;
|
|
|
|
const TDate datafcomp = mov.get_date(MOVANA_DATAFCOMP);
|
|
if (datafcomp.ok() && _dadata.ok() && datafcomp < _dadata)
|
|
return false;
|
|
}
|
|
|
|
//..poi le righe (devono comparire solo le righe con cdc/cms/fsc che appaiono nello sheet)
|
|
const TRectype& rmov = rel.curr(LF_RMOVANA);
|
|
|
|
if (_codcosto.not_empty())
|
|
{
|
|
const TString& cos = rmov.get(RMOVANA_CODCCOSTO);
|
|
if (cos != _codcosto)
|
|
return false;
|
|
}
|
|
if (_codcms.not_empty())
|
|
{
|
|
const TString& cms = rmov.get(RMOVANA_CODCMS);
|
|
if (cms != _codcms)
|
|
return false;
|
|
}
|
|
if (_codfas.not_empty())
|
|
{
|
|
const TString& fas = rmov.get(RMOVANA_CODFASE);
|
|
if (fas != _codfas)
|
|
return false;
|
|
}
|
|
if (_contsep.not_empty())
|
|
{
|
|
const TString& contsep = mov.get(MOVANA_CONTSEP);
|
|
if (contsep != _contsep)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TPrint_mastrini_ca_recordset::mov_filter(const TRelation* rel)
|
|
{
|
|
return myself->valid_record(*rel);
|
|
}
|
|
|
|
void TPrint_mastrini_ca_recordset::set_custom_filter(TCursor& cur) const
|
|
{
|
|
//filtro sui conti selezionati sulla maschera
|
|
TRectype darec(cur.curr()), arec(cur.curr()); //record corrente (rmovana (solo movimentati))
|
|
|
|
if (_daconto.full())
|
|
darec.put(RMOVANA_CODCONTO, _daconto);
|
|
|
|
if (_aconto.full())
|
|
arec.put(RMOVANA_CODCONTO, _aconto);
|
|
|
|
cur.setregion(darec, arec);
|
|
|
|
myself = this;
|
|
cur.set_filterfunction(mov_filter, true); //questa gestirà le date
|
|
}
|
|
|
|
const TImporto& TPrint_mastrini_ca_recordset::saldo_iniziale(const char* conto) const
|
|
{
|
|
TAnal_bill bill(conto, _codcosto, _codcms, _codfas);
|
|
const TSaldanal& saldo = ca_saldo(bill, _contsep, _dadata, _adata, _tipimov);
|
|
|
|
return saldo._ini;
|
|
}
|
|
|
|
const TVariant& TPrint_mastrini_ca_recordset::get(const char* column_name) const
|
|
{
|
|
const TFixed_string fld(column_name);
|
|
if (fld.starts_with("SALDOINI:"))
|
|
{
|
|
const TString16 sub_field = column_name+9;
|
|
const TString& conto = get(RMOVANA_CODCONTO).as_string();
|
|
const TImporto& saldo_ini = saldo_iniziale(conto);
|
|
|
|
TVariant& var = get_tmp_var();
|
|
if (sub_field == "DARE")
|
|
var = saldo_ini.sezione() == 'D' ? saldo_ini.valore() : ZERO;
|
|
else
|
|
var = saldo_ini.sezione() == 'A' ? saldo_ini.valore() : ZERO;
|
|
return var;
|
|
}
|
|
else
|
|
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);
|
|
}
|
|
|
|
//metodo per caricare i valori nel recordset dalla maschera...fighissimo!!
|
|
void TPrint_mastrini_ca_recordset::set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row)
|
|
{
|
|
_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);
|
|
}
|
|
_contsep = msk.get(F_CONTSEP);
|
|
for (int i = 0; msk.id2pos(F_CDC1_INI+i) > 0; i++)
|
|
{
|
|
_daconto << msk.get(F_CDC1_INI+i);
|
|
_aconto << msk.get(F_CDC1_FIN+i);
|
|
}
|
|
|
|
_anno = msk.get_int(F_ANNO);
|
|
_dadata = msk.get_date(F_DATAINI);
|
|
_adata = msk.get_date(F_DATAFIN);
|
|
|
|
_tipimov = 0;
|
|
switch (msk.get(F_TIPIMOV)[0])
|
|
{
|
|
case 'N': _tipimov = 1; break;
|
|
case 'P': _tipimov = 6; break;
|
|
default: _tipimov = 7; break;
|
|
}
|
|
_tipoconti = msk.get_int(F_TIPOCONTI);
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
// RECORDSET SECONDARIO (casi alternativi: conti con saldo != 0 e tutti i conti)
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TPrint_mastrini_ca_alternative_recordset : public TPrint_mastrini_ca_recordset
|
|
{
|
|
TIsamtempfile* _tmp_rmovana;
|
|
protected:
|
|
const TImporto& saldo_finale(const char* conto) const;
|
|
virtual void set_custom_filter(TCursor& cur) const;
|
|
|
|
public:
|
|
virtual void set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row);
|
|
TPrint_mastrini_ca_alternative_recordset(const TString& sql);
|
|
~TPrint_mastrini_ca_alternative_recordset() { delete _tmp_rmovana; }
|
|
};
|
|
|
|
TPrint_mastrini_ca_alternative_recordset::TPrint_mastrini_ca_alternative_recordset(const TString& sql)
|
|
: TPrint_mastrini_ca_recordset(sql)
|
|
{
|
|
_tmp_rmovana = NULL;
|
|
}
|
|
|
|
|
|
const TImporto& TPrint_mastrini_ca_alternative_recordset::saldo_finale(const char* conto) const
|
|
{
|
|
TAnal_bill bill(conto, _codcosto, _codcms, _codfas);
|
|
const TSaldanal& saldo = ca_saldo(bill, "", _dadata, _adata, _tipimov); // qui
|
|
|
|
return saldo._fin;
|
|
}
|
|
|
|
void TPrint_mastrini_ca_alternative_recordset::set_custom_filter(TCursor& cur) const
|
|
{
|
|
//crea un file temporaneo che non viene distrutto ad inizio stampa effettiva
|
|
TIsamtempfile* tmp = new TIsamtempfile(LF_RMOVANA, "anal", false, false);
|
|
relation()->replace(tmp); //sostituisce il vero file rmovana con quello temporaneo
|
|
}
|
|
|
|
void TPrint_mastrini_ca_alternative_recordset::set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row)
|
|
{
|
|
//se esiste non vuoto il file temporano con tracciato rmovana lo cancella e lo ricrea vuoto
|
|
if (_tmp_rmovana != NULL)
|
|
delete _tmp_rmovana;
|
|
|
|
_tmp_rmovana = new TIsamtempfile(LF_RMOVANA, "anal", true, true);
|
|
|
|
//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);
|
|
}
|
|
|
|
for (int i = 0; msk.id2pos(F_CDC1_INI+i) > 0; i++)
|
|
{
|
|
_daconto << msk.get(F_CDC1_INI+i);
|
|
_aconto << msk.get(F_CDC1_FIN+i);
|
|
}
|
|
|
|
_dadata = msk.get_date(F_DATAINI);
|
|
_adata = msk.get_date(F_DATAFIN);
|
|
// Riempie le date con valori sensati
|
|
if (!_dadata.ok() || !_adata.ok())
|
|
{
|
|
TEsercizi_contabili esc;
|
|
const int codes = msk.get_int(F_ANNO);
|
|
if (esc.exist(codes))
|
|
{
|
|
const TEsercizio& esercizio = esc[codes];
|
|
if (!_dadata.ok())
|
|
_dadata = esercizio.inizio();
|
|
if (!_adata.ok())
|
|
_adata = esercizio.fine();
|
|
}
|
|
else
|
|
{
|
|
if (!_adata.ok())
|
|
_adata = TDate(31, 12, 9999);
|
|
}
|
|
}
|
|
|
|
_tipimov = 0;
|
|
switch (msk.get(F_TIPIMOV)[0])
|
|
{
|
|
case 'N': _tipimov = 1; break;
|
|
case 'P': _tipimov = 6; break;
|
|
default: _tipimov = 7; break;
|
|
}
|
|
|
|
_tipoconti = msk.get_int(F_TIPOCONTI);
|
|
|
|
//scandisce il piano dei conti analitico creando un cursore con i conti nell'intervallo scelto sulla maschera
|
|
if (cms_row >= 0)
|
|
{
|
|
TPconana_recordset pconana;
|
|
|
|
pconana.set_filter(' ', _daconto, _aconto, _codcosto, _codcms, _codfas, _contsep,
|
|
_dadata, _adata, _tipimov, _tipoconti==1, _tipoconti==2);
|
|
|
|
const long pconana_items = pconana.items();
|
|
TProgind pi(pconana_items, TR("Scansione conti..."));
|
|
|
|
TRelation rel_rmovana(LF_RMOVANA);
|
|
rel_rmovana.add(LF_MOVANA, "NUMREG==NUMREG"); //aggiunge le testate x avere i tipi mov.
|
|
|
|
TRectype da_rmovana(LF_RMOVANA);
|
|
da_rmovana.put(RMOVANA_DATACOMP, _dadata);
|
|
TRectype a_rmovana(LF_RMOVANA);
|
|
a_rmovana.put(RMOVANA_DATACOMP, _adata);
|
|
|
|
TString filtro;
|
|
if (_codcosto.full())
|
|
filtro << "(" << RMOVANA_CODCCOSTO << "?=\"" << _codcosto << "*\")";
|
|
if (_codcms.full())
|
|
{
|
|
if (filtro.full())
|
|
filtro << "&&";
|
|
filtro << "(" << RMOVANA_CODCMS << "?=\"" << _codcms << "*\")";
|
|
}
|
|
if (_codfas.full())
|
|
{
|
|
if (filtro.full())
|
|
filtro << "&&";
|
|
filtro << "(" << RMOVANA_CODFASE << "?=\"" << _codfas << "*\")";
|
|
}
|
|
if (_contsep.full())
|
|
{
|
|
if (filtro.full())
|
|
filtro << "&&";
|
|
filtro << "(" << MOVANA_CONTSEP << "==\"" << _contsep << "*\")";
|
|
}
|
|
|
|
//scandisce il piano dei conti..
|
|
for (bool pok = pconana.move_first(); pok; pok = pconana.move_next())
|
|
{
|
|
if (!pi.addstatus(1))
|
|
break;
|
|
const TString& conto = pconana.get(PCONANA_CODCONTO).as_string();
|
|
|
|
//..crea un cursore su rmovana per vedere se i conti selezionati hanno veri movimenti che soddisfano
|
|
//i parametri del filtro sulla maschera
|
|
da_rmovana.put(RMOVANA_CODCONTO, conto);
|
|
a_rmovana.put(RMOVANA_CODCONTO, conto);
|
|
|
|
TCursor cur_rmovana(&rel_rmovana, filtro, 2, &da_rmovana, &a_rmovana);
|
|
const long rmovana_items = cur_rmovana.items();
|
|
bool almeno_uno_aggiunto = false;
|
|
if (rmovana_items > 0)
|
|
{
|
|
cur_rmovana.freeze();
|
|
for (cur_rmovana = 0; cur_rmovana.pos() < rmovana_items; ++cur_rmovana)
|
|
{
|
|
//deve coincidere anche il tipomov! sarebbe stato troppo semplice...
|
|
const char tipomov = rel_rmovana.curr(LF_MOVANA).get_char(MOVANA_TIPOMOV);
|
|
int tipomov_int = 0;
|
|
switch (tipomov)
|
|
{
|
|
case 'P': tipomov_int = 2; break;
|
|
case 'V': tipomov_int = 4; break;
|
|
default: tipomov_int = 1; break;
|
|
}
|
|
if ((_tipimov & tipomov_int) != 0)
|
|
{
|
|
_tmp_rmovana->write(cur_rmovana.curr()); // aggiunge i record al file temporaneo
|
|
almeno_uno_aggiunto = true;
|
|
}
|
|
}
|
|
cur_rmovana.freeze(false);
|
|
}
|
|
//se non ha aggiunto nemmeno un record valido..
|
|
//crea un record di rmovana con il solo conto,datacomp e lo aggiunge al file temporaneo
|
|
if (!almeno_uno_aggiunto)
|
|
{
|
|
TRectype fake_rmovana_rec(LF_RMOVANA);
|
|
fake_rmovana_rec.put(RMOVANA_CODCONTO, conto);
|
|
fake_rmovana_rec.put(RMOVANA_DATACOMP, _dadata);
|
|
_tmp_rmovana->write(fake_rmovana_rec);
|
|
}
|
|
|
|
} //end for su pconana_items
|
|
}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////
|
|
// REPORT
|
|
////////////////////////////////////////////////////////
|
|
class TPrint_mastrini_ca_rep : public TAnal_report
|
|
{
|
|
protected:
|
|
virtual bool set_recordset(const TString& sql);
|
|
virtual const char * get_excel_header_section() { return "H1|H2"; }
|
|
virtual void set_dbase_fixed_fields(bool on);
|
|
|
|
public:
|
|
void set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row);
|
|
};
|
|
|
|
bool TPrint_mastrini_ca_rep::set_recordset(const TString& sql)
|
|
{
|
|
TPrint_mastrini_ca_recordset* rs = new TPrint_mastrini_ca_recordset(sql);
|
|
return TReport::set_recordset(rs);
|
|
}
|
|
|
|
void TPrint_mastrini_ca_rep::set_dbase_fixed_fields(bool on)
|
|
{
|
|
field("B1.201")->show(on);
|
|
field("B1.202")->show(on);
|
|
field("B1.203")->show(on);
|
|
field("B1.204")->show(on);
|
|
field("B1.205")->show(on);
|
|
}
|
|
|
|
void TPrint_mastrini_ca_rep::set_filter(const TPrint_mastrini_ca_mask& msk, int cms_row)
|
|
{
|
|
TReport::set_recordset(NULL); //forza azzeramento file anal.dbf prima di ricostruirlo
|
|
|
|
const int tipoconti = msk.get_int(F_TIPOCONTI);
|
|
|
|
TPrint_mastrini_ca_recordset* recset = NULL;
|
|
|
|
const char* const query ="USE RMOVANA KEY 2\nJOIN MOVANA INTO NUMREG==NUMREG\nJOIN MOV TO MOVANA INTO NUMREG==NUMREGCG";
|
|
switch (tipoconti)
|
|
{
|
|
case 1:
|
|
recset = new TPrint_mastrini_ca_recordset(query);
|
|
break;
|
|
default:
|
|
recset = new TPrint_mastrini_ca_alternative_recordset(query);
|
|
break;
|
|
}
|
|
recset->set_filter(msk, cms_row);
|
|
TAnal_report::set_recordset(recset);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////
|
|
// APPLICAZIONE
|
|
////////////////////////////////////////////////////////
|
|
class TPrint_mastrini_ca : public TReport_application
|
|
{
|
|
TPrint_mastrini_ca_mask* _mask;
|
|
TPrint_mastrini_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 TAutomask & get_mask();
|
|
virtual TTrec * get_dbase_recdesc(TReport & rep, const TAutomask & 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 "mastrini"; }
|
|
// @cmember Distruzione dei dati dell'utente
|
|
virtual bool user_destroy() { return true; }
|
|
|
|
public:
|
|
TPrint_mastrini_ca() : _mask(nullptr), _rep(nullptr) {}
|
|
~TPrint_mastrini_ca() {}
|
|
};
|
|
|
|
TReport & TPrint_mastrini_ca::get_report(const TAutomask & m)
|
|
{
|
|
if (_rep == nullptr)
|
|
_rep = new TPrint_mastrini_ca_rep;
|
|
_rep->load(_mask->get(DLG_REPORT));
|
|
return *_rep;
|
|
}
|
|
|
|
TAutomask & TPrint_mastrini_ca::get_mask()
|
|
{
|
|
if (_mask == nullptr)
|
|
_mask = new TPrint_mastrini_ca_mask;
|
|
return *_mask;
|
|
}
|
|
|
|
TTrec * TPrint_mastrini_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);
|
|
|
|
desc->add_fielddef(movana.rec_des(), MOVANA_DATACOMP);
|
|
desc->add_fielddef(rmovana.rec_des(), RMOVANA_NUMREG);
|
|
desc->add_fielddef(rmovana.rec_des(), RMOVANA_NUMRIG);
|
|
desc->add_fielddef(rmovana.rec_des(), RMOVANA_DESCR);
|
|
desc->add_fielddef(movana.rec_des(), MOVANA_NUMREGCG);
|
|
desc->add_fielddef(movana.rec_des(), MOVANA_DATADOC);
|
|
desc->add_fielddef(movana.rec_des(), MOVANA_NUMDOC);
|
|
desc->add_fielddef(movana.rec_des(), MOVANA_CODCAUS);
|
|
desc->add_fielddef("DESCRCAUS", _alfafld, 50);
|
|
desc->add_fielddef("DARE", _realfld, 18, 2);
|
|
desc->add_fielddef("AVERE", _realfld, 18, 2);
|
|
desc->add_fielddef("SALDO", _realfld, 18, 2);
|
|
desc->add_fielddef("TIPO", _alfafld, 18);
|
|
desc->add_fielddef("CODCF", _longfld, 6);
|
|
desc->add_fielddef("RAGSOC", _alfafld, 50);
|
|
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(movana.rec_des(), MOVANA_CONTSEP);
|
|
desc->add_fielddef(rmovana.rec_des(), RMOVANA_CODCONTO);
|
|
|
|
TToken_string keydef(CDC_CODCOSTO, '+');
|
|
|
|
keydef.add(COMMESSE_CODCMS);
|
|
keydef.add(FASI_CODFASE);
|
|
keydef.add(RMOVANA_CODCONTO);
|
|
keydef.add(MOVANA_DATACOMP);
|
|
keydef.add(RMOVANA_NUMREG);
|
|
keydef.add(RMOVANA_NUMRIG);
|
|
|
|
desc->add_keydef(keydef, true);
|
|
|
|
return desc;
|
|
}
|
|
|
|
void TPrint_mastrini_ca::execute_print(TReport_book & book, TAutomask & mask, TReport & rep, export_type & type)
|
|
{
|
|
TSheet_field& sheet = _mask->sfield(F_RIGHE);
|
|
TString msg; //stringa che compare nella progind
|
|
|
|
if (sheet.empty()) //se non ci sono righe sullo sheet (selezione su tutte le cms/cdc)...
|
|
{
|
|
if (_mask->get_bool(F_PERCONTO))
|
|
{
|
|
((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &)mask, -1);
|
|
book.add(rep);
|
|
}
|
|
else
|
|
{
|
|
TToken_string& row = sheet.row(-1); //crea la prima riga dello sheet
|
|
|
|
//stabilisce quale è il primo livello (tra CDC e CMS)..
|
|
const TMultilevel_code_info& liv1 = *ca_multilevel_code_info_by_index(0);
|
|
const int logic1 = liv1.logic();
|
|
|
|
TAssoc_array codici_buoni;
|
|
TString query;
|
|
query << "USE RMOVANA KEY 2\n";
|
|
TISAM_recordset rmovana(query);
|
|
TString80 daconto, aconto;
|
|
for (int i = 0; _mask->id2pos(F_CDC1_INI+i) > 0; i++)
|
|
{
|
|
daconto << _mask->get(F_CDC1_INI+i);
|
|
aconto << _mask->get(F_CDC1_FIN+i);
|
|
}
|
|
// rmovana.set_var("#DACONTO", daconto);
|
|
// rmovana.set_var("#ACONTO", aconto);
|
|
if (!daconto.blank())
|
|
query << "FROM " << CDC_CODCONTO << "=\"" << (const char*) daconto << "\"\n";
|
|
|
|
if (!daconto.blank())
|
|
query << "TO " << CDC_CODCONTO << "=\"" << (const char*)aconto << "\"\n";
|
|
const long items = rmovana.items();
|
|
if (items > 0)
|
|
{
|
|
TProgind po(items, "Analisi righe movimento analitiche...", true, true);
|
|
|
|
for (bool ok = rmovana.move_first(); ok; ok = rmovana.move_next())
|
|
{
|
|
if (!po.addstatus(1))
|
|
break;
|
|
|
|
const TString& codice = rmovana.get(logic1 == LF_COMMESSE ? RMOVANA_CODCMS : RMOVANA_CODCCOSTO).as_string();
|
|
codici_buoni.add(codice);
|
|
}
|
|
}
|
|
|
|
TISAM_recordset set(logic1 == LF_CDC ? "USE CDC" : "USE COMMESSE"); //..e di conseguenza scrive la use giusta
|
|
|
|
bool skip_closed = false;
|
|
if (logic1 == LF_COMMESSE)
|
|
skip_closed = !yesno_box(TR("E' stata richiesta la stampa di tutte le commesse:\n"
|
|
"Si desidera includere anche le commesse chiuse?"));
|
|
|
|
TProgress_monitor pi(set.items(), msg, true);
|
|
for (bool sok = set.move_first(); pi.add_status() && sok; sok = set.move_next()) //fighissimo metodo per scandire un file in 1 riga!
|
|
{
|
|
if (skip_closed && set.get_bool(COMMESSE_CHIUSA))
|
|
continue;
|
|
|
|
// row = set.get_string(0u);
|
|
if (logic1 == LF_CDC)
|
|
row = set.get_string(CDC_CODCOSTO);
|
|
else
|
|
row = set.get_string(COMMESSE_CODCMS); //prende il valore del primo campo del file (CDC o CMS code)
|
|
if (!codici_buoni.is_key(row))
|
|
continue;
|
|
|
|
//completa la stringa da visualizzare sulla progind
|
|
msg = row;
|
|
msg << '\n' << set.get(1u);
|
|
pi.set_text(msg);
|
|
|
|
for (int l = liv1.levels()-2; l >= 0; l--) //se la struttura è a più livelli costruisce la tokenstring
|
|
row.insert("|", liv1.total_len(l));
|
|
|
|
((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &)mask, 0); //fa la set filter sulla prima riga (che è quella usata)
|
|
book.add(rep);
|
|
}
|
|
sheet.destroy(); //cancella le commesse aggiunte in automatico sullo sheet
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
{
|
|
((TPrint_mastrini_ca_rep &)rep).set_filter((TPrint_mastrini_ca_mask &) mask, r);
|
|
rep.set_export_sections(type);
|
|
book.add(rep, type);
|
|
rep.reset_export_sections();
|
|
}
|
|
}
|
|
}
|
|
|
|
int ca3200(int argc, char* argv[])
|
|
{
|
|
TPrint_mastrini_ca a;
|
|
a.run(argc, argv, TR("Stampa mastrini"));
|
|
return 0;
|
|
} |