Patch level : 10.0 67

Files correlati     :
Ricompilazione Demo : [ ]
Commento           :

RIportata la verione 3.2 1167


git-svn-id: svn://10.65.10.50/trunk@16724 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2008-06-11 11:31:27 +00:00
parent 93e1a7e428
commit 40fefcabc0
18 changed files with 1433 additions and 355 deletions

View File

@ -54,7 +54,8 @@ void TMotore_application::init_query_mode( TMask& m )
disable_menu_item(M_FILE_PRINT);
TEdit_field& cn = _msk->efield(F_CODNUM);
if (cn.empty())
if (cn.empty())
{
cn.set(_codnum);
if (_msk->field(F_TIPODOC).empty())
@ -65,12 +66,21 @@ void TMotore_application::init_query_mode( TMask& m )
_msk->set(F_TIPODOC, _tipodoc, TRUE);
}
}
TEdit_field& n = m.efield(F_NDOC);
if (!n.empty())
{
if (find(0))
modify_mode();
}
}
void TMotore_application::init_insert_mode( TMask& m )
{
TDocumento_mask& dm = (TDocumento_mask&)m;
TString4 codnum(m.get(F_CODNUM));
dm.reset_father_rows();
if (codnum.empty())
{
TMask * query_mask = get_mask(MODE_QUERY);
@ -85,7 +95,7 @@ void TMotore_application::init_insert_mode( TMask& m )
const int anno = m.get_int(F_ANNO);
const char provv = m.get(F_PROVV)[0];
const long numdoc = m.get_long(F_NDOC);
TDocumento_mask& dm = (TDocumento_mask&)m;
TDocumento& curdo = dm.doc();
curdo.read(provv, anno, codnum, numdoc);
@ -134,7 +144,17 @@ void TMotore_application::init_insert_mode( TMask& m )
tp.set_defaults(m);
m.disable(DLG_PRINT);
if (provv == 'P')
{
m.hide(DLG_PRINT);
m.show(DLG_CONFERMA);
}
else
{
m.show(DLG_PRINT);
m.hide(DLG_CONFERMA);
m.disable(DLG_PRINT);
}
m.disable(DLG_ELABORA);
if (curdo.tipo().auto_add())
@ -149,15 +169,30 @@ void TMotore_application::init_insert_mode( TMask& m )
void TMotore_application::init_modify_mode( TMask& m )
{
TEdit_field& n = query_mask().efield(F_NDOC);
n.set("");
n.update_flags("R");
const bool enable_print = edit_mask().doc().tipo().printable();
enable_menu_item(M_FILE_PRINT, enable_print);
m.enable(DLG_PRINT, enable_print);
const TString4 provv = m.get(F_PROVV);
enable_menu_item(M_FILE_PRINT, provv == "D" && enable_print);
if (provv[0] == 'P')
{
m.hide(DLG_PRINT);
m.show(DLG_CONFERMA);
}
else
{
m.show(DLG_PRINT);
m.hide(DLG_CONFERMA);
m.enable(DLG_PRINT, enable_print);
}
m.enable(DLG_ELABORA);
m.disable(F_STATO);
TString80 key;
key << m.get(F_CODNUM);
key << m.get(F_ANNO);
key << m.get(F_PROVV);
key << provv;
key << m.get(F_NDOC);
// Non dare messaggi inutili durante la cancellazione automatica
@ -292,17 +327,23 @@ const char* TMotore_application::get_next_key( )
int TMotore_application::read( TMask& m )
{
TDocumento_mask& mask = (TDocumento_mask&) m;
TRelation_application::read(m);
mask.reset_father_rows();
doc() = (TDocumento &)_rel->curr();
mask.update_father_rows(false);
_codnum = m.get(F_CODNUM);
_tipodoc = m.get(F_TIPODOC);
((TDocumento_mask &)m).doc2mask();
mask.doc2mask();
COLOR high_back_color = _sel_color->get_back_color(_link_pos);
COLOR high_color = _sel_color->get_fore_color(_link_pos);
((TDocumento_mask &)m).highlight(high_back_color, high_color);
mask.highlight(high_back_color, high_color);
return NOERR;
}
@ -343,16 +384,39 @@ int TMotore_application::write( const TMask& m ) // C 90
}
}
return TRelation_application::write(m);
const int err = TRelation_application::write(m);
if (err == NOERR)
{
mask.update_father_rows();
mask.save_father_rows();
}
return err;
}
int TMotore_application::rewrite( const TMask& m ) // C 90
{
TDocumento& d = (TDocumento &) _rel->curr();
TDocumento_mask& mask = (TDocumento_mask&) m;
if (d.bloccato())
return NOERR;
d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
return TRelation_application::rewrite(m);
const int err = TRelation_application::rewrite(m);
if (err == NOERR)
{
mask.update_father_rows();
mask.save_father_rows();
}
return err;
}
bool TMotore_application::remove() // C 90
{
const bool ok = TRelation_application::remove();
if (ok)
edit_mask().save_father_rows();
return ok;
}
void TMotore_application::on_firm_change()
@ -361,9 +425,60 @@ void TMotore_application::on_firm_change()
delete _config_ditta;
_config_ditta = new TConfig(CONFIG_DITTA);
_doc_masks.destroy();
load_auto_reopen_data();
TRelation_application::on_firm_change();
}
void TMotore_application::load_auto_reopen_data()
{
TAssoc_array & auto_reopen_nums = TDocumento_mask::auto_reopen_nums();
TAssoc_array & tipidoc_rels = TDocumento_mask::tipidoc_rels();
TTable num("%NUM");
TTable eld("%ELD");
auto_reopen_nums.destroy();
tipidoc_rels.destroy();
for (int err = num.first(); err == NOERR; err = num.next())
{
if (num.get_bool("B7"))
{
const TString4 codnum = num.get("CODTAB");
TCodice_numerazione numeraz(codnum);
const int ntipidoc = numeraz.ntipi_doc();
TString_array tipi;
for (int k = 0 ; k < ntipidoc; k++)
tipi.add(numeraz.tipo_doc(k));
auto_reopen_nums.add(codnum, codnum);
for (int err1 = eld.first(); err1 == NOERR; err1 = eld.next())
{
TCopia_documento e(eld.get("CODTAB"));
const TTipo_elaborazione tipo = e.tipo();
if (tipo == _consegna_ordini ||
tipo == _consuntivazione_produzione)
{
const TString4 dest_tipo_doc = e.tipo_finale();
const char stato_finale = e.stato_finale_doc_iniziale()[0];
for (int i = 0; i < 10; i++)
{
TToken_string key(e.tipo_iniziale(i));
if (key.blank())
break;
if (tipi.find(key) >= 0)
{
key.add(dest_tipo_doc);
tipidoc_rels.add(key, new TStati(e.stato_iniziale(i), stato_finale));
}
}
}
}
}
}
}
bool TMotore_application::user_create( )
{
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR,
@ -393,7 +508,9 @@ bool TMotore_application::user_create( )
_tipodoc = utente.get("TIPODOC");
_docmsk = NULL;
return TRUE;
load_auto_reopen_data();
return true;
}
bool TMotore_application::user_destroy( )
@ -416,7 +533,7 @@ bool TMotore_application::user_destroy( )
delete _rel;
// delete _condv;
return TRUE;
return true;
}
int TMotore_application::stato_corrente( )
@ -732,7 +849,13 @@ void TMotore_application::ini2mask(TConfig& ini, TMask& msk, bool query)
void TMotore_application::print()
{
if (_print_directly || save(false)) // Registra il record corrente
bool ok = _print_directly;
if (!ok)
{
ok = save(false);
edit_mask().update_father_rows(false);
}
if (ok) // Registra il record corrente
{
TDocumento& doc = (TDocumento&)get_relation()->curr();
@ -759,15 +882,18 @@ void TMotore_application::print()
TExternal_app interattivo( commandline );
if (interattivo.run() == NOERR)
{
TDocumento_mask& m = edit_mask();
TDocumento& maindoc = m.doc();
maindoc.read(); // Aggiorna STATO e MOVMAG generati da ve1
if (da_stampare) // Aggiorna stato documento se necessario
{
TDocumento_mask& m = edit_mask();
TDocumento& maindoc = m.doc();
maindoc.read(); // Aggiorna STATO e MOVMAG generati da ve1
// Lo stato del documento vive di vita propria
const char sfs = maindoc.tipo().stato_finale_stampa();
maindoc.stato(sfs);
const char str_sfs[2] = { sfs, '\0' };
m.set(F_STATO, str_sfs, true);
const char sfs = maindoc.tipo().stato_finale_stampa();
maindoc.stato(sfs);
const char str_sfs[2] = { sfs, '\0' };
m.set(F_STATO, str_sfs, true);
}
}
}
}

View File

@ -37,7 +37,6 @@ class TMotore_application : public TRelation_application
int _link_pos;
bool _print_directly;
protected:
// Ridefinizione dei metodi virtuali
@ -49,9 +48,11 @@ protected:
virtual void init_query_mode(TMask& m);
virtual void init_insert_mode( TMask& m );
virtual void init_modify_mode( TMask& m );
void load_auto_reopen_data();
virtual int read( TMask& m );
virtual int write( const TMask& m );
virtual int rewrite( const TMask& m );
virtual bool remove();
virtual void print();
virtual bool has_filtered_cursor() const { return true; }
virtual TCursor& get_filtered_cursor() const;

View File

@ -162,7 +162,6 @@ NUMBER F_NDOC_ELAB 6
BEGIN
PROMPT 24 5 "Numero doc. "
USE LF_DOC KEY 4
JOIN LF_CLIFO TO LF_DOC INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT TIPOCF F_TIPOCF_ELAB SELECT
INPUT CODCF F_CODCF_ELAB SELECT
INPUT PROVV F_PROVV_ELAB SELECT
@ -176,9 +175,6 @@ BEGIN
DISPLAY "N.Doc. " NDOC
DISPLAY "Stato" STATO
DISPLAY "Data\ndocumento" DATADOC
DISPLAY "C/F" TIPOCF
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" LF_CLIFO->RAGSOC
OUTPUT F_DATADOC_ELAB DATADOC
OUTPUT F_CODNUM_ELAB CODNUM
OUTPUT F_NDOC_ELAB NDOC

76
ve/ve0100d.uml Executable file
View File

@ -0,0 +1,76 @@
#include "veuml.h"
PAGE "Estremi del documento" 1 1 80 14
GROUPBOX DLG_NULL 78 7
BEGIN
PROMPT 1 4 "Estremi del documento definitivo"
END
STRING F_CODNUM 4
BEGIN
PROMPT 2 5 "Numerazione "
FIELD CODNUM
HELP "Codice numerazione"
USE %NUM
INPUT CODTAB F_CODNUM
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_CODNUM CODTAB
OUTPUT F_DESNUM S0
CHECKTYPE FORCED
FLAG "UPA"
WARNING "Numerazione assente"
KEY 1 2
END
STRING F_DESNUM 50
BEGIN
PROMPT 24 5 ""
HELP "Descrizione numerazione"
USE %NUM KEY 2
INPUT S0 F_DESNUM
DISPLAY "Descrizione@50" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_CODNUM
END
STRING F_TIPODOC 4
BEGIN
PROMPT 2 6 "Tipo "
FIELD TIPODOC
HELP "Codice tipo documento"
USE %TIP
INPUT CODTAB F_TIPODOC
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_TIPODOC CODTAB
OUTPUT F_DESTIPODOC S0
CHECKTYPE FORCED
FLAG "UP"
END
STRING F_DESTIPODOC 50
BEGIN
PROMPT 24 6 ""
HELP "Descrizione tipo documento"
USE %TIP KEY 2
INPUT S0 F_DESTIPODOC
DISPLAY "Descrizione@50" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_TIPODOC
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -1253,6 +1253,13 @@ void TMask_generator::genera( const TString& profilo )
_m->message( "EXIT,20082" );
_m->end( );
_m->control( T_BOTTONE, DLG_CONFERMA, 1002 );
_m->begin( );
_m->prompt( -45, -1, "~Conferma");
_m->picture(BMP_OK);
_m->flag("H");
_m->end( );
_m->control( T_BOTTONE, DLG_CANCEL, 1002 );
_m->begin( );
_m->prompt( -55, -1 );

View File

@ -6,294 +6,6 @@
#include <doc.h>
///////////////////////////////////////////////////////////
// Lista Cliente/Fornitore per vendite
///////////////////////////////////////////////////////////
class TLista_clifo : public TObject // velib04
{
class TClifo : public TObject
{
long _codice;
long _agente;
long _zona;
protected:
void zero() { _codice = _agente = _zona = 0L; }
void init(const TRectype& rec, const TRectype& ven);
bool read(char tipo, long cod);
public: // TObject
virtual bool ok() const { return _codice > 0; }
public:
long codice() const { return _codice; }
long agente() const { return _agente; }
long zona() const { return _zona; }
TClifo() { zero(); }
TClifo(char tipo, long cod) { read(tipo, cod); }
TClifo(const TRectype& rec, const TRectype& ven) { init(rec, ven); }
TClifo(const TRectype& rec);
virtual ~TClifo() { }
};
TArray _clifo;
protected:
virtual char tipo() const pure;
const TClifo& clifo(int n) const { return (TClifo&)_clifo[n]; }
static int sort_by_code(const TObject** o1, const TObject** o2);
static int sort_by_agent(const TObject** o1, const TObject** o2);
static int sort_by_zone(const TObject** o1, const TObject** o2);
public:
int ordina_per_codice();
int ordina_per_agente();
int ordina_per_zona();
int leggi(long dc, long ac, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
int leggi_ragsoc(const char *dr, const char * ar, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
long operator[] (int n) const { return clifo(n).codice(); }
int items() const { return _clifo.items(); }
int find(long cod) const;
int add(long cod);
TLista_clifo() { }
virtual ~TLista_clifo() { }
};
class TLista_clienti : public TLista_clifo
{
protected:
virtual char tipo() const { return 'C'; }
};
class TLista_fornitori : public TLista_clifo
{
protected:
virtual char tipo() const { return 'F'; }
};
class TLista_cf : public TLista_clifo
{
char _tipo;
protected:
virtual char tipo() const { return _tipo; }
public:
TLista_cf(char tipo) : _tipo(tipo) {}
};
void TLista_clifo::TClifo::init(const TRectype& rec, const TRectype& ven)
{
_codice = rec.get_long(CLI_CODCF);
CHECK(_codice > 0, "Codice cliente nullo");
if (!ven.empty())
{
_agente = ven.get_long(CLI_CODAG);
_zona = ven.get_long(CLI_CODZONA);
}
else
_agente = _zona = 0;
}
bool TLista_clifo::TClifo::read(char tipo, long cod)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
TRectype& curr = clifo.curr();
curr.put(CLI_TIPOCF, tipo);
curr.put(CLI_CODCF, cod);
if (clifo.read() == NOERR)
init(curr, clifo.curr(LF_CFVEN));
else
zero();
return ok();
}
TLista_clifo::TClifo::TClifo(const TRectype& rec)
{
CHECK(rec.num() == LF_CLIFO, "Record non clienti");
const char tipo = rec.get_char(CLI_TIPOCF);
const long codice = rec.get_long(CLI_CODCF);
read(tipo, codice);
}
int TLista_clifo::leggi(long dc, long ac, long da, long aa, const char * dz, const char * az)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF==TIPOCF|CODCF==CODCF");
TRectype start(LF_CLIFO), stop(LF_CLIFO);
start.put(CLI_TIPOCF, tipo());
if (dc > 0)
start.put(CLI_CODCF, dc);
stop.put(CLI_TIPOCF, tipo());
if (ac > 0)
stop.put(CLI_CODCF, ac);
TString filter(32);
if (da > 0)
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << ">=" << da << ')';
if (aa > 0)
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << "<=" << aa << ')';
}
if (dz && (*dz !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=\"" << dz << "\")";
}
if (az && (*az !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=\"" << az << "\")";
}
TCursor cur(&clifo, "", 1, &start, &stop);
if (filter.not_empty())
cur.setfilter(filter, TRUE);
const TRectype& cli = cur.curr();
const TRectype& ven = cur.curr(LF_CFVEN);
for (cur = 0; cur.ok(); ++cur)
{
TClifo* c = new TClifo(cli, ven);
_clifo.add(c);
}
if (dc > 0 || ac > 0)
ordina_per_codice();
else
if (da > 0 || aa > 0)
ordina_per_agente();
else
if ((dz && (*dz !='\0')) || (az && (*dz !='\0')))
ordina_per_zona();
return _clifo.items();
}
int TLista_clifo::leggi_ragsoc(const char *dr, const char * ar, long da, long aa, const char * dz, const char * az)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF==TIPOCF|CODCF==CODCF");
TRectype start(LF_CLIFO), stop(LF_CLIFO);
start.put(CLI_TIPOCF, tipo());
if (dr && *dr)
start.put(CLI_RAGSOC, dr);
stop.put(CLI_TIPOCF, tipo());
if (ar && *ar)
stop.put(CLI_RAGSOC, ar);
TString filter(32);
if (da > 0)
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << ">=" << da << ')';
if (aa > 0)
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << "<=" << aa << ')';
}
if (dz && (*dz !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=\"" << dz << "\")";
}
if (az && (*az !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=\"" << az << "\")";
}
TCursor cur(&clifo, "", 2, &start, &stop);
if (filter.not_empty())
cur.setfilter(filter, TRUE);
const TRectype& cli = cur.curr();
const TRectype& ven = cur.curr(LF_CFVEN);
for (cur = 0; cur.ok(); ++cur)
{
TClifo* c = new TClifo(cli, ven);
_clifo.add(c);
}
return _clifo.items();
}
int TLista_clifo::sort_by_code(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->codice() - c2->codice();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::sort_by_agent(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->agente() - c2->agente();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::sort_by_zone(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->zona() - c2->zona();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::ordina_per_codice()
{
_clifo.sort(sort_by_code);
return _clifo.items();
}
int TLista_clifo::ordina_per_agente()
{
_clifo.sort(sort_by_agent);
return _clifo.items();
}
int TLista_clifo::ordina_per_zona()
{
_clifo.sort(sort_by_zone);
return _clifo.items();
}
int TLista_clifo::find(long cod) const
{
int i;
for (i = items()-1; i >= 0; i--)
if (clifo(i).codice() == cod) break;
return i;
}
int TLista_clifo::add(long cod)
{
int pos = find(cod);
if (pos < 0)
{
TClifo* c = new TClifo(tipo(), cod);
pos = _clifo.add(c);
}
return pos;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// TFatturazione_bolle_app
///////////////////////////////////////////////////////////

View File

@ -360,6 +360,9 @@ public:
const bool fattura_emettere_ricevere() const { return get_bool("B3"); }
const bool save_and_new() const { return get_bool("B4"); }
const bool test_eser() const { return !get_bool("B5"); }
const bool newnumdef() const { return get_bool("B8"); }
const TString& codnumdef() const { return get("S8"); }
const TString& tipodocdef() const { return get("S9"); }
const TString& tipo_doc(int i) const;
int ntipi_doc() const;
@ -392,7 +395,9 @@ class TTipo_riga_documento : public TRectype // velib02
int _search_years;
int _max_rows_art;
bool _no_desc;
TToken_string _search_active_docs;
TToken_string _fields_to_update;
int _decrp, _incrp;
protected:
@ -423,6 +428,8 @@ public:
const TToken_string& search_nums() const { return _search_nums;}
const int max_rows_art() const { return _max_rows_art;}
bool no_desc() const { return _no_desc;}
TToken_string& search_active_docs() { return _search_active_docs;}
TToken_string& fields_to_update() { return _fields_to_update;}
const TString& provv() const { return _field_provv;}
const int incr_perc_prezzo() const { return _incrp;}
@ -801,6 +808,19 @@ public:
class TCodgiac_livelli;
class TStati : public TObject
{
char _iniziale;
char _finale;
public:
char iniziale() const { return _iniziale;}
char finale() const { return _finale;}
TStati(char iniziale, char finale) { _iniziale = iniziale; _finale = finale;}
virtual ~TStati() { }
};
class TDocumento_mask : public TVariable_mask // velib06
{
int _progs_page; // pagina in cui cominciano i progressivi
@ -816,6 +836,9 @@ class TDocumento_mask : public TVariable_mask // velib06
bool _ges_mag, _ges_dep, _ges_ca;
TString _std_mag, _std_dep;
TSmart_card * _smartcard;
static TAssoc_array _father_rows;
static TAssoc_array _auto_reopen_nums;
static TAssoc_array _tipidoc_rels;
short _cdc_start;
short _cdc_end;
short _cms_start;
@ -860,6 +883,7 @@ public:
static bool codcamp_handler( TMask_field& f, KEY key );
static bool datacambio_handler( TMask_field& f, KEY key );
static bool codval_handler( TMask_field& f, KEY key );
static bool confirm_handler( TMask_field& f, KEY key );
static bool ss_notify(TSheet_field& ss, int r, KEY key);
static bool ss_handler(TMask_field& f, KEY key);
void user_set_handler( int fieldid, int index);
@ -878,6 +902,12 @@ public:
void update_giacenza();
static TAssoc_array & auto_reopen_nums() { return _auto_reopen_nums;}
static TAssoc_array & tipidoc_rels() { return _tipidoc_rels;}
void reset_father_rows() {_father_rows.destroy();}
void update_father_rows(bool add = true);
void save_father_rows();
const TString& stdmag() const { return _std_mag; }
const TString& stddep() const { return _std_dep; }

View File

@ -128,6 +128,8 @@ void TTipo_riga_documento::read_formule()
_search_nums = profile.get("SEARCHNUMS");
_search_years = profile.get_int("SEARCHYEARS");
_max_rows_art = profile.get_int("MAXROWSART");
_search_active_docs = profile.get("SEARCHACTDOCS");
_fields_to_update = profile.get("FIELDSTOUPDATE");
_no_desc = profile.get_bool("NODESC");
_formule = profile.get("CAMPICALC");
@ -947,7 +949,7 @@ void TRiga_documento::autosave(TSheet_field& f)
codmag << row.get( f.cid2index(FR_CODDEP ));
put( RDOC_CODMAG, codmag);
put( RDOC_CODART, row.get( f.cid2index(FR_CODART )) );
TString liv;
TString80 liv;
for (int l = 0; l<4 ; l++)
doc().livelli().pack_grpcode(liv,row.get(f.cid2index(FR_LIV1+l)),l+1);
put( RDOC_LIVELLO, liv); // da modificare
@ -1012,6 +1014,8 @@ void TRiga_documento::autosave(TSheet_field& f)
put( RDOC_QTAGG5, row.get( f.cid2index(FR_QTAGG5 )) );
put( RDOC_IMPIANTO, row.get( f.cid2index(FR_IMPIANTO )) );
put( RDOC_LINEA, row.get( f.cid2index(FR_LINEA )) );
put( RDOC_CODAGG1, row.get( f.cid2index(FR_CODAGG1)) );
put( RDOC_CODAGG2, row.get( f.cid2index(FR_CODAGG2)) );
f.select(num); // Seleziona la riga in modo da selezionare la maschera di riga giusta
for (short cdcid = FR_CDC1; cdcid <= FR_CDC12; cdcid++)
@ -1068,19 +1072,22 @@ void TRiga_documento::autosave(TSheet_field& f)
} //if(tipodet!=9)
} //if(m.field(...
put( RDOC_CODAGG1, row.get(f.cid2index(FR_CODAGG1)) );
put( RDOC_CODAGG2, row.get(f.cid2index(FR_CODAGG2)) );
for (short jid = FR_JOLLY1; jid <= FR_JOLLY10; jid++)
// Salvo i campi con un FIELD manuale
const int last_pos = f.cid2index(FR_CODAGG2);
f.select(num); // Seleziono la riga giusta in modo da avere la maschera giusta
const TMask& m = f.sheet_mask();
for (int i = last_pos+1; ; i++)
{
const int pos = m.id2pos(jid);
if (pos < 0)
const char* val = row.get(i);
if (val != NULL)
{
const TMask_field& c = m.field(FR_LORDO+i);
const TFieldref* fld = c.field();
if (fld != NULL)
fld->write(val, *this);
}
else
break;
const TMask_field& fld = m.fld(pos);
const TFieldref* fldref = fld.field();
if (fldref == NULL)
break;
fldref->write(fld.get(), *this);
}
}
}
@ -1107,10 +1114,8 @@ void TRiga_documento::autoload(TSheet_field & f)
row.add(s, f.cid2index(FR_DESCR ));
row.add( get( RDOC_UMQTA ), f.cid2index(FR_UMQTA ));
TString8 codiva(get(RDOC_CODIVA));
real prezzo = get_real( RDOC_PREZZO );
const TString4 codiva(get(RDOC_CODIVA));
real prezzo = get_real(RDOC_PREZZO);
if (doc().tipo().calcolo_lordo())
{
const real prezzol = get_real(RDOC_PREZZOL);
@ -1150,6 +1155,8 @@ void TRiga_documento::autoload(TSheet_field & f)
row.add( get( RDOC_QTAGG5) , f.cid2index(FR_QTAGG5));
row.add( get( RDOC_IMPIANTO) , f.cid2index(FR_IMPIANTO));
row.add( get( RDOC_LINEA) , f.cid2index(FR_LINEA));
row.add( get( RDOC_CODAGG1) , f.cid2index(FR_CODAGG1));
row.add( get( RDOC_CODAGG2) , f.cid2index(FR_CODAGG2));
f.select(num); // Seleziona la riga in modo da selezionare la maschera di riga giusta
TMask& m = f.sheet_mask();
@ -1165,21 +1172,22 @@ void TRiga_documento::autoload(TSheet_field & f)
const TString& val = fldref->read(*this);
row.add(val, f.cid2index(cdcid));
}
row.add( get( RDOC_CODAGG1) , f.cid2index(FR_CODAGG1));
row.add( get( RDOC_CODAGG2) , f.cid2index(FR_CODAGG2));
row.add( get( RDOC_TIPODET) , f.cid2index(FR_TIPODET));
for (short jid = FR_JOLLY1; jid <= FR_JOLLY10; jid++)
// Leggo i campi con un FIELD manuale
const int last_pos = f.cid2index(FR_CODAGG2);
f.select(num); // Seleziono la riga giusta in modo da avere la maschera giusta
const TMask& m = f.sheet_mask();
FOR_EACH_MASK_FIELD(m, i, c)
{
const int pos = m.id2pos(jid);
if (pos < 0)
break;
TMask_field& fld = m.fld(pos);
const TFieldref* fldref = fld.field();
if (fldref == NULL)
break;
const TString& val = fldref->read(*this);
row.add(val, f.cid2index(jid));
const TFieldref* fld = c->field();
if (fld != NULL)
{
const int idx = f.cid2index(c->dlg());
if (idx > last_pos && idx < MAX_COLUMNS)
row.add(fld->read(*this), idx);
}
}
}

View File

@ -175,6 +175,215 @@ int TLista_documenti::write(bool re) const
return err;
}
///////////////////////////////////////////////////////////
// TLista_clifo
///////////////////////////////////////////////////////////
void TLista_clifo::TClifo::init(const TRectype& rec, const TRectype& ven)
{
_codice = rec.get_long(CLI_CODCF);
CHECK(_codice > 0, "Codice cliente nullo");
if (!ven.empty())
{
_agente = ven.get_long(CLI_CODAG);
_zona = ven.get_long(CLI_CODZONA);
}
else
_agente = _zona = 0;
}
bool TLista_clifo::TClifo::read(char tipo, long cod)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
TRectype& curr = clifo.curr();
curr.put(CLI_TIPOCF, tipo);
curr.put(CLI_CODCF, cod);
if (clifo.read() == NOERR)
init(curr, clifo.curr(LF_CFVEN));
else
zero();
return ok();
}
TLista_clifo::TClifo::TClifo(const TRectype& rec)
{
CHECK(rec.num() == LF_CLIFO, "Record non clienti");
const char tipo = rec.get_char(CLI_TIPOCF);
const long codice = rec.get_long(CLI_CODCF);
read(tipo, codice);
}
int TLista_clifo::leggi(long dc, long ac, long da, long aa, const char * dz, const char * az)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF==TIPOCF|CODCF==CODCF");
TRectype start(LF_CLIFO), stop(LF_CLIFO);
start.put(CLI_TIPOCF, tipo());
if (dc > 0)
start.put(CLI_CODCF, dc);
stop.put(CLI_TIPOCF, tipo());
if (ac > 0)
stop.put(CLI_CODCF, ac);
TString filter(32);
if (da > 0)
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << ">=" << da << ')';
if (aa > 0)
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << "<=" << aa << ')';
}
if (dz && (*dz !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=\"" << dz << "\")";
}
if (az && (*az !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=\"" << az << "\")";
}
TCursor cur(&clifo, "", 1, &start, &stop);
if (filter.not_empty())
cur.setfilter(filter, TRUE);
const TRectype& cli = cur.curr();
const TRectype& ven = cur.curr(LF_CFVEN);
for (cur = 0; cur.ok(); ++cur)
{
TClifo* c = new TClifo(cli, ven);
_clifo.add(c);
}
if (dc > 0 || ac > 0)
ordina_per_codice();
else
if (da > 0 || aa > 0)
ordina_per_agente();
else
if ((dz && (*dz !='\0')) || (az && (*dz !='\0')))
ordina_per_zona();
return _clifo.items();
}
int TLista_clifo::leggi_ragsoc(const char *dr, const char * ar, long da, long aa, const char * dz, const char * az)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF==TIPOCF|CODCF==CODCF");
TRectype start(LF_CLIFO), stop(LF_CLIFO);
start.put(CLI_TIPOCF, tipo());
if (dr && *dr)
start.put(CLI_RAGSOC, dr);
stop.put(CLI_TIPOCF, tipo());
if (ar && *ar)
stop.put(CLI_RAGSOC, ar);
TString filter(32);
if (da > 0)
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << ">=" << da << ')';
if (aa > 0)
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << "<=" << aa << ')';
}
if (dz && (*dz !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=\"" << dz << "\")";
}
if (az && (*az !='\0'))
{
if (filter.not_empty()) filter << "&&";
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=\"" << az << "\")";
}
TCursor cur(&clifo, "", 2, &start, &stop);
if (filter.not_empty())
cur.setfilter(filter, TRUE);
const TRectype& cli = cur.curr();
const TRectype& ven = cur.curr(LF_CFVEN);
for (cur = 0; cur.ok(); ++cur)
{
TClifo* c = new TClifo(cli, ven);
_clifo.add(c);
}
return _clifo.items();
}
int TLista_clifo::sort_by_code(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->codice() - c2->codice();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::sort_by_agent(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->agente() - c2->agente();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::sort_by_zone(const TObject** o1, const TObject** o2)
{
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->zona() - c2->zona();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clifo::ordina_per_codice()
{
_clifo.sort(sort_by_code);
return _clifo.items();
}
int TLista_clifo::ordina_per_agente()
{
_clifo.sort(sort_by_agent);
return _clifo.items();
}
int TLista_clifo::ordina_per_zona()
{
_clifo.sort(sort_by_zone);
return _clifo.items();
}
int TLista_clifo::find(long cod) const
{
int i;
for (i = items()-1; i >= 0; i--)
if (clifo(i).codice() == cod) break;
return i;
}
int TLista_clifo::add(long cod)
{
int pos = find(cod);
if (pos < 0)
{
TClifo* c = new TClifo(tipo(), cod);
pos = _clifo.add(c);
}
return pos;
}
///////////////////////////////////////////////////////////
// TParametri_elaborazione
///////////////////////////////////////////////////////////

View File

@ -43,6 +43,88 @@ public:
virtual ~TLista_documenti() {};
};
///////////////////////////////////////////////////////////
// Lista Cliente/Fornitore per vendite
///////////////////////////////////////////////////////////
class TLista_clifo : public TObject // velib04
{
class TClifo : public TObject
{
long _codice;
long _agente;
long _zona;
protected:
void zero() { _codice = _agente = _zona = 0L; }
void init(const TRectype& rec, const TRectype& ven);
bool read(char tipo, long cod);
public: // TObject
virtual bool ok() const { return _codice > 0; }
public:
long codice() const { return _codice; }
long agente() const { return _agente; }
long zona() const { return _zona; }
TClifo() { zero(); }
TClifo(char tipo, long cod) { read(tipo, cod); }
TClifo(const TRectype& rec, const TRectype& ven) { init(rec, ven); }
TClifo(const TRectype& rec);
virtual ~TClifo() { }
};
TArray _clifo;
protected:
virtual char tipo() const pure;
const TClifo& clifo(int n) const { return (TClifo&)_clifo[n]; }
static int sort_by_code(const TObject** o1, const TObject** o2);
static int sort_by_agent(const TObject** o1, const TObject** o2);
static int sort_by_zone(const TObject** o1, const TObject** o2);
public:
int ordina_per_codice();
int ordina_per_agente();
int ordina_per_zona();
int leggi(long dc, long ac, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
int leggi_ragsoc(const char *dr, const char * ar, long da = 0, long aa = 0, const char * dz = "", const char * az = "");
long operator[] (int n) const { return clifo(n).codice(); }
int items() const { return _clifo.items(); }
int find(long cod) const;
int add(long cod);
TLista_clifo() { }
virtual ~TLista_clifo() { }
};
class TLista_clienti : public TLista_clifo
{
protected:
virtual char tipo() const { return 'C'; }
};
class TLista_fornitori : public TLista_clifo
{
protected:
virtual char tipo() const { return 'F'; }
};
class TLista_cf : public TLista_clifo
{
char _tipo;
protected:
virtual char tipo() const { return _tipo; }
public:
TLista_cf(char tipo) : _tipo(tipo) {}
};
enum TTipo_elaborazione { _esterna, _consegna_ordini, _fatturazione_bolle,
_contabilizzazione, _copia_documento,
_generazione_effetti, _consuntivazione_produzione,
@ -491,6 +573,21 @@ public:
virtual ~TConsuntivazione_produzione() { }
};
class TLista_elaborazioni : public TObject // velib04
{
TAssoc_array * _elab;
protected:
void read();
public:
TElaborazione & operator [](const char * key) const;
int select(TString_array & result, const char * tipo_iniziale = NULL, const char * stato_iniziale = NULL, const char * tipo_finale = NULL, const char * stato_finale = NULL);
void update();
TLista_elaborazioni() : _elab(NULL) {}
virtual ~TLista_elaborazioni();
};
class TCache_causali; // Internal use only
class TContabilizzazione_analitica : public TElaborazione // velib04f

View File

@ -286,6 +286,7 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
{
TWait_cursor hourglass;
TToken_string campi_doc(128); // Lista di campi che devono essere uguali
TBit_array closed;
campi_raggruppamento( campi_doc);
@ -313,7 +314,13 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
{
for (od = 0; od < tot; od++) // ... cerca un documento compatibile.
{
if (doc_raggruppabile(campione, doc_out[od], campi_doc))
const int in_rows = campione.rows();
const int out_rows = doc_out[od].rows();
if (in_rows + out_rows <= 990)
closed.set(od);
else
if (!closed[od] && doc_raggruppabile(campione, doc_out[od], campi_doc))
// if (campione.raggruppabile(doc_out[od], campi_doc))
break;
}
@ -368,4 +375,4 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
return tot > 0;
}

View File

@ -1,5 +1,7 @@
#include <automask.h>
#include <diction.h>
#include <reprint.h>
#include <reputils.h>
#include <utility.h>
#include "velib04.h"
@ -159,6 +161,7 @@ bool TConsuntivazione_produzione::elabora(TLista_documenti& doc_in, TLista_docum
const TDate& data_elab, bool interattivo)
{
TConsuntivazione_mask msk;
TLog_report log("Consuntivazione produzione");
bool done = false;
if (msk.run() == K_ENTER)
{
@ -236,7 +239,7 @@ bool TConsuntivazione_produzione::elabora(TLista_documenti& doc_in, TLista_docum
else
{
const char* msg = TR("Impossibile aggiornare il documento");
error_box("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc);
log.log(1, format("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc));
}
if (ordine.is_evaso())
ordine.stato(stato_finale_doc_iniziale()[0]);
@ -244,7 +247,7 @@ bool TConsuntivazione_produzione::elabora(TLista_documenti& doc_in, TLista_docum
if (err != NOERR)
{
const char* msg = TR("Impossibile aggiornare il documento");
error_box("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc);
log.log(1, format("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc));
}
done = true;
@ -266,23 +269,35 @@ bool TConsuntivazione_produzione::elabora(TLista_documenti& doc_in, TLista_docum
if (err != NOERR)
{
const char* msg = TR("Impossibile aggiornare la riga di rilevazione");
error_box("%s %s %s %d", msg, (const char*)codart, (const char*)data.string(), prog);
log.log(1, format("%s %s %s %d", msg, (const char*)codart, (const char*)data.string(), prog));
break;
}
}
else
{
const char* msg = TR("Impossibile leggere l'ordine di produzione");
error_box("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc);
log.log(1, format("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc));
}
}
else
{
const char* msg = TR("Impossibile trovare l'ordine di produzione\nrelativo all'ordine cliente");
error_box("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc);
const char* msg = TR("Impossibile trovare l'ordine di produzione relativo all'ordine cliente");
log.log(1, format("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc));
ril.put("CODART", codart);
ril.put("DATA", data);
ril.put("PROG", prog);
if (rilevazioni.read(_isequal, _testandlock) == NOERR)
{
ril.put("CHIUSO", chiuso);
ril.put("CODNUMP", outdoc.get(DOC_CODNUM));
rilevazioni.rewrite();
}
}
}
}
TReport_book book;
book.add(log);
book.preview();
return done;
}

View File

@ -19,7 +19,7 @@
#include "ve0100.h"
#include "ve0100b1.h"
#include "ve0100C.h"
#include "ve0100c.h"
#include "ve0100o.h"
#include "veuml.h"
#include "veuml1.h"
@ -132,6 +132,7 @@ TDocumento_mask::TDocumento_mask(const char* td)
set_field_handler( F_DATADOCRIF, datadocrif_handler);
set_handler( DLG_ELABORA, elabora_handler );
set_handler( DLG_PRINT, print_handler );
set_handler( DLG_CONFERMA, confirm_handler );
const TString_array& handlers = tdoc.handlers();
int numhandler = handlers.items();
@ -2527,6 +2528,8 @@ bool TElabora_mask::elabora()
const long movmag = app_doc.get_long(DOC_MOVMAG);
const TDate datadoc = app_doc.get_date(DOC_DATADOC);
const TDate datainsc = app_doc.get_date(DOC_DATAINSC);
const TDate datapart = app_doc.get_date(DOC_DATAPART);
const TString8 orapart(app_doc.get(DOC_ORAPART));
const char stato = app_doc.stato();
TDocumento::copy_data(app_doc.head(), in[0].head());
@ -2902,6 +2905,7 @@ bool TDocumento_mask::elabora_handler( TMask_field& f, KEY key )
bool do_checks = false;
const char stato_iniziale = m.doc().stato();
m.update_father_rows();
while (selection->run() == K_ENTER) //NON riportare modifiche dalla 3.1!! Già sistemato
{
m.mask2doc();
@ -2941,6 +2945,7 @@ bool TDocumento_mask::elabora_handler( TMask_field& f, KEY key )
for (i = tutti-1; i >= 0; i--)
m.fld(i).set_dirty(FALSE);
}
m.update_father_rows(false);
delete selection;
}
}
@ -3259,3 +3264,212 @@ bool TDocumento_mask::codval_handler( TMask_field& f, KEY key )
}
return TRUE;
}
void TDocumento_mask::update_father_rows(bool add)
{
if (_auto_reopen_nums.empty())
return;
const int rows = doc().physical_rows();
for (int i = 1; i <= rows; i++)
{
const TRiga_documento & r = doc()[i];
if (r.is_merce() || r.is_omaggio()|| r.is_prestazione())
{
TRiga_documento * original_row = (TRiga_documento *) r.find_original_rdoc();
if (original_row != NULL && _auto_reopen_nums.objptr(original_row->get(RDOC_CODNUM)) != NULL)
{
TToken_string key;
key.add(original_row->get(RDOC_PROVV));
key.add(original_row->get(RDOC_ANNO));
key.add(original_row->get(RDOC_CODNUM));
key.add(original_row->get(RDOC_NDOC));
key.add(original_row->get(RDOC_IDRIGA));
real * qta = (real *) _father_rows.objptr(key);
if (qta == NULL)
{
qta = new real;
_father_rows.add(key, qta);
}
real value = r.quantita();
if (r.is_articolo())
{
TArticolo art(r.get(RDOC_CODARTMAG));
value = art.convert_to_um(value, original_row->get(RDOC_UMQTA), r.get(RDOC_UMQTA));
}
if(add)
*qta += value;
else
*qta -= value;
if (*qta == ZERO)
_father_rows.remove(key);
}
}
}
}
TAssoc_array TDocumento_mask::_father_rows;
TAssoc_array TDocumento_mask::_auto_reopen_nums;
TAssoc_array TDocumento_mask::_tipidoc_rels;
void TDocumento_mask::save_father_rows()
{
if (_auto_reopen_nums.empty())
return;
TLocalisamfile rdoc(LF_RIGHEDOC);
TString_array rows;
TToken_string last_doc;
TToken_string curr_doc;
int nrows = 0;
FOR_EACH_ASSOC_OBJECT(_father_rows, h, k, o)
{
rows.add(k);
}
rows.sort();
rows.add("");
FOR_EACH_ARRAY_ROW(rows, i, r)
{
curr_doc = r->get(0);
curr_doc.add(r->get());
curr_doc.add(r->get());
curr_doc.add(r->get());
if (last_doc != curr_doc && nrows > 0)
{
TDocumento d;
d.read(last_doc.get_char(0), last_doc.get_int(1), last_doc.get(2), last_doc.get_long(3), _isequal, _lock);
for (int j = i - nrows; j < i; j++)
{
TToken_string & key = rows.row(j);
const long idriga = key.get_long(4);
const int nrows = d.physical_rows();
for (int k = 1; k <= nrows; k++)
{
TRiga_documento & rdoc_row = d[k];
if (idriga == rdoc_row.get_long(RDOC_IDRIGA))
{
const real * qta = (const real *) _father_rows.objptr(key);
const TString16 name = rdoc_row.field_qtaevasa();
real qtaevasa = rdoc_row.get_real(name) + * qta;
if (qtaevasa < ZERO)
qtaevasa = ZERO;
rdoc_row.put(name, qtaevasa);
if (qtaevasa < rdoc_row.quantita())
rdoc_row.zero(RDOC_RIGAEVASA);
else
rdoc_row.put(RDOC_RIGAEVASA, "X");
break;
}
}
}
TToken_string key(d.tipo().codice());
key.add(doc().tipo().codice());
TStati * stati = (TStati *) _tipidoc_rels.objptr(key);
if (stati != NULL)
{
const int nrows = d.physical_rows();
bool evaso = true;
for (int k = 1; evaso && k <= nrows; k++)
evaso &= d[k].is_evasa();
d.stato(evaso ? stati->finale() : stati->iniziale());
}
d.rewrite();
nrows = 0;
}
last_doc = curr_doc;
nrows++;
}
}
bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key )
{
if (key == K_SPACE)
{
TMask m("ve0100d");
TDocumento_mask & mask = (TDocumento_mask &) f.mask();
const TDocumento& src = mask.doc();
TCodice_numerazione num(src.numerazione());
TString4 codnum(num.codnumdef());
TString4 tipodoc(num.tipodocdef());
if (!num.newnumdef())
{
codnum = src.get(DOC_CODNUM);
tipodoc = src.get(DOC_TIPODOC);
}
else
{
codnum = num.get("S8");
tipodoc = num.get("S9");
}
bool ok = codnum.full() && tipodoc.full();
if (!ok)
{
m.set(F_CODNUM, codnum);
m.enable(F_CODNUM, codnum.blank());
m.enable(F_DESNUM, codnum.blank());
m.set(F_TIPODOC, tipodoc);
m.enable(F_TIPODOC, tipodoc.blank());
m.enable(F_DESTIPODOC, tipodoc.blank());
ok = m.run() == K_ENTER;
if (ok)
{
codnum = m.get(F_CODNUM);
tipodoc = m.get(F_TIPODOC);
}
}
ok = codnum.full() && tipodoc.full();
if (ok)
{
TDocumento dest(src);
dest.put(DOC_CODNUM, codnum);
dest.put(DOC_TIPODOC, tipodoc);
dest.put(DOC_PROVV, "D");
dest.zero(DOC_NDOC);
int err = dest.write();
if (err == NOERR)
{
err = src.remove();
if (err != NOERR)
warning_box("Errore %d nell'eliminazione del documento provvisorio", err);
mask.stop_run(K_ESC);
TMask & qmask = app().query_mask();
qmask.set(F_CODNUM, codnum);
qmask.set(F_PROVV, dest.get_char(DOC_PROVV));
qmask.set(F_ANNO, dest.get_int(DOC_ANNO));
qmask.set(F_NDOC, dest.get_long(DOC_NDOC));
qmask.field(F_NDOC).update_flags("RP");
// qmask.send_key(K_ENTER, 0);
}
else
return error_box("Errore %d nella generazione del documento definitivo", err);
}
}
return ok;
}

View File

@ -356,7 +356,7 @@ bool data_hndl( TMask_field& field, KEY key )
// handler delle righe
void row_set_handler( TMask& m, const int field, const int index )
void row_set_handler( TMask& m, const int field, const int index)
{
switch ( index )
{
@ -374,6 +374,10 @@ void row_set_handler( TMask& m, const int field, const int index )
if (field == FR_CODART)
m.set_handler( field, find_price_handler );
break;
case 5:
if (field == FR_CODART)
m.set_handler( field, link_row_handler );
break;
default:
yesnofatal_box( false, "Funzione di handler sulla riga non definita( %d ).", index );
break;
@ -1173,6 +1177,131 @@ bool find_price_handler(TMask_field& f, KEY key )
return codart_handler( f, key);
}
class TLink_article_sheet : public TBrowse_sheet
{
protected:
virtual bool get_ini_paragraph(const TEdit_field& field, TString& parag) const;
public:
TLink_article_sheet(TCursor& cur, TEdit_field& f);
};
bool TLink_article_sheet::get_ini_paragraph(const TEdit_field& field, TString& parag) const
{
const bool ok = TSheet::get_ini_paragraph(field, parag);
if (ok)
parag << "_F82";
return ok;
}
TLink_article_sheet::TLink_article_sheet(TCursor& cur, TEdit_field& f)
: TBrowse_sheet(&cur, "-201->S0|-202->S0|NDOC|33->DATADOC|QTA|QTAEVASA",
TR("Ricerca Prezzi"),
HR("Numerazione@18|Tipo Documento@18|Num.|Data@10|Quantità@15P|Evaso@15P"),
0, f, TToken_string())
{ }
bool link_row_handler(TMask_field& f, KEY key )
{
TMask& row_mask = f.mask();
TSheet_field& sh = *row_mask.get_sheet();
if (key == K_F8 && !sh.sheet_mask().is_running())
{
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
TDocumento &doc = mask.doc();
const int current_doc_row = sh.selected() + 1;
TRiga_documento & r = doc[current_doc_row];
TTipo_riga_documento & tipo = (TTipo_riga_documento &) r.tipo();
if ((tipo.search_active_docs().blank()) || (tipo.search_active_docs().find(doc.tipo().codice()) >= 0))
{
TEdit_field& ef = (TEdit_field&)f;
const TString& codart = row_mask.get(FR_CODART);
if (codart.full() && r.get(RDOC_DACODNUM).empty())
{
TDate datadoc = mask.get_date(F_DATADOC);
TToken_string nums(((TTipo_riga_documento&)r.tipo()).search_nums());
if (nums.blank())
nums = mask.get(F_CODNUM);
TString4 first_num(nums.get(0));
TString4 last_num(first_num);
TString filter;
filter << "(RIGAEVASA!=\"X\")&&(CODART==\"" << codart << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")";
FOR_EACH_TOKEN(nums, s)
{
if (first_num > s)
first_num = s;
if (last_num < s)
last_num = s;
filter << "||(CODNUM==\"" << s << "\")";
}
filter << ")";
TRelation rel(LF_RIGHEDOC);
TRectype from(rel.curr());
TRectype to(rel.curr());
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
const int last_anno = mask.get_int(F_ANNO);
const int first_anno = last_anno - tipo.search_years();
from.put(RDOC_CODART, codart);
from.put(RDOC_CODNUM, first_num);
from.put(RDOC_ANNO, first_anno);
from.put(RDOC_PROVV, 'D');
to.put(RDOC_CODART, codart);
to.put(RDOC_CODNUM, last_num);
to.put(RDOC_ANNO, last_anno);
to.put(RDOC_PROVV, 'D');
TSorted_cursor cur(&rel, "33->DATADOC|CODNUM|NDOC", filter, 5, &from, &to);
cur.items();
cur.freeze();
cur.relation()->add("%NUM", "CODTAB==CODNUM", 1, 0, 201);
cur.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 202);
TLink_article_sheet sheet(cur, (TEdit_field&)f);
sheet.add_string (FR_DESCR, 0, "", 38, 0, 50, "D", 30);
sheet.set(FR_CODART, codart);
sheet.set(FR_DESCR, cache().get(LF_ANAMAG, codart, "DESCR"));
if (sheet.run() == K_ENTER)
{
r.set_original_rdoc_key(cur.curr());
const TRectype * orig_doc = r.find_original_doc(); // warning
if (orig_doc != NULL)
{
r.autosave(sh);
TDocumento doc(*orig_doc);
TRiga_documento & row = doc[cur.curr().get_int(RDOC_NRIGA)];
const TString16 livello = row.get(RDOC_LIVELLO);
r.put(RDOC_LIVELLO, livello);
r.put(RDOC_QTA, row.qtaresidua());
TToken_string flds = tipo.fields_to_update();
for (const char * fld = flds.get(0); fld && * fld; fld = flds.get())
{
const TString16 f(fld);
const TString val = row.get(fld);
r.put(f, val);
}
r.autoload(sh);
sh.force_update(sh.selected());
}
}
}
return true;
}
}
return codart_handler( f, key);
}
bool codart_handler(TMask_field& f, KEY key )
{
TMask& row_mask = f.mask();

View File

@ -1,5 +1,169 @@
#include "velib07.h"
///////////////////////////////////////////////////////////
// TMateriali_base_recordset
///////////////////////////////////////////////////////////
const TVariant& TMateriali_base_recordset::get(const char* column_name) const
{
const TString name(column_name);
if (name[0] != '#')
{
TVariant& var = get_tmp_var();
int rownum = current_row();
if (_reverse)
rownum = items() - 1 - rownum;
const TRiga_esplosione * row = (const TRiga_esplosione *)boom().objptr(rownum);
if (row != NULL)
{
if (name == "LASTQTA")
var = row->last_qta();
else
if (name == "TOTQTA")
var = row->val();
else
{
const TRectype * rec = row->rdist_rec();
if (rec != NULL)
{
const TString & v = rec->get(column_name);
var = v;
}
}
}
return var;
}
return TRecordset::get(column_name);
}
const TVariant& TMateriali_base_recordset::get(unsigned int column) const
{
const TRecordset_column_info & ci = column_info(column);
return get(ci._name);
}
void TMateriali_base_recordset::requery()
{
TDistinta_tree distinta;
_boom.destroy();
int pos1 = query().find("SCALARE");
if (pos1 > 0)
{
pos1 += 7;
_reverse = query()[pos1] == '-';
if (_reverse)
pos1++;
int pos = query().find("==", pos1);
if (pos > 0)
{
TString val(query().mid(pos + 2));
if (val.starts_with("\"") || val.starts_with("'"))
{
val.ltrim(1);
val.rtrim(1);
}
else
{
TVariant var = get(val);
val = var.as_string();
}
TCodice_articolo art(val);
if (distinta.set_root(art))
{
const int level = atoi(_query.mid(pos1));
distinta.explode(_boom, true, RAGGR_EXP_UMDIST, level, "AV");
}
}
}
}
TMateriali_base_recordset::TMateriali_base_recordset(const char* use) : _query(use)
{
const TRectype rec(LF_RDIST);
const int nfields = rec.items();
int pos = 1;
for ( int i = 0 ; i < nfields; i++)
{
TRecordset_column_info * ci = new TRecordset_column_info;
ci->_name = rec.fieldname(i);
ci->_pos = pos;
ci->_type = rec.type(ci->_name);
const int len = rec.length(ci->_name);
pos += len;
ci->_width = len;
_column.add(ci);
}
}
///////////////////////////////////////////////////////////
// TScalare_recordset
///////////////////////////////////////////////////////////
void TScalare_recordset::requery()
{
TDistinta_tree distinta;
boom().destroy();
int pos1 = query().find("SCALARE");
if (pos1 > 0)
{
pos1 += 7;
reverse() = query()[pos1] == '-';
if (reverse())
pos1++;
int pos = query().find("==", pos1);
if (pos > 0)
{
TString val(query().mid(pos + 2));
if (val.starts_with("\"") || val.starts_with("'"))
{
val.ltrim(1);
val.rtrim(1);
}
else
{
TVariant var = get(val);
val = var.as_string();
}
TCodice_articolo art(val);
if (distinta.set_root(art))
{
while (isspace(query()[pos1]))
pos1++;
const int level = atoi(query().mid(pos1));
if (level > 0 || query()[pos1] =='0')
while (isdigit(query()[pos1]))
pos1++;
while (isspace(query()[pos1]))
pos1++;
TString8 filter;
if (query()[pos1] != 'S')
while (isalpha(query()[pos1]))
filter << query()[pos1++];
distinta.explode(boom(), false, RAGGR_EXP_NONE, level, filter);
}
}
}
}
///////////////////////////////////////////////////////////
// TDocument_cache
///////////////////////////////////////////////////////////
@ -105,6 +269,11 @@ const TVariant& TDocument_recordset::get_field(int num, const char* field) const
bool TDocument_report::set_recordset(const TString& query)
{
if (query.find("MATBASE") > 0)
return TReport::set_recordset(new TMateriali_base_recordset(query));
if (query.find("SCALARE") > 0)
return TReport::set_recordset(new TScalare_recordset(query));
return TReport::set_recordset(new TDocument_recordset(query));
}
@ -123,6 +292,12 @@ bool TDocument_report::load(const char* name)
if (recset != NULL)
{
const TString use = recset->query_text();
if (use.find("MATBASE") > 0)
recset = new TMateriali_base_recordset(use);
else
if (use.find("SCALARE") > 0)
recset = new TScalare_recordset(use);
else
recset = new TDocument_recordset(use);
sec->set_recordset(recset);
}
@ -132,4 +307,212 @@ bool TDocument_report::load(const char* name)
return ok;
}
void TDocument_report::output_values(const TRectype& rec, const TString& output)
{
TToken_string out(output, '!');
TString curr;
for (const char * str = out.get(0); str; str = out.get())
{ // scansione sugli elementi dell'output
curr = str;
int poseq = curr.find('='); // divide la stringa corrente in lvalue e rvalue
if (poseq < 0)
{
curr_field()->set(rec.get(curr));
}
else
{
int posrv = poseq+1;
if (poseq >= 0 && curr[posrv] == '=')
posrv++;
TString16 fld(curr.left(poseq)); // preleva il nome del campo del form alla sinistra dell'uguale
const TString& dat = rec.get(curr.mid(posrv)); // preleva il nome del campo del file alla destra dell'uguale e lo legge dal record
TReport_field* campo = field(fld);
if (campo != NULL)
campo->set(dat);
}
}
}
void TDocument_report::reset_values(const TString& output)
{
TToken_string out(output, '!');
TString curr;
for (const char * str = out.get(0); str; str = out.get())
{ // scansione sugli elementi dell'output
curr = str;
int poseq = curr.find('='); // divide la stringa corrente in lvalue e rvalue
if (poseq < 0)
{
curr_field()->set("");
}
else
{
TString16 fld(curr.left(poseq)); // preleva il nome del campo del form alla sinistra dell'uguale
TReport_field* campo = field(fld);
if (campo != NULL)
campo->set("");
}
}
}
bool TDocument_report::msg_parent_doc(TVariant_stack& stack)
{
TReport_field& cf = *curr_field();
int idx =((TISAM_recordset *)recordset())->cursor()->relation()->log2ind(LF_DOC);
if (idx < 0)
return false;
const TRectype& rec = ((TISAM_recordset*)recordset())->cursor()->relation()->file(idx).curr();
TDocumento & doc = (TDocumento &)((TDocument_recordset*)recordset())->doc(rec);
const TRiga_documento * rdoc = NULL;
// Se il campo corrente non appartiene al body allora cerco la prima riga documento buona!
if (cf.section().type() == 'B')
{
idx = ((TISAM_recordset*)recordset())->cursor()->relation()->log2ind(LF_RIGHEDOC);
if (idx < 0)
return false;
const TRectype& rec = ((TISAM_recordset*)recordset())->cursor()->relation()->file(idx).curr();
const int n = rec.get_long("NRIGA");
rdoc = &(doc[n]);
}
else
{
const TRiga_documento * first_desc = NULL;
for (int r = 1; r <= doc.physical_rows(); r++)
{
const TRiga_documento& row = doc[r];
if (row.get(RDOC_DANDOC).not_empty())
{
if (row.is_descrizione())
{
if (first_desc == NULL)
first_desc = &row; // Non e' una riga buona, ma nemmeno da buttare!
}
else
{
rdoc = &row;
break; // Ho trovato la riga buona!
}
}
}
if (rdoc == NULL && first_desc != NULL)
rdoc = first_desc;
}
int level = stack.pop().as_int();
for (; rdoc != NULL && level > 0; level--)
rdoc = (const TRiga_documento *)(rdoc->find_original_rdoc());
const TString& values = stack.pop().as_string();
const bool is_full = stack.peek().as_bool();
if (rdoc != NULL && rdoc->get(RDOC_PROVV).not_empty())
{
const char provv = rdoc->get_char(RDOC_PROVV);
const int anno = rdoc->get_int(RDOC_ANNO);
const TString4 codnum = rdoc->get(RDOC_CODNUM);
const long ndoc = rdoc->get_long(RDOC_NDOC);
if (is_full)
{
TDocumento doc(provv, anno, codnum, ndoc);
output_values(doc, values);
}
else
{
TToken_string key;
key.add(provv); key.add(anno); key.add(codnum); key.add(ndoc);
const TRectype& doc = cache().get(LF_DOC, key);
output_values(doc, values);
}
}
else
reset_values(values);
return true;
}
bool TDocument_report::msg_parent_row(TVariant_stack& stack)
{
int idx = ((TISAM_recordset*)recordset())->cursor()->relation()->log2ind(LF_RIGHEDOC);
if (idx < 0)
return false;
const TRectype& rec = ((TISAM_recordset*)recordset())->cursor()->relation()->file(idx).curr();
const int n = rec.get_long("NRIGA");
idx =((TISAM_recordset *)recordset())->cursor()->relation()->log2ind(LF_DOC);
if (idx < 0)
return false;
TDocumento & doc = (TDocumento &)((TDocument_recordset*)recordset())->doc(rec);
const TRiga_documento * rdoc = &(doc[n]);
// Se il campo corrente non appartiene al body allora cerco la prima riga documento buona!
int level = stack.pop().as_int();
for (; rdoc != NULL && level > 0; level--)
rdoc = (const TRiga_documento *)(rdoc->find_original_rdoc());
const TString& values = stack.pop().as_string();
const bool is_full = stack.peek().as_bool();
if (rdoc != NULL && rdoc->get(RDOC_PROVV).not_empty())
{
if (is_full)
{
const char provv = rdoc->get_char(RDOC_PROVV);
const int anno = rdoc->get_int(RDOC_ANNO);
const TString4 codnum = rdoc->get(RDOC_CODNUM);
const long ndoc = rdoc->get_long(RDOC_NDOC);
TDocumento doc(provv, anno, codnum, ndoc);
output_values(doc[rdoc->get_int(RDOC_NRIGA)], values);
}
else
output_values(*rdoc, values);
}
return true;
}
size_t TDocument_report::get_usr_words(TString_array& words) const
{
TReport::get_usr_words(words);
const char* const name[] =
{
"DOC_PARENT_DOC", "DOC_PARENT_ROW",
NULL
};
((TDocument_report*)this)->_first_msg = words.items(); // Calcola il primo numero disponibile
size_t i;
for (i = 0; name[i] != NULL; i++)
words.add(name[i]);
return words.items();
}
bool TDocument_report::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
{
if (opcode < _first_msg)
return TReport::execute_usr_word(opcode, stack);
opcode -= _first_msg;
switch (opcode)
{
case 0 : msg_parent_doc(stack); break;
case 1 : msg_parent_row(stack); break;
default: break;
}
while (!stack.pop().is_null()); // Svuota eventuali parametri variabili inutilizzati
return true;
}

View File

@ -5,10 +5,66 @@
#include "velib.h"
#endif
#ifndef __REPORT_H
#include <report.h>
#ifndef __ASSOC_H
#include <assoc.h>
#endif
#ifndef __REPRINT_H
#include <reprint.h>
#endif
#include "../db/dblib.h"
///////////////////////////////////////////////////////////
// TMateriali_base_recordset
///////////////////////////////////////////////////////////
class TMateriali_base_recordset : public TRecordset
{
TString _query;
TArray _boom;
long _pos;
TArray _column;
bool _reverse;
protected:
const TString & query() const { return _query; }
TArray & boom() { return _boom; }
const TArray & boom() const { return _boom; }
bool & reverse() { return _reverse;}
public:
virtual TRecnotype items() const { return _boom.items(); }
virtual bool move_to(TRecnotype pos) { _pos = pos; return pos < items();}
virtual TRecnotype current_row() const { return _pos; }
virtual void requery();
virtual unsigned int columns() const { return _column.items();}
virtual const TRecordset_column_info& column_info(unsigned int column) const { return (const TRecordset_column_info&) _column[column];}
virtual const TVariant& get(unsigned int column) const;
virtual const TVariant& get(const char* column_name) const;
TMateriali_base_recordset(const char* use);
virtual ~TMateriali_base_recordset(){ }
};
///////////////////////////////////////////////////////////
// TScalare_recordset
///////////////////////////////////////////////////////////
class TScalare_recordset : public TMateriali_base_recordset
{
protected:
public:
virtual void requery();
TScalare_recordset(const char* use) : TMateriali_base_recordset(use) {}
virtual ~TScalare_recordset() { }
};
///////////////////////////////////////////////////////////
// TDocument_cache
///////////////////////////////////////////////////////////
@ -35,9 +91,10 @@ class TDocument_recordset : public TISAM_recordset
TDocument_cache _cache;
protected:
virtual const TVariant& get_field(int logic, const char* field) const;
virtual const TVariant& get(int logic, const char* field) const;
public:
const TDocumento & doc(const TRectype& rec) { return _cache.doc(rec);}
TDocument_recordset(const char* use) : TISAM_recordset(use) { }
virtual ~TDocument_recordset() { }
@ -50,11 +107,20 @@ public:
class TDocument_report : public TReport
{
size_t _first_msg;
protected:
virtual size_t get_usr_words(TString_array& words) const;
virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack);
virtual bool set_recordset(const TString& query);
bool msg_parent_doc(TVariant_stack& stack);
bool msg_parent_row(TVariant_stack& stack);
void output_values(const TRectype& rec, const TString& output);
void reset_values(const TString& output);
public:
bool load(const char* name);
};
#endif

View File

@ -19,6 +19,7 @@ bool codmag_handler(TMask_field& f, KEY key);
bool codmag_coll_handler(TMask_field& f, KEY key);
bool search_price_handler(TMask_field& f, KEY key);
bool find_price_handler(TMask_field& f, KEY key);
bool link_row_handler(TMask_field& f, KEY key);
bool codart_handler(TMask_field& f, KEY key);
bool umart_handler(TMask_field& f, KEY key);
bool um_handler(TMask_field& f, KEY key);

View File

@ -126,4 +126,5 @@
#define DLG_FUNC07 417
#define DLG_FUNC08 418
#define DLG_CONFERMA 420
#endif // veuml.h