Invio solleciti per e-mail
git-svn-id: svn://10.65.10.50/branches/R_10_00@22829 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
38d0373fb9
commit
12d9139ed1
223
sc/sc2400.cpp
223
sc/sc2400.cpp
@ -1,11 +1,13 @@
|
|||||||
#include <applicat.h>
|
|
||||||
#include <printer.h>
|
|
||||||
|
|
||||||
#include "sc2.h"
|
#include "sc2.h"
|
||||||
#include "sc2402.h"
|
#include "sc2402.h"
|
||||||
#include "sc2102.h"
|
#include "sc2102.h"
|
||||||
#include "sc2400a.h"
|
#include "sc2400a.h"
|
||||||
|
|
||||||
|
#include <applicat.h>
|
||||||
|
#include <progind.h>
|
||||||
|
#include <printer.h>
|
||||||
|
#include <reputils.h>
|
||||||
|
|
||||||
#include <clifo.h>
|
#include <clifo.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -25,13 +27,19 @@ protected:
|
|||||||
virtual void main_loop();
|
virtual void main_loop();
|
||||||
virtual void on_firm_change();
|
virtual void on_firm_change();
|
||||||
|
|
||||||
|
bool get_mail_address(TToken_string& to, TToken_string& cc) const;
|
||||||
|
virtual bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
|
||||||
|
TString& subj, TString& text, TToken_string& attach, short& ui) const;
|
||||||
|
|
||||||
|
int print_sol(); // stampa l'elemento corrente
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TSol_mask &mask() { return *_msk; }
|
TSol_mask &mask() const { return *_msk; }
|
||||||
TSol_form &form() { return *_form; }
|
TSol_form &form() const { return *_form; }
|
||||||
TCursor_sheet &sheet() { return _msk->cur_sheet(); }
|
TCursor_sheet &sheet() { return _msk->cur_sheet(); }
|
||||||
|
|
||||||
bool print_selected(); // cicla la stampa sugli elementi selezionati
|
bool print_selected(); // cicla la stampa sugli elementi selezionati
|
||||||
int print_sol(); // stampa l'elemento corrente
|
bool mail_selected(); // manda email agli elementi selezionati
|
||||||
|
|
||||||
TStampaSol_application();
|
TStampaSol_application();
|
||||||
virtual ~TStampaSol_application() {}
|
virtual ~TStampaSol_application() {}
|
||||||
@ -66,8 +74,7 @@ bool TStampaSol_application::print_selected()
|
|||||||
{
|
{
|
||||||
if (print_all || s.checked(i))
|
if (print_all || s.checked(i))
|
||||||
{
|
{
|
||||||
fc= i; // muove il cursore alla posizione corrente
|
fc = i; // muove il cursore alla posizione corrente
|
||||||
|
|
||||||
const int ret = print_sol();
|
const int ret = print_sol();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
analfabeti++;
|
analfabeti++;
|
||||||
@ -132,7 +139,7 @@ int TStampaSol_application::print_sol()
|
|||||||
err = partite.read(_isgreat))
|
err = partite.read(_isgreat))
|
||||||
{
|
{
|
||||||
TPartita game(partite.curr());
|
TPartita game(partite.curr());
|
||||||
real saldo(game.calcola_scaduto_al(FALSE, data_limite_scad));
|
const real saldo = game.calcola_scaduto_al(FALSE, data_limite_scad);
|
||||||
|
|
||||||
TImporto unreferenced; //Totale non assegnati per questa partita.
|
TImporto unreferenced; //Totale non assegnati per questa partita.
|
||||||
{
|
{
|
||||||
@ -151,8 +158,7 @@ int TStampaSol_application::print_sol()
|
|||||||
if (sel_tot_saldo || (saldo > ZERO && saldo >= sel_importo ))
|
if (sel_tot_saldo || (saldo > ZERO && saldo >= sel_importo ))
|
||||||
{
|
{
|
||||||
const bool printed = form().print_game(game);
|
const bool printed = form().print_game(game);
|
||||||
if (printed)
|
one_printed |= printed;
|
||||||
one_printed = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partite.put(PART_NRIGA, 9999);
|
partite.put(PART_NRIGA, 9999);
|
||||||
@ -168,7 +174,179 @@ int TStampaSol_application::print_sol()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return one_printed ? 1 : 0;
|
return one_printed ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TStampaSol_application::get_mail_address(TToken_string& to, TToken_string& cc) const
|
||||||
|
{
|
||||||
|
const TRectype& fc = form().cursor()->curr();
|
||||||
|
const long codcf = fc.get_long(CLI_CODCF);
|
||||||
|
TString8 clifo; clifo.format("C%06ld", 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)
|
||||||
|
{
|
||||||
|
const TFixed_string doc(tok);
|
||||||
|
if (doc.starts_with("sc2400", true) || doc.starts_with("sollec", 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 << "C|" << codcf;
|
||||||
|
to = cache().get(LF_CLIFO, key, CLI_DOCMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return to.full();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TStampaSol_application::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) && get_mail_address(to, cc);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
const TDate oggi = mask().get(F_DATASEND);
|
||||||
|
subj << TR("Sollecito ") << prefix().firm().ragione_sociale();
|
||||||
|
text << TR("Si sollecita il rispetto delle scadenze aperte al ") << oggi << TR(" riepilogate nel file ") << attach
|
||||||
|
<< "\n" << prefix().firm().ragione_sociale();
|
||||||
|
if (to.full())
|
||||||
|
ui &= ~0x1; // No user interface
|
||||||
|
ui |= 0x2; // Query receipt
|
||||||
|
|
||||||
|
const long codcf = form().cursor()->curr().get_long(CLI_CODCF);
|
||||||
|
TFilename pdf;
|
||||||
|
ok = get_next_pdf(oggi.year(), -1, "SOLL", oggi.date2ansi(), codcf, pdf);
|
||||||
|
attach = pdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TMail_message : public TObject
|
||||||
|
{
|
||||||
|
TToken_string _to, _cc, _ccn;
|
||||||
|
TString _subj, _text;
|
||||||
|
TToken_string _attach;
|
||||||
|
short _ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool TStampaSol_application::mail_selected()
|
||||||
|
{
|
||||||
|
TCursor_sheet &s = sheet();
|
||||||
|
TCursor &c = *s.cursor();
|
||||||
|
|
||||||
|
const char who = mask().get_who();
|
||||||
|
const int key = mask().get_key();
|
||||||
|
|
||||||
|
// Attiva la stampa del saldo partita
|
||||||
|
form().stampa_saldo(mask().stampa_saldo());
|
||||||
|
|
||||||
|
// filtra il cursore del form in modo che diventi uguale al cursor_sheet corrente
|
||||||
|
// Qui sarebbe bello copiarsi l'indice dell'altro cursore
|
||||||
|
TCursor &fc = *form().cursor();
|
||||||
|
fc.setkey(key);
|
||||||
|
TRectype filter(LF_CLIFO);
|
||||||
|
filter.put(CLI_TIPOCF, who);
|
||||||
|
fc.setregion(filter, filter);
|
||||||
|
|
||||||
|
const long print_all = !s.one_checked(); // se non ho selezionato nulla allora li stampo tutti
|
||||||
|
|
||||||
|
TLog_report log;
|
||||||
|
|
||||||
|
TArray mail;
|
||||||
|
|
||||||
|
const long items = c.items();
|
||||||
|
if (items > 0)
|
||||||
|
{
|
||||||
|
const TDate oggi(TODAY);
|
||||||
|
TProgind pi(items);
|
||||||
|
for (long i=0; i < items; i++)
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
if (print_all || s.checked(i))
|
||||||
|
{
|
||||||
|
fc = i; // muove il cursore alla posizione corrente
|
||||||
|
|
||||||
|
printer().set_printtype(exportprinter);
|
||||||
|
printer().open();
|
||||||
|
const int ret = print_sol();
|
||||||
|
printer().close();
|
||||||
|
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg << fc.curr().get(CLI_RAGSOC) << ": ";
|
||||||
|
msg.strip_double_spaces();
|
||||||
|
|
||||||
|
TMail_message* m = new TMail_message;
|
||||||
|
bool done = false;
|
||||||
|
if (get_next_mail(m->_to, m->_cc, m->_ccn, m->_subj, m->_text, m->_attach, m->_ui))
|
||||||
|
{
|
||||||
|
const TFilename fn = m->_attach;
|
||||||
|
done = printer().print_pdf(printer().get_txt(), fn);
|
||||||
|
if (done)
|
||||||
|
{
|
||||||
|
msg << TR("invio ") << fn.name() << TR(" a ") << m->_to;
|
||||||
|
log.log(0, msg);
|
||||||
|
mail.add(m);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg << TR("Impossibile genereare ") << fn;
|
||||||
|
log.log(2, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg << TR("Impossibile trovare un indirizzo e-mail valido");
|
||||||
|
log.log(2, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!done)
|
||||||
|
delete m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printer().read_configuration();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.preview();
|
||||||
|
|
||||||
|
if (!mail.empty() && yesno_box(FR("Confermare l'invio di %ld mail?"), mail.items()))
|
||||||
|
{
|
||||||
|
FOR_EACH_ARRAY_ITEM(mail, r,obj)
|
||||||
|
{
|
||||||
|
const TMail_message& m = *(TMail_message*)obj;
|
||||||
|
xvt_mail_send(m._to, m._cc, m._ccn, m._subj, m._text, m._attach, m._ui);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TStampaSol_application::create()
|
bool TStampaSol_application::create()
|
||||||
{
|
{
|
||||||
@ -202,20 +380,27 @@ void TStampaSol_application::on_firm_change()
|
|||||||
|
|
||||||
void TStampaSol_application::main_loop()
|
void TStampaSol_application::main_loop()
|
||||||
{
|
{
|
||||||
TSol_mask &m= mask();
|
TSol_mask& m = mask();
|
||||||
while (m.run() != K_QUIT)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
const KEY key = m.run();
|
||||||
|
if (key == K_QUIT)
|
||||||
|
break;
|
||||||
|
|
||||||
const TDate dlimsol(m.get(F_DATALIMSOL));
|
const TDate dlimsol(m.get(F_DATALIMSOL));
|
||||||
const TDate dsped(m.get(F_DATASEND));
|
const TDate dsped(m.get(F_DATASEND));
|
||||||
if (dlimsol > dsped)
|
if (dlimsol >= dsped)
|
||||||
error_box(TR("La data limite sollecito deve essere specificata e non puo' essere superiore alla data di invio"));
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_form= new TSol_form(m, _gesval, F_DATALIMOP, F_DATALIMSOL);
|
_form= new TSol_form(m, _gesval, F_DATALIMOP, F_DATALIMSOL);
|
||||||
print_selected();
|
if (key == 'M')
|
||||||
|
mail_selected();
|
||||||
|
else
|
||||||
|
print_selected();
|
||||||
delete _form;
|
delete _form;
|
||||||
_form= NULL;
|
_form= NULL;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
error_box(TR("La data limite sollecito deve essere specificata e non puo' essere superiore alla data di invio"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,28 @@
|
|||||||
#include "sc2400a.h"
|
#include "sc2400a.h"
|
||||||
|
|
||||||
TOOLBAR "" 0 0 0 2
|
TOOLBAR "" 0 0 0 2
|
||||||
#include <printbar.h>
|
|
||||||
|
BUTTON DLG_PRINT 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Stampa"
|
||||||
|
PICTURE TOOL_PRINT
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_SETPRINT 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 1 "Imposta"
|
||||||
|
PICTURE TOOL_SETPRINT
|
||||||
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_EMAIL 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Mail"
|
||||||
|
PICTURE TOOL_EMAIL
|
||||||
|
MESSAGE EXIT,77
|
||||||
|
END
|
||||||
|
|
||||||
|
#include <helpbar.h>
|
||||||
|
|
||||||
ENDPAGE
|
ENDPAGE
|
||||||
|
|
||||||
PAGE "Stampa solleciti" 0 0 0 0
|
PAGE "Stampa solleciti" 0 0 0 0
|
||||||
@ -91,7 +112,7 @@ BEGIN
|
|||||||
PROMPT 2 6 "Importo minimo "
|
PROMPT 2 6 "Importo minimo "
|
||||||
END
|
END
|
||||||
|
|
||||||
RADIOBUTTON F_RIFIMPMIN 12
|
RADIOBUTTON F_RIFIMPMIN 14
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 50 5 ""
|
PROMPT 50 5 ""
|
||||||
ITEM "P|Partita"
|
ITEM "P|Partita"
|
||||||
|
@ -20,9 +20,7 @@ public:
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class TSol_row : public TESSL_row
|
class TSol_row : public TESSL_row
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
protected: // TSortable
|
protected: // TSortable
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user