637 lines
19 KiB
C++
637 lines
19 KiB
C++
|
#include <applicat.h>
|
||
|
#include <automask.h>
|
||
|
#include <assoc.h>
|
||
|
#include <expr.h>
|
||
|
#include <reprint.h>
|
||
|
#include <progind.h>
|
||
|
#include <varmask.h>
|
||
|
#include <utility.h>
|
||
|
#include "ba9b00.h"
|
||
|
#include "../cg/cgsaldac.h"
|
||
|
#include "../ve/velib07.h"
|
||
|
#include <clifo.h>
|
||
|
#include <pconti.h>
|
||
|
#include <partite.h>
|
||
|
#include <saldi.h>
|
||
|
#include <cfven.h>
|
||
|
#include <doc.h>
|
||
|
#include <rdoc.h>
|
||
|
|
||
|
#define RPC_DATAUFATT "DATAUFATT"
|
||
|
#define RPC_IMPFATT "IMPFATT"
|
||
|
#define RPC_TOTFATT "TOTFATT"
|
||
|
#define RPC_DARE "DARE"
|
||
|
#define RPC_AVERE "AVERE"
|
||
|
#define RPC_SCADUTO "SCADUTO"
|
||
|
#define RPC_MOVIMENTATO "MOVIMENTATO"
|
||
|
|
||
|
#define RPC_SOLV "SOLV"
|
||
|
#define RPC_NINS "NINS"
|
||
|
#define RPC_ESPCAM "ESPCAM"
|
||
|
|
||
|
HIDDEN const char * const __fields[] = { TOSTRING(LF_CLIFO) "->" CLI_CODCF, TOSTRING(LF_CLIFO) "->" CLI_RAGSOC, TOSTRING(LF_CLIFO) "->" CLI_CAPCF, TOSTRING(LF_CFVEN) "->" CFV_CODAG,
|
||
|
TOSTRING(LF_CLIFO) "->" CLI_CODZONA, TOSTRING(LF_CFVEN) "->" CFV_CODAG1, TOSTRING(LF_CFVEN) "->" CFV_CODLIST, TOSTRING(LF_CFVEN) "->" CFV_SCONTO,
|
||
|
TOSTRING(LF_CLIFO) "->" CLI_FIDO, TOSTRING(LF_CLIFO) "->" CLI_CODPAG, TOSTRING(LF_CFVEN) "->" CFV_CODMAG, TOSTRING(LF_CFVEN) "->" CFV_CODDEP,
|
||
|
TOSTRING(LF_CFVEN) "->" CFV_VSDATAREG, TOSTRING(LF_CFVEN) "->" CFV_CODPORTO, TOSTRING(LF_CFVEN) "->" CFV_CODSPMEZZO, TOSTRING(LF_CFVEN) "->" CFV_CATVEN,
|
||
|
RPC_DATAUFATT, RPC_IMPFATT, RPC_TOTFATT, RPC_DARE,
|
||
|
RPC_AVERE, RPC_SCADUTO, RPC_MOVIMENTATO, NULL };
|
||
|
|
||
|
HIDDEN const char * const __field_descrs[] = { "Codice", "Ragione Sociale", "CAP", "Codice agente", "Codice Zona",
|
||
|
"Codice Agente 2", "Codice listino", "Sconto", "Fido", "Pagamento",
|
||
|
"Magazzino", "Deposito", "Data Esenzione", "Porto", "Spedizione",
|
||
|
"Categoria economica", "Data ultima fattura", "Fatturato netto", "Totale fatturato", "Dare",
|
||
|
"Avere", "Scaduto", "Movimentato", NULL };
|
||
|
|
||
|
HIDDEN bool __need_es[] = { false, false, false, false, false,
|
||
|
false, false, false, false, false,
|
||
|
false, false, false, false, false,
|
||
|
false, true, true, true, true,
|
||
|
true, true, true
|
||
|
};
|
||
|
HIDDEN bool __virtual[] = { false, false, false, false, false,
|
||
|
false, false, false, false, false,
|
||
|
false, false, false, false, false,
|
||
|
false, true, true, true, true,
|
||
|
true, true, true
|
||
|
};
|
||
|
HIDDEN const char * const __macros[] = { "$REPSEL", "$KEY", "$TIPOCF", "$TIPOCF", "$ANNO", "$AANNO", "$DA", "$A",
|
||
|
NULL };
|
||
|
|
||
|
/* 09 N.INSOLUTI
|
||
|
SOLVIBILITA */
|
||
|
|
||
|
class TReporting_clienti_fornitori : public TSkeleton_application
|
||
|
{
|
||
|
|
||
|
protected:
|
||
|
void update_recset(TDocument_report & rep, const TMask & m);
|
||
|
virtual const char * extra_modules() const { return "RS"; }
|
||
|
|
||
|
virtual void main_loop();
|
||
|
virtual void print();
|
||
|
};
|
||
|
|
||
|
void TReporting_clienti_fornitori::print()
|
||
|
{
|
||
|
WINDOW win = cur_win(); // Trova la finestra corrente di XVT
|
||
|
if (win != NULL_WIN && win != TASK_WIN) // E' una finestra valida?
|
||
|
{
|
||
|
TWindow* w = (TWindow*)xvt_vobj_get_data(win); // Risale alla classe originale
|
||
|
if (w != NULL) // E' una TWindow valida? (sarebbe TMask)
|
||
|
w->stop_run(K_ENTER); // Simula la pressione del bottone stampa
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class TRepcom_recordset : public TDocument_recordset
|
||
|
{
|
||
|
int _codes;
|
||
|
int _codes_to;
|
||
|
TAssoc_array _fields_val;
|
||
|
TExpression _virtual;
|
||
|
TString_array _num;
|
||
|
// long _fromcli;
|
||
|
// long tocli;
|
||
|
|
||
|
protected:
|
||
|
virtual const TVariant& get_field(int num, const char* field) const;
|
||
|
void scaduto_al(const TString4 & tipo, const long codcf, const TDate & data, real & scaduto, real & esposto, real & nins);
|
||
|
bool saldo_cont_al(const TString4 & tipo, const long codcf, const TDate & data, real & dare, real & avere);
|
||
|
void load_cli_val(const TString4 & tipo, const long codcf, TAssoc_array * vals);
|
||
|
const TVariant& get_field_value(const TString & field) ;
|
||
|
|
||
|
public:
|
||
|
void set_es(int codes) { codes > 0 ?_codes = codes : 2002;}
|
||
|
void set_es_to(int codes) { codes > 0 && codes >= _codes ? _codes_to = codes : esercizi().last();}
|
||
|
void set_virtual(const char *select) { _virtual.set(select, _strexpr); }
|
||
|
bool eval_virtual();
|
||
|
TAssoc_array & get_curr_row();
|
||
|
virtual TCursor* cursor() const;
|
||
|
|
||
|
TRepcom_recordset(const char* use);
|
||
|
virtual ~TRepcom_recordset() {}
|
||
|
};
|
||
|
|
||
|
HIDDEN TRepcom_recordset * __r = NULL;
|
||
|
|
||
|
bool virfunc(const TRelation* r)
|
||
|
{
|
||
|
return __r->eval_virtual();
|
||
|
}
|
||
|
|
||
|
TAssoc_array & TRepcom_recordset::get_curr_row()
|
||
|
{
|
||
|
const TString4 tipo = get(CLI_TIPOCF).as_string();
|
||
|
const TString cod = get(CLI_CODCF).as_string();
|
||
|
TAssoc_array * row = (TAssoc_array *) _fields_val.objptr(cod);
|
||
|
|
||
|
if (row ==NULL)
|
||
|
{
|
||
|
_fields_val.add(cod, row = new TAssoc_array);
|
||
|
this->load_cli_val(tipo, atol(cod), row);
|
||
|
}
|
||
|
return * row;
|
||
|
}
|
||
|
|
||
|
bool TRepcom_recordset::eval_virtual()
|
||
|
{
|
||
|
TAssoc_array & row = get_curr_row();
|
||
|
|
||
|
FOR_EACH_ASSOC_OBJECT(row, obj, key, val)
|
||
|
if (_virtual.exist(key))
|
||
|
_virtual.setvar(key, ((TVariant *) val)->as_string());
|
||
|
return _virtual.as_bool();
|
||
|
}
|
||
|
|
||
|
TCursor* TRepcom_recordset::cursor() const
|
||
|
{
|
||
|
TCursor * c = TDocument_recordset::cursor();
|
||
|
|
||
|
if (_virtual.string()[0] != '\0')
|
||
|
c->set_filterfunction(virfunc);
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
TRepcom_recordset::TRepcom_recordset(const char* use)
|
||
|
: TDocument_recordset(use)
|
||
|
{
|
||
|
TString_array tip;
|
||
|
|
||
|
numerazioni_fatture(_num, tip);
|
||
|
TCursor & c = *cursor();
|
||
|
|
||
|
__r = this;
|
||
|
}
|
||
|
|
||
|
void TRepcom_recordset::scaduto_al(const TString4 & tipo, const long codcf, const TDate & data, real & scaduto, real & esposto, real & nins)
|
||
|
{
|
||
|
TString query("USE ");
|
||
|
TDate rischio = data;
|
||
|
|
||
|
rischio -= 10 ;
|
||
|
query << LF_PARTITE << "\nFROM " << PART_TIPOCF << "='" << tipo << "' " << PART_GRUPPO << "='' " << PART_CONTO << "=''\n"
|
||
|
<< PART_SOTTOCONTO << "='" << codcf << "' "
|
||
|
<< "TO " << PART_TIPOCF << "='" << tipo << "' " << PART_GRUPPO << "='' " << PART_CONTO << "=''\n"
|
||
|
<< PART_SOTTOCONTO << "='" << codcf << "' ";
|
||
|
|
||
|
TISAM_recordset part(query);
|
||
|
|
||
|
for (bool ok=part.move_first(); ok; ok = part.move_next())
|
||
|
{
|
||
|
TPartita p(part.cursor()->curr());
|
||
|
const int last = p.last();
|
||
|
|
||
|
scaduto +=p.calcola_scaduto_al(false, data);
|
||
|
|
||
|
for (int i = p.prima_fattura(); i >= 0 && i <= last; i = p.succ(i))
|
||
|
{
|
||
|
TRiga_partite & riga = p.riga(i);
|
||
|
|
||
|
if (riga.is_fattura())
|
||
|
{
|
||
|
const int nrate = riga.rate();
|
||
|
bool sbf = false;
|
||
|
|
||
|
for (int r = 1; r <= nrate; r++)
|
||
|
{
|
||
|
TRiga_scadenze& s = riga.rata(r);
|
||
|
TImporto esposto_scad = s.esposto(false, data, rischio, sbf); esposto_scad.normalize(tipo == "C" ? 'D' : 'A');
|
||
|
|
||
|
esposto += esposto_scad.valore();
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
if (riga.is_insoluto())
|
||
|
nins += UNO;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool TRepcom_recordset::saldo_cont_al(const TString4 & tipo, const long codcf, const TDate & data, real & dare, real & avere)
|
||
|
{
|
||
|
TString query("USE ");
|
||
|
|
||
|
query << LF_SALDI << " KEY 3 SELECT ((" << SLD_SOTTOCONTO << "=" << codcf << ")&&("<< LF_PCON << "->" << PCN_TMCF << "==\"" << tipo << "\"))\nJOIN "
|
||
|
<< LF_PCON << " INTO " << PCN_GRUPPO << "==" << SLD_GRUPPO
|
||
|
<< " " << PCN_CONTO << "==" << SLD_CONTO << "\n"
|
||
|
<< "FROM " << SLD_SOTTOCONTO << "=" << codcf << " " << SLD_ANNOES << "=" << _codes << "\n"
|
||
|
<< "TO " << SLD_SOTTOCONTO << "=" << codcf << " " << SLD_ANNOES << "=" << _codes_to << "\n" ;
|
||
|
|
||
|
TISAM_recordset saldi(query);
|
||
|
|
||
|
dare = ZERO;
|
||
|
avere = ZERO;
|
||
|
for (bool ok=saldi.move_first(); ok; ok = saldi.move_next())
|
||
|
{
|
||
|
const real si = saldi.get(SLD_SALDO).as_real();
|
||
|
|
||
|
if (saldi.get(SLD_FLAGSALINI).as_string() == "D")
|
||
|
dare += si;
|
||
|
else
|
||
|
avere += si;
|
||
|
dare += saldi.get(SLD_PDARE).as_real();
|
||
|
avere += saldi.get(SLD_PAVERE).as_real();
|
||
|
}
|
||
|
return dare != ZERO || avere != ZERO;
|
||
|
}
|
||
|
|
||
|
void TRepcom_recordset::load_cli_val(const TString4 & tipo, const long codcf, TAssoc_array * vals)
|
||
|
{
|
||
|
// manca RPC_SOLV
|
||
|
TDate ult;
|
||
|
real totnetto;
|
||
|
real totfatt;
|
||
|
real dare;
|
||
|
real avere;
|
||
|
real scaduto;
|
||
|
real solv;
|
||
|
real nins;
|
||
|
real espcam;
|
||
|
|
||
|
if (_codes == 0)
|
||
|
_codes = esercizi().last();
|
||
|
TString query("USE ");
|
||
|
|
||
|
query << LF_DOC << " KEY 2\nFROM " << DOC_TIPOCF << "='" << tipo << "' "
|
||
|
<< DOC_CODCF << "='" << get(DOC_CODCF) << "' " << DOC_PROVV << "='D' " << DOC_ANNO << "='" << _codes << "'\n"
|
||
|
<< "TO " << DOC_TIPOCF << "='" << tipo << "' "
|
||
|
<< DOC_CODCF << "='" << get(DOC_CODCF) << "' " << DOC_PROVV << "='D' " << DOC_ANNO << "='" << _codes_to << "'\n";
|
||
|
|
||
|
TDocument_recordset fatt(query);
|
||
|
|
||
|
for (bool ok=fatt.move_first(); ok; ok = fatt.move_next())
|
||
|
{
|
||
|
const TString4 num = fatt.get(DOC_CODNUM).as_string();
|
||
|
|
||
|
if (_num.find(num) >= 0)
|
||
|
{
|
||
|
const TDocumento & doc = fatt.doc(fatt.cursor()->curr());
|
||
|
const TDate datadoc = doc.get_date(DOC_DATADOC);
|
||
|
|
||
|
if (datadoc > ult)
|
||
|
ult = datadoc;
|
||
|
TCurrency_documento netto(doc.totale_netto(), doc);
|
||
|
|
||
|
netto.change_to_firm_val();
|
||
|
totnetto += netto.get_num();
|
||
|
|
||
|
TCurrency_documento tot(doc.totale_doc(), doc);
|
||
|
|
||
|
tot.change_to_firm_val();
|
||
|
totfatt += tot.get_num();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
scaduto_al(tipo, codcf, TDate(TODAY), scaduto, espcam, nins);
|
||
|
vals->add(RPC_MOVIMENTATO, saldo_cont_al(tipo, codcf, TDate(TODAY), dare, avere) ? TVariant("X") : NULL_VARIANT);
|
||
|
vals->add(RPC_DATAUFATT, TVariant(ult));
|
||
|
vals->add(RPC_IMPFATT, TVariant(totnetto));
|
||
|
vals->add(RPC_TOTFATT, TVariant(totfatt));
|
||
|
vals->add(RPC_DARE, TVariant(dare));
|
||
|
vals->add(RPC_AVERE, TVariant(avere));
|
||
|
vals->add(RPC_SCADUTO, TVariant(scaduto));
|
||
|
vals->add(RPC_SOLV, TVariant(solv));
|
||
|
vals->add(RPC_NINS, TVariant(nins));
|
||
|
vals->add(RPC_ESPCAM, TVariant(espcam));
|
||
|
}
|
||
|
|
||
|
const TVariant& TRepcom_recordset::get_field_value(const TString & field)
|
||
|
{
|
||
|
TVariant& var = get_tmp_var();
|
||
|
TAssoc_array & row = get_curr_row();
|
||
|
TVariant * v = (TVariant *) row.objptr(field);
|
||
|
|
||
|
if (v != NULL)
|
||
|
var = *v;
|
||
|
|
||
|
return var;
|
||
|
}
|
||
|
|
||
|
const TVariant& TRepcom_recordset::get_field(int num, const char* field) const
|
||
|
{
|
||
|
const TString16 f(field);
|
||
|
|
||
|
if (f == RPC_DATAUFATT || f == RPC_IMPFATT || f == RPC_TOTFATT ||
|
||
|
f == RPC_DARE || f == RPC_AVERE || f == RPC_MOVIMENTATO ||
|
||
|
f == RPC_SCADUTO || f == RPC_SOLV || f == RPC_NINS || f == RPC_ESPCAM)
|
||
|
return ((TRepcom_recordset *)this)->get_field_value(f);
|
||
|
return TDocument_recordset::get_field(num, field);
|
||
|
}
|
||
|
|
||
|
void TReporting_clienti_fornitori::update_recset(TDocument_report & rep, const TMask & m)
|
||
|
{
|
||
|
TString select;
|
||
|
TString virsel;
|
||
|
TSheet_field & s = m.sfield(F_SHEET);
|
||
|
const int nrows = s.items();
|
||
|
const int key = m.get_int(F_KEY);
|
||
|
TISAM_recordset *r = (TISAM_recordset*) rep.recordset();
|
||
|
TString query = r->query_text();
|
||
|
|
||
|
for (int i = 0; i < nrows; i++)
|
||
|
{
|
||
|
TToken_string & row = s.row(i);
|
||
|
TString fromval(row.get(1));
|
||
|
TString toval(row.get(2));
|
||
|
|
||
|
if (fromval.full() || toval.full())
|
||
|
{
|
||
|
if ( i == 0 && key == 1)
|
||
|
{
|
||
|
int pos = 0;
|
||
|
for (int j = 0; pos >= 0 && j < 2; j++)
|
||
|
{
|
||
|
pos = query.find("$TIPOCF", pos);
|
||
|
|
||
|
if (pos >= 0)
|
||
|
{
|
||
|
pos += 8;
|
||
|
TString wrk;
|
||
|
const TString val = row.get(j + 1);
|
||
|
|
||
|
if (val.full())
|
||
|
wrk << ' ' << CLI_CODCF << "='" << val << "'";
|
||
|
query.insert(wrk, pos);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
if ( i == 1 && key == 2)
|
||
|
{
|
||
|
int pos = 0;
|
||
|
for (int j = 0; pos >= 0 && j < 2; j++)
|
||
|
{
|
||
|
pos = query.find("$TIPOCF", pos);
|
||
|
|
||
|
if (pos >= 0)
|
||
|
{
|
||
|
pos += 8;
|
||
|
TString wrk;
|
||
|
const TString val = row.get(j + 1);
|
||
|
|
||
|
if (val.full())
|
||
|
wrk << ' ' << CLI_RAGSOC << "='" << val << "\'";
|
||
|
query.insert(wrk, pos);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const TString field(__fields[i]);
|
||
|
|
||
|
if (__virtual[i])
|
||
|
{
|
||
|
if (virsel.full())
|
||
|
virsel << "&&";
|
||
|
if (i == 22)
|
||
|
{
|
||
|
if (fromval.full())
|
||
|
virsel << " (" << field << "!=\"\")";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (fromval.empty())
|
||
|
{
|
||
|
if (i == 0 || i == 8 || i > 15)
|
||
|
fromval = "0";
|
||
|
else
|
||
|
fromval = "\"\"";
|
||
|
}
|
||
|
if (toval.blank())
|
||
|
select << "(" << field << ">=\"" << fromval << "\")";
|
||
|
else
|
||
|
virsel << "BETWEEN(" << field << ",\"" << fromval << "\",\"" << toval << "\")";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (select.full())
|
||
|
select << "&&";
|
||
|
if (fromval.empty())
|
||
|
{
|
||
|
if (i == 0 || i == 8 || i > 15)
|
||
|
fromval = "0";
|
||
|
else
|
||
|
fromval = "\"\"";
|
||
|
}
|
||
|
if (i == 0 || i == 8 || i > 15)
|
||
|
{
|
||
|
if (toval.blank())
|
||
|
select << "(" << field << ">=" << fromval << ")";
|
||
|
else
|
||
|
select << "BETWEEN(" << field << "," << fromval << "," << toval << ")";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (toval.blank())
|
||
|
select << "(" << field << ">=\"" << fromval << "\")";
|
||
|
else
|
||
|
select << "BETWEEN(" << field << ",\"" << fromval << "\",\"" << toval << "\")";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (select.full())
|
||
|
select.format("(%s)", (const char *) select);
|
||
|
|
||
|
for (int i = 0; __macros[i]; i++)
|
||
|
{
|
||
|
int pos = query.find(__macros[i]);
|
||
|
|
||
|
while (pos >= 0)
|
||
|
{
|
||
|
TString wrk = query.left(pos);
|
||
|
|
||
|
switch (i)
|
||
|
{
|
||
|
case 0:
|
||
|
wrk << "(" << select << ")";
|
||
|
break;
|
||
|
case 1:
|
||
|
wrk << key;
|
||
|
break;
|
||
|
case 2:
|
||
|
case 3:
|
||
|
wrk << m.get(F_TIPOCF);
|
||
|
break;
|
||
|
case 4:
|
||
|
if (esercizi().exist(m.get_int(F_CODES)))
|
||
|
wrk << esercizi().esercizio(m.get_int(F_CODES)).inizio().year();
|
||
|
break;
|
||
|
case 5:
|
||
|
if (esercizi().exist(m.get_int(F_CODES_TO)))
|
||
|
wrk << esercizi().esercizio(m.get_int(F_CODES_TO)).inizio().year();
|
||
|
break;
|
||
|
case 6:
|
||
|
wrk << m.get(F_DA);
|
||
|
break;
|
||
|
case 7:
|
||
|
wrk << m.get(F_A);
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
wrk << query.mid(pos + strlen(__macros[i]));
|
||
|
query = wrk;
|
||
|
pos = query.find(__macros[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
TRepcom_recordset * recset = new TRepcom_recordset(query);
|
||
|
|
||
|
recset->set_es(m.get_int(F_CODES));
|
||
|
recset->set_es_to(m.get_int(F_CODES_TO));
|
||
|
for (int i = 0; i < nrows; i++)
|
||
|
{
|
||
|
TToken_string & row = s.row(i);
|
||
|
TString fromval(row.get(1));
|
||
|
TString toval(row.get(2));
|
||
|
const TString field(row.get(3));
|
||
|
TString from("#DA_"); from << field;
|
||
|
TString to("#A_"); to << field;
|
||
|
|
||
|
recset->set_var(from, TVariant(fromval));
|
||
|
recset->set_var(to, TVariant(toval));
|
||
|
}
|
||
|
recset->set_virtual(virsel);
|
||
|
rep.set_recordset(((TDocument_recordset *)recset));
|
||
|
}
|
||
|
|
||
|
class TRepcom_mask : public TVariable_automask
|
||
|
|
||
|
{
|
||
|
private:
|
||
|
|
||
|
protected:
|
||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
static TMask* getmask(int numriga, TMask& fullmask);
|
||
|
|
||
|
public:
|
||
|
TRepcom_mask() : TVariable_automask("ba9b00a") { sfield(F_SHEET).set_append(false); ((TVariable_sheet_field &) sfield(F_SHEET)).set_getmask(getmask); }
|
||
|
};
|
||
|
|
||
|
TMask* TRepcom_mask::getmask(int numriga, TMask& fullmask)
|
||
|
{
|
||
|
TSheet_field* sf = fullmask.get_sheet();
|
||
|
TRepcom_mask & m = (TRepcom_mask &)sf->mask();
|
||
|
static TArray __masks;
|
||
|
TMask * mask = (TMask *)__masks.objptr(numriga);
|
||
|
|
||
|
if (mask == NULL)
|
||
|
{
|
||
|
TFilename mask_name("ba9b00a");
|
||
|
|
||
|
mask_name = mask_name << format("%02d", numriga + 1);
|
||
|
__masks.add(mask = new TMask(mask_name), numriga);
|
||
|
}
|
||
|
return mask;
|
||
|
}
|
||
|
|
||
|
bool TRepcom_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
|
{
|
||
|
switch (o.dlg())
|
||
|
{
|
||
|
case F_TIPOCF:
|
||
|
if (e == fe_init || e == fe_modify)
|
||
|
{
|
||
|
const TString4 tipo = o.get();
|
||
|
TSheet_field & s = o.mask().sfield(F_SHEET);
|
||
|
const int nrows = s.items();
|
||
|
|
||
|
for (int i = 0; i < nrows; i++)
|
||
|
{
|
||
|
TToken_string & row = s.row(i);
|
||
|
|
||
|
row.add(tipo, s.cid2index(S_TIPOCF));
|
||
|
}
|
||
|
s.force_update();
|
||
|
}
|
||
|
case F_CODES:
|
||
|
if (e == fe_init || e == fe_modify)
|
||
|
{
|
||
|
bool active = o.get().full();
|
||
|
TSheet_field & s = sfield(F_SHEET);
|
||
|
|
||
|
for (int i = 0; __fields[i]; i++)
|
||
|
{
|
||
|
if (__need_es[i])
|
||
|
{
|
||
|
if (!active)
|
||
|
{
|
||
|
TToken_string & row = s.row(i);
|
||
|
|
||
|
row.add("", 1);
|
||
|
row.add("", 2);
|
||
|
}
|
||
|
s.enable_row(i, active);
|
||
|
if (i == 22)
|
||
|
s.disable_cell(i, s.cid2index(S_A));
|
||
|
}
|
||
|
}
|
||
|
s.force_update();
|
||
|
}
|
||
|
break;
|
||
|
case F_SHEET:
|
||
|
if (e == se_query_add)
|
||
|
return false;
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void TReporting_clienti_fornitori::main_loop()
|
||
|
{
|
||
|
bool repcom = false;
|
||
|
// Costruisce il nome del report in base alla riga di comando
|
||
|
TFilename rep;
|
||
|
|
||
|
if (argc() > 2)
|
||
|
rep = argv(2);
|
||
|
|
||
|
TDocument_report r;
|
||
|
bool ok = true;
|
||
|
TRepcom_mask m;
|
||
|
TSheet_field & s = m.sfield(F_SHEET);
|
||
|
|
||
|
for (int i = 0; __fields[i]; i++)
|
||
|
{
|
||
|
TToken_string & row = s.row(i);
|
||
|
|
||
|
row.add(__field_descrs[i], 0);
|
||
|
row.add("", 1);
|
||
|
row.add("", 2);
|
||
|
row.add(__fields[i], 3);
|
||
|
row.add("", 4);
|
||
|
}
|
||
|
if (rep.full())
|
||
|
{
|
||
|
m.set(F_REPORT, rep);
|
||
|
m.disable(F_REPORT);
|
||
|
}
|
||
|
|
||
|
while ((m.run() == K_ENTER))
|
||
|
{
|
||
|
if (r.load(m.get(F_REPORT))) // Controlla l'effettiva esistenza del report
|
||
|
{
|
||
|
update_recset(r, m);
|
||
|
|
||
|
TReport_book b;
|
||
|
|
||
|
b.add(r); // Richiede parametri di stampa in base alla maschera omonima
|
||
|
|
||
|
if (b.pages() > 0)
|
||
|
b.print_or_preview(); // Stampa effettivamente
|
||
|
else
|
||
|
warning_box (TR("Nessun record estratto per i parametri inseriti"));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int ba9200(int argc, char* argv[])
|
||
|
{
|
||
|
TReporting_clienti_fornitori app;
|
||
|
app.run(argc, argv, TR("Report Clienti Fornitori"));
|
||
|
return 0;
|
||
|
}
|
||
|
|