Patch level : 4.0 911

Files correlati     :
Ricompilazione Demo : [ ]
Commento           :

Riportata la versione 3.2 1010


git-svn-id: svn://10.65.10.50/trunk@16377 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2008-03-26 12:38:22 +00:00
parent 1ae6a4b21f
commit c13654bc84
4 changed files with 311 additions and 156 deletions

View File

@ -24,7 +24,7 @@ TCursor& TMotore_application::get_filtered_cursor() const
bool TMotore_application::save_and_new() const
{
TDocumento_mask & m = *_docmsk;
TDocumento_mask & m = edit_mask();
bool new_doc = false;
if (m.insert_mode())
@ -32,7 +32,7 @@ bool TMotore_application::save_and_new() const
TDocumento & doc = m.doc();
new_doc = doc.codice_numerazione().save_and_new();
if (new_doc && doc.tipo().printable() && yesno_box("Devo stampare il documento"))
if (new_doc && doc.tipo().printable() && yesno_box(TR("Si desidera stampare il documento")))
{
const char s[2] = { doc.tipo().stato_finale_stampa(), '\0' };
@ -91,7 +91,7 @@ void TMotore_application::init_insert_mode( TMask& m )
curdo.read(provv, anno, codnum, numdoc);
curdo.set_tipo(m.get(F_TIPODOC));
const TTipo_documento& tp = (const TTipo_documento&)curdo.tipo();
const TTipo_documento& tp = curdo.tipo();
const char stato = tp.stato_finale_inserimento();
curdo.stato(stato);
@ -108,21 +108,14 @@ void TMotore_application::init_insert_mode( TMask& m )
char str_stato[2] = { stato, '\0' };
m.set(F_STATO, str_stato);
TLocalisamfile doc(LF_DOC);
TDate data_doc(TODAY);
doc.curr() = curdo.head();
if (!m.field(F_DATADOC).automagic())
const magic_datadoc = m.field(F_DATADOC).automagic();
if (!magic_datadoc)
{
doc.read(_isgteq);
if (doc.eof() || doc.prev() == NOERR)
{
if (doc.curr().same_key(curdo.head(), 1, 1))
data_doc = doc.get_date(DOC_DATADOC);
}
long ndoc = 0; // unused
last_doc(provv, anno, codnum, ndoc, data_doc);
}
m.set(F_DATADOC, data_doc);
m.set(F_DATADOC, data_doc, 0x1);
int pos = m.id2pos( F_DATACAMBIO1);
if (pos >= 0 && m.fld(pos).active() && !m.get(F_CODVAL).empty())
@ -130,7 +123,7 @@ void TMotore_application::init_insert_mode( TMask& m )
m.fld(pos).set(data_doc);
m.fld(pos).dirty();
}
m.disable(DLG_PRINT);
pos = m.id2pos(F_CAUSMAG);
if (pos >= 0)
@ -141,6 +134,7 @@ void TMotore_application::init_insert_mode( TMask& m )
tp.set_defaults(m);
m.disable(DLG_PRINT);
m.disable(DLG_ELABORA);
if (curdo.tipo().auto_add())
@ -243,32 +237,56 @@ TMask* TMotore_application::get_mask( int mode )
return _docmsk;
}
// Cerca numero e data dell'ultimo documento di una numerazione di un anno
bool TMotore_application::last_doc(char provv, int anno, const char* codnum,
long& ndoc, TDate& ddoc) const
{
TRelation rel(LF_DOC);
TRectype& curr = rel.curr();
curr.put(DOC_PROVV, provv);
curr.put(DOC_ANNO, anno);
TString cod(codnum); cod.left_just(4, '~');
curr.put(DOC_CODNUM, cod);
TCursor cur(&rel, "", 1, &curr, &curr);
TRecnotype docs = cur.items();
bool found = docs > 0;
if (found)
{
cur = docs-1;
ndoc = curr.get_long(DOC_NDOC);
ddoc = curr.get_date(DOC_DATADOC);
}
else
{
ndoc = 0;
const TDate oggi(TODAY);
if (anno < oggi.year())
ddoc = TDate(31, 12, anno);
else
ddoc = oggi;
}
return found;
}
const char* TMotore_application::get_next_key( )
{
TMask& m = curr_mask( );
TCodice_numerazione cod_num(m.get(F_CODNUM));
const TMask& m = curr_mask( );
const TCodice_numerazione cod_num(m.get(F_CODNUM));
// Se per questa numerazione h abilitata le numerazione automatica
if( cod_num.auto_num())
// Se per questa numerazione e' abilitata le numerazione automatica
if (cod_num.auto_num())
{
TLocalisamfile doc(LF_DOC);
doc.zero();
doc.put("CODNUM", cod_num.codice());
doc.put("ANNO", m.get(F_ANNO));
doc.put("PROVV", m.get(F_PROVV));
TRectype cmp_rec(doc.curr()); // record campione
doc.put( "NDOC", 9999999L );
if (doc.read(_isgreat) == NOERR)
doc.prev();
TDate ddoc; // unused
long ndoc = 1;
if (last_doc(m.get(F_PROVV)[0], m.get_int(F_ANNO), cod_num.codice(), ndoc, ddoc))
ndoc++;
else
doc.last();
const long num = ((doc.curr() == cmp_rec) ? doc.get_long( "NDOC" ) : 0) + 1;
return (format( "%d|%ld", F_NDOC, num));
ndoc = 1;
return format("%d|%ld", F_NDOC, ndoc);
}
return "";
}

View File

@ -74,12 +74,15 @@ protected:
// caricamento Inifile
virtual void sheet2ini(TSheet_field& s, TConfig& ini);
virtual void ini2mask(TConfig& ini, TMask& m, bool query);
bool last_doc(char provv, int anno, const char* codnum, long& ndoc, TDate& datadoc) const;
public:
virtual TRelation* get_relation( ) const { return _rel;}
// Funzioni di accesso alle variabili private
TMask & query_mask() { CHECK( _msk, "Maschera di ricerca nulla!" ); return *_msk; }
virtual TMask & query_mask() { CHECK( _msk, "Maschera di ricerca nulla!" ); return *_msk; }
virtual TDocumento_mask & edit_mask() const { CHECK( _docmsk, "Maschera di edit nulla!" ); return *_docmsk; }
TRelation & rel() { CHECK( _rel, "Relazione nulla!" ); return *_rel; }
TSheet_field & sheet() { return edit_mask().sheet(); }

View File

@ -3,10 +3,12 @@
#include <applicat.h>
#include <automask.h>
#include <defmask.h>
#include <modaut.h>
#include <postman.h>
#include <progind.h>
#include <reprint.h>
#include <reputils.h>
#include <statbar.h>
#include <clifo.h>
@ -99,31 +101,83 @@ const TVariant& TDoc_recordset::get_field(int logic, const char* field) const
return TISAM_recordset::get_field(logic, field);
}
TDoc_recordset::TDoc_recordset(const TRecordset& doc, const TString& query)
: TISAM_recordset(query), _doc(NULL), _mypos(-1)
static TString _sortexpr;
static int compare_rdocs(const TObject** p1, const TObject** p2)
{
const TRectype& r1 = *(const TRectype*)(*p1);
const TRectype& r2 = *(const TRectype*)(*p2);
const TString& c1 = r1.get(_sortexpr);
const TString& c2 = r2.get(_sortexpr);
return c1.compare(c2);
}
TDoc_recordset::TDoc_recordset(const TRecordset& doc, const TString& old_query)
: TISAM_recordset(old_query), _doc(NULL), _mypos(-1)
{
TRectype curr(LF_DOC);
TString new_query = query;
const int acapo = query.find('\n')+1;
TToken_string query(old_query, '\n');
TToken_string new_query("", '\n');
TString line;
_sortexpr.cut(0);
FOR_EACH_TOKEN(query, tok)
{
line = tok;
line.trim();
if (line.starts_with("SORT "))
{
const int pos = line.find("BY ");
if (pos > 0)
{
_sortexpr = line.mid(pos + 3);
_sortexpr.trim();
if (_sortexpr.starts_with("34."))
_sortexpr.ltrim(3);
if (_sortexpr.starts_with("RDOC."))
_sortexpr.ltrim(5);
}
line = query.get();
line.trim();
if (line.starts_with("JOIN TO"))
line.insert("34 ", 5);
new_query.add(line);
continue;
}
if (line.starts_with("USE "))
{
new_query.add(line);
for (int i = 0; i < 2; i++)
{
const char* key[] = { DOC_PROVV, DOC_ANNO, DOC_CODNUM, DOC_NDOC };
TString80 filter = (i == 0) ? "FROM " : "TO ";
line = (i == 0) ? "FROM " : "TO ";
for (int k = 0; k < 4; k++)
{
const TString& val = doc.get(key[k]).as_string();
filter << key[k] << "='" << val << "' ";
line << key[k] << "='" << val << "' ";
if (i == 0)
curr.put(key[k], val);
}
filter << '\n';
new_query.insert(filter, acapo);
new_query.add(line);
}
continue;
}
new_query.add(line);
}
set(new_query);
_doc = new TDocumentoEsteso(curr);
if (_sortexpr.full())
{
TRecord_array& rows = _doc->body();
rows.sort(compare_rdocs);
}
const bool has_conai = (_doc->tipo().add_conai() && _doc->clifor().vendite().get_bool(CFV_CONAIASS));
if (has_conai || _doc->rows() == 0)
{
@ -179,7 +233,7 @@ protected:
int set_printed_status(TDocumento& doc) const;
public:
bool print(const TRecordset& doc, TReport_book& book, bool def, int copies, bool alleg, bool arc);
bool print(const TRecordset& doc, TReport_book& book, bool def, word copies, bool alleg, bool arc);
TReport_doc(const char* name);
virtual ~TReport_doc();
@ -235,7 +289,7 @@ int TReport_doc::set_printed_status(TDocumento& doc) const
return err;
}
bool TReport_doc::print(const TRecordset& doc, TReport_book& book, bool definitive, int copie, bool can_allegate, bool arc)
bool TReport_doc::print(const TRecordset& doc, TReport_book& book, bool definitive, word copie, bool can_allegate, bool arc)
{
const TString old_query = recordset()->query_text();
@ -246,6 +300,7 @@ bool TReport_doc::print(const TRecordset& doc, TReport_book& book, bool definiti
for (int c = 1; c <= copie; c++)
{
set_copy(c, copie);
// Tenta di stampare gli allegati solo sull'ultima copia definitiva
if (c == copie && can_allegate)
{
@ -749,6 +804,7 @@ bool TReport_doc_mask::on_field_event(TOperable_field& o, TField_event e, long j
TReport_doc_mask::TReport_doc_mask() : TAutomask("ve1100a")
{
hide(F_PROVV);
show(DLG_EMAIL);
}
///////////////////////////////////////////////////////////
@ -783,16 +839,18 @@ class TReport_doc_app : public TSkeleton_application
int _anno;
TString4 _codnum;
long _ndoc, _codcf;
char _tipocf;
protected:
void add_data_filter(TString& query, bool from) const;
void add_ndoc_filter(TString& query, bool from) const;
void add_filter(TString& str, bool from) const;
bool print_loop(const TString& query);
void print_selection();
bool print_loop(const TString& query, bool send_by_mail);
void print_selection(bool send_by_mail = false);
void set_next_pdf(int an, const char* cn, long nd, long cf);
void set_next_pdf(int an, const char* cn, long nd, char tcf, long cf);
virtual bool get_next_pdf(int anno, long ditta, const char* codnum, long numdoc, long codcf, TFilename& pdf) const;
const TString & get_mail_address() const;
virtual bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
TString& subj, TString& text, TToken_string& attach, bool& ui) const ;
@ -802,11 +860,12 @@ public:
virtual bool destroy();
};
void TReport_doc_app::set_next_pdf(int an, const char* cn, long nd, long cf)
void TReport_doc_app::set_next_pdf(int an, const char* cn, long nd, char tcf, long cf)
{
_anno = an;
_codnum = cn;
_ndoc = nd;
_tipocf = tcf;
_codcf = cf;
}
@ -818,16 +877,31 @@ bool TReport_doc_app::get_next_pdf(int anno, long ditta, const char* codnum, lon
return ok;
}
const TString & TReport_doc_app::get_mail_address() const
{
TString key;
key << _tipocf << '|' << _codcf;
return cache().get(LF_CLIFO, key, CLI_DOCMAIL);
}
bool TReport_doc_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
TString& subj, TString& text, TToken_string& attach, bool& ui) const
{
const bool ok = TApplication::get_next_mail(to, cc, ccn, subj, text, attach, ui);
bool ok = TApplication::get_next_mail(to, cc, ccn, subj, text, attach, ui);
if (_ndoc > 0L)
{
to = get_mail_address();
ok = to.full();
if (ok)
{
TDocumento doc('D', _anno, _codnum, _ndoc);
to = doc.clifor().get(CLI_MAIL);
doc.riferimento(subj);
if (subj.blank())
subj = doc.tipo().descrizione();
text << "Invio documento " << subj;
}
}
return ok;
}
@ -880,7 +954,7 @@ bool TReport_doc_app::destroy()
return TSkeleton_application::destroy();
}
bool TReport_doc_app::print_loop(const TString& query)
bool TReport_doc_app::print_loop(const TString& query, bool send_by_mail)
{
TISAM_recordset doc(query);
const int docs = doc.items();
@ -900,8 +974,10 @@ bool TReport_doc_app::print_loop(const TString& query)
TReports_cache reports; // Cache degli ultimi reports usati
TDoc_book book; // Destinazione dell'intera stampa
TDoc_book * mail_book = NULL; // Destinazione dell'intera stampa
TLog_report log("Invio documenti per email");
TProgind pi(docs, TR("Elaborazione documenti..."), true, true);
for (int i = 0; i < docs; i++)
{
if (!pi.addstatus(1))
@ -914,62 +990,56 @@ bool TReport_doc_app::print_loop(const TString& query)
{
const TString& codnum = doc.get(DOC_CODNUM).as_string();
arc = cache().get("%NUM", codnum, "B6").full();
if (arc)
{
set_next_pdf(doc.get(DOC_ANNO).as_int(),
doc.get(DOC_CODNUM).as_string(),
doc.get(DOC_NDOC).as_int(),
doc.get(DOC_CODCF).as_int());
}
}
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 TString& tipodoc = doc.get(DOC_TIPODOC).as_string();
const TTipo_documento& tipo = _tipi_cache.tipo(tipodoc);
TFilename profilo;
if (tipo.main_print_profile(profilo))
const TString8 codprof(tipo.main_print_profile());
const bool send_mail = send_by_mail && get_mail_address().full();
if (codprof.full())
{
int copies = _msk->get_int(F_NCOPIE);
if (copies <= 0 && is_definitive)
copies = tipo.ncopie();
if (copies <= 0)
copies = 1;
TFilename profilo(codprof); profilo.ext("rep");
TReport_doc& report = reports.get(profilo);
if (!report.print(doc, book, is_definitive, copies, true, arc))
break;
if (profilo.custom_path()) // Tenta di costruirsi il nome del report
{
int 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, arc))
break;
TString mesg(TDocumento::tipo(doc.get(DOC_TIPODOC).as_string()).descrizione());
mesg << " n. " << doc.get(DOC_NDOC).as_int() << " a " << get_mail_address();
log.log(0, mesg);
}
else
if (!report.print(doc, book, is_definitive, copies, true, arc))
break;
}
else
{
TString msg; msg << TR("Report inesistente") << " : " << profilo;
TString msg; msg << TR("Report inesistente") << " : " << codprof;
statbar_set_title(TASK_WIN, msg);
beep(2);
beep(2);
continue;
}
}
// Stampa eventuali allegati
if (tipo.additional_print_profile(profilo))
{
int copies = tipo.additional_ncopie();
if (copies <= 0) copies = 1;
TReport_doc& allegato = reports.get(profilo);
// Il flag di definitvo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
allegato.print(doc, book, false, copies, false, arc);
}
else
{
TString msg; msg << TR("Report allegato inesistente") << " : " << profilo;
statbar_set_title(TASK_WIN, msg);
}
// Stampa eventuali allegati
TFilename codalleg;
tipo.additional_print_profile(codalleg);
codalleg.trim();
const TString8 codalleg = tipo.additional_print_profile();
if (codalleg.full())
{
TFilename profilo(codalleg); profilo.ext("rep");
@ -983,6 +1053,9 @@ bool TReport_doc_app::print_loop(const TString& query)
// Cambio _codnum per non sovrascrivere il pdf precedente
if (arc) _codnum = codalleg;
// Il flag di definitvo deve essere false altrimenti riaggiorna lo stato e ristampa i documenti allegati
if (send_mail)
allegato.print(doc, *mail_book, false, 1, false, arc);
else
allegato.print(doc, book, false, copies, false, arc);
}
else
@ -991,24 +1064,41 @@ bool TReport_doc_app::print_loop(const TString& query)
statbar_set_title(TASK_WIN, msg);
}
}
if (mail_book != NULL)
{
if (mail_book->pages() > 0)
{
TFilename attachment;
attachment.tempdir();
attachment << SLASH << _anno <<'_' << _codnum << '_' << _ndoc;
attachment.ext("pdf");
mail_book->send_mail(attachment);
remove(attachment);
}
delete mail_book;
mail_book = NULL;
}
}
if (book.pages() > 0)
{
set_next_pdf(0, "", 0L, 0L); // Disabilita archiviazione PDF
if (docs > 1)
set_next_pdf(0, "", 0L, ' ', 0L); // Disabilita archiviazione PDF
book.add(log);
book.print_or_preview();
}
return true;
}
void TReport_doc_app::print_selection()
void TReport_doc_app::print_selection(bool send_by_mail)
{
TString query;
query << "USE " << LF_DOC;
add_filter(query, true);
add_filter(query, false);
print_loop(query);
print_loop(query, send_by_mail);
}
void TReport_doc_app::main_loop()
@ -1028,8 +1118,10 @@ void TReport_doc_app::main_loop()
}
else
{
while (_msk->run() == K_ENTER) // Stampa interattiva
print_selection();
KEY k;
while ((k = _msk->run()) != K_QUIT) // Stampa interattiva
print_selection(k != K_ENTER);
}
}
@ -1038,4 +1130,4 @@ int ve1300(int argc, char* argv[])
TReport_doc_app a;
a.run(argc, argv, TR("Stampa documenti"));
return (0);
}
}

View File

@ -24,8 +24,10 @@
#include "veuml.h"
#include "veuml1.h"
#include "veini.h"
#include "sconti.h"
#include "rcondv.h"
#include <occas.h>
class TOriginal_row_mask : public TAutomask
{
@ -257,7 +259,7 @@ TDocumento_mask::TDocumento_mask(const char* td)
if (pos >= 0)
fld(pos).show(has_movmag);
for (i = fields() - 1; i >= 0; i--)
FOR_EACH_MASK_FIELD((*this), j, f)
{
const TMask_field& f = fld(i);
@ -601,7 +603,8 @@ bool TDocumento_mask::on_key(KEY key)
{
TRelation r(LF_DOC);
r.curr()=doc();
if (!doc().bloccato() && ::user_can_write(&r))
bool can_save = !doc().bloccato() && !doc().chiuso();
if (can_save && ::user_can_write(&r))
{
TMask_field& stato = field(F_STATO);
stato.enable();
@ -1296,7 +1299,7 @@ bool TDocumento_mask::ss_handler(TMask_field& f, KEY key)
if (key == K_ENTER && f.mask().insert_mode())
{
TSheet_field& ss = (TSheet_field&)f;
if (!app().is_transaction() && ss.items() == 0)
if (!app().is_transaction() && ss.empty()
ok = yesno_box("Il documento e' privo di righe:\n"
"Si desidera continuare ugualmente?");
}
@ -1336,11 +1339,11 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
if (riga.is_omaggio() && riga.is_generata())
{
ss.destroy(r + 1);
doc.destroy_row(r + 1, TRUE);
doc.destroy_row(r + 1, true);
}
}
doc.dirty_fields();
if (m.is_calculated_page(m.curr_page()))
if (m.is_calculated_page(ss.page()))
m.update_progs();
}
break;
@ -1359,6 +1362,7 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
m.send_key(K_CTRL + '+', 0);
if (!enabled) ss.disable_row(r);
ss.force_update(r);
return false;
}
}
doc.insert_row(r + 1, m.get( F_LBTIPORIGA ));
@ -1368,7 +1372,7 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
{
TRiga_documento & riga = doc[r + 1];
TRectype & ven_rec = doc.clifor().vendite();
TString16 s(ven_rec.get(CFV_CODMAG));
TString8 s(ven_rec.get(CFV_CODMAG));
const TTipo_riga_documento & t = riga.tipo();
if (s.full())
@ -1382,7 +1386,7 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
if (s.full())
{
const TRectype & c=cache().get("%CAU", s);
if (!c.empty() && !c.get("S10").blank())
if (!c.empty() && c.get_char("S10") > ' ') // Ignora magazzini non validi
s = c.get("S10");
else
{
@ -1392,7 +1396,8 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
}
}
}
riga.put("CODMAG", s);
if (s.full())
riga.put("CODMAG", s);
riga.autoload(ss);
ss.check_row(r);
t.set_defaults(ss, r + 1);
@ -1437,23 +1442,34 @@ TMask* TDocumento_mask::ss_getmask(int numriga, TMask& fullmask)
bool TDocumento_mask::occas_code_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
{
const char* code = f.get();
if (*code)
{
TRelation occas(LF_OCCAS);
occas.lfile().put("CFPI", code);
if (occas.read(_isequal) == NOERR)
{
TMask& m = f.mask();
m.autoload(occas);
m.send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
m.send_key(K_TAB, O_COMUNENAS);
}
}
}
return TRUE;
TMask& m = f.mask();
if (key == K_TAB && (f.dirty() || !m.is_running()))
{
const TString& code = f.get();
if (code.full())
{
TRelation occas(LF_OCCAS);
occas.curr().put(OCC_CFPI, code);
if (occas.read(_isequal) == NOERR)
{
m.autoload(occas);
m.send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
m.send_key(K_TAB, O_COMUNENAS);
}
}
}
return true;
}
bool TDocumento_mask::occas_cfpi_handler(TMask_field& f, KEY key)
{
if (key == K_ENTER)
{
const TMask& om = f.mask();
if (om.field(O_COFI).empty() && om.field(O_PAIV).empty())
return f.error_box(TR("E' necessario specificare il codice fiscale o la partita IVA"));
}
return true;
}
bool TDocumento_mask::occas_handler( TMask_field& f, KEY key )
@ -1463,6 +1479,11 @@ bool TDocumento_mask::occas_handler( TMask_field& f, KEY key )
{
TDocumento& doc = m.doc();
TOccasionale& occ = doc.occas();
TMask occas_mask("ve0100o");
occas_mask.set_handler(O_CODICE, occas_code_handler );
occas_mask.set_handler(O_COFI, occas_cfpi_handler );
occas_mask.set_handler(O_PAIV, occas_cfpi_handler );
TMask occas_mask("ve0100o");
occas_mask.set_handler( O_CODICE, occas_code_handler );
@ -1528,16 +1549,15 @@ bool TDocumento_mask::clifo_handler( TMask_field& f, KEY key )
}
}
if (cli_for.occasionale())
{
TOccasionale& occas = d.occas();
if(m.id2pos(F_OCCASEDIT) > 0 && f.to_check(key) && *(occas.codice()) == '\0')
m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
}
else
d.zero(DOC_OCFPI);
}
if (cli_for.occasionale())
{
const TOccasionale& occas = d.occas();
if(m.id2pos(F_OCCASEDIT) > 0 && f.to_check(key) && occas.codice().blank())
m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
}
else
d.zero(DOC_OCFPI);
}
return true;
}
@ -1629,7 +1649,7 @@ int TLista_elaborazioni::select(TString_array & result, const char * tipo_inizia
result.destroy();
for (TElaborazione * el = (TElaborazione *)_elab->get(); el ; el = (TElaborazione *) _elab->get())
{
bool ok = FALSE;
bool ok = false;
TString ti;
if ((tipo_iniziale && *tipo_iniziale) && (stato_iniziale && *stato_iniziale))
for (int i = 0; !ok && i < TElaborazione::_max_tipi_doc_elab; i++)
@ -1640,7 +1660,7 @@ int TLista_elaborazioni::select(TString_array & result, const char * tipo_inizia
si == *stato_iniziale;
}
else
ok = TRUE;
ok = true;
if ((tipo_finale && *tipo_finale) && (stato_finale && *stato_finale))
ok &= el->tipo_finale() == tipo_finale &&
el->stato_finale() == stato_finale;
@ -2103,12 +2123,12 @@ void TDocument_tree::set_cursor(char tipocf, long codcf, int anno, const char* f
rec.put(DOC_CODCF, codcf);
rec.put(DOC_PROVV, "D");
rec.put(DOC_ANNO, anno);
_cursor->freeze(FALSE);
_cursor->freeze(false);
_cursor->setfilter(""); // Force cursor rebuild
_cursor->setfilter(filter);
_cursor->setregion(rec, rec);
const long items = _cursor->items();
_cursor->freeze(TRUE);
_cursor->freeze(true);
goto_root();
if (items <= 3)
@ -2503,7 +2523,28 @@ bool TElabora_mask::elabora()
{
TDocumento* d = new TDocumento(provv, anno, codnum, ndoc);
in.add(d);
if (numdoc <= 0)
{
TDocumento::copy_data(d.head(), app_doc.head());
d.put(DOC_TIPODOC, get(F_TIPODOC_ELAB));
d.put(DOC_STATO, get(F_STATODOC_ELAB));
const TDate datadoc = d.get_date(DOC_DATADOC);
const TDate datainsc = d.get_date(DOC_DATAINSC);
const bool equal = !datainsc.ok() || datadoc == datainsc;
d.put(DOC_DATADOC, get(F_DATADOC_ELAB));
if (equal)
d.zero(DOC_DATAINSC);
const TTipo_documento & t = d.tipo();
if (t.mov_mag())
d.put(DOC_CAUSMAG, t.caus_mov());
else
d.zero(DOC_CAUSMAG);
}
in.add(d);
}
if (update_header)
{
@ -2793,6 +2834,11 @@ void TElabora_mask::update_ndoc_filter(bool is_tipo_elaborazione)
header << " Quantità";
tf.set_header(header);
if (aggiungi_doc_att && _art_filter.full())
_tree.set_cursor(get(F_TIPOCF_ELAB)[0], get_long(F_CODCF_ELAB), get_int(F_ANNO_ELAB), filter, article_filter);
else
_tree.set_cursor(get(F_TIPOCF_ELAB)[0], get_long(F_CODCF_ELAB), get_int(F_ANNO_ELAB), filter);
if (aggiungi_doc_att) // GF20059
{
TCursor& cur = *_tree.get_cursor();
@ -2994,21 +3040,17 @@ bool TDocumento_mask::call_handler( TMask_field& f, KEY key)
bool TDocumento_mask::universal_handler( TMask_field& f, KEY key)
{
TDocumento_mask & m = (TDocumento_mask &)f.mask();
static int last_page = -1;
static bool calculated = false;
TDocumento_mask& m = (TDocumento_mask&)f.mask();
bool ok = m.call_handler(f, key);
if (ok && key == K_TAB && f.focusdirty())
{
const int page = m.curr_page();
if (last_page != page)
{
calculated = m.is_calculated_page(page);
last_page = page;
}
if (calculated)
const TFieldref* fr = f.field();
if (fr != NULL && (fr->file() == 0 || fr->file() == LF_DOC))
fr->write(f.get(), m.doc());
const int page = f.page();
if (m.is_calculated_page(page))
m.update_progs();
}
@ -3079,11 +3121,11 @@ bool TDocumento_mask::tip_handler( TMask_field& f, KEY key )
{
const TString16 curtipo(cod_num.tipo_doc(i));
if (curtipo == tipo)
return TRUE;
return true;
}
return f.error_box( "Tipo non valido per la numerazione selezionata!" );
}
return TRUE;
return true;
}
bool TDocumento_mask::codlist_handler( TMask_field& f, KEY key )
@ -3108,7 +3150,7 @@ bool TDocumento_mask::codlist_handler( TMask_field& f, KEY key )
}
}
}
return TRUE;
return true;
}
bool TDocumento_mask::codcont_handler( TMask_field& f, KEY key )