2019-01-02 14:48:09 +01:00
|
|
|
|
#include "fplib.h"
|
|
|
|
|
|
|
|
|
|
#define FILE_CONFIG CONFIG_DITTA
|
|
|
|
|
#define FILE_SECTION "fp"
|
2019-01-10 14:11:28 +01:00
|
|
|
|
#define FP_TAB_MOD "FP"
|
|
|
|
|
|
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
|
2019-04-02 15:04:14 +02:00
|
|
|
|
#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"
|
|
|
|
|
#define FP_MAIL "mail"
|
|
|
|
|
#define FP_NOTA_PIEDE_F "npf" // Nota piede fattura
|
|
|
|
|
#define FP_CHECK_NO_SCONTI_FATT "noscontifatt"
|
|
|
|
|
#define FP_CHECK_NO_EXPORT_PRONTO "noexportpronto"
|
2019-05-27 16:06:02 +02:00
|
|
|
|
#define FP_DATASTARTFATT "datastartfatt"
|
2020-09-17 17:09:13 +02:00
|
|
|
|
#define FP_DATASTARTNEWFATT "startnewtracciato"
|
2019-01-02 14:48:09 +01:00
|
|
|
|
|
2019-02-15 11:38:50 +01:00
|
|
|
|
// Sheet fp0300
|
2019-01-10 14:11:28 +01:00
|
|
|
|
#define FP_SLD_COD "SLD"
|
2019-02-15 11:38:50 +01:00
|
|
|
|
|
2019-01-10 14:11:28 +01:00
|
|
|
|
#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"
|
|
|
|
|
|
2019-02-15 11:38:50 +01:00
|
|
|
|
// 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"
|
2019-01-10 14:11:28 +01:00
|
|
|
|
|
2019-02-15 11:38:50 +01:00
|
|
|
|
#define FP_SHT_DEF_QTA RDOC_QTA
|
|
|
|
|
#define FP_SHT_DEF_PREZZO "PREZZONN"
|
|
|
|
|
#define FP_SHT_DEF_IMPONIBILE "IMPNS"
|
2019-01-02 14:48:09 +01:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:06:02 +02:00
|
|
|
|
const TString& TFP_settings::get_data_start_fatt() const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_DATASTARTFATT, "01-01-2019");
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-07 18:00:02 +01:00
|
|
|
|
const bool TFP_settings::is_f8() const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_F8);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-21 17:44:31 +01:00
|
|
|
|
const bool TFP_settings::get_check_not_block() const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NOT_BLOCK);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 10:38:43 +01:00
|
|
|
|
const TString& TFP_settings::get_body_mail(int idx) const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, FP_MAIL, "STOpsTOP", idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
const TString& TFP_settings::get_npf(const char * tipodoc, int idx) const
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
2019-03-21 15:53:29 +01:00
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "-" << tipodoc;
|
2019-03-20 09:41:44 +01:00
|
|
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, name, "FERMATIostrega", idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
const TString TFP_settings::get_npf_tipodoc(int indx) const
|
|
|
|
|
{
|
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "_tipodoc";
|
|
|
|
|
return ini_get_string(FILE_CONFIG, FILE_SECTION, name, "FERMATIostrega", indx);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-17 17:09:13 +02:00
|
|
|
|
TDate TFP_settings::get_date_start_new_fatt()
|
|
|
|
|
{
|
|
|
|
|
return ini_get_date(CONFIG_DITTA, FILE_SECTION, FP_DATASTARTNEWFATT, "01-01-2021");
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 10:30:02 +01:00
|
|
|
|
const bool TFP_settings::get_no_sconti_fatt() const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_SCONTI_FATT, false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-02 15:04:14 +02:00
|
|
|
|
bool TFP_settings::get_no_export_pronto() const
|
|
|
|
|
{
|
|
|
|
|
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_EXPORT_PRONTO, false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 14:48:09 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-07 18:00:02 +01:00
|
|
|
|
void TFP_settings::set_f8(const bool f8) const
|
|
|
|
|
{
|
|
|
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_F8, f8);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-21 17:44:31 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 10:38:43 +01:00
|
|
|
|
void TFP_settings::set_body_mail(const char* msg, int idx) const
|
|
|
|
|
{
|
|
|
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_MAIL, msg, idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-20 09:41:44 +01:00
|
|
|
|
// Set nota piede fattura
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_settings::set_npf(const char * tipodoc, const char* msg, int idx) const
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
2019-03-21 15:53:29 +01:00
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "-" << tipodoc;
|
2019-03-20 09:41:44 +01:00
|
|
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, name, msg, idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 10:30:02 +01:00
|
|
|
|
void TFP_settings::set_no_sconti_fatt(const bool no_sconti_fatt) const
|
|
|
|
|
{
|
|
|
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_SCONTI_FATT, no_sconti_fatt);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-02 15:04:14 +02:00
|
|
|
|
void TFP_settings::set_no_export_pronto(const bool no_export_pronto) const
|
|
|
|
|
{
|
|
|
|
|
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_EXPORT_PRONTO, no_export_pronto);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:06:02 +02:00
|
|
|
|
void TFP_settings::set_data_start_fatt(const char* date) const
|
|
|
|
|
{
|
2019-06-03 15:20:42 +02:00
|
|
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_DATASTARTFATT, date);
|
2019-05-27 16:06:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-17 17:09:13 +02:00
|
|
|
|
void TFP_settings::set_data_start_new_fatt(const char* date) const
|
|
|
|
|
{
|
|
|
|
|
ini_set_string(CONFIG_DITTA, FILE_SECTION, FP_DATASTARTNEWFATT, date);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 10:38:43 +01:00
|
|
|
|
void TFP_settings::remove_para_ini(int idx)
|
|
|
|
|
{
|
|
|
|
|
ini_remove(FILE_CONFIG, FILE_SECTION, FP_MAIL, idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_settings::remove_npf_ini(const char * tipodoc, int idx)
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
2019-03-21 15:53:29 +01:00
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "-" << tipodoc;
|
2019-03-20 09:41:44 +01:00
|
|
|
|
ini_remove(FILE_CONFIG, FILE_SECTION, name, idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_settings::set_npf_tipodoc(const TString& tipodoc, int indx) const
|
|
|
|
|
{
|
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "_tipodoc";
|
|
|
|
|
ini_set_string(FILE_CONFIG, FILE_SECTION, name, tipodoc, indx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rimuove linea ini in eccesso per tipodoc per nota piede fattura
|
|
|
|
|
void TFP_settings::remove_tipodoc_npf(const int idx) const
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
2019-03-21 15:53:29 +01:00
|
|
|
|
TString name; name << FP_NOTA_PIEDE_F << "_tipodoc";
|
2019-03-20 09:41:44 +01:00
|
|
|
|
ini_remove(FILE_CONFIG, FILE_SECTION, name, idx);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 14:11:28 +01:00
|
|
|
|
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));
|
2019-01-25 14:47:19 +01:00
|
|
|
|
row.add(TTipo_documento(rec.get(FP_SLD_TIPODOC)).tipo_doc_sdi());
|
2019-01-10 14:11:28 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFP_selected_docs::save_sheet(const TSheet_field& sheet) const
|
|
|
|
|
{
|
|
|
|
|
// Svuoto il db
|
|
|
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
|
|
|
TRectype rec(LF_TABMOD);
|
|
|
|
|
|
2019-01-25 16:36:29 +01:00
|
|
|
|
for (*_cur = 0; _cur->pos() != _cur->items();)
|
2019-01-10 14:11:28 +01:00
|
|
|
|
{
|
|
|
|
|
rec = _cur->curr();
|
2019-01-25 16:36:29 +01:00
|
|
|
|
int err = rec.remove(tabmod);
|
2019-01-10 14:11:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Carico il db
|
|
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, n, r)
|
|
|
|
|
{
|
|
|
|
|
// Chissene anche se copio ogni volta
|
|
|
|
|
rec = fill_rectype();
|
2019-02-05 16:23:20 +01:00
|
|
|
|
static TString num;
|
|
|
|
|
num.cut(0);
|
|
|
|
|
num.format("%08d", n);
|
|
|
|
|
rec.put(FP_SLD_CODTAB, num);
|
2019-01-10 14:11:28 +01:00
|
|
|
|
|
|
|
|
|
// 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));
|
|
|
|
|
}
|
2019-02-15 11:38:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_nota_piede_f::write_ini_npf(const TString& tipodoc, TToken_string& msg)
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
2019-03-21 15:53:29 +01:00
|
|
|
|
/* Vado a salvare in un config .ini tipo-doc:messaggio su piu righe */
|
2019-03-20 09:41:44 +01:00
|
|
|
|
int indx = 0;
|
|
|
|
|
|
|
|
|
|
// Conto quanti ne avevo salvati prima nel file ini per poi controllare
|
|
|
|
|
// che non sto salvando meno di quelli che ci sono gi<67>
|
|
|
|
|
int previous_indx = 0;
|
2019-03-21 15:53:29 +01:00
|
|
|
|
for (TString row = fp_settings().get_npf(tipodoc, previous_indx); row != "FERMATIostrega"; row = fp_settings().get_npf(tipodoc, previous_indx))
|
2019-03-20 09:41:44 +01:00
|
|
|
|
previous_indx++;
|
|
|
|
|
// Vado a salvare ogni riga nel file ini
|
|
|
|
|
for (const char* row = msg.get(); row; row = msg.get())
|
2019-03-21 15:53:29 +01:00
|
|
|
|
fp_settings().set_npf(tipodoc, row, indx++);
|
2019-03-20 09:41:44 +01:00
|
|
|
|
|
|
|
|
|
if (indx < previous_indx)
|
|
|
|
|
{
|
|
|
|
|
for (int i = indx; i < previous_indx; i++)
|
2019-03-21 15:53:29 +01:00
|
|
|
|
fp_settings().remove_npf_ini(tipodoc, i);
|
2019-03-20 09:41:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_nota_piede_f::delete_ini_npf(const TString& tipodoc)
|
|
|
|
|
{
|
|
|
|
|
// Conto quanti ne avevo salvati prima nel file ini per poi controllare
|
|
|
|
|
// che non sto salvando meno di quelli che ci sono gi<67>
|
|
|
|
|
int previous_indx = 0;
|
|
|
|
|
for (TString row = fp_settings().get_npf(tipodoc, previous_indx); row != "FERMATIostrega"; row = fp_settings().get_npf(tipodoc, previous_indx))
|
|
|
|
|
previous_indx++;
|
|
|
|
|
for (int i = 0; i < previous_indx; i++)
|
|
|
|
|
fp_settings().remove_npf_ini(tipodoc, i);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Crea la stringa della nota se su piu righe dal file ini (nometag+indice)
|
|
|
|
|
TString TFP_nota_piede_f::get_ini_npf(const TString& tipodoc)
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
|
|
|
|
TString msg; msg.cut(0);
|
|
|
|
|
|
|
|
|
|
int indx = 0;
|
2019-03-21 15:53:29 +01:00
|
|
|
|
for (TString row = fp_settings().get_npf(tipodoc, indx); row != "FERMATIostrega"; row = fp_settings().get_npf(tipodoc, indx))
|
2019-03-20 09:41:44 +01:00
|
|
|
|
{
|
|
|
|
|
if(indx++ > 0)
|
|
|
|
|
msg << '\n';
|
|
|
|
|
msg << row;
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 15:53:29 +01:00
|
|
|
|
void TFP_nota_piede_f::get_load()
|
|
|
|
|
{
|
|
|
|
|
// Prima leggo i tipi doc che ho salvato dall'ini
|
|
|
|
|
TString tipo_get = "";
|
|
|
|
|
int indx = 0;
|
|
|
|
|
while ((tipo_get = fp_settings().get_npf_tipodoc(indx++)) != "FERMATIostrega")
|
|
|
|
|
_tipi_doc.add(tipo_get);
|
|
|
|
|
|
|
|
|
|
const int itms = _tipi_doc.items();
|
|
|
|
|
for (int i = 0; i < itms; i++)
|
|
|
|
|
{
|
|
|
|
|
tipo_get = _tipi_doc.get();
|
|
|
|
|
TString npf = get_ini_npf(tipo_get);
|
|
|
|
|
_nota_piede_fattura.insert({ tipo_get, npf });
|
|
|
|
|
}
|
|
|
|
|
_loaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFP_nota_piede_f::load_sheet(TSheet_field& sheet_field)
|
|
|
|
|
{
|
|
|
|
|
sheet_field.hide();
|
|
|
|
|
// Prima leggo i tipi doc che ho salvato dall'ini
|
|
|
|
|
TString tipo_get = "";
|
|
|
|
|
int indx = 0;
|
|
|
|
|
while((tipo_get = fp_settings().get_npf_tipodoc(indx++)) != "FERMATIostrega")
|
|
|
|
|
_tipi_doc.add(tipo_get);
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (!(tipo_get = _tipi_doc.get()).empty())
|
|
|
|
|
{
|
|
|
|
|
TString npf = get_ini_npf(tipo_get);
|
|
|
|
|
TToken_string& row = sheet_field.row(-1);
|
|
|
|
|
row.add(tipo_get);
|
|
|
|
|
row.add(npf);
|
|
|
|
|
}
|
|
|
|
|
sheet_field.show();
|
|
|
|
|
sheet_field.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFP_nota_piede_f::save_npf_spredsheet(TSheet_field& sheet_field)
|
|
|
|
|
{
|
|
|
|
|
const int items_sf = sheet_field.items();
|
|
|
|
|
TString tipo_doc = 0;
|
|
|
|
|
// Salvo le note piede fatt presenti nello spreadsheet
|
|
|
|
|
// Se ho eliminato una nota di un tipodoc devo rimuovere tutte le righe di quel tipodoc
|
|
|
|
|
for (int i = 0; i < items_sf; i++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string row = sheet_field.row(i);
|
|
|
|
|
TToken_string msg(row.get(1), '\n');
|
|
|
|
|
write_ini_npf(tipo_doc = row.get(0), msg);
|
|
|
|
|
_tipi_doc.restart();
|
|
|
|
|
for (int j = 0; j < _tipi_doc.items(); j++)
|
|
|
|
|
if (tipo_doc == _tipi_doc.get()) // Elimino dall'array i tipi doc che sto salvando
|
|
|
|
|
_tipi_doc.destroy(j); // Per controllare che non ne rimangano alcuni in piu`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_tipi_doc.items() > 0) // E` rimasto qualcuno fuori (<28> stato eliminato un tipodoc rispetto a quelli salvati nel file ini)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _tipi_doc.items(); i++) // Per ogni tipodoc rimasto fuori elimino tutte le possibili righe del messaggio
|
|
|
|
|
delete_ini_npf(_tipi_doc.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFP_nota_piede_f::save_new_tipidoc(TSheet_field& sheet_field)
|
|
|
|
|
{
|
|
|
|
|
int n_tipidoc = 0;
|
|
|
|
|
TString npf_get;
|
|
|
|
|
// Conto quanti tipi doc ho nel file ini
|
|
|
|
|
for (int i = 0; (npf_get = fp_settings().get_npf_tipodoc(i)) != "FERMATIostrega"; i++)
|
|
|
|
|
{
|
|
|
|
|
n_tipidoc++;
|
|
|
|
|
_tipi_doc.add(npf_get);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Salvo i nuovi tipidoc
|
|
|
|
|
const int items_sf = sheet_field.items();
|
|
|
|
|
for (int i = 0; i < items_sf; i++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string row = sheet_field.row(i);
|
|
|
|
|
TString tipodoc_sf(row.get(0));
|
|
|
|
|
fp_settings().set_npf_tipodoc(tipodoc_sf, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (items_sf < n_tipidoc)
|
|
|
|
|
for (int i = items_sf; i < n_tipidoc; i++)
|
|
|
|
|
fp_settings().remove_tipodoc_npf(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TFP_nota_piede_f::save_sheet(TSheet_field& sheet_field)
|
|
|
|
|
{
|
|
|
|
|
save_new_tipidoc(sheet_field);
|
|
|
|
|
save_npf_spredsheet(sheet_field);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& TFP_nota_piede_f::get_nota_piede(const TString& tipo_doc)
|
|
|
|
|
{
|
|
|
|
|
if (!_loaded)
|
|
|
|
|
get_load();
|
|
|
|
|
if(_nota_piede_fattura.find(tipo_doc) != _nota_piede_fattura.end())
|
|
|
|
|
return _nota_piede_fattura[tipo_doc];
|
|
|
|
|
return _null_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFP_nota_piede_f::TFP_nota_piede_f() : _loaded(false), _null_string("")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-15 11:38:50 +01:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|