Patch level : 2.1 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunto programma stampa documenti avanzata git-svn-id: svn://10.65.10.50/trunk@12149 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c27b814001
commit
17057da7a5
112
ve/ve1300.cpp
112
ve/ve1300.cpp
@ -1,6 +1,8 @@
|
|||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <automask.h>
|
#include <automask.h>
|
||||||
|
#include <postman.h>
|
||||||
#include <printer.h>
|
#include <printer.h>
|
||||||
|
#include <progind.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <reprint.h>
|
#include <reprint.h>
|
||||||
#include <statbar.h>
|
#include <statbar.h>
|
||||||
@ -155,24 +157,78 @@ protected:
|
|||||||
bool msg_scadenze(TVariant_stack& stack);
|
bool msg_scadenze(TVariant_stack& stack);
|
||||||
bool msg_tot_imponibili(TVariant_stack& stack);
|
bool msg_tot_imponibili(TVariant_stack& stack);
|
||||||
|
|
||||||
|
int set_printed_status(TDocumento& doc) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void print(const TRecordset& doc);
|
bool print(const TRecordset& doc, TReport_book& book, bool def);
|
||||||
|
|
||||||
TReport_doc(const char* name);
|
TReport_doc(const char* name);
|
||||||
virtual ~TReport_doc();
|
virtual ~TReport_doc();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TReport_doc::print(const TRecordset& doc)
|
int TReport_doc::set_printed_status(TDocumento& doc) const
|
||||||
|
{
|
||||||
|
int err = NOERR;
|
||||||
|
if (doc.get_char(DOC_PROVV) == 'D') // Se e' una numerazione definitiva
|
||||||
|
{
|
||||||
|
if (doc.stampabile()) // Controlla se non e' gia' nello stato si stampato in definitiva
|
||||||
|
{
|
||||||
|
doc.stato(doc.tipo().stato_finale_stampa()); // Se e' gia' in definitiva aggiorna solo lo stato
|
||||||
|
err = doc.rewrite();
|
||||||
|
|
||||||
|
// Invia la transazione di cambio stato se necessario
|
||||||
|
if (::can_dispatch_transaction(doc))
|
||||||
|
{
|
||||||
|
TFilename tmpname; tmpname.temp();
|
||||||
|
{ // Parentesi strategiche
|
||||||
|
TConfig ini(tmpname, "Transaction");
|
||||||
|
ini.set("Action", "MODIFY");
|
||||||
|
ini.set("Firm", prefix().get_codditta());
|
||||||
|
ini.set("Mode", "A");
|
||||||
|
TString8 paradoc; paradoc.format("%d", LF_DOC);
|
||||||
|
ini.set_paragraph(paradoc);
|
||||||
|
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, doc.stato());
|
||||||
|
}
|
||||||
|
::dispatch_transaction(doc, tmpname);
|
||||||
|
::remove(tmpname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Se e' una numerazione provvisoria
|
||||||
|
{
|
||||||
|
// Scrive il nuovo documento con lo stato, numero e flag di definitiva
|
||||||
|
TDocumento bak_doc;
|
||||||
|
bak_doc = doc; // Setta il flag di nuovo documento
|
||||||
|
bak_doc.put(DOC_STATO,doc.tipo().stato_finale_stampa());
|
||||||
|
bak_doc.put(DOC_PROVV,"D");
|
||||||
|
bak_doc.put(DOC_NDOC,-1L);
|
||||||
|
const int pr = bak_doc.physical_rows();
|
||||||
|
for (int i=1;i<=pr;i++)
|
||||||
|
bak_doc[i].put(DOC_PROVV,"D");
|
||||||
|
err = bak_doc.write(); // Esegue automagicamente rinumerazione di testata e righe nel caso di reinsert
|
||||||
|
if (err == NOERR) // Cancella il vecchio documento
|
||||||
|
doc.remove();
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TReport_doc::print(const TRecordset& doc, TReport_book& book, bool def)
|
||||||
{
|
{
|
||||||
const TString old_query = recordset()->query_text();
|
const TString old_query = recordset()->query_text();
|
||||||
|
|
||||||
TDoc_recordset* rs = new TDoc_recordset(doc, old_query);
|
TDoc_recordset* rs = new TDoc_recordset(doc, old_query);
|
||||||
set_recordset(rs);
|
set_recordset(rs);
|
||||||
|
|
||||||
TReport_printer reprinter(*this);
|
const bool ok = book.add(*this, false);
|
||||||
reprinter.print(printer().printtype() == screenvis);
|
if (ok && def)
|
||||||
|
set_printed_status(rs->doc());
|
||||||
|
|
||||||
set_recordset(old_query);
|
set_recordset(old_query);
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso& TReport_doc::doc()
|
TDocumentoEsteso& TReport_doc::doc()
|
||||||
@ -688,6 +744,7 @@ protected:
|
|||||||
void add_data_filter(TString& query, bool from) const;
|
void add_data_filter(TString& query, bool from) const;
|
||||||
void add_ndoc_filter(TString& query, bool from) const;
|
void add_ndoc_filter(TString& query, bool from) const;
|
||||||
void add_filter(TString& str, bool from) const;
|
void add_filter(TString& str, bool from) const;
|
||||||
|
bool print_loop(const TString& query);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
@ -740,28 +797,32 @@ bool TReport_doc_app::destroy()
|
|||||||
return TSkeleton_application::destroy();
|
return TSkeleton_application::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TReport_doc_app::main_loop()
|
bool TReport_doc_app::print_loop(const TString& query)
|
||||||
{
|
{
|
||||||
while (_msk->run() == K_ENTER)
|
|
||||||
{
|
|
||||||
TString query;
|
|
||||||
query << "USE " << LF_DOC;
|
|
||||||
add_filter(query, true);
|
|
||||||
add_filter(query, false);
|
|
||||||
|
|
||||||
TISAM_recordset doc(query);
|
TISAM_recordset doc(query);
|
||||||
const int docs = doc.items();
|
const int docs = doc.items();
|
||||||
TReport_doc* report = NULL;
|
if (docs <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const bool is_definitive = yesno_box(TR("Stampa in definitiva?"));
|
||||||
|
|
||||||
|
TReport_doc* report = NULL;
|
||||||
|
TReport_book book;
|
||||||
|
|
||||||
|
TProgind pi(docs, TR("Elaborazione documenti..."), TRUE, TRUE);
|
||||||
for (int i = 0; i < docs; i++)
|
for (int i = 0; i < docs; i++)
|
||||||
{
|
{
|
||||||
|
pi.addstatus(1);
|
||||||
|
if (pi.iscancelled())
|
||||||
|
break;
|
||||||
|
|
||||||
doc.move_to(i);
|
doc.move_to(i);
|
||||||
const TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
|
const TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
|
||||||
const TString& codprof = cache().get("%TIP", tipodoc, "S5");
|
const TString& codprof = cache().get("%TIP", tipodoc, "S5");
|
||||||
TFilename profilo = codprof; profilo.ext("rep");
|
TFilename profilo = codprof; profilo.ext("rep");
|
||||||
if (!profilo.custom_path()) // Tenta di costruirsi il nome del report
|
if (!profilo.custom_path()) // Tenta di costruirsi il nome del report
|
||||||
{
|
{
|
||||||
TString msg; msg << "Non esiste il report " << codprof;
|
TString msg; msg << codprof << " : " << TR("Report inesistente");
|
||||||
statbar_set_title(TASK_WIN, msg);
|
statbar_set_title(TASK_WIN, msg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -771,10 +832,29 @@ void TReport_doc_app::main_loop()
|
|||||||
delete report;
|
delete report;
|
||||||
report = new TReport_doc(profilo);
|
report = new TReport_doc(profilo);
|
||||||
}
|
}
|
||||||
report->print(doc);
|
|
||||||
|
if (!report->print(doc, book, is_definitive))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (report != NULL)
|
if (report != NULL)
|
||||||
delete report;
|
{
|
||||||
|
book.print_or_preview();
|
||||||
|
delete report; // Distruggere il report DOPO l'anteprima!
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TReport_doc_app::main_loop()
|
||||||
|
{
|
||||||
|
while (_msk->run() == K_ENTER)
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "USE " << LF_DOC;
|
||||||
|
add_filter(query, true);
|
||||||
|
add_filter(query, false);
|
||||||
|
print_loop(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user