Files correlati : mg0.exe mg1.exe mg3.exe mg4.exe Ricompilazione Demo : [ ] Commento : Bug 0000134 Implementare la gestione multilingua git-svn-id: svn://10.65.10.50/trunk@12084 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			570 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			570 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <tabutil.h>
 | 
						|
 | 
						|
#include "anamag.h"
 | 
						|
#include "mag.h"
 | 
						|
#include "stomag.h"
 | 
						|
#include "umart.h"
 | 
						|
#include "movmag.h"
 | 
						|
#include "rmovmag.h"
 | 
						|
           
 | 
						|
#include "../ve/veconf.h"
 | 
						|
#include "mglib.h"
 | 
						|
#include "mg4300.h"
 | 
						|
#include "mg4frm.h"
 | 
						|
 | 
						|
class TRegistro_giornalemag : public TRegistro_std
 | 
						|
{           
 | 
						|
public:
 | 
						|
  int freq_stampa() const { return get_int("I3"); } 
 | 
						|
  bool raggruppato() const { return get_bool("B1"); }
 | 
						|
  bool ragg_mag() const { return get_bool("B2"); }
 | 
						|
  bool ragg_giac() const { return get_bool("B3"); }
 | 
						|
  bool ragg_clafis() const { return get_bool("B4"); }
 | 
						|
  bool ragg_grpfis() const { return get_bool("B5"); }
 | 
						|
  bool ragg_caus() const { return get_bool("B6"); }
 | 
						|
 | 
						|
  long last_numreg() const { return get_long("I4"); }
 | 
						|
  void set_last_numreg(long n) { put("I4",n); }
 | 
						|
  // data ultima stampa esercizio precedente
 | 
						|
  TDate last_print_prec() const { return get_date("D4"); }
 | 
						|
  // pagina ultima stampa esercizio precedente
 | 
						|
  int pag_stampate_prec() const{ return get_int("I6"); }
 | 
						|
 | 
						|
  TRegistro_giornalemag(const char* code = "", int year = 0);  
 | 
						|
  virtual ~TRegistro_giornalemag() {}
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
// ************************************************
 | 
						|
// TEMP!!!!!!!!!!!!!!!!
 | 
						|
TRegistro_giornalemag::TRegistro_giornalemag(const char* cod, int year) 
 | 
						|
                     :TRegistro_std(cod,year)
 | 
						|
{
 | 
						|
  if (tipo()!=TIPOREG_GIOMAG)
 | 
						|
    fatal_box(TR("Il registro richiesto non è relativo ad un libro giornale di magazzino"));
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
class TGiornalemag : public TForm_stampemg
 | 
						|
{
 | 
						|
  static TDate _dadata;
 | 
						|
  static TDate _adata;
 | 
						|
  static int freq_stampa;
 | 
						|
  static bool stampa_def;
 | 
						|
  static bool ragg_mag;
 | 
						|
  static bool ragg_articoli;
 | 
						|
  static bool ragg_classi;
 | 
						|
  static bool ragg_raggart;
 | 
						|
  static bool ragg_caus;
 | 
						|
  static TCursor * cur;
 | 
						|
  static TGiornalemag* giofrm;
 | 
						|
  static TAssoc_array _cod_magazzini;
 | 
						|
  static TAssoc_array _cau_magazzino;
 | 
						|
  static int _annoes;
 | 
						|
  static int livello_giac;
 | 
						|
 | 
						|
  TConfig *conf_ditta;
 | 
						|
  TArticolo_giacenza * _curr_art;
 | 
						|
  TString16 _codlist,_catven;
 | 
						|
  word last_pag_stampata;
 | 
						|
  long last_num_reg;
 | 
						|
  TRegistro_giornalemag *_reg_giorn;
 | 
						|
 | 
						|
private:
 | 
						|
  TArticolo_giacenza &curr_art();
 | 
						|
 | 
						|
static const char * get_fiscfield(TVariable_rectype & r);
 | 
						|
static const char * get_cronofield(TVariable_rectype & r);
 | 
						|
static bool filter_func(const TRelation* r);
 | 
						|
 | 
						|
protected:
 | 
						|
//  void add_mag(TRectype & magrec,const char * codreg);
 | 
						|
  void calcola_range_movimenti(TRecnotype& primo, TRecnotype& ultimo) const;
 | 
						|
 | 
						|
public:
 | 
						|
  void set_parametri(TMask & m);
 | 
						|
  bool can_be_printed();
 | 
						|
 | 
						|
  bool validate(TForm_item &cf, TToken_string &s);
 | 
						|
 | 
						|
  TGiornalemag(const char *name,const char *code) ;
 | 
						|
  ~TGiornalemag();
 | 
						|
};
 | 
						|
 | 
						|
TArticolo_giacenza &TGiornalemag::curr_art()
 | 
						|
{
 | 
						|
  TRectype & magrec=relation()->lfile(LF_MAG).curr();
 | 
						|
  if (_curr_art==NULL || _curr_art->codice()!=magrec.get(MAG_CODART) ) {
 | 
						|
    if (_curr_art) delete _curr_art;
 | 
						|
    _curr_art=new TArticolo_giacenza(magrec.get(MAG_CODART));
 | 
						|
  }
 | 
						|
  return *_curr_art;
 | 
						|
}
 | 
						|
 | 
						|
bool TGiornalemag::validate(TForm_item &cf, TToken_string &s)
 | 
						|
{ 
 | 
						|
  const TString code(s.get(0)); // prende il primo parametro, il codice del messaggio
 | 
						|
  TString valore,vv;
 | 
						|
  TString subcode;
 | 
						|
 | 
						|
  if (code=="_USER") {
 | 
						|
    subcode=s.get();
 | 
						|
 | 
						|
    if (subcode== "INTEST_REG")   {
 | 
						|
      cf.set(_reg_giorn->intest());
 | 
						|
      return TRUE;
 | 
						|
    
 | 
						|
    } else if (subcode== "INTEST_DITTA")  {
 | 
						|
      if (_reg_giorn->stampa_intditta())
 | 
						|
        s = "_DITTA,!RAGSOC";
 | 
						|
      else  
 | 
						|
        return TRUE;
 | 
						|
    } else if (subcode== "PAGENO")  {
 | 
						|
      valore << (int)(last_pag_stampata+printer().getcurrentpage());
 | 
						|
      cf.set(valore);
 | 
						|
      return TRUE;
 | 
						|
 | 
						|
    } else if (subcode== "NUMREGST")  {
 | 
						|
      valore << last_num_reg;
 | 
						|
      cf.set(valore);
 | 
						|
      return TRUE;
 | 
						|
 | 
						|
    } else if (subcode=="INCNUMREGST")    {
 | 
						|
      last_num_reg=max(last_num_reg,_reg_giorn->last_numreg())+1;
 | 
						|
      if (stampa_def)
 | 
						|
      {
 | 
						|
        _reg_giorn->set_last_numreg(last_num_reg);
 | 
						|
        _reg_giorn->rewrite();
 | 
						|
      }
 | 
						|
      return TRUE;
 | 
						|
 | 
						|
    } else if (subcode== "REGISTRASTAMPA") {
 | 
						|
      TRectype & movr=cursor()->relation()->lfile(LF_MOVMAG).curr();
 | 
						|
      if ((1 || movr.get_long("NUMREGST")<=last_num_reg )&& stampa_def)
 | 
						|
      {
 | 
						|
        // movimento ancora da registrare
 | 
						|
        movr.put("NUMREGST",last_num_reg+1);
 | 
						|
        cursor()->relation()->lfile(LF_MOVMAG).rewrite();
 | 
						|
 | 
						|
        _reg_giorn->set_pag_stampate(last_pag_stampata+printer().getcurrentpage());
 | 
						|
        _reg_giorn->set_last_print(TDate(TODAY));
 | 
						|
        _reg_giorn->rewrite();
 | 
						|
      } 
 | 
						|
 | 
						|
    } else if (subcode== "INFO_CRONO") {
 | 
						|
      TDate datamov(cursor()->relation()->curr(LF_MOVMAG).get_date("DATAREG"));
 | 
						|
      switch (freq_stampa ) {
 | 
						|
        case 0:
 | 
						|
          valore.format(FR("%7g Movimento del %s "),  (double)last_num_reg+1, (const char *)datamov.string());
 | 
						|
          valore << cursor()->relation()->curr(LF_MOVMAG).get("DESCR");
 | 
						|
        break;
 | 
						|
        default:
 | 
						|
          valore.format(FR("%7g Movimenti di %s, dal %d al %d"), (double)last_num_reg+1, 
 | 
						|
            (const char *)itom(datamov.month()),
 | 
						|
            (int)((datamov.day()-1)/freq_stampa)*freq_stampa+1,
 | 
						|
            (int)min(((datamov.day()-1)/freq_stampa+1)*freq_stampa,TDate::last_day(datamov.month(),datamov.year()))  );
 | 
						|
        break;
 | 
						|
      }
 | 
						|
      cf.set(valore);
 | 
						|
      return TRUE;
 | 
						|
 | 
						|
    } else if (subcode== "INFO_FISC") {
 | 
						|
      valore.cut(0);
 | 
						|
      if (!ragg_mag)
 | 
						|
      {
 | 
						|
        vv=cursor()->relation()->lfile(LF_RMOVMAG).get("CODMAG");
 | 
						|
        valore << TR("Mag.") << vv.mid(0,3);
 | 
						|
        vv=vv.mid(3,2);
 | 
						|
        if (vv.not_empty())
 | 
						|
          valore << '-' << vv ;
 | 
						|
        else
 | 
						|
          valore << "   " ;
 | 
						|
        valore  << ' ';
 | 
						|
        vv = "";
 | 
						|
      } 
 | 
						|
 | 
						|
      const TRectype& anamag = cursor()->relation()->curr(LF_ANAMAG);
 | 
						|
      if (ragg_articoli)
 | 
						|
      {
 | 
						|
        valore << TR("Art.") << cursor()->relation()->lfile(LF_ANAMAG).get(ANAMAG_CODART) << ' ';
 | 
						|
 | 
						|
        TString livello(cursor()->relation()->curr(LF_RMOVMAG).get("LIVGIAC"));
 | 
						|
        if (livello.not_empty() && livello_giac != 0)
 | 
						|
        {
 | 
						|
          for (int lev=1; lev <= livello_giac; lev++)
 | 
						|
          {
 | 
						|
            if (!livelli_giacenza().enabled(lev))
 | 
						|
              continue;
 | 
						|
            const int starts = livelli_giacenza().code_start(lev) -1;
 | 
						|
            const int length   = livelli_giacenza().code_length(lev);
 | 
						|
            valore << livello.mid(starts,length);
 | 
						|
            valore << "/";
 | 
						|
          }
 | 
						|
          valore << livelli_giacenza().name(livello_giac);
 | 
						|
          valore << " " << livelli_giacenza().group_descr_packed(livello,livello_giac) << " ";
 | 
						|
        }
 | 
						|
      } 
 | 
						|
      else 
 | 
						|
      {
 | 
						|
        if (ragg_classi)
 | 
						|
        {
 | 
						|
          valore << TR("Classe fiscale ") << cursor()->relation()->lfile(LF_ANAMAG).get(ANAMAG_CLASSEFIS) << ' ';
 | 
						|
 | 
						|
          if (ragg_raggart)
 | 
						|
          {
 | 
						|
            valore << TR(" ragg. ") << cursor()->relation()->lfile(LF_ANAMAG).get(ANAMAG_RAGGFIS) << ' ';
 | 
						|
 | 
						|
          }
 | 
						|
        } else {
 | 
						|
          vv.cut(0);
 | 
						|
          vv << TR("Art. ") << cursor()->relation()->lfile(LF_ANAMAG).get(ANAMAG_CODART);
 | 
						|
 | 
						|
        }
 | 
						|
      }
 | 
						|
      valore << vv;
 | 
						|
      cf.set(valore);
 | 
						|
      return TRUE;
 | 
						|
    } 
 | 
						|
    else if (subcode== "INFO_CAUS") 
 | 
						|
    {
 | 
						|
      const TRectype& rec_caus = cache().get("%CAU", cf.get());
 | 
						|
      if (ragg_caus)
 | 
						|
      {
 | 
						|
        const TString16 raggcau  = rec_caus.get("S8");
 | 
						|
        if (raggcau.blank())
 | 
						|
          valore << TR("Causali varie");
 | 
						|
        else
 | 
						|
        {
 | 
						|
          const TRectype& rec_rag = cache().get("%RFC", raggcau);
 | 
						|
          valore << TR("Causali gruppo ") << raggcau << ' ' << rec_rag.get("S0");
 | 
						|
        }
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {   
 | 
						|
        valore << TR("Causale ") << cf.get() << ' ' << rec_caus.get("S0");
 | 
						|
      }
 | 
						|
      cf.set(valore);
 | 
						|
      return TRUE;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return TForm_stampemg::validate(cf, s);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
const char * TGiornalemag::get_cronofield(TVariable_rectype & rmovmag)
 | 
						|
{
 | 
						|
  // static buffer
 | 
						|
  static TString * valore=NULL; 
 | 
						|
  if (valore == NULL ) 
 | 
						|
    valore = new TString16;
 | 
						|
                                  
 | 
						|
  const TRectype& movmag = cache().get(LF_MOVMAG, rmovmag.get(RMOVMAG_NUMREG));
 | 
						|
  const TDate datamov = movmag.get_date(MOVMAG_DATAREG);
 | 
						|
 | 
						|
  // gestione frequenza
 | 
						|
  valore->cut(0);
 | 
						|
  switch (freq_stampa ) {
 | 
						|
    case 0:
 | 
						|
      valore->format("%4d%2d%2d%7d",datamov.year(),
 | 
						|
        datamov.month(),
 | 
						|
        datamov.day(),
 | 
						|
        movmag.get_long("NUMREG"));
 | 
						|
    break;
 | 
						|
    default:
 | 
						|
      valore->format("%4d%2d%2d",datamov.year(),
 | 
						|
        datamov.month(),
 | 
						|
        (int)(datamov.day()/freq_stampa));
 | 
						|
  }
 | 
						|
  return *valore;
 | 
						|
}
 | 
						|
 | 
						|
const char * TGiornalemag::get_fiscfield(TVariable_rectype & rmovmag)
 | 
						|
{
 | 
						|
  static TString * valore=NULL; 
 | 
						|
  if (valore == NULL ) 
 | 
						|
    valore = new TString80 ;
 | 
						|
  
 | 
						|
  TString80 vv;
 | 
						|
  valore->cut(0);
 | 
						|
  
 | 
						|
  const TString80 codart = rmovmag.get(RMOVMAG_CODART);
 | 
						|
  
 | 
						|
  // gestione ragruppamenti
 | 
						|
  if (!ragg_mag)
 | 
						|
  {
 | 
						|
    valore->format("%-15s",(const char *)rmovmag.get(RMOVMAG_CODMAG));
 | 
						|
  }
 | 
						|
  if (ragg_articoli)
 | 
						|
  {
 | 
						|
    *valore << codart;
 | 
						|
 | 
						|
    if (livello_giac)
 | 
						|
    {
 | 
						|
      const TString80 c2 = rmovmag.get("LIVGIAC");
 | 
						|
      *valore << livelli_giacenza().unpack_grpcode(c2, livello_giac);
 | 
						|
    }
 | 
						|
  } 
 | 
						|
  else 
 | 
						|
  {
 | 
						|
    if (ragg_classi)
 | 
						|
    {
 | 
						|
      const TRectype& anamag = cache().get(LF_ANAMAG, codart);
 | 
						|
      *valore << anamag.get(ANAMAG_CLASSEFIS);
 | 
						|
      if (ragg_raggart)
 | 
						|
        *valore << anamag.get(ANAMAG_RAGGFIS);
 | 
						|
    } 
 | 
						|
    else 
 | 
						|
    {
 | 
						|
      if (!ragg_caus && freq_stampa==0) 
 | 
						|
      {
 | 
						|
        vv.format("%4d",rmovmag.get_int(RMOVMAG_NRIG));
 | 
						|
      } 
 | 
						|
      else 
 | 
						|
      {
 | 
						|
        vv.format("%-20s", (const char *)codart);
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
  
 | 
						|
  TString16 codcaus = rmovmag.get(RMOVMAG_CODCAUS);
 | 
						|
  if (codcaus.empty())                                                           
 | 
						|
  {
 | 
						|
    const TRectype& movmag = cache().get(LF_MOVMAG, rmovmag.get(RMOVMAG_NUMREG));
 | 
						|
    codcaus = movmag.get(MOVMAG_CODCAUS);
 | 
						|
  }
 | 
						|
  
 | 
						|
  if (ragg_caus) // raggruppo per "tipo" di causale
 | 
						|
  {
 | 
						|
    TCausale_magazzino* caus = (TCausale_magazzino*)_cau_magazzino.objptr(codcaus);
 | 
						|
    *valore << caus->get("S8");
 | 
						|
  }
 | 
						|
  else
 | 
						|
    *valore << codcaus;
 | 
						|
  *valore << vv;
 | 
						|
  return *valore;
 | 
						|
}
 | 
						|
 | 
						|
void TGiornalemag::calcola_range_movimenti(TRecnotype& primo, TRecnotype& ultimo) const
 | 
						|
{           
 | 
						|
  TRelation rel(LF_MOVMAG);
 | 
						|
  TRectype recfr(LF_MOVMAG), recto(LF_MOVMAG);
 | 
						|
  if (_dadata.ok())
 | 
						|
    recfr.put(MOVMAG_DATAREG, _dadata);
 | 
						|
  if (_adata.ok())
 | 
						|
    recto.put(MOVMAG_DATAREG, _adata);   
 | 
						|
  TCursor cur(&rel, "", 3, &recfr, &recto);
 | 
						|
  const TRecnotype items = cur.items();
 | 
						|
  cur.freeze();
 | 
						|
  primo = 0;
 | 
						|
  ultimo = 0;
 | 
						|
  for (cur = 0L; cur.pos() < items; ++cur)
 | 
						|
  {
 | 
						|
    const long numreg = rel.curr().get_long(MOVMAG_NUMREG);
 | 
						|
    if (primo == 0 || numreg < primo)
 | 
						|
      primo = numreg;
 | 
						|
    if (numreg > ultimo)
 | 
						|
      ultimo = numreg;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TGiornalemag::set_parametri(TMask & m)
 | 
						|
{
 | 
						|
  // set static variables
 | 
						|
  _dadata=m.get_date(F_DATAIN);
 | 
						|
  _adata=m.get_date(F_DATAFIN);
 | 
						|
  freq_stampa = m.get_int(F_FREQ);
 | 
						|
  stampa_def = (*m.get(F_DEFINITIVA) == 'D');
 | 
						|
  ragg_mag = m.get_bool(F_RAGGMAG);
 | 
						|
  ragg_articoli = m.get_bool(F_RAGGARTICOLI );
 | 
						|
  ragg_classi = m.get_bool(F_CLASSEFISART );
 | 
						|
  ragg_raggart = m.get_bool(F_RAGGFISART );
 | 
						|
  ragg_caus = m.get_bool(F_RAGGCAUS );
 | 
						|
  livello_giac = m.get_int(F_TOLIVELLOGIAC);
 | 
						|
  _annoes=m.get_int(F_ANNOES);
 | 
						|
  cur=cursor();
 | 
						|
  giofrm = this;
 | 
						|
  // load Tregistro
 | 
						|
  if (_reg_giorn) delete _reg_giorn;
 | 
						|
  _reg_giorn= new TRegistro_giornalemag(m.get(F_CODREG),m.get_int(F_ANNOES));
 | 
						|
  last_pag_stampata=_reg_giorn->pag_stampate();
 | 
						|
  last_num_reg=_reg_giorn->last_numreg();
 | 
						|
 | 
						|
  // show/hide sections
 | 
						|
  find_field('B',odd_page,"HEADER_RAGG_FISC").show(
 | 
						|
    ragg_articoli || ragg_classi || ragg_caus);
 | 
						|
  find_field('B',odd_page,"HEADER_MOV").show(freq_stampa==0);
 | 
						|
 | 
						|
  TVariable_rectype *vrec_rmov= new TVariable_rectype(LF_RMOVMAG);
 | 
						|
  vrec_rmov->add_field(new TVariable_field ("CRONO_FIELD",get_cronofield,32));
 | 
						|
  vrec_rmov->add_field(new TVariable_field ("FISC_FIELD",get_fiscfield,48));
 | 
						|
    
 | 
						|
  cursor()->relation()->lfile().set_curr(vrec_rmov);
 | 
						|
 | 
						|
  // inserisce tutti i magazzini collegati
 | 
						|
  _cod_magazzini.destroy();
 | 
						|
  TTable mag("MAG"); 
 | 
						|
  int err;
 | 
						|
  for (err = mag.first(); err == NOERR; err = mag.next())
 | 
						|
  {
 | 
						|
    const TString16 codmag(mag.get("CODTAB").left(3));
 | 
						|
    if (codmag.len() == 3 && mag.get("S8")==m.get(F_CODREG))
 | 
						|
      _cod_magazzini.add(codmag);
 | 
						|
  }
 | 
						|
  
 | 
						|
  _cau_magazzino.destroy();
 | 
						|
  TTable cau("%CAU");
 | 
						|
  for (err = cau.first(); err == NOERR; err = cau.next())
 | 
						|
  {
 | 
						|
    TCausale_magazzino* cm = new TCausale_magazzino(cau.curr());
 | 
						|
    _cau_magazzino.add(cm->codice(), cm);
 | 
						|
  }
 | 
						|
 
 | 
						|
  TRecnotype primo, ultimo;
 | 
						|
  calcola_range_movimenti(primo, ultimo);
 | 
						|
  
 | 
						|
  TRectype recfr(LF_RMOVMAG), recto(LF_RMOVMAG);
 | 
						|
  if (primo > 0)
 | 
						|
    recfr.put(RMOVMAG_NUMREG, primo);
 | 
						|
  if (ultimo > 0)
 | 
						|
    recto.put(RMOVMAG_NUMREG, ultimo);
 | 
						|
  cursor()->setregion(recfr, recto);
 | 
						|
 | 
						|
  // setta il filtro sui magazzini di questo giornale
 | 
						|
  cursor()->set_filterfunction(filter_func,FALSE);
 | 
						|
}
 | 
						|
 | 
						|
bool TGiornalemag::filter_func(const TRelation* r)
 | 
						|
{                       
 | 
						|
//  const TRectype& movmag = r->curr(LF_MOVMAG);
 | 
						|
  const TRectype& rmovmag = r->curr(LF_RMOVMAG);
 | 
						|
  const TRectype& movmag = cache().get(LF_MOVMAG, rmovmag.get(RMOVMAG_NUMREG));
 | 
						|
 | 
						|
  const TDate datareg = movmag.get_date(MOVMAG_DATAREG);
 | 
						|
  if (datareg.year() != _annoes)
 | 
						|
    return FALSE;
 | 
						|
  if (!_dadata.empty() && datareg < _dadata)
 | 
						|
    return FALSE;
 | 
						|
  if (!_adata.empty() && datareg > _adata) 
 | 
						|
    return FALSE;
 | 
						|
 | 
						|
  const TString4 codmag = rmovmag.get(RMOVMAG_CODMAG).left(3);
 | 
						|
  if (!_cod_magazzini.is_key(codmag))
 | 
						|
    return FALSE;
 | 
						|
  
 | 
						|
  // considera solo le causali "fiscali" o quelle che movimentano le rimanenze iniziali(movimenti d'apertura)
 | 
						|
  bool rval = FALSE;               
 | 
						|
 | 
						|
  TString16 codcaus = rmovmag.get(RMOVMAG_CODCAUS);
 | 
						|
  if (codcaus.empty())
 | 
						|
    codcaus = movmag.get(MOVMAG_CODCAUS);
 | 
						|
  TCausale_magazzino* caus = (TCausale_magazzino*)_cau_magazzino.objptr(codcaus);
 | 
						|
  if (caus != NULL)
 | 
						|
    rval = caus->is_fiscale() || caus->sgn(s_rim);
 | 
						|
  
 | 
						|
  return rval;
 | 
						|
}
 | 
						|
 | 
						|
bool TGiornalemag::can_be_printed()
 | 
						|
{
 | 
						|
  if (stampa_def) 
 | 
						|
  {
 | 
						|
    TLocalisamfile mov(LF_MOVMAG);
 | 
						|
    mov.setkey(3);
 | 
						|
    mov.put(MOVMAG_DATAREG,_dadata);
 | 
						|
    mov.read();
 | 
						|
    mov.prev();
 | 
						|
    if (!mov.eof() || mov.get(MOVMAG_NUMREGST)!=_reg_giorn->last_numreg())
 | 
						|
      return FALSE;
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
TGiornalemag::TGiornalemag(const char *name,const char *code) :
 | 
						|
  TForm_stampemg(name,code),_curr_art(NULL),
 | 
						|
  last_pag_stampata(0),last_num_reg(0),_reg_giorn(NULL)
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
TGiornalemag::~TGiornalemag()
 | 
						|
{
 | 
						|
  if (_curr_art) delete _curr_art;
 | 
						|
  if (_reg_giorn) delete _reg_giorn;
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
// dichiarazioni degli static
 | 
						|
TDate TGiornalemag::_dadata;
 | 
						|
TDate TGiornalemag::_adata;
 | 
						|
int   TGiornalemag::freq_stampa;
 | 
						|
bool TGiornalemag::ragg_mag;
 | 
						|
bool TGiornalemag::stampa_def;
 | 
						|
bool TGiornalemag::ragg_articoli;
 | 
						|
bool TGiornalemag::ragg_classi;
 | 
						|
bool TGiornalemag::ragg_raggart;
 | 
						|
bool TGiornalemag::ragg_caus;
 | 
						|
int  TGiornalemag::livello_giac;
 | 
						|
TCursor * TGiornalemag::cur;
 | 
						|
TGiornalemag * TGiornalemag::giofrm;
 | 
						|
TAssoc_array TGiornalemag::_cod_magazzini;
 | 
						|
TAssoc_array TGiornalemag::_cau_magazzino;
 | 
						|
int TGiornalemag::_annoes;
 | 
						|
 | 
						|
// STAMPA giornale
 | 
						|
class TStampa_giornalemag : public TSkeleton_application
 | 
						|
{
 | 
						|
  TStampemg_mask * _mask;
 | 
						|
  TGiornalemag * _giorn_mag; // to be moved into TPrint_application
 | 
						|
  TCursor * _cur;
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual bool create();
 | 
						|
  virtual bool destroy();
 | 
						|
  virtual void main_loop();
 | 
						|
 | 
						|
public:
 | 
						|
  TStampa_giornalemag() {}
 | 
						|
};
 | 
						|
 | 
						|
bool TStampa_giornalemag::create()
 | 
						|
{
 | 
						|
  open_files(LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_TAB, LF_TABCOM, 0);
 | 
						|
  _mask = new TStampemg_mask("mg4300");
 | 
						|
  _mask->show(F_TOLIVELLOGIAC, livelli_giacenza().enabled()); // Abilita la gestione del dettaglio livello giacenza
 | 
						|
  return TSkeleton_application::create();
 | 
						|
}
 | 
						|
 | 
						|
bool TStampa_giornalemag::destroy()
 | 
						|
{
 | 
						|
  delete _mask;
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TStampa_giornalemag::main_loop()
 | 
						|
{
 | 
						|
  while (_mask->run() == K_ENTER) 
 | 
						|
  {
 | 
						|
    if (_mask->magazz_ini().gestmag(TRUE)) 
 | 
						|
    {
 | 
						|
      _giorn_mag = new TGiornalemag("mg4300", "");
 | 
						|
      _giorn_mag->set_parametri(*_mask);
 | 
						|
      if (_giorn_mag->can_be_printed())
 | 
						|
        _giorn_mag->print();
 | 
						|
      else
 | 
						|
        error_box(TR("Impossibile stampare il giornale dalla data indicata"));
 | 
						|
      delete _giorn_mag;
 | 
						|
    } 
 | 
						|
  } // while true  
 | 
						|
  return ;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
int mg4300(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TStampa_giornalemag a;
 | 
						|
  a.run(argc,argv,TR("Stampa giornale di magazzino"));
 | 
						|
  return 0;
 | 
						|
} |