Allineamento file modificati durante la transizione da cvs a svn

git-svn-id: svn://10.65.10.50/branches/R_10_00@22612 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-03-20 13:37:23 +00:00
parent cbe7122e89
commit 4dc843a0a2
37 changed files with 41354 additions and 40622 deletions

View File

@ -512,8 +512,20 @@ void TPrimanota_application::on_firm_change()
TRelation_application::on_firm_change(); // May be useful, who knows?
_lastreg = 0;
if (_rel->lfile().last() == NOERR)
_lastreg = _rel->curr().get_long(MOV_NUMREG); // Init last registration number
TLocalisamfile& m = _rel->lfile();
TWait_cursor hourglass;
int err = m.last();
if (err != _isemptyfile)
{
while (err == _islocked)
{
xvt_sys_sleep(1000);
err = m.last();
}
_lastreg = m.get_long(MOV_NUMREG); // Init last registration number
}
_esercizi.update(); // Init exercises
}
@ -523,7 +535,7 @@ void TPrimanota_application::on_config_change()
TConfig cnf(CONFIG_DITTA, "cg");
_ges_val = cnf.get_bool("GesVal");
_ges_sal = cnf.get_bool("GesSal");
_easy_sal = _ges_sal && cnf.get_bool("EasySal", NULL, -1, false);
_easy_sal = _ges_sal && cnf.get_bool("EasySal", NULL, -1, false) && xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR) > 2101;
_npart_is_prot = cnf.get_bool("RifPro");
_liqdiff = cnf.get_bool("GesLiqDiff");

View File

@ -1122,7 +1122,7 @@ void TPartita::carica_allineamento()
_for_align = cd.get_bool("NrForDx") ? 'R' : 'L';
// Nel nuovo saldaconto si possono rilevare le differenze cambi su pagamenti non a saldo
_diffcam_always = cd.get_bool("EasySal") && cd.get_bool("DiffCamAlways");
_diffcam_always = cd.get_bool("EasySal") && cd.get_bool("DiffCamAlways") && xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR) > 2091;
}
char TPartita::allineamento_richiesto(char tipocf)
@ -2170,7 +2170,7 @@ TPartita* TPartite_array::find(const TBill& clifo, int anno, const char* num, bo
TPartita* TPartite_array::find(const TRectype& r, bool create)
{
TBill zio; zio.get(r);
if (zio.gruppo() == 0)
if (zio.gruppo() == 0 && r.num() == LF_PARTITE)
{
zio.set(r.get_int(PART_GRUPPOCL), r.get_int(PART_CONTOCL),
zio.codclifo(), zio.tipo());

View File

@ -285,7 +285,7 @@ public:
const TBill& conto() const { return _conto; }
int anno() const { return _anno; }
const TString& numero() const { return _num; }
const TString& descrizione() const;
//const TString& descrizione() const;
const char* build_key(TString& key) const;
TImporto importo_speso(long numreg, int numrig, bool valuta, int mode = 0xF) const;

View File

@ -193,16 +193,16 @@ int TEffetto::remove(TLocalisamfile& f)const
// restituisce true se l'effetto si riferisce ad una sola fattura
// ovvero se l'effetto non è raggruppato
bool TEffetto::fatt(long num)
bool TEffetto::fatt() const
{
/* Codice inutile: rimosso il 14/03/2012
TLocalisamfile righe_eff(LF_REFFETTI);
righe_eff.put(REFF_NPROGTR, num);
righe_eff.read();
*/
// prende il numero delle righe dell'effetto
// ovvero di fatture a cui fa riferimento
int items = rows_r();
bool condition = (items == 1);
return condition;
return rows_r() == 1;
}
// restituisce i dati relativi alle fatture a cui si riferisce l'effetto

View File

@ -86,7 +86,7 @@ public:
// setta i campi per la prima chiave del file
void put_key(TRectype& rec,long numeff) const;
// restituisce true se l'effetto si riferisce ad una sola fattura
bool fatt(long num);
bool fatt() const;
// restituisce i dati relativi alle fatture a cui si riferisce l'effetto
TToken_string& dati_fatt(long num, const bool valuta, TToken_string& dati);
// restituisce i dati codnum, ndoc, anno relativi alle fatture a cui si riferisce l'effetto

View File

@ -255,7 +255,7 @@ int TVariazione_distinte::read(TMask& m)
riga.add(cache().get(LF_CLIFO, codice, CLI_RAGSOC));
riga.add(get_ban_desc(eff));
if (eff.fatt(numero))// se l'effetto contiene solo una fattura
if (eff.fatt())// se l'effetto contiene solo una fattura
{ // metto i riferimenti al documento ed al numero di rata
const TRectype& rec_r = eff.row_r(1);
riga.add(rec_r.get(REFF_NFATT));
@ -503,11 +503,11 @@ void TVariazione_distinte::carica_riba(int tipopag, const bool reset)
// se non indico un tipo di effetto prendo il tipo del primo che
// seleziono
const bool to_select = (tipopag == 0) || (tipopag == tipop) ||
((tipopag == 2 || tipopag ==5 || tipopag == 7) &&
(tipop == 2 || tipop ==5 || tipop == 7));
((tipopag == 2 || tipopag == 5 || tipopag == 7) &&
(tipop == 2 || tipop == 5 || tipop == 7));
const char tipo = eff.get_tipo();
TString16 valuta = eff.get(EFF_CODVAL);
const TString4 valuta = eff.get(EFF_CODVAL);
const bool valuta_ok = ::same_values(valuta, codval);
const long numero = eff.get_long(EFF_NPROGTR);
@ -524,7 +524,7 @@ void TVariazione_distinte::carica_riba(int tipopag, const bool reset)
riga.add(cache().get(LF_CLIFO, codice, CLI_RAGSOC));
riga.add(get_ban_desc(eff));
if (eff.fatt(numero))// se l'effetto contiene solo una fattura
if (eff.fatt())// se l'effetto contiene solo una fattura
{ // metto i riferimenti al documento ed al numero di rata
const TRectype& rec_r = eff.row_r(1);
riga.add(rec_r.get(REFF_NFATT));

View File

@ -1,5 +1,7 @@
#include <applicat.h>
#include <msksheet.h>
#include <progind.h>
#include <recset.h>
#include <relation.h>
#include "ef0.h"
@ -25,9 +27,7 @@ protected:
static bool conferma_handler(TMask_field& f, KEY k);
static bool annulla_handler(TMask_field& f, KEY k);
static void elimina();
public:
TEliminazione_effetti() {};
virtual ~TEliminazione_effetti() {};
static void elimina_orfani(const TRectype* from);
};
// restituisce un riferimento all' applicazione
@ -140,6 +140,17 @@ bool TEliminazione_effetti::to_data_handler(TMask_field& f, KEY k)
return TRUE;
}
void TEliminazione_effetti::elimina_orfani(const TRectype* from)
{
TString query = "USE REFFETTI SELECT 31.NPROGTR=0\nJOIN 31 INTO NPROGTR==NPROGTR\n";
if (from && !from->empty())
query << "\nFROM NPROGTR=" << from->get("NPROGTR");
TISAM_recordset orfani(query);
TLocalisamfile& f = orfani.cursor()->file();
for (bool ok = orfani.move_first(); ok; ok = orfani.move_next())
f.remove();
}
// Si effettua l'istanziazione del cursore e si eliminano gli effetti che vi
// appartengono
void TEliminazione_effetti::elimina()
@ -178,27 +189,37 @@ void TEliminazione_effetti::elimina()
default : //cancello tutti gli effetti
break;
}
TCursor cur(rel,filter,key,from,to); // istanzio il cursore
TLocalisamfile& delfile = cur.file();// prendo un riferimento al file
long n = cur.items();// prendo il numero di elementi del cursore
cur.freeze();// congelo lo stato del cursore
for (cur=0; cur.pos() < n; ++cur)// scandisco tutti gli elementi del cursore
const long n = cur.items();// prendo il numero di elementi del cursore
if (n > 0)
{
TEffetto eff(delfile.curr());// istanzio un effetto
eff.remove(delfile); // e lo cancello
if (noyes_box(TR("Si desidera veramente eliminare %ld effetti?"), n))
{
TLocalisamfile& delfile = cur.file();// prendo un riferimento al file
cur.freeze();// congelo lo stato del cursore
TProgind pi(n, main_app().title());
for (cur=0; cur.pos() < n; ++cur)// scandisco tutti gli elementi del cursore
{
if (!pi.addstatus(1))
break;
TEffetto eff(delfile.curr());// istanzio un effetto
eff.remove(delfile); // e lo cancello
}
elimina_orfani(from);
}
}
else
warning_box(TR("Non sono stati selezionati effetti da eliminare"));
}
//Handler per gestire la conferma della cancellazione degli effetti
bool TEliminazione_effetti::conferma_handler(TMask_field& f, KEY k)
{
TMask &m = f.mask();
if (k == K_SPACE)
{
if (yesno_box(TR("Si desidera veramente eliminare gli effetti selezionati")))
elimina();
}
return TRUE;
elimina();
return true;
}
// Handler per gestire la conferma dell'annullamento dei dati
@ -216,7 +237,7 @@ bool TEliminazione_effetti::annulla_handler(TMask_field& f, KEY k)
int ef0400(int argc, char* argv[])
{
TEliminazione_effetti a ;
TEliminazione_effetti a;
a.run(argc, argv, TR("Eliminazione Effetti"));
return 0;
}

View File

@ -75,8 +75,8 @@ BEGIN
DISPLAY "Data scadenza" DATASCAD
OUTPUT F_A_RIBA NPROGTR
// CHECKTYPE NORMAL
NUM_EXPR {#THIS_FIELD>=#F_DA_RIBA}
WARNING "Limite superiore non valido"
NUM_EXPR (#THIS_FIELD==0)||(#THIS_FIELD>=#F_DA_RIBA)
WARNING "Limite superiore non valido"
END
GROUPBOX DLG_NULL 55 3

View File

@ -693,7 +693,7 @@ bool TRiba_form::validate(TForm_item &cf, TToken_string &s)
TEffetto effetto(cursor()->file().curr());// = eff.curr();
long num = effetto.numero();
const bool in_valuta = effetto.in_valuta();
bool condition = (effetto.fatt(num));//TRUE se effetto non raggruppato
bool condition = (effetto.fatt());//TRUE se effetto non raggruppato
TToken_string dati; effetto.dati_fatt(num, in_valuta, dati);
TString in(s.get());
if (in[0]=='!')

View File

@ -505,7 +505,7 @@ void TApplication::run(
bool TApplication::get_version_info(int& year, int& release, int& tag, int& patch)
{
const char* const VERSIONANDPATCH = "Don't cry for me Argentina.2091.10.00.0212.2313";
const char* const VERSIONANDPATCH = "Don't cry for me Argentina.2121.11.00.0000.2132";
TToken_string vep(VERSIONANDPATCH, '.');
year = vep.get_int(1);

View File

@ -1640,7 +1640,7 @@ static void clean_string(TString& str)
{
char* d = str.get_buffer();
for (const char* s = d; *s; s++)
if (isalnum(*s)) *d++ = *s;
if (*s < '\0' || isalnum(*s)) *d++ = *s;
*d = '\0';
str.upper();
}

View File

@ -1561,6 +1561,7 @@ TTreelist_window::TTreelist_window(int x, int y, int dx, int dy, WINDOW parent,
wd->wtype = WC_TREELIST;
wd->v.ctl.ctrl_id = owner->dlg();
wd->v.ctl.font_id = xvtil_default_font();
wd->v.ctl.flags = owner->roman() ? CTL_FLAG_MULTIPLE : 0;
xvt_vobj_get_client_rect(win(), &wd->rct);
wd->ctlcolors = xcc;

View File

@ -1877,22 +1877,16 @@ bool TCondizione_vendita::cerca( int tiporicerca, const char * codriga , const r
_condv.setkey( 1 );
switch( tiporicerca )
{
case A_CONTRATTI:
case A_LISTINI:
{
_condv.put("TIPOCF", "");
_condv.put("CODCF", "");
if( !config_ditta().get_bool("GESLISCV", "ve"))
_condv.put("CATVEN", "");
}
break;
case A_LISTINI:
{
_condv.put("TIPOCF", "");
_condv.put("CODCF", "");
if( !config_ditta().get_bool("GESLISCV", "ve"))
_condv.put("CATVEN", "");
}
break;
case A_OFFERTE:
{
}
break;
default:
break;
}
if( _condv.read() == NOERR )
{
@ -1922,13 +1916,14 @@ bool TCondizione_vendita::cerca( int tiporicerca, const char * codriga , const r
_rcondv.put( "CODRIGA", codriga);
int err = _rcondv.read();
found = (err == NOERR);
if (!found)
if ((err = _rcondv.prev()) == NOERR)
if (_rcondv.get("TIPORIGA")[0] == 'A')
{
const TString cod_found(_rcondv.get("CODRIGA"));
found = cod_found.compare(codriga, cod_found.len()) == 0;
}
if (!found && config_ditta().get_bool("GESLIVART", "mg")) // Per articoli strutturati prova la riga precedente
{
if ((err = _rcondv.prev()) == NOERR && _rcondv.get("TIPORIGA")[0] == 'A')
{
const TString& cod_found(_rcondv.get("CODRIGA"));
found = cod_found.compare(codriga, cod_found.len()) == 0;
}
}
}
break;
case 'R':

View File

@ -3,20 +3,31 @@
#include <applicat.h>
#include <automask.h>
#include <progind.h>
#include <recset.h>
#include <relation.h>
#include <treectrl.h>
#include <mov.h>
class TPareggio_tree : public TObject_tree
{
TPartite_array _games;
protected:
virtual TFieldtypes get_var(const TString& name, TVariant& var) const;
virtual bool marked() const { return rand() % 2 != 0; }
const TPartita& partita(const TRectype& rec) const;
public:
bool init(const TBill& bill, const TString& valuta, bool nc, int stato); // Stato- 1=aperte; 2=chiuse; 0 o 3 = tutte
};
const TPartita& TPareggio_tree::partita(const TRectype& rec) const
{
return ((TPartite_array&)_games).partita(rec);
}
TFieldtypes TPareggio_tree::get_var(const TString& name, TVariant& var) const
{
TFieldtypes ft = _nullfld;
@ -39,12 +50,20 @@ TFieldtypes TPareggio_tree::get_var(const TString& name, TVariant& var) const
}
else
{
if (name == PART_DATADOC)
if (name.starts_with("PART.", true))
{
const TString& fld = name.after(".");
if (rec.num() == LF_SCADENZE)
{
var = rec.get_date(SCAD_DATASCAD);
ft = _datefld;
const int nriga = rec.get_int(SCAD_NRIGA);
const TPartita& game = partita(rec);
var = game.riga(nriga).get(fld);
ft = _alfafld;
}
else
{
var = rec.get(fld);
ft = _alfafld;
}
} else
if (name == "RESIDUO")
@ -55,7 +74,7 @@ TFieldtypes TPareggio_tree::get_var(const TString& name, TVariant& var) const
case LF_SCADENZE:
if (!rec.get_bool(SCAD_PAGATA))
{
const TPartita game(rec);
const TPartita& game = partita(rec);
const TRiga_scadenze& s = game.rata(rec.get_int(SCAD_NRIGA), rec.get_int(SCAD_NRATA));
saldo = s.residuo(true);
}
@ -63,7 +82,7 @@ TFieldtypes TPareggio_tree::get_var(const TString& name, TVariant& var) const
case LF_PARTITE:
if (!rec.get_bool(PART_CHIUSA))
{
const TPartita game(rec);
const TPartita& game = partita(rec);
saldo = game.calcola_saldo(true);
}
break;
@ -113,8 +132,12 @@ bool TPareggio_tree::init(const TBill& bill, const TString& valuta, bool nc, int
int last_year = 0;
TString80 id_year, id_rec;
TProgind pi(games.items(), nc ? TR("Caricamento note di credito") : TR("Caricamento fatture"));
for (bool ok = games.move_first(); ok; ok = games.move_next())
{
if (!pi.addstatus(1))
break;
const TString& codval = rec.get(PART_CODVAL);
if (!same_values(codval, valuta))
continue;
@ -124,14 +147,22 @@ bool TPareggio_tree::init(const TBill& bill, const TString& valuta, bool nc, int
if (nc)
{
add_riga = !rec.get_bool(PART_CHIUSA);
// Se filtro le note di credito cerco di riconoscere le fatture negative
if (add_riga && tm == tm_fattura)
if (add_riga)
{
const char sezione_positiva = bill.tipo() == 'C' ? 'D' : 'A';
TImporto importo(rec.get_char(PART_SEZ), rec.get_real(PART_IMPORTO));
importo.normalize();
if (sezione_positiva == importo.sezione()) // Controlla se fattura positiva o negativa
add_riga = false; // Ignora fattura positiva
// Se filtro le note di credito cerco di riconoscere le fatture negative
if (tm == tm_fattura)
{
const char sezione_positiva = bill.tipo() == 'C' ? 'D' : 'A';
TImporto importo(rec.get_char(PART_SEZ), rec.get_real(PART_IMPORTO));
importo.normalize();
add_riga = sezione_positiva != importo.sezione(); // Ignora fattura positiva
}
else
{
const int nriga = rec.get_int(PART_NRIGA);
const TPartita& game = partita(rec);
add_riga = ((TPartita&)game).unassigned().exist(nriga);
}
}
}
else
@ -144,6 +175,13 @@ bool TPareggio_tree::init(const TBill& bill, const TString& valuta, bool nc, int
else
add_riga = stato == 1;
}
if (add_riga)
{
const char sezione_positiva = bill.tipo() == 'C' ? 'D' : 'A';
TImporto importo(rec.get_char(PART_SEZ), rec.get_real(PART_IMPORTO));
importo.normalize();
add_riga = sezione_positiva == importo.sezione(); // Ignora fattura negativa
}
}
if (!add_riga)
@ -213,8 +251,7 @@ bool TPareggio_tree::init(const TBill& bill, const TString& valuta, bool nc, int
class TPareggio_mask : public TAutomask
{
TPareggio_tree _nc, _ft;
private:
long _numreg;
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
@ -245,6 +282,29 @@ bool TPareggio_mask::on_field_event(TOperable_field& o, TField_event e, long jol
tfield(F_NC_TREE).set_tree(&_nc);
tfield(F_FT_TREE).set_tree(&_ft);
_numreg = 0;
disable(DLG_LINK);
}
break;
case F_NC_TREE:
case F_FT_TREE:
if (e == fe_button || e == fe_modify)
{
TTree_field& tf = (TTree_field&)o;
TVariant var;
if (tf.tree()->get_var("PART.NREG", var))
_numreg = var.as_int();
else
_numreg = 0L;
enable(DLG_LINK, _numreg > 0);
}
break;
case DLG_LINK:
if (_numreg > 0)
{
TRectype mov(LF_MOV); mov.put(MOV_NUMREG, _numreg);
if (mov.edit())
send_key(K_SPACE, F_TUTTE, &o);
}
break;
default: break;
@ -252,7 +312,7 @@ bool TPareggio_mask::on_field_event(TOperable_field& o, TField_event e, long jol
return true;
}
TPareggio_mask::TPareggio_mask() : TAutomask("sc0300a")
TPareggio_mask::TPareggio_mask() : TAutomask("sc0300a"), _numreg(0L)
{
RCT rct_nc; field(F_NC_TREE).get_rect(rct_nc);
RCT rct_ft; field(F_FT_TREE).get_rect(rct_ft);
@ -272,14 +332,18 @@ class TPareggio_partite : public TSkeleton_application
{
protected:
virtual void main_loop();
public:
};
void TPareggio_partite::main_loop()
{
TPareggio_mask pm;
pm.run();
const int anno = xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR);
if (anno > 2101)
{
TPareggio_mask pm;
pm.run();
}
else
error_box(TR("Versione non supportata: %d"), anno);
}
///////////////////////////////////////////////////////////

View File

@ -8,10 +8,10 @@ BEGIN
PICTURE TOOL_EDIT
END
BUTTON DLG_NEWREC 2 2
BUTTON DLG_LINK 2 2
BEGIN
PROMPT 2 1 "Nuovo"
PICTURE TOOL_NEWREC
PROMPT 2 1 "Collega"
PICTURE TOOL_LINK
END
#include <helpbar.h>
@ -172,9 +172,10 @@ BEGIN
PROMPT 0 5 ""
DISPLAY "Partita@12" NUMPART
DISPLAY "Riga@4R" NRIGA
DISPLAY "Data@8" DATADOC
DISPLAY "Importo@10R" IMPORTO
DISPLAY "Residuo@10R" RESIDUO
DISPLAY "Descrizione Nota di Credito@35" DESCR
DISPLAY "Descrizione Nota di Credito@35" PART.DESCR
DISPLAY "P.N.@6R" NREG
END
@ -184,11 +185,12 @@ BEGIN
DISPLAY "Partita@12" NUMPART
DISPLAY "Riga@4R" NRIGA
DISPLAY "Rata@4R" NRATA
DISPLAY "Data@8" DATADOC
DISPLAY "Scadenza@8" DATASCAD
DISPLAY "Importo@10R" IMPORTO
DISPLAY "Residuo@10R" RESIDUO
DISPLAY "Descrizione Fattura@35" DESCR
DISPLAY "P.N.@6R" NREG
DISPLAY "Descrizione Fattura@35" PART.DESCR
DISPLAY "P.N.@6R" PART.NREG
FLAGS "M"
END
ENDMASK

View File

@ -5,6 +5,147 @@
#include <wx/hashset.h>
#include <wx/textfile.h>
#include <wx/arrstr.h>
#include <wx/dynarray.h>
///////////////////////////////////////////////////////////
// Utilities
///////////////////////////////////////////////////////////
static wxString BuildKey(const wxSocketBase& sock, const wxChar* user, int session)
{
wxIPV4address peer; sock.GetPeer(peer);
wxString strUserAtHost;
if (user && *user)
strUserAtHost.Printf("%s@%s:%d", user, peer.Hostname().c_str(), session);
else
strUserAtHost.Printf("*@%s:%d", user, peer.Hostname().c_str(), session);
return strUserAtHost;
}
///////////////////////////////////////////////////////////
// TModuleInfo
///////////////////////////////////////////////////////////
class TModuleInfo : public wxObject
{
size_t m_nModule, m_nMaxUsers;
wxArrayString m_Users;
public:
bool CanAddUser(const wxString& strUserAtHost) const;
bool AddUser(const wxString& strUserAtHost);
bool RemoveUser(const wxString& strUserAtHost);
size_t Users() const { return m_Users.GetCount(); }
size_t MaxUsers() const { return m_nMaxUsers; }
TModuleInfo(size_t nMod, size_t nMax) : m_nModule(nMod), m_nMaxUsers(nMax) { }
};
bool TModuleInfo::CanAddUser(const wxString& strUserAtHost) const
{
// Posso aggiungere un utente se ho licenze disponibili o se è già connesso
return Users() < MaxUsers() || m_Users.Index(strUserAtHost, false) >= 0;
}
bool TModuleInfo::AddUser(const wxString& strUserAtHost)
{
wxASSERT(strUserAtHost.Index('@') > 0);
const bool ok = CanAddUser(strUserAtHost);
if (ok && m_Users.Index(strUserAtHost, false) < 0)
m_Users.Add(strUserAtHost);
return ok;
}
bool TModuleInfo::RemoveUser(const wxString& strUserAtHost)
{
wxASSERT(strUserAtHost.Index('@') > 0);
bool ok = false;
if (strUserAtHost.StartsWith("*@"))
{
const wxString strHost = strUserAtHost.Mid(2);
for (int i = m_Users.GetCount()-1; i >= 0; i--)
{
const wxString& h = m_Users[i].AfterFirst('@');
if (h == strHost)
{
m_Users.RemoveAt(i);
ok = true;
}
}
}
else
{
const int i = m_Users.Index(strUserAtHost, false);
ok = i >= 0;
if (ok)
m_Users.RemoveAt(i);
}
return ok;
}
WX_DECLARE_OBJARRAY(TModuleInfo*, TModulesArray);
class TModuleTable : public TModulesArray
{
public:
bool AddConnection(wxSocketBase& sock, const wxChar* user, int session, size_t module);
bool RemoveConnection(wxSocketBase& sock, const wxChar* user, int session, size_t module);
bool KillSession(wxSocketBase& sock, int session) { return RemoveConnection(sock, NULL, session, size_t(-1)); }
unsigned short Users(size_t nModule) const;
unsigned short MaxUsers(size_t nModule) const;
void Init(const TDongle& dongle);
};
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY(TModulesArray)
void TModuleTable::Init(const TDongle& dongle)
{
for (size_t m = 0; m < dongle.Modules(); m++)
{
const size_t u = dongle.MaxUsers(m);
Add(new TModuleInfo(m, u));
}
}
bool TModuleTable::AddConnection(wxSocketBase& sock, const wxChar* user, int session, size_t nModule)
{
bool ok = true;
if (nModule > 0 && nModule < GetCount())
{
const wxString strUser = BuildKey(sock, user, session);
ok = Item(nModule)->AddUser(strUser);
}
return ok;
}
bool TModuleTable::RemoveConnection(wxSocketBase& sock, const wxChar* user, int session, size_t nModule)
{
bool ok = false;
const wxString strUser = BuildKey(sock, user, session);
const size_t nModules = GetCount();
if (nModule >= nModules)
{
for (size_t m = nModules-1; m > 0; m--)
ok |= Item(m)->RemoveUser(strUser);
}
else
ok = Item(nModule)->RemoveUser(strUser);
return ok;
}
unsigned short TModuleTable::Users(size_t nModule) const
{ return (nModule > 0 && nModule < GetCount()) ? Item(nModule)->Users() : 0; }
unsigned short TModuleTable::MaxUsers(size_t nModule) const
{ return nModule == 0 ? 0xFFFF : (nModule < GetCount() ? Item(nModule)->MaxUsers() : 0); }
///////////////////////////////////////////////////////////
// TUserInfo
@ -29,9 +170,6 @@ WX_DECLARE_HASH_MAP( wxString, TUserInfo*, wxStringHash, wxStringEqual, TUsersHa
class TUserTable : public TUsersHashMap
{
protected:
wxString BuildKey(wxSocketBase& sock, const wxChar* user, int session) const;
public:
TUserInfo* AddConnection(wxSocketBase& sock, const wxChar* user, int session);
TUserInfo* Find(wxSocketBase& sock, const wxChar* user, int session);
@ -71,14 +209,6 @@ size_t TUserTable::GetLicenses() const
return hsHosts.size();
}
wxString TUserTable::BuildKey(wxSocketBase& sock, const wxChar* user, int session) const
{
wxIPV4address peer; sock.GetPeer(peer);
wxString strUserAtHost;
strUserAtHost.Printf("%s@%s:%d", user, peer.Hostname().c_str(), session);
return strUserAtHost;
}
TUserInfo* TUserTable::AddConnection(wxSocketBase& sock, const wxChar* user, int session)
{
TUserInfo* ui = Find(sock, user, session);
@ -176,18 +306,19 @@ private:
unsigned int m_MaxTries;
TUserTable m_Users;
TModuleTable m_Mods;
protected:
virtual const wxChar* GetAppName() const;
virtual bool ProcessCommand(wxString cmd, wxSocketBase& outs);
void AddNumber(TXmlItem& tr, int n) const;
void AddNumberOfUsers(TXmlItem& tr, int n) const;
wxString DescribeModule(int m) const;
wxString ModuleCode(int m) const;
bool KeyIsGood(const wxString& key, const wxString& gar) const;
void InitModules();
wxString GetModulesFilename() const;
wxString GarbleMD5(const char* str, const wxDateTime& date) const;
wxString GarbleMD5(int n, const wxDateTime& date) const;
@ -235,6 +366,7 @@ void TAuthorizationServer::InitModules()
}
}
}
m_Mods.Init(m_Dongle);
}
wxString TAuthorizationServer::GarbleMD5(const char* str, const wxDateTime& date) const
@ -329,25 +461,14 @@ bool TAuthorizationServer::IsMagicName(wxString& strFilename) const
return false;
}
wxString TAuthorizationServer::GetModulesFilename() const
{ return wxT("../campo.aut"); }
wxString TAuthorizationServer::DescribeModule(int m) const
{
wxString strModule;
wxTextFile txt(GetModulesFilename());
if (txt.Open())
strModule = txt.GetLine(m).Mid(3);
return strModule;
return m_Dongle.ModuleDescription(m);
}
wxString TAuthorizationServer::ModuleCode(int m) const
{
wxString strModule;
wxTextFile txt(GetModulesFilename());
if (txt.Open())
strModule = txt.GetLine(m).Left(2).Upper();
return strModule;
return m_Dongle.ModuleNumberToCode(m);
}
void TAuthorizationServer::AddNumber(TXmlItem& tr, int n) const
@ -357,6 +478,19 @@ void TAuthorizationServer::AddNumber(TXmlItem& tr, int n) const
td << wxString::Format("%d", n);
}
void TAuthorizationServer::AddNumberOfUsers(TXmlItem& tr, int n) const
{
TXmlItem& td = tr.AddChild("td");
td.SetAttr("align", "right");
if (n == 0)
td.AddChild("i") << "None"; else
if (n > 0 && n < 128)
td << wxString::Format("%d", n);
else
td.AddChild("b") << "Unlimited";
}
void TAuthorizationServer::GenerateIndex(wxString& strFilename)
{
TXmlItem html;
@ -372,9 +506,9 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename)
wxString strModel;
switch (m_Dongle.hardware())
{
case _dongle_xsec:
img.SetAttr("src", "xsec.gif");
strModel = wxT("XSec");
case _dongle_ssa:
img.SetAttr("src", "ssa.gif");
strModel = wxT("SSA");
break;
case _dongle_hardlock:
img.SetAttr("src", "hardlock.gif");
@ -416,17 +550,17 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename)
TXmlItem& tr2 = body.AddChild("tr");
TXmlItem& mu = tr2.AddChild("td").AddChild("a");
mu.SetAttr("href", "maxusers.htm") << "Maximum Users";
AddNumber(tr2, m_Dongle.MaxUsers());
AddNumberOfUsers(tr2, m_Dongle.MaxUsers());
TXmlItem& tr3 = body.AddChild("tr");
TXmlItem& au = tr3.AddChild("td").AddChild("a");
au.SetAttr("href", "Users.htm"); au << "Active Users";
AddNumber(tr3, m_Users.GetCount());
AddNumberOfUsers(tr3, m_Users.GetCount());
TXmlItem& tr3a = body.AddChild("tr");
TXmlItem& lu = tr3a.AddChild("td").AddChild("a");
lu << "Active Licenses";
AddNumber(tr3a, m_Users.GetLicenses());
AddNumberOfUsers(tr3a, m_Users.GetLicenses());
TXmlItem& tr4 = body.AddChild("tr");
TXmlItem& am = tr4.AddChild("td").AddChild("a");
@ -455,38 +589,40 @@ void TAuthorizationServer::GenerateModules(wxString& strFilename)
{
TXmlItem html;
TXmlItem& body = CreatePageBody(html, "Modules");
TXmlItem& table = body.AddChild("table");
table.SetAttr("border", "1"); table.SetAttr("width", "100%");
TXmlItem& table = body.AddChild("center").AddChild("table");
table.SetAttr("border", "1").SetAttr("width", "100%");
TXmlItem& th = body.AddChild("thead");
th.AddChild("th").SetAttr("width", "7%") << "N.";
th.AddChild("th").SetAttr("width", "8%") << "Module";
th.AddChild("th").SetAttr("width", "70%") << "Description";
TXmlItem& th = table.AddChild("thead");
th.AddChild("th") << "N.";
th.AddChild("th") << "Module";
th.AddChild("th") << "Description";
th.AddChild("th") << "Users";
th.AddChild("th") << "Max.";
const bool bNormalUser = m_Dongle.Number() > 0;
const bool bNormalUser = m_Dongle.Number() > 0 && m_Dongle.hardware() != _dongle_ssa;
if (bNormalUser)
th.AddChild("th").SetAttr("width", "15%") << "De/Activate";
th.AddChild("th") << "De/Activate";
const wxString strAut = GetModulesFilename();
wxFileInputStream aut(strAut);
for (int nModule = 0; !aut.Eof(); nModule++)
TXmlItem& tb = table.AddChild("tbody");
for (size_t nModule = 1; ; nModule++)
{
wxString line;
aut >> line;
if (line.IsEmpty())
const wxString strCode = m_Dongle.ModuleNumberToCode(nModule);
if (strCode.IsEmpty())
break;
const wxString strCode = line.Left(2).Lower();
const wxString strDesc = line.Mid(3);
if (nModule > 0 && strCode != "xx" && !strDesc.IsEmpty())
if (strCode != "xx")
{
const bool bOn = nModule == 0 || m_Dongle.Active(nModule);
TXmlItem& tr = body.AddChild("tr");
const bool bOn = m_Dongle.Active(nModule);
TXmlItem& tr = tb.AddChild("tr");
AddNumber(tr, nModule);
tr.AddChild("td").SetAttr("align", "center") << strCode;
TXmlItem& td = tr.AddChild("td");
td.AddChild(bOn ? "b" : "i") << strDesc;
if (bNormalUser && nModule > 0)
td.AddChild(bOn ? "b" : "i") << m_Dongle.ModuleDescription(nModule);
AddNumberOfUsers(tr, m_Mods.Users(nModule));
AddNumberOfUsers(tr, m_Mods.MaxUsers(nModule));
if (bNormalUser)
{
const char* prompt = bOn ? "Deactivate" : "Activate";
const wxString href = wxString::Format("%s?%d", prompt, nModule);
@ -901,29 +1037,26 @@ void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock)
unsigned int num = 0;
if (m_Dongle.Connected())
{
// Preliminary GUEST login
// if (wxStricmp(strUser,"******")==0 && wxStricmp(strProgram, "ba0100")==0)
// {
// num = 1;
// }
// else
if (m_Users.GetLicenses() >= m_Dongle.MaxUsers() && m_Users.Find(sock, NULL, session) == NULL)
{
WriteLog(_("*** Maximum number of licenses exceeded"), 1);
num = 0;
}
else
{
if (m_Users.GetLicenses() >= m_Dongle.MaxUsers() && m_Users.Find(sock, NULL, session) == NULL)
{
WriteLog(_("*** Maximum number of users exceeded"), 1);
num = 0;
}
if (strcmp(strPassword, "******") == 0) // Older 16 bit version
num = 1;
else
{
if (strcmp(strPassword, "******") == 0) // Older 16 bit version
num = 1;
else
num = DecodePassword(strPassword, strProgram);
if (num > 0)
m_Users.AddConnection(sock, strUser, session);
else
WriteLog(_("*** Bad password"), 1);
}
num = DecodePassword(strPassword, strProgram);
if (num > 0)
{
const wxChar strModule[4] = { tolower(strProgram[0]), tolower(strProgram[1]), 0, 0 };
const size_t nModule = m_Dongle.ModuleCodeToNumber(strModule);
if (m_Mods.AddConnection(sock, strUser, session, nModule))
m_Users.AddConnection(sock, strUser, session);
}
else
WriteLog(_("*** Bad password"), 1);
}
}
else
@ -944,9 +1077,19 @@ bool TAuthorizationServer::ProcessUserLogout(wxString cmd, wxSocketBase& sock)
if (nStr < 2)
session = 0;
m_Users.RemoveConnection(sock, strUser, session);
if (wxStrcmp(strProgram, "ba0100") == 0)
{
m_Users.KillSession(sock, session);
m_Mods.KillSession(sock, session);
}
else
{
m_Users.RemoveConnection(sock, strUser, session);
strProgram[2] = '\0';
const size_t nModule = m_Dongle.ModuleCodeToNumber(strProgram);
m_Mods.RemoveConnection(sock, strUser, session, nModule);
}
return true;
}
@ -1062,9 +1205,9 @@ bool TAuthorizationServer::ProcessCommand(wxString cmd, wxSocketBase& outs)
bool TAuthorizationServer::Initialization()
{
#ifdef __WXMSW__
// Add global atom if not already present
// Add global atom if not already present (3.2 compatibility)
if (::GlobalFindAtom(ATOMIC_SEMAPHORE) == NULL)
::GlobalAddAtom(ATOMIC_SEMAPHORE); // Same as old Frontend.exe
::GlobalAddAtom(ATOMIC_SEMAPHORE);
#endif
const int delay = GetConfigInt("Delay", 10);
m_MaxTries = GetConfigInt("MaxTries", 8);
@ -1087,16 +1230,19 @@ bool TAuthorizationServer::Initialization()
bool TAuthorizationServer::Deinitialization()
{
m_Dongle.Logout();
#ifdef __WXMSW__
// Definitely kill global atom
// Definitely kill global atom (3.2 compatibility)
for (ATOM a = ::GlobalFindAtom(ATOMIC_SEMAPHORE);
a != NULL;
a = ::GlobalDeleteAtom(a));
#endif
return true;
return true;
}
// Istanziare l'applicazione principale
IMPLEMENT_APP(TAuthorizationServer)

View File

@ -597,7 +597,9 @@ void TBaseServerApp::OnIdle(wxIdleEvent& evt)
sock.Notify(true);
}
m_Sockets.RemoveAt(0);
if (m_Sockets.GetCount() > 0)
m_Sockets.RemoveAt(0, 1);
evt.RequestMore(); // FONDAMENTALE per gestire richieste multiple!
}
wxApp::OnIdle(evt);

View File

@ -1,6 +1,8 @@
#include "baseserv.h"
#include "dongle.h"
#include <wx/textfile.h>
///////////////////////////////////////////////////////////
// TBit_array
///////////////////////////////////////////////////////////
@ -346,15 +348,46 @@ inline void reset_bit(unsigned short& w, unsigned char b)
w &= ~(1 << b);
}
///////////////////////////////////////////////////////////
// SSA Stuff
///////////////////////////////////////////////////////////
extern "C"
{
__declspec(dllimport) int Login(const char* session, const char* product);
__declspec(dllimport) int ApriModulo(const char* session, const char* product);
__declspec(dllimport) int ChiudiModulo(const char* session, const char* product);
__declspec(dllimport) int Logout(const char* session, const char* product);
}
///////////////////////////////////////////////////////////
// TDongle
///////////////////////////////////////////////////////////
TDongle::TDongle()
: _hardware(_dongle_unknown), _type(_no_dongle), _serno(0xFFFF),
_max_users(1), _year_assist(2007), _dirty(false)
_max_users(1), _year_assist(2011), _dirty(false)
{
memset(_eprom, 0, sizeof(_eprom));
memset(_user, 0, sizeof(_user));
wxTextFile aut("../campo.aut");
if (aut.Open())
{
for (size_t m = 0; m < aut.GetLineCount(); m++)
{
const wxString& l = aut[m];
_code.Add(l.Left(2).Lower());
wxString d = l.Mid(3);
d.Replace("a'", "à");
_desc.Add(d);
}
}
else
{
_code.Add("ba");
_desc.Add("Base");
}
}
TDongle::~TDongle()
@ -632,6 +665,58 @@ bool TDongle::eutron_login(bool test_all_keys)
return ok;
}
wxString TDongle::GetSessionId() const
{
wxString strSession = wxGetHostName();
DWORD session = 0;
::ProcessIdToSessionId(::GetCurrentProcessId(), &session);
strSession << ':' << session;
const size_t len = strSession.Len();
if (len > 23)
strSession = strSession.Right(23);
return strSession;
}
bool TDongle::ssa_login(bool WXUNUSED(test_all_dongles))
{
const wxString u = GetSessionId();
const bool ok1 = ::Login(u, "Campo") == 0;
const bool ok2 = ::Login(u, "Enterprise") != 0; // Test for dll tampering
const bool ok = ok1 && ok2;
if (ok)
{
_hardware = _dongle_ssa;
_type = _sirio_dongle;
_serno = 0;
_last_update = wxDateTime::Now();
_year_assist = _last_update.GetYear();
_max_users = 1;
for (size_t m = 0; m < _code.GetCount(); m++)
{
const wxString c = ModuleNumberToCode(m);
if (::ApriModulo(u, c) == 0)
{
_module.set(m);
::ChiudiModulo(u, c);
unsigned short& mu = _user[m];
mu = ComputeMaxUsers(m);
if (mu > _max_users && mu < 128)
_max_users = mu;
}
}
}
return ok;
}
bool TDongle::ssa_logout()
{
return ::Logout(GetSessionId(), "Campo") == 0;
}
bool TDongle::Login(bool test_all_keys)
{
bool ok = true;
@ -639,9 +724,14 @@ bool TDongle::Login(bool test_all_keys)
if (_type != _no_dongle) // Already logged in
Logout();
#ifdef NDEBUG
TDongleHardware hw = _hardware;
if (hw == _dongle_unknown)
hw = (TDongleHardware)GetServerApp().GetConfigInt("Donglehw");
#else
TDongleHardware hw = _dongle_ssa;
#endif
switch(hw)
{
case _dongle_hardlock:
@ -650,6 +740,9 @@ bool TDongle::Login(bool test_all_keys)
case _dongle_eutron:
ok = eutron_login(test_all_keys);
break;
case _dongle_ssa:
ok = ssa_login(test_all_keys);
break;
default:
ok = false;
break;
@ -660,6 +753,8 @@ bool TDongle::Login(bool test_all_keys)
ok = eutron_login(test_all_keys);
if (!ok && hw != _dongle_hardlock)
ok = hardlock_login(test_all_keys);
if (!ok && hw != _dongle_ssa)
ok = ssa_login(test_all_keys);
if (ok)
GetServerApp().SetConfigInt("Donglehw",(int)_hardware);
}
@ -678,13 +773,14 @@ bool TDongle::Logout()
case _dongle_eutron:
if (_eutron_key)
{
#ifdef WIN32
_eutron_key->net_command = NET_KEY_CLOSE;
#endif
_eutron_key->command = 0;
smartlink(_eutron_key);
}
break;
case _dongle_ssa:
ssa_logout();
break;
default:
break;
}
@ -904,7 +1000,7 @@ bool TDongle::burn_eutron()
if (ok)
{
unsigned short data[sob]; memset(data, 0, sizeof(data));
for (int module = 1; module < 256; module++)
for (size_t module = 1; module < _code.GetCount(); module++)
{
if (Active(module))
{
@ -926,9 +1022,9 @@ bool TDongle::Burn()
{
switch(_hardware)
{
case _dongle_hardlock: ok = burn_hardlock(); break;
case _dongle_eutron : ok = burn_eutron(); break;
default : break;
case _dongle_hardlock: ok = burn_hardlock(); break;
case _dongle_eutron : ok = burn_eutron(); break;
default : ok = false; break;
}
}
if (ok)
@ -937,3 +1033,71 @@ bool TDongle::Burn()
return ok;
}
wxString TDongle::ModuleNumberToCode(size_t module) const
{
return module < _code.GetCount() ? _code[module] : wxEmptyString;
}
size_t TDongle::ModuleCodeToNumber(const wxChar* code) const
{
size_t n = 0;
if (code && *code)
{
const wxChar k[4] = { code[0], code[1], '\0', '\0' };
n = _code.Index(k, false);
}
return n;
}
wxString TDongle::ModuleDescription(size_t module) const
{
return module < _desc.GetCount() ? _desc[module] : wxEmptyString;
}
unsigned short TDongle::ComputeMaxUsers(size_t module) const
{
wxASSERT(_hardware == _dongle_ssa);
unsigned short n = module == 0 ? 0xFFFF : 0;
if (module > 0 && Active(module))
{
const wxString m = ModuleNumberToCode(module);
wxString u;
for (n = 0; n < 32; n++)
{
u.Printf("DummyDongle:%d", n);
if (::Login(u, "Campo") != 0 || ::ApriModulo(u, m) != 0)
break;
}
for (short i = 0; i < n; i++)
{
u.Printf("DummyDongle:%d", i);
::Logout(u, "Campo");
}
}
return n < 32 ? n : -1;
}
unsigned short TDongle::MaxUsers(size_t module) const
{
if (module == 0)
return _max_users;
if (!Active(module))
return 0;
return _hardware == _dongle_ssa ? _user[module] : _max_users;
}
bool TDongle::OpenModule(size_t module)
{
if (MaxUsers(module) == 0)
return false;
if (_hardware == _dongle_ssa)
{
const wxString u = GetSessionId();
const wxString m = ModuleNumberToCode(module);
if (::ApriModulo(u, m) != 0)
return false;
}
return true;
}

View File

@ -5,8 +5,8 @@
#include <wx/datetime.h>
#endif
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_xsec };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle };
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_ssa };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _sirio_dongle };
enum { MAX_DONGLE_ASSIST = 8 };
class TBit_array : public wxObject
@ -60,12 +60,23 @@ class TDongle : public wxObject
TBit_array _module;
bool _dirty;
// Module codes and descriptions
wxArrayString _code, _desc;
unsigned short _user[64];
wxString GetSessionId() const; // host:session
unsigned short ComputeMaxUsers(size_t module) const;
bool OpenModule(size_t module);
protected:
bool already_programmed() const;
bool hardlock_login(bool test_all_dongles);
bool eutron_login(bool test_all_dongles);
bool ssa_login(bool test_all_dongles);
bool ssa_logout();
bool burn_hardlock();
bool burn_eutron();
@ -79,12 +90,10 @@ public:
bool Connected();
unsigned short Number() const { return _serno; }
unsigned short MaxUsers() const { return _max_users; }
unsigned short YearAssist() const { return _year_assist; }
unsigned short MaxUsers(size_t module = 0) const;
void garble(unsigned short* data) const;
// Solo per un po' di tempo, poi diverranno protected (servono a ba1500 old style)
bool read_words(unsigned short reg, unsigned short len, unsigned short *data) const;
bool write_words(unsigned short reg, unsigned short len, unsigned short *data) const;
@ -97,11 +106,16 @@ public:
void set_year_assist(unsigned short y) { _year_assist = y; _dirty = true; }
const wxDateTime& last_update() const { return _last_update; }
bool dirty() const { return _dirty; }
bool IsDirty() const { return _dirty; }
bool Burn();
TDongleHardware hardware() const { return _hardware; }
size_t Modules() const { return _code.GetCount(); }
wxString ModuleNumberToCode(size_t module) const;
size_t ModuleCodeToNumber(const wxChar* code) const;
wxString ModuleDescription(size_t module) const;
TDongle();
virtual ~TDongle();
};

File diff suppressed because it is too large Load Diff

View File

@ -643,7 +643,11 @@ bool UnzipFile(const char* strSrcFile, const char* strDestDir)
}
else
{
wxZipInputStream fin(strZipFile, strFileName);
//wxZipInputStream fin(strZipFile, strFileName);
wxFileInputStream fstr(strZipFile);
wxZipInputStream fin(fstr);
wxZipEntry ze(strFileName);
fin.OpenEntry(ze);
wxString strOutFile = strDestDir;
if (!wxEndsWithPathSeparator(strOutFile) && !wxIsPathSeparator(strFileName[0]))
@ -658,6 +662,8 @@ bool UnzipFile(const char* strSrcFile, const char* strDestDir)
fout.Write(fin);
fout.Close();
fin.CloseEntry();
if (strOutFile.EndsWith("res.zip"))
UnzipFile(strOutFile , strPath);
}

View File

@ -54,7 +54,7 @@ bool TCache_art::update_paper_composition(const char* key, TArticolo_pack& art)
qry << "SELECT Paper_Composition_Group.CompDesc\n"
<< "FROM Mag_Existing_Article, Articles_Composition, Paper_Composition_Group\n"
<< "WHERE (Mag_Existing_Article.ArtCode='" << key << "') AND "
<< "(Mag_Existing_Article.ArticleCode=Articles_composition.ArticleCode) AND "
<< "(Mag_Existing_Article.ArticleCode=Articles_composition.ArticleCode) AND (Mag_Existing_Article.VariantCode=Articles_composition.VariantCode) AND "
<< "(Articles_Composition.CompCode=Paper_Composition_Group.CompCode);";
TODBC_recordset paperset(qry);
bool done = paperset.move_first();
@ -209,7 +209,6 @@ const TArticolo_pack& TCache_art::articolo()
if (gruconto > 0 && sottoconto > 0)
codart << "*" << gruconto << '*' << sottoconto;
}
return *(const TArticolo_pack*)objptr(codart);
}
@ -765,7 +764,7 @@ bool TPack_ddt::trasferisci()
if (_order_paper_info)
get_paper_from_order(descr);
if (bIsSingleSheet && descr.find('(') < 0) // E' un foglio singolo senza dimensioni?
if (descr.find('(') < 0) // E' un foglio singolo senza dimensioni?
{
TString80 misure;
misure << get_str("Height") << " x " << get_str("Width");

View File

@ -8,7 +8,7 @@ int main( int argc, char** argv )
switch (r)
{
case 2: ve6200(argc, argv); break; // creazione fatture partendo da bolle
case 2: ve6200(argc, argv); break; // fatturazione bolle
case 3: ve6300(argc, argv); break; // generazione effetti
case 4: ve6400(argc, argv); break; // generazione scontrini
case 5: ve6500(argc, argv); break; // generazione righe da penna ottica

View File

@ -48,7 +48,7 @@ class TContabilizzazione_app : public TApplication
TDate _data_reg; // data di registrazione immessa
TDate _data_ini; // data di inizio intervallo
TDate _data_fine; // data di fine intervallo
bool _auto_data; // se TRUE prende in automatico la data di registrazione dalla data documento
bool _auto_data; // se true prende in automatico la data di registrazione dalla data documento
TMask *_msk; // maschera di selezione dati
TArray_sheet *_num_sheet; // Array sheet selezionabile dei codici numerazione
TString_array _tipi_doc; // Array di stringhe contenente i tipi documenti da elaborare
@ -91,15 +91,12 @@ bool TContabilizzazione_app::handle_data_range(TMask_field& f, KEY k)
{
TMask& m = f.mask();
if (m.get_bool(F_DATA_AUTO))
return TRUE; // Skip controls if data is automatic
return true; // Skip controls if data is automatic
TDate da(m.get_date(F_DATA_INI));
TDate a(m.get_date(F_DATA_FIN));
m.field(F_DATA_REG).set_dirty();
if ((a - da) > 15)
{
f.error_box(TR("L'intervallo tra le date non puo' eccedere i 15 giorni."));
return FALSE;
}
return f.error_box(TR("L'intervallo tra le date non puo' eccedere i 15 giorni."));
if (f.dlg() == F_DATA_FIN)
m.set(F_DATA_REG,f.get());
}
@ -109,7 +106,7 @@ bool TContabilizzazione_app::handle_data_range(TMask_field& f, KEY k)
if (!m.get_bool(F_DATA_AUTO) && f.dlg() == F_DATA_FIN)
m.set(F_DATA_REG,f.get());
}
return TRUE;
return true;
}
bool TContabilizzazione_app::handle_data_reg(TMask_field& f, KEY k)
@ -119,20 +116,15 @@ bool TContabilizzazione_app::handle_data_reg(TMask_field& f, KEY k)
TMask& m = f.mask();
TDate data_reg(f.get());
if (data_reg == botime) return TRUE;
if (data_reg == botime)
return true;
TDate da(m.get_date(F_DATA_INI));
if ((data_reg - da) > 15)
{
f.error_box(TR("L'intervallo tra la data di registrazione e la data di inizio non puo' eccedere i 15 giorni."));
return FALSE;
}
return f.error_box(TR("L'intervallo tra la data di registrazione e la data di inizio non puo' eccedere i 15 giorni."));
if (data_reg < da)
{
f.error_box(TR("La data di registrazione non puo' essere minore della data di inizio."));
return FALSE;
}
return f.error_box(TR("La data di registrazione non puo' essere minore della data di inizio."));
}
return TRUE;
return true;
}
bool TContabilizzazione_app::handle_cod_eld(TMask_field& f, KEY k)
@ -143,7 +135,7 @@ bool TContabilizzazione_app::handle_cod_eld(TMask_field& f, KEY k)
f.mask().disable(DLG_OK);
app().build_num_sheet();
}
return TRUE;
return true;
}
bool TContabilizzazione_app::handle_select(TMask_field& f, KEY k)
@ -160,7 +152,7 @@ bool TContabilizzazione_app::handle_select(TMask_field& f, KEY k)
m.disable(DLG_OK);
}
}
return TRUE;
return true;
}
void TContabilizzazione_app::build_num_sheet()
@ -227,7 +219,7 @@ bool TContabilizzazione_app::doc_tipo_stato_ok(const TRectype& doc)
const TString16 tipox(t.get(0));
const char statox = t.get(1)[0];
if (tipo == tipox && stato == statox)
found = TRUE;
found = true;
}
return found;
}
@ -252,7 +244,7 @@ bool TContabilizzazione_app::create()
_num_sheet = new TArray_sheet(-1,-1,-4,-4,"Codici numerazione",
"@1|Cod. numerazione|Descrizione@50");
dispatch_e_menu(BAR_ITEM_ID(1));
return TRUE;
return true;
}
bool TContabilizzazione_app::destroy()
@ -284,7 +276,7 @@ void TContabilizzazione_app::contabilize()
const long items = _num_sheet->items();
int year_from = _data_ini.year();
int year_to = _data_fine.year();
TString16 codnum;
TString4 codnum;
TString msg,filt_expr;
TToken_string nums;
TContabilizzazione cont(_cod_el);
@ -329,10 +321,10 @@ void TContabilizzazione_app::contabilize()
TLista_documenti lista_in,lista_out;
doc_cur.freeze();
msg = "Selezione documenti dal ";
msg << _data_ini.string() << " al ";
msg = TR("Selezione documenti dal ");
msg << _data_ini.string() << TR(" al ");
msg << _data_fine.string();
TProgind p(cur_items,msg,FALSE,TRUE);
TProgind p(cur_items,msg,FALSE,true);
const TRectype& cur_rec = doc_cur.curr();
// Scorre tutti i documenti che rientrano nell'intervallo selezionato
@ -363,5 +355,5 @@ int ve6100 (int argc, char **argv)
{
TContabilizzazione_app a;
a.run(argc,argv,"Contabilizzazione documenti");
return TRUE;
return true;
}

View File

@ -17,8 +17,7 @@ bool TFatturazione_bolle_app::create()
LF_DOC, LF_RIGHEDOC, LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_CONDV, LF_SVRIEP,
LF_AGENTI, LF_PERCPROV, LF_CAUSALI, 0);
TConfig cfg(CONFIG_DITTA, "ve");
_default_selection = cfg.get("FATBOLSEL");
_default_selection = ini_get_string(CONFIG_DITTA, "ve", "FATBOLSEL");
return TSkeleton_application::create();
}

View File

@ -268,10 +268,8 @@ void TGenerazioneEffetti_app::build_num_sheet()
bool TGenerazioneEffetti_app::create()
{
if (!has_module(EFAUT))
{
error_box("Impossibile eseguire il programma se il modulo Effetti non e' abilitato");
return FALSE;
}
return error_box("Il modulo Effetti non e' abilitato");
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_OCCAS, LF_INDSP, LF_CFVEN,
LF_DOC, LF_RIGHEDOC, LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_CONDV,
LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CESS, LF_CAUSALI, 0);

View File

@ -111,23 +111,16 @@ int TLista_documenti::read(char provv, char tipocf, long clifo, int anno,
stop.put(DOC_ANNO, anno_stop);
}
TString filter(16);
if (codnum && *codnum)
TString filter;
if (codnum && *codnum > ' ')
{
bool numfilter = false;
if (start.get(DOC_DATADOC).empty())
numfilter = true;
else
if (!start.get(DOC_DATADOC).empty())
start.put(DOC_CODNUM, codnum);
if (stop.get(DOC_DATADOC).empty())
numfilter = true;
else
if (!stop.get(DOC_DATADOC).empty())
stop.put(DOC_CODNUM, codnum);
if (numfilter)
filter << DOC_CODNUM << "=\"" << codnum << '"';
filter << DOC_CODNUM << "=\"" << codnum << '"';
}
TCursor cur(&doc, filter, 2, &start, &stop);

View File

@ -421,7 +421,7 @@ protected:
// Testa il fatto che il documento sia una nota di credito/debito
bool test_swap();
// Istanzia la causale contabile
TCausale * get_caus(const TDocumento& doc, const int year);
TCausale* get_caus(const TDocumento& doc, const int year) const;
// Ritorna l'ultimo numero di registrazione disponibile dei movimenti di prima nota
error_type get_next_reg_num(long &);

View File

@ -958,16 +958,17 @@ error_type TContabilizzazione::get_next_reg_num(long& nr)
long TContabilizzazione::doc_contabilized(const TDocumento& doc, bool anticipo) const
{
const char* const key[4] = { DOC_PROVV, DOC_ANNO, DOC_CODNUM, DOC_NDOC };
// NON usare la cache qui!!!!!!!!!!!!!!!!!!!!!!
long nreg = doc.get_long(anticipo ? DOC_NUMANT : DOC_NUMREG);
if (nreg > 0)
{
// NON usare la cache qui!!!!!!!!!!!!!!!!!!!!!!
TLocalisamfile mov(LF_MOV);
mov.put(MOV_NUMREG, nreg);
if (mov.read() == NOERR) // Il movimento esiste!
{
// Controlla che il movimento abbia ancora il riferimento esatto al documento
const char* const key[4] = { DOC_PROVV, DOC_ANNO, DOC_CODNUM, DOC_NDOC };
TString8 dkey, dval;
for (int k = 0; k < 4; k++)
{
@ -983,24 +984,57 @@ long TContabilizzazione::doc_contabilized(const TDocumento& doc, bool anticipo)
else
nreg = 0; // Il movimento non esiste più: l'hanno cancellato!
}
else if (!anticipo)
{
const TDate data_reg = _auto_data ? doc.get_date(DOC_DATADOC) : _data_reg;
const TCausale* caus = get_caus(doc, data_reg.year());
TLocalisamfile mov(LF_MOV);
mov.setkey(3);
mov.put(MOV_TIPO, doc.clifor().tipo());
mov.put(MOV_CODCF, doc.clifor().codice());
mov.put(MOV_DATAREG, data_reg);
for (int err = mov.read(_isgteq); err == NOERR; err = mov.next())
{
const TDate d = mov.get(MOV_DATAREG);
if (d != data_reg)
break;
const TString& cau = mov.get(MOV_CODCAUS);
if (cau != caus->codice())
continue; // Altra causale, probabilmente anticipo
// Controlla che il movimento abbia il riferimento esatto al documento
TString8 dkey, dval;
int k = 0;
for (k = 0; k < 4; k++)
{
dkey = "D"; dkey << key[k];
dval = mov.get(dkey);
if (dval != doc.get(key[k]))
break; // La chiave non corrisponde: è un altro documento
}
if (k == 4) // Ricontabilizziaaamoo!
{
nreg = mov.get_long(MOV_NUMREG);
break;
}
}
}
return nreg;
}
TCausale * TContabilizzazione::get_caus(const TDocumento& doc, const int year)
TCausale* TContabilizzazione::get_caus(const TDocumento& doc, const int year) const
{
TString16 codcaus;
TString8 codcaus;
TToken_string key;
if (!_fld_cms_cont.blank())
if (_fld_cms_cont.full())
{
const TString & cms = doc.commessa_principale();
if (!cms.blank())
const TString& cms = doc.commessa_principale();
if (cms.full())
{
key.add(cms);
const TString16 fld_val = cache().get(LF_COMMESSE, key, _fld_cms_cont);
if (!fld_val.blank())
if (fld_val.full())
{
key = "CTCMS";
key.add(doc.tipo().codice());
@ -1020,7 +1054,17 @@ TCausale * TContabilizzazione::get_caus(const TDocumento& doc, const int year)
codcaus = doc.tipo().causale(); // Istanzia la causale del documento corrente...
}
return codcaus.blank() ? NULL : new TCausale(codcaus, year);
if (_caus != NULL && _caus->codice() == codcaus && _caus->reg().year() == year)
return _caus;
if (_caus != NULL)
{
delete _caus;
_caus = NULL;
}
if (codcaus.full())
_caus = new TCausale(codcaus, year);
return _caus;
}
error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
@ -1062,12 +1106,12 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
{
msg << "stampato su bollato";
_viswin->add_line(msg);
}
} else
if (mov.get_bool(MOV_STAMPATO))
{
msg << "stampato sul giornale";
_viswin->add_line(msg);
}
} else
if (mov.get_bool(MOV_INVIATO))
{
msg << "inviato ad altra contabilità";
@ -1101,20 +1145,11 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
}
numdoc.upper(); // Il numero documento e' uppercase!
// Istanzia la causale del documento corrente...
const TTipo_documento& tipo = doc.tipo();
TString16 codcaus = tipo.causale();
TToken_string key;
key.add(doc.get(DOC_TIPOCF));
key.add(doc.get(DOC_CODCF));
const TRectype& cfven = cache().get(LF_CFVEN, key);
const TString& caus_cli = cfven.get(doc.is_nota_credito() ? CFV_CODCAUSNC : CFV_CODCAUS);
if (caus_cli.not_empty())
codcaus = caus_cli; // La causale del cliente prevale su quella del tipo documento
// Istanzia la causale del documento corrente...
_caus = get_caus(doc, data_reg.year());
_righe_iva->set_caus(_caus);
if (_caus == NULL || !_caus->ok())
{
@ -4015,7 +4050,7 @@ void TContabilizzazione::display_error(TDocumento& doc)
TToken_string msg(256, '.');
const TString4 numerazione = doc.numerazione();
const long numero = doc.numero();
const TString4 causale = _caus == NULL ? "" : _caus->codice();
const char* causale = _caus == NULL ? "" : _caus->codice();
switch (_error)
{
@ -4267,8 +4302,12 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc
_error = no_error;
_nrow = 0;
_total_docs = 0L;
_caus = NULL;
_data_reg = data_elab;
if (_caus != NULL)
{
delete _caus;
_caus = NULL;
}
if (interattivo)
{

View File

@ -79,7 +79,7 @@ TGenerazione_effetti::~TGenerazione_effetti()
void TGenerazione_effetti::display_error(TDocumento& doc)
{
TString msg;
TString numerazione = doc.numerazione();
const TString4 numerazione = doc.numerazione();
const long numero = doc.numero();
switch (_error)
@ -696,7 +696,10 @@ void TGenerazione_effetti::generate_bill(TDocumento& doc, bool interattivo) // b
reffetto.put(REFF_IMPFATT,totfatlit.get_num());
reffetto.put(REFF_IMPORTOVAL,importo);
}
if (_efffile->write() == NOERR && _refffile->write() == NOERR)
int err = _efffile->write();
if (err == NOERR)
err = _refffile->write_rewrite();
if (err == NOERR)
{
_total_bills++;
nprog++;

View File

@ -3951,6 +3951,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
case ATTR_APPL_VERSION_STRING:
ret = (long)(const char*)_appl_version;
break;
case ATTR_APPL_VERSION_YEAR:
ret = wxAtoi(_appl_version.Left(4));
break;
case ATTR_APPL_ALREADY_RUNNING:
ret = _appl_already_running;
break;

View File

@ -5,7 +5,7 @@
* Agreement with XVT Software.
*
* $RCSfile: xvt_defs.h,v $
* $Revision: 1.11.2.1 $
* $Revision: 1.11.2.2 $
*
* Purpose: Global XVT macro definitions.
*
@ -493,6 +493,7 @@
#define ATTR_SPEECH_MODE (ATTR_BASE + 720) /* Added by Guy */
#define ATTR_APPL_VERSION_STRING (ATTR_BASE + 721) /* Added by Guy */
#define ATTR_APPL_ALREADY_RUNNING (ATTR_BASE + 722) /* Added by Guy */
#define ATTR_APPL_VERSION_YEAR (ATTR_BASE + 723) /* Added by Guy */
/* Font attributes */
#define ATTR_FONT_MAPPER (ATTR_BASE + 800)

View File

@ -1,10 +1,10 @@
#include "wxinc.h"
#include "xvt.h"
#include "../../ssa/h/ssadll.h"
#include "../../ssa/h/ssaerr.h"
//#define SSA_MOD_NOTFOUND -201
//#define SSA_NO_LOGIN -301
#include <errno.h>
static int _ssa_serial = SSA_UTENTE_NON_LOGGATO;
static wxString _ssa_module;
@ -27,21 +27,25 @@ int xvt_dongle_sa_login(const char* module)
{
int err = _ssa_serial;
if (_ssa_serial < 0)
const int nAssYear = xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR);
if (nAssYear > 2091)
{
err = SSA_Login(xvt_dongle_sa_id(), "Campo");
if (err == 0)
err = _ssa_serial = SSA_NumeroSerie("Campo");
}
if (_ssa_serial >= 0 && module && *module)
{
err = SSA_ApriModulo(xvt_dongle_sa_id(), module);
if (err == 0)
if (_ssa_serial < 0)
{
if (!_ssa_module.IsEmpty())
xvt_dongle_sa_logout(_ssa_module);
_ssa_module = module;
err = SSA_Login(xvt_dongle_sa_id(), "Campo");
if (err == 0)
err = _ssa_serial = SSA_NumeroSerie("Campo");
}
if (_ssa_serial >= 0 && module && *module)
{
err = SSA_ApriModulo(xvt_dongle_sa_id(), module);
if (err == 0)
{
if (!_ssa_module.IsEmpty())
xvt_dongle_sa_logout(_ssa_module);
_ssa_module = module;
}
}
}
@ -53,7 +57,7 @@ int xvt_dongle_sa_crypt(unsigned short* data)
if (_ssa_serial < 0)
return SSA_UTENTE_NON_LOGGATO;
if (data == NULL)
return -ENOMEM;
return -EACCES;
data[0] ^= 0xDEAD;
data[1] ^= 0xBEEF;
data[2] ^= 0xDEAD;

View File

@ -182,7 +182,7 @@ public:
void Suspend();
void Resume();
void Enable(const wxTreeItemId& id, bool on);
TwxTreeListCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
TwxTreeListCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool multisel);
};
struct TwxOutlookItem
@ -357,7 +357,8 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
break;
case WC_TREELIST:
{
TwxTreeListCtrl* tv = new TwxTreeListCtrl(pParent, id, rct.GetPosition(), rct.GetSize());
const bool multisel = (win_def_p->v.ctl.flags & CTL_FLAG_MULTIPLE) != 0;
TwxTreeListCtrl* tv = new TwxTreeListCtrl(pParent, id, rct.GetPosition(), rct.GetSize(), multisel);
win = (WINDOW)tv;
}
break;
@ -2851,9 +2852,9 @@ void TwxTreeListCtrl::SetNodeImages(const wxTreeItemId& id, XVT_IMAGE item_image
}
TwxTreeListCtrl::TwxTreeListCtrl(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size)
const wxPoint& pos, const wxSize& size, bool multisel)
: wxTreeListCtrl(parent, id, pos, size,
wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT|wxTR_ROW_LINES|wxTR_COLUMN_LINES|wxTR_SINGLE),
wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT|wxTR_ROW_LINES|wxTR_COLUMN_LINES|(multisel ? wxTR_MULTIPLE : wxTR_SINGLE)),
m_nFrozen(0)
{
AddColumn(wxEmptyString, size.x);

View File

@ -250,15 +250,19 @@ TMessageBox::TMessageBox(wxWindow* pParent, const wxString& msg, int nStyle, int
if (!bTerminalino)
{
const wxBitmap bmpCopy = wxArtProvider::GetBitmap(wxART_COPY, wxART_BUTTON);
wxBitmapButton* btnCopy = new wxBitmapButton(this, wxID_COPY, bmpCopy);
pSmallSizer->Add(btnCopy, 0, wxALIGN_TOP);
if (xvt_mail_installed())
const int nAssYear = xvt_vobj_get_attr(NULL_WIN, ATTR_APPL_VERSION_YEAR);
if (nAssYear > 2091)
{
const wxBitmap bmpMail = wxArtProvider::GetBitmap("139", wxART_BUTTON, wxSize(bmpCopy.GetWidth(), bmpCopy.GetHeight()));
wxBitmapButton* btnMail = new wxBitmapButton(this, wxID_SAVEAS, bmpMail);
pSmallSizer->Add(btnMail, 0, wxALIGN_TOP);
const wxBitmap bmpCopy = wxArtProvider::GetBitmap(wxART_COPY, wxART_BUTTON);
wxBitmapButton* btnCopy = new wxBitmapButton(this, wxID_COPY, bmpCopy);
pSmallSizer->Add(btnCopy, 0, wxALIGN_TOP);
if (xvt_mail_installed())
{
const wxBitmap bmpMail = wxArtProvider::GetBitmap("139", wxART_BUTTON, wxSize(bmpCopy.GetWidth(), bmpCopy.GetHeight()));
wxBitmapButton* btnMail = new wxBitmapButton(this, wxID_SAVEAS, bmpMail);
pSmallSizer->Add(btnMail, 0, wxALIGN_TOP);
}
}
}