150972f6e5
git-svn-id: svn://10.65.10.50/branches/R_10_00@23175 c028cbd2-c16b-5b4b-a496-9718f37d4682
1261 lines
34 KiB
C++
Executable File
1261 lines
34 KiB
C++
Executable File
#include <colmask.h>
|
||
#include <dongle.h>
|
||
#include <execp.h>
|
||
#include <modaut.h>
|
||
#include <recset.h>
|
||
#include <tabutil.h>
|
||
#include <utility.h>
|
||
#include <urldefid.h>
|
||
|
||
#include "ve0100.h"
|
||
#include "veini.h"
|
||
|
||
#include "vepriv.h"
|
||
#include "veuml1.h"
|
||
#include "verig.h"
|
||
#include "velib04.h"
|
||
#include "../mg/mglib.h"
|
||
|
||
#include "sconti.h"
|
||
#include <occas.h>
|
||
|
||
TCursor& TMotore_application::get_filtered_cursor() const
|
||
{
|
||
const TEdit_field& f = _msk->efield(F_NDOC);
|
||
return *f.browse()->cursor();
|
||
}
|
||
|
||
bool TMotore_application::can_I_write(const TRelation* rel) const
|
||
{
|
||
/*
|
||
static int err = -1;
|
||
if (err < 0)
|
||
{
|
||
Tdninst dninst;
|
||
err = dninst.check_customer();
|
||
if (err != 0)
|
||
{
|
||
TString html;
|
||
html << "<html><body>"
|
||
<< "<h5>Attenzione: chiave " << dongle().number() << " non riconosciuta.</h5>\n"
|
||
<< "<p align=justify>Al fine di poter riattivare la chiave <b>" << dongle().product().before(" ")
|
||
<< "</b> in oggetto e poter quindi effettuare registrazioni, "
|
||
<< "La preghiamo di contattare Sirio informatica e sistemi ai seguenti riferimenti:</p><br/>"
|
||
<< "<ul><li>Sara Coppini, segreteria commerciale: <br />"
|
||
<< "<a href=mailto:scoppini@sirio-is.it>scoppini@sirio-is.it</a> Tel. 348-9897249</li>"
|
||
<< "<li>Morena Martini, responsabile commerciale canale: <br />"
|
||
<< "<a href=mailto:mmartini@sirio-is.it>mmartini@sirio-is.it</a> Tel. 349-3421433</li></ul>"
|
||
<< "</body></html>";
|
||
warning_box(html);
|
||
}
|
||
}
|
||
|
||
bool yes = TRelation_application::can_I_write(rel);
|
||
if (yes && err > 0)
|
||
{
|
||
yes = rel != NULL && ((TDocumento&)_rel->curr()).physical_rows() > 0; // Posso registrare ma non inserire
|
||
}
|
||
|
||
return yes;
|
||
*/
|
||
return TRelation_application::can_I_write(rel);
|
||
}
|
||
|
||
|
||
bool TMotore_application::save_and_new() const
|
||
{
|
||
bool new_doc = false;
|
||
|
||
TDocumento_mask& m = edit_mask();
|
||
if (m.insert_mode())
|
||
{
|
||
TDocumento& doc = m.doc();
|
||
new_doc = doc.codice_numerazione().save_and_new();
|
||
}
|
||
|
||
return new_doc;
|
||
}
|
||
|
||
void TMotore_application::init_query_mode( TMask& m )
|
||
{
|
||
disable_menu_item(M_FILE_PRINT);
|
||
disable_menu_item(M_FILE_PREVIEW);
|
||
disable_menu_item(MENU_ITEM_ID(1));
|
||
|
||
TEdit_field& cn = _msk->efield(F_CODNUM);
|
||
|
||
if (!lnflag() && cn.empty() && _codnum.full())
|
||
{
|
||
cn.set(_codnum);
|
||
if (_msk->field(F_TIPODOC).empty() && _tipodoc.full())
|
||
{
|
||
cn.set_focusdirty(TRUE);
|
||
cn.on_key(K_TAB);
|
||
cn.set_dirty(FALSE);
|
||
_msk->set(F_TIPODOC, _tipodoc, 1);
|
||
}
|
||
}
|
||
|
||
TEdit_field& n = m.efield(F_NDOC);
|
||
if (!n.empty())
|
||
{
|
||
if (find(0))
|
||
modify_mode();
|
||
}
|
||
}
|
||
|
||
void TMotore_application::init_insert_mode( TMask& m )
|
||
{
|
||
TDocumento_mask& dm = (TDocumento_mask&)m;
|
||
TString4 codnum(m.get(F_CODNUM));
|
||
|
||
enable_menu_item(MENU_ITEM_ID(1));
|
||
dm.reset_father_rows();
|
||
if (codnum.empty())
|
||
{
|
||
TMask * query_mask = get_mask(MODE_QUERY);
|
||
|
||
codnum = query_mask->get(F_CODNUM);
|
||
m.set(F_CODNUM, codnum);
|
||
m.set(F_TIPODOC, query_mask->get(F_TIPODOC));
|
||
m.set(F_ANNO, query_mask->get_int(F_ANNO));
|
||
m.set(F_PROVV, query_mask->get(F_PROVV));
|
||
}
|
||
|
||
const int anno = m.get_int(F_ANNO);
|
||
const char provv = m.get(F_PROVV)[0];
|
||
const long numdoc = m.get_long(F_NDOC);
|
||
|
||
TDocumento& curdo = dm.doc();
|
||
|
||
curdo.read(provv, anno, codnum, numdoc);
|
||
curdo.set_tipo(m.get(F_TIPODOC));
|
||
|
||
const TTipo_documento& tp = curdo.tipo();
|
||
|
||
const char stato = tp.stato_finale_inserimento();
|
||
curdo.stato(stato);
|
||
|
||
_codnum = codnum;
|
||
_tipodoc = m.get(F_TIPODOC);
|
||
|
||
m.field(F_CODNUM).set_focusdirty(TRUE);
|
||
m.field(F_CODNUM).on_key(K_TAB);
|
||
m.field(F_TIPODOC).set_focusdirty(TRUE);
|
||
m.field(F_TIPODOC).on_key(K_TAB);
|
||
|
||
m.set(F_ANNORIF, anno);
|
||
m.set(F_CODNUMRIF, codnum);
|
||
|
||
// Giro per supplire alla mancanza di una TMask::set(short id, char c);
|
||
char str_stato[2] = { stato, '\0' };
|
||
m.set(F_STATO, str_stato);
|
||
|
||
TDate data_doc(TODAY);
|
||
const bool magic_datadoc = m.field(F_DATADOC).automagic();
|
||
if (!magic_datadoc)
|
||
{
|
||
long ndoc = 0; // unused
|
||
last_doc(provv, anno, codnum, ndoc, 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())
|
||
{
|
||
m.fld(pos).set(data_doc);
|
||
m.fld(pos).dirty();
|
||
}
|
||
|
||
pos = m.id2pos(F_CAUSMAG);
|
||
if (pos >= 0)
|
||
{
|
||
m.fld(pos).set(tp.caus_mov());
|
||
m.fld(pos).dirty();
|
||
}
|
||
|
||
tp.set_defaults(m);
|
||
|
||
if (!dm.field(F_CODCF).empty()) // Carica i dati dell'eventuale cliente
|
||
{
|
||
curdo.put(DOC_TIPOCF, dm.get(F_TIPOCF));
|
||
curdo.put(DOC_CODCF, dm.get(F_CODCF));
|
||
dm.cli2mask(true);
|
||
}
|
||
|
||
if (provv == 'P')
|
||
m.enable(DLG_CONFERMA);
|
||
else
|
||
m.disable(DLG_CONFERMA);
|
||
m.disable(DLG_PRINT);
|
||
m.disable(DLG_PREVIEW);
|
||
m.disable(DLG_EMAIL);
|
||
m.disable(DLG_ELABORA);
|
||
|
||
TSheet_field& ss = dm.sfield(F_SHEET);
|
||
|
||
if (curdo.tipo().auto_add())
|
||
{
|
||
for (int i = 0; i < 10; i++)
|
||
ss.insert(-1, false, true);
|
||
}
|
||
else
|
||
ss.destroy();
|
||
|
||
dm.mask2doc();
|
||
}
|
||
|
||
void TMotore_application::init_modify_mode( TMask& m )
|
||
{
|
||
TEdit_field& n = query_mask().efield(F_NDOC);
|
||
|
||
n.set("");
|
||
n.update_flags("R");
|
||
const bool enable_print = edit_mask().doc().tipo().printable();
|
||
const char provv = m.get(F_PROVV)[0];
|
||
enable_menu_item(MENU_ITEM_ID(1));
|
||
if (provv == 'P')
|
||
{
|
||
m.enable(DLG_CONFERMA);
|
||
m.disable(DLG_PRINT);
|
||
m.disable(DLG_EMAIL);
|
||
m.disable(DLG_PREVIEW);
|
||
enable_menu_item(M_FILE_PRINT, false);
|
||
enable_menu_item(M_FILE_PREVIEW, false);
|
||
}
|
||
else
|
||
{
|
||
m.disable(DLG_CONFERMA);
|
||
m.enable(DLG_PRINT, enable_print);
|
||
m.enable(DLG_EMAIL, enable_print);
|
||
m.enable(DLG_PREVIEW, enable_print);
|
||
enable_menu_item(M_FILE_PRINT, enable_print);
|
||
enable_menu_item(M_FILE_PREVIEW, enable_print);
|
||
}
|
||
m.enable(DLG_ELABORA);
|
||
m.disable(F_STATO);
|
||
|
||
if (m.id2pos(F_CURGIAC)>0 && m.efield(F_CURGIAC).shown())
|
||
{
|
||
cached_article_balances(NULL); // Azzera cache delle giacenze
|
||
edit_mask().update_giacenza(); // Aggiorna giacenza riga corrente
|
||
}
|
||
|
||
TString80 key;
|
||
key << m.get(F_CODNUM);
|
||
key << m.get(F_ANNO);
|
||
key << provv;
|
||
key << m.get(F_NDOC);
|
||
|
||
// Non dare messaggi inutili durante la cancellazione automatica
|
||
if (autodeleting() != 0x3)
|
||
{
|
||
const bool transaction = is_transaction();
|
||
const bool no_mod = !transaction && !doc().modificabile();
|
||
const bool no_del = !doc().cancellabile();
|
||
if (no_del || no_mod)
|
||
{
|
||
if (key != __last_key)
|
||
{
|
||
TString msg;
|
||
msg.format(FR("Documento non %s%s%s."), (no_mod ? TR("modificabile"):""),
|
||
(no_mod && no_del ? TR(" ne' "):""), (no_del ? TR("cancellabile"):""));
|
||
xvtil_statbar_set(msg);
|
||
}
|
||
}
|
||
if (no_mod)
|
||
m.disable(DLG_SAVEREC);
|
||
if (no_del)
|
||
m.disable(DLG_DELREC);
|
||
|
||
if (m.id2pos(F_IBAN_STATO) > 0)
|
||
m.efield(F_IBAN_STATO).validate(K_TAB); // Decodifica IBAN
|
||
}
|
||
__last_key = key;
|
||
}
|
||
|
||
int TMotore_application::user_function(int index)
|
||
{
|
||
switch(index)
|
||
{
|
||
case 1:
|
||
break;
|
||
default:
|
||
yesnofatal_box("Chiamata ad una procedura utente non definita: %d", index);
|
||
break;
|
||
}
|
||
return NOERR;
|
||
}
|
||
|
||
bool TMotore_application::changing_mask( int mode )
|
||
{
|
||
static int lastmode = NO_MODE;
|
||
static TString4 last_tipodoc;
|
||
const TDocumento & doc = (const TDocumento &) get_relation()->curr();
|
||
const TString& tipodoc = mode == MODE_QUERY ? EMPTY_STRING : doc.tipo().codice();
|
||
|
||
const bool change = ( mode != lastmode) || (last_tipodoc != tipodoc);
|
||
lastmode = mode;
|
||
last_tipodoc = tipodoc;
|
||
return change;
|
||
}
|
||
|
||
TMask* TMotore_application::get_mask( int mode )
|
||
{
|
||
if (mode != MODE_INS && mode != MODE_MOD)
|
||
return _msk;
|
||
|
||
TString4 tipodoc = _msk->get(F_TIPODOC); // Prendo il tipo documento dalla maschera di query;
|
||
if (mode == MODE_MOD)
|
||
tipodoc = get_relation()->curr().get(DOC_TIPODOC); // Lo prendo dalla relazione (Gelai)
|
||
|
||
_docmsk = (TDocumento_mask*)_doc_masks.objptr(tipodoc);
|
||
if (_docmsk == NULL)
|
||
{
|
||
_docmsk = new TDocumento_mask(tipodoc);
|
||
_doc_masks.add(tipodoc, _docmsk);
|
||
}
|
||
|
||
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( )
|
||
{
|
||
const TMask& m = curr_mask( );
|
||
const TCodice_numerazione& cod_num = cached_numerazione(m.get(F_CODNUM));
|
||
|
||
// Se per questa numerazione e' abilitata le numerazione automatica
|
||
if (cod_num.auto_num())
|
||
{
|
||
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
|
||
ndoc = 1;
|
||
return format("%d|%ld", F_NDOC, ndoc);
|
||
}
|
||
|
||
return "";
|
||
}
|
||
|
||
const char* TMotore_application::record_description(const TRelation& rel) const
|
||
{
|
||
const TString4 tipodoc = rel.curr().get(DOC_TIPODOC);
|
||
const TString& desc = cache().get("%TIP", tipodoc, "S0");
|
||
return desc.empty() ? TR("Documento") : desc;
|
||
}
|
||
|
||
int TMotore_application::read(TMask& m)
|
||
{
|
||
TDocumento_mask& mask = (TDocumento_mask&) m;
|
||
TRelation_application::read(m);
|
||
|
||
mask.reset_father_rows();
|
||
|
||
doc() = (TDocumento &)_rel->curr();
|
||
mask.update_father_rows(false);
|
||
|
||
_codnum = m.get(F_CODNUM);
|
||
_tipodoc = m.get(F_TIPODOC);
|
||
|
||
mask.doc2mask();
|
||
|
||
return NOERR;
|
||
}
|
||
|
||
bool TMotore_application::menu(MENU_TAG mt)
|
||
{
|
||
bool ok = true;
|
||
if (mt == MENU_ITEM_ID(1))
|
||
{
|
||
if (_docmsk != NULL)
|
||
_docmsk->sel_color();
|
||
}
|
||
else
|
||
ok = TRelation_application::menu(mt);
|
||
return ok;
|
||
}
|
||
|
||
void TMotore_application::do_elab( TDocumento& doc, int when) // C 90
|
||
{
|
||
TString16 codelab;
|
||
switch (when)
|
||
{
|
||
case 1: codelab = doc.tipo().elaborazione_stampa(); break;
|
||
case 2: codelab = doc.tipo().elaborazione_definitiva(); break;
|
||
default: codelab = doc.tipo().elaborazione(); break;
|
||
}
|
||
|
||
if (codelab.full())
|
||
{
|
||
const TRectype& eld = cache().get("%ELD", codelab);
|
||
if (!eld.empty())
|
||
{
|
||
TElaborazione * el = NULL;
|
||
switch (eld.get_int("I0"))
|
||
{
|
||
case _esterna :
|
||
el = new TElaborazione_esterna(eld);
|
||
break;
|
||
case _consegna_ordini:
|
||
el = new TConsegna_ordini(eld);
|
||
break;
|
||
case _fatturazione_bolle :
|
||
el = new TFatturazione_bolle(eld);
|
||
break;
|
||
case _contabilizzazione :
|
||
el = new TContabilizzazione(eld);
|
||
break;
|
||
case _copia_documento :
|
||
el = new TCopia_documento(eld);
|
||
break;
|
||
case _generazione_effetti :
|
||
el = new TGenerazione_effetti(eld);
|
||
break;
|
||
case _consuntivazione_produzione :
|
||
el = new TConsuntivazione_produzione(eld);
|
||
break;
|
||
case _contabilizzazione_analitica :
|
||
el = new TContabilizzazione_analitica(eld);
|
||
break;
|
||
default :
|
||
break;
|
||
}
|
||
|
||
if (el != NULL && el->is_document_ok(doc))
|
||
{
|
||
TLista_documenti in; in.add(doc);
|
||
TLista_documenti out;
|
||
|
||
if (when == 0)
|
||
{
|
||
TDocumento* newdoc = new TDocumento(doc.get_char(DOC_PROVV), doc.get_int(DOC_ANNO), el->codice_numerazione_finale(), 0L);
|
||
TDocumento::copy_data(newdoc->head(), doc.head());
|
||
newdoc->put(DOC_TIPODOC, el->tipo_finale());
|
||
newdoc->put(DOC_STATO, el->stato_finale());
|
||
if (newdoc->tipo().mov_mag())
|
||
newdoc->put(DOC_CAUSMAG, newdoc->tipo().caus_mov());
|
||
else
|
||
newdoc->zero(DOC_CAUSMAG);
|
||
out.add(newdoc);
|
||
}
|
||
|
||
if (el->elabora(in, out, TDate(TODAY), true))
|
||
{
|
||
if (when == 0 && out.items() && out[0].numero() > 0L)
|
||
out.rewrite();
|
||
if (when < 2 && in.items() && in[0] != doc)
|
||
doc = in[0];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
int TMotore_application::write( const TMask& m ) // C 90
|
||
{
|
||
TDocumento_mask& mask = (TDocumento_mask&) m;
|
||
TDocumento& d = (TDocumento&)_rel->curr();
|
||
d = mask.doc(); // Trasferisce il documento da maschera a record
|
||
|
||
// Se ho attivato la creazione automatica delle righe allora cancello quelle vuote finali
|
||
if (d.tipo().auto_add())
|
||
{
|
||
for (int r = d.rows(); r > 0; r--)
|
||
{
|
||
const TRiga_documento& dr = d[r];
|
||
if (dr.get(RDOC_CODART).empty() && dr.get(RDOC_DESCR).empty())
|
||
d.destroy_row(r);
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
|
||
const int err = TRelation_application::write(m);
|
||
|
||
if (err == NOERR)
|
||
{
|
||
do_elab(d);
|
||
mask.update_father_rows();
|
||
mask.save_father_rows();
|
||
|
||
// Stampa immediatamente dopo aver salvato se possibile
|
||
if (d.codice_numerazione().save_and_new() && d.tipo().printable())
|
||
{
|
||
const TString& sis = d.tipo().stati_iniziali_stampa();
|
||
if (sis.find(d.stato()) >= 0)
|
||
save_and_print(false, winprinter);
|
||
}
|
||
}
|
||
|
||
return err;
|
||
}
|
||
|
||
int TMotore_application::rewrite( const TMask& m ) // C 90
|
||
{
|
||
TDocumento& d = (TDocumento &) _rel->curr();
|
||
TDocumento_mask& mask = (TDocumento_mask&) m;
|
||
|
||
if (d.bloccato())
|
||
return NOERR;
|
||
d = ((TDocumento_mask&)m).doc(); // Trasferisce il documento da maschera a record
|
||
const int err = TRelation_application::rewrite(m);
|
||
if (err == NOERR)
|
||
{
|
||
do_elab(d);
|
||
mask.update_father_rows();
|
||
mask.save_father_rows();
|
||
}
|
||
return err;
|
||
}
|
||
|
||
bool TMotore_application::remove() // C 90
|
||
{
|
||
TDocumento& d = (TDocumento &) _rel->curr();
|
||
|
||
d.put(DOC_NOTE, "DELETING");
|
||
do_elab(d);
|
||
const bool ok = TRelation_application::remove();
|
||
if (ok)
|
||
edit_mask().save_father_rows();
|
||
return ok;
|
||
}
|
||
|
||
void TMotore_application::on_firm_change()
|
||
{
|
||
if (_config_ditta != NULL)
|
||
delete _config_ditta;
|
||
_config_ditta = new TConfig(CONFIG_DITTA);
|
||
_doc_masks.destroy();
|
||
load_auto_reopen_data();
|
||
TRelation_application::on_firm_change();
|
||
}
|
||
|
||
void TMotore_application::load_auto_reopen_data()
|
||
{
|
||
TAssoc_array & auto_reopen_nums = TDocumento_mask::auto_reopen_nums();
|
||
TAssoc_array & tipidoc_rels = TDocumento_mask::tipidoc_rels();
|
||
TTable num("%NUM");
|
||
TTable eld("%ELD");
|
||
|
||
auto_reopen_nums.destroy();
|
||
tipidoc_rels.destroy();
|
||
for (int err = num.first(); err == NOERR; err = num.next())
|
||
{
|
||
if (num.get_bool("B7"))
|
||
{
|
||
const TString4 codnum = num.get("CODTAB");
|
||
TCodice_numerazione numeraz(codnum);
|
||
const int ntipidoc = numeraz.ntipi_doc();
|
||
TString_array tipi;
|
||
|
||
for (int k = 0 ; k < ntipidoc; k++)
|
||
tipi.add(numeraz.tipo_doc(k));
|
||
auto_reopen_nums.add(codnum, codnum);
|
||
for (int err1 = eld.first(); err1 == NOERR; err1 = eld.next())
|
||
{
|
||
TCopia_documento e(eld.get("CODTAB"));
|
||
const TTipo_elaborazione tipo = e.tipo();
|
||
|
||
if (tipo == _consegna_ordini ||
|
||
tipo == _consuntivazione_produzione)
|
||
{
|
||
const TString4 dest_tipo_doc = e.tipo_finale();
|
||
const char stato_finale = e.stato_finale_doc_iniziale()[0];
|
||
|
||
|
||
for (int i = 0; i < 10; i++)
|
||
{
|
||
TToken_string key(e.tipo_iniziale(i));
|
||
if (key.blank())
|
||
break;
|
||
if (tipi.find(key) >= 0)
|
||
{
|
||
key.add(dest_tipo_doc);
|
||
tipidoc_rels.add(key, new TStati(e.stato_iniziale(i), stato_finale));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
static bool num_filter(const TRelation* r)
|
||
{
|
||
const TCodice_numerazione& cod_num = cached_numerazione(r->curr().get("CODTAB"));
|
||
const int last = cod_num.ntipi_doc();
|
||
for (int i = 0; i < last; i++)
|
||
{
|
||
if (is_tipodoc_ok(cod_num.tipo_doc(i)))
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
bool TMotore_application::ndoc_handler(TMask_field& f, KEY k)
|
||
{
|
||
if (k == K_ENTER && !f.empty())
|
||
{
|
||
const TMask& m = f.mask();
|
||
const TString& codnum = m.get(F_CODNUM);
|
||
const TCodice_numerazione& num = cached_numerazione(codnum);
|
||
if (num.auto_num())
|
||
{
|
||
const char provv = m.get(F_PROVV)[0];
|
||
const int anno = m.get_int(F_ANNO);
|
||
const long ndoc = atol(f.get());
|
||
long last_ndoc = 0;
|
||
TDate last_datadoc;
|
||
if (app().last_doc(provv, anno, codnum, last_ndoc, last_datadoc))
|
||
{
|
||
last_ndoc++;
|
||
if (ndoc > last_ndoc)
|
||
return yesno_box(TR("Il numero documento %ld non rispetta la sequenza prevista (%ld).\n"
|
||
"Si desidera proseguire ugualmente?"), ndoc, last_ndoc);
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool TMotore_application::tdoc_handler(TMask_field& f, KEY k)
|
||
{
|
||
if (k == K_TAB && !f.empty() && f.focusdirty())
|
||
{
|
||
const TTipo_documento& td = cached_tipodoc(f.get());
|
||
const char cf[2] = { td.tipocf(), '\0' };
|
||
f.mask().set(F_TIPOCF, cf);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
bool TMotore_application::user_create( )
|
||
{
|
||
open_files(LF_DOC, LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_DESLIN, LF_CODCORR,
|
||
LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_INDSP, LF_OCCAS, LF_PCON, LF_MOV, LF_STOMAG,
|
||
LF_MOVMAG, LF_RMOVMAG, LF_MAG, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_ATTIV, LF_CAUSALI, 0);
|
||
|
||
TISAM_recordset num("USE %NUM");
|
||
for (bool ok = num.move_first(); ok; ok = num.move_next())
|
||
cached_numerazione(num.get("CODTAB").as_string());
|
||
|
||
TISAM_recordset tip("USE %TIP");
|
||
for (bool ok = tip.move_first(); ok; ok = tip.move_next())
|
||
cached_tipodoc(tip.get("CODTAB").as_string());
|
||
|
||
_config_ditta = new TConfig(CONFIG_DITTA);
|
||
|
||
// Metto in relazione testata e righe
|
||
_rel = new TRelation(LF_DOC);
|
||
_rel->lfile().set_curr(new TDocumento);
|
||
|
||
_msk = new TMask(query_mask_name());
|
||
set_search_field(F_NDOC);
|
||
|
||
_msk->set_handler(F_ANNO, TDocumento_mask::anno_handler);
|
||
_msk->set_handler(F_CODNUM, TDocumento_mask::num_handler);
|
||
_msk->set_handler(F_TIPODOC, tdoc_handler);
|
||
_msk->set_handler(F_NUMDOCRIF, TDocumento_mask::numdocrif_search_handler);
|
||
//_msk->set_handler(F_RAGSOCSEARCH, TDocumento_mask::ragsoc_search_handler);
|
||
_msk->set_handler(F_NDOC, ndoc_handler);
|
||
|
||
const int args = argc() ;
|
||
|
||
TEdit_field & e = _msk->efield(F_CODNUM);
|
||
TBrowse * b = e.browse();
|
||
TEdit_field & edes = _msk->efield(F_DESNUM);
|
||
TBrowse * bdes = edes.browse();
|
||
TCursor * cur = b->cursor();
|
||
TCursor * descur = bdes->cursor();
|
||
|
||
cur->set_filterfunction(num_filter);
|
||
descur->set_filterfunction(num_filter);
|
||
|
||
for (int i = 2; i < args; i++)
|
||
{
|
||
const TFixed_string arg(argv(i));
|
||
|
||
if (arg.starts_with("-def"))
|
||
{
|
||
TToken_string str(arg.mid(4), ',');
|
||
//attenzione: non ridefinire le TString16 in TString4 perch<63> il nome di variabile codnum non c'entra un benemerito..
|
||
//..cazzo con codnum, ma pu<70> essere una variabile qualunque (compliemti all'astuzia nella scelta del nome)
|
||
const TString16 codnum(str.get());
|
||
const TString16 tipodoc(str.get());
|
||
const TString16 paragraph(str.get());
|
||
|
||
if (paragraph.blank())
|
||
{
|
||
_codnum = codnum;
|
||
_tipodoc = tipodoc;
|
||
}
|
||
else
|
||
{
|
||
TConfig c(CONFIG_DITTA, paragraph);
|
||
_codnum = c.get(codnum);
|
||
_tipodoc = c.get(tipodoc);
|
||
}
|
||
}
|
||
else
|
||
if (arg.starts_with("-filt"))
|
||
{
|
||
if (b != NULL || bdes != NULL)
|
||
{
|
||
TString filter = b->get_filter();
|
||
if (filter.full())
|
||
{
|
||
filter.insert("(");
|
||
filter << ")&&(" << arg.mid(5) << ")";
|
||
if (b != NULL)
|
||
b->set_filter(filter);
|
||
if (bdes != NULL)
|
||
bdes->set_filter(filter);
|
||
}
|
||
else
|
||
{
|
||
const TString newfilter(arg.mid(5));
|
||
if (b != NULL)
|
||
b->set_filter(newfilter);
|
||
if (bdes != NULL)
|
||
bdes->set_filter(newfilter);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
TConfig utente(CONFIG_GUI, app().name().left(2));
|
||
if (_codnum.blank())
|
||
_codnum = utente.get("CODNUM");
|
||
if (_tipodoc.blank())
|
||
_tipodoc = utente.get("TIPODOC");
|
||
_docmsk = NULL;
|
||
|
||
load_auto_reopen_data();
|
||
|
||
return true;
|
||
}
|
||
|
||
bool TMotore_application::user_destroy( )
|
||
{
|
||
// Registro l'ultimo tipo documento e l'ultima numerazione
|
||
TConfig utente( CONFIG_GUI, app().name().left(2) );
|
||
utente.set( "CODNUM", _codnum );
|
||
utente.set( "TIPODOC", _tipodoc );
|
||
|
||
if (_config_ditta != NULL)
|
||
delete _config_ditta;
|
||
// Distruggo la maschera di modifica
|
||
if ( _msk != NULL )
|
||
delete _msk;
|
||
|
||
// Distruggo la relazione
|
||
delete _rel;
|
||
// delete _condv;
|
||
|
||
return true;
|
||
}
|
||
|
||
int TMotore_application::stato_corrente( )
|
||
{
|
||
return edit_mask().get_int(F_STATO);
|
||
}
|
||
|
||
void TMotore_application::sheet2ini(TSheet_field &sheet,TConfig& ini)
|
||
{
|
||
// scrive le righe degli sheet associati
|
||
TString16 defpar;
|
||
TString str(80);
|
||
TDocumento_mask &m = (TDocumento_mask &)sheet.mask();
|
||
int r;
|
||
|
||
for (r = 1; r <= sheet.items(); r++)
|
||
{
|
||
defpar.format("%d,%d",LF_RIGHEDOC,r);
|
||
const TMask* sm = m.riga_mask(r-1);
|
||
const TToken_string& rigar = sheet.row(r-1);
|
||
for (int sf = 0; sf < sm->fields(); sf++)
|
||
{
|
||
TMask_field& campo = sm->fld(sf);
|
||
if (campo.shown() && campo.field())
|
||
{
|
||
// str = sheet.row(r-1).get(sheet.cid2index(campo.dlg()));
|
||
const short id = campo.dlg();
|
||
rigar.get(sheet.cid2index(id), str);
|
||
if (str.empty())
|
||
str = " ";
|
||
const word field_class = campo.class_id();
|
||
if (field_class == CLASS_MEMO_FIELD || field_class == CLASS_ZOOM_FIELD)
|
||
{
|
||
int p;
|
||
while ((p = str.find('\n', 0)) >= 0)
|
||
{
|
||
str.overwrite("\\", p);
|
||
str.insert("n", p+1);
|
||
}
|
||
}
|
||
if (campo.field()->name() == RDOC_PREZZO)
|
||
{
|
||
const TCodiceIVA c(sm->get(FR_CODIVA));
|
||
TFieldref l;
|
||
real prezzo(str);
|
||
real prezzol;
|
||
|
||
l = RDOC_PREZZOL;
|
||
if (m.doc().tipo().calcolo_lordo())
|
||
{
|
||
prezzol = prezzo;
|
||
c.scorpora(prezzo);
|
||
}
|
||
else
|
||
prezzol = c.lordo(prezzo);
|
||
l.write(ini, defpar, prezzol.string());
|
||
str = prezzo.string();
|
||
}
|
||
campo.field()->write(ini, defpar, str);
|
||
}
|
||
const TRiga_documento &rdoc = m.doc()[r];
|
||
TFieldref f;
|
||
|
||
f = RDOC_DACODNUM;
|
||
f.write(ini, defpar, rdoc.get(RDOC_DACODNUM));
|
||
f = RDOC_DAANNO;
|
||
f.write(ini, defpar, rdoc.get(RDOC_DAANNO));
|
||
f = RDOC_DAPROVV;
|
||
f.write(ini, defpar, rdoc.get(RDOC_DAPROVV));
|
||
f = RDOC_DANDOC;
|
||
f.write(ini, defpar, rdoc.get(RDOC_DANDOC));
|
||
f = RDOC_DAIDRIGA;
|
||
f.write(ini, defpar, rdoc.get(RDOC_DAIDRIGA));
|
||
}
|
||
}
|
||
for ( ; ; r++)
|
||
{
|
||
defpar.format("%d,%d",LF_RIGHEDOC,r);
|
||
if (ini.set_paragraph(defpar))
|
||
ini.remove_all();
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
|
||
void TMotore_application::ini2mask(TConfig& ini, TMask& msk, bool query)
|
||
{
|
||
TRelation_application::ini2mask(ini, msk, query); // Default processing
|
||
|
||
if (query)
|
||
{
|
||
// Dobbiamo riempire il tipo documento per determinare il profilo corretto!
|
||
TMask_field& campo = msk.field(F_TIPODOC);
|
||
TString16 str = campo.field()->read(ini, format("%d", LF_DOC));
|
||
if (str.empty())
|
||
{
|
||
TToken_string key;
|
||
key.add(msk.get(F_PROVV));
|
||
key.add(msk.get(F_ANNO));
|
||
key.add(msk.get(F_CODNUM));
|
||
key.add(msk.get(F_NDOC));
|
||
str = cache().get(LF_DOC, key, DOC_TIPODOC);
|
||
}
|
||
campo.set(str);
|
||
}
|
||
else
|
||
{
|
||
TDocumento& d = doc();
|
||
d.put(DOC_TIPOCF, msk.get(F_TIPOCF));
|
||
d.put(DOC_CODCF, msk.get(F_CODCF));
|
||
const TCli_for& c = d.clifor();
|
||
|
||
// Compilo dati occasionale se presenti
|
||
if (c.occasionale() && ini.set_paragraph("18")) // LF_OCCAS
|
||
{
|
||
const TString& ocfpi = ini.get(OCC_CFPI);
|
||
if (ocfpi.full())
|
||
{
|
||
TLocalisamfile occas(LF_OCCAS);
|
||
TRectype& rec = occas.curr();
|
||
rec.put(OCC_CFPI, ocfpi);
|
||
if (occas.read(_isequal, _lock) != NOERR)
|
||
rec.zero();
|
||
TAssoc_array& vars = ini.list_variables();
|
||
FOR_EACH_ASSOC_STRING(vars, obj, key, str)
|
||
{
|
||
if (rec.exist(key))
|
||
rec.put(key, str);
|
||
}
|
||
if (occas.write_rewrite() == NOERR)
|
||
{
|
||
doc().put(DOC_OCFPI, ocfpi);
|
||
doc().occas() = rec;
|
||
}
|
||
}
|
||
}
|
||
|
||
ini.set_paragraph("33");
|
||
if (!ini.exist(DOC_CODVAL))
|
||
{
|
||
const TString4 codval = c.get(CLI_CODVAL); // Attenzione: Non usare TString& qui!
|
||
msk.set(F_CODVAL, codval, true);
|
||
msk.set(F_CODVAL1, codval, true);
|
||
if (codval.blank())
|
||
msk.reset(F_CAMBIO);
|
||
}
|
||
if (!ini.exist(DOC_CODLIN))
|
||
msk.set(F_CODLIN, c.get(CLI_CODLIN), true);
|
||
if (!ini.exist(DOC_CODPAG))
|
||
msk.set(F_CODPAG, c.get(CLI_CODPAG), true);
|
||
if (!ini.exist(DOC_CODABIA))
|
||
msk.set(F_CODABIA, c.get(CLI_CODABI), true);
|
||
if (!ini.exist(DOC_CODCABA))
|
||
msk.set(F_CODCABA, c.get(CLI_CODCAB), true);
|
||
if (!ini.exist(DOC_IBAN))
|
||
{
|
||
const TString & iban = c.get(CLI_IBAN);
|
||
|
||
msk.set(F_IBAN, iban, true);
|
||
if (iban.not_empty())
|
||
{
|
||
msk.set(F_IBAN_STATO, iban.left(2));
|
||
msk.set(F_IBAN_CHECK, iban.mid(2,2));
|
||
msk.set(F_BBAN , iban.mid(4));
|
||
msk.set(F_BBAN_CIN , iban.mid(4,1));
|
||
msk.set(F_BBAN_ABI , iban.mid(5,5));
|
||
msk.set(F_BBAN_CAB , iban.mid(10,5));
|
||
msk.set(F_BBAN_CONTO, iban.mid(15,12));
|
||
}
|
||
}
|
||
|
||
// Setta i campi che appartengono al file LF_CFVEN
|
||
const TRectype& ven_rec = c.vendite();
|
||
|
||
if (!ini.exist(DOC_CODABIP))
|
||
msk.set(F_CODABIP, ven_rec.get(CFV_CODABIPR), true);
|
||
if (!ini.exist(DOC_CODCABP))
|
||
msk.set(F_CODCABP, ven_rec.get(CFV_CODCABPR), true);
|
||
if (!ini.exist(DOC_RAGGR))
|
||
msk.set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
|
||
if (!ini.exist(DOC_RAGGREFF))
|
||
msk.set(F_RAGGREFF, ven_rec.get(CFV_RAGGEFF));
|
||
if (!ini.exist(DOC_CODINDSP))
|
||
msk.set(F_CODINDSP, ven_rec.get(CFV_CODINDSP), true);
|
||
if (!ini.exist(DOC_CODAG))
|
||
msk.set(F_CODAG, ven_rec.get(CFV_CODAG));
|
||
if (!ini.exist(DOC_CODAGVIS))
|
||
msk.set(F_CODAGVIS, ven_rec.get(CFV_CODAG1));
|
||
if (!ini.exist(DOC_CODSPMEZZO))
|
||
msk.set(F_CODSPMEZZO, ven_rec.get(CFV_CODSPMEZZO), true);
|
||
if (!ini.exist(DOC_CODPORTO))
|
||
msk.set(F_CODPORTO, ven_rec.get(CFV_CODPORTO), true);
|
||
if (!ini.exist(DOC_CODNOTESP1))
|
||
msk.set(F_CODNOTESP1, ven_rec.get(CFV_CODNOTESP1), true);
|
||
if (!ini.exist(DOC_CODNOTESP2))
|
||
msk.set(F_CODNOTESP2, ven_rec.get(CFV_CODNOTESP2), true);
|
||
if (!ini.exist(DOC_CODNOTE))
|
||
msk.set(F_CODNOTE, ven_rec.get(CFV_CODNOTE), true);
|
||
if (!ini.exist(DOC_CODVETT1))
|
||
msk.set(F_CODVETT1, ven_rec.get(CFV_CODVETT1), true);
|
||
if (!ini.exist(DOC_CODVETT2))
|
||
msk.set(F_CODVETT2, ven_rec.get(CFV_CODVETT2), true);
|
||
if (!ini.exist(DOC_CODVETT3))
|
||
msk.set(F_CODVETT3, ven_rec.get(CFV_CODVETT3), true);
|
||
if (!ini.exist(DOC_PERCSPINC))
|
||
msk.set(F_SPESEINC, ven_rec.get(CFV_PERCSPINC));
|
||
if (!ini.exist(DOC_ADDBOLLI))
|
||
msk.set(F_ADDBOLLI, ven_rec.get(CFV_ADDBOLLI));
|
||
if (!ini.exist(DOC_CATVEN))
|
||
msk.set(F_CATVEN, ven_rec.get(CFV_CATVEN), false);
|
||
if (!ini.exist(DOC_ZONA))
|
||
msk.set(F_CODZON, ven_rec.get(CFV_CODZONA), true);
|
||
if (!ini.exist(DOC_CODLIST))
|
||
msk.set(F_CODLIST, ven_rec.get(CFV_CODLIST), true);
|
||
if (!ini.exist(DOC_CODCONT) && ven_rec.get(CFV_GESTCONTR))
|
||
((TDocumento_mask&)msk).contr2mask();
|
||
|
||
TSheet_field& f = msk.sfield(F_SHEET);
|
||
|
||
TTipo_riga_documento tr;
|
||
|
||
// Scorre tutti i paragrafi delle righe documento
|
||
const TMaskmode oldmode= (TMaskmode)msk.mode();
|
||
|
||
msk.set_mode(MODE_MOD);
|
||
|
||
TString_array pl; ini.list_paragraphs(pl);
|
||
|
||
if (pl.items() > 2)
|
||
{
|
||
bool should_reset = true;
|
||
FOR_EACH_ARRAY_ROW_BACK(pl, p, pa)
|
||
{
|
||
if (pa->starts_with("34,"))
|
||
{
|
||
if (pa->find('-') > 0)
|
||
should_reset = false; // Modalit<69> append righe
|
||
}
|
||
else
|
||
pl.destroy(p);
|
||
}
|
||
// Se trovo almeno una riga allora cancello tutto, poi aggiungo le righe
|
||
if (should_reset && pl.items() > 0)
|
||
{
|
||
f.destroy();
|
||
doc().destroy_rows();
|
||
}
|
||
}
|
||
|
||
FOR_EACH_ARRAY_ROW(pl, p, pa) if (pa->starts_with("34,"))
|
||
{
|
||
ini.set_paragraph(*pa);
|
||
|
||
// Considera solo i tipi riga validi
|
||
const TString4 tipo(ini.get(RDOC_TIPORIGA));
|
||
if (tr.read(tipo) == NOERR)
|
||
{
|
||
// Crea una nuova riga documento
|
||
TRiga_documento& rec = doc().new_row(tipo);
|
||
// Riempie i campi della nuova riga
|
||
TAssoc_array& var = ini.list_variables();
|
||
FOR_EACH_ASSOC_STRING(var, obj, key, val)
|
||
{
|
||
if (*val == '"' || *val == '\'')
|
||
{
|
||
const int len = strlen(val);
|
||
*(char*)(val+len-1) = '\0';
|
||
val++;
|
||
}
|
||
|
||
if (xvt_str_compare_ignoring_case(key, RDOC_DESCR) == 0) // Trattamento speciale per la descrizione qui verificare
|
||
{
|
||
TString s = esc(val); s.rtrim();
|
||
int split_pos = s.find('\n');
|
||
const int descr_len = rec.length(RDOC_DESCR);
|
||
if (split_pos < 0 && s.len() > descr_len)
|
||
split_pos = descr_len;
|
||
if (split_pos > descr_len)
|
||
split_pos = descr_len;
|
||
if (split_pos > 0)
|
||
{
|
||
rec.put(RDOC_DESCR, s.left(split_pos));
|
||
rec.put(RDOC_DESCLUNGA, "X");
|
||
rec.put(RDOC_DESCEST, s.mid(split_pos));
|
||
}
|
||
else
|
||
{
|
||
rec.put(RDOC_DESCR, s);
|
||
rec.zero(RDOC_DESCLUNGA);
|
||
rec.zero(RDOC_DESCEST);
|
||
}
|
||
|
||
}
|
||
else
|
||
if (xvt_str_compare_ignoring_case(key, RDOC_NRIGA) != 0) // Ignora il numero riga ..
|
||
if (xvt_str_compare_ignoring_case(key, RDOC_TIPORIGA) != 0) // ... ed il tipo riga
|
||
rec.put(key, val);
|
||
}
|
||
|
||
// solo la insert chiama la post_insert necessaria alla disabilitazione verifichiamo l'autoload ??
|
||
f.insert(-1, FALSE);
|
||
// Aggiunge la riga allo sheet
|
||
|
||
const bool checked = rec.get_bool(RDOC_CHECKED);
|
||
|
||
if (checked)
|
||
{
|
||
const TString& codart = rec.get(RDOC_CODARTMAG);
|
||
|
||
if (codart.full())
|
||
{
|
||
const TRectype& art = cache().get(LF_ANAMAG, codart);
|
||
if (art.empty())
|
||
{
|
||
error_box(FR("Articolo non valido sulla riga %d: %s"), f.items(), (const char*)codart);
|
||
rec.zero(RDOC_CODARTMAG);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!ini.exist(RDOC_DESCR))
|
||
{
|
||
const TString& codart = rec.get(RDOC_CODARTMAG);
|
||
if (codart.full())
|
||
{
|
||
const TRectype& art = cache().get(LF_ANAMAG, codart);
|
||
|
||
rec.put(RDOC_DESCR, art.get(ANAMAG_DESCR));
|
||
rec.put(RDOC_CODIVA, art.get(ANAMAG_CODIVA));
|
||
}
|
||
rec.put(RDOC_CHECKED, "X");
|
||
}
|
||
}
|
||
|
||
if (!ini.exist(RDOC_CODIVA) && !(rec.is_descrizione() || rec.is_sconto() || rec.is_sconto_perc()))
|
||
{
|
||
const TString4 codiva = ((TDocumento_mask &) msk).doc().codesiva();
|
||
if (codiva.full())
|
||
rec.put(RDOC_CODIVA, codiva);
|
||
}
|
||
rec.autoload(f);
|
||
const int last_row = f.items() - 1;
|
||
f.check_row(last_row, 0x2);
|
||
|
||
if (!checked) //se non e' checked, il record viene autosalvato (in modo che sia salvato completamente)
|
||
{
|
||
const TString& prezzo = ini.get(RDOC_PREZZO);
|
||
if (prezzo.full())
|
||
f.row(last_row).add(prezzo, f.cid2index(FR_PREZZO));
|
||
rec.autosave(f);
|
||
}
|
||
}
|
||
}
|
||
msk.set_mode(oldmode);
|
||
}
|
||
}
|
||
|
||
bool TMotore_application::save_and_print(bool savedoc, TPrtype mode)
|
||
{
|
||
static bool already_printing = false;
|
||
if (already_printing)
|
||
return false;
|
||
already_printing = true;
|
||
|
||
if (savedoc)
|
||
{
|
||
TSheet_field& ss = edit_mask().sfield(F_SHEET);
|
||
if (!ss.on_key(K_ENTER))
|
||
return already_printing = false;
|
||
|
||
if (save(false))
|
||
edit_mask().update_father_rows(false);
|
||
else
|
||
return already_printing = false;
|
||
}
|
||
|
||
const TDocumento& doc = (const TDocumento&)get_relation()->curr();
|
||
|
||
const TTipo_documento& tipo = doc.tipo();
|
||
TFilename rep;
|
||
|
||
int filter = has_module(RSAUT) ? 2 : 1;
|
||
while (filter > 0 && !tipo.main_print_profile(rep, filter))
|
||
filter--;
|
||
|
||
if (filter > 0)
|
||
{
|
||
const bool da_stampare = doc.stampabile();
|
||
const char old_stato = doc.stato();
|
||
|
||
TString commandline;
|
||
commandline = "ve1 -";
|
||
if (filter == 2)
|
||
commandline << 2; // Esiste il nuovo report :-)
|
||
else
|
||
commandline << 0; // Esiste il vecchio form :-(
|
||
|
||
commandline << ' ' << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << ' ';
|
||
switch (mode)
|
||
{
|
||
case exportprinter: commandline << " E"; break;
|
||
case fileprinter : commandline << " P"; break;
|
||
case screenvis : commandline << " A"; break;
|
||
default : commandline << " S"; break;
|
||
}
|
||
commandline << ' ' << (da_stampare ? 'D' : 'P');
|
||
|
||
const int ncopie = tipo.ncopie();
|
||
if (ncopie > 0)
|
||
commandline << ' ' << ncopie;
|
||
|
||
TExternal_app interattivo( commandline );
|
||
if (interattivo.run() == NOERR)
|
||
{
|
||
TDocumento_mask& m = edit_mask();
|
||
TDocumento& maindoc = m.doc();
|
||
|
||
if (da_stampare) // Aggiorna stato documento se necessario
|
||
{
|
||
maindoc.read(); // Aggiorna STATO e MOVMAG generati da ve1
|
||
|
||
// Lo stato del documento vive di vita propria
|
||
const char sfs = maindoc.tipo().stato_finale_stampa();
|
||
const char new_stato = old_stato > sfs ? old_stato : sfs;
|
||
maindoc.stato(new_stato);
|
||
const char ss[2] = { new_stato, '\0' };
|
||
m.set(F_STATO, ss, true);
|
||
init_modify_mode(m);
|
||
}
|
||
do_elab(maindoc, true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
rep.ext("");
|
||
cantread_box(rep);
|
||
return already_printing = false;
|
||
}
|
||
|
||
already_printing = false;
|
||
return true;
|
||
}
|
||
|
||
void TMotore_application::print()
|
||
{
|
||
if (edit_mask().id2pos(DLG_PREVIEW) < 0)
|
||
save_and_print(true, printer().printtype());
|
||
else
|
||
save_and_print(true, winprinter);
|
||
}
|
||
|
||
void TMotore_application::mailto()
|
||
{
|
||
save_and_print(true, exportprinter);
|
||
}
|
||
|
||
void TMotore_application::preview()
|
||
{
|
||
save_and_print(true, screenvis);
|
||
}
|
||
|
||
int ve0100( int argc, char* argv[])
|
||
{
|
||
TMotore_application a;
|
||
a.run( argc, argv, TR("Gestione documenti"));
|
||
return 0;
|
||
}
|