1998-08-25 18:07:30 +00:00
|
|
|
|
#include <applicat.h>
|
2002-05-31 10:35:40 +00:00
|
|
|
|
#include <automask.h>
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include <dongle.h>
|
|
|
|
|
#include <modaut.h>
|
2000-05-05 15:25:49 +00:00
|
|
|
|
#include <sheet.h>
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include <tabutil.h>
|
2002-05-31 10:35:40 +00:00
|
|
|
|
#include <tree.h>
|
1999-10-22 10:00:18 +00:00
|
|
|
|
#include <postman.h>
|
2002-07-02 16:21:23 +00:00
|
|
|
|
#include <urldefid.h>
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
#include "velib.h"
|
|
|
|
|
#include "vepriv.h"
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include "verig.h"
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
2001-05-02 13:40:49 +00:00
|
|
|
|
#include "ve0100.h"
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include "ve0100b1.h"
|
|
|
|
|
#include "ve0100o.h"
|
1997-06-12 16:15:09 +00:00
|
|
|
|
#include "veuml.h"
|
|
|
|
|
#include "veuml1.h"
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include "veini.h"
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
#include "sconti.h"
|
1997-06-27 09:21:13 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
#include "doc.h"
|
|
|
|
|
#include "rdoc.h"
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TDocumento_mask::TDocumento_mask(const char* td)
|
|
|
|
|
: TVariable_mask(), _progs_page(-1), _last_prog(-1),
|
|
|
|
|
_condv(NULL)
|
|
|
|
|
{
|
|
|
|
|
CHECK(strlen(td) <= 4, "TDocumento_mask(TipoDocumento) not (MaskName)");
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TMagazzini m;
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
_ges_mag = m.gestmag();
|
|
|
|
|
_ges_dep = m.gestdep();
|
|
|
|
|
_std_mag = m.standardmag();
|
|
|
|
|
_std_dep = m.standarddep();
|
|
|
|
|
}
|
|
|
|
|
_doc.set_tipo(td);
|
|
|
|
|
const TString mname = _doc.tipo().mask_name();
|
|
|
|
|
read_mask(mname, 0, MAX_PAGES);
|
|
|
|
|
|
|
|
|
|
int pos = id2pos(BASE_PIEDE + 1);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
_progs_page = find_parent_page(fld(pos));
|
|
|
|
|
_last_prog = 0;
|
|
|
|
|
while (id2pos(BASE_PIEDE + _last_prog + 1) >= 0)
|
|
|
|
|
_last_prog++;
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
_sheet = &sfield(F_SHEET);
|
|
|
|
|
_sheet->set_handler( ss_handler );
|
1998-08-25 18:07:30 +00:00
|
|
|
|
_sheet->set_notify( ss_notify );
|
|
|
|
|
_sheet->set_append(FALSE);
|
|
|
|
|
|
|
|
|
|
TList_field& listbox = ( TList_field& )field( F_LBTIPORIGA );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
TTipo_documento& tdoc = (TTipo_documento&)_doc.tipo();
|
|
|
|
|
TToken_string& keys = (TToken_string&) tdoc.keys_descrs()[0];
|
|
|
|
|
TToken_string& descrs = (TToken_string&) tdoc.keys_descrs()[1];
|
|
|
|
|
listbox.replace_items(keys, descrs);
|
|
|
|
|
|
|
|
|
|
configura_sheet(*_sheet);
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
((TVariable_sheet_field*)_sheet)->set_getmask( ss_getmask );
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (_doc.tipo().clifo_optional())
|
|
|
|
|
{
|
|
|
|
|
field(F_CODCF).check_type(CHECK_NORMAL);
|
|
|
|
|
field(F_RAGSOC).check_type(CHECK_NORMAL);
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
set_handler( F_OCCASEDIT, occas_handler );
|
|
|
|
|
set_handler( F_CODCF, clifo_handler );
|
1998-08-25 18:07:30 +00:00
|
|
|
|
set_handler( F_CODPAG, condpag_hndl );
|
|
|
|
|
set_handler( F_DATAINSC, condpag_hndl );
|
|
|
|
|
set_handler( F_CODNOTE, note_hndl );
|
|
|
|
|
set_handler( F_DATADOC, data_hndl );
|
|
|
|
|
set_handler( F_CODLIST, codlist_handler );
|
|
|
|
|
set_handler( F_CODLIST1, codlist_handler );
|
|
|
|
|
set_handler( F_CODCONT, codcont_handler );
|
|
|
|
|
set_handler( F_CODCONT1, codcont_handler );
|
|
|
|
|
set_handler( F_CODCAMP, codcamp_handler );
|
2000-05-05 15:25:49 +00:00
|
|
|
|
set_handler( F_CODVAL, codval_handler );
|
|
|
|
|
set_handler( F_CODVAL1, codval_handler );
|
2003-02-25 14:39:02 +00:00
|
|
|
|
set_handler( F_DATACAMBIO1, datacambio_handler );
|
2000-10-03 13:45:12 +00:00
|
|
|
|
set_handler( F_NUMDOCRIF, datadocrif_handler);
|
|
|
|
|
set_handler( F_DATADOCRIF, datadocrif_handler);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
set_handler( DLG_ELABORA, elabora_handler );
|
|
|
|
|
set_handler( DLG_PRINT, print_handler );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
const TString_array& handlers = tdoc.handlers();
|
|
|
|
|
int numhandler = handlers.items();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numhandler; i ++ )
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TToken_string& riga = (TToken_string&) handlers[i];
|
1998-08-25 18:07:30 +00:00
|
|
|
|
user_set_handler( riga.get_int( 0 ), riga.get_int( 1 ) );
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
_livelli_giac = new TCodgiac_livelli;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
|
for (i = 4; i > 0; i--)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
const short pos = _sheet->cid2index(FR_LIV1 + i -1);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (_livelli_giac->enabled(i))
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const TString & header = _livelli_giac->name(i);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const int len = header.len() + 1;
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const int f_len = _livelli_giac->code_length(i);
|
|
|
|
|
_sheet->set_column_header(pos, header);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
_sheet->set_column_width(pos, (len > f_len ? len : f_len) * 8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
|
_sheet->sheet_mask().hide(FR_LIV1 + i -1);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
_sheet->delete_column(pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// configurazione campi
|
|
|
|
|
|
|
|
|
|
TConfig cfg(CONFIG_DITTA, "ve");
|
|
|
|
|
const bool gesval = cfg.get_bool("GESVAL");
|
|
|
|
|
const bool gescambi = cfg.get_bool("GESVALAC");
|
|
|
|
|
|
|
|
|
|
if (gesval)
|
|
|
|
|
{
|
2001-05-02 13:40:49 +00:00
|
|
|
|
const bool enable_controeuro = cfg.get_bool("CONTROEURO");
|
|
|
|
|
|
|
|
|
|
enable(F_CONTROEURO, enable_controeuro);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
show(F_CODVAL, !gescambi);
|
|
|
|
|
show(F_DATACAMBIO, !gescambi);
|
|
|
|
|
show(F_NOMEVAL, !gescambi);
|
|
|
|
|
show(F_CODVAL1, gescambi);
|
|
|
|
|
show(F_DATACAMBIO1, gescambi);
|
|
|
|
|
show(F_NOMEVAL1, gescambi);
|
|
|
|
|
show(F_CAMBIO);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
disable(F_CODVAL);
|
|
|
|
|
disable(F_DATACAMBIO);
|
2001-05-02 13:40:49 +00:00
|
|
|
|
disable(F_CONTROEURO);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
disable(F_NOMEVAL);
|
|
|
|
|
hide(F_CODVAL1);
|
|
|
|
|
hide(F_DATACAMBIO1);
|
|
|
|
|
hide(F_NOMEVAL1);
|
|
|
|
|
disable(F_CAMBIO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool geslin = cfg.get_bool("GESLIN");
|
|
|
|
|
|
|
|
|
|
enable(F_CODLIN, geslin);
|
|
|
|
|
enable(F_DESLIN, geslin);
|
|
|
|
|
|
|
|
|
|
const bool geslis = cfg.get_bool("GES", "ve", 1);
|
|
|
|
|
const bool gesliscatven = cfg.get_bool("GESLISCV");
|
|
|
|
|
|
|
|
|
|
if (geslis)
|
|
|
|
|
{
|
|
|
|
|
show(F_CODLIST, !gesliscatven);
|
|
|
|
|
show(F_CODLIST1, gesliscatven);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
disable(F_CODLIST);
|
|
|
|
|
hide(F_CODLIST1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool gescontr = cfg.get_bool("GES", "ve", 2);
|
|
|
|
|
const bool gescontrcli = cfg.get_bool("GESCONCC");
|
|
|
|
|
|
|
|
|
|
if (gescontr)
|
|
|
|
|
{
|
|
|
|
|
show(F_CODCONT1, gescontrcli);
|
|
|
|
|
show(F_CODCONT, !gescontrcli);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
disable(F_CODCONT);
|
|
|
|
|
hide(F_CODCONT1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool gesoff = cfg.get_bool("GES", "ve", 3);
|
|
|
|
|
enable(F_CODCAMP, gesoff);
|
|
|
|
|
|
|
|
|
|
const bool gessco = cfg.get_char("GESSCO") != 'N';
|
|
|
|
|
enable(F_SCONTOPERC, gessco);
|
|
|
|
|
|
|
|
|
|
const bool gesage = cfg.get_bool("GESAGE");
|
|
|
|
|
enable(F_CODAG, gesage);
|
|
|
|
|
enable(F_DESAG, gesage);
|
|
|
|
|
enable(F_CODAGVIS, gesage);
|
|
|
|
|
enable(F_DESAGVIS, gesage);
|
|
|
|
|
|
|
|
|
|
const bool has_movmag = dongle().active(MGAUT) && _doc.tipo().mov_mag();
|
|
|
|
|
pos = id2pos(F_CAUSMAG);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
|
|
|
|
pos = id2pos(F_DESCRMAG);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
|
|
|
|
pos = id2pos(F_CAUSMAGC);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
|
|
|
|
pos = id2pos(F_DESCRMAGC);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
1999-04-26 15:58:05 +00:00
|
|
|
|
pos = id2pos(F_CURGIAC);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
pos = id2pos(F_CURDISP);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
fld(pos).show(has_movmag);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocumento_mask::~TDocumento_mask()
|
|
|
|
|
{
|
|
|
|
|
if (_condv)
|
|
|
|
|
delete _condv;
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (_livelli_giac)
|
|
|
|
|
delete _livelli_giac;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
void TDocumento_mask::configura_sheet(TSheet_field& sheet)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TBit_array to_delete(MAX_COLUMNS);
|
|
|
|
|
to_delete.set();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TTipo_documento& tdoc = (TTipo_documento&) _doc.tipo();
|
|
|
|
|
const TString_array& sheet_columns = tdoc.sheet_columns();
|
|
|
|
|
int ncols = sheet_columns.items();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
TToken_string colonne;
|
|
|
|
|
colonne = "0";
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ncols; i ++ )
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TToken_string& sheet_col = (TToken_string&) sheet_columns[i];
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const int field_id = sheet_col.get_int(0);
|
|
|
|
|
const int coltomove = sheet.cid2index(field_id);
|
|
|
|
|
to_delete.reset(coltomove);
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
const TString80 descr(sheet_col.get(1));
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (descr.not_empty() )
|
|
|
|
|
sheet.set_column_header( field_id, descr);
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const int size = sheet_col.get_int(2) * 8; // XI_FU_MULTIPLE
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (size != 0)
|
|
|
|
|
sheet.set_column_width( field_id, size);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (field_id != FR_LORDO || tdoc.calcolo_lordo())
|
|
|
|
|
colonne.add(field_id);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (tdoc.calcolo_lordo())
|
2000-05-05 15:25:49 +00:00
|
|
|
|
to_delete.reset(0L);
|
|
|
|
|
else
|
|
|
|
|
to_delete.set(0L);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
to_delete.reset(1);
|
1999-06-18 15:35:05 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
if (!to_delete[sheet.cid2index(FR_CODDEP)])
|
|
|
|
|
sheet.enable_column(FR_CODDEP, _ges_dep && _ges_mag);
|
|
|
|
|
if (!to_delete[sheet.cid2index(FR_CODMAG)])
|
|
|
|
|
sheet.enable_column(FR_CODMAG, _ges_mag);
|
|
|
|
|
if (!to_delete[sheet.cid2index(FR_CODDEPC)])
|
|
|
|
|
sheet.enable_column(FR_CODDEPC, _ges_dep && _ges_mag);
|
|
|
|
|
if (!to_delete[sheet.cid2index(FR_CODMAGC)])
|
|
|
|
|
sheet.enable_column(FR_CODMAGC, _ges_mag);
|
|
|
|
|
to_delete.set(sheet.cid2index(FR_CODARTMAG));
|
|
|
|
|
to_delete.set(sheet.cid2index(FR_CHECKED));
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
/*
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const int sconto_col = sheet.cid2index(FR_SCONTO);
|
|
|
|
|
if (to_delete[sconto_col] == FALSE)
|
|
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
|
const bool del = tdoc.sconto_riga() == "N";
|
1998-08-25 18:07:30 +00:00
|
|
|
|
to_delete.set(sconto_col, del);
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
*/
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
for ( i = MAX_COLUMNS - 1; i >= 0; i-- )
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if( to_delete[i] )
|
|
|
|
|
{
|
|
|
|
|
sheet.enable_column( i + FIRST_FIELD, FALSE);
|
|
|
|
|
sheet.delete_column( i + FIRST_FIELD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sheet.user_saved_columns_order())
|
|
|
|
|
sheet.set_columns_order(&colonne);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TCond_vendita& TDocumento_mask::condv() const
|
|
|
|
|
{
|
|
|
|
|
if (_condv == NULL)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask* myself = (TDocumento_mask*)this;
|
|
|
|
|
myself->_condv = new TCond_vendita(myself, NULL);
|
|
|
|
|
}
|
|
|
|
|
return *_condv;
|
1997-06-12 16:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-05-02 13:40:49 +00:00
|
|
|
|
void TDocumento_mask::update_progs()
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
|
|
|
|
|
for (int f = id2pos(BASE_PIEDE + 1)-1; f >= 0; f--)
|
|
|
|
|
{
|
|
|
|
|
const TMask_field& mf = fld(f);
|
|
|
|
|
const TFieldref* fr = mf.field();
|
|
|
|
|
if (fr)
|
|
|
|
|
_doc.put(fr->name(), mf.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_doc.set_riga_esenzione();
|
|
|
|
|
|
|
|
|
|
for (int i = _last_prog; i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
const short id = BASE_PIEDE + i;
|
|
|
|
|
const TString& name = field(id).field()->name();
|
|
|
|
|
const TString& val = _doc.get(name);
|
|
|
|
|
set(id, val, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
void TDocumento_mask::next_page(int p)
|
|
|
|
|
{
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const bool was_normal_page = curr_page() < _progs_page;
|
1997-06-12 16:15:09 +00:00
|
|
|
|
TMask::next_page(p);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const bool is_calculated_page = curr_page() >= _progs_page;
|
|
|
|
|
|
|
|
|
|
if (was_normal_page && is_calculated_page)
|
2001-05-02 13:40:49 +00:00
|
|
|
|
update_progs();
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
2001-05-02 13:40:49 +00:00
|
|
|
|
bool TDocumento_mask::stop_run(KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key != K_ESC && key != K_QUIT)
|
|
|
|
|
update_progs();
|
|
|
|
|
return TVariable_mask::stop_run(key);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::on_key(KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_SHIFT + K_F12)
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
TRelation r(LF_DOC);
|
|
|
|
|
r.curr()=doc();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (!doc().bloccato() && ::user_can_write(&r))
|
1999-10-22 10:00:18 +00:00
|
|
|
|
{
|
|
|
|
|
TMask_field& stato = field(F_STATO);
|
|
|
|
|
stato.enable();
|
|
|
|
|
enable(DLG_SAVEREC);
|
|
|
|
|
enable(DLG_DELREC);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1999-10-22 10:00:18 +00:00
|
|
|
|
warning_box("L'utente %s non puo' modificare questo documento",
|
2000-05-05 15:25:49 +00:00
|
|
|
|
(const char*)user());
|
1997-06-12 16:15:09 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return TVariable_mask::on_key(key);
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
void TDocumento_mask::occ2mask()
|
1997-06-12 16:15:09 +00:00
|
|
|
|
{
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const TOccasionale& o = doc().occas();
|
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
reset(F_COFI);
|
|
|
|
|
reset(F_PAIVA);
|
|
|
|
|
set(F_OCFPI, o.get(OCC_CFPI));
|
|
|
|
|
const TString & ragsoc = o.get(OCC_RAGSOC);
|
|
|
|
|
set(F_RAGSOC, ragsoc);
|
|
|
|
|
set(F_RAGSOCSP, ragsoc);
|
|
|
|
|
const TString & indir = o.get(OCC_INDIR);
|
|
|
|
|
set(F_INDCF, indir);
|
|
|
|
|
set(F_INDSP, indir);
|
|
|
|
|
const TString & civ = o.get(OCC_CIV);
|
|
|
|
|
set(F_CIVCF, civ);
|
|
|
|
|
set(F_CIVSP, civ);
|
|
|
|
|
const TString & cap = o.get(OCC_CAP);
|
|
|
|
|
set(F_CAPCF, cap);
|
|
|
|
|
set(F_CAPSP, cap);
|
|
|
|
|
const TString & com = o.get(OCC_COM);
|
|
|
|
|
set(F_COMCF, com);
|
|
|
|
|
set( F_COMSP, com);
|
|
|
|
|
const TString & stato = o.get(OCC_STATO);
|
|
|
|
|
set(F_STATOCF, stato);
|
|
|
|
|
set( F_STATOSP, stato);
|
1997-08-04 13:52:55 +00:00
|
|
|
|
if (id2pos(F_CODINDSP) >= 0)
|
|
|
|
|
reset(F_CODINDSP);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
// Sugli occasionali non c'<27> la localit<69>
|
1997-08-04 13:52:55 +00:00
|
|
|
|
const TString & localita = o.get(OCC_LOCALITA);
|
|
|
|
|
set(F_LOCALITACF, localita);
|
|
|
|
|
set(F_LOCALITASP, localita);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
check_field(F_COMSP);
|
|
|
|
|
check_field(F_STATOSP);
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
void TDocumento_mask::cli2mask()
|
1997-06-12 16:15:09 +00:00
|
|
|
|
{
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TCli_for & c = doc().clifor();
|
|
|
|
|
TOccasionale & o = doc().occas();
|
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
const bool onload = !is_running();
|
|
|
|
|
const TString16 codval(get(F_CODVAL));
|
|
|
|
|
const TString16 datacambio(get(F_DATACAMBIO1));
|
|
|
|
|
|
|
|
|
|
// Setta i campi che appartengono al file LF_CLIFO
|
|
|
|
|
const bool occas = c.occasionale();
|
|
|
|
|
|
|
|
|
|
show(F_OCCASEDIT, occas);
|
1997-08-04 13:52:55 +00:00
|
|
|
|
if (!occas)
|
|
|
|
|
reset(F_OCFPI);
|
|
|
|
|
show(F_OCFPI, occas);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
// In forse per l'Occasionale, sicuri per il Normale
|
|
|
|
|
show(F_COFI, !occas);
|
|
|
|
|
show(F_STATOPAIVA, !occas);
|
|
|
|
|
show(F_PAIVA, !occas);
|
|
|
|
|
set(F_RAGSOC, c.get(CLI_RAGSOC));
|
|
|
|
|
enable(F_RAGSOC, !occas);
|
|
|
|
|
|
|
|
|
|
const TRectype & ven_rec = c.vendite();
|
|
|
|
|
|
|
|
|
|
if(!onload)
|
|
|
|
|
{
|
|
|
|
|
short pos = id2pos(F_CODVAL);
|
|
|
|
|
const TString & codval = c.get(CLI_CODVAL);
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (pos >= 0)
|
1997-06-12 16:15:09 +00:00
|
|
|
|
fld(pos).set(codval);
|
|
|
|
|
pos = id2pos(F_CODVAL1);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (pos >= 0)
|
1997-06-12 16:15:09 +00:00
|
|
|
|
fld(pos).set(codval);
|
|
|
|
|
pos = id2pos(F_CODLIN);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).set(c.get(CLI_CODLIN));
|
|
|
|
|
set(F_CODPAG, c.get(CLI_CODPAG));
|
|
|
|
|
set(F_CODABIA, c.get(CLI_CODABI));
|
|
|
|
|
set(F_CODCABA, c.get(CLI_CODCAB));
|
|
|
|
|
// Setta i campi che appartengono al file LF_CFVEN
|
|
|
|
|
set(F_CODABIP, ven_rec.get(CFV_CODABIPR));
|
|
|
|
|
set(F_CODCABP, ven_rec.get(CFV_CODCABPR));
|
|
|
|
|
set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
|
1997-12-05 11:55:02 +00:00
|
|
|
|
set(F_RAGGREFF, ven_rec.get(CFV_RAGGEFF));
|
1997-06-12 16:15:09 +00:00
|
|
|
|
set(F_CODINDSP, ven_rec.get(CFV_CODINDSP));
|
|
|
|
|
set(F_CODAG, ven_rec.get(CFV_CODAG));
|
|
|
|
|
set(F_CODSPMEZZO, ven_rec.get(CFV_CODSPMEZZO));
|
|
|
|
|
set(F_CODPORTO, ven_rec.get(CFV_CODPORTO));
|
|
|
|
|
set(F_CODNOTESP1, ven_rec.get(CFV_CODNOTESP1));
|
|
|
|
|
set(F_CODNOTESP2, ven_rec.get(CFV_CODNOTESP2));
|
|
|
|
|
set(F_CODNOTE, ven_rec.get(CFV_CODNOTE));
|
|
|
|
|
set(F_CODVETT1, ven_rec.get(CFV_CODVETT1));
|
|
|
|
|
set(F_CODVETT2, ven_rec.get(CFV_CODVETT2));
|
|
|
|
|
set(F_CODVETT3, ven_rec.get(CFV_CODVETT3));
|
|
|
|
|
set(F_SPESEINC, ven_rec.get(CFV_PERCSPINC));
|
|
|
|
|
set(F_ADDBOLLI, ven_rec.get(CFV_ADDBOLLI));
|
|
|
|
|
set(F_CATVEN, ven_rec.get(CFV_CATVEN));
|
|
|
|
|
pos = id2pos(F_CODLIST);
|
|
|
|
|
const TString & codlist = ven_rec.get(CFV_CODLIST);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TEdit_field & f = (TEdit_field&) fld(pos);
|
|
|
|
|
|
|
|
|
|
f.set(codlist);
|
|
|
|
|
f.check();
|
|
|
|
|
f.on_hit();
|
|
|
|
|
}
|
1997-06-12 16:15:09 +00:00
|
|
|
|
pos = id2pos(F_CODLIST1);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TEdit_field & f = (TEdit_field&) fld(pos);
|
|
|
|
|
|
|
|
|
|
f.set(codlist);
|
|
|
|
|
f.check();
|
|
|
|
|
f.on_hit();
|
|
|
|
|
}
|
1997-06-12 16:15:09 +00:00
|
|
|
|
pos = id2pos(F_CODAG);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).set(ven_rec.get(CFV_CODAG));
|
|
|
|
|
set(F_CODZON, ven_rec.get(CFV_CODZONA));
|
|
|
|
|
set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
|
1998-08-25 18:07:30 +00:00
|
|
|
|
sconto_testa2mask();
|
|
|
|
|
spese2mask();
|
1997-06-12 16:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
enable( F_CODINDSP , !occas);
|
|
|
|
|
if (occas)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
occ2mask();
|
1997-06-12 16:15:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
set(F_COFI, c.get(CLI_COFI));
|
|
|
|
|
set(F_INDCF, c.get(CLI_INDCF));
|
|
|
|
|
set(F_CIVCF, c.get(CLI_CIVCF));
|
|
|
|
|
set(F_STATOPAIVA, c.get(CLI_STATOPAIV));
|
|
|
|
|
set(F_PAIVA, c.get(CLI_PAIV));
|
|
|
|
|
set(F_LOCALITACF, c.get(CLI_LOCCF));
|
|
|
|
|
set(F_CAPCF, c.get(CLI_CAPCF));
|
|
|
|
|
set(F_COMCF, c.get(CLI_COMCF));
|
|
|
|
|
set(F_STATOCF, c.get(CLI_STATOCF));
|
|
|
|
|
check_field( F_CODINDSP );
|
|
|
|
|
}
|
|
|
|
|
const TString16 newcodval(get(F_CODVAL));
|
|
|
|
|
const TString16 newdatacambio(get(F_DATACAMBIO1));
|
|
|
|
|
|
|
|
|
|
short pos = id2pos(F_CAMBIO);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if ((pos >= 0) && newcodval.empty())
|
1997-08-18 16:06:51 +00:00
|
|
|
|
fld(pos).reset();
|
1997-06-12 16:15:09 +00:00
|
|
|
|
pos = id2pos(F_CODVAL);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
1998-11-04 18:04:26 +00:00
|
|
|
|
fld(pos).check(STARTING_CHECK);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
pos = id2pos(F_CODVAL1);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
1998-11-04 18:04:26 +00:00
|
|
|
|
fld(pos).check(STARTING_CHECK);
|
1997-06-12 16:15:09 +00:00
|
|
|
|
pos = id2pos(F_DATACAMBIO1);
|
|
|
|
|
if (pos >= 0 && fld(pos).active() &&
|
|
|
|
|
(codval != newcodval || datacambio != newdatacambio))
|
|
|
|
|
fld(pos).check();
|
|
|
|
|
check_field(F_COMCF);
|
|
|
|
|
check_field(F_STATOCF);
|
|
|
|
|
check_field( F_CODPAG );
|
|
|
|
|
pos = id2pos(F_CODLIN);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).check();
|
|
|
|
|
check_field( F_CODCABA );
|
|
|
|
|
pos = id2pos(F_CODLIST);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).check();
|
|
|
|
|
pos = id2pos(F_CODLIST1);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).check();
|
|
|
|
|
check_field( F_CODCABP );
|
|
|
|
|
pos = id2pos(F_CODAG);
|
|
|
|
|
if (pos >= 0 && fld(pos).active())
|
|
|
|
|
fld(pos).check();
|
|
|
|
|
check_field( F_CODSPMEZZO );
|
|
|
|
|
check_field( F_CODPORTO );
|
|
|
|
|
check_field( F_CODNOTESP1 );
|
|
|
|
|
check_field( F_CODNOTESP2 );
|
|
|
|
|
check_field( F_CODNOTE );
|
|
|
|
|
check_field( F_CODVETT1 );
|
|
|
|
|
check_field( F_CODVETT2 );
|
|
|
|
|
check_field( F_CODVETT3 );
|
|
|
|
|
check_field( F_CATVEN );
|
|
|
|
|
check_field( F_CODZON );
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
const bool contr_enabled = ven_rec.get_bool(CFV_GESTCONTR);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
bool gescontr = FALSE;
|
|
|
|
|
if (contr_enabled)
|
|
|
|
|
{
|
|
|
|
|
TConfig ditta(CONFIG_DITTA, "ve");
|
|
|
|
|
gescontr = ditta.get_bool("GES", "ve", 2);
|
|
|
|
|
}
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
|
|
|
|
enable(F_CODCONT1, contr_enabled && gescontr);
|
|
|
|
|
enable(F_CODCONT, contr_enabled && gescontr);
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
void TDocumento_mask::sconto_testa2mask()
|
1997-06-12 16:15:09 +00:00
|
|
|
|
{
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TCli_for & c = doc().clifor();
|
|
|
|
|
TConfig ditta(CONFIG_DITTA, "ve");
|
1997-06-12 16:15:09 +00:00
|
|
|
|
const char tipogestione = ditta.get("GESSCO", "ve")[ 0 ];
|
|
|
|
|
switch( tipogestione )
|
|
|
|
|
{
|
|
|
|
|
case 'N': // Sconti non gestiti: pussa via!
|
|
|
|
|
break;
|
|
|
|
|
case 'P': // Percentuale su anagrafica cliente
|
1997-08-18 16:06:51 +00:00
|
|
|
|
set( F_SCONTOPERC, c.vendite().get(CFV_SCONTO));
|
1997-06-12 16:15:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'T': // Gestione tabella sconti
|
|
|
|
|
{
|
|
|
|
|
const TString16 codsconto(c.vendite().get(CFV_CODSCC));
|
|
|
|
|
|
|
|
|
|
if (codsconto.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TTable sconti("%SCC");
|
|
|
|
|
sconti.setkey(1);
|
|
|
|
|
sconti.zero();
|
|
|
|
|
sconti.put("CODTAB", codsconto);
|
|
|
|
|
if (sconti.read( ) == NOERR)
|
|
|
|
|
set(F_SCONTOPERC, sconti.get("S1"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'A': // Gestione archivio sconti
|
|
|
|
|
{
|
1997-08-29 16:42:42 +00:00
|
|
|
|
TString16 cod;
|
1997-06-12 16:15:09 +00:00
|
|
|
|
const TRectype & ven_rec = c.vendite();
|
|
|
|
|
TLocalisamfile sconti(LF_SCONTI );
|
1997-08-29 16:42:42 +00:00
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
sconti.setkey(1);
|
|
|
|
|
sconti.zero();
|
|
|
|
|
sconti.put("TIPO", "I");
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 1))
|
|
|
|
|
sconti.put("CODCAT", ven_rec.get(CFV_CATVEN));
|
|
|
|
|
if(ditta.get_bool("SCOKEY", "ve", 2))
|
|
|
|
|
cod.format("%-2s", (const char *)ven_rec.get(CFV_CODSCC));
|
|
|
|
|
else
|
|
|
|
|
cod = " ";
|
|
|
|
|
if( ditta.get_bool("SCOKEY", "ve", 3))
|
2002-05-31 10:35:40 +00:00
|
|
|
|
{
|
|
|
|
|
TString8 cz; cz.format("%-2s", (const char*)ven_rec.get(CFV_CODZONA));
|
|
|
|
|
cod << cz;
|
|
|
|
|
}
|
1997-06-12 16:15:09 +00:00
|
|
|
|
else
|
|
|
|
|
cod << " ";
|
|
|
|
|
if( ditta.get_bool("SCOKEY", "ve", 4))
|
|
|
|
|
cod << c.get(CLI_CODPAG);
|
|
|
|
|
sconti.put("CODART", cod);
|
|
|
|
|
if(sconti.read() == NOERR)
|
|
|
|
|
set(F_SCONTOPERC, sconti.get( "SCONTO"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
void TDocumento_mask::spese2mask()
|
1997-06-12 16:15:09 +00:00
|
|
|
|
{
|
|
|
|
|
TSheet_field & sh = (TSheet_field &) field(F_SHEET);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TCli_for & c = doc().clifor();
|
1997-06-12 16:15:09 +00:00
|
|
|
|
|
|
|
|
|
TString16 name("CODSP0");
|
|
|
|
|
TString_array spese;
|
|
|
|
|
TRectype & ven_rec = c.vendite();
|
|
|
|
|
for (int i = 1; i <= 4; i++)
|
|
|
|
|
{
|
|
|
|
|
name.rtrim(1); name << i;
|
|
|
|
|
const TString16 s(ven_rec.get(name));
|
|
|
|
|
|
|
|
|
|
if (s.not_empty())
|
|
|
|
|
spese.add(s);
|
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
// autosave(*_rel);
|
|
|
|
|
|
1997-08-01 09:20:02 +00:00
|
|
|
|
doc().put("SPESEUPD", FALSE);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
doc().put(DOC_CODVAL, get(F_CODVAL));
|
|
|
|
|
doc().put(DOC_CAMBIO, get(F_CAMBIO));
|
|
|
|
|
doc().put(DOC_CONTROEURO, get(F_CONTROEURO));
|
|
|
|
|
|
1997-06-12 16:15:09 +00:00
|
|
|
|
doc().update_spese_aut(spese, FALSE, &sh);
|
|
|
|
|
sh.force_update();
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
void TDocumento_mask::reset_masks(const TString& tipo_doc)
|
|
|
|
|
{
|
|
|
|
|
static TString16 last_tipo_doc;
|
|
|
|
|
|
|
|
|
|
if (tipo_doc != last_tipo_doc)
|
|
|
|
|
{
|
|
|
|
|
FOR_EACH_ASSOC_OBJECT(_maskriga, h, k, o)
|
|
|
|
|
{
|
|
|
|
|
TMask* m = (TMask*)o;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
m->enable_default();
|
|
|
|
|
if (!_sheet->exist_column(FR_PREZZO))
|
|
|
|
|
m->hide(FR_PREZZO);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
last_tipo_doc = tipo_doc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocumento_mask::doc2mask(bool reload_clifo)
|
1998-08-26 10:54:46 +00:00
|
|
|
|
{
|
|
|
|
|
for (int p = id2pos(BASE_PIEDE + 1)-1; p >= 0; p--)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TMask_field& f = fld(p);
|
|
|
|
|
const TFieldref* fr = f.field();
|
|
|
|
|
if (fr)
|
|
|
|
|
f.set(fr->read(doc()));
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (reload_clifo)
|
|
|
|
|
cli2mask();
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
TSheet_field& s = sfield(F_SHEET);
|
|
|
|
|
s.destroy( );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
const int righe = doc().physical_rows();
|
|
|
|
|
for (int i = 0; i < righe; i++)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
s.insert(-1, FALSE);
|
|
|
|
|
TToken_string& r = s.row(i);
|
|
|
|
|
doc()[i+1].autoload(s);
|
1998-11-04 18:04:26 +00:00
|
|
|
|
s.check_row(i, 0x2);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
reset_masks(get(F_TIPODOC));
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
s.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocumento_mask::mask2doc()
|
|
|
|
|
{
|
|
|
|
|
for (int p = fields()-1; p >= 0; p--)
|
|
|
|
|
{
|
|
|
|
|
TMask_field& f = fld(p);
|
|
|
|
|
const TFieldref* fr = f.field();
|
|
|
|
|
if (fr)
|
|
|
|
|
fr->write(f.get(), doc());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TVariable_mask* TDocumento_mask::riga_mask(int numriga)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento& riga = doc()[numriga + 1];
|
|
|
|
|
const TTipo_riga_documento& tiporiga = riga.tipo();
|
|
|
|
|
const char* name = tiporiga.mask_name();
|
|
|
|
|
|
|
|
|
|
TVariable_mask* m = (TVariable_mask*)_maskriga.objptr(name);
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
{
|
|
|
|
|
m = new TVariable_mask(name);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
_maskriga.add(name, m);
|
|
|
|
|
|
|
|
|
|
TFilename proname(tiporiga.profile_name());
|
|
|
|
|
proname.ext("ini");
|
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TConfig pro( proname, "HANDLERS" );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
int numhandler = pro.get_int( "NHANDLER", "HANDLERS" );
|
|
|
|
|
|
|
|
|
|
for( int i = 1; i <= numhandler; i ++ )
|
|
|
|
|
{
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TString8 chiave; chiave.format("%d", i );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TToken_string riga = pro.get( chiave, "HANDLERS" );
|
|
|
|
|
row_set_handler( *m, riga.get_int( 0 ), riga.get_int( 1 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m->set_handler( FR_QTA, qta_handler );
|
|
|
|
|
m->set_handler( FR_UMQTA, um_handler );
|
|
|
|
|
|
|
|
|
|
const int pos = m->id2pos(FR_CODART);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
const TMask_field & f = m->field(FR_CODART);
|
|
|
|
|
if (f.is_edit())
|
|
|
|
|
{
|
|
|
|
|
TBrowse * browse = ((TEdit_field &) f).browse();
|
|
|
|
|
const char tipo_r = tiporiga.tipo();
|
|
|
|
|
|
|
|
|
|
if (browse )
|
|
|
|
|
{
|
|
|
|
|
const TCursor * cur = browse->cursor();
|
|
|
|
|
if (cur)
|
|
|
|
|
{
|
|
|
|
|
const int num = cur->file().num();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (num == LF_ANAMAG || num == LF_CODCORR)
|
1998-11-04 18:04:26 +00:00
|
|
|
|
{
|
|
|
|
|
m->set_handler( FR_CODMAG, codmag_handler );
|
|
|
|
|
m->set_handler( FR_CODMAGC, codmag_coll_handler );
|
|
|
|
|
m->set_handler( FR_CODART, codart_handler );
|
|
|
|
|
m->set_handler( FR_LIV1, liv_handler );
|
|
|
|
|
m->set_handler( FR_LIV2, liv_handler );
|
|
|
|
|
m->set_handler( FR_LIV3, liv_handler );
|
1999-04-06 15:34:39 +00:00
|
|
|
|
m->set_handler( FR_LIV4, liv_handler );
|
1998-11-04 18:04:26 +00:00
|
|
|
|
m->set_handler( FR_UMQTA, umart_handler );
|
|
|
|
|
m->set_handler( FR_CODARTMAG, codartmag_handler );
|
|
|
|
|
m->set_handler( FR_DESCR, descr_handler );
|
|
|
|
|
m->set_handler( FR_QTA, qtaart_handler );
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (livelli().autoinsert(1))
|
|
|
|
|
m->field(FR_LIV1).check_type(CHECK_NONE);
|
|
|
|
|
if (livelli().autoinsert(2))
|
|
|
|
|
m->field(FR_LIV2).check_type(CHECK_NONE);
|
|
|
|
|
if (livelli().autoinsert(3))
|
|
|
|
|
m->field(FR_LIV3).check_type(CHECK_NONE);
|
|
|
|
|
if (livelli().autoinsert(4))
|
|
|
|
|
m->field(FR_LIV4).check_type(CHECK_NONE);
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
else
|
|
|
|
|
if (tipo_r == RIGA_SPESEDOC || tipo_r == RIGA_PRESTAZIONI)
|
|
|
|
|
m->set_handler( FR_CODART, sppr_handler );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m->set_handler(FR_QTAEVASA, qta_evasa_handler);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
m->set_handler(FR_CAUS, causmag_handler);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
if (m->id2pos(FR_CODIVA) >= 0)
|
|
|
|
|
{
|
|
|
|
|
m->set_handler(FR_CODIVA, iva_handler);
|
|
|
|
|
const TString& tipiva = doc().tipo().tipi_iva_validi();
|
|
|
|
|
if (tipiva.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TBrowse& browse = *(m->efield(FR_CODIVA)).browse();
|
|
|
|
|
TString filter = browse.get_filter();
|
|
|
|
|
|
|
|
|
|
bool close_filter = FALSE;
|
|
|
|
|
if (filter.not_empty())
|
|
|
|
|
{
|
|
|
|
|
filter.insert("(");
|
|
|
|
|
filter << ")&&(";
|
|
|
|
|
close_filter = TRUE;
|
|
|
|
|
}
|
|
|
|
|
bool firstor = TRUE;
|
|
|
|
|
for (int i = tipiva.len()-1; i >= 0; i--) if (tipiva[i] != ' ')
|
|
|
|
|
{
|
|
|
|
|
if (firstor)
|
|
|
|
|
firstor = FALSE;
|
|
|
|
|
else
|
|
|
|
|
filter << "||";
|
|
|
|
|
filter << "(S1==\"";
|
|
|
|
|
switch(i)
|
|
|
|
|
{
|
|
|
|
|
case 1: filter << "VE"; break;
|
|
|
|
|
case 2: filter << "ES"; break;
|
|
|
|
|
case 3: filter << "NI"; break;
|
|
|
|
|
case 4: filter << "NS"; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
filter << "\")";
|
|
|
|
|
}
|
|
|
|
|
if (close_filter) filter << ')';
|
|
|
|
|
browse.set_filter(filter);
|
|
|
|
|
}
|
2002-05-31 10:35:40 +00:00
|
|
|
|
m->set_handler(DLG_USER, link_handler);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
m->set_sheet((TSheet_field *)&(field(F_SHEET)));
|
|
|
|
|
|
|
|
|
|
int pos = m->id2pos(FR_PREZZO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
TEditable_field & f =((TEditable_field &) m->fld(pos));
|
|
|
|
|
f.reset_driver(F_CODVAL);
|
|
|
|
|
f.add_driver(-F_CODVAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos = m->id2pos(FR_IMPFISSO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
TEditable_field & f =((TEditable_field &) m->fld(pos));
|
|
|
|
|
f.reset_driver();
|
|
|
|
|
f.add_driver(-F_CODVAL);
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1999-04-26 15:58:05 +00:00
|
|
|
|
void TDocumento_mask::update_giacenza()
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (id2pos(F_CURGIAC)<0)
|
1999-04-26 15:58:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TSheet_field& sf = sfield(F_SHEET);
|
1999-04-26 15:58:05 +00:00
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
|
|
|
|
const TString codart = row.get(sf.cid2index(FR_CODARTMAG));
|
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
real giac, disp;
|
1999-04-26 15:58:05 +00:00
|
|
|
|
if (codart.not_empty())
|
|
|
|
|
{
|
|
|
|
|
const TString& annoes = get(F_ANNO);
|
|
|
|
|
TString16 codmag = row.get(sf.cid2index(FR_CODMAG));
|
|
|
|
|
const TString16 coddep = row.get(sf.cid2index(FR_CODDEP));
|
|
|
|
|
if (!coddep.blank())
|
|
|
|
|
codmag << coddep;
|
|
|
|
|
|
|
|
|
|
TString16 livello;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
const char* liv = row.get(sf.cid2index(FR_LIV1+i));
|
|
|
|
|
if (*liv > ' ')
|
|
|
|
|
livello << liv;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArticolo_giacenza art(codart);
|
|
|
|
|
giac = art.disponibilita(annoes, codmag, livello, TRUE);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
disp = art.disponibilita(annoes, codmag, livello, FALSE);
|
1999-04-26 15:58:05 +00:00
|
|
|
|
|
|
|
|
|
TLocalisamfile umart(LF_UMART);
|
|
|
|
|
umart.setkey(2);
|
|
|
|
|
umart.put(UMART_CODART, codart);
|
|
|
|
|
umart.put(UMART_UM, row.get(sf.cid2index(FR_UMQTA)));
|
|
|
|
|
if (umart.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
real curr_fc = umart.get_real(UMART_FC);
|
|
|
|
|
if (curr_fc > ZERO)
|
2000-05-05 15:25:49 +00:00
|
|
|
|
{
|
1999-04-26 15:58:05 +00:00
|
|
|
|
giac /= curr_fc;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
disp /= curr_fc;
|
|
|
|
|
}
|
1999-04-26 15:58:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1999-04-26 15:58:05 +00:00
|
|
|
|
set(F_CURGIAC, giac.string());
|
2002-12-20 16:15:03 +00:00
|
|
|
|
set(F_CURDISP, disp.string());
|
|
|
|
|
|
1999-04-26 15:58:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Handlers and notifiers
|
1999-10-22 10:00:18 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
2002-12-20 16:15:03 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool TDocumento_mask::ss_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
if (key == K_ENTER && f.mask().insert_mode())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& ss = (TSheet_field&)f;
|
2001-05-02 13:40:49 +00:00
|
|
|
|
if (!app().is_transaction() && ss.items() == 0)
|
1999-10-22 10:00:18 +00:00
|
|
|
|
ok = yesno_box("Il documento e' privo di righe:\n"
|
|
|
|
|
"Si desidera continuare ugualmente?");
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)ss.mask();
|
|
|
|
|
TDocumento& doc = m.doc();
|
|
|
|
|
|
|
|
|
|
if ( key == K_ENTER ) // modifica
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r + 1];
|
|
|
|
|
riga.autosave(ss);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if ( key == K_DEL ) // Cancellazione
|
|
|
|
|
{
|
|
|
|
|
doc.destroy_row(r + 1, TRUE);
|
|
|
|
|
if (r < doc.rows())
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r + 1];
|
|
|
|
|
if (riga.is_omaggio() && riga.is_generata())
|
|
|
|
|
{
|
|
|
|
|
ss.destroy(r + 1);
|
|
|
|
|
doc.destroy_row(r + 1, TRUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (key == K_INS) // Inserimento
|
|
|
|
|
{
|
|
|
|
|
if (r < doc.rows())
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r + 1];
|
|
|
|
|
if (riga.is_omaggio() && riga.is_generata())
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
doc.insert_row(r + 1, m.get( F_LBTIPORIGA ));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (key == K_CTRL + K_INS)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r + 1];
|
|
|
|
|
TRectype & ven_rec = doc.clifor().vendite();
|
|
|
|
|
TString16 s(ven_rec.get(CFV_CODMAG));
|
|
|
|
|
if (s.not_empty())
|
|
|
|
|
{
|
|
|
|
|
s.left_just(3);
|
|
|
|
|
s << ven_rec.get(CFV_CODDEP);
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
else
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
1999-04-06 15:34:39 +00:00
|
|
|
|
s = m.get(F_CAUSMAG);
|
1999-06-18 15:35:05 +00:00
|
|
|
|
if (!s.blank())
|
1999-04-26 15:58:05 +00:00
|
|
|
|
{
|
1999-06-18 15:35:05 +00:00
|
|
|
|
const TRectype & c=cache().get("%CAU", s);
|
|
|
|
|
if (!c.empty() && !c.get("S10").blank())
|
|
|
|
|
s = c.get("S10");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s = m._std_mag;
|
|
|
|
|
s.left_just(3);
|
|
|
|
|
s << m._std_dep;
|
|
|
|
|
}
|
1999-04-26 15:58:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
riga.put("CODMAG", s);
|
|
|
|
|
riga.autoload(ss);
|
|
|
|
|
ss.check_row(r);
|
2000-10-03 13:45:12 +00:00
|
|
|
|
// ss.select(r, 1); // Ma serve a qualcosa?
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1999-04-26 15:58:05 +00:00
|
|
|
|
if ( key == K_TAB ) // ingresso nella riga
|
|
|
|
|
{
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TMask & sm = ss.sheet_mask();
|
|
|
|
|
set_curr_um(sm);
|
1999-04-26 15:58:05 +00:00
|
|
|
|
m.update_giacenza();
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const bool on = doc[r + 1].get(RDOC_DACODNUM).not_empty();
|
|
|
|
|
sm.enable(DLG_USER, on);
|
1999-04-26 15:58:05 +00:00
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Funzione che dato il profilo di riga ottiene la maschera
|
|
|
|
|
// Serve per ottenere una maschera diversa per ogni riga
|
|
|
|
|
TMask* TDocumento_mask::ss_getmask(int numriga, TMask& fullmask)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field* sf = fullmask.get_sheet();
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)sf->mask();
|
|
|
|
|
const TDocumento& doc = m.doc();
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (numriga < doc.physical_rows())
|
|
|
|
|
return m.riga_mask(numriga);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
else
|
|
|
|
|
return &fullmask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::occas_code_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
const char* code = f.get();
|
|
|
|
|
if (*code)
|
|
|
|
|
{
|
|
|
|
|
TRelation occas(LF_OCCAS);
|
|
|
|
|
occas.lfile().put("CFPI", code);
|
|
|
|
|
if (occas.read(_isequal) == NOERR)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
m.autoload(occas);
|
|
|
|
|
m.send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
|
|
|
|
|
m.send_key(K_TAB, O_COMUNENAS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::occas_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &)f.mask();
|
|
|
|
|
if ( key == K_SPACE && m.is_running( ) )
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = m.doc();
|
|
|
|
|
TOccasionale& occ = doc.occas();
|
|
|
|
|
|
|
|
|
|
TMask occas_mask("ve0100o");
|
|
|
|
|
occas_mask.set_handler( O_CODICE, occas_code_handler );
|
|
|
|
|
|
|
|
|
|
for (int i = occas_mask.fields() - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
TMask_field & f = occas_mask.fld(i);
|
|
|
|
|
const TFieldref * c = f.field();
|
|
|
|
|
if (c)
|
|
|
|
|
f.set(c->read(occ));
|
|
|
|
|
}
|
|
|
|
|
if (occas_mask.run() != K_ESC)
|
|
|
|
|
{
|
|
|
|
|
const TString ocfpi(occas_mask.get(O_CODICE));
|
|
|
|
|
doc.put("OCFPI", ocfpi);
|
|
|
|
|
m.set(F_OCFPI, ocfpi);
|
|
|
|
|
|
|
|
|
|
for (int i = occas_mask.fields() - 1; i >= 0; i--)
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const TMask_field& f = occas_mask.fld(i);
|
|
|
|
|
const TFieldref* c = f.field();
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (c)
|
2000-05-05 15:25:49 +00:00
|
|
|
|
{
|
|
|
|
|
const char* val = f.get();
|
|
|
|
|
c->write(val, occ);
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
m.occ2mask();
|
|
|
|
|
}
|
|
|
|
|
f.set_focus( );
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::clifo_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key != K_ENTER && f.to_check(key, TRUE))
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) f.mask();
|
|
|
|
|
TDocumento & d = m.doc();
|
|
|
|
|
const TString & val = f.get();
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
TTipo_documento& tdoc = (TTipo_documento&) d.tipo();
|
|
|
|
|
d.put("TIPOCF", tdoc.tipocf());
|
1998-08-25 18:07:30 +00:00
|
|
|
|
d.put("CODCF", atol(val));
|
|
|
|
|
|
|
|
|
|
TCli_for & cli_for = d.clifor();
|
|
|
|
|
cli_for.put(CLI_CODCF, ""); // force reload
|
|
|
|
|
|
|
|
|
|
if ( cli_for.get_bool("SOSPESO") )
|
|
|
|
|
return f.error_box( "Il codice '%ld' e' sospeso e non puo' essere utilizzato", atol(val) );
|
|
|
|
|
m.cli2mask();
|
|
|
|
|
if (cli_for.occasionale())
|
|
|
|
|
{
|
|
|
|
|
TOccasionale & occas = d.occas();
|
|
|
|
|
if(m.id2pos(F_OCCASEDIT) > 0 && f.to_check(key) && *(occas.codice()) == '\0')
|
|
|
|
|
m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
d.zero("OCFPI");
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
void TDocumento_mask::highlight(COLOR high_back_color, COLOR high_color)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field & sf = sfield(F_SHEET);
|
|
|
|
|
const int items = sf.items();
|
|
|
|
|
|
|
|
|
|
for (int i = 0 ; i < items; i++)
|
|
|
|
|
{
|
|
|
|
|
const bool on = doc()[i + 1].linked();
|
|
|
|
|
|
|
|
|
|
COLOR back = on ? high_back_color : NORMAL_BACK_COLOR;
|
|
|
|
|
COLOR fore = on ? high_color : NORMAL_COLOR;
|
|
|
|
|
|
|
|
|
|
sf.set_back_and_fore_color(back, fore, i);
|
|
|
|
|
sf.force_update(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-20 16:15:03 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TLista_elaborazioni
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TLista_elaborazioni::read()
|
|
|
|
|
{
|
|
|
|
|
if (_elab == NULL)
|
|
|
|
|
{
|
|
|
|
|
_elab = new TAssoc_array();
|
|
|
|
|
|
|
|
|
|
TTable eld("%ELD");
|
|
|
|
|
|
|
|
|
|
for (int err = eld.first(); err == NOERR; err = eld.next())
|
|
|
|
|
{
|
|
|
|
|
TElaborazione * el = NULL;
|
|
|
|
|
switch (eld.curr().get_int("I0"))
|
|
|
|
|
{
|
|
|
|
|
case _esterna :
|
|
|
|
|
el = new TElaborazione_esterna(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
case _consegna_ordini:
|
|
|
|
|
el = new TConsegna_ordini(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
case _fatturazione_bolle :
|
|
|
|
|
el = new TFatturazione_bolle(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
case _contabilizzazione :
|
|
|
|
|
el = new TContabilizzazione(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
case _copia_documento :
|
|
|
|
|
el = new TCopia_documento(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
case _generazione_effetti :
|
|
|
|
|
el = new TGenerazione_effetti(eld.curr());
|
|
|
|
|
break;
|
|
|
|
|
default :
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
_elab->add(el->codice(), el);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TLista_elaborazioni::select(TString_array & result, const char * tipo_iniziale, const char * stato_iniziale, const char * tipo_finale, const char * stato_finale)
|
|
|
|
|
{
|
|
|
|
|
read();
|
|
|
|
|
_elab->restart();
|
|
|
|
|
result.destroy();
|
|
|
|
|
for (TElaborazione * el = (TElaborazione *)_elab->get(); el ; el = (TElaborazione *) _elab->get())
|
|
|
|
|
{
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
TString ti;
|
|
|
|
|
if ((tipo_iniziale && *tipo_iniziale) && (stato_iniziale && *stato_iniziale))
|
|
|
|
|
for (int i = 0; !ok && i < TElaborazione::_max_tipi_doc_elab; i++)
|
|
|
|
|
{
|
|
|
|
|
ti = el->tipo_iniziale(i);
|
|
|
|
|
const char si = el->stato_iniziale(i);
|
|
|
|
|
ok |= ti == tipo_iniziale &&
|
|
|
|
|
si == *stato_iniziale;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ok = TRUE;
|
|
|
|
|
if ((tipo_finale && *tipo_finale) && (stato_finale && *stato_finale))
|
|
|
|
|
ok &= el->tipo_finale() == tipo_finale &&
|
|
|
|
|
el->stato_finale() == stato_finale;
|
|
|
|
|
if (ok)
|
|
|
|
|
result.add(el->codice());
|
|
|
|
|
}
|
|
|
|
|
return result.items();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TElaborazione & TLista_elaborazioni::operator [](const char * key) const
|
|
|
|
|
{
|
|
|
|
|
((TLista_elaborazioni *)this)->read();
|
|
|
|
|
return (TElaborazione &) (*_elab)[key];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TLista_elaborazioni::update()
|
|
|
|
|
{
|
|
|
|
|
delete _elab; _elab = NULL;
|
|
|
|
|
read();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TLista_elaborazioni::~TLista_elaborazioni()
|
|
|
|
|
{
|
|
|
|
|
if (_elab)
|
|
|
|
|
delete _elab;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TDocument_tree
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TDocument_tree : public TBidirectional_tree
|
|
|
|
|
{
|
|
|
|
|
TRelation* _relation;
|
|
|
|
|
TCursor* _cursor;
|
|
|
|
|
TToken_string _curnode;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void node2id(const TObject* node, TString& id) const;
|
|
|
|
|
bool on_head() const;
|
|
|
|
|
bool on_row() const;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
|
|
|
|
void format_field(const TRectype& rec, const TString& field, TString& str) const;
|
|
|
|
|
void append_custom_fields(const TTipo_documento& tipo, const TRectype& rec, TString& str) const;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool goto_root();
|
|
|
|
|
virtual bool goto_firstson();
|
|
|
|
|
virtual bool goto_rbrother();
|
|
|
|
|
virtual bool goto_node(const TString &id);
|
|
|
|
|
virtual bool has_son() const;
|
|
|
|
|
virtual bool has_rbrother() const;
|
|
|
|
|
virtual bool has_father() const;
|
|
|
|
|
virtual bool has_lbrother() const;
|
|
|
|
|
virtual bool goto_father();
|
|
|
|
|
virtual bool goto_lbrother();
|
|
|
|
|
virtual TObject* curr_node() const { return &(TToken_string&)_curnode; }
|
|
|
|
|
virtual bool get_description(TString& str) const;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
virtual TImage* image(bool selected) const;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
|
|
|
|
|
const TRectype& testata() const;
|
|
|
|
|
const TRectype& riga() const;
|
|
|
|
|
const TRectype& record() const;
|
|
|
|
|
|
|
|
|
|
void set_cursor(char tipocf, long codcf, int anno, const char* filter, FILTERFUNCTION ff = NULL);
|
|
|
|
|
TCursor* get_cursor() { return _cursor; }
|
|
|
|
|
|
|
|
|
|
TDocument_tree();
|
|
|
|
|
~TDocument_tree();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TRectype& TDocument_tree::testata() const
|
|
|
|
|
{
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
const TRecnotype pos = me._curnode.get_long(0);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
if (_cursor->pos() != pos || _relation->curr(LF_RIGHEDOC).empty())
|
2002-05-31 10:35:40 +00:00
|
|
|
|
*me._cursor = pos;
|
|
|
|
|
return _relation->curr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRectype& TDocument_tree::riga() const
|
|
|
|
|
{
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
const TRectype& rec = _relation->curr(LF_RIGHEDOC);
|
|
|
|
|
const TRecnotype pos = me._curnode.get_long(0);
|
|
|
|
|
const int nriga = me._curnode.get_int(1);
|
|
|
|
|
if (_cursor->pos() != pos || rec.get_int(RDOC_NRIGA) > nriga)
|
|
|
|
|
*me._cursor = pos;
|
|
|
|
|
for (int i = rec.get_int(RDOC_NRIGA); i < nriga; i++)
|
|
|
|
|
_relation->next_match(LF_RIGHEDOC);
|
|
|
|
|
return rec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRectype& TDocument_tree::record() const
|
|
|
|
|
{
|
|
|
|
|
return on_row() ? riga() : testata();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocument_tree::node2id(const TObject* node, TString& id) const
|
|
|
|
|
{
|
|
|
|
|
id = *(TString*)node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::on_head() const
|
|
|
|
|
{
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
return me._curnode.get_int(1) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::on_row() const
|
|
|
|
|
{
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
return me._curnode.get_int(1) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_root()
|
|
|
|
|
{
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const bool ok = _cursor != NULL && _cursor->items()>0;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
_curnode = ok ? "0" : "";
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_firstson()
|
|
|
|
|
{
|
|
|
|
|
bool ok = has_son();
|
|
|
|
|
if (ok)
|
|
|
|
|
_curnode.add(1,1);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_rbrother()
|
|
|
|
|
{
|
|
|
|
|
bool ok = has_rbrother();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
if (on_head())
|
|
|
|
|
{
|
|
|
|
|
const long pos = _curnode.get_long(0);
|
|
|
|
|
_curnode.add(pos+1, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const int nriga = _curnode.get_int(1);
|
|
|
|
|
_curnode.add(nriga+1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_node(const TString &id)
|
|
|
|
|
{
|
|
|
|
|
_curnode = id;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::has_son() const
|
|
|
|
|
{
|
|
|
|
|
bool ok = on_head();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
testata();
|
|
|
|
|
const TRectype& rec = _relation->curr(LF_RIGHEDOC);
|
|
|
|
|
ok = rec.get_int(RDOC_NRIGA) > 0;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::has_rbrother() const
|
|
|
|
|
{
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
if (on_head())
|
|
|
|
|
{
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
const long pos = me._curnode.get_long(0);
|
|
|
|
|
ok = pos < _cursor->items()-1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
riga(); // Posizionati sulla riga corrente
|
|
|
|
|
ok = _relation->next_match(LF_RIGHEDOC);
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::has_father() const
|
|
|
|
|
{
|
|
|
|
|
return on_row();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::has_lbrother() const
|
|
|
|
|
{
|
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
TDocument_tree& me = (TDocument_tree&)*this;
|
|
|
|
|
if (on_head())
|
|
|
|
|
{
|
|
|
|
|
const long pos = me._curnode.get_long(0);
|
|
|
|
|
ok = pos > 0L;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const int nriga = me._curnode.get_int(1);
|
|
|
|
|
ok = nriga > 1;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_father()
|
|
|
|
|
{
|
|
|
|
|
bool ok = on_row();
|
|
|
|
|
if (ok)
|
|
|
|
|
_curnode.add(0, 1);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocument_tree::goto_lbrother()
|
|
|
|
|
{
|
|
|
|
|
bool ok = has_lbrother();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
if (on_head())
|
|
|
|
|
{
|
|
|
|
|
const long pos = _curnode.get_long(0);
|
|
|
|
|
_curnode.add(pos-1, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const int nriga = _curnode.get_int(1);
|
|
|
|
|
_curnode.add(nriga-1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
void TDocument_tree::format_field(const TRectype& rec, const TString& field, TString& str) const
|
|
|
|
|
{
|
|
|
|
|
const TFieldref fld(field, rec.num());
|
|
|
|
|
const TString& value = fld.read(rec);
|
|
|
|
|
const TFieldtypes ft = rec.type(fld.name());
|
|
|
|
|
if (ft == _realfld)
|
|
|
|
|
{
|
|
|
|
|
const int len = rec.length(fld.name());
|
|
|
|
|
const int ndec = rec.ndec(fld.name());
|
|
|
|
|
TString8 pic; pic.format(".%d", ndec);
|
|
|
|
|
const real r = value;
|
|
|
|
|
str = r.string(pic);
|
|
|
|
|
str.right_just(len);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
str = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocument_tree::append_custom_fields(const TTipo_documento& tipo, const TRectype& rec, TString& str) const
|
|
|
|
|
{
|
|
|
|
|
const TString& format = rec.num() == LF_DOC ? tipo.stringa_descrizione_documento()
|
|
|
|
|
: tipo.stringa_descrizione_riga();
|
|
|
|
|
if (format.not_empty())
|
|
|
|
|
{
|
|
|
|
|
str << ' ';
|
|
|
|
|
int ch = -1;
|
|
|
|
|
TString tmp;
|
|
|
|
|
for (int ap = format.find('{'); ap >= 0; ap = format.find('{', ch+1))
|
|
|
|
|
{
|
|
|
|
|
str << format.sub(ch+1, ap);
|
|
|
|
|
ch = format.find('}', ap);
|
|
|
|
|
const TString16 field = format.sub(ap+1, ch);
|
|
|
|
|
format_field(rec, field, tmp);
|
|
|
|
|
str << tmp;
|
|
|
|
|
}
|
|
|
|
|
str << format.mid(ch+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TImage* TDocument_tree::image(bool selected) const
|
|
|
|
|
{
|
|
|
|
|
if (on_row())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = riga();
|
|
|
|
|
if (rec.get_bool(RDOC_RIGAEVASA))
|
|
|
|
|
return get_res_image(BMP_STOP);
|
|
|
|
|
}
|
|
|
|
|
return TTree::image(selected);
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
bool TDocument_tree::get_description(TString& str) const
|
|
|
|
|
{
|
|
|
|
|
if (on_head())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = testata();
|
|
|
|
|
str = rec.get(DOC_ANNO);
|
|
|
|
|
str << ' ' << rec.get(DOC_CODNUM);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
TString16 tmp;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
tmp.format("%6ld", rec.get_long(DOC_NDOC));
|
|
|
|
|
str << ' ' << tmp << ' ' << rec.get(DOC_DATADOC);
|
|
|
|
|
const char tipocf = rec.get_char(DOC_TIPOCF);
|
|
|
|
|
const long codcf = rec.get_long(DOC_CODCF);
|
|
|
|
|
tmp.format(" %c%6ld ", tipocf, codcf);
|
|
|
|
|
str << tmp;
|
|
|
|
|
tmp.format("%c|%6ld", tipocf, codcf);
|
|
|
|
|
str << cache().get(LF_CLIFO, tmp, CLI_RAGSOC);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
str.left_just(63);
|
|
|
|
|
|
|
|
|
|
const TTipo_documento& tipo = TDocumento::tipo(rec.get(DOC_TIPODOC));
|
|
|
|
|
append_custom_fields(tipo, rec, str);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = riga();
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const TRectype& testata = _relation->curr();
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
const TString80 codart = rec.get(RDOC_CODART);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
str = codart;
|
|
|
|
|
str.left_just(21);
|
|
|
|
|
str << rec.get(RDOC_DESCR).left(30);
|
|
|
|
|
str.left_just(52);
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
if (codart.not_empty())
|
|
|
|
|
{
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const TTipo_documento& tipo = TDocumento::tipo(testata.get(DOC_TIPODOC));
|
|
|
|
|
const real qta = rec.get(tipo.field_qta());
|
|
|
|
|
str << qta.string("###.###.##@,@@@");
|
|
|
|
|
if (tipo.is_ordine())
|
|
|
|
|
{
|
|
|
|
|
const real qta_evasa = rec.get(tipo.field_qtaevasa());
|
|
|
|
|
const real residuo = qta_evasa < qta ? (qta-qta_evasa) : ZERO;
|
|
|
|
|
str << residuo.string("###.###.##@,@@@");
|
|
|
|
|
}
|
|
|
|
|
append_custom_fields(tipo, rec, str);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocument_tree::set_cursor(char tipocf, long codcf, int anno, const char* filter, FILTERFUNCTION ff)
|
|
|
|
|
{
|
|
|
|
|
if (_relation == NULL)
|
|
|
|
|
{
|
|
|
|
|
_relation = new TRelation(LF_DOC);
|
|
|
|
|
_relation->add(LF_RIGHEDOC, "PROVV==PROVV|ANNO==ANNO|CODNUM==CODNUM|NDOC==NDOC");
|
|
|
|
|
}
|
|
|
|
|
if (_cursor == NULL)
|
|
|
|
|
{
|
|
|
|
|
_cursor = new TCursor(_relation, "", 2);
|
|
|
|
|
}
|
|
|
|
|
TRectype& rec = _relation->curr();
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(DOC_TIPOCF, tipocf);
|
|
|
|
|
rec.put(DOC_CODCF, codcf);
|
|
|
|
|
rec.put(DOC_PROVV, "D");
|
|
|
|
|
rec.put(DOC_ANNO, anno);
|
|
|
|
|
_cursor->freeze(FALSE);
|
|
|
|
|
_cursor->setfilter(filter);
|
|
|
|
|
_cursor->setregion(rec, rec);
|
|
|
|
|
const long items = _cursor->items();
|
|
|
|
|
_cursor->freeze(TRUE);
|
|
|
|
|
|
|
|
|
|
goto_root();
|
|
|
|
|
if (items <= 3)
|
|
|
|
|
expand_all();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocument_tree::TDocument_tree()
|
|
|
|
|
: _relation(NULL), _cursor(NULL)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocument_tree::~TDocument_tree()
|
|
|
|
|
{
|
|
|
|
|
if (_cursor)
|
|
|
|
|
delete _cursor;
|
|
|
|
|
if (_relation)
|
|
|
|
|
delete _relation;
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TElabora_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
class TElabora_mask : public TAutomask
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TDocumento_mask* _main;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TLista_elaborazioni _elab;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TDocument_tree _tree;
|
2003-02-25 14:39:02 +00:00
|
|
|
|
|
|
|
|
|
TElaborazione* _last_elab;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
|
|
|
|
// @access Protected Member
|
|
|
|
|
protected:
|
|
|
|
|
TString _art_filter, _liv_filter;
|
|
|
|
|
static TElabora_mask* _myself;
|
|
|
|
|
static bool article_filter(const TRelation* rel);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
|
|
|
|
|
void add_valuta_filter(TString& filter) const;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
void docrif_search();
|
2002-07-02 16:21:23 +00:00
|
|
|
|
int update_list();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
void update_ndoc_filter(bool is_tipo_elaborazione = FALSE);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
// @access Public Member
|
|
|
|
|
public:
|
1998-08-25 18:07:30 +00:00
|
|
|
|
bool elabora();
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TElaborazione* curr_elab();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TElabora_mask(TDocumento_mask& main_mask);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
// @cmember Distruttore
|
|
|
|
|
virtual ~TElabora_mask() {}
|
|
|
|
|
};
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
TElabora_mask* TElabora_mask::_myself = NULL;
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
bool TElabora_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_CODART:
|
|
|
|
|
case F_CODNUM_ELAB:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
update_ndoc_filter();
|
|
|
|
|
break;
|
|
|
|
|
case F_TYPE:
|
|
|
|
|
if (e == fe_init || e == fe_modify)
|
|
|
|
|
{
|
2002-07-02 16:21:23 +00:00
|
|
|
|
int ne = update_list();
|
|
|
|
|
if (e == fe_init && ne == 0) // Riprova a cambiare flag e ricostruire la lista
|
|
|
|
|
{
|
|
|
|
|
set(F_TYPE, "X");
|
|
|
|
|
ne = update_list();
|
|
|
|
|
if (ne == 0)
|
|
|
|
|
set(F_TYPE, "");
|
|
|
|
|
}
|
2002-05-31 10:35:40 +00:00
|
|
|
|
update_ndoc_filter(TRUE);
|
2002-09-13 14:06:05 +00:00
|
|
|
|
const bool is_search = o.get().empty() || field(F_CODCF_ELAB).empty();
|
|
|
|
|
o.mask().field(F_NDOC_ELAB).check_type(is_search ? CHECK_SEARCH : CHECK_REQUIRED);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_STATODOC_ELAB:
|
|
|
|
|
case F_TIPODOC_ELAB:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
update_list();
|
|
|
|
|
update_ndoc_filter();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_ELAB:
|
2003-01-28 13:33:45 +00:00
|
|
|
|
case F_ANNO_ELAB:
|
2003-02-25 14:39:02 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
if (e == fe_modify)
|
2003-02-25 14:39:02 +00:00
|
|
|
|
update_ndoc_filter();
|
2002-05-31 10:35:40 +00:00
|
|
|
|
break;
|
|
|
|
|
case F_NUMDOCRIF_ELAB:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
docrif_search();
|
|
|
|
|
break;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
case F_NDOC_ELAB:
|
|
|
|
|
if ((e == fe_modify || e == fe_close) && o.check_type() == CHECK_SEARCH && !o.empty())
|
|
|
|
|
{
|
2002-09-13 14:06:05 +00:00
|
|
|
|
/* Metodo inaffidabile in assenza di codice clifo
|
2002-07-02 16:21:23 +00:00
|
|
|
|
o.check_type(CHECK_REQUIRED);
|
|
|
|
|
const bool ok = o.on_key (K_ENTER);
|
|
|
|
|
o.check_type(CHECK_SEARCH);
|
|
|
|
|
return ok;
|
2002-09-13 14:06:05 +00:00
|
|
|
|
*/
|
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add("D"); key.add(get(F_ANNO_ELAB));
|
|
|
|
|
key.add(get(F_CODNUM_ELAB)); key.add(o.get());
|
|
|
|
|
const TRectype& rec = cache().get(LF_DOC, key);
|
|
|
|
|
bool ok = !rec.empty(); // Verifica esistenza documento
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TCursor* c = _tree.get_cursor();
|
|
|
|
|
c->curr() = rec;
|
|
|
|
|
ok = c->test(_isequal) == NOERR; // Verifica compatibilit<69> documento
|
|
|
|
|
}
|
|
|
|
|
if (!ok)
|
|
|
|
|
return error_box(((TEdit_field&)o).get_warning());
|
2002-07-02 16:21:23 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
case F_ROWS:
|
|
|
|
|
if (e == fe_modify && is_running())
|
|
|
|
|
{
|
|
|
|
|
TCursor* c = _tree.get_cursor();
|
|
|
|
|
if (c != NULL && c->items() > 0)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& head = _tree.testata();
|
|
|
|
|
set(F_DATADOC_ELAB, head.get(DOC_DATADOC)); // Anch'essa nella chiave 2!
|
2003-01-28 13:33:45 +00:00
|
|
|
|
set(F_ANNO_ELAB, head.get(DOC_ANNO));
|
2002-07-02 16:21:23 +00:00
|
|
|
|
set(F_CODNUM_ELAB, head.get(DOC_CODNUM));
|
|
|
|
|
field(F_CODNUM_ELAB).check();
|
2002-05-31 10:35:40 +00:00
|
|
|
|
set(F_NDOC_ELAB, head.get(DOC_NDOC));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
int TElabora_mask::update_list()
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TString_array elabs;
|
|
|
|
|
const TString16 tipo(_main->get(F_TIPODOC));
|
|
|
|
|
const TString16 stato(_main->get(F_STATO));
|
|
|
|
|
const TString16 tipo_elab(get(F_TIPODOC_ELAB));
|
|
|
|
|
const TString16 stato_elab(get(F_STATODOC_ELAB));
|
|
|
|
|
const bool from_elab = !get_bool(F_TYPE);
|
|
|
|
|
int items = 0;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
|
|
|
|
bool agg_test = FALSE;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (from_elab)
|
1999-04-26 15:58:05 +00:00
|
|
|
|
items = _elab.select(elabs, tipo, stato,"",""/*tipo_elab, stato_elab*/) ;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
else
|
1999-10-22 10:00:18 +00:00
|
|
|
|
{
|
|
|
|
|
items = _elab.select(elabs, tipo_elab, stato_elab, tipo, stato);
|
|
|
|
|
agg_test = _main->sfield(F_SHEET).items() == 0;
|
|
|
|
|
}
|
|
|
|
|
set(F_UPDATE_HEADER, agg_test ? "X" : "");
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
const bool ok = items > 0;
|
|
|
|
|
enable(DLG_OK, ok);
|
|
|
|
|
enable(F_ELAB, ok);
|
|
|
|
|
|
|
|
|
|
TList_field & f = (TList_field &) field(F_ELAB);
|
|
|
|
|
TToken_string codes;
|
|
|
|
|
TToken_string descrs;
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
for (int i = 0; i < items; i++)
|
|
|
|
|
{
|
|
|
|
|
const TElaborazione& e = _elab[elabs.row(i)];
|
|
|
|
|
codes.add(e.codice());
|
|
|
|
|
descrs.add(e.descrizione());
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (codes != f.get_codes())
|
|
|
|
|
f.replace_items(codes, descrs);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
const TElaborazione * e = curr_elab();
|
|
|
|
|
if (e && e->tipo() == _consegna_ordini)
|
1999-10-22 10:00:18 +00:00
|
|
|
|
show(-GRP_ART);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
reset(-GRP_ART);
|
|
|
|
|
hide(-GRP_ART);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
}
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
|
|
|
|
return items;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TElabora_mask::elabora()
|
|
|
|
|
{
|
|
|
|
|
bool update_mask = FALSE;
|
|
|
|
|
|
|
|
|
|
TLista_documenti in;
|
|
|
|
|
TLista_documenti out;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TDocumento& app_doc = ((TDocumento_mask *)_main)->doc();
|
1998-08-25 18:07:30 +00:00
|
|
|
|
long numdoc = get_long(F_NDOC_ELAB);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
const bool update_header = get_bool(F_UPDATE_HEADER);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TDocumento* newdoc = new TDocumento(*get(F_PROVV_ELAB), get_int(F_ANNO_ELAB), get(F_CODNUM_ELAB), numdoc);
|
|
|
|
|
TDocumento& d = *newdoc;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
|
|
|
|
|
if (numdoc <= 0)
|
|
|
|
|
{
|
|
|
|
|
TDocumento::copy_data(d.head(), app_doc.head());
|
1998-11-04 18:04:26 +00:00
|
|
|
|
d.put(DOC_TIPODOC, get(F_TIPODOC_ELAB));
|
|
|
|
|
|
|
|
|
|
const TDate datadoc = d.get_date(DOC_DATADOC);
|
|
|
|
|
const TDate datainsc = d.get_date(DOC_DATAINSC);
|
|
|
|
|
const bool equal = !datainsc.ok() || datadoc == datainsc;
|
|
|
|
|
|
|
|
|
|
d.put(DOC_DATADOC, get(F_DATADOC_ELAB));
|
|
|
|
|
if (equal)
|
|
|
|
|
d.zero(DOC_DATAINSC);
|
|
|
|
|
|
|
|
|
|
const TTipo_documento & t = d.tipo();
|
|
|
|
|
|
|
|
|
|
if (t.mov_mag())
|
|
|
|
|
d.put(DOC_CAUSMAG, t.caus_mov());
|
|
|
|
|
else
|
|
|
|
|
d.zero(DOC_CAUSMAG);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (update_header)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tipo_doc(app_doc.get(DOC_TIPODOC));
|
|
|
|
|
const TString16 caus_mag(app_doc.get(DOC_CAUSMAG));
|
|
|
|
|
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);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
const char stato = app_doc.stato();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TDocumento::copy_data(app_doc.head(), d.head());
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
app_doc.put(DOC_TIPODOC, tipo_doc);
|
|
|
|
|
app_doc.put(DOC_CAUSMAG, caus_mag);
|
|
|
|
|
app_doc.put(DOC_MOVMAG, movmag);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
app_doc.put(DOC_DATADOC, datadoc);
|
|
|
|
|
app_doc.put(DOC_DATAINSC, datainsc);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
app_doc.put(DOC_STATO, stato);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
const bool from_elab = !get_bool(F_TYPE);
|
|
|
|
|
TElaborazione * e = curr_elab();
|
|
|
|
|
|
|
|
|
|
if (e == NULL)
|
|
|
|
|
return FALSE;
|
1999-07-16 14:59:11 +00:00
|
|
|
|
|
|
|
|
|
if (e->tipo() == _consegna_ordini)
|
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
TParametri_elaborazione& p = e->params();
|
|
|
|
|
p.set("ARTICOLO", get(F_CODART));
|
|
|
|
|
p.set("UM", get(F_UMQTA));
|
|
|
|
|
p.set("QUANTITA", get(F_QTA));
|
1999-07-16 14:59:11 +00:00
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (from_elab)
|
|
|
|
|
{
|
|
|
|
|
in.add(app_doc);
|
|
|
|
|
out.add(d);
|
|
|
|
|
if (e->elabora(in, out, TDate(TODAY), TRUE))
|
|
|
|
|
{
|
|
|
|
|
if (out[0] != d)
|
|
|
|
|
out.rewrite();
|
2001-05-02 13:40:49 +00:00
|
|
|
|
if (app_doc != in[0])
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
in.rewrite();
|
|
|
|
|
app_doc = in[0];
|
|
|
|
|
update_mask = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
out.add(app_doc);
|
|
|
|
|
in.add(d);
|
|
|
|
|
if (e->elabora(in, out, TDate(TODAY), TRUE))
|
|
|
|
|
{
|
|
|
|
|
if (out[0] != app_doc)
|
|
|
|
|
{
|
|
|
|
|
out.rewrite();
|
|
|
|
|
app_doc = out[0];
|
|
|
|
|
update_mask = TRUE;
|
|
|
|
|
}
|
2001-05-02 13:40:49 +00:00
|
|
|
|
if (d != in[0])
|
1998-08-25 18:07:30 +00:00
|
|
|
|
in.rewrite();
|
|
|
|
|
}
|
2001-06-25 10:41:20 +00:00
|
|
|
|
TString8 num_in(e->codice_numerazione_iniziale());
|
|
|
|
|
|
|
|
|
|
set(F_CODNUM_ELAB, num_in);
|
|
|
|
|
set(F_NDOC_ELAB, "");
|
2002-05-31 10:35:40 +00:00
|
|
|
|
set(F_NUMDOCRIF_ELAB, "");
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
1999-07-16 14:59:11 +00:00
|
|
|
|
if (e->tipo() == _consegna_ordini)
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
TParametri_elaborazione& p = e->params();
|
1999-10-22 10:00:18 +00:00
|
|
|
|
if (p.get("ARTICOLO").not_empty())
|
|
|
|
|
{
|
|
|
|
|
real qta = get_real(F_QTA);
|
|
|
|
|
if (qta > ZERO)
|
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const real qta_evasa = p.get_real("QUANTITA");
|
1999-10-22 10:00:18 +00:00
|
|
|
|
qta -= qta_evasa;
|
|
|
|
|
set(F_QTA, qta);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-16 14:59:11 +00:00
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
delete newdoc;
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
2003-01-28 13:33:45 +00:00
|
|
|
|
// Azzera l'anno in caso di ordini
|
|
|
|
|
if (in.items() > 0 && in[0].is_ordine())
|
|
|
|
|
{
|
|
|
|
|
reset(F_ANNO_ELAB);
|
|
|
|
|
update_mask = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-02 16:21:23 +00:00
|
|
|
|
if (update_mask)
|
|
|
|
|
update_ndoc_filter();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
return update_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TElaborazione * TElabora_mask::curr_elab()
|
|
|
|
|
{
|
|
|
|
|
const TString16 cod_elab(get(F_ELAB));
|
1999-10-22 10:00:18 +00:00
|
|
|
|
return cod_elab.not_empty() ? &_elab[cod_elab] : NULL;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool TElabora_mask::article_filter(const TRelation* rel)
|
|
|
|
|
{
|
|
|
|
|
bool yes = FALSE;
|
|
|
|
|
TElabora_mask& m = *_myself;
|
|
|
|
|
TLocalisamfile rdoc(LF_RIGHEDOC);
|
|
|
|
|
rdoc.put(RDOC_CODNUM, rel->curr().get(DOC_CODNUM));
|
|
|
|
|
rdoc.put(RDOC_ANNO, rel->curr().get(DOC_ANNO));
|
|
|
|
|
rdoc.put(RDOC_PROVV, rel->curr().get(DOC_PROVV));
|
|
|
|
|
rdoc.put(RDOC_NDOC, rel->curr().get(DOC_NDOC));
|
|
|
|
|
rdoc.put(RDOC_NRIGA, 1);
|
|
|
|
|
int next_riga = 1;
|
|
|
|
|
for (int err = rdoc.read(); err == NOERR; err = rdoc.next())
|
|
|
|
|
{
|
|
|
|
|
const int nriga = rdoc.get_int(RDOC_NRIGA);
|
|
|
|
|
if (nriga != next_riga)
|
|
|
|
|
break;
|
|
|
|
|
next_riga++;
|
|
|
|
|
const bool evasa= rdoc.get_bool(RDOC_RIGAEVASA);
|
|
|
|
|
const TString& codart = rdoc.get(RDOC_CODART);
|
|
|
|
|
if (!evasa && codart == m._art_filter)
|
|
|
|
|
{
|
2002-07-02 16:21:23 +00:00
|
|
|
|
yes = TRUE;
|
|
|
|
|
break;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return yes;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
void TElabora_mask::add_valuta_filter(TString& filter) const
|
|
|
|
|
{
|
|
|
|
|
TString16 valuta = get(F_CODVAL_ELAB);
|
|
|
|
|
if (::is_firm_value(valuta))
|
|
|
|
|
{
|
|
|
|
|
filter << "((CODVAL==\"" << valuta << "\")";
|
|
|
|
|
if (valuta.empty())
|
|
|
|
|
valuta = TCurrency::get_firm_val();
|
|
|
|
|
else
|
|
|
|
|
valuta.cut(0);
|
|
|
|
|
filter << "||(CODVAL==\"" << valuta << "\"))";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filter << "(CODVAL==\"" << valuta << "\")";
|
|
|
|
|
}
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
void TElabora_mask::update_ndoc_filter(bool is_tipo_elaborazione)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
TString filter(80);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
// Ora <20> nella maschera
|
|
|
|
|
// filter.format("(TIPOCF==\"%s\")&&(CODCF==\"%s\")&&", (const char *)get(F_TIPOCF_ELAB), (const char *)get(F_CODCF_ELAB));
|
|
|
|
|
add_valuta_filter(filter);
|
2003-02-25 14:39:02 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
TElaborazione * e = curr_elab();
|
2003-02-25 14:39:02 +00:00
|
|
|
|
const bool elab_changed = e != _last_elab;
|
|
|
|
|
_last_elab = e;
|
2001-05-02 13:40:49 +00:00
|
|
|
|
|
2003-02-25 14:39:02 +00:00
|
|
|
|
const bool aggiungi_doc_att = get_bool(F_TYPE);
|
|
|
|
|
enable(-1, aggiungi_doc_att /*&& e != NULL*/);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
|
2003-02-25 14:39:02 +00:00
|
|
|
|
if (!aggiungi_doc_att && is_tipo_elaborazione )
|
2002-07-02 16:21:23 +00:00
|
|
|
|
reset(-1);
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (e != NULL)
|
1999-04-26 15:58:05 +00:00
|
|
|
|
{
|
2003-02-25 14:39:02 +00:00
|
|
|
|
if (aggiungi_doc_att)
|
1999-04-26 15:58:05 +00:00
|
|
|
|
{
|
2003-02-25 14:39:02 +00:00
|
|
|
|
const TString8 num_in = e->codice_numerazione_iniziale();
|
|
|
|
|
if (elab_changed)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tipo_in(e->tipo_iniziale(0));
|
|
|
|
|
const char stato_in = e->stato_iniziale(0);
|
|
|
|
|
|
|
|
|
|
set(F_CODNUM_ELAB, num_in);
|
|
|
|
|
field(F_CODNUM_ELAB).check();
|
|
|
|
|
set(F_TIPODOC_ELAB , tipo_in);
|
|
|
|
|
field(F_TIPODOC_ELAB).check();
|
|
|
|
|
TString8 si; si << stato_in;
|
|
|
|
|
set(F_STATODOC_ELAB, si);
|
|
|
|
|
field(F_STATODOC_ELAB).check();
|
|
|
|
|
|
|
|
|
|
// Azzero anno di elaaborazione quando ho a che fare con degli ordini
|
|
|
|
|
const TTipo_documento& tipodocin = _main->doc().tipo(tipo_in);
|
|
|
|
|
if (tipodocin.is_ordine())
|
|
|
|
|
reset(F_ANNO_ELAB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!field(F_TIPODOC_ELAB).empty())
|
|
|
|
|
{
|
|
|
|
|
const TString16 tipo(get(F_TIPODOC_ELAB));
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TString80 td; td.format("&&(TIPODOC==\"%s\")", (const char *)tipo);
|
|
|
|
|
filter << td;
|
|
|
|
|
const TString& stato = get(F_STATODOC_ELAB);
|
|
|
|
|
if (stato.not_empty())
|
|
|
|
|
{
|
|
|
|
|
filter << "&&(STATO==\"" << stato << "\")";
|
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool almost_one = FALSE;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < TElaborazione::_max_tipi_doc_elab; i++)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tipo_in(e->tipo_iniziale(i));
|
|
|
|
|
const char stato_in = e->stato_iniziale(i);
|
|
|
|
|
|
|
|
|
|
if (tipo == tipo_in && stato_in > '0')
|
|
|
|
|
{
|
|
|
|
|
if (almost_one)
|
|
|
|
|
filter << "||";
|
|
|
|
|
else
|
|
|
|
|
filter << "&&(";
|
|
|
|
|
almost_one = TRUE;
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
filter << "(STATO==\"" << stato_in << "\")";
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (almost_one)
|
|
|
|
|
filter << ')';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool almost_one = FALSE;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < TElaborazione::_max_tipi_doc_elab; i++)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tipo_in(e->tipo_iniziale(i));
|
|
|
|
|
if (tipo_in.not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (almost_one)
|
|
|
|
|
filter << "||";
|
|
|
|
|
else
|
|
|
|
|
filter << "&&(";
|
|
|
|
|
almost_one = TRUE;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
filter << "((TIPODOC==\"" << tipo_in << "\")";
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
const char stato_in[2] = { e->stato_iniziale(i), '\0' };
|
|
|
|
|
if (stato_in[0] > '0')
|
|
|
|
|
filter << "&&(STATO==\"" << stato_in << "\")";
|
1998-11-04 18:04:26 +00:00
|
|
|
|
filter << ')';
|
2003-02-26 15:23:59 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
if (almost_one)
|
|
|
|
|
filter << ')';
|
2003-02-26 15:23:59 +00:00
|
|
|
|
}
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2002-05-31 10:35:40 +00:00
|
|
|
|
{
|
|
|
|
|
const TString16 tipo_fin(e->tipo_finale());
|
|
|
|
|
const TString16 stato_fin(e->stato_finale());
|
|
|
|
|
|
|
|
|
|
filter << "&&";
|
|
|
|
|
if (stato_fin != "0")
|
|
|
|
|
filter << '(';
|
|
|
|
|
filter << "(TIPODOC==\"" << tipo_fin << "\")";
|
|
|
|
|
if (stato_fin != "0")
|
|
|
|
|
filter << "&&(STATO==\"" << stato_fin << "\"))";
|
|
|
|
|
|
1998-11-04 18:04:26 +00:00
|
|
|
|
if (is_tipo_elaborazione)
|
|
|
|
|
{
|
|
|
|
|
const TString16 num_fin(e->codice_numerazione_finale());
|
|
|
|
|
set(F_CODNUM_ELAB, num_fin);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
field(F_CODNUM_ELAB).check();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
set(F_TIPODOC_ELAB, tipo_fin);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
field(F_TIPODOC_ELAB).check();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
set(F_STATODOC_ELAB, stato_fin);
|
1999-07-16 14:59:11 +00:00
|
|
|
|
field(F_STATODOC_ELAB).check();
|
1998-11-04 18:04:26 +00:00
|
|
|
|
}
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
1999-10-22 10:00:18 +00:00
|
|
|
|
}
|
2003-02-25 14:39:02 +00:00
|
|
|
|
|
|
|
|
|
if (!field(F_CODNUM_ELAB).empty())
|
|
|
|
|
{
|
|
|
|
|
TString80 cn; cn.format("&&(CODNUM==\"%s\")", (const char*)get(F_CODNUM_ELAB));
|
|
|
|
|
filter << cn;
|
|
|
|
|
}
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
|
|
|
|
TBrowse& brew = *efield(F_NDOC_ELAB).browse();
|
|
|
|
|
brew.set_filter(filter);
|
|
|
|
|
|
|
|
|
|
_art_filter = get(F_CODART);
|
2002-05-31 10:35:40 +00:00
|
|
|
|
|
|
|
|
|
TCursor* cursor = brew.cursor();
|
2003-02-25 14:39:02 +00:00
|
|
|
|
if (_art_filter.not_empty() && aggiungi_doc_att)
|
2002-05-31 10:35:40 +00:00
|
|
|
|
cursor->set_filterfunction(article_filter);
|
1999-10-22 10:00:18 +00:00
|
|
|
|
else
|
2002-05-31 10:35:40 +00:00
|
|
|
|
cursor->set_filterfunction(NULL);
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TTree_field& tf = tfield(F_ROWS);
|
2003-02-25 14:39:02 +00:00
|
|
|
|
if (!field(F_TIPODOC_ELAB).empty() && e != NULL)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
2002-05-31 10:35:40 +00:00
|
|
|
|
tf.set_tree(&_tree);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
TToken_string header(256, '\n');
|
|
|
|
|
header.add("Anno Num. N. Data Cli/For Ragione Sociale");
|
|
|
|
|
header.add(" Codice Articolo Descrizione Riga ");
|
|
|
|
|
if (e->tipo() == _consegna_ordini)
|
|
|
|
|
header << "Da Evadere Residuo";
|
|
|
|
|
else
|
|
|
|
|
header << " Quantit<69>";
|
|
|
|
|
tf.set_header(header);
|
|
|
|
|
|
2003-02-25 14:39:02 +00:00
|
|
|
|
if (aggiungi_doc_att && _art_filter.not_empty())
|
2002-05-31 10:35:40 +00:00
|
|
|
|
_tree.set_cursor(get(F_TIPOCF_ELAB)[0], get_long(F_CODCF_ELAB), get_int(F_ANNO_ELAB), filter, article_filter);
|
|
|
|
|
else
|
|
|
|
|
_tree.set_cursor(get(F_TIPOCF_ELAB)[0], get_long(F_CODCF_ELAB), get_int(F_ANNO_ELAB), filter);
|
2002-07-02 16:21:23 +00:00
|
|
|
|
|
|
|
|
|
TCursor& cur = *_tree.get_cursor();
|
|
|
|
|
if (cur.items() == 1) // Propone l'unico documento possibile
|
|
|
|
|
{
|
|
|
|
|
cur = 0L;
|
|
|
|
|
const TRectype& curr = cur.curr();
|
|
|
|
|
set(F_NDOC_ELAB, curr.get(DOC_NDOC));
|
|
|
|
|
set(F_DATADOC_ELAB, curr.get(DOC_DATADOC));
|
|
|
|
|
}
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
2002-05-31 10:35:40 +00:00
|
|
|
|
else
|
|
|
|
|
tf.set_tree(NULL);
|
|
|
|
|
tf.win().force_update();
|
1999-10-22 10:00:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
void TElabora_mask::docrif_search()
|
2000-05-05 15:25:49 +00:00
|
|
|
|
{
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TRectype filtrec(LF_DOC);
|
|
|
|
|
filtrec.put(DOC_TIPOCF, get(F_TIPOCF_ELAB));
|
|
|
|
|
filtrec.put(DOC_CODCF, get(F_CODCF_ELAB));
|
|
|
|
|
filtrec.put(DOC_PROVV, get(F_PROVV_ELAB));
|
|
|
|
|
filtrec.put(DOC_ANNO, get(F_ANNO_ELAB));
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TRelation rel(LF_DOC);
|
|
|
|
|
rel.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF");
|
|
|
|
|
TSorted_cursor cur(&rel, "TIPOCF|CODCF|PROVV|ANNO|CODNUM|NUMDOCRIF", "", 2, &filtrec, &filtrec);
|
|
|
|
|
TString flt(256);
|
|
|
|
|
if (!field(F_CODNUM_ELAB).empty())
|
|
|
|
|
flt << "(CODNUM==\"" << get(F_CODNUM_ELAB) << "\")&&";
|
|
|
|
|
if (!field(F_TIPODOC_ELAB).empty())
|
|
|
|
|
flt << "(TIPODOC==\"" << get(F_TIPODOC_ELAB) << "\")&&";
|
|
|
|
|
if (!field(F_STATODOC_ELAB).empty())
|
|
|
|
|
flt << "(STATO==\"" << get(F_STATODOC_ELAB) << "\")&&";
|
|
|
|
|
add_valuta_filter(flt); flt << "&&";
|
|
|
|
|
TEdit_field& f = efield(F_NUMDOCRIF_ELAB);
|
|
|
|
|
if (!f.empty())
|
|
|
|
|
flt << "(NUMDOCRIF==\"" << f.get() << "\")&&";
|
|
|
|
|
flt.rtrim(2); // Togli gli ultimi &&
|
|
|
|
|
|
|
|
|
|
cur.setfilter(flt);
|
|
|
|
|
|
|
|
|
|
TToken_string fields = "ANNO|CODNUM|TIPODOC|NUMDOCRIF|STATO|DATADOCRIF|DOC1|DOC2|DOC3|NDOC|20->RAGSOC";
|
|
|
|
|
TCursor_sheet sheet(&cur, fields,
|
|
|
|
|
"Documento di riferimento",
|
|
|
|
|
"Anno|Num.|Tipo|Docum.Rif.|Stato|Data@10|Docum.Rif.1|Docum.Rif.2|Docum.Rif.3|Documento|Ragione Sociale@50",
|
|
|
|
|
0, 1);
|
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
const int nrifpos = fields.get_pos("NUMDOCRIF");
|
|
|
|
|
const TString16 nrif = sheet.row(-1).get(nrifpos);
|
|
|
|
|
f.set(nrif);
|
|
|
|
|
const int ndocpos = fields.get_pos("NDOC");
|
|
|
|
|
const TString16 ndoc = sheet.row(-1).get(ndocpos);
|
|
|
|
|
set(F_NDOC_ELAB, ndoc);
|
|
|
|
|
const int codnumpos = fields.get_pos("CODNUM");
|
|
|
|
|
const TString16 codnum = sheet.row(-1).get(codnumpos);
|
|
|
|
|
set(F_CODNUM_ELAB, codnum, TRUE);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TElabora_mask::TElabora_mask(TDocumento_mask& main_mask)
|
2003-02-25 14:39:02 +00:00
|
|
|
|
: TAutomask("ve0100b"), _main(&main_mask), _last_elab(NULL)
|
1999-10-22 10:00:18 +00:00
|
|
|
|
{
|
|
|
|
|
_myself = this;
|
2003-01-28 13:33:45 +00:00
|
|
|
|
|
|
|
|
|
set(F_ANNO_ELAB, _main->get(F_ANNO));
|
1998-11-04 18:04:26 +00:00
|
|
|
|
set(F_TIPOCF_ELAB, _main->get(F_TIPOCF));
|
|
|
|
|
set(F_CODCF_ELAB, _main->get(F_CODCF));
|
2000-10-03 13:45:12 +00:00
|
|
|
|
set(F_CODVAL_ELAB, _main->get(F_CODVAL));
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::elabora_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)f.mask();
|
2001-05-02 13:40:49 +00:00
|
|
|
|
m.update_progs();
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (m.check_fields()) // Check values
|
|
|
|
|
{
|
2002-05-31 10:35:40 +00:00
|
|
|
|
TElabora_mask* selection = new TElabora_mask(m); // No woman no stack
|
1999-07-16 14:59:11 +00:00
|
|
|
|
bool update_mask = FALSE;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
const char stato_iniziale = m.doc().stato();
|
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
|
while (selection->run() != K_ESC)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
{
|
|
|
|
|
m.mask2doc();
|
1999-07-16 14:59:11 +00:00
|
|
|
|
update_mask |= selection->elabora();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
if (m.doc().stato() != stato_iniziale)
|
|
|
|
|
break;
|
|
|
|
|
if (update_mask)
|
|
|
|
|
{
|
|
|
|
|
m.doc2mask(FALSE);
|
|
|
|
|
TSheet_field& ss = m.sfield(F_SHEET);
|
|
|
|
|
for (int i = 0; i < ss.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
m.ss_notify(ss,i,K_TAB);
|
|
|
|
|
m.ss_notify(ss,i,K_SPACE);
|
|
|
|
|
m.ss_notify(ss,i,K_ENTER);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
1999-07-16 14:59:11 +00:00
|
|
|
|
if (update_mask)
|
2000-05-05 15:25:49 +00:00
|
|
|
|
{
|
1999-10-22 10:00:18 +00:00
|
|
|
|
m.doc2mask(FALSE);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
// Provoca decodifiche necessarie
|
|
|
|
|
const int last = m.id2pos(BASE_PIEDE + 1);
|
|
|
|
|
for (int p = 0; p < last; p++)
|
|
|
|
|
{
|
|
|
|
|
TMask_field& f = m.fld(p);
|
|
|
|
|
f.check(STARTING_CHECK);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
delete selection;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-31 10:35:40 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TDocumento_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
bool TDocumento_mask::print_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2001-05-02 13:40:49 +00:00
|
|
|
|
if (key == K_SPACE)
|
1998-08-25 18:07:30 +00:00
|
|
|
|
main_app().print();
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TDocumento_mask::user_set_handler(int fieldid, int index)
|
|
|
|
|
{
|
|
|
|
|
switch( index )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
set_handler( fieldid, ora_hndl );
|
|
|
|
|
break;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
case 2:
|
|
|
|
|
set_handler( fieldid, totdoc_hndl );
|
|
|
|
|
break;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
case 3:
|
2001-05-02 13:40:49 +00:00
|
|
|
|
set_handler( fieldid, numdocrif_hndl );
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
1998-08-25 18:07:30 +00:00
|
|
|
|
set_handler( fieldid, dummy_hndl );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
CHECK( FALSE, "Tentativo di installare un handler non definito" );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::num_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.to_check(key, TRUE))
|
|
|
|
|
{
|
|
|
|
|
// Ottengo la maschera
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)f.mask( );
|
|
|
|
|
|
|
|
|
|
TTable & tabnum = ((TTable &) ((TEdit_field &)f).browse()->cursor()->file());
|
|
|
|
|
if ( tabnum.good())
|
|
|
|
|
{
|
|
|
|
|
TCodice_numerazione cod_num(tabnum.curr());
|
|
|
|
|
m.set( F_DESNUM, cod_num.descrizione());
|
|
|
|
|
// Propone il primo tipo di documento come default
|
2001-05-02 13:40:49 +00:00
|
|
|
|
if (m.field(F_TIPODOC).empty() || f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
m.set( F_TIPODOC, cod_num.tipo_doc(0));
|
|
|
|
|
m.send_key( K_TAB, F_TIPODOC );
|
|
|
|
|
}
|
1999-10-22 10:00:18 +00:00
|
|
|
|
// Se per questa numerazione e' abilitata le numerazione provvisoria
|
1998-08-25 18:07:30 +00:00
|
|
|
|
if (cod_num.num_provv())
|
|
|
|
|
{
|
|
|
|
|
// Setta di default la numerazione provvisoria
|
|
|
|
|
m.set( F_PROVV, "P" );
|
|
|
|
|
// Abilita il campo per la selezione della numerazione
|
|
|
|
|
m.enable( F_PROVV );
|
|
|
|
|
}
|
|
|
|
|
else // Altrimenti ...
|
|
|
|
|
{
|
|
|
|
|
// Setta la numerazione a definitiva
|
|
|
|
|
m.set( F_PROVV, "D" );
|
|
|
|
|
// Disabilita il campo per la selezione della numerazione
|
|
|
|
|
m.disable( F_PROVV );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m.set( F_DESNUM, "" );
|
|
|
|
|
m.set( F_TIPODOC, "" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::tip_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)f.mask( );
|
|
|
|
|
if ( key == K_TAB && m.is_running() && m.get(F_TIPODOC).not_empty())
|
|
|
|
|
{
|
|
|
|
|
TCodice_numerazione cod_num(m.get(F_CODNUM));
|
|
|
|
|
const TString& tipo = f.get();
|
|
|
|
|
int last = cod_num.ntipi_doc();
|
|
|
|
|
for (int i = 0; i < last; i++ )
|
|
|
|
|
{
|
|
|
|
|
const TString16 curtipo(cod_num.tipo_doc(i));
|
|
|
|
|
if (curtipo == tipo)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return f.error_box( "Tipo non valido per la numerazione selezionata!" );
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::codlist_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile & list = ((TEdit_field &) f).browse()->cursor()->file();
|
|
|
|
|
const TDate datadoc(f.mask().get(F_DATADOC));
|
|
|
|
|
const TDate datascad(list.get_date("VALFIN"));
|
|
|
|
|
|
|
|
|
|
if (datascad.ok() && datadoc > datascad)
|
|
|
|
|
{
|
|
|
|
|
const TString16 codsucc(list.get("CODLISSUCC"));
|
|
|
|
|
|
|
|
|
|
if (codsucc.empty())
|
|
|
|
|
return error_box("Listino scaduto il %s", datascad.string());
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
f.set(codsucc);
|
|
|
|
|
f.set_focusdirty();
|
|
|
|
|
((TEdit_field &)f).check();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::codcont_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile & cont = ((TEdit_field &) f).browse()->cursor()->file();
|
|
|
|
|
const TDate datadoc(f.mask().get(F_DATADOC));
|
|
|
|
|
const TDate datascad(cont.get_date("VALFIN"));
|
|
|
|
|
|
|
|
|
|
if (datascad.ok() && datadoc > datascad)
|
|
|
|
|
return error_box("Contratto scaduto il %s", datascad.string());
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TDocumento_mask::codcamp_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile & camp = ((TEdit_field &) f).browse()->cursor()->file();
|
|
|
|
|
const TDate datadoc(f.mask().get(F_DATADOC));
|
|
|
|
|
const TDate datascad(camp.get_date("VALFIN"));
|
|
|
|
|
|
|
|
|
|
if (datascad.ok() && datadoc > datascad)
|
|
|
|
|
return error_box("Offerta scaduta il %s", datascad.string());
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
2003-01-28 13:33:45 +00:00
|
|
|
|
/*
|
|
|
|
|
bool TDocumento_mask::controeuro_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TMask & m = f.mask();
|
|
|
|
|
|
|
|
|
|
if (m.is_running() && key == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
const real cambio_euro = TCurrency::get_euro_change();
|
|
|
|
|
const real val = cambio_euro / m.get_real(F_CAMBIO);
|
|
|
|
|
|
|
|
|
|
m.set(F_CAMBIO, val);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
*/
|
2003-02-25 14:39:02 +00:00
|
|
|
|
bool TDocumento_mask::datacambio_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.mask().get(F_CAMBIO).empty())
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rec = cache().get("%VAL", f.mask().get(F_CODVAL1));
|
|
|
|
|
real c = rec.get_real("S4");
|
|
|
|
|
f.mask().set(F_CAMBIO, c);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-01-28 13:33:45 +00:00
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
bool TDocumento_mask::codval_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
2003-01-28 13:33:45 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
|
|
// Cerco un cambio per la data specificata, se non lo trovo lo invento
|
|
|
|
|
TDate datacam = m.get(F_DATACAMBIO);
|
|
|
|
|
if (!datacam.ok())
|
|
|
|
|
{
|
|
|
|
|
datacam = m.get_date(F_DATADOC);
|
|
|
|
|
m.set(F_DATACAMBIO, datacam);
|
|
|
|
|
}
|
|
|
|
|
TExchange exc(f.get());
|
|
|
|
|
exchange_type et;
|
|
|
|
|
real cambio = exc.get_change(et); // Determino il cambio standard ed il "Contro-Euro"
|
|
|
|
|
TString16 key;
|
|
|
|
|
key.format("%-3s", (const char*)f.get()); key << datacam.string(ANSI);
|
|
|
|
|
const real giornaliero = cache().get("CAM", key, "S4");
|
|
|
|
|
if (!giornaliero.is_zero())
|
|
|
|
|
cambio = giornaliero; // Ho trovato un cambio per il giorno!
|
|
|
|
|
m.set(F_CAMBIO, cambio);
|
|
|
|
|
m.set(F_CONTROEURO, et == _exchange_contro ? "X" : "");
|
|
|
|
|
|
|
|
|
|
TSheet_field& righe = m.sfield(F_SHEET);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
righe.force_update();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2003-02-05 14:26:24 +00:00
|
|
|
|
}
|