0c1d585185
Files correlati : ve1 Ricompilazione Demo : [ ] Commento : Corretta gestione richiesta di conferma e-mail git-svn-id: svn://10.65.10.50/trunk@20413 c028cbd2-c16b-5b4b-a496-9718f37d4682
114 lines
2.8 KiB
C++
Executable File
114 lines
2.8 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <dongle.h>
|
|
#include <mask.h>
|
|
#include <modaut.h>
|
|
#include <spotlite.h>
|
|
#include <defmask.h>
|
|
|
|
#include <bagn003.h>
|
|
|
|
// Funzione per generare il nome di un file da archiviare
|
|
bool spotlite_generate_name(const char* codnum, TFilename& pdf)
|
|
{
|
|
bool ok = main_app().get_next_pdf(0, -1, codnum, 0, 0, pdf);
|
|
if (ok && pdf.exist())
|
|
{
|
|
TString msg;
|
|
msg = TR("Il documento risulta essere gia' archiviato: sovrascrivere");
|
|
msg << '\n' << pdf.name();
|
|
ok = yesno_box(msg);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
KEY spotlite_ask_name(TFilename& pdf)
|
|
{
|
|
TMask msk("bagn009");
|
|
|
|
TApplication& a = main_app();
|
|
const bool can_arc = a.has_module(RSAUT);
|
|
const bool can_sign = can_arc && a.has_module(FDAUT);
|
|
msk.enable(DLG_EXPORT, can_arc);
|
|
msk.enable(DLG_PDF, can_arc);
|
|
msk.enable(DLG_SIGNPDF, can_sign);
|
|
|
|
TFilename export_name;
|
|
const bool gnp = a.get_next_pdf(0, 0, NULL, 1, 0, pdf);
|
|
if (gnp)
|
|
{
|
|
pdf.ext("");
|
|
export_name = pdf.name();
|
|
}
|
|
if (export_name.blank())
|
|
export_name = "export";
|
|
|
|
msk.enable(DLG_ARCHIVE, can_arc && gnp);
|
|
msk.enable(DLG_SIGNARC, can_sign && gnp);
|
|
|
|
msk.enable(DLG_EMAIL, can_arc);
|
|
msk.enable(DLG_SIGNMAIL, can_sign);
|
|
|
|
pdf.tempdir();
|
|
msk.set(F_PRINTER, pdf); // Cartella dei file da esportare
|
|
msk.set(F_FORM, export_name); // Nome standard del file da esportare
|
|
KEY key = msk.run();
|
|
if (key != K_ESC && key != K_QUIT)
|
|
{
|
|
pdf = msk.get(F_PRINTER);
|
|
if (!pdf.exist())
|
|
pdf.tempdir();
|
|
if (!msk.field(F_FORM).empty())
|
|
export_name = msk.get(F_FORM);
|
|
pdf.add(export_name);
|
|
pdf.ext("pdf");
|
|
|
|
switch (key)
|
|
{
|
|
case 'A':
|
|
case 'a':
|
|
if (!spotlite_generate_name(msk.get(F_FORM), pdf))
|
|
key = K_QUIT;
|
|
break;
|
|
case 'E':
|
|
case 'e':
|
|
pdf.ext("txt");
|
|
break;
|
|
case 'X':
|
|
case 'x':
|
|
pdf.ext("xls");
|
|
break;
|
|
default : break;
|
|
}
|
|
}
|
|
return key;
|
|
}
|
|
|
|
// Funzione per notificare al sistema l'avvenuta archiviazione
|
|
bool spotlite_notify(const TFilename& pdf)
|
|
{
|
|
bool ok = pdf.exist();
|
|
if (ok)
|
|
{
|
|
TFilename sentinel = pdf.path();
|
|
sentinel.add("sentinel.ini");
|
|
ofstream s(sentinel, ios::app);
|
|
s << pdf.name() << endl;
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
// Funzione per spedire un pdf via mail
|
|
bool spotlite_send_mail(const TFilename& pdf)
|
|
{
|
|
TToken_string to(15, ';'), cc(15, ';'), ccn(15, ';'), attach(pdf, ';');
|
|
TString subj, text;
|
|
short flags = 0x1; // UI
|
|
bool ok = main_app().get_next_mail(to, cc, ccn, subj, text, attach, flags);
|
|
if (subj.blank())
|
|
subj.cut(0) << TR("Invio di ") << pdf.name();
|
|
if (!(flags & 0x1) && to.empty_items() && cc.empty_items() && ccn.empty_items())
|
|
flags |= 0x1; // Forza UI in assenza di destinatari
|
|
ok = xvt_mail_send(to, cc, ccn, subj, text, attach, flags) != 0;
|
|
return ok;
|
|
}
|