#ifndef __FPLIB01_H #define __FPLIB01_H #include #include #include #include "../ve/velib05.h" #include "../fe/felib.h" #include #include #define SQL_FLD "sql/" #define CARATTERI_SPECIALI "אטילעש°'\\" // Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione SSimple_query& fp_db(); // Controlla il livello di patch installato e aggiorna le tabelle se necessario bool check_tables(); // Genera la chiave per i paf bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt); bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt); bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString& pec); inline const TString& no_special(char a); // Contenitore di campi di un record di database MSSQLServer class TPaf_record : public TObject { TString8 _table; TToken_string _key; TAssoc_array _fields; protected: void copy(const TPaf_record& rec) { _table = rec._table; _key = rec._key; _fields = rec._fields; } const TString& var2str(const TString& fld, const TVariant& var) const; const TVariant& get(const char* fld) const; public: void reset() { _fields.destroy(); } void set(const char* fld, const TVariant& var); void set(const char* fld, long var); void set(const char* fld, const char* var); void set(const char* fld, const real& var); void set(const char* fld, const TString& var); void set(const char* fld, const TDate& var); void set(const char* fld, bool var); const TString sq_get(const char* fld) const; TString& insert_string(); bool insert(); TString& remove_string(); bool remove(); bool search(); bool search(const char* k1, const char* k2, const char* k3 = NULL); virtual TObject* dup() const { return new TPaf_record(*this); } virtual bool ok() const { return _table.not_empty(); } TPaf_record& operator=(const TPaf_record& rec) { copy(rec); return *this; } TPaf_record(const TPaf_record& rec) { copy(rec); } TPaf_record(const char* table); }; // Gestione PAF class TDoc_fp { private: TAnagrafica _ditta; TString16 _cofi; TFilename _dbname; TLog_report* _log; TString _logpaf; bool _gestioneallegati; bool _allegafattura; TString _def_fld; TString _def_usr_fld; bool _to_commit; bool _cache_insert; vector _query; int parse_line(const TString& line, TString& var, TString& val) const; bool create_table(TScanner& paf, const TString& table); const TRectype* find_parent_row(const TRectype& rdoc) const; int find_ancestors(const TRiga_documento& rdoc, TArray& ancestors) const; bool insert(TPaf_record& p); bool remove(TPaf_record& p); bool save_paf(); protected: bool parse_sconto(const TString& formula, TToken_string& sconti) const; static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban); bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const; const TString& descrizione(const TRiga_documento& rdoc) const; const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta void log(int severity, const char* msg); const char* natura(const TString& codiva) const; static void set_IVA(const TString& codiva, TPaf_record& paf); static void set_IVA(const TRiga_documento& rdoc, TPaf_record& paf); bool add_row_art(const TString codice_tipo, const TString& codice_valore, TPaf_record& paf); bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf); void set_descrizione(const TRiga_documento* doc); public: bool doc_to_paf(TDocumentoEsteso& doc); bool doc_to_paf(const TRectype& rec); bool doc_to_paf(const TDoc_key& key); bool doc_to_paf(const TFilename& ini); // Mostra il log a fine esecuzione bool show_log(); const int commit(); void set_cache_insert(const bool v) { _cache_insert = v; } TDoc_fp(); ~TDoc_fp(); }; #endif // __FPLIB01_H