f5e27b6add
Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 98.01.03pl015 git-svn-id: svn://10.65.10.50/trunk@6577 c028cbd2-c16b-5b4b-a496-9718f37d4682
638 lines
20 KiB
C++
Executable File
638 lines
20 KiB
C++
Executable File
#include <applicat.h>
|
|
|
|
#include "movmag.h"
|
|
#include "rmovmag.h"
|
|
|
|
#include "mglib.h"
|
|
#include "mg3300.h"
|
|
|
|
#ifndef __CGLIB01_H
|
|
#include "..\cg\cglib01.h"
|
|
#endif
|
|
|
|
|
|
class TForm_schedemag : public TForm_stampemg
|
|
{
|
|
TRecord_cache * _causali_mag;
|
|
int _tolivgiac,_tolivart;
|
|
TString16 _anno_prec;
|
|
bool _magazzino_chiuso;
|
|
bool _sottocatmer;
|
|
|
|
TToken_string *_rmov_sortexp;
|
|
TString *_rmov_raggcond,*_rmov_joinexp;
|
|
|
|
//TMag_livelli * _giaclev,*_artlev; // gestori dei gruppi articolo/giacenza
|
|
//TDecoder *_giacgrp,*_artgrp; // decodifiche dei gruppi articolo/giacenza
|
|
TTipo_saldomag _tiposcheda; // tipo scheda
|
|
|
|
bool ragg_exprs(int livart,int livgiac);
|
|
public:
|
|
TToken_string& rmov_sortexp() {return *_rmov_sortexp;}
|
|
TString & rmov_joinexp() {return *_rmov_joinexp;}
|
|
|
|
void set_tiposcheda(const char * tipo);
|
|
void set_chiusura_mag(const int val);
|
|
bool validate(TForm_item &cf, TToken_string &s);
|
|
void setdett_perart(bool percatmer, bool sottocatmer,int livart,int livgiac,bool sudd_mag, bool sudd_dep);
|
|
void setdett_percatmer(bool sottocat,int livart,int livgiac,bool sudd_mag,bool sudd_dep);
|
|
void setdett_permag(bool sudd_dep, bool showdett,int livart,int livgiac);
|
|
TString descr_tiposcheda();
|
|
TString nomecampo_scheda();
|
|
|
|
TForm_schedemag(const char *name,const char *code) ;
|
|
virtual ~TForm_schedemag();
|
|
};
|
|
|
|
TString TForm_schedemag::descr_tiposcheda()
|
|
{
|
|
switch (_tiposcheda)
|
|
{
|
|
case s_giac:
|
|
return ("Giacenza");
|
|
case s_acl:
|
|
return ("A conto lavoro");
|
|
case s_incl:
|
|
return ("In conto lavoro");
|
|
case s_prodc:
|
|
return ("In produzione componenti");
|
|
case s_prodf:
|
|
return ("In produzione finiti");
|
|
case s_ordc:
|
|
return ("Ordinato clienti");
|
|
case s_ordf:
|
|
return ("Ordinato fornitori");
|
|
}
|
|
return "";
|
|
}
|
|
|
|
TString TForm_schedemag::nomecampo_scheda()
|
|
{
|
|
switch (_tiposcheda)
|
|
{
|
|
case s_giac:
|
|
return (MAG_GIAC);
|
|
case s_acl:
|
|
return (MAG_ACL);
|
|
case s_incl:
|
|
return (MAG_INCL);
|
|
case s_prodc:
|
|
return (MAG_PRODCOMP);
|
|
case s_prodf:
|
|
return (MAG_PRODFIN);
|
|
case s_ordc:
|
|
return (MAG_ORDC);
|
|
case s_ordf:
|
|
return (MAG_ORDF);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
bool TForm_schedemag::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") {
|
|
subcode=s.get();
|
|
if (subcode=="TIPOSCHEDA") {
|
|
cf.set(descr_tiposcheda());
|
|
return TRUE;
|
|
}
|
|
if (subcode=="CODGRUPPOART") {
|
|
TString valore(relation()->lfile(LF_ANAMAG).get("CODART"));
|
|
if (artlev().enabled())
|
|
valore.cut(min(valore.len(),artlev().packed_length(_tolivart)));
|
|
cf.set(valore);
|
|
return TRUE;
|
|
}
|
|
if (subcode=="GRUPPOART") {
|
|
TString valore;
|
|
if (_tolivart==artlev().last_level())
|
|
valore=relation()->lfile(LF_ANAMAG).get("DESCR");
|
|
else
|
|
valore=artlev().group_descr(relation()->lfile(LF_ANAMAG).get("CODART"),_tolivart);
|
|
cf.set(valore);
|
|
return TRUE;
|
|
}
|
|
if (subcode=="CODGRUPPOGIAC") {
|
|
TString levname(giaclev().name(_tolivgiac)),valore;
|
|
int lv=0;
|
|
valore="";
|
|
do {
|
|
TString piece(giaclev().unpack_grpcode(relation()->lfile(LF_RMOVMAG).get("LIVGIAC"),lv+1));
|
|
if (piece.empty())
|
|
piece=UNKNOWN_NAME;
|
|
if (valore.not_empty())
|
|
valore << '/';
|
|
valore << piece ;
|
|
} while (++lv<_tolivgiac);
|
|
cf.set(levname << ' ' << valore);
|
|
}
|
|
if (subcode=="GRUPPOGIAC") {
|
|
TString valore;
|
|
valore=giaclev().group_descr(relation()->lfile(LF_RMOVMAG).get("LIVGIAC"),_tolivgiac);
|
|
cf.set(valore);
|
|
return TRUE;
|
|
}
|
|
if (subcode=="CODCATMER") {
|
|
TString valore(relation()->lfile(LF_ANAMAG).get("GRMERC"));
|
|
if (!_sottocatmer)
|
|
valore.cut(3);
|
|
cf.set(valore);
|
|
return TRUE;
|
|
}
|
|
if (subcode=="CATMER") {
|
|
TString valore;
|
|
if (_sottocatmer)
|
|
valore=relation()->lfile(-ALIAS_SOTTOCATMER).get("S0");
|
|
else
|
|
valore=relation()->lfile(-ALIAS_CATMER).get("S0");
|
|
cf.set(valore);
|
|
return TRUE;
|
|
}
|
|
TCausale_magazzino &cau_r=(TCausale_magazzino &)_causali_mag->get(relation()->lfile(LF_RMOVMAG).get(RMOVMAG_CODCAUS));
|
|
TCausale_magazzino &cau_m=(TCausale_magazzino &)_causali_mag->get(relation()->lfile(LF_MOVMAG).get(MOVMAG_CODCAUS));
|
|
TCausale_magazzino &cau=(cau_r.codice().blank() ? cau_m : cau_r);
|
|
if (subcode=="*SEGNOCAUS") {
|
|
real v(cf.get());
|
|
v=v*cau.sgn(_tiposcheda) ;
|
|
cf.set(v.string());
|
|
return TRUE;
|
|
}
|
|
if (subcode=="CAUSALERIGA") {
|
|
cf.set(cau.codice());
|
|
return TRUE;
|
|
}
|
|
if (subcode=="DESCRCAUSALE") {
|
|
cf.set(cau.descr());
|
|
return TRUE;
|
|
}
|
|
if (subcode=="SALDOPREC") {
|
|
if (!_magazzino_chiuso) // mag precedente non chiuso, mancano i saldi di apertura
|
|
{
|
|
TLocalisamfile _mag_annoprec(LF_MAG);
|
|
_mag_annoprec.curr() = cursor()->relation()->lfile(LF_MAG).curr();
|
|
_mag_annoprec.put(MAG_ANNOES, _anno_prec);
|
|
_mag_annoprec.read();
|
|
real valsaldo = _mag_annoprec.get_real(nomecampo_scheda());
|
|
cf.set(valsaldo.string());
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
return TForm::validate(cf, s);
|
|
}
|
|
|
|
|
|
bool TForm_schedemag::ragg_exprs(int livart,int livgiac)
|
|
{
|
|
TString piece,rest;
|
|
// ***********
|
|
int tolivart,tolivgiac;
|
|
|
|
tolivart =livart ? livart : artlev().last_level() ;
|
|
tolivgiac=livgiac ? livgiac : giaclev().last_level();
|
|
// sezioni livello codice
|
|
piece="CODART";
|
|
if (artlev().enabled())
|
|
piece << "[1," << artlev().packed_length(tolivart) <<']';
|
|
*_rmov_raggcond<< (_rmov_raggcond->empty()? "":"+" )<<piece;
|
|
_rmov_sortexp->add(piece);
|
|
_rmov_joinexp->cut(0) << piece << "==" << piece;
|
|
if (livart==0)
|
|
{
|
|
piece="LIVGIAC";
|
|
if (giaclev().enabled())
|
|
piece << "[1," << giaclev().packed_length(tolivgiac) <<']';
|
|
*_rmov_raggcond << '+' << piece;
|
|
_rmov_sortexp->add(piece);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void TForm_schedemag::setdett_percatmer(bool sottocat,int livart,int livgiac,bool sudd_mag,bool sudd_dep)
|
|
{
|
|
TForm_subsection &h_c=(TForm_subsection &)find_field('B',odd_page,"HEADER_CATMER");
|
|
h_c.enable();
|
|
TForm_subsection &h_a=(TForm_subsection &)find_field('B',odd_page,"HEADER_ARTICOLO");
|
|
h_a.enable();
|
|
TForm_subsection &h_g=(TForm_subsection &)find_field('B',odd_page,"HEADER_GRMOV");
|
|
h_g.enable((livart ==0 || livgiac !=0 || sudd_mag));
|
|
TForm_subsection &h_l=(TForm_subsection &)find_field('B',odd_page,"HEADER_LIVGIAC");
|
|
h_l.enable(giaclev().enabled() && livgiac !=0 );
|
|
TForm_subsection &h_m=(TForm_subsection &)find_field('B',odd_page,"HEADER_MAG");
|
|
h_m.enable(sudd_mag );
|
|
TForm_subsection &h_d=(TForm_subsection &)find_field('B',odd_page,"HEADER_DEP");
|
|
h_d.enable(sudd_dep);
|
|
|
|
TString piece;
|
|
piece << LF_ANAMAG << "->GRMERC";
|
|
if (!sottocat)
|
|
piece << "[1,3]";
|
|
|
|
*_rmov_raggcond=piece;
|
|
_rmov_sortexp->add(piece);
|
|
|
|
ragg_exprs(livart,livgiac);
|
|
if (sudd_mag) {
|
|
*_rmov_raggcond="+CODMAG[1,3]";
|
|
_rmov_sortexp->add("CODMAG[1,3]");
|
|
if (sudd_dep) {
|
|
*_rmov_raggcond << "+CODMAG[4,5]";
|
|
_rmov_sortexp->add("CODMAG[4,5]");
|
|
}
|
|
}
|
|
|
|
TForm_subsection &s=(TForm_subsection &)find_field('B',odd_page,"GRUPPI_RMOVMAG");
|
|
s.setcondition(*_rmov_raggcond,_strexpr);
|
|
|
|
TString cond;
|
|
cond << LF_MOVMAG << "->DATAREG";
|
|
_rmov_sortexp->add(cond);
|
|
_rmov_sortexp->add("NUMREG");
|
|
|
|
_tolivart=livart ? livart :artlev().last_level() ;
|
|
_tolivgiac=livgiac ? livgiac :giaclev().last_level();
|
|
_sottocatmer=sottocat;
|
|
}
|
|
|
|
void TForm_schedemag::setdett_permag(bool sudd_dep,bool show_dett,int livart,int livgiac)
|
|
{
|
|
TForm_subsection &h_d=(TForm_subsection &)find_field('B',odd_page,"HEADER_DEP");
|
|
h_d.enable(sudd_dep);
|
|
TForm_subsection &h_a=(TForm_subsection &)find_field('B',odd_page,"HEADER_ARTICOLO");
|
|
h_a.enable(show_dett);
|
|
TForm_subsection &h_g=(TForm_subsection &)find_field('B',odd_page,"HEADER_LIVGIAC");
|
|
h_g.enable(giaclev().enabled() && (livart ==0 || livgiac !=0 ));
|
|
|
|
*_rmov_raggcond="CODMAG[1,3]";
|
|
_rmov_sortexp->add("CODMAG[1,3]");
|
|
if (sudd_dep)
|
|
{
|
|
*_rmov_raggcond << "+CODMAG[4,5]";
|
|
_rmov_sortexp->add("CODMAG[4,5]");
|
|
if (show_dett)
|
|
{
|
|
ragg_exprs(livart,livgiac);
|
|
}
|
|
}
|
|
|
|
TForm_subsection &s=(TForm_subsection &)find_field('B',odd_page,"GRUPPI_RMOVMAG");
|
|
s.setcondition(*_rmov_raggcond,_strexpr);
|
|
|
|
TString cond;
|
|
cond << LF_MOVMAG << "->DATAREG";
|
|
_rmov_sortexp->add(cond);
|
|
_rmov_sortexp->add("NUMREG");
|
|
|
|
_tolivart=livart ? livart :artlev().last_level() ;
|
|
_tolivgiac=livgiac ? livgiac :giaclev().last_level();
|
|
}
|
|
|
|
void TForm_schedemag::setdett_perart(bool percatmer,bool sottocatmer,int livart,int livgiac,bool sudd_mag,bool sudd_dep)
|
|
{
|
|
// raggruppamento MAX fino all'articolo
|
|
TForm_subsection &h_cm=(TForm_subsection &)find_field('B',odd_page,"HEADER_CATMER");
|
|
h_cm.enable(percatmer);
|
|
TForm_subsection &h_cm2=(TForm_subsection &)find_field('B',odd_page,"HEADER_LIVGIACCATMER");
|
|
h_cm2.enable(percatmer);
|
|
|
|
TForm_subsection &h_a=(TForm_subsection &)find_field('B',odd_page,"HEADER_ARTICOLO");
|
|
h_a.enable(livart!=0 && !sudd_mag);
|
|
TForm_subsection &t_a=(TForm_subsection &)find_field('B',odd_page,"TOTALI_GRUPPIART");
|
|
t_a.show( livart!=0 && !sudd_mag);
|
|
|
|
// raggruppamento MAX fino alla giacenza
|
|
TForm_subsection &h_g=(TForm_subsection &)find_field('B',odd_page,"HEADER_GRMOV");
|
|
h_g.enable((livart !=0 || livgiac !=0 || sudd_mag));
|
|
TForm_subsection &h_l=(TForm_subsection &)find_field('B',odd_page,"HEADER_LIVGIAC");
|
|
h_l.enable(giaclev().enabled() && (livart ==0 || livgiac !=0 ));
|
|
TForm_subsection &h_m=(TForm_subsection &)find_field('B',odd_page,"HEADER_MAG");
|
|
h_m.enable(sudd_mag );
|
|
TForm_subsection &h_d=(TForm_subsection &)find_field('B',odd_page,"HEADER_DEP");
|
|
h_d.enable(sudd_dep);
|
|
|
|
TForm_subsection &t_s=(TForm_subsection &)find_field('B',odd_page,"TOTALI_GRMOV");
|
|
t_s.show(livart==0 || livgiac !=0 || sudd_mag);
|
|
|
|
_tolivart=livart ? livart :artlev().last_level() ;
|
|
_tolivgiac=livgiac ? livgiac :giaclev().last_level();
|
|
_sottocatmer=sottocatmer;
|
|
|
|
// settaggio catmer/ragg codice
|
|
if (livart || percatmer) {
|
|
TForm_subsection &s=(TForm_subsection &)find_field('B',odd_page,"GRUPPI_ARTICOLO");
|
|
TString catmercod("GRMERC"),cond;
|
|
if (percatmer) {
|
|
catmercod << (sottocatmer ? "[1,3]" :"");
|
|
cond << catmercod << '+';
|
|
}
|
|
cond << "CODART[1," << artlev().packed_length(_tolivart) << ']';
|
|
s.setcondition(cond,_strexpr);
|
|
}
|
|
// settaggio raggruppamenti codice sulla scheda
|
|
ragg_exprs(livart,livgiac);
|
|
if (sudd_mag) {
|
|
*_rmov_raggcond << "+CODMAG[1,3]";
|
|
_rmov_sortexp->add("CODMAG[1,3]");
|
|
if (sudd_dep)
|
|
{
|
|
*_rmov_raggcond << "+CODMAG[4,5]";
|
|
_rmov_sortexp->add("CODMAG[4,5]");
|
|
}
|
|
}
|
|
TForm_subsection &s=(TForm_subsection &)find_field('B',odd_page,"GRUPPI_RMOVMAG");
|
|
s.setcondition(*_rmov_raggcond,_strexpr);
|
|
TString cond;
|
|
cond << LF_MOVMAG << "->DATAREG";
|
|
_rmov_sortexp->add(cond);
|
|
_rmov_sortexp->add("NUMREG");
|
|
}
|
|
|
|
void TForm_schedemag::set_tiposcheda(const char * tipo)
|
|
{
|
|
if (*tipo=='G')
|
|
_tiposcheda=s_giac;
|
|
if (*tipo=='A')
|
|
_tiposcheda=s_acl;
|
|
if (*tipo=='I')
|
|
_tiposcheda=s_incl;
|
|
if (*tipo=='P')
|
|
{
|
|
if (tipo[1]=='F')
|
|
_tiposcheda=s_prodf;
|
|
else
|
|
_tiposcheda=s_prodc;
|
|
}
|
|
if (*tipo=='O')
|
|
{
|
|
if (tipo[1]=='F')
|
|
_tiposcheda=s_ordf;
|
|
else
|
|
_tiposcheda=s_ordc;
|
|
}
|
|
}
|
|
|
|
void TForm_schedemag::set_chiusura_mag(const int anno)
|
|
{
|
|
TEsercizi_contabili ec;
|
|
|
|
_anno_prec.format("%4d",ec.pred(anno));
|
|
_magazzino_chiuso = (ec.pred(anno) == 0) || !(ec.esercizio(atoi(_anno_prec)).chiusura_mag().empty());
|
|
}
|
|
|
|
TForm_schedemag::TForm_schedemag(const char *name,const char *code) :
|
|
TForm_stampemg(name,code)
|
|
{
|
|
_causali_mag=new TRecord_cache("%CAU");
|
|
_tolivgiac=0;
|
|
_tolivart=0;
|
|
|
|
_rmov_sortexp=new TToken_string;
|
|
_rmov_joinexp=new TString;
|
|
_rmov_raggcond=new TString;
|
|
}
|
|
|
|
TForm_schedemag::~TForm_schedemag()
|
|
{
|
|
delete _rmov_sortexp;
|
|
delete _rmov_joinexp;
|
|
delete _rmov_raggcond;
|
|
delete _causali_mag;
|
|
}
|
|
|
|
|
|
// mg3300 Stampa
|
|
// mg3300 Stampa
|
|
class TStampa_schede_mag : public TSkeleton_application
|
|
{
|
|
TArray * _files;
|
|
TStampemg_mask * _mask;
|
|
TCursor * _cur;
|
|
TForm_schedemag *_form; // to be moved into TPrint_application
|
|
|
|
int _codicees;
|
|
bool _raggmag;
|
|
protected:
|
|
void setprint_perarticoli();
|
|
void setprint_permagazzini();
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual void main_loop();
|
|
|
|
public:
|
|
TStampa_schede_mag() {}
|
|
};
|
|
|
|
|
|
void TStampa_schede_mag::setprint_permagazzini()
|
|
{
|
|
char subordine=*_mask->get(F_ORDINEART);
|
|
TRectype darec(LF_RMOVMAG),arec(LF_RMOVMAG);
|
|
TString cfilter;
|
|
|
|
_form->set_tiposcheda(_mask->get(F_SCHEDA));
|
|
_cur = _form->cursor();
|
|
// filtering from/to MAGS
|
|
if (*_mask->get(F_DAMAG))
|
|
cfilter << "(CODMAG[1,3]>=" <<'"' << _mask->get(F_DAMAG)<< "\")&&" ;
|
|
if (*_mask->get(F_AMAG))
|
|
cfilter << "(CODMAG[1,3]<=" <<'"' << _mask->get(F_AMAG)<< "\")&&" ;
|
|
cfilter << "(" << LF_MOVMAG <<"->ANNOES==" <<'"' << _mask->get(F_ANNOES)<< "\")&&" ;
|
|
// filtering from/to DATA
|
|
if (*_mask->get(F_ADATA))
|
|
{
|
|
TDate d1(_mask->get(F_ADATA));
|
|
cfilter << "(ANSI(110->DATAREG)<=" <<'"' << d1.string(ANSI) << "\")&&" ;
|
|
}
|
|
if (*_mask->get(F_DADATA))
|
|
{
|
|
TDate d1(_mask->get(F_DADATA));
|
|
TString cond;
|
|
cond << "ANSI(" << LF_MOVMAG << "->DATAREG)>=\"" << d1.string(ANSI) << '"';
|
|
((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_INTERESSATI")).setcondition(cond,_strexpr);
|
|
cond.cut(0) << "ANSI(" << LF_MOVMAG << "->DATAREG)<\"" << d1.string(ANSI) << '"';
|
|
((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_PRECEDENTI")).setcondition(cond,_strexpr);
|
|
}
|
|
|
|
// Imposta i livelli di dettaglio della scheda
|
|
_form->setdett_permag(
|
|
_mask->get_bool(F_DETTAGLIOMAG),
|
|
_mask->get_bool(F_DETTAGLIODEP),
|
|
_mask->get_int(F_TOLIVELLOART),
|
|
_mask->get_int(F_TOLIVELLOGIAC));
|
|
|
|
// filtering from/to ART
|
|
darec.put("CODART",_mask->get(F_DAART));
|
|
arec.put("CODART",_mask->get(F_AART));
|
|
// filtering ONLY NEGATIVES
|
|
if (*_mask->get(F_FILTRO)=='N') {
|
|
TForm_subsection &s=((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_PRECEDENTI"));
|
|
TString cond;
|
|
cond << '(' << s.condition() << ")&&(STR("<< LF_MAG << "->" << _form->nomecampo_scheda() << "<0))";
|
|
s.setcondition(cond,_strexpr);
|
|
TForm_subsection &s2=((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_INTERESSATI"));
|
|
cond.cut(0) << '(' << s2.condition() << ")&&(STR("<< LF_MAG << "->" << _form->nomecampo_scheda() << "<0))";
|
|
s2.setcondition(cond,_strexpr);
|
|
}
|
|
// prepare cursor to print....
|
|
((TSorted_cursor *)_cur)->change_order(_form->rmov_sortexp());
|
|
if (cfilter.not_empty())
|
|
cfilter.cut(cfilter.len()-2);
|
|
|
|
TLocalisamfile *mag=new TLocalisamfile(LF_MAG);
|
|
mag->setkey(2);
|
|
TString mag_joinexp;
|
|
mag_joinexp << "ANNOES==" << _mask->get(F_ANNOES) << "|CODMAG==CODMAG|CODART==CODART|LIVELLO==LIVGIAC";
|
|
_cur->relation()->replace(mag,1,mag_joinexp);
|
|
_cur->setfilter(cfilter,TRUE);
|
|
_cur->setregion(darec,arec);
|
|
}
|
|
|
|
// ORDINAMENTO per articoli
|
|
void TStampa_schede_mag::setprint_perarticoli()
|
|
{
|
|
TRectype darec(LF_ANAMAG),arec(LF_ANAMAG);
|
|
TString cfilter,filter;
|
|
|
|
_form->set_tiposcheda(_mask->get(F_SCHEDA));
|
|
char subordine=*_mask->get(F_ORDINEART);
|
|
_cur = _form->cursor();
|
|
// filtering ANNOES
|
|
filter << '(' << LF_MOVMAG << "->ANNOES==" << _mask->get(F_ANNOES)<< ")&&" ;
|
|
// filtering from/to MAGS
|
|
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)<< "\")&&" ;
|
|
// filtering from/to DATA
|
|
if (*_mask->get(F_DADATA))
|
|
{
|
|
TDate d1(_mask->get(F_DADATA));
|
|
TString cond;
|
|
cond << "ANSI(" << LF_MOVMAG << "->DATAREG)>=\"" << d1.string(ANSI) << '"';
|
|
((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_INTERESSATI")).setcondition(cond,_strexpr);
|
|
cond.cut(0) << "ANSI(" << LF_MOVMAG << "->DATAREG)<\"" << d1.string(ANSI) << '"';
|
|
((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_PRECEDENTI")).setcondition(cond,_strexpr);
|
|
}
|
|
if (*_mask->get(F_ADATA))
|
|
{
|
|
TDate d1(_mask->get(F_ADATA));
|
|
filter << "(ANSI(110->DATAREG)<=" <<'"' << d1.string(ANSI) << "\")&&" ;
|
|
}
|
|
// filtering ONLY NEGATIVES
|
|
if (*_mask->get(F_FILTRO)=='N') {
|
|
TForm_subsection &s=((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_PRECEDENTI"));
|
|
TString cond;
|
|
cond << '(' << s.condition() << ")&&(STR("<< LF_MAG << "->" << _form->nomecampo_scheda() << "<0))";
|
|
s.setcondition(cond,_strexpr);
|
|
TForm_subsection &s2=((TForm_subsection &)_form->find_field('B',odd_page,"MOVS_INTERESSATI"));
|
|
cond.cut(0) << '(' << s2.condition() << ")&&(STR("<< LF_MAG << "->" << _form->nomecampo_scheda() << "<0))";
|
|
s2.setcondition(cond,_strexpr);
|
|
}
|
|
// Imposta i livelli di dettaglio della scheda
|
|
switch (subordine)
|
|
{
|
|
case 'C':
|
|
_cur->setkey(1);
|
|
darec.put("CODART",_mask->get(F_DAART));
|
|
arec.put("CODART",_mask->get(F_AART));
|
|
_form->setdett_perart(FALSE,FALSE,
|
|
_mask->get_int(F_TOLIVELLOART),
|
|
_mask->get_int(F_TOLIVELLOGIAC),
|
|
_mask->get_bool(F_SUDDIV_MAGAZZINI),
|
|
_mask->get_bool(F_SUDDIV_DEPOSITI));
|
|
break;
|
|
case 'D':
|
|
_cur->setkey(2);
|
|
darec.put("DESCR",_mask->get(F_DADES));
|
|
arec.put("DESCR",_mask->get(F_ADES));
|
|
_form->setdett_perart(FALSE,FALSE,
|
|
_mask->get_int(F_TOLIVELLOART),
|
|
_mask->get_int(F_TOLIVELLOGIAC),
|
|
_mask->get_bool(F_SUDDIV_MAGAZZINI),
|
|
_mask->get_bool(F_SUDDIV_DEPOSITI));
|
|
case 'M':
|
|
_cur->setkey(3);
|
|
darec.put("GRMERC",_mask->get(F_DACATMER));
|
|
arec.put("GRMERC",_mask->get(F_ACATMER));
|
|
if (*_mask->get(F_AART))
|
|
cfilter << "(CODART<=" <<'"' << _mask->get(F_AART)<< TString(20,(char)127)<< "\")&&" ;
|
|
if (*_mask->get(F_DAART))
|
|
cfilter << "(CODART>=" <<'"' << _mask->get(F_DAART) << "\")&&" ;
|
|
_form->setdett_perart(TRUE,FALSE,
|
|
_mask->get_int(F_TOLIVELLOART),
|
|
_mask->get_int(F_TOLIVELLOGIAC),
|
|
_mask->get_bool(F_SUDDIV_MAGAZZINI),
|
|
_mask->get_bool(F_SUDDIV_DEPOSITI));
|
|
break;
|
|
}
|
|
// prepare cursor's relation....
|
|
TRelation *aux=new TRelation (LF_RMOVMAG);
|
|
aux->add(LF_MOVMAG,"NUMREG==NUMREG");
|
|
if (filter.not_empty()) filter.cut(filter.len()-2);
|
|
TSortedfile *rmovmag= new TSortedfile(LF_RMOVMAG,aux,_form->rmov_sortexp(),filter,2);
|
|
_cur->relation()->replace(rmovmag,1,_form->rmov_joinexp());
|
|
|
|
TLocalisamfile *mag=new TLocalisamfile(LF_MAG);
|
|
mag->setkey(2);
|
|
TString mag_joinexp;
|
|
mag_joinexp << "ANNOES==" << _mask->get(F_ANNOES) << "|CODMAG==CODMAG|CODART==CODART|LIVELLO==LIVGIAC";
|
|
_cur->relation()->replace(mag,2,mag_joinexp);
|
|
|
|
if (cfilter.not_empty()) cfilter.cut(cfilter.len()-2);
|
|
_cur->setfilter(cfilter);
|
|
_cur->setregion(darec,arec);
|
|
}
|
|
|
|
|
|
void TStampa_schede_mag::main_loop()
|
|
{
|
|
while (_mask->run() == K_ENTER)
|
|
{
|
|
if (_mask->magazz_ini().gestmag(TRUE))
|
|
{
|
|
if (*_mask->get(F_ORDINE)=='A')
|
|
{
|
|
_form = new TForm_schedemag("mg3300a", "");
|
|
setprint_perarticoli();
|
|
} else if (*_mask->get(F_ORDINE)=='M') {
|
|
_form = new TForm_schedemag("mg3300b", "");
|
|
setprint_permagazzini();
|
|
}
|
|
_form->set_chiusura_mag(_mask->get_int(F_ANNOES));
|
|
|
|
_form->print();
|
|
delete _form;
|
|
}
|
|
} // while true
|
|
return ;
|
|
}
|
|
bool TStampa_schede_mag::create()
|
|
{
|
|
_mask = new TStampemg_mask("mg3300");
|
|
_files= new TArray;
|
|
_files->add(new TLocalisamfile(LF_RMOVMAG));
|
|
_files->add(new TLocalisamfile(LF_MOVMAG));
|
|
_files->add(new TLocalisamfile(LF_MAG));
|
|
_files->add(new TLocalisamfile(LF_TABCOM));
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TStampa_schede_mag::destroy()
|
|
{
|
|
delete _files;
|
|
delete _mask;
|
|
return TSkeleton_application::destroy();
|
|
}
|
|
|
|
int mg3300(int argc, char* argv[])
|
|
{
|
|
TStampa_schede_mag a;// derivata da Application e con uso di form
|
|
a.run(argc,argv,"Stampa schede di magazzino");
|
|
return 0;
|
|
}
|