Modificata la gestione delle attivazioni/utenti tramite spreadsheet

con moduli in ordine alfabetico.


git-svn-id: svn://10.65.10.50/trunk@2918 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-05-28 09:39:05 +00:00
parent c4d66791b0
commit 45da7bd5cd
7 changed files with 435 additions and 555 deletions

View File

@ -1,6 +1,7 @@
#define F_USER 101 #define F_USER 101
#define F_PASSWORD 102 #define F_PASSWORD 102
#define F_USERDESC 103 #define F_USERDESC 103
#define F_MODULI 104
#define F_BASE 200 #define F_BASE 200
#define F_74 201 #define F_74 201
#define F_75 202 #define F_75 202
@ -36,3 +37,7 @@
#define F_EF 234 #define F_EF 234
#define F_DB 235 #define F_DB 235
#define F_SP 236 #define F_SP 236
#define F_NOMEMOD 101
#define F_ENABLE 102
#define F_CODE 103

View File

@ -3,14 +3,17 @@
#include <modaut.h> #include <modaut.h>
#include <prefix.h> #include <prefix.h>
#include <utility.h> #include <utility.h>
#include <msksheet.h>
#include "ba1.h" #include "ba1.h"
#include "ba1500.h"
#include "ba0100a.h" #include "ba0100a.h"
class TSet_users : public TRelation_application class TSet_users : public TRelation_application
{ {
TMask* _msk; TMask* _msk;
TRelation* _rel; TRelation* _rel;
TInformazione_moduli* _im;
virtual bool user_create(); virtual bool user_create();
virtual bool user_destroy(); virtual bool user_destroy();
@ -18,15 +21,18 @@ class TSet_users : public TRelation_application
virtual bool changing_mask(int mode) { return FALSE;} virtual bool changing_mask(int mode) { return FALSE;}
virtual TRelation* get_relation() const { return _rel;} virtual TRelation* get_relation() const { return _rel;}
virtual int read(TMask& m); virtual int read(TMask& m);
void put_in_record(const TMask& m);
virtual int write(const TMask& m); virtual int write(const TMask& m);
virtual int rewrite(const TMask& m); virtual int rewrite(const TMask& m);
void enable_aut(TMask& m); void enable_aut(TMask& m);
static bool user_handler(TMask_field& f, KEY key); static bool user_handler(TMask_field& f, KEY key);
static bool password_handler(TMask_field& f, KEY key); static bool password_handler(TMask_field& f, KEY key);
static bool k_notify(TSheet_field & f, int r, KEY k);
virtual void init_query_mode(TMask& m) { enable_aut(m);} virtual void init_query_mode(TMask& m) { enable_aut(m);}
virtual void init_insert_mode(TMask& m) { enable_aut(m);} virtual void init_insert_mode(TMask& m) { build_sheet(m,NULL); enable_aut(m);}
virtual void init_modify_mode(TMask& m) { enable_aut(m);} virtual void init_modify_mode(TMask& m) { enable_aut(m);}
TSheet_field& sheet_field() { return (TSheet_field&) _msk->field(F_MODULI);}
void build_sheet(TMask& m, const TRelation* r);
public: public:
TSet_users() : _msk(NULL), _rel(NULL) {} TSet_users() : _msk(NULL), _rel(NULL) {}
@ -53,35 +59,73 @@ bool TSet_users::password_handler(TMask_field& f, KEY key)
return ok; return ok;
} }
void TSet_users::build_sheet(TMask& m, const TRelation* r)
{
TString autstr;
TSheet_field& sf = sheet_field();
if (r != NULL)
autstr = r->lfile().get("AUTSTR");
const int l = autstr.len();
sf.destroy();
for (int i = 0; i < ENDAUT; i++)
{
TString d( _im->get_description_by_order(i));
if (d.trim().empty()) continue;
TToken_string& riga = sf.row(i);
riga = d;
const int module = _im->get_module_by_order(i);
if (r!= NULL && module<l && autstr[module]=='X')
riga.add("X");
else riga.add(" ");
riga.add(module);
}
}
void TSet_users::enable_aut(TMask& m) void TSet_users::enable_aut(TMask& m)
{ {
const bool prassi = (m.get(F_USER) == "PRASSI"); const bool prassi = (m.get(F_USER) == "PRASSI");
const int uns = _im->unassigned();
for (int i = 1; i < ENDAUT; i++) TSheet_field& sf = sheet_field();
const int itms = sf.items();
for (int i = 0; i < itms; i++)
{ {
if (i == MUAUT) continue; const int module = _im->get_module_by_order(i+uns);
const int pos = _msk->id2pos(F_BASE + i); TToken_string& riga = sf.row(i);
if (pos >= 0) if (module == BAAUT || module == MUAUT)
{ {
TMask_field& f = m.fld(pos); sf.disable_cell(i,1);
riga.add("X",1);
f.enable_default(); }
if (f.enabled()) else
f.enable(!prassi && has_module(i, CHK_DONGLE)); {
if (prassi) f.set("X"); sf.enable_cell(i,1,!prassi && has_module(module, CHK_DONGLE));
if (prassi) riga.add("X",1);
} }
} }
} }
bool TSet_users::k_notify(TSheet_field& f, int r, KEY k)
{
if (k == K_INS)
return FALSE;
return TRUE;
}
bool TSet_users::user_create() bool TSet_users::user_create()
{ {
if (user() != "PRASSI") if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma"); return error_box("Utente non abilitato all'uso di questo programma");
_msk = new TMask("ba1400a") ; _msk = new TMask("ba1400a") ;
_rel = new TRelation(LF_USER); _rel = new TRelation(LF_USER);
_msk->field(F_MU).disable();
_msk->set_handler(F_USER, user_handler); _msk->set_handler(F_USER, user_handler);
_msk->set_handler(F_PASSWORD, password_handler); _msk->set_handler(F_PASSWORD, password_handler);
TSheet_field& sf = sheet_field();
sf.set_notify(k_notify);
_im = new TInformazione_moduli;
return TRUE; return TRUE;
} }
@ -90,28 +134,45 @@ int TSet_users::read(TMask& m)
{ {
TRelation_application::read(m); TRelation_application::read(m);
const TRelation *r = get_relation(); const TRelation *r = get_relation();
build_sheet(m,r);
m.set(F_PASSWORD, decode(r->lfile().get("PASSWORD"))); m.set(F_PASSWORD, decode(r->lfile().get("PASSWORD")));
return NOERR; return NOERR;
} }
void TSet_users::put_in_record(const TMask& m)
{
TRelation *r = get_relation();
TString16 s(encode(m.get(F_PASSWORD)));
TString autstr(ENDAUT);
TSheet_field& sf = sheet_field();
const int itms = sf.items();
autstr.fill(' ');
for (int i=0; i<itms; i++)
{
TToken_string& riga = sf.row(i);
const int module = atoi(riga.get(2));
const char c = riga.get(1)[0];
if ( c == 'X')
autstr[module] = c;
}
r->lfile().put("AUTSTR", (const char *) autstr);
r->lfile().put("PASSWORD", (const char *) s);
}
int TSet_users::write(const TMask& m) int TSet_users::write(const TMask& m)
{ {
TRelation *r = get_relation(); put_in_record(m);
TString16 s(encode(m.get(F_PASSWORD)));
r->lfile().put("PASSWORD", (const char *) s);
return TRelation_application::write(m); return TRelation_application::write(m);
} }
int TSet_users::rewrite(const TMask& m) int TSet_users::rewrite(const TMask& m)
{ {
TRelation *r = get_relation(); put_in_record(m);
TString16 s(encode(m.get(F_PASSWORD)));
r->lfile().put("PASSWORD", s);
return TRelation_application::rewrite(m); return TRelation_application::rewrite(m);
} }
@ -120,6 +181,7 @@ bool TSet_users::user_destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
if (_rel != NULL) delete _rel; if (_rel != NULL) delete _rel;
if (_im != NULL) delete _im;
return TRUE; return TRUE;
} }

View File

@ -6,11 +6,6 @@ ENDPAGE
PAGE "Gestione moduli" -1 -1 35 7 PAGE "Gestione moduli" -1 -1 35 7
GROUPBOX DLG_NULL 78 15
BEGIN
PROMPT 0 4 "Moduli"
END
STRING F_USER 8 STRING F_USER 8
BEGIN BEGIN
PROMPT 1 1 "Utente " PROMPT 1 1 "Utente "
@ -31,245 +26,53 @@ STRING F_USERDESC 50
BEGIN BEGIN
PROMPT 1 2 "Descrizione " PROMPT 1 2 "Descrizione "
FIELD USERDESC FIELD USERDESC
MESSAGE "X",F_BASE
END END
STRING F_PASSWORD 8 STRING F_PASSWORD 8
BEGIN BEGIN
PROMPT 1 3 "Password " PROMPT 1 3 "Password "
HELP "Inserire la password" HELP "Inserire la password"
MESSAGE "X",F_BASE
MESSAGE "X",F_MU
END END
BOOLEAN F_BASE SPREADSHEET F_MODULI 78
BEGIN BEGIN
PROMPT 1 5 "Base" PROMPT 0 5 "Moduli"
FLAGS "D" ITEM "Modulo@40"
FIELD AUTSTR[1,1] ITEM "Abilitato@C"
END ITEM "Codice"
END
BOOLEAN F_74
BEGIN ENDPAGE
PROMPT 31 5 "Modello 740"
FIELD AUTSTR[2,2] ENDMASK
END
PAGE "Campo" -1 -1 60 11
BOOLEAN F_75
BEGIN STRING F_NOMEMOD 40
PROMPT 59 5 "Modello 750" BEGIN
FIELD AUTSTR[3,3] PROMPT 1 3 "Modulo "
END FLAGS "D"
END
BOOLEAN F_76
BEGIN BOOLEAN F_ENABLE
PROMPT 1 6 "Modello 760" BEGIN
FIELD AUTSTR[4,4] PROMPT 11 5 "Abilitato "
END END
BOOLEAN F_77 NUMBER F_CODE 3
BEGIN BEGIN
PROMPT 31 6 "Modello 770" PROMPT 1 7 "Codice "
FIELD AUTSTR[5,5] FLAGS "D"
END END
BOOLEAN F_GI BUTTON DLG_OK 9 2
BEGIN BEGIN
PROMPT 59 6 "Gestione IVA" PROMPT -12 -1 ""
FIELD AUTSTR[6,6] END
END
BUTTON DLG_CANCEL 9 2
BOOLEAN F_SE BEGIN
BEGIN PROMPT -22 -1 ""
PROMPT 1 7 "Cont.Semplificata"
FIELD AUTSTR[7,7]
END
BOOLEAN F_CG
BEGIN
PROMPT 31 7 "Contabilita'"
FIELD AUTSTR[8,8]
END
BOOLEAN F_ST
BEGIN
PROMPT 59 7 "Gestione Studi"
FIELD AUTSTR[9,9]
END
BOOLEAN F_MI
BEGIN
PROMPT 1 8 "Modello IVA 11"
FIELD AUTSTR[10,10]
END
BOOLEAN F_AI
BEGIN
PROMPT 31 8 "Archiviazione immagini"
FIELD AUTSTR[11,11]
FLAGS "D"
END
BOOLEAN F_CE
BEGIN
PROMPT 59 8 "Cespiti"
FIELD AUTSTR[12,12]
END
BOOLEAN F_AD
BEGIN
PROMPT 1 9 "Anagrafici dichar."
FIELD AUTSTR[13,13]
END
BOOLEAN F_SC
BEGIN
PROMPT 31 9 "Saldaconto"
FIELD AUTSTR[14,14]
END
BOOLEAN F_MU
BEGIN
PROMPT 59 9 "Multiutenza"
FIELD AUTSTR[15,15]
END
BOOLEAN F_CM
BEGIN
PROMPT 1 10 "Gestione Commesse"
FIELD AUTSTR[16,16]
END
BOOLEAN F_73
BEGIN
PROMPT 31 10 "Modello 730"
FIELD AUTSTR[17,17]
END
BOOLEAN F_AT
BEGIN
PROMPT 59 10 "AVIS Assist"
FIELD AUTSTR[18,18]
END
BOOLEAN F_IN
BEGIN
PROMPT 1 11 "Elenchi Intrac."
FIELD AUTSTR[19,19]
END
BOOLEAN F_PO
BEGIN
PROMPT 31 11 "Modulo Penna Ottica"
FIELD AUTSTR[20,20]
FLAGS "D"
END
BOOLEAN F_AB
BEGIN
PROMPT 59 11 "Analisi bil."
FIELD AUTSTR[21,21]
END
BOOLEAN F_NI
BEGIN
PROMPT 1 12 "Nota Integrativa"
FIELD AUTSTR[22,22]
END
BOOLEAN F_NR
BEGIN
PROMPT 31 12 "Nota Integrativa Rid."
FIELD AUTSTR[23,23]
END
BOOLEAN F_PC
BEGIN
PROMPT 59 12 "Parcellazione"
FIELD AUTSTR[24,24]
END
BOOLEAN F_AF
BEGIN
PROMPT 1 13 "Autoformazione"
FIELD AUTSTR[25,25]
FLAGS "D"
END
BOOLEAN F_IC
BEGIN
PROMPT 31 13 "Gestione ICI"
FIELD AUTSTR[26,26]
END
BOOLEAN F_IS
BEGIN
PROMPT 59 13 "Gestione ISI"
FIELD AUTSTR[27,27]
END
BOOLEAN F_TC
BEGIN
PROMPT 1 14 "Tecnico Contabile"
FIELD AUTSTR[28,28]
FLAGS "D"
END
BOOLEAN F_TM
BEGIN
PROMPT 31 14 "Tecnico App.Merci"
FIELD AUTSTR[29,29]
FLAGS "D"
END
BOOLEAN DLG_NULL
BEGIN
PROMPT 59 14 ""
FIELD AUTSTR[30,30]
FLAGS "D"
END
BOOLEAN DLG_NULL
BEGIN
PROMPT 1 15 ""
FIELD AUTSTR[31,31]
FLAGS "D"
END
BOOLEAN F_VE
BEGIN
PROMPT 31 15 "Vendite"
FIELD AUTSTR[32,32]
END
BOOLEAN F_MG
BEGIN
PROMPT 59 15 "Magazzino"
FIELD AUTSTR[33,33]
END
BOOLEAN F_OR
BEGIN
PROMPT 1 16 "Ordini"
FIELD AUTSTR[34,34]
END
BOOLEAN F_EF
BEGIN
PROMPT 31 16 "Gestione effetti"
FIELD AUTSTR[35,35]
END
BOOLEAN F_DB
BEGIN
PROMPT 59 16 "Distinta Base"
FIELD AUTSTR[36,36]
END
BOOLEAN F_SP
BEGIN
PROMPT 1 17 "Statistiche e Provvigioni"
FIELD AUTSTR[38,38]
END END
ENDPAGE ENDPAGE

View File

@ -1,7 +1,7 @@
#include <applicat.h> #include <applicat.h>
#include <date.h> #include <date.h>
#include <modaut.h> #include <modaut.h>
#include <mask.h> #include <msksheet.h>
#include <prefix.h> #include <prefix.h>
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
@ -9,22 +9,98 @@
#include <extcdecl.h> #include <extcdecl.h>
#include "ba1.h" #include "ba1.h"
#include "ba0100a.h" #include "ba1500.h"
#include "ba1500a.h" #include "ba1500a.h"
#define USERADR 26952 #define USERADR 26952
#define AGAADR 26953 #define AGAADR 26953
#define PRASSIADR 26954 #define PRASSIADR 26954
#define PROCOMADR 26956
#define K1 0x4500 #define K1 0x4500
#define LBYTEMASK 0x00FF #define LBYTEMASK 0x00FF
#define UBYTEMASK 0xFF00 #define UBYTEMASK 0xFF00
#define MAXAUT 49 #define MAXAUT 49
enum KeyType { _user_key, _aga_key, _prassi_key}; enum KeyType { _user_key, _aga_key, _prassi_key, _procom_key};
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0) #define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
#define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) #define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p)))))
TInformazione_moduli::TInformazione_moduli()
{
int mod = 0;
char _buffer[256];
TString s;
TToken_string t;
_unassigned_modules = 0;
ifstream in("prassi.aut");
while (!in.eof() && in.good())
{
in.getline(_buffer, sizeof(_buffer),'\n');
s = _buffer;
s.trim();
if (s.empty()) break;
const int l = s.len();
if (l > 2)
{
t = format("%-40s",(const char*)s.right(l-3));
t.add(s.left(2));
}
else
{
t = " "; t.add(" ");
_unassigned_modules++;
}
t.add(mod++);
_infos.add(t);
}
if (in.bad() && !in.eof())
error_box("Si e' verificato un errore leggendo il file di descrizione moduli.");
_infos.sort();
for (int i=0;i<mod;i++)
{
TToken_string& riga = _infos.row(i);
_index[atoi(riga.get(2))] = i;
}
}
const char * TInformazione_moduli::get_description_by_order(int index)
{
if (index>=0 && index<ENDAUT)
return _infos.row(index).get(0);
else
return "";
}
const char * TInformazione_moduli::get_name_by_order(int index)
{
if (index>=0 && index<ENDAUT)
return _infos.row(index).get(1);
else
return "";
}
int TInformazione_moduli::get_module_by_order(int index)
{
if (index>=0 && index<ENDAUT)
return atoi(_infos.row(index).get(2));
else
return -1;
}
const char * TInformazione_moduli::get_description(int module)
{ return get_description_by_order(_index[module]); }
const char * TInformazione_moduli::get_name(int module)
{ return get_name_by_order(_index[module]); }
int TInformazione_moduli::get_index(int module)
{ return _index[module]; }
class TError_application : public TApplication class TError_application : public TApplication
{ {
TString _errmess; TString _errmess;
@ -38,6 +114,7 @@ class TError_application : public TApplication
class TAttivazione_moduli : public TApplication class TAttivazione_moduli : public TApplication
{ {
TMask* _msk; TMask* _msk;
TInformazione_moduli* _im;
KeyType _key_type; KeyType _key_type;
word _serno; word _serno;
@ -49,10 +126,13 @@ class TAttivazione_moduli : public TApplication
virtual bool menu(MENU_TAG); virtual bool menu(MENU_TAG);
void generate_key(); void generate_key();
int build_sheet(bool on = TRUE);
static void keyext(const TString & s, word * v); static void keyext(const TString & s, word * v);
static bool user_hnd(TMask_field & f, KEY k); static bool user_hnd(TMask_field & f, KEY k);
static void encode_second_key();
static bool decode_hnd(TMask_field & f, KEY k); static bool decode_hnd(TMask_field & f, KEY k);
static bool activate_hnd(TMask_field & f, KEY k); static bool activate_hnd(TMask_field & f, KEY k);
static bool k_notify(TSheet_field & f, int r, KEY k);
public: public:
TAttivazione_moduli() : _msk(NULL) { _key_type = _user_key;} TAttivazione_moduli() : _msk(NULL) { _key_type = _user_key;}
@ -61,6 +141,26 @@ public:
HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli &)main_app(); } HIDDEN TAttivazione_moduli& app() { return (TAttivazione_moduli &)main_app(); }
int TAttivazione_moduli::build_sheet(bool on)
{
int nmod = 0;
TSheet_field& sf = (TSheet_field&) _msk->field(F_MODULI);
for (int i = 0; i < ENDAUT; i++)
{
TString d( _im->get_description_by_order(i));
if (d.trim().empty()) continue;
TToken_string& riga = sf.row(i);
riga = d;
const int module = _im->get_module_by_order(i);
if (has_module(module, CHK_DONGLE) && on || module==0)
{
riga.add("X");
if (module != 0) nmod++;
} else riga.add(" ");
riga.add(module);
}
return nmod;
}
void TAttivazione_moduli::generate_key() void TAttivazione_moduli::generate_key()
{ {
@ -82,20 +182,10 @@ void TAttivazione_moduli::generate_key()
HL_READ(51, &ud[3]); HL_READ(51, &ud[3]);
#endif #endif
int nmod = 0; int nmod;
_msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3])); _msk->set(F_K2, format("%04X%04X%04X%04X", ud[0], ud[1], ud[2], ud[3]));
for (int i = 1; i < MAXAUT; i++) nmod = build_sheet();
{
const int pos = _msk->id2pos(F_BASE + i);
if (pos >= 0 && has_module(i, CHK_DONGLE))
{
_msk->fld(pos).set("X");
nmod++;
}
}
_serno = SerNo; _serno = SerNo;
ud[0] = _serno; ud[0] = _serno;
ud[1] = K1 | (nmod & LBYTEMASK); ud[1] = K1 | (nmod & LBYTEMASK);
@ -180,13 +270,14 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k)
for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno; for (int i = 0; i < 4; i++) ud2[i] ^= app()._serno;
if (ud2[3] != 0) if (ud2[3] != 0)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
for (i = 1; i < MAXAUT; i++) TSheet_field& sf = (TSheet_field&) m.field(F_MODULI);
const int un = app()._im->unassigned();
for (i = un; i < ENDAUT; i++)
{ {
const int af = i - 1; const int af = app()._im->get_module_by_order(i) - 1;
const int pos = m.id2pos(F_BASE + i); if (af < 0) continue;
TToken_string& tt = sf.row(i-un);
if (pos >= 0) tt.add(BITTEST(ud2[af / 16], af % 16) ? "X" : " ", 1);
m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " ");
} }
if (k == K_ENTER) if (k == K_ENTER)
{ {
@ -207,10 +298,54 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k)
HL_WRITE(50, ud2[2]); HL_WRITE(50, ud2[2]);
HL_WRITE(51, ud2[3]); HL_WRITE(51, ud2[3]);
#endif #endif
} } else
sf.force_update();
return TRUE; return TRUE;
} }
void TAttivazione_moduli::encode_second_key()
{
TMask * m = app()._msk;
word ud1[4], ud2[4], port = app()._port;
int nmod = 0;
for (int i = 0; i < 4; i++) ud2[i] = 0;
TSheet_field& sf = (TSheet_field&) m->field(F_MODULI);
const int un = app()._im->unassigned();
for (i = un; i < ENDAUT; i++)
{
const int af = app()._im->get_module_by_order(i) -1;
if (af < 0) continue;
TToken_string& tt = sf.row(i-un);
if (tt.get(1)[0] == 'X')
{
BITSET(ud2[af / 16], af % 16, TRUE);
nmod++;
}
}
for (i = 0; i < 4; i++) ud2[i] ^= app()._serno;
const TDate d(m->get(F_DT));
long & l = (long &) ud1[0];
l = d.year()*10000L + d.month()*100L + d.day();
ud1[2] = K1 | (nmod & UBYTEMASK);
ud1[3] = app()._serno;
#if XVT_OS == XVT_OS_SCOUNIX
INT_OFF();
HL_ON(port, ModAd);
K_EYE(port, (unsigned char *) ud1, HLBLOCK);
K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port);
INT_ON();
#else
HL_CODE(EYECAST ud1, HLBLOCK);
HL_CODE(EYECAST ud2, HLBLOCK);
#endif
m->set(F_K4, format("%04X%04X%04X%04X", ud2[0], ud2[1], ud2[2], ud2[3]));
m->set(F_K3, format("%04X%04X%04X%04X", ud1[0], ud1[1], ud1[2], ud1[3]));
}
bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k)
{ {
const TString16 k2(f.get()); const TString16 k2(f.get());
@ -249,56 +384,32 @@ bool TAttivazione_moduli::decode_hnd(TMask_field & f, KEY k)
return f.error_box("secondo codice errato"); return f.error_box("secondo codice errato");
m.set(F_SN, app()._serno); m.set(F_SN, app()._serno);
m.set(F_DT, d.string()); m.set(F_DT, d.string());
for (i = 1; i < MAXAUT; i++) m.set(F_K3,k1);
m.set(F_K4,k2);
TSheet_field& sf = (TSheet_field&) m.field(F_MODULI);
const int un = app()._im->unassigned();
for (i = un; i < ENDAUT; i++)
{ {
const int af = i - 1; const int af = app()._im->get_module_by_order(i) -1;
const int pos = m.id2pos(F_BASE + i); if (af < 0) continue;
TToken_string& tt = sf.row(i-un);
if (pos >= 0) tt.add(BITTEST(ud2[af / 16], af % 16) ? "X" : " ", 1);
m.fld(pos).set(BITTEST(ud2[af / 16], af % 16) ? "X" : " ");
} }
encode_second_key();
sf.force_update();
return TRUE; return TRUE;
} }
bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k) bool TAttivazione_moduli::activate_hnd(TMask_field & f, KEY k)
{ {
TMask & m = f.mask(); encode_second_key();
word ud1[4], ud2[4], port = app()._port; return TRUE;
int nmod = 0;
for (int i = 0; i < 4; i++) ud2[i] = 0;
for (i = 1; i < MAXAUT; i++)
{
const int af = i - 1;
const int pos = m.id2pos(F_BASE + i);
if (pos >= 0 && m.get_bool(F_BASE + i))
{
BITSET(ud2[af / 16], af % 16, TRUE);
nmod++;
} }
}
for (i = 0; i < 4; i++) ud2[i] ^= app()._serno;
const TDate d(m.get(F_DT)); bool TAttivazione_moduli::k_notify(TSheet_field& f, int r, KEY k)
long & l = (long &) ud1[0]; {
if (k == K_INS)
l = d.year()*10000L + d.month()*100L + d.day(); return FALSE;
ud1[2] = K1 | (nmod & UBYTEMASK);
ud1[3] = app()._serno;
#if XVT_OS == XVT_OS_SCOUNIX
INT_OFF();
HL_ON(port, ModAd);
K_EYE(port, (unsigned char *) ud1, HLBLOCK);
K_EYE(port, (unsigned char *) ud2, HLBLOCK);
HL_OFF(port);
INT_ON();
#else
HL_CODE(EYECAST ud1, HLBLOCK);
HL_CODE(EYECAST ud2, HLBLOCK);
#endif
m.set(F_K4, format("%04X%04X%04X%04X", ud2[0], ud2[1], ud2[2], ud2[3]));
m.set(F_K3, format("%04X%04X%04X%04X", ud1[0], ud1[1], ud1[2], ud1[3]));
return TRUE; return TRUE;
} }
@ -307,6 +418,8 @@ bool TAttivazione_moduli::create()
if (user() != "PRASSI") if (user() != "PRASSI")
return error_box("Utente non abilitato all'uso di questo programma"); return error_box("Utente non abilitato all'uso di questo programma");
_im = new TInformazione_moduli;
disable_menu_item(M_FILE_NEW); disable_menu_item(M_FILE_NEW);
disable_menu_item(M_FILE_REVERT); disable_menu_item(M_FILE_REVERT);
disable_menu_item(M_FILE_PG_SETUP); disable_menu_item(M_FILE_PG_SETUP);
@ -318,6 +431,9 @@ bool TAttivazione_moduli::create()
else else
if (Hl_Port(PRASSIADR) != 0) if (Hl_Port(PRASSIADR) != 0)
_key_type = _prassi_key; _key_type = _prassi_key;
else
if (Hl_Port(PROCOMADR) != 0)
_key_type = _prcom_key;
_port = Hl_Port(USERADR); _port = Hl_Port(USERADR);
#else #else
HL_LOGOUT(); HL_LOGOUT();
@ -328,10 +444,19 @@ bool TAttivazione_moduli::create()
HL_LOGOUT(); HL_LOGOUT();
if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK) if (HL_LOGIN(PRASSIADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_key_type = _prassi_key; _key_type = _prassi_key;
else
{
HL_LOGOUT();
if (HL_LOGIN(PROCOMADR, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
_key_type = _procom_key;
}
} }
HL_LOGOUT(); HL_LOGOUT();
HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY); HL_LOGIN(USERADR, DONT_CARE, REFKEY, VERKEY);
#endif #endif
TSheet_field& sf = (TSheet_field&) _msk->field(F_MODULI);
const int un = _im->unassigned();
sf.set_notify(k_notify);
switch (_key_type) switch (_key_type)
{ {
@ -341,40 +466,47 @@ bool TAttivazione_moduli::create()
_msk->disable(F_K2); _msk->disable(F_K2);
_msk->set_handler(F_K4, user_hnd); _msk->set_handler(F_K4, user_hnd);
generate_key(); generate_key();
for (int i = 1; i < ENDAUT; i++) const int nm = sf.items();
{ for (int i = 0; i < nm; i++)
const int pos = _msk->id2pos(F_BASE + i); sf.disable_cell(i,1);
if (pos >= 0) _msk->fld(pos).disable();
}
} }
break; break;
case _prassi_key: case _prassi_key:
_msk->disable(F_CM); sf.disable_cell(_im->get_index(CMAUT)-un,1);
_msk->disable(F_AT); sf.disable_cell(_im->get_index(ATAUT)-un,1);
_msk->disable(F_PO); sf.disable_cell(_im->get_index(POAUT)-un,1);
_msk->disable(F_AF); sf.disable_cell(_im->get_index(AFAUT)-un,1);
_msk->disable(F_TC); sf.disable_cell(_im->get_index(TCAUT)-un,1);
_msk->disable(F_TM); sf.disable_cell(_im->get_index(TMAUT)-un,1);
_msk->disable(F_VE); sf.disable_cell(_im->get_index(VEAUT)-un,1);
_msk->disable(F_MG); sf.disable_cell(_im->get_index(MGAUT)-un,1);
_msk->disable(F_OR); sf.disable_cell(_im->get_index(ORAUT)-un,1);
_msk->disable(F_EF); sf.disable_cell(_im->get_index(EFAUT)-un,1);
_msk->disable(F_DB); sf.disable_cell(_im->get_index(DBAUT)-un,1);
_msk->disable(F_SP); sf.disable_cell(_im->get_index(SPAUT)-un,1);
case _aga_key: case _aga_key:
case _procom_key:
{ {
_msk->set_handler(F_K2, decode_hnd); _msk->set_handler(F_K2, decode_hnd);
_msk->disable(F_K3); _msk->disable(F_K3);
_msk->disable(F_K4); _msk->disable(F_K4);
for (int i = 1; i < MAXAUT; i++) sf.sheet_mask().field(F_ENABLE).set_handler(activate_hnd);
build_sheet(FALSE);
for (int i = un; i < ENDAUT; i++)
{ {
const int pos = _msk->id2pos(F_BASE + i); const int af = _im->get_module_by_order(i);
const int index = i-un;
if (pos >= 0) if (af == 0)
_msk->set_handler(F_BASE + i, activate_hnd); sf.disable_cell(index,1);
if (_key_type == _procom_key)
sf.enable_cell(index,1,af>=40 && af<=46);
else
if (af>=40 && af<=46)
sf.disable_cell(index,1);
} }
} }
break; break;
default: default:
break; break;
} }
@ -385,6 +517,7 @@ return TRUE;
bool TAttivazione_moduli::destroy() bool TAttivazione_moduli::destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
if (_im != NULL) delete _im;
return TRUE; return TRUE;
} }

23
ba/ba1500.h Executable file
View File

@ -0,0 +1,23 @@
#ifndef __STRINGS_H
#include <strings.h>
#endif
class TInformazione_moduli : public TObject
{
TString_array _infos;
int _index[ENDAUT];
int _unassigned_modules; // Moduli non assegnati, con descrizione vuota
public:
const char * get_description_by_order(int index);
const char * get_name_by_order(int index);
int get_module_by_order(int index);
const char * get_description(int module);
const char * get_name(int module);
int get_index(int module);
int unassigned() { return _unassigned_modules; }
TInformazione_moduli() ;
~TInformazione_moduli() {};
};

View File

@ -1,6 +1,17 @@
#define F_K1 101 #define F_K1 101
#define F_K2 102 #define F_K2 102
#define F_K3 103 #define F_K2A 103
#define F_K4 104 #define F_K2B 104
#define F_SN 105 #define F_K2C 105
#define F_DT 106 #define F_K3 106
#define F_K4 107
#define F_K4A 108
#define F_K4B 109
#define F_K4C 110
#define F_SN 111
#define F_DT 112
#define F_MODULI 113
#define F_NOMEMOD 101
#define F_ENABLE 102
#define F_CODE 103

View File

@ -1,14 +1,13 @@
#include "ba0100a.h"
#include "ba1500a.h" #include "ba1500a.h"
TOOLBAR "" 0 20 0 2 TOOLBAR "" 0 20 0 2
BUTTON DLG_OK 9 2 BUTTON DLG_OK 10 2
BEGIN BEGIN
PROMPT -12 -1 "" PROMPT -12 -1 ""
END END
BUTTON DLG_CANCEL 9 2 BUTTON DLG_CANCEL 10 2
BEGIN BEGIN
PROMPT -22 -1 "" PROMPT -22 -1 ""
END END
@ -17,16 +16,10 @@ ENDPAGE
PAGE "Attivazione Moduli" -1 -1 79 21 PAGE "Attivazione Moduli" -1 -1 79 21
GROUPBOX DLG_NULL 78 15
BEGIN
PROMPT 0 4 "Moduli"
END
STRING F_K1 16 STRING F_K1 16
BEGIN BEGIN
PROMPT 1 1 "Attivazione 1 " PROMPT 1 1 "Attivazione 1 "
FLAGS "U" FLAGS "U"
MESSAGE "X",F_BASE
END END
STRING F_K2 16 STRING F_K2 16
@ -41,211 +34,61 @@ BEGIN
FLAGS "ZD" FLAGS "ZD"
END END
STRING F_K3 16
BEGIN
PROMPT 1 2 "Attivazione 2 "
FLAGS "U"
MESSAGE "X",F_BASE
END
STRING F_K4 16
BEGIN
PROMPT 35 2 ""
FLAGS "U"
END
DATE F_DT DATE F_DT
BEGIN BEGIN
PROMPT 56 2 "Data " PROMPT 56 2 "Data "
FLAGS "D" FLAGS "D"
END END
BOOLEAN F_BASE STRING F_K3 16
BEGIN BEGIN
PROMPT 1 5 "Base" PROMPT 1 3 "Attivazione 2 "
FLAGS "U"
END
STRING F_K4 16
BEGIN
PROMPT 35 3 ""
FLAGS "U"
END
SPREADSHEET F_MODULI 78
BEGIN
PROMPT 0 5 "Moduli"
ITEM "Modulo@40"
ITEM "Abilitato@C"
ITEM "Codice"
END
ENDPAGE
ENDMASK
PAGE "Campo" -1 -1 60 11
STRING F_NOMEMOD 40
BEGIN
PROMPT 1 3 "Modulo "
FLAGS "D" FLAGS "D"
END END
BOOLEAN F_74 BOOLEAN F_ENABLE
BEGIN BEGIN
PROMPT 31 5 "Modello 740" PROMPT 11 5 "Abilitato "
END END
BOOLEAN F_75 NUMBER F_CODE 3
BEGIN BEGIN
PROMPT 59 5 "Modello 750" PROMPT 1 7 "Codice "
END
BOOLEAN F_76
BEGIN
PROMPT 1 6 "Modello 760"
END
BOOLEAN F_77
BEGIN
PROMPT 31 6 "Modello 770"
END
BOOLEAN F_GI
BEGIN
PROMPT 59 6 "Gestione IVA"
END
BOOLEAN F_SE
BEGIN
PROMPT 1 7 "Cont.Semplificata"
END
BOOLEAN F_CG
BEGIN
PROMPT 31 7 "Contabilita'"
END
BOOLEAN F_ST
BEGIN
PROMPT 59 7 "Gestione Studi"
END
BOOLEAN F_MI
BEGIN
PROMPT 1 8 "Modello IVA 11"
END
BOOLEAN F_AI
BEGIN
PROMPT 31 8 "Archviazione Immagini"
END
BOOLEAN F_CE
BEGIN
PROMPT 59 8 "Cespiti"
END
BOOLEAN F_AD
BEGIN
PROMPT 1 9 "Anagrafici dichar."
END
BOOLEAN F_SC
BEGIN
PROMPT 31 9 "Saldaconto"
END
BOOLEAN F_MU
BEGIN
PROMPT 59 9 "Multiutenza"
END
BOOLEAN F_CM
BEGIN
PROMPT 1 10 "Commesse"
END
BOOLEAN F_73
BEGIN
PROMPT 31 10 "Modello 730"
END
BOOLEAN F_AT
BEGIN
PROMPT 59 10 "AVIS Assist"
END
BOOLEAN F_IN
BEGIN
PROMPT 1 11 "Elenchi Intrac."
END
BOOLEAN F_PO
BEGIN
PROMPT 31 11 "Penna Ottica"
END
BOOLEAN F_AB
BEGIN
PROMPT 59 11 "Analisi bil."
END
BOOLEAN F_NI
BEGIN
PROMPT 1 12 "Nota Integrativa"
END
BOOLEAN F_NR
BEGIN
PROMPT 31 12 "Nota Integrativa Rid."
END
BOOLEAN F_PC
BEGIN
PROMPT 59 12 "Parcellazione"
END
BOOLEAN F_AF
BEGIN
PROMPT 1 13 "Autoformazione"
END
BOOLEAN F_IC
BEGIN
PROMPT 31 13 "Gestione ICI"
END
BOOLEAN F_IS
BEGIN
PROMPT 59 13 "Gestione ISI"
END
BOOLEAN F_TC
BEGIN
PROMPT 1 14 "Tecnico Contabile"
END
BOOLEAN F_TM
BEGIN
PROMPT 31 14 "Tecnico App.Merci"
END
BOOLEAN DLG_NULL
BEGIN
PROMPT 59 14 ""
FLAGS "D" FLAGS "D"
END END
BOOLEAN DLG_NULL BUTTON DLG_OK 9 2
BEGIN BEGIN
PROMPT 1 15 "" PROMPT -12 -1 ""
FLAGS "D"
END END
BOOLEAN F_VE BUTTON DLG_CANCEL 9 2
BEGIN BEGIN
PROMPT 31 15 "Vendite" PROMPT -22 -1 ""
END
BOOLEAN F_MG
BEGIN
PROMPT 59 15 "Magazzino"
END
BOOLEAN F_OR
BEGIN
PROMPT 1 16 "Ordini"
END
BOOLEAN F_EF
BEGIN
PROMPT 31 16 "Gestione effetti"
END
BOOLEAN F_DB
BEGIN
PROMPT 59 16 "Distinta Base"
END
BOOLEAN F_SP
BEGIN
PROMPT 1 17 "Statistiche e Provvigioni"
END END
ENDPAGE ENDPAGE