666 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			666 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <config.h>
 | 
						|
#include <mask.h>   
 | 
						|
#include <printer.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <urldefid.h>
 | 
						|
#include <utility.h>
 | 
						|
#include <form.h>
 | 
						|
#include <printapp.h>
 | 
						|
 | 
						|
#include "mglib.h"
 | 
						|
#include "mg3300.h"
 | 
						|
 | 
						|
class TForm_schedemag : public TForm
 | 
						|
{	
 | 
						|
	int _tolivgiac,_tolivart;
 | 
						|
	bool _sottocatmer;
 | 
						|
 | 
						|
	TToken_string *_rmov_sortexp;
 | 
						|
	TString *_rmov_raggcond,*_rmov_joinexp;
 | 
						|
 | 
						|
	TCausale_magazzino * _cau;				// causale di magazzino del movimento corrente
 | 
						|
	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);
 | 
						|
	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_tiposcheda();
 | 
						|
 | 
						|
	TForm_schedemag(const char *name,const char *code) ;
 | 
						|
	~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_tiposcheda()
 | 
						|
{
 | 
						|
	switch (_tiposcheda)
 | 
						|
	{
 | 
						|
		case s_giac:
 | 
						|
			return ("GIAC");
 | 
						|
		case s_acl:
 | 
						|
			return ("ACL");
 | 
						|
		case s_incl:
 | 
						|
			return ("INCL");
 | 
						|
		case s_prodc:
 | 
						|
			return ("PRODCOMP");
 | 
						|
		case s_prodf:
 | 
						|
			return ("PRODFIN");
 | 
						|
		case s_ordc:
 | 
						|
			return ("ORDC");
 | 
						|
		case s_ordf:
 | 
						|
			return ("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=="*SEGNOCAUS") {
 | 
						|
			real v(cf.get());
 | 
						|
			v=v*_cau->sgn(_tiposcheda);
 | 
						|
			cf.set(v.string());
 | 
						|
	  	return TRUE;
 | 
						|
  	}
 | 
						|
  	if (subcode=="TIPOSCHEDA") {
 | 
						|
 			cf.set(descr_tiposcheda());
 | 
						|
	  	return TRUE;
 | 
						|
  	}
 | 
						|
  	if (subcode=="CODGRUPPOART") {
 | 
						|
 			TString valore(relation()->lfile(LF_ANAMAG).get("CODART"));
 | 
						|
 			cf.set(valore.cut(min(valore.len(),_artlev->packed_lenght(_tolivart))));
 | 
						|
	  	return TRUE;
 | 
						|
  	}
 | 
						|
  	if (subcode=="GRUPPOART") {
 | 
						|
 			TString valore;
 | 
						|
 			if (_tolivart==_artlev->last_level())
 | 
						|
 				valore=relation()->lfile(LF_ANAMAG).get("DESCR");
 | 
						|
			else
 | 
						|
 				valore=(_artgrp->decode(_artlev->build_tabcode(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=_giacgrp->decode(_giaclev->build_tabcode(relation()->lfile(LF_RMOVMAG).get("LIVGIAC"),_tolivgiac));
 | 
						|
			cf.set(valore);
 | 
						|
			return TRUE;
 | 
						|
		}  
 | 
						|
  	if (subcode=="SETCAUSALE") {
 | 
						|
			if (_cau) delete _cau;
 | 
						|
			_cau = new TCausale_magazzino(cf.get());
 | 
						|
			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;
 | 
						|
		}  
 | 
						|
  }
 | 
						|
  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";
 | 
						|
	piece << "[1," << _artlev->packed_lenght(tolivart) <<']';
 | 
						|
	*_rmov_raggcond<< (_rmov_raggcond->empty()? "":"+" )<<piece;
 | 
						|
	_rmov_sortexp->add(piece);
 | 
						|
	_rmov_joinexp->cut(0) << piece << "==" << piece;
 | 
						|
	if (livart==0)
 | 
						|
	{
 | 
						|
		piece="LIVGIAC";
 | 
						|
		piece << "[1," << _giaclev->packed_lenght(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_LIVGIAC");
 | 
						|
	h_g.enable((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);
 | 
						|
 | 
						|
	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((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);
 | 
						|
	TForm_subsection &t_a=(TForm_subsection &)find_field('B',odd_page,"TOTALI_GRUPPIART");
 | 
						|
	t_a.show(livart!=0);
 | 
						|
 | 
						|
	// raggruppamento MAX fino alla giacenza
 | 
						|
	TForm_subsection &h_g=(TForm_subsection &)find_field('B',odd_page,"HEADER_LIVGIAC");
 | 
						|
	h_g.enable((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);
 | 
						|
 | 
						|
	_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_lenght(_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;
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
TForm_schedemag::TForm_schedemag(const char *name,const char *code) :
 | 
						|
	TForm(name,code)
 | 
						|
{
 | 
						|
	_giaclev= new TMag_livelli("FCG");
 | 
						|
	_artlev= new TMag_livelli("FCA"); 
 | 
						|
	_giacgrp= new TDecoder("GCG");
 | 
						|
	_artgrp= new TDecoder("GCA");
 | 
						|
	_cau=NULL;
 | 
						|
	_tolivgiac=0;
 | 
						|
	_tolivart=0;
 | 
						|
 | 
						|
	_rmov_sortexp=new TToken_string;
 | 
						|
	_rmov_joinexp=new TString;
 | 
						|
	_rmov_raggcond=new TString;
 | 
						|
}
 | 
						|
 | 
						|
TForm_schedemag::~TForm_schedemag()
 | 
						|
{
 | 
						|
	delete _giaclev;
 | 
						|
	delete _artlev;
 | 
						|
	delete _giacgrp;
 | 
						|
	delete _artgrp;
 | 
						|
	delete _rmov_sortexp;
 | 
						|
	delete _rmov_joinexp;
 | 
						|
	delete _rmov_raggcond;
 | 
						|
	if (_cau) delete _cau;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
// mg3300       Stampa 
 | 
						|
// mg3300       Stampa 
 | 
						|
class TStampa_schede_mag : public TPrint_application
 | 
						|
{
 | 
						|
	TArray * _files;
 | 
						|
	TMask * _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 print_one(int file);  
 | 
						|
  virtual bool user_create();
 | 
						|
  virtual bool user_destroy();
 | 
						|
  virtual bool set_print(int i=1);
 | 
						|
	
 | 
						|
public:
 | 
						|
  TStampa_schede_mag() {}
 | 
						|
};
 | 
						|
 | 
						|
/*void TStampa_schede_mag::setprint_percatmer()
 | 
						|
{
 | 
						|
  char subordine=*_mask->get(F_ORDINEART);
 | 
						|
  TRectype darec(LF_RMOVMAG),arec(LF_RMOVMAG);
 | 
						|
  TString cfilter;
 | 
						|
 | 
						|
  _cur = _form->cursor();
 | 
						|
	// setta il filtro sul cursore
 | 
						|
	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)<< "\")&&" ;
 | 
						|
	TString catmercode("GRMERC");
 | 
						|
	if (!FALSE)
 | 
						|
		catmercode << "[1,3]";
 | 
						|
	if (*_mask->get(F_DACATMER))
 | 
						|
		cfilter << "(" << LF_ANAMAG << "->" <<catmercode << ">=" <<'"' << _mask->get(F_DACATMER)<< "\")&&" ;
 | 
						|
	if (*_mask->get(F_ACATMER))
 | 
						|
		cfilter << "("<< LF_ANAMAG << "->" << catmercode <<"<=" <<'"' << _mask->get(F_ACATMER)<< "\")&&" ;
 | 
						|
 | 
						|
	cfilter << "(" << LF_MOVMAG <<"->ANNOES==" <<'"' << _mask->get(F_ANNOES)<< "\")&&" ;
 | 
						|
	if (*_mask->get(F_ADATA)) 
 | 
						|
	{
 | 
						|
		TDate d1(_mask->get(F_ADATA));
 | 
						|
		cfilter << "(ANSI(110->DATAREG)<=" <<'"' << d1.string(ANSI) << "\")&&" ;
 | 
						|
  }
 | 
						|
	if (cfilter.not_empty())
 | 
						|
		cfilter.cut(cfilter.len()-2); 
 | 
						|
 | 
						|
	if (*_mask->get(F_DADATA))
 | 
						|
	{
 | 
						|
		TDate d1(_mask->get(F_DADATA));
 | 
						|
		// SET conditional section 
 | 
						|
		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);		
 | 
						|
	}
 | 
						|
 | 
						|
  _form->set_tiposcheda(_mask->get(F_SCHEDA));
 | 
						|
	// abilita/disabilita le sezioni dei totali
 | 
						|
	_form->setdett_percatmer(FALSE,
 | 
						|
		_mask->get_int(F_TOLIVELLOART),
 | 
						|
		_mask->get_int(F_TOLIVELLOGIAC),
 | 
						|
		_mask->get_bool(F_SUDDIV_MAGAZZINI),
 | 
						|
		_mask->get_bool(F_SUDDIV_DEPOSITI));
 | 
						|
 | 
						|
	darec.put("CODART",_mask->get(F_DAART));
 | 
						|
	arec.put("CODART",_mask->get(F_AART));
 | 
						|
	((TSorted_cursor *)_cur)->change_order(_form->rmov_sortexp());
 | 
						|
	_cur->setfilter(cfilter,TRUE);
 | 
						|
	_cur->setregion(darec,arec);
 | 
						|
}*/
 | 
						|
 | 
						|
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_SUDDIV_MAGAZZINI),
 | 
						|
		_mask->get_bool(F_SUDDIV_DEPOSITI),
 | 
						|
		_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_tiposcheda() << "<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_tiposcheda() << "<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_tiposcheda() << "<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_tiposcheda() << "<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);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
bool TStampa_schede_mag::set_print(int i)
 | 
						|
{
 | 
						|
	while (TRUE) {
 | 
						|
  	if (_mask->run() != K_ENTER) 
 | 
						|
	    return FALSE;
 | 
						|
 | 
						|
	  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->print();
 | 
						|
		delete _form;
 | 
						|
	} // while true  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
bool TStampa_schede_mag::user_create()
 | 
						|
{
 | 
						|
  _mask = new TMask("mg3300");
 | 
						|
  _files= new TArray;
 | 
						|
	_files->add(new TLocalisamfile(LF_RMOVMAG));
 | 
						|
	_files->add(new TLocalisamfile(LF_MOVMAG));
 | 
						|
	_files->add(new TLocalisamfile(LF_MAG));
 | 
						|
	return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampa_schede_mag::user_destroy()
 | 
						|
{
 | 
						|
	delete _files;
 | 
						|
	delete _mask;
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TStampa_schede_mag ::print_one(int file)
 | 
						|
{
 | 
						|
	return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
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;
 | 
						|
}
 |