Files correlati : f90100.cpp f90100d.uml f90104.sql Commento: Aggiornamenti sostanziali al programma di Archiviazione Passiva. Il funzionamento è rimasto lo stesso della versione precedente ma il giro interno del programma è stato rivisto e migliorato (si spera)
261 lines
7.8 KiB
C++
261 lines
7.8 KiB
C++
#ifndef _F90100_H_
|
|
#define _F90100_H_
|
|
|
|
#include "execp.h"
|
|
#include "f90100a.h"
|
|
#include "mov.h"
|
|
#include "automask.h"
|
|
#include "applicat.h"
|
|
|
|
#include "f9lib.h"
|
|
|
|
/** class TEstrai_mask
|
|
* \brief Piccola maschera "creata a runtime" per avviare l'estrazione.
|
|
*/
|
|
class TEstrai_mask : public TMask
|
|
{
|
|
TEstrazione * _estrazione; // Oggetto estrazione in corso di elaborazione
|
|
|
|
void enable_fields(bool en = true);
|
|
|
|
TDate get_dataini() const { return get_date(ES_DATAINI); }
|
|
TDate get_dataend() const { return get_date(ES_DATAEND); }
|
|
char get_tipodoc() const { return get(ES_TIPODOC)[0]; }
|
|
TipoIVA get_tipoiva() const { return get_tipodoc() == 'A' ? iva_acquisti : iva_vendite; }
|
|
TString get_descr() const { return get(ES_DESCR); }
|
|
bool is_provviso() const { return get(ES_FLAGPROV)[0] == 'P'; }
|
|
|
|
/* Prepara l'estrazione caricando tutti i movimenti dato un periodo (data registrazione),
|
|
* e avvia la procedura di estrazione.
|
|
* [See TEstrazione::estrai()].
|
|
*/
|
|
int estrai();
|
|
/** Segna su DRD che l'estrazione e' in errore diag. gestionale. */
|
|
void segna_in_errore() const;
|
|
|
|
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);
|
|
|
|
public:
|
|
TEstrai_mask();
|
|
~TEstrai_mask() { safe_delete(_estrazione); };
|
|
};
|
|
|
|
class TApri_estr_msk : public TAutomask
|
|
{
|
|
TString _idestr;
|
|
TDate _dataestr;
|
|
bool _provv;
|
|
char _tipodoc;
|
|
TString _statoestr;
|
|
TDate _datadal;
|
|
TDate _dataal;
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
|
|
bool inall_handler() const;
|
|
bool inescludi_handler() const;
|
|
bool inselect_handler() const;
|
|
void conferma_esclusi() const;
|
|
public:
|
|
void fill_estr() const;
|
|
void fill_res() const;
|
|
void set_from_row_estrazione(TToken_string& row_estrazione);
|
|
|
|
TApri_estr_msk();
|
|
~TApri_estr_msk() {}
|
|
};
|
|
class TMonitor_mask : public TAutomask
|
|
{
|
|
// friend class TF9_app;
|
|
TString_array _fppro;
|
|
TApri_estr_msk _inclusi_mask;
|
|
|
|
// Configurazione mask
|
|
bool save_conf(TMask& m);
|
|
|
|
// Forza Aggiornamento LVL Patch delle tabelle F9
|
|
static bool update_table_level(TMask_field& f, KEY key);
|
|
|
|
// Metodi per la maschera 'Apri Estr.'
|
|
|
|
void open_apri_estr_win();
|
|
|
|
// Controllo estr. mask
|
|
void controllo_errori() const;
|
|
static void delete_estr_fld(const TString& idestr);
|
|
void delete_pack(bool all = false) const;
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
static void open_win_estr();
|
|
void open_win_conf();
|
|
void sel() const;
|
|
|
|
public:
|
|
// Riempie sheet per visualizzare le estrazioni
|
|
void fill() const;
|
|
|
|
TMonitor_mask();
|
|
~TMonitor_mask() {}
|
|
};
|
|
|
|
class TConfig_f9_mask: public TAutomask
|
|
{
|
|
protected:
|
|
bool on_key(const KEY key);
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
|
|
TConfig_f9_mask(const char* filename, int num = 0) : TAutomask(filename, num) {};
|
|
// @cmember Costruttore (crea una maschera vuota con i parametri dati)
|
|
TConfig_f9_mask(const char* title, int pages, int cols, int rows, int xpos = -1, int ypos = -1) : TAutomask(title, pages, cols, rows, xpos, ypos) {};
|
|
};
|
|
|
|
class TControllo_mask : public TAutomask
|
|
{
|
|
TArray _controllo_mov; // Usare import_error_list().
|
|
char _ordin;
|
|
char _verso;
|
|
int _selected_mov;
|
|
bool _sel_esclusi;
|
|
bool _is_escluso;
|
|
TString _cod_soc;
|
|
TString _id_estr;
|
|
char _tipo_doc_err{};
|
|
TDate _datada;
|
|
TDate _dataa;
|
|
|
|
void associa();
|
|
void conferma_esclusi() const;
|
|
|
|
TArray& import_error_list();
|
|
void fill();
|
|
void fill_fppro_sheet() const;
|
|
TMask& get_win_order();
|
|
void open_win_order();
|
|
|
|
TToken_string* selected_mov();
|
|
TToken_string* selected_fat() const;
|
|
|
|
/** Gestisce la selezione multipla negli sheet di controllo movimenti */
|
|
void selfatt(TOperable_field& o, long jolly) const;
|
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
public:
|
|
TControllo_mask(const char* codsoc, const char* id_estr, bool esclusi = false);
|
|
};
|
|
|
|
class TF9_app : public TSkeleton_application
|
|
{
|
|
// friend class TMonitor_mask;
|
|
friend class TEstrai_mask;
|
|
// friend class TControllo_mask;
|
|
// friend class TApri_estr_msk;
|
|
friend class TEstrazione;
|
|
|
|
TMask * _esclusi_mask;
|
|
TEstrai_mask * _estr_msk;
|
|
TMonitor_mask * _msk;
|
|
TArray _movs; // TMovimento_estr
|
|
TArray _esclusi; // Vettore con i movimenti esclusi
|
|
TArray _esclusi_vect;
|
|
TToken_string _mov_escl;
|
|
char _tipodoc_escl;
|
|
char _flagprov_escl;
|
|
TString _log;
|
|
TEstrazione* _estr_escluso;
|
|
|
|
|
|
char get_tipodoc_escl() const { return _tipodoc_escl; }
|
|
// Dato il codice stato estrazione (es. "01") viene restituito il suo significato a parole (es. "in diagnostica").
|
|
TMask & esclusi_mask() { return *_esclusi_mask; }
|
|
|
|
public:
|
|
TArray & esclusi() { return _esclusi; }
|
|
TipoIVA get_tipoiva_escl() const { return get_tipodoc_escl() == 'A' ? iva_acquisti : iva_vendite; }
|
|
static const char* traduci_stato(const TString& cod);
|
|
static bool is_stato_errore(const TString& stato_etr);
|
|
/** Mostra la finestrella per l'inserimento delle opzioni per l'estrazione e avviarla. */
|
|
void run_estr_msk() { _estr_msk->run(); }
|
|
void notify_estraction() const;
|
|
|
|
// Estrazione esclusi - handlers
|
|
|
|
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);
|
|
static bool estrai_escl_handler(TMask_field&, KEY key);
|
|
|
|
void open_esclusi();
|
|
void fill_esclusi();
|
|
|
|
TMovimento_estr * TF9_app::escl2mov(TSheet_field & sf, int row) { return new TMovimento_estr(sf, row); }
|
|
|
|
static bool mov_handler_escl(TMask_field&, KEY key);
|
|
|
|
/** Aggiorna tabella F9WA. */
|
|
void edit_wa(TString& old_codsoc) const;
|
|
|
|
// logs
|
|
|
|
void print_log();
|
|
void add_msg_log(const char* msg);
|
|
void add_sqlerror_msg_log(const char* query);
|
|
|
|
static bool is_autofattura(const TLocalisamfile& mov);
|
|
|
|
/** Segna su mov che il movimento e' stato estratto. */
|
|
bool segna_estratti(bool escluso = false, int numreg = 0);
|
|
|
|
// Controllo e aggiornamento tabelle F9
|
|
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.
|
|
bool check_table() const; // Controllo e aggiornamento versione sql. Chiamata in main_loop.
|
|
|
|
public:
|
|
void main_loop() override;
|
|
|
|
TF9_app::TF9_app() : _mov_escl("", '|'), _tipodoc_escl('A'), _flagprov_escl('P'), _estr_escluso(nullptr) {}
|
|
~TF9_app() { safe_delete(_esclusi_mask); safe_delete(_estr_msk); }
|
|
};
|
|
|
|
inline TF9_app& f9_app()
|
|
{
|
|
static TF9_app* app = nullptr;
|
|
if (app == nullptr)
|
|
app = (TF9_app*)&main_app();
|
|
return *app;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
#endif //_F90100_H_
|