Patch level : 2.2

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

Corretta gestione nome dei profili di stampa (principale ed aggiuntivo)
Non funzionanva corretamente in presenza di profilo principale lungo meno di 8 caratteri
quando si specificava anche un profilo aggiuntivo (non vuoto).

Attenzione: ricompilare per benino anche vedoc.lib


git-svn-id: svn://10.65.10.50/trunk@13496 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-11-15 12:04:34 +00:00
parent f22e8df6d2
commit cc5fcc3c2e
5 changed files with 120 additions and 99 deletions

View File

@ -547,37 +547,39 @@ void TMotore_application::print()
if (_print_directly || save(TRUE)) // Registra il record corrente if (_print_directly || save(TRUE)) // Registra il record corrente
{ {
TDocumento& doc = (TDocumento&)get_relation()->curr(); TDocumento& doc = (TDocumento&)get_relation()->curr();
const bool da_stampare = doc.stampabile();
const TTipo_documento& tipo = doc.tipo(); const TTipo_documento& tipo = doc.tipo();
TFilename rep(tipo.main_print_profile()); TFilename rep;
rep.ext("rep"); if (tipo.main_print_profile(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 int ncopie = tipo.ncopie();
if (ncopie > 0)
commandline << ' ' << ncopie;
TExternal_app interattivo( commandline );
if (interattivo.run() == NOERR)
{ {
if (da_stampare) // Aggiorna stato documento se necessario const bool da_stampare = doc.stampabile();
{
const char s[2] = { tipo.stato_finale_stampa(), '\0' };
TDocumento_mask & m = edit_mask();
doc.put(DOC_STATO, s); TString commandline;
if (rep.ends_with(".rep"))
commandline = "ve1 -2"; // Esiste il nuovo report :-)
else
commandline = "ve1 -0"; // Esiste il vecchio form :-(
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 int ncopie = tipo.ncopie();
if (ncopie > 0)
commandline << ' ' << ncopie;
TExternal_app interattivo( commandline );
if (interattivo.run() == NOERR)
{
if (da_stampare) // Aggiorna stato documento se necessario
{
const char s[2] = { tipo.stato_finale_stampa(), '\0' };
TDocumento_mask & m = edit_mask();
doc.put(DOC_STATO, s);
m.set(F_STATO, s, TRUE); m.set(F_STATO, s, TRUE);
}
} }
} }
} }

View File

@ -167,35 +167,32 @@ void TDocumento_form::set_doc_ext(TRectype* doc)
static TTipi_documento_cache __tipi; static TTipi_documento_cache __tipi;
TDocumento_form::TDocumento_form(TRectype& doc, TRelation& rel, bool definitiva, bool interattivo, bool aggiuntivo) TDocumento_form::TDocumento_form(TRectype& doc, TRelation& rel, bool definitiva, bool interattivo, bool aggiuntivo)
: _firmrel(rel), _sorted_cur(NULL), _docfile(NULL), _rdocfile(NULL), _doc(NULL), _valid(FALSE) : _firmrel(rel), _sorted_cur(NULL), _docfile(NULL), _rdocfile(NULL), _doc(NULL), _valid(false)
{ {
_form = this; _form = this;
const TString4 tipodoc(doc.get(DOC_TIPODOC)); const TString4 tipodoc(doc.get(DOC_TIPODOC));
TFilename nomeform; const TTipo_documento& tipo = __tipi.tipo(tipodoc);
const TTipo_documento & tipo = __tipi.tipo(tipodoc); if (tipo.empty())
if (tipo.empty())
{ {
error_box(FR("Tipo di documento non valido: '%s'"), (const char*)tipodoc); error_box(FR("Tipo di documento non valido: '%s'"), (const char*)tipodoc);
return; return;
} }
if (tipo.printable())
{ // se non ci sono errori procede con la stampa
nomeform = aggiuntivo ? tipo.additional_print_profile() : tipo.main_print_profile(); // legge il nome del form di stampa
nomeform.trim();
TFilename test(nomeform); test.ext("frm"); bool found = false;
if (!test.custom_path()) TFilename nomeform;
{ if (aggiuntivo)
error_box(FR("Nome form di stampa '%s' non valido per il tipo documento %s"), (const char*)nomeform, (const char*)tipodoc); found = tipo.additional_print_profile(nomeform);
return; else
} found = tipo.main_print_profile(nomeform);
found &= nomeform.ends_with(".frm");
if (!found)
{
error_box(FR("Nome form di stampa '%s' non valido per il tipo documento %s"), (const char*)nomeform, (const char*)tipodoc);
return;
} }
else
return;
_valid = TRUE; _valid = true;
read(nomeform); read(nomeform);
_cli_loaded= FALSE; _cli_loaded= FALSE;
set_doc_ext(&doc); // istanzia TDocumentoEsteso set_doc_ext(&doc); // istanzia TDocumentoEsteso
@ -1439,22 +1436,25 @@ void TStampaDoc_application::print_selected()
extdoc.scadenze_reset(); extdoc.scadenze_reset();
// Stampa eventuali documenti allegati // Stampa eventuali documenti allegati
const TFilename formagg = extdoc.tipo().additional_print_profile(); TFilename formagg;
const int ncopie2 = extdoc.tipo().get_int("I2"); if (extdoc.tipo().additional_print_profile(formagg))
if (!formagg.blank() && ncopie2 > 0) // Se esiste un tipo documento da accodare
{ {
TDocumento_form* secform = new TDocumento_form(cur.curr(), *_firmrel, _definitiva, _interattivo, TRUE); const int ncopie2 = extdoc.tipo().get_int("I2");
if (secform->valid())
{ if (ncopie2 > 0) // Se esiste un tipo documento da accodare
for (int i = 0; i < ncopie2; i++) {
{ TDocumento_form* secform = new TDocumento_form(cur.curr(), *_firmrel, _definitiva, _interattivo, true);
print_documento(*secform); if (secform->valid())
extdoc.summary_reset(); {
extdoc.scadenze_reset(); for (int i = 0; i < ncopie2; i++)
} {
} print_documento(*secform);
delete secform; extdoc.summary_reset();
extdoc.scadenze_reset();
}
}
delete secform;
}
} }
} }

View File

@ -804,48 +804,26 @@ bool TReport_doc_app::print_loop(const TString& query)
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 TTipo_documento& tipo = _tipi_cache.tipo(tipodoc); const TTipo_documento& tipo = _tipi_cache.tipo(tipodoc);
TString16 codprof(tipo.main_print_profile()); TFilename profilo;
if (tipo.main_print_profile(profilo) && profilo.ends_with(".rep"))
codprof.trim();
if (!codprof.blank())
{ {
TFilename profilo(codprof); profilo.ext("rep"); TReport_doc& report = reports.get(profilo);
if (!report.print(doc, book, is_definitive))
if (profilo.custom_path()) // Tenta di costruirsi il nome del report break;
{
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);
beep(2);
continue;
}
} }
else else
{
TString msg; msg << TR("Report inesistente") << " : " << profilo;
statbar_set_title(TASK_WIN, msg);
beep(2);
continue; continue;
}
// Stampa eventuali allegati // Stampa eventuali allegati
TString16 codalleg(tipo.additional_print_profile()); if (tipo.additional_print_profile(profilo) && profilo.ends_with(".rep"))
codalleg.trim();
if (!codalleg.blank())
{ {
TFilename profilo(codalleg); profilo.ext("rep"); TReport_doc& allegato = reports.get(profilo);
allegato.print(doc, book, is_definitive);
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);
}
} }
} }

View File

@ -288,12 +288,12 @@ public:
bool stato_with_mov_mag(const char stato) const; bool stato_with_mov_mag(const char stato) const;
bool scarica_residuo() const; bool scarica_residuo() const;
bool clifo_optional() const { return get_bool("B5"); } bool clifo_optional() const { return get_bool("B5"); }
bool printable() const { return !get("S5").empty(); } bool printable() const { return get("S5").not_empty(); }
const TString & main_print_profile() const { return get("S5").left(8); } bool main_print_profile(TFilename& report) const;
const TString & additional_print_profile() const { return get("S5").mid(8); } bool additional_print_profile(TFilename& report) const;
TFormula_documento * first_formula() { return succ_formula(true); } TFormula_documento* first_formula() { return succ_formula(true); }
TFormula_documento * succ_formula(bool restart = FALSE); TFormula_documento* succ_formula(bool restart = FALSE);
const int ncopie() const { return get_int("I0"); } const int ncopie() const { return get_int("I0"); }
bool spese_aut() const { return get_bool("B0"); } bool spese_aut() const { return get_bool("B0"); }

View File

@ -51,6 +51,47 @@ const TFilename& TTipo_documento::profile_name(TFilename& profile) const
return profile; return profile;
} }
bool TTipo_documento::main_print_profile(TFilename& report) const
{
TString16 base = get("S5");
base.cut(8);
base.trim();
bool ok = base.not_empty();
if (ok)
{
report = base;
report.ext("rep");
ok = report.custom_path();
if (!ok)
{
report = base;
report.ext("frm");
ok = report.custom_path();
}
}
return ok;
}
bool TTipo_documento::additional_print_profile(TFilename& report) const
{
TString16 base = get("S5");
base.ltrim(8); base.rtrim();
bool ok = base.not_empty();
if (ok)
{
report = base;
report.ext("rep");
ok = report.custom_path();
if (!ok)
{
report = base;
report.ext("frm");
ok = report.custom_path();
}
}
return ok;
}
const char TTipo_documento::tipocf() const const char TTipo_documento::tipocf() const
{ {
if (_tipocf < ' ') if (_tipocf < ' ')