2019-06-13 17:43:30 +02:00
|
|
|
|
#include "lffiles.h"
|
|
|
|
|
#include "isam.h"
|
2019-09-13 17:35:25 +02:00
|
|
|
|
#include "../f1/f1lib.h"
|
2019-06-13 17:43:30 +02:00
|
|
|
|
#include "../fp/fplib.h"
|
2019-08-02 07:43:36 +02:00
|
|
|
|
#include "urldefid.h"
|
|
|
|
|
#include "progind.h"
|
2019-09-10 17:33:59 +02:00
|
|
|
|
#include "f90100.h"
|
|
|
|
|
#include "f901tab.h"
|
|
|
|
|
#include "f90100b.h"
|
2019-10-24 17:11:19 +02:00
|
|
|
|
#include "f90100d.h"
|
2019-10-16 14:23:36 +02:00
|
|
|
|
#include "sqlset.h"
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2019-10-24 17:11:19 +02:00
|
|
|
|
/** \file f90100.cpp
|
|
|
|
|
* Per aggiornare le tabelle f9 aggiungere nella cartella "sql\f9\" il file sql cosi' fatto:
|
2019-09-13 17:06:08 +02:00
|
|
|
|
* f9xxxx.sql dove xxxx e' il numero zero-filled della versione delle tabelle, che INCREMENTA DI DUE COME CON LE PATCH, IMPORTANTE!
|
2019-10-24 17:11:19 +02:00
|
|
|
|
* Aggiornare la definizione qui sotto di SQL_VERSION mettendo la nuova versione.
|
|
|
|
|
* Fare patch del file sql e dell'eseguibile f90.exe.
|
|
|
|
|
* Lanciare il programma per eseguire l'aggiornamento.
|
2019-09-13 17:06:08 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2019-09-16 18:10:27 +02:00
|
|
|
|
#define TABMOD_TABVER "S0" // Campo per la memorizzazione della versione attuale delle tabelle
|
|
|
|
|
#define TAB_BASE_VERSION 100 // Versione base delle tabelle
|
2020-04-14 10:19:04 +02:00
|
|
|
|
#define SQL_VERSION 104 // Utilizzo questo per controllare la versione attuale delle tabelle e nel caso aggiornarle
|
2019-06-13 17:43:30 +02:00
|
|
|
|
|
2020-04-21 18:53:15 +02:00
|
|
|
|
/* MD5 Check Sums dei file aggiornamento tabelle todo: possibile aggiunta: controllo del cheksum dei file (anche per FP) */
|
|
|
|
|
const TString v_check_sums[] = {
|
|
|
|
|
"SUMFILE0100e e d 1 8 5 f a 8 f 1 2 2 0 1 0 f 4 2 6 d 9 9 a 2 3 f 2 6 c 8 8",
|
|
|
|
|
"SUMFILE01023 5 3 3 3 a 5 e 3 b 4 9 e d 3 1 9 8 0 8 5 1 2 4 3 f 8 3 b 9 4 d",
|
|
|
|
|
"SUMFILE01040 a f f e 3 2 7 4 1 c d 7 4 1 8 1 4 c e 2 c a b 2 d 9 9 2 f 6 b" };
|
2020-04-18 16:00:37 +02:00
|
|
|
|
|
2020-04-21 18:53:15 +02:00
|
|
|
|
TString get_checksum(const int version)
|
|
|
|
|
{
|
|
|
|
|
TString cs = v_check_sums[(version - 100) / 2];
|
|
|
|
|
cs.ltrim(11);
|
|
|
|
|
cs.replace(" ", "");
|
|
|
|
|
return cs;
|
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
2020-04-01 21:37:55 +02:00
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// Utilities
|
|
|
|
|
////////////////////////////////////////////////////////
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
TMask& descr_msk()
|
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
static std::unique_ptr<TMask> m = nullptr;
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (m == nullptr)
|
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
m = std::make_unique<TMask>("Estrazione", 1, 60, 5);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
|
|
|
|
|
m->add_groupbox(DES_GROUP, 0, "Inserire descrizione estrazione:", 1, 0, 59, 3, "");
|
|
|
|
|
m->add_string(DES_TEXT, 0, "Descrizione", 4, 1, 250, "", 40);
|
|
|
|
|
}
|
|
|
|
|
return *m;
|
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TMask& esclusi_mask()
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
static unique_ptr<TMask> _esclusi_mask = nullptr;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (_esclusi_mask == nullptr)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
_esclusi_mask = std::make_unique<TMask>("f90100c.msk");
|
2019-09-13 17:06:08 +02:00
|
|
|
|
TMask& m = *_esclusi_mask;
|
|
|
|
|
((TSheet_field&)m.field(S_ESCL)).set_notify(TF9_app::select_escl_notify); // Handler dello sheet per selezione singola
|
2020-04-06 19:25:21 +02:00
|
|
|
|
m.set_handler(DLG_FINDREC, TF9_app::controllo_escl_handler); // Bottone per aprire maschera di controllo movimenti
|
|
|
|
|
m.set_handler(B_ESTRAI, TF9_app::estrai_escl_handler); // Bottone estrai
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
|
|
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
|
2020-04-01 21:26:49 +02:00
|
|
|
|
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler_escl); // Bottone collega movimento
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
|
|
m.field(DLG_FINDREC).disable();
|
|
|
|
|
}
|
2020-04-06 19:25:21 +02:00
|
|
|
|
return *_esclusi_mask;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TMask& inclusi_mask()
|
2019-10-24 17:11:19 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
static std::unique_ptr<TMask> _inclusi_mask = nullptr;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (_inclusi_mask == nullptr)
|
2019-10-24 17:11:19 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
_inclusi_mask = std::make_unique<TMask>("f90100d.msk");
|
2019-10-24 17:11:19 +02:00
|
|
|
|
TMask& m = *_inclusi_mask;
|
|
|
|
|
((TSheet_field&)m.field(S_ESCL)).set_notify(TF9_app::select_escl_notify); // Handler dello sheet per selezione singola
|
|
|
|
|
|
|
|
|
|
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
|
|
|
|
|
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler); // Bottone collega movimento
|
|
|
|
|
}
|
2020-04-06 19:25:21 +02:00
|
|
|
|
return *_inclusi_mask;
|
2019-10-24 17:11:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const TString& recset_get_string(const TRecordset& rec, const char* field, const int zero_filled)
|
|
|
|
|
{
|
|
|
|
|
const TString& str = rec.get(rec.find_column(field)).as_string();
|
|
|
|
|
if (zero_filled == -1)
|
|
|
|
|
return str;
|
|
|
|
|
static TString c;
|
|
|
|
|
c.cut(0);
|
|
|
|
|
const int len = str.len();
|
|
|
|
|
for (int i = len; i < zero_filled; i++) // Sistemo il codcaus per via del TVariant che non restituisce la stringa esattamente come l'originale
|
|
|
|
|
c << "0";
|
|
|
|
|
c << str;
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int recset_get_int(const TRecordset& rec, const char* field, const int zero_filled)
|
|
|
|
|
{
|
|
|
|
|
return rec.get(rec.find_column(field)).as_int();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool recset_get_bool(const TRecordset& rec, const char* field)
|
|
|
|
|
{
|
|
|
|
|
return rec.get(rec.find_column(field)).as_bool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
real recset_get_real(const TRecordset& rec, const char* field)
|
|
|
|
|
{
|
|
|
|
|
return rec.get(rec.find_column(field)).as_real();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
|
|
|
|
|
2019-08-02 07:43:36 +02:00
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// TEstrai_mask
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
TEstrai_mask::TEstrai_mask() : TMask("Estrazione", 1, 60, 16)
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
add_button_tool(DLG_ELABORA, "Estrai", TOOL_ELABORA);
|
|
|
|
|
add_button_tool(DLG_NULL, "", 0);
|
|
|
|
|
add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
|
|
|
|
|
|
|
|
|
|
add_groupbox(ES_DATEGROUP, 0, "Inserire periodo per estrazione:", 1, 0, 59, 3, "");
|
|
|
|
|
add_date(ES_DATAINI, 0, "dal", 4, 1, "");
|
|
|
|
|
add_date(ES_DATAEND, 0, " al", 33, 1, "");
|
|
|
|
|
add_groupbox(ES_FLAGGROUP, 0, "Selezionare tipo di estrazione:", 1, 3, 28, 3, "");
|
|
|
|
|
add_list(ES_FLAGPROV, 0, "Flag provvisorio", 2, 4, 1, "", "P|D", "Provvisorio|Definitivo");
|
|
|
|
|
add_groupbox(ES_TIPOGROUP, 0, "Selezionare documenti da estrarre:", 32, 3, 28, 3, "");
|
|
|
|
|
add_list(ES_TIPODOC, 0, "Tipi documento", 33, 4, 1, "", "A|V", "Acquisti|Vendite");
|
2019-09-25 17:43:55 +02:00
|
|
|
|
add_groupbox(ES_DESCGROUP, 0, "Inserire descrizione estrazione:", 1, 6, 59, 3, "");
|
|
|
|
|
add_string(ES_DESCR, 0, "Descrizione", 2, 7, 250, "", 40);
|
2019-06-13 17:43:30 +02:00
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TMask::set_handler(DLG_ELABORA, estrai_handler);
|
|
|
|
|
TMask::set_handler(ES_DATAINI, dataini_handler);
|
|
|
|
|
TMask::set_handler(ES_DATAEND, dataend_handler);
|
2019-06-13 17:43:30 +02:00
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TDate dt(TODAY); dt.set_day(1); dt.set_month(1);
|
|
|
|
|
set(ES_DATAINI, dt);
|
|
|
|
|
set(ES_DATAEND, today);
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
bool TEstrai_mask::estrai_handler(TMask_field& f, KEY key)
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TEstrai_mask& msk = (TEstrai_mask&)f.mask(); // this estrai_mask
|
2020-04-01 21:37:55 +02:00
|
|
|
|
TF9_app& a = f9_app();
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
|
|
// Estraggo
|
|
|
|
|
const int stato = a.estrai(); // Main function
|
|
|
|
|
|
|
|
|
|
// Gestione risultato estrazione
|
2019-09-13 17:06:08 +02:00
|
|
|
|
if (stato == 1)
|
|
|
|
|
{
|
|
|
|
|
message_box("Estrazione avvenuta con successo!");
|
2020-04-01 21:26:49 +02:00
|
|
|
|
a.segna_estratti();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
2019-10-22 17:36:05 +02:00
|
|
|
|
if (stato == 0 || stato == -3)
|
2019-09-17 11:45:00 +02:00
|
|
|
|
{
|
|
|
|
|
warning_box("L'estrazione non e' stata completata. Controllare il log degli errori.");
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (stato == 0) // Errore scrittura F9IVA, non segno in errore in testata...
|
2020-04-15 18:01:09 +02:00
|
|
|
|
TF9_app::segna_in_errore(); // ... se l'errore e' dovuto alla scrittura sul db
|
2019-09-17 11:45:00 +02:00
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
a.print_log();
|
2019-09-25 17:43:55 +02:00
|
|
|
|
msk.field(ES_DESCR).set("");
|
|
|
|
|
msk.stop_run(K_FORCE_CLOSE);
|
2020-04-01 21:26:49 +02:00
|
|
|
|
return true;
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TEstrai_mask::enable_fields(bool en)
|
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
enable(ES_DATAINI, en);
|
|
|
|
|
enable(ES_DATAEND, en);
|
|
|
|
|
enable(ES_FLAGPROV, en);
|
|
|
|
|
enable(ES_TIPODOC, en);
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
bool TEstrai_mask::enable_handler(TMask_field& f, KEY key)
|
2019-08-02 07:43:36 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
((TEstrai_mask&)f.mask()).enable_fields();
|
|
|
|
|
return true;
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
bool TEstrai_mask::dataini_handler(TMask_field& f, KEY key)
|
2019-08-02 07:43:36 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TMask& msk = f.mask();
|
|
|
|
|
if (key == K_TAB)
|
|
|
|
|
{
|
|
|
|
|
if (msk.get(ES_DATAINI).full() && msk.get(ES_DATAEND).full() && msk.get_date(ES_DATAINI) > msk.get_date(ES_DATAEND))
|
|
|
|
|
return f.error_box("La data di inizio non puo' essere maggiore di quella di fine");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2019-06-13 17:43:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
bool TEstrai_mask::dataend_handler(TMask_field& f, KEY key)
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TMask& msk = f.mask();
|
|
|
|
|
if (key == K_TAB)
|
|
|
|
|
{
|
|
|
|
|
if (msk.get(ES_DATAINI).full() && msk.get(ES_DATAEND).full() && msk.get_date(ES_DATAINI) > msk.get_date(ES_DATAEND))
|
|
|
|
|
return f.error_box("La data di fine non puo' essere minore di quella di inizio");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
|
2019-08-02 07:43:36 +02:00
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// TMonitor_mask
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-09-25 17:43:55 +02:00
|
|
|
|
bool TMonitor_mask::save_conf_handler(TMask_field& f, KEY key)
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TMask& config_mask = f.mask();
|
|
|
|
|
TF9_app& a = f9_app();
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TString old_codsoc = a.get_ambiente();
|
|
|
|
|
if(config_mask.get(CF_CODSOC).empty())
|
|
|
|
|
warning_box("Codice Ambiente vuoto. Impossibile salvare i dati.");
|
2020-04-01 21:37:55 +02:00
|
|
|
|
a.set_ambiente (config_mask.get(CF_CODSOC));
|
|
|
|
|
a.set_addr_doc (config_mask.get(CF_ADDRDOC));
|
|
|
|
|
a.set_has_vendext (config_mask.get_bool(CF_VENDEXT));
|
|
|
|
|
a.set_viewmov (config_mask.get_bool(CF_VIEWMOVPRE));
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
|
|
|
|
if (a.get_ambiente().full())
|
|
|
|
|
ini_set_string(CONFIG_DITTA, "F9", AMBIENTE_F9, a.get_ambiente());
|
|
|
|
|
if (a.get_addr_doc().full())
|
|
|
|
|
ini_set_string(CONFIG_DITTA, "F9", ADDRCART_F9, a.get_addr_doc());
|
|
|
|
|
ini_set_bool(CONFIG_DITTA, PAR_MOD, VENDEXT_F9, a.get_has_vendext());
|
|
|
|
|
ini_set_bool(CONFIG_DITTA, PAR_MOD, VIEWMOV_F9, a.get_viewmov());
|
|
|
|
|
config_mask.close();
|
2020-04-18 16:00:37 +02:00
|
|
|
|
a.edit_wa(old_codsoc);
|
2020-04-01 21:26:49 +02:00
|
|
|
|
return true;
|
2019-06-13 17:43:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
|
void TMonitor_mask::controllo_errori() const
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2019-09-13 17:06:08 +02:00
|
|
|
|
TString id_estr;
|
|
|
|
|
TSheet_field& sf = sfield(S_ELAB);
|
|
|
|
|
bool flag = false;
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
|
|
|
{
|
|
|
|
|
if (row->get(0)[0] == 'X')
|
|
|
|
|
{
|
|
|
|
|
id_estr << row->get(cid2index(F_IDESTR));
|
|
|
|
|
flag = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TControllo_mask controllo(f9_app().get_ambiente(), id_estr);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
controllo.run();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
warning_box("Selezionare un'estrazione.");
|
2019-06-13 17:43:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 11:45:00 +02:00
|
|
|
|
void TMonitor_mask::delete_pack(const bool all) const
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
|
|
|
|
bool flag = false;
|
|
|
|
|
TSheet_field& sf = sfield(S_ELAB);
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (row->get(0)[0] == 'X' || all)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
const TString id_estr(row->get(cid2index(F_IDESTR)));
|
|
|
|
|
TString query;
|
2020-04-16 18:54:56 +02:00
|
|
|
|
const TString codsoc(f9_app().get_ambiente());
|
2019-09-13 17:06:08 +02:00
|
|
|
|
query << "BEGIN\n"
|
2019-09-16 10:19:27 +02:00
|
|
|
|
" DECLARE @stato CHAR(2);\n\n"
|
|
|
|
|
" SELECT @stato = " DRD_STATO "\n"
|
|
|
|
|
" FROM " F9_DRD "\n"
|
|
|
|
|
" WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
|
|
|
|
|
" IF(@stato = '" D_GEST_ERR "') BEGIN\n"
|
2020-04-16 18:54:56 +02:00
|
|
|
|
" DELETE FROM " F9_ERR " WHERE IDOC = '" << codsoc << "' AND IDESTR = '" << id_estr << "';\n"
|
2019-09-16 10:19:27 +02:00
|
|
|
|
" END\n"
|
|
|
|
|
" ELSE BEGIN\n"
|
|
|
|
|
" SELECT @stato AS STATO;\n"
|
|
|
|
|
" END\n"
|
|
|
|
|
"END";
|
2020-04-01 21:26:49 +02:00
|
|
|
|
fp_db().sq_set_exec(query);
|
2019-09-16 10:19:27 +02:00
|
|
|
|
// Elimino testata in DRD, solo se provvis.
|
|
|
|
|
query.cut(0) << "BEGIN\n"
|
2019-09-13 17:06:08 +02:00
|
|
|
|
" DECLARE @flag_prov CHAR(1), @stato CHAR(2);\n\n"
|
|
|
|
|
" SELECT @flag_prov = " DRD_FLAG_PD ", @stato = " DRD_STATO "\n"
|
|
|
|
|
" FROM " F9_DRD "\n"
|
|
|
|
|
" WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
|
|
|
|
|
" IF (@flag_prov = 'P' OR @stato = '" D_GEST_ERR "') BEGIN\n"
|
2020-04-16 18:54:56 +02:00
|
|
|
|
" DELETE FROM " F9_DRD " WHERE " DRD_CODSOC " = '" << codsoc << "' AND " DRD_ID_EST " = '" << id_estr << "';\n"
|
|
|
|
|
" DELETE FROM " F9_IVA " WHERE " IVA_CODSOC " = '" << codsoc << "' AND " IVA_IDLAN " = '" << id_estr << "';\n"
|
|
|
|
|
" DELETE FROM " F9_MOVESTR " WHERE " MOV_CODSOC " = '" << codsoc << "' AND " MOV_IDESTR " = '" << id_estr << "';\n"
|
2019-09-13 17:06:08 +02:00
|
|
|
|
" END\n"
|
|
|
|
|
" SELECT @flag_prov AS FLAG, @stato AS STATO;\n"
|
|
|
|
|
"END";
|
2020-04-01 21:26:49 +02:00
|
|
|
|
fp_db().sq_set_exec(query);
|
|
|
|
|
if (fp_db().sq_get("FLAG") != "P" && fp_db().sq_get("STATO") != "02" && !all)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
|
|
|
|
warning_box("E' possibile eliminare solo un'estrazione provvisoria o in stato di errore diagnostica gestionale.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-16 18:54:56 +02:00
|
|
|
|
fp_db().sq_commit();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
if (!all)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (!flag)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (noyes_box("Eliminare tutti i pacchetti provvisori o in stato di errore gestionale?"))
|
2019-09-13 17:06:08 +02:00
|
|
|
|
delete_pack(true);
|
|
|
|
|
}
|
|
|
|
|
fill();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TMonitor_mask::fill() const
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString query;
|
|
|
|
|
query << "SELECT * FROM F9DRD00K ORDER BY " << DRD_TIME << " DESC;";
|
|
|
|
|
fp_db().sq_set_exec(query, false);
|
|
|
|
|
|
2019-09-13 17:06:08 +02:00
|
|
|
|
TSheet_field& sf = sfield(S_ELAB);
|
|
|
|
|
sf.hide();
|
2020-04-01 21:29:53 +02:00
|
|
|
|
sf.destroy();
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString tipo;
|
|
|
|
|
TToken_string& row = sf.row(i++);
|
|
|
|
|
row.add(" ");
|
|
|
|
|
row.add(fp_db().sq_get(DRD_STATO) == "09" ? "X" : "");
|
|
|
|
|
row.add(fp_db().sq_get(DRD_ID_EST));
|
|
|
|
|
row.add(fp_db().sq_get_date(DRD_TIME));
|
|
|
|
|
row.add(fp_db().sq_get(DRD_FLAG_PD) == "P" ? "X" : "");
|
|
|
|
|
|
|
|
|
|
tipo << fp_db().sq_get(DRD_TIPODOC);
|
|
|
|
|
if (tipo == "A") tipo << "cquisti";
|
|
|
|
|
if (tipo == "V") tipo << "endite";
|
|
|
|
|
if (tipo == "C") tipo << "orrispettivi";
|
|
|
|
|
row.add(tipo);
|
|
|
|
|
|
|
|
|
|
row.add(fp_db().sq_get_date(DRD_DATADA));
|
|
|
|
|
row.add(fp_db().sq_get_date(DRD_DATAA));
|
|
|
|
|
row.add(fp_db().sq_get(DRD_UTENTE));
|
|
|
|
|
row.add(fp_db().sq_get(DRD_STATO) << " - " << TF9_app::traduci_stato(fp_db().sq_get(DRD_STATO)));
|
|
|
|
|
row.add(fp_db().sq_get(DRD_DESC));
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TMonitor_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case DLG_ELABORA:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
open_win_estr();
|
|
|
|
|
break;
|
|
|
|
|
case DLG_DELREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
delete_pack();
|
|
|
|
|
break;
|
|
|
|
|
case DLG_CONFIG:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
open_win_conf();
|
|
|
|
|
break;
|
|
|
|
|
case DLG_FINDREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
controllo_errori();
|
|
|
|
|
break;
|
|
|
|
|
case DLG_RECALC:
|
|
|
|
|
fill();
|
|
|
|
|
break;
|
|
|
|
|
case B_SHOWESTR:
|
|
|
|
|
open_mostra_estrazione();
|
|
|
|
|
break;
|
|
|
|
|
case B_SHOWESCL:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
f9_app().open_esclusi();
|
|
|
|
|
break;
|
|
|
|
|
case F_SEL:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
sel();
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TMonitor_mask::on_key(const KEY key)
|
|
|
|
|
{
|
|
|
|
|
return TAutomask::on_key(key);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
void TMonitor_mask::open_mostra_estrazione() const
|
2019-10-24 17:11:19 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TMask& msk = inclusi_mask();
|
2019-10-24 17:11:19 +02:00
|
|
|
|
//fill
|
|
|
|
|
TSheet_field& sf = msk.sfield(S_ESCL);
|
|
|
|
|
sf.destroy();
|
|
|
|
|
TString id;
|
|
|
|
|
TToken_string* _row = nullptr;
|
|
|
|
|
FOR_EACH_SHEET_ROW(sfield(S_ELAB), nr, row)
|
|
|
|
|
{
|
|
|
|
|
if (row->get(0)[0] == 'X')
|
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (TString(row->get(cid2index(F_STATESTR))).starts_with("02"))
|
|
|
|
|
{
|
|
|
|
|
message_box("Impossibile controllare un pacchetto in stato di errore '02'.\n"
|
|
|
|
|
"Usare il 'Controllo Estrazioni' per vedere i movimenti in errore.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-10-24 17:11:19 +02:00
|
|
|
|
_row = row;
|
|
|
|
|
id = row->get(cid2index(F_IDESTR));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
if (_row == nullptr)
|
2019-10-24 17:11:19 +02:00
|
|
|
|
{
|
|
|
|
|
message_box("Selezionare un pacchetto.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
msk.set(F_IIDESTR, _row->get(cid2index(F_IDESTR)));
|
|
|
|
|
msk.set(F_IDATA, _row->get(cid2index(F_DATAESTR)));
|
|
|
|
|
msk.set(F_IPROV, _row->get(cid2index(F_PROV_B)));
|
|
|
|
|
msk.set(F_ITIPOD, _row->get(cid2index(F_TIPODOC)));
|
|
|
|
|
msk.set(F_IDAL, _row->get(cid2index(F_DATADAL)));
|
|
|
|
|
msk.set(F_IAL, _row->get(cid2index(F_DATAAL)));
|
|
|
|
|
|
|
|
|
|
TString query;
|
|
|
|
|
query << "SELECT " IVA_SEZIVA ", " IVA_DATADOC ", " IVA_NUMDOC ", " IVA_NPROT "\n"
|
|
|
|
|
"FROM " F9_IVA "\n"
|
|
|
|
|
"WHERE " IVA_IDLAN " = '" << id << "'";
|
|
|
|
|
|
2020-04-01 21:26:49 +02:00
|
|
|
|
// REG + DATAREG + PROTIVA + DATAINC + DATA74TER + NUMREG
|
2019-10-24 17:11:19 +02:00
|
|
|
|
TString sql;
|
|
|
|
|
TSQL_recordset rec("");
|
2020-04-01 21:26:49 +02:00
|
|
|
|
fp_db().sq_set_exec(query, false);
|
|
|
|
|
|
|
|
|
|
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
2019-10-24 17:11:19 +02:00
|
|
|
|
{
|
2020-04-01 21:26:49 +02:00
|
|
|
|
sql.cut(0) << "SELECT NUMREG, DATAREG, DATADOC, CODCAUS, TIPODOC, MESELIQ, NUMDOC, TOTDOC, CODCF, REG, PROTIVA, DESCR\n"
|
|
|
|
|
"FROM MOV\n"
|
|
|
|
|
"WHERE REG = '" << fp_db().sq_get(IVA_SEZIVA) << "' AND DATADOC=" << TDate(fp_db().sq_get_date(IVA_DATADOC)).date2ansi() <<
|
|
|
|
|
" AND PROTIVA = " << fp_db().sq_get(IVA_NPROT);
|
2019-10-24 17:11:19 +02:00
|
|
|
|
rec.set(sql);
|
|
|
|
|
rec.move_first();
|
2020-04-01 21:26:49 +02:00
|
|
|
|
TToken_string& r = sf.row(-1);
|
|
|
|
|
r.add(" ", 0);
|
|
|
|
|
r.add(rec.get(rec.find_column(MOV_NUMREG)).as_string());
|
|
|
|
|
r.add(rec.get(1).as_string());
|
|
|
|
|
r.add(rec.get(2).as_string());
|
|
|
|
|
r.add(rec.get(3).as_string());
|
|
|
|
|
r.add(rec.get(4).as_string());
|
|
|
|
|
r.add(rec.get(5).as_string());
|
|
|
|
|
r.add(rec.get(6).as_string());
|
|
|
|
|
r.add(rec.get(7).as_string());
|
|
|
|
|
r.add(rec.get(8).as_string()); // Siamo sicuri?
|
2019-10-24 17:11:19 +02:00
|
|
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
|
|
|
clifo.put(CLI_CODCF, rec.get(7).as_string());
|
|
|
|
|
clifo.put(CLI_TIPOCF, _row->get(cid2index(F_TIPODOC))[0] == 'A' ? "F" : "C");
|
|
|
|
|
clifo.read();
|
2020-04-01 21:26:49 +02:00
|
|
|
|
r.add(clifo.get(CLI_RAGSOC));
|
|
|
|
|
r.add(TString(rec.get(8).as_string()) << "/" << rec.get(9).as_string());
|
|
|
|
|
r.add(rec.get(10).as_string());
|
2019-10-24 17:11:19 +02:00
|
|
|
|
}
|
|
|
|
|
msk.run();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TMonitor_mask::open_win_estr()
|
2019-08-02 07:43:36 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (!f9_app().get_ambiente().full())
|
|
|
|
|
warning_box("Inserire codice ambiente societa' in configurazione");
|
|
|
|
|
else f9_app().run_estr_msk();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TMonitor_mask::open_win_conf() const
|
|
|
|
|
{
|
|
|
|
|
static TMask* m = nullptr;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (m == nullptr)
|
|
|
|
|
{
|
|
|
|
|
m = new TMask("Configurazione Archiviazione Sostitutiva", 1, 60, 18);
|
2019-08-02 07:43:36 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
|
|
|
|
|
m->add_button_tool(DLG_NULL, "", 0);
|
|
|
|
|
m->add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m->add_groupbox(CF_CODGROUP, 0, "Codice Ambiente Societa' (WEBAPP):", 1, 0, 59, 3, "");
|
|
|
|
|
m->add_string(CF_CODSOC, 0, "Codice ambiente", 4, 1, 10, "", 10);
|
|
|
|
|
m->add_groupbox(CF_ADDRGROUP, 0, "Indicare percorso documenti cartacei:", 1, 3, 59, 3, "");
|
|
|
|
|
m->add_string(CF_ADDRDOC, 0, "Percorso", 2, 4, 256, "", 40);
|
|
|
|
|
m->add_groupbox(CF_ESTRGROUP, 0, "Opzioni estrazione", 1, 6, 59, 4, "");
|
|
|
|
|
m->add_boolean(CF_VENDEXT, 0, "Disabilita controllo documenti vendita (no fatturazione vendite)", 2, 7);
|
|
|
|
|
m->add_boolean(CF_VIEWMOVPRE, 0, "Visualizza movimenti preparati prima di lanciare l'estrazione", 2, 8);
|
|
|
|
|
|
|
|
|
|
m->set_handler(DLG_OK, save_conf_handler);
|
|
|
|
|
|
2020-04-01 21:37:55 +02:00
|
|
|
|
m->set(CF_CODSOC, ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9));
|
|
|
|
|
m->set(CF_ADDRDOC, ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9));
|
|
|
|
|
m->set(CF_VENDEXT, ini_get_bool(CONFIG_DITTA, PAR_MOD, VENDEXT_F9));
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m->set(CF_VIEWMOVPRE, ini_get_bool(CONFIG_DITTA, PAR_MOD, VIEWMOV_F9));
|
|
|
|
|
}
|
|
|
|
|
m->run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TMonitor_mask::sel() const
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(S_ELAB);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
sf.hide();
|
2020-04-01 21:29:53 +02:00
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (*row->get(0) == 'X')
|
|
|
|
|
row->add("", 0);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////
|
|
|
|
|
// TControllo_mask
|
|
|
|
|
/////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TControllo_mask::associa() // todo: levare gli ultimi residui del vecchio funzionamento del controllo errori
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string* mov_sel = selected_mov();
|
|
|
|
|
TToken_string* fat_sel = selected_fat();
|
|
|
|
|
if (mov_sel == nullptr || fat_sel == nullptr)
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
warning_box("Selezionare prima un movimento e una fattura elettronica.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TToken_string keys(fat_sel->get(cid2index(F_FPROKEYS)), ';');
|
|
|
|
|
fppro_db().set_keys(keys);
|
|
|
|
|
const bool ok = fppro_db().associa_mov(mov_sel->get_int(cid2index(F_CNUMREG)));
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
// Tolgo il flag di in errore sul vettore in modo da rifare la fill e non venir piu' contato come da controllare
|
|
|
|
|
auto it = _movs.begin();
|
|
|
|
|
int count = -1;
|
|
|
|
|
while (count < _selected_mov && it != _movs.end())
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (it->get(0)[0] == 'X') // Devo saltare tutti quelli che non hanno il flag e contare solo quelli che ce l'hanno
|
|
|
|
|
count++;
|
|
|
|
|
if (count < _selected_mov)
|
|
|
|
|
++it;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
it->add(' ', 0);
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TF9_dberr::del_err(_cod_soc, _id_estr, mov_sel->get_int(cid2index(F_CNUMREG)));
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2019-10-24 17:11:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TControllo_mask::conferma_esclusi() const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const TMask& mask = *this;
|
|
|
|
|
TSheet_field& sf = mask.sfield(S_CONTROLLO);
|
|
|
|
|
sf.hide();
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
2020-04-01 21:26:49 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TLocalisamfile movs(LF_MOV);
|
|
|
|
|
movs.put(MOV_NUMREG, row->get_int(cid2index(F_CNUMREG)));
|
|
|
|
|
movs.read();
|
|
|
|
|
if (*row->get(cid2index(F_CESCLUDI)) == 'X')
|
2020-04-01 21:26:49 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const TDate today(TODAY);
|
|
|
|
|
TToken_string stato("", ';');
|
|
|
|
|
stato.add("", 0);
|
|
|
|
|
stato.add(today.date2ansi());
|
|
|
|
|
stato.add("X");
|
|
|
|
|
movs.put(MOV_ELABF9, stato);
|
|
|
|
|
movs.rewrite();
|
|
|
|
|
row->add("Si", cid2index(F_CESCLUSO));
|
|
|
|
|
TString query;
|
2020-04-21 18:53:15 +02:00
|
|
|
|
query << "UPDATE " F9_ERR " SET ESCLUSO = 'Si' WHERE " ERR_CODSOC " = '" << _cod_soc << "' AND IDESTR = '" <<
|
|
|
|
|
_id_estr << "' AND NUMREG = '" << row->get(cid2index(F_CNUMREG)) << "';";
|
2020-04-01 21:29:53 +02:00
|
|
|
|
fp_db().sq_set_exec(query);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (movs.get(MOV_ELABF9).full())
|
2020-04-01 21:26:49 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
movs.put(MOV_ELABF9, "");
|
|
|
|
|
row->add("", cid2index(F_CESCLUSO));
|
|
|
|
|
movs.rewrite();
|
|
|
|
|
TString query;
|
2020-04-21 18:53:15 +02:00
|
|
|
|
query << "UPDATE " F9_ERR " SET ESCLUSO = NULL WHERE " ERR_CODSOC " = '" << _cod_soc << "' AND IDESTR = '" <<
|
|
|
|
|
_id_estr << "' AND NUMREG = '" << row->get(cid2index(F_CNUMREG)) << "';";
|
2020-04-01 21:29:53 +02:00
|
|
|
|
fp_db().sq_set_exec(query);
|
2020-04-01 21:26:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
}
|
2020-04-01 21:26:49 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
vector<TToken_string>& TControllo_mask::import_error_list()
|
|
|
|
|
{
|
|
|
|
|
static vector<TToken_string> controllo_mov;
|
|
|
|
|
controllo_mov.clear();
|
|
|
|
|
TF9_dberr dberr;
|
2020-04-18 16:00:37 +02:00
|
|
|
|
_tipo_doc_err = TF9_dberr::get_errori(_cod_soc, _id_estr, controllo_mov);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return controllo_mov;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TControllo_mask::fill()
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TSheet_field& sf = sfield(S_CONTROLLO);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
sf.hide();
|
|
|
|
|
sf.destroy();
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_movs = !_is_escluso ? import_error_list() : f9_app()._esclusi; // Prendo da _esclusi se sto aprendo il controllo dalla maschera degli esclusi
|
|
|
|
|
|
|
|
|
|
for (auto it = _movs.begin(); it != _movs.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sf.row(-1);
|
|
|
|
|
if (*it->get(0) == 'X')
|
|
|
|
|
{
|
|
|
|
|
row = *it;
|
|
|
|
|
row[0] = (char&)" ";
|
|
|
|
|
/*if (!_is_escluso && _tipo_doc_err == 'A' || _is_escluso && f9_app().get_tipoiva_escl() == iva_acquisti)
|
|
|
|
|
row.add("", cid2index(F_CESCLUDI));
|
|
|
|
|
else
|
|
|
|
|
row.add("X", cid2index(F_CESCLUDI));*/
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-13 17:06:08 +02:00
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
// Fill fppro sheet
|
|
|
|
|
if (!_is_escluso && _tipo_doc_err == 'A' || _is_escluso && f9_app().get_tipoiva_escl() == iva_acquisti)
|
|
|
|
|
fill_fppro_sheet();
|
2020-04-01 21:26:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TControllo_mask::fill_fppro_sheet() const
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TSheet_field& sf = sfield(S_FPPRO);
|
|
|
|
|
sf.hide();
|
|
|
|
|
sf.destroy();
|
|
|
|
|
const char* order;
|
|
|
|
|
switch (_ordin)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
default:
|
|
|
|
|
case 'D': order = "P7_DATA"; break;
|
|
|
|
|
case 'N': order = "P7_NUMERO"; break;
|
|
|
|
|
case 'F': order = "FORNITORE"; break;
|
|
|
|
|
case 'R': order = "P2_ANADENOMIN"; break;
|
|
|
|
|
case 'P': order = "P2_FISCIVACOD"; break;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString query;
|
|
|
|
|
query << "SELECT PQ_KEYPRGINVIO AS KEYPRGINVIO, PQ_KEYHEADERFATT AS KEYHEADERFATT, PQ_KEYBODYFATT AS KEYBODYFATT,\n" <<
|
|
|
|
|
"PZ_TIPODOC AS TIPODOC, P7_DATA AS DATA, P7_NUMERO AS NUMDOC, PQ_IMPTOTDOC AS IMPTOTDOC,\n" <<
|
|
|
|
|
"CASE\n" <<
|
|
|
|
|
"WHEN PZ_CLIFOR <> '' THEN CAST(PZ_CLIFOR AS NUMERIC(10, 0))\n" <<
|
|
|
|
|
"WHEN PZ_CLIFOR = '' THEN 0\n" <<
|
|
|
|
|
"END AS FORNITORE, " <<
|
|
|
|
|
"P2_ANADENOMIN AS RAGSOC, P2_FISCIVAPAESE AS STATOPIVA, P2_FISCIVACOD AS PIVA FROM PAA2700F\n" <<
|
|
|
|
|
"JOIN PAA0700F ON PQ_KEYPRGINVIO = P7_KEYPRGINVIO AND PQ_KEYHEADERFATT = P7_KEYHEADERFATT AND PQ_KEYBODYFATT = P7_KEYBODYFATT\n" <<
|
|
|
|
|
"JOIN PAA0200F ON PQ_KEYPRGINVIO = P2_KEYPRGINVIO AND PQ_KEYHEADERFATT = P2_KEYHEADERFATT AND PQ_KEYBODYFATT = P2_KEYBODYFATT\n" <<
|
|
|
|
|
"JOIN FPPRO00F ON PQ_KEYPRGINVIO = PZ_KEYPRGINVIO AND PQ_KEYHEADERFATT = PZ_KEYHEADERFATT AND PQ_KEYBODYFATT = PZ_KEYBODYFATT\n" <<
|
|
|
|
|
"WHERE PZ_NUMREGCONT = '0' AND PZ_DATAREGCONT = '2001-01-01'\n" <<
|
|
|
|
|
"ORDER BY " << order << " " << (_verso == 'A' ? "ASC" : "DESC") << "\n";
|
|
|
|
|
fp_db().sq_set_exec(query, false);
|
2019-10-24 17:11:19 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
|
|
|
|
{
|
|
|
|
|
TToken_string& row = sf.row(-1);
|
|
|
|
|
row.add(fp_db().sq_get("TIPODOC"), 1);
|
|
|
|
|
row.add(fp_db().sq_get_date("DATA"));
|
|
|
|
|
row.add(fp_db().sq_get("NUMDOC"));
|
|
|
|
|
row.add(fp_db().sq_get("IMPTOTDOC"));
|
|
|
|
|
row.add(fp_db().sq_get("FORNITORE"));
|
|
|
|
|
row.add(fp_db().sq_get("RAGSOC"));
|
|
|
|
|
row.add(fp_db().sq_get("STATOPIVA"));
|
|
|
|
|
row.add(fp_db().sq_get("PIVA"));
|
|
|
|
|
row.add(fp_db().sq_get("KEYPRGINVIO") << ";" << fp_db().sq_get("KEYHEADERFATT") << ";" << fp_db().sq_get("KEYBODYFATT"));
|
|
|
|
|
}
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TMask& TControllo_mask::get_win_order()
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
|
|
|
|
static TMask* m = nullptr;
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
2019-09-10 17:33:59 +02:00
|
|
|
|
if (m == nullptr)
|
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m = new TMask("Configurazione Archiviazione Sostitutiva", 1, 60, 10);
|
|
|
|
|
// TOOLBAR
|
2019-09-10 17:33:59 +02:00
|
|
|
|
m->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
m->add_button_tool(DLG_NULL, "", 0);
|
|
|
|
|
m->add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
|
|
|
|
|
|
|
|
|
|
// Ordinatori
|
|
|
|
|
m->add_radio(F_ORDER, 0, "Ordina per:", 1, 0, 59, "D|N|F|R|P", "DATA|NUMDOC|FORNITORE|RAGSOC|PIVA", "Z");
|
|
|
|
|
m->add_radio(F_VERSO, 0, "Verso:", 1, 3, 59, "A|D", "Crescente|Decrescente", "Z");
|
|
|
|
|
|
|
|
|
|
//m->set_handler(DLG_OK, save_conf_handler);
|
|
|
|
|
_ordin = ini_get_string(CONFIG_DITTA, PAR_MOD, "ORDINAM", "D")[0];
|
|
|
|
|
_verso = ini_get_string(CONFIG_DITTA, PAR_MOD, "VERSO", "A")[0];
|
|
|
|
|
m->set(F_ORDER, &_ordin);
|
|
|
|
|
m->set(F_VERSO, &_verso);
|
|
|
|
|
|
|
|
|
|
/*m->set(CF_CODSOC, ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9));
|
|
|
|
|
m->set(CF_ADDRDOC, ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9));*/
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
return *m;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TControllo_mask::open_win_order()
|
2019-08-02 07:43:36 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TMask& m = get_win_order();
|
|
|
|
|
m.run();
|
|
|
|
|
_ordin = m.get(F_ORDER)[0];
|
|
|
|
|
_verso = m.get(F_VERSO)[0];
|
|
|
|
|
ini_set_string(CONFIG_DITTA, PAR_MOD, "ORDINAM", &_ordin);
|
|
|
|
|
ini_set_string(CONFIG_DITTA, PAR_MOD, "VERSO", &_verso);
|
2019-06-13 17:43:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string* TControllo_mask::selected_mov()
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TSheet_field& movs = sfield(S_CONTROLLO);
|
|
|
|
|
FOR_EACH_SHEET_ROW(movs, nr, row)
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (row->get(0)[0] == 'X')
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_selected_mov = nr;
|
|
|
|
|
return row;
|
2019-09-17 16:12:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return nullptr;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string* TControllo_mask::selected_fat() const
|
2019-10-22 17:36:05 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TSheet_field& fppro = sfield(S_FPPRO);
|
|
|
|
|
FOR_EACH_SHEET_ROW(fppro, nr, row)
|
2019-10-22 17:36:05 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (row->get(0)[0] == 'X')
|
|
|
|
|
return row;
|
2019-10-22 17:36:05 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return nullptr;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TControllo_mask::selfatt(TOperable_field& o, const long jolly) const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const TMask& mask = *this;
|
|
|
|
|
TSheet_field* sf;
|
|
|
|
|
if (jolly == 1) // Sheet controllo
|
|
|
|
|
sf = &mask.sfield(S_CONTROLLO);
|
|
|
|
|
else
|
|
|
|
|
sf = &mask.sfield(S_FPPRO);
|
|
|
|
|
sf->hide();
|
|
|
|
|
FOR_EACH_SHEET_ROW(*sf, nr, row)
|
|
|
|
|
{
|
|
|
|
|
if (*row->get(0) == 'X')
|
|
|
|
|
row->add("", 0);
|
|
|
|
|
}
|
|
|
|
|
sf->force_update();
|
|
|
|
|
sf->show();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TControllo_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
switch (o.dlg())
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
case DLG_USER:
|
|
|
|
|
if (e == fe_button && jolly > 0)
|
|
|
|
|
{
|
2020-04-21 18:53:15 +02:00
|
|
|
|
TSheet_field& sf = sfield(S_CONTROLLO);
|
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TRectype mov(LF_MOV);
|
|
|
|
|
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
|
|
|
|
|
if (open_mov(mov))
|
|
|
|
|
fill();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_ORDER:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
open_win_order();
|
|
|
|
|
fill_fppro_sheet();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_ASSOC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
associa();
|
|
|
|
|
fill(); // Ricarico gli sheet
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_ESCL:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
conferma_esclusi();
|
|
|
|
|
fill();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_SELESCL:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
_sel_esclusi = !_sel_esclusi;
|
|
|
|
|
field(B_ASSOC).enable(!_sel_esclusi);
|
|
|
|
|
field(B_ESCL).enable(_sel_esclusi);
|
|
|
|
|
field(B_ALLESCL).enable(_sel_esclusi);
|
|
|
|
|
sfield(S_CONTROLLO).enable_column(cid2index(F_CESCLUDI), _sel_esclusi);
|
|
|
|
|
sfield(S_CONTROLLO).force_update();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_ALLESCL:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = sfield(S_CONTROLLO);
|
|
|
|
|
sf.hide();
|
|
|
|
|
const bool active = *sf.row(0).get(cid2index(F_CESCLUDI)) == 'X';
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
|
|
|
row->add(active ? " " : "X", cid2index(F_CESCLUDI));
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case S_CONTROLLO:
|
|
|
|
|
if (e == fe_init)
|
|
|
|
|
sfield(S_CONTROLLO).enable_column(cid2index(F_CESCLUDI), false);
|
|
|
|
|
break;
|
|
|
|
|
case F_CSEL:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
selfatt(o, jolly);
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return true;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TControllo_mask::TControllo_mask(const char* codsoc, const char* id_estr, bool esclusi)
|
2020-04-14 10:19:04 +02:00
|
|
|
|
: TAutomask("f90100b"), _ordin('D'), _verso('A'), _selected_mov(0), _sel_esclusi(false)
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-18 16:00:37 +02:00
|
|
|
|
_cod_soc = codsoc;
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_id_estr = id_estr;
|
|
|
|
|
field(B_ESCL).disable();
|
|
|
|
|
field(B_ALLESCL).disable();
|
|
|
|
|
get_win_order();
|
|
|
|
|
_is_escluso = esclusi;
|
|
|
|
|
|
|
|
|
|
// Fill controllo sheet
|
|
|
|
|
fill();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
// TF9_app
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
const char* TF9_app::traduci_stato(const TString& cod)
|
2019-09-16 10:19:27 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
static TString stato;
|
|
|
|
|
static TString last_cod;
|
|
|
|
|
if (last_cod != cod)
|
2019-09-16 10:19:27 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
last_cod = cod;
|
|
|
|
|
stato.cut(0);
|
|
|
|
|
if (cod == "01")
|
|
|
|
|
stato << "in diagnostica";
|
|
|
|
|
else if (cod == "02")
|
|
|
|
|
stato << "errore diagnostica gestionale";
|
|
|
|
|
else if (cod == "03")
|
|
|
|
|
stato << "diagnostica gestionale passata";
|
|
|
|
|
else if (cod == "04")
|
|
|
|
|
stato << "controllo WebApp";
|
|
|
|
|
else if (cod == "05")
|
|
|
|
|
stato << "errore diagnostica WebApp";
|
|
|
|
|
else if (cod == "06")
|
|
|
|
|
stato << "diagnostica WebApp passata";
|
|
|
|
|
else if (cod == "07")
|
|
|
|
|
stato << "in elaborazione da sostitutiva";
|
|
|
|
|
else if (cod == "08")
|
|
|
|
|
stato << "errore diagnostica da sostitutiva";
|
|
|
|
|
else if (cod == "09")
|
|
|
|
|
stato << "Archiviato";
|
|
|
|
|
}
|
|
|
|
|
return (const char*)stato;
|
2019-09-16 10:19:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
// Estrazione esclusi
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::select_escl_notify(TSheet_field& s, int row, KEY key)
|
|
|
|
|
{
|
|
|
|
|
TMask_field& field = s;
|
|
|
|
|
const TMask& mask = field.mask();
|
|
|
|
|
TSheet_field& sf = mask.sfield(S_ESCL);
|
|
|
|
|
sf.hide();
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, riga)
|
|
|
|
|
{
|
|
|
|
|
if (*riga->get(0) == 'X')
|
|
|
|
|
riga->add("", 0);
|
|
|
|
|
}
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::controllo_escl_handler(TMask_field& field, KEY key)
|
|
|
|
|
{
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TF9_app& app = f9_app();
|
|
|
|
|
TControllo_mask controllo(app.get_ambiente(), app._estr_escluso->get_id_estr(), true);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
controllo.run();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-08-02 07:43:36 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::year_handler(TMask_field& field, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB)
|
|
|
|
|
{
|
|
|
|
|
const int year = real(field.get()).integer();
|
|
|
|
|
if (year <= 2001 || year >= 2100)
|
|
|
|
|
{
|
|
|
|
|
error_box("Anno non corretto");
|
|
|
|
|
field.mask().set(501, today.year());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2019-08-02 07:43:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::add_msg_log(const char* msg)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_log << msg << "\n\n";
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::add_sqlerror_msg_log(const char* query)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString msg;
|
|
|
|
|
msg << query << "\n" <<
|
|
|
|
|
fp_db().sq_get_string_error() << "\n" <<
|
|
|
|
|
fp_db().sq_get_text_error();
|
|
|
|
|
add_msg_log(msg);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::open_esclusi()
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
/* Prima chiedo quale mese e anno visualizzare
|
|
|
|
|
*/
|
2020-04-21 18:53:15 +02:00
|
|
|
|
// FINESTRA
|
2020-04-01 21:29:53 +02:00
|
|
|
|
static TMask* ym_msk = nullptr;
|
|
|
|
|
if (ym_msk == nullptr)
|
|
|
|
|
{
|
|
|
|
|
ym_msk = new TMask("Mostra esclusi", 1, 25, 16);
|
|
|
|
|
ym_msk->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
|
|
|
|
|
ym_msk->add_button_tool(DLG_NULL, "", 0);
|
|
|
|
|
ym_msk->add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
|
|
|
|
|
ym_msk->add_groupbox(507, 0, "Movimenti da visualizzare:", 0, 0, 25, 6);
|
|
|
|
|
ym_msk->add_number(501, 0, "Anno", 1, 1, 4);
|
|
|
|
|
ym_msk->add_list(502, 0, "Mese", 1, 2, 8, "", "01|02|03|04|05|06|07|08|09|10|11|12", "Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
|
|
|
|
|
ym_msk->add_list(503, 0, "Fino al", 1, 3, 9, "", " |01|02|03|04|05|06|07|08|09|10|11|12", " |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
|
|
|
|
|
ym_msk->add_groupbox(506, 0, "Selezionare il tipo di estrazione", 0, 6, 25);
|
|
|
|
|
ym_msk->add_list(504, 0, "Flag Provvisorio", 1, 7, 1, "", "P|D", "Provvisorio|Definitivo");
|
|
|
|
|
ym_msk->add_list(505, 0, "Tipo doc.", 1, 4, 1, "", "A|V", "Acquisti|Vendite");
|
|
|
|
|
ym_msk->set(501, today.year());
|
|
|
|
|
ym_msk->set_handler(501, year_handler);
|
|
|
|
|
}
|
|
|
|
|
ym_msk->run();
|
|
|
|
|
if (ym_msk->last_key() == K_QUIT)
|
|
|
|
|
return;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_flagprov_escl = ym_msk->get(504)[0];
|
|
|
|
|
_tipodoc_escl = ym_msk->get(505)[0];
|
|
|
|
|
|
2020-04-21 18:53:15 +02:00
|
|
|
|
/* Caricamento esclusi
|
|
|
|
|
* LOADING DI QUEL MESE E ANNO */
|
2020-04-01 21:29:53 +02:00
|
|
|
|
f9_app()._esclusi_vect.clear();
|
|
|
|
|
const int anno = ym_msk->get_int(501);
|
|
|
|
|
const int mese = ym_msk->get_int(502);
|
|
|
|
|
const int to_m = ym_msk->get_int(503);
|
|
|
|
|
TLocalisamfile movs(LF_MOV);
|
|
|
|
|
movs.setkey(2);
|
|
|
|
|
const TDate from(1, mese, anno);
|
|
|
|
|
TDate to(from);
|
|
|
|
|
if (to_m != 0)
|
|
|
|
|
to.set_month(to_m);
|
|
|
|
|
to.set_end_month();
|
|
|
|
|
|
|
|
|
|
movs.put(MOV_DATAREG, from);
|
|
|
|
|
movs.read();
|
|
|
|
|
if (movs.get_date(MOV_DATAREG) >= from && movs.get_date(MOV_DATAREG) <= to)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
for (bool ok = true; ok && movs.get_date(MOV_DATAREG) <= to; ok = movs.next() == NOERR)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string stato(movs.get(MOV_ELABF9), ';');
|
|
|
|
|
if (stato.items() == 3 && stato.get(2)[0] == 'X')
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string m("", '|');
|
|
|
|
|
m.add("", 0);
|
|
|
|
|
m.add(movs.get_int(MOV_NUMREG));
|
|
|
|
|
m.add(movs.get_date(MOV_DATAREG));
|
|
|
|
|
m.add(movs.get_date(MOV_DATADOC));
|
|
|
|
|
m.add(movs.get(MOV_CODCAUS));
|
|
|
|
|
m.add(movs.get(MOV_MESELIQ));
|
|
|
|
|
m.add(movs.get(MOV_NUMDOC));
|
|
|
|
|
const real imptot = movs.get_real(MOV_TOTDOC) + movs.get_real(MOV_RITFIS) + movs.get_real(MOV_RITSOC);
|
|
|
|
|
m.add(imptot);
|
|
|
|
|
m.add(movs.get_int(MOV_CODCF));
|
|
|
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
|
|
|
TString ragsoc; ragsoc = clifo.get(CLI_RAGSOC);
|
|
|
|
|
m.add(ragsoc);
|
|
|
|
|
m.add(TString(movs.get(MOV_REG)) << "/" << movs.get(MOV_PROTIVA));
|
|
|
|
|
m.add(movs.get(MOV_DESCR));
|
|
|
|
|
f9_app()._esclusi_vect.insert(f9_app()._esclusi_vect.end(), m);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
if (f9_app()._esclusi_vect.empty())
|
2019-09-16 18:10:27 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
warning_box("Non ci sono movimenti esclusi da mostrare");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Esclusi mask ////////////////////////////////
|
|
|
|
|
fill_esclusi();
|
2020-04-06 19:25:21 +02:00
|
|
|
|
while (esclusi_mask().run() == K_ENTER)
|
2020-04-21 18:53:15 +02:00
|
|
|
|
{ }
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::fill_esclusi()
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
vector<TToken_string>& esclusi = f9_app()._esclusi_vect;
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TSheet_field& sf = esclusi_mask().sfield(S_ESCL);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
sf.hide();
|
|
|
|
|
sf.destroy();
|
|
|
|
|
for (auto it = esclusi.begin(); it != esclusi.end(); ++it)
|
|
|
|
|
sf.row(-1) = *it;
|
|
|
|
|
sf.force_update();
|
|
|
|
|
sf.show();
|
|
|
|
|
}
|
2019-09-13 17:06:08 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
movimento_t TF9_app::escl2mov(TToken_string* row)
|
|
|
|
|
{
|
|
|
|
|
movimento_t t;
|
2020-04-18 16:00:37 +02:00
|
|
|
|
t.err = row->get(0)[0] == 'X';
|
|
|
|
|
t.numreg = row->get_int(1);
|
|
|
|
|
t.datareg = row->get(2);
|
|
|
|
|
t.datadoc = row->get(3);
|
|
|
|
|
t.codcaus = row->get(4);
|
|
|
|
|
t.meseliq = row->get_int(5);
|
|
|
|
|
t.numdoc = row->get(6);
|
|
|
|
|
t.tot = row->get(7);
|
|
|
|
|
t.codcf = row->get_int(8);
|
|
|
|
|
t.ragsoc = row->get_int(9);
|
|
|
|
|
t.reg_protiva = row->get(10);
|
|
|
|
|
t.descr = row->get(11);
|
|
|
|
|
t.state = null_state;
|
|
|
|
|
t.descr_err = "";
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TF9_app::estrai_escl_handler(TMask_field&, KEY key)
|
|
|
|
|
{
|
2020-04-21 18:53:15 +02:00
|
|
|
|
TMask& msk = esclusi_mask();
|
|
|
|
|
TF9_app& a = f9_app();
|
2020-04-01 21:29:53 +02:00
|
|
|
|
vector<TToken_string>& _esclusi = a._esclusi_vect;
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TSheet_field& sf = msk.sfield(S_ESCL);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
descr_msk().run();
|
|
|
|
|
const TString descr = descr_msk().get(DES_TEXT);
|
|
|
|
|
descr_msk().set(DES_TEXT, "");
|
|
|
|
|
|
|
|
|
|
a._estr_escluso =
|
|
|
|
|
new TEstrazione(a.get_ambiente(), a._flagprov_escl, a._tipodoc_escl, descr, a.get_addr_doc(), true);
|
|
|
|
|
|
|
|
|
|
// Prendo la riga selezionata (e controllo che sia selezionato qualcosa)
|
|
|
|
|
bool flag = false;
|
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (row->get(0)[0] == 'X')
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const auto mov = escl2mov(row);
|
|
|
|
|
a._estr_escluso->add_mov(mov);
|
|
|
|
|
const int stato = a._estr_escluso->estrai();
|
|
|
|
|
if (stato == 1)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_esclusi.erase(_esclusi.begin() + nr); // Tolto il movimento estratto dal vettore e setto come estratto su elabf9 di mov
|
|
|
|
|
a.segna_estratti(true, mov.numreg);
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
flag = true;
|
|
|
|
|
break;
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (!flag)
|
|
|
|
|
message_box("Selezionare il movimento da estrarre");
|
|
|
|
|
else
|
|
|
|
|
a.print_log();
|
|
|
|
|
fill_esclusi();
|
2019-09-13 17:06:08 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::mov_handler(TMask_field& f, KEY key)
|
2019-08-02 07:43:36 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TSheet_field& sf = inclusi_mask().sfield(S_ESCL);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
|
|
|
|
TRectype mov(LF_MOV);
|
|
|
|
|
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
|
|
|
|
|
return open_mov(mov);
|
2019-06-13 17:43:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::mov_handler_escl(TMask_field& f, KEY key)
|
2019-06-13 17:43:30 +02:00
|
|
|
|
{
|
2020-04-06 19:25:21 +02:00
|
|
|
|
TSheet_field& sf = esclusi_mask().sfield(S_ESCL);
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
|
|
|
|
TRectype mov(LF_MOV);
|
|
|
|
|
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
|
|
|
|
|
return open_mov(mov);
|
|
|
|
|
}
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-18 16:00:37 +02:00
|
|
|
|
void TF9_app::edit_wa(TString& old_codsoc) const
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString query;
|
2020-04-18 16:00:37 +02:00
|
|
|
|
if (!old_codsoc.empty())
|
|
|
|
|
query << "DELETE FROM " F9_WA " WHERE " WA_CODSOC " = '" << old_codsoc << "';\n";
|
|
|
|
|
query << "INSERT INTO " F9_WA " (" WA_CODSOC ", " WA_ADDR_DOC ") VALUES (" << _config.ambiente << ", " << _config.addr_doc << ");";
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
int TF9_app::estrai()
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const TDate dataini = get_dataini();
|
|
|
|
|
const TDate dataend = get_dataend();
|
|
|
|
|
const char tipodoc = get_tipodoc();
|
|
|
|
|
const bool flagpro = is_provviso();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
// Vero e proprio oggetto estrazione
|
2020-04-06 19:25:21 +02:00
|
|
|
|
_estrazione = make_unique<TEstrazione>(
|
2020-04-15 18:01:09 +02:00
|
|
|
|
get_ambiente(), // Codice ambiente
|
|
|
|
|
flagpro, // Flag prov.
|
|
|
|
|
tipodoc, // Tipo doc.
|
|
|
|
|
get_descr(), // Descrizione estrazione
|
|
|
|
|
get_addr_doc(), // Cartella documenti
|
|
|
|
|
false, // Estrazione di un escluso
|
|
|
|
|
&dataini, // Data estr. mov dal
|
|
|
|
|
&dataend, // Data estr. mov al
|
|
|
|
|
get_has_vendext() // Flag in configurazione per staltare controlli vendite
|
2020-04-01 21:29:53 +02:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Leggo i movimenti e li carico nell'estrazione. /////////////
|
|
|
|
|
TString query;
|
|
|
|
|
query << "SELECT * FROM MOV WHERE DATAREG>=" << dataini.date2ansi() << " AND DATAREG<=" << dataend.date2ansi() << ";";
|
|
|
|
|
TSQL_recordset mov(query);
|
|
|
|
|
|
|
|
|
|
TProgress_monitor progr(mov.items(), "Acquisizione movimenti");
|
|
|
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
|
|
|
const TipoIVA tipo = tipodoc == 'A' ? iva_acquisti : iva_vendite;
|
|
|
|
|
|
|
|
|
|
// Prendo tutti i movimenti a partire da una data e li carico tutti fino alla data finale
|
|
|
|
|
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (!progr.add_status())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
TToken_string elab_f9(recset_get_string(mov, MOV_ELABF9), ';'); // Stringa del campo elaborazione f9 nel file mov
|
|
|
|
|
const bool escluso = !(elab_f9.items() == 3 && elab_f9.get(2)[0] != 'X' || elab_f9.empty());
|
|
|
|
|
const TCausale caus(recset_get_string(mov, MOV_CODCAUS, 3));
|
|
|
|
|
const bool stampato = recset_get_bool(mov, MOV_REGST);
|
|
|
|
|
const TString& numdoc = recset_get_string(mov, MOV_NUMDOC);
|
|
|
|
|
// Se definitivo controllo il flag di stampato REGST
|
2020-04-14 10:19:04 +02:00
|
|
|
|
if ((flagpro || stampato) && numdoc.full() && caus.reg().iva() == tipo)
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
clifo.zero();
|
|
|
|
|
clifo.put(CLI_TIPOCF, tipo == iva_acquisti ? "F" : "C");
|
|
|
|
|
clifo.put(CLI_CODCF, recset_get_string(mov, MOV_CODCF));
|
|
|
|
|
|
|
|
|
|
// Creo il movimento da inserire
|
|
|
|
|
movimento_t t;
|
2020-04-01 21:37:55 +02:00
|
|
|
|
t.err = false;
|
|
|
|
|
t.numreg = recset_get_int (mov, MOV_NUMREG);
|
|
|
|
|
t.datareg = recset_get_string(mov, MOV_DATAREG);
|
|
|
|
|
t.datadoc = recset_get_string(mov, MOV_DATADOC);
|
2020-04-14 10:19:04 +02:00
|
|
|
|
t.codcaus = recset_get_string(mov, MOV_CODCAUS, 3);
|
2020-04-01 21:37:55 +02:00
|
|
|
|
t.meseliq = recset_get_int (mov, MOV_MESELIQ);
|
|
|
|
|
t.numdoc = recset_get_string(mov, MOV_NUMDOC);
|
|
|
|
|
t.tot = recset_get_real (mov, MOV_TOTDOC) + recset_get_real(mov, MOV_RITFIS) + recset_get_real(mov, MOV_RITSOC);
|
|
|
|
|
t.codcf = recset_get_int (mov, MOV_CODCF);
|
|
|
|
|
t.ragsoc = clifo.read() == NOERR ? clifo.get(CLI_RAGSOC) : " ";
|
2020-04-01 21:29:53 +02:00
|
|
|
|
t.reg_protiva = TString(recset_get_string(mov, MOV_REG)) << "/" << recset_get_string(mov, MOV_PROTIVA);
|
2020-04-01 21:37:55 +02:00
|
|
|
|
t.descr = recset_get_string(mov, MOV_DESCR);
|
2020-04-14 10:19:04 +02:00
|
|
|
|
if (escluso)
|
|
|
|
|
{
|
|
|
|
|
t.estratto = false;
|
|
|
|
|
t.descr_estr = movimento_t::escluso;
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
// Effettivo inserimento del movimento
|
|
|
|
|
_estrazione->add_mov(t);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
const result_estr result = _estrazione->estrai();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
// Ricalcolo sheet estrazioni
|
|
|
|
|
_msk->fill();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return result;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::print_log()
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
ofstream fout;
|
|
|
|
|
fout.open("f9exp_err.txt");
|
|
|
|
|
fout << _log;
|
|
|
|
|
_log.cut(0);
|
|
|
|
|
}
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::is_autofattura(const TLocalisamfile& mov)
|
|
|
|
|
{
|
|
|
|
|
return TCausale(mov.get(MOV_CODCAUS)).tipo_doc() == "AF";
|
|
|
|
|
}
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::segna_estratti(const bool escluso, const int numreg)
|
|
|
|
|
{
|
|
|
|
|
bool ok = true;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
vector<movimento_t> escl;
|
|
|
|
|
if (escluso)
|
2020-04-08 14:28:26 +02:00
|
|
|
|
escl.insert(escl.begin(), movimento_t{ false, numreg }); // todo: datareg?
|
2020-04-01 21:29:53 +02:00
|
|
|
|
vector<movimento_t>& movs_v = escluso ? escl : _movs;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TLocalisamfile mov(LF_MOV);
|
2020-04-18 16:00:37 +02:00
|
|
|
|
TToken_string elab("", ';');
|
2020-04-01 21:29:53 +02:00
|
|
|
|
elab.add("X", 0); elab.add(today.date2ansi()); elab.add(" "); // "[flag estratto];[data estrazione];[flag escluso]"
|
|
|
|
|
for (auto it = movs_v.begin(); it != movs_v.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
TString8 num_reg(it->numreg);
|
|
|
|
|
mov.zero();
|
|
|
|
|
mov.put(MOV_NUMREG, num_reg);
|
|
|
|
|
mov.read();
|
|
|
|
|
mov.put(MOV_ELABF9, elab);
|
|
|
|
|
ok &= mov.rewrite() == NOERR;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return ok;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 14:28:26 +02:00
|
|
|
|
void TF9_app::segna_in_errore()
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString query;
|
|
|
|
|
query << "UPDATE " F9_DRD "\n"
|
|
|
|
|
"SET " DRD_STATO " = '" D_GEST_ERR "'\n"
|
|
|
|
|
"WHERE " DRD_ID_EST " = '" << f9_app()._estrazione->get_id_estr() << "'\n";
|
|
|
|
|
fp_db().sq_set_exec(query);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::create_tables() const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool ok = aggiorna_tab_f9(100);
|
|
|
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
|
|
|
tabmod.put("MOD", "F9");
|
|
|
|
|
tabmod.put("COD", "SQL");
|
|
|
|
|
tabmod.put("CODTAB", "VERSION");
|
|
|
|
|
char ver[5] = "0000";
|
|
|
|
|
sprintf_s(ver, 5, "%04d", 100);
|
|
|
|
|
tabmod.put(TABMOD_TABVER, ver);
|
|
|
|
|
tabmod.write();
|
|
|
|
|
ok &= tabmod.rewrite() == NOERR;
|
|
|
|
|
return ok;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::check_tabelle_f9() const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool ok = true;
|
|
|
|
|
TString query;
|
|
|
|
|
query << "IF (EXISTS (\n" <<
|
|
|
|
|
"SELECT * FROM INFORMATION_SCHEMA.TABLES\n" <<
|
|
|
|
|
"WHERE TABLE_NAME = '" F9_DRD "'))\n" <<
|
|
|
|
|
"SELECT 1 AS EXIST ELSE SELECT 0 AS EXIST";
|
|
|
|
|
fp_db().sq_set_exec(query);
|
2020-04-18 16:00:37 +02:00
|
|
|
|
if (fp_db().sq_get("EXIST") != "1") // Se non esiste la tabella la creo
|
2020-04-01 21:29:53 +02:00
|
|
|
|
ok &= create_tables();
|
|
|
|
|
return ok;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
bool TF9_app::aggiorna_tab_f9(int version) const
|
|
|
|
|
{
|
|
|
|
|
bool ok = true;
|
|
|
|
|
TString file;
|
|
|
|
|
string sql;
|
|
|
|
|
char ver[5] = "0000";
|
|
|
|
|
sprintf_s(ver, 5, "%04d", version);
|
|
|
|
|
TString name; name << "f9" << ver << ".sql";
|
|
|
|
|
file << "sql\\f90\\" << name;
|
|
|
|
|
|
|
|
|
|
std::ifstream fin;
|
|
|
|
|
fin.open(file);
|
|
|
|
|
if (ok &= fin.is_open())
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
while (!fin.eof() && ok)
|
2019-09-13 17:06:08 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
std::string appo_line;
|
|
|
|
|
std::getline(fin, appo_line);
|
|
|
|
|
if (appo_line[0] == '-' && appo_line[1] == '-') // Se <20> una riga di commento la salto
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
sql += "\n" + appo_line;
|
|
|
|
|
const int end = sql.find(';'); // Se trovo un comma lancio la query
|
|
|
|
|
if (end != int(std::string::npos))
|
|
|
|
|
{
|
|
|
|
|
TString query; query << sql.c_str();
|
|
|
|
|
ok &= fp_db().sq_set_exec(query, false);
|
|
|
|
|
ok &= fp_db().sq_commit();
|
|
|
|
|
sql.erase();
|
|
|
|
|
}
|
2019-09-13 17:06:08 +02:00
|
|
|
|
}
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString msg; msg << "Impossibile trovare il file di aggiornamento tabelle: " << file;
|
|
|
|
|
error_box(msg);
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return ok;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::check_tab_version() const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool ok = true;
|
|
|
|
|
TLocalisamfile tabmod(LF_TABMOD);
|
|
|
|
|
tabmod.put("MOD", "F9");
|
|
|
|
|
tabmod.put("COD", "SQL");
|
|
|
|
|
tabmod.put("CODTAB", "VERSION");
|
|
|
|
|
const bool exists = tabmod.read() == NOERR;
|
|
|
|
|
|
|
|
|
|
int version = exists ? real(tabmod.get(TABMOD_TABVER)).integer() : TAB_BASE_VERSION - 2;
|
|
|
|
|
if (version < SQL_VERSION) // Controllo la versione
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
for (; version < SQL_VERSION; version += 2) // Effettuo le modifiche per ogni avanzamento di versione
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (ok &= aggiorna_tab_f9(version + 2))
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
char ver[5] = "0000";
|
|
|
|
|
sprintf_s(ver, 5, "%04d", version + 2);
|
|
|
|
|
tabmod.put(TABMOD_TABVER, ver); // Avanzo il contatore della versione in TABMOD
|
|
|
|
|
if (!exists)
|
|
|
|
|
{
|
|
|
|
|
tabmod.zero();
|
|
|
|
|
tabmod.put("MOD", "F9");
|
|
|
|
|
tabmod.put("COD", "SQL");
|
|
|
|
|
tabmod.put("CODTAB", "VERSION");
|
|
|
|
|
tabmod.put(TABMOD_TABVER, ver); // Avanzo il contatore della versione in TABMOD
|
|
|
|
|
tabmod.write();
|
|
|
|
|
}
|
|
|
|
|
tabmod.rewrite();
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
else
|
|
|
|
|
break;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
return ok;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
bool TF9_app::check_table() const
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (!check_tab_version())
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TString msg;
|
|
|
|
|
std::ofstream fout;
|
|
|
|
|
fout.open("f9checktaberr.txt");
|
|
|
|
|
fout << fp_db().sq_get_text_error(false) << std::endl;
|
|
|
|
|
fout.close();
|
|
|
|
|
msg << "! Errore controllo database F9: creazione/aggiornamento tabelle.\n" << fp_db().sq_get_text_error() << "\n" << fp_db().sq_get_string_error();
|
|
|
|
|
fatal_box(msg);
|
|
|
|
|
return false;
|
2019-09-10 17:33:59 +02:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
#ifdef DBG
|
|
|
|
|
void pulisci_mov()
|
2019-09-10 17:33:59 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TLocalisamfile mov(LF_MOV);
|
|
|
|
|
mov.setkey(2);
|
|
|
|
|
mov.put(MOV_DATAREG, TDate("01-01-2002"));
|
|
|
|
|
mov.read();
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
mov.put(MOV_ELABF9, "");
|
|
|
|
|
mov.write();
|
|
|
|
|
mov.rewrite();
|
|
|
|
|
} while (mov.next() == NOERR);
|
2019-10-16 14:23:36 +02:00
|
|
|
|
}
|
2020-04-01 21:29:53 +02:00
|
|
|
|
#endif
|
2019-10-16 14:23:36 +02:00
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
void TF9_app::main_loop()
|
2019-10-16 14:23:36 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
if (!check_table())
|
|
|
|
|
fatal_box("Controllo tabelle modulo fallito.");
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
//pulisci_mov();
|
|
|
|
|
#endif
|
2019-10-16 14:23:36 +02:00
|
|
|
|
|
2020-04-01 21:37:55 +02:00
|
|
|
|
_msk = make_unique<TMonitor_mask>();
|
2020-04-01 21:29:53 +02:00
|
|
|
|
_estr_msk = make_unique<TEstrai_mask>();
|
|
|
|
|
|
2020-04-01 21:37:55 +02:00
|
|
|
|
while (_msk->run() != K_QUIT) { }
|
2020-04-01 21:29:53 +02:00
|
|
|
|
|
|
|
|
|
/*delete _msk;
|
|
|
|
|
delete _estr_msk;*/
|
2019-10-16 14:23:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TF9_app& f9_app()
|
2019-10-16 14:23:36 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
static TF9_app* app = nullptr;
|
|
|
|
|
if (app == nullptr)
|
|
|
|
|
app = (TF9_app*)&main_app();
|
|
|
|
|
return *app;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 18:53:15 +02:00
|
|
|
|
int f90100(const int argc, char* argv[])
|
2020-04-01 21:26:49 +02:00
|
|
|
|
{
|
2020-04-01 21:29:53 +02:00
|
|
|
|
TF9_app app;
|
|
|
|
|
app.run(argc, argv, TR("Archiviazione Sostitutiva"));
|
|
|
|
|
return 0;
|
2020-04-01 21:26:49 +02:00
|
|
|
|
}
|