164 lines
4.1 KiB
C++
Executable File
164 lines
4.1 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <postman.h>
|
|
#include <progind.h>
|
|
|
|
#include "ve5200.h"
|
|
#include "velib04.h"
|
|
|
|
class TStatus_mask : public TMask
|
|
{
|
|
public:
|
|
TStatus_mask() : TMask("ve5200") { }
|
|
};
|
|
|
|
|
|
class TStatus_change : public TSkeleton_application
|
|
{
|
|
virtual const char* extra_modules() const { return "dt"; }
|
|
|
|
protected: // TSkeleton_application
|
|
virtual void main_loop();
|
|
virtual bool create();
|
|
|
|
public:
|
|
void do_elab( TDocumento& doc);
|
|
};
|
|
|
|
bool TStatus_change::create()
|
|
{
|
|
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_OCCAS, LF_INDSP, LF_CFVEN, LF_DOC, LF_RIGHEDOC,
|
|
LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_CONDV, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CESS,
|
|
LF_CAUSALI, LF_RCAUSALI, 0);
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TStatus_change::do_elab(TDocumento& doc) // C 90
|
|
{
|
|
TElaborazione * el = NULL;
|
|
|
|
const TString16 codelab = doc.tipo().elaborazione();
|
|
if (codelab.full())
|
|
{
|
|
const TRectype& eld = cache().get("%ELD", codelab);
|
|
if (!eld.empty())
|
|
{
|
|
switch (eld.get_int("I0"))
|
|
{
|
|
case _esterna :
|
|
el = new TElaborazione_esterna(eld);
|
|
break;
|
|
case _consegna_ordini:
|
|
el = new TConsegna_ordini(eld);
|
|
break;
|
|
case _fatturazione_bolle :
|
|
el = new TFatturazione_bolle(eld);
|
|
break;
|
|
case _contabilizzazione :
|
|
el = new TContabilizzazione(eld);
|
|
break;
|
|
case _copia_documento :
|
|
el = new TCopia_documento(eld);
|
|
break;
|
|
case _generazione_effetti :
|
|
el = new TGenerazione_effetti(eld);
|
|
break;
|
|
case _consuntivazione_produzione :
|
|
el = new TConsuntivazione_produzione(eld);
|
|
break;
|
|
case _contabilizzazione_analitica :
|
|
el = new TContabilizzazione_analitica(eld);
|
|
break;
|
|
default :
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (el != NULL && el->is_document_ok(doc))
|
|
{
|
|
TLista_documenti in; in.add(doc);
|
|
TLista_documenti out;
|
|
el->elabora(in, out, TDate(TODAY), false);
|
|
}
|
|
}
|
|
|
|
void TStatus_change::main_loop()
|
|
{
|
|
TStatus_mask m;
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
TRelation rel(LF_DOC);
|
|
m.autosave(rel);
|
|
|
|
TRectype recini(rel.curr());
|
|
TRectype recfin(rel.curr());
|
|
|
|
recini.put(DOC_NDOC, m.get(F_DANUMERO));
|
|
recfin.put(DOC_NDOC, m.get(F_ANUMERO));
|
|
|
|
TString filter;
|
|
filter << DOC_STATO << "==\"" << m.get(F_INIZIALE) << "\"";
|
|
|
|
TCursor cur(&rel, filter, 1, &recini, &recfin);
|
|
const long total = cur.items();
|
|
if (total > 0)
|
|
{
|
|
TString msg = TR("Confermare l'aggiornamento di ");
|
|
msg.add_plural(total, TR("documento"));
|
|
if (yesno_box(msg))
|
|
{
|
|
TProgress_monitor pi(total, title());
|
|
const TString& finale = m.get(F_FINALE);
|
|
TDocumento* doc = new TDocumento;
|
|
rel.lfile().set_curr(doc);
|
|
cur.freeze();
|
|
for (cur = 0; cur.pos() < total; ++cur)
|
|
{
|
|
if (!pi.add_status())
|
|
break;
|
|
doc->put(DOC_STATO, finale);
|
|
int err = doc->rewrite();
|
|
|
|
if (err == NOERR)
|
|
do_elab(*doc);
|
|
|
|
// Invia anche la transazione se necessario
|
|
if (err = NOERR && ::can_dispatch_transaction(*doc))
|
|
{
|
|
TFilename tmpname; tmpname.tempdir(); tmpname.add("ve5trans.ini");
|
|
{ // Parentesi strategiche
|
|
TConfig ini(tmpname, "Transaction");
|
|
ini.set("Action", "MODIFY");
|
|
ini.set("Firm", get_firm());
|
|
ini.set("Mode", "A");
|
|
ini.set_paragraph("33");
|
|
ini.set(DOC_PROVV, doc->get(DOC_PROVV));
|
|
ini.set(DOC_ANNO, doc->get(DOC_ANNO));
|
|
ini.set(DOC_CODNUM, doc->get(DOC_CODNUM));
|
|
ini.set(DOC_NDOC, doc->get(DOC_NDOC));
|
|
ini.set(DOC_STATO, finale);
|
|
}
|
|
::dispatch_transaction(*doc, tmpname);
|
|
xvt_fsys_remove_file(tmpname);
|
|
}
|
|
}
|
|
|
|
// Forza l'aggiornamento dell'indice del cursore
|
|
TEdit_field& ef = m.efield(F_DANUMERO);
|
|
TCursor* cur = ef.browse()->cursor();
|
|
filter = cur->filter();
|
|
cur->setfilter("");
|
|
cur->setfilter(filter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int ve5200(int argc, char* argv[])
|
|
{
|
|
TStatus_change a;
|
|
a.run(argc, argv, "Aggiornamento stato");
|
|
return 0;
|
|
}
|
|
|