Files correlati : fp Commento : - Aggiunto piccolo controllo preventivo durante l'esportazione degli XML - Aggiunto flag per non rendere il controllo bloccante - Sistemata banca di appoggio - Aggiunta gestione casse professionali
368 lines
9.1 KiB
C++
368 lines
9.1 KiB
C++
#include "fplib.h"
|
|
|
|
#define FILE_CONFIG CONFIG_DITTA
|
|
#define FILE_SECTION "fp"
|
|
#define FP_TAB_MOD "FP"
|
|
|
|
|
|
|
|
#define FP_IP "ip"
|
|
#define FP_DB "db"
|
|
#define FP_USR "usr"
|
|
#define FP_PSW "psw"
|
|
#define FP_FLD_DEST "flddest"
|
|
#define FP_FLD_USR_DEST "fldusrdest"
|
|
#define FP_COFI_TRAS "cofitras"
|
|
#define FP_GEST_ALLEG "gestioneallegati"
|
|
#define FP_ALLEG_FAT "allegafatt"
|
|
#define FP_ESP_PRI "esppri"
|
|
#define FP_ESP_EST "espest"
|
|
#define FP_ESP_EST_COD "espestcod"
|
|
#define FP_F8 "f8"
|
|
#define FP_CHECK_NOT_BLOCK "checknotblock"
|
|
|
|
// Sheet fp0300
|
|
#define FP_SLD_COD "SLD"
|
|
|
|
#define FP_SLD_CODTAB "CODTAB"
|
|
#define FP_SLD_CODNUM "S0"
|
|
#define FP_SLD_TIPODOC "S1"
|
|
#define FP_SLD_DASTATO "I0"
|
|
#define FP_SLD_ASTATO "I1"
|
|
|
|
// Sheet fp0100
|
|
#define FP_SHT_CUST "SCUSTRIG"
|
|
#define FP_SHT_CODTAB FP_SLD_CODTAB
|
|
#define FP_SHT_TIPODOC "S0"
|
|
#define FP_SHT_TIPORIGA "S1"
|
|
#define FP_SHT_COL_QTA "S2"
|
|
#define FP_SHT_COL_PREZZO "S3"
|
|
#define FP_SHT_COL_IMPONIBILE "S4"
|
|
|
|
#define FP_SHT_DEF_QTA RDOC_QTA
|
|
#define FP_SHT_DEF_PREZZO "PREZZONN"
|
|
#define FP_SHT_DEF_IMPONIBILE "IMPNS"
|
|
|
|
const TString& TFP_settings::get_db_indirizzo() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_IP);
|
|
}
|
|
|
|
const TString& TFP_settings::get_db_database() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_DB);
|
|
}
|
|
|
|
const TString& TFP_settings::get_db_str_con() const
|
|
{
|
|
return get_tmp_string().cut(0) << get_db_indirizzo() << "@" << get_db_database();
|
|
}
|
|
|
|
const TString& TFP_settings::get_db_user() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_USR);
|
|
}
|
|
|
|
const TString& TFP_settings::get_db_password() const
|
|
{
|
|
return get_tmp_string().cut(0) << decode(ini_get_string(FILE_CONFIG, FILE_SECTION, FP_PSW));
|
|
}
|
|
|
|
const TString& TFP_settings::get_fld_dest() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_FLD_DEST);
|
|
}
|
|
|
|
const TString& TFP_settings::get_fld_dest_usr() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_FLD_USR_DEST, "");
|
|
}
|
|
|
|
const TString& TFP_settings::get_cofi_tras() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_COFI_TRAS);
|
|
}
|
|
|
|
const bool TFP_settings::get_gest_alleg() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_GEST_ALLEG);
|
|
}
|
|
|
|
const bool TFP_settings::get_allega_fat() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_ALLEG_FAT);
|
|
}
|
|
|
|
const bool TFP_settings::get_esp_pri_empty() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_ESP_PRI);
|
|
}
|
|
|
|
const bool TFP_settings::get_esp_est() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_ESP_EST);
|
|
}
|
|
|
|
const TString& TFP_settings::get_esp_est_cod() const
|
|
{
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_ESP_EST_COD, "XXXXXXX");
|
|
}
|
|
|
|
const bool TFP_settings::is_f8() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_F8);
|
|
}
|
|
|
|
const bool TFP_settings::get_check_not_block() const
|
|
{
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NOT_BLOCK);
|
|
}
|
|
|
|
void TFP_settings::set_db_indirizzo(const TString& ind) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_IP, ind);
|
|
}
|
|
|
|
void TFP_settings::set_db_database(const TString& db) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_DB, db);
|
|
}
|
|
|
|
void TFP_settings::set_db_user(const TString& usr) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_USR, usr);
|
|
}
|
|
|
|
void TFP_settings::set_db_password(const TString& psw) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_PSW, encode(psw));
|
|
}
|
|
|
|
void TFP_settings::set_fld_dest(const TString& fld_dest) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_FLD_DEST, fld_dest);
|
|
}
|
|
|
|
void TFP_settings::set_fld_dest_usr(const TString& fld_dest_usr) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_FLD_USR_DEST, fld_dest_usr);
|
|
}
|
|
|
|
void TFP_settings::set_cofi_tras(const TString& cofi) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_COFI_TRAS, cofi);
|
|
}
|
|
|
|
void TFP_settings::set_gest_alleg(const bool gest_alleg) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_GEST_ALLEG, gest_alleg);
|
|
}
|
|
|
|
void TFP_settings::set_allega_fat(const bool allega_fatt) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_ALLEG_FAT, allega_fatt);
|
|
}
|
|
|
|
void TFP_settings::set_esp_pri_empty(const bool esp_pri) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_ESP_PRI, esp_pri);
|
|
}
|
|
|
|
void TFP_settings::set_esp_est(const bool esp_est) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_ESP_EST, esp_est);
|
|
}
|
|
|
|
void TFP_settings::set_esp_est_cod(const TString& esp_est_cod) const
|
|
{
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_ESP_EST_COD, esp_est_cod);
|
|
}
|
|
|
|
void TFP_settings::set_f8(const bool f8) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_F8, f8);
|
|
}
|
|
|
|
void TFP_settings::set_check_not_block(const bool not_block) const
|
|
{
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NOT_BLOCK, not_block);
|
|
}
|
|
|
|
TRectype TFP_selected_docs::fill_rectype() const
|
|
{
|
|
TRectype r(LF_TABMOD);
|
|
r.put("MOD", FP_TAB_MOD);
|
|
r.put("COD", FP_SLD_COD);
|
|
return r;
|
|
}
|
|
|
|
void TFP_selected_docs::fill_sheet(TSheet_field& sheet) const
|
|
{
|
|
for(*_cur = 0; _cur->pos() < _cur->items(); ++*_cur)
|
|
{
|
|
TRectype rec = _cur->curr();
|
|
TToken_string& row = sheet.row(-1);
|
|
row.add(rec.get(FP_SLD_CODNUM));
|
|
row.add(rec.get(FP_SLD_TIPODOC));
|
|
row.add(rec.get(FP_SLD_DASTATO));
|
|
row.add(rec.get(FP_SLD_ASTATO));
|
|
row.add(TTipo_documento(rec.get(FP_SLD_TIPODOC)).tipo_doc_sdi());
|
|
}
|
|
}
|
|
|
|
void TFP_selected_docs::save_sheet(const TSheet_field& sheet) const
|
|
{
|
|
// Svuoto il db
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
TRectype rec(LF_TABMOD);
|
|
|
|
for (*_cur = 0; _cur->pos() != _cur->items();)
|
|
{
|
|
rec = _cur->curr();
|
|
int err = rec.remove(tabmod);
|
|
}
|
|
|
|
// Carico il db
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, n, r)
|
|
{
|
|
// Chissene anche se copio ogni volta
|
|
rec = fill_rectype();
|
|
static TString num;
|
|
num.cut(0);
|
|
num.format("%08d", n);
|
|
rec.put(FP_SLD_CODTAB, num);
|
|
|
|
// Prendo tutta la riga tranne il cod sdi
|
|
rec.put(FP_SLD_CODNUM, r->get(_codnum));
|
|
rec.put(FP_SLD_TIPODOC, r->get(_tipodoc));
|
|
rec.put(FP_SLD_DASTATO, r->get(_dastato));
|
|
rec.put(FP_SLD_ASTATO, r->get(_astato));
|
|
rec.write(tabmod);
|
|
}
|
|
}
|
|
|
|
TFP_selected_docs::TFP_selected_docs() : _r_tabmod(LF_TABMOD), _flt(fill_rectype())
|
|
{
|
|
_cur.reset(new TCursor(&_r_tabmod, "", 1, &_flt, &_flt));
|
|
}
|
|
|
|
|
|
TFP_righe_custom::TCustCol& TFP_righe_custom::get_no_custom()
|
|
{
|
|
static TCustCol* default_cust_col = nullptr;
|
|
if(default_cust_col == nullptr)
|
|
{
|
|
default_cust_col = new TCustCol();
|
|
default_cust_col->_col_qta = FP_SHT_DEF_QTA;
|
|
default_cust_col->_col_prezzo = FP_SHT_DEF_PREZZO;
|
|
default_cust_col->_col_imponibile = FP_SHT_DEF_IMPONIBILE;
|
|
}
|
|
return *default_cust_col;
|
|
}
|
|
|
|
TFP_righe_custom::TCustCol& TFP_righe_custom::get(const TString& codriga, const TString& tipodoc)
|
|
{
|
|
if(!_loaded)
|
|
{
|
|
load_map();
|
|
}
|
|
|
|
if(_custom_table.find(codriga) != _custom_table.end())
|
|
{
|
|
if (_custom_table[codriga].find(tipodoc) != _custom_table[codriga].end())
|
|
{
|
|
return _custom_table[codriga][tipodoc];
|
|
}
|
|
else if (_custom_table[codriga].find("") != _custom_table[codriga].end())
|
|
{
|
|
return _custom_table[codriga][""];
|
|
}
|
|
}
|
|
|
|
return get_no_custom();
|
|
}
|
|
|
|
void TFP_righe_custom::load_map()
|
|
{
|
|
TRelation rel(LF_TABMOD);
|
|
TRectype rec(LF_TABMOD);
|
|
rec.put("MOD", FP_TAB_MOD);
|
|
rec.put("COD", FP_SHT_CUST);
|
|
TCursor cur(&rel, "", 1, &rec, &rec);
|
|
for (cur = 0; cur.pos() < cur.items(); ++cur)
|
|
{
|
|
rec = cur.curr();
|
|
TCustCol& app = _custom_table[rec.get(FP_SHT_TIPORIGA)][rec.get(FP_SHT_TIPODOC)];
|
|
app._col_qta = rec.get(FP_SHT_COL_QTA).full() ? rec.get(FP_SHT_COL_QTA) : FP_SHT_DEF_QTA;
|
|
app._col_prezzo = rec.get(FP_SHT_COL_PREZZO).full() ? rec.get(FP_SHT_COL_PREZZO) : FP_SHT_DEF_PREZZO;
|
|
app._col_imponibile = rec.get(FP_SHT_COL_IMPONIBILE).full() ? rec.get(FP_SHT_COL_IMPONIBILE) : FP_SHT_DEF_IMPONIBILE;
|
|
}
|
|
|
|
_loaded = true;
|
|
}
|
|
|
|
void TFP_righe_custom::save_sheet(TSheet_field& sheet_field)
|
|
{
|
|
// Svuoto il db
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
TRelation rel(LF_TABMOD);
|
|
TRectype rec(LF_TABMOD);
|
|
rec.put("MOD", FP_TAB_MOD);
|
|
rec.put("COD", FP_SHT_CUST);
|
|
TCursor cur(&rel, "", 1, &rec, &rec);
|
|
|
|
for (cur = 0; cur.pos() != cur.items();)
|
|
{
|
|
rec = cur.curr();
|
|
int err = rec.remove(tabmod);
|
|
}
|
|
|
|
// Carico il db
|
|
FOR_EACH_SHEET_ROW(sheet_field, n, r)
|
|
{
|
|
// Chissene anche se copio ogni volta
|
|
rec.put("MOD", FP_TAB_MOD);
|
|
rec.put("COD", FP_SHT_CUST);
|
|
static TString num;
|
|
num.cut(0);
|
|
num.format("%08d", n);
|
|
|
|
rec.put(FP_SHT_CODTAB, num);
|
|
|
|
// Prendo tutta la riga tranne il cod sdi
|
|
rec.put(FP_SHT_TIPODOC, r->get(0));
|
|
rec.put(FP_SHT_TIPORIGA, r->get());
|
|
rec.put(FP_SHT_COL_QTA, r->get());
|
|
rec.put(FP_SHT_COL_PREZZO, r->get());
|
|
rec.put(FP_SHT_COL_IMPONIBILE, r->get());
|
|
|
|
rec.write(tabmod);
|
|
}
|
|
}
|
|
|
|
void TFP_righe_custom::load_sheet(TSheet_field& sheet_field)
|
|
{
|
|
TRelation rel(LF_TABMOD);
|
|
TRectype rec(LF_TABMOD);
|
|
rec.put("MOD", FP_TAB_MOD);
|
|
rec.put("COD", FP_SHT_CUST);
|
|
TCursor cur(&rel, "", 1, &rec, &rec);
|
|
for (cur = 0; cur.pos() < cur.items(); ++cur)
|
|
{
|
|
TToken_string& row = sheet_field.row(-1);
|
|
TRectype& cur_rec = cur.curr();
|
|
row.add(cur_rec.get(FP_SHT_TIPODOC), 0);
|
|
row.add(cur_rec.get(FP_SHT_TIPORIGA));
|
|
row.add(cur_rec.get(FP_SHT_COL_QTA));
|
|
row.add(cur_rec.get(FP_SHT_COL_PREZZO));
|
|
row.add(cur_rec.get(FP_SHT_COL_IMPONIBILE));
|
|
}
|
|
sheet_field.force_update();
|
|
}
|
|
|
|
TFP_righe_custom::TFP_righe_custom() : _loaded(false)
|
|
{
|
|
|
|
}
|