2000-10-03 13:45:12 +00:00
|
|
|
|
#include <applicat.h>
|
2008-12-09 15:22:23 +00:00
|
|
|
|
#include <execp.h>
|
1998-05-04 09:54:49 +00:00
|
|
|
|
#include <defmask.h>
|
2000-10-03 13:45:12 +00:00
|
|
|
|
#include <modaut.h>
|
1998-11-04 18:04:26 +00:00
|
|
|
|
#include <progind.h>
|
2008-11-15 09:41:12 +00:00
|
|
|
|
#include <recset.h>
|
1999-10-22 10:00:18 +00:00
|
|
|
|
#include <sheet.h>
|
2004-11-30 22:02:59 +00:00
|
|
|
|
#include <smartcard.h>
|
1997-10-23 10:53:49 +00:00
|
|
|
|
#include <tabutil.h>
|
2011-02-16 09:42:19 +00:00
|
|
|
|
#include <toolfld.h>
|
2007-09-18 14:25:15 +00:00
|
|
|
|
#include <urldefid.h>
|
2008-12-09 15:22:23 +00:00
|
|
|
|
#include <utility.h>
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
#include "sconti.h"
|
|
|
|
|
#include "veini.h"
|
2008-03-26 16:43:54 +00:00
|
|
|
|
#include "vepriv.h"
|
1997-10-23 10:53:49 +00:00
|
|
|
|
#include "verig.h"
|
|
|
|
|
#include "veuml1.h"
|
|
|
|
|
#include "veini.h"
|
2005-08-23 08:54:32 +00:00
|
|
|
|
#include "sconti.h"
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2008-12-04 15:32:01 +00:00
|
|
|
|
#include "velib07.h"
|
2011-02-16 09:42:19 +00:00
|
|
|
|
#include "ve0100n.h"
|
2008-12-04 15:32:01 +00:00
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
#include "../cg/cg2103.h"
|
2006-12-13 16:22:33 +00:00
|
|
|
|
#include "../db/dblib.h"
|
1998-11-04 18:04:26 +00:00
|
|
|
|
#include "../mg/mglib.h"
|
2005-08-23 08:54:32 +00:00
|
|
|
|
#include "../db/dblib.h"
|
1998-11-04 18:04:26 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
#include "../mg/anamag.h"
|
|
|
|
|
#include "../mg/codcorr.h"
|
|
|
|
|
#include "../mg/deslin.h"
|
|
|
|
|
#include "../mg/umart.h"
|
Patch level : 10.0 870
Files correlati : ef0.exe
Ricompilazione Demo : [ ]
Commento :
Gestione CUP
Verificare che i profili persnalizzati continuino a funzionare
Nella gestione profili e documenti aggiunti i campi per gestire piu banche di appoggio e presentazione dei clienti/ fornitori
La ricerca e sulla tabella se il cliente / fornitore non ha banche altrimenti e sulle banche del cliente/fornitore.
Ai profili personalizzati vanno aggiunti-modificati e posizionati i campi :
NU 117 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIA
US %BAN SE CODTAB?="?????"
IN CODTAB[1,5] 117
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 117 CODTAB[1,5]
OU 336 S0
OU 197 CODTAB[1,5]
ME CO,220
EN
NU 118 5
BE
PR 42 11 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABA
US %BAN SE CODTAB?="??????????"
IN CODTAB[1,5] 117
IN CODTAB[6,10] 118
CO DI 117
OU 117 CODTAB[1,5]
OU 118 CODTAB[6,10]
OU 336 S0
OU 198 CODTAB[6,10]
ME CO,221
EN
NU 220 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIA
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "V"
IN ABI 220
IN CAB 221
IN PROGPR ""
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 220 ABI
OU 221 CAB
OU 336 %BAN->S0
OU 192 IBAN
OU 197 ABI
OU 198 CAB
EN
NU 221 5
BE
PR 42 11 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABA
CO US 220
CO IN 220
CO DI 220
CO OU 220
EN
per la banca di appoggio
NU 119 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIP
CO US 117
IN CODTAB[1,5] 119
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 119 CODTAB[1,5]
OU 338 S0
ME CO,222
EN
NU 120 5
BE
PR 42 14 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABP
CO US 118
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
CO DI 119
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 338 S0
ME CO,223
EN
NU 214 2
BE
PR 60 14 "Progressivo "
FL "Z"
FI PROGBNP
US BNP
JOIN %BAN ALIAS 100 INTO CODTAB=CODTAB[1,10]
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
IN CODTAB[11,12] 214
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Progr." CODTAB[11,12]
DI "IBAN@27" S3
DI "Denominazione@50" 100@->S0
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 214 CODTAB[11,12]
OU 338 100@->S0
ME CO,224
EN
NU 222 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIP
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "N"
IN ABI 222
IN CAB 223
IN PROGPR 224
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "Progr." PROGPR
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 222 ABI
OU 223 CAB
OU 224 PROGPR
OU 338 %BAN->S0
OU 192 IBAN
EN
NU 223 5
BE
PR 42 14 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
NU 224 2
BE
PR 60 14 "Progressivo "
FL "ZH"
CH NORMAL
FI PROGBNP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
per la banca di presentazione.
Sono stati aggiunti campi CUP e CIG che hanno la ricerca sulla tabella ne caso normale e la ricerca sul file
commesse clienti nel caso sia presente l'analitica
Vanno aggiunti e posizionati ai profili personalizzati nel caso servano:
ST 215 15
BE
PR 2 11 "Cod.Unico Prog."
FL "U"
CH NORMAL
FI CUP
US %CUP
IN CODTAB 215
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 215 CODTAB
OU 216 S0
HE "Inserisci il Codice Unico di Progetto"
WA "Codice Unico di Progetto non trovato"
CH NORMAL
EN
ST 216 50
BE
PR 35 11 ""
FL ""
CH NORMAL
US %CUP KEY 2
IN S0 216
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 215
EN
ST 217 15
BE
PR 2 12 "Cod.Ident.Gara "
FL "U"
CH NORMAL
FI CIG
US %CIG
IN CODTAB 217
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 217 CODTAB
OU 218 S0
HE "Inserisci il Codice Identificativo Gara"
WA "Codice Identificativo Gara non trovato"
CH NORMAL
EN
ST 218 50
BE
PR 35 12 ""
FL ""
CH NORMAL
US %CIG KEY 2
IN S0 218
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 217
EN
ST 219 20
BE
PR 2 13 ""
FL "H"
FI CODCMS
EN
La generazione effetti scrive il CUP e il CIG sull'effetto.
La contabilizzazione scrive il CUP e il CIG sulle righe contabili.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21374 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-12-28 08:28:47 +00:00
|
|
|
|
#include "../cg/cfban.h"
|
|
|
|
|
#include "../ca/cfcms.h"
|
2005-08-23 08:54:32 +00:00
|
|
|
|
#include "../ca/calib01.h"
|
2007-11-16 13:46:49 +00:00
|
|
|
|
#include "../ca/commesse.h"
|
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
1999-06-18 15:35:05 +00:00
|
|
|
|
#define MAX_VIS_RATE 5
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2001-05-02 13:40:49 +00:00
|
|
|
|
bool numdocrif_hndl( TMask_field& field, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask&)field.mask();
|
|
|
|
|
TString16 campo = DOC_NUMDOCRIF;
|
|
|
|
|
if (field.field() != NULL)
|
|
|
|
|
campo = field.field()->name();
|
|
|
|
|
|
|
|
|
|
TRectype filtrec(LF_DOC);
|
|
|
|
|
filtrec.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
filtrec.put(DOC_CODCF, m.get(F_CODCF));
|
|
|
|
|
filtrec.put(DOC_PROVV, m.get(F_PROVV));
|
|
|
|
|
filtrec.put(DOC_ANNO, m.get(F_ANNO));
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_DOC);
|
|
|
|
|
TString sortkey = "TIPOCF|CODCF|PROVV|ANNO|CODNUM|"; sortkey << campo;
|
|
|
|
|
TSorted_cursor cur(&rel, sortkey, "", 2, &filtrec, &filtrec);
|
2008-03-26 11:24:36 +00:00
|
|
|
|
TString16 f; f.format("CODNUM==\"%s\"", (const char*)m.get(F_CODNUM));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
cur.setfilter(f);
|
|
|
|
|
|
|
|
|
|
filtrec.put(DOC_CODNUM, m.get(F_CODNUM));
|
|
|
|
|
filtrec.put(campo, field.get());
|
|
|
|
|
cur.curr() = filtrec;
|
|
|
|
|
cur.read(_isequal);
|
|
|
|
|
|
|
|
|
|
if (cur.file().status() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const long numdoc = m.get_long(F_NDOC);
|
|
|
|
|
if (numdoc != cur.curr().get_long(DOC_NDOC))
|
|
|
|
|
return yesno_box("Il numero di riferimento %s <20> gi<67> stato utilizzato\nsi desidera registrare ugualmente?",
|
|
|
|
|
(const char *)field.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2001-05-02 13:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool totdoc_hndl( TMask_field& field, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) field.mask();
|
|
|
|
|
const real totdoc = m.doc().totale_doc();
|
|
|
|
|
const real totdoc_check(field.get());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m.doc().physical_rows() > 0 && totdoc != totdoc_check)
|
|
|
|
|
{
|
|
|
|
|
const TString16 tchk(totdoc_check.string());
|
|
|
|
|
|
|
|
|
|
return yesno_box("Il totale documento digitato (%s) non corrisponde\nal totale documento (%s) calcolato,\n devo registrare ugualmente",
|
|
|
|
|
(const char *) tchk, totdoc.string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
}
|
2001-05-02 13:40:49 +00:00
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
bool smart_hndl( TMask_field& field, KEY key )
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_SPACE)
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) field.mask();
|
|
|
|
|
TSmart_card * s = m.smartcard();
|
|
|
|
|
|
|
|
|
|
if (s != NULL)
|
|
|
|
|
{
|
|
|
|
|
smartcard_error err = s->connect_card();
|
|
|
|
|
if (err == no_smarterror)
|
|
|
|
|
err = s->check_key(m);
|
|
|
|
|
if (err == no_smarterror)
|
|
|
|
|
{
|
|
|
|
|
s->card2mask(m);
|
|
|
|
|
if (s->with_card(m))
|
|
|
|
|
m.enable(DLG_SAVEREC);
|
|
|
|
|
m.disable(F_CODCF);
|
|
|
|
|
m.disable(F_RAGSOC);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
s->display_error(err);
|
|
|
|
|
if (err == new_card)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
if (m.get(F_CODCF).empty() && m.field(F_CODCF).on_key(K_F9) == false)
|
|
|
|
|
{
|
|
|
|
|
s->disconnect_card();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) field.mask();
|
|
|
|
|
TSmart_card * s = m.smartcard();
|
|
|
|
|
|
|
|
|
|
if (s != NULL && s->card_connected())
|
|
|
|
|
{
|
|
|
|
|
s->mask2card(m);
|
|
|
|
|
smartcard_error err = s->write();
|
|
|
|
|
if (err != no_smarterror)
|
|
|
|
|
s->display_error(err);
|
|
|
|
|
if (m.insert_mode() && m.doc().codice_numerazione().save_and_new())
|
|
|
|
|
s->disconnect_card();
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return true;
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-04 15:32:01 +00:00
|
|
|
|
bool fido_hndl(TMask_field& field, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER && !field.empty())
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask &) field.mask();
|
|
|
|
|
const real fido_bau(field.get());
|
|
|
|
|
const char tipocf = m.get(F_TIPOCF)[0];
|
|
|
|
|
const long codcf = m.get_long(F_CODCF);
|
|
|
|
|
const TDate& datadoc = m.get_date(F_DATADOC);
|
2009-03-19 15:50:58 +00:00
|
|
|
|
const int riskdays = ini_get_int(CONFIG_DITTA, "ve", "FIDO_RISKDAYS");
|
|
|
|
|
const real perc_toll = ini_get_string(CONFIG_DITTA, "ve", "FIDO_PERCTOLL");
|
2008-12-04 15:32:01 +00:00
|
|
|
|
//calcola l'esposizione PRIMA del documento corrente
|
|
|
|
|
const real esposizione = calcola_fido_cliente (tipocf, codcf, datadoc, riskdays);
|
|
|
|
|
//prende il valore del documento corrente
|
|
|
|
|
const real totdoc = m.doc().totale_doc();
|
|
|
|
|
//esposizione comprensiva del documento corrente
|
|
|
|
|
const real esposizione_totale = esposizione + totdoc;
|
|
|
|
|
const real fido_con_tolleranza = fido_bau * (CENTO + perc_toll) / CENTO;
|
|
|
|
|
|
|
|
|
|
if (esposizione_totale > fido_con_tolleranza)
|
|
|
|
|
return yesno_box(FR("Attenzione! Il cliente %ld risulta fuori fido.\nEsposizione corrente: %s\n"
|
|
|
|
|
"Tot. Doc. corrente: %s\nEsposizione totale: %s\nRegistrare ugualmente il documento?"),
|
|
|
|
|
codcf, esposizione.stringa(), totdoc.stringa(), esposizione_totale.stringa());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool ora_hndl( TMask_field& field, KEY key )
|
|
|
|
|
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (field.to_check(key,true))
|
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
TString16 ora;
|
|
|
|
|
|
|
|
|
|
if (field.automagic() && field.get().empty())
|
|
|
|
|
{
|
2008-06-13 08:45:21 +00:00
|
|
|
|
struct tm* t = xvt_time_now();
|
2005-02-17 18:13:12 +00:00
|
|
|
|
ora.format("%02d%02d", t->tm_hour, t->tm_min);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
field.set((ora));
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2005-02-17 18:13:12 +00:00
|
|
|
|
ora = field.get();
|
|
|
|
|
if (ora.not_empty())
|
|
|
|
|
{
|
2009-03-19 15:50:58 +00:00
|
|
|
|
if (!isdigit(ora[0]) || !isdigit(ora[1]) || !isdigit(ora[2]) ||
|
|
|
|
|
!isdigit(ora[3]) || atoi(ora.left(2)) > 23 || atoi(ora.mid(2)) > 59)
|
|
|
|
|
return error_box(TR("Ora errata"));
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (field.required())
|
2009-03-19 15:50:58 +00:00
|
|
|
|
return error_box(TR("Ora obbligatoria"));
|
2005-02-17 18:13:12 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2005-02-17 18:13:12 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dummy_hndl(TMask_field& field, KEY key)
|
|
|
|
|
{
|
2009-03-19 15:50:58 +00:00
|
|
|
|
warning_box(FR("Al campo %d <20> arrivato un KEY %d"), field.dlg( ), key );
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handler per il calcolo delle date di pagamento
|
|
|
|
|
bool condpag_hndl( TMask_field& field, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask &) field.mask( );
|
|
|
|
|
|
|
|
|
|
if ( field.to_check(key) || (key == K_TAB && !m.is_running()))
|
|
|
|
|
{
|
|
|
|
|
const TString& condpag = m.get(F_CODPAG);
|
|
|
|
|
if (condpag.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TDocumento& doc = m.doc();
|
|
|
|
|
// Aggiorna dati necessari per determinare il pagamento
|
|
|
|
|
doc.put(DOC_CODPAG, condpag);
|
|
|
|
|
doc.put(DOC_DATADOC, m.get(F_DATADOC));
|
|
|
|
|
doc.put(DOC_DATAINSC, m.get(F_DATAINSC));
|
|
|
|
|
doc.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
doc.put(DOC_CODCF, m.get(F_CODCF));
|
|
|
|
|
TPagamento& pag = doc.pagamento();
|
|
|
|
|
pag.set_total(CENTO, real(10), real(10));
|
|
|
|
|
pag.set_rate_auto();
|
|
|
|
|
|
|
|
|
|
const int numrate = pag.n_rate( );
|
|
|
|
|
for(int i = 0; i < MAX_VIS_RATE; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i < numrate)
|
|
|
|
|
{
|
|
|
|
|
m.show(F_DATASCAD1+i);
|
|
|
|
|
m.set(F_DATASCAD1+i, pag.data_rata(i));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m.hide(F_DATASCAD1+i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool note_hndl( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask &) f.mask();
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && (f.focusdirty() || !m.is_running()))
|
|
|
|
|
{
|
|
|
|
|
const TRectype& note = cache().get("%NOT", f.get());
|
|
|
|
|
if (!note.empty())
|
|
|
|
|
{
|
|
|
|
|
if (m.is_running() || m.field(F_NOTECLI).empty()) // Preserva descrizione presente in caricamento
|
|
|
|
|
{
|
2011-04-04 13:30:08 +00:00
|
|
|
|
if (!note.get_bool("B1"))
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2011-04-04 13:30:08 +00:00
|
|
|
|
// gestione del campo con descrizione estesa
|
|
|
|
|
TString stringone;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
const char fieldname[3] = { 'S', i+'0', '\0' };
|
|
|
|
|
stringone << note.get(fieldname);
|
|
|
|
|
}
|
|
|
|
|
stringone.replace(char(0xB6), '\n');
|
|
|
|
|
m.set(F_NOTECLI, stringone);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2011-05-04 13:03:37 +00:00
|
|
|
|
else
|
|
|
|
|
message_box(FR("Attenzione : %s"), (const char*)note.get("S0"));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2011-04-04 13:30:08 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (m.doc().modificabile() && m.field(DLG_SAVEREC).enabled())
|
|
|
|
|
{
|
|
|
|
|
const bool reg_disabled = note.get_bool("B0");
|
|
|
|
|
if (reg_disabled)
|
|
|
|
|
{
|
|
|
|
|
message_box(FR("Registrazione disabilitata : %s"), (const char*)note.get("S0"));
|
|
|
|
|
m.disable(DLG_SAVEREC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handler per il calcolo delle date di pagamento
|
|
|
|
|
bool data_hndl( TMask_field& field, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& m = (TDocumento_mask &) field.mask();
|
|
|
|
|
if (field.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
if (m.id2pos(F_DATAINSC) >= 0)
|
|
|
|
|
{
|
|
|
|
|
TEdit_field & e = m.efield(F_DATAINSC);
|
|
|
|
|
e.set_dirty();
|
|
|
|
|
e.on_hit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m.id2pos(F_DATACAMBIO1) >= 0 && !m.get(F_CODVAL).empty())
|
|
|
|
|
m.set(F_DATACAMBIO1, field.get(), true);
|
|
|
|
|
}
|
|
|
|
|
if (key == K_ENTER || field.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
const TDate datadoc(m.get(F_DATADOC));
|
|
|
|
|
if (!datadoc.ok())
|
|
|
|
|
return field.error_box("La data documento deve essere comunque indicata.");
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
if (m.id2pos(F_DATACAMBIO1) >= 0 && !m.get(F_CODVAL).empty())
|
|
|
|
|
m.set(F_DATACAMBIO1, field.get(), TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (key == K_ENTER || field.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
const TDate datadoc(m.get(F_DATADOC));
|
2008-03-26 11:24:36 +00:00
|
|
|
|
const int annodoc = m.get_int(F_ANNO);
|
|
|
|
|
if (datadoc.year() != annodoc)
|
|
|
|
|
{
|
|
|
|
|
if (datadoc.ok())
|
|
|
|
|
return field.error_box(TR("La data documento deve appartenere all'anno %d"), annodoc);
|
|
|
|
|
else
|
|
|
|
|
return field.error_box(TR("La data documento deve essere comunque indicata"));
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const TCodice_numerazione codnum(m.get(F_CODNUM));
|
|
|
|
|
if (codnum.test_eser())
|
|
|
|
|
{
|
2008-10-07 00:50:22 +00:00
|
|
|
|
if (esercizi().date2esc(datadoc) <= 0)
|
2004-09-03 13:52:59 +00:00
|
|
|
|
return field.error_box("La data documento non appartiene ad un esercizio valido.");
|
|
|
|
|
if (main_app().has_module(CGAUT))
|
|
|
|
|
{
|
|
|
|
|
const TTipo_documento& td = m.doc().tipo();
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString4 codcaus = td.causale();
|
2004-09-03 13:52:59 +00:00
|
|
|
|
if (codcaus.empty())
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const TRectype& clifo = m.doc().clifor().vendite();
|
|
|
|
|
codcaus = clifo.get("CODCAUS");
|
2004-09-03 13:52:59 +00:00
|
|
|
|
}
|
|
|
|
|
if (codcaus.not_empty())
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const int year = datadoc.year();
|
|
|
|
|
TCausale caus;
|
|
|
|
|
if (!caus.read(codcaus, year))
|
|
|
|
|
return error_box(TR("Causale assente!")); // L'errore viene segnalato nella read
|
2004-09-03 13:52:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
if (codnum.dont_test_datadoc())
|
|
|
|
|
return true; // Non devo fare altri test
|
|
|
|
|
|
|
|
|
|
TLocalisamfile doc(LF_DOC);
|
|
|
|
|
|
|
|
|
|
doc.curr() = m.doc().head();
|
|
|
|
|
bool same_key = false;
|
|
|
|
|
|
|
|
|
|
doc.read(_isgteq);
|
|
|
|
|
if (doc.eof() || doc.prev() == NOERR)
|
|
|
|
|
{
|
2008-03-26 11:24:36 +00:00
|
|
|
|
const TDate dataprev = doc.get_date(DOC_DATADOC);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
same_key = doc.curr().same_key(m.doc().head(), 1, 1);
|
|
|
|
|
if (same_key && datadoc < dataprev)
|
|
|
|
|
return field.error_box("Data documento inferiore alla data del documento precedente");
|
2006-04-18 16:26:03 +00:00
|
|
|
|
}
|
2008-03-26 11:24:36 +00:00
|
|
|
|
|
|
|
|
|
doc.curr() = m.doc().head();
|
|
|
|
|
doc.read(_isgreat);
|
|
|
|
|
same_key = doc.curr().same_key(m.doc().head(), 1, 1);
|
|
|
|
|
if (doc.good() && same_key && datadoc > doc.get_date(DOC_DATADOC))
|
|
|
|
|
return field.error_box("Data documento superiore alla data del documento successivo");
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2008-12-03 08:47:27 +00:00
|
|
|
|
// handler di campi delle maschere di riga
|
2008-12-04 10:19:38 +00:00
|
|
|
|
void TDocumento_mask::user_set_row_handler(TMask& rm, short field, int index)
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
2008-12-03 08:47:27 +00:00
|
|
|
|
switch (index)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2008-12-03 08:47:27 +00:00
|
|
|
|
case 1: rm.set_handler( field, pricerange_handler ); break;
|
|
|
|
|
case 2: rm.set_handler( field, dummy_hndl ); break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (field == FR_CODART)
|
|
|
|
|
rm.set_handler( field, search_price_handler );
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (field == FR_CODART)
|
|
|
|
|
rm.set_handler( field, find_price_handler );
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (field == FR_CODART)
|
|
|
|
|
rm.set_handler( field, link_row_handler );
|
|
|
|
|
break;
|
2008-12-09 15:22:23 +00:00
|
|
|
|
case 6:
|
|
|
|
|
if (field == FR_CODART)
|
|
|
|
|
rm.set_handler( field, evasion_check_handler );
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
if (field == FR_CODART)
|
|
|
|
|
rm.set_handler(field, distinta_link_handler);
|
|
|
|
|
break;
|
2009-02-06 13:46:58 +00:00
|
|
|
|
case 8:
|
|
|
|
|
if (field >= FR_LIV1 && field <= FR_LIV4)
|
2009-02-06 13:49:06 +00:00
|
|
|
|
rm.set_handler(field, gen_livelli_handler);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
break;
|
2008-12-09 15:22:23 +00:00
|
|
|
|
default:
|
2008-12-03 08:47:27 +00:00
|
|
|
|
break;
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2008-12-03 08:47:27 +00:00
|
|
|
|
HIDDEN TString4 curr_um;
|
2008-03-26 11:24:36 +00:00
|
|
|
|
HIDDEN real curr_fc = UNO;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
bool iva_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) f.mask().get_sheet()->mask();
|
|
|
|
|
|
2008-03-26 11:24:36 +00:00
|
|
|
|
if (key == 0 || (key == K_ENTER && f.empty()))
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2009-07-09 15:31:20 +00:00
|
|
|
|
const TString& codiva = mask.condv().clifo().vendite().get(CFV_ASSFIS);
|
|
|
|
|
if (codiva.full())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
f.set(codiva);
|
|
|
|
|
f.check();
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (key == 0 || (key == K_ENTER && f.empty()))
|
2006-04-13 17:56:02 +00:00
|
|
|
|
{
|
2009-07-09 15:31:20 +00:00
|
|
|
|
const TString& codiva = mask.doc().codesiva();
|
|
|
|
|
if (codiva.full())
|
2006-04-13 17:56:02 +00:00
|
|
|
|
f.set(codiva);
|
|
|
|
|
f.check();
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-09 15:31:20 +00:00
|
|
|
|
if (key == K_ENTER && /*f.focusdirty() &&*/ f.empty())
|
2006-04-13 17:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
TMask & row_mask = f.mask();
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const int r = row_mask.get_sheet()->selected() + 1;
|
|
|
|
|
const TRiga_documento& riga = mask.doc()[r];
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
|
|
|
|
const int pos_ai = row_mask.id2pos(FR_ADDIVA);
|
|
|
|
|
bool addiva = false;
|
|
|
|
|
|
|
|
|
|
if (pos_ai >= 0)
|
|
|
|
|
addiva = row_mask.fld(pos_ai).get() == "X"; // Controlla le righe Omaggio solo se e' settato l'addebito IVA
|
|
|
|
|
|
|
|
|
|
const bool check = riga.is_merce() || riga.is_spese() || riga.is_prestazione() ||
|
|
|
|
|
(riga.is_omaggio() && addiva);
|
|
|
|
|
|
|
|
|
|
if (check)
|
|
|
|
|
{
|
|
|
|
|
const int pos_p = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
const int pos_q = row_mask.id2pos(FR_QTA);
|
|
|
|
|
const bool pe = pos_p >= 0 && row_mask.fld(pos_p).enabled();
|
|
|
|
|
const bool qe = pos_q >= 0 && row_mask.fld(pos_q).enabled();
|
|
|
|
|
const bool pf = pe && row_mask.fld(pos_p).get().not_empty();
|
|
|
|
|
const bool qf = qe && row_mask.fld(pos_q).get().not_empty();
|
|
|
|
|
const bool required = pf && !(qe && !qf);
|
|
|
|
|
if (required)
|
|
|
|
|
return f.error_box("Il codice IVA e' obbligatorio.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
|
|
|
|
bool dcons_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& s = *row_mask.get_sheet();
|
2004-11-30 22:02:59 +00:00
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &) s.mask();
|
2009-06-11 01:02:50 +00:00
|
|
|
|
const int r0 = f.mask().get_sheet()->selected() + 1;
|
|
|
|
|
int r = r0 + 1;
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
bool multiple_rows = (r <= doc.physical_rows());
|
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
if (r > 1)
|
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
if (multiple_rows)
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
const TString codart = doc[r].get(RDOC_CODART);
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2009-06-11 01:02:50 +00:00
|
|
|
|
multiple_rows = codart == doc[r0].get(RDOC_CODART);
|
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2009-06-11 01:02:50 +00:00
|
|
|
|
if (multiple_rows)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento& prev = doc[r - 1];
|
|
|
|
|
TDate first_date = prev.get_date(RDOC_DATACONS);
|
|
|
|
|
TDate second_date = doc[r].get_date(RDOC_DATACONS);
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2009-06-11 01:02:50 +00:00
|
|
|
|
if (!second_date.ok())
|
|
|
|
|
second_date = mask.get_date(F_DATACONS);
|
|
|
|
|
if (second_date.ok())
|
|
|
|
|
{
|
|
|
|
|
if (!first_date.ok())
|
|
|
|
|
first_date = mask.get_date(F_DATACONS);
|
|
|
|
|
if (first_date.ok())
|
|
|
|
|
{
|
|
|
|
|
if (second_date.is_end_month() && first_date.is_end_month())
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
int year = second_date.year();
|
|
|
|
|
int month = second_date.month();
|
|
|
|
|
const int months = ( year * 12 + month) - (first_date.year() * 12 + first_date.month());
|
|
|
|
|
const TString80 cod = doc[r].get(RDOC_CODART);
|
2004-11-30 22:02:59 +00:00
|
|
|
|
if (months > 0)
|
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
for (r++ ; r <= doc.physical_rows() && cod == doc[r].get(RDOC_CODART); r++)
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r];
|
|
|
|
|
TToken_string & tr = s.row(r - 1);
|
|
|
|
|
|
2009-06-11 01:02:50 +00:00
|
|
|
|
month += months;
|
|
|
|
|
if (month > 12)
|
|
|
|
|
{
|
|
|
|
|
year++;
|
|
|
|
|
month -= 12;
|
|
|
|
|
}
|
|
|
|
|
TDate d(1, month, year);
|
|
|
|
|
|
|
|
|
|
d.set_end_month();
|
|
|
|
|
riga.put(RDOC_DATACONS, d);
|
2004-11-30 22:02:59 +00:00
|
|
|
|
tr.add(riga.get(RDOC_DATACONS), s.cid2index(FR_DATACONS));
|
|
|
|
|
}
|
|
|
|
|
s.force_update();
|
|
|
|
|
}
|
2009-06-11 01:02:50 +00:00
|
|
|
|
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-06-11 01:02:50 +00:00
|
|
|
|
if (second_date.day() == first_date.day())
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
const int months = ( second_date.year() * 12 + second_date.month()) - (first_date.year() * 12 + first_date.month());
|
|
|
|
|
if (months > 0)
|
2004-11-30 22:02:59 +00:00
|
|
|
|
{
|
2009-06-11 01:02:50 +00:00
|
|
|
|
const TString80 cod = doc[r].get(RDOC_CODART);
|
|
|
|
|
for (r++ ; r <= doc.physical_rows() && cod == doc[r].get(RDOC_CODART); r++)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r];
|
|
|
|
|
TToken_string & tr = s.row(r - 1);
|
|
|
|
|
|
|
|
|
|
second_date.addmonth(months);
|
|
|
|
|
riga.put(RDOC_DATACONS, second_date);
|
|
|
|
|
tr.add(riga.get(RDOC_DATACONS), s.cid2index(FR_DATACONS));
|
|
|
|
|
}
|
|
|
|
|
s.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const int days = second_date - first_date;
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2009-06-11 01:02:50 +00:00
|
|
|
|
if (days > 0)
|
|
|
|
|
{
|
|
|
|
|
const TString80 cod = doc[r].get(RDOC_CODART);
|
|
|
|
|
for (r++ ; r <= doc.physical_rows() && cod == doc[r].get(RDOC_CODART); r++)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r];
|
|
|
|
|
TToken_string & tr = s.row(r - 1);
|
|
|
|
|
|
|
|
|
|
second_date += days;
|
|
|
|
|
riga.put(RDOC_DATACONS, second_date);
|
|
|
|
|
tr.add(riga.get(RDOC_DATACONS), s.cid2index(FR_DATACONS));
|
|
|
|
|
}
|
|
|
|
|
s.force_update();
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-11 01:02:50 +00:00
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-11 01:02:50 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc.insert_row(r, doc[r - 1].tipo().codice());
|
|
|
|
|
|
|
|
|
|
TDocumento::copy_data(riga, doc[r - 1]);
|
|
|
|
|
s.insert(r - 1);
|
2010-09-21 11:21:30 +00:00
|
|
|
|
s.post_select(r - 1);
|
2009-06-11 01:02:50 +00:00
|
|
|
|
|
|
|
|
|
TToken_string & tr = s.row(r - 1);
|
|
|
|
|
|
|
|
|
|
riga.zero(RDOC_QTA);
|
|
|
|
|
riga.zero(RDOC_DATACONS);
|
|
|
|
|
riga.autoload(s);
|
|
|
|
|
// tr.add("", s.cid2index(FR_QTA));
|
|
|
|
|
// tr.add("", s.cid2index(FR_DATACONS));
|
|
|
|
|
s.check_row(r - 1);
|
|
|
|
|
s.force_update();
|
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return true;
|
2004-11-30 22:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-05-25 11:32:58 +00:00
|
|
|
|
bool tipo_riga_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (key == K_SPACE && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask & row_mask = f.mask();
|
2005-05-25 11:32:58 +00:00
|
|
|
|
TVariable_sheet_field * sf = (TVariable_sheet_field *) row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
if (sf != NULL)
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask & docmask = (TDocumento_mask&)sf->mask();
|
|
|
|
|
if (docmask.is_running())
|
|
|
|
|
{
|
|
|
|
|
const int curr_row = sf->selected();
|
|
|
|
|
TToken_string & row = sf->row(curr_row);
|
2009-05-28 13:57:51 +00:00
|
|
|
|
const TString16 old_tipo_riga = docmask.doc()[curr_row + 1].get(RDOC_TIPORIGA);
|
2005-05-25 11:32:58 +00:00
|
|
|
|
const TString16 tipo_riga = f.get();
|
|
|
|
|
|
2009-05-28 13:57:51 +00:00
|
|
|
|
if (old_tipo_riga != tipo_riga)
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
2009-05-28 13:57:51 +00:00
|
|
|
|
if (!row_mask.is_running())
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
|
|
|
|
docmask.doc()[curr_row + 1].set_tipo(tipo_riga);
|
|
|
|
|
sf->post_insert(curr_row);
|
|
|
|
|
sf->check_row(curr_row);
|
|
|
|
|
sf->force_update(curr_row);
|
|
|
|
|
}
|
2009-05-28 13:57:51 +00:00
|
|
|
|
else
|
2005-05-25 11:32:58 +00:00
|
|
|
|
{
|
|
|
|
|
f.set(old_tipo_riga);
|
2009-05-28 13:57:51 +00:00
|
|
|
|
return f.error_box("Impossibile cambiare il tipo nella maschera di riga");
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
2009-05-28 13:57:51 +00:00
|
|
|
|
}
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2005-05-25 11:32:58 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
1998-04-30 14:04:19 +00:00
|
|
|
|
bool codmag_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2006-04-13 17:56:02 +00:00
|
|
|
|
// if (f.to_check(key, true))
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sf = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& docmask = (TDocumento_mask&)sf.mask();
|
|
|
|
|
|
|
|
|
|
if (sf.column_enabled(sf.cid2index(FR_CODDEP)))
|
|
|
|
|
{
|
|
|
|
|
const int pos = row_mask.id2pos(FR_CODDEP);
|
|
|
|
|
const TString & val = f.get();
|
|
|
|
|
|
|
|
|
|
if (pos >= 0 && val.not_empty())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& mag = cache().get("MAG", val);
|
|
|
|
|
const bool active = mag.get_bool("B0");
|
|
|
|
|
row_mask.fld(pos).enable(active);
|
|
|
|
|
if (!active)
|
|
|
|
|
row_mask.fld(pos).reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
|
if (f.get().empty() && docmask.doc().tipo().mov_mag())
|
|
|
|
|
return f.error_box("Indicare il magazzino.");
|
|
|
|
|
|
|
|
|
|
docmask.update_giacenza();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
1998-04-30 14:04:19 +00:00
|
|
|
|
|
|
|
|
|
bool codmag_coll_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2006-04-13 17:56:02 +00:00
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sf = *row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
if (sf.column_enabled( ((TSheet_field &)f).cid2index(FR_CODDEPC)))
|
|
|
|
|
{
|
|
|
|
|
const int pos = row_mask.id2pos(FR_CODDEPC);
|
|
|
|
|
const TString & val = f.get();
|
|
|
|
|
|
|
|
|
|
if (pos >= 0 && val.not_empty())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& mag = cache().get("MAG", val);
|
|
|
|
|
const bool active = mag.get_bool("B0");
|
|
|
|
|
row_mask.fld(pos).enable(active);
|
|
|
|
|
if (!active)
|
|
|
|
|
row_mask.fld(pos).reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
1998-04-30 14:04:19 +00:00
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2008-10-07 00:50:22 +00:00
|
|
|
|
void upd_colli_peso_tara(TMask& m, const TString & codart)
|
1999-05-24 13:34:11 +00:00
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
// const real qta = m.get_real(FR_QTA) * curr_fc; // curr_fc puo' non essere inizializzata e vale -1
|
|
|
|
|
// Usando il metodo apposito di TArticolo non si sbaglia micca mai.
|
|
|
|
|
// Sarebbe bene sparare (come dice Luca) a curr_fc ovunque copaia
|
2008-10-07 00:50:22 +00:00
|
|
|
|
TArticolo & articolo = cached_article(codart);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const real qta = articolo.convert_to_um(m.get_real(FR_QTA), NULL, m.get(FR_UMQTA));
|
|
|
|
|
|
2008-10-07 00:50:22 +00:00
|
|
|
|
const real ppcollo = articolo.get_real(ANAMAG_PPCOLLO);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
real ncolli = ppcollo.is_zero() ? UNO : qta / ppcollo;
|
|
|
|
|
ncolli.ceil(0);
|
|
|
|
|
|
|
|
|
|
int pos = m.id2pos(FR_NCOLLI);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
if (ppcollo != ZERO)
|
|
|
|
|
m.fld(pos).set(ncolli.string());
|
|
|
|
|
else
|
|
|
|
|
m.fld(pos).reset();
|
|
|
|
|
|
|
|
|
|
pos = m.id2pos(FR_TARA);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
2008-10-07 00:50:22 +00:00
|
|
|
|
const real tara = ncolli * articolo.get_real(ANAMAG_TARA);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
m.fld(pos).set(tara.string());
|
|
|
|
|
}
|
|
|
|
|
pos = m.id2pos(FR_PNETTO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
2008-10-07 00:50:22 +00:00
|
|
|
|
const real peso = qta * articolo.get_real(ANAMAG_PESO);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
m.fld(pos).set(peso.string());
|
|
|
|
|
}
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2001-06-25 10:41:20 +00:00
|
|
|
|
bool pricerange_handler(TMask_field& f, KEY key )
|
2006-04-13 17:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
|
|
|
|
|
if (mask.doc().tipo().controllo_prezzi())
|
|
|
|
|
{
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
TRiga_documento & riga = mask.doc()[current_doc_row];
|
|
|
|
|
const real old_price = riga.get_real(RDOC_PREZZO);
|
|
|
|
|
const real new_price = row_mask.get_real(FR_PREZZO);
|
|
|
|
|
|
|
|
|
|
if (!old_price.is_zero())
|
|
|
|
|
{
|
|
|
|
|
const TTipo_riga_documento& tipo_riga = riga.tipo();
|
|
|
|
|
const int incr = tipo_riga.incr_perc_prezzo();
|
|
|
|
|
const int decr = tipo_riga.decr_perc_prezzo();
|
|
|
|
|
|
|
|
|
|
if (incr == 0 && decr == 0)
|
|
|
|
|
{
|
|
|
|
|
if (old_price != new_price && !yesno_box("Il prezzo <20> variato, confermare"))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
real inf = old_price * (UNO - (decr/CENTO));
|
|
|
|
|
if (inf > new_price && !yesno_box("Il prezzo <20> diminuito di pi<70> del %d%%, confermare", decr))
|
|
|
|
|
return false;
|
|
|
|
|
real sup = old_price * (UNO + (incr/CENTO));
|
|
|
|
|
if (sup < new_price && !yesno_box("Il prezzo <20> aumentato di pi<70> del %d%%, confermare", incr))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
riga.put(RDOC_PREZZO, new_price);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
static bool __in_handler = false;
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
static int sort_sheet(const TObject** a, const TObject** b)
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string * t1 = (TToken_string *) *a;
|
|
|
|
|
TToken_string * t2 = (TToken_string *) *b;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const char * a1 = t1->get(2);
|
|
|
|
|
const char * a2 = t2->get(2);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
int cmp = strcmp(a1, a2);
|
|
|
|
|
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
{
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TDate d1(t1->get(1));
|
|
|
|
|
TDate d2(t2->get(1));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
cmp = d2 - d1;
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
return t2->get_int(8) - t1->get_int(8);
|
|
|
|
|
}
|
|
|
|
|
return cmp;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
// Classe indispensabile alla Sig.ra Firpo
|
|
|
|
|
class TPrice_sheet : public TArray_sheet
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& _fld;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool get_ini_paragraph(const TEdit_field& f, TString& name) const;
|
|
|
|
|
|
2009-10-20 15:37:29 +00:00
|
|
|
|
virtual long handler(WINDOW win, EVENT* ep);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TEdit_field& field() { return _fld; }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TPrice_sheet(TEdit_field& f);
|
|
|
|
|
};
|
|
|
|
|
|
2009-10-20 15:37:29 +00:00
|
|
|
|
long TPrice_sheet::handler(WINDOW win, EVENT* ep)
|
2007-09-17 15:33:04 +00:00
|
|
|
|
{
|
|
|
|
|
if (ep->type == E_MOUSE_DOWN)
|
|
|
|
|
{
|
|
|
|
|
switch (ep->v.mouse.button )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR);
|
2009-10-07 15:35:29 +00:00
|
|
|
|
if (menu != NULL && menu->child != NULL)
|
2007-09-17 15:33:04 +00:00
|
|
|
|
{
|
|
|
|
|
dictionary_translate_menu(menu);
|
|
|
|
|
const PNT& p = ep->v.mouse.where;
|
|
|
|
|
RCT cr; xvt_vobj_get_client_rect(win, &cr);
|
|
|
|
|
XVT_POPUP_ALIGNMENT pa = XVT_POPUP_CENTER;
|
|
|
|
|
if (p.h < cr.right / 3)
|
|
|
|
|
pa = XVT_POPUP_LEFT_ALIGN;
|
|
|
|
|
else
|
|
|
|
|
if (p.h > 2 * cr.right / 3)
|
|
|
|
|
pa = XVT_POPUP_RIGHT_ALIGN;
|
|
|
|
|
|
|
|
|
|
xvt_menu_popup(menu->child, win, p, pa, NULL);
|
|
|
|
|
xvt_res_free_menu_tree(menu);
|
|
|
|
|
}
|
2009-10-20 15:37:29 +00:00
|
|
|
|
return 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (ep->type == E_COMMAND)
|
|
|
|
|
{
|
|
|
|
|
switch (ep->v.cmd.tag)
|
|
|
|
|
{
|
|
|
|
|
case BROWSE_BAR + 1:
|
|
|
|
|
save_columns_order(field());
|
2009-10-20 15:37:29 +00:00
|
|
|
|
return 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
case BROWSE_BAR + 2:
|
|
|
|
|
set_columns_order(NULL);
|
2009-10-20 15:37:29 +00:00
|
|
|
|
return 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
case BROWSE_BAR + 3:
|
|
|
|
|
fld(0).on_key(K_F11);
|
2009-10-20 15:37:29 +00:00
|
|
|
|
return 0;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-20 15:37:29 +00:00
|
|
|
|
return TArray_sheet::handler(win, ep);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPrice_sheet::get_ini_paragraph(const TEdit_field& field, TString& parag) const
|
|
|
|
|
{
|
|
|
|
|
const bool ok = TSheet::get_ini_paragraph(field, parag);
|
|
|
|
|
if (ok)
|
|
|
|
|
parag << "_F80";
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPrice_sheet::TPrice_sheet(TEdit_field& f)
|
|
|
|
|
: TArray_sheet(0, 3, -1, 16, TR("Ricerca Prezzi"),
|
|
|
|
|
HR("Num.|Data@10|Codice articolo@20|Descrizione@40|Quantit<69>@15P|Prezzo@18P|Sconto@10|Numerazione@18|Tipo Documento@18"), 0, 1),
|
|
|
|
|
_fld(f)
|
|
|
|
|
{
|
|
|
|
|
load_columns_order(_fld);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void search_price(TEdit_field& f, KEY key )
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
2007-09-17 15:33:04 +00:00
|
|
|
|
|
|
|
|
|
TPrice_sheet sheet(f);
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
TString_array & el = sheet.rows_array();
|
|
|
|
|
TRelation * rel = new TRelation(LF_DOC);
|
|
|
|
|
TRectype from(rel->curr());
|
|
|
|
|
TRectype to(rel->curr());
|
|
|
|
|
TDate datadoc = mask.get_date(F_DATADOC);
|
|
|
|
|
const long codcf = mask.get_long(F_CODCF);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const long numdoc = mask.get_long(F_NDOC);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
const int last_anno = mask.get_int(F_ANNO);
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
|
|
|
|
|
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
|
|
|
|
|
const TString& tipocf = mask.get(F_TIPOCF);
|
|
|
|
|
|
|
|
|
|
from.put(DOC_TIPOCF, tipocf);
|
|
|
|
|
to.put(DOC_TIPOCF, tipocf);
|
|
|
|
|
from.put(DOC_CODCF, codcf);
|
|
|
|
|
to.put(DOC_CODCF, codcf);
|
|
|
|
|
from.put(DOC_PROVV, "D");
|
|
|
|
|
to.put(DOC_PROVV, "D");
|
|
|
|
|
from.put(DOC_ANNO, first_anno);
|
|
|
|
|
to.put(DOC_ANNO, last_anno);
|
|
|
|
|
to.put(DOC_DATADOC, datadoc);
|
|
|
|
|
|
|
|
|
|
if (nums.empty())
|
|
|
|
|
nums = mask.get(F_CODNUM);
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString4 first_num(nums.get(0));
|
|
|
|
|
TString4 last_num(first_num);;
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString filter;
|
|
|
|
|
filter << "((CODNUM==\"" << first_num << "\")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
for (const char * s = nums.get(); s && *s; s = nums.get())
|
|
|
|
|
{
|
|
|
|
|
if (first_num > s)
|
|
|
|
|
first_num = s;
|
|
|
|
|
if (last_num < s)
|
|
|
|
|
last_num = s;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
filter << "||(CODNUM==\"" << s << "\")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
}
|
2007-09-17 15:33:04 +00:00
|
|
|
|
filter << ")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TCursor cur(rel, filter, 2, &from, &to);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
const int items = cur.items();
|
|
|
|
|
cur.freeze();
|
|
|
|
|
TRecord_array r(LF_RIGHEDOC, RDOC_NRIGA);
|
|
|
|
|
TRectype rec(LF_RIGHEDOC);
|
|
|
|
|
|
|
|
|
|
for(cur = 0L; cur.pos() < items; ++cur)
|
|
|
|
|
{
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const TDate data(cur.curr().get(DOC_DATADOC));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
const TString80 num(cache().get("%NUM", cur.curr().get(DOC_CODNUM), "S0"));
|
|
|
|
|
const TString80 tipo(cache().get("%TIP", cur.curr().get(DOC_TIPODOC), "S0"));
|
|
|
|
|
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(RDOC_PROVV, cur.curr().get(DOC_PROVV));
|
|
|
|
|
rec.put(RDOC_ANNO, cur.curr().get(DOC_ANNO));
|
|
|
|
|
rec.put(RDOC_CODNUM, cur.curr().get(DOC_CODNUM));
|
|
|
|
|
rec.put(RDOC_NDOC, cur.curr().get(DOC_NDOC));
|
|
|
|
|
r.read(rec);
|
|
|
|
|
|
|
|
|
|
int last_row = r.last_row();
|
|
|
|
|
|
|
|
|
|
for (int i = r.first_row(); i <= last_row; i = r.succ_row(i))
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rdoc = r.row(i);
|
|
|
|
|
const TString & codart = rdoc.get(RDOC_CODART);
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (codart.full())
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
TToken_string row;
|
|
|
|
|
row.add(rdoc.get(RDOC_NDOC));
|
|
|
|
|
row.add(data);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
row.add(codart);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
row.add(rdoc.get(RDOC_DESCR));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row.add(rdoc.get(RDOC_QTA));
|
2007-09-17 15:33:04 +00:00
|
|
|
|
row.add(rdoc.get(RDOC_PREZZO));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row.add(rdoc.get(RDOC_SCONTO));
|
|
|
|
|
row.add(num);
|
|
|
|
|
row.add(tipo);
|
|
|
|
|
row.add(rdoc.get(RDOC_NRIGA));
|
|
|
|
|
el.add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
el.TArray::sort(sort_sheet);
|
|
|
|
|
|
|
|
|
|
const int max_rows = ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).max_rows_art();
|
|
|
|
|
|
|
|
|
|
if (max_rows > 0)
|
|
|
|
|
{
|
|
|
|
|
const int items = el.items();
|
|
|
|
|
TString80 last_cod;
|
|
|
|
|
long last_doc = 0L;
|
|
|
|
|
real last_price(ZERO);
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i = 0 ; i < items; i++)
|
|
|
|
|
{
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const TString & codart = el.row(i).get(2);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
long ndoc = el.row(i).get_long(0);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
real price(el.row(i).get(5));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
if (codart != last_cod)
|
|
|
|
|
{
|
|
|
|
|
last_cod = codart;
|
|
|
|
|
last_doc = ndoc;
|
|
|
|
|
last_price = price;
|
|
|
|
|
count = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ndoc == last_doc && price == last_price)
|
|
|
|
|
{
|
|
|
|
|
el.destroy(i);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
last_doc = ndoc;
|
|
|
|
|
last_price = price;
|
|
|
|
|
count++;
|
|
|
|
|
if (count > max_rows)
|
|
|
|
|
el.destroy(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
el.pack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
__in_handler = true;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const TToken_string& selected = sheet.row(-1);
|
|
|
|
|
|
|
|
|
|
real prezzo; selected.get(5, prezzo);
|
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
|
|
|
|
TString80 str; selected.get(2, str);
|
|
|
|
|
row_mask.set(FR_CODART, str, 3);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.field(FR_CODART).set_dirty(false);
|
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
selected.get(6, str);
|
|
|
|
|
row_mask.set(FR_SCONTO, str);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
__in_handler = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
class TPrice_article_sheet : public TBrowse_sheet
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool get_ini_paragraph(const TEdit_field& field, TString& parag) const;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TPrice_article_sheet(TCursor& cur, TEdit_field& f);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TPrice_article_sheet::get_ini_paragraph(const TEdit_field& field, TString& parag) const
|
|
|
|
|
{
|
|
|
|
|
const bool ok = TSheet::get_ini_paragraph(field, parag);
|
|
|
|
|
if (ok)
|
|
|
|
|
parag << "_F81";
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPrice_article_sheet::TPrice_article_sheet(TCursor& cur, TEdit_field& f)
|
2009-03-26 16:31:58 +00:00
|
|
|
|
: TBrowse_sheet(&cur, HR("NDOC|33->DATADOC|PREZZO|QTA|SCONTO|-201->S0|-202->S0"),
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TR("Ricerca Prezzi"),
|
|
|
|
|
HR("Num.|Data@10|Prezzo@18P|Quantit<69>@15P|Sconto@10|Numerazione@18|Tipo Documento@18"),
|
|
|
|
|
0, f, TToken_string())
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void search_price_article(TEdit_field& f, KEY key )
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
const TString80 codart(row_mask.get(FR_CODART));
|
|
|
|
|
TDate datadoc = mask.get_date(F_DATADOC);
|
|
|
|
|
const char tipocf = mask.get(F_TIPOCF)[0];
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const long codcf = mask.get_long(F_CODCF);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (nums.blank())
|
2006-07-11 13:12:41 +00:00
|
|
|
|
nums = mask.get(F_CODNUM);
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString4 first_num(nums.get(0));
|
|
|
|
|
TString4 last_num(first_num);
|
|
|
|
|
TString filter;
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
filter << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")";
|
|
|
|
|
FOR_EACH_TOKEN(nums, s)
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (first_num > s)
|
|
|
|
|
first_num = s;
|
|
|
|
|
if (last_num < s)
|
|
|
|
|
last_num = s;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
filter << "||(CODNUM==\"" << s << "\")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
}
|
2007-09-17 15:33:04 +00:00
|
|
|
|
filter << ")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
TRelation rel(LF_RIGHEDOC);
|
|
|
|
|
TRectype from(rel.curr());
|
|
|
|
|
TRectype to(rel.curr());
|
|
|
|
|
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
|
|
|
|
|
|
|
|
|
|
const int last_anno = mask.get_int(F_ANNO);
|
|
|
|
|
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
|
2008-11-14 14:40:28 +00:00
|
|
|
|
TString80 livello;
|
|
|
|
|
|
|
|
|
|
for (int l = 0; l<4 ; l++)
|
|
|
|
|
mask.doc().livelli().pack_grpcode(livello, row_mask.get(FR_LIV1 + l),l + 1);
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
from.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
from.put(RDOC_LIVELLO, livello);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
from.put(RDOC_CODNUM, first_num);
|
|
|
|
|
from.put(RDOC_ANNO, first_anno);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
from.put(RDOC_PROVV, 'D');
|
2006-07-11 13:12:41 +00:00
|
|
|
|
to.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
to.put(RDOC_LIVELLO, livello);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
to.put(RDOC_CODNUM, last_num);
|
|
|
|
|
to.put(RDOC_ANNO, last_anno);
|
2007-09-17 15:33:04 +00:00
|
|
|
|
to.put(RDOC_PROVV, 'D');
|
|
|
|
|
TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", filter, 5, &from, &to);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
cur.items();
|
|
|
|
|
cur.freeze();
|
|
|
|
|
cur.relation()->add("%NUM", "CODTAB==CODNUM", 1, 0, 201);
|
|
|
|
|
cur.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 202);
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TPrice_article_sheet sheet(cur, f);
|
|
|
|
|
sheet.add_string (FR_DESCR, 0, "", 38, 0, 50, "D", 30);
|
|
|
|
|
sheet.set(FR_CODART, codart);
|
|
|
|
|
sheet.set(FR_DESCR, cache().get(LF_ANAMAG, codart, "DESCR"));
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
__in_handler = true;
|
2009-03-26 16:31:58 +00:00
|
|
|
|
row_mask.set(FR_CODART, codart, 0x3);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.field(FR_CODART).set_dirty(false);
|
|
|
|
|
__in_handler = false;
|
2009-03-26 16:31:58 +00:00
|
|
|
|
TToken_string& row = sheet.row(-1);
|
|
|
|
|
const TString& prezzo = row.get(2);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
2009-03-26 16:31:58 +00:00
|
|
|
|
const TString& sconto = row.get(4);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.set(FR_SCONTO, sconto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool search_price_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
if (key == K_F8 && !sh.sheet_mask().is_running())
|
|
|
|
|
{
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TEdit_field& ef = (TEdit_field&)f;
|
|
|
|
|
const TString& codart = row_mask.get(FR_CODART);
|
|
|
|
|
if (codart.blank())
|
|
|
|
|
search_price(ef, key);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
else
|
2007-09-17 15:33:04 +00:00
|
|
|
|
search_price_article(ef,key);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if ((key == K_TAB && f.focusdirty()))
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
const TCodice_articolo codart = row_mask.get(FR_CODART);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
if (!__in_handler && codart.full() && row_mask.get(FR_PREZZO).empty())
|
2006-07-11 13:12:41 +00:00
|
|
|
|
{
|
|
|
|
|
TDate datadoc = mask.get_date(F_DATADOC);
|
|
|
|
|
const char tipocf = mask.get(F_TIPOCF)[0];
|
2009-03-26 16:31:58 +00:00
|
|
|
|
const long codcf = mask.get_long(F_CODCF);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
|
|
|
|
|
TToken_string nums(((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_nums());
|
|
|
|
|
|
|
|
|
|
if (nums.empty())
|
|
|
|
|
nums = mask.get(F_CODNUM);
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
TString4 first_num(nums.get(0));
|
|
|
|
|
TString4 last_num(first_num);;
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
|
|
|
|
TString form;
|
2009-03-26 16:31:58 +00:00
|
|
|
|
form << "(33->TIPOCF==\"" << tipocf << "\")&&(33->CODCF==\"" << codcf << "\")&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")" << "&&((CODNUM==\"" << first_num << "\")";
|
2006-07-11 13:12:41 +00:00
|
|
|
|
for (const char * s = nums.get(); s && *s; s = nums.get())
|
|
|
|
|
{
|
|
|
|
|
if (first_num > s)
|
|
|
|
|
first_num = s;
|
|
|
|
|
if (last_num < s)
|
|
|
|
|
last_num = s;
|
|
|
|
|
form << "||(CODNUM==\"" << s << "\")";
|
|
|
|
|
}
|
|
|
|
|
form << ")";
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_RIGHEDOC);
|
|
|
|
|
TRectype from(rel.curr());
|
|
|
|
|
TRectype to(rel.curr());
|
|
|
|
|
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
|
|
|
|
|
|
|
|
|
|
const int last_anno = mask.get_int(F_ANNO);
|
|
|
|
|
const int first_anno = last_anno - ((TTipo_riga_documento&)mask.doc()[current_doc_row].tipo()).search_years();
|
2008-11-14 14:40:28 +00:00
|
|
|
|
TString80 livello;
|
|
|
|
|
|
|
|
|
|
for (int l = 0; l<4 ; l++)
|
|
|
|
|
mask.doc().livelli().pack_grpcode(livello, row_mask.get(FR_LIV1 + l),l + 1);
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
from.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
from.put(RDOC_LIVELLO, livello);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
from.put(RDOC_CODNUM, first_num);
|
|
|
|
|
from.put(RDOC_ANNO, first_anno);
|
|
|
|
|
from.put(RDOC_PROVV, "D");
|
|
|
|
|
to.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
to.put(RDOC_LIVELLO, livello);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
to.put(RDOC_CODNUM, last_num);
|
|
|
|
|
to.put(RDOC_ANNO, last_anno);
|
|
|
|
|
to.put(RDOC_PROVV, "D");
|
|
|
|
|
|
|
|
|
|
TSorted_cursor cur(&rel, "33->DATADOC-|CODNUM|NDOC-", "", 5, &from, &to);
|
|
|
|
|
cur.setfilter(form, true);
|
|
|
|
|
if (cur.items() > 0L)
|
|
|
|
|
{
|
|
|
|
|
cur = 0L;
|
|
|
|
|
__in_handler = true;
|
2009-03-26 16:31:58 +00:00
|
|
|
|
row_mask.set(FR_CODART, codart, 0x3);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.field(FR_CODART).set_dirty(false);
|
|
|
|
|
__in_handler = false;
|
2009-03-26 16:31:58 +00:00
|
|
|
|
const TString& prezzo = cur.curr().get(RDOC_PREZZO);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
2009-03-26 16:31:58 +00:00
|
|
|
|
const TString& sconto = cur.curr().get(RDOC_SCONTO);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
row_mask.set(FR_SCONTO, sconto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return codart_handler( f, key);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-17 15:33:04 +00:00
|
|
|
|
bool find_price_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
if (key == K_F8 && !sh.sheet_mask().is_running())
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& ef = (TEdit_field&)f;
|
|
|
|
|
const TString& codart = row_mask.get(FR_CODART);
|
|
|
|
|
if (codart.empty())
|
|
|
|
|
search_price(ef, key);
|
|
|
|
|
else
|
|
|
|
|
search_price_article(ef,key);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return codart_handler( f, key);
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-14 14:40:28 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TCache_documenti
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
class TCache_documenti : public TRecord_cache
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual TObject* rec2obj(const TRectype& rec) const;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TDocumento& doc(const char* key);
|
|
|
|
|
TCache_documenti();
|
|
|
|
|
virtual ~TCache_documenti() { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TCache_documenti::TCache_documenti()
|
|
|
|
|
: TRecord_cache(LF_DOC, 1)
|
|
|
|
|
{
|
|
|
|
|
test_file_changes(); // Tieni d'occhio le modifiche sul file
|
|
|
|
|
set_items_limit(256); // Standard
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TObject* TCache_documenti::rec2obj(const TRectype& curr) const
|
|
|
|
|
{
|
|
|
|
|
return new TDocumento(curr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocumento & TCache_documenti::doc(const char* key)
|
|
|
|
|
{
|
|
|
|
|
return (TDocumento &)query(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDocumento & cached_doc(const char* key)
|
|
|
|
|
{
|
|
|
|
|
static TCache_documenti * _cache_docs = NULL;
|
|
|
|
|
|
|
|
|
|
if (_cache_docs == NULL)
|
|
|
|
|
_cache_docs = new TCache_documenti();
|
|
|
|
|
return _cache_docs->doc(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TLink_riga_documento : public TRiga_documento
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
const TDocumento_mask * _mask;
|
|
|
|
|
virtual const TString& get_str(const char* fieldname) const;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual const TDocumento & doc() const;
|
|
|
|
|
void set_mask(const TDocumento_mask * m) { _mask = m;}
|
|
|
|
|
virtual real qtaresidua() const;
|
|
|
|
|
|
|
|
|
|
TLink_riga_documento(const TDocumento_mask * m = NULL, const char* tipo = NULL) : TRiga_documento(NULL, tipo), _mask(m){}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TString& TLink_riga_documento::get_str(const char* fieldname) const
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(fieldname, "RESIDUO") == 0)
|
|
|
|
|
{
|
|
|
|
|
TString & value = get_tmp_string(80);
|
|
|
|
|
|
|
|
|
|
value = qtaresidua().string();
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRiga_documento::get_str(fieldname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TDocumento & TLink_riga_documento::doc() const
|
|
|
|
|
{
|
|
|
|
|
if (has_doc())
|
|
|
|
|
return TRiga_documento::doc();
|
|
|
|
|
TToken_string key;
|
|
|
|
|
|
|
|
|
|
key.add(get_char(RDOC_PROVV));
|
|
|
|
|
key.add(get_int(RDOC_ANNO));
|
|
|
|
|
key.add(get(RDOC_CODNUM));
|
|
|
|
|
key.add(get_long(RDOC_NDOC));
|
|
|
|
|
return cached_doc(key);;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
real TLink_riga_documento::qtaresidua() const
|
|
|
|
|
{
|
|
|
|
|
real residuo = TRiga_documento::qtaresidua();
|
|
|
|
|
TToken_string key, key_to_compare;
|
|
|
|
|
const TDocumento_mask& m = (const TDocumento_mask &) *_mask;
|
|
|
|
|
const TDocumento &doc = m.doc();
|
|
|
|
|
const int rows = doc.physical_rows();
|
|
|
|
|
const int current_doc_row = m.sfield(F_SHEET).selected() + 1;
|
|
|
|
|
|
|
|
|
|
key.add(get(RDOC_PROVV));
|
|
|
|
|
key.add(get(RDOC_ANNO));
|
|
|
|
|
key.add(get(RDOC_CODNUM));
|
|
|
|
|
key.add(get(RDOC_NDOC));
|
|
|
|
|
key.add(get(RDOC_IDRIGA));
|
|
|
|
|
|
|
|
|
|
real * qta = (real *) m.father_rows().objptr(key);
|
|
|
|
|
|
|
|
|
|
if (qta != NULL)
|
|
|
|
|
residuo -= *qta;
|
|
|
|
|
for (int j = 1; j <= rows; j++)
|
|
|
|
|
{
|
|
|
|
|
if (j != current_doc_row)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento & row = doc[j];
|
|
|
|
|
|
|
|
|
|
key_to_compare.cut(0);
|
|
|
|
|
key_to_compare.add(row.get(RDOC_DAPROVV));
|
|
|
|
|
key_to_compare.add(row.get(RDOC_DAANNO));
|
|
|
|
|
key_to_compare.add(row.get(RDOC_DACODNUM));
|
|
|
|
|
key_to_compare.add(row.get(RDOC_DANDOC));
|
|
|
|
|
key_to_compare.add(row.get(RDOC_DAIDRIGA));
|
|
|
|
|
|
|
|
|
|
if (key == key_to_compare)
|
|
|
|
|
residuo -= row.quantita();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return residuo;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
class TLink_article_sheet : public TBrowse_sheet
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool get_ini_paragraph(const TEdit_field& field, TString& parag) const;
|
|
|
|
|
|
|
|
|
|
public:
|
2010-10-26 13:45:23 +00:00
|
|
|
|
TLink_article_sheet(TCursor& cur, TEdit_field& f, const char * fieldlist, const char * headers);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool TLink_article_sheet::get_ini_paragraph(const TEdit_field& field, TString& parag) const
|
|
|
|
|
{
|
|
|
|
|
const bool ok = TSheet::get_ini_paragraph(field, parag);
|
|
|
|
|
if (ok)
|
|
|
|
|
parag << "_F82";
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-26 13:45:23 +00:00
|
|
|
|
TLink_article_sheet::TLink_article_sheet(TCursor& cur, TEdit_field& f, const char * fieldlist, const char * headers)
|
|
|
|
|
: TBrowse_sheet(&cur, fieldlist, TR("Evasione"), headers, 0, f, TToken_string())
|
|
|
|
|
{ }
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
|
|
|
|
bool link_row_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
if (key == K_F8 && !sh.sheet_mask().is_running())
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
TDocumento &doc = mask.doc();
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
TRiga_documento & r = doc[current_doc_row];
|
|
|
|
|
TTipo_riga_documento & tipo = (TTipo_riga_documento &) r.tipo();
|
|
|
|
|
|
|
|
|
|
if ((tipo.search_active_docs().blank()) || (tipo.search_active_docs().find(doc.tipo().codice()) >= 0))
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& ef = (TEdit_field&)f;
|
2010-10-26 13:45:23 +00:00
|
|
|
|
const TCodice_articolo codart(row_mask.get(FR_CODART));
|
2008-11-14 14:40:28 +00:00
|
|
|
|
const bool select_clifo = tipo.select_clifo();
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
|
|
|
|
if (codart.full() && r.get(RDOC_DACODNUM).empty())
|
|
|
|
|
{
|
|
|
|
|
TDate datadoc = mask.get_date(F_DATADOC);
|
|
|
|
|
TToken_string nums(((TTipo_riga_documento&)r.tipo()).search_nums());
|
2008-11-14 14:40:28 +00:00
|
|
|
|
const int sel = sh.selected();
|
|
|
|
|
TToken_string & sh_row = sh.row(sel);
|
|
|
|
|
const TString row_cod(sh_row.get(sh.cid2index(FR_CODART)));
|
|
|
|
|
TString80 from_livello, to_livello;
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
|
|
for (int l = 1; l <= doc.livelli().last_level() ; l++)
|
|
|
|
|
{
|
|
|
|
|
doc.livelli().pack_grpcode(from_livello, row_mask.get(FR_LIV1 + l - 1),l);
|
|
|
|
|
len += doc.livelli().code_length(l);
|
|
|
|
|
}
|
|
|
|
|
to_livello = from_livello;
|
|
|
|
|
|
|
|
|
|
if (doc.livelli().last_level() > 0 && to_livello.blank())
|
|
|
|
|
to_livello.fill('{', len);
|
|
|
|
|
if (row_cod.blank())
|
|
|
|
|
{
|
|
|
|
|
sh_row.add("", sh.cid2index(FR_CHECKED));
|
|
|
|
|
sh_row.add(codart, sh.cid2index(FR_CODART));
|
|
|
|
|
sh.check_row(sel);
|
|
|
|
|
}
|
|
|
|
|
r.autosave(sh);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
|
|
|
|
if (nums.blank())
|
|
|
|
|
nums = mask.get(F_CODNUM);
|
|
|
|
|
|
|
|
|
|
TString4 first_num(nums.get(0));
|
|
|
|
|
TString4 last_num(first_num);
|
|
|
|
|
TString filter;
|
|
|
|
|
|
2008-11-14 14:40:28 +00:00
|
|
|
|
filter << "(RIGAEVASA!=\"X\")&&(CODART==\"" << codart << "\")&&((LIVELLO>=\""
|
|
|
|
|
<< from_livello << "\")&&(LIVELLO<=\"" << to_livello << "\"))&&(ANSI(33->DATADOC)<=\"" << datadoc.string(ANSI) << "\")";
|
|
|
|
|
if (nums.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
const bool more_nums = (nums.items() > 1);
|
|
|
|
|
bool add_or = false;
|
|
|
|
|
|
|
|
|
|
filter<< "&&";
|
|
|
|
|
if (more_nums)
|
|
|
|
|
filter<< "(";
|
2008-06-11 11:31:27 +00:00
|
|
|
|
FOR_EACH_TOKEN(nums, s)
|
|
|
|
|
{
|
2008-11-14 14:40:28 +00:00
|
|
|
|
if (add_or)
|
|
|
|
|
filter << "||";
|
|
|
|
|
add_or = true;
|
2008-06-11 11:31:27 +00:00
|
|
|
|
if (first_num > s)
|
|
|
|
|
first_num = s;
|
|
|
|
|
if (last_num < s)
|
|
|
|
|
last_num = s;
|
2008-11-14 14:40:28 +00:00
|
|
|
|
filter << "(CODNUM==\"" << s << "\")";
|
|
|
|
|
}
|
|
|
|
|
if (more_nums)
|
|
|
|
|
filter << ")";
|
2008-06-11 11:31:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-26 13:45:23 +00:00
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
TRelation rel(LF_RIGHEDOC);
|
|
|
|
|
TRectype from(rel.curr());
|
|
|
|
|
TRectype to(rel.curr());
|
|
|
|
|
|
2008-11-14 14:40:28 +00:00
|
|
|
|
rel.lfile().set_curr(new TLink_riga_documento(&mask));
|
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
rel.add(LF_DOC, "PROVV==PROVV|ANNO=ANNO|CODNUM==CODNUM|NDOC==NDOC");
|
2010-10-26 13:45:23 +00:00
|
|
|
|
|
|
|
|
|
if (select_clifo)
|
|
|
|
|
{
|
|
|
|
|
filter << "&&(33->TIPOCF==\"" << doc.get(DOC_TIPOCF) << "\")";
|
|
|
|
|
filter << "&&(33->CODCF==\"" << doc.get(DOC_CODCF) << "\")";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
rel.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF", 1, LF_DOC);
|
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
|
|
|
|
const int last_anno = mask.get_int(F_ANNO);
|
|
|
|
|
const int first_anno = last_anno - tipo.search_years();
|
|
|
|
|
|
|
|
|
|
from.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
from.put(RDOC_LIVELLO, from_livello);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
from.put(RDOC_CODNUM, first_num);
|
|
|
|
|
from.put(RDOC_ANNO, first_anno);
|
|
|
|
|
from.put(RDOC_PROVV, 'D');
|
|
|
|
|
to.put(RDOC_CODART, codart);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
to.put(RDOC_LIVELLO, to_livello);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
to.put(RDOC_CODNUM, last_num);
|
|
|
|
|
to.put(RDOC_ANNO, last_anno);
|
|
|
|
|
to.put(RDOC_PROVV, 'D');
|
2010-10-26 13:45:23 +00:00
|
|
|
|
TString order = tipo.order();
|
|
|
|
|
|
|
|
|
|
if (order.blank())
|
|
|
|
|
order ="33->DATADOC|CODNUM|NDOC";
|
|
|
|
|
|
|
|
|
|
TSorted_cursor cur(&rel, order, filter, 5, &from, &to);
|
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
cur.items();
|
|
|
|
|
cur.freeze();
|
|
|
|
|
cur.relation()->add("%NUM", "CODTAB==CODNUM", 1, 0, 201);
|
|
|
|
|
cur.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 202);
|
2010-10-26 13:45:23 +00:00
|
|
|
|
TToken_string fieldlist = tipo.field_list();
|
|
|
|
|
TToken_string header = tipo.header();
|
|
|
|
|
|
|
|
|
|
if (fieldlist.blank())
|
|
|
|
|
fieldlist = "-201->S0|-202->S0|NDOC|33->DATADOC|QTA|QTAEVASA";
|
|
|
|
|
if (header.blank())
|
|
|
|
|
header = HR("Numerazione@18|Tipo Documento@18|Num.|Data@10|Quantit<69>@15P|Evaso@15P");
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
2010-10-26 13:45:23 +00:00
|
|
|
|
if (!select_clifo)
|
|
|
|
|
{
|
|
|
|
|
fieldlist << "|20->CODCF|20->RAGSOC";
|
|
|
|
|
header << HR("|Codice|Ragione sociale@50");
|
|
|
|
|
}
|
|
|
|
|
TLink_article_sheet sheet(cur, (TEdit_field&)f, fieldlist, header);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
sheet.add_string (FR_DESCR, 0, "", 38, 0, 50, "D", 30);
|
|
|
|
|
sheet.set(FR_CODART, codart);
|
|
|
|
|
sheet.set(FR_DESCR, cache().get(LF_ANAMAG, codart, "DESCR"));
|
2008-11-14 14:40:28 +00:00
|
|
|
|
|
2008-06-11 11:31:27 +00:00
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
r.set_original_rdoc_key(cur.curr());
|
|
|
|
|
const TRectype * orig_doc = r.find_original_doc(); // warning
|
|
|
|
|
if (orig_doc != NULL)
|
|
|
|
|
{
|
2008-11-14 14:40:28 +00:00
|
|
|
|
TDocumento father_doc(*orig_doc);
|
|
|
|
|
TLink_riga_documento & father_row = (TLink_riga_documento &) cur.curr();
|
|
|
|
|
const TString16 livello = father_row.get(RDOC_LIVELLO);
|
|
|
|
|
|
|
|
|
|
father_row.set_doc(&doc);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
r.put(RDOC_LIVELLO, livello);
|
2010-10-26 13:45:23 +00:00
|
|
|
|
r.put(r.field_qta(), father_row.qtaresidua());
|
|
|
|
|
|
|
|
|
|
TToken_string & flds = tipo.fields_to_update();
|
2008-06-11 11:31:27 +00:00
|
|
|
|
|
2008-11-14 14:40:28 +00:00
|
|
|
|
FOR_EACH_TOKEN(flds, fld)
|
2008-06-11 11:31:27 +00:00
|
|
|
|
{
|
2008-11-14 14:40:28 +00:00
|
|
|
|
const TString & val = father_row.get(fld);
|
|
|
|
|
|
|
|
|
|
r.put(fld, val);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
}
|
|
|
|
|
r.autoload(sh);
|
2008-11-14 14:40:28 +00:00
|
|
|
|
sh.force_update(sel);
|
2008-06-11 11:31:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return codart_handler( f, key);
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool codart_handler(TMask_field& f, KEY key )
|
1997-10-23 10:53:49 +00:00
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
|
|
|
|
|
if (f.to_check(key, true))
|
|
|
|
|
{
|
2011-02-16 09:42:19 +00:00
|
|
|
|
TEdit_field& liv1 = row_mask.efield(FR_LIV1);
|
|
|
|
|
if (f.empty())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2011-02-16 09:42:19 +00:00
|
|
|
|
liv1.reset();
|
|
|
|
|
liv1.disable();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2011-02-16 09:42:19 +00:00
|
|
|
|
else
|
|
|
|
|
liv1.enable();
|
|
|
|
|
liv1.on_hit();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_CHECKED).empty()))
|
|
|
|
|
{
|
|
|
|
|
TCond_vendita & condv = mask.condv();
|
|
|
|
|
|
|
|
|
|
condv.set_testa(&mask);
|
|
|
|
|
condv.set_riga(&row_mask);
|
|
|
|
|
|
2009-09-16 09:14:38 +00:00
|
|
|
|
TCodice_articolo codart = f.get();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TRectype anamag = cache().get(LF_ANAMAG, codart); // anamag puo' cambiare
|
|
|
|
|
bool found = !anamag.empty();
|
2010-02-16 12:19:54 +00:00
|
|
|
|
TString4 umcorr;
|
2011-04-21 12:41:19 +00:00
|
|
|
|
TString desc;
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (found)
|
|
|
|
|
row_mask.set(FR_CODARTMAG, codart, true);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile codalt(LF_CODCORR);
|
|
|
|
|
|
|
|
|
|
codalt.setkey(2);
|
|
|
|
|
codalt.put(CODCORR_CODARTALT, codart);
|
|
|
|
|
if (codalt.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
codart = codalt.get(CODCORR_CODART);
|
2011-04-21 12:41:19 +00:00
|
|
|
|
desc = codalt.get(CODCORR_DESCR);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
anamag = cache().get(LF_ANAMAG, codart);
|
|
|
|
|
found = !anamag.empty();
|
|
|
|
|
if (found)
|
2006-12-13 16:22:33 +00:00
|
|
|
|
{
|
2007-05-30 16:46:56 +00:00
|
|
|
|
row_mask.set(FR_CODARTMAG, codart, true);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
umcorr = codalt.get(CODCORR_UM);
|
|
|
|
|
|
2011-06-09 16:13:13 +00:00
|
|
|
|
const TString& liv1 = codalt.get(CODCORR_LIV1);
|
2006-12-13 16:22:33 +00:00
|
|
|
|
|
|
|
|
|
if (liv1.full())
|
|
|
|
|
row_mask.set(FR_LIV1, liv1);
|
|
|
|
|
|
|
|
|
|
const TString & liv2 = codalt.get(CODCORR_LIV2);
|
|
|
|
|
|
|
|
|
|
if (liv2.full())
|
|
|
|
|
row_mask.set(FR_LIV2, liv2);
|
|
|
|
|
|
|
|
|
|
const TString & liv3 = codalt.get(CODCORR_LIV3);
|
|
|
|
|
|
|
|
|
|
if (liv3.full())
|
|
|
|
|
row_mask.set(FR_LIV3, liv3);
|
|
|
|
|
|
|
|
|
|
const TString & liv4 = codalt.get(CODCORR_LIV4);
|
|
|
|
|
|
|
|
|
|
if (liv4.full())
|
|
|
|
|
row_mask.set(FR_LIV4, liv4);
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
row_mask.set(FR_CHECKED, "X");
|
2007-05-30 16:46:56 +00:00
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
row_mask.set(FR_CODARTMAG, "", true);
|
2007-05-30 16:46:56 +00:00
|
|
|
|
if (main_app().has_module(DBAUT))
|
|
|
|
|
{
|
|
|
|
|
const TRectype& dist = cache().get(LF_DIST, codart);
|
|
|
|
|
if (!dist.empty())
|
|
|
|
|
{
|
|
|
|
|
desc = dist.get("DESCR");
|
|
|
|
|
umcorr = dist.get("UM");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-05-30 16:46:56 +00:00
|
|
|
|
const TString4 lingua = mask.get(F_CODLIN);
|
|
|
|
|
const TCodice_articolo codart = row_mask.get(FR_CODARTMAG);
|
2011-04-21 12:41:19 +00:00
|
|
|
|
|
|
|
|
|
if (desc.blank())
|
|
|
|
|
desc = anamag.get(ANAMAG_DESCR);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
if (mask.doc()[current_doc_row].is_omaggio())
|
|
|
|
|
{
|
2010-02-16 12:19:54 +00:00
|
|
|
|
static TString dicitura_omaggio;
|
|
|
|
|
if (dicitura_omaggio.empty())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2010-02-16 12:19:54 +00:00
|
|
|
|
dicitura_omaggio = ini_get_string(CONFIG_STUDIO, "ve", "DESOMAGGI");
|
|
|
|
|
if (dicitura_omaggio.blank())
|
|
|
|
|
dicitura_omaggio = TR("(OMAGGIO)");
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2010-02-16 12:19:54 +00:00
|
|
|
|
desc << ' ' << dicitura_omaggio;
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
if (lingua.not_empty())
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile deslin(LF_DESLIN);
|
|
|
|
|
deslin.setkey(2);
|
|
|
|
|
deslin.put(DESLIN_CODART, codart);
|
|
|
|
|
deslin.put(DESLIN_CODLIN, lingua);
|
|
|
|
|
if (deslin.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
static int __lingua_only = 3;
|
|
|
|
|
|
|
|
|
|
if (__lingua_only > 2)
|
|
|
|
|
{
|
|
|
|
|
TConfig c(CONFIG_DITTA, "ve");
|
|
|
|
|
__lingua_only = c.get_bool("LINGUA_ONLY");
|
|
|
|
|
}
|
|
|
|
|
if (__lingua_only)
|
|
|
|
|
desc = deslin.get(DESLIN_DESCR);
|
|
|
|
|
else
|
|
|
|
|
desc << '\n' << deslin.get(DESLIN_DESCR);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& descest = anamag.get("DESCRAGG");
|
|
|
|
|
if (descest.not_empty())
|
2009-10-26 15:51:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (!mask.doc()[current_doc_row].tipo().extended_desc_search())
|
|
|
|
|
desc << "\n";
|
|
|
|
|
desc << descest;
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2007-05-30 16:46:56 +00:00
|
|
|
|
if (!mask.doc()[current_doc_row].tipo().no_desc())
|
|
|
|
|
row_mask.set(FR_DESCR, desc);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TString80 key; key << codart << "|1";
|
|
|
|
|
const TRectype& umart = cache().get(LF_UMART, key);
|
|
|
|
|
if (!umart.empty())
|
|
|
|
|
{
|
|
|
|
|
curr_um = umart.get(UMART_UM);
|
|
|
|
|
curr_fc = umart.get_real(UMART_FC);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
curr_um.cut(0);
|
|
|
|
|
curr_fc = 1.0;
|
|
|
|
|
}
|
|
|
|
|
row_mask.set(FR_UMQTA, curr_um);
|
2008-10-07 00:50:22 +00:00
|
|
|
|
upd_colli_peso_tara(row_mask, codart);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-07 11:36:57 +00:00
|
|
|
|
condv.ricerca();
|
2011-06-09 16:13:13 +00:00
|
|
|
|
|
|
|
|
|
const char* rdoc_prezzo = mask.doc().tipo().calcolo_lordo() ? RDOC_PREZZOL : RDOC_PREZZO;
|
|
|
|
|
mask.doc()[current_doc_row].put(rdoc_prezzo, row_mask.get(FR_PREZZO));
|
2007-03-07 11:36:57 +00:00
|
|
|
|
|
2009-09-24 15:27:38 +00:00
|
|
|
|
FOR_EACH_CONFIGURED_CONAI_CLASS(type)
|
2009-09-18 15:14:51 +00:00
|
|
|
|
{
|
2009-09-24 15:27:38 +00:00
|
|
|
|
short id = conai_sottocat_id(type);
|
|
|
|
|
int pos = row_mask.id2pos(id);
|
2009-09-18 15:14:51 +00:00
|
|
|
|
|
2009-09-24 15:27:38 +00:00
|
|
|
|
if (pos >= 0 && row_mask.fld(pos).get().blank())
|
2009-10-07 08:55:38 +00:00
|
|
|
|
{
|
|
|
|
|
const int lognum = anamag.num();
|
|
|
|
|
const TFieldref fr(conai_sottocat_name(type, lognum), lognum);
|
|
|
|
|
row_mask.fld(pos).set(fr.read(anamag));
|
|
|
|
|
}
|
2009-09-22 11:19:13 +00:00
|
|
|
|
|
2009-09-24 15:27:38 +00:00
|
|
|
|
id = conai_peso_id(type);
|
|
|
|
|
pos = row_mask.id2pos(id);
|
2009-09-22 11:19:13 +00:00
|
|
|
|
|
2009-09-24 15:27:38 +00:00
|
|
|
|
if (pos >= 0 && row_mask.fld(pos).get().blank())
|
2009-10-07 08:55:38 +00:00
|
|
|
|
{
|
|
|
|
|
const int lognum = anamag.num();
|
|
|
|
|
const TFieldref fr(conai_peso_name(type, lognum), lognum);
|
2009-10-07 15:35:29 +00:00
|
|
|
|
row_mask.fld(pos).set(fr.read(anamag));
|
2009-10-07 08:55:38 +00:00
|
|
|
|
}
|
2009-09-18 15:14:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const int pos = row_mask.id2pos(FR_CODIVA);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
iva_handler(row_mask.fld(pos), 0);
|
|
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
|
{
|
2009-10-07 15:35:29 +00:00
|
|
|
|
TString8 caus(row_mask.get(FR_CAUS));
|
|
|
|
|
if (caus.blank())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
caus = mask.get(F_CAUSMAG);
|
|
|
|
|
|
2009-10-07 15:35:29 +00:00
|
|
|
|
if (caus.full())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2008-10-07 00:50:22 +00:00
|
|
|
|
const TCausale_magazzino & c = cached_causale_magazzino(caus);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (!c.movimenta_sospesi())
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG));
|
2009-10-07 15:35:29 +00:00
|
|
|
|
if (rec.get_bool(ANAMAG_SOSPESO))
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return error_box(TR("Articolo %s sospeso, quindi non movimentabile"), (const char *)codart);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-16 09:42:19 +00:00
|
|
|
|
|
|
|
|
|
if (mask.gestione_note_per_articolo())
|
|
|
|
|
mask.send_key(K_F8, F_NAR, &sh);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-09-21 11:21:30 +00:00
|
|
|
|
if (key == K_F8 && !row_mask.is_running())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2010-09-21 11:21:30 +00:00
|
|
|
|
const bool explode_db = ini_get_bool(CONFIG_DITTA, "ve", "EXPLODEDB");
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (explode_db && !sh.sheet_mask().is_running())
|
|
|
|
|
{
|
2010-09-21 11:21:30 +00:00
|
|
|
|
const bool valcomp = ini_get_bool(CONFIG_DITTA, "ve", "VALCOMP");
|
|
|
|
|
const bool matbase = ini_get_bool(CONFIG_DITTA, "ve", "TIPOESPL");
|
|
|
|
|
const TExplosion_grouping raggart = (TExplosion_grouping) ini_get_int(CONFIG_DITTA, "ve", "RAGGART");
|
|
|
|
|
const bool elrorig = ini_get_bool(CONFIG_DITTA, "ve", "ELRORIG");
|
|
|
|
|
const int livello = ini_get_int(CONFIG_DITTA, "ve", "LIVESPL");
|
|
|
|
|
const int ordin = ini_get_int(CONFIG_DITTA, "ve", "ORDDB");
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
TRiga_documento & curr_row = doc[current_doc_row];
|
2009-04-17 16:26:10 +00:00
|
|
|
|
const int start_level = curr_row.get_int(RDOC_LEVEL);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
sh.update_row(current_doc_row - 1);
|
|
|
|
|
curr_row.autosave(sh);
|
|
|
|
|
|
|
|
|
|
TDistinta_tree db;
|
|
|
|
|
TArray components;
|
|
|
|
|
|
|
|
|
|
db.set_root(curr_row);
|
|
|
|
|
|
|
|
|
|
const int items = db.explode(components, matbase, raggart, livello, "A", ordin);
|
|
|
|
|
if (items > 0)
|
|
|
|
|
{
|
|
|
|
|
TProgind pi(items, "Esplosione in corso...",false, true);
|
|
|
|
|
int row = current_doc_row;
|
|
|
|
|
const TString16 tiporiga(curr_row.tipo().codice());
|
|
|
|
|
|
|
|
|
|
TString_array& str_arr = sh.rows_array();
|
|
|
|
|
|
|
|
|
|
for (int i = components.first(); i < items; i = components.succ(i))
|
|
|
|
|
{
|
|
|
|
|
pi.addstatus(1L);
|
|
|
|
|
TRiga_esplosione & r = (TRiga_esplosione &) components[i];
|
2009-04-23 15:26:54 +00:00
|
|
|
|
sh.insert(row, false, true);
|
|
|
|
|
TRiga_documento & new_row = doc[row + 1];
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TDocumento::copy_data(new_row, curr_row);
|
|
|
|
|
new_row.put(RDOC_CODART, r.articolo());
|
|
|
|
|
new_row.put(RDOC_CODARTMAG, r.articolo());
|
|
|
|
|
new_row.put(RDOC_LIVELLO, r.giacenza());
|
|
|
|
|
new_row.zero(RDOC_DESCR);
|
|
|
|
|
new_row.zero(RDOC_DESCLUNGA);
|
|
|
|
|
new_row.zero(RDOC_DESCEST);
|
|
|
|
|
new_row.put(RDOC_CHECKED, "");
|
|
|
|
|
new_row.put(RDOC_UMQTA, r.um());
|
2008-12-09 15:22:23 +00:00
|
|
|
|
new_row.put(RDOC_GENERATA, "X");
|
2005-08-23 08:54:32 +00:00
|
|
|
|
new_row.put(RDOC_QTA, r.val() /* * qta_fin */);
|
2009-04-17 16:26:10 +00:00
|
|
|
|
const int level = start_level + r.livello();
|
|
|
|
|
new_row.put(RDOC_LEVEL, level);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (!valcomp)
|
|
|
|
|
{
|
|
|
|
|
new_row.zero(RDOC_PREZZO);
|
2009-04-21 00:07:11 +00:00
|
|
|
|
sh.row(row).add("0", sh.cid2index(FR_PREZZO));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
row_mask.reset(FR_PREZZO);
|
|
|
|
|
}
|
2010-09-21 11:21:30 +00:00
|
|
|
|
new_row.autoload(sh);
|
|
|
|
|
sh.check_row(row);
|
|
|
|
|
new_row.autosave(sh); // Da sheet a rdoc
|
2005-08-23 08:54:32 +00:00
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
if (elrorig)
|
|
|
|
|
{
|
|
|
|
|
doc.destroy_row(current_doc_row, true);
|
|
|
|
|
sh.destroy(current_doc_row - 1, false);
|
|
|
|
|
row--;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (valcomp)
|
|
|
|
|
{
|
|
|
|
|
curr_row.zero(RDOC_PREZZO);
|
|
|
|
|
curr_row.autoload(sh);
|
|
|
|
|
}
|
|
|
|
|
sh.force_update();
|
2010-09-21 11:21:30 +00:00
|
|
|
|
sh.post_select(current_doc_row - 1);
|
|
|
|
|
sh.update_mask(current_doc_row - 1);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-07 15:35:29 +00:00
|
|
|
|
mask.update_giacenza();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
|
|
|
|
bool codartmag_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TMask & m = f.mask();
|
2011-06-09 16:13:13 +00:00
|
|
|
|
|
|
|
|
|
/* Modo vecchio con funzionamento dubbiamente legato a !mask.is_running
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TSheet_field& s = *m.get_sheet();
|
|
|
|
|
TDocumento_mask& mask= (TDocumento_mask&)s.mask();
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
bool to_check = key == K_TAB && f.focusdirty();
|
|
|
|
|
if (!to_check)
|
|
|
|
|
to_check = !mask.is_running();
|
|
|
|
|
|
|
|
|
|
if (to_check)
|
|
|
|
|
{
|
2011-06-09 16:13:13 +00:00
|
|
|
|
const bool artmag = !f.empty() && TRiga_documento::tipo(m.get(FR_TIPORIGA)).is_merce();
|
|
|
|
|
m.show(FR_UMQTA, artmag);
|
|
|
|
|
m.show(FR_UMQTA2, !artmag);
|
|
|
|
|
mask.update_giacenza();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2011-06-09 16:13:13 +00:00
|
|
|
|
*/
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2011-06-09 16:13:13 +00:00
|
|
|
|
if (key == K_TAB)
|
|
|
|
|
{
|
|
|
|
|
const bool artmag = !f.empty() && TRiga_documento::tipo(m.get(FR_TIPORIGA)).is_merce();
|
|
|
|
|
m.show(FR_UMQTA, artmag);
|
|
|
|
|
m.show(FR_UMQTA2, !artmag);
|
|
|
|
|
|
|
|
|
|
if (f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& s = *m.get_sheet();
|
|
|
|
|
TDocumento_mask& mask= (TDocumento_mask&)s.mask();
|
|
|
|
|
if (mask.is_running())
|
|
|
|
|
mask.update_giacenza();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool liv_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
bool ok = true;
|
|
|
|
|
TDocumento_mask & mask=(TDocumento_mask &) f.mask().get_sheet()->mask();
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && f.focusdirty() && !f.get().empty())
|
|
|
|
|
{
|
|
|
|
|
const int levnum=f.dlg()-FR_LIV1+1;
|
|
|
|
|
// Se e' abilitato l'autoinserimento del livello di giacenza...
|
|
|
|
|
if (mask.livelli().autoinsert(levnum))
|
|
|
|
|
mask.livelli().autoinsert(levnum, f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (f.to_check(key, true))
|
|
|
|
|
{
|
|
|
|
|
if (f.dlg() < FR_LIV4)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TMask_field & next = row_mask.field(f.dlg() + 1);
|
|
|
|
|
if (f.get().not_empty())
|
|
|
|
|
next.enable();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
next.reset();
|
|
|
|
|
next.disable();
|
|
|
|
|
}
|
|
|
|
|
next.on_hit();
|
|
|
|
|
}
|
|
|
|
|
TDocumento_mask& mask=(TDocumento_mask&)f.mask().get_sheet()->mask();
|
|
|
|
|
mask.update_giacenza();
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
1997-10-23 10:53:49 +00:00
|
|
|
|
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2003-11-17 10:20:13 +00:00
|
|
|
|
void set_curr_um(const TString & um)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
curr_um = um;
|
|
|
|
|
curr_fc = -1.0;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool umart_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2005-09-19 12:45:16 +00:00
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty() && mask.is_running())
|
|
|
|
|
{
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
|
|
|
|
|
TCond_vendita & condv = mask.condv();
|
|
|
|
|
condv.set_riga(&row_mask);
|
|
|
|
|
|
|
|
|
|
const TString& um = f.get();
|
2011-06-09 16:13:13 +00:00
|
|
|
|
real fc = UNO;
|
2005-09-19 12:45:16 +00:00
|
|
|
|
|
|
|
|
|
if (um.not_empty() && curr_um.not_empty() && um != curr_um)
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile umart(LF_UMART);
|
|
|
|
|
umart.setkey(2);
|
|
|
|
|
umart.put(UMART_CODART, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
umart.put(UMART_UM, um);
|
|
|
|
|
if (umart.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
real qta(row_mask.get_real(FR_QTA));
|
|
|
|
|
fc = umart.get_real(UMART_FC);
|
|
|
|
|
if (curr_fc < ZERO)
|
|
|
|
|
{
|
|
|
|
|
umart.put(UMART_CODART, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
umart.put(UMART_UM, curr_um);
|
|
|
|
|
if (umart.read() == NOERR)
|
|
|
|
|
curr_fc = umart.get_real(UMART_FC);
|
|
|
|
|
else
|
2011-06-09 16:13:13 +00:00
|
|
|
|
curr_fc = UNO;
|
2005-09-19 12:45:16 +00:00
|
|
|
|
}
|
|
|
|
|
qta *= curr_fc;
|
|
|
|
|
qta /= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTA, qta);
|
|
|
|
|
qta = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
qta *= curr_fc;
|
|
|
|
|
qta /= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTAEVASA, qta);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
curr_um = um;
|
|
|
|
|
curr_fc = fc;
|
2006-04-13 17:56:02 +00:00
|
|
|
|
condv.ricerca(true);
|
2005-09-19 12:45:16 +00:00
|
|
|
|
|
2011-06-09 16:13:13 +00:00
|
|
|
|
const char* const prezzo = mask.doc().tipo().calcolo_lordo() ? RDOC_PREZZOL : RDOC_PREZZO;
|
|
|
|
|
mask.doc()[current_doc_row].put(prezzo, row_mask.get(FR_PREZZO));
|
2005-09-19 12:45:16 +00:00
|
|
|
|
|
2011-06-09 16:13:13 +00:00
|
|
|
|
const int pos = row_mask.id2pos(FR_CODIVA);
|
2005-09-19 12:45:16 +00:00
|
|
|
|
if (pos >= 0)
|
|
|
|
|
iva_handler(row_mask.fld(pos), 0);
|
|
|
|
|
}
|
2006-04-13 17:56:02 +00:00
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool um_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TTable & ums = (TTable &) ((TEdit_field &) f).browse()->cursor()->file();
|
|
|
|
|
|
|
|
|
|
const TString16 um(f.get());
|
|
|
|
|
real fc(1.0);
|
|
|
|
|
|
|
|
|
|
if (um.not_empty() && curr_um.not_empty() && um != curr_um)
|
|
|
|
|
{
|
|
|
|
|
ums.put("CODTAB", curr_um);
|
|
|
|
|
if (ums.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
real qta(row_mask.get_real(FR_QTA));
|
|
|
|
|
const TString16 umsrif0(ums.get("S7"));
|
|
|
|
|
const real fc0 = ums.get_real("R10");
|
|
|
|
|
if (um == umsrif0)
|
|
|
|
|
fc = fc0;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ums.put("CODTAB", um);
|
|
|
|
|
if (ums.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const real fc1 = ums.get_real("R10");
|
|
|
|
|
const TString16 umsrif1(ums.get("S7"));
|
|
|
|
|
|
|
|
|
|
if (fc1 > ZERO)
|
|
|
|
|
{
|
|
|
|
|
if (curr_um == umsrif1)
|
|
|
|
|
fc = 1 / fc1;
|
|
|
|
|
else
|
|
|
|
|
if (umsrif0 == ums.get("S7"))
|
|
|
|
|
fc = fc0 / ums.get_real("R10");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
qta *= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTA, qta);
|
|
|
|
|
qta = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
qta *= fc;
|
|
|
|
|
qta.round(5);
|
|
|
|
|
row_mask.set(FR_QTAEVASA, qta);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
curr_um = um;
|
|
|
|
|
curr_fc = fc;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool descr_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
if (key == K_TAB && f.focusdirty())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask &)sh.mask();
|
|
|
|
|
const TTipo_riga_documento & t = mask.doc()[sh.selected() + 1].tipo();
|
|
|
|
|
|
|
|
|
|
if (t.extended_desc_search())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2009-10-30 00:18:03 +00:00
|
|
|
|
const TString& s = f.get();
|
2009-09-16 09:14:38 +00:00
|
|
|
|
TLocalisamfile& anamag = ((TEdit_field&)f).browse()->cursor()->file();
|
2009-10-30 00:18:03 +00:00
|
|
|
|
if (s == anamag.get(ANAMAG_DESCR))
|
|
|
|
|
f.mask().set(FR_CODART, anamag.get(ANAMAG_CODART), 3);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
2009-10-26 15:51:02 +00:00
|
|
|
|
else
|
2009-12-02 11:17:42 +00:00
|
|
|
|
{
|
|
|
|
|
const TString& s = f.get();
|
|
|
|
|
if (s.find('\n') < 0)
|
2009-10-26 15:51:02 +00:00
|
|
|
|
{
|
2009-12-02 11:17:42 +00:00
|
|
|
|
TLocalisamfile& anamag = ((TEdit_field&)f).browse()->cursor()->file();
|
2009-12-19 13:26:17 +00:00
|
|
|
|
TString codart = anamag.get(ANAMAG_CODART);
|
|
|
|
|
|
|
|
|
|
if (s == anamag.get(ANAMAG_DESCR) && codart != f.mask().get(FR_CODART))
|
2009-12-02 11:17:42 +00:00
|
|
|
|
f.mask().set(FR_CODART, anamag.get(ANAMAG_CODART), 3);
|
2009-10-26 15:51:02 +00:00
|
|
|
|
}
|
2009-12-02 11:17:42 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool qtaart_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask&) sh.mask();
|
|
|
|
|
const int current_doc_row = sh.selected() + 1;
|
|
|
|
|
TCond_vendita & condv = mask.condv();
|
2007-03-07 16:51:50 +00:00
|
|
|
|
|
|
|
|
|
condv.set_riga(&row_mask);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
condv.ricerca(false, true);
|
2007-03-07 16:45:02 +00:00
|
|
|
|
if (mask.doc().tipo().calcolo_lordo())
|
|
|
|
|
mask.doc()[current_doc_row].put(RDOC_PREZZOL, row_mask.get(FR_PREZZO));
|
|
|
|
|
else
|
|
|
|
|
mask.doc()[current_doc_row].put(RDOC_PREZZO, row_mask.get(FR_PREZZO));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
const TString& codart = row_mask.get(FR_CODARTMAG);
|
|
|
|
|
|
|
|
|
|
if (codart.not_empty())
|
2008-10-07 00:50:22 +00:00
|
|
|
|
upd_colli_peso_tara(row_mask, codart);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2007-03-07 16:51:50 +00:00
|
|
|
|
} //if(key==K_TAB
|
2005-08-23 08:54:32 +00:00
|
|
|
|
else
|
|
|
|
|
if (key == K_ENTER && f.dirty())
|
|
|
|
|
{
|
|
|
|
|
TDocumento_mask& mask=(TDocumento_mask&)f.mask().get_sheet()->mask();
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
|
|
|
|
|
if ((doc.tipo().check_giac() || doc.tipo().check_disp()) &&
|
|
|
|
|
main_app().has_module(MGAUT, CHK_DONGLE) && doc.tipo().mov_mag())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sf = mask.sfield(F_SHEET);
|
|
|
|
|
TToken_string& row = sf.row(sf.selected());
|
2010-06-22 11:10:40 +00:00
|
|
|
|
const TCodice_articolo codart = row.get(sf.cid2index(FR_CODARTMAG));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2010-06-22 11:10:40 +00:00
|
|
|
|
if (codart.full())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2010-06-22 11:10:40 +00:00
|
|
|
|
TString8 codmag = row.get(sf.cid2index(FR_CODMAG));
|
|
|
|
|
const TString4 coddep = row.get(sf.cid2index(FR_CODDEP));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (!coddep.blank())
|
|
|
|
|
codmag << coddep;
|
|
|
|
|
|
|
|
|
|
TString16 livello;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
const char* liv = row.get(sf.cid2index(FR_LIV1+i));
|
|
|
|
|
if (*liv > ' ')
|
|
|
|
|
livello << liv;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-06-22 11:10:40 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
real qta(row.get(sf.cid2index(FR_QTA)));
|
|
|
|
|
const TString16 caus(mask.get(F_CAUSMAG));
|
2009-11-19 12:16:06 +00:00
|
|
|
|
const TCausale_magazzino & c = cached_causale_magazzino(caus);
|
2007-03-07 16:51:50 +00:00
|
|
|
|
const long nmovmag = doc.get_long(DOC_MOVMAG);
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (nmovmag != 0)
|
|
|
|
|
{
|
2008-10-07 00:50:22 +00:00
|
|
|
|
TLocalisamfile rmovmag(LF_RMOVMAG);
|
|
|
|
|
|
|
|
|
|
rmovmag.setkey(2);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
rmovmag.put(RMOVMAG_CODART, codart);
|
|
|
|
|
rmovmag.put(RMOVMAG_LIVGIAC, livello);
|
|
|
|
|
rmovmag.put(RMOVMAG_CODMAG, codmag);
|
|
|
|
|
rmovmag.put(RMOVMAG_NUMREG, nmovmag);
|
|
|
|
|
if (rmovmag.read() == NOERR)
|
|
|
|
|
qta -= rmovmag.get_real(RMOVMAG_QUANT);
|
|
|
|
|
}
|
2010-06-21 14:39:27 +00:00
|
|
|
|
if (mask.fconv_qta() != UNO)
|
|
|
|
|
qta *= mask.fconv_qta();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (doc.tipo().check_giac())
|
|
|
|
|
{
|
|
|
|
|
real giac(mask.get(F_CURGIAC));
|
2008-11-14 14:40:28 +00:00
|
|
|
|
|
|
|
|
|
if (giac < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione giacenza negativa, Devo continuare ?"))
|
|
|
|
|
return false;
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (doc.tipo().check_disp())
|
|
|
|
|
{
|
|
|
|
|
real disp(mask.get(F_CURDISP));
|
2008-11-14 14:40:28 +00:00
|
|
|
|
|
|
|
|
|
if (disp < -(c.sgn(s_giac) * qta) && !yesno_box("Attenzione disponibilita' negativa, Devo continuare ?"))
|
|
|
|
|
return false;
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return qta_handler(f, key);
|
2006-07-11 13:12:41 +00:00
|
|
|
|
}
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
bool qta_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
// Se qualcuno cerca di modificare la maschera
|
|
|
|
|
if ( key == K_TAB && f.focusdirty())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
const real qta_evasa = row_mask.get_real(FR_QTAEVASA);
|
|
|
|
|
const real qta(f.get());
|
|
|
|
|
|
|
|
|
|
if (qta_evasa > 0 && qta_evasa >= qta)
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_RIGAEVASA, "X");
|
|
|
|
|
row_mask.disable(FR_RIGAEVASA);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
row_mask.enable(FR_RIGAEVASA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
1998-08-25 18:07:30 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
1998-08-25 18:07:30 +00:00
|
|
|
|
bool qta_evasa_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
if (f.to_check(key) || (key == K_TAB && !row_mask.is_running()))
|
|
|
|
|
{
|
|
|
|
|
const real qta_evasa(f.get());
|
|
|
|
|
const real qta = row_mask.get_real(FR_QTA);
|
|
|
|
|
|
|
|
|
|
bool enable_evasa = true;
|
|
|
|
|
if (qta_evasa > 0 && qta_evasa >= qta)
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_RIGAEVASA, "X");
|
|
|
|
|
enable_evasa = false;
|
|
|
|
|
}
|
|
|
|
|
row_mask.enable(FR_RIGAEVASA, enable_evasa);
|
|
|
|
|
if (!row_mask.is_running())
|
|
|
|
|
{
|
|
|
|
|
TSheet_field* sheet = row_mask.get_sheet();
|
|
|
|
|
const int riga = sheet->selected();
|
|
|
|
|
sheet->enable_cell(riga, sheet->cid2index(FR_RIGAEVASA), enable_evasa);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool causmag_handler( TMask_field& f, KEY key )
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2006-04-13 17:56:02 +00:00
|
|
|
|
if (f.to_check(key))
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask( );
|
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
2007-11-27 12:52:31 +00:00
|
|
|
|
TString8 causmag(f.get());
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2008-10-07 00:50:22 +00:00
|
|
|
|
if (causmag.blank())
|
2006-04-13 17:56:02 +00:00
|
|
|
|
causmag = mask.get(F_CAUSMAG);
|
|
|
|
|
if (causmag.full())
|
|
|
|
|
{
|
2009-11-19 12:16:06 +00:00
|
|
|
|
TCausale_magazzino c = cached_causale_magazzino(causmag); // deve essere modiifcata quindi non puo' essere un reference
|
2008-10-07 00:50:22 +00:00
|
|
|
|
|
|
|
|
|
if (c.has_default_mag() && row_mask.get(FR_CODMAG).empty())
|
2006-04-13 17:56:02 +00:00
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_CODMAG, c.default_mag(), true);
|
|
|
|
|
row_mask.set(FR_CODDEP, "", true);
|
|
|
|
|
}
|
|
|
|
|
if (c.has_default_dep() && row_mask.get(FR_CODDEP).empty())
|
|
|
|
|
row_mask.set(FR_CODDEP, c.default_dep(), true);
|
|
|
|
|
|
|
|
|
|
if (c.caus_collegata().full())
|
|
|
|
|
{
|
|
|
|
|
c = cache().get("%CAU", c.caus_collegata());
|
|
|
|
|
if (c.has_default_mag() && row_mask.get(FR_CODMAGC).empty())
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_CODMAGC, c.default_mag(), true);
|
|
|
|
|
row_mask.set(FR_CODDEPC, "", true);
|
|
|
|
|
}
|
|
|
|
|
if (c.has_default_dep() && row_mask.get(FR_CODDEPC).empty())
|
|
|
|
|
row_mask.set(FR_CODDEPC, c.default_dep(), true);
|
|
|
|
|
|
|
|
|
|
static int copy_defmagc = -883;
|
|
|
|
|
if (copy_defmagc < 0)
|
|
|
|
|
{
|
|
|
|
|
TFilename fname; mask.doc().tipo().profile_name(fname);
|
|
|
|
|
TConfig c_tipo_documento(fname,"MAIN");
|
|
|
|
|
copy_defmagc = c_tipo_documento.get_bool("DEFMAGXCOLL");
|
|
|
|
|
}
|
|
|
|
|
if (copy_defmagc!=0)
|
|
|
|
|
{
|
|
|
|
|
if (row_mask.get(FR_CODMAGC).empty())
|
|
|
|
|
row_mask.set(FR_CODMAGC, mask.stdmag(), true);
|
|
|
|
|
if (row_mask.get(FR_CODDEPC).empty())
|
|
|
|
|
row_mask.set(FR_CODDEPC, mask.stddep(), true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!c.movimenta_sospesi())
|
|
|
|
|
{
|
|
|
|
|
const TRectype & rec = cache().get(LF_ANAMAG, row_mask.get(FR_CODARTMAG));
|
|
|
|
|
|
|
|
|
|
if (rec.get_bool("SOSPESO"))
|
|
|
|
|
return error_box("Articolo %s sospeso, quindi non movimentabile", (const char *)rec.get(ANAMAG_CODART));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
1997-10-23 10:53:49 +00:00
|
|
|
|
bool sppr_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
|
|
|
|
|
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_DESCR).empty()))
|
|
|
|
|
{
|
2006-02-02 13:49:19 +00:00
|
|
|
|
const TRectype& curr = ((TEdit_field&)f).browse()->cursor()->curr();
|
2008-10-07 00:50:22 +00:00
|
|
|
|
const TSpesa_prest sp(curr);
|
2006-02-02 13:49:19 +00:00
|
|
|
|
|
|
|
|
|
const int pos = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
if (pos >= 0 && !sp.empty())
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2006-02-02 13:49:19 +00:00
|
|
|
|
const char tipo = sp.tipo();
|
|
|
|
|
const bool qta_val_fl = tipo == 'Q';
|
|
|
|
|
const bool perc_fl = tipo == 'P';
|
|
|
|
|
int pos = row_mask.id2pos(FR_UMQTASP);
|
|
|
|
|
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_PREZZO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_SCONTO);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
row_mask.fld(pos).enable(!perc_fl);
|
|
|
|
|
pos = row_mask.id2pos(FR_QTA);
|
|
|
|
|
if (pos >= 0)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
2006-02-02 13:49:19 +00:00
|
|
|
|
row_mask.fld(pos).show(!perc_fl);
|
|
|
|
|
row_mask.fld(pos).enable(qta_val_fl);
|
|
|
|
|
}
|
|
|
|
|
pos = row_mask.id2pos(FR_PERCSP);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
row_mask.fld(pos).show(perc_fl);
|
|
|
|
|
row_mask.fld(pos).enable(perc_fl);
|
|
|
|
|
}
|
|
|
|
|
if (!perc_fl)
|
|
|
|
|
{
|
2007-03-07 16:51:50 +00:00
|
|
|
|
const TDocumento_mask& mask = (const TDocumento_mask&)row_mask.get_sheet()->mask();
|
2006-02-02 13:49:19 +00:00
|
|
|
|
const real cambio = mask.get_real(F_CAMBIO);
|
|
|
|
|
real prezzo = sp.prezzo();
|
|
|
|
|
const TString& doc_valuta = mask.get(F_CODVAL);
|
|
|
|
|
const bool controeuro = mask.get_bool(F_CONTROEURO);
|
|
|
|
|
|
|
|
|
|
sppr_calc(sp, doc_valuta, cambio, prezzo, controeuro ? _exchange_contro : _exchange_base);
|
2007-03-07 11:36:57 +00:00
|
|
|
|
if (mask.doc().tipo().calcolo_lordo())
|
|
|
|
|
prezzo = TRiga_documento::iva(sp.cod_iva()).lordo(prezzo, ALL_DECIMALS);
|
2006-02-02 13:49:19 +00:00
|
|
|
|
row_mask.set(FR_PREZZO, prezzo);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2006-02-02 13:49:19 +00:00
|
|
|
|
const int posiva = row_mask.id2pos(FR_CODIVA);
|
|
|
|
|
if (posiva >= 0)
|
|
|
|
|
iva_handler(row_mask.fld(posiva), 0);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2009-11-30 10:42:00 +00:00
|
|
|
|
if (row_mask.id2pos(FR_CDC1) >= 0 && sp.get("S1").full())
|
2006-02-02 13:49:19 +00:00
|
|
|
|
{
|
|
|
|
|
const TString80 cdc(sp.cdc());
|
|
|
|
|
const TString80 cms(sp.cms());
|
|
|
|
|
const TString80 fase(sp.fase());
|
2006-02-02 01:51:04 +00:00
|
|
|
|
|
2006-02-02 13:49:19 +00:00
|
|
|
|
for (short i = FR_CDC1; i <= FR_CDC12; i++)
|
|
|
|
|
{
|
2006-12-29 14:16:28 +00:00
|
|
|
|
const int pos = row_mask.id2pos(i);
|
2006-02-02 13:49:19 +00:00
|
|
|
|
if (pos >=0)
|
2006-02-02 01:51:04 +00:00
|
|
|
|
{
|
2006-02-02 13:49:19 +00:00
|
|
|
|
TEdit_field& e = (TEdit_field&)row_mask.fld(pos);
|
|
|
|
|
const TFieldref& fr = *e.field();
|
2006-02-02 01:51:04 +00:00
|
|
|
|
|
2006-02-02 13:49:19 +00:00
|
|
|
|
if (fr.name() == RDOC_CODCOSTO)
|
2009-11-30 10:42:00 +00:00
|
|
|
|
{
|
|
|
|
|
if (cdc.full())
|
|
|
|
|
e.set(cdc.sub(fr.from(), fr.to()));
|
|
|
|
|
} else
|
|
|
|
|
if (fr.name() == RDOC_CODCMS)
|
|
|
|
|
{
|
|
|
|
|
if (cms.full())
|
|
|
|
|
e.set(cms.sub(fr.from(), fr.to()));
|
|
|
|
|
} else
|
|
|
|
|
if (fr.name() == RDOC_FASCMS)
|
|
|
|
|
{
|
|
|
|
|
if (fase.full())
|
|
|
|
|
e.set(fase.sub(fr.from(), fr.to()));
|
|
|
|
|
}
|
2006-02-02 01:51:04 +00:00
|
|
|
|
}
|
2006-02-02 13:49:19 +00:00
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1997-10-23 10:53:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
// Costava troppo fare una unica funzione, ma alla fine ce l'abbiamo fatta! :-)
|
|
|
|
|
static void add_custom_search_fields(TMask& m, TToken_string& fields, TToken_string& headers)
|
|
|
|
|
{
|
|
|
|
|
TFilename name(m.source_file()); name.ext("ini");
|
|
|
|
|
TConfig c(name, "Search");
|
|
|
|
|
const TString& f = c.get("FieldList");
|
|
|
|
|
if (f.full())
|
|
|
|
|
{
|
|
|
|
|
if (f[0] == fields.separator())
|
|
|
|
|
fields << f;
|
|
|
|
|
else
|
|
|
|
|
fields.add(f);
|
|
|
|
|
|
|
|
|
|
const TString& h = c.get("Header");
|
|
|
|
|
if (h[0] == headers.separator())
|
|
|
|
|
headers << h;
|
|
|
|
|
else
|
|
|
|
|
headers.add(h);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-14 17:13:09 +00:00
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
|
bool TDocumento_mask::numdocrif_search_handler(TMask_field& f, KEY key)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_F9)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_DOC);
|
|
|
|
|
rel.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF");
|
2009-02-14 17:13:09 +00:00
|
|
|
|
rel.add(LF_RIGHEDOC, "PROVV==PROVV|ANNO==ANNO|CODNUM==CODNUM|NDOC==NDOC|NRIGA==1");
|
2011-04-01 13:00:11 +00:00
|
|
|
|
const long codcf = m.get_int(F_CODCF);
|
|
|
|
|
bool is_clifor = (codcf > 0L);
|
2009-02-14 17:13:09 +00:00
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
TRectype& filtrec = rel.curr();
|
|
|
|
|
|
2011-04-01 13:00:11 +00:00
|
|
|
|
if (is_clifor)
|
|
|
|
|
{
|
|
|
|
|
filtrec.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
filtrec.put(DOC_CODCF, codcf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
filtrec.put(DOC_CODNUM, m.get(F_CODNUM));
|
|
|
|
|
filtrec.put(DOC_PROVV, m.get(F_PROVV));
|
|
|
|
|
filtrec.put(DOC_ANNO, m.get(F_ANNO));
|
|
|
|
|
|
|
|
|
|
TSorted_cursor cur(&rel, "NUMDOCRIF", "", is_clifor ? 2: 1, &filtrec, &filtrec);
|
|
|
|
|
|
|
|
|
|
if (is_clifor)
|
|
|
|
|
{
|
|
|
|
|
TString80 filter;
|
|
|
|
|
|
|
|
|
|
filter.format(DOC_CODNUM "==\"%s\"", (const char*)m.get(F_CODNUM));
|
|
|
|
|
cur.setfilter(filter);
|
|
|
|
|
}
|
2008-03-26 11:24:36 +00:00
|
|
|
|
TToken_string siblings;
|
2011-02-18 15:29:46 +00:00
|
|
|
|
|
2011-04-01 13:00:11 +00:00
|
|
|
|
TToken_string header(HR("Docum.Rif.|Data@10|Codice|Ragione Sociale@50|Docum.Rif. 1|Docum.Rif. 2|Docum.Rif. 3|Documento|Data\nDocumento@10|Totale\nDocumento@18V|Valuta|Stato"));
|
|
|
|
|
TToken_string fieldlist("NUMDOCRIF|DATADOCRIF|CODCF|20->RAGSOC|DOC1|DOC2|DOC3|NDOC|DATADOC|G1:TOTDOC|CODVAL|STATO");
|
2011-02-18 15:29:46 +00:00
|
|
|
|
add_custom_search_fields(m, fieldlist, header);
|
2009-02-14 17:13:09 +00:00
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
TBrowse_sheet sheet(&cur, fieldlist, TR("Documento di riferimento"),
|
|
|
|
|
header, 0, (TEdit_field&)f, siblings);
|
2011-04-01 13:00:11 +00:00
|
|
|
|
TCursor * c = sheet.cursor();
|
|
|
|
|
|
|
|
|
|
if (c != NULL)
|
|
|
|
|
{
|
|
|
|
|
TRectype rec(filtrec);
|
|
|
|
|
|
|
|
|
|
rec.put(DOC_NUMDOCRIF, m.get(F_NUMDOCRIF));
|
|
|
|
|
c->curr() = rec;
|
|
|
|
|
c->read();
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
2011-02-18 15:29:46 +00:00
|
|
|
|
const int pos_ndoc = fieldlist.get_pos(DOC_NDOC);
|
|
|
|
|
const long ndoc = sheet.row(-1).get_long(pos_ndoc);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
m.set(F_NDOC, ndoc);
|
|
|
|
|
m.stop_run(K_AUTO_ENTER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
1999-10-22 10:00:18 +00:00
|
|
|
|
}
|
2000-10-03 13:45:12 +00:00
|
|
|
|
|
2004-09-03 13:52:59 +00:00
|
|
|
|
bool TDocumento_mask::ragsoc_search_handler(TMask_field& f, KEY key)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (key == K_F9)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = f.mask();
|
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
TRelation rel(LF_DOC);
|
|
|
|
|
rel.add(LF_CLIFO, "TIPOCF==TIPOCF|CODCF==CODCF");
|
|
|
|
|
|
|
|
|
|
TRectype& filtrec = rel.curr();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
filtrec.put(DOC_PROVV, m.get(F_PROVV));
|
|
|
|
|
filtrec.put(DOC_ANNO, m.get(F_ANNO));
|
2011-02-18 15:29:46 +00:00
|
|
|
|
filtrec.put(DOC_CODNUM, m.get(F_CODNUM));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
|
|
|
|
TSorted_cursor cur(&rel, "TIPOCF|UPPER(20->RAGSOC)|PROVV|ANNO|CODNUM|PROVV|NDOC", "", 1, &filtrec, &filtrec);
|
2011-02-18 15:29:46 +00:00
|
|
|
|
TString filter; filter.format("(CODNUM==\"%s\")&&(PROVV==\"D\")&&(TIPOCF==\"%s\")",
|
|
|
|
|
(const char*)m.get(F_CODNUM), (const char*)m.get(F_TIPOCF));
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2008-03-26 11:24:36 +00:00
|
|
|
|
cur.setfilter(filter, true);
|
|
|
|
|
TToken_string siblings;
|
2009-06-11 01:02:50 +00:00
|
|
|
|
TToken_string header(HR("Ragione Sociale@50|Codice|Documento|Data\nDocumento@10|Totale\nDocumento@18V|Valuta|Stato|Partita IVA"));
|
|
|
|
|
TToken_string fieldlist("20->RAGSOC|CODCF|NDOC|DATADOC|G1:TOTDOC|CODVAL|STATO|20->PAIV");
|
2011-02-18 15:29:46 +00:00
|
|
|
|
add_custom_search_fields(m, fieldlist, header);
|
2009-02-14 17:13:09 +00:00
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
TBrowse_sheet sheet(&cur, fieldlist, TR("Ragione Sociale"),
|
|
|
|
|
header, 0, (TEdit_field&)f, siblings);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
|
2011-02-18 15:29:46 +00:00
|
|
|
|
if (!f.empty())
|
|
|
|
|
{
|
|
|
|
|
TString ragsoc(f.get()); ragsoc.upper();
|
|
|
|
|
filtrec.zero();
|
|
|
|
|
filtrec.put(DOC_TIPOCF, m.get(F_TIPOCF));
|
|
|
|
|
rel.curr(LF_CLIFO).put(CLI_RAGSOC, ragsoc);
|
|
|
|
|
cur.read();
|
|
|
|
|
}
|
2006-04-13 17:56:02 +00:00
|
|
|
|
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
|
{
|
2011-02-18 15:29:46 +00:00
|
|
|
|
const int pos_ndoc = fieldlist.get_pos(DOC_NDOC);
|
|
|
|
|
const long ndoc = sheet.row(-1).get_long(pos_ndoc);
|
2005-08-23 08:54:32 +00:00
|
|
|
|
m.set(F_NDOC, ndoc);
|
|
|
|
|
m.stop_run(K_AUTO_ENTER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2004-09-03 13:52:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-07-11 13:12:41 +00:00
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
|
bool TDocumento_mask::datadocrif_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (key == K_ENTER && f.empty())
|
|
|
|
|
{
|
|
|
|
|
const TDocumento_mask& m = (const TDocumento_mask&)f.mask();
|
|
|
|
|
if (m.get_bool(F_RAGGREFF))
|
|
|
|
|
{
|
|
|
|
|
const TDocumento& doc = m.doc();
|
|
|
|
|
if (doc.is_nota_credito())
|
|
|
|
|
return f.error_box("E' necessario specificare data e numero documento di riferimento\n"
|
|
|
|
|
"quando si desidera generare effetti raggruppati");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2002-05-31 10:35:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool link_handler( TMask_field& f, KEY key )
|
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
if (key == K_SPACE)
|
|
|
|
|
{
|
2009-02-26 23:32:16 +00:00
|
|
|
|
TSheet_field & sf = *f.mask().get_sheet();
|
2009-04-23 15:26:54 +00:00
|
|
|
|
TDocumento_mask & m = (TDocumento_mask & )sf.mask();
|
2009-02-26 23:32:16 +00:00
|
|
|
|
TDocumento & d = (TDocumento &) m.doc();
|
|
|
|
|
int row = sf.selected();
|
|
|
|
|
const TRiga_documento & r = d[row + 1];
|
|
|
|
|
const TMask & row_mask = f.mask();
|
|
|
|
|
|
|
|
|
|
if (r.linked())
|
|
|
|
|
r.edit(LF_DOC, "DAPROVV|DAANNO|DACODNUM|DANDOC");
|
|
|
|
|
else
|
|
|
|
|
if (!row_mask.is_running() && row_mask.id2pos(FR_CODART) >= 0)
|
|
|
|
|
{
|
|
|
|
|
TBrowse * brw = row_mask.efield(FR_CODART).browse();
|
|
|
|
|
|
|
|
|
|
if (row_mask.get(FR_CODART).empty() && brw)
|
|
|
|
|
{
|
|
|
|
|
TCursor& cur = *brw->cursor();
|
|
|
|
|
TToken_string siblings;
|
|
|
|
|
|
|
|
|
|
TToken_string head(brw->head());
|
|
|
|
|
head.insert("@1|", 0);
|
|
|
|
|
TToken_string items(brw->items());
|
|
|
|
|
items.insert(" |", 0);
|
|
|
|
|
|
|
|
|
|
cur = 0L;
|
|
|
|
|
siblings.add(FR_CODART);
|
|
|
|
|
|
2009-07-09 14:22:48 +00:00
|
|
|
|
TBrowse_sheet sht(&cur, items, TR("Selezione multipla"), head, 0, row_mask.efield(FR_CODART), siblings);
|
2009-02-26 23:32:16 +00:00
|
|
|
|
|
|
|
|
|
if (sht.run() == K_ENTER && sht.one_checked())
|
|
|
|
|
{
|
|
|
|
|
const int items_selected = sht.checked();
|
|
|
|
|
const long totit = cur.items();
|
|
|
|
|
if (items_selected * d.physical_rows() < 950)
|
|
|
|
|
{
|
|
|
|
|
int processed = 0L;
|
|
|
|
|
TToken_string out_id(brw->get_output_fields());
|
|
|
|
|
TToken_string out_fnames(brw->get_output_field_names());
|
|
|
|
|
const TString4 tipo(row_mask.get(FR_TIPORIGA));
|
|
|
|
|
|
|
|
|
|
cur.freeze(TRUE);
|
|
|
|
|
for (cur = 0L; cur.pos() < totit; ++cur)
|
|
|
|
|
if (sht.checked(cur.pos()))
|
|
|
|
|
{
|
|
|
|
|
if (++processed < items_selected)
|
2009-04-23 15:26:54 +00:00
|
|
|
|
sf.insert(row, false, true); // call notify ?
|
|
|
|
|
d[row + 1].autoload(sf);
|
2009-02-26 23:32:16 +00:00
|
|
|
|
TToken_string & shrow = sf.row(row);
|
|
|
|
|
shrow.add(tipo, sf.cid2index(FR_TIPORIGA));
|
|
|
|
|
shrow.add("", sf.cid2index(FR_CHECKED));
|
|
|
|
|
|
2009-04-23 15:26:54 +00:00
|
|
|
|
TMask & row_mask = sf.sheet_row_mask(row);
|
2009-02-26 23:32:16 +00:00
|
|
|
|
|
2009-04-23 15:26:54 +00:00
|
|
|
|
row_mask.set(FR_TIPORIGA, tipo);
|
2009-02-26 23:32:16 +00:00
|
|
|
|
out_fnames.restart();
|
|
|
|
|
for (short id = out_id.get_int(0); id > 0; id = out_id.get_int())
|
|
|
|
|
{
|
|
|
|
|
const TString16 fn(out_fnames.get());
|
|
|
|
|
const TFieldref fr(fn, 0);
|
2009-04-23 15:26:54 +00:00
|
|
|
|
row_mask.set(id, fr.read(cur.curr()));
|
|
|
|
|
shrow.add(row_mask.get(id), sf.cid2index(id));
|
2009-02-26 23:32:16 +00:00
|
|
|
|
}
|
|
|
|
|
sf.check_row(row, 0x2);
|
|
|
|
|
d[row + 1].autosave(sf);
|
2009-04-23 15:26:54 +00:00
|
|
|
|
m.highlight_row(row);
|
2009-02-26 23:32:16 +00:00
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
cur.freeze(FALSE);
|
|
|
|
|
sf.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ca_mag_handler(TMask_field& f, bool cdc = true)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
const TSheet_field & sf = *f.mask().get_sheet();
|
|
|
|
|
const TDocumento_mask & mask = (TDocumento_mask & )sf.mask();
|
|
|
|
|
short i, first_fld, last_fld;
|
|
|
|
|
const int lffile = cdc ? LF_CDC : LF_COMMESSE;
|
|
|
|
|
const TMultilevel_code_info & info = ca_multilevel_code_info(lffile);
|
|
|
|
|
TString80 cod;
|
|
|
|
|
|
|
|
|
|
last_fld = f.dlg();
|
|
|
|
|
first_fld = last_fld - info.levels() + 1;
|
2010-09-06 10:32:45 +00:00
|
|
|
|
for (i = first_fld; i <= last_fld; i++)
|
2005-08-23 08:54:32 +00:00
|
|
|
|
cod << row_mask.get(i);
|
|
|
|
|
if (cod.blank())
|
|
|
|
|
{
|
|
|
|
|
cod.cut(0);
|
2007-11-16 13:46:49 +00:00
|
|
|
|
last_fld = cdc ? mask.cdc_end() : mask.cms_end();
|
2005-08-23 08:54:32 +00:00
|
|
|
|
first_fld = last_fld - info.levels() + 1;
|
|
|
|
|
|
|
|
|
|
for (i = first_fld; i <= last_fld; i++)
|
|
|
|
|
cod << mask.get(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRectype & rec = cache().get(lffile, cod);
|
|
|
|
|
const TString16 codmag = rec.get("CODMAG");
|
|
|
|
|
|
|
|
|
|
if (codmag.not_empty())
|
|
|
|
|
{
|
|
|
|
|
row_mask.set(FR_CODMAG, codmag.left(3), true);
|
|
|
|
|
row_mask.set(FR_CODDEP, codmag.mid(3), true);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool cms_mag_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if ((key == K_TAB && f.focusdirty()) || key == K_ENTER)
|
2007-11-16 13:46:49 +00:00
|
|
|
|
{
|
2005-08-23 08:54:32 +00:00
|
|
|
|
ca_mag_handler(f, false);
|
2007-11-16 13:46:49 +00:00
|
|
|
|
TMask & m = f.mask();
|
|
|
|
|
const TSheet_field & s = *m.get_sheet();
|
|
|
|
|
TDocumento_mask & mask = (TDocumento_mask & )s.mask();
|
|
|
|
|
const TRectype & curr = m.efield(mask.cms_start_sh()).browse()->cursor()->curr();
|
2009-07-09 15:31:20 +00:00
|
|
|
|
const TString codcms = curr.get(COMMESSE_CODCMS);
|
2007-11-16 13:46:49 +00:00
|
|
|
|
|
2009-07-09 15:31:20 +00:00
|
|
|
|
if (mask.codcms_sh() != codcms) // Cambio commessa
|
2007-11-16 13:46:49 +00:00
|
|
|
|
{
|
|
|
|
|
mask.codcms_sh() = codcms;
|
2009-07-09 15:31:20 +00:00
|
|
|
|
|
|
|
|
|
const TString codcosto = curr.get(COMMESSE_CODCOSTO);
|
|
|
|
|
if (mask.cdc_start_sh() > mask.cms_start_sh() && codcosto.full())
|
|
|
|
|
{
|
|
|
|
|
for (short i = mask.cdc_start_sh(); i <= mask.cdc_end_sh(); i++)
|
|
|
|
|
{
|
|
|
|
|
TEdit_field & e = m.efield(i);
|
|
|
|
|
const TFieldref * f = e.field();
|
|
|
|
|
|
|
|
|
|
if (f != NULL)
|
|
|
|
|
{
|
|
|
|
|
const int from = f->from();
|
|
|
|
|
const int to = f->to();
|
|
|
|
|
|
|
|
|
|
m.set(i, codcosto.sub(from, to), 0x2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-11-16 13:46:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2005-08-23 08:54:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool cdc_mag_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if ((key == K_TAB && f.focusdirty()) || key == K_ENTER)
|
|
|
|
|
ca_mag_handler(f);
|
|
|
|
|
return true;
|
2007-11-16 13:46:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool codcms_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
2009-07-09 15:31:20 +00:00
|
|
|
|
TDocumento_mask& mask = (TDocumento_mask&)f.mask();
|
2011-03-30 23:36:40 +00:00
|
|
|
|
const TRectype& curr = mask.efield(mask.cms_end()).browse()->cursor()->curr();
|
Patch level : 10.0 870
Files correlati : ef0.exe
Ricompilazione Demo : [ ]
Commento :
Gestione CUP
Verificare che i profili persnalizzati continuino a funzionare
Nella gestione profili e documenti aggiunti i campi per gestire piu banche di appoggio e presentazione dei clienti/ fornitori
La ricerca e sulla tabella se il cliente / fornitore non ha banche altrimenti e sulle banche del cliente/fornitore.
Ai profili personalizzati vanno aggiunti-modificati e posizionati i campi :
NU 117 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIA
US %BAN SE CODTAB?="?????"
IN CODTAB[1,5] 117
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 117 CODTAB[1,5]
OU 336 S0
OU 197 CODTAB[1,5]
ME CO,220
EN
NU 118 5
BE
PR 42 11 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABA
US %BAN SE CODTAB?="??????????"
IN CODTAB[1,5] 117
IN CODTAB[6,10] 118
CO DI 117
OU 117 CODTAB[1,5]
OU 118 CODTAB[6,10]
OU 336 S0
OU 198 CODTAB[6,10]
ME CO,221
EN
NU 220 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIA
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "V"
IN ABI 220
IN CAB 221
IN PROGPR ""
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 220 ABI
OU 221 CAB
OU 336 %BAN->S0
OU 192 IBAN
OU 197 ABI
OU 198 CAB
EN
NU 221 5
BE
PR 42 11 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABA
CO US 220
CO IN 220
CO DI 220
CO OU 220
EN
per la banca di appoggio
NU 119 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIP
CO US 117
IN CODTAB[1,5] 119
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 119 CODTAB[1,5]
OU 338 S0
ME CO,222
EN
NU 120 5
BE
PR 42 14 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABP
CO US 118
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
CO DI 119
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 338 S0
ME CO,223
EN
NU 214 2
BE
PR 60 14 "Progressivo "
FL "Z"
FI PROGBNP
US BNP
JOIN %BAN ALIAS 100 INTO CODTAB=CODTAB[1,10]
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
IN CODTAB[11,12] 214
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Progr." CODTAB[11,12]
DI "IBAN@27" S3
DI "Denominazione@50" 100@->S0
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 214 CODTAB[11,12]
OU 338 100@->S0
ME CO,224
EN
NU 222 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIP
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "N"
IN ABI 222
IN CAB 223
IN PROGPR 224
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "Progr." PROGPR
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 222 ABI
OU 223 CAB
OU 224 PROGPR
OU 338 %BAN->S0
OU 192 IBAN
EN
NU 223 5
BE
PR 42 14 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
NU 224 2
BE
PR 60 14 "Progressivo "
FL "ZH"
CH NORMAL
FI PROGBNP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
per la banca di presentazione.
Sono stati aggiunti campi CUP e CIG che hanno la ricerca sulla tabella ne caso normale e la ricerca sul file
commesse clienti nel caso sia presente l'analitica
Vanno aggiunti e posizionati ai profili personalizzati nel caso servano:
ST 215 15
BE
PR 2 11 "Cod.Unico Prog."
FL "U"
CH NORMAL
FI CUP
US %CUP
IN CODTAB 215
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 215 CODTAB
OU 216 S0
HE "Inserisci il Codice Unico di Progetto"
WA "Codice Unico di Progetto non trovato"
CH NORMAL
EN
ST 216 50
BE
PR 35 11 ""
FL ""
CH NORMAL
US %CUP KEY 2
IN S0 216
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 215
EN
ST 217 15
BE
PR 2 12 "Cod.Ident.Gara "
FL "U"
CH NORMAL
FI CIG
US %CIG
IN CODTAB 217
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 217 CODTAB
OU 218 S0
HE "Inserisci il Codice Identificativo Gara"
WA "Codice Identificativo Gara non trovato"
CH NORMAL
EN
ST 218 50
BE
PR 35 12 ""
FL ""
CH NORMAL
US %CIG KEY 2
IN S0 218
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 217
EN
ST 219 20
BE
PR 2 13 ""
FL "H"
FI CODCMS
EN
La generazione effetti scrive il CUP e il CIG sull'effetto.
La contabilizzazione scrive il CUP e il CIG sulle righe contabili.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21374 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-12-28 08:28:47 +00:00
|
|
|
|
const TString codcms = curr.get(COMMESSE_CODCMS);
|
|
|
|
|
|
|
|
|
|
if (f.to_check(key, TRUE))
|
|
|
|
|
mask.set(F_CMSH, codcms);
|
2007-11-16 13:46:49 +00:00
|
|
|
|
if ((key == K_TAB && f.focusdirty()) || key == K_ENTER)
|
|
|
|
|
{
|
2009-07-09 09:56:24 +00:00
|
|
|
|
// Controlla se c'e' la gestione dei centri di costo al secondo livello
|
2011-02-26 22:49:55 +00:00
|
|
|
|
if (mask.codcms() != codcms)
|
|
|
|
|
{
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
TSheet_field & sf = mask.sfield(F_SHEET);
|
|
|
|
|
const int rows = doc.physical_rows();
|
|
|
|
|
|
|
|
|
|
doc.put(DOC_CODCMS, codcms);
|
|
|
|
|
for (int r = 1; r <= rows; r++)
|
|
|
|
|
{
|
|
|
|
|
TRiga_documento & riga = doc[r];
|
|
|
|
|
const TMask & m = sf.sheet_row_mask(r -1);
|
|
|
|
|
|
|
|
|
|
if (m.id2pos(FR_TIPODET) >= 0 && m.field(FR_TIPODET).active()) //solo se attivo il campo di indetraibilita'...
|
|
|
|
|
{
|
|
|
|
|
riga.cms2tipodet();
|
|
|
|
|
riga.autoload(sf);
|
|
|
|
|
sf.force_update(r - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Patch level : 10.0 870
Files correlati : ef0.exe
Ricompilazione Demo : [ ]
Commento :
Gestione CUP
Verificare che i profili persnalizzati continuino a funzionare
Nella gestione profili e documenti aggiunti i campi per gestire piu banche di appoggio e presentazione dei clienti/ fornitori
La ricerca e sulla tabella se il cliente / fornitore non ha banche altrimenti e sulle banche del cliente/fornitore.
Ai profili personalizzati vanno aggiunti-modificati e posizionati i campi :
NU 117 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIA
US %BAN SE CODTAB?="?????"
IN CODTAB[1,5] 117
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 117 CODTAB[1,5]
OU 336 S0
OU 197 CODTAB[1,5]
ME CO,220
EN
NU 118 5
BE
PR 42 11 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABA
US %BAN SE CODTAB?="??????????"
IN CODTAB[1,5] 117
IN CODTAB[6,10] 118
CO DI 117
OU 117 CODTAB[1,5]
OU 118 CODTAB[6,10]
OU 336 S0
OU 198 CODTAB[6,10]
ME CO,221
EN
NU 220 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIA
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "V"
IN ABI 220
IN CAB 221
IN PROGPR ""
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 220 ABI
OU 221 CAB
OU 336 %BAN->S0
OU 192 IBAN
OU 197 ABI
OU 198 CAB
EN
NU 221 5
BE
PR 42 11 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABA
CO US 220
CO IN 220
CO DI 220
CO OU 220
EN
per la banca di appoggio
NU 119 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIP
CO US 117
IN CODTAB[1,5] 119
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 119 CODTAB[1,5]
OU 338 S0
ME CO,222
EN
NU 120 5
BE
PR 42 14 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABP
CO US 118
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
CO DI 119
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 338 S0
ME CO,223
EN
NU 214 2
BE
PR 60 14 "Progressivo "
FL "Z"
FI PROGBNP
US BNP
JOIN %BAN ALIAS 100 INTO CODTAB=CODTAB[1,10]
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
IN CODTAB[11,12] 214
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Progr." CODTAB[11,12]
DI "IBAN@27" S3
DI "Denominazione@50" 100@->S0
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 214 CODTAB[11,12]
OU 338 100@->S0
ME CO,224
EN
NU 222 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIP
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "N"
IN ABI 222
IN CAB 223
IN PROGPR 224
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "Progr." PROGPR
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 222 ABI
OU 223 CAB
OU 224 PROGPR
OU 338 %BAN->S0
OU 192 IBAN
EN
NU 223 5
BE
PR 42 14 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
NU 224 2
BE
PR 60 14 "Progressivo "
FL "ZH"
CH NORMAL
FI PROGBNP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
per la banca di presentazione.
Sono stati aggiunti campi CUP e CIG che hanno la ricerca sulla tabella ne caso normale e la ricerca sul file
commesse clienti nel caso sia presente l'analitica
Vanno aggiunti e posizionati ai profili personalizzati nel caso servano:
ST 215 15
BE
PR 2 11 "Cod.Unico Prog."
FL "U"
CH NORMAL
FI CUP
US %CUP
IN CODTAB 215
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 215 CODTAB
OU 216 S0
HE "Inserisci il Codice Unico di Progetto"
WA "Codice Unico di Progetto non trovato"
CH NORMAL
EN
ST 216 50
BE
PR 35 11 ""
FL ""
CH NORMAL
US %CUP KEY 2
IN S0 216
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 215
EN
ST 217 15
BE
PR 2 12 "Cod.Ident.Gara "
FL "U"
CH NORMAL
FI CIG
US %CIG
IN CODTAB 217
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 217 CODTAB
OU 218 S0
HE "Inserisci il Codice Identificativo Gara"
WA "Codice Identificativo Gara non trovato"
CH NORMAL
EN
ST 218 50
BE
PR 35 12 ""
FL ""
CH NORMAL
US %CIG KEY 2
IN S0 218
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 217
EN
ST 219 20
BE
PR 2 13 ""
FL "H"
FI CODCMS
EN
La generazione effetti scrive il CUP e il CIG sull'effetto.
La contabilizzazione scrive il CUP e il CIG sulle righe contabili.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21374 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-12-28 08:28:47 +00:00
|
|
|
|
if (mask.cdc_start() > 0 && mask.cdc_start() > mask.cms_start() && mask.codcms() != codcms)
|
2009-07-09 09:56:24 +00:00
|
|
|
|
{
|
2009-10-28 17:24:49 +00:00
|
|
|
|
mask.codcms() = codcms;
|
2007-12-03 14:04:02 +00:00
|
|
|
|
const TString codcosto = curr.get(COMMESSE_CODCOSTO);
|
2009-07-09 09:56:24 +00:00
|
|
|
|
if (codcosto.full()) // Propone centro di costo solo se specificato
|
|
|
|
|
{
|
|
|
|
|
for (short i = mask.cdc_start(); i <= mask.cdc_end(); i++)
|
|
|
|
|
{
|
|
|
|
|
TEdit_field & e = mask.efield(i);
|
|
|
|
|
const TFieldref * f = e.field();
|
|
|
|
|
if (f != NULL)
|
|
|
|
|
{
|
|
|
|
|
const int from = f->from();
|
|
|
|
|
const int to = f->to();
|
|
|
|
|
mask.set(i, codcosto.sub(from, to), 0x2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-13 15:59:46 +00:00
|
|
|
|
if ((key == K_TAB && f.focusdirty()))
|
|
|
|
|
{
|
|
|
|
|
TDocumento & doc = mask.doc();
|
|
|
|
|
|
|
|
|
|
if (!doc.bloccato())
|
|
|
|
|
{
|
|
|
|
|
char name[8] = "CODSP0";
|
|
|
|
|
TString_array spese;
|
|
|
|
|
|
|
|
|
|
const TRectype & ven_rec = doc.clifor().vendite();
|
|
|
|
|
for (int i = 1; i <= 4; i++)
|
|
|
|
|
{
|
|
|
|
|
name[5] = '0' + i;
|
|
|
|
|
const TString& s = ven_rec.get(name);
|
|
|
|
|
if (s.full())
|
|
|
|
|
spese.add(s);
|
|
|
|
|
}
|
|
|
|
|
mask.mask2doc();
|
|
|
|
|
doc.put(DOC_SPESEUPD, "");
|
|
|
|
|
doc.update_spese_aut(spese, false, &mask.sfield(F_SHEET));
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-09 09:56:24 +00:00
|
|
|
|
}
|
Patch level : 10.0 870
Files correlati : ef0.exe
Ricompilazione Demo : [ ]
Commento :
Gestione CUP
Verificare che i profili persnalizzati continuino a funzionare
Nella gestione profili e documenti aggiunti i campi per gestire piu banche di appoggio e presentazione dei clienti/ fornitori
La ricerca e sulla tabella se il cliente / fornitore non ha banche altrimenti e sulle banche del cliente/fornitore.
Ai profili personalizzati vanno aggiunti-modificati e posizionati i campi :
NU 117 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIA
US %BAN SE CODTAB?="?????"
IN CODTAB[1,5] 117
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 117 CODTAB[1,5]
OU 336 S0
OU 197 CODTAB[1,5]
ME CO,220
EN
NU 118 5
BE
PR 42 11 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABA
US %BAN SE CODTAB?="??????????"
IN CODTAB[1,5] 117
IN CODTAB[6,10] 118
CO DI 117
OU 117 CODTAB[1,5]
OU 118 CODTAB[6,10]
OU 336 S0
OU 198 CODTAB[6,10]
ME CO,221
EN
NU 220 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIA
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "V"
IN ABI 220
IN CAB 221
IN PROGPR ""
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 220 ABI
OU 221 CAB
OU 336 %BAN->S0
OU 192 IBAN
OU 197 ABI
OU 198 CAB
EN
NU 221 5
BE
PR 42 11 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABA
CO US 220
CO IN 220
CO DI 220
CO OU 220
EN
per la banca di appoggio
NU 119 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIP
CO US 117
IN CODTAB[1,5] 119
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 119 CODTAB[1,5]
OU 338 S0
ME CO,222
EN
NU 120 5
BE
PR 42 14 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABP
CO US 118
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
CO DI 119
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 338 S0
ME CO,223
EN
NU 214 2
BE
PR 60 14 "Progressivo "
FL "Z"
FI PROGBNP
US BNP
JOIN %BAN ALIAS 100 INTO CODTAB=CODTAB[1,10]
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
IN CODTAB[11,12] 214
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Progr." CODTAB[11,12]
DI "IBAN@27" S3
DI "Denominazione@50" 100@->S0
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 214 CODTAB[11,12]
OU 338 100@->S0
ME CO,224
EN
NU 222 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIP
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "N"
IN ABI 222
IN CAB 223
IN PROGPR 224
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "Progr." PROGPR
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 222 ABI
OU 223 CAB
OU 224 PROGPR
OU 338 %BAN->S0
OU 192 IBAN
EN
NU 223 5
BE
PR 42 14 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
NU 224 2
BE
PR 60 14 "Progressivo "
FL "ZH"
CH NORMAL
FI PROGBNP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
per la banca di presentazione.
Sono stati aggiunti campi CUP e CIG che hanno la ricerca sulla tabella ne caso normale e la ricerca sul file
commesse clienti nel caso sia presente l'analitica
Vanno aggiunti e posizionati ai profili personalizzati nel caso servano:
ST 215 15
BE
PR 2 11 "Cod.Unico Prog."
FL "U"
CH NORMAL
FI CUP
US %CUP
IN CODTAB 215
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 215 CODTAB
OU 216 S0
HE "Inserisci il Codice Unico di Progetto"
WA "Codice Unico di Progetto non trovato"
CH NORMAL
EN
ST 216 50
BE
PR 35 11 ""
FL ""
CH NORMAL
US %CUP KEY 2
IN S0 216
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 215
EN
ST 217 15
BE
PR 2 12 "Cod.Ident.Gara "
FL "U"
CH NORMAL
FI CIG
US %CIG
IN CODTAB 217
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 217 CODTAB
OU 218 S0
HE "Inserisci il Codice Identificativo Gara"
WA "Codice Identificativo Gara non trovato"
CH NORMAL
EN
ST 218 50
BE
PR 35 12 ""
FL ""
CH NORMAL
US %CIG KEY 2
IN S0 218
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 217
EN
ST 219 20
BE
PR 2 13 ""
FL "H"
FI CODCMS
EN
La generazione effetti scrive il CUP e il CIG sull'effetto.
La contabilizzazione scrive il CUP e il CIG sulle righe contabili.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21374 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-12-28 08:28:47 +00:00
|
|
|
|
if (main_app().has_module(CUAUT) && (key == K_TAB && f.focusdirty()))
|
|
|
|
|
{
|
|
|
|
|
TToken_string key;
|
|
|
|
|
static TRecord_cache __cfcm(LF_CFCMS, 4);
|
|
|
|
|
|
|
|
|
|
if (mask.get(F_TIPOCF) != "C")
|
|
|
|
|
{
|
|
|
|
|
key.add(codcms);
|
|
|
|
|
key.add("C");
|
|
|
|
|
key.add(1);
|
|
|
|
|
const TRectype & cfcms = cache().get(LF_CFCMS, key);
|
|
|
|
|
|
|
|
|
|
mask.set(F_CUP, cfcms.get(CFCMS_CUP), 3);
|
|
|
|
|
mask.set(F_CIG, cfcms.get(CFCMS_CIG), 3);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
key.add(codcms);
|
|
|
|
|
key.add(mask.get(F_TIPOCF));
|
|
|
|
|
key.add(mask.get(F_CODCF));
|
|
|
|
|
const TRectype & cfcms1 = __cfcm.get(key);
|
2011-03-03 15:14:07 +00:00
|
|
|
|
|
|
|
|
|
if (cfcms1.empty())
|
|
|
|
|
{
|
|
|
|
|
key = codcms;
|
|
|
|
|
key.add("C");
|
|
|
|
|
key.add(1);
|
|
|
|
|
const TRectype & cfcms2 = cache().get(LF_CFCMS, key);
|
|
|
|
|
|
|
|
|
|
mask.set(F_CUP, cfcms2.get(CFCMS_CUP), 3);
|
|
|
|
|
mask.set(F_CIG, cfcms2.get(CFCMS_CIG), 3);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mask.set(F_CUP, cfcms1.get(CFCMS_CUP), 3);
|
|
|
|
|
mask.set(F_CIG, cfcms1.get(CFCMS_CIG), 3);
|
|
|
|
|
}
|
Patch level : 10.0 870
Files correlati : ef0.exe
Ricompilazione Demo : [ ]
Commento :
Gestione CUP
Verificare che i profili persnalizzati continuino a funzionare
Nella gestione profili e documenti aggiunti i campi per gestire piu banche di appoggio e presentazione dei clienti/ fornitori
La ricerca e sulla tabella se il cliente / fornitore non ha banche altrimenti e sulle banche del cliente/fornitore.
Ai profili personalizzati vanno aggiunti-modificati e posizionati i campi :
NU 117 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIA
US %BAN SE CODTAB?="?????"
IN CODTAB[1,5] 117
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 117 CODTAB[1,5]
OU 336 S0
OU 197 CODTAB[1,5]
ME CO,220
EN
NU 118 5
BE
PR 42 11 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABA
US %BAN SE CODTAB?="??????????"
IN CODTAB[1,5] 117
IN CODTAB[6,10] 118
CO DI 117
OU 117 CODTAB[1,5]
OU 118 CODTAB[6,10]
OU 336 S0
OU 198 CODTAB[6,10]
ME CO,221
EN
NU 220 5
BE
PR 2 11 "Banca appoggio : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIA
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "V"
IN ABI 220
IN CAB 221
IN PROGPR ""
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 220 ABI
OU 221 CAB
OU 336 %BAN->S0
OU 192 IBAN
OU 197 ABI
OU 198 CAB
EN
NU 221 5
BE
PR 42 11 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABA
CO US 220
CO IN 220
CO DI 220
CO OU 220
EN
per la banca di appoggio
NU 119 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "Z"
CH NORMAL
FI CODABIP
CO US 117
IN CODTAB[1,5] 119
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Denominazione@50" S0
OU 119 CODTAB[1,5]
OU 338 S0
ME CO,222
EN
NU 120 5
BE
PR 42 14 "Cod. CAB "
FL "Z"
CH NORMAL
FI CODCABP
CO US 118
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
CO DI 119
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 338 S0
ME CO,223
EN
NU 214 2
BE
PR 60 14 "Progressivo "
FL "Z"
FI PROGBNP
US BNP
JOIN %BAN ALIAS 100 INTO CODTAB=CODTAB[1,10]
IN CODTAB[1,5] 119
IN CODTAB[6,10] 120
IN CODTAB[11,12] 214
DI "Cod. Istit." CODTAB[1,5]
DI "Cod. Fil." CODTAB[6,10]
DI "Progr." CODTAB[11,12]
DI "IBAN@27" S3
DI "Denominazione@50" 100@->S0
OU 119 CODTAB[1,5]
OU 120 CODTAB[6,10]
OU 214 CODTAB[11,12]
OU 338 100@->S0
ME CO,224
EN
NU 222 5
BE
PR 2 14 "Banca presentazione : Cod. ABI "
FL "ZH"
CH NORMAL
FI CODABIP
US 98 KEY 2
JOIN %BAN INTO CODTAB[1,5]==ABI CODTAB[6,10]==CAB
IN TIPOCF 107 SE
IN CODCF 108 SE
IN TIPOBAN "N"
IN ABI 222
IN CAB 223
IN PROGPR 224
DI "Cod. Istit." ABI
DI "Cod. Fil." CAB
DI "Progr." PROGPR
DI "IBAN@27" IBAN
DI "Denominazione@50" %BAN->S0
OU 222 ABI
OU 223 CAB
OU 224 PROGPR
OU 338 %BAN->S0
OU 192 IBAN
EN
NU 223 5
BE
PR 42 14 "Cod. CAB "
FL "ZH"
CH NORMAL
FI CODCABP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
NU 224 2
BE
PR 60 14 "Progressivo "
FL "ZH"
CH NORMAL
FI PROGBNP
CO US 222
CO IN 222
CO DI 222
CO OU 222
EN
per la banca di presentazione.
Sono stati aggiunti campi CUP e CIG che hanno la ricerca sulla tabella ne caso normale e la ricerca sul file
commesse clienti nel caso sia presente l'analitica
Vanno aggiunti e posizionati ai profili personalizzati nel caso servano:
ST 215 15
BE
PR 2 11 "Cod.Unico Prog."
FL "U"
CH NORMAL
FI CUP
US %CUP
IN CODTAB 215
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 215 CODTAB
OU 216 S0
HE "Inserisci il Codice Unico di Progetto"
WA "Codice Unico di Progetto non trovato"
CH NORMAL
EN
ST 216 50
BE
PR 35 11 ""
FL ""
CH NORMAL
US %CUP KEY 2
IN S0 216
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 215
EN
ST 217 15
BE
PR 2 12 "Cod.Ident.Gara "
FL "U"
CH NORMAL
FI CIG
US %CIG
IN CODTAB 217
DI "Codice@15" CODTAB
DI "Descrizione@50" S0
OU 217 CODTAB
OU 218 S0
HE "Inserisci il Codice Identificativo Gara"
WA "Codice Identificativo Gara non trovato"
CH NORMAL
EN
ST 218 50
BE
PR 35 12 ""
FL ""
CH NORMAL
US %CIG KEY 2
IN S0 218
DI "Descrizione@50" S0
DI "Codice@15" CODTAB
CO OU 217
EN
ST 219 20
BE
PR 2 13 ""
FL "H"
FI CODCMS
EN
La generazione effetti scrive il CUP e il CIG sull'effetto.
La contabilizzazione scrive il CUP e il CIG sulle righe contabili.
git-svn-id: svn://10.65.10.50/branches/R_10_00@21374 c028cbd2-c16b-5b4b-a496-9718f37d4682
2010-12-28 08:28:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
key.cut(0);
|
|
|
|
|
key.add(codcms);
|
|
|
|
|
key.add(mask.get(F_TIPOCF));
|
|
|
|
|
key.add(mask.get(F_CODCF));
|
|
|
|
|
|
|
|
|
|
const TRectype & cfcms1 = __cfcm.get(key);
|
|
|
|
|
const int nrigaban = cfcms1.get_int(CFCMS_NRIGABAN);
|
|
|
|
|
|
|
|
|
|
if (nrigaban > 0)
|
|
|
|
|
{
|
|
|
|
|
key.cut(0);
|
|
|
|
|
key.add(mask.get(F_TIPOCF));
|
|
|
|
|
key.add(mask.get(F_CODCF));
|
|
|
|
|
key.add("V");
|
|
|
|
|
key.add(nrigaban);
|
|
|
|
|
|
|
|
|
|
const TRectype & cfban = cache().get(LF_CFBAN, key);
|
|
|
|
|
|
|
|
|
|
mask.set(mask.field(F_CODABIA).active() ? F_CODABIA : F_CODABIA1, cfban.get(CFBAN_ABI), 3);
|
|
|
|
|
mask.set(mask.field(F_CODCABA).active() ? F_CODCABA : F_CODCABA1, cfban.get(CFBAN_CAB), 3);
|
|
|
|
|
mask.set(F_IBAN, cfban.get(CFBAN_IBAN));
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-11-16 13:46:49 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (key == K_TAB && !mask.is_running())
|
|
|
|
|
mask.codcms() = mask.doc().get(DOC_CODCMS);
|
|
|
|
|
|
|
|
|
|
return true;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
}
|
2007-11-16 13:46:49 +00:00
|
|
|
|
|
2008-11-14 14:40:28 +00:00
|
|
|
|
bool evasion_check_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_ENTER && f.dirty())
|
|
|
|
|
{
|
|
|
|
|
const real qta(f.get());
|
|
|
|
|
if (qta <= ZERO)
|
|
|
|
|
return true;
|
|
|
|
|
const TFieldref * fld = f.field();
|
|
|
|
|
if (fld == NULL)
|
|
|
|
|
return true;
|
|
|
|
|
TSheet_field & sf = *f.mask().get_sheet();
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask & )sf.mask();
|
|
|
|
|
const TDocumento & d = m.doc();
|
|
|
|
|
const int nrow = sf.selected() + 1;
|
|
|
|
|
const TRiga_documento & r = d[nrow];
|
|
|
|
|
const TString16 name = fld->name();
|
|
|
|
|
const TRectype * orig_doc = r.find_original_doc(); // warning
|
|
|
|
|
|
|
|
|
|
if (orig_doc != NULL)
|
|
|
|
|
{
|
|
|
|
|
const long ndoc = d.get_long(DOC_NDOC);
|
|
|
|
|
TToken_string key;
|
|
|
|
|
|
|
|
|
|
key.add(orig_doc->get(DOC_PROVV));
|
|
|
|
|
key.add(orig_doc->get(DOC_ANNO));
|
|
|
|
|
key.add(orig_doc->get(DOC_CODNUM));
|
|
|
|
|
key.add(orig_doc->get(DOC_NDOC));
|
|
|
|
|
|
|
|
|
|
TDocumento & father_doc = cached_doc(key);
|
|
|
|
|
const TRectype * row = r.find_original_rdoc();
|
|
|
|
|
|
|
|
|
|
if (row != NULL)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento & father_row = father_doc[row->get_int(RDOC_NRIGA)];
|
|
|
|
|
const real ordinato(father_row.get(name));
|
|
|
|
|
|
|
|
|
|
TString query("USE RDOC KEY 4 SELECT NDOC!=");
|
|
|
|
|
const int anno = r.get_int(RDOC_DAANNO);
|
|
|
|
|
const TString4 & codnum = r.get(RDOC_DACODNUM);
|
|
|
|
|
const long numdoc = r.get_long(RDOC_DANDOC);
|
|
|
|
|
TString select;
|
|
|
|
|
|
|
|
|
|
select << " DAPROVV='" << r.get(RDOC_DAPROVV) << "'";
|
|
|
|
|
select << " DAANNO='" << r.get(RDOC_DAANNO) << "'";
|
|
|
|
|
select << " DACODNUM='" << r.get(RDOC_DACODNUM) << "'";
|
|
|
|
|
select << " DANDOC='" << r.get(RDOC_DANDOC) << "'";
|
|
|
|
|
select << " DAIDRIGA='" << r.get(RDOC_DAIDRIGA) << "'";
|
|
|
|
|
|
|
|
|
|
query << ndoc ;
|
|
|
|
|
query << "\nFROM " << select;
|
|
|
|
|
query << "\nTO " << select;
|
|
|
|
|
|
|
|
|
|
TISAM_recordset recset(query);
|
|
|
|
|
real evaso;
|
|
|
|
|
|
|
|
|
|
for (bool ok = recset.move_first(); ok ; ok = recset.move_next())
|
|
|
|
|
evaso += recset.get(name).as_real();
|
|
|
|
|
|
|
|
|
|
const int doc_rows = d.physical_rows();
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= doc_rows; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != nrow)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_documento & row = d[i];
|
|
|
|
|
|
|
|
|
|
if (r.get(RDOC_CODART) == row.get(RDOC_CODART))
|
|
|
|
|
evaso += row.get_real(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const real residuo = ordinato - evaso;
|
|
|
|
|
if (residuo < qta)
|
|
|
|
|
if (!yesno_box(FR("La quantita' %s e' superiore al residuo %s,\nvuoi continuare ugualmente"), qta.stringa(), residuo.stringa()))
|
|
|
|
|
{
|
|
|
|
|
if (!f.mask().is_running())
|
|
|
|
|
{
|
|
|
|
|
m.set_focus_field(F_SHEET);
|
|
|
|
|
sf.post_select(nrow - 1);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (!f.mask().is_running())
|
|
|
|
|
m.set_focus_field(F_SHEET);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (f.dlg() == FR_QTA)
|
|
|
|
|
return qtaart_handler(f, key);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-09 15:22:23 +00:00
|
|
|
|
bool distinta_link_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
|
|
|
|
|
TFilename tempfile;
|
|
|
|
|
TCodice_articolo codart(row_mask.get(FR_CODART));
|
|
|
|
|
const bool exist = !cache().get(LF_DIST, codart).empty();
|
|
|
|
|
|
|
|
|
|
tempfile.temp("ve0");
|
|
|
|
|
tempfile.ext("ini");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TConfig configfile(tempfile);
|
|
|
|
|
TString8 para;
|
|
|
|
|
para << LF_DIST;
|
|
|
|
|
|
|
|
|
|
configfile.set("Action", exist ? "Modify" : "Insert", "Transaction");
|
|
|
|
|
configfile.set("Mode", "R", "Transaction");
|
|
|
|
|
configfile.set("CODDIST", codart, para);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TString commandline;
|
|
|
|
|
|
|
|
|
|
commandline.format("db0 -4 /i%s",(const char*)tempfile);
|
|
|
|
|
|
|
|
|
|
TExternal_app db(commandline);
|
|
|
|
|
db.run();
|
|
|
|
|
|
|
|
|
|
remove_file(tempfile);
|
|
|
|
|
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask & )sh.mask();
|
|
|
|
|
const TDocumento & d = m.doc();
|
|
|
|
|
const int row = sh.selected() + 1;
|
|
|
|
|
|
|
|
|
|
if (row < d.physical_rows() && d[row + 1].get_bool(RDOC_GENERATA))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return codart_handler( f, key);
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-06 13:46:58 +00:00
|
|
|
|
bool gen_livelli_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8 && f.get().blank())
|
|
|
|
|
{
|
|
|
|
|
TMask& row_mask = f.mask();
|
|
|
|
|
TSheet_field& sh = *row_mask.get_sheet();
|
|
|
|
|
TDocumento_mask & m = (TDocumento_mask & )sh.mask();
|
|
|
|
|
const TDocumento & d = m.doc();
|
|
|
|
|
const int row = sh.selected() + 1;
|
|
|
|
|
const int livello = f.dlg() - FR_LIV1;
|
|
|
|
|
const TRiga_documento & r = d[row];
|
|
|
|
|
TToken_string * str = r.tipo().genconf(livello);
|
|
|
|
|
if (str != NULL)
|
|
|
|
|
{
|
|
|
|
|
const TString codart = row_mask.get(FR_CODART);
|
|
|
|
|
|
|
|
|
|
if (codart.full())
|
|
|
|
|
{
|
|
|
|
|
TString code;
|
|
|
|
|
const TRectype & anamag = cache().get(LF_ANAMAG, codart);
|
|
|
|
|
const int items = str->items();
|
|
|
|
|
|
2009-10-26 15:51:02 +00:00
|
|
|
|
for (int i = 0; i < items; i++)
|
2009-02-06 13:46:58 +00:00
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
const TString & name = str->get(i);
|
|
|
|
|
if (name.starts_with("PROG"))
|
2009-02-06 13:46:58 +00:00
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
TTable mat(format("VE%1d", livello + 1));
|
|
|
|
|
const int chars = atoi(name.after("PROG"));
|
2009-02-06 13:46:58 +00:00
|
|
|
|
|
2009-10-26 15:51:02 +00:00
|
|
|
|
mat.put("CODTAB", code);
|
|
|
|
|
if (mat.read(_isequal) != NOERR)
|
|
|
|
|
{
|
|
|
|
|
mat.zero();
|
2009-05-11 12:59:28 +00:00
|
|
|
|
mat.put("CODTAB", code);
|
2009-10-26 15:51:02 +00:00
|
|
|
|
mat.write();
|
|
|
|
|
}
|
|
|
|
|
const int prog = mat.get_int("I0") + 1;
|
|
|
|
|
mat.put("I0", prog);
|
|
|
|
|
mat.rewrite();
|
|
|
|
|
TString s; s << prog; s.lpad(chars, '0');
|
|
|
|
|
code << s;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (name.starts_with("33."))
|
|
|
|
|
{
|
|
|
|
|
TFieldref fld(name.after("33."), LF_DOC);
|
|
|
|
|
|
|
|
|
|
code << fld.read(d);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-10-26 15:51:02 +00:00
|
|
|
|
if (name.starts_with("34."))
|
2009-02-06 13:46:58 +00:00
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
TFieldref fld(name.after("34."), LF_RIGHEDOC);
|
|
|
|
|
|
|
|
|
|
code << fld.read(r);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2009-10-26 15:51:02 +00:00
|
|
|
|
if (name.starts_with("47."))
|
2009-02-06 13:46:58 +00:00
|
|
|
|
{
|
2009-10-26 15:51:02 +00:00
|
|
|
|
TFieldref fld(name.after("47."), LF_ANAMAG);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
|
2009-10-26 15:51:02 +00:00
|
|
|
|
code << fld.read(anamag);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-26 15:51:02 +00:00
|
|
|
|
row_mask.set(f.dlg(), code, 0x3);
|
2009-02-06 13:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-09-18 15:14:51 +00:00
|
|
|
|
|
2009-09-22 11:19:13 +00:00
|
|
|
|
bool sottocat_conai_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
{
|
2009-09-24 15:27:38 +00:00
|
|
|
|
const TString& codart = f.mask().get(FR_CODARTMAG);
|
|
|
|
|
const TArticolo& articolo = cached_article(codart);
|
|
|
|
|
const TCONAI_class type = conai_id2class(f.dlg());
|
|
|
|
|
const TFieldref fld(conai_sottocat_name(type, LF_ANAMAG), LF_ANAMAG);
|
|
|
|
|
f.set(fld.read(articolo));
|
2009-09-22 11:19:13 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-18 15:14:51 +00:00
|
|
|
|
bool peso_conai_handler(TMask_field& f, KEY key )
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
{
|
|
|
|
|
const TString & codart = f.mask().get(FR_CODARTMAG);
|
|
|
|
|
TArticolo & articolo = cached_article(codart);
|
2009-09-24 15:27:38 +00:00
|
|
|
|
const TCONAI_class type = conai_id2class(f.dlg());
|
|
|
|
|
f.set(articolo.get(conai_peso_name(type, LF_ANAMAG)));
|
2009-09-18 15:14:51 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
2010-04-15 08:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool datacomp_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (key == K_F8)
|
|
|
|
|
f.set(f.mask().get(F_DATADOC));
|
|
|
|
|
|
|
|
|
|
if (f.to_check(key, false))
|
|
|
|
|
{
|
|
|
|
|
const TDate datadoc = f.mask().get_date(F_DATADOC);
|
|
|
|
|
const TEsercizi_contabili es_doc;
|
|
|
|
|
int anno_doc = es_doc.date2esc(datadoc);
|
|
|
|
|
|
|
|
|
|
const TDate datacomp = f.get();
|
|
|
|
|
const TEsercizi_contabili es_comp;
|
|
|
|
|
int anno_comp = es_comp.date2esc(datacomp);
|
|
|
|
|
|
|
|
|
|
if (anno_doc != anno_comp)
|
|
|
|
|
return error_box("La data inizio competenza deve appartenere all'esercizio del documento!");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool datafcomp_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
if (f.to_check(key, false))
|
|
|
|
|
{
|
|
|
|
|
const TDate datacomp = f.mask().get_date(F_DATACOMP);
|
|
|
|
|
const TDate datafcomp = f.get();
|
|
|
|
|
if (datafcomp < datacomp)
|
|
|
|
|
return error_box("La data fine competenza non puo' essere antecedente alla data inizio competenza!");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2010-06-22 11:10:40 +00:00
|
|
|
|
}
|
2011-02-16 09:42:19 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Gestione note articolo
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#if 0 && (_MSC_VER > 1300) // Dalla versione 10.x
|
|
|
|
|
#define NAR_TABLE "&VENAR"
|
|
|
|
|
#else // Versione 3.x
|
|
|
|
|
#define NAR_TABLE "NAR"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
class TNar_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
static TMask* _doc_mask;
|
|
|
|
|
static char _tipocf;
|
|
|
|
|
static long _codcf;
|
|
|
|
|
static TString4 _tipodoc;
|
|
|
|
|
static TCodice_articolo _codart;
|
|
|
|
|
static bool nar_filter(const TRelation* rel);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
bool add_nota(const TRectype& curr, TSheet_field& sht);
|
|
|
|
|
|
|
|
|
|
public: // virtual methods
|
|
|
|
|
virtual void open(); // : TMask : TWindow
|
|
|
|
|
virtual void close(); // : TMask : TWindow
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void set_doc_mask(TMask& docmask) { _doc_mask = &docmask; }
|
|
|
|
|
bool show_note();
|
|
|
|
|
TNar_mask();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TMask* TNar_mask::_doc_mask = NULL;
|
|
|
|
|
char TNar_mask::_tipocf = ' ';
|
|
|
|
|
long TNar_mask::_codcf;
|
|
|
|
|
TString4 TNar_mask::_tipodoc;
|
|
|
|
|
TCodice_articolo TNar_mask::_codart;
|
|
|
|
|
|
|
|
|
|
void TNar_mask::open()
|
|
|
|
|
{
|
|
|
|
|
RCT rctd; xvt_vobj_get_client_rect(_doc_mask->win(), &rctd);
|
|
|
|
|
RCT rctn; xvt_vobj_get_client_rect(win(), &rctn);
|
|
|
|
|
const short dx = rctd.right - (rctn.right-rctn.left) - 4;
|
|
|
|
|
const short dy = 4;
|
|
|
|
|
xvt_rect_offset(&rctn, dx-rctn.left, dy-rctn.top);
|
|
|
|
|
xvt_vobj_move(win(), &rctn);
|
|
|
|
|
|
|
|
|
|
TAutomask::open();
|
|
|
|
|
_running = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TNar_mask::close()
|
|
|
|
|
{
|
|
|
|
|
TAutomask::close();
|
|
|
|
|
_running = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TNar_mask::nar_filter(const TRelation* rel)
|
|
|
|
|
{
|
|
|
|
|
const TString& codtab = rel->curr().get("S0");
|
|
|
|
|
|
|
|
|
|
const char r_tipocf = codtab[0]; // C/F
|
|
|
|
|
if (r_tipocf > ' ' && r_tipocf != _tipocf) // Considera solo le note cliente/fornitore compatibili
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const long r_codcf = atol(codtab.mid(1,6));
|
|
|
|
|
if (r_codcf > 0 && r_codcf != _codcf)
|
|
|
|
|
return false; // Scarta i clienti diversi da quello sulla maschera
|
|
|
|
|
|
|
|
|
|
TString4 r_tipod = codtab.mid(7, 4);
|
|
|
|
|
if (r_tipod.full())
|
|
|
|
|
{
|
|
|
|
|
r_tipod.rtrim();
|
|
|
|
|
if (r_tipod != _tipodoc)
|
|
|
|
|
return false; // Scarta i tipi documento diversi da quello sulla maschera
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& codart = codtab.mid(11);
|
|
|
|
|
return codart.blank() || codart == _codart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TNar_mask::add_nota(const TRectype& curr, TSheet_field& sht)
|
|
|
|
|
{
|
|
|
|
|
TToken_string nota;
|
|
|
|
|
char sn[4] = "S0";
|
|
|
|
|
for (int s = 1; s <= 3; s++)
|
|
|
|
|
{
|
|
|
|
|
sn[1] = '0' + s;
|
|
|
|
|
const TString& esse = curr.get(sn);
|
|
|
|
|
if (esse.full())
|
|
|
|
|
nota << esse << ' ';
|
|
|
|
|
}
|
|
|
|
|
const bool done = nota.full();
|
|
|
|
|
if (done)
|
|
|
|
|
{
|
|
|
|
|
nota.strip_double_spaces();
|
|
|
|
|
|
|
|
|
|
TString8 tipo;
|
|
|
|
|
tipo << 'X' << nota.separator();
|
|
|
|
|
if (atol(curr.get("S0").mid(1,6)) > 0)
|
|
|
|
|
tipo << 'C';
|
|
|
|
|
if (curr.get("S0").mid(7,4).full())
|
|
|
|
|
tipo << 'T';
|
|
|
|
|
if (curr.get("S0").mid(11).full())
|
|
|
|
|
tipo << 'A';
|
|
|
|
|
tipo << nota.separator();
|
|
|
|
|
nota.insert(tipo, 0);
|
|
|
|
|
const int n = sht.insert(-1, false, true);
|
|
|
|
|
sht.row(n) = nota;
|
|
|
|
|
sht.set_row_height(n, 2*CHARY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int notes_compare(TSheet_field& s, int r1, int r2)
|
|
|
|
|
{
|
|
|
|
|
TToken_string order = "C|T|CT|A|CA|TA|CTA";
|
|
|
|
|
const char* c1 = s.row(r1).get(1);
|
|
|
|
|
const char* c2 = s.row(r2).get(1);
|
|
|
|
|
const int i1 = order.get_pos(c1);
|
|
|
|
|
const int i2 = order.get_pos(c2);
|
|
|
|
|
int cmp = i1 - i2;
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
cmp = r1 - r2;
|
|
|
|
|
return cmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TNar_mask::show_note()
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& ss = _doc_mask->sfield(F_SHEET);
|
|
|
|
|
const int sel = ss.selected();
|
|
|
|
|
if (sel >= 0)
|
|
|
|
|
{
|
|
|
|
|
_tipocf = _doc_mask->get(F_TIPOCF)[0];
|
|
|
|
|
_codcf = _doc_mask->get_long(F_CODCF);
|
|
|
|
|
_tipodoc = _doc_mask->get(F_TIPODOC);
|
|
|
|
|
_codart = ss.row(sel).get(ss.cid2index(FR_CODART));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_codart.cut(0);
|
|
|
|
|
|
|
|
|
|
close();
|
|
|
|
|
if (_codart.full())
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(NAR_TABLE);
|
|
|
|
|
TCursor cur(&rel, "", 2);
|
|
|
|
|
cur.set_filterfunction(nar_filter);
|
|
|
|
|
|
|
|
|
|
const TRecnotype items = cur.items();
|
|
|
|
|
if (items > 0)
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
cur.freeze();
|
|
|
|
|
const TRectype& curr = rel.curr();
|
|
|
|
|
TSheet_field& sheet = sfield(N_NOTES);
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
|
|
|
add_nota(curr, sheet);
|
|
|
|
|
sheet.sort(notes_compare);
|
|
|
|
|
open();
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return is_open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TNar_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case DLG_FINDREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(NAR_TABLE);
|
|
|
|
|
TCursor cur(&rel, "", 2);
|
|
|
|
|
TRectype& curr = rel.curr();
|
|
|
|
|
bool update = false;
|
|
|
|
|
_tipocf = _doc_mask->get(F_TIPOCF)[0];
|
|
|
|
|
_codcf = _doc_mask->get_long(F_CODCF);
|
|
|
|
|
_tipodoc = _doc_mask->get(F_TIPODOC);
|
|
|
|
|
_codart.cut(0); // Nessun codice articolo corrente
|
|
|
|
|
cur.set_filterfunction(nar_filter);
|
|
|
|
|
TCursor_sheet as(&cur, "CODTAB|S0[1,1]|S0[2,7]|S0[8,11]|S0[12,31]|S1", TR("Note articolo"),
|
|
|
|
|
HR("Codice Nota@20|C/F|Codice|Tipo|Articolo@20|Note@50"), 0x3, 1, parent());
|
|
|
|
|
switch (as.run())
|
|
|
|
|
{
|
|
|
|
|
case K_ENTER:
|
|
|
|
|
cur = as.selected();
|
|
|
|
|
update = true;
|
|
|
|
|
break;
|
|
|
|
|
case K_CTRL+'G':
|
|
|
|
|
cur = as.selected();
|
|
|
|
|
update = curr.edit();
|
|
|
|
|
if (update)
|
|
|
|
|
cur = as.selected(); // Aggiorna valori editati esternamente
|
|
|
|
|
break;
|
|
|
|
|
case K_INS:
|
|
|
|
|
rel.file().zero(); // Usa azzeramento avanzato che funziona anche per tabelle di modulo
|
|
|
|
|
curr.edit();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& ns = sfield(N_NOTES); // Sheet delle note articolo
|
|
|
|
|
ns.destroy();
|
|
|
|
|
if (add_nota(curr, ns))
|
|
|
|
|
{
|
|
|
|
|
ns.force_update();
|
|
|
|
|
open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_NEWREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(NAR_TABLE); // Lascio a rel l'onere di decidere se TAB o TABMOD
|
|
|
|
|
rel.curr().edit();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& ns = sfield(N_NOTES); // Sheet delle note articolo
|
|
|
|
|
TString note;
|
|
|
|
|
FOR_EACH_SHEET_ROW(ns, n, row) if (row->get_char(0) > ' ') // For each checked row
|
|
|
|
|
note << row->get(2) << '\n';
|
|
|
|
|
if (note.full())
|
|
|
|
|
{
|
|
|
|
|
const TString4 tiporiga = _doc_mask->get(F_LBTIPORIGA); // Memorizza tipo riga
|
|
|
|
|
_doc_mask->set(F_LBTIPORIGA, "05"); // Impone riga descrizione
|
|
|
|
|
TSheet_field& ss = _doc_mask->sfield(F_SHEET); // Sheet delle righe documento
|
|
|
|
|
int i = ss.selected() + (get(N_WHERE)=="A" ? 1 : 0); // Inserisci prima o dopo?
|
|
|
|
|
i = ss.insert(i, false, true); // Crea nuova riga descrizione
|
|
|
|
|
ss.row(i).add(note.trim(), ss.cid2index(FR_DESCR)); // Copia descrizione dal memo
|
|
|
|
|
ss.force_update(); // Aggiorna sheet
|
|
|
|
|
_doc_mask->set(F_LBTIPORIGA, tiporiga); // Ripristina tipo riga
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (e == fe_button && is_open())
|
|
|
|
|
close();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TNar_mask::TNar_mask() : TAutomask("ve0100n")
|
|
|
|
|
{
|
|
|
|
|
_doc_mask = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nar_handler(TMask_field& f, KEY key)
|
|
|
|
|
{
|
|
|
|
|
static TNar_mask* nw = NULL;
|
|
|
|
|
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case K_SPACE:
|
|
|
|
|
if (nw == NULL)
|
|
|
|
|
nw = new TNar_mask;
|
|
|
|
|
nw->set_doc_mask(f.mask());
|
|
|
|
|
nw->open();
|
|
|
|
|
break;
|
|
|
|
|
case K_ESC:
|
|
|
|
|
case K_ENTER:
|
|
|
|
|
if (nw != NULL && nw->is_open())
|
|
|
|
|
nw->close();
|
|
|
|
|
break;
|
|
|
|
|
case K_F8:
|
|
|
|
|
if (xvt_vobj_is_focusable(f.parent()))
|
|
|
|
|
{
|
|
|
|
|
if (nw == NULL)
|
|
|
|
|
{
|
|
|
|
|
nw = new TNar_mask;
|
|
|
|
|
nw->set_doc_mask(f.mask());
|
|
|
|
|
}
|
|
|
|
|
nw->show_note();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|