diff --git a/lib/.gitignore b/lib/.gitignore new file mode 100644 index 000000000..7d1321348 --- /dev/null +++ b/lib/.gitignore @@ -0,0 +1,17 @@ +/*.pdb +/*.exp +/*.bsc +/AgaLib.lib +/cb6.lib +/gfm.lib +/pdflib.lib +/vedoc.lib +/vedocext.lib +/xi.lib +/xvaga.lib +/xvapp.lib +/ServerLib.lib +/Uno.lib +/hlw32_mc.lib +/pdflibwrap.lib +/xid.lib diff --git a/lib/AgaLib.lib b/lib/AgaLib.lib deleted file mode 100644 index c4ac0ecf0..000000000 Binary files a/lib/AgaLib.lib and /dev/null differ diff --git a/lib/ServerLib.lib b/lib/ServerLib.lib deleted file mode 100644 index 6dd387d58..000000000 Binary files a/lib/ServerLib.lib and /dev/null differ diff --git a/lib/Uno.lib b/lib/Uno.lib deleted file mode 100644 index 584c6e2eb..000000000 Binary files a/lib/Uno.lib and /dev/null differ diff --git a/lib/cb6.exp b/lib/cb6.exp deleted file mode 100644 index 7efc024e8..000000000 Binary files a/lib/cb6.exp and /dev/null differ diff --git a/lib/cb6.lib b/lib/cb6.lib deleted file mode 100644 index eae1e8ab6..000000000 Binary files a/lib/cb6.lib and /dev/null differ diff --git a/lib/gfm.exp b/lib/gfm.exp deleted file mode 100644 index bee7555c3..000000000 Binary files a/lib/gfm.exp and /dev/null differ diff --git a/lib/gfm.lib b/lib/gfm.lib deleted file mode 100644 index 9a0c91fdf..000000000 Binary files a/lib/gfm.lib and /dev/null differ diff --git a/lib/hlw32_mc.lib b/lib/hlw32_mc.lib deleted file mode 100644 index c0a1902d9..000000000 Binary files a/lib/hlw32_mc.lib and /dev/null differ diff --git a/lib/pdflib.exp b/lib/pdflib.exp deleted file mode 100644 index 13064f3ff..000000000 Binary files a/lib/pdflib.exp and /dev/null differ diff --git a/lib/pdflib.lib b/lib/pdflib.lib deleted file mode 100644 index 0c1b12e23..000000000 Binary files a/lib/pdflib.lib and /dev/null differ diff --git a/lib/pdflib_dll.bsc b/lib/pdflib_dll.bsc deleted file mode 100644 index 2028921da..000000000 Binary files a/lib/pdflib_dll.bsc and /dev/null differ diff --git a/lib/pdflibwrap.lib b/lib/pdflibwrap.lib deleted file mode 100644 index 3851f1b40..000000000 Binary files a/lib/pdflibwrap.lib and /dev/null differ diff --git a/lib/vedoc.lib b/lib/vedoc.lib deleted file mode 100644 index f174616c6..000000000 Binary files a/lib/vedoc.lib and /dev/null differ diff --git a/lib/vedocext.lib b/lib/vedocext.lib deleted file mode 100644 index 5d8bfa873..000000000 Binary files a/lib/vedocext.lib and /dev/null differ diff --git a/lib/xi.bsc b/lib/xi.bsc deleted file mode 100644 index f1b4d5143..000000000 Binary files a/lib/xi.bsc and /dev/null differ diff --git a/lib/xi.exp b/lib/xi.exp deleted file mode 100644 index 5491c02da..000000000 Binary files a/lib/xi.exp and /dev/null differ diff --git a/lib/xi.lib b/lib/xi.lib deleted file mode 100644 index da06f540b..000000000 Binary files a/lib/xi.lib and /dev/null differ diff --git a/lib/xid.exp b/lib/xid.exp deleted file mode 100644 index 1f06ec738..000000000 Binary files a/lib/xid.exp and /dev/null differ diff --git a/lib/xid.lib b/lib/xid.lib deleted file mode 100644 index b91f53864..000000000 Binary files a/lib/xid.lib and /dev/null differ diff --git a/lib/xvaga.bsc b/lib/xvaga.bsc deleted file mode 100644 index d73b3d449..000000000 Binary files a/lib/xvaga.bsc and /dev/null differ diff --git a/lib/xvaga.exp b/lib/xvaga.exp deleted file mode 100644 index d07b9e6d2..000000000 Binary files a/lib/xvaga.exp and /dev/null differ diff --git a/lib/xvaga.lib b/lib/xvaga.lib deleted file mode 100644 index 4647cfa7a..000000000 Binary files a/lib/xvaga.lib and /dev/null differ diff --git a/lib/xvapp.lib b/lib/xvapp.lib deleted file mode 100644 index 431bbe7c0..000000000 Binary files a/lib/xvapp.lib and /dev/null differ diff --git a/src/fp/fp0300.cpp b/src/fp/fp0300.cpp index d0e0d28d8..671cc674d 100644 --- a/src/fp/fp0300.cpp +++ b/src/fp/fp0300.cpp @@ -743,14 +743,13 @@ bool TDoc2Paf::create() { open_files(LF_TAB, LF_TABCOM, LF_TABMOD, LF_ANAG, LF_CLIFO, LF_CFVEN, LF_CFBAN, LF_NDITTE, - LF_DOC, LF_RIGHEDOC, 0); + LF_DOC, LF_RIGHEDOC, LF_CODCORR, LF_ANAMAG, 0); - TRectype cfven(LF_CFVEN); + const TRectype cfven(LF_CFVEN); if (cfven.length(CFV_PADESTIN) != 7) // Nuova lunghezza per privati return error_box(TR("Database non convertito per fatturazione F.P.")); return check_tables() && TSkeleton_application::create(); - } bool TDoc2Paf::destroy() diff --git a/src/fp/fplib.h b/src/fp/fplib.h index 146f2fba3..b1e5f26df 100644 --- a/src/fp/fplib.h +++ b/src/fp/fplib.h @@ -389,7 +389,8 @@ private: enum TFP_operator { error, eq, neq, gt, ls, gteq, lseq, and, or }; // Etrattori - static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search); + static void extract_info(const TString& expr, TString& tabella, TString& campo); + static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key); static bool calc_table(const TString& tabella, int& file); static void split_condition(const TString& cond, TString& cond_sx, TString& cond_dx, TFP_operator& symb); static TVariant& get_value(const TRectype& rec, const TString& campo); diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index 6d9a64aff..dcf5b75d0 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -51,6 +51,7 @@ bool set_connection(SSimple_query& s) #endif return ok; } + SSimple_query& fp_db() { static SSimple_query* db = nullptr; @@ -63,6 +64,7 @@ SSimple_query& fp_db() } return *db; } + bool run_fp_psw_mask() { static TMask* m; diff --git a/src/fp/fplib05.cpp b/src/fp/fplib05.cpp index 672fbd1e8..c486b54a0 100644 --- a/src/fp/fplib05.cpp +++ b/src/fp/fplib05.cpp @@ -255,8 +255,6 @@ TFP_custom_cache::TFP_custom_cache() } } - - /****************************************************************************** * TFP_expression *******************************************************************************/ @@ -364,7 +362,7 @@ bool TFP_expression::check_condition(const TString& cond, TRiga_documento& rdoc) } } -void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search) +void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo) { // Prendo la stringa pulita della parte sinistra TString clean_expr = expr.mid(expr.find('(') + 1); @@ -377,13 +375,38 @@ void TFP_expression::extract_info(const TString& expr, TString& tabella, TString // Trimmare sempre come se non sapessi fare altro nella vita tabella.cut(0) << info.remove(0); tabella.trim(); campo.cut(0) << info.remove(0); campo.trim(); - if (search != nullptr) +} + + +void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key) +{ + // Prendo la stringa pulita della parte sinistra + TString clean_expr = expr.mid(expr.find('(') + 1); + // Tolgo eventuali spazi ai lati + clean_expr.trim(); + // Tolgo la virgola finale + clean_expr.rtrim(1); + TToken_string info(clean_expr, ','); + + // Trimmare sempre come se non sapessi fare altro nella vita + tabella.cut(0) << info.remove(0); tabella.trim(); + if(tabella.contains('.')) { - // Prendo il resto - search->cut(0) << info; - search->trim(); - search->restart(); + TToken_string app(tabella, '.'); + tabella = app.get(); + key = atoi(app.get()); } + else + { + key = 1; + } + + campo.cut(0) << info.remove(0); campo.trim(); + + // Prendo il resto e lo devolvo nella ricerca + search.cut(0) << info; + search.trim(); + search.restart(); } bool TFP_expression::calc_table(const TString& tabella, int& file) @@ -549,17 +572,26 @@ TVariant& TFP_expression::parse_var(const TString& str) TVariant& TFP_expression::parse_read(const TString& str, TRiga_documento& rdoc) { TString tabella, campo; - extract_info(str, tabella, campo, nullptr); + extract_info(str, tabella, campo); return do_read(tabella, campo, rdoc); } TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, TRiga_documento& rdoc) { - + const TDocumento& doc = rdoc.doc(); // Prima di tutto controllo se è una delle tabelle multitracciato che supporto if(tabella == "%TIP") { - return get_value(rdoc.doc().tipo(), campo); + return get_value(doc.tipo(), campo); + } + if(tabella == "%NUM") + { + return get_value(doc.codice_numerazione(), campo); + } + + if(tabella == "%CPG") + { + return get_value(cache().get("%CPG", doc.get(DOC_CODPAG)), campo); } int file; @@ -568,17 +600,19 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, switch (file) { case LF_DOC: - return get_value(rdoc.doc(), campo); + return get_value(doc, campo); case LF_RIGHEDOC: return get_value(rdoc, campo); case LF_CLIFO: - return get_value(rdoc.doc().clifor(), campo); + return get_value(doc.clifor(), campo); case LF_CFVEN: - return get_value(rdoc.doc().clifor().vendite(), campo); + return get_value(doc.clifor().vendite(), campo); case LF_LETINT: - return get_value(rdoc.doc().clifor().lettera(), campo); + return get_value(doc.clifor().lettera(), campo); case LF_ANAMAG: return get_value(rdoc.articolo(), campo); + case LF_CODCORR: + return get_value(cache().get(LF_CODCORR, rdoc.articolo().codice()), campo); default: static TVariant null_var(EMPTY_STRING); return null_var; @@ -588,10 +622,10 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc) { TString tabella, campo; - TToken_string input_search, search; - int file; + TToken_string input_search("", ';'), search; + int file, key; - extract_info(str, tabella, campo, &input_search); + extract_info(str, tabella, campo, input_search, key); const bool multi_table = calc_table(tabella, file); // Parso ogni singolo token della ricerca @@ -602,10 +636,10 @@ TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc if (multi_table) { - return get_value(cache().get(tabella, search), campo); + return get_value(cache().get(tabella, search, key), campo); } else { - return get_value(cache().get(file, search), campo); + return get_value(cache().get(file, search, key), campo); } } diff --git a/src/include/recarray.cpp b/src/include/recarray.cpp index bafdd3ced..f6ef8ac1d 100755 --- a/src/include/recarray.cpp +++ b/src/include/recarray.cpp @@ -957,13 +957,42 @@ int TDB_cache::build_table_key(const char* table, const char* key, TToken_string return file; } -const TRectype& TDB_cache::get(const char* table, const char* key) +const TRectype& TDB_cache::get(const int file, const char* key_tok, const int key) +{ + // Prendo la vecchia chiave + const int old_key = rec_cache(file).key_number(); + // Setto la nuova chiave + rec_cache(file).set_key(key); + // Poi chiamo la get normale + const TRectype& app = get(file, key_tok); + // Ripristino la vecchia chiave per mantenere la compatibilità con i metodi vecchi + // non vorrei rischiare che altre applicazioni si basano sulla chiave vecchia + rec_cache(file).set_key(old_key); + return app; +} + +const TRectype& TDB_cache::get(const char* table, const char* key_tok) { TToken_string tabkey; - const int file = build_table_key(table, key, tabkey); + const int file = build_table_key(table, key_tok, tabkey); return rec_cache(table).get(tabkey); } +const TRectype& TDB_cache::get(const char* table, const char* key_tok, const int key) +{ + TToken_string tabkey; + const int file = build_table_key(table, key_tok, tabkey); + + // Per il giro della vecchia chiave guardare get(const int, const char*, const int) + const int old_key = rec_cache(file).key_number(); + rec_cache(table).set_key(key); + const TRectype& app = rec_cache(table).get(tabkey); + + rec_cache(file).set_key(old_key); + return app; +} + + const TRectype& TDB_cache::get(const TRectype& curr) { const int num = curr.num(); // Numero logico del file (o tabella) diff --git a/src/include/recarray.h b/src/include/recarray.h index 2dfb7d425..b49293570 100755 --- a/src/include/recarray.h +++ b/src/include/recarray.h @@ -184,6 +184,7 @@ public: int io_result(); const int key_number() const { return _key; } + void set_key(const int key) { _key = key; } bool already_loaded(const char* code) const; bool already_loaded(long code) const; @@ -263,9 +264,11 @@ public: void flush(int file) { rec_cache(file).flush(); } void discard(int file); + const TRectype& get(int file, const char* key_tok, const int key); const TRectype& get(int file, const char* key_tok) { return rec_cache(file).get(key_tok); } const TRectype& get(int file, long key) { return rec_cache(file).get(key); } const TRectype& get(const char* table, const char* key_tok); + const TRectype& get(const char* table, const char* key_tok, const int key); const TRectype& get(const TRectype& key); const TRectype& get_rec(int file, char c, long n);