Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 01.05 patch 282 git-svn-id: svn://10.65.10.50/trunk@8019 c028cbd2-c16b-5b4b-a496-9718f37d4682
892 lines
29 KiB
C++
Executable File
892 lines
29 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <currency.h>
|
||
|
||
#include "..\ve\veconf.h"
|
||
#include "mglib.h"
|
||
#include "mg4200.h"
|
||
#include "mg4frm.h"
|
||
|
||
#define MAX_VAL_COLUMNS 6
|
||
class TForm_inventario : public TForm_stampemg
|
||
{
|
||
int _colonne;
|
||
TSorted_cursor *_sortcur; // Cursore sortato: RAGGFIS+CODART usato in stampe per raggr. fisc.
|
||
TConfig *conf_ditta;
|
||
bool _use_alternate_cursor;
|
||
TArticolo_giacenza * _curr_art;
|
||
TString16 _codlist,_catven; // codici listino e cat vendita
|
||
bool _giaceff, // flag inventario di giacenza
|
||
_valcomp; // flag valorizzzione finiti o componenti
|
||
TTipo_valorizz _valorizz_scelte[MAX_VAL_COLUMNS]; // valorizzazioni delle varie colonne
|
||
|
||
TCurrency *_currency;
|
||
TArticolo_giacenza &curr_art();
|
||
public:
|
||
virtual TCursor* cursor() const ;
|
||
bool genera_intestazione_supplementare(pagetype p, short y);
|
||
void set_parametri(const char * codcm,const char * cod,bool giaceff, bool valcomp);
|
||
bool valorizzazione(TForm_item &cf, TTipo_valorizz t);
|
||
bool validate(TForm_item &cf, TToken_string &s);
|
||
void use_alternate_cursor(const bool b = TRUE) { _use_alternate_cursor = b; }
|
||
void add_colval(int tipo);
|
||
TForm_inventario(const char *name,const char *code) ;
|
||
~TForm_inventario();
|
||
};
|
||
|
||
TCursor* TForm_inventario::cursor() const
|
||
{
|
||
if (_use_alternate_cursor) // Se e' settata la stampa per ragg. fisc ritorna il cursore appropriato
|
||
return (TCursor*)_sortcur;
|
||
return TForm_stampemg::cursor();
|
||
}
|
||
|
||
bool TForm_inventario::validate(TForm_item &cf, TToken_string &s)
|
||
{
|
||
const TString code(s.get(0)); // prende il primo parametro, il codice del messaggio
|
||
TString subcode;
|
||
|
||
if (code=="_USER") {
|
||
TLocalisamfile & magfile=relation()->lfile(LF_MAG);
|
||
TRectype & magrec=magfile.curr();
|
||
TString16 annoes(magrec.get(MAG_ANNOES));
|
||
subcode=s.get();
|
||
if (subcode=="GIAC") {
|
||
real v=curr_art().giacenza_corretta(magrec,_giaceff,_valcomp);
|
||
cf.set(v.string());
|
||
}
|
||
if (subcode=="VAL1") {
|
||
valorizzazione(cf,_valorizz_scelte[0]);
|
||
}
|
||
if (subcode=="VAL2"&& _colonne >=2) {
|
||
valorizzazione(cf,_valorizz_scelte[1]);
|
||
}
|
||
if (subcode=="VAL3" && _colonne >=3) {
|
||
valorizzazione(cf,_valorizz_scelte[2]);
|
||
}
|
||
if (subcode=="VAL4" && _colonne >=4) {
|
||
valorizzazione(cf,_valorizz_scelte[3]);
|
||
}
|
||
if (subcode=="VAL5"&& _colonne >=5) {
|
||
valorizzazione(cf,_valorizz_scelte[4]);
|
||
}
|
||
if (subcode=="VAL6" && _colonne >=6) {
|
||
valorizzazione(cf,_valorizz_scelte[5]);
|
||
}
|
||
if (subcode=="NAMEVAL1") {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[0]]);
|
||
}
|
||
if (subcode=="NAMEVAL2"&& _colonne >=2) {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[1]]);
|
||
}
|
||
if (subcode=="NAMEVAL3" && _colonne >=3) {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[2]]);
|
||
}
|
||
if (subcode=="NAMEVAL4" && _colonne >=4) {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[3]]);
|
||
}
|
||
if (subcode=="NAMEVAL5"&& _colonne >=5) {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[4]]);
|
||
}
|
||
if (subcode=="NAMEVAL6" && _colonne >=6) {
|
||
cf.set(Nome_valorizz[_valorizz_scelte[5]]);
|
||
}
|
||
if (subcode=="LINEATOTALI") {
|
||
TString l(29*_colonne+12,'-');
|
||
cf.set(l);
|
||
}
|
||
}
|
||
return TForm_stampemg::validate(cf, s);
|
||
}
|
||
|
||
TArticolo_giacenza &TForm_inventario::curr_art()
|
||
{
|
||
TString newcode(relation()->lfile(LF_ANAMAG).curr().get(ANAMAG_CODART));
|
||
if (_curr_art==NULL || newcode != _curr_art->codice())
|
||
{
|
||
if (_curr_art) delete _curr_art;
|
||
_curr_art=new TArticolo_giacenza(newcode);
|
||
}
|
||
return *_curr_art;
|
||
}
|
||
|
||
void TForm_inventario::add_colval(int tipo)
|
||
{
|
||
TTipo_valorizz t= (TTipo_valorizz )tipo;
|
||
if (t>=valorizz_ultcos && tipo <=valorizz_LIFOr)
|
||
{
|
||
// Accende le colonne totali del Footer Last...
|
||
find_field('F', last_page, FF_BASEFL + (_colonne * 2)).show();
|
||
if (t < valorizz_FIFOa)
|
||
find_field('F', last_page, FF_BASEFL + (_colonne * 2) +1).show();
|
||
|
||
_valorizz_scelte[_colonne++]=t;
|
||
TString col;
|
||
col << _colonne;
|
||
find_field('B',odd_page,FF_ENABLECOLS).set(col);
|
||
|
||
// Accende le colonne per l'intestazione
|
||
const int base_col = 2*(_colonne-1);
|
||
find_field('B',odd_page,FF_COL1HEADER + base_col).show(); // Colonna valore
|
||
find_field('B',odd_page,FF_COL1HEADER + base_col+1).show(t < valorizz_FIFOa); // Colonna valore unitario (abilitata solo se ! FIFO/LIFO)
|
||
|
||
// Nasconde la colonna del valore unitario se il tipo di valorizzazzione e' FIFO/LIFO
|
||
if (t >= valorizz_FIFOa && t <= valorizz_LIFOr)
|
||
// Abilita i campi necessari per "nascondere" le colonne del prezzo unitario in tutto il form.
|
||
find_field('B', odd_page, FF_DISABLEUNIT1 + _colonne - 1).enable();
|
||
}
|
||
}
|
||
|
||
bool TForm_inventario::valorizzazione(TForm_item &cf, TTipo_valorizz t)
|
||
{
|
||
TRectype & magrec=relation()->lfile(LF_MAG).curr();
|
||
TString annoes(magrec.get(MAG_ANNOES));
|
||
real v;
|
||
if (t==valorizz_ultcos) {
|
||
v=curr_art().ultimo_costo(annoes);
|
||
}
|
||
if (t==valorizz_mediacos) {
|
||
v=curr_art().media_costi(annoes);
|
||
}
|
||
if (t==valorizz_przlist) {
|
||
v=100.0 / (100.0 + curr_art().get_real(ANAMAG_PERCRIC));
|
||
v=curr_art().prezzo_listino(annoes,_catven,_codlist) * v;
|
||
}
|
||
if (t==valorizz_coststd) {
|
||
v=curr_art().costo_standard(annoes);
|
||
}
|
||
if (t==valorizz_costmediopond) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().costo_mediopond(annoes,codmag,livello);
|
||
}
|
||
if (t==valorizz_costmedio) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().costo_medio(annoes,codmag,livello);
|
||
}
|
||
// arrotonda le valorizzazioni a costo unitario
|
||
_currency->set_price(TRUE);
|
||
_currency->set_num(v);
|
||
v = _currency->string();
|
||
|
||
if (t==valorizz_LIFO) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().LIFO(annoes,codmag,livello, _giaceff,_valcomp);
|
||
}
|
||
if (t==valorizz_FIFO) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().FIFO(annoes,codmag,livello, _giaceff,_valcomp);
|
||
}
|
||
if (t==valorizz_LIFOa) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().LIFO_annuale(annoes,codmag,livello, _giaceff,_valcomp);
|
||
}
|
||
if (t==valorizz_FIFOa) {
|
||
TString codmag(magrec.get(MAG_CODMAG));codmag.left(3);
|
||
const TString livello(magrec.get(MAG_LIVELLO));
|
||
v=curr_art().FIFO_annuale(annoes,codmag,livello, _giaceff,_valcomp);
|
||
}
|
||
const real giac_corretta = curr_art().giacenza_corretta(magrec,_giaceff,_valcomp);
|
||
v= v * giac_corretta ;
|
||
_currency->set_price(FALSE);
|
||
_currency->set_num(v);
|
||
cf.set(_currency->string());
|
||
//* curr_art().giacenza_corretta(magrec,_giaceff,_valcomp)
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
bool TForm_inventario::genera_intestazione_supplementare(pagetype p, short y)
|
||
{
|
||
TPrint_section* body = exist('B', p);
|
||
if (body == NULL || !body->columnwise())
|
||
return FALSE;
|
||
|
||
TPrint_section* header = exist('H', p);
|
||
if (header == NULL)
|
||
return FALSE;
|
||
|
||
TForm_string* s;
|
||
TString des;
|
||
for (int j=0;j<_colonne;j++)
|
||
{
|
||
TForm_item& fi = body->find_field(FF_COL1HEADER+j*2);
|
||
des = Nome_valorizz[_valorizz_scelte[j]];
|
||
int w = fi.width();
|
||
if (_valorizz_scelte[j] < valorizz_FIFOa)
|
||
w *= 2;
|
||
des.center_just(w);
|
||
s = new TForm_string(header);
|
||
s->id() = -1;
|
||
s->set_x(fi.x());
|
||
s->y() = y;
|
||
s->set_prompt(des);
|
||
s->temp() = TRUE;
|
||
header->add_field(s);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void TForm_inventario::set_parametri(const char * codcatv,const char * codlist,bool giaceff, bool valcomp)
|
||
{
|
||
_catven=codcatv;
|
||
_codlist=codlist;
|
||
_giaceff=giaceff;
|
||
_valcomp=valcomp;
|
||
}
|
||
|
||
TForm_inventario::TForm_inventario(const char *name,const char *code) :
|
||
TForm_stampemg(name,code),_curr_art(NULL)
|
||
{
|
||
_sortcur = new TSorted_cursor(relation(),"RAGGFIS|CODART");
|
||
_use_alternate_cursor = FALSE;
|
||
_colonne=0;
|
||
_currency = new TCurrency(ZERO,"_FIRM");
|
||
}
|
||
|
||
|
||
TForm_inventario::~TForm_inventario()
|
||
{
|
||
if (_curr_art) delete _curr_art;
|
||
if (_sortcur) delete _sortcur;
|
||
delete _currency;
|
||
}
|
||
|
||
|
||
|
||
class TStampainv_mask: public TStampemg_mask
|
||
{
|
||
static bool handle_ragg(TMask_field &fld, KEY k); // handler
|
||
static bool handle_liv(TMask_field &fld, KEY k); // handler
|
||
static bool handle_subord(TMask_field &fld, KEY k); // handler
|
||
static bool handle_codlist(TMask_field &fld, KEY k); // handler
|
||
static bool handle_filt(TMask_field &fld, KEY k); // handler
|
||
public:
|
||
TStampainv_mask();
|
||
~TStampainv_mask(){};
|
||
};
|
||
|
||
TStampainv_mask::TStampainv_mask():
|
||
TStampemg_mask("mg4200")
|
||
{
|
||
TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente
|
||
if (prassid.get_bool("GES", NULL, A_LISTINI))
|
||
field(F_CATVENLISTINO).enable(prassid.get_bool("GESLISCV"));
|
||
else {
|
||
field(F_CATVENLISTINO).disable(); field(F_CODLISTINO).disable();
|
||
}
|
||
|
||
set_handler(F_TOLIVELLOART, handle_liv);
|
||
set_handler(F_TOLIVELLOGIAC, handle_liv);
|
||
set_handler(F_ORDINE, handle_ragg);
|
||
//set_handler(F_DETTAGLIODEP, handle_ragg);
|
||
set_handler(F_DETTAGLIOMAG, handle_ragg);
|
||
set_handler(F_ORDINEART,handle_subord);
|
||
set_handler(F_ORDINEMAG,handle_subord);
|
||
set_handler(F_CODLISTINO, handle_codlist);
|
||
set_handler(F_FILTRO, handle_filt);
|
||
}
|
||
|
||
bool TStampainv_mask::handle_filt(TMask_field &fld, KEY k)
|
||
{
|
||
if (k == K_SPACE)
|
||
{
|
||
const bool articles = fld.mask().get(F_ORDINE)=="A";
|
||
TMask& m = fld.mask();
|
||
switch (fld.get()[0])
|
||
{
|
||
case '+':
|
||
case 'N':
|
||
m.show(F_ORDINEMAG);
|
||
m.hide(F_ORDINEART);
|
||
m.send_key(K_SPACE, F_ORDINEMAG);
|
||
break;
|
||
case 'T':
|
||
m.show(F_ORDINEART, articles);
|
||
m.show(F_ORDINEMAG, !articles);
|
||
m.send_key(K_SPACE, articles ? F_ORDINEART : F_ORDINEMAG);
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
bool TStampainv_mask::handle_subord(TMask_field &fld, KEY k)
|
||
{
|
||
if (k == K_SPACE)
|
||
{
|
||
TOperable_field &fraggcod=(TOperable_field &)fld.mask().field(F_RAGGCODICE);
|
||
TOperable_field &fragggiac=(TOperable_field &)fld.mask().field(F_RAGGLIVGIAC);
|
||
switch (fld.get()[0]) {
|
||
case 'C':
|
||
if (fld.mask().get(F_ORDINE)=="A")
|
||
fraggcod.enable();
|
||
else {
|
||
if (!fld.mask().get_bool(F_DETTAGLIODEP))
|
||
{
|
||
fraggcod.reset(); fraggcod.disable();
|
||
fragggiac.reset(); fragggiac.disable();
|
||
fraggcod.do_message(0);fragggiac.do_message(0);
|
||
}
|
||
}
|
||
break;
|
||
case 'M':
|
||
case 'S':
|
||
case 'R':
|
||
case 'D':
|
||
fraggcod.reset(); fraggcod.check();fraggcod.disable();
|
||
break;
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
bool TStampainv_mask::handle_liv(TMask_field &fld, KEY k)
|
||
{
|
||
if (k == K_TAB)
|
||
{
|
||
TOperable_field &ftotmag=(TOperable_field &)fld.mask().field(F_TOTALIMAGAZZINI);
|
||
TOperable_field &fdettmag=(TOperable_field &)fld.mask().field(F_DETTAGLIOMAG);
|
||
if (fld.mask().get(F_ORDINE)=="A")
|
||
{
|
||
if (fld.mask().get_int(F_TOLIVELLOART) || fld.mask().get_int(F_TOLIVELLOGIAC))
|
||
{
|
||
// raggruppamenti prima del dettaglio magazzini
|
||
ftotmag.reset(); ftotmag.disable();ftotmag.do_message(0);
|
||
} else {
|
||
ftotmag.enable();
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
bool TStampainv_mask::handle_ragg(TMask_field &fld, KEY k)
|
||
{
|
||
if (k == K_SPACE)
|
||
{
|
||
TOperable_field &ftotmag=(TOperable_field &)fld.mask().field(F_TOTALIMAGAZZINI);
|
||
TOperable_field &fraggcod=(TOperable_field &)fld.mask().field(F_RAGGCODICE);
|
||
TOperable_field &fragggiac=(TOperable_field &)fld.mask().field(F_RAGGLIVGIAC);
|
||
if (fld.mask().get(F_ORDINE)=="M")
|
||
{
|
||
ftotmag.enable();
|
||
if (!fld.mask().get_bool(F_DETTAGLIODEP))
|
||
{
|
||
fraggcod.reset(); fraggcod.disable();
|
||
fragggiac.reset(); fragggiac.disable();
|
||
fraggcod.do_message(0);fragggiac.do_message(0);
|
||
return TRUE;
|
||
}
|
||
}
|
||
fraggcod.enable();
|
||
fragggiac.enable();
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
bool TStampainv_mask::handle_codlist(TMask_field &fld, KEY k)
|
||
{
|
||
if (k == K_ENTER)
|
||
{
|
||
if (fld.empty())
|
||
{
|
||
TMask & m=fld.mask();
|
||
|
||
if (m.get_int(F_VAL1)-1==valorizz_przlist ||
|
||
m.get_int(F_VAL2)-1==valorizz_przlist ||
|
||
m.get_int(F_VAL3)-1==valorizz_przlist ||
|
||
m.get_int(F_VAL4)-1==valorizz_przlist ||
|
||
m.get_int(F_VAL5)-1==valorizz_przlist ||
|
||
m.get_int(F_VAL6)-1==valorizz_przlist
|
||
)
|
||
return fld.error_box("Occorre specificare il listino per la valorizzazione");
|
||
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
// STAMPA anagrafiche
|
||
class TStampa_inventario : public TSkeleton_application
|
||
{
|
||
TArray * _files;
|
||
TStampemg_mask * _mask;
|
||
TCursor * _cur;
|
||
TForm_inventario * _form; // to be moved into TPrint_application
|
||
|
||
protected:
|
||
virtual bool create();
|
||
virtual bool destroy();
|
||
virtual void main_loop();
|
||
virtual void on_firm_change();
|
||
|
||
void setprint_permagazzini();
|
||
void setprint_perarticoli();
|
||
void setprint_perarticoli_all();
|
||
|
||
public:
|
||
TStampa_inventario() {}
|
||
};
|
||
|
||
void TStampa_inventario ::on_firm_change()
|
||
{
|
||
_mask->enable_livellicodice();
|
||
}
|
||
|
||
|
||
|
||
bool TStampa_inventario::create()
|
||
{
|
||
_mask = new TStampainv_mask();
|
||
_files = new TArray();
|
||
// aggiunge i files per usare i tracciati record
|
||
_files->add(new TLocalisamfile(LF_ANAMAG));
|
||
_files->add(new TLocalisamfile(LF_UMART));
|
||
_files->add(new TLocalisamfile(LF_DESLIN));
|
||
_files->add(new TLocalisamfile(LF_CODCORR));
|
||
_files->add(new TLocalisamfile(LF_MAG));
|
||
_files->add(new TLocalisamfile(LF_STOMAG));
|
||
_files->add(new TLocalisamfile(LF_MOVMAG));
|
||
_files->add(new TLocalisamfile(LF_RMOVMAG));
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
bool TStampa_inventario::destroy()
|
||
{
|
||
delete _mask;
|
||
delete _files;
|
||
return TRUE;
|
||
}
|
||
|
||
void TStampa_inventario::setprint_permagazzini()
|
||
{
|
||
const char subordine=*_mask->get(F_ORDINEMAG);
|
||
const bool totdep = _mask->get_bool(F_TOTALIDEPOSITI);
|
||
TRectype darec(LF_MAG),arec(LF_MAG);
|
||
TString cfilter, espr1, espr2;
|
||
_cur = _form->cursor();
|
||
// setta il filtro sul cursore
|
||
if (*_mask->get(F_FILTRO)=='N')
|
||
cfilter << "(GIAC!=0)&&" ;
|
||
if (*_mask->get(F_FILTRO)=='+')
|
||
cfilter << "(GIAC>0)&&" ;
|
||
if (*_mask->get(F_DAART))
|
||
cfilter << "(CODART>=" <<'"' << _mask->get(F_DAART)<< "\")&&" ;
|
||
if (*_mask->get(F_AART))
|
||
cfilter << "(CODART<=" <<'"' << _mask->get(F_AART)<< "~~~~~~~~~~~~~~~~~~~\")&&" ;
|
||
if (cfilter.not_empty())
|
||
cfilter.cut(cfilter.len()-2);
|
||
switch (subordine)
|
||
{
|
||
case 'C':
|
||
_form->find_field('B',odd_page,"H_CATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").hide();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
if (!totdep)
|
||
espr1 = "ANNOES|CODMAG[1,3]|CODART|LIVELLO|CODMAG[4,5]";
|
||
else
|
||
espr1 = "ANNOES|CODMAG|CODART|LIVELLO";
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART",_strexpr);
|
||
_form->set_ordering(normale);
|
||
break;
|
||
case 'S':
|
||
case 'M':
|
||
{
|
||
TString16 m1,m2;
|
||
m1 = _mask->get(F_DACATMER);
|
||
m2 = _mask->get(F_ACATMER);
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
if (!totdep)
|
||
espr1.format("ANNOES|CODMAG[1,3]|%d->GRMERC|CODART|LIVELLO|CODMAG[4,5]", LF_ANAMAG);
|
||
else
|
||
espr1.format("ANNOES|CODMAG|%d->GRMERC|CODART|LIVELLO", LF_ANAMAG);
|
||
_form->set_ordering(cat_merc);
|
||
espr2.format("CODMAG[1,3]+CODMAG[1,5]+%d->GRMERC[1,3]", LF_ANAMAG);
|
||
_form->find_field('B',odd_page,"GRUPPI_CATMER").setcondition(espr2,_strexpr);
|
||
if (subordine == 'S')
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").show();
|
||
m1 << _mask->get(F_DASCATMER);
|
||
m2 << _mask->get(F_ASCATMER);
|
||
m1.trim();
|
||
m2.trim();
|
||
}
|
||
else
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
}
|
||
if (m1.not_empty())
|
||
{
|
||
espr2.format("&&(%d->GRMERC>=\"%s\")", LF_ANAMAG, (const char*) m1);
|
||
cfilter << espr2;
|
||
}
|
||
if (m2.not_empty())
|
||
{
|
||
espr2.format("&&(%d->GRMERC<=\"%s\")", LF_ANAMAG, (const char*) m2);
|
||
cfilter << espr2;
|
||
}
|
||
}
|
||
break;
|
||
case 'R':
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
if (!totdep)
|
||
espr1.format("ANNOES|CODMAG[1,3]|%d->RAGGFIS|CODART|LIVELLO|CODMAG[4,5]",LF_ANAMAG);
|
||
else
|
||
espr1.format("ANNOES|CODMAG|%d->RAGGFIS|CODART|LIVELLO|CODMAG[4,5]",LF_ANAMAG);
|
||
_form->set_ordering(ragg_fisc);
|
||
espr2.format("CODMAG[1,3]+CODMAG[1,5]+%d->RAGGFIS", LF_ANAMAG);
|
||
_form->find_field('B',odd_page,"GRUPPI_CATMER").setcondition(espr2,_strexpr);
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition(espr2,_strexpr);
|
||
|
||
if (_mask->get(F_DARAGFIS).not_empty())
|
||
{
|
||
espr2.format("&&(%d->RAGGFIS>=\"%s\")", LF_ANAMAG, (const char*) _mask->get(F_DARAGFIS));
|
||
cfilter << espr2;
|
||
}
|
||
if (_mask->get(F_ARAGFIS).not_empty())
|
||
{
|
||
espr2.format("&&(%d->RAGGFIS<=\"%s\")", LF_ANAMAG, (const char*) _mask->get(F_ARAGFIS));
|
||
cfilter << espr2;
|
||
}
|
||
break;
|
||
default: break;
|
||
}
|
||
//_mask->set_livellicodice();
|
||
// abilita/disabilita le sezioni dei totali
|
||
_form->setdett_permag(
|
||
_mask->get_bool(F_RAGGCODICE),_mask->get_int(F_FROMLIVELLOART),_mask->get_int(F_TOLIVELLOART),
|
||
_mask->get_bool(F_RAGGLIVGIAC),_mask->get_int(F_FROMLIVELLOGIAC),_mask->get_int(F_TOLIVELLOGIAC),
|
||
TRUE,_mask->get_bool(F_TOTALIDEPOSITI),_mask->get_bool(F_DETTAGLIODEP));
|
||
|
||
((TSorted_cursor *)_cur)->change_order(espr1);
|
||
if (!totdep)
|
||
_form->find_field('B',odd_page,"GRUPPI_DEPOSITO").setcondition("CODMAG[1,3]",_strexpr);
|
||
else
|
||
_form->find_field('B',odd_page,"GRUPPI_DEPOSITO").setcondition("CODMAG[1,5]",_strexpr);
|
||
|
||
darec.put("ANNOES",_mask->get(F_ANNOES));
|
||
darec.put("CODMAG",_mask->get(F_DAMAG));
|
||
arec.put("ANNOES",_mask->get(F_ANNOES));
|
||
arec.put("CODMAG",_mask->get(F_AMAG));
|
||
_cur->setfilter(cfilter, TRUE);
|
||
_cur->setregion(darec,arec);
|
||
}
|
||
|
||
// ORDINAMENTO
|
||
void TStampa_inventario::setprint_perarticoli()
|
||
{
|
||
char subordine=*_mask->get(F_ORDINEART);
|
||
TRectype darec(LF_MAG),arec(LF_MAG);
|
||
TString cfilter, espr1, espr2;
|
||
_cur = _form->cursor();
|
||
// setta il filtro sul cursore
|
||
if (*_mask->get(F_FILTRO)=='N')
|
||
cfilter << "(GIAC!=0)&&" ;
|
||
if (*_mask->get(F_FILTRO)=='+')
|
||
cfilter << "(GIAC>0)&&" ;
|
||
if (cfilter.not_empty())
|
||
cfilter.cut(cfilter.len()-2);
|
||
|
||
switch (subordine)
|
||
{
|
||
case 'C':
|
||
case 'D':
|
||
_form->find_field('B',odd_page,"H_CATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").hide();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
espr1 = "ANNOES|CODART|LIVELLO|CODMAG";
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART",_strexpr);
|
||
_form->set_ordering(normale);
|
||
break;
|
||
case 'S':
|
||
case 'M':
|
||
{
|
||
TString16 m1,m2;
|
||
m1 = _mask->get(F_DACATMER);
|
||
m2 = _mask->get(F_ACATMER);
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
espr1.format("ANNOES|%d->GRMERC|CODART|LIVELLO|CODMAG", LF_ANAMAG);
|
||
_form->set_ordering(cat_merc);
|
||
espr2.format("%d->GRMERC[1,3]", LF_ANAMAG);
|
||
_form->find_field('B',odd_page,"GRUPPI_CATMER").setcondition(espr2,_strexpr);
|
||
if (subordine == 'S')
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").show();
|
||
m1 << _mask->get(F_DASCATMER);
|
||
m2 << _mask->get(F_ASCATMER);
|
||
m1.trim();
|
||
m2.trim();
|
||
}
|
||
else
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
}
|
||
if (m1.not_empty())
|
||
{
|
||
espr2.format("&&(%d->GRMERC>=\"%s\")", LF_ANAMAG, (const char*) m1);
|
||
cfilter << espr2;
|
||
}
|
||
if (m2.not_empty())
|
||
{
|
||
espr2.format("&&(%d->GRMERC<=\"%s\")", LF_ANAMAG, (const char*) m2);
|
||
cfilter << espr2;
|
||
}
|
||
}
|
||
break;
|
||
case 'R':
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
espr1.format("ANNOES|%d->RAGGFIS|CODART|LIVELLO|CODMAG",LF_ANAMAG);
|
||
_form->set_ordering(ragg_fisc);
|
||
espr2.format("%d->RAGGFIS", LF_ANAMAG);
|
||
_form->find_field('B',odd_page,"GRUPPI_CATMER").setcondition(espr2,_strexpr);
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition(espr2,_strexpr);
|
||
|
||
if (_mask->get(F_DARAGFIS).not_empty())
|
||
{
|
||
espr2.format("&&(%d->RAGGFIS>=\"%s\")", LF_ANAMAG, (const char*) _mask->get(F_DARAGFIS));
|
||
cfilter << espr2;
|
||
}
|
||
if (_mask->get(F_ARAGFIS).not_empty())
|
||
{
|
||
espr2.format("&&(%d->RAGGFIS<=\"%s\")", LF_ANAMAG, (const char*) _mask->get(F_ARAGFIS));
|
||
cfilter << espr2;
|
||
}
|
||
break;
|
||
default: break;
|
||
}
|
||
_form->setdett_perart(
|
||
_mask->get_bool(F_RAGGCODICE),_mask->get_int(F_FROMLIVELLOART),_mask->get_int(F_TOLIVELLOART),
|
||
_mask->get_bool(F_RAGGLIVGIAC),_mask->get_int(F_FROMLIVELLOGIAC),_mask->get_int(F_TOLIVELLOGIAC),
|
||
_mask->get_bool(F_TOTALIMAGAZZINI),_mask->get_bool(F_DETTAGLIOMAG));
|
||
|
||
((TSorted_cursor *)_cur)->change_order(espr1);
|
||
|
||
darec.put("ANNOES",_mask->get(F_ANNOES));
|
||
darec.put("CODMAG",_mask->get(F_DAMAG));
|
||
if (*_mask->get(F_DAART))
|
||
cfilter << "&&(CODART>=\"" << _mask->get(F_DAART) << "\")";
|
||
if (*_mask->get(F_AART))
|
||
cfilter << "&&(CODART<=\"" << _mask->get(F_AART) << "\")";
|
||
arec.put("ANNOES",_mask->get(F_ANNOES));
|
||
arec.put("CODMAG",_mask->get(F_AMAG));
|
||
_cur->setfilter(cfilter, subordine != 'C');
|
||
_cur->setregion(darec,arec);
|
||
}
|
||
|
||
void TStampa_inventario::setprint_perarticoli_all()
|
||
{
|
||
TRectype darec(LF_ANAMAG),arec(LF_ANAMAG);
|
||
TString cfilter,filter,joinexp;
|
||
TString sortexp("ANNOES|CODART|LIVELLO|CODMAG");
|
||
|
||
char subordine=*_mask->get(F_ORDINEART);
|
||
|
||
_cur = _form->cursor();
|
||
if (*_mask->get(F_FILTRO)=='N')
|
||
filter << "(" << LF_MAG <<"->GIAC!=0)&&" ;
|
||
if (*_mask->get(F_FILTRO)=='+')
|
||
filter << "(" << LF_MAG <<"->GIAC>0)&&" ;
|
||
if (*_mask->get(F_DAMAG))
|
||
filter << "(CODMAG[1,3]>=" <<'"' << _mask->get(F_DAMAG)<< "\")&&" ;
|
||
if (*_mask->get(F_AMAG))
|
||
filter << "(CODMAG[1,3]<=" <<'"' << _mask->get(F_AMAG)<< "\")&&" ;
|
||
if (filter.not_empty())
|
||
filter.cut(filter.len()-2);
|
||
|
||
//_mask->set_livellicodice();
|
||
switch (subordine)
|
||
{
|
||
case 'C':
|
||
_cur->setkey(1);
|
||
darec.put("CODART",_mask->get(F_DAART));
|
||
arec.put("CODART",_mask->get(F_AART));
|
||
_form->find_field('B',odd_page,"H_CATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").hide();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART",_strexpr);
|
||
_form->set_ordering(normale);
|
||
break;
|
||
case 'D':
|
||
_cur->setkey(2);
|
||
darec.put("DESCR",_mask->get(F_DADES));
|
||
arec.put("DESCR",_mask->get(F_ADES));
|
||
_form->find_field('B',odd_page,"H_CATMER").disable();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").hide();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART",_strexpr);
|
||
_form->set_ordering(normale);
|
||
break;
|
||
case 'S':
|
||
case 'M':
|
||
{
|
||
TString16 m1,m2;
|
||
m1 = _mask->get(F_DACATMER);
|
||
m2 = _mask->get(F_ACATMER);
|
||
if (subordine == 'S')
|
||
{
|
||
m1 << _mask->get(F_DASCATMER);
|
||
m2 << _mask->get(F_ASCATMER);
|
||
m1.trim();
|
||
m2.trim();
|
||
}
|
||
// Siccome GRMERC e' il primo campo della chiave, se e' settato l'articolo di fine intervallo
|
||
// ed esso non e' vuoto, mentre la categoria merc. lo e'... la setregion() del cursore non ha effetti,
|
||
// Quindi se non viene indicata alcuna categoria merc. di fine interv, va preimpostata
|
||
// Alla ultima stringa possibile
|
||
if (m2.empty() && _mask->get(F_AART).not_empty())
|
||
m2.fill('\254',subordine == 'S' ? 5 : 3);
|
||
_cur->setkey(3);
|
||
darec.put("GRMERC", m1);
|
||
darec.put("CODART",_mask->get(F_DAART));
|
||
arec.put("GRMERC", m2);
|
||
arec.put("CODART",_mask->get(F_AART));
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
if (subordine == 'S')
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").show();
|
||
}
|
||
else
|
||
{
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART",_strexpr);
|
||
}
|
||
_form->set_ordering(cat_merc);
|
||
}
|
||
break;
|
||
case 'R':
|
||
{
|
||
//TString filter_expr;
|
||
_form->set_ordering(ragg_fisc);// Setta la subsection in modo da raggruppare per RAGGFIS
|
||
_form->use_alternate_cursor();
|
||
_cur = _form->cursor(); // Setta il cursore sortato per questo ordinamento... siccome non esiste una chiave RAGGFIS+CODART
|
||
_cur->setkey(1);
|
||
darec.put("CODART",_mask->get(F_DAART));
|
||
arec.put("CODART",_mask->get(F_AART));
|
||
_form->find_field('B',odd_page,"H_CATMER").show();
|
||
_form->find_field('B',odd_page,"TOT_CATMER").show();
|
||
_form->find_field('B',odd_page,"H_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
|
||
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("RAGGFIS",_strexpr);
|
||
|
||
if (_mask->get(F_DARAGFIS).not_empty())
|
||
cfilter.format("(RAGGFIS>=\"%s\")",(const char*)_mask->get(F_DARAGFIS));
|
||
if (cfilter.not_empty() && _mask->get(F_ARAGFIS).not_empty())
|
||
{
|
||
cfilter << "&&(RAGGFIS<=\"";
|
||
cfilter << _mask->get(F_ARAGFIS);
|
||
cfilter << "\")&&";
|
||
}
|
||
_cur->setfilter(cfilter);
|
||
_cur->setregion(darec, arec);
|
||
}
|
||
break;
|
||
}
|
||
_form->setdett_perart(
|
||
_mask->get_bool(F_RAGGCODICE),_mask->get_int(F_FROMLIVELLOART),_mask->get_int(F_TOLIVELLOART),
|
||
_mask->get_bool(F_RAGGLIVGIAC),_mask->get_int(F_FROMLIVELLOGIAC),_mask->get_int(F_TOLIVELLOGIAC),
|
||
_mask->get_bool(F_TOTALIMAGAZZINI),_mask->get_bool(F_DETTAGLIOMAG));
|
||
/* if (*_mask->get(F_FILTRO)=='N')
|
||
_form->find_field('B',odd_page,"TOT_DEPOSITO").setcondition("GIAC!=0");
|
||
if (*_mask->get(F_FILTRO)=='+')
|
||
_form->find_field('B',odd_page,"TOT_DEPOSITO").setcondition("GIAC>0");
|
||
*/
|
||
|
||
|
||
joinexp << "ANNOES==" << _mask->get(F_ANNOES) << "|CODART==CODART";
|
||
|
||
TSortedfile *mag;
|
||
// !?!?!! ATTENZIONE : Modifica temporanea
|
||
mag= new TSortedfile(LF_MAG,NULL,sortexp,"",1);
|
||
// il filtro viene qui settato DOPO la creazione del Sortedfile a causa di una bug
|
||
// sulla libreria nei TSorted_file / TCursor
|
||
mag->cursor().setfilter(filter);
|
||
// FINE MODIFICA ; rimettere il filtro nel costruttore quando il bug sar<61> risolto
|
||
|
||
_cur->relation()->replace(mag,1,joinexp);
|
||
_cur->setregion(darec,arec);
|
||
}
|
||
|
||
|
||
void TStampa_inventario::main_loop()
|
||
{
|
||
while (_mask->run() == K_ENTER)
|
||
{
|
||
if (_mask->magazz_ini().gestmag(TRUE))
|
||
{
|
||
if (_mask->get(F_DAART).blank() && _mask->get(F_AART).blank() &&
|
||
_mask->get(F_DAMAG).blank() && _mask->get(F_AMAG).blank() &&
|
||
!yesno_box("Sono stati selezionati tutti gli articoli. Confermi la stampa?"))
|
||
continue;
|
||
if (*_mask->get(F_ORDINE)=='A')
|
||
{
|
||
if (*_mask->get(F_FILTRO)=='T') // tutti gli articoli
|
||
{
|
||
_form = new TForm_inventario("mg4200aa", "");
|
||
setprint_perarticoli_all();
|
||
}
|
||
else
|
||
{
|
||
_form = new TForm_inventario("mg4200a", "");
|
||
setprint_perarticoli();
|
||
}
|
||
} else {
|
||
_form = new TForm_inventario("mg4200b", "");
|
||
setprint_permagazzini();
|
||
}
|
||
_form->set_parametri(_mask->get(F_CATVENLISTINO),
|
||
_mask->get(F_CODLISTINO),
|
||
*_mask->get(F_REALE_GIAC)=='R',
|
||
*_mask->get(F_FIN_COMP)=='C' );
|
||
_form->add_colval(_mask->get_int(F_VAL1)-1);
|
||
_form->add_colval(_mask->get_int(F_VAL2)-1);
|
||
_form->add_colval(_mask->get_int(F_VAL3)-1);
|
||
_form->add_colval(_mask->get_int(F_VAL4)-1);
|
||
_form->add_colval(_mask->get_int(F_VAL5)-1);
|
||
_form->add_colval(_mask->get_int(F_VAL6)-1);
|
||
|
||
_form->genera_intestazioni(odd_page, 5);
|
||
_form->genera_intestazione_supplementare(odd_page, 4); // Nomi valorizzazioni applicate per colonna
|
||
|
||
_form->print();
|
||
delete _form;
|
||
}
|
||
} // while true
|
||
return ;
|
||
}
|
||
|
||
|
||
int mg4200(int argc, char* argv[])
|
||
{
|
||
TStampa_inventario a;
|
||
a.run(argc,argv,"Stampa inventario");
|
||
return 0;
|
||
}
|