Preventivazione cantieri
git-svn-id: svn://10.65.10.50/branches/R_10_00@22929 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7fcde8da9b
commit
80f65c95ef
@ -7,7 +7,8 @@ int main(int argc, char** argv)
|
||||
const int r = (argc > 1) ? argv[1][1] - '0' : 0;
|
||||
switch (r)
|
||||
{
|
||||
case 3:
|
||||
case 4: pe1500(argc, argv); break; // generazione ordini
|
||||
case 5: pe1600(argc, argv); break; // generazione fabbisogni
|
||||
default: pe1400(argc, argv); break; // gestione preventivi
|
||||
}
|
||||
return 0;
|
||||
|
3
pe/pe1.h
3
pe/pe1.h
@ -2,5 +2,8 @@
|
||||
#define __PE1_H
|
||||
|
||||
int pe1400(int argc, char* argv[]); // gestione preventivi
|
||||
int pe1500(int argc, char* argv[]); // generazione ordini
|
||||
int pe1600(int argc, char* argv[]); // generazione fabbisogni
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -113,6 +113,7 @@ protected:
|
||||
virtual const char* extra_modules() const { return "ci"; }
|
||||
bool save_and_print(TPrtype mode);
|
||||
|
||||
|
||||
public:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
@ -125,6 +126,7 @@ public:
|
||||
|
||||
virtual void init_insert_mode(TMask& m);
|
||||
virtual void init_modify_mode(TMask& m);
|
||||
virtual const char* record_description(const TRelation& rel) const;
|
||||
|
||||
virtual int read(TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
@ -1271,9 +1273,10 @@ TPreventivo_emsk::TPreventivo_emsk() : TPreventivo_msk("pe1400b"), _tree(NULL),
|
||||
TMask_field& cdc0 = field(F_CDC0);
|
||||
RCT rct0; cdc0.get_rect(rct0);
|
||||
const int yca = rct0.top / ROWY + 1; // Riga del primo campo di analitica
|
||||
short idcdc, idcms, idfase, idconto;
|
||||
|
||||
short idcdc = 0, idcms = 0, idfase = 0, idconto = 0;
|
||||
ca_create_fields_ext(*this, 0, 2, yca, F_CDC0+1, idcdc, idcms, idfase, idconto,
|
||||
DOC_CODCOSTO, DOC_CODCMS /*, DOC_FASCMS */); // Niente fasi qui!
|
||||
DOC_CODCOSTO, DOC_CODCMS, NULL); // Niente fasi qui!
|
||||
|
||||
set_sheet_color(F_DISTINTE, COLOR_YELLOW);
|
||||
set_sheet_color(F_ARTICOLI, COLOR_GREEN);
|
||||
@ -1287,6 +1290,9 @@ TPreventivo_emsk::TPreventivo_emsk() : TPreventivo_msk("pe1400b"), _tree(NULL),
|
||||
|
||||
bool TPreventivo_app::user_create()
|
||||
{
|
||||
if (ca_config().get_int("Authorizations") < 2)
|
||||
return error_box("E' necessario configurare la contabilità analitica o industriale");
|
||||
|
||||
open_files(LF_TAB, LF_TABCOM, LF_CLIFO,
|
||||
LF_DOC, LF_RIGHEDOC, LF_COMMESSE, LF_FASI, 0);
|
||||
_rel = new TRelation(LF_DOC);
|
||||
@ -1366,7 +1372,7 @@ int TPreventivo_app::read(TMask& m)
|
||||
keytok.add(doc.get(DOC_ANNO));
|
||||
keytok.add(doc.get(DOC_PROVV));
|
||||
keytok.add(doc.get(DOC_NDOC));
|
||||
TRecord_array rdoc(keytok, LF_RIGHEDOC);
|
||||
const TRecord_array rdoc(keytok, LF_RIGHEDOC);
|
||||
|
||||
TPreventivo_tree& t = ((TPreventivo_emsk&)m).tree();
|
||||
t.append_row(doc);
|
||||
@ -1378,6 +1384,8 @@ int TPreventivo_app::read(TMask& m)
|
||||
t.goto_root();
|
||||
t.expand();
|
||||
t.owner().force_update();
|
||||
|
||||
m.set(F_FASEMAX, pe_numero_fasi(rdoc));
|
||||
}
|
||||
_codelab.cut(0); // Azzera in ogni caso l'elaborazione
|
||||
return err;
|
||||
@ -1437,7 +1445,7 @@ static bool tree_save_row(TTree& tree, void* jolly, word /*flags*/)
|
||||
// Make sure of coherent level on final record
|
||||
const TPreventivo_level pl = t.level(*rec);
|
||||
if (pl > pl_fase1 && pl < pl_distinta)
|
||||
row.put(RPRV_LEVEL, t.curr_depth()-1);
|
||||
row.put(RPRV_LEVEL, int(t.curr_depth() - 1)); // Don't assume RPRV_LEVEL = pl-pl_fase1
|
||||
else
|
||||
row.zero(RPRV_LEVEL);
|
||||
}
|
||||
@ -1544,6 +1552,9 @@ void TPreventivo_app::init_insert_mode(TMask& m)
|
||||
TRelation_application::init_insert_mode(m);
|
||||
m.set(F_DATADOC, TDate(TODAY));
|
||||
update_tools(m);
|
||||
|
||||
const TMultilevel_code_info& fi = ca_multilevel_code_info(LF_FASI);
|
||||
m.set(F_FASEMAX, fi.levels());
|
||||
}
|
||||
|
||||
void TPreventivo_app::init_modify_mode(TMask& m)
|
||||
@ -1600,6 +1611,13 @@ void TPreventivo_app::preview()
|
||||
save_and_print(screenvis);
|
||||
}
|
||||
|
||||
const char* TPreventivo_app::record_description(const TRelation& rel) const
|
||||
{
|
||||
const TString4 tipodoc = rel.curr().get(DOC_TIPODOC);
|
||||
const TString& desc = cache().get("%TIP", tipodoc, "S0");
|
||||
return desc.empty() ? title() : desc;
|
||||
}
|
||||
|
||||
int pe1400(int argc, char* argv[])
|
||||
{
|
||||
TPreventivo_app a;
|
||||
|
@ -307,9 +307,9 @@ BEGIN
|
||||
END
|
||||
|
||||
|
||||
STRING F_CLIPOT 7
|
||||
STRING F_CLIPOT 16
|
||||
BEGIN
|
||||
PROMPT 2 10 "Potenz. Cliente"
|
||||
PROMPT 2 10 "Potenziale Cliente "
|
||||
USE LF_OCCAS
|
||||
INPUT CFPI F_CLIPOT
|
||||
DISPLAY "Codice@20" CFPI
|
||||
@ -321,9 +321,9 @@ BEGIN
|
||||
ADD RU cg0 -6
|
||||
END
|
||||
|
||||
STRING F_RAGPOT 45
|
||||
STRING F_RAGPOT 50
|
||||
BEGIN
|
||||
PROMPT 29 10 ""
|
||||
PROMPT 24 11 ""
|
||||
USE LF_OCCAS KEY 2
|
||||
INPUT RAGSOC F_RAGPOT
|
||||
DISPLAY "Ragione Sociale@50" RAGSOC
|
||||
@ -521,7 +521,6 @@ BEGIN
|
||||
ITEM "2|2 Livelli"
|
||||
ITEM "3|3 Livelli"
|
||||
ITEM "4|4 Livelli"
|
||||
FIELD NCOLLI
|
||||
END
|
||||
|
||||
SPREADSHEET F_DISTINTE 0 11
|
||||
|
@ -242,7 +242,7 @@ TFieldtypes TPreventivo_tree::get_var(const TString& name, TVariant& var) const
|
||||
{
|
||||
if (rec->num() == LF_DOC)
|
||||
{
|
||||
const TMask& m = owner().mask();
|
||||
const TMask& m =owner().mask();
|
||||
if (name == RDOC_CODART)
|
||||
{
|
||||
TString16 str = m.get(F_NPREV);
|
||||
@ -264,10 +264,10 @@ TFieldtypes TPreventivo_tree::get_var(const TString& name, TVariant& var) const
|
||||
if (name == RDOC_PREZZO || name == RPRV_COSTO)
|
||||
{
|
||||
real c, p; ((TPreventivo_tree*)this)->ricalcola(c, p);
|
||||
if (name == RDOC_PREZZO )
|
||||
var = p.stringa(0,2);
|
||||
if (name == RDOC_PREZZO)
|
||||
var = p.string(".2");
|
||||
else
|
||||
var = c.stringa(0,2);
|
||||
var = c.string(".2");
|
||||
ft = _realfld;
|
||||
}
|
||||
}
|
||||
@ -282,12 +282,12 @@ TFieldtypes TPreventivo_tree::get_var(const TString& name, TVariant& var) const
|
||||
{
|
||||
real c, p; ((TPreventivo_tree*)this)->ricalcola(c, p);
|
||||
if (name == RDOC_PREZZO )
|
||||
var = p.stringa(0,2);
|
||||
var = p.string(".2");
|
||||
else
|
||||
var = c.stringa(0,2);
|
||||
var = c.string(".2");
|
||||
}
|
||||
else
|
||||
var = rec->get_real(name).stringa(0, 2);
|
||||
var = rec->get_real(name).string(".2");
|
||||
}
|
||||
else
|
||||
var = rec->get(name);
|
||||
|
279
pe/pe1500.cpp
279
pe/pe1500.cpp
@ -1,9 +1,40 @@
|
||||
#include "../ve/velib04.h"
|
||||
#include "../ca/calib01.h"
|
||||
#include "pe1400.h"
|
||||
#include "pe1500.h"
|
||||
|
||||
#include "../ca/fasi.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int pe_numero_fasi(const TRecord_array& preventivo)
|
||||
{
|
||||
static const TString4 strFasi = ini_get_string(CONFIG_DITTA, "pe", "TipoRigaFase", "05");
|
||||
int level = 0;
|
||||
for (int i = preventivo.last_row(); i > 0; i = preventivo.pred_row(i))
|
||||
{
|
||||
const TRectype& rdoc = preventivo.row(i);
|
||||
const TString& tr = rdoc.get(RDOC_TIPORIGA);
|
||||
if (tr == strFasi)
|
||||
{
|
||||
const int p = rdoc.get_int(RPRV_LEVEL) + 1;
|
||||
if (p > level)
|
||||
level = p;
|
||||
}
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
int pe_numero_fasi(const TDocumento& preventivo)
|
||||
{ return pe_numero_fasi(preventivo.body()); }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TOrdinazione
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TOrdinazione : public TElaborazione_esterna
|
||||
{
|
||||
TString4 _strFasi, _strDist;
|
||||
@ -14,24 +45,102 @@ public:
|
||||
TOrdinazione(const TString& cod);
|
||||
};
|
||||
|
||||
const TRectype& find_ordine(const TDocumento& doc, const TString& codnum, bool& bEvaso)
|
||||
{
|
||||
TString query, limit;
|
||||
limit << RDOC_DAPROVV << '=' << doc.get(DOC_PROVV) << ' '
|
||||
<< RDOC_DAANNO << '=' << doc.get_int(DOC_ANNO) << ' '
|
||||
<< RDOC_DACODNUM << '=' << doc.get(DOC_CODNUM) << ' '
|
||||
<< RDOC_DANDOC << '=' << doc.get_long(DOC_NDOC);
|
||||
query << "USE 34 KEY 4"
|
||||
<< "\nSELECT CODNUM=\"" << codnum << '"'
|
||||
<< "\nFROM " << limit << "\nTO " << limit;
|
||||
|
||||
bEvaso = false;
|
||||
TISAM_recordset recset(query);
|
||||
const TRectype& rdoc = recset.cursor()->curr();
|
||||
TToken_string key;
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
key = rdoc.get(RDOC_PROVV);
|
||||
key.add(rdoc.get(RDOC_ANNO));
|
||||
key.add(rdoc.get(RDOC_CODNUM));
|
||||
key.add(rdoc.get(RDOC_NDOC));
|
||||
if (rdoc.get_bool(RDOC_RIGAEVASA))
|
||||
{
|
||||
bEvaso = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cache().get(LF_DOC, key);
|
||||
}
|
||||
|
||||
bool TOrdinazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo)
|
||||
{
|
||||
const TString80 codart = ini_get_string(CONFIG_DITTA, "ci", "CODARTPR");
|
||||
|
||||
TConfig& cfg = ca_config();
|
||||
TString_array picture_fasi;
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
const TString& pic = cfg.get("Fsc", "ca", i);
|
||||
if (pic.full())
|
||||
picture_fasi.add(pic);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
const int cfg_levels = picture_fasi.items();
|
||||
if (cfg_levels <= 0)
|
||||
return error_box(TR("Occorre configurare le fasi analitiche"));
|
||||
|
||||
for (int i = 0; i < doc_in.items(); i++)
|
||||
{
|
||||
if (i >= doc_out.items())
|
||||
TDocumento& din = doc_in[i];
|
||||
|
||||
// Mi assicuro che ad ogni documento in ingresso ne corrisponda uno in uscita
|
||||
if (i >= doc_out.items())
|
||||
{
|
||||
TDocumento* doc = new TDocumento('D', data_elab.year(), codice_numerazione_finale(), 0L);
|
||||
doc->put(DOC_TIPODOC, tipo_finale());
|
||||
const TString& codnum = codice_numerazione_finale();
|
||||
bool bEvaso = false;
|
||||
const TRectype& ord = find_ordine(din, codnum, bEvaso);
|
||||
|
||||
if (!ord.empty())
|
||||
{
|
||||
if (bEvaso)
|
||||
{
|
||||
if (interattivo)
|
||||
error_box("Il preventivo è collegato all'ordine già evaso %s %d/%ld",
|
||||
(const char*)ord.get(DOC_CODNUM), ord.get_int(DOC_ANNO), ord.get_long(DOC_NDOC));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (interattivo)
|
||||
warning_box("Il preventivo aggiornerà l'ordine %s %d/%ld",
|
||||
(const char*)ord.get(DOC_CODNUM), ord.get_int(DOC_ANNO), ord.get_long(DOC_NDOC));
|
||||
}
|
||||
}
|
||||
|
||||
TDocumento* doc = NULL;
|
||||
if (ord.empty())
|
||||
{
|
||||
doc = new TDocumento('D', data_elab.year(), codnum, 0L);
|
||||
doc->put(DOC_TIPODOC, tipo_finale());
|
||||
}
|
||||
else
|
||||
{
|
||||
doc = new TDocumento(ord);
|
||||
doc->destroy_rows();
|
||||
}
|
||||
doc_out.add(doc);
|
||||
}
|
||||
|
||||
TDocumento& din = doc_in[i];
|
||||
TDocumento& don = doc_out[i];
|
||||
|
||||
din.put(DOC_STATO, stato_finale_doc_iniziale());
|
||||
din.put(DOC_STATO, stato_finale_doc_iniziale());
|
||||
|
||||
don.put(DOC_TIPOCF, din.get(DOC_TIPOCF));
|
||||
don.put(DOC_CODCF, din.get(DOC_CODCF));
|
||||
@ -42,31 +151,74 @@ bool TOrdinazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
don.put(DOC_NUMDOCRIF, din.get(DOC_NDOC));
|
||||
don.put(DOC_DATADOCRIF, din.get(DOC_DATADOC));
|
||||
|
||||
const int doc_levels = pe_numero_fasi(din);
|
||||
if (doc_levels <= 0)
|
||||
continue; // Should never happen
|
||||
|
||||
TLocalisamfile fasi(LF_FASI);
|
||||
|
||||
const TMultilevel_code_info cfg_fasi(LF_FASI);
|
||||
TString16 fase;
|
||||
TString16 fase[4], codfase; // Livelli delle fasi (max 4)
|
||||
|
||||
const int nrows = din.rows();
|
||||
// Crea gli eventuali livelli iniziali mancanti
|
||||
const int delta_levels = cfg_levels-doc_levels;
|
||||
if (delta_levels > 0)
|
||||
{
|
||||
TString80 descr;
|
||||
for (int lev = 0; lev < delta_levels; lev++)
|
||||
{
|
||||
fase[lev].format("%0*ld", picture_fasi.row(lev).len(), 0);
|
||||
fasi.put(FASI_CODCMSFAS, din.get(DOC_CODCMS));
|
||||
|
||||
int tot_len = 0;
|
||||
for (int l = 0; l <= lev; l++)
|
||||
tot_len += picture_fasi.row(lev).len();
|
||||
descr.format("%0*ld", tot_len, 0);
|
||||
fasi.put(FASI_CODFASE, descr);
|
||||
|
||||
descr.format(FR("FASE%d"), lev);
|
||||
fasi.put(FASI_DESCRIZ, descr);
|
||||
|
||||
fasi.write_rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
const int nrows = din.physical_rows();
|
||||
FOR_EACH_PHYSICAL_RDOC(din, r, rdoc)
|
||||
{
|
||||
const TString& tr = rdoc->get(RDOC_TIPORIGA);
|
||||
if (tr == _strFasi)
|
||||
{
|
||||
if (r >= nrows || din[r+1].is_descrizione())
|
||||
int level = rdoc->get_int(RPRV_LEVEL); // Livello logico della riga [0,3]
|
||||
if (delta_levels > 0)
|
||||
level += delta_levels; // Livello fisico [0,3]
|
||||
|
||||
if (r >= nrows || (level == (cfg_levels-1) && din[r+1].is_descrizione()))
|
||||
continue; // Salta fasi vuote
|
||||
|
||||
TRiga_documento& rout = don.new_row(_strFasi);
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
|
||||
const int last_lev = cfg_fasi.levels()-1;
|
||||
if (last_lev >= 0)
|
||||
if (level >= 0 && level < cfg_levels)
|
||||
{
|
||||
const int last_len = cfg_fasi.len(last_lev);
|
||||
const long last_val = atol(fase)+1;
|
||||
fase.format("%0*ld", last_len, last_val);
|
||||
const int fase_len = picture_fasi.row(level).len();
|
||||
TString& cod = fase[level];
|
||||
cod = rdoc->get(RDOC_CODART).left(10);
|
||||
const int delta_len = fase_len - cod.len();
|
||||
if (delta_len != 0)
|
||||
{
|
||||
if (delta_len > 0)
|
||||
{
|
||||
if (isdigit(cod[0]))
|
||||
cod.lpad(fase_len, '0');
|
||||
else
|
||||
cod.rpad(fase_len, ' ');
|
||||
}
|
||||
else
|
||||
cod.cut(fase_len);
|
||||
}
|
||||
codfase.cut(0); for (int i = 0; i <= level; i++) codfase << fase[i];
|
||||
fasi.put(FASI_CODCMSFAS, din.get(DOC_CODCMS));
|
||||
fasi.put(FASI_CODFASE, fase);
|
||||
fasi.put(FASI_CODFASE, codfase);
|
||||
fasi.put(FASI_DESCRIZ, rdoc->get(RDOC_DESCR));
|
||||
fasi.write_rewrite();
|
||||
}
|
||||
@ -76,10 +228,14 @@ bool TOrdinazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
TRiga_documento& rout = don.new_row(_strDist);
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
rout.set_original_rdoc_key(*rdoc);
|
||||
rout.put(RDOC_FASCMS, fase);
|
||||
rout.put(RDOC_CODCMS, din.get(DOC_CODCMS));
|
||||
rout.put(RDOC_FASCMS, codfase);
|
||||
rout.put(RDOC_CODARTMAG, codart);
|
||||
rdoc->put(RDOC_FASCMS, codfase); // Aggiorna codice fase anche nella riga di input
|
||||
}
|
||||
}
|
||||
din.rewrite(); // Aggiorna codici fase nelle righe
|
||||
don.write(); // Salva ordine
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -96,7 +252,7 @@ TOrdinazione::TOrdinazione(const TString& cod) : TElaborazione_esterna(cod)
|
||||
|
||||
class TFabbisognazione : public TElaborazione_esterna
|
||||
{
|
||||
TString4 _strDett, _strDist;
|
||||
TString4 _strFasi, _strDett, _strDist;
|
||||
|
||||
public:
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
@ -130,15 +286,59 @@ bool TFabbisognazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
don.put(DOC_NUMDOCRIF, din.get(DOC_NDOC));
|
||||
don.put(DOC_DATADOCRIF, din.get(DOC_DATADOC));
|
||||
|
||||
const int doc_levels = pe_numero_fasi(din);
|
||||
if (doc_levels <= 0)
|
||||
continue; // Should never happen
|
||||
|
||||
TLocalisamfile fasi(LF_FASI);
|
||||
|
||||
TString16 fase[4], codfase; // Livelli delle fasi (max 4)
|
||||
|
||||
|
||||
const TMultilevel_code_info cfg_fasi(LF_FASI);
|
||||
TString16 fase;
|
||||
const int cfg_levels = cfg_fasi.levels();
|
||||
if (cfg_levels <= 0)
|
||||
return error_box(TR("Occorre configurare le fasi analitiche"));
|
||||
|
||||
// Calcola gli eventuali livelli iniziali mancanti
|
||||
const int delta_levels = cfg_levels-doc_levels;
|
||||
|
||||
real qta = UNO;
|
||||
const int nrows = din.rows();
|
||||
FOR_EACH_PHYSICAL_RDOC(din, r, rdoc)
|
||||
{
|
||||
const TString& tr = rdoc->get(RDOC_TIPORIGA);
|
||||
if (tr == _strFasi)
|
||||
{
|
||||
int level = rdoc->get_int(RPRV_LEVEL); // Livello logico della riga [0,3]
|
||||
if (delta_levels > 0)
|
||||
level += delta_levels; // Livello fisico [0,3]
|
||||
|
||||
if (r >= nrows || (level == (cfg_levels-1) && din[r+1].is_descrizione()))
|
||||
continue; // Salta fasi vuote
|
||||
|
||||
if (level >= 0 && level < cfg_levels)
|
||||
{
|
||||
const int fase_len = cfg_fasi.len(level);
|
||||
TString& cod = fase[level];
|
||||
cod = rdoc->get(RDOC_CODART).left(10);
|
||||
const int delta_len = fase_len - cod.len();
|
||||
if (delta_len != 0)
|
||||
{
|
||||
if (delta_len > 0)
|
||||
{
|
||||
if (isdigit(cod[0]))
|
||||
cod.lpad(fase_len, '0');
|
||||
else
|
||||
cod.rpad(fase_len, ' ');
|
||||
}
|
||||
else
|
||||
cod.cut(fase_len);
|
||||
}
|
||||
codfase.cut(0);
|
||||
for (int i = 0; i <= level; i++) codfase << fase[i];
|
||||
}
|
||||
}
|
||||
if (tr == _strDist)
|
||||
{
|
||||
qta = rdoc->get_real(RDOC_QTA);
|
||||
@ -152,15 +352,17 @@ bool TFabbisognazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_o
|
||||
rout.put(RDOC_QTA, real(qta * rdoc->get_real(RDOC_QTA)));
|
||||
rout.put(RDOC_PREZZO, rdoc->get(RDOC_QTAGG5));
|
||||
rout.set_original_rdoc_key(*rdoc);
|
||||
rout.put(RDOC_FASCMS, fase);
|
||||
rout.put(RDOC_FASCMS, codfase);
|
||||
}
|
||||
}
|
||||
don.write(); // Salva nuovo documento
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TFabbisognazione::TFabbisognazione(const TString& cod) : TElaborazione_esterna(cod)
|
||||
{
|
||||
_strFasi = ini_get_string(CONFIG_DITTA, "pe", "TipoRigaFase", "05");
|
||||
_strDist = ini_get_string(CONFIG_DITTA, "pe", "TipoRigaDist", "P1");
|
||||
_strDett = ini_get_string(CONFIG_DITTA, "pe", "TipoRigaDett", "01");
|
||||
}
|
||||
@ -219,7 +421,6 @@ bool pe_genera_documento(TRectype& doc, const TString& cod, char tipo)
|
||||
const TString& app = cache().get("%ELD", codelab, "S3");
|
||||
tipo = app.find("-5") > 0 ? 'F' : 'O';
|
||||
|
||||
|
||||
TElaborazione* e = NULL;
|
||||
if (tipo == 'F')
|
||||
e = new TFabbisognazione(codelab);
|
||||
@ -228,26 +429,31 @@ bool pe_genera_documento(TRectype& doc, const TString& cod, char tipo)
|
||||
if (e->empty())
|
||||
{
|
||||
delete e;
|
||||
return error_box("Impossibile trovare l'elaborazione %s", (const char*)cod);
|
||||
return error_box(FR("Impossibile trovare l'elaborazione %s"), (const char*)cod);
|
||||
}
|
||||
|
||||
const TDate oggi(TODAY);
|
||||
TLista_documenti doc_in, doc_out;
|
||||
doc_in.add(new TDocumento(doc));
|
||||
|
||||
bool ok = e->elabora(doc_in, doc_out, oggi);
|
||||
bool ok = e->elabora(doc_in, doc_out, oggi, true);
|
||||
if (ok)
|
||||
{
|
||||
doc_in.rewrite();
|
||||
doc_out.write();
|
||||
|
||||
const TRectype& idoc = doc_in[0];
|
||||
for (int i = 0; i < idoc.items(); i++)
|
||||
int err = doc_in.rewrite();
|
||||
if (err == NOERR)
|
||||
{
|
||||
const char* fld = idoc.fieldname(i);
|
||||
const TString& val = idoc.get(fld);
|
||||
if (val.full())
|
||||
doc.put(fld, val);
|
||||
const TRectype& idoc = doc_in[0];
|
||||
for (int i = 0; i < idoc.items(); i++)
|
||||
{
|
||||
const char* fld = idoc.fieldname(i);
|
||||
const TString& val = idoc.get(fld);
|
||||
if (val.full())
|
||||
doc.put(fld, val);
|
||||
}
|
||||
|
||||
err = doc_out.write();
|
||||
if (err != NOERR)
|
||||
error_box(TR("Errore %d in scrittura del documento"), err);
|
||||
}
|
||||
}
|
||||
delete e;
|
||||
@ -299,4 +505,13 @@ void TOrdinazione_app::main_loop()
|
||||
ini.set(fld, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int pe1500(int argc, char* argv[])
|
||||
{
|
||||
TOrdinazione_app a;
|
||||
a.run(argc, argv, TR("Generazione ordini"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
11
pe/pe1500.h
11
pe/pe1500.h
@ -1,14 +1,21 @@
|
||||
#ifndef __PE1500_H
|
||||
#define __PE1500_H
|
||||
|
||||
#ifndef __ISAM_H
|
||||
#include <isam.h>
|
||||
#ifndef __RECARRAY_H
|
||||
#include <recarray.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MASK_H
|
||||
#include <mask.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VELIB_H
|
||||
class TDocumento;
|
||||
#endif
|
||||
|
||||
int pe_numero_fasi(const TRecord_array& rdoc);
|
||||
int pe_numero_fasi(const TDocumento& doc);
|
||||
|
||||
const TString& pe_trova_elaborazione(const TRectype& doc, char tipo);
|
||||
const TString& pe_trova_elaborazione(const TMask& doc, char tipo);
|
||||
bool pe_genera_documento(TRectype& doc, const TString& codelab, char tipo);
|
||||
|
@ -48,3 +48,12 @@ void TFabbisognazione_app::main_loop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int pe1600(int argc, char* argv[])
|
||||
{
|
||||
TFabbisognazione_app a;
|
||||
a.run(argc, argv, TR("Generazione fabbisogni"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user