2020-04-01 21:26:49 +02:00
|
|
|
#ifndef __F90100H__
|
|
|
|
#define __F90100H__
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
#define PAR_MOD "F9"
|
|
|
|
#define AMBIENTE_F9 "CODSOC" // Codice ambiente (codsoc)
|
|
|
|
#define ADDRCART_F9 "ADDDOC" // Indirizzo documenti cartacei
|
|
|
|
#define CHECKVEND_F9 "CHECKVEND" // Flag controlli per vendite (quando hai fatt. con Campo)
|
|
|
|
#define CARTEXP_F9 "CARTEXP" // Flag esporta documenti cartacei
|
|
|
|
#define VIEWMOV_F9 "VIEWMOVPRE" // Flag visualizza moviementi prima di estrarre
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
#include "execp.h"
|
|
|
|
#include "f90100a.h"
|
|
|
|
#include "f9lib01.h"
|
|
|
|
#include "mov.h"
|
2020-05-14 23:38:30 +02:00
|
|
|
#include "automask.h"
|
2020-04-01 21:26:49 +02:00
|
|
|
#include "applicat.h"
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
/** class TEstrai_mask
|
|
|
|
* \brief Piccola maschera "creata a runtime" per avviare l'estrazione.
|
|
|
|
*/
|
2019-09-10 17:33:59 +02:00
|
|
|
class TEstrai_mask : public TMask
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
TString _descr;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
void enable_fields(bool en = true);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static bool estrai_handler(TMask_field& f, KEY key);
|
|
|
|
static bool enable_handler(TMask_field& f, KEY key);
|
|
|
|
static bool dataini_handler(TMask_field& f, KEY key);
|
|
|
|
static bool dataend_handler(TMask_field& f, KEY key);
|
2019-09-10 17:33:59 +02:00
|
|
|
public:
|
2020-04-01 21:26:49 +02:00
|
|
|
TString& get_descr() { return _descr; }
|
|
|
|
TEstrai_mask();
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
class TF9_app : public TSkeleton_application
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
//friend class TEstrai_mask;
|
|
|
|
friend class TMonitor_mask;
|
|
|
|
friend class TControllo_mask;
|
|
|
|
friend class TEstrazione;
|
|
|
|
|
|
|
|
struct config
|
|
|
|
{
|
|
|
|
TString ambiente; // Codice ambiente (codsoc)
|
|
|
|
TString addr_doc; // Indirizzo documenti cartacei
|
2020-05-14 23:38:30 +02:00
|
|
|
bool cartexp;
|
|
|
|
bool checkvend;
|
2020-04-01 21:26:49 +02:00
|
|
|
bool viewmovpre;
|
2020-04-18 16:00:37 +02:00
|
|
|
} _config; // todo: controllare che siano sqlsafe
|
2020-04-01 21:26:49 +02:00
|
|
|
unique_ptr<TEstrai_mask> _estr_msk;
|
|
|
|
unique_ptr<TMonitor_mask> _msk;
|
|
|
|
vector<movimento_t> _movs;
|
|
|
|
vector<TToken_string> _esclusi; // Vettore con i movimenti esclusi
|
|
|
|
vector<TToken_string> _esclusi_vect;
|
|
|
|
TToken_string _mov_escl;
|
|
|
|
char _tipodoc_escl;
|
|
|
|
char _flagprov_escl;
|
|
|
|
TString _log;
|
|
|
|
|
2020-04-06 19:25:21 +02:00
|
|
|
unique_ptr<TEstrazione> _estrazione;
|
2020-04-01 21:26:49 +02:00
|
|
|
TEstrazione* _estr_escluso;
|
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
TDate get_dataini() const { return _estr_msk->get_date(ES_DATAINI); }
|
|
|
|
TDate get_dataend() const { return _estr_msk->get_date(ES_DATAEND); }
|
|
|
|
char get_tipodoc() const { return _estr_msk->get(ES_TIPODOC)[0]; }
|
|
|
|
char get_tipodoc_escl() const { return _tipodoc_escl; }
|
|
|
|
TipoIVA get_tipoiva() const { return get_tipodoc() == 'A' ? iva_acquisti : iva_vendite; }
|
|
|
|
TipoIVA get_tipoiva_escl() const { return get_tipodoc_escl() == 'A' ? iva_acquisti : iva_vendite; }
|
|
|
|
TString get_descr() const { return _estr_msk->get(ES_DESCR); }
|
|
|
|
bool is_provviso() const { return _estr_msk->get(ES_FLAGPROV)[0] == 'P'; }
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
// Dato il codice stato estrazione (es. '01') viene restituito il suo significato a parole.
|
2019-09-10 17:33:59 +02:00
|
|
|
static const char* traduci_stato(const TString& cod);
|
|
|
|
|
|
|
|
public:
|
2020-05-14 23:38:30 +02:00
|
|
|
const TString& get_ambiente() const { return _config.ambiente; }
|
|
|
|
const TString& get_addr_doc() const { return _config.addr_doc; }
|
|
|
|
bool get_has_cartexp() const { return _config.cartexp; }
|
|
|
|
bool get_has_checkvend() const { return _config.checkvend; }
|
|
|
|
bool get_viewmov() const { return _config.viewmovpre; }
|
|
|
|
|
|
|
|
void set_ambiente(const char* cod) { _config.ambiente.cut(0) << cod; }
|
|
|
|
void set_addr_doc(const char* add) { _config.addr_doc.cut(0) << add; }
|
|
|
|
void set_has_cartexp(const bool flag) { _config.cartexp = flag; }
|
|
|
|
void set_has_checkvend(const bool flag){ _config.checkvend = flag; }
|
|
|
|
void set_viewmov(const bool flag) { _config.viewmovpre = flag; }
|
|
|
|
|
|
|
|
/** Esegue la maschera di inserimento opzioni per avviare l'estrazione. */
|
2020-04-01 21:26:49 +02:00
|
|
|
void run_estr_msk() const { _estr_msk->run(); }
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
// Estrazione esclusi - handlers
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
static bool select_escl_notify(TSheet_field& s, int row, KEY key);
|
|
|
|
static bool controllo_escl_handler(TMask_field& field, KEY key);
|
|
|
|
static bool year_handler(TMask_field& field, KEY key);
|
2020-05-14 23:38:30 +02:00
|
|
|
static bool estrai_escl_handler(TMask_field&, KEY key);
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
void open_esclusi();
|
2019-09-13 17:06:08 +02:00
|
|
|
static void fill_esclusi();
|
2020-05-14 23:38:30 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static movimento_t escl2mov(TToken_string* row);
|
2020-05-14 23:38:30 +02:00
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
static bool mov_handler(TMask_field&, KEY key);
|
2019-10-28 12:31:23 +01:00
|
|
|
static bool mov_handler_escl(TMask_field&, KEY key);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
/** Aggiorna tabella F9WA. */
|
2020-04-18 16:00:37 +02:00
|
|
|
void edit_wa(TString& old_codsoc) const;
|
2020-05-14 23:38:30 +02:00
|
|
|
/** Prepara l'estrazione caricando tutti i movimenti dato un periodo (data registrazione),
|
|
|
|
* e avvia la procedura di estrazione.
|
|
|
|
* \return See \a TEstrazione::estrai().
|
2020-04-01 21:26:49 +02:00
|
|
|
*/
|
|
|
|
int estrai();
|
2019-10-28 12:31:23 +01:00
|
|
|
|
|
|
|
// logs
|
|
|
|
|
|
|
|
void print_log();
|
|
|
|
void add_msg_log(const char* msg);
|
|
|
|
void add_sqlerror_msg_log(const char* query);
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static bool is_autofattura(const TLocalisamfile& mov);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
/** Segna su mov che il movimento e' stato estratto. */
|
|
|
|
bool segna_estratti(bool escluso = false, int numreg = 0);
|
|
|
|
/** Segna su DRD che l'estrazione e' in errore diag. gestionale. */
|
|
|
|
static void segna_in_errore();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
// Controllo e aggiornamento tabelle F9
|
|
|
|
|
2020-05-14 23:38:30 +02:00
|
|
|
private:
|
|
|
|
bool create_tables() const; // Creazione tabelle F9.
|
|
|
|
bool check_tabelle_f9() const; // Controllo esistenza delle tabelle e in caso le crea.
|
|
|
|
bool aggiorna_tab_f9(int version) const; // Aggiorna modifiche alle tabelle F9 come descritto in cima al file f90100.cpp.
|
|
|
|
bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle.
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool check_table() const; /**< Controllo e aggiornamento versione sql. */
|
|
|
|
|
|
|
|
void main_loop() override;
|
|
|
|
|
|
|
|
TF9_app();
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
2020-05-14 23:38:30 +02:00
|
|
|
|
|
|
|
inline TF9_app& f9_app()
|
|
|
|
{
|
|
|
|
static TF9_app* app = nullptr;
|
|
|
|
if (app == nullptr)
|
|
|
|
app = (TF9_app*)&main_app();
|
|
|
|
return *app;
|
|
|
|
}
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
|
|
class TMonitor_mask : public TAutomask
|
|
|
|
{
|
2019-09-13 17:06:08 +02:00
|
|
|
friend class TF9_app;
|
2020-04-01 21:26:49 +02:00
|
|
|
vector<TToken_string> _fppro;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
static bool save_conf_handler(TMask_field& f, KEY key);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
void controllo_errori() const;
|
2019-10-28 12:31:23 +01:00
|
|
|
void delete_pack(bool all = false) const;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
// Riempie sheet per visualizzare le estrazioni
|
|
|
|
void fill() const;
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
bool on_key(KEY key) override;
|
|
|
|
void open_mostra_estrazione() const;
|
|
|
|
static void open_win_estr();
|
|
|
|
void open_win_conf() const;
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
void sel() const;
|
2019-09-10 17:33:59 +02:00
|
|
|
public:
|
2020-04-01 21:26:49 +02:00
|
|
|
TMonitor_mask() : TAutomask("f90100a") { fill(); }
|
2019-09-10 17:33:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class TControllo_mask : public TAutomask
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
char _ordin;
|
|
|
|
char _verso;
|
|
|
|
int _selected_mov;
|
|
|
|
bool _sel_esclusi;
|
|
|
|
bool _is_escluso;
|
2020-04-18 16:00:37 +02:00
|
|
|
TString _cod_soc;
|
2020-04-01 21:26:49 +02:00
|
|
|
TString _id_estr;
|
|
|
|
char _tipo_doc_err{};
|
|
|
|
vector<TToken_string> _movs;
|
|
|
|
|
|
|
|
void associa();
|
|
|
|
void conferma_esclusi() const;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
vector<TToken_string>& import_error_list();
|
|
|
|
void fill();
|
2019-09-10 17:33:59 +02:00
|
|
|
void fill_fppro_sheet() const;
|
|
|
|
TMask& get_win_order();
|
|
|
|
void open_win_order();
|
|
|
|
|
|
|
|
TToken_string* selected_mov();
|
|
|
|
TToken_string* selected_fat() const;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
/** Gestisce la selezione multipla negli sheet di controllo movimenti */
|
2019-09-10 17:33:59 +02:00
|
|
|
void selfatt(TOperable_field& o, long jolly) const;
|
|
|
|
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
public:
|
2020-04-18 16:00:37 +02:00
|
|
|
explicit TControllo_mask(const char* codsoc, const char* id_estr, bool esclusi = false);
|
2019-09-13 17:06:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool open_mov(const TRectype& mov)
|
|
|
|
{
|
|
|
|
TFilename ininame; ininame.temp("lnk", "ini");
|
|
|
|
{
|
|
|
|
TConfig ini(ininame, "Transaction");
|
|
|
|
ini.set("Action", "LINK");
|
|
|
|
ini.set_paragraph("23");
|
|
|
|
ini.set("NUMREG", mov.get(MOV_NUMREG));
|
|
|
|
}
|
|
|
|
TString app;
|
|
|
|
app << "cg2.exe -0 -i" << ininame;
|
|
|
|
TExternal_app a(app);
|
|
|
|
bool ok = a.run() == 0;
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
xvt_sys_sleep(500);
|
|
|
|
const TString& result = ini_get_string(ininame, "Transaction", "Result");
|
|
|
|
ok = result == "OK";
|
|
|
|
}
|
|
|
|
xvt_fsys_remove_file(ininame);
|
|
|
|
return ok;
|
2019-10-16 14:23:36 +02:00
|
|
|
}
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-16 14:23:36 +02:00
|
|
|
// Getters per semplificare i get dai TRecorset
|
|
|
|
|
|
|
|
const TString& recset_get_string(const TRecordset& rec, const char* field, int zero_filled = -1);
|
2020-04-01 21:26:49 +02:00
|
|
|
int recset_get_int(const TRecordset& rec, const char* field, int zero_filled = -1);
|
2019-10-16 14:23:36 +02:00
|
|
|
bool recset_get_bool(const TRecordset& rec, const char* field);
|
|
|
|
real recset_get_real(const TRecordset& rec, const char* field);
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
#endif //__F90100H__
|