2007-06-21 14:20:08 +00:00
|
|
|
#include "ve2400.h"
|
|
|
|
#include "ve2401.h"
|
|
|
|
|
|
|
|
#include <automask.h>
|
|
|
|
#include <diction.h>
|
|
|
|
#include <recarray.h>
|
|
|
|
#include <recset.h>
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Utility per gestione struttura codice avanzato
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const TString& root_code()
|
|
|
|
{
|
|
|
|
static TString4 _root_code;
|
|
|
|
if (_root_code.empty())
|
|
|
|
{
|
2007-06-26 09:56:34 +00:00
|
|
|
const TString query = "USE FSA SELECT B0=\"X\"";
|
2007-06-21 14:20:08 +00:00
|
|
|
TISAM_recordset set(query);
|
|
|
|
if (set.move_first())
|
|
|
|
_root_code = set.get("CODTAB").as_string();
|
|
|
|
else
|
|
|
|
_root_code = " "; // Evito riletture inutili
|
2007-06-26 09:56:34 +00:00
|
|
|
|
2007-06-21 14:20:08 +00:00
|
|
|
}
|
|
|
|
return _root_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const TRectype& get_sublevel_info(const TString& code)
|
|
|
|
{
|
|
|
|
return cache().get("FSA", code.full() ? code : root_code());
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Maschera dianamica per inserimento codici
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TCodart_mask : public TAutomask
|
|
|
|
{
|
2007-06-26 11:06:18 +00:00
|
|
|
static TString4 _restart;
|
|
|
|
|
2007-06-21 14:20:08 +00:00
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
void create_level(int level, const TString& subcode);
|
2007-06-26 11:06:18 +00:00
|
|
|
void build_children();
|
2007-06-21 14:20:08 +00:00
|
|
|
|
|
|
|
public:
|
2007-06-26 11:06:18 +00:00
|
|
|
bool restart() const { return _restart.full(); }
|
|
|
|
|
2007-06-21 14:20:08 +00:00
|
|
|
TCodart_mask();
|
|
|
|
};
|
|
|
|
|
2007-06-26 11:06:18 +00:00
|
|
|
TString4 TCodart_mask::_restart;
|
|
|
|
|
2007-06-21 14:20:08 +00:00
|
|
|
bool TCodart_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
switch (o.dlg())
|
|
|
|
{
|
|
|
|
case 101:
|
2007-06-26 11:06:18 +00:00
|
|
|
if (e == fe_init && restart())
|
|
|
|
{
|
|
|
|
o.set(_restart);
|
|
|
|
_restart.cut(0);
|
|
|
|
o.check(STARTING_CHECK);
|
|
|
|
e = fe_modify;
|
|
|
|
}
|
|
|
|
if (e == fe_modify) // Se cambio il contenuto del primo livello ...
|
|
|
|
{
|
|
|
|
if (id2pos(102) < 0)
|
|
|
|
build_children(); // Ricostruisco la maschera
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_restart = o.get();
|
|
|
|
stop_run(K_FORCE_CLOSE);
|
|
|
|
}
|
|
|
|
}
|
2007-06-21 14:20:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TCodart_mask::create_level(int level, const TString& subcode)
|
|
|
|
{
|
|
|
|
const TRectype& fsa = get_sublevel_info(subcode);
|
|
|
|
if (!fsa.empty())
|
|
|
|
{
|
|
|
|
const TString4 code = fsa.get("CODTAB"); // Puo' essere diverso da subcode!
|
2007-06-26 11:06:18 +00:00
|
|
|
TString80 prompt = fsa.get("S0"); prompt.left_just(30);
|
2007-06-21 14:20:08 +00:00
|
|
|
const TString& picture = fsa.get("S1");
|
|
|
|
const int length = picture.len();
|
|
|
|
|
|
|
|
TEdit_field& kfld = add_string(100+level, 0, prompt, 1, level, length, "B");
|
|
|
|
TEdit_field& dfld = add_string(200+level, 0, "", 40, level, 36, "D");
|
|
|
|
|
|
|
|
TFilename tmp; tmp.temp();
|
|
|
|
ofstream out(tmp);
|
|
|
|
|
|
|
|
out << "USE GSA" << endl; //usa la tabella dei sottolivelli articolo
|
|
|
|
|
|
|
|
out << "IN CODTAB[1,3] \"" << code << "\" SELECT" << endl;
|
|
|
|
out << "IN CODTAB[4,0] " << kfld.dlg() << endl;
|
|
|
|
out << "DI \"" << prompt;
|
|
|
|
if (length > prompt.len())
|
|
|
|
out << '@' << length;
|
|
|
|
out << "\" CODTAB[4,0]" << endl;
|
|
|
|
out << "DI \"" << HR("Descrizione") << "@50\" S0" << endl;
|
|
|
|
out << "OU " << kfld.dlg() << " CODTAB[4,0]" << endl;
|
|
|
|
out << "OU " << dfld.dlg() << " S0" << endl;
|
|
|
|
|
|
|
|
out << "CH RE" << endl;
|
|
|
|
out << "EN" << endl;
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
TScanner scan(tmp);
|
|
|
|
while (scan.pop() != "EN")
|
|
|
|
kfld.parse_item(scan);
|
|
|
|
|
|
|
|
xvt_fsys_removefile(tmp);
|
|
|
|
set_handlers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 11:06:18 +00:00
|
|
|
void TCodart_mask::build_children()
|
2007-06-21 14:20:08 +00:00
|
|
|
{
|
|
|
|
TArray& a = fields_array();
|
|
|
|
|
|
|
|
TString8 code = root_code();
|
|
|
|
code << get(101);
|
|
|
|
const TString& children = cache().get("GSA", code, "S1");
|
2007-06-26 11:06:18 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
2007-06-21 14:20:08 +00:00
|
|
|
{
|
|
|
|
const TString& subcode = children.mid(i*3, 3);
|
|
|
|
if (subcode.full())
|
|
|
|
create_level(i+2, subcode);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
TCodart_mask::TCodart_mask() : TAutomask(TR("Articolo guidato"), 1, 78, 13)
|
|
|
|
{
|
|
|
|
add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
|
|
add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
|
|
|
create_level(1, EMPTY_STRING);
|
|
|
|
}
|
|
|
|
|
2007-06-25 15:43:58 +00:00
|
|
|
bool advanced_get_codart(TString& code, TString& desc)
|
2007-06-21 14:20:08 +00:00
|
|
|
{
|
2007-06-26 11:06:18 +00:00
|
|
|
bool ok = false;
|
|
|
|
bool running = true;
|
|
|
|
while (running)
|
2007-06-21 14:20:08 +00:00
|
|
|
{
|
2007-06-26 11:06:18 +00:00
|
|
|
TCodart_mask m;
|
|
|
|
ok = m.run() == K_ENTER;
|
|
|
|
if (ok)
|
2007-06-25 15:43:58 +00:00
|
|
|
{
|
2007-06-26 11:06:18 +00:00
|
|
|
code.cut(0);
|
|
|
|
desc.cut(0);
|
|
|
|
for (short id = 101; m.id2pos(id) >= 0; id++)
|
|
|
|
{
|
|
|
|
code << m.get(id);
|
|
|
|
if (id == 102)
|
|
|
|
desc << ' ';
|
|
|
|
desc << m.get(id+100);
|
|
|
|
}
|
|
|
|
running = false;
|
2007-06-25 15:43:58 +00:00
|
|
|
}
|
2007-06-26 11:06:18 +00:00
|
|
|
else
|
|
|
|
running = m.restart();
|
2007-06-21 14:20:08 +00:00
|
|
|
}
|
2007-06-25 15:43:58 +00:00
|
|
|
return ok;
|
2007-06-21 14:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Essenzialissima interfaccia pubblica
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool advanced_codart_enabled()
|
|
|
|
{
|
|
|
|
return root_code().full();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool advanced_codart_handler(TMask_field& fld, KEY key)
|
|
|
|
{
|
|
|
|
if (key == K_SPACE)
|
|
|
|
{
|
2007-06-25 15:43:58 +00:00
|
|
|
TString code, desc;
|
|
|
|
if (advanced_get_codart(code, desc))
|
|
|
|
{
|
|
|
|
TMask& msk = fld.mask();
|
|
|
|
msk.set(F_DESCR, desc);
|
|
|
|
msk.set(F_CODART, code, true);
|
2007-06-26 11:06:18 +00:00
|
|
|
msk.field(F_CODART).set_focus();
|
2007-06-25 15:43:58 +00:00
|
|
|
}
|
2007-06-21 14:20:08 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|