Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiornamento periodico del main trunk con riporti del best of 1.5


git-svn-id: svn://10.65.10.50/trunk@7959 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1999-03-22 15:55:50 +00:00
parent dd9f77838f
commit a6b2a85c00
19 changed files with 594 additions and 134 deletions

View File

@ -480,7 +480,7 @@ void TApplication::set_perms()
_dongle_aut.set(0, TRUE);
for (int i = 1 ; i < ENDAUT; i++)
{
const bool val = dongle().active(i);
const bool val = ::dongle().active(i);
_dongle_aut.set(i, val);
}
#endif
@ -489,7 +489,7 @@ void TApplication::set_perms()
const TString& utente = user();
if (utente.not_empty())
{
if (utente == "PRASSI")
if (utente == ::dongle().administrator())
{
for (int i = 1 ; i < ENDAUT; i++)
_user_aut.set(i);

View File

@ -3,6 +3,7 @@
#include <applicat.h>
#include <colors.h>
#include <config.h>
#include <dongle.h>
#include <scanner.h>
#include <prefix.h>
#include <utility.h>
@ -102,45 +103,61 @@ void TConfig::_write_file()
if (_write_protected)
return;
ifstream in(_file, ios::in | ios::nocreate, filebuf::sh_read);
TFilename temp;
temp.temp("cnf");
ofstream out(temp);
TString l(1024);
TString cnf; cnf << '[' << _paragraph << ']';
if (!out.good())
{
NFCHECK("Impossibile scrivere %s per aggiornare %s",
(const char*)temp, (const char*)_file);
return;
}
bool skip = FALSE, done = FALSE, skip_empty = TRUE;
while (in && !in.eof())
if (_file.exist())
{
in.getline(l.get_buffer(), l.size());
l.trim();
if (cnf == l)
ifstream in(_file, ios::in | ios::nocreate, filebuf::sh_read);
if (in.good())
{
// write paragraph and all variables
_write_paragraph(out);
skip = skip_empty = done = TRUE;
TString l(1024);
TString cnf; cnf << '[' << _paragraph << ']';
while (!in.eof())
{
in.getline(l.get_buffer(), l.size());
l.trim();
if (cnf == l)
{
// write paragraph and all variables
_write_paragraph(out);
skip = skip_empty = done = TRUE;
}
else
{
if (skip)
skip = l[0] != '[';
if (!skip)
{
const bool empty = l.empty();
if (!empty || !skip_empty)
out << l << endl;
skip_empty = empty;
}
}
}
}
else
{
if (skip)
skip = l[0] != '[';
if (!skip)
{
const bool empty = l.empty();
if (!empty || !skip_empty)
out << l << endl;
skip_empty = empty;
}
NFCHECK("Impossibile aggiornare il file %s", (const char*)_file);
return;
}
}
// new paragraph
if (!done) _write_paragraph(out);
out.close(); in.close();
if (!done)
_write_paragraph(out);
out.close();
if (fexist(_file))
{
@ -707,7 +724,7 @@ TConfig::TConfig(int which_config, const char* paragraph)
{
TString16 u = user();
if (u.blank())
u = "PRASSI";
u = ::dongle().administrator();
else
u.upper();
_file.add(u);

View File

@ -413,11 +413,11 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
if (dy <= 0)
{
if (top < 0)
if (y < -1)
{
height = -top;
top += max.bottom;
y = 21 - height/ROWY;
y = 22 - height/ROWY;
}
else
height = max.bottom - top + dy * ROWY;
@ -1982,6 +1982,7 @@ void TDropDownList::close()
void TDropDownList::destroy()
{
_xi_lst = NULL;
_open = FALSE;
}
bool TDropDownList::select(int i, bool force)

View File

@ -114,7 +114,6 @@ void TDowJones::test_cache()
_euro_val = "EUR";
_cache.add(_euro_val, euro);
}
_euro_chg = get_change(_euro_val);
if (_base_val.empty()) // Si son dimenticati delle LIRE?
{
@ -125,6 +124,7 @@ void TDowJones::test_cache()
_cache.add(_base_val, lira);
}
_firm_val = prefix().firm().codice_valuta();
_euro_chg = get_change(_euro_val);
}
}

View File

@ -127,6 +127,28 @@ TDongle::~TDongle()
logout();
}
const TString& TDongle::administrator(TString* pwd)
{
if (_admin.empty())
{
TConfig ini("install.ini", "Main");
_admin = ini.get("Administrator");
if (_admin.empty())
_admin = "PRASSI";
else
_admin = ::decode(_admin);
_admpwd = ini.get("Password");
if (_admpwd.empty())
_admpwd = "pr.assi";
else
_admpwd = ::decode(_admpwd);
}
if (pwd)
*pwd = _admpwd;
return _admin;
}
// Data punta ad un array di 4 words
// Deve essere cosi' per problemi del C,
// non trasformare in array: pena di morte!

View File

@ -22,6 +22,8 @@ class TDongle : public TObject
TDate _last_update;
TBit_array _module;
bool _dirty;
TString16 _admin, _admpwd;
protected:
bool already_programmed() const;
@ -70,6 +72,8 @@ public:
TDongleHardware hardware() const { return _hardware; }
bool local() const { return _hardware == _dongle_hardlock || _hardware == _dongle_eutron; }
bool network() const { return _hardware == _dongle_network; }
const TString& administrator(TString* pwd = NULL);
TDongle();
virtual ~TDongle();

View File

@ -5,6 +5,7 @@
#define EFF_DATASCAD "DATASCAD"
#define EFF_TIPOPAG "TIPOPAG"
#define EFF_ULTCLASS "ULTCLASS"
#define EFF_TIPOCF "TIPOCF"
#define EFF_CODCF "CODCF"
#define EFF_NUMEMISS "NUMEMISS"
#define EFF_DATAEMISS "DATAEMISS"
@ -28,5 +29,6 @@
#define EFF_DISRIBAEST "DISRIBAEST"
#define EFF_IMPORTO "IMPORTO"
#define EFF_IMPORTOVAL "IMPORTOVAL"
#define EFF_ACCSAL "ACCSAL"
#endif

View File

@ -132,11 +132,17 @@
#define LF_STOBIL 125
#define LF_CARADD 126
#define LF_COLLDICH 127
#define LF_IDONEITA 128
#define LF_ATSTATS 129
#define LF_ATOPERA 130
#define LF_ATROPERA 131
#define LF_MRPREPORT 132
#define LF_INTRA 133
#define LF_RINTRA 134
#define LF_RIEPRETT 135
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
#define CNF_GENERAL 10000

View File

@ -1887,6 +1887,111 @@ void TMask::copy_values(
}
}
void TMask::make_profile_name(TFilename& f) const
{
f =::firm2dir(-1); // Directory dati
f.add("config"); // Directory config
f.add(source_file()); // Nome Maschera
f.ext("ini"); // Estensione
}
int TMask::save_profile(int num, const char* desc) const
{
TFilename prof;
make_profile_name(prof);
TConfig ini(prof, "Main");
if (num == 0)
num = ini.get_int(user());
if (num <= 0)
{
TString_array p;
TBit_array b(256);
b.set(255); b.set(); b.reset(0);
ini.list_paragraphs(p);
FOR_EACH_ARRAY_ROW_BACK(p, r, row)
{
num = atoi(*row);
if (num > 0)
b.reset(num);
}
num = int(b.first_one());
}
TString16 para; para << num;
ini.set(user(), para);
TString description = desc;
if (ini.set_paragraph(para))
{
if (description.blank())
description = ini.get("Description");
ini.remove_all();
}
else
{
if (description.blank())
description << "Profilo standard per " << user();
}
ini.set("Description", description);
TString16 name;
for (int i = 0; i < fields(); i++)
{
TMask_field& f = fld(i);
if (f.is_loadable() && f.get_default().empty())
{
name.format("F_%d", f.dlg());
if (f.is_sheet())
{
TSheet_field& s = (TSheet_field&)f;
FOR_EACH_SHEET_ROW(s, r, row)
ini.set(name, *row, NULL, TRUE, r);
}
else
ini.set(name, f.get());
}
}
return num;
}
int TMask::load_profile(int num)
{
TFilename prof;
make_profile_name(prof);
TConfig ini(prof, "Main");
if (num <= 0)
num = ini.get_int(user());
else
ini.set(user(), num);
TString16 name; name << num;
TAssoc_array& var = ini.list_variables(name);
for (int pos = fields()-1; pos >= 0; pos--)
{
TMask_field& f = fld(pos);
if (f.is_loadable() && f.get_default().empty())
{
name.format("F_%d", f.dlg());
if (f.is_sheet())
{
TSheet_field& sf = (TSheet_field&)f;
sf.destroy();
for (int r = 0; ini.exist(name,r); r++)
sf.row(r) = ini.get(name, NULL, r);
sf.force_update();
}
else
f.set(ini.get(name));
}
}
return num;
}
const char* TMask::get_caption(TString& str) const
{
char* title = str.get_buffer(128);

View File

@ -371,6 +371,13 @@ public:
// @cmember Copia i valori dei campi dalla maschera <p m>
void copy_values(const TMask &m);
// @cmember Crea il nome del file dei profili in <p f>
void make_profile_name(TFilename& f) const;
// @cmember Salva il profilo <p num>
int save_profile(int num = 0, const char* desc = NULL) const;
// @cmember Carica il profilo <p num>
int load_profile(int num = 0);
// @cmember Ritorna il primo campo dirty
short dirty() const;

View File

@ -447,6 +447,17 @@ const TString& TMask_field::get() const
return _ctl_data._park.cut(0);
}
void TMask_field::set_default(const char*)
{
NFCHECK("Only loadables can have a default");
}
const TString& TMask_field::get_default() const
{
NFCHECK("Only loadables can have a default");
return EMPTY_STRING;
}
// @doc EXTERNAL
// @mfunc Verifica se il campo deve essere sottoposto a check
@ -950,6 +961,29 @@ bool TOperable_field::on_hit()
return ok;
}
///////////////////////////////////////////////////////////
// TLoadable_field
///////////////////////////////////////////////////////////
bool TLoadable_field::parse_item(TScanner& scanner)
{
if (scanner.key() == "DE") // DEFAULT
{
set_default(scanner.line());
return TRUE;
}
return TOperable_field::parse_item(scanner);
}
// @cmember Ritorna il valore di default del campo
const TString& TLoadable_field::get_default() const
{ return _default; }
// @cmember Imposta il valore di default del campo
void TLoadable_field::set_default(const char* def)
{ _default = def; }
///////////////////////////////////////////////////////////
// Button_field
///////////////////////////////////////////////////////////
@ -1160,7 +1194,6 @@ TOperable_field* TEditable_field::add_driver(short id)
}
else
{
TOperable_field* driver = NULL;
const int pos = mask().id2pos(id);
if (pos >= 0)
{
@ -1178,7 +1211,7 @@ TOperable_field* TEditable_field::add_driver(short id)
_drivers->add(driver);
}
else
NFCHECK("Non esiste ancora il campo driver %d", id);
NFCHECK("Non esiste il campo driver %d per il campo %d", id, dlg());
return driver;
}
@ -1260,7 +1293,7 @@ bool TEditable_field::parse_item(TScanner& scanner)
return TRUE;
}
return TOperable_field::parse_item(scanner);
return TLoadable_field::parse_item(scanner);
}
void TEditable_field::set_key(byte key)
@ -2596,6 +2629,184 @@ bool TFile_select::check(CheckTime ct)
return ok;
}
///////////////////////////////////////////////////////////
// TProfile_select
///////////////////////////////////////////////////////////
TProfile_select::TProfile_select(TEdit_field* ef)
: TBrowse_button(ef)
{ }
void TProfile_select::parse_input(TScanner& scanner)
{
scanner.pop();
}
void TProfile_select::parse_output(TScanner& scanner)
{
scanner.pop();
}
HIDDEN int get_profile_desc(TConfig& cfg, void* jolly)
{
const int num = atoi(cfg.get_paragraph());
if (num > 0)
{
TString_array& p = *(TString_array*)jolly;
TToken_string* str = new TToken_string;
str->format("%4d", num);
str->add(cfg.get("Description"));
p.add(str);
}
return FALSE;
}
int TProfile_select::get_descriptions(TString_array& a) const
{
TFilename profname;
field().mask().make_profile_name(profname);
TConfig prof(profname);
a.destroy();
prof.for_each_paragraph(get_profile_desc, &a);
a.sort();
return a.items();
}
KEY TProfile_select::run()
{
TArray_sheet p(3, 3, -3, -3, "Profili", "Codice@6R|Descrizione@60", 0x6, 2);
const short id = DLG_USER+1;
TEdit_field& prompt = p.add_string(id, 0, "Salva con nome ", 1, 0, 60);
p.add_button(DLG_SAVEREC, "~Registra", K_CTRL+'r', BMP_SAVEREC, BMP_SAVERECDN);
prompt.set(field().get());
TMask& m = field().mask();
TFilename profname; m.make_profile_name(profname);
bool running = TRUE;
KEY key;
while (running)
{
p.destroy();
TString_array& a = p.rows_array();
get_descriptions(a);
p.field(DLG_SAVEREC).enable(a.items()>0);
FOR_EACH_ARRAY_ROW_BACK(a, r, row)
if (field().get() == row->get(1)) break;
if (r)
p.select(r);
key = p.run();
switch(key)
{
case K_ENTER:
{
const int num = p.row().get_int(0);
TString16 para; para << m.load_profile(num);
prompt.set(p.row().get(1));
running = FALSE;
}
break;
case K_CTRL+'r':
{
const TString& name = p.get(id);
FOR_EACH_ARRAY_ROW_BACK(a, r, row)
if (r != p.selected() && name == row->get(1)) break;
if (r < 0)
{
const int num = p.row().get_int(0);
m.save_profile(num, name);
running = FALSE;
}
else
error_box("Esiste gia' un profilo di nome\n%s",
(const char*)name);
}
break;
case K_INS:
{
const TString& name = p.get(id);
if (!name.blank())
{
FOR_EACH_ARRAY_ROW_BACK(a, r, row)
if (name == row->get(1)) break;
if (r < 0)
{
TString16 para; para << m.save_profile(-1, name);
field().set(name);
running = FALSE;
}
else
error_box("Esiste gia' un profilo di nome\n%s",
(const char*)name);
}
else
error_box("E' necessario dare un nome al profilo");
}
break;
case K_DEL:
{
TString16 para; para << p.row().get_int(0);
const TString desc = p.row().get(1);
TConfig prof(profname, para);
if (yesno_box("Confermare la cancellazione del profilo %s\n%s",
(const char*)para, (const char*)desc))
prof.remove_all();
}
break;
default:
running = FALSE;
break;
}
}
field().set(prompt.get());
return key;
}
bool TProfile_select::check(CheckTime ct)
{
switch (ct)
{
case STARTING_CHECK:
{
TMask& m = field().mask();
TFilename name; m.make_profile_name(name);
TString16 para; para << m.load_profile();
TConfig ini(name, para);
field().set(ini.get("Description"));
}
break;
case RUNNING_CHECK:
if (!field().empty())
{
const TString& name = field().get();
TString_array a;
get_descriptions(a);
FOR_EACH_ARRAY_ROW_BACK(a, r, row)
{
if (name == row->get(1))
{
field().mask().load_profile(row->get_int(0));
break;
}
}
if (r < 0)
return field().error_box("Profilo inesistente");
}
break;
case FINAL_CHECK:
if (!field().active())
{
TMask& m = field().mask();
m.save_profile();
}
break;
default:
break;
}
return TRUE;
}
///////////////////////////////////////////////////////////
// TEdit_field
///////////////////////////////////////////////////////////
@ -2811,6 +3022,18 @@ bool TEdit_field::parse_item(TScanner& scanner)
return TRUE;
}
if (scanner.key() == "PS") // PSELECT
{
#ifdef DBG
if (_browse)
NFCHECK("PSELECT duplicato nel campo %d", _ctl_data._dlg);
#endif
_browse = new TProfile_select(this);
_check_enabled = TRUE;
set_default("NONE");
return TRUE;
}
if (scanner.key() == "IT") // ITEM
{
#ifdef DBG
@ -4133,9 +4356,12 @@ int TList_field::str2curr(const char* data)
if (i < 0)
{
if (items() && str.not_empty())
NFCHECK("'%s' non e' un valore valido per il campo %s: %d",
data, prompt(), dlg());
if (shown() || ghost())
{
if (items() && str.not_empty())
NFCHECK("'%s' non e' un valore valido per il campo %s: %d",
data, prompt(), dlg());
}
i = 0;
}
return i;

View File

@ -314,6 +314,12 @@ public:
// @cmember Ritorna il contenuto del campo
virtual const TString& get() const;
// @cmember Ritorna il default del campo
virtual const TString& get_default() const;
// @cmember Setta il default del campo
virtual void set_default(const char*);
virtual bool empty() const { return FALSE; }
@ -534,7 +540,11 @@ public:
// @base public | TOperable_field
class TLoadable_field : public TOperable_field
{
TString _default;
public:
virtual bool parse_item(TScanner& scanner);
// @cmember Legge dalla relazione il valore del campo
virtual bool autoload(const TRelation& r) pure;
@ -543,7 +553,13 @@ public:
// @cmember Ritorna TRUE se il campo e' caricabile da file
virtual bool is_loadable() const { return TRUE; }
// @cmember Ritorna il valore di default del campo
virtual const TString& get_default() const;
// @cmember Imposta il valore di default del campo
virtual void set_default(const char* def);
// @cmember costruttore
TLoadable_field(TMask* mask): TOperable_field(mask) {};
// @cmember distruttore
@ -958,6 +974,30 @@ public:
virtual ~TFile_select() { }
};
class TProfile_select : public TBrowse_button
{
protected:
// @cmember Controlla la sintassi della input del campo e ne setta i membri
virtual void parse_input(TScanner& scanner);
// @cmember Controlla la sintassi della output del campo e ne setta i membri
virtual void parse_output(TScanner& scanner);
public:
virtual KEY run();
// @cmember Controlla la validita' del campo
virtual bool check(CheckTime = RUNNING_CHECK);
// @cmember E' un campo profilo
virtual bool is_profile() const { return TRUE; }
// @cmember Estrae dal .ini tutti i profili
int get_descriptions(TString_array& a) const;
TProfile_select(TEdit_field* ef);
virtual ~TProfile_select() { }
};
// @doc EXTERNAL

View File

@ -191,6 +191,7 @@ public:
void show_column(int col, bool on = TRUE);
// @cmember Permette di eliminare una colonna dallo spreadsheet
void delete_column(const int col) const;
bool exist_column(const int col) const { return find_column(col) != NULL; }
// @cmember Sposta la colonna dalla posizione <p fromindex> alla posizione
// <p toindex>
void move_column(const int fromindex, const int toindex) const;
@ -856,7 +857,7 @@ const char* TSpreadsheet::copy_cell2field(XI_OBJ* cell)
if (_edit_field->is_editable())
{
if (_edit_field->class_id() == CLASS_ZOOM_FIELD)
_edit_field->set(row(_cur_row).get(cid2index(_edit_field->dlg())));
_edit_field->set(row(_cur_rec).get(cid2index(_edit_field->dlg())));
const char* val = _edit_field->is_kind_of(CLASS_LIST_FIELD) ? txt :
(const char*)((TEditable_field*)_edit_field)->win2raw(txt);
@ -2055,7 +2056,7 @@ void TSpreadsheet::set_columns_order(TToken_string* order)
if (focus)
xi_set_focus(focus);
}
// Certified 99%
// @doc INTERNAL
@ -2463,6 +2464,12 @@ bool TSheet_field::column_disabled(int column) const
return s->column_disabled(column);
}
bool TSheet_field::exist_column(const int column) const
{
TSpreadsheet* s = (TSpreadsheet*)_ctl;
return s->exist_column(column);
}
bool TSheet_field::cell_disabled(int row, int column) const
{
TSpreadsheet* s = (TSpreadsheet*)_ctl;

View File

@ -98,11 +98,11 @@ protected:
// @cmember Ricopia i campi del record <p n>-esimo nella maschera
virtual void row2mask(int n, TToken_string & rec, int mode = 0x3);
// @access Public Member
public:
// @cmember Permette di mettere il focus su una cella
void set_focus_cell(int riga, int colonna);
// @access Public Member
public:
// @cmember Gestisce la pressione del tasto (TRUE se la gestione ha avuto successo)
virtual bool on_key(KEY k);
@ -195,6 +195,7 @@ public:
void show_column(int col, bool on) const;
// @cmember Permette di eliminare una colonna dallo spreadsheet
void delete_column( const int col ) const;
bool exist_column(const int col) const;
// @cmember Sposta la colonna dalla posizione <p fromindex> alla posizione
// <p toindex>
void move_column( const int fromindex, const int toindex ) const;

View File

@ -687,9 +687,9 @@ const TString& TRecord_cache::get(const char* key, const char* field)
// TDB_cache
///////////////////////////////////////////////////////////
TRecord_cache& TDB_cache::cache(int file)
TRecord_cache& TDB_cache::rec_cache(int file)
{
CHECKD(file >= LF_USER && file < LF_EXTERNAL, "Invalid file ", file);
CHECKD(file >= LF_USER, "Invalid file ", file);
TRecord_cache* rc = (TRecord_cache*)objptr(file);
if (rc == NULL)
{
@ -713,7 +713,26 @@ const TRectype& TDB_cache::get(const char* table, const char* key)
}
TString80 tabkey;
tabkey << table << '|' << key;
return get(file, key);
return get(file, tabkey);
}
bool TDB_cache::discard(int file, const char* key)
{
return rec_cache(file).discard(key);
}
bool TDB_cache::discard(const char *table, const char* key)
{
CHECK(table && *table, "Invalid Table code");
int file = LF_TAB;
if (*table == '%')
{
file = LF_TABCOM;
table++;
}
TString80 tabkey;
tabkey << table << '|' << key;
return rec_cache(file).discard(tabkey);
}
TDB_cache& cache()
@ -724,3 +743,5 @@ TDB_cache& cache()
return *_frate_cercone;
}
TRecord_cache& rec_cache(int file)
{ return cache().rec_cache(file); }

View File

@ -230,20 +230,33 @@ public:
class TDB_cache : public TArray
{
protected:
TRecord_cache& cache(int file);
public:
TRecord_cache& rec_cache(int file);
bool discard(int file, const char* key);
bool discard(const char *table, const char* key);
void flush(int file) { rec_cache(file).flush(); }
const TRectype& get(int file, const char* key)
{ return cache(file).get(key); }
{ return rec_cache(file).get(key); }
const TRectype& get(int file, long key)
{ return cache(file).get(key); }
{ return rec_cache(file).get(key); }
const TRectype& get(const char* table, const char* key);
const TString& get(int file, const char* key, const char * campo)
{ return get(file, key).get(campo); }
const TString& get(int file, long key, const char * campo)
{ return get(file, key).get(campo); }
const TString& get(const char* table, const char* key, const char * campo)
{ return get(table, key).get(campo); }
void test_file_changes(int file, bool t = TRUE)
{ rec_cache(file).test_file_changes(t); }
};
TDB_cache& cache();
TRecord_cache& rec_cache(int file);
#endif

View File

@ -16,5 +16,6 @@
#define REFF_IMPORTO "IMPORTO"
#define REFF_IMPFATTVAL "IMPFATTVAL"
#define REFF_IMPORTOVAL "IMPORTOVAL"
#define REFF_ACCSAL "ACCSAL"
#endif

View File

@ -4,6 +4,7 @@
#include <stdarg.h>
#include <strstrea.h>
#include <dongle.h>
#include <real.h>
#include <regexp.h>
#include <utility.h>
@ -283,7 +284,8 @@ TString& TString::strip(
for (int i = 0; _str[i]; i++)
{
char c = _str[i];
if (strchr(k, c) == NULL) _str[j++] = c;
if (strchr(k, c) == NULL)
_str[j++] = c;
}
return cut(j);
}
@ -442,9 +444,8 @@ bool TString::match(const char* pat) const
int TString::replace(char find_char, char replace_char)
{
const int l = len();
int n = 0;
for (int i = 0; i < l; i++)
for (int i = 0; _str[i]; i++)
if (_str[i] == find_char)
{
_str[i] = replace_char;
@ -541,9 +542,8 @@ TString& TString::cut(int n)
// @mfunc Espande la stringa fino alla lunghezza indicata, eventualmente aggiungendo spazi a destra
TString& TString::rpad(const int n,const char c)
{
const int & l= len();
if (n>l)
const int l = len();
if (n > l)
{
if (n > size()) resize(n, TRUE);
memset(_str+l, c, n-l);
@ -1175,7 +1175,7 @@ const TFilename& TFilename::tempdir()
TString16 theuser(user());
if (theuser.empty())
theuser = "prassi";
theuser = ::dongle().administrator();
theuser.lower();
const int f = _tempdir.find(theuser);
if (f < 0 || f != _tempdir.len() - theuser.len())

View File

@ -1,9 +1,12 @@
#include <defmask.h>
#include <stdlib.h>
#include <ctype.h>
#include <expr.h>
#include <isam.h>
#include <mask.h>
#include <prefix.h>
#include <recarray.h>
#include <validate.h>
#include <defmask.h>
#include <nditte.h>
@ -127,16 +130,17 @@ bool pi_check(
return ok;
}
// Controlla la partita iva se e' non vuota
// Controlla la partita iva se e' non vuota ed italiana
HIDDEN bool _pi_val(TMask_field& f, KEY)
{
TMask& m = f.mask();
{
const TMask& m = f.mask();
if (m.query_mode())
return TRUE;
const TString& stato = m.get(atoi(get_val_param(0)));
const TString& pi = f.get();
bool ok = pi_check(stato, pi);
bool ok = pi_check (stato, pi);
if (!ok)
{
if(f.dirty())
@ -144,8 +148,7 @@ HIDDEN bool _pi_val(TMask_field& f, KEY)
ok = f.yesno_box("Partita IVA errata, la accetto ugualmente?");
if (ok) f.set_dirty(FALSE);
}
else
ok = TRUE; // Era gia' errata e la ho accettata
else ok = TRUE; // Era gia' errata e la ho accettata
}
return ok;
}
@ -263,29 +266,29 @@ HIDDEN bool _cf_val(TMask_field& f, KEY key)
HIDDEN bool _xt_pi_val(TMask_field& f, KEY key)
{
TMask& m = f.mask();
if (m.query_mode())
return TRUE;
if (m.query_mode()) return TRUE;
TString16 value = f.get();
TString16 value(f.get());
if (value.empty())
return f.error_box("Partita IVA obbligatoria");
return f.error_box("Partita IVA obbligatoria");
if (!_pi_val(f, key))
return FALSE;
const TString& stato = m.get(atoi(get_val_param(0)));
// if (stato.not_empty() && stato != "IT") return TRUE;
if (stato.empty() || stato == "IT")
{
const int pi = atoi(value.mid(7,3));
{
TLocalisamfile c(LF_COMUNI);
const int pi = atoi(value.mid(7,3));
for (int i = 1 ; i < 3; i++)
{
const short id_comune = short(atoi(get_val_param(i)));
if (id_comune > 0 && !m.field(id_comune).empty())
const int comune = atoi(get_val_param(i));
if (comune > 0 && !m.field(comune).empty())
{
TString16 codcom; codcom << " |" << m.get(id_comune);
const TRectype& c = cache().get(LF_COMUNI, codcom);
if (!c.empty())
const TString16 com(m.get(comune)); // Comune residenza fiscale e residenza
c.zero();
c.put("COM", com);
if (c.read() == NOERR)
{
const int s1 = c.get_int("UFFIVA1");
const int s2 = c.get_int("UFFIVA2");
@ -308,6 +311,7 @@ HIDDEN bool _xt_pi_val(TMask_field& f, KEY key)
return TRUE;
}
HIDDEN bool _xtz_pi_val(TMask_field& f, KEY key)
{
if (f.empty() || f.mask().query_mode())
@ -320,7 +324,7 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
{
if (f.mask().query_mode()) return TRUE;
TString16 cf = f.get();
TString16 cf(f.get());
if (cf.empty()) return f.error_box("Codice fiscale obbligatorio");
if (!_cf_val(f, key)) return FALSE;
@ -416,26 +420,27 @@ HIDDEN bool _xt_cf_val(TMask_field& f, KEY key)
}
HIDDEN bool _xtz_cf_val(TMask_field& f, KEY key)
HIDDEN bool _xtz_cf_val(TMask_field& f, KEY key)
{
if (f.empty() || f.mask().query_mode())
return TRUE;
return _xt_cf_val(f, key);
if (f.mask().query_mode()) return TRUE;
const char* cf = f.get();
return (*cf == '\0') ? TRUE : _xt_cf_val(f, key);
}
HIDDEN bool _notempty_val(TMask_field& f, KEY)
{
return f.mask().query_mode() || !f.empty();
return f.mask().query_mode() || f.get().not_empty();
}
HIDDEN bool _date_cmp(TMask_field& f, KEY)
{
if (f.empty())
return TRUE;
TFixed_string s(f.get());
if (s.empty()) return TRUE;
TDate d0(f.get()), d1(f.mask().get(atoi(get_val_param(1))));
TDate d0(s), d1(f.mask().get(atoi(get_val_param(1))));
TFixed_string op(get_val_param(0));
if (op == "==") return d0 == d1;
@ -453,16 +458,15 @@ HIDDEN bool _date_cmp(TMask_field& f, KEY)
}
HIDDEN bool _fixlen_val(TMask_field& f, KEY)
HIDDEN bool _fixlen_val(TMask_field& f, KEY)
{
if (f.empty())
return TRUE;
const TFixed_string s(f.get());
if (s.empty()) return TRUE;
const TString& s = f.get();
const int length = atoi(get_val_param(0));
const bool ok = s.len() == length;
if (!ok)
f.error_box("Lunghezza errata: deve essere %d", length);
if (!ok) f.error_box("Lunghezza errata: deve essere %d", length);
return ok;
}
@ -470,36 +474,28 @@ HIDDEN bool _fixlen_val(TMask_field& f, KEY)
HIDDEN bool _mtcheck_val(TMask_field& f, KEY)
{
const int month = atoi(f.get());
if (month < 1 || month > 13)
return FALSE;
/*
if (month < 1 || month > 13) return FALSE;
TLocalisamfile d(LF_NDITTE);
d.zero();
d.put(NDT_CODDITTA, prefix().get_codditta());
d.read();
if (d.bad())
return TRUE;
if (d.get_char(NDT_FREQVIVA) == 'M')
return TRUE;
if (d.bad()) return TRUE;
if (d.get_char(NDT_FREQVIVA) == 'M') return TRUE;
return month == 13 || (month % 3) == 0;
*/
const TRectype& d = cache().get(LF_NDITTE, prefix().get_codditta());
if (d.get_char(NDT_FREQVIVA) == 'T')
return month == 13 || (month % 3) == 0;
return TRUE;
}
HIDDEN bool _reqif_val(TMask_field& f, KEY k)
{
if (k == K_ENTER && f.empty())
if (k == K_ENTER)
{
const TMask& m = f.mask();
if (f.get().not_empty()) return TRUE;
const int nparms = get_val_param_num();
for (int i = 0; i < nparms; i++)
for (int i = 0 ; i < nparms; i++)
{
const short id = f.atodlg(get_val_param(i));
if (id > 0 && !m.field(id).empty())
const short id = atoi(get_val_param(i));
if (id > 0 && f.mask().get(id).not_empty())
return FALSE;
}
}
@ -509,8 +505,9 @@ HIDDEN bool _reqif_val(TMask_field& f, KEY k)
HIDDEN bool _autoexit_val(TMask_field& f, KEY key)
{
const TMask& m = f.mask();
if (key == K_ENTER || !m.query_mode() )
TMask& m = f.mask();
if (!m.query_mode() || key == K_ENTER)
return TRUE;
/*
@ -566,7 +563,7 @@ HIDDEN bool _numcalc_val(TMask_field& f, KEY k)
const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
}
const TString& s = e.as_string();
const TFixed_string s(e.as_string());
f.set(s);
return TRUE;
}
@ -589,7 +586,7 @@ HIDDEN bool _strcalc_val(TMask_field& f, KEY k)
const int fldid = atoi(s);
e.setvar(i, fldid == 0 ? f.get() : f.mask().get(fldid));
}
const TString& s = e.as_string();
TFixed_string s( e.as_string());
f.set(s);
return TRUE;
}
@ -597,11 +594,11 @@ HIDDEN bool _strcalc_val(TMask_field& f, KEY k)
HIDDEN bool _onereq_val(TMask_field& f, KEY k)
{
if (k != K_ENTER) return TRUE;
const TMask& m = f.mask();
if (k != K_ENTER || m.query_mode())
return TRUE;
if (m.mode() == MODE_QUERY) return TRUE;
const int nparms = get_val_param_num();
for (int i = 0; i < nparms ; i++)
{
const char* s = m.get(atoi(get_val_param(i)));
@ -793,19 +790,9 @@ HIDDEN bool _ora_val(TMask_field& f, KEY key)
return TRUE;
}
HIDDEN bool _firm_val(TMask_field& f, KEY key)
{
bool ok = TRUE;
if (f.to_check(key))
{
const long firm = atol(f.get());
if (firm > 0 && !prefix().exist(firm))
ok = f.error_box("Non esistono gli archivi della ditta %ld.", firm);
}
return ok;
}
#define MAX_FUNC 25
#define MAX_FUNC 24
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{
@ -833,7 +820,7 @@ HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
_not_empty_chkfld_val,
_ora_val,
_sconto_val,
_firm_val,
};
// @doc INTERNAL