Patch level : 11.0
Files correlati : ve1.exe Ricompilazione Demo : [ ] Commento : Corretta stampa fattura combiante con invio per email. A volte i font cambiavano le dimensioni del 20%, infatti: Risoluzione PDF = 720 DPI; Risoluzione stampa = 600 DPI; 720 / 600 = 1.20 git-svn-id: svn://10.65.10.50/branches/R_10_00@22075 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
95ad7491ae
commit
14031e74a1
285
ve/ve1300.cpp
285
ve/ve1300.cpp
@ -1156,10 +1156,10 @@ bool TReport_doc_app::print_loop(TRecordset& doc, TOutput_mode mode, bool is_def
|
||||
if (docs <= 0)
|
||||
return false;
|
||||
|
||||
if (mode == out_signed_mail && !xvt_sign_start())
|
||||
if ((mode == out_signed_mail || mode == out_signed_pdf) && !xvt_sign_start())
|
||||
{
|
||||
if (yesno_box(TR("Si desidera generare comunque documenti non firmati?")))
|
||||
mode = out_mail;
|
||||
mode = TOutput_mode(mode-1);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -1173,135 +1173,164 @@ bool TReport_doc_app::print_loop(TRecordset& doc, TOutput_mode mode, bool is_def
|
||||
|
||||
bool attach_mail = mode==out_mail || mode==out_signed_mail;
|
||||
if (attach_mail && is_power_station())
|
||||
attach_mail = yesno_box(TR("Si desidera spedire veramente i documenti via mail?\n"
|
||||
"Rispondendo NO verranno solo salvati gli allegati."));
|
||||
|
||||
for (int i = 0; i < docs; i++)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
doc.move_to(i);
|
||||
|
||||
const TString4 tipodoc = doc.get(DOC_TIPODOC).as_string();
|
||||
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
|
||||
|
||||
bool arc = false;
|
||||
if (is_definitive)
|
||||
{
|
||||
if (doc.get(DOC_STATO).as_string()[0] == tipo.stato_finale_stampa())
|
||||
continue; // Evita lavoro inutile!
|
||||
|
||||
const TString4 codnum = doc.get(DOC_CODNUM).as_string();
|
||||
const TCodice_numerazione& cn = cached_numerazione(codnum);
|
||||
arc = cn.auto_archive();
|
||||
}
|
||||
set_next_pdf(doc.get(DOC_ANNO).as_int(), doc.get(DOC_CODNUM).as_string(),
|
||||
doc.get(DOC_NDOC).as_int(), doc.get(DOC_TIPOCF).as_string()[0],
|
||||
doc.get(DOC_CODCF).as_int());
|
||||
|
||||
const bool send_mail = ( mode == out_mail || mode == out_signed_mail) && get_mail_address().full();
|
||||
const bool paperless = send_mail || mode == out_pdf || mode == out_signed_pdf;
|
||||
|
||||
// Tenta di costruirsi il nome del report: se non stampo su carta cerco di usare un profilo con sfondo
|
||||
TFilename profilo;
|
||||
const bool ok = nome_report(doc, paperless ? 2 : 0, profilo);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
int copies = 1;
|
||||
if (!paperless)
|
||||
{
|
||||
copies = _msk->get_int(F_NCOPIE);
|
||||
if (copies <= 0 && is_definitive)
|
||||
copies = tipo.ncopie();
|
||||
if (copies <= 0)
|
||||
copies = 1;
|
||||
}
|
||||
|
||||
TReport_doc& report = reports.get(profilo);
|
||||
if (send_mail)
|
||||
{
|
||||
mail_book = new TDoc_book;
|
||||
if (!report.print(doc, *mail_book, is_definitive, 1, true, false, false)) // Non archiviare per ora...
|
||||
break;
|
||||
if (arc) // ... eventualemte archivia direttamente il book senza passare per uno temporaneo
|
||||
mail_book->archive(NULL, signature);
|
||||
|
||||
TString mesg;
|
||||
mesg << tipo.descrizione() << TR(" n. ") << doc.get(DOC_NDOC)
|
||||
<< TR(" del ") << doc.get(DOC_DATADOC) << TR(" a ") << get_mail_address();
|
||||
mail_log.log(0, mesg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!report.print(doc, book, is_definitive, copies, true, arc, signature))
|
||||
break;
|
||||
if (!paperless)
|
||||
print_extra_copies(report, doc, book, copies);
|
||||
}
|
||||
} //if(profilo.custom_path()...
|
||||
else
|
||||
{
|
||||
TString msg; msg << TR("Report inesistente: ") << profilo;
|
||||
xvtil_popup_error(msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Stampa eventuali allegati
|
||||
if (nome_report(doc, 1, profilo))
|
||||
{
|
||||
int copies = tipo.additional_ncopie();
|
||||
if (copies <= 0) copies = 1;
|
||||
|
||||
TReport_doc& allegato = reports.get(profilo);
|
||||
// Cambio _codnum per non sovrascrivere il pdf precedente
|
||||
if (arc)
|
||||
{
|
||||
_codnum = profilo.name();
|
||||
_codnum = _codnum.before(".");
|
||||
}
|
||||
// Il flag di definitivo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
|
||||
if (send_mail)
|
||||
allegato.print(doc, *mail_book, false, 1, false, false, false); // Non archivio gli allegati alla mail
|
||||
else
|
||||
{
|
||||
allegato.print(doc, book, false, copies, false, arc, signature);
|
||||
if (!paperless)
|
||||
print_extra_copies(allegato, doc, book, copies);
|
||||
}
|
||||
}
|
||||
|
||||
if (mail_book != NULL)
|
||||
{
|
||||
if (mail_book->pages() > 0)
|
||||
{
|
||||
TFilename attachment;
|
||||
bool is_tmp = false;
|
||||
|
||||
// Se ho archiviato (arc==true) allora il file di attachment e' gia' pronto!
|
||||
bool ok = arc && get_next_pdf(_anno, -1, _codnum, _ndoc, _codcf, attachment);
|
||||
if (!ok || !attachment.exist()) // Altrimenti ne creo uno temporaneo
|
||||
{
|
||||
attachment.tempdir();
|
||||
attachment << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
|
||||
attachment.ext("pdf");
|
||||
ok = mail_book->export_pdf(attachment, mode == out_signed_mail);
|
||||
is_tmp = ok;
|
||||
}
|
||||
if (ok && attach_mail) // Ho chiesto la spedizione vera e propria
|
||||
{
|
||||
ok = spotlite_send_mail(attachment);
|
||||
if (is_tmp)
|
||||
attachment.fremove();
|
||||
}
|
||||
}
|
||||
delete mail_book;
|
||||
mail_book = NULL;
|
||||
}
|
||||
attach_mail =
|
||||
#ifdef DBG
|
||||
noyes_box
|
||||
#else
|
||||
yesno_box
|
||||
#endif
|
||||
(TR("Si desidera spedire veramente i documenti via mail?\n"
|
||||
"Rispondendo NO verranno solo salvati gli allegati."));
|
||||
}
|
||||
|
||||
if (book.pages() > 0)
|
||||
const bool mail_requested = (mode == out_mail || mode == out_signed_mail);
|
||||
|
||||
for (short loop = mail_requested ? 0 : 1; loop < 2; loop++)
|
||||
{
|
||||
const bool mail_loop = (loop == 0);
|
||||
const bool print_loop = !mail_loop;
|
||||
|
||||
for (int i = 0; i < docs; i++)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
doc.move_to(i);
|
||||
|
||||
const TString4 tipodoc = doc.get(DOC_TIPODOC).as_string();
|
||||
const TTipo_documento& tipo = cached_tipodoc(tipodoc);
|
||||
|
||||
bool arc = false;
|
||||
if (is_definitive)
|
||||
{
|
||||
if (doc.get(DOC_STATO).as_string()[0] == tipo.stato_finale_stampa())
|
||||
continue; // Evita lavoro inutile!
|
||||
|
||||
const TString4 codnum = doc.get(DOC_CODNUM).as_string();
|
||||
const TCodice_numerazione& cn = cached_numerazione(codnum);
|
||||
arc = cn.auto_archive();
|
||||
}
|
||||
set_next_pdf(doc.get(DOC_ANNO).as_int(), doc.get(DOC_CODNUM).as_string(),
|
||||
doc.get(DOC_NDOC).as_int(), doc.get(DOC_TIPOCF).as_string()[0],
|
||||
doc.get(DOC_CODCF).as_int());
|
||||
|
||||
// const bool send_mail = ( mode == out_mail || mode == out_signed_mail) && get_mail_address().full();
|
||||
const bool send_mail = mail_requested && get_mail_address().full();
|
||||
const bool paperless = send_mail || mode == out_pdf || mode == out_signed_pdf;
|
||||
|
||||
// Tenta di costruirsi il nome del report: se non stampo su carta cerco di usare un profilo con sfondo
|
||||
TFilename profilo;
|
||||
const bool ok = nome_report(doc, paperless ? 2 : 0, profilo);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
int copies = 1;
|
||||
if (!paperless)
|
||||
{
|
||||
copies = _msk->get_int(F_NCOPIE);
|
||||
if (copies <= 0 && is_definitive)
|
||||
copies = tipo.ncopie();
|
||||
if (copies <= 0)
|
||||
copies = 1;
|
||||
}
|
||||
|
||||
TReport_doc& report = reports.get(profilo);
|
||||
if (send_mail)
|
||||
{
|
||||
if (mail_loop)
|
||||
{
|
||||
mail_book = new TDoc_book;
|
||||
if (!report.print(doc, *mail_book, is_definitive, 1, true, false, false)) // Non archiviare per ora...
|
||||
break;
|
||||
if (arc) // ... eventualemte archivia direttamente il book senza passare per uno temporaneo
|
||||
mail_book->archive(NULL, signature);
|
||||
|
||||
TString mesg;
|
||||
mesg << tipo.descrizione() << TR(" n. ") << doc.get(DOC_NDOC)
|
||||
<< TR(" del ") << doc.get(DOC_DATADOC) << TR(" a ") << get_mail_address();
|
||||
mail_log.log(0, mesg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (print_loop)
|
||||
{
|
||||
if (!report.print(doc, book, is_definitive, copies, true, arc, signature))
|
||||
break;
|
||||
if (!paperless)
|
||||
print_extra_copies(report, doc, book, copies);
|
||||
}
|
||||
}
|
||||
} //if(profilo.custom_path()...
|
||||
else
|
||||
{
|
||||
TString msg; msg << TR("Report inesistente: ") << profilo;
|
||||
xvtil_popup_error(msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Stampa eventuali allegati
|
||||
if (nome_report(doc, 1, profilo))
|
||||
{
|
||||
int copies = tipo.additional_ncopie();
|
||||
if (copies <= 0) copies = 1;
|
||||
|
||||
TReport_doc& allegato = reports.get(profilo);
|
||||
// Cambio _codnum per non sovrascrivere il pdf precedente
|
||||
if (arc)
|
||||
{
|
||||
_codnum = profilo.name();
|
||||
_codnum = _codnum.before(".");
|
||||
}
|
||||
// Il flag di definitivo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
|
||||
if (send_mail)
|
||||
{
|
||||
if (mail_loop)
|
||||
allegato.print(doc, *mail_book, false, 1, false, false, false); // Non archivio gli allegati alla mail
|
||||
}
|
||||
else
|
||||
{
|
||||
if (print_loop)
|
||||
{
|
||||
allegato.print(doc, book, false, copies, false, arc, signature);
|
||||
if (!paperless)
|
||||
print_extra_copies(allegato, doc, book, copies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mail_book != NULL)
|
||||
{
|
||||
if (mail_book->pages() > 0)
|
||||
{
|
||||
TFilename attachment;
|
||||
bool is_tmp = false;
|
||||
|
||||
// Se ho archiviato (arc==true) allora il file di attachment e' gia' pronto!
|
||||
bool ok = arc && get_next_pdf(_anno, -1, _codnum, _ndoc, _codcf, attachment);
|
||||
if (!ok || !attachment.exist()) // Altrimenti ne creo uno temporaneo
|
||||
{
|
||||
attachment.tempdir();
|
||||
attachment << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
|
||||
attachment.ext("pdf");
|
||||
ok = mail_book->export_pdf(attachment, mode == out_signed_mail);
|
||||
is_tmp = ok;
|
||||
}
|
||||
if (ok && attach_mail) // Ho chiesto la spedizione vera e propria
|
||||
{
|
||||
ok = spotlite_send_mail(attachment);
|
||||
if (is_tmp)
|
||||
attachment.fremove();
|
||||
}
|
||||
}
|
||||
delete mail_book;
|
||||
mail_book = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (book.pages() > 0)
|
||||
{
|
||||
if (docs > 1)
|
||||
set_next_pdf(0, "", 0L, ' ', 0L); //spegne l'archiviazione nell'esportazione;non si possono archiviare più docs in uno!!!
|
||||
|
@ -3623,15 +3623,9 @@ bool TDocumento_mask::print_handler( TMask_field& f, KEY key )
|
||||
{
|
||||
switch (f.dlg())
|
||||
{
|
||||
case DLG_EMAIL :
|
||||
app().mailto();
|
||||
break;
|
||||
case DLG_PREVIEW :
|
||||
app().preview();
|
||||
break;
|
||||
default :
|
||||
app().print();
|
||||
break;
|
||||
case DLG_EMAIL : app().mailto(); break;
|
||||
case DLG_PREVIEW : app().preview(); break;
|
||||
default : app().print(); break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user