Patch level : 12.0 no-patch
Files correlati : fp Commento : - Rename funzione db() to fp_db() - Aggiunti valori debug - Tolta obbligatorietà di essere non privati per il CIG e CUP
This commit is contained in:
parent
fdedce8cbb
commit
0996deaedf
@ -17,7 +17,7 @@ class TParametri_mask : public TAutomask
|
||||
private:
|
||||
void load_all();
|
||||
protected:
|
||||
void tipi_import();
|
||||
void tipi_import() const;
|
||||
static TMask& get_tmp_msk(const char* title);
|
||||
virtual bool on_key(KEY key);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
@ -58,7 +58,7 @@ void TParametri_mask::load_all()
|
||||
set(F_ESPORTADOC, ini_get_bool(CONFIG_DITTA, "fp", "allegafatt"));
|
||||
}
|
||||
|
||||
void TParametri_mask::tipi_import()
|
||||
void TParametri_mask::tipi_import() const
|
||||
{
|
||||
if(yesno_box("Attenzione! Questa procedura riporterà su tutti i documenti il tipo documento SDI della configurazione!\nEventuali modifiche già fatte verranno sovrascritte, continuare?"))
|
||||
{
|
||||
@ -161,8 +161,8 @@ bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jo
|
||||
{
|
||||
if (yesno_box("Sei sicuro di voler svuotare tutte le tabelle del database? Questa procedura NON É REVERSIBILE"))
|
||||
{
|
||||
db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'TRUNCATE TABLE ? '");
|
||||
db().sq_commit();
|
||||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'TRUNCATE TABLE ? '");
|
||||
fp_db().sq_commit();
|
||||
message_box("Procedura terminata");
|
||||
}
|
||||
}
|
||||
@ -172,8 +172,8 @@ bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jo
|
||||
{
|
||||
if (yesno_box("Sei sicuro di voler cancellare tutte le tabelle del database? Questa procedura NON É REVERSIBILE"))
|
||||
{
|
||||
db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||||
db().sq_commit();
|
||||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||||
fp_db().sq_commit();
|
||||
message_box("Procedura terminata");
|
||||
}
|
||||
}
|
||||
@ -183,14 +183,14 @@ bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jo
|
||||
{
|
||||
if (yesno_box("Sei sicuro di voler ricreare tutte le tabelle del database? Questa procedura NON É REVERSIBILE"))
|
||||
{
|
||||
db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||||
TLocalisamfile tabmod(LF_TABMOD);
|
||||
tabmod.put("MOD", "FP");
|
||||
tabmod.put("COD", "SQL");
|
||||
tabmod.put("CODTAB", "VERSION");
|
||||
tabmod.remove();
|
||||
check_tables();
|
||||
db().sq_commit();
|
||||
fp_db().sq_commit();
|
||||
message_box("Procedura terminata");
|
||||
}
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ bool TDoc2Paf::create()
|
||||
|
||||
bool TDoc2Paf::destroy()
|
||||
{
|
||||
db().sq_disconnect();
|
||||
fp_db().sq_disconnect();
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
|
@ -25,16 +25,23 @@
|
||||
|
||||
void set_connection(SSimple_query& s)
|
||||
{
|
||||
#ifdef DBG
|
||||
if (s.sq_connect("TESTCAMPO2012@campo_fp",
|
||||
"fp",
|
||||
"fp",
|
||||
TSDB_MSSQL) != NOERR)
|
||||
fatal_box("Impossibile connettersi al DB esterno");
|
||||
#elif
|
||||
if (s.sq_connect(
|
||||
TString() << ini_get_string(CONFIG_DITTA, "fp", "ip") << "@" << ini_get_string(CONFIG_DITTA, "fp", "db"),
|
||||
ini_get_string(CONFIG_DITTA, "fp", "usr"),
|
||||
decode(ini_get_string(CONFIG_DITTA, "fp", "psw")),
|
||||
TSDB_MSSQL) != NOERR)
|
||||
fatal_box("Impossibile connettersi al DB esterno");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
SSimple_query& db()
|
||||
SSimple_query& fp_db()
|
||||
{
|
||||
static SSimple_query* db = nullptr;
|
||||
|
||||
@ -92,9 +99,9 @@ bool check_tables()
|
||||
{
|
||||
string query = s.substr(0, limiter);
|
||||
s.erase(0, limiter);
|
||||
if(!db().sq_set_exec(query) || !db().sq_commit())
|
||||
if(!fp_db().sq_set_exec(query) || !fp_db().sq_commit())
|
||||
{
|
||||
fatal_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), db().sq_get_string_error());
|
||||
fatal_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), fp_db().sq_get_string_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -302,7 +309,7 @@ void TPaf_record::set(const char* fld, bool var)
|
||||
|
||||
const TString TPaf_record::sq_get(const char* fld) const
|
||||
{
|
||||
return db().sq_get(fld);
|
||||
return fp_db().sq_get(fld);
|
||||
}
|
||||
|
||||
// Legge il valore di un campo variant
|
||||
@ -377,7 +384,7 @@ TString& TPaf_record::remove_string()
|
||||
// Elimina il record in base ai campi chiave
|
||||
bool TPaf_record::remove()
|
||||
{
|
||||
return db().sq_set_exec(remove_string());
|
||||
return fp_db().sq_set_exec(remove_string());
|
||||
}
|
||||
|
||||
// Carica un record in base ai campi chiave
|
||||
@ -397,7 +404,7 @@ bool TPaf_record::search()
|
||||
|
||||
// return xvt_sql_execute(_db, query, paf_search_record, this) == 1;
|
||||
// TODO: Valutare
|
||||
return db().sq_set_exec(query);
|
||||
return fp_db().sq_set_exec(query);
|
||||
}
|
||||
|
||||
// Carica un record in base ad un massimo di 3 campi chiave
|
||||
@ -437,7 +444,7 @@ TString & TPaf_record::insert_string()
|
||||
// Aggiunge un record al db
|
||||
bool TPaf_record::insert()
|
||||
{
|
||||
return db().sq_set_exec(insert_string());
|
||||
return fp_db().sq_set_exec(insert_string());
|
||||
}
|
||||
|
||||
// Crea un record della tabella data ed imposta i nomi dei campi chiave
|
||||
@ -450,9 +457,9 @@ TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
|
||||
where K.[name] = '" << table << "_KEY' \
|
||||
AND idx.[object_id] = object_id('" << table << "') \
|
||||
ORDER BY index_column_id ASC";
|
||||
for (bool ok = db().sq_set_exec(q); ok; ok = db().sq_next())
|
||||
for (bool ok = fp_db().sq_set_exec(q); ok; ok = fp_db().sq_next())
|
||||
{
|
||||
_key.add(db().sq_get("name"));
|
||||
_key.add(fp_db().sq_get("name"));
|
||||
}
|
||||
CHECKS(!_key.empty_items(), "Invalid primary key for table ", table);
|
||||
}
|
||||
@ -657,7 +664,7 @@ bool TDoc_fp::insert(TPaf_record& p)
|
||||
ok = p.insert();
|
||||
if (!ok)
|
||||
{
|
||||
log(2, db().sq_get_string_error());
|
||||
log(2, fp_db().sq_get_string_error());
|
||||
log(2, p.insert_string());
|
||||
}
|
||||
}
|
||||
@ -677,7 +684,7 @@ bool TDoc_fp::remove(TPaf_record& p)
|
||||
ok = p.remove();
|
||||
if (!ok)
|
||||
{
|
||||
log(2, db().sq_get_string_error());
|
||||
log(2, fp_db().sq_get_string_error());
|
||||
log(2, p.remove_string());
|
||||
}
|
||||
}
|
||||
@ -692,10 +699,10 @@ bool TDoc_fp::save_paf()
|
||||
string query;
|
||||
for (auto i = _query.begin(); i != _query.end(); ++i)
|
||||
query += *i;
|
||||
ok = db().sq_set_exec(query);
|
||||
ok = fp_db().sq_set_exec(query);
|
||||
if (!ok)
|
||||
{
|
||||
log(2, db().sq_get_string_error());
|
||||
log(2, fp_db().sq_get_string_error());
|
||||
log(2, query.c_str());
|
||||
}
|
||||
}
|
||||
@ -754,14 +761,14 @@ const int TDoc_fp::commit()
|
||||
int r = 0;
|
||||
if (_to_commit)
|
||||
{
|
||||
if(db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'") && db().sq_commit())
|
||||
if(fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'") && fp_db().sq_commit())
|
||||
{
|
||||
r = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = -1;
|
||||
log(2, db().sq_get_string_error());
|
||||
log(2, fp_db().sq_get_string_error());
|
||||
log(2, "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'");
|
||||
}
|
||||
}
|
||||
@ -834,6 +841,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
|
||||
TString8 coddest = doc.clifor().vendite().get("PADESTIN");
|
||||
TString pec = doc.clifor().get("PEC");
|
||||
const bool is_pa = doc.clifor().get_int("ALLEG") == 7;
|
||||
|
||||
if (!get_coddest(doc.clifor().tipo(), doc.clifor().codice(), coddest, pec))
|
||||
return false;
|
||||
@ -1086,83 +1094,84 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
const TString16 cig = doc.get(DOC_CIG);
|
||||
const TString80 com = doc.get(DOC_CODCMS);
|
||||
|
||||
if (!privato)
|
||||
// SEMPRE
|
||||
// Azzera contratti
|
||||
TPaf_record paf1000f("PAF1000F");
|
||||
paf1000f.set("P0_KEYHEADERFATT", hfatt);
|
||||
paf1000f.set("P0_KEYBODYFATT", bfatt);
|
||||
paf1000f.set("P0_RIFNUMLINEA", 0L);
|
||||
remove(paf1000f);
|
||||
|
||||
// Azzera convenzioni
|
||||
TPaf_record paf1100f("PAF1100F");
|
||||
paf1100f.set("PA_KEYHEADERFATT", hfatt);
|
||||
paf1100f.set("PA_KEYBODYFATT", bfatt);
|
||||
paf1100f.set("PA_RIFNUMLINEA", 0L);
|
||||
remove(paf1100f);
|
||||
|
||||
// Azzera ordini
|
||||
TPaf_record paf1200f("PAF1200F");
|
||||
paf1200f.set("PB_KEYHEADERFATT", hfatt);
|
||||
paf1200f.set("PB_KEYBODYFATT", bfatt);
|
||||
paf1200f.set("PB_RIFNUMLINEA", 0L);
|
||||
remove(paf1200f);
|
||||
|
||||
TString80 con = doc.get(DOC_CONTRATTO);
|
||||
if (con.full() || cup.full() || cig.full())
|
||||
{
|
||||
// Azzera contratti
|
||||
TPaf_record paf1000f("PAF1000F");
|
||||
paf1000f.set("P0_KEYHEADERFATT", hfatt);
|
||||
paf1000f.set("P0_KEYBODYFATT", bfatt);
|
||||
remove(paf1000f);
|
||||
char tcon = doc.get_char(DOC_MODPAG);
|
||||
if (tcon < 'C') tcon = 'C';
|
||||
|
||||
// Azzera convenzioni
|
||||
TPaf_record paf1100f("PAF1100F");
|
||||
paf1100f.set("PA_KEYHEADERFATT", hfatt);
|
||||
paf1100f.set("PA_KEYBODYFATT", bfatt);
|
||||
remove(paf1100f);
|
||||
|
||||
// Azzera ordini
|
||||
TPaf_record paf1200f("PAF1200F");
|
||||
paf1200f.set("PB_KEYHEADERFATT", hfatt);
|
||||
paf1200f.set("PB_KEYBODYFATT", bfatt);
|
||||
remove(paf1200f);
|
||||
|
||||
TString80 con = doc.get(DOC_CONTRATTO);
|
||||
if (con.full() || cup.full() || cig.full())
|
||||
TDate datadoc; // Data contratto non obbligatoria
|
||||
if (con.full())
|
||||
{
|
||||
char tcon = doc.get_char(DOC_MODPAG);
|
||||
if (tcon < 'C') tcon = 'C';
|
||||
|
||||
TDate datadoc; // Data contratto non obbligatoria
|
||||
if (con.full())
|
||||
{
|
||||
datadoc = cco(doc).get_date("D0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// IdDocumento obbligatorio
|
||||
con = cig;
|
||||
if (con.blank())
|
||||
con = cup;
|
||||
}
|
||||
|
||||
if (tcon == 'O')
|
||||
{
|
||||
paf1000f.set("P0_RIFNUMLINEA", 0L);
|
||||
paf1000f.set("P0_IDDOC", con);
|
||||
paf1000f.set("P0_DATADOC", datadoc);
|
||||
paf1000f.set("P0_COMMCONVENZ", com);
|
||||
paf1000f.set("P0_CODCUP", cup);
|
||||
paf1000f.set("P0_CODCIG", cig);
|
||||
paf1000f.set("P0_GESTIONE", "D");
|
||||
ok &= insert(paf1000f);
|
||||
}
|
||||
else if (tcon == 'C')
|
||||
{
|
||||
paf1100f.set("PA_RIFNUMLINEA", 0L);
|
||||
paf1100f.set("PA_IDDOC", con);
|
||||
paf1100f.set("PA_DATADOCU", datadoc);
|
||||
paf1100f.set("PA_COMMCONVENZ", com);
|
||||
paf1100f.set("PA_CODCUP", cup);
|
||||
paf1100f.set("PA_CODCIG", cig);
|
||||
paf1000f.set("PA_GESTIONE", "D");
|
||||
ok &= insert(paf1100f);
|
||||
}
|
||||
else
|
||||
{
|
||||
paf1200f.set("PB_RIFNUMLINEA", 0L);
|
||||
paf1200f.set("PB_IDDOC", con);
|
||||
paf1200f.set("PB_DATADOCO", datadoc);
|
||||
paf1200f.set("PB_COMMCONVENZ", com);
|
||||
paf1200f.set("PB_CODCUP", cup);
|
||||
paf1200f.set("PB_CODCIG", cig);
|
||||
paf1200f.set("PB_GESTIONE", "D");
|
||||
ok &= insert(paf1200f);
|
||||
}
|
||||
datadoc = cco(doc).get_date("D0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// IdDocumento obbligatorio
|
||||
con = cig;
|
||||
if (con.blank())
|
||||
con = cup;
|
||||
}
|
||||
|
||||
if (cup.blank() && cig.blank())
|
||||
log(1, "CIG e CUP assenti");
|
||||
if (tcon == 'O')
|
||||
{
|
||||
paf1000f.set("P0_RIFNUMLINEA", 0L);
|
||||
paf1000f.set("P0_IDDOC", con);
|
||||
paf1000f.set("P0_DATADOC", datadoc);
|
||||
paf1000f.set("P0_COMMCONVENZ", com);
|
||||
paf1000f.set("P0_CODCUP", cup);
|
||||
paf1000f.set("P0_CODCIG", cig);
|
||||
paf1000f.set("P0_GESTIONE", "D");
|
||||
ok &= insert(paf1000f);
|
||||
}
|
||||
else if (tcon == 'C')
|
||||
{
|
||||
paf1100f.set("PA_RIFNUMLINEA", 0L);
|
||||
paf1100f.set("PA_IDDOC", con);
|
||||
paf1100f.set("PA_DATADOCU", datadoc);
|
||||
paf1100f.set("PA_COMMCONVENZ", com);
|
||||
paf1100f.set("PA_CODCUP", cup);
|
||||
paf1100f.set("PA_CODCIG", cig);
|
||||
paf1000f.set("PA_GESTIONE", "D");
|
||||
ok &= insert(paf1100f);
|
||||
}
|
||||
else
|
||||
{
|
||||
paf1200f.set("PB_RIFNUMLINEA", 0L);
|
||||
paf1200f.set("PB_IDDOC", con);
|
||||
paf1200f.set("PB_DATADOCO", datadoc);
|
||||
paf1200f.set("PB_COMMCONVENZ", com);
|
||||
paf1200f.set("PB_CODCUP", cup);
|
||||
paf1200f.set("PB_CODCIG", cig);
|
||||
paf1200f.set("PB_GESTIONE", "D");
|
||||
ok &= insert(paf1200f);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_pa && cup.blank() && cig.blank())
|
||||
log(1, "CIG e CUP assenti");
|
||||
// <DatiBeniServizi>
|
||||
|
||||
TPaf_record paf1800f("PAF1800F");
|
||||
@ -1324,12 +1333,9 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
paf1000f.set("P0_RIFNUMLINEA", (long)r);
|
||||
paf1000f.set("P0_IDDOC", a._numdoc);
|
||||
paf1000f.set("P0_DATADOC", a._datadoc);
|
||||
if (!privato)
|
||||
{
|
||||
paf1000f.set("P0_COMMCONVENZ", com);
|
||||
paf1000f.set("P0_CODCUP", cup);
|
||||
paf1000f.set("P0_CODCIG", cig);
|
||||
}
|
||||
paf1000f.set("P0_COMMCONVENZ", com);
|
||||
paf1000f.set("P0_CODCUP", cup);
|
||||
paf1000f.set("P0_CODCIG", cig);
|
||||
paf1000f.set("P0_GESTIONE", "D");
|
||||
ok &= insert(paf1000f);
|
||||
// </DatiOrdineAcquisto>
|
||||
@ -1590,7 +1596,7 @@ bool TDoc_fp::doc_to_paf(const TRectype& rec)
|
||||
TDocumentoEsteso doc;
|
||||
if (doc.read(rec) == NOERR)
|
||||
{
|
||||
return doc_to_paf(doc) ? db().sq_commit() : db().sq_rollback();
|
||||
return doc_to_paf(doc) ? fp_db().sq_commit() : fp_db().sq_rollback();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1623,8 +1629,12 @@ TDoc_fp::TDoc_fp() : _log(nullptr), _cache_insert(false)
|
||||
if (_cofi.blank())
|
||||
_cofi = _ditta.codice_fiscale();
|
||||
|
||||
#ifdef DBG
|
||||
_gestioneallegati = _allegafattura = false;
|
||||
#elif
|
||||
_gestioneallegati = ini_get_bool(CONFIG_DITTA, "fp", "gestioneallegati");
|
||||
_allegafattura = ini_get_bool(CONFIG_DITTA, "fp", "allegafatt");
|
||||
#endif
|
||||
|
||||
_def_fld = ini_get_string(CONFIG_DITTA, "fp", "flddest");
|
||||
if (!_def_fld.ends_with("\\"))
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define CARATTERI_SPECIALI "àèéìòù°'\\"
|
||||
|
||||
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
|
||||
SSimple_query& db();
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user