Patch level : 2.1 780

Files correlati     : ve0.exe ve1.exe
Ricompilazione Demo : [ ]
Commento            :

Implementata chiamata automatica della stampa avanzata documenti
nel caso esista il nuovo file di report.


git-svn-id: svn://10.65.10.50/trunk@12222 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-06-30 08:55:13 +00:00
parent 4f6e201dd2
commit 2aad986915
2 changed files with 109 additions and 28 deletions

View File

@ -527,12 +527,20 @@ void TMotore_application::print()
const TDocumento& doc = (const TDocumento&)get_relation()->curr();
const bool da_stampare = doc.stampabile();
TString commandline("ve1 -0 ");
commandline << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO) << ' ';
const TTipo_documento& tipo = doc.tipo();
TFilename rep = tipo.get("S5").left(8);
rep.ext("rep");
TString commandline;
if (rep.custom_path()) // Esiste il nuovo report :-)
commandline = "ve1 -2";
else // Esiste il vecchio form :-(
commandline = "ve1 -0";
commandline << ' ' << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO) << ' ';
commandline << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << ' ' << doc.get(DOC_NDOC);
commandline << ' ' << (da_stampare ? 'D' : 'P');
const TTipo_documento& tipo = doc.tipo();
const int ncopie = tipo.ncopie();
if (ncopie > 0)
commandline << ' ' << ncopie;

View File

@ -710,6 +710,22 @@ TReport_doc::~TReport_doc()
{
}
///////////////////////////////////////////////////////////
// TDoc_book
///////////////////////////////////////////////////////////
class TDoc_book : public TReport_book
{
protected:
virtual void draw_link(const TRectangle& rect, const char* text, const char* link);
};
void TDoc_book::draw_link(const TRectangle& rect, const char* text, const char* link)
{
if (main_app().argc() < 6) // Vieta i link quando sono in batch
TReport_book::draw_link(rect, text, link);
}
///////////////////////////////////////////////////////////
// TReport_doc_mask
///////////////////////////////////////////////////////////
@ -733,6 +749,26 @@ TReport_doc_mask::TReport_doc_mask() : TAutomask("ve1100a")
hide(F_PROVV);
}
///////////////////////////////////////////////////////////
// TReports_cache
///////////////////////////////////////////////////////////
class TReports_cache : TCache
{
protected:
virtual TObject* key2obj(const char* key);
public:
TReport_doc& get(const TString& key) { return *(TReport_doc*)objptr(key); }
TReports_cache() : TCache(7) { }
};
TObject* TReports_cache::key2obj(const char* key)
{
TReport_doc* rep = new TReport_doc(key);
return rep;
}
///////////////////////////////////////////////////////////
// TReport_doc_app
///////////////////////////////////////////////////////////
@ -746,6 +782,7 @@ protected:
void add_ndoc_filter(TString& query, bool from) const;
void add_filter(TString& str, bool from) const;
bool print_loop(const TString& query);
void print_selection();
public:
virtual bool create();
@ -808,12 +845,16 @@ bool TReport_doc_app::print_loop(const TString& query)
if (docs <= 0)
return false;
const bool is_definitive = yesno_box(TR("Stampare in definitiva %d documenti?"), docs);
bool is_definitive = false;
if (argc() >= 6) // Batch
is_definitive = *argv(6) == 'D';
else
is_definitive = yesno_box(FR("Stampare in definitiva %d documenti?"), docs);
TReport_doc* report = NULL;
TReport_book book;
TReports_cache reports; // Cache degli ultimi reports usati
TDoc_book book; // Destinazione dell'intera stampa
TProgind pi(docs, TR("Elaborazione documenti..."), TRUE, TRUE);
TProgind pi(docs, TR("Elaborazione documenti..."), true, true);
for (int i = 0; i < docs; i++)
{
pi.addstatus(1);
@ -822,42 +863,74 @@ bool TReport_doc_app::print_loop(const TString& query)
doc.move_to(i);
const TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
const TString& codprof = cache().get("%TIP", tipodoc, "S5");
// Nei primi 8 caratteri di S5 c'e' il report, negli altri 8 l'allegato
const TString profilo_allegato = cache().get("%TIP", tipodoc, "S5");
const TString& codprof = profilo_allegato.left(8);
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 << codprof << " : " << TR("Report inesistente");
TReport_doc& report = reports.get(profilo);
if (!report.print(doc, book, is_definitive))
break;
}
else
{
TString msg; msg << TR("Report inesistente") << " : " << codprof;
statbar_set_title(TASK_WIN, msg);
continue;
}
// Se ho cambiato report cancello il vecchio
if (report == NULL || report->filename() != profilo)
// Stampa eventuali allegati
const TString& codalleg = profilo_allegato.mid(8);
if (!codalleg.blank())
{
delete report;
report = new TReport_doc(profilo);
}
if (!report->print(doc, book, is_definitive))
break;
profilo = codalleg; profilo.ext("rep");
if (profilo.custom_path())
{
TReport_doc& allegato = reports.get(profilo);
allegato.print(doc, book, is_definitive);
}
else
{
TString msg; msg << TR("Report allegato inesistente") << " : " << codalleg;
statbar_set_title(TASK_WIN, msg);
}
}
}
if (report != NULL)
{
if (book.pages() > 0)
book.print_or_preview();
delete report; // Distruggere il report DOPO l'anteprima!
}
return true;
}
void TReport_doc_app::print_selection()
{
TString query;
query << "USE " << LF_DOC;
add_filter(query, true);
add_filter(query, false);
print_loop(query);
}
void TReport_doc_app::main_loop()
{
while (_msk->run() == K_ENTER)
if (argc() >= 6) // Stampa da riga di comando
{
TString query;
query << "USE " << LF_DOC;
add_filter(query, true);
add_filter(query, false);
print_loop(query);
_msk->set(F_DATA_O_NUM, "N"); // Stampa per numero documento
_msk->set(F_PROVV, argv(4));
_msk->set(F_ANNO, argv(3));
_msk->set(F_CODNUM, argv(2));
_msk->set(F_DA_NDOC, argv(5));
_msk->set(F_A_NDOC, argv(5));
if (argc() >= 8)
_msk->set(F_NCOPIE, argv(7)); // Numero copie
print_selection();
}
else
{
while (_msk->run() == K_ENTER) // Stampa interattiva
print_selection();
}
}