Aggiunti programmi di gestione parametri statistiche e stampa schede
git-svn-id: svn://10.65.10.50/trunk@5063 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
21ea6df4df
commit
52a0e9cd8f
3
sv/f86.dir
Executable file
3
sv/f86.dir
Executable file
@ -0,0 +1,3 @@
|
||||
86
|
||||
0
|
||||
$svriep|0|0|95|0|Riepilogo statistiche di vendita|||
|
16
sv/f86.trr
Executable file
16
sv/f86.trr
Executable file
@ -0,0 +1,16 @@
|
||||
86
|
||||
12
|
||||
ANNO|2|4|0|Anno solare
|
||||
PERIODO|2|3|0|Periodo di riferimento
|
||||
TIPODOC|1|4|0|Tipo documento
|
||||
TIPOART|1|1|0|Tipo articolo
|
||||
CODART|1|20|0|Codice articolo
|
||||
UMQTA|1|2|0|Unita' di misura
|
||||
CODAG|1|5|0|Codice agente
|
||||
CODCF|1|6|0|Codice cliente/fornitore
|
||||
LIVELLO|1|15|0|Livello di giacenza
|
||||
CODMAG|1|5|0|Codice magazzino
|
||||
QUANTITA|4|11|3|Quantita
|
||||
VALORE|4|18|2|Valore
|
||||
1
|
||||
ANNO+PERIODO+TIPODOC+TIPOART+CODART+UMQTA+CODAG+CODCF+LIVELLO+CODMAG|
|
@ -2,7 +2,6 @@
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
SUBMENU M_FONT "~Opzioni" DISABLED
|
||||
|
||||
MENU M_FONT
|
||||
ITEM M_FONT_SELECT "~Font"
|
||||
|
@ -1,17 +1,47 @@
|
||||
#include <confapp.h>
|
||||
#include <execp.h>
|
||||
|
||||
#include "sv0400a.h"
|
||||
|
||||
class TParametri_st : public TConfig_application
|
||||
class TParametri_stat : public TConfig_application
|
||||
{
|
||||
bool _ask_update;
|
||||
|
||||
protected:
|
||||
virtual bool postprocess_config_changed (const char* par, const char* var, const char* oldv, const char* newv);
|
||||
virtual bool user_destroy();
|
||||
|
||||
public:
|
||||
TParametri_st() : TConfig_application(CONFIG_DITTA) { }
|
||||
virtual ~TParametri_st() { }
|
||||
TParametri_stat();
|
||||
virtual ~TParametri_stat() { }
|
||||
};
|
||||
|
||||
bool TParametri_stat::postprocess_config_changed (const char*, const char*, const char*, const char*)
|
||||
{
|
||||
return _ask_update = TRUE;
|
||||
}
|
||||
|
||||
bool TParametri_stat::user_destroy()
|
||||
{
|
||||
if (_ask_update)
|
||||
{
|
||||
bool recalc = yesno_box("Si desidera ricalcolare le statistiche ora?");
|
||||
if (recalc)
|
||||
{
|
||||
TExternal_app app("sv2 -0");
|
||||
app.run();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TParametri_stat::TParametri_stat()
|
||||
: TConfig_application(CONFIG_DITTA), _ask_update(FALSE)
|
||||
{ }
|
||||
|
||||
int st0400(int argc, char* argv[])
|
||||
{
|
||||
TParametri_st app;
|
||||
TParametri_stat app;
|
||||
app.run(argc, argv, "Parametri statistiche");
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#ifndef __ST0400A_H
|
||||
#define __ST0400A_H
|
||||
|
||||
#define F_FREQUENZA 100
|
||||
#define F_NO_CODICE 101
|
||||
#define F_NO_MAGAZZINO 102
|
||||
#define F_NO_RAGGRUPPA 103
|
||||
|
@ -16,49 +16,43 @@ ENDPAGE
|
||||
|
||||
PAGE "Parametri Ditta Statistiche" -1 -1 76 17
|
||||
|
||||
GROUPBOX DLG_NULL 76 5
|
||||
GROUPBOX DLG_NULL 76 3
|
||||
BEGIN
|
||||
PROMPT 1 1 "@bGestione articoli con codice inesistente"
|
||||
PROMPT 1 1 "@bFrequenza di raggruppamento"
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_CODICE
|
||||
LIST F_FREQUENZA 1 20
|
||||
BEGIN
|
||||
PROMPT 2 2 "Includi articoli senza codice"
|
||||
FIELD ArtNoCode
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_MAGAZZINO
|
||||
BEGIN
|
||||
PROMPT 2 3 "Includi articoli non presenti in anagrafica"
|
||||
FIELD ArtNoAnag
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_RAGGRUPPA
|
||||
BEGIN
|
||||
PROMPT 2 4 "Raggruppa articoli senza codice e non presenti in anagrafica"
|
||||
FIELD ArtNoAnagGrp
|
||||
PROMPT 2 2 "Frequenza "
|
||||
ITEM "G|Giornaliera"
|
||||
ITEM "S|Settimanale"
|
||||
ITEM "Q|Quindicinale"
|
||||
ITEM "M|Mensile"
|
||||
ITEM "B|Bimestrale"
|
||||
ITEM "T|Trimestrale"
|
||||
FIELD Frequenza
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 76 5
|
||||
BEGIN
|
||||
PROMPT 1 6 "@bGestione tipi riga"
|
||||
PROMPT 1 4 "@bTipi riga da includere"
|
||||
END
|
||||
|
||||
BOOLEAN F_MERCE
|
||||
BEGIN
|
||||
PROMPT 2 7 "Includi righe Merce"
|
||||
PROMPT 2 5 "Includi righe Merce"
|
||||
FIELD StatMerce
|
||||
END
|
||||
|
||||
BOOLEAN F_PRESTAZIONI
|
||||
BEGIN
|
||||
PROMPT 2 8 "Includi righe Prestazioni"
|
||||
PROMPT 2 6 "Includi righe Prestazioni"
|
||||
FIELD StatPrestazioni
|
||||
END
|
||||
|
||||
BOOLEAN F_OMAGGI
|
||||
BEGIN
|
||||
PROMPT 2 9 "Includi righe Omaggi"
|
||||
PROMPT 2 7 "Includi righe Omaggi"
|
||||
FIELD StatOmaggi
|
||||
MESSAGE FALSE CLEAR,F_RAGGRUPPA_OMAGGI
|
||||
MESSAGE TRUE ENABLE,F_RAGGRUPPA_OMAGGI
|
||||
@ -66,65 +60,88 @@ END
|
||||
|
||||
BOOLEAN F_RAGGRUPPA_OMAGGI
|
||||
BEGIN
|
||||
PROMPT 40 9 "Raggruppa Omaggi con Merce"
|
||||
PROMPT 40 7 "Raggruppa Omaggi con Merce"
|
||||
FIELD OmaggioIsMerce
|
||||
END
|
||||
|
||||
|
||||
GROUPBOX DLG_NULL 76 5
|
||||
BEGIN
|
||||
PROMPT 1 9 "@bGestione articoli con codice inesistente"
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_CODICE
|
||||
BEGIN
|
||||
PROMPT 2 10 "Includi articoli senza codice"
|
||||
FIELD ArtNoCode
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_MAGAZZINO
|
||||
BEGIN
|
||||
PROMPT 2 11 "Includi articoli non presenti in anagrafica"
|
||||
FIELD ArtNoAnag
|
||||
END
|
||||
|
||||
BOOLEAN F_NO_RAGGRUPPA
|
||||
BEGIN
|
||||
PROMPT 2 12 "Raggruppa articoli senza codice e non presenti in anagrafica"
|
||||
FIELD ArtNoAnagGrp
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 76 7
|
||||
BEGIN
|
||||
PROMPT 1 11 "@bRaggruppamento statistiche"
|
||||
PROMPT 1 14 "@bRaggruppamento statistiche"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 12 "Tipo documento"
|
||||
PROMPT 2 15 "Tipo documento"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 13 "Anno solare"
|
||||
PROMPT 2 16 "Anno solare"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 14 "Data documento"
|
||||
PROMPT 2 17 "Data documento"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 15 "Articolo"
|
||||
PROMPT 2 18 "Articolo"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 16 "Unita' di misura"
|
||||
PROMPT 2 19 "Unita' di misura"
|
||||
END
|
||||
|
||||
BOOLEAN F_AGENTE
|
||||
BEGIN
|
||||
PROMPT 40 12 "Agente"
|
||||
FIELD AgentGrp
|
||||
PROMPT 40 15 "Agente"
|
||||
FIELD AgenteGrp
|
||||
END
|
||||
|
||||
BOOLEAN F_CLIENTE
|
||||
BEGIN
|
||||
PROMPT 40 13 "Cliente"
|
||||
FIELD ClientGrp
|
||||
PROMPT 40 16 "Cliente"
|
||||
FIELD ClienteGrp
|
||||
END
|
||||
|
||||
BOOLEAN F_GIACENZA
|
||||
BEGIN
|
||||
PROMPT 40 14 "Giacenza"
|
||||
FIELD GiacGrp
|
||||
PROMPT 40 17 "Giacenza"
|
||||
FIELD GiacenzaGrp
|
||||
END
|
||||
|
||||
BOOLEAN F_MAGAZZINO
|
||||
BEGIN
|
||||
PROMPT 40 15 "Magazzino"
|
||||
FIELD MagazGrp
|
||||
PROMPT 40 18 "Magazzino"
|
||||
FIELD MagazzinoGrp
|
||||
END
|
||||
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
20
sv/sv1.cpp
Executable file
20
sv/sv1.cpp
Executable file
@ -0,0 +1,20 @@
|
||||
#include <xvt.h>
|
||||
#include <checks.h>
|
||||
|
||||
#include "sv1.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
sv1100(argc, argv);
|
||||
break;
|
||||
default:
|
||||
error_box("Invalid argument %s", argv[1]);
|
||||
break;
|
||||
}
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
6
sv/sv1.h
Executable file
6
sv/sv1.h
Executable file
@ -0,0 +1,6 @@
|
||||
#ifndef __SV1_H
|
||||
#define __SV1_H
|
||||
|
||||
int sv1100(int argc, char* argv[]);
|
||||
|
||||
#endif
|
22
sv/sv1.url
Executable file
22
sv/sv1.url
Executable file
@ -0,0 +1,22 @@
|
||||
#include <default.url>
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENU M_FONT
|
||||
ITEM M_FONT_SELECT "~Font"
|
||||
ITEM MENU_ITEM(2) "~Colori"
|
||||
ITEM MENU_ITEM(3) "~Editor"
|
||||
|
||||
MENUBAR MENU_BAR(1)
|
||||
MENU MENU_BAR(1)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(2)
|
||||
MENU MENU_BAR(2)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(3)
|
||||
MENU MENU_BAR(3)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
744
sv/sv1100.cpp
Executable file
744
sv/sv1100.cpp
Executable file
@ -0,0 +1,744 @@
|
||||
#include <applicat.h>
|
||||
#include <config.h>
|
||||
#include <form.h>
|
||||
#include <msksheet.h>
|
||||
#include <printer.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "../sc/scselect.h"
|
||||
#include "../ve/velib.h"
|
||||
|
||||
#include <doc.h>
|
||||
|
||||
#include "sv1.h"
|
||||
#include "sv1100a.h"
|
||||
|
||||
class TSchede_mask : public TSelection_mask
|
||||
{
|
||||
void init_sheet(short id);
|
||||
void ini2sheet(short id);
|
||||
void sheet2ini(short id);
|
||||
|
||||
protected:
|
||||
static bool date_handler(TMask_field& f, KEY k);
|
||||
static bool num_handler(TMask_field& f, KEY k);
|
||||
static bool save_handler(TMask_field& f, KEY k);
|
||||
static bool sheet_notify(TSheet_field& s, int row, KEY k);
|
||||
static bool fieldname_handler(TMask_field& f, KEY k);
|
||||
|
||||
public:
|
||||
void mask2ini();
|
||||
void ini2mask();
|
||||
|
||||
TSchede_mask();
|
||||
virtual ~TSchede_mask() { }
|
||||
};
|
||||
|
||||
bool TSchede_mask::date_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (f.to_check(k))
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const TDate fd(m.get(F_FROMDATE));
|
||||
const TDate td(m.get(F_TODATE));
|
||||
if (td.ok() && td < fd)
|
||||
ok = f.error_box("La data finale deve seguire quella iniziale");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TSchede_mask::num_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (f.to_check(k))
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const TString& fn = m.get(F_FROMNUM);
|
||||
const TString& tn = m.get(F_TONUM);
|
||||
if (tn.not_empty() && tn < fn)
|
||||
ok = f.error_box("La numerazione finale deve seguire quella iniziale");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TSchede_mask::save_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TSchede_mask& m = (TSchede_mask&)f.mask();
|
||||
m.mask2ini();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TSchede_mask::fieldname_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (f.to_check(k))
|
||||
{
|
||||
TSchede_mask& m = (TSchede_mask&)f.mask();
|
||||
TEdit_field& head = m.efield(S_HEAD);
|
||||
if (head.empty())
|
||||
{
|
||||
TParagraph_string para(m.get(S_DESCR), head.size());
|
||||
head.set(para.get(0));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TSchede_mask::sheet_notify(TSheet_field& s, int row, KEY k)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
switch(k)
|
||||
{
|
||||
case K_INS:
|
||||
ok = s.items() < 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TSchede_mask::sheet2ini(short id)
|
||||
{
|
||||
TSheet_field& sheet = sfield(id);
|
||||
TString_array& arr = sheet.rows_array();
|
||||
for (int r = arr.last(); r >= 0; r--)
|
||||
if (arr.row(r)[0] <= ' ')
|
||||
arr.destroy(r);
|
||||
arr.pack();
|
||||
|
||||
const char* field = id == F_SINTETICA ? "SynField" : "DetField";
|
||||
const char* head = id == F_SINTETICA ? "SynHead" : "DetHead";
|
||||
|
||||
TConfig ini(CONFIG_STUDIO, "sv1100");
|
||||
for (r = arr.last(); r >= 0; r--)
|
||||
{
|
||||
TToken_string& row = arr.row(r);
|
||||
ini.set(field, row.get(0), NULL, TRUE, r);
|
||||
ini.set(head, row.get(), NULL, TRUE, r);
|
||||
}
|
||||
ini.remove(field, arr.items());
|
||||
ini.remove(head, arr.items());
|
||||
}
|
||||
|
||||
void TSchede_mask::ini2sheet(short id)
|
||||
{
|
||||
TSheet_field& sheet = sfield(id);
|
||||
|
||||
const char* field = id == F_SINTETICA ? "SynField" : "DetField";
|
||||
const char* head = id == F_SINTETICA ? "SynHead" : "DetHead";
|
||||
|
||||
TConfig ini(CONFIG_STUDIO, "sv1100");
|
||||
for (int r = 0; ; r++)
|
||||
{
|
||||
TString16 str = ini.get(field, NULL, r);
|
||||
if (str.not_empty())
|
||||
{
|
||||
TToken_string& row = sheet.row(r);
|
||||
row = str;
|
||||
row.add(ini.get(head, NULL, r));
|
||||
sheet.check_row(r);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TSchede_mask::mask2ini()
|
||||
{
|
||||
sheet2ini(F_SINTETICA);
|
||||
sheet2ini(F_DETTAGLIATA);
|
||||
}
|
||||
|
||||
void TSchede_mask::ini2mask()
|
||||
{
|
||||
ini2sheet(F_SINTETICA);
|
||||
ini2sheet(F_DETTAGLIATA);
|
||||
}
|
||||
|
||||
void TSchede_mask::init_sheet(short id)
|
||||
{
|
||||
TSheet_field& sheet = sfield(id);
|
||||
sheet.set_notify(sheet_notify);
|
||||
TMask& sm = sheet.sheet_mask();
|
||||
sm.set_handler(S_FIELD, fieldname_handler);
|
||||
}
|
||||
|
||||
TSchede_mask::TSchede_mask()
|
||||
: TSelection_mask("sv1100a")
|
||||
{
|
||||
set_handler(F_TODATE, date_handler);
|
||||
set_handler(F_TONUM, num_handler);
|
||||
set_handler(DLG_SAVEREC, save_handler);
|
||||
|
||||
init_sheet(F_SINTETICA);
|
||||
init_sheet(F_DETTAGLIATA);
|
||||
|
||||
ini2mask();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSchede_form
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSchede_form : public TForm
|
||||
{
|
||||
public:
|
||||
void init(const TSheet_field& sheet);
|
||||
|
||||
TSchede_form();
|
||||
virtual ~TSchede_form() { }
|
||||
};
|
||||
|
||||
TSchede_form::TSchede_form()
|
||||
: TForm("sv1100a")
|
||||
{
|
||||
}
|
||||
|
||||
void TSchede_form::init(const TSheet_field& sheet)
|
||||
{
|
||||
TPrint_section& body = section('B', odd_page);
|
||||
|
||||
TString_array& arr = sheet.rows_array();
|
||||
|
||||
TString80 str;
|
||||
bool on = TRUE;
|
||||
for (word r = 3; r < body.fields(); r++)
|
||||
{
|
||||
const int riga = r-3;
|
||||
if (on)
|
||||
{
|
||||
if (riga < arr.items())
|
||||
{
|
||||
str = arr.row(riga).get(0);
|
||||
on = str.not_empty();
|
||||
}
|
||||
else
|
||||
on = FALSE;
|
||||
}
|
||||
TForm_item& item = body.field(r);
|
||||
if (!item.is_section())
|
||||
{
|
||||
item.show(on);
|
||||
if (on)
|
||||
{
|
||||
str = arr.row(riga).get(1);
|
||||
item.set_col_head(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const TPrint_section& head = section('H', odd_page);
|
||||
const TPrint_section& foot = section('F', odd_page);
|
||||
|
||||
const int hh = head.height();
|
||||
const int fh = foot.height();
|
||||
const int fl = printer().formlen();
|
||||
|
||||
int rows[4]; // Righe orizzontali
|
||||
rows[0] = hh-2; // Terzultima riga della testata
|
||||
rows[1] = hh; // Ultima riga della testata
|
||||
rows[2] = fl-fh+1; // Prima riga del footer
|
||||
rows[3] = 0;
|
||||
|
||||
genera_fincatura(odd_page, rows[0], rows[2], rows);
|
||||
genera_intestazioni(odd_page, hh-1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Main app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TStampa_schede : public TApplication
|
||||
{
|
||||
TArray _file;
|
||||
char _tipo; // <D>ettagliata o <S>intetica
|
||||
char _sort; // <F>attura o <A>rticolo
|
||||
char _prov; // <P>rovvisori o <D>efinitivi
|
||||
TDate _fromdate, _todate; // Date limite
|
||||
TString _fromnum, _tonum; // Numerazioni limite
|
||||
|
||||
TArray _totali; // Totali complessivi
|
||||
TArray _totriga; // Totali di riga
|
||||
long _progressivo; // Numero progressivo di record per file di stampa
|
||||
TString _lastkey; // Ultima chiave del file di stampa temporaneo
|
||||
|
||||
TSchede_mask* _mask; // Mask di stampa
|
||||
TSchede_form* _form; // Form di stampa
|
||||
|
||||
protected:
|
||||
virtual bool menu(MENU_TAG mt);
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
|
||||
protected:
|
||||
void put_real(TRectype& tab, int index, real val, bool importo, const TDocumento& doc);
|
||||
void fill_key(TRectype& tab, const TDocumento& doc);
|
||||
void fill_key(TRectype& tab, const TRiga_documento& rdoc);
|
||||
|
||||
public:
|
||||
void open_files(int logicnum, ...);
|
||||
bool fill_doc(TRectype& tab, const TDocumento& doc);
|
||||
bool fill_rdoc(TRectype& tab, const TRiga_documento& rdoc);
|
||||
void update_totriga(const TRectype& tab);
|
||||
void fill_totriga(TRectype& tab);
|
||||
void fill_tot(TRectype& tab);
|
||||
bool write_tab(TLocalisamfile& tab) const;
|
||||
bool write_totali_per_articolo(TLocalisamfile& tab);
|
||||
|
||||
bool stampa_sintetica() const { return _tipo == 'S'; }
|
||||
bool stampa_dettagliata() const { return _tipo == 'D'; }
|
||||
bool stampa_per_articolo() const { return _sort == 'A'; }
|
||||
bool stampa_per_documento() const { return _sort == 'D'; }
|
||||
|
||||
bool stampa_clifo(TCursor& cur, const TString& ragsoc);
|
||||
};
|
||||
|
||||
void TStampa_schede::put_real(TRectype& tab, int index, real val,
|
||||
bool importo, const TDocumento& doc)
|
||||
{
|
||||
char erre[4]; sprintf(erre, "R%d", index);
|
||||
if (importo && doc.in_valuta())
|
||||
{
|
||||
val *= doc.cambio();
|
||||
val.round(0);
|
||||
}
|
||||
tab.put(erre, val);
|
||||
|
||||
real* r = (real*)_totali.objptr(index);
|
||||
if (r == NULL)
|
||||
_totali.add(val, index);
|
||||
else
|
||||
*r += val;
|
||||
}
|
||||
|
||||
void TStampa_schede::fill_key(TRectype& tab, const TDocumento& doc)
|
||||
{
|
||||
tab.zero();
|
||||
tab.put("COD", "PRN");
|
||||
|
||||
const TCli_for& clifo = doc.clifor();
|
||||
tab.put("S8", clifo.tipo());
|
||||
tab.put("I8", clifo.codice());
|
||||
|
||||
TString16 str;
|
||||
TString80 key;
|
||||
|
||||
key = doc.data().string(ANSI);
|
||||
|
||||
str = doc.numerazione(); str.left_just(4);
|
||||
key << str;
|
||||
|
||||
str.format("%4d", doc.numero());
|
||||
key << str;
|
||||
|
||||
tab.put("S0", key);
|
||||
tab.put("CODTAB", ++_progressivo);
|
||||
}
|
||||
|
||||
void TStampa_schede::fill_key(TRectype& tab, const TRiga_documento& rdoc)
|
||||
{
|
||||
fill_key(tab, rdoc.doc());
|
||||
|
||||
_lastkey = tab.get("S0");
|
||||
|
||||
_lastkey.left_just(20);
|
||||
if (stampa_per_articolo())
|
||||
{
|
||||
TString80 str = rdoc.get(RDOC_CODART);
|
||||
str.left_just(20);
|
||||
_lastkey.insert(str, 0);
|
||||
}
|
||||
|
||||
TString16 numero;
|
||||
numero.format("%4d", rdoc.numero());
|
||||
|
||||
_lastkey << numero;
|
||||
tab.put("S0", _lastkey);
|
||||
}
|
||||
|
||||
|
||||
bool TStampa_schede::fill_doc(TRectype& tab, const TDocumento& doc)
|
||||
{
|
||||
if (stampa_dettagliata())
|
||||
return FALSE;
|
||||
|
||||
fill_key(tab, doc);
|
||||
|
||||
TString descr(80);
|
||||
|
||||
const TTipo_documento& tipo = doc.tipo();
|
||||
const TCodice_numerazione& num = doc.codice_numerazione();
|
||||
|
||||
descr << tipo.descrizione() << ' ';
|
||||
descr << num.prefisso();
|
||||
descr << doc.numero();
|
||||
descr << num.postfisso();
|
||||
descr << " del " << doc.data();
|
||||
tab.put("S1", descr);
|
||||
|
||||
put_real(tab, 0, doc.totale_netto(), TRUE, doc);
|
||||
put_real(tab, 1, doc.totale_doc(), TRUE, doc);
|
||||
|
||||
TSheet_field& sheet = _mask->sfield(F_SINTETICA);
|
||||
TString_array& arr = sheet.rows_array();
|
||||
|
||||
TString16 src;
|
||||
for (int r = 0; r < arr.items(); r++)
|
||||
{
|
||||
TToken_string& row = arr.row(r);
|
||||
src = row.get(0);
|
||||
if (src.blank())
|
||||
break;
|
||||
const bool importo = row.get(3)[0] > ' ';
|
||||
real val = doc.get(src);
|
||||
put_real(tab, r+2, val, importo, doc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TStampa_schede::fill_rdoc(TRectype& tab, const TRiga_documento& rdoc)
|
||||
{
|
||||
if (stampa_sintetica())
|
||||
return FALSE;
|
||||
|
||||
switch(rdoc.tipo().tipo())
|
||||
{
|
||||
case RIGA_MERCE : break;
|
||||
case RIGA_OMAGGI : break;
|
||||
case RIGA_PRESTAZIONI: break;
|
||||
default : return FALSE;
|
||||
}
|
||||
|
||||
const TDocumento& doc = rdoc.doc();
|
||||
|
||||
fill_key(tab, rdoc);
|
||||
|
||||
TString descr(80);
|
||||
descr << rdoc.get(RDOC_CODART) << ' ';
|
||||
descr << rdoc.get(RDOC_DESCR);
|
||||
tab.put("S1", descr);
|
||||
|
||||
put_real(tab, 0, rdoc.importo(TRUE, FALSE, 0), TRUE, doc);
|
||||
put_real(tab, 1, rdoc.importo(TRUE, TRUE, 0), TRUE, doc);
|
||||
|
||||
TSheet_field& sheet = _mask->sfield(F_DETTAGLIATA);
|
||||
TString_array& arr = sheet.rows_array();
|
||||
|
||||
TString16 src;
|
||||
for (int r = 0; r < arr.items(); r++)
|
||||
{
|
||||
TToken_string& row = arr.row(r);
|
||||
src = row.get(0);
|
||||
if (src.blank())
|
||||
break;
|
||||
const bool importo = row.get(3)[0] > ' ';
|
||||
real val = rdoc.get(src);
|
||||
put_real(tab, r+2, val, importo, doc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TStampa_schede::update_totriga(const TRectype& tab)
|
||||
{
|
||||
char erre[4];
|
||||
for (int r = _totali.last(); r >= 0; r--)
|
||||
{
|
||||
sprintf(erre, "R%d", r);
|
||||
const real val(tab.get(erre));
|
||||
|
||||
real* tot = (real*)_totriga.objptr(r);
|
||||
if (tot == NULL)
|
||||
_totriga.add(val, r);
|
||||
else
|
||||
*tot += val;
|
||||
}
|
||||
}
|
||||
|
||||
void TStampa_schede::fill_totriga(TRectype& tab)
|
||||
{
|
||||
tab.zero();
|
||||
tab.put("COD", "PRN");
|
||||
tab.put("CODTAB", ++_progressivo);
|
||||
|
||||
_lastkey.overwrite("9999", _lastkey.len()-4);
|
||||
tab.put("S0", _lastkey);
|
||||
tab.put("S1", stampa_per_articolo() ? "Totale articolo" : "Totale documento");
|
||||
tab.put("B8", TRUE); // Riga totale
|
||||
|
||||
for (int r = _totriga.last(); r >= 0; r--)
|
||||
{
|
||||
char erre[4]; sprintf(erre, "R%d", r);
|
||||
tab.put(erre, (real&)_totriga[r]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TStampa_schede::fill_tot(TRectype& tab)
|
||||
{
|
||||
tab.zero();
|
||||
tab.put("COD", "PRN");
|
||||
tab.put("CODTAB", ++_progressivo);
|
||||
tab.put("S0", "zzzzzzzzzzzzzzzzzzzz");
|
||||
|
||||
tab.put("S1", "Totale");
|
||||
tab.put("B8", TRUE); // Riga totale
|
||||
|
||||
for (int r = _totali.last(); r >= 0; r--)
|
||||
{
|
||||
char erre[4]; sprintf(erre, "R%d", r);
|
||||
tab.put(erre, (real&)_totali[r]);
|
||||
}
|
||||
}
|
||||
|
||||
bool TStampa_schede::write_tab(TLocalisamfile& tab) const
|
||||
{
|
||||
int err = tab.write();
|
||||
if (err != NOERR)
|
||||
error_box("Errore %d durante la scrittura sul file temporaneo", err);
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
bool TStampa_schede::write_totali_per_articolo(TLocalisamfile& tab)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
TRectype& curtab = tab.curr();
|
||||
const TRecfield key(curtab, "S0");
|
||||
|
||||
_lastkey.cut(0);
|
||||
_totriga.destroy();
|
||||
for (int err = tab.first(); err == NOERR && ok; err = tab.next())
|
||||
{
|
||||
if (_lastkey.not_empty() && _lastkey.compare((const char*)key, 20) != 0)
|
||||
{
|
||||
const TRecnotype pos = tab.recno();
|
||||
fill_totriga(curtab);
|
||||
ok = write_tab(tab);
|
||||
tab.readat(pos);
|
||||
_totriga.destroy();
|
||||
}
|
||||
_lastkey = (const char*)key;
|
||||
update_totriga(curtab);
|
||||
}
|
||||
|
||||
if (ok && _lastkey.not_empty())
|
||||
{
|
||||
fill_totriga(curtab);
|
||||
ok = write_tab(tab);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TStampa_schede::stampa_clifo(TCursor& cur, const TString& ragsoc)
|
||||
{
|
||||
const long items = cur.items();
|
||||
|
||||
TString header(160);
|
||||
header = "Preparazione file temporaneo di stampa ...";
|
||||
if (ragsoc.not_empty())
|
||||
header << '\n' << ragsoc;
|
||||
|
||||
TProgind pi(items, header, TRUE, TRUE, 60);
|
||||
|
||||
cur.file().set_curr(new TDocumento);
|
||||
TDocumento& doc = (TDocumento&)cur.file().curr();
|
||||
|
||||
TIsamtempfile* tab = new TIsamtempfile(LF_TAB, "svschede", TRUE);
|
||||
tab->set_autodel(TRUE);
|
||||
tab->setkey(2);
|
||||
_form->relation()->replace(tab);
|
||||
TRectype& curtab = tab->curr();
|
||||
|
||||
_totali.destroy();
|
||||
_progressivo = 0;
|
||||
|
||||
bool can_print = TRUE;
|
||||
|
||||
for (cur = 0; cur.pos() < items && can_print; ++cur)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
{
|
||||
can_print = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (stampa_sintetica())
|
||||
{
|
||||
if (fill_doc(curtab, doc))
|
||||
can_print = write_tab(*tab);
|
||||
}
|
||||
else
|
||||
{
|
||||
_totriga.destroy();
|
||||
for (int r = doc.physical_rows(); r > 0 && can_print; r--)
|
||||
{
|
||||
const TRiga_documento& rdoc = doc[r];
|
||||
if (fill_rdoc(curtab, rdoc))
|
||||
{
|
||||
can_print = write_tab(*tab);
|
||||
if (stampa_per_documento())
|
||||
update_totriga(curtab);
|
||||
}
|
||||
}
|
||||
|
||||
if (can_print && _totriga.items() > 0)
|
||||
{
|
||||
fill_totriga(curtab);
|
||||
can_print = write_tab(*tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (can_print && stampa_per_articolo())
|
||||
can_print = write_totali_per_articolo(*tab);
|
||||
|
||||
if (can_print)
|
||||
{
|
||||
fill_tot(curtab);
|
||||
can_print = write_tab(*tab);
|
||||
}
|
||||
|
||||
pi.close_modal();
|
||||
|
||||
if (can_print && tab->items() > 0)
|
||||
{
|
||||
_form->print();
|
||||
}
|
||||
|
||||
_form->relation()->replace(new TLocalisamfile(LF_TAB));
|
||||
|
||||
return can_print;
|
||||
}
|
||||
|
||||
bool TStampa_schede::menu(MENU_TAG mt)
|
||||
{
|
||||
TSchede_mask& m = *_mask;
|
||||
while (m.run() != K_QUIT)
|
||||
{
|
||||
_tipo = m.get(F_TIPO)[0];
|
||||
_sort = m.get(F_ORDINE)[0];
|
||||
_prov = m.get(F_PROVVIS)[0];
|
||||
_fromdate = m.get_date(F_FROMDATE);
|
||||
_todate = m.get_date(F_TODATE);
|
||||
_fromnum = m.get(F_FROMNUM);
|
||||
_tonum = m.get(F_TONUM);
|
||||
|
||||
_form->init(m.sfield(stampa_dettagliata() ? F_DETTAGLIATA : F_SINTETICA));
|
||||
|
||||
TString filter(80);
|
||||
|
||||
if (_fromdate.ok())
|
||||
{
|
||||
if (filter.not_empty()) filter << "&&";
|
||||
filter << "(ANSI(" << DOC_DATADOC << ")>=\"" << _fromdate.string(ANSI) << "\")";
|
||||
}
|
||||
if (_todate.ok())
|
||||
{
|
||||
if (filter.not_empty()) filter << "&&";
|
||||
filter << "(ANSI(" << DOC_DATADOC << ")<=\"" << _todate.string(ANSI) << "\")";
|
||||
}
|
||||
if (_fromnum.not_empty())
|
||||
{
|
||||
if (filter.not_empty()) filter << "&&";
|
||||
filter << '(' << DOC_CODNUM << ">=\"" << _fromnum << "\")";
|
||||
}
|
||||
if (_tonum.not_empty())
|
||||
{
|
||||
if (filter.not_empty()) filter << "&&";
|
||||
filter << '(' << DOC_CODNUM << "<=\"" << _tonum << "\")";
|
||||
}
|
||||
|
||||
const TCursor_sheet& clifosheet = m.cur_sheet();
|
||||
TCursor& clifocur = *clifosheet.cursor();
|
||||
const long clifos = clifocur.items();
|
||||
const bool all = clifosheet.checked() == 0;
|
||||
|
||||
TRelation rel(LF_DOC);
|
||||
TRectype rec(LF_DOC);
|
||||
|
||||
TString ragsoc(80);
|
||||
|
||||
bool cancel = FALSE;
|
||||
if (all)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("Attenzione: e' stata selezionata la stampa di tutti i %s!\n"
|
||||
"Si desidera continuare ugualmente?",
|
||||
m.get_who() == 'C' ? "clienti" : "fornitori");
|
||||
cancel = !yesno_box(msg);
|
||||
}
|
||||
|
||||
for (clifocur = 0; clifocur.pos() < clifos && !cancel; ++clifocur)
|
||||
{
|
||||
if (all || clifosheet.checked(clifocur.pos()))
|
||||
{
|
||||
const long codcf = clifocur.file().get_long(CLI_CODCF);
|
||||
ragsoc = m.get_who() == 'C' ? "Cliente" : "Fornitore";
|
||||
ragsoc << ' ' << codcf << " - " << clifocur.file().get(CLI_RAGSOC);
|
||||
|
||||
rec.put(DOC_TIPOCF, m.get_who());
|
||||
rec.put(DOC_CODCF, codcf);
|
||||
rec.put(DOC_PROVV, _prov);
|
||||
// Uso la chiave 2: TIPOCF+CODCF+PROVV+ANNO+DATADOC+CODNUM+NDOC
|
||||
TCursor cur(&rel, filter, 2, &rec, &rec);
|
||||
if (cur.items() > 0)
|
||||
{
|
||||
cur.freeze();
|
||||
cancel = !stampa_clifo(cur, ragsoc);
|
||||
cur.freeze(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void TStampa_schede::open_files(int logicnum, ...)
|
||||
{
|
||||
va_list marker;
|
||||
va_start(marker, logicnum);
|
||||
while (logicnum > 0)
|
||||
{
|
||||
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
|
||||
_file.add(new TLocalisamfile(logicnum), logicnum);
|
||||
logicnum = va_arg(marker, int);
|
||||
}
|
||||
}
|
||||
|
||||
bool TStampa_schede::create()
|
||||
{
|
||||
open_files(LF_TABCOM, 0); // File comuni
|
||||
open_files(LF_TAB, LF_CLIFO, LF_OCCAS, 0); // File ditta
|
||||
open_files(LF_CFVEN, LF_DOC, LF_RIGHEDOC, 0); // File vendite
|
||||
|
||||
_mask = new TSchede_mask;
|
||||
_form = new TSchede_form;
|
||||
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TStampa_schede::destroy()
|
||||
{
|
||||
delete _form;
|
||||
delete _mask;
|
||||
_file.destroy();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int sv1100(int argc, char* argv[])
|
||||
{
|
||||
TStampa_schede app;
|
||||
app.run(argc, argv, "Stampa schede");
|
||||
return 0;
|
||||
}
|
||||
|
172
sv/sv1100a.frm
Executable file
172
sv/sv1100a.frm
Executable file
@ -0,0 +1,172 @@
|
||||
USE 5
|
||||
JOIN 20 INTO TIPOCF=S0|CODCF=I0
|
||||
JOIN 13 TO 20 INTO STATO==STATOCF|COM==COMCF
|
||||
|
||||
END
|
||||
|
||||
DESCRIPTION
|
||||
BEGIN
|
||||
5->* "Tabella temporanea di stampa"
|
||||
20->* "Clienti/Fornitori"
|
||||
13->* "Comuni"
|
||||
END
|
||||
|
||||
GENERAL
|
||||
BEGIN
|
||||
OFFSET 0 0
|
||||
FONT "Courier New"
|
||||
SIZE 7
|
||||
END
|
||||
|
||||
|
||||
SECTION HEADER ODD 12
|
||||
|
||||
STRINGA 1
|
||||
BEGIN
|
||||
KEY "Spettabile/Egregio"
|
||||
PROMPT 2 1 "Spettabile"
|
||||
END
|
||||
|
||||
NUMERO 218
|
||||
BEGIN
|
||||
KEY "Pagina"
|
||||
PROMPT 70 1 "Pagina "
|
||||
END
|
||||
|
||||
STRINGA 3
|
||||
BEGIN
|
||||
KEY "Codice cliente/fornitore"
|
||||
PROMPT 2 2 ""
|
||||
FIELD 20->CODCF
|
||||
END
|
||||
|
||||
STRINGA 4
|
||||
BEGIN
|
||||
KEY "Ragione sociale"
|
||||
PROMPT 8 2 ""
|
||||
FIELD 20->RAGSOC
|
||||
END
|
||||
|
||||
STRINGA 5
|
||||
BEGIN
|
||||
KEY "Indirizzo"
|
||||
PROMPT 2 3 ""
|
||||
FLAGS "H"
|
||||
FIELD 20->INDCF
|
||||
MESSAGE COPY,7
|
||||
END
|
||||
|
||||
STRINGA 6
|
||||
BEGIN
|
||||
KEY "Numero civico"
|
||||
PROMPT 52 3 ""
|
||||
FLAGS "H"
|
||||
FIELD 20->CIVCF
|
||||
MESSAGE APPEND,7
|
||||
END
|
||||
|
||||
STRINGA 7
|
||||
BEGIN
|
||||
KEY "Indirizzo completo"
|
||||
PROMPT 2 3 ""
|
||||
END
|
||||
|
||||
STRINGA 8
|
||||
BEGIN
|
||||
KEY "C.A.P."
|
||||
PROMPT 2 4 "C.A.P. "
|
||||
FIELD 20->CAPCF
|
||||
END
|
||||
|
||||
STRINGA 9
|
||||
BEGIN
|
||||
KEY "Localita'"
|
||||
PROMPT 26 4 ""
|
||||
FIELD 20->LOCALITACF
|
||||
END
|
||||
|
||||
STRINGA 10
|
||||
BEGIN
|
||||
KEY "Comune"
|
||||
PROMPT 2 5 ""
|
||||
FLAGS "H"
|
||||
FIELD 13->DENCOM
|
||||
MESSAGE COPY,12
|
||||
END
|
||||
|
||||
STRINGA 11
|
||||
BEGIN
|
||||
KEY "Provincia"
|
||||
PROMPT 52 5 ""
|
||||
FLAGS "H"
|
||||
FIELD 13->PROVCOM
|
||||
MESSAGE APPEND,12
|
||||
END
|
||||
|
||||
STRINGA 12
|
||||
BEGIN
|
||||
KEY "Comune completo"
|
||||
PROMPT 2 5 ""
|
||||
END
|
||||
|
||||
STRINGA 13
|
||||
BEGIN
|
||||
KEY "Prefisso telefonico"
|
||||
PROMPT 2 6 "Telefono "
|
||||
FLAGS "H"
|
||||
FIELD PTEL
|
||||
MESSAGE COPY,15
|
||||
END
|
||||
|
||||
STRINGA 14
|
||||
BEGIN
|
||||
KEY "Telefono"
|
||||
PROMPT 24 6 "/ "
|
||||
FLAGS "H"
|
||||
FIELD TEL
|
||||
MESSAGE APPEND,15
|
||||
END
|
||||
|
||||
STRINGA 15
|
||||
BEGIN
|
||||
KEY "Telefono completo"
|
||||
PROMPT 2 6 "Telefono "
|
||||
END
|
||||
|
||||
STRINGA 101
|
||||
BEGIN
|
||||
KEY "Luogo d'invio"
|
||||
PROMPT 2 7 ""
|
||||
END
|
||||
|
||||
DATA 102
|
||||
BEGIN
|
||||
KEY "Data d'invio"
|
||||
PROMPT 52 7 ""
|
||||
FORMAT "1444-"
|
||||
END
|
||||
|
||||
STRINGA 103 40 3
|
||||
BEGIN
|
||||
KEY "Testo fisso"
|
||||
FLAG "M"
|
||||
PROMPT 2 8 ""
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
SECTION BODY ODD -1 COLUMNWISE
|
||||
|
||||
STRINGA 201 8
|
||||
BEGIN
|
||||
SPECIAL STRINGA INTESTAZIONE "Num.doc." "Numero documento"
|
||||
SPECIAL NUMERO OFFSET "0" "Offset iniziale campo"
|
||||
SPECIAL STRINGA FINCATURA "XX" "Fincatura sinistra e destra"
|
||||
KEY "Numero documento"
|
||||
PROMPT 1 1 ""
|
||||
FLAGS "H"
|
||||
END
|
||||
|
||||
END // Fine body
|
||||
|
||||
END // Fine Form
|
20
sv/sv1100a.h
Executable file
20
sv/sv1100a.h
Executable file
@ -0,0 +1,20 @@
|
||||
#ifndef __SV1100A_H
|
||||
#define __SV1100A_H
|
||||
|
||||
#define F_FROMDATE 101
|
||||
#define F_TODATE 102
|
||||
#define F_FROMNUM 103
|
||||
#define F_TONUM 104
|
||||
#define F_PROVVIS 105
|
||||
#define F_TIPO 106
|
||||
#define F_ORDINE 107
|
||||
|
||||
#define F_SINTETICA 201
|
||||
#define F_DETTAGLIATA 202
|
||||
|
||||
#define S_FIELD 101
|
||||
#define S_HEAD 102
|
||||
#define S_DESCR 103
|
||||
#define S_IMPORTO 104
|
||||
|
||||
#endif
|
287
sv/sv1100a.uml
Executable file
287
sv/sv1100a.uml
Executable file
@ -0,0 +1,287 @@
|
||||
#include "../sc/scselmsk.h"
|
||||
#include "sv1100a.h"
|
||||
|
||||
TOOLBAR "Toolbar" 0 20 0 3
|
||||
|
||||
BUTTON DLG_PRINT 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 "~Stampa"
|
||||
END
|
||||
|
||||
BUTTON DLG_SAVEREC 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 "~Registra"
|
||||
PICTURE BMP_SAVEREC
|
||||
PICTURE BMP_SAVERECDN
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 "Fine"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Stampa schede" -1 -1 60 20
|
||||
|
||||
GROUPBOX DLG_NULL 78 8
|
||||
BEGIN
|
||||
PROMPT 1 1 "@bSelezione Clienti/Fornitori"
|
||||
END
|
||||
|
||||
RADIOBUTTON SC_CLIFO 22
|
||||
BEGIN
|
||||
PROMPT 2 2 "Selezione"
|
||||
ITEM "C|Clienti" MESSAGE ENABLE,1@
|
||||
ITEM "F|Fornitori" MESSAGE CLEAR,1@
|
||||
END
|
||||
|
||||
RADIOBUTTON SC_SORTCF 25
|
||||
BEGIN
|
||||
PROMPT 26 2 "Ordinamento"
|
||||
ITEM "1|Per codice" MESSAGE HIDE,2@|SHOW,3@
|
||||
ITEM "2|Per ragione sociale" MESSAGE HIDE,3@|SHOW,2@
|
||||
END
|
||||
|
||||
NUMBER SC_NSEL 3
|
||||
BEGIN
|
||||
PROMPT 71 2 "N. "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BUTTON SC_SELECT 10 2
|
||||
BEGIN
|
||||
PROMPT 52 3 "S~elezione"
|
||||
END
|
||||
|
||||
BUTTON SC_RESET 10 2
|
||||
BEGIN
|
||||
PROMPT 66 3 "A~zzera"
|
||||
END
|
||||
|
||||
NUMBER SC_CFCODFR 6
|
||||
BEGIN
|
||||
PROMPT 2 6 "Da codice "
|
||||
GROUP 3
|
||||
FLAGS "B"
|
||||
END
|
||||
|
||||
NUMBER SC_CFCODTO 6
|
||||
BEGIN
|
||||
PROMPT 2 7 "A codice "
|
||||
GROUP 3
|
||||
FLAGS "B"
|
||||
END
|
||||
|
||||
STRING SC_CFDESFR 50
|
||||
BEGIN
|
||||
PROMPT 2 6 "Da ragione sociale "
|
||||
GROUP 2
|
||||
FLAGS "HB"
|
||||
END
|
||||
|
||||
STRING SC_CFDESTO 50
|
||||
BEGIN
|
||||
PROMPT 2 7 "A ragione sociale "
|
||||
GROUP 2
|
||||
FLAGS "HB"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 10 "@bLimiti di stampa"
|
||||
END
|
||||
|
||||
DATE F_FROMDATE
|
||||
BEGIN
|
||||
PROMPT 2 11 "Dalla data "
|
||||
MESSAGE CHECK,F_TODATE
|
||||
END
|
||||
|
||||
DATE F_TODATE
|
||||
BEGIN
|
||||
PROMPT 2 12 "Alla data "
|
||||
END
|
||||
|
||||
STRING F_FROMNUM 4
|
||||
BEGIN
|
||||
PROMPT 51 11 "Dalla numerazione "
|
||||
USE %NUM
|
||||
INPUT CODTAB F_FROMNUM
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_FROMNUM CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
MESSAGE CHECK,F_TONUM
|
||||
END
|
||||
|
||||
STRING F_TONUM 4
|
||||
BEGIN
|
||||
PROMPT 51 12 "Alla numerazione "
|
||||
COPY USE F_FROMNUM
|
||||
INPUT CODTAB F_TONUM
|
||||
COPY DISPLAY F_FROMNUM
|
||||
OUTPUT F_TONUM CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
RADIOBUTTON F_PROVVIS 1 24
|
||||
BEGIN
|
||||
PROMPT 1 15 "Tipo movimenti"
|
||||
ITEM "D|Definitivi"
|
||||
ITEM "P|Provvisori"
|
||||
END
|
||||
|
||||
RADIOBUTTON F_TIPO 1 26
|
||||
BEGIN
|
||||
PROMPT 27 15 "Tipo stampa"
|
||||
ITEM "S|Sintetica"
|
||||
MESSAGE CLEAR,F_ORDINE
|
||||
ITEM "D|Dettagliata"
|
||||
MESSAGE ENABLE,F_ORDINE
|
||||
END
|
||||
|
||||
RADIOBUTTON F_ORDINE 1 24
|
||||
BEGIN
|
||||
PROMPT 55 15 "Ordinamento"
|
||||
ITEM "D|Documento"
|
||||
ITEM "A|Articolo"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Opzioni" -1 -1 60 20
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 1 1 "@bCampi per stampa sintetica"
|
||||
END
|
||||
|
||||
SPREADSHEET F_SINTETICA 0 8
|
||||
BEGIN
|
||||
PROMPT 1 2 ""
|
||||
ITEM "Campo@12"
|
||||
ITEM "Testata@12"
|
||||
ITEM "Descrizione@50"
|
||||
ITEM "Importo"
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 1 11 "@bCampi per stampa dettagliata"
|
||||
END
|
||||
|
||||
SPREADSHEET F_DETTAGLIATA
|
||||
BEGIN
|
||||
PROMPT 1 12 ""
|
||||
ITEM "Campo@12"
|
||||
ITEM "Testata@12"
|
||||
ITEM "Descrizione@50"
|
||||
ITEM "Importo"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
PAGE "Sheet 1" -1 -1 56 6
|
||||
|
||||
STRING S_FIELD 15
|
||||
BEGIN
|
||||
PROMPT 1 1 "Nome campo "
|
||||
USE %FRD SELECT B0="X"
|
||||
INPUT CODTAB S_FIELD
|
||||
DISPLAY "Campo@15" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT S_FIELD CODTAB
|
||||
OUTPUT S_DESCR S0
|
||||
OUTPUT S_IMPORTO B1
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
STRING S_HEAD 15
|
||||
BEGIN
|
||||
PROMPT 1 2 "Intestazione "
|
||||
END
|
||||
|
||||
STRING S_DESCR 50 40
|
||||
BEGIN
|
||||
PROMPT 1 3 "Descrizione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_IMPORTO
|
||||
BEGIN
|
||||
PROMPT 1 4 "Importo"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
PAGE "Sheet 2" -1 -1 56 6
|
||||
|
||||
STRING S_FIELD 15
|
||||
BEGIN
|
||||
PROMPT 1 1 "Nome campo "
|
||||
USE %FRR SELECT B0="X"
|
||||
INPUT CODTAB S_FIELD
|
||||
DISPLAY "Campo@15" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT S_FIELD CODTAB
|
||||
OUTPUT S_DESCR S0
|
||||
OUTPUT S_IMPORTO B1
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
STRING S_HEAD 15
|
||||
BEGIN
|
||||
PROMPT 1 2 "Intestazione "
|
||||
END
|
||||
|
||||
STRING S_DESCR 50 40
|
||||
BEGIN
|
||||
PROMPT 1 3 "Descrizione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_IMPORTO
|
||||
BEGIN
|
||||
PROMPT 1 4 "Importo"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
20
sv/sv2.cpp
Executable file
20
sv/sv2.cpp
Executable file
@ -0,0 +1,20 @@
|
||||
#include <xvt.h>
|
||||
#include <checks.h>
|
||||
|
||||
#include "sv2.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int n = argc > 1 ? atoi(argv[1]+1) : 0;
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
sv2100(argc, argv);
|
||||
break;
|
||||
default:
|
||||
error_box("Invalid argument %s", argv[1]);
|
||||
break;
|
||||
}
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
6
sv/sv2.h
Executable file
6
sv/sv2.h
Executable file
@ -0,0 +1,6 @@
|
||||
#ifndef __SV2_H
|
||||
#define __SV2_H
|
||||
|
||||
int sv2100(int argc, char* argv[]);
|
||||
|
||||
#endif
|
22
sv/sv2.url
Executable file
22
sv/sv2.url
Executable file
@ -0,0 +1,22 @@
|
||||
#include <default.url>
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENU M_FONT
|
||||
ITEM M_FONT_SELECT "~Font"
|
||||
ITEM MENU_ITEM(2) "~Colori"
|
||||
ITEM MENU_ITEM(3) "~Editor"
|
||||
|
||||
MENUBAR MENU_BAR(1)
|
||||
MENU MENU_BAR(1)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(2)
|
||||
MENU MENU_BAR(2)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(3)
|
||||
MENU MENU_BAR(3)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
156
sv/sv2100.cpp
Executable file
156
sv/sv2100.cpp
Executable file
@ -0,0 +1,156 @@
|
||||
#include <applicat.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "sv2.h"
|
||||
#include "svlib01.h"
|
||||
#include "sv2100a.h"
|
||||
|
||||
#include "svriep.h"
|
||||
|
||||
class TRicalcolo_stats : public TApplication
|
||||
{
|
||||
TArray _file; // Array dei files aperti
|
||||
TStats_agg _agg;
|
||||
|
||||
void open_files(int logicnum, ...) ;
|
||||
|
||||
protected:
|
||||
virtual bool menu(MENU_TAG mt);
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
virtual void on_config_change();
|
||||
|
||||
public:
|
||||
bool kill_stats(const TDate& dfr, const TDate& dto);
|
||||
void calc_stats(const TDate& dfr, const TDate& dto);
|
||||
};
|
||||
|
||||
void TRicalcolo_stats::open_files(int logicnum, ...)
|
||||
{
|
||||
va_list marker;
|
||||
va_start(marker, logicnum);
|
||||
while (logicnum > 0)
|
||||
{
|
||||
CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
|
||||
_file.add(new TLocalisamfile(logicnum), logicnum);
|
||||
logicnum = va_arg(marker, int);
|
||||
}
|
||||
}
|
||||
|
||||
bool TRicalcolo_stats::create()
|
||||
{
|
||||
open_files(LF_TABCOM, 0); // File comuni
|
||||
open_files(LF_TAB, LF_CLIFO, LF_OCCAS, 0); // File ditta
|
||||
open_files(LF_CFVEN, LF_DOC, LF_RIGHEDOC, 0); // File vendite
|
||||
open_files(LF_SVRIEP, 0); // File statistiche
|
||||
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TRicalcolo_stats::on_config_change()
|
||||
{
|
||||
_agg.init();
|
||||
}
|
||||
|
||||
bool TRicalcolo_stats::destroy()
|
||||
{
|
||||
_file.destroy();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto)
|
||||
{
|
||||
TRelation rel(LF_SVRIEP);
|
||||
|
||||
TRectype recfrom(LF_SVRIEP), recto(LF_SVRIEP);
|
||||
|
||||
if (dfr.ok())
|
||||
{
|
||||
recfrom.put(SVR_ANNO, dfr.year());
|
||||
recfrom.put(SVR_PERIODO, _agg.date2period(dfr));
|
||||
}
|
||||
if (dto.ok())
|
||||
{
|
||||
recto.put(SVR_ANNO, dto.year());
|
||||
recto.put(SVR_PERIODO, _agg.date2period(dto));
|
||||
}
|
||||
|
||||
TCursor cur(&rel, "", 1, &recfrom, &recto);
|
||||
const long items = cur.items();
|
||||
TProgind pi(items, "Azzeramneto statistiche", FALSE, TRUE, 60);
|
||||
cur.freeze();
|
||||
|
||||
int err = NOERR;
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
err = cur.file().remove();
|
||||
if (err != NOERR)
|
||||
break;
|
||||
}
|
||||
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
|
||||
{
|
||||
TRectype recfrom(LF_DOC), recto(LF_DOC);
|
||||
recfrom.put(DOC_DATADOC, dfr);
|
||||
if (dto.ok())
|
||||
recto.put(DOC_DATADOC, dto);
|
||||
|
||||
TRelation rel(LF_DOC);
|
||||
TCursor cur(&rel, "PROVV='D'", 3, &recfrom, &recto);
|
||||
const long items = cur.items();
|
||||
TProgind pi(items, "Ricalcolo statistiche", FALSE, TRUE, 60);
|
||||
|
||||
TDocumento* curr = new TDocumento;
|
||||
cur.file().set_curr(curr);
|
||||
const TDocumento& doc = *curr;
|
||||
|
||||
long records = 0;
|
||||
_agg.reset();
|
||||
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
pi.addstatus(1);
|
||||
|
||||
const TTipo_documento& tipodoc = doc.tipo();
|
||||
if (!tipodoc.statistiche())
|
||||
continue;
|
||||
|
||||
for (int r = doc.physical_rows()-1; r > 0; r--)
|
||||
{
|
||||
const TRiga_documento& rdoc = doc[r];
|
||||
_agg.add(rdoc);
|
||||
}
|
||||
|
||||
records++;
|
||||
if (records % 1000 == 0)
|
||||
_agg.update();
|
||||
}
|
||||
_agg.update();
|
||||
}
|
||||
|
||||
bool TRicalcolo_stats::menu(MENU_TAG)
|
||||
{
|
||||
TMask m("sv2100a");
|
||||
while (m.run() == K_ENTER)
|
||||
{
|
||||
const TDate dfr(m.get(F_FROMDATE));
|
||||
const TDate dto(m.get(F_TODATE));
|
||||
if (kill_stats(dfr, dto))
|
||||
calc_stats(dfr, dto);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int sv2100(int argc, char* argv[])
|
||||
{
|
||||
TRicalcolo_stats app;
|
||||
app.run(argc, argv, "Ricalcolo statistiche");
|
||||
return 0;
|
||||
}
|
7
sv/sv2100a.h
Executable file
7
sv/sv2100a.h
Executable file
@ -0,0 +1,7 @@
|
||||
#ifndef __SV2100A_H
|
||||
#define __SV2100A_H
|
||||
|
||||
#define F_FROMDATE 101
|
||||
#define F_TODATE 102
|
||||
|
||||
#endif
|
27
sv/sv2100a.uml
Executable file
27
sv/sv2100a.uml
Executable file
@ -0,0 +1,27 @@
|
||||
#include "sv2100a.h"
|
||||
|
||||
PAGE "Ricalcolo statistiche" -1 -1 30 6
|
||||
|
||||
DATE F_FROMDATE
|
||||
BEGIN
|
||||
PROMPT 1 1 "Dalla data "
|
||||
END
|
||||
|
||||
DATE F_TODATE
|
||||
BEGIN
|
||||
PROMPT 1 2 "Alla data "
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
243
sv/svlib01.cpp
243
sv/svlib01.cpp
@ -1,31 +1,77 @@
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
|
||||
#include "svlib01.h"
|
||||
|
||||
#include "doc.h"
|
||||
#include "rdoc.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TStats_data
|
||||
///////////////////////////////////////////////////////////
|
||||
#include "svriep.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TStats_agg
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TStats_agg::date2class(const TDate& datadoc) const
|
||||
void TStats_agg::init()
|
||||
{
|
||||
TConfig ini(CONFIG_DITTA, "sv");
|
||||
|
||||
switch(ini.get_char("Frequenza"))
|
||||
{
|
||||
case 'B': _frequenza = fs_bimestrale; break;
|
||||
case 'M': _frequenza = fs_mensile; break;
|
||||
case 'Q': _frequenza = fs_quindicinale; break;
|
||||
case 'S': _frequenza = fs_settimanale; break;
|
||||
case 'T': _frequenza = fs_trimestrale; break;
|
||||
default : _frequenza = fs_giornaliera; break;
|
||||
}
|
||||
|
||||
_merce = ini.get_bool("StatMerce");
|
||||
_prestazioni = ini.get_bool("StatPrestazioni");
|
||||
_omaggi = ini.get_bool("StatOmaggi");
|
||||
_omaggio_is_merce = ini.get_bool("OmaggioIsMerce");
|
||||
|
||||
_art_nocode = ini.get_bool("ArtNoCode");
|
||||
_art_noanag = ini.get_bool("ArtNoAnag");
|
||||
_art_noanag_grp = ini.get_bool("ArtNoAnagGrp");
|
||||
|
||||
_agente = ini.get_bool("AgenteGrp");
|
||||
_cliente = ini.get_bool("ClienteGrp");
|
||||
_giacenza = ini.get_bool("GiacenzaGrp");
|
||||
_magazzino = ini.get_bool("MagazzinoGrp");
|
||||
}
|
||||
|
||||
void TStats_agg::test_firm() const
|
||||
{
|
||||
const long ditta = prefix().get_codditta();
|
||||
if (ditta != _ditta)
|
||||
{
|
||||
CHECK(_data.items() == 0, "Non cambiare ditta durante un'operazione di ricalcolo!");
|
||||
((TStats_agg*)this)->init();
|
||||
((TStats_agg*)this)->_ditta = ditta;
|
||||
}
|
||||
}
|
||||
|
||||
int TStats_agg::date2period(const TDate& datadoc) const
|
||||
{
|
||||
test_firm();
|
||||
|
||||
int classe;
|
||||
if (_frequenza > fs_settimanale)
|
||||
{
|
||||
classe = datadoc.month();
|
||||
if (_frequenza == fs_bimestrale)
|
||||
classe = (classe-1) / 2 + 1;
|
||||
else if (_frequenza == fs_trimestrale)
|
||||
classe = (classe-1) / 3 + 1;
|
||||
else if (_frequenza == fs_quindicinale)
|
||||
switch(_frequenza)
|
||||
{
|
||||
case fs_quindicinale:
|
||||
classe = (classe-1) * 2 + 1;
|
||||
if (datadoc.day() > 15) classe++;
|
||||
}
|
||||
break;
|
||||
case fs_bimestrale:
|
||||
classe = (classe-1) / 2 + 1;
|
||||
break;
|
||||
case fs_trimestrale:
|
||||
classe = (classe-1) / 3 + 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -38,38 +84,71 @@ int TStats_agg::date2class(const TDate& datadoc) const
|
||||
return classe;
|
||||
}
|
||||
|
||||
void TStats_agg::put_key(TRectype& stat, TToken_string& key) const
|
||||
{
|
||||
CHECK(stat.num() == LF_SVRIEP, "Ci vuole un record delle statistiche");
|
||||
stat.zero();
|
||||
stat.put(SVR_ANNO, key.get(0));
|
||||
stat.put(SVR_PERIODO, key.get());
|
||||
stat.put(SVR_TIPODOC, key.get());
|
||||
stat.put(SVR_TIPOART, key.get());
|
||||
stat.put(SVR_CODART, key.get());
|
||||
stat.put(SVR_UMQTA, key.get());
|
||||
stat.put(SVR_CODAG, key.get());
|
||||
stat.put(SVR_CODCF, key.get());
|
||||
stat.put(SVR_LIVELLO, key.get());
|
||||
stat.put(SVR_CODMAG, key.get());
|
||||
}
|
||||
|
||||
TStats_agg::TStats_data& TStats_agg::find(const TRiga_documento& rdoc)
|
||||
{
|
||||
test_firm();
|
||||
|
||||
const TDocumento& doc = rdoc.doc();
|
||||
const TDate datadoc = doc.get(DOC_DATADOC);
|
||||
|
||||
TToken_string key(24);
|
||||
TToken_string key(64);
|
||||
|
||||
key = doc.get(DOC_TIPODOC);
|
||||
key.add(datadoc.year());
|
||||
key.add(date2class(datadoc));
|
||||
key.add(rdoc.get(RDOC_UMQTA));
|
||||
key.add(date2period(datadoc));
|
||||
key.add(doc.get(DOC_TIPODOC));
|
||||
|
||||
char tipo = rdoc.tipo().tipo();
|
||||
if (tipo == 'O' && _omaggio_is_merce)
|
||||
tipo = 'M';
|
||||
if (tipo == RIGA_OMAGGI && _omaggio_is_merce)
|
||||
tipo = RIGA_MERCE;
|
||||
key.add(tipo);
|
||||
|
||||
TString80 codart = rdoc.get(RDOC_CODARTMAG);
|
||||
if (codart.empty()) codart = rdoc.get(RDOC_CODART);
|
||||
TString80 codart;
|
||||
if (tipo != RIGA_PRESTAZIONI)
|
||||
{
|
||||
codart = rdoc.get(RDOC_CODARTMAG);
|
||||
if (codart.empty() && !_art_noanag_grp)
|
||||
codart = rdoc.get(RDOC_CODART);
|
||||
}
|
||||
else
|
||||
codart = rdoc.get(RDOC_CODART);
|
||||
key.add(codart);
|
||||
key.add(rdoc.get(RDOC_UMQTA));
|
||||
|
||||
if (_agente)
|
||||
key.add(doc.get(DOC_CODAG));
|
||||
else
|
||||
key.add("");
|
||||
|
||||
if (_cliente)
|
||||
key.add(doc.get(DOC_CODCF));
|
||||
else
|
||||
key.add("");
|
||||
|
||||
if (_giacenza)
|
||||
key.add(doc.get(DOC_CODCF));
|
||||
key.add(rdoc.get(RDOC_LIVELLO));
|
||||
else
|
||||
key.add("");
|
||||
|
||||
if (_magazzino)
|
||||
key.add(doc.get(RDOC_CODMAG));
|
||||
key.add(rdoc.get(RDOC_CODMAG));
|
||||
else
|
||||
key.add("");
|
||||
|
||||
TStats_data* ptr = (TStats_data*)_data.objptr(key);
|
||||
if (ptr == NULL)
|
||||
@ -82,17 +161,39 @@ TStats_agg::TStats_data& TStats_agg::find(const TRiga_documento& rdoc)
|
||||
}
|
||||
|
||||
bool TStats_agg::can_add(const TRiga_documento& rdoc) const
|
||||
{
|
||||
bool ok;
|
||||
const char tipo = rdoc.tipo().tipo();
|
||||
switch(tipo)
|
||||
{
|
||||
test_firm();
|
||||
|
||||
const TTipo_documento& tip = rdoc.doc().tipo();
|
||||
bool ok = tip.statistiche();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
case 'M': ok = _merce; break;
|
||||
case 'O': ok = _omaggi; break;
|
||||
case 'P': ok = _prestazioni; break;
|
||||
default : ok = FALSE; break;
|
||||
const char tipo = rdoc.tipo().tipo();
|
||||
switch(tipo)
|
||||
{
|
||||
case RIGA_MERCE : ok = _merce; break;
|
||||
case RIGA_OMAGGI : ok = _omaggi; break;
|
||||
case RIGA_PRESTAZIONI: ok = _prestazioni; break;
|
||||
default : ok = FALSE; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ok && !rdoc.is_articolo())
|
||||
{
|
||||
const TString& codart = rdoc.get(RDOC_CODART);
|
||||
if (codart.empty())
|
||||
ok = _art_nocode;
|
||||
else
|
||||
ok = _art_noanag;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TStats_agg::reset()
|
||||
{
|
||||
_data.destroy();
|
||||
}
|
||||
|
||||
bool TStats_agg::sub(const TRiga_documento& rdoc)
|
||||
@ -113,32 +214,74 @@ bool TStats_agg::add(const TRiga_documento& rdoc)
|
||||
if (ok)
|
||||
{
|
||||
TStats_data& data = find(rdoc);
|
||||
data._quantita += rdoc.quantita();
|
||||
|
||||
data._valore += rdoc.imponibile();
|
||||
real qta = rdoc.quantita();
|
||||
if (qta.is_zero())
|
||||
qta = 1.0;
|
||||
data._quantita += qta;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TStats_agg::update()
|
||||
{
|
||||
return TRUE;
|
||||
{
|
||||
TProgind pi(_data.items(), "Aggiornamento statistiche", FALSE, TRUE, 60);
|
||||
|
||||
test_firm();
|
||||
|
||||
bool ok = TRUE;
|
||||
|
||||
TToken_string key(64);
|
||||
TLocalisamfile stat(LF_SVRIEP);
|
||||
TRectype& curr = stat.curr();
|
||||
|
||||
_data.restart();
|
||||
for (THash_object* h = _data.get_hashobj(); h; h = _data.get_hashobj())
|
||||
{
|
||||
pi.addstatus(1);
|
||||
|
||||
TStats_data& data = (TStats_data&)h->obj();
|
||||
if (data._quantita.is_zero() && data._valore.is_zero())
|
||||
continue;
|
||||
|
||||
key = h->key();
|
||||
|
||||
bool saved = FALSE;
|
||||
while (!saved)
|
||||
{
|
||||
put_key(curr, key);
|
||||
int err = stat.read(_isequal, _lock);
|
||||
if (err != NOERR)
|
||||
put_key(curr, key);
|
||||
real quantita(curr.get(SVR_QUANTITA));
|
||||
real valore(curr.get(SVR_VALORE));
|
||||
quantita += data._quantita;
|
||||
valore += data._valore;
|
||||
curr.put(SVR_QUANTITA, quantita);
|
||||
curr.put(SVR_VALORE, valore);
|
||||
|
||||
if (err == NOERR)
|
||||
err = stat.rewrite();
|
||||
else
|
||||
err = stat.write();
|
||||
|
||||
switch(err)
|
||||
{
|
||||
case NOERR : saved = TRUE;
|
||||
break;
|
||||
case _isreinsert: break;
|
||||
default : saved = !yesno_box("Errore %d nell'aggiornamento statistiche:"
|
||||
"Si desidera ritentare?", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
reset();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
TStats_agg::TStats_agg()
|
||||
TStats_agg::TStats_agg() : _ditta(0)
|
||||
{
|
||||
TConfig ini(CONFIG_DITTA, "sv");
|
||||
switch(ini.get_char("DataFreq"))
|
||||
{
|
||||
case 'B': _frequenza = fs_bimestrale; break;
|
||||
case 'M': _frequenza = fs_mensile; break;
|
||||
case 'Q': _frequenza = fs_quindicinale; break;
|
||||
case 'S': _frequenza = fs_settimanale; break;
|
||||
case 'T': _frequenza = fs_trimestrale; break;
|
||||
default : _frequenza = fs_giornaliera; break;
|
||||
}
|
||||
|
||||
_merce = ini.get_bool("StatMerce");
|
||||
_prestazioni = ini.get_bool("StatPrestazioni");
|
||||
_omaggi = ini.get_bool("StatOmaggi");
|
||||
_omaggio_is_merce = ini.get_bool("OmaggioIsMerce");
|
||||
}
|
||||
|
16
sv/svlib01.h
16
sv/svlib01.h
@ -20,24 +20,32 @@ class TStats_agg : public TObject
|
||||
public:
|
||||
real _quantita, _valore;
|
||||
};
|
||||
|
||||
|
||||
long _ditta;
|
||||
TAssoc_array _data;
|
||||
|
||||
TFrequenza_statistiche _frequenza;
|
||||
bool _merce, _prestazioni, _omaggi, _omaggio_is_merce;
|
||||
bool _art_nocode, _art_noanag, _art_noanag_grp;
|
||||
bool _agente, _cliente, _articolo, _giacenza, _magazzino;
|
||||
|
||||
protected:
|
||||
// Converte una data nella classe temporale definita dalla frequenza delle statisitiche
|
||||
int date2class(const TDate& datadoc) const;
|
||||
void test_firm() const;
|
||||
void put_key(TRectype& stat, TToken_string& key) const;
|
||||
TStats_agg::TStats_data& find(const TRiga_documento& rdoc);
|
||||
bool can_add(const TRiga_documento& rdoc) const;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
void init();
|
||||
void reset();
|
||||
bool sub(const TRiga_documento& rdoc);
|
||||
bool add(const TRiga_documento& rdoc);
|
||||
bool update();
|
||||
|
||||
// Converte una data nella classe temporale definita dalla frequenza delle statisitiche
|
||||
int date2period(const TDate& datadoc) const;
|
||||
|
||||
TStats_agg();
|
||||
virtual ~TStats_agg() { }
|
||||
};
|
||||
|
17
sv/svriep.h
Executable file
17
sv/svriep.h
Executable file
@ -0,0 +1,17 @@
|
||||
#ifndef __SVRIEP_H
|
||||
#define __SVRIEP_H
|
||||
|
||||
#define SVR_TIPODOC "TIPODOC"
|
||||
#define SVR_ANNO "ANNO"
|
||||
#define SVR_PERIODO "PERIODO"
|
||||
#define SVR_TIPOART "TIPOART"
|
||||
#define SVR_CODART "CODART"
|
||||
#define SVR_UMQTA "UMQTA"
|
||||
#define SVR_CODAG "CODAG"
|
||||
#define SVR_CODCF "CODCF"
|
||||
#define SVR_LIVELLO "LIVELLO"
|
||||
#define SVR_CODMAG "CODMAG"
|
||||
#define SVR_QUANTITA "QUANTITA"
|
||||
#define SVR_VALORE "VALORE"
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user