1998-06-25 07:29:35 +00:00
|
|
|
// Stampa dettaglio disponibilita' articoli
|
|
|
|
#include <applicat.h>
|
2002-12-17 12:06:42 +00:00
|
|
|
#include <printer.h>
|
2003-06-27 14:55:37 +00:00
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
|
|
#include "doc.h"
|
|
|
|
#include "rdoc.h"
|
|
|
|
|
2002-12-17 12:06:42 +00:00
|
|
|
#include "orlib.h"
|
|
|
|
#include "or1200a.h"
|
1998-06-25 07:29:35 +00:00
|
|
|
|
2003-06-27 14:55:37 +00:00
|
|
|
#include "../cg/cglib01.h"
|
|
|
|
#include "../ve/velib.h"
|
|
|
|
|
|
|
|
|
1998-06-25 07:29:35 +00:00
|
|
|
class TStampa_dettaglio_articoli : public TSkeleton_application
|
|
|
|
{
|
2000-05-05 14:32:44 +00:00
|
|
|
TMask *_m;
|
|
|
|
TOrdine_form
|
|
|
|
*_frm;
|
|
|
|
TCodgiac_livelli
|
|
|
|
*_codgiac;
|
|
|
|
TTable *_fcg;
|
|
|
|
TString _fromcodnum, _tocodnum; // Range calcolati automaticamente all'inizio del prg
|
|
|
|
int _anno;
|
|
|
|
char _provv;
|
|
|
|
bool _da_ordinare, // Se TRUE solo gli articoli da ordinare, FALSE tutti.
|
|
|
|
_detail_mag, _detail_dep,
|
|
|
|
_giac_eff, _val_comp;
|
|
|
|
TDate _data_oss; // Data di osservazione
|
|
|
|
TDate _data_inizio;
|
|
|
|
TArray _date_array; // Array di date di suddivisione periodi di osservazione
|
|
|
|
TArray _file; // Array di files da aprire per i malditos TRecord_array
|
|
|
|
int _periods,
|
|
|
|
_detail_level; //0..4 0 = Articoli 4 = FCG #4 Maximum detail level
|
|
|
|
TString _from_art, //ranges
|
|
|
|
_to_art,
|
|
|
|
_from_mag, _to_mag,
|
|
|
|
_from_dep, _to_dep;
|
2002-12-17 12:06:42 +00:00
|
|
|
TString_array
|
|
|
|
_from_giac, _to_giac;
|
1998-06-25 07:29:35 +00:00
|
|
|
protected:
|
|
|
|
virtual bool create();
|
|
|
|
virtual bool destroy();
|
|
|
|
virtual void main_loop();
|
2002-12-17 12:06:42 +00:00
|
|
|
void set_date_array();
|
|
|
|
void set_form();
|
1998-06-25 07:29:35 +00:00
|
|
|
public:
|
|
|
|
TStampa_dettaglio_articoli() {};
|
|
|
|
virtual ~TStampa_dettaglio_articoli() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TStampa_dettaglio_articoli::create()
|
|
|
|
{
|
2000-05-05 14:32:44 +00:00
|
|
|
open_files(LF_UMART, LF_OCCAS, LF_CLIFO, LF_INDSP, LF_CFVEN, LF_TABCOM, LF_MAG, 0);
|
|
|
|
_m = new TMask("or1200a");
|
|
|
|
// Reperisce i flags per vedere se e' abilitata la gestione depositi e la gestione livelli di giacenza
|
|
|
|
// Abilita quindi i campi relativi per la selezione dettaglio deposito/livello di giacenza
|
|
|
|
TConfig conf(CONFIG_DITTA,"mg");
|
|
|
|
bool geslivgiac = conf.get_bool("GESLIVGIAC");
|
|
|
|
bool gesdepositi = conf.get_bool("GESDEPOSITI");
|
|
|
|
_m->enable(-GR_DEP, gesdepositi);
|
|
|
|
_m->enable(-GR_GIAC, geslivgiac);
|
|
|
|
_fcg = new TTable("FCG");
|
|
|
|
_codgiac = new TCodgiac_livelli;
|
|
|
|
if (geslivgiac) // Completa i campi per i livelli di giacenza al fine di poter effettuare le ricerche
|
|
|
|
{
|
|
|
|
short id = F_GIAC1;
|
|
|
|
for (_fcg->first(); _fcg->good(); _fcg->next(), id+=4)
|
|
|
|
_m->set(id, _fcg->get("CODTAB"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trova gli estremi codice numerazione per tutti i documenti ordine
|
|
|
|
TTable tip("%TIP");
|
|
|
|
TString cod;
|
|
|
|
for (tip.first(); tip.good(); tip.next())
|
|
|
|
{
|
|
|
|
if (tip.get_int("I1") == 3) // Trattasi di ordine ??
|
|
|
|
{
|
|
|
|
cod = tip.get("CODTAB");
|
|
|
|
if (_fromcodnum.empty() || cod < _fromcodnum)
|
|
|
|
_fromcodnum = cod;
|
|
|
|
if (cod > _tocodnum)
|
|
|
|
_tocodnum = cod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-25 07:29:35 +00:00
|
|
|
return TSkeleton_application::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStampa_dettaglio_articoli::destroy()
|
|
|
|
{
|
2002-12-17 12:06:42 +00:00
|
|
|
delete _codgiac;
|
|
|
|
delete _fcg;
|
|
|
|
delete _m;
|
1998-06-25 07:29:35 +00:00
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
}
|
|
|
|
|
2000-05-05 14:32:44 +00:00
|
|
|
void TStampa_dettaglio_articoli::set_date_array()
|
|
|
|
{
|
|
|
|
TDate dday;
|
|
|
|
|
|
|
|
_date_array.destroy();
|
|
|
|
const long ndays = _data_oss - _data_inizio;
|
|
|
|
const long daysperiod = ndays / _periods;
|
|
|
|
|
|
|
|
dday = _data_inizio;
|
|
|
|
|
|
|
|
for (int i = 0; i < _periods; i++)
|
|
|
|
{
|
|
|
|
dday += daysperiod;
|
|
|
|
if (i == _periods -1)
|
|
|
|
dday = _data_oss;
|
|
|
|
_date_array.add(dday);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-10 08:26:39 +00:00
|
|
|
|
2000-05-05 14:32:44 +00:00
|
|
|
void TStampa_dettaglio_articoli::set_form()
|
|
|
|
{
|
|
|
|
CHECK(_frm,"Invalid form");
|
|
|
|
_frm->set_options(_detail_level, _detail_mag, _detail_dep, _giac_eff, _val_comp, &_date_array);
|
|
|
|
|
|
|
|
// Setta il filtro e l'ordinamento per il cursore del form...
|
|
|
|
TString lev_str, mag_str, s, filter_expr;
|
|
|
|
TSorted_cursor* cur = (TSorted_cursor*)_frm->cursor();
|
|
|
|
|
2003-06-10 08:26:39 +00:00
|
|
|
// TDocumento *doc = new TDocumento; // Don't delete it
|
|
|
|
// cur->file(LF_DOC).set_curr(doc); // File collegato
|
|
|
|
// cur->file(LF_RIGHEDOC).set_curr(new TRiga_documento(doc)); // File principale
|
2000-05-05 14:32:44 +00:00
|
|
|
|
|
|
|
if (_detail_level > 0)
|
|
|
|
lev_str.format("LIVELLO[1,%d]",_codgiac->packed_length(_detail_level));
|
|
|
|
if (_detail_mag)
|
|
|
|
mag_str.format("CODMAG[1,3]");
|
|
|
|
if (_detail_dep)
|
|
|
|
mag_str.format("CODMAG");
|
|
|
|
s = "CODART|";
|
|
|
|
|
|
|
|
if (lev_str.not_empty())
|
|
|
|
s << lev_str << "|";
|
|
|
|
if (mag_str.not_empty())
|
|
|
|
s << mag_str << "|";
|
|
|
|
s << "CODNUM|ANNO|PROVV|NDOC";
|
|
|
|
cur->change_order(s); // Cursor order expression
|
|
|
|
|
|
|
|
TRectype f(LF_RIGHEDOC), t(LF_RIGHEDOC);
|
|
|
|
if (_anno != 0)
|
|
|
|
{
|
|
|
|
f.put(DOC_PROVV, _provv);
|
|
|
|
f.put(DOC_ANNO, _anno);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.format("(PROVV==\"%c\") &&", _provv);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
f.put(DOC_CODNUM, _fromcodnum);
|
|
|
|
t = f;
|
|
|
|
t.put(DOC_CODNUM, _tocodnum);
|
|
|
|
cur->setregion(f,t); // Cursor region
|
|
|
|
|
|
|
|
// Considera solo i documenti con data consegna compresa tra oggi e la data di osservazione
|
|
|
|
s.format("(ANSI(%d->DATACONS)>=\"%s\")", LF_RIGHEDOC,
|
|
|
|
(const char*)_data_inizio.string(ANSI));
|
|
|
|
filter_expr << s;
|
2003-06-10 08:26:39 +00:00
|
|
|
|
|
|
|
if (_data_oss.ok())
|
|
|
|
{
|
2006-12-12 13:53:57 +00:00
|
|
|
s.format("&& (ANSI(%d->DATACONS)<=\"%s\")", LF_RIGHEDOC, (const char*) _data_oss.string(ANSI));
|
2003-06-10 08:26:39 +00:00
|
|
|
filter_expr << s;
|
2006-12-12 13:53:57 +00:00
|
|
|
// s.format("&& ((ANSI(%d->DATASCIMP)==\"\")||(ANSI(%d->DATASCIMP)>=\"%s\"))", LF_DOC, LF_DOC, (const char*) _data_oss.string(ANSI));
|
|
|
|
// filter_expr << s;
|
2003-06-10 08:26:39 +00:00
|
|
|
}
|
2000-05-05 14:32:44 +00:00
|
|
|
|
|
|
|
// Setta i range per il codice articolo
|
|
|
|
if (_from_art.not_empty())
|
|
|
|
{
|
|
|
|
s.format("&&(%d->CODART>=\"%s\")",
|
|
|
|
LF_RIGHEDOC, (const char*)_from_art);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
if (_to_art.not_empty())
|
|
|
|
{
|
|
|
|
filter_expr << "&&";
|
|
|
|
s.format("(%d->CODART<=\"%s\")",
|
|
|
|
LF_RIGHEDOC, (const char*)_to_art);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
// Setta i range per i livelli di giacenza (da 1 a 4)
|
|
|
|
if (_detail_level > 0)
|
|
|
|
for (int lev=1, index=0; lev <= _detail_level; lev++)
|
|
|
|
{
|
|
|
|
if (!_codgiac->enabled(lev))
|
|
|
|
continue;
|
|
|
|
TString& from = (TString&) _from_giac[index];
|
|
|
|
TString& to = (TString&) _to_giac[index++];
|
|
|
|
const int starts = _codgiac->code_start(lev);
|
|
|
|
const int ends = starts+_codgiac->code_length(lev);
|
|
|
|
if (from.not_empty())
|
|
|
|
{
|
|
|
|
s.format("&&(%d->LIVELLO[%d,%d]>=\"%s\")",
|
|
|
|
LF_RIGHEDOC,starts,ends,(const char*)from);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
if (to.not_empty())
|
|
|
|
{
|
|
|
|
s.format("&&(%d->LIVELLO[%d,%d]<=\"%s\")",
|
|
|
|
LF_RIGHEDOC,starts,ends,(const char*)to);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Setta i range per il codice magazzino (deposito incluso)
|
|
|
|
if (_from_mag.not_empty())
|
|
|
|
{
|
|
|
|
s.format("&&(%d->CODMAG>=\"%s\")",
|
|
|
|
LF_RIGHEDOC, (const char*)_from_mag);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
if (_to_mag.not_empty())
|
|
|
|
{
|
|
|
|
s.format("&&(%d->CODMAG<=\"%s\")",
|
|
|
|
LF_RIGHEDOC, (const char*)_to_mag);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
if (_da_ordinare)
|
|
|
|
{
|
|
|
|
s.format("&&(%d->RIGAEVASA!=\"X\")", LF_RIGHEDOC);
|
|
|
|
filter_expr << s;
|
|
|
|
}
|
|
|
|
|
|
|
|
cur->setfilter(filter_expr,TRUE); // Cursor filter expression
|
|
|
|
|
|
|
|
// Una volta settato il cursore del form, pensiamo ai campi del form
|
|
|
|
// ed alle espressioni delle sottosezioni, le colonne da abilitare etc. etc...
|
|
|
|
|
|
|
|
// Disabilita le colonne in base al numero di periodi da suddividere
|
|
|
|
for (short id = 4+_periods*2; id <= 15; id++)
|
|
|
|
{
|
2003-06-10 08:26:39 +00:00
|
|
|
_frm->find_field('B',odd_page,id).disable();
|
|
|
|
_frm->find_field('B',odd_page,id+50).disable();
|
2000-05-05 14:32:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Fincature & altro
|
|
|
|
const int hh = 7;
|
|
|
|
const int fl = printer().formlen();
|
|
|
|
|
|
|
|
int rows[5]; // Righe orizzontali
|
|
|
|
rows[0] = hh-4;
|
|
|
|
rows[1] = hh-2;
|
|
|
|
rows[2] = hh;
|
|
|
|
rows[3] = fl-1;
|
|
|
|
rows[4] = 0;
|
|
|
|
_frm->genera_intestazioni(odd_page, hh-1);
|
|
|
|
_frm->genera_intestazione_supplementare(odd_page, hh-3);
|
|
|
|
_frm->genera_fincatura(odd_page, hh-4, fl-1, rows);
|
|
|
|
}
|
|
|
|
|
1998-06-25 07:29:35 +00:00
|
|
|
void TStampa_dettaglio_articoli::main_loop()
|
|
|
|
{
|
2000-05-05 14:32:44 +00:00
|
|
|
while (_m->run()!=K_QUIT)
|
|
|
|
{
|
|
|
|
_provv = _m->get(F_PROVV)[0];
|
|
|
|
_anno = _m->get_int(F_ANNO);
|
|
|
|
_data_inizio = _m->get_date(F_DATE_H);
|
|
|
|
_data_oss = _m->get_date(F_DATAOSS);
|
2003-06-10 08:26:39 +00:00
|
|
|
if (!_data_oss.ok())
|
|
|
|
{
|
|
|
|
_data_oss = _data_inizio;
|
|
|
|
_data_oss.set_month(12);
|
|
|
|
_data_oss.set_day(31);
|
|
|
|
int anno = _anno;
|
|
|
|
if (anno <= 0)
|
|
|
|
{
|
2003-06-27 14:55:37 +00:00
|
|
|
TEsercizi_contabili esc;
|
|
|
|
const int codes = esc.last();
|
2003-06-10 08:26:39 +00:00
|
|
|
if (codes > 0)
|
2003-06-27 14:55:37 +00:00
|
|
|
anno = esc[codes].fine().year();
|
2003-06-10 08:26:39 +00:00
|
|
|
}
|
|
|
|
if (anno > _data_oss.year())
|
|
|
|
_data_oss.set_year(anno);
|
|
|
|
}
|
|
|
|
|
2000-05-05 14:32:44 +00:00
|
|
|
_from_mag = _m->get(F_MAGFROM);
|
|
|
|
_to_mag = _m->get(F_MAGTO);
|
|
|
|
_from_dep = _m->get(F_DEPFROM);
|
|
|
|
_to_dep = _m->get(F_DEPTO);
|
|
|
|
if (_from_mag.not_empty())
|
|
|
|
_from_mag.left_just(3);
|
|
|
|
if (_to_mag.not_empty())
|
|
|
|
_to_mag.left_just(3);
|
|
|
|
_from_mag << _from_dep;
|
|
|
|
_to_mag << _to_dep;
|
|
|
|
_from_art = _m->get(F_ARTFROM);
|
|
|
|
_to_art = _m->get(F_ARTTO);
|
|
|
|
_from_giac.destroy();
|
|
|
|
_to_giac.destroy();
|
|
|
|
_from_giac.add(_m->get(F_GIAC1_FROM),0);
|
|
|
|
_to_giac.add(_m->get(F_GIAC1_TO),0);
|
|
|
|
_from_giac.add(_m->get(F_GIAC2_FROM),1);
|
|
|
|
_to_giac.add(_m->get(F_GIAC2_TO),1);
|
|
|
|
_from_giac.add(_m->get(F_GIAC3_FROM),2);
|
|
|
|
_to_giac.add(_m->get(F_GIAC3_TO),2);
|
|
|
|
_from_giac.add(_m->get(F_GIAC4_FROM),3);
|
|
|
|
_to_giac.add(_m->get(F_GIAC4_TO),3);
|
|
|
|
_detail_mag = _m->get_bool(F_DETAIL_MAG);
|
|
|
|
_detail_dep = _m->get_bool(F_DETAIL_DEP);
|
|
|
|
_detail_level = _m->get_int(F_DETAIL_LEV);
|
|
|
|
_periods = _m->get_int(F_PERIODS);
|
|
|
|
_da_ordinare = _m->get(F_RIGHETUTTE) == "O";
|
|
|
|
_giac_eff = _m->get_bool(F_GIACEFF);
|
|
|
|
_val_comp = _m->get_bool(F_VALCOMP);
|
|
|
|
|
|
|
|
set_date_array();
|
|
|
|
_frm = new TOrdine_form("or1200a");
|
|
|
|
set_form();
|
|
|
|
|
|
|
|
if (_frm->cursor()->items() > 0)
|
2003-06-10 08:26:39 +00:00
|
|
|
{
|
|
|
|
TCursor* cur = _frm->cursor();
|
|
|
|
TDocumento *doc = new TDocumento; // Don't delete it
|
|
|
|
cur->file(LF_DOC).set_curr(doc); // File collegato
|
|
|
|
cur->file(LF_RIGHEDOC).set_curr(new TRiga_documento(doc)); // File principale
|
|
|
|
|
2000-05-05 14:32:44 +00:00
|
|
|
_frm->print();
|
2003-06-10 08:26:39 +00:00
|
|
|
|
|
|
|
cur->file(LF_DOC).set_curr(new TRectype(LF_DOC));
|
|
|
|
cur->file(LF_RIGHEDOC).set_curr(new TRectype(LF_RIGHEDOC));
|
|
|
|
}
|
2000-05-05 14:32:44 +00:00
|
|
|
|
|
|
|
// Reset mask
|
|
|
|
_m->reset();
|
|
|
|
delete _frm;
|
|
|
|
}
|
1998-06-25 07:29:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int or1200(int argc, char** argv)
|
|
|
|
{
|
|
|
|
TStampa_dettaglio_articoli a;
|
2004-05-18 13:07:58 +00:00
|
|
|
a.run(argc,argv,TR("Stampa disponibilita' articoli"));
|
1998-06-25 07:29:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-12-17 12:06:42 +00:00
|
|
|
|