Merge branch 'R_10_00' of http://10.65.20.33/sirio/CAMPO/campo into R_10_00

This commit is contained in:
Sirio Builder 2019-02-28 09:27:30 +01:00
commit 062fa376e3
21 changed files with 410 additions and 191 deletions

View File

@ -79,6 +79,7 @@ void TRiepilogoIVA_app::main_loop()
{
damese = 1;
amese = 12;
recset->set_annuale(true);
}
const TDate da(1, damese, anno);

View File

@ -586,10 +586,15 @@ bool TLiquidazione_app::ch_year_handler(TMask_field& f, KEY key)
(wht)f.mask().get_int(CG43_RDB_VERS) : all);
TMask& msk = f.mask();
const int vers = msk.get_int(CG43_RDB_VERS);
const int m = (vers == 3) ? msk.get_int(CG43_LST_TRIM) : msk.get_int(CG43_LST_MESE);
int m = (vers == 3) ? msk.get_int(CG43_LST_TRIM) : msk.get_int(CG43_LST_MESE);
app()._is_liq_acconto = (m == 20);
if (app()._is_liq_acconto)
m = 12;
const TRectype & lim = app().get_lim(m);
const bool def = lim.get_bool("B1");
const bool calc = !def && (lim.empty() || lim.get_bool("B0"));
const bool calc = app()._is_liq_acconto || (!def && (lim.empty() || lim.get_bool("B0")));
msk.set(CG43_CHK_CALCULATE, app()._lim_cleared && calc, 0x3);
msk.set(CG43_CHK_FINAL, app()._lim_cleared && def, 0x3);
@ -690,6 +695,11 @@ bool TLiquidazione_app::what_freq_handler(TMask_field& f, KEY key)
if (key == K_SPACE)
{
int month = f.mask().get_int(CG43_LST_MESE);
app()._is_liq_acconto = (month == 20);
if (app()._is_liq_acconto)
month = 12;
if (f.get()[0] == '3') // trimestre intelligente
{
if (month > 3)
@ -778,7 +788,11 @@ bool TLiquidazione_app::chk_calculate_handler(TMask_field& f, KEY key)
TMask& m = f.mask();
// Abilita solo se il mese di ricalcolo e' != 13 (annuale) e non e' checkkato il campo
const int vers = m.get_int(CG43_RDB_VERS);
const int mese = vers == 3 ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE);
int mese = vers == 3 ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE);
app()._is_liq_acconto = (mese == 20);
if (app()._is_liq_acconto)
mese = 12;
const bool abilita = m.get_bool(CG43_CHK_CALCULATE) && mese != 13;
m.enable(CG43_LST_CALC, abilita);
}
@ -893,10 +907,19 @@ bool TLiquidazione_app::set_liquidazione()
// handlers have set everything
_month = _what == trimestre ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE);
app()._is_liq_acconto = (_month == 20);
if (app()._is_liq_acconto)
{
_month = 12;
_recalc = one;
}
else
_recalc = m.get_bool(CG43_CHK_CALCULATE) ? one : never;
_year = m.get(CG43_FLD_ANNO);
_date = m.get(CG43_FLD_DATA);
_isprint = m.get_bool(CG43_CHK_STAMPA);
_recalc = m.get_bool(CG43_CHK_CALCULATE) ? one : never;
_printonly = !m.get_bool(CG43_CHK_CALCULATE);
_definitiva = m.get_bool(CG43_CHK_FINAL);

View File

@ -304,6 +304,7 @@ class TLiquidazione_app : public TPrint_application
int _monthinatt; // mese inizio attivita' (serve per differita)
bool _lim_cleared;
bool _definitiva;
bool _is_liq_acconto;
bool _end_cassa;
real _diff_ven_ap, _diff_ven_ap_iva, _diff_acq_ap, _diff_acq_ap_iva;

View File

@ -27,15 +27,16 @@ BEGIN
CHECKTYPE REQUIRED
END
LIST CG43_LST_MESE 15
LIST CG43_LST_MESE 20
BEGIN
PROMPT 28 3 "Periodo "
HELP "Mese per cui effettuare il calcolo liquidazione"
ITEM "13|13a liquid."
ITEM "20|Acconto Dicembre"
FLAGS "MP"
END
LIST CG43_LST_TRIM 15
LIST CG43_LST_TRIM 20
BEGIN
PROMPT 28 3 "Periodo "
HELP "Trimestre di cui effettuare il calcolo liquidazione"
@ -44,6 +45,7 @@ BEGIN
ITEM "9|3 Trimestre "
ITEM "12|4 Trimestre"
ITEM "13|13a liquid."
ITEM "20|Acconto Dicembre"
END
BOOLEAN CG43_CHK_CALCULATE

View File

@ -1184,7 +1184,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array &
if (date.year() != year_int) // Controlla anno di appartenenza, altrimenti is_date_ok potrebbe non funzionare
continue;
}
#ifdef DBG
if (nr == 35363)
int i = 1;
#endif
const TRectype& rcs = _cur->curr(LF_CAUSALI);
const TDate datareg = _mov->get_date(MOV_DATAREG);
const TDate datadoc = _mov->get_date(MOV_DATADOC);
@ -4167,8 +4170,12 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
if (risul > ZERO)
{
if (gestione_manuale_credito_compensabile)
credito_utilizzabile -= lim.get_real("R15");
credito_utilizzato_iva = min(risul, credito_utilizzabile);
{
credito_utilizzato_iva = lim.get_real("R15");
credito_utilizzato_iva = min(risul, credito_utilizzato_iva);
}
else
credito_utilizzato_iva = min(risul, credito_utilizzabile);
res_cred += credito_utilizzato_iva;
risultato -= credito_utilizzato_iva;
}
@ -4523,7 +4530,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts)
const TRectype & lia = get_lia();
const bool gestione_manuale_credito_compensabile = lia.get_bool("B6");
// if (!gestione_manuale_credito_compensabile)
if (!gestione_manuale_credito_compensabile)
lim.put("R15", credito_utilizzato_iva);
if (month == 13)

View File

@ -57,7 +57,8 @@ bool TLiquidazione_app::is_month_ok(int x, int mtocalc) const
{
// per l'annuale ritorna true per tutti i mesi da liquidare
ret = x <= 13;
}
}
return ret;
}
@ -138,7 +139,12 @@ bool TLiquidazione_app::is_date_ok(const TDate& d, int month, int liqmonth, int
else // Nuova selezione dal 1998 in poi
{
if (month <= 12)
return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month));
{
if (_is_liq_acconto)
return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month)) && (d.day() <= _ver->giorno_acc());
else
return (regyear == year) && ((regmonth == month && liqmonth == 0) || (liqmonth == month));
}
else // Annuale, month == 13
return (regyear == year && liqmonth != 12) || (regyear == year + 1 && liqmonth == 12);
}

View File

@ -1440,6 +1440,9 @@ void TLiquidazione_app::set_firm(_DescrItem& d)
if (d._s2 == "T")
tim_title << format(FR(" del %d° Trimestre %s"), d._f1/3, (const char*) _year);
else
if (_is_liq_acconto)
tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year);
else
tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year);
}
@ -1501,6 +1504,9 @@ void TLiquidazione_app::set_att(_DescrItem& d)
if (d._s4 == "T")
tim_title << format(FR(" del %d° Trimestre %s"), d._f1 / 3, (const char*)_year);
else
if (_is_liq_acconto)
tim_title << format(FR(" al %d %s %s"), _ver->giorno_acc(), itom(d._f1), (const char*)_year);
else
tim_title << format(FR(" del mese di %s %s"), itom(d._f1), (const char*)_year);
}

View File

@ -158,18 +158,20 @@ BEGIN
GROUP 3
END
LISTBOX FINO_A_MESE 10
LISTBOX FINO_A_MESE 20
BEGIN
PROMPT 3 9 "Fino al mese "
HELP "Mese fino al quale eseguire la stampa"
ITEM "20|Acconto di dicembre"
FLAGS "M"
GROUP 1
END
LISTBOX MESE 10
LISTBOX MESE 20
BEGIN
PROMPT 3 9 "Mese "
HELP "Mese di cui eseguire la stampa"
ITEM "20|Acconto di dicembre"
FLAGS "M"
GROUP 2
END

View File

@ -125,6 +125,8 @@ void TRiepilogoIVA_app::main_loop()
recset->set_registrazioneIVAritardo(m.get_bool(F_REGRIT));
recset->set_from(m.get_date(F_DADATA));
recset->set_to(m.get_date(F_ADATA));
recset->set_annuale((m.get_date(F_DADATA).month() == 1) && (m.get_date(F_ADATA).month() == 12)
);
recset->set_from_conto(m.get_long(F_DAGRUPPO), m.get_long(F_DACONTO), m.get_long(F_DASOTTOC));
if (m.get_long(F_DAGRUPPO) != 0)

View File

@ -1,4 +1,16 @@
#include "cglib05.h"
#include <utility.h>
enum tiporeg {
vendita = 1,
acquisto = 2,
riepilogativo = 3,
incassi = 4,
giornale = 5,
sociale = 6,
cespiti = 7
};
///////////////////////////////////////////////////////////
// TRiepilogoIVA_recordset
///////////////////////////////////////////////////////////
@ -51,7 +63,7 @@ void TRiepilogoIVA_recordset::requery()
TAssoc_array work_array;
TString16 reg_fieldname; reg_fieldname << LF_MOV << "." << MOV_REG;
TString16 datareg_fieldname; datareg_fieldname << LF_MOV << "." << MOV_DATAREG;
TString16 datacomp_fieldname; datacomp_fieldname << LF_MOV << "." << MOV_MESELIQ;
TString16 datadoc_fieldname; datadoc_fieldname << LF_MOV << "." << MOV_DATADOC;
TString16 meseliq_fieldname; meseliq_fieldname << LF_MOV << "." << MOV_MESELIQ;
int p = wrk.find("FROMDATE");
@ -114,7 +126,19 @@ void TRiepilogoIVA_recordset::requery()
}
if (registrazioneIVAritardo())
{
TDate datacomp = recset.get(datacomp_fieldname).as_date();
const TDate datadoc = recset.get(datadoc_fieldname).as_date();
const TString4 codreg = recset.get(reg_fieldname).as_string();
const TRegistro reg(codreg);
const TipoIVA tipo = reg.iva(); // 1=Vendite; 2=Acquisti
const bool fatt_rit_2018 = recset.get(TOSTRING(LF_MOV) "." MOV_DATAREG).as_bool() && (data.year() >= 2018);
const int year_diff = data.year() - datadoc.year();
const bool fattritind = ((tipo == iva_acquisti) && fatt_rit_2018) &&
((year_diff > 2) || ((year_diff >= 1) && data.month() >= 5));
const bool fattrit = ((tipo == iva_acquisti) && !fattritind && fatt_rit_2018) && (year_diff >= 1);
if (fattrit && !annuale() && _to_date.year() == datadoc.year())
continue;
}
if (senzacompetenzaIVA() && (data < _from_date || data > _to_date))
continue;
@ -275,9 +299,9 @@ const TVariant& TRiepilogoIVA_recordset::get(unsigned int column) const
}
TRiepilogoIVA_recordset::TRiepilogoIVA_recordset() : TRecordset(), _pos(0), _from_date(botime), _to_date(eotime),
_from_gruppo(0), _from_conto(0), _from_sottoconto(0L),
_to_gruppo(999), _to_conto(999), _to_sottoconto(999999L),
_freezed(false)
_from_gruppo(0), _from_conto(0), _from_sottoconto(0L),
_to_gruppo(999), _to_conto(999), _to_sottoconto(999999L), _freezed(false), _annuale(false)
{
add_field(_alfafld, 101, 4, COD);
add_field(_alfafld, 102, 50, DESC);

View File

@ -32,6 +32,7 @@ class TRiepilogoIVA_recordset : public TRecordset
long _to_sottoconto;
TArray _info;
bool _freezed;
bool _annuale;
protected:
virtual const TVariant& get_field(int num, const char* field) const;
@ -59,9 +60,11 @@ public:
virtual bool set_senzacompetenzaIVA(bool on) { return true; }
virtual bool set_competenzadiversaIVA(bool on) { return false; }
virtual bool set_registrazioneIVAritardo(bool on) { return false; }
virtual bool senzacompetenzaIVA() { return true; }
virtual bool competenzadiversaIVA() { return false; }
virtual bool registrazioneIVAritardo() { return false; }
virtual bool set_annuale(bool on) { _annuale = on; return _annuale; }
virtual bool senzacompetenzaIVA() const { return true; }
virtual bool competenzadiversaIVA() const { return false; }
virtual bool registrazioneIVAritardo() const { return false; }
virtual bool annuale() const { return _annuale; }
TRiepilogoIVA_recordset();
virtual ~TRiepilogoIVA_recordset() { }

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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
View 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);
}

View File

@ -12,6 +12,12 @@ const TDate SSimple_query::sq_get_date(const char * field)
return app;
}
const real SSimple_query::sq_get_real(const char * field)
{
const real app(_rec.get(field));
return app;
}
TString SSimple_query::sq_get(const char* field, bool rtrim)
{
TString fld = _rec.get(field);
@ -21,7 +27,7 @@ TString SSimple_query::sq_get(const char* field, bool rtrim)
return fld;
}
TString SSimple_query::sq_get(string field, bool rtrim)
TString SSimple_query::sq_get(const string& field, const bool rtrim)
{
return sq_get(field.c_str(), rtrim);
}

View File

@ -74,48 +74,48 @@ public:
/**< Costruttore, non inizializza nulla, da caricare successivamente */
SSimple_query() = default;
/**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */
SSimple_query(const char* db, const char* user, const char* pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {}
//SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
/**< Distruttore */
virtual ~SSimple_query() = default;
// Connection functions
/**< Eseguo la connessione */
int sq_connect(const char* db, const char* user, const char* pass, TT_driver tipoDb) { return _rec.connect(db, user, pass, tipoDb); }
int sq_connect(const char* db, const char* user, const char* pass, const TT_driver tipo_db) { return _rec.connect(db, user, pass, tipo_db); }
/* Mi scollego */
void sq_disconnect() { _rec.disconnect(); }
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
const bool sq_commit(bool autoRoll = true) { return _rec.commit(); }
const bool sq_commit(const bool auto_roll = true) { return _rec.commit(auto_roll); }
/**< Esegue il rollback all'ultimo commit */
const bool sq_rollback() { return _rec.rollback(); }
/**< Imposto il tipo di client che utilizzo */
void sq_set_client(int client) { _rec.setClient((TT_driver)client); }
void sq_set_client(TT_driver client) { _rec.setClient(client); }
void sq_set_client(int client) { _rec.set_client(static_cast<TT_driver>(client)); }
void sq_set_client(const TT_driver client) { _rec.set_client(client); }
// Imposto una opzione generica dellla connessione
void sq_set_con_option(const char* opt) { _rec.setConOption(opt); }
void sq_set_con_option(const char* opt) { _rec.set_con_option(opt); }
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
void sq_set_autocommit(bool ac) { _rec.setAutocommit(ac); }
void sq_set_autocommit(const bool ac) { _rec.set_autocommit(ac); }
/** Imposta la visibilità delle transazioni (vedi Funzione) */
void sq_set_visibility(isoLvl vis = committed) { _rec.setVisibility(vis); }
void sq_set_visibility(const iso_lvl vis = committed) { _rec.set_visibility(vis); }
// Getters
/** Ritorna se la conessione è connessa */
const bool sq_is_connect() const { return _rec.isConnect(); }
const bool sq_is_connect() const { return _rec.is_connect(); }
/**< Ritorna se la connessione è attiva */
const bool sq_is_alive() const { return _rec.isAlive(); }
const bool sq_is_alive() const { return _rec.is_alive(); }
/** Ritorna la visibilità impostata */
const int sq_get_visibility() { return _rec.getVisibility(); }
const int sq_get_visibility() { return _rec.get_visibility(); }
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
const bool sq_get_autocommit() { return _rec.getAutocommit(); }
const bool sq_get_autocommit() { return _rec.get_autocommit(); }
/**< Ritorna il valore dell'opzione specificata */
const char* sq_get_option(const char* opt) { return _rec.getOption(opt); }
const char* sq_get_option(const char* opt) { return _rec.get_option(opt); }
/**< Ritorno la versione del Client che sto utilizzando */
const long sq_get_client_v() { return _rec.getClientV(); }
const long sq_get_client_v() { return _rec.get_client_v(); }
/**< Ritorno la versione del Server che sto utilizzando */
const char* sq_get_server_v() { return _rec.getServerV(); }
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
const long sq_get_server_vn() { return _rec.getServerVN(); }
const long sq_get_server_vn() { return _rec.get_server_vn(); }
/**< Ritorno se il recordset è carico */
const bool sq_is_loaded() const { return _rec.isLoaded(); }
const bool sq_is_loaded() const { return _rec.is_loaded(); }
/** Ritorno il numero di elementi nella query */
const long sq_items() { return _rec.items(); }
@ -123,17 +123,17 @@ public:
/**< Imposta la query ricevuta come (const char *) nel recordset */
const bool sq_set(const char* query) { return _rec.set(query); }
/**< Imposta la query ricevuta come (string) nel recordset */
const bool sq_set(string query) { return _rec.set(query.c_str()); }
const bool sq_set(const string& query) { return _rec.set(query.c_str()); }
/**< Imposta la query ricevuta come (TString) nel recordset */
const bool sq_set(TString& query) { return _rec.set(static_cast<const char *>(query)); }
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando sqNext() */
const bool sq_exec(bool autoF = true) { return _rec.exec(autoF); }
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (const char *) */
const bool sq_set_exec(const char* query, bool autoF = true) { _rec.set(query); return _rec.exec(autoF); }
const bool sq_set_exec(const char* query, const bool auto_f = true) { _rec.set(query); return _rec.exec(auto_f); }
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (string) */
const bool sq_set_exec(string query, bool autoF = true) { _rec.set(query.c_str()); return _rec.exec(autoF); }
const bool sq_set_exec(const string& query, const bool auto_f = true) { _rec.set(query.c_str()); return _rec.exec(auto_f); }
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (TString) */
const bool sq_set_exec(TString& query, bool autoF = true) { return sq_set_exec(static_cast<const char*>(query), autoF); }
const bool sq_set_exec(TString& query, const bool auto_f = true) { return sq_set_exec(static_cast<const char*>(query), auto_f); }
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
const bool sq_next() { return _rec.next(); }
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
@ -143,9 +143,9 @@ public:
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
const bool sq_last() { return _rec.last(); }
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
const bool sq_go(int newPos) { return _rec.go(newPos); }
const bool sq_go(const int new_pos) { return _rec.go(new_pos); }
/**< Ritorna il numero di righe affette dall'ultima query */
const int sq_rows_affected() { return _rec.rowsAffected(); }
const int sq_rows_affected() const { return _rec.rows_affected(); }
// Getters
@ -168,7 +168,7 @@ public:
/**< Ritorna il valore nel campo (field) passato come (const char *) in formato (const char *) */
TString sq_get(const char* field, bool rtrim = true);
/**< Ritorna il valore nel campo (field) passato come (string) in formato (const char *) */
TString sq_get(string field, bool rtrim = true);
TString sq_get(const string& field, bool rtrim = true);
/**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */
TString sq_get(TString& field, bool rtrim = true);
/**< Ritorna il valore nel campo (field) in formato (char) */
@ -178,11 +178,11 @@ public:
// Error Getters
/**< Ritorno l'ultimo codice errore segnalato in formato /int) */
const long sq_get_code_error(bool erase = true) { return _rec.get_code_error(erase); }
const long sq_get_code_error(const bool erase = true) { return _rec.get_code_error(erase); }
/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
const char* sq_get_string_error(bool erase = true) { return _rec.get_string_error(erase); }
const char* sq_get_string_error(const bool erase = true) { return _rec.get_string_error(erase); }
/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
const char* sq_get_text_error(bool erase = true) { return _rec.get_text_error(erase); }
const char* sq_get_text_error(const bool erase = true) { return _rec.get_text_error(erase); }
};
#endif

View File

@ -9,6 +9,7 @@
#define _CPY_STR(from,to) (to = strdup(from));
#define _GET_ERROR(from,to) _CPY_STR(from,to)
#define CHECK_FREEZED if (is_freezed()) { return set_error_freezed(); }
/******************************************************************************
* TXvt_recordset *
@ -84,7 +85,7 @@ const bool TXvt_recordset::checkPermission()
{
bool err = is_freezed();
if (err)
setErrorFreezed();
set_error_freezed();
return !err;
}
@ -94,7 +95,7 @@ const bool TXvt_recordset::checkPermission()
* Gestione Connection *
**************************************************************************************************/
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipoDb)
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipo_db)
{
if (_con != NULL)
{
@ -105,7 +106,7 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass,
SAString dbAddress = db;
SAString usr = user;
SAString psw = pass;
SAClient_t dbDriver = (SAClient_t)tipoDb;
SAClient_t dbDriver = (SAClient_t)tipo_db;
if (dbAddress.IsEmpty() || usr.IsEmpty())
{
_code_error = NOT_INITIALIZED;
@ -189,22 +190,22 @@ bool TXvt_recordset::rollback()
return true;
}
void TXvt_recordset::setClient(TT_driver client)
void TXvt_recordset::set_client(TT_driver client)
{
_CON(_con)->setClient((SAClient_t) client);
}
void TXvt_recordset::setConOption(const char* opt)
void TXvt_recordset::set_con_option(const char* opt)
{
_CON(_con)->setOption(opt);
}
void TXvt_recordset::setAutocommit(bool ac)
void TXvt_recordset::set_autocommit(bool ac)
{
_CON(_con)->setAutoCommit(ac ? SA_AutoCommitOn : SA_AutoCommitOff);
}
void TXvt_recordset::setVisibility(isoLvl vis)
void TXvt_recordset::set_visibility(iso_lvl vis)
{
/* La libreria attuale supporta diversi tipi di visibilità, per mantenere una compatibilità massima
* (evitando inutili seghe mentali) consiglio di usare i primi due, di default la classe imposta "Read committed"
@ -217,27 +218,27 @@ void TXvt_recordset::setVisibility(isoLvl vis)
_CON(_con)->setIsolationLevel((SAIsolationLevel_t)vis);
}
const bool TXvt_recordset::isConnect() const
const bool TXvt_recordset::is_connect() const
{
return _CON(_con)->isConnected();
}
const bool TXvt_recordset::isAlive() const
const bool TXvt_recordset::is_alive() const
{
return _CON(_con)->isAlive();
}
int TXvt_recordset::getVisibility()
int TXvt_recordset::get_visibility()
{
return (isoLvl)_CON(_con)->IsolationLevel();
return (iso_lvl)_CON(_con)->IsolationLevel();
}
bool TXvt_recordset::getAutocommit()
bool TXvt_recordset::get_autocommit()
{
return _CON(_con)->AutoCommit() == SA_AutoCommitOn;
}
const char* TXvt_recordset::getOption(const char* opt)
const char* TXvt_recordset::get_option(const char* opt)
{
return _CON(_con)->Option(opt);
}
long TXvt_recordset::getClientV()
long TXvt_recordset::get_client_v()
{
return _CON(_con)->ClientVersion();
}
@ -245,12 +246,12 @@ const char* TXvt_recordset::getServerV()
{
return _CON(_con)->ServerVersionString();
}
long TXvt_recordset::getServerVN()
long TXvt_recordset::get_server_vn()
{
return _CON(_con)->ServerVersion();
}
bool TXvt_recordset::isLoaded() const
bool TXvt_recordset::is_loaded() const
{
return _loaded;
}
@ -331,10 +332,10 @@ bool TXvt_recordset::exec(bool autoF)
return ok;
}
bool TXvt_recordset::setExec(const char* query, bool autoF)
bool TXvt_recordset::set_exec(const char* query, bool auto_f)
{
set(query);
return exec(autoF);
return exec(auto_f);
}
bool TXvt_recordset::next()
@ -426,18 +427,18 @@ bool TXvt_recordset::last()
return fetched;
}
bool TXvt_recordset::go(int newPos)
bool TXvt_recordset::go(int new_pos)
{
// Controllo che la nuova posizione non sia fuori dal limite inferiore (Non so quanto è grande il recordset)
bool result = newPos >= 0 ? true : false;
bool result = new_pos >= 0 ? true : false;
// Se la posizione è minore mi sposto indietro
while (newPos < _recno && result)
while (new_pos < _recno && result)
{
result = prev();
}
// Se la posizione è maggiore mi sposto in avanti
while (newPos > _recno && result)
while (new_pos > _recno && result)
{
result = next();
}
@ -451,7 +452,7 @@ bool TXvt_recordset::go(int newPos)
return result;
}
const int TXvt_recordset::rowsAffected()
const int TXvt_recordset::rows_affected() const
{
return _RCS(_recset)->RowsAffected();
}
@ -624,7 +625,7 @@ const char* TXvt_recordset::get_text_error(bool erase)
return app;
}
const bool TXvt_recordset::setErrorFreezed()
const bool TXvt_recordset::set_error_freezed()
{
_code_error = ERROR_FREEZED;
_string_error = _string_error_full_text = ERROR_FREEZEDS;

View File

@ -13,8 +13,6 @@
#define SQLAPIV "SQLAPI++ 4.1.5" // Da tenere aggiornato
#define CHECK_FREEZED if (is_freezed()) { return setErrorFreezed(); }
enum TT_driver
{
//! DBMS client is not specified
@ -45,7 +43,7 @@ enum TT_driver
TSDB_SQLAnywhere
};
enum isoLvl { unknown = -1, uncommitted, committed, rr, serializable };
enum iso_lvl { unknown = -1, uncommitted, committed, rr, serializable };
#define P_CONN_VOID void *
#define P_COMM_VOID void *
@ -113,7 +111,7 @@ public:
* pass = Angela
* driver = TSDB_MSSQL
*/
int connect(const char* db, const char* user, const char* pass, TT_driver tipoDb);
int connect(const char* db, const char* user, const char* pass, TT_driver tipo_db);
/* Mi scollego */
void disconnect();
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
@ -124,35 +122,35 @@ public:
// Setters
/**< Imposto il tipo di client che utilizzo */
void setClient(TT_driver client);
void set_client(TT_driver client);
// Imposto una opzione generica dellla connessione
void setConOption(const char* opt);
void set_con_option(const char* opt);
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
void setAutocommit(bool ac);
/** Imposta la visibilità delle transazioni (vedi Funzione) */
void setVisibility(isoLvl vis = committed);
void set_autocommit(bool ac);
/**< Imposta la visibilità delle transazioni (vedi Funzione) */
void set_visibility(iso_lvl vis = committed);
// Getters
/** Ritorna se la conessione è connessa */
const bool isConnect() const;
/**< Ritorna se la conessione è connessa */
const bool is_connect() const;
/**< Ritorna se la connessione è attiva */
const bool isAlive() const;
/** Ritorna la visibilità impostata */
int getVisibility();
const bool is_alive() const;
/**< Ritorna la visibilità impostata */
int get_visibility();
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
bool getAutocommit();
bool get_autocommit();
/**< Ritorna il valore dell'opzione specificata */
const char* getOption(const char* opt);
const char* get_option(const char* opt);
/**< Ritorno la versione del Client che sto utilizzando */
long getClientV();
long get_client_v();
/**< Ritorno la versione del Server che sto utilizzando */
const char* getServerV();
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
long getServerVN();
long get_server_vn();
/**< Ritorno se il recordset è carico */
bool isLoaded() const;
/** Ritorno il numero di elementi nella query */
bool is_loaded() const;
/**< Ritorno il numero di elementi nella query */
long items();
/**************************************************************************************************
@ -165,7 +163,7 @@ public:
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando Next() */
bool exec(bool autoF = true);
/**< Unisce le funzioni Set e Exec, riceve la query */
bool setExec(const char* query, bool autoF = true);
bool set_exec(const char* query, bool auto_f = true);
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
bool next();
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
@ -175,9 +173,9 @@ public:
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
bool last();
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
bool go(int newPos);
bool go(int new_pos);
/**< Ritorna il numero di righe affette dall'ultima query */
const int rowsAffected();
const int rows_affected() const;
// Getters
/**< Ritorna il valore nel campo (field) in formato (int) */
@ -223,7 +221,7 @@ public:
bool frozen() const { return is_freezed(); }
bool not_frozen() const { return !is_freezed(); }
/**< Imposta l'errore di record congelato */
const bool setErrorFreezed();
const bool set_error_freezed();
};