diff --git a/build/ps.sln b/build/ps.sln
index 0828a9fa1..3ec363bd4 100644
--- a/build/ps.sln
+++ b/build/ps.sln
@@ -53,6 +53,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps1004", "ps1004.vcxproj",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps6215", "ps6215.vcxproj", "{42AC85CF-2D74-4ADB-8CC4-87CE816B1508}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps6362", "ps6362.vcxproj", "{F3AA5A90-8D73-4C9E-B417-2EA5747884D6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ps0650", "ps0650.vcxproj", "{9934F14A-64EC-40BE-90C3-8FC4AB97F9AC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -159,6 +163,14 @@ Global
{42AC85CF-2D74-4ADB-8CC4-87CE816B1508}.Debug|Win32.Build.0 = Debug|Win32
{42AC85CF-2D74-4ADB-8CC4-87CE816B1508}.Release|Win32.ActiveCfg = Release|Win32
{42AC85CF-2D74-4ADB-8CC4-87CE816B1508}.Release|Win32.Build.0 = Release|Win32
+ {F3AA5A90-8D73-4C9E-B417-2EA5747884D6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F3AA5A90-8D73-4C9E-B417-2EA5747884D6}.Debug|Win32.Build.0 = Debug|Win32
+ {F3AA5A90-8D73-4C9E-B417-2EA5747884D6}.Release|Win32.ActiveCfg = Release|Win32
+ {F3AA5A90-8D73-4C9E-B417-2EA5747884D6}.Release|Win32.Build.0 = Release|Win32
+ {9934F14A-64EC-40BE-90C3-8FC4AB97F9AC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9934F14A-64EC-40BE-90C3-8FC4AB97F9AC}.Debug|Win32.Build.0 = Debug|Win32
+ {9934F14A-64EC-40BE-90C3-8FC4AB97F9AC}.Release|Win32.ActiveCfg = Release|Win32
+ {9934F14A-64EC-40BE-90C3-8FC4AB97F9AC}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/ps6362.vcxproj b/build/ps6362.vcxproj
new file mode 100644
index 000000000..a9d663689
--- /dev/null
+++ b/build/ps6362.vcxproj
@@ -0,0 +1,179 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {F3AA5A90-8D73-4C9E-B417-2EA5747884D6}
+ 10.0.17763.0
+
+
+
+ Application
+ false
+ v141
+
+
+ Application
+ false
+ v141
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ ..\exe\
+ ..\obj\$(SolutionName)\$(ProjectName)\
+ false
+ ..\exe\
+ ..\obj\$(SolutionName)\$(ProjectName)\
+ true
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ true
+ true
+ Win32
+ .\..\release/ps1004.tlb
+
+
+
+
+ MaxSpeed
+ OnlyExplicitInline
+ ..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories)
+ NDEBUG;WIN32;_WINDOWS;%(PreprocessorDefinitions)
+ true
+ MultiThreaded
+ true
+ .\..\release/ps1004.pch
+ .\..\release/
+ .\..\release/
+ .\..\release/
+ Level3
+ true
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ 0x0410
+ ..\wx28X\include;%(AdditionalIncludeDirectories)
+
+
+ wsock32.lib;%(AdditionalDependencies)
+ $(OutDir)$(TargetName)$(TargetExt)
+ true
+ %(IgnoreSpecificDefaultLibraries)
+ .\..\release/ps1004.pdb
+ Windows
+ false
+
+
+ MachineX86
+
+
+ true
+ .\..\release/ps1004.bsc
+
+
+ "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\signtool.exe" sign /a /s MY /n "Sirio Informatica e Sistemi SPA" /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ true
+ true
+ Win32
+ .\..\debug/ps1004.tlb
+
+
+
+
+ Disabled
+ ..\src\xvtdb\;..\src\cg;..\src\include;..\src\xvaga;%(AdditionalIncludeDirectories)
+ _DEBUG;WIN32;__LONGDOUBLE__;_WINDOWS;%(PreprocessorDefinitions)
+ false
+ MultiThreadedDebug
+ .\..\debug/ps1004.pch
+ .\..\debug/
+ .\..\debug/
+ .\..\debug/
+ Level3
+ true
+ ProgramDatabase
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ 0x0410
+ ..\libraries\wx28X\include;%(AdditionalIncludeDirectories)
+
+
+ rpcrt4.lib;wsock32.lib;%(AdditionalDependencies)
+ $(OutDir)$(TargetName)$(TargetExt)
+ true
+ %(IgnoreSpecificDefaultLibraries)
+ true
+ .\..\debug/ps1004.pdb
+ Windows
+ false
+
+
+ MachineX86
+ false
+
+
+
+
+ true
+ .\..\debug/ps1004.bsc
+
+
+
+
+ {2d38a763-3d74-4338-9362-b891784ec90e}
+
+
+
+
+ %(PreprocessorDefinitions)
+ ..\libraries\wx28X\include;%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+
+
+
+
+
+
+ Document
+ msk32 %(FullPath) $(TargetDir)%(Filename).msk
+ Compiling mask %(FullPath)...
+ $(TargetDir)%(Filename).msk;%(Outputs)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/ps6362.vcxproj.filters b/build/ps6362.vcxproj.filters
new file mode 100644
index 000000000..1fbd269f4
--- /dev/null
+++ b/build/ps6362.vcxproj.filters
@@ -0,0 +1,41 @@
+
+
+
+
+ {2aa15991-562d-4fba-afc5-a0fd3b06ec97}
+ cpp
+
+
+ {c41a2928-af62-4e3d-94cd-59438053b6e2}
+ uml
+
+
+ {ca21a647-c7c2-492c-bbbe-26d801e87179}
+ h
+
+
+
+
+
+
+
+ Sources
+
+
+ Sources
+
+
+
+
+ Headers
+
+
+ Headers
+
+
+
+
+ Masks
+
+
+
\ No newline at end of file
diff --git a/src/ps/ps6362.cpp b/src/ps/ps6362.cpp
new file mode 100644
index 000000000..6521ea75b
--- /dev/null
+++ b/src/ps/ps6362.cpp
@@ -0,0 +1,15 @@
+#include
+#include "ps6362.h"
+
+int main(int argc, char** argv)
+{
+ int rt = -1;
+ const int r = (argc > 1) ? atoi(&argv[1][1]) : 1;
+
+ switch (r)
+ {
+ default:
+ case 0: rt = ps6362100(argc, argv); break; // Esportrazione Major-Flexform
+ }
+ return rt;
+}
\ No newline at end of file
diff --git a/src/ps/ps6362100.cpp b/src/ps/ps6362100.cpp
new file mode 100644
index 000000000..a5d673467
--- /dev/null
+++ b/src/ps/ps6362100.cpp
@@ -0,0 +1,661 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ps6362.h"
+#include "ps6362100a.h"
+#include
+#include "tabutil.h"
+#include "sqlset.h"
+#include "doc.h"
+#include "rdoc.h"
+#include "progind.h"
+
+///////////////////////////////////////////////////////////
+// TXML_element
+///////////////////////////////////////////////////////////
+
+#define XML_ROOT_TAG nullptr
+
+class TFlexform_xml_ordini;
+class TOrdini_riga_xml;
+
+class TXML_element
+{
+ vector> _attributes{};
+ vector _childs{};
+ TString _indent;
+ TString _name;
+ TXML_element* _parent;
+ TString _value;
+
+public:
+ void add_attribute(const char* _Tag, const char* _Val) { _attributes.insert(_attributes.end(), { _Tag, _Val }); }
+ void add_attribute(const char* _Tag, const TString& _Val) { _attributes.insert(_attributes.end(), { _Tag, _Val }); }
+ void add_attribute(const char* _Tag, const TDate& _Val) { _attributes.insert(_attributes.end(), { _Tag, TString(_Val) }); }
+ void add_child(TXML_element& child) { child._parent = this; _childs.insert(_childs.end(), &child); }
+
+ bool print_on_file(ofstream* fout, int deep = 0, const char* indent = "");
+
+ /** Imposta tab (use_tab = true) o spazi (false). Se spazi indicare n_spazi (1 - 8): se non specificato o troppo grande sara' di 4; */
+ void set_indentation(bool use_tab, short n_spaces = -1);
+ void set_parent(TXML_element& parent) { parent.add_child(*this); }
+ void set_root() { _parent = XML_ROOT_TAG; }
+
+ TXML_element& operator<<(const char* _Val) { _value = _Val; return *this; }
+
+ explicit TXML_element(const char* name, const char* value = "") : _indent("\t"), _name(name), _parent(nullptr), _value(value) { }
+ explicit TXML_element(const TString& name, const TString& value = "") : _name(name), _parent(nullptr), _value(value) { }
+};
+
+bool TXML_element::print_on_file(ofstream* fout, const int deep, const char* indent)
+{
+ const TString _indent = this->_parent == XML_ROOT_TAG ? this->_indent : indent;
+
+ if (fout == nullptr || !fout->is_open() || _name.empty())
+ return false;
+
+ ofstream& out = *fout;
+ bool ok = true;
+
+ // Stampo prima la riga con tag e attributi
+ for (int i = 0; i < deep; ++i) // Indentazione
+ out << _indent;
+ // Apro riga del tag
+ out << "<" << (const char*)_name;
+ for (auto& it : _attributes) // Aggiungo eventuali attributi
+ out << " " << (const char*)it.first << "=\"" << (const char*)it.second << "\"";
+ out << ">";
+ // Fine riga del tag
+
+ // Stampo figli
+ if (!_childs.empty()) // O ha figli o ha tag con valore
+ {
+ out << endl;
+ for (auto& child : _childs)
+ ok &= child->print_on_file(fout, deep + 1, _indent);
+ for (int i = 0; i < deep; ++i)
+ out << _indent;
+ }
+ else
+ out << (const char*)_value;
+
+ // Chiudo tag
+ out << "" << (const char*)_name << ">" << endl;
+ return ok;
+}
+
+void TXML_element::set_indentation(bool use_tab, short n_spaces)
+{
+ if (use_tab)
+ _indent = "\t";
+ else
+ {
+ const short to = n_spaces > 0 && n_spaces <= 8 ? n_spaces : (short)4;
+ _indent.cut(0);
+ for (short i = 0; i < to; ++i)
+ _indent << " ";
+ }
+}
+
+class TEsa_import_xml : public TXML_element
+{
+public:
+ void set_attributes(const TString& source, const TDate& creation_date, const TString& instance_guid, const TString& file_version);
+ TEsa_import_xml() : TXML_element("ESA_IMPORT") { }
+};
+
+void TEsa_import_xml::set_attributes(const TString& source, const TDate& creation_date, const TString& instance_guid, const TString& file_version)
+{
+ TString date(creation_date); date.replace('-', '/');
+ add_attribute("Source", source);
+ add_attribute("CreationDate", date);
+ add_attribute("InstanceGuid", instance_guid);
+ add_attribute("FileVersion", file_version);
+}
+
+
+
+
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+// Flexform export xml
+/////////////////////////////////////////////////////////
+
+class TFlexform_xml
+{
+protected:
+ TString _file_name;
+ ofstream* _fout;
+ TEsa_import_xml _esa_import;
+
+ static const char* generatre_GUID();
+ void set_indentation(const bool use_tab, const short n_spaces) { _esa_import.set_indentation(use_tab, n_spaces); }
+ virtual bool print() pure;
+
+public:
+ bool ok() const { return _fout != nullptr && _fout->is_open(); }
+
+ TFlexform_xml(const char* xml_name = "");
+ virtual ~TFlexform_xml() { delete _fout; }
+};
+
+/////////////////////////////////////////////////////////
+// ORDINI
+/////////////////////////////////////////////////////////
+// Riga /////////////////////////////////////////////////
+class TOrdini_riga_xml : public TXML_element
+{
+ TXML_element* _datarow; // Unico figlio di OR_ORDINIR contenenti i campi campi dell'ordine
+
+ // Figli di _datarow: campi dell'ordine
+
+ TXML_element* _tiporiga;
+ TXML_element* _art;
+ TXML_element* _des_articolo;
+ TXML_element* _merce;
+ TXML_element* _libero;
+
+public:
+ void set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6);
+ TOrdini_riga_xml() : TXML_element("OR_ORDINIR"), _datarow(nullptr), _tiporiga(nullptr), _art(nullptr), _des_articolo(nullptr), _merce(nullptr), _libero(nullptr) { }
+ ~TOrdini_riga_xml();
+};
+
+// Testata //////////////////////////////////////////////
+class TOrdini_testata_xml : public TXML_element
+{
+ TXML_element* _datarow;
+
+ // Figli di _datarow: campi della testata
+
+ TXML_element* _dat_doc;
+ TXML_element* _des_num;
+ TXML_element* _sig_serie;
+public:
+ void add_row(TOrdini_riga_xml& riga) { add_child((TXML_element&)riga); }
+ void set_testata(const char* data_doc, const char* num_doc, const char* str = "CCL");
+
+ TOrdini_testata_xml() : TXML_element("OR_ORDINIT"), _datarow(nullptr), _dat_doc(nullptr), _des_num(nullptr), _sig_serie(nullptr) { }
+ ~TOrdini_testata_xml();
+};
+
+// TFlexform_xml_ordini /////////////////////////////////
+class TFlexform_xml_ordini : public TFlexform_xml
+{
+ TXML_element _ordine_impegno; // Unico ordine, figlio di _esa_import
+ TOrdini_testata_xml _testata; // _testata contiene i dati di testata, piu' tutte gli ordini riga come figli, figlio di _ordine_impegno
+
+public:
+ void add_row(TOrdini_riga_xml* riga) { riga->set_parent(_testata); }
+ bool print() override;
+ void set_testata(const char* data_doc, const char* num_doc, const char* str) { _testata.set_testata(data_doc, num_doc, str); }
+
+ TFlexform_xml_ordini(const char* xml_name = "");
+};
+
+/////////////////////////////////////////////////////////
+// DDT
+/////////////////////////////////////////////////////////
+// Riga /////////////////////////////////////////////////
+class TDDT_riga_xml : public TXML_element
+{
+ TXML_element* _datarow; // Unico figlio di OR_ORDINIR contenenti i campi campi dell'ordine
+
+ // Figli di _datarow: campi dell'ordine
+
+ TXML_element* _tiporiga;
+ TXML_element* _art;
+ TXML_element* _des_articolo;
+ TXML_element* _merce;
+ TXML_element* _libero;
+
+public:
+ void set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6);
+ TDDT_riga_xml() : TXML_element("MG_MOVMAGR"), _datarow(nullptr), _tiporiga(nullptr), _art(nullptr),
+ _des_articolo(nullptr), _merce(nullptr), _libero(nullptr) { }
+ ~TDDT_riga_xml();
+};
+
+// Testata //////////////////////////////////////////////
+class TDDT_testata_xml : public TXML_element
+{
+ TXML_element* _datarow;
+
+ // Figli di _datarow: campi della testata
+
+ TXML_element* _dat_doc;
+ TXML_element* _des_num;
+public:
+ void add_row(TDDT_riga_xml& riga) { add_child((TXML_element&)riga); }
+ void set_testata(const char* data_doc, const char* num_doc);
+
+ TDDT_testata_xml() : TXML_element("MG_MOVMAGT"), _datarow(nullptr), _dat_doc(nullptr), _des_num(nullptr) { }
+ ~TDDT_testata_xml();
+};
+
+// TFlexform_xml_ddt ///////////////////////////////////////
+class TFlexform_xml_ddt final : public TFlexform_xml
+{
+ vector _docs_unico; // Tanti doc_unico, figli di _esa_import
+ vector _testate; // _testata contiene i dati di testata, piu' tutte gli ordini riga come figli
+
+ vector _rows;
+public:
+ int add_doc();
+ /** Aggiungo la riga al documento n. \a which_riga, altrimenti se non specificato mette sull'ultimo doc presente.
+ * \returns indice documento in cui e' stata inserita la riga.
+ * \returns -1 se non e' mai stato inserito alcun documento o l'indice (\a which_doc) non e' corretto.
+ */
+ int add_row(TDDT_riga_xml* riga, int which_doc = -1);
+ bool print() override;
+ TDDT_riga_xml* new_row() { _rows.push_back(new TDDT_riga_xml); return _rows.back(); }
+
+ /** Setto testata al documento n. \a which_riga, altrimenti se non specificato setta l'ultimo doc presente.
+ * \returns indice documento settato.
+ * \returns -1 se non e' mai stato inserito alcun documento o l'indice (\a which_doc) non e' corretto.
+ */
+ int set_testata(const char* data_doc, const char* num_doc, int which_doc = -1);
+
+ TFlexform_xml_ddt(const char* xml_name = "") : TFlexform_xml(xml_name) { }
+ ~TFlexform_xml_ddt();
+};
+
+
+
+// Definizioni
+/////////////////////////////////////////////////////////
+// Flexform export xml
+/////////////////////////////////////////////////////////
+
+const char* TFlexform_xml::generatre_GUID()
+{
+ static TString _guid;
+ if(_guid.empty())
+ {
+ char cstr[39];
+ size_t chars;
+ GUID uuid;
+ if (UuidCreate(&uuid) == RPC_S_OK)
+ {
+ LPOLESTR lpsz;
+ StringFromCLSID(uuid, &lpsz);
+ wcstombs_s(&chars, cstr, lpsz, wcslen(lpsz));
+ _guid = cstr;
+ }
+ else
+ _guid = "";
+ }
+ return _guid;
+}
+
+TFlexform_xml::TFlexform_xml(const char* xml_name) : _file_name(xml_name), _fout(nullptr)
+{
+ _esa_import.set_attributes(TConfig(CONFIG_DITTA, "Main").get("RAGSOC"), TDate(TODAY), generatre_GUID(), "1");
+ _esa_import.set_root();
+ _fout = new ofstream(xml_name);
+}
+
+/////////////////////////////////////////////////////////
+// ORDINI
+/////////////////////////////////////////////////////////
+// Righe ////////////////////////////////////////////////
+
+void TOrdini_riga_xml::set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6)
+{
+ _datarow = new TXML_element("datarow"); add_child(*_datarow);
+ _tiporiga = new TXML_element("ind_tiporiga", ind_tiporiga); _datarow->add_child(*_tiporiga);
+ _art = new TXML_element("cod_art", cod_art); _datarow->add_child(*_art);
+ _des_articolo = new TXML_element("des_articolo_riga", des_articolo_riga); _datarow->add_child(*_des_articolo);
+ _merce = new TXML_element("qta_merce", qta_merce); _datarow->add_child(*_merce);
+ _libero = new TXML_element("des_campo_libero6", des_campo_libero6); _datarow->add_child(*_libero);
+}
+
+TOrdini_riga_xml::~TOrdini_riga_xml()
+{
+ delete _datarow;
+ delete _tiporiga;
+ delete _art;
+ delete _des_articolo;
+ delete _merce;
+ delete _libero;
+}
+
+// Testata //////////////////////////////////////////////
+
+void TOrdini_testata_xml::set_testata(const char* data_doc, const char* num_doc, const char* str)
+{
+ _datarow = new TXML_element("datarow"); add_child(*_datarow);
+ _dat_doc = new TXML_element("dat_doc_esterno", data_doc); _datarow->add_child(*_dat_doc);
+ _des_num = new TXML_element("des_num_esterno", num_doc); _datarow->add_child(*_des_num);
+ _sig_serie = new TXML_element("sig_serie_esterno", str); _datarow->add_child(*_sig_serie);
+}
+
+TOrdini_testata_xml::~TOrdini_testata_xml()
+{
+ delete _datarow;
+ delete _dat_doc;
+ delete _des_num;
+ delete _sig_serie;
+}
+
+// TFlexform_xml_ordini /////////////////////////////////
+
+bool TFlexform_xml_ordini::print()
+{
+ ofstream& out = *_fout;
+ out << R"()" << endl;
+ const bool ok = _esa_import.print_on_file(_fout);
+ _fout->close();
+ return ok;
+}
+
+TFlexform_xml_ordini::TFlexform_xml_ordini(const char* xml_name) : TFlexform_xml(xml_name), _ordine_impegno("ORDINE_IMPEGNO")
+{
+ _ordine_impegno.add_attribute("TipoOperazione", "Insert");
+ _ordine_impegno.set_parent(_esa_import);
+ _testata.set_parent(_ordine_impegno);
+ _fout = new ofstream(_file_name);
+}
+
+/////////////////////////////////////////////////////////
+// DDT
+/////////////////////////////////////////////////////////
+// Riga /////////////////////////////////////////////////
+
+void TDDT_riga_xml::set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6)
+{
+ const TString _cod_art = cod_art; _cod_art.left(25);
+ const TString _desc = des_articolo_riga; _desc.left(255);
+ const TString _libero6 = des_campo_libero6; _libero6.left(30);
+ _datarow = new TXML_element("datarow"); add_child(*_datarow);
+ _tiporiga = new TXML_element("ind_tiporiga", ind_tiporiga); _datarow->add_child(*_tiporiga);
+ _art = new TXML_element("cod_art", (const char*)_cod_art); _datarow->add_child(*_art);
+ _des_articolo = new TXML_element("des_articolo_riga", (const char*)_desc); _datarow->add_child(*_des_articolo);
+ _merce = new TXML_element("qta_merce", qta_merce); _datarow->add_child(*_merce);
+ _libero = new TXML_element("des_campo_libero6", (const char*)_libero6); _datarow->add_child(*_libero);
+}
+
+TDDT_riga_xml::~TDDT_riga_xml()
+{
+ delete _datarow;
+ delete _tiporiga;
+ delete _art;
+ delete _des_articolo;
+ delete _merce;
+ delete _libero;
+}
+
+// Testata //////////////////////////////////////////////
+
+void TDDT_testata_xml::set_testata(const char* data_doc, const char* num_doc)
+{
+ _datarow = new TXML_element("datarow"); add_child(*_datarow);
+ _dat_doc = new TXML_element("dat_doc", data_doc); _datarow->add_child(*_dat_doc);
+ _des_num = new TXML_element("des_num_doc", num_doc); _datarow->add_child(*_des_num);
+}
+
+TDDT_testata_xml::~TDDT_testata_xml()
+{
+ delete _datarow;
+ delete _dat_doc;
+ delete _des_num;
+}
+
+// TFlexform_xml_ddt ///////////////////////////////////////
+
+int TFlexform_xml_ddt::add_doc()
+{
+ TXML_element* doc = new TXML_element("DOC_UNICO");
+ _docs_unico.insert(_docs_unico.end(), doc);
+ _docs_unico.back()->set_parent(_esa_import);
+ TDDT_testata_xml* test = new TDDT_testata_xml;
+ _testate.insert(_testate.end(), test);
+ _testate.back()->set_parent(*_docs_unico.back());
+ return _docs_unico.size();
+}
+
+int TFlexform_xml_ddt::add_row(TDDT_riga_xml* riga, int which_doc)
+{
+ int i = which_doc < 0 ? (int)_testate.size() - 1 : which_doc;
+ if (!_testate.empty() && i < (int)_testate.size())
+ riga->set_parent(*_testate[i]);
+ else
+ i = -1;
+ return i;
+}
+
+bool TFlexform_xml_ddt::print()
+{
+ ofstream& out = *_fout;
+ out << R"()" << endl;
+ const bool ok = _esa_import.print_on_file(_fout);
+ _fout->close();
+ return ok;
+}
+
+int TFlexform_xml_ddt::set_testata(const char* data_doc, const char* num_doc, const int which_doc)
+{
+ int i = which_doc < 0 ? (int)_testate.size() - 1 : which_doc;
+ if (!_testate.empty() && i < (int)_testate.size())
+ _testate[i]->set_testata(data_doc, num_doc);
+ else
+ i = -1;
+ return i;
+}
+
+TFlexform_xml_ddt::~TFlexform_xml_ddt()
+{
+ for (auto doc : _docs_unico)
+ delete doc;
+ for (auto testata : _testate)
+ delete testata;
+ for (auto row : _rows)
+ delete row;
+}
+///////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////
+// Main Mask
+///////////////////////////////////////////////////////////
+
+class TMajor_export_mask final : public TAutomask
+{
+protected:
+ bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
+ void load_all();
+public:
+ void save_all() const;
+ TMajor_export_mask();
+ ~TMajor_export_mask() { save_all(); }
+};
+
+bool TMajor_export_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
+{
+ return true;
+}
+
+TMajor_export_mask::TMajor_export_mask() : TAutomask("ps6362100a")
+{
+ load_all();
+}
+
+void TMajor_export_mask::save_all() const
+{
+ ini_set_string(CONFIG_DITTA, "ps6362", "flddest", get(F_FLDDEST));
+ ini_set_bool(CONFIG_DITTA, "ps6362", "fldroot_b", get(F_SUBFLD));
+ ini_set_string(CONFIG_DITTA, "ps6362", "numddt", get(F_NUMDDT));
+ ini_set_string(CONFIG_DITTA, "ps6362", "numord", get(F_NUMORD));
+}
+
+void TMajor_export_mask::load_all()
+{
+ TFilename temp;
+ temp.tempdir();
+ set(F_FLDDEST, ini_get_string(CONFIG_DITTA, "ps6362", "flddest", temp));
+ set(F_SUBFLD, ini_get_bool(CONFIG_DITTA, "ps6362", "fldroot_b"));
+ set(F_ANNO_ELAB, TDate(TODAY).year());
+ set(F_NUMDDT, ini_get_string(CONFIG_DITTA, "ps6362", "numddt", ""));
+ set(F_NUMORD, ini_get_string(CONFIG_DITTA, "ps6362", "numord", ""));
+ if(get(F_NUMDDT).empty() || get(F_NUMORD).empty())
+ {
+ TTable num("%NUM");
+ TString ord, ddt;
+ for (num.first(); num.good(); num.next())
+ {
+ if (ddt.empty() && num.get("CODTAB").starts_with("B0"))
+ ddt = num.get("CODTAB");
+ else if (ord.empty() && num.get("CODTAB").starts_with("ORC"))
+ ord = num.get("CODTAB");
+ if (ord.full() && ddt.full())
+ break;
+ }
+ if (get(F_NUMDDT).empty())
+ set(F_NUMDDT, ddt);
+ if (get(F_NUMORD).empty())
+ set(F_NUMORD, ord);
+ }
+}
+
+
+
+
+///////////////////////////////////////////////////////////
+// Main Program
+///////////////////////////////////////////////////////////
+
+class TMajor_export_app : public TSkeleton_application
+{
+ TString _fld_dest;
+
+ bool create() override;
+
+ static TFilename check_name_file(const TString& dir, bool sub_fld, int from, int to, bool ddt = true);
+ static bool export_ddt(TMask& msk);
+ static bool export_ordini() { return false; }
+ void main_loop() override;
+public:
+ TMajor_export_app() = default;
+};
+
+bool TMajor_export_app::create()
+{
+ return TSkeleton_application::create();
+}
+
+TFilename TMajor_export_app::check_name_file(const TString& dir, const bool sub_fld, const int from, const int to, bool ddt)
+{
+ TString cartella = dir; cartella << "/";
+ if (sub_fld)
+ cartella << "CAMPO_" << TDate(TODAY).date2ansi() << "/";
+ TString da, a;
+ da.format("%07d", from);
+ a.format("%07d", to);
+
+ TString name; name << (ddt ? "ddt" : "ord") << TDate(TODAY).year() << da << a;
+ TFilename xml(cartella);
+ if (!xvt_fsys_dir_exists(xml))
+ xvt_fsys_mkdir(xml);
+ xml << name << ".xml";
+ if (xml.exist())
+ {
+ const int key = yesnocancel_box("Esiste gia' un file per questa esportazione. Creare nuovo nome?\nCliccare 'No' se si vuole sostituire il file.");
+ if (key == K_YES)
+ {
+ int i = 1;
+ do
+ {
+ xml = cartella;
+ xml << name << "_" << i++ << ".xml";
+ } while (xml.exist() && i < 128);
+ if (i == 128)
+ fatal_box("Attenzione si sta cercando di generare troppi file per questa esportazione.");
+ }
+ else if (key != K_NO)
+ xml = "";
+ }
+ return xml;
+}
+
+bool TMajor_export_app::export_ddt(TMask& msk)
+{
+ const TString& dir = msk.get(F_FLDDEST);
+ const bool sub_fld = msk.get_bool(F_SUBFLD);
+ const int year = msk.get_int(F_ANNO_ELAB);
+ const int from = msk.get_int(F_NUMDDT_DA);
+ const int to = msk.get_int(F_NUMDDT_A);
+ const TString& codnum = msk.get(F_NUMDDT);
+
+ TFilename xml = check_name_file(dir, sub_fld, from, to);
+ if (xml.empty())
+ return false;
+ TFlexform_xml_ddt ddt(xml);
+ TString query_doc;
+ query_doc << "SELECT * FROM doc WHERE CODNUM = \"" << codnum << "\" AND ANNO == " << year << " AND PROVV == \"D\" AND NDOC >= " << from << " AND NDOC <= " << to;
+ TSQL_recordset doc(query_doc);
+ TProgress_monitor bar(doc.items(), "Esportazione ddt");
+
+ for(bool ok_d = doc.move_first(); ok_d; ok_d = doc.move_next())
+ {
+ if (!bar.add_status())
+ break;
+ ddt.add_doc();
+ TFormatted_date day(doc.get(doc.find_column(DOC_DATADOC)).as_date()); day.set_format("1444/");
+ const TString& n_doc = doc.get(doc.find_column(DOC_NDOC)).as_string();
+ ddt.set_testata(day.string(), n_doc);
+ // Righe documento
+ TString query_righe; query_righe << "SELECT * FROM rdoc WHERE CODNUM = \"" << codnum << "\" AND ANNO == " << year << " AND PROVV == \"D\" AND NDOC=" << n_doc;
+ TSQL_recordset righe_doc(query_righe);
+ for (bool ok_r = righe_doc.move_first(); ok_r; ok_r = righe_doc.move_next())
+ {
+ TDDT_riga_xml* riga = ddt.new_row();
+ const TString& cod_art = righe_doc.get(righe_doc.find_column(RDOC_CODART)).as_string();
+ TString descr = righe_doc.get(righe_doc.find_column(RDOC_DESCR)).as_string();
+ if (righe_doc.get(righe_doc.find_column(RDOC_DESCLUNGA)).as_bool())
+ descr << righe_doc.get(righe_doc.find_column(RDOC_DESCEST)).as_string();
+ const TString& qta = righe_doc.get(righe_doc.find_column(RDOC_QTA)).as_string();
+
+ riga->set_datarow("C", cod_art, descr, qta, "");
+ ddt.add_row(riga);
+ }
+ }
+ bool ok = true;
+ if (ok &= ddt.ok())
+ ok &= ddt.print();
+ return ok;
+}
+
+void TMajor_export_app::main_loop()
+{
+ TMajor_export_mask msk;
+ while (msk.run() == K_ENTER)
+ {
+ bool ok = true;
+ TString msg; msg << "Esportazione ";
+ if (msk.get(F_TIPODOC) == "D")
+ {
+ ok &= export_ddt(msk);
+ msg << "DDT";
+ }
+ else
+ {
+ ok &= export_ordini();
+ msg << "ordini";
+ }
+ if (ok)
+ message_box(msg << " eseguita correttamente.");
+ else
+ warning_box(msg << " non completata.");
+ }
+}
+
+int ps6362100(const int argc, char* argv[])
+{
+ TMajor_export_app pe;
+ pe.run(argc, argv, TR("Esportazione Major-Flexform"));
+ return 0;
+}
diff --git a/src/ps/ps6362100a.h b/src/ps/ps6362100a.h
new file mode 100644
index 000000000..6b48b48b3
--- /dev/null
+++ b/src/ps/ps6362100a.h
@@ -0,0 +1,8 @@
+#define F_FLDDEST 101
+#define F_SUBFLD 102
+#define F_TIPODOC 103
+#define F_NUMORD 104
+#define F_NUMDDT 105
+#define F_ANNO_ELAB 106
+#define F_NUMDDT_DA 107
+#define F_NUMDDT_A 108
\ No newline at end of file
diff --git a/src/ps/ps6362100a.uml b/src/ps/ps6362100a.uml
new file mode 100644
index 000000000..2b6da7312
--- /dev/null
+++ b/src/ps/ps6362100a.uml
@@ -0,0 +1,113 @@
+#include "ps6362100a.h"
+
+TOOLBAR "topbar" 0 0 0 2
+BUTTON DLG_OK 2 2
+BEGIN
+ PROMPT 1 1 "~Conferma"
+ PICTURE TOOL_OK
+END
+
+#include
+ENDPAGE
+
+PAGE "Configurazione Esportazione Major-Flexform" 0 2 0 0
+
+GROUPBOX DLG_NULL 78 4
+BEGIN
+ PROMPT 1 0 "@bPercorso salvataggio file"
+END
+
+STRING F_FLDDEST 250 50
+BEGIN
+ PROMPT 2 1 "Cartella di destinazione"
+ DSELECT
+ FLAGS ""
+ CHECKTYPE REQUIRED
+END
+
+BOOLEAN F_SUBFLD
+BEGIN
+ PROMPT 2 2 "Crea sottocartella con data odierna"
+ FLAGS ""
+END
+
+GROUPBOX DLG_NULL 66 12
+BEGIN
+ PROMPT 5 4 "@bEstremi dei documenti da elaborare:"
+END
+
+RADIOBUTTON F_TIPODOC 64
+BEGIN
+ PROMPT 6 5 "@bSelezionare tipo documento da esportare"
+ ITEM "D|DDT"
+ ITEM "O|Ordini"
+ FLAG "ZD"
+END
+
+GROUPBOX DLG_NULL 25 4
+BEGIN
+ PROMPT 6 8 "@bSelezionare cod. numerazione"
+END
+
+STRING F_NUMDDT 4
+BEGIN
+ PROMPT 7 9 "DDT "
+ FLAG "UZ"
+ USE %NUM
+ INPUT CODTAB F_NUMDDT
+ DISPLAY "Codice" CODTAB
+ DISPLAY "Descrizione@50" S0
+ OUTPUT F_NUMDDT CODTAB
+ CHECKTYPE NORMAL
+END
+
+STRING F_NUMORD 4
+BEGIN
+ PROMPT 7 10 "ORDINI"
+ FLAG "UZD"
+ USE %NUM
+ INPUT CODTAB F_NUMORD
+ DISPLAY "Codice" CODTAB
+ DISPLAY "Descrizione@50" S0
+ OUTPUT F_NUMORD CODTAB
+ CHECKTYPE NORMAL
+END
+
+STRING F_ANNO_ELAB 4
+BEGIN
+ PROMPT 37 8 "Anno elaborazione"
+END
+
+STRING F_NUMDDT_DA 7
+BEGIN
+ PROMPT 37 9 "da num. doc. "
+ USE LF_DOC
+ JOIN %TIP ALIAS 104 INTO CODTAB=TIPODOC
+ JOIN LF_CLIFO INTO TIPOCF=TIPOCF CODCF=CODCF
+ INPUT PROVV "D"
+ INPUT ANNO F_ANNO_ELAB SELECT
+ INPUT CODNUM F_NUMDDT SELECT
+ INPUT NDOC F_NUMDDT_DA
+ DISPLAY "Numero" NDOC
+ DISPLAY "Tipo@50" 104@->S0
+ DISPLAY "Ragione sociale@50" LF_CLIFO->RAGSOC
+ OUTPUT F_NUMDDT_DA NDOC
+ ADD RUN ve0 -0
+END
+
+STRING F_NUMDDT_A 7
+BEGIN
+ PROMPT 37 10 "a "
+ COPY USE F_NUMDDT_DA
+ INPUT PROVV "D"
+ INPUT ANNO F_ANNO_ELAB SELECT
+ INPUT CODNUM F_NUMDDT SELECT
+ INPUT NDOC F_NUMDDT_A
+ COPY DISPLAY F_NUMDDT_DA
+ OUTPUT F_NUMDDT_A NDOC
+ NUM_EXPR (#THIS_FIELD==0)||(#THIS_FIELD>=#F_NUMDDT_DA)
+ WARNING "Specificare un numero documento superiore a quello di partenza"
+ ADD RUN ve0 -0
+END
+
+ENDPAGE
\ No newline at end of file