Patch level : 12.0 no-patch
Files correlati : fp Commento : Preparazione invio mail per mancate consegna (fp0500)
This commit is contained in:
parent
5e752b772e
commit
b1766cadce
@ -288,7 +288,7 @@ END
|
||||
|
||||
BOOLEAN S_SPLITPAY
|
||||
BEGIN
|
||||
PROMPT 1 7 "Assogettato scissione pagamenti art.17 ter DPR 633/72"
|
||||
PROMPT 1 7 "Soggetto a scissione pagamenti art.17 ter DPR 633/72"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
|
@ -151,9 +151,6 @@ void TMancati_mask::fill()
|
||||
bool first, show, ask = !((show = (first = true)));
|
||||
int fat_no_cod = 0;
|
||||
|
||||
// Disabilito la colonna del codice ufficio
|
||||
docs.enable_column(docs.cid2index(S_UFFICIO), false);
|
||||
|
||||
for (bool okc = rec.move_first(); okc; okc = rec.move_next())
|
||||
{
|
||||
if (!pi.add_status())
|
||||
@ -171,56 +168,19 @@ void TMancati_mask::fill()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TToken_string& row = docs.row(-1);
|
||||
row = "";
|
||||
row.add(rec.get(DOC_ANNO).as_int(), 1);
|
||||
row.add(rec.get(DOC_CODNUM).as_string());
|
||||
row.add(rec.get(DOC_TIPODOC).as_string());
|
||||
if (!rec.get(DOC_TIPODOCSDI).is_empty())
|
||||
row.add(rec.get(DOC_TIPODOCSDI).as_string());
|
||||
else
|
||||
row.add(td.tipo_doc_sdi());
|
||||
row.add(rec.get(DOC_NDOC).as_int());
|
||||
row.add(rec.get(DOC_DATADOC).as_date());
|
||||
row.add(rec.get(CFV_CODCF).as_int());
|
||||
row.add(rec.get("20." CLI_RAGSOC).as_string());
|
||||
|
||||
TString rif = get_dest_sdi(rec.get(CFV_TIPOCF).as_string()[0], rec.get(CFV_CODCF).as_int());
|
||||
// Se è ancora vuoto potrebbe essere estero
|
||||
if(rif.empty())
|
||||
{
|
||||
// Segno la riga errata
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
// Abilito la colonna del codice ufficio per segnalare l'errore
|
||||
docs.enable_column(docs.cid2index(S_UFFICIO));
|
||||
}
|
||||
docs.set_back_and_fore_color(COLOR_RED, COLOR_WHITE, rec.current_row(), docs.cid2index(S_UFFICIO));
|
||||
fat_no_cod++;
|
||||
}
|
||||
;
|
||||
row.add(rif);
|
||||
row.add(rec.get("17." CFV_PARIFAMM).as_string());
|
||||
row.add(rec.get("20." CLI_COFI).as_string());
|
||||
|
||||
bool split = rec.get("20." CLI_SPLITPAY).as_bool();
|
||||
if (split)
|
||||
{
|
||||
const long numreg = rec.get(DOC_NUMREG).as_int();
|
||||
if (numreg > 0)
|
||||
{
|
||||
const TRectype& mov = cache().get(LF_MOV, numreg);
|
||||
split = is_split_payment(mov);
|
||||
}
|
||||
}
|
||||
row.add(split ? "X" : " ");
|
||||
|
||||
const bool attach = !rec.get("COLL_GOLEM").is_empty();
|
||||
row.add(attach ? "X" : " ");
|
||||
|
||||
row.add(!td.invio_xml() ? "X" : "");
|
||||
row.add(rec.get("20." CLI_DOCMAIL).as_string()); // Indirizzo email
|
||||
row.add(rec.get("20." CLI_BYMAIL).as_string()); // Consenso invio email
|
||||
}
|
||||
|
||||
docs.force_update();
|
||||
@ -353,9 +313,20 @@ bool TMancati_mask::check_doc_filter(const TDocumentoEsteso& d) const
|
||||
|
||||
class TMancati_app : public TSkeleton_application
|
||||
{
|
||||
int _anno;
|
||||
TString16 _codnum, _tipodoc;
|
||||
long _ndoc, _codcf;
|
||||
char _tipocf;
|
||||
|
||||
void set_next_pdf(const int anno, const TFixed_string& codnum, const TFixed_string& tipodoc, const long ndoc, const long codcf);
|
||||
bool get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, long codcf, TFilename& pdf) const override;
|
||||
bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn, TString& subj, TString& text,
|
||||
TToken_string& attach, short& ui) const override;
|
||||
bool get_mail_address(TToken_string& to, TToken_string& cc) const;
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
|
||||
virtual bool destroy();
|
||||
virtual void main_loop();
|
||||
|
||||
@ -367,6 +338,27 @@ void TMancati_app::main_loop()
|
||||
TMancati_mask mask;
|
||||
while (mask.run() == K_ENTER)
|
||||
{
|
||||
TString_array& sht = mask.sfield(F_DOCS).rows_array();
|
||||
TFp_mail_sender mail_sender;
|
||||
|
||||
FOR_EACH_ARRAY_ROW(sht, r, riga)
|
||||
{
|
||||
//if (!pi.add_status(1))
|
||||
//break;
|
||||
|
||||
if (riga->starts_with("X"))
|
||||
{
|
||||
const int anno = riga->get_int(mask.sfield(F_DOCS).cid2index(S_ANNO));
|
||||
const long ndoc = riga->get_long(mask.sfield(F_DOCS).cid2index(S_NDOC));
|
||||
const TFixed_string codnum(riga->get(mask.sfield(F_DOCS).cid2index(S_CODNUM)));
|
||||
const TFixed_string tipodoc(riga->get(mask.sfield(F_DOCS).cid2index(S_TIPODOC)));
|
||||
const long codcf = riga->get_long(mask.sfield(F_DOCS).cid2index(S_CLIENTE));
|
||||
|
||||
|
||||
mail_sender.set_doc(anno, ndoc, codnum, tipodoc, codcf);
|
||||
mail_sender.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,6 +376,112 @@ bool TMancati_app::create()
|
||||
|
||||
}
|
||||
|
||||
void TMancati_app::set_next_pdf(const int anno, const TFixed_string& codnum, const TFixed_string& tipodoc, const long ndoc, const long codcf)
|
||||
{
|
||||
_anno = anno;
|
||||
_codnum = codnum;
|
||||
_ndoc = ndoc;
|
||||
_tipodoc = tipodoc;
|
||||
_tipocf = 'C';
|
||||
_codcf = codcf;
|
||||
}
|
||||
|
||||
bool TMancati_app::get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, long codcf, TFilename& pdf) const
|
||||
{
|
||||
bool ok = false;
|
||||
if (_anno > 0 && _codnum.full() && _ndoc > 0 && _codcf > 0)
|
||||
ok = TSkeleton_application::get_next_pdf(_anno, ditta, _codnum, _ndoc, _codcf, pdf);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool TMancati_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
|
||||
TString& subj, TString& text, TToken_string& attach, short& ui) const
|
||||
{
|
||||
bool ok = TApplication::get_next_mail(to, cc, ccn, subj, text, attach, ui);
|
||||
|
||||
if (_ndoc > 0L)
|
||||
{
|
||||
ok = get_mail_address(to, cc);
|
||||
if (ok)
|
||||
{
|
||||
const TDocumento doc('D', _anno, _codnum, _ndoc);
|
||||
doc.riferimento(subj);
|
||||
if (subj.blank())
|
||||
subj = doc.tipo().descrizione();
|
||||
subj << ' ' << _ndoc << TR(" del ") << doc.get(DOC_DATADOC)
|
||||
<< ' ' << prefix().firm().ragione_sociale();
|
||||
|
||||
TString saluti = esc(ini_get_string(CONFIG_USER, "Mail", "Signature"));
|
||||
if (saluti.full())
|
||||
{
|
||||
if (saluti.find('\n') < 0 && fexist(saluti))
|
||||
{
|
||||
TScanner s(saluti);
|
||||
while (!s.eof())
|
||||
text << s.line() << '\n';
|
||||
}
|
||||
else
|
||||
text << saluti << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
text << TR("Cordiali Saluti ") << prefix().firm().ragione_sociale();
|
||||
}
|
||||
text.trim();
|
||||
if (to.full())
|
||||
ui &= ~0x1; // No user interface
|
||||
ui |= 0x2; // Query receipt
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMancati_app::get_mail_address(TToken_string& to, TToken_string& cc) const
|
||||
{
|
||||
if (_tipodoc.full())
|
||||
{
|
||||
const TTipo_documento& tipo = cached_tipodoc(_tipodoc);
|
||||
TFilename report; tipo.mail_print_profile(report);
|
||||
report = report.name_only();
|
||||
|
||||
TString8 clifo; clifo.format("%c%06ld", _tipocf, _codcf);
|
||||
TISAM_recordset contacts("USE MULTIREL\nFROM COD=BACON FIRST=#CLIFO\nTO COD=BACON FIRST=#CLIFO");
|
||||
contacts.set_var("#CLIFO", clifo);
|
||||
|
||||
TToken_string data;
|
||||
for (bool ok = contacts.move_first(); ok; ok = contacts.move_next())
|
||||
{
|
||||
data = contacts.get("DATA").as_string();
|
||||
FOR_EACH_TOKEN(data, tok)
|
||||
{
|
||||
if (_tipodoc.match(tok, true) || report.match(tok, true))
|
||||
{
|
||||
const TRectype& rub = cache().get(LF_CONTACT, contacts.get("SECOND").as_int());
|
||||
TString80 mail = rub.get("MAIL");
|
||||
if (mail.blank())
|
||||
mail = rub.get("MAIL2");
|
||||
if (mail.full())
|
||||
{
|
||||
if (to.blank())
|
||||
to = mail;
|
||||
else
|
||||
cc.add(mail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (to.blank())
|
||||
{
|
||||
TString8 key; key << _tipocf << '|' << _codcf;
|
||||
to = cache().get(LF_CLIFO, key, CLI_DOCMAIL);
|
||||
}
|
||||
return to.full();
|
||||
}
|
||||
|
||||
bool TMancati_app::destroy()
|
||||
{
|
||||
fp_db().sq_disconnect();
|
||||
|
@ -21,14 +21,10 @@
|
||||
#define S_ANNO 102
|
||||
#define S_CODNUM 103
|
||||
#define S_TIPODOC 104
|
||||
#define S_CODSDI 105
|
||||
#define S_NDOC 106
|
||||
#define S_DATADOC 107
|
||||
#define S_CLIENTE 108
|
||||
#define S_RAGSOC 109
|
||||
#define S_UFFICIO 110
|
||||
#define S_RIFAMM 111
|
||||
#define S_COFI 112
|
||||
#define S_SPLITPAY 113
|
||||
#define S_ATTACH 114
|
||||
#define S_ONLYGEN 115
|
||||
#define S_NDOC 105
|
||||
#define S_DATADOC 106
|
||||
#define S_CLIENTE 107
|
||||
#define S_RAGSOC 108
|
||||
#define S_COFI 109
|
||||
#define S_DOCMAIL 110
|
||||
#define S_BYMAIL 111
|
@ -15,6 +15,14 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BUTTON DLG_EMAIL 10 2
|
||||
BEGIN
|
||||
PROMPT 5 1 "Mail"
|
||||
PICTURE TOOL_EMAIL
|
||||
MESSAGE EXIT,69
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
@ -56,17 +64,13 @@ BEGIN
|
||||
ITEM "Anno"
|
||||
ITEM "Cod.\nNum.@4"
|
||||
ITEM "Tipo\nDoc@4"
|
||||
ITEM "Tipo SDI@4"
|
||||
ITEM "Num.\nDoc.@7"
|
||||
ITEM "Data\nDoc.@10"
|
||||
ITEM "Cliente"
|
||||
ITEM "Ragione Sociale@50"
|
||||
ITEM "Codice destinatario@20"
|
||||
ITEM "Riferimento\nAmministrazione@20"
|
||||
ITEM "Codice Fiscale@16"
|
||||
ITEM "Scissione\nPagamenti@9"
|
||||
ITEM "Allegati"
|
||||
ITEM "Solo generazione"
|
||||
ITEM "EMail@50"
|
||||
ITEM "Consenso\ninvio@7"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
@ -181,18 +185,6 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
LIST S_CODSDI 35
|
||||
BEGIN
|
||||
PROMPT 41 2 "Tipo Doc SDI"
|
||||
ITEM "TD01|TD01 Fattura"
|
||||
ITEM "TD02|TD02 Acconto/Anticipo su fattura"
|
||||
ITEM "TD03|TD03 Acconto/Anticipo su parcella"
|
||||
ITEM "TD04|TD04 Nota di credito"
|
||||
ITEM "TD05|TD05 Nota di debito"
|
||||
ITEM "TD06|TD06 Parcella"
|
||||
ITEM "TD20|TD20 Autofattura"
|
||||
END
|
||||
|
||||
NUMBER S_NDOC 7
|
||||
BEGIN
|
||||
PROMPT 1 3 "Numero "
|
||||
@ -217,39 +209,21 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_UFFICIO 50 20
|
||||
BEGIN
|
||||
PROMPT 1 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_RIFAMM 20
|
||||
BEGIN
|
||||
PROMPT 21 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_COFI 20
|
||||
BEGIN
|
||||
PROMPT 1 6 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_SPLITPAY
|
||||
STRING S_DOCMAIL 50
|
||||
BEGIN
|
||||
PROMPT 1 7 "Assogettato scissione pagamenti art.17 ter DPR 633/72"
|
||||
PROMPT 1 6 "email"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_ATTACH
|
||||
BOOLEAN S_BYMAIL
|
||||
BEGIN
|
||||
PROMPT 1 8 "Documenti in allegato"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_ONLYGEN
|
||||
BEGIN
|
||||
PROMPT 20 8 "Solo generazione"
|
||||
PROMPT 1 7 "Consenso invio email"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
|
@ -305,5 +305,21 @@ public:
|
||||
|
||||
TFP_righe_custom();
|
||||
};
|
||||
class TFp_mail_sender
|
||||
{
|
||||
int _anno;
|
||||
TString16 _codnum;
|
||||
const TTipo_documento* _tipodoc;
|
||||
long _ndoc, _codcf;
|
||||
|
||||
|
||||
public:
|
||||
void set_doc(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf);
|
||||
bool genera_pdf();
|
||||
void send();
|
||||
|
||||
TFp_mail_sender() { }
|
||||
TFp_mail_sender(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf)
|
||||
{ set_doc(anno, ndoc, codnum, tipodoc, codcf); }
|
||||
};
|
||||
#endif // __FPLIB_H
|
||||
|
53
src/fp/fplib03.cpp
Normal file
53
src/fp/fplib03.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "fplib.h"
|
||||
#include "execp.h"
|
||||
|
||||
class TExternal_app;
|
||||
|
||||
void TFp_mail_sender::set_doc(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf)
|
||||
{
|
||||
_anno = anno;
|
||||
_codnum = codnum;
|
||||
_tipodoc = &cached_tipodoc(tipodoc);
|
||||
_ndoc = ndoc;
|
||||
_codcf = codcf;
|
||||
}
|
||||
|
||||
bool TFp_mail_sender::genera_pdf()
|
||||
{
|
||||
static TString commandline;
|
||||
commandline.cut(0) << "ve1 -2 " << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << " X P 1 D"; // X: stampa su disco, P: provvisorio, 1: 1 copia, D: disabilita archiviazione
|
||||
TExternal_app interattivo(commandline);
|
||||
if (interattivo.run() != NOERR)
|
||||
{
|
||||
TString msgerr = "Fallita generazione PDF documento ";
|
||||
msgerr << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC);
|
||||
error_box(msgerr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename pdf; pdf.tempdir();
|
||||
pdf << SLASH << doc.get(DOC_ANNO) << '_' << doc.get(DOC_CODNUM) << '_' << doc.get(DOC_NDOC) << ".pdf";
|
||||
if (!pdf.exist() && !yesno_box("Attenzione! Non è stato possibile creare il pdf, continuare?"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!add_row_alleg(pdf, nprogr, paf2600f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void TFp_mail_sender::send()
|
||||
{
|
||||
TFilename mail;
|
||||
if (fp_settings().get_allega_fat()) {
|
||||
TString fld_pdf = fp_settings().get_fld_dest_usr(); // Cartella dove ci sono i pdf generati
|
||||
|
||||
//se lo trovo ce l'ho già altrimenti devo generarlo
|
||||
genera_pdf();
|
||||
|
||||
|
||||
|
||||
}
|
||||
_tipodoc->mail_print_profile(mail);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user