Patch level : 10.0 526

Files correlati     :  ca0.exe
Ricompilazione Demo : [ ]

Aggiunto il filtro utente anche sul campo albero delle anagrafiche


git-svn-id: svn://10.65.10.50/trunk@19678 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2009-11-29 18:18:41 +00:00
parent 8e78b05d59
commit d515833571
3 changed files with 89 additions and 46 deletions

View File

@ -87,7 +87,7 @@ bool TCdC_app::user_create()
return error_box(TR("I centri di costo non sono stati configurati"));
//eventuali filtri per utente
_has_filter = cache().get("%AUC", user(), "S0").full();
_has_filter = cache().get("%AUC", user(), "S1").full();
return TAnal_app::user_create();
}

View File

@ -98,7 +98,7 @@ bool TFsc_app::user_create()
return error_box(TR("Le fasi non sono state configurate"));
//eventuali filtri per utente
_has_filter = cache().get("%AUC", user(), "S0").full();
_has_filter = cache().get("%AUC", user(), "S2").full();
return TAnal_app::user_create();
}

View File

@ -644,28 +644,38 @@ int ca_create_fields(TMask& msk, int page, int logicnum, int x, int y,
struct TAnal_tree_pos : public TObject
{
TRecnotype _recno;
TRecnotype _pos;
TToken_string _key;
void as_string(TString& id) const;
TRecnotype pos() const { return _pos; }
int level() const { return _key.items(); }
void reset();
void set(const char * key, TRecnotype pos);
};
void TAnal_tree_pos::as_string(TString& id) const
{
id.format("%ld|%s", _recno, (const char*)_key);
id.format("%ld|%s", _pos, (const char*)_key);
}
void TAnal_tree_pos::set(const char * key, TRecnotype pos)
{
_key = key;
_pos = _key.full() ? pos : 0;
}
void TAnal_tree_pos::reset()
{
_recno = 0;
_pos = 0;
_key.cut(0);
}
class TAnal_tree : public TBidirectional_tree
{
TLocalisamfile* _file;
TCursor * _curs;
int _fathfasi;
TAnal_tree_pos _curr;
@ -934,9 +944,8 @@ int TSimple_anal_msk::create_key_fields()
const TToken_string& TAnal_tree::curr_of_file() const
{
const TMultilevel_code_info& mci = ca_multilevel_code_info(_file->num());
const TRectype& rec = _file->curr();
const TMultilevel_code_info& mci = ca_multilevel_code_info(_curs->relation()->lfile().num());
const TRectype& rec = _curs->curr();
TToken_string& k = get_tmp_string();
/* if (_fathfasi > 0)
@ -987,7 +996,7 @@ int TAnal_tree::curr_level() const
int TAnal_tree::max_level() const
{
const TMultilevel_code_info& mci = ca_multilevel_code_info(_file->num());
const TMultilevel_code_info& mci = ca_multilevel_code_info(_curs->relation()->lfile().num());
int ml = mci.levels();
if (_fathfasi > 0)
{
@ -1016,11 +1025,7 @@ const TToken_string& TAnal_tree::father_of_file() const
void TAnal_tree::update_curr()
{
_curr._key = curr_of_file();
if (_curr._key.not_empty())
_curr._recno = _file->recno();
else
_curr.reset();
_curr.set(curr_of_file(), _curs->pos());
}
bool TAnal_tree::repos() const
@ -1028,10 +1033,9 @@ bool TAnal_tree::repos() const
bool ok = false;
if (_curr.level() > 0)
{
if (_file->recno() != _curr._recno)
ok = ((TLocalisamfile*)_file)->readat(_curr._recno) == NOERR;
else
ok = true;
if (_curs->pos() != _curr.pos())
((TCursor&) *_curs) = _curr.pos();
ok = true;
}
return ok;
}
@ -1044,9 +1048,13 @@ void TAnal_tree::node2id(const TObject* node, TString& id) const
bool TAnal_tree::goto_root()
{
const bool ok = _file->first() == NOERR;
if (ok)
bool ok = false;
if (_curs->items() > 0)
{
*_curs = 0L;
update_curr();
ok = true;
}
else
_curr.reset();
return ok;
@ -1057,9 +1065,10 @@ bool TAnal_tree::goto_firstson()
bool ok = _curr.level() < max_level() && repos();
if (ok)
{
ok = _file->next() == NOERR;
ok = _curs->pos() < _curs->items();
if (ok)
{
++(*_curs);
ok = father_of_file() == _curr._key;
if (ok)
update_curr();
@ -1074,15 +1083,17 @@ bool TAnal_tree::goto_rbrother()
if (repos())
{
const TToken_string curr_father = father_of(_curr._key);
while (_file->next() == NOERR)
++(*_curs);
while (ok = _curs->pos() < _curs->items())
{
const int lev = level_of_file();
if (lev > _curr.level())
continue;
const TToken_string& next_father = father_of_file();
ok = next_father == curr_father;
break;
if (lev <= _curr.level())
{
const TToken_string& next_father = father_of_file();
ok = next_father == curr_father;
break;
}
++(*_curs);
}
if (ok)
update_curr();
@ -1093,12 +1104,15 @@ bool TAnal_tree::goto_rbrother()
bool TAnal_tree::goto_node(const TString &id)
{
const TRecnotype rec = atol(id);
const int err = _file->readat(rec);
if (err == NOERR)
if (rec >= 0L && rec < _curs->items())
{
*_curs = rec;
update_curr();
return true;
}
return err == NOERR;
return false;
}
bool TAnal_tree::goto_father()
@ -1107,17 +1121,17 @@ bool TAnal_tree::goto_father()
bool ok = lev > 1;
if (ok)
{
TRectype& rec = _file->curr();
TRectype& rec = _curs->curr();
rec.zero();
const TMultilevel_code_info& mci = ca_multilevel_code_info(_file->num());
const TMultilevel_code_info& mci = ca_multilevel_code_info(_curs->relation()->lfile().num());
for (int i = 0; i < lev-1; i++)
{
const char* val = _curr._key.get(i);
const TFieldref& fld = mci.fieldref(i);
fld.write(val, rec);
}
ok = _file->read() == NOERR;
ok = _curs->read() == NOERR;
if (ok)
update_curr();
}
@ -1130,15 +1144,17 @@ bool TAnal_tree::goto_lbrother()
if (repos())
{
const TString curr_father = father_of(_curr._key);
while (_file->prev() == NOERR)
--(*_curs);
while (ok = _curs->pos() > 0L)
{
const int lev = level_of_file();
if (lev > _curr.level())
continue;
const TString& next_father = father_of_file();
ok = next_father == curr_father;
break;
if (lev <= _curr.level())
{
const TString& next_father = father_of_file();
ok = next_father == curr_father;
break;
}
--(*_curs);
}
if (ok)
update_curr();
@ -1159,10 +1175,10 @@ bool TAnal_tree::get_description(TString& desc) const
const int lev = _curr.level();
if (lev > 0)
{
const TMultilevel_code_info& mci = ca_multilevel_code_info(_file->num());
const TMultilevel_code_info& mci = ca_multilevel_code_info(_curs->relation()->lfile().num());
const TFieldref& fld1 = mci.fieldref(lev-1, 1);
const TFieldref& fld2 = mci.fieldref(0, 2);
const TRectype& rec = _file->curr();
const TRectype& rec = _curs->curr();
desc = fld1.read(rec);
desc << ' ' << fld2.read(rec);
}
@ -1172,7 +1188,34 @@ bool TAnal_tree::get_description(TString& desc) const
TAnal_tree::TAnal_tree(int logicnum)
{
_file = new TLocalisamfile(logicnum);
TString select;
const char* fieldname = NULL;
switch (logicnum)
{
case LF_COMMESSE:
fieldname = "S0";
break;
case LF_CDC:
fieldname = "S1";
break;
case LF_FASI:
fieldname = "S2";
break;
default:
break;
}
if (fieldname != NULL)
{
const TString utente(user());
const TString gruppo(cache().get(LF_USER, utente,"GROUPNAME"));
if (gruppo.full())
select = cache().get("%AUC", gruppo, fieldname);
if (utente.full())
select = cache().get("%AUC", utente, fieldname);
}
_curs = new TCursor(new TRelation(logicnum), select);
_fathfasi = 0;
if (logicnum == LF_FASI)
{
@ -1184,7 +1227,7 @@ TAnal_tree::TAnal_tree(int logicnum)
TAnal_tree::~TAnal_tree()
{
delete _file;
delete _curs;
}