Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@15368 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			3746 lines
		
	
	
		
			110 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			3746 lines
		
	
	
		
			110 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <execp.h>
 | 
						|
#include <mailbox.h>
 | 
						|
#include <msksheet.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <sheet.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include <clifo.h>
 | 
						|
#include <pconti.h>
 | 
						|
#include <mov.h>
 | 
						|
#include <rmov.h>
 | 
						|
#include <comuni.h>
 | 
						|
#include <saldi.h>
 | 
						|
#include <causali.h>
 | 
						|
#include <nditte.h>
 | 
						|
#include <unloc.h>
 | 
						|
 | 
						|
#include "cgp3.h"
 | 
						|
#include "cgp3100.h"
 | 
						|
 | 
						|
#include "cglib02.h"
 | 
						|
#include "cglib03.h"
 | 
						|
 | 
						|
class TMastrini_application : public TPrintapp
 | 
						|
{
 | 
						|
  static bool data_inizio (TMask_field& f, KEY k);
 | 
						|
  static bool data_fine   (TMask_field& f, KEY k);
 | 
						|
  static bool gruppo_hnd  (TMask_field& f, KEY k);
 | 
						|
  
 | 
						|
  static bool memorizza_handler(TMask_field& f, KEY k);
 | 
						|
  static bool scelte_notify(TSheet_field& s, int r, KEY k);
 | 
						|
 | 
						|
  TDociva_array      _b;
 | 
						|
  TRelation*         _rel;
 | 
						|
  TMask*             _msk;
 | 
						|
  TTable*            _tabivd, * _tabtpd, * _tabreg;
 | 
						|
  TLocalisamfile*    _mov;
 | 
						|
  TLocalisamfile*    _nditte;
 | 
						|
  TLocalisamfile*    _unloc;
 | 
						|
  TLocalisamfile*    _comuni;
 | 
						|
  TLocalisamfile*    _clifo;
 | 
						|
  TLocalisamfile*    _caus;
 | 
						|
  TSaldo*            _sld;
 | 
						|
  TParagraph_string* _d18,* _d23,* _d30;
 | 
						|
  TArray             _riga, _lista;
 | 
						|
  
 | 
						|
  TDate _data_ini,_data_fine,_data_finese,_data_finesesucc,_ultima_data_reg;
 | 
						|
  TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa,_inizioes;
 | 
						|
  int _cur1,_gruppo,_conto,_numcarat,_stampanum,_numivd,_annoiva;
 | 
						|
  int _numrig,_natdoc,_tipo,_tipostampa,_g_prec,_c_prec,_numrivd_int;
 | 
						|
  real _progredare,_progreavere,_totprogre_dare_al,_totprogre_avere_al;
 | 
						|
  real _totprogre_dare,_totprogre_avere,_importo;
 | 
						|
  real _riporto_dare,_riporto_avere,_riporto_parziale_dare,_riporto_parziale_avere;
 | 
						|
  real _totale_periodo_dare,_totale_periodo_avere,_totale_prima_dare,_totale_prima_avere;
 | 
						|
  real _saldo_periodo,_saldo_progre,_saldo_progre_al,_saldo_progre_prec;
 | 
						|
  real _saldo_movimenti,_saldo_progressivi,_totale_saldo,_riporto_footer_dare,_riporto_footer_avere;
 | 
						|
  TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc;
 | 
						|
  long _codice_ditta,_s_prec;
 | 
						|
  TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva;
 | 
						|
  TString _g_contr,_c_contr,_s_contr;
 | 
						|
 | 
						|
  char    _sezivd,_lettivd; 
 | 
						|
  TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr;
 | 
						|
  TString _dataregs, _datadocs;
 | 
						|
  int _nummast,_pagina;
 | 
						|
  int     _gruppocontr,_contocontr;
 | 
						|
  long    _sottocontocontr;
 | 
						|
 | 
						|
  bool _stampaprogre,_stampatotiva,_stampatot,_stampa_mov_prov;
 | 
						|
  bool _stampato,_devi_stampare_footer;
 | 
						|
 
 | 
						|
  int  _annomsk,_annoesmsk,_annoes,_annomsksucc,_tipo_mask,_anno_ghost;
 | 
						|
  int  _anno_corrente,_anno_precedente,_indbil,_numero_pag;
 | 
						|
  long _sottoc,_numreg,_numgio,_protiva;
 | 
						|
  bool _stampa_progressivi_si,_competenza,/*_inizio_stampa,*/_puoi_stampare,_stampa_footer_si;
 | 
						|
  bool _cambia_mastrino,_gia_stampata_intestazione;
 | 
						|
  char _tmcf,_tipo_contr; 
 | 
						|
  
 | 
						|
  TDate _dataregrmov;
 | 
						|
  int  _gruppof,_contof;
 | 
						|
  long _sottocf;
 | 
						|
  TString _dataregrmovstring,_importo_str,_saldo_movimenti_str,_saldo_progressivi_str;
 | 
						|
 | 
						|
  int  _rw, _conta_mastrini, _indice_array, _item, _item_lista, _indice_lista;
 | 
						|
  int  _ddociva_len;
 | 
						|
 | 
						|
  bool _noseparator;
 | 
						|
  TString _real_picture;
 | 
						|
  
 | 
						|
  TString256 TMP;
 | 
						|
  TString _str_tipo, _str_sotto;
 | 
						|
  
 | 
						|
  real _gb_saldo_periodo, _gb_totale_periodo_dare, _gb_totale_periodo_avere;
 | 
						|
  real _gb_saldo_progre, _gb_totprogre_dare, _gb_totprogre_avere;
 | 
						|
  real _gb_saldo_progre_al, _gb_totprogre_dare_al, _gb_totprogre_avere_al;
 | 
						|
  bool _gb_last_page;
 | 
						|
    
 | 
						|
  TConfig* _collins;
 | 
						|
  
 | 
						|
protected:
 | 
						|
  virtual bool user_create() ;
 | 
						|
  virtual bool user_destroy();
 | 
						|
  virtual bool set_print(int m);
 | 
						|
 
 | 
						|
  virtual bool preprocess_print(int file, int counter);
 | 
						|
  virtual bool preprocess_page (int,int);
 | 
						|
  virtual print_action postprocess_page (int,int);
 | 
						|
  virtual print_action postprocess_print(int,int);
 | 
						|
  virtual void preprocess_header();   
 | 
						|
  virtual void preprocess_footer();
 | 
						|
  virtual void set_page(int,int);
 | 
						|
  virtual bool process_link(int id, const char* txt);
 | 
						|
      
 | 
						|
  void set_handlers(TMask* msk) const;
 | 
						|
  bool mask2sheet();
 | 
						|
  bool sheet2mask();
 | 
						|
 | 
						|
  // Aggiorna totali di Gastone Bizzarri                            
 | 
						|
  void aggiorna_totali_gb();
 | 
						|
 | 
						|
public:
 | 
						|
  //TDate _inizioEs,_fineEs;
 | 
						|
  
 | 
						|
  int  date2esc(const TDate& d);   
 | 
						|
  void ricerca_clifo();
 | 
						|
  void ricerca_gruppo();
 | 
						|
  int  ricerca_clifo(int riga);
 | 
						|
  int  ricerca_gruppo(int riga);
 | 
						|
 | 
						|
  void calcola_progressivi();
 | 
						|
  void calcola_progressivi_al(); 
 | 
						|
  void stampa_progressivi();
 | 
						|
  int  stampa_progressivi(int start_riga);
 | 
						|
  void stampa_progre_riporto();
 | 
						|
  int  stampa_progre_riporto(int start_riga);
 | 
						|
  void documenti_iva();
 | 
						|
  void ricerca_regiva();
 | 
						|
  void descrizione_causale();
 | 
						|
  void saldi_zero();
 | 
						|
  int  crea_intestazione(int riga);
 | 
						|
  void crea_intestazione();
 | 
						|
  void fai_stampa132();
 | 
						|
  void fai_stampa198();
 | 
						|
  void stampa_totali132();
 | 
						|
  void stampa_totali198();      
 | 
						|
  void stampa_totali132_II();
 | 
						|
  void stampa_totali198_II();  
 | 
						|
  void carica_array_totali132();
 | 
						|
  void carica_array_totali198();  
 | 
						|
  void stampa_totaliiva();  
 | 
						|
  void ricerca_classe_IV(bool scelta);
 | 
						|
  void data_fine_esercizio(int);
 | 
						|
  const char* descrizione_gruppo();
 | 
						|
  const char* descrizione_conto();    
 | 
						|
  const char* descrizione_sottoconto();
 | 
						|
  const char* descrizione_classe(char,char,int,int);
 | 
						|
  bool almeno_un_record();
 | 
						|
  void ricerca_dati_ditta();
 | 
						|
  void conto(int,int,bool);                       
 | 
						|
  bool check_ordine(TMask_field& f, KEY k);
 | 
						|
  
 | 
						|
  void setta_riga (int r, TString riga);              
 | 
						|
  int  righe_rimaste_da_stampare();
 | 
						|
  
 | 
						|
  const char* trans(const char* italian);
 | 
						|
  
 | 
						|
  TMastrini_application() {}
 | 
						|
  virtual ~TMastrini_application() {}
 | 
						|
};
 | 
						|
 | 
						|
inline TMastrini_application& app() { return (TMastrini_application&)main_app(); }
 | 
						|
 | 
						|
const char* TMastrini_application::trans(const char* italian)
 | 
						|
{                                 
 | 
						|
  TString80 key(italian);
 | 
						|
  key.replace(' ', '_');
 | 
						|
  const TString& str = _collins->get(key, NULL, -1, italian);
 | 
						|
  return str;
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::righe_rimaste_da_stampare()
 | 
						|
{  
 | 
						|
  int righe_rimaste = 0;
 | 
						|
                  
 | 
						|
  if (_nummast == 2)
 | 
						|
  { 
 | 
						|
    if (printer().rows_left() != 0)
 | 
						|
    {
 | 
						|
      if ( (_conta_mastrini % 2) != 0)
 | 
						|
      { 
 | 
						|
        if ( (printer().formlen() % 2) != 0)
 | 
						|
          righe_rimaste = printer().rows_left() - (printer().formlen() / 2) + 1; //- 33;
 | 
						|
        else
 | 
						|
          righe_rimaste = printer().rows_left() - (printer().formlen() / 2); 
 | 
						|
      }
 | 
						|
      else
 | 
						|
        righe_rimaste = printer().rows_left();
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      if ( (_conta_mastrini % 2) != 0)
 | 
						|
        righe_rimaste = printer().formlen() / 2; //32;
 | 
						|
      else 
 | 
						|
      {
 | 
						|
        if ( (printer().formlen() % 2) != 0)
 | 
						|
          righe_rimaste = (printer().formlen() / 2) + 1; //33;
 | 
						|
        else
 | 
						|
          righe_rimaste = printer().formlen() / 2;
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
 
 | 
						|
  return righe_rimaste;
 | 
						|
} 
 | 
						|
 | 
						|
bool TMastrini_application::process_link(int id, const char* txt)
 | 
						|
{                                         
 | 
						|
  TRectype mov(LF_MOV);
 | 
						|
  mov.put(MOV_NUMREG, txt);
 | 
						|
  return mov.edit();
 | 
						|
} 
 | 
						|
 | 
						|
bool TMastrini_application::gruppo_hnd (TMask_field& f, KEY k)
 | 
						|
{  
 | 
						|
  if (k == K_ENTER)
 | 
						|
  {
 | 
						|
    int gruppof = f.mask().get_int(F_GRUPPOFINE);
 | 
						|
    
 | 
						|
    if (gruppof == 0)
 | 
						|
      return TRUE;
 | 
						|
      
 | 
						|
    int gruppoi = f.mask().get_int(F_GRUPPOINI);
 | 
						|
    
 | 
						|
    if (gruppoi > gruppof)
 | 
						|
      return f.error_box("Il gruppo di partenza deve essere inferiore o uguale al gruppo di arrivo");
 | 
						|
  }   
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::check_ordine(TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  const int gruppof = f.mask().get_int(F_GRUPPOFINE);
 | 
						|
    
 | 
						|
  if (gruppof == 0)
 | 
						|
    return TRUE;
 | 
						|
      
 | 
						|
  const int gruppoi = f.mask().get_int(F_GRUPPOINI);
 | 
						|
    
 | 
						|
  if (gruppoi < gruppof)
 | 
						|
    return TRUE;
 | 
						|
    
 | 
						|
  int contof = f.mask().get_int(F_CONTOFINE_CONTO);
 | 
						|
  int contoi = f.mask().get_int(F_CONTOINI_CONTO);
 | 
						|
    
 | 
						|
  if (contof == 0 || contoi < contof)
 | 
						|
    return TRUE;
 | 
						|
    
 | 
						|
  return f.error_box("Il conto di partenza deve essere inferiore o uguale al conto di arrivo");
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::memorizza_handler(TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  if (k == K_SPACE)
 | 
						|
  {
 | 
						|
    if (app().mask2sheet())
 | 
						|
    {
 | 
						|
      TMask& m = f.mask();
 | 
						|
      m.reset(-9);
 | 
						|
      m.set_focus_field(F_GRUPPOINI);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::scelte_notify(TSheet_field& s, int r, KEY k)
 | 
						|
{
 | 
						|
  bool ok = TRUE;
 | 
						|
  if (k == K_INS)
 | 
						|
    return ok = FALSE;
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::date2esc(const TDate& d)
 | 
						|
{                   
 | 
						|
  TEsercizi_contabili esc;
 | 
						|
  return esc.date2esc(d);
 | 
						|
}
 | 
						|
 | 
						|
//Questa funzione restituisce vero se il record su piano dei conti ha almeno un
 | 
						|
//record figlio (e che soddisfa la condizione riguardante la data di registr.).
 | 
						|
//Viene successivamente utilizzata per stampare l'intestazione (e i totali)
 | 
						|
//oppure no
 | 
						|
 | 
						|
bool TMastrini_application::almeno_un_record()
 | 
						|
{
 | 
						|
  bool  trovato=FALSE;
 | 
						|
  int   gruppo,conto;
 | 
						|
  TDate datareg, datacomp;
 | 
						|
  TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | 
						|
  
 | 
						|
  if (current_cursor()->is_first_match(LF_RMOV))
 | 
						|
  {
 | 
						|
    long record = rmov.recno();
 | 
						|
    rmov.zero();
 | 
						|
    rmov.put(RMV_GRUPPO,     _gruppo);
 | 
						|
    rmov.put(RMV_CONTO,      _conto);
 | 
						|
//    rmov.put(RMV_SOTTOCONTO, _sottoc);
 | 
						|
 | 
						|
    for (int err = rmov.read(_isgteq); err == NOERR; err = rmov.next())
 | 
						|
    {
 | 
						|
      const int  annoes = rmov.get_int (RMV_ANNOES);
 | 
						|
      const long numreg = rmov.get_long(RMV_NUMREG);
 | 
						|
 | 
						|
      _mov->setkey(1);
 | 
						|
      _mov->curr().zero();
 | 
						|
      _mov->curr().put(MOV_NUMREG,numreg);
 | 
						|
      _mov->read();
 | 
						|
      if (_mov->bad())
 | 
						|
        _mov->zero();
 | 
						|
      datacomp = _mov->curr().get(MOV_DATACOMP);
 | 
						|
      
 | 
						|
      const char provvis = _mov->curr().get_char(MOV_PROVVIS);
 | 
						|
        
 | 
						|
      if (_annomsk == 0)
 | 
						|
        datareg = rmov.get_date(RMV_DATAREG);
 | 
						|
      else
 | 
						|
        datareg = datacomp;
 | 
						|
 | 
						|
      gruppo = rmov.get_int(RMV_GRUPPO);
 | 
						|
      conto = rmov.get_int(RMV_CONTO);
 | 
						|
//      sottoc = rmov.get_long(RMV_SOTTOCONTO);
 | 
						|
      if ((gruppo != _gruppo)||(conto != _conto)/*||(sottoc != _sottoc)*/)
 | 
						|
        break;
 | 
						|
      else
 | 
						|
        if ( ((annoes==_annomsk) || (_annomsk==0)) && ((datareg>=_data_ini) && (datareg<=_data_fine)) && (_stampa_mov_prov || provvis <= ' '))
 | 
						|
        {
 | 
						|
          trovato = TRUE;
 | 
						|
          break;
 | 
						|
        }
 | 
						|
    }
 | 
						|
    rmov.readat(record);
 | 
						|
  }
 | 
						|
  return trovato;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::data_inizio(TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  const TDate data = f.mask().get    (F_DATAINI);
 | 
						|
  const int anno = f.mask().get_int(F_ANNO);
 | 
						|
  app()._annomsk = anno;
 | 
						|
  
 | 
						|
  if (k == K_ENTER)
 | 
						|
  {
 | 
						|
    if (anno != 0)
 | 
						|
    {
 | 
						|
      app().data_fine_esercizio(anno);
 | 
						|
 | 
						|
      if (data.ok())
 | 
						|
      {
 | 
						|
        if (data < app()._data_inizioese || data > app()._data_finese)
 | 
						|
        {
 | 
						|
          f.error_box("La data non appartiene all'esercizio indicato");
 | 
						|
              return FALSE;
 | 
						|
        }
 | 
						|
        else
 | 
						|
          app()._data_ini = data;
 | 
						|
      }    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      if (data == botime)
 | 
						|
        return f.error_box("La data deve essere obbligatoriamente indicata");
 | 
						|
 | 
						|
      if (app().date2esc(data) == 0)
 | 
						|
        return f.error_box("La data indicata non appartiene ad alcun esercizio");
 | 
						|
      else
 | 
						|
        app()._data_ini = data;
 | 
						|
    }  
 | 
						|
  }  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::data_fine(TMask_field& f, KEY k)
 | 
						|
{
 | 
						|
  int   annoes;
 | 
						|
  TDate data, data_ini;
 | 
						|
 | 
						|
  annoes   = f.mask().get_int(F_ANNO);
 | 
						|
  data     = f.mask().get    (F_DATAFINE);
 | 
						|
  data_ini = f.mask().get    (F_DATAINI);
 | 
						|
  app()._annomsk = annoes;
 | 
						|
  
 | 
						|
  if (k == K_ENTER)
 | 
						|
  {
 | 
						|
    if (annoes != 0)
 | 
						|
    {                  
 | 
						|
      app().data_fine_esercizio(annoes);
 | 
						|
      
 | 
						|
      if (data.ok())
 | 
						|
      {
 | 
						|
        if (data < app()._data_inizioese || data > app()._data_finese)
 | 
						|
        {
 | 
						|
          f.error_box("La data non appartiene all'esercizio indicato");
 | 
						|
          return FALSE;
 | 
						|
        }
 | 
						|
        else
 | 
						|
          app()._data_fine = data;
 | 
						|
      }
 | 
						|
    }
 | 
						|
    else
 | 
						|
      {
 | 
						|
        if (data == botime)
 | 
						|
          return f.error_box("La data deve essere obbligatoriamente indicata");
 | 
						|
 | 
						|
        app()._anno_ghost = app().date2esc(data_ini); 
 | 
						|
        
 | 
						|
        if (app()._anno_ghost == 0)
 | 
						|
          return f.error_box("La data indicata non appartiene ad alcun esercizio");
 | 
						|
        //app()._inizioes = app()._inizioEs;
 | 
						|
 | 
						|
        //if (data < app()._inizioEs || data > app()._fineEs)
 | 
						|
        //{
 | 
						|
        //  f.error_box("La data non appartiene all'esercizio indicato");
 | 
						|
        //  return FALSE;
 | 
						|
        //}
 | 
						|
        //else
 | 
						|
        app()._data_fine = data;
 | 
						|
      }
 | 
						|
 | 
						|
    if (data < data_ini)
 | 
						|
    {
 | 
						|
      f.error_box("La data finale non puo' essere inferiore alla data di partenza");
 | 
						|
      return FALSE;
 | 
						|
    }
 | 
						|
 | 
						|
    
 | 
						|
  } 
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::saldi_zero()
 | 
						|
{
 | 
						|
  TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | 
						|
  real saldo_dare, saldo_avere;
 | 
						|
  long record;
 | 
						|
 | 
						|
  saldo_dare = saldo_avere = 0.0;
 | 
						|
 | 
						|
  if (current_cursor()->is_first_match(LF_RMOV))
 | 
						|
  {
 | 
						|
    record = rmov.recno();
 | 
						|
  
 | 
						|
    while (!rmov.eof())
 | 
						|
    {
 | 
						|
      long numreg = rmov.get_long(RMV_NUMREG);
 | 
						|
      _mov->setkey(1);
 | 
						|
      _mov->curr().zero();
 | 
						|
      _mov->curr().put(MOV_NUMREG,numreg);
 | 
						|
      _mov->read();
 | 
						|
      if (_mov->bad())
 | 
						|
        _mov->zero();
 | 
						|
      char provvis = _mov->curr().get_char(MOV_PROVVIS);
 | 
						|
      int gruppo = atoi(rmov.get(RMV_GRUPPO));
 | 
						|
      int conto = atoi(rmov.get(RMV_CONTO));
 | 
						|
//      long sottoc = atol(rmov.get(RMV_SOTTOCONTO));
 | 
						|
 | 
						|
      if ((gruppo == _gruppo)&&(conto == _conto)/*&&(sottoc == _sottoc)*/) 
 | 
						|
      {
 | 
						|
        if (_stampa_mov_prov || provvis <= ' ')
 | 
						|
        {
 | 
						|
          char sezione = rmov.curr().get(RMV_SEZIONE)[0];
 | 
						|
          real importo = rmov.curr().get_real(RMV_IMPORTO);
 | 
						|
          if (sezione == 'D')
 | 
						|
            saldo_dare += importo;
 | 
						|
          else
 | 
						|
            saldo_avere += importo;
 | 
						|
        }                 
 | 
						|
      }
 | 
						|
      else break;
 | 
						|
      rmov.next();
 | 
						|
    }
 | 
						|
    rmov.readat(record);
 | 
						|
  }
 | 
						|
  _totale_saldo = saldo_dare - saldo_avere;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::fai_stampa132()
 | 
						|
{ 
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 1;
 | 
						|
  else
 | 
						|
    if (_nummast == 2)
 | 
						|
    {  
 | 
						|
      int riga;
 | 
						|
              
 | 
						|
      if ( (_conta_mastrini % 2) != 0 )
 | 
						|
        riga = (printer().formlen() / 2);    //-1
 | 
						|
      else
 | 
						|
        riga = printer().formlen();          //-1;
 | 
						|
        
 | 
						|
      int app1    = printer().formlen();
 | 
						|
      int app2    = printer().rows_left();
 | 
						|
      int cur_row = (app1 - app2);
 | 
						|
          
 | 
						|
      if (cur_row == riga) 
 | 
						|
      {
 | 
						|
        //_rw += 2;
 | 
						|
        _rw = crea_intestazione(_rw);
 | 
						|
        _rw = stampa_progre_riporto(_rw);
 | 
						|
        
 | 
						|
        if (_item != 0)  
 | 
						|
        {
 | 
						|
          for (int i = _indice_array; i < _item; i++)
 | 
						|
          {
 | 
						|
            TString& data = (TString&)_riga[i];
 | 
						|
    
 | 
						|
            int g1 = data.find("g",1);
 | 
						|
            int c1 = data.find("@",g1);
 | 
						|
            int g2 = data.find("g",c1);
 | 
						|
              
 | 
						|
            TString fmt1 = "";
 | 
						|
            TString fmt2 = "";
 | 
						|
            TString str1,str2;
 | 
						|
              
 | 
						|
            if (g1 != -1)
 | 
						|
            {
 | 
						|
              fmt1 = data.sub(0,g1+1);
 | 
						|
              fmt1 << "%s";
 | 
						|
              str1 = data.sub(g1+1,c1);
 | 
						|
            }  
 | 
						|
            if (c1 != -1)
 | 
						|
            {
 | 
						|
              fmt2 = data.sub(c1,g2+1);
 | 
						|
              fmt2 << "%s";
 | 
						|
              str2 = data.sub(g2+1);
 | 
						|
            }
 | 
						|
              
 | 
						|
            if (fmt1 != "")
 | 
						|
              set_row (_rw,fmt1,(const char*) str1);
 | 
						|
            if (fmt2 != "")
 | 
						|
              set_row (_rw,fmt2,(const char*) str2);
 | 
						|
              
 | 
						|
            _rw++;
 | 
						|
          }  
 | 
						|
        }  
 | 
						|
      }
 | 
						|
      else
 | 
						|
        _rw = 1;
 | 
						|
      
 | 
						|
      if (_item != 0)  
 | 
						|
        _riga.destroy();
 | 
						|
    }
 | 
						|
    
 | 
						|
  set_row (_rw,"@0g#t",  &_dataregs);
 | 
						|
  if (_stampanum == 1)
 | 
						|
    set_row (_rw,"@11g$[r]#7d$[n]", &_numreg);
 | 
						|
  else
 | 
						|
    if (_stampanum == 2)
 | 
						|
    {
 | 
						|
      set_row (_rw,"@11g#7d", &_numgio);
 | 
						|
    }            
 | 
						|
    
 | 
						|
  set_row (_rw,"@19g#t", &_datadocs);
 | 
						|
  set_row (_rw,"@30g#7t", &_numdoc);
 | 
						|
  set_row (_rw,"@38g#3t", &_codcaus);
 | 
						|
//  set_row (_rw,"@117g#3t #3t #6t", &_g_contr, &_c_contr, &_s_contr);
 | 
						|
  set_row (_rw,"@117g#1t #6t", &_str_tipo, &_str_sotto);
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::fai_stampa198()
 | 
						|
{            
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 1;
 | 
						|
  else
 | 
						|
    if (_nummast == 2)
 | 
						|
    {            
 | 
						|
      int riga;
 | 
						|
              
 | 
						|
      if ( (_conta_mastrini % 2) != 0 )
 | 
						|
        riga = (printer().formlen() / 2);    //-1
 | 
						|
      else
 | 
						|
        riga = printer().formlen();          //-1;
 | 
						|
 | 
						|
      int app1    = printer().formlen();
 | 
						|
      int app2    = printer().rows_left();
 | 
						|
      int cur_row = (app1 - app2);
 | 
						|
          
 | 
						|
      if (cur_row == riga) 
 | 
						|
      {
 | 
						|
        //_rw += 2;
 | 
						|
        _rw = crea_intestazione(_rw);
 | 
						|
        _rw = stampa_progre_riporto(_rw);
 | 
						|
        
 | 
						|
        if (_item != 0)
 | 
						|
        {
 | 
						|
          for (int i = _indice_array; i < _item; i++)
 | 
						|
          {
 | 
						|
            TString& data = (TString&)_riga[i];
 | 
						|
    
 | 
						|
            int g1 = data.find("g",1);
 | 
						|
            int c1 = data.find("@",g1);
 | 
						|
            int g2 = data.find("g",c1);
 | 
						|
              
 | 
						|
            TString fmt1 = "";
 | 
						|
            TString fmt2 = "";
 | 
						|
            TString str1,str2;
 | 
						|
              
 | 
						|
            if (g1 != -1)
 | 
						|
            {
 | 
						|
              fmt1 = data.sub(0,g1+1);
 | 
						|
              fmt1 << "%s";
 | 
						|
              str1 = data.sub(g1+1,c1);
 | 
						|
            }  
 | 
						|
            if (c1 != -1)
 | 
						|
            {
 | 
						|
              fmt2 = data.sub(c1,g2+1);
 | 
						|
              fmt2 << "%s";
 | 
						|
              str2 = data.sub(g2+1);
 | 
						|
            }
 | 
						|
              
 | 
						|
            if (fmt1 != "")
 | 
						|
              set_row (_rw,fmt1,(const char*) str1);
 | 
						|
            if (fmt2 != "")
 | 
						|
              set_row (_rw,fmt2,(const char*) str2);
 | 
						|
              
 | 
						|
            _rw++;
 | 
						|
          }
 | 
						|
        }
 | 
						|
      }
 | 
						|
      else
 | 
						|
        _rw = 1;
 | 
						|
         
 | 
						|
      if (_item != 0)   
 | 
						|
        _riga.destroy();  
 | 
						|
    }
 | 
						|
 | 
						|
  set_row (_rw,"@0g#t", &_dataregs);
 | 
						|
  if (_stampanum == 1)            
 | 
						|
  {
 | 
						|
    set_row (_rw,"@11g$[r]#7d$[n]", &_numreg);
 | 
						|
    set_row (_rw,"@18g/#3d", &_numrig);
 | 
						|
  }
 | 
						|
  else if (_stampanum == 2)
 | 
						|
     set_row (_rw,"@11g#7d", &_numgio);
 | 
						|
     
 | 
						|
  set_row (_rw,"@23g#t", &_datadocs);
 | 
						|
  set_row (_rw,"@34g#7t", &_numdoc);
 | 
						|
  set_row (_rw,"@42g#3t", &_codcaus);
 | 
						|
 | 
						|
// Stampa saldo movimenti
 | 
						|
 | 
						|
  set_row (_rw,"@151g#t", &_saldo_movimenti_str);
 | 
						|
//  set_row (_rw,"@168g#3t #3t #6t", &_g_contr, &_c_contr, &_s_contr);
 | 
						|
  set_row (_rw,"@168g#1t #6t", &_str_tipo, &_str_sotto);
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::aggiorna_totali_gb()
 | 
						|
{
 | 
						|
  _gb_saldo_periodo += _saldo_periodo;
 | 
						|
  _gb_totale_periodo_dare += _totale_periodo_dare;    
 | 
						|
  _gb_totale_periodo_avere += _totale_periodo_avere;
 | 
						|
  _gb_saldo_progre += _saldo_progre;
 | 
						|
  _gb_totprogre_dare += _totprogre_dare;
 | 
						|
  _gb_totprogre_avere += _totprogre_avere;
 | 
						|
  _gb_saldo_progre_al += _saldo_progre_al;
 | 
						|
  _gb_totprogre_dare_al += _totprogre_dare_al;
 | 
						|
  _gb_totprogre_avere_al += _totprogre_avere_al;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::stampa_totali132()
 | 
						|
{
 | 
						|
  TString sep(132);
 | 
						|
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 2;
 | 
						|
      
 | 
						|
  sep.fill('-');                            //Stampa 132 - (sep(132))      
 | 
						|
  set_row(_rw++,"@0g%s", (const char*)sep);
 | 
						|
 | 
						|
  _totprogre_dare=_progredare+_totale_periodo_dare;
 | 
						|
  _totprogre_avere=_progreavere+_totale_periodo_avere;
 | 
						|
  _saldo_periodo = _totale_periodo_dare - _totale_periodo_avere;
 | 
						|
  _saldo_progre = _totprogre_dare - _totprogre_avere;
 | 
						|
  _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | 
						|
  set_row (_rw,"@32g%s", trans("TOTALI PERIODO"));
 | 
						|
  set_row (_rw,"@66g%r", &_saldo_periodo);
 | 
						|
  set_row (_rw,"@83g%r", &_totale_periodo_dare);   
 | 
						|
  set_row (_rw++,"@100g%r", &_totale_periodo_avere);
 | 
						|
  
 | 
						|
  set_row (_rw,"@32g%s", trans("TOTALI PROGRESSIVI"));
 | 
						|
  set_row (_rw,"@66g%r", &_saldo_progre);
 | 
						|
  set_row (_rw,"@83g%r", &_totprogre_dare);
 | 
						|
  set_row (_rw++,"@100g%r", &_totprogre_avere);
 | 
						|
  if (_stampaprogre)                         //Progressivi attuali
 | 
						|
  {                                            
 | 
						|
    set_row (_rw,"@32g%s %s", trans("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string());
 | 
						|
    set_row (_rw,"@66g%r", &_saldo_progre_al);
 | 
						|
    set_row (_rw,"@83g%r", &_totprogre_dare_al);
 | 
						|
    set_row (_rw,"@100g%r", &_totprogre_avere_al);
 | 
						|
  }                        
 | 
						|
  _devi_stampare_footer = FALSE;   
 | 
						|
  
 | 
						|
  aggiorna_totali_gb();
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::carica_array_totali132()
 | 
						|
{
 | 
						|
  TString sep(132);
 | 
						|
  TToken_string r(255); 
 | 
						|
  
 | 
						|
  if (_nummast == 2)
 | 
						|
    _rw = 1;
 | 
						|
 | 
						|
  _totprogre_dare=_progredare+_totale_periodo_dare;
 | 
						|
  _totprogre_avere=_progreavere+_totale_periodo_avere;
 | 
						|
  _saldo_periodo = _totale_periodo_dare - _totale_periodo_avere;
 | 
						|
  _saldo_progre = _totprogre_dare - _totprogre_avere;
 | 
						|
  _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | 
						|
 | 
						|
  sep.fill(' ');
 | 
						|
  r.add("@0g%s");
 | 
						|
  r.add(sep);  
 | 
						|
  _lista.add(r);  
 | 
						|
  r = "";
 | 
						|
  
 | 
						|
  sep.fill('-');                            //Stampa 132 - (sep(132))      
 | 
						|
  r.add("@0g%s");
 | 
						|
  r.add(sep);
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
 | 
						|
  r.add("@32g%s@66g%s@83g%s@100g%s");
 | 
						|
  r.add(trans("TOTALI PERIODO"));
 | 
						|
  r.add(_saldo_periodo.string(_real_picture));     
 | 
						|
  r.add(_totale_periodo_dare.string(_real_picture));
 | 
						|
  r.add(_totale_periodo_avere.string(_real_picture));
 | 
						|
  _lista.add(r);  
 | 
						|
  r = "";
 | 
						|
 | 
						|
  r.add("@32g%s@66g%s@83g%s@100g%s");
 | 
						|
  r.add(trans("TOTALI PROGRESSIVI"));
 | 
						|
  r.add(_saldo_progre.string(_real_picture));       
 | 
						|
  r.add(_totprogre_dare.string(_real_picture));
 | 
						|
  r.add(_totprogre_avere.string(_real_picture));
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
  
 | 
						|
  if (_stampaprogre)                         //Progressivi attuali
 | 
						|
  {
 | 
						|
    r.add("@32g%s@55g%s@66g%s@83g%s@100g%s");
 | 
						|
    r.add(trans("TOTALI PROGRESSIVI AL"));
 | 
						|
    r.add(_ultima_data_reg.string());
 | 
						|
    r.add(_saldo_progre_al.string(_real_picture));
 | 
						|
    r.add(_totprogre_dare_al.string(_real_picture));
 | 
						|
    r.add(_totprogre_avere_al.string(_real_picture));
 | 
						|
    _lista.add(r);
 | 
						|
    r = "";
 | 
						|
  } 
 | 
						|
 | 
						|
  if (_stampatotiva)
 | 
						|
  {         
 | 
						|
    real totale;
 | 
						|
    
 | 
						|
    sep.fill(' ');
 | 
						|
    r.add("@0g%s");
 | 
						|
    r.add(sep);  
 | 
						|
    _lista.add(r);  
 | 
						|
    r = "";
 | 
						|
 | 
						|
    TString fmt ("@0g%s");
 | 
						|
    TString fmt1(format("@%dg", _ddociva_len));
 | 
						|
    fmt << fmt1 << "%15s";
 | 
						|
 | 
						|
    for (int j = 0; j < _b.items(); j++)
 | 
						|
    {
 | 
						|
      TDociva& riga = (TDociva&)_b[j];
 | 
						|
      r.add(fmt);
 | 
						|
      r.add(riga._descrdoc);   
 | 
						|
      totale = riga._totdociva;
 | 
						|
      r.add(totale.string(_real_picture));
 | 
						|
      _lista.add(r);
 | 
						|
      r = "";
 | 
						|
    }
 | 
						|
 | 
						|
    _b.destroy();
 | 
						|
  }
 | 
						|
  
 | 
						|
  _indice_lista = 0;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::stampa_totali132_II()
 | 
						|
{                              
 | 
						|
  int riga,cur_row,diff;
 | 
						|
  int lim = 0;
 | 
						|
  
 | 
						|
  _item_lista = _lista.items();
 | 
						|
  
 | 
						|
  if ( (_conta_mastrini % 2) != 0 )
 | 
						|
  {
 | 
						|
    riga    = (printer().formlen() / 2);    //- 1;
 | 
						|
    cur_row = printer().formlen() - printer().rows_left();
 | 
						|
    diff    = riga - cur_row;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    riga    = printer().formlen();          //- 1;
 | 
						|
    cur_row = printer().formlen() - printer().rows_left();
 | 
						|
    diff    = riga - cur_row;
 | 
						|
  }
 | 
						|
 | 
						|
  if (_indice_lista == 0 && diff != 0)
 | 
						|
  {
 | 
						|
    if (_item_lista > diff)
 | 
						|
      lim = diff;
 | 
						|
    else
 | 
						|
      lim = _item_lista;
 | 
						|
  }
 | 
						|
  else  
 | 
						|
  {
 | 
						|
    lim = _item_lista;
 | 
						|
    _rw = 1;
 | 
						|
    _rw = crea_intestazione(_rw);
 | 
						|
    _rw = stampa_progre_riporto(_rw);          
 | 
						|
    if ( (_conta_mastrini % 2) != 0 )
 | 
						|
    {
 | 
						|
      riga    = (printer().formlen() / 2);    //- 1;
 | 
						|
      cur_row = _rw;
 | 
						|
      diff    = riga - cur_row;
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      riga    = printer().formlen();          //- 1;
 | 
						|
      cur_row = _rw + (printer().formlen() / 2); //32;
 | 
						|
      diff    = riga - cur_row;
 | 
						|
    }
 | 
						|
  }
 | 
						|
            
 | 
						|
  for (int i = _indice_lista; i < lim; i++)
 | 
						|
  {
 | 
						|
    TToken_string& data = (TToken_string&)_lista[i];
 | 
						|
  
 | 
						|
    TString fmt  (data.get(0));
 | 
						|
    TString arg1 (data.get(1));
 | 
						|
    TString arg2 (data.get(2));
 | 
						|
    TString arg3 (data.get(3));
 | 
						|
    TString arg4 (data.get(4));
 | 
						|
    
 | 
						|
    set_row(_rw++,fmt, (const char*) arg1, (const char*) arg2, (const char*) arg3, (const char*) arg4);         
 | 
						|
    
 | 
						|
    _indice_lista++;
 | 
						|
  }                  
 | 
						|
  
 | 
						|
  if (_item_lista <= diff)
 | 
						|
    _lista.destroy();
 | 
						|
  
 | 
						|
  _devi_stampare_footer = FALSE;  
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::stampa_totali198()
 | 
						|
{
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 1;
 | 
						|
 | 
						|
  TString sep(198);
 | 
						|
  sep.fill('-');                            //Stampa 198 - (sep(198))      
 | 
						|
  set_row(_rw++,"@0g%s", (const char*)sep);
 | 
						|
 | 
						|
  _totprogre_dare=_progredare+_totale_periodo_dare;
 | 
						|
  _totprogre_avere=_progreavere+_totale_periodo_avere;
 | 
						|
 | 
						|
  set_row (_rw,"@32g%s@100g%r", trans("TOTALI PERIODO"), &_totale_periodo_dare);
 | 
						|
  set_row (_rw,"@117g%r", &_totale_periodo_avere);
 | 
						|
  set_row (_rw++,"@151g%r", &_saldo_movimenti);
 | 
						|
  set_row (_rw,"@32g%s@100g%r", trans("TOTALI PROGRESSIVI"), &_totprogre_dare);
 | 
						|
  set_row (_rw,"@117g%r", &_totprogre_avere);
 | 
						|
  set_row (_rw++,"@134g%r", &_saldo_progressivi);
 | 
						|
  if (_stampaprogre)                          //Progressivi attuali
 | 
						|
  {
 | 
						|
    _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | 
						|
    set_row(_rw,"@32g%s@55g%s", trans("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string());
 | 
						|
    set_row (_rw,"@100g%r", &_totprogre_dare_al);
 | 
						|
    set_row (_rw,"@117g%r", &_totprogre_avere_al); 
 | 
						|
    set_row (_rw,"@134g%r", &_saldo_progre_al);
 | 
						|
  }                             
 | 
						|
  _devi_stampare_footer = FALSE;
 | 
						|
  
 | 
						|
  aggiorna_totali_gb();
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::carica_array_totali198()
 | 
						|
{
 | 
						|
  TString sep(198);
 | 
						|
  TToken_string r(255); 
 | 
						|
  
 | 
						|
  if (_nummast == 2)
 | 
						|
    _rw = 1;
 | 
						|
            
 | 
						|
  sep.fill(' ');                            //Stampa 132 - (sep(132))      
 | 
						|
  r.add("@0g%s");
 | 
						|
  r.add(sep);
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
 | 
						|
  sep.fill('-');                            //Stampa 132 - (sep(132))      
 | 
						|
  r.add("@0g%s");
 | 
						|
  r.add(sep);
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
 | 
						|
  _totprogre_dare=_progredare+_totale_periodo_dare;
 | 
						|
  _totprogre_avere=_progreavere+_totale_periodo_avere;
 | 
						|
 | 
						|
  r.add("@32g%s@100g%s@117g%s@151g%s");
 | 
						|
  r.add(trans("TOTALI PERIODO"));
 | 
						|
  r.add(_totale_periodo_dare.string(_real_picture));
 | 
						|
  r.add(_totale_periodo_avere.string(_real_picture));
 | 
						|
  r.add(_saldo_movimenti.string(_real_picture));
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
 | 
						|
  r.add("@32g%s@100g%s@117g%s@134g%s");
 | 
						|
  r.add(trans("TOTALI PROGRESSIVI"));
 | 
						|
  r.add(_totprogre_dare.string(_real_picture));
 | 
						|
  r.add(_totprogre_avere.string(_real_picture));
 | 
						|
  r.add(_saldo_progressivi.string(_real_picture));     
 | 
						|
  _lista.add(r);
 | 
						|
  r = "";
 | 
						|
  
 | 
						|
  if (_stampaprogre)                          //Progressivi attuali
 | 
						|
  {
 | 
						|
    _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al;
 | 
						|
    r.add("@32g%s@55g%s@100g%s@117g%s@134g%s");
 | 
						|
    r.add(trans("TOTALI PROGRESSIVI AL"));
 | 
						|
    r.add(_ultima_data_reg.string());
 | 
						|
    r.add(_totprogre_dare_al.string(_real_picture));
 | 
						|
    r.add(_totprogre_avere_al.string(_real_picture));
 | 
						|
    r.add(_saldo_progre_al.string(_real_picture));    
 | 
						|
    _lista.add(r);
 | 
						|
    r = "";
 | 
						|
  }                 
 | 
						|
 | 
						|
  if (_stampatotiva)
 | 
						|
  { 
 | 
						|
    real totale;
 | 
						|
    
 | 
						|
    sep.fill(' ');
 | 
						|
    r.add("@0g%s");
 | 
						|
    r.add(sep);  
 | 
						|
    _lista.add(r);  
 | 
						|
    r = "";
 | 
						|
 | 
						|
//  Guy: Real dick programmig!    
 | 
						|
//    TString fmt ("@0g%s");
 | 
						|
//    TString fmt1(format("@%dg", _ddociva_len));
 | 
						|
//    fmt << fmt1 << "%15s";
 | 
						|
    
 | 
						|
    TString16 fmt;
 | 
						|
    fmt << "@0g%s@" << _ddociva_len << "g%15s";
 | 
						|
    
 | 
						|
    for (int j = 0; j < _b.items(); j++)
 | 
						|
    {
 | 
						|
      TDociva& riga = (TDociva&)_b[j];
 | 
						|
      r.add(fmt);
 | 
						|
      r.add(riga._descrdoc);   
 | 
						|
      totale = riga._totdociva;
 | 
						|
      r.add(totale.string(_real_picture));
 | 
						|
      _lista.add(r);
 | 
						|
      r = "";
 | 
						|
    }
 | 
						|
 | 
						|
    _b.destroy();
 | 
						|
  }
 | 
						|
  
 | 
						|
  _indice_lista = 0;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::stampa_totali198_II()
 | 
						|
{
 | 
						|
  int riga,cur_row,diff;
 | 
						|
  int lim = 0;
 | 
						|
  
 | 
						|
  _item_lista = _lista.items();
 | 
						|
  
 | 
						|
  if ( (_conta_mastrini % 2) != 0 )
 | 
						|
  {
 | 
						|
    riga    = (printer().formlen() / 2);    //- 1;
 | 
						|
    cur_row = printer().formlen() - printer().rows_left();
 | 
						|
    diff    = riga - cur_row;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    riga    = printer().formlen();          //- 1;
 | 
						|
    cur_row = printer().formlen() - printer().rows_left();
 | 
						|
    diff    = riga - cur_row;
 | 
						|
  }
 | 
						|
 | 
						|
  if (_indice_lista == 0 && diff != 0)
 | 
						|
  {
 | 
						|
    if (_item_lista > diff)
 | 
						|
      lim = diff;
 | 
						|
    else
 | 
						|
      lim = _item_lista;
 | 
						|
  }
 | 
						|
  else  
 | 
						|
  {
 | 
						|
    lim = _item_lista;
 | 
						|
    _rw = 1;
 | 
						|
    _rw = crea_intestazione(_rw);
 | 
						|
    _rw = stampa_progre_riporto(_rw);          
 | 
						|
    if ( (_conta_mastrini % 2) != 0 )
 | 
						|
    {
 | 
						|
      riga    = (printer().formlen() / 2);    //- 1;
 | 
						|
      cur_row = _rw;
 | 
						|
      diff    = riga - cur_row;
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      riga    = printer().formlen();          //- 1;
 | 
						|
      cur_row = _rw + (printer().formlen() / 2);  //32;
 | 
						|
      diff    = riga - cur_row;
 | 
						|
    }
 | 
						|
  }
 | 
						|
            
 | 
						|
  for (int i = _indice_lista; i < lim; i++)
 | 
						|
  {
 | 
						|
    TToken_string& data = (TToken_string&)_lista[i];
 | 
						|
  
 | 
						|
    TString fmt  (data.get(0));
 | 
						|
    TString arg1 (data.get(1));
 | 
						|
    TString arg2 (data.get(2));
 | 
						|
    TString arg3 (data.get(3));
 | 
						|
    TString arg4 (data.get(4));
 | 
						|
    
 | 
						|
    set_row(_rw++,fmt, (const char*) arg1, (const char*) arg2, (const char*) arg3, (const char*) arg4);         
 | 
						|
    
 | 
						|
    _indice_lista++;
 | 
						|
  }                  
 | 
						|
  
 | 
						|
  if (_item_lista <= diff)
 | 
						|
    _lista.destroy();           
 | 
						|
    
 | 
						|
  _devi_stampare_footer = FALSE;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::setta_riga (int r, TString riga)
 | 
						|
{                         
 | 
						|
  TString *p = (TString*)_riga.objptr(r);
 | 
						|
  if (!p)
 | 
						|
  {
 | 
						|
    p = new TString;
 | 
						|
    _riga.add (p);
 | 
						|
  }
 | 
						|
  *p << riga;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::preprocess_page(int file, int counter)
 | 
						|
{ 
 | 
						|
  TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
 | 
						|
  long    rec;
 | 
						|
  TDate   datasucc;
 | 
						|
  TString datasuccstring,dataregrmovstring;
 | 
						|
  int     gruppof,contof;
 | 
						|
  long    sottocf;
 | 
						|
  TString provvis = "";
 | 
						|
  int     annoes;
 | 
						|
 | 
						|
  if (counter)
 | 
						|
    return TRUE;
 | 
						|
  
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
    case LF_SALDI:
 | 
						|
    {
 | 
						|
// Usati in crea_intestazione()
 | 
						|
      
 | 
						|
      _devi_stampare_footer = TRUE;
 | 
						|
       
 | 
						|
      if (_nummast == 3 || _nummast == 2)
 | 
						|
      {
 | 
						|
        _rw = 0;
 | 
						|
        _rw++;
 | 
						|
      }
 | 
						|
       
 | 
						|
      const TRectype& recsaldi = current_cursor()->curr(LF_SALDI);
 | 
						|
 | 
						|
      _gruppo = recsaldi.get_int(SLD_GRUPPO);
 | 
						|
      _conto  = recsaldi.get_int(SLD_CONTO);
 | 
						|
      _sottoc = recsaldi.get_long(SLD_SOTTOCONTO); 
 | 
						|
      
 | 
						|
      _cambia_mastrino = TRUE;
 | 
						|
      
 | 
						|
      annoes  = recsaldi.get_int(SLD_ANNOES);  
 | 
						|
      conto(_gruppo,_conto,TRUE);
 | 
						|
 | 
						|
      if (annoes != _anno_corrente && annoes != _anno_precedente)
 | 
						|
        return FALSE;
 | 
						|
 | 
						|
      if (_g_prec == _gruppo && _c_prec == _conto /* && _s_prec == _sottoc */)
 | 
						|
        return FALSE;
 | 
						|
 | 
						|
      _g_prec = _gruppo;
 | 
						|
      _c_prec = _conto;
 | 
						|
      _s_prec = _sottoc;
 | 
						|
 | 
						|
      _saldo_periodo = ZERO;
 | 
						|
      _totale_periodo_dare = ZERO;
 | 
						|
      _totale_periodo_avere = ZERO;
 | 
						|
      _saldo_progre = ZERO;
 | 
						|
      _totprogre_dare = ZERO;
 | 
						|
      _totprogre_avere = ZERO;
 | 
						|
      _saldo_progre_al = ZERO;
 | 
						|
      _totprogre_dare_al = ZERO;
 | 
						|
      _totprogre_avere_al = ZERO;
 | 
						|
      _progredare = ZERO;
 | 
						|
      _progreavere = ZERO;
 | 
						|
      _totale_prima_dare = ZERO;
 | 
						|
      _totale_prima_avere = ZERO;
 | 
						|
      _saldo_movimenti = ZERO;
 | 
						|
      _saldo_progressivi = ZERO;
 | 
						|
      _saldo_progre_prec = ZERO;
 | 
						|
      if (_tipostampa == 2)
 | 
						|
      {
 | 
						|
//        saldi_zero();
 | 
						|
        calcola_progressivi();
 | 
						|
        _totale_saldo = _totprogre_dare_al - _totprogre_avere_al;
 | 
						|
      }
 | 
						|
//      else
 | 
						|
//        _totale_saldo = 1.0;
 | 
						|
                      
 | 
						|
      if ((_tipostampa == 1) || (_tipostampa == 2))
 | 
						|
      {  
 | 
						|
        if ((_tipostampa == 1 && almeno_un_record()) ||
 | 
						|
            (_tipostampa == 2 && _totale_saldo != ZERO))
 | 
						|
        {                                
 | 
						|
          _puoi_stampare = TRUE;  
 | 
						|
          
 | 
						|
          if (_nummast == 3 || _nummast == 2)  
 | 
						|
          {                           
 | 
						|
            int cur_row = printer().formlen() - printer().rows_left();
 | 
						|
            int diff = printer().formlen() - cur_row;
 | 
						|
            if (diff <= 13 && diff != 0)
 | 
						|
              printer().formfeed();
 | 
						|
              
 | 
						|
            _rw = crea_intestazione(_rw);
 | 
						|
            calcola_progressivi();
 | 
						|
            _saldo_progressivi += _saldo_progre_prec;          
 | 
						|
            _rw = stampa_progre_riporto(_rw);
 | 
						|
          }
 | 
						|
        }  
 | 
						|
        else
 | 
						|
        {
 | 
						|
          _puoi_stampare = FALSE; 
 | 
						|
          return FALSE;
 | 
						|
        }                      
 | 
						|
      }
 | 
						|
      else
 | 
						|
        if (_tipostampa == 3) 
 | 
						|
        {  
 | 
						|
          calcola_progressivi();
 | 
						|
          if (_progredare == ZERO && _progreavere == ZERO && !almeno_un_record())  
 | 
						|
          { 
 | 
						|
            _puoi_stampare = FALSE;
 | 
						|
            return FALSE;
 | 
						|
          }
 | 
						|
          else               
 | 
						|
          {                                
 | 
						|
            _puoi_stampare = TRUE; 
 | 
						|
            
 | 
						|
            if (_nummast == 3 || _nummast == 2)
 | 
						|
            {                                                        
 | 
						|
              int cur_row = printer().formlen() - printer().rows_left();            
 | 
						|
              int diff = printer().formlen() - cur_row;
 | 
						|
              if (diff <= 13 && diff != 0)
 | 
						|
                printer().formfeed();
 | 
						|
                
 | 
						|
              _rw = crea_intestazione(_rw);
 | 
						|
              _saldo_progressivi += _saldo_progre_prec;
 | 
						|
              _rw = stampa_progre_riporto(_rw);
 | 
						|
            }
 | 
						|
          }
 | 
						|
        }    
 | 
						|
      }
 | 
						|
      break;
 | 
						|
 | 
						|
    case LF_RMOV:
 | 
						|
    {
 | 
						|
     //Il flag _gia_stampata_intestazione serve nella stampa in continuo, xche'
 | 
						|
     //sono costretto a richiamare l'intestazione sia nella preprocess_page (per
 | 
						|
     //i mastrini con intestazione a meta' pagina), sia nella preprocess_header
 | 
						|
     //per i mastrini che si trovano a cavallo fra una pagina e quella successiva.
 | 
						|
     //In quest'ultimo caso infatti quando vado a pagina nuova devo stampare l'intestazione
 | 
						|
     //ma senza il flag rischio di stamparla due volte.
 | 
						|
     if (_nummast == 3)
 | 
						|
        _gia_stampata_intestazione = FALSE;  
 | 
						|
      
 | 
						|
      if (_nummast == 1 || _nummast == 3)
 | 
						|
        _rw = 1;
 | 
						|
        
 | 
						|
      // Ricerca la contropartita di quel movimento
 | 
						|
      
 | 
						|
      TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
 | 
						|
      const TRectype& curmov = rmov.curr();
 | 
						|
           
 | 
						|
      _numreg = curmov.get_long(RMV_NUMREG);
 | 
						|
      _numrig = curmov.get_int(RMV_NUMRIG);
 | 
						|
 | 
						|
      _gruppocontr     = curmov.get_int (RMV_GRUPPOC);
 | 
						|
      _contocontr      = curmov.get_int (RMV_CONTOC);
 | 
						|
      _sottocontocontr = curmov.get_long(RMV_SOTTOCONTOC);  
 | 
						|
      _g_contr = curmov.get(RMV_GRUPPOC);
 | 
						|
      _c_contr = curmov.get(RMV_CONTOC);
 | 
						|
      _s_contr = curmov.get(RMV_SOTTOCONTOC);
 | 
						|
 | 
						|
      _str_tipo  = curmov.get(RMV_TIPOC);
 | 
						|
      _str_sotto = curmov.get(RMV_SOTTOCONTO);
 | 
						|
 | 
						|
    // Stampa solo quelli che hanno anno esercizio uguale a quello specificato
 | 
						|
    // nella maschera. Se non viene specificato li stampa tutti
 | 
						|
 | 
						|
      _importo = curmov.get_real(RMV_IMPORTO);
 | 
						|
      _importo_str = _importo.string(_real_picture);
 | 
						|
      _mov->setkey(1);
 | 
						|
      _mov->curr().zero();
 | 
						|
      _mov->curr().put(MOV_NUMREG,_numreg);
 | 
						|
      _mov->read();
 | 
						|
      if (_mov->bad())
 | 
						|
        _mov->zero();
 | 
						|
      _annoes  = _mov->get_int(MOV_ANNOES);
 | 
						|
      _regiva  = _mov->curr().get(MOV_REG);   
 | 
						|
      _annoiva = _mov->curr().get_int(MOV_ANNOIVA);
 | 
						|
 | 
						|
      // Controlla se saldo e' diverso da 0
 | 
						|
 | 
						|
      if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0.0))
 | 
						|
      { 
 | 
						|
        _sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE);     
 | 
						|
 | 
						|
        if (_annomsk == 0)
 | 
						|
        {
 | 
						|
          _datareg = (_mov->curr().get(MOV_DATAREG));
 | 
						|
          _datareg_stampa = _datareg;
 | 
						|
        }
 | 
						|
        else
 | 
						|
          if (_annomsk != 0)
 | 
						|
          {
 | 
						|
            _datareg = _mov->curr().get(MOV_DATACOMP);
 | 
						|
            _datareg_stampa = _mov->curr().get(MOV_DATAREG);
 | 
						|
          }
 | 
						|
 | 
						|
        provvis  =  _mov->curr().get(MOV_PROVVIS);
 | 
						|
  
 | 
						|
        _dataregs = _datareg_stampa.string();
 | 
						|
 | 
						|
        if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty())))
 | 
						|
        {
 | 
						|
          if ((_datareg >= _data_ini) && (_datareg <= _data_fine))
 | 
						|
          {   
 | 
						|
            // Determino l' anno di competenza dell' operazione in esame          
 | 
						|
            int anno = date2esc(_datareg_stampa);
 | 
						|
            if (anno != _annoes)
 | 
						|
              if (_numcarat == 1)
 | 
						|
                set_row (_rw, "@131g*");
 | 
						|
              else
 | 
						|
                set_row (_rw, "@197g*");
 | 
						|
 | 
						|
            if (_stampa_mov_prov  && provvis.trim().not_empty()) 
 | 
						|
              if (_numcarat == 1)
 | 
						|
                set_row(_rw, "@129gP"); 
 | 
						|
              else
 | 
						|
                set_row(_rw, "@195gP");
 | 
						|
                
 | 
						|
            _codcaus = _mov->curr().get(MOV_CODCAUS);
 | 
						|
            _tipodoc = _mov->curr().get(MOV_TIPODOC);
 | 
						|
            if (_stampatotiva && (_tmcf == 'C' || _tmcf == 'F'))
 | 
						|
            {  
 | 
						|
              if (_tipodoc != "")
 | 
						|
              {
 | 
						|
                documenti_iva();
 | 
						|
                _b.add_riga(_descrdociva,_importo, _natdoc);     
 | 
						|
                if (_descrdociva.len() > _ddociva_len)
 | 
						|
                  _ddociva_len = _descrdociva.len();
 | 
						|
              }
 | 
						|
            }
 | 
						|
            _datadoc = (_mov->curr().get(MOV_DATADOC));
 | 
						|
            _datadocs = _datadoc.string();
 | 
						|
            _numdoc = _mov->curr().get(MOV_NUMDOC);
 | 
						|
            descrizione_causale();
 | 
						|
            _descrizionemov = _mov->curr().get(MOV_DESCR);
 | 
						|
            _numgio = atol(_mov->curr().get(MOV_NUMGIO));
 | 
						|
 | 
						|
            _descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR);
 | 
						|
          
 | 
						|
            if (_nummast == 1 || _nummast == 3)
 | 
						|
            {
 | 
						|
              if (_numcarat == 1)     // Stampa 132 caratteri
 | 
						|
              {
 | 
						|
                if (_descrizione != "")
 | 
						|
                {
 | 
						|
                  *_d23 = (const char*) _descrizione;
 | 
						|
                  if (_descrizionemov != "")
 | 
						|
                  {                                    
 | 
						|
                    *_d18 = (const char*) _descrizionemov;
 | 
						|
                    set_row(_rw, "@42g#a", _d18);
 | 
						|
                    set_row(_rw, "@61g#a", _d23);
 | 
						|
                  }
 | 
						|
                  else if (_descrizionemov == "")
 | 
						|
                  { 
 | 
						|
                    *_d18 = (const char*) _descrcaus;
 | 
						|
                    set_row(_rw, "@42g#a", _d18);
 | 
						|
                    set_row(_rw, "@61g#a", _d23);
 | 
						|
                  }
 | 
						|
                }
 | 
						|
                else if (_descrizione == "")
 | 
						|
                       if (_descrizionemov != "")
 | 
						|
                       {
 | 
						|
                         *_d23 = (const char*) _descrizionemov;
 | 
						|
                         *_d18 = (const char*) _descrcaus;
 | 
						|
                         set_row (_rw,"@42g#a", _d18); 
 | 
						|
                         set_row (_rw,"@61g#a", _d23);
 | 
						|
                       }
 | 
						|
                       else
 | 
						|
                         if (_descrizionemov == "")
 | 
						|
                         {
 | 
						|
                           conto(_gruppocontr,_contocontr,FALSE);
 | 
						|
                           TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | 
						|
                           TString80 descr_contr = tc.descrizione();    
 | 
						|
                           //set_row (1,"@42g%.18s", (const char*) _descrcaus); 
 | 
						|
                           //if (descr_contr != "Sconosciuto")
 | 
						|
                           //  set_row (1,"@61g%.23s", (const char*) descr_contr);
 | 
						|
                           *_d18 = (const char*) _descrcaus;
 | 
						|
                           set_row (_rw,"@42g#a", _d18); 
 | 
						|
                           if (descr_contr != "Sconosciuto")
 | 
						|
                           {
 | 
						|
                             *_d23 = (const char*) descr_contr;
 | 
						|
                             set_row (_rw,"@61g#a", _d23);
 | 
						|
                           }
 | 
						|
                         }  
 | 
						|
              }
 | 
						|
              else
 | 
						|
                if (_numcarat == 2)     // Stampa 198 caratteri
 | 
						|
                {
 | 
						|
                  if (_descrizione != "")
 | 
						|
                  {
 | 
						|
                    *_d30 = (const char*) _descrizione;
 | 
						|
                    if (_descrizionemov != "")
 | 
						|
                    {                                    
 | 
						|
                      *_d23 = (const char*) _descrizionemov;
 | 
						|
                      set_row (_rw,"@46g#a", _d23);
 | 
						|
                      set_row (_rw,"@70g#a", _d30);
 | 
						|
                    }
 | 
						|
                    else if (_descrizionemov == "")
 | 
						|
                    { 
 | 
						|
                      //set_row (1,"@46g%.23s", (const char*) _descrcaus);  
 | 
						|
                      //set_row (1,"@70g%.30s", (const char*) _descrizione); 
 | 
						|
                      *_d23 = (const char*) _descrcaus;
 | 
						|
                      set_row(_rw, "@46g#a", _d23);
 | 
						|
                      set_row(_rw, "@70g#a", _d30);
 | 
						|
                    }
 | 
						|
                  }
 | 
						|
                  else if (_descrizione == "") 
 | 
						|
                         if (_descrizionemov != "")
 | 
						|
                         {
 | 
						|
                           //set_row (1,"@46g%.23s", (const char*) _descrcaus); 
 | 
						|
                           //set_row (1,"@70g%.30s", (const char*) _descrizionemov);
 | 
						|
                           *_d30 = (const char*) _descrizionemov;
 | 
						|
                           *_d23 = (const char*) _descrcaus;
 | 
						|
                           set_row (_rw,"@46g#a", _d23); 
 | 
						|
                           set_row (_rw,"@70g#a", _d30);
 | 
						|
                         }
 | 
						|
                         else
 | 
						|
                           if (_descrizionemov == "")
 | 
						|
                           {
 | 
						|
                             conto(_gruppocontr,_contocontr,FALSE);
 | 
						|
                             TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | 
						|
                             TString descr_contr = tc.descrizione();
 | 
						|
                             //set_row (1,"@46g%.23s", (const char*) _descrcaus); 
 | 
						|
                             //if (descr_contr != "Sconosciuto")
 | 
						|
                             //  set_row (1,"@70g%.30s", (const char*) descr_contr);                       
 | 
						|
                             *_d23 = (const char*) _descrcaus;
 | 
						|
                             set_row (_rw,"@46g#a", _d23); 
 | 
						|
                             if (descr_contr != "Sconosciuto")
 | 
						|
                             {
 | 
						|
                              *_d30 = (const char*) descr_contr;
 | 
						|
                              set_row (_rw,"@70g#a", _d30);
 | 
						|
                             }
 | 
						|
                           }
 | 
						|
                }
 | 
						|
            }  //if (_nummast == 1 || _nummast == 3)
 | 
						|
          
 | 
						|
            if (_nummast == 2)
 | 
						|
            {                       
 | 
						|
              TString d18,d23,d30;
 | 
						|
            
 | 
						|
              if (_numcarat == 1)     // Stampa 132 caratteri
 | 
						|
              {
 | 
						|
                if (_descrizione != "")
 | 
						|
                {
 | 
						|
                  d23 = _descrizione;
 | 
						|
                  if (_descrizionemov != "")
 | 
						|
                    d18 = _descrizionemov;
 | 
						|
                  else if (_descrizionemov == "")
 | 
						|
                    d18 = _descrcaus;
 | 
						|
                }
 | 
						|
                else if (_descrizione == "")
 | 
						|
                       if (_descrizionemov != "")
 | 
						|
                       {
 | 
						|
                         d23 = _descrizionemov;
 | 
						|
                         d18 = _descrcaus;
 | 
						|
                       }
 | 
						|
                       else
 | 
						|
                         if (_descrizionemov == "")
 | 
						|
                         {
 | 
						|
                           conto(_gruppocontr,_contocontr,FALSE);
 | 
						|
                           TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | 
						|
                           TString80 descr_contr = tc.descrizione();    
 | 
						|
                           d18 = _descrcaus;
 | 
						|
                           if (descr_contr != "Sconosciuto")
 | 
						|
                             d23 = descr_contr;
 | 
						|
                         }  
 | 
						|
                        
 | 
						|
                TParagraph_string d_18 (d18,18);
 | 
						|
                int i = 0;  
 | 
						|
                const char* str;
 | 
						|
                while ( (str = d_18.get()) != NULL)
 | 
						|
                { 
 | 
						|
                  TString stringa = "";
 | 
						|
                  stringa << "@42g" << str;
 | 
						|
                  setta_riga(i,stringa);
 | 
						|
                  i++;
 | 
						|
                }
 | 
						|
                
 | 
						|
                TParagraph_string d_23 (d23,23);
 | 
						|
                i = 0;
 | 
						|
                while ( (str = d_23.get()) != NULL)
 | 
						|
                {
 | 
						|
                  TString stringa = "";
 | 
						|
                  stringa << "@61g" << str;
 | 
						|
                  setta_riga(i,stringa);
 | 
						|
                  i++;
 | 
						|
                }           
 | 
						|
              }
 | 
						|
              else
 | 
						|
                if (_numcarat == 2)     // Stampa 198 caratteri
 | 
						|
                {
 | 
						|
                  if (_descrizione != "")
 | 
						|
                  {
 | 
						|
                    d30 = _descrizione;
 | 
						|
                    if (_descrizionemov != "")
 | 
						|
                      d23 = _descrizionemov;
 | 
						|
                    else if (_descrizionemov == "")
 | 
						|
                      d23 = _descrcaus;
 | 
						|
                  }
 | 
						|
                  else if (_descrizione == "") 
 | 
						|
                         if (_descrizionemov != "")
 | 
						|
                         {
 | 
						|
                           d30 = _descrizionemov;
 | 
						|
                           d23 = _descrcaus;
 | 
						|
                         }
 | 
						|
                         else
 | 
						|
                           if (_descrizionemov == "")
 | 
						|
                           {
 | 
						|
                             conto(_gruppocontr,_contocontr,FALSE);
 | 
						|
                             TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr);
 | 
						|
                             TString descr_contr = tc.descrizione();
 | 
						|
                             d23 = _descrcaus;
 | 
						|
                             if (descr_contr != "Sconosciuto")
 | 
						|
                              d30 = descr_contr;
 | 
						|
                           }
 | 
						|
                         
 | 
						|
                  TParagraph_string d_23 (d23,23);
 | 
						|
                  int i = 0;
 | 
						|
                  const char* str;
 | 
						|
                  while ( (str = d_23.get()) != NULL)
 | 
						|
                  { 
 | 
						|
                    TString stringa = "";
 | 
						|
                    stringa << "@46g" << str;
 | 
						|
                    setta_riga(i,stringa);
 | 
						|
                    i++;
 | 
						|
                  }
 | 
						|
                
 | 
						|
                  TParagraph_string d_30 (d30,30);
 | 
						|
                  i = 0;
 | 
						|
                  while ( (str = d_30.get()) != NULL)
 | 
						|
                  {                     
 | 
						|
                    TString stringa = "";
 | 
						|
                    stringa << "@70g" << str;
 | 
						|
                    setta_riga(i,stringa);
 | 
						|
                    i++;
 | 
						|
                  }
 | 
						|
                }
 | 
						|
             
 | 
						|
              _item = _riga.items();
 | 
						|
              int riga,cur_row,diff;
 | 
						|
            
 | 
						|
              if ( (_conta_mastrini % 2) != 0 )
 | 
						|
              {   
 | 
						|
                int app = 0;
 | 
						|
                riga    = (printer().formlen() / 2);
 | 
						|
                if (printer().rows_left() == 0)
 | 
						|
                  app = printer().formlen() - _rw;
 | 
						|
                else    
 | 
						|
                  app = printer().rows_left();
 | 
						|
                cur_row = printer().formlen() - app;  
 | 
						|
                diff    = riga - cur_row;
 | 
						|
              }
 | 
						|
              else
 | 
						|
              {
 | 
						|
                riga    = printer().formlen();          
 | 
						|
                cur_row = printer().formlen() - printer().rows_left();
 | 
						|
                diff    = riga - cur_row;
 | 
						|
              }
 | 
						|
               
 | 
						|
              bool stampa_riporti;
 | 
						|
               
 | 
						|
              int lim = 0;
 | 
						|
              if (_item >= diff)  
 | 
						|
              { 
 | 
						|
                lim = diff - 1;
 | 
						|
                stampa_riporti = TRUE;
 | 
						|
              }
 | 
						|
              else 
 | 
						|
              {
 | 
						|
                lim = _item;   
 | 
						|
                stampa_riporti = FALSE;
 | 
						|
              }
 | 
						|
            
 | 
						|
              _indice_array = 0;
 | 
						|
            
 | 
						|
              int k = _rw;
 | 
						|
              
 | 
						|
              for (int i = 0; i < lim; i++)
 | 
						|
              {
 | 
						|
                TString& data = (TString&)_riga[i];
 | 
						|
              
 | 
						|
                int g1 = data.find("g",1);
 | 
						|
                int c1 = data.find("@",g1);
 | 
						|
                int g2 = data.find("g",c1);
 | 
						|
              
 | 
						|
                TString fmt1 = "";
 | 
						|
                TString fmt2 = "";
 | 
						|
                TString str1,str2;
 | 
						|
              
 | 
						|
                if (g1 != -1)
 | 
						|
                {
 | 
						|
                  fmt1 = data.sub(0,g1+1);
 | 
						|
                  fmt1 << "%s";
 | 
						|
                  str1 = data.sub(g1+1,c1);
 | 
						|
                }  
 | 
						|
                if (c1 != -1)
 | 
						|
                {
 | 
						|
                  fmt2 = data.sub(c1,g2+1);
 | 
						|
                  fmt2 << "%s";
 | 
						|
                  str2 = data.sub(g2+1);
 | 
						|
                }
 | 
						|
              
 | 
						|
                if (fmt1 != "")
 | 
						|
                  set_row (k,fmt1,(const char*) str1);
 | 
						|
                if (fmt2 != "")
 | 
						|
                  set_row (k,fmt2,(const char*) str2);
 | 
						|
              
 | 
						|
                k++;
 | 
						|
                _indice_array++;
 | 
						|
              }
 | 
						|
              if (stampa_riporti)
 | 
						|
              { 
 | 
						|
                _rw = k;        
 | 
						|
                if (lim == 0)
 | 
						|
                {
 | 
						|
                  if (_numcarat == 1)
 | 
						|
                  {  
 | 
						|
                    TString app(132);
 | 
						|
                    app.spaces(); 
 | 
						|
                    set_row (_rw, "@0g%s", (const char*)app);
 | 
						|
                  }
 | 
						|
                  else
 | 
						|
                  {  
 | 
						|
                    TString app(198);
 | 
						|
                    app.spaces(); 
 | 
						|
                    set_row (_rw, "@0g%s", (const char*)app);
 | 
						|
                  }
 | 
						|
                }
 | 
						|
                real dep_dare,dep_avere;
 | 
						|
                if (_stampa_footer_si)
 | 
						|
                {
 | 
						|
                  _riporto_footer_dare  = _progredare  + _riporto_parziale_dare;
 | 
						|
                  _riporto_footer_avere = _progreavere + _riporto_parziale_avere;
 | 
						|
      
 | 
						|
                  real imp_d,imp_a;
 | 
						|
                  imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
                  imp_a = _sezione == "A" ? _importo : ZERO;   
 | 
						|
                  if (lim != 0)                   
 | 
						|
                  {
 | 
						|
                    _riporto_footer_dare  += imp_d;
 | 
						|
                    _riporto_footer_avere += imp_a;
 | 
						|
                  }
 | 
						|
                  dep_dare  = _riporto_footer_dare;
 | 
						|
                  dep_avere = _riporto_footer_avere;
 | 
						|
                  
 | 
						|
                  _stampa_footer_si = FALSE;
 | 
						|
                }                           
 | 
						|
                else
 | 
						|
                {
 | 
						|
                  _riporto_footer_dare  += _riporto_parziale_dare;
 | 
						|
                  _riporto_footer_avere += _riporto_parziale_avere;
 | 
						|
 | 
						|
                  real imp_d,imp_a;
 | 
						|
                  imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
                  imp_a = _sezione == "A" ? _importo : ZERO;  
 | 
						|
                  if (lim != 0)
 | 
						|
                  {
 | 
						|
                    _riporto_footer_dare  += imp_d;
 | 
						|
                    _riporto_footer_avere += imp_a;
 | 
						|
                  }
 | 
						|
                  dep_dare  = _riporto_footer_dare;
 | 
						|
                  dep_avere = _riporto_footer_avere;
 | 
						|
                }
 | 
						|
                
 | 
						|
                if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | 
						|
                {  
 | 
						|
                  TString dare  (dep_dare.string(_real_picture));
 | 
						|
                  TString avere (dep_avere.string(_real_picture));
 | 
						|
                  if (_numcarat == 1)                  
 | 
						|
                  {
 | 
						|
                    set_row (_rw,"@32gA RIPORTO@83g%s", (const char*) dare);
 | 
						|
                    set_row (_rw,"@100g%s", (const char*) avere);
 | 
						|
                  }  
 | 
						|
                  else
 | 
						|
                    if (_numcarat == 2) 
 | 
						|
                    {
 | 
						|
                      set_row (_rw,"@32gA RIPORTO@100g%s", (const char*) dare);
 | 
						|
                      set_row (_rw,"@117g%s", (const char*) avere);
 | 
						|
                    }        
 | 
						|
                }                          
 | 
						|
                if (lim == 0)
 | 
						|
                {
 | 
						|
                  rmov.prev();
 | 
						|
                  _riga.destroy();   
 | 
						|
                  _item = 0;        
 | 
						|
                  return TRUE;  
 | 
						|
                } 
 | 
						|
                _rw--;
 | 
						|
//                return TRUE;  
 | 
						|
              }
 | 
						|
              //_riga.destroy();
 | 
						|
            }  //if (_nummast == 2)
 | 
						|
 | 
						|
            if (_sezione == "D")
 | 
						|
            {
 | 
						|
              _totale_periodo_dare += _importo;
 | 
						|
              _riporto_parziale_dare += _importo;
 | 
						|
        
 | 
						|
              if (_numcarat == 1)    // Stampa 132 caratteri
 | 
						|
                set_row (_rw,"@83g%s", (const char*) _importo_str);
 | 
						|
              else
 | 
						|
                if (_numcarat == 2)  // Stampa 198 caratteri
 | 
						|
                {
 | 
						|
                  _saldo_progressivi += _importo;
 | 
						|
                  _saldo_movimenti += _importo;
 | 
						|
                  set_row (_rw,"@100g%s", (const char*) _importo_str);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else if (_sezione == "A")
 | 
						|
                 {
 | 
						|
                   _totale_periodo_avere += _importo;
 | 
						|
                   _riporto_parziale_avere += _importo;
 | 
						|
 | 
						|
                   if (_numcarat == 1)    // Stampa 132 caratteri
 | 
						|
                     set_row (_rw,"@100g%s", (const char*) _importo_str);
 | 
						|
                   else
 | 
						|
                     if (_numcarat == 2)  // Stampa 198 caratteri
 | 
						|
                     {
 | 
						|
                       _saldo_progressivi -= _importo;
 | 
						|
                       _saldo_movimenti -= _importo;
 | 
						|
                       set_row (_rw,"@117g%s", (const char*) _importo_str);
 | 
						|
                     }
 | 
						|
                 }
 | 
						|
           
 | 
						|
            const int righe_rimaste = printer().rows_left();
 | 
						|
            _stampato = righe_rimaste >= 1;
 | 
						|
            
 | 
						|
            _saldo_progressivi_str=_saldo_progressivi.string(_real_picture);
 | 
						|
            _saldo_movimenti_str=_saldo_movimenti.string(_real_picture);
 | 
						|
            if (_numcarat == 2)
 | 
						|
            {
 | 
						|
               ricerca_regiva();
 | 
						|
              _protiva = atol(_mov->curr().get(MOV_PROTIVA));
 | 
						|
              if (_protiva != 0)   
 | 
						|
                set_row (_rw,"@191g%5d", _protiva);
 | 
						|
          
 | 
						|
              if (_tipo < 3)
 | 
						|
                set_row (_rw,"@183g#t" , &_regiva);
 | 
						|
              _dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG);
 | 
						|
              dataregrmovstring=_dataregrmov.string();
 | 
						|
 | 
						|
//Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV
 | 
						|
 | 
						|
              rec = rmov.recno();
 | 
						|
              rmov.next();
 | 
						|
              gruppof = rmov.get_int(RMV_GRUPPO);
 | 
						|
              contof = rmov.get_int(RMV_CONTO);
 | 
						|
              sottocf = rmov.get_int(RMV_SOTTOCONTO);
 | 
						|
              datasucc = rmov.get_date(RMV_DATAREG);
 | 
						|
              datasuccstring=datasucc.string();
 | 
						|
              if (((gruppof!=_gruppo)||(contof!=_conto)/*||(sottocf!=_sottoc)*/)||(rmov.eof()))
 | 
						|
                datasucc = ("");
 | 
						|
              if (datasucc != _dataregrmov)
 | 
						|
              {
 | 
						|
                /* Il flag del cazzo, beato lui */
 | 
						|
                real saldo_prog(_saldo_progressivi);
 | 
						|
                
 | 
						|
                if (_stampa_progressivi_si)
 | 
						|
                {
 | 
						|
                  calcola_progressivi();                             
 | 
						|
                  saldo_prog += _saldo_progre_prec;
 | 
						|
                }  
 | 
						|
                set_row (_rw,"@134g%r", &saldo_prog);
 | 
						|
              }
 | 
						|
 | 
						|
              rmov.readat(rec);
 | 
						|
            } 
 | 
						|
            _rw = 1;
 | 
						|
          
 | 
						|
            return TRUE;
 | 
						|
          }
 | 
						|
          else
 | 
						|
            return FALSE;         
 | 
						|
        }
 | 
						|
        else
 | 
						|
          return FALSE;
 | 
						|
      }
 | 
						|
      else
 | 
						|
        return FALSE;
 | 
						|
    break; 
 | 
						|
    }
 | 
						|
    default:
 | 
						|
      break;   
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::set_page(int file, int counter)
 | 
						|
{
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
  case LF_SALDI:
 | 
						|
    reset_print();
 | 
						|
    break;
 | 
						|
 | 
						|
  case LF_RMOV:
 | 
						|
    reset_print();
 | 
						|
    if (_numcarat == 1)
 | 
						|
      fai_stampa132();
 | 
						|
    else if (_numcarat == 2)
 | 
						|
           fai_stampa198();
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
    break;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
print_action TMastrini_application::postprocess_page(int file, int counter)
 | 
						|
{                   
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
  {
 | 
						|
    if (counter)
 | 
						|
    { 
 | 
						|
      if (_nummast == 1)      //Il salto pagina a rottura di mastrino viene
 | 
						|
        printer().formfeed(); //fatto solo quando seleziono un mastrino per pagina
 | 
						|
      
 | 
						|
      reset_print();     // per evitare che stampi di nuovo il totale prec.  
 | 
						|
      _stampa_progressivi_si  = TRUE;
 | 
						|
      _stampa_footer_si       = TRUE;
 | 
						|
      _riporto_dare           = ZERO;
 | 
						|
      _riporto_avere          = ZERO;   
 | 
						|
      _riporto_footer_dare    = ZERO;
 | 
						|
      _riporto_footer_avere   = ZERO;
 | 
						|
      _riporto_parziale_dare  = ZERO;
 | 
						|
      _riporto_parziale_avere = ZERO;
 | 
						|
      _ddociva_len            = 0;
 | 
						|
      
 | 
						|
      return NEXT_PAGE;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_nummast == 2)
 | 
						|
    { 
 | 
						|
      int item_lista = _lista.items();
 | 
						|
        
 | 
						|
      if (counter && item_lista == 0)
 | 
						|
      { 
 | 
						|
        reset_print();     // per evitare che stampi di nuovo il totale prec.  
 | 
						|
        _stampa_progressivi_si  = TRUE;  
 | 
						|
        _stampa_footer_si       = TRUE;
 | 
						|
        _riporto_dare           = ZERO;
 | 
						|
        _riporto_avere          = ZERO; 
 | 
						|
        _riporto_footer_dare    = ZERO;
 | 
						|
        _riporto_footer_avere   = ZERO;
 | 
						|
        _riporto_parziale_dare  = ZERO;
 | 
						|
        _riporto_parziale_avere = ZERO;
 | 
						|
        _ddociva_len            = 0;
 | 
						|
        
 | 
						|
        return NEXT_PAGE;
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
  switch (file)
 | 
						|
  {
 | 
						|
  case LF_SALDI:
 | 
						|
  { 
 | 
						|
    if (_nummast == 1 || _nummast == 3)
 | 
						|
    {
 | 
						|
      if (_tipostampa == 3)
 | 
						|
      {
 | 
						|
        reset_print();
 | 
						|
        if (_numcarat == 1)
 | 
						|
          stampa_totali132();
 | 
						|
        else if (_numcarat == 2)
 | 
						|
               stampa_totali198();
 | 
						|
 | 
						|
        if (_stampatotiva)     
 | 
						|
          stampa_totaliiva();
 | 
						|
      }
 | 
						|
      else if (_tipostampa == 2)
 | 
						|
           {
 | 
						|
             reset_print();
 | 
						|
             if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | 
						|
               if (_numcarat == 1)
 | 
						|
                 stampa_totali132();
 | 
						|
               else if (_numcarat == 2)
 | 
						|
                      stampa_totali198();
 | 
						|
             if (_stampatotiva)      
 | 
						|
               stampa_totaliiva();
 | 
						|
       }
 | 
						|
       else if (_tipostampa == 1)
 | 
						|
            {
 | 
						|
              reset_print();
 | 
						|
              if (_puoi_stampare)
 | 
						|
                if (_numcarat == 1)
 | 
						|
                  stampa_totali132();
 | 
						|
                else if (_numcarat == 2)
 | 
						|
                       stampa_totali198();
 | 
						|
              if (_stampatotiva)     
 | 
						|
                stampa_totaliiva();
 | 
						|
            }
 | 
						|
    }
 | 
						|
    else
 | 
						|
      if (_nummast == 2)             
 | 
						|
      {                          
 | 
						|
        if (!counter)                                                                                   
 | 
						|
        { 
 | 
						|
          if (_numcarat == 1)
 | 
						|
            carica_array_totali132();
 | 
						|
          else
 | 
						|
            if (_numcarat == 2)
 | 
						|
              carica_array_totali198(); 
 | 
						|
        }
 | 
						|
        
 | 
						|
        if (_tipostampa == 3)
 | 
						|
        {
 | 
						|
          reset_print();
 | 
						|
          if (_numcarat == 1)
 | 
						|
            stampa_totali132_II();
 | 
						|
          else if (_numcarat == 2)
 | 
						|
                 stampa_totali198_II();
 | 
						|
        }
 | 
						|
        else if (_tipostampa == 2)
 | 
						|
             {
 | 
						|
               reset_print();
 | 
						|
               if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | 
						|
                 if (_numcarat == 1)
 | 
						|
                   stampa_totali132_II();
 | 
						|
                 else if (_numcarat == 2)
 | 
						|
                        stampa_totali198_II();
 | 
						|
         }
 | 
						|
         else if (_tipostampa == 1)
 | 
						|
              {
 | 
						|
                reset_print();
 | 
						|
                if (_puoi_stampare)
 | 
						|
                  if (_numcarat == 1)
 | 
						|
                    stampa_totali132_II();
 | 
						|
                  else if (_numcarat == 2)
 | 
						|
                         stampa_totali198_II();
 | 
						|
              }
 | 
						|
              
 | 
						|
        int item_lista = _lista.items();   
 | 
						|
        
 | 
						|
        if (item_lista == 0)
 | 
						|
        {   
 | 
						|
          int righe_rimaste = righe_rimaste_da_stampare();
 | 
						|
             
 | 
						|
          righe_rimaste = righe_rimaste - _rw;  //_rw sono le righe dei totali gia' settate, mentre
 | 
						|
                                               //righe rimaste conteneva le righe senza quelle dei totali gia' settate
 | 
						|
          if (righe_rimaste > 0)
 | 
						|
          {                                
 | 
						|
            _rw++; //incremento la riga altrimenti copro l'ultimo totale settato con una riga bianca
 | 
						|
              
 | 
						|
            TString sep = " ";
 | 
						|
    
 | 
						|
            for (int i = 0; i < righe_rimaste; i++)
 | 
						|
              set_row(_rw++,"@0g%s", (const char*) sep);
 | 
						|
          }
 | 
						|
        }
 | 
						|
      }
 | 
						|
 | 
						|
//    _stampa_progressivi_si = TRUE;
 | 
						|
    return REPEAT_PAGE;
 | 
						|
  }
 | 
						|
  case LF_RMOV:  
 | 
						|
    force_setpage();
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  return NEXT_PAGE;
 | 
						|
}                                                 
 | 
						|
 | 
						|
print_action TMastrini_application::postprocess_print(int file, int counter)
 | 
						|
{
 | 
						|
  if (file == LF_SALDI)
 | 
						|
  {                                
 | 
						|
    TPrinter& p = printer();                        
 | 
						|
    
 | 
						|
    // Stampa totali Bizzarri
 | 
						|
    if (p.current_row() > 0)
 | 
						|
    {
 | 
						|
      int t1, t2, t3, t4, t5;  // Tabulatori
 | 
						|
 | 
						|
      reset_header();          // Azzera header e footer;
 | 
						|
      reset_footer();
 | 
						|
      _gb_last_page = TRUE;
 | 
						|
      
 | 
						|
      TPrintrow row;           // Stampa riga vuota
 | 
						|
      p.print(row);
 | 
						|
      if (_numcarat == 1)
 | 
						|
      {            
 | 
						|
        TString line(132, '=');
 | 
						|
        row.put(line);      
 | 
						|
        t1 = 32; t2 = 55; t3 = 66; t4 = 83; t5 = 100;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        TString line(198, '=');
 | 
						|
        row.put(line);
 | 
						|
        t1 = 32; t2 = 55; t3 = 100; t4 = 117; t5 = 134;
 | 
						|
      }
 | 
						|
      // Stampa una fila di uguali
 | 
						|
      p.print(row);
 | 
						|
      
 | 
						|
      row.reset();
 | 
						|
      row.put(trans("TOTALI GLOBALI PERIODO"), t1);
 | 
						|
      row.put(_gb_saldo_periodo.string(_real_picture), t3);
 | 
						|
      row.put(_gb_totale_periodo_dare.string(_real_picture), t4);
 | 
						|
      row.put(_gb_totale_periodo_avere.string(_real_picture), t5);
 | 
						|
      p.print(row);                       
 | 
						|
      row.reset();
 | 
						|
      row.put(trans("TOTALI GLOBALI PROGRESSIVI"), t1);
 | 
						|
      row.put(_gb_saldo_progre.string(_real_picture), t3);
 | 
						|
      row.put(_gb_totprogre_dare.string(_real_picture), t4);
 | 
						|
      row.put(_gb_totprogre_avere.string(_real_picture), t5);
 | 
						|
      p.print(row);                
 | 
						|
      if (_stampaprogre)                         //Progressivi attuali
 | 
						|
      {                                            
 | 
						|
        row.reset();
 | 
						|
        row.put(trans("TOTALI GLOBALI AL"), t1);  
 | 
						|
        row.put(_ultima_data_reg.string(), t2);
 | 
						|
        row.put(_gb_saldo_progre_al.string(_real_picture), t3);
 | 
						|
        row.put(_gb_totprogre_dare_al.string(_real_picture), t4);
 | 
						|
        row.put(_gb_totprogre_avere_al.string(_real_picture), t5);
 | 
						|
        p.print(row);                
 | 
						|
      }                        
 | 
						|
    }                        
 | 
						|
    
 | 
						|
    _msk->reset(F_GRUPPOINI);   
 | 
						|
    _msk->reset(F_CONTOINI_CONTO);    
 | 
						|
    _msk->reset(F_DESCRINI_CONTO);
 | 
						|
      
 | 
						|
    _msk->reset(F_GRUPPOFINE);      
 | 
						|
    _msk->reset(F_CONTOFINE_CONTO);
 | 
						|
    _msk->reset(F_DESCRFINE_CONTO);
 | 
						|
  }     
 | 
						|
  return NEXT_PAGE;
 | 
						|
}
 | 
						|
// Stampa dei totali documenti iva se richiesta
 | 
						|
 | 
						|
void TMastrini_application::stampa_totaliiva()
 | 
						|
{
 | 
						|
  real totale;
 | 
						|
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
  {
 | 
						|
    _rw = 7;                        
 | 
						|
    _ddociva_len++;     
 | 
						|
    TString fmt (format("@%dg", _ddociva_len));
 | 
						|
    fmt << "%15s";
 | 
						|
    
 | 
						|
    if (_stampatotiva)
 | 
						|
      for (int j = 0; j < _b.items(); j++)
 | 
						|
      {
 | 
						|
        TDociva& riga = (TDociva&)_b[j];
 | 
						|
        set_row(_rw+j, "@0g%s",(const char*) riga._descrdoc);   
 | 
						|
        totale = riga._totdociva;
 | 
						|
        TString string = totale.string(_real_picture);
 | 
						|
        set_row(_rw+j, fmt, (const char*)string);
 | 
						|
      }
 | 
						|
 | 
						|
    _b.destroy();
 | 
						|
  } 
 | 
						|
}
 | 
						|
 | 
						|
// Ricerca della descrizione relativa al codice causale di MOV.dta
 | 
						|
// sull'archivio CAUS.dta
 | 
						|
 | 
						|
void TMastrini_application::descrizione_causale()
 | 
						|
{
 | 
						|
  _caus->setkey(1);
 | 
						|
  _caus->curr().zero();
 | 
						|
  _caus->curr().put(CAU_CODCAUS, _codcaus);
 | 
						|
  _caus->read();
 | 
						|
  if (_caus->bad())
 | 
						|
    _caus->zero();
 | 
						|
  _descrcaus = _caus->curr().get(CAU_DESCR);
 | 
						|
}       
 | 
						|
 | 
						|
// Ricerca sulla tabella dei tipi documento, la descrizione e la natura del
 | 
						|
// documento, accedendovi tramite il tipo documento trovato su MOV.dta
 | 
						|
 | 
						|
void TMastrini_application::documenti_iva()
 | 
						|
{
 | 
						|
  TString dep;
 | 
						|
 
 | 
						|
  _tabtpd->zero();
 | 
						|
  dep.format ("%2s",(const char*) _tipodoc);
 | 
						|
  _tabtpd->curr().put("CODTAB", dep);
 | 
						|
  _tabtpd->read();
 | 
						|
  _descrdociva = _tabtpd->get("S0");
 | 
						|
  _natdoc = _tabtpd->get_int("I0");
 | 
						|
}     
 | 
						|
 | 
						|
void TMastrini_application::ricerca_regiva()
 | 
						|
{
 | 
						|
  TString16 dep;
 | 
						|
 | 
						|
  _tabreg->curr().zero();
 | 
						|
  dep << format("%04d", _annoiva); 
 | 
						|
  dep << format("%3s" , (const char*) _regiva);
 | 
						|
  _tabreg->curr().put("CODTAB", (const char*) dep);
 | 
						|
  _tabreg->read();
 | 
						|
  _tipo = _tabreg->get_int("I0");
 | 
						|
}    
 | 
						|
 | 
						|
bool TMastrini_application::preprocess_print(int file, int counter) 
 | 
						|
{  
 | 
						|
  if (file == LF_SALDI)
 | 
						|
  {
 | 
						|
    _g_prec = 0;
 | 
						|
    _c_prec = 0;
 | 
						|
    _s_prec = 0; 
 | 
						|
    
 | 
						|
    _saldo_periodo = ZERO;
 | 
						|
    _totale_periodo_dare = ZERO;
 | 
						|
    _totale_periodo_avere = ZERO;
 | 
						|
    _saldo_progre = ZERO;
 | 
						|
    _totprogre_dare = ZERO;
 | 
						|
    _totprogre_avere = ZERO;
 | 
						|
    _saldo_progre_al = ZERO;
 | 
						|
    _totprogre_dare_al = ZERO;
 | 
						|
    _totprogre_avere_al = ZERO;
 | 
						|
    _progredare = ZERO;
 | 
						|
    _progreavere = ZERO;
 | 
						|
    _totale_prima_dare = ZERO;
 | 
						|
    _totale_prima_avere = ZERO;
 | 
						|
    _saldo_movimenti = ZERO;
 | 
						|
    _saldo_progressivi = ZERO;
 | 
						|
    _saldo_progre_prec = ZERO;
 | 
						|
    _riporto_parziale_dare = ZERO;
 | 
						|
    _riporto_parziale_avere = ZERO;
 | 
						|
    
 | 
						|
    _gb_saldo_periodo = ZERO;
 | 
						|
    _gb_totale_periodo_dare = ZERO;    
 | 
						|
    _gb_totale_periodo_avere = ZERO;
 | 
						|
    _gb_saldo_progre = ZERO;
 | 
						|
    _gb_totprogre_dare = ZERO;
 | 
						|
    _gb_totprogre_avere = ZERO;
 | 
						|
    _gb_saldo_progre_al = ZERO;
 | 
						|
    _gb_totprogre_dare_al = ZERO;
 | 
						|
    _gb_totprogre_avere_al = ZERO;
 | 
						|
    _gb_last_page = FALSE;
 | 
						|
        
 | 
						|
    _protiva = 0;
 | 
						|
     
 | 
						|
    _stampa_progressivi_si = TRUE; 
 | 
						|
    _stampa_footer_si      = TRUE;
 | 
						|
  }
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::set_print(int)
 | 
						|
{
 | 
						|
  _puoi_stampare = TRUE;   
 | 
						|
 | 
						|
  KEY tasto;
 | 
						|
                   
 | 
						|
  // Controlla se esistono impostazioni di stampa in coda                 
 | 
						|
  if (sheet2mask())
 | 
						|
  {
 | 
						|
    // Simula l'immediata pressione del tasto stampa senza nemmeno lanciare la maschera
 | 
						|
    tasto = K_ENTER;
 | 
						|
  }  
 | 
						|
  else
 | 
						|
  {  
 | 
						|
    tasto = _msk->run();
 | 
						|
    if (tasto == K_ENTER)
 | 
						|
    {                                                          
 | 
						|
      // Se lo sheet e' vuoto allora usa solo la maschera corrente per la stampa,
 | 
						|
      // altrimenti estrae il primo elemento sovrascrivendo la maschera corrente.
 | 
						|
      // Questa figata cerca di correggere gli errori MI6185 e MI3592 in una botta
 | 
						|
      TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE);
 | 
						|
      if (sht.items() != 0)
 | 
						|
        sheet2mask();     // Estrae la prima riga dalla coda di stampa
 | 
						|
    }  
 | 
						|
  }  
 | 
						|
  
 | 
						|
  _noseparator = _msk->get_bool(F_SEPARATOR);
 | 
						|
  if (_noseparator)
 | 
						|
    _real_picture = "################";
 | 
						|
  else
 | 
						|
    _real_picture = "####.###.###.###";
 | 
						|
  set_real_picture(_real_picture);
 | 
						|
 | 
						|
 | 
						|
  if (tasto == K_ENTER)
 | 
						|
  {
 | 
						|
    _codice_ditta       = get_firm();
 | 
						|
    _annomsk            = _msk->get_int(F_ANNO);
 | 
						|
    
 | 
						|
    int gruppoini       = _msk->get_int(F_GRUPPOINI);
 | 
						|
    int contoini        = _msk->get_int(F_CONTOINI_CONTO);
 | 
						|
//    long sottocontoini  = _msk->get_long(F_SOTTOCINI_CONTO);
 | 
						|
    int gruppofine      = _msk->get_int(F_GRUPPOFINE);
 | 
						|
    int contofine       = _msk->get_int(F_CONTOFINE_CONTO);
 | 
						|
//    long sottocontofine = _msk->get_long(F_SOTTOCFINE_CONTO);
 | 
						|
 | 
						|
    _stampaprogre       = _msk->get_bool(F_STAMPAPROGRE);
 | 
						|
    _stampatotiva       = _msk->get_bool(F_STAMPATOTIVA);
 | 
						|
    _stampanum          = _msk->get_int(F_STAMPANUM);
 | 
						|
    _stampa_mov_prov    = _msk->get_bool(F_STAMPAMOVPROV); 
 | 
						|
    _tipostampa         = _msk->get_int(F_TIPOSTAMPA);
 | 
						|
 | 
						|
    _numcarat           = _msk->get_int(F_NUMCARAT);
 | 
						|
    _nummast            = _msk->get_int(F_NUMMAST);
 | 
						|
    _data_ini           = _msk->get_date(F_DATAINI);
 | 
						|
    _data_fine          = _msk->get_date(F_DATAFINE);
 | 
						|
 | 
						|
    TEsercizi_contabili esc;   
 | 
						|
 | 
						|
    if (_annomsk != 0)
 | 
						|
      _anno_corrente = _annomsk;
 | 
						|
    else               
 | 
						|
    {                                                        
 | 
						|
      _anno_ghost = esc.date2esc(_data_ini);
 | 
						|
      _anno_corrente = _anno_ghost;
 | 
						|
      _inizioes = esc[_anno_ghost].inizio();
 | 
						|
    }
 | 
						|
 | 
						|
    data_fine_esercizio(_anno_corrente); // Ricalcola _data_inizioese e _data_finese
 | 
						|
    if (!_data_ini.ok())  _data_ini  = _data_inizioese;
 | 
						|
    if (!_data_fine.ok()) _data_fine = _data_finese;
 | 
						|
       
 | 
						|
    _anno_precedente = esc.pred(_anno_corrente);
 | 
						|
 | 
						|
    ricerca_dati_ditta();
 | 
						|
 | 
						|
    int formato         = _msk->get_int(F_FORMATO);    // Molto scenografico!
 | 
						|
 | 
						|
    if (_nummast == 1 || _nummast == 3)
 | 
						|
      printer().footerlen(4);
 | 
						|
    else                               
 | 
						|
      printer().footerlen(2);
 | 
						|
      
 | 
						|
//Crea il cursore su gruppo, conto e sottoconto del file RMOV
 | 
						|
 | 
						|
    reset_files();         //resetta l'albero di stampa
 | 
						|
    add_file(LF_SALDI);
 | 
						|
    add_file(LF_RMOV,LF_SALDI);   
 | 
						|
    select_cursor(_cur1);
 | 
						|
      
 | 
						|
    TRectype da(LF_SALDI), a(LF_SALDI);       
 | 
						|
    da.put(SLD_GRUPPO,gruppoini);        
 | 
						|
    da.put(SLD_CONTO,contoini);
 | 
						|
//    da.put(SLD_SOTTOCONTO,sottocontoini);
 | 
						|
    a.put(SLD_GRUPPO,gruppofine);        
 | 
						|
    a.put(SLD_CONTO,contofine);
 | 
						|
//    a.put(SLD_SOTTOCONTO,sottocontofine); 
 | 
						|
    current_cursor()->setregion(da, a);
 | 
						|
    if (_stampatotiva)   
 | 
						|
      _b.destroy();
 | 
						|
 | 
						|
    //_inizio_stampa   = TRUE;    
 | 
						|
    _numero_pag      = 1;
 | 
						|
    if (_nummast == 3)
 | 
						|
      _pagina = 0;
 | 
						|
    else      
 | 
						|
      _pagina          = 1;
 | 
						|
    _cambia_mastrino = FALSE; 
 | 
						|
    _rw              = 0;
 | 
						|
    _conta_mastrini  = 0;
 | 
						|
    _indice_lista    = 0; 
 | 
						|
    _ddociva_len     = 0;                                                           
 | 
						|
                                                               
 | 
						|
    _riga.destroy();
 | 
						|
    _lista.destroy();
 | 
						|
    
 | 
						|
    switch (_tipostampa)
 | 
						|
    {
 | 
						|
      case 1: _totale_saldo = 1.0; break;
 | 
						|
      case 2: _totale_saldo = 0.0; break;
 | 
						|
      case 3: _totale_saldo = 1.0; break;
 | 
						|
      default: break;
 | 
						|
    }
 | 
						|
   
 | 
						|
    enable_print_menu();
 | 
						|
    enable_link("Collegamento prima nota: ", 'r');
 | 
						|
   
 | 
						|
    return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::data_fine_esercizio(int anno)
 | 
						|
{
 | 
						|
  TEsercizi_contabili esc;
 | 
						|
  _data_inizioese = esc[anno].inizio();
 | 
						|
  _data_finese    = esc[anno].fine();
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::preprocess_header()
 | 
						|
{                         
 | 
						|
  if (_gb_last_page)
 | 
						|
    return;
 | 
						|
 | 
						|
  if (_nummast == 1)
 | 
						|
  {
 | 
						|
    if (_tipostampa == 3)
 | 
						|
      crea_intestazione();
 | 
						|
    else
 | 
						|
      if (_tipostampa == 2)
 | 
						|
      {
 | 
						|
        if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | 
						|
          crea_intestazione();
 | 
						|
      }
 | 
						|
      else if (_tipostampa == 1)
 | 
						|
             if (_puoi_stampare)
 | 
						|
               crea_intestazione();
 | 
						|
  }                
 | 
						|
  else
 | 
						|
    if (_nummast == 3 && !_gia_stampata_intestazione)
 | 
						|
    {
 | 
						|
      if (_tipostampa == 3)
 | 
						|
        crea_intestazione();
 | 
						|
      else
 | 
						|
        if (_tipostampa == 2)
 | 
						|
        {
 | 
						|
          if ((_totale_saldo != 0.0) && (_puoi_stampare))
 | 
						|
            crea_intestazione();
 | 
						|
        }
 | 
						|
        else if (_tipostampa == 1)
 | 
						|
               if (_puoi_stampare)
 | 
						|
                 crea_intestazione();
 | 
						|
    }                
 | 
						|
}  
 | 
						|
 | 
						|
void TMastrini_application::preprocess_footer()
 | 
						|
{   
 | 
						|
  if (_gb_last_page)
 | 
						|
    return;
 | 
						|
 | 
						|
  reset_footer();
 | 
						|
  if (_nummast != 1 && _nummast != 3)
 | 
						|
    return;
 | 
						|
      
 | 
						|
  if (_devi_stampare_footer)
 | 
						|
  {                    
 | 
						|
    real dep_dare,dep_avere;
 | 
						|
      
 | 
						|
    if (_stampa_footer_si)
 | 
						|
    {
 | 
						|
      _riporto_footer_dare  = _progredare  + _riporto_parziale_dare;
 | 
						|
      _riporto_footer_avere = _progreavere + _riporto_parziale_avere;
 | 
						|
      
 | 
						|
      real imp_d,imp_a;
 | 
						|
      imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
      imp_a = _sezione == "A" ? _importo : ZERO;
 | 
						|
      dep_dare  = _stampato ? _riporto_footer_dare  : _riporto_footer_dare - imp_d;
 | 
						|
      dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a;
 | 
						|
      
 | 
						|
      _stampa_footer_si = FALSE;
 | 
						|
    }                           
 | 
						|
    else
 | 
						|
    {
 | 
						|
      _riporto_footer_dare  += _riporto_parziale_dare;
 | 
						|
      _riporto_footer_avere += _riporto_parziale_avere;
 | 
						|
 | 
						|
      real imp_d,imp_a;
 | 
						|
      imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
      imp_a = _sezione == "A" ? _importo : ZERO;
 | 
						|
      dep_dare  = _stampato ? _riporto_footer_dare  : _riporto_footer_dare - imp_d;
 | 
						|
      dep_avere = _stampato ? _riporto_footer_avere : _riporto_footer_avere - imp_a;
 | 
						|
    }
 | 
						|
    
 | 
						|
    if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | 
						|
    {     
 | 
						|
      TString dare  (dep_dare.string(_real_picture));
 | 
						|
      TString avere (dep_avere.string(_real_picture));
 | 
						|
      if (_numcarat == 1)                  
 | 
						|
      {
 | 
						|
        set_footer (2,"@32gA RIPORTO@83g%s", (const char*) dare);
 | 
						|
        set_footer (2,"@100g%s", (const char*) avere);
 | 
						|
      }  
 | 
						|
      else
 | 
						|
      {
 | 
						|
        set_footer (2,"@32gA RIPORTO@100g%s", (const char*) dare);
 | 
						|
        set_footer (2,"@117g%s", (const char*) avere);
 | 
						|
      }  
 | 
						|
    }             
 | 
						|
  }                
 | 
						|
}  
 | 
						|
 | 
						|
void TMastrini_application::conto(int gruppo, int conto, bool no_contropartita)
 | 
						|
{
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
 | 
						|
  pconti.setkey(1);
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO, gruppo);
 | 
						|
  pconti.put(PCN_CONTO , conto);
 | 
						|
  pconti.read();
 | 
						|
  if (pconti.bad())
 | 
						|
    pconti.zero();
 | 
						|
  
 | 
						|
  if (no_contropartita)
 | 
						|
  {
 | 
						|
    _indbil = pconti.get_int(PCN_INDBIL);
 | 
						|
    _tmcf   = pconti.get_char(PCN_TMCF);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    _tipo_contr = pconti.get_char(PCN_TMCF);
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::ricerca_dati_ditta()
 | 
						|
{
 | 
						|
  long app;
 | 
						|
 | 
						|
  _nditte->setkey(1);
 | 
						|
  _nditte->curr().zero();
 | 
						|
  _nditte->curr().put(NDT_CODDITTA,_codice_ditta);
 | 
						|
  _nditte->read();
 | 
						|
  app=_nditte->curr().get_long(NDT_CODDITTA);
 | 
						|
  _ragsoc=_nditte->curr().get(NDT_RAGSOC);
 | 
						|
 
 | 
						|
  _unloc->setkey(1);
 | 
						|
  _unloc->curr().zero();
 | 
						|
  _unloc->curr().put(ULC_CODDITTA,app);
 | 
						|
  _unloc->curr().put(ULC_CODULC,"1");
 | 
						|
  _unloc->read();
 | 
						|
  _indulc=_unloc->curr().get(ULC_INDULC);
 | 
						|
  _civulc=_unloc->curr().get(ULC_CIVULC);   
 | 
						|
  int len = _indulc.len();
 | 
						|
  if (len <= 31)
 | 
						|
  {
 | 
						|
    if (len <= 26)
 | 
						|
      _indulc << " " << _civulc;
 | 
						|
    else
 | 
						|
      _indulc << " " << _civulc.mid(0,5);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _indulc = _indulc.mid(0,31);
 | 
						|
    _indulc << " " << _civulc.mid(0,5);
 | 
						|
  }
 | 
						|
  _capulc=_unloc->curr().get(ULC_CAPULC);
 | 
						|
  _comulc=_unloc->curr().get(ULC_COMULC);
 | 
						|
 
 | 
						|
  _comuni->setkey(1);
 | 
						|
  _comuni->zero();
 | 
						|
  _comuni->put(COM_COM,_comulc);
 | 
						|
  _comuni->read();
 | 
						|
  if  (_comuni->good())
 | 
						|
  {
 | 
						|
    _com=_comuni->get(COM_DENCOM);
 | 
						|
    _prov=_comuni->get(COM_PROVCOM);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _com="";
 | 
						|
    _prov="";
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// Crea l'intestazione per la stampa a 132 e a 198 caratteri
 | 
						|
 | 
						|
void TMastrini_application::crea_intestazione()
 | 
						|
{
 | 
						|
  TString sep(132),sep1(198); 
 | 
						|
  sep = "";
 | 
						|
 | 
						|
  reset_header();
 | 
						|
  
 | 
						|
  int np = get_page_number();
 | 
						|
  
 | 
						|
  if (_cambia_mastrino)
 | 
						|
  { 
 | 
						|
    if (_nummast != 3)
 | 
						|
      _pagina = 1;
 | 
						|
    _cambia_mastrino = FALSE;
 | 
						|
  }
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      if (_pagina != np)
 | 
						|
        sep << "Pag. @#";
 | 
						|
    }     
 | 
						|
    else
 | 
						|
      sep << "Pag. " << _pagina;
 | 
						|
    sep.right_just(132);
 | 
						|
    set_header(1,(const char*) sep);
 | 
						|
    sep ="";
 | 
						|
    set_header(2,"@1g%s",(const char*) sep);  
 | 
						|
    //set_header(1,"@126gPag. %2d", _numero_pag++);
 | 
						|
  }
 | 
						|
  else if (_numcarat == 2)
 | 
						|
       {
 | 
						|
         if (_nummast == 3)
 | 
						|
         {         
 | 
						|
           if (_pagina != np)
 | 
						|
            sep1 << "Pagina @#";
 | 
						|
         }             
 | 
						|
         else          
 | 
						|
           sep1 << "Pagina " << _pagina;
 | 
						|
         sep1.right_just(198);
 | 
						|
         set_header(1,(const char*) sep1);
 | 
						|
         sep1 ="";
 | 
						|
         set_header(2,"@1g%s",(const char*) sep1);       
 | 
						|
         //set_header(1,"@190gPagina %2d", _numero_pag++);
 | 
						|
       }
 | 
						|
  if (_nummast != 3)     
 | 
						|
    _pagina++;
 | 
						|
  
 | 
						|
  if (_nummast != 3 || _pagina != np)
 | 
						|
  {
 | 
						|
    set_header (1, "@0g%s@6g%5ld", trans("DITTA"), _codice_ditta);
 | 
						|
    set_header (1, "@12g%-.45s", (const char*) _ragsoc);
 | 
						|
    set_header (1, "@59g%s", (const char*) _indulc);
 | 
						|
    //set_header (1, "@86g%-.9s", (const char*) _civulc);
 | 
						|
    set_header (1, "@97g%-.5s", (const char*) _capulc);
 | 
						|
    set_header (1, "@103g%-.18s", (const char*) _com);
 | 
						|
    set_header (1, "@122g%-.3s", (const char*) _prov);
 | 
						|
  }
 | 
						|
  if (_nummast == 3)
 | 
						|
    set_header (3, "@0g%s@12g@b%3d %3d", trans("Conto"), _gruppo, _conto);
 | 
						|
  else
 | 
						|
    set_header (3, "@0g%s@12g%3d %3d", trans("Conto"), _gruppo, _conto);
 | 
						|
 | 
						|
/*
 | 
						|
  if (_tmcf == 'C')                       
 | 
						|
    _tipo_mask = 1;                       
 | 
						|
    else if (_tmcf == 'F')                
 | 
						|
            _tipo_mask = 2;               
 | 
						|
            else if (_tmcf == '\0')       
 | 
						|
*/            
 | 
						|
           _tipo_mask = 3;        
 | 
						|
  switch (_tipo_mask)
 | 
						|
  {
 | 
						|
    case 1: ricerca_clifo();
 | 
						|
              break;
 | 
						|
    case 2: ricerca_clifo();
 | 
						|
              break;
 | 
						|
    case 3: ricerca_gruppo();
 | 
						|
              break;
 | 
						|
    default:  break;
 | 
						|
  }    
 | 
						|
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    sep.fill('-');                            //Stampa 132 - (sep(132))      
 | 
						|
    set_header (6, (const char *) sep);
 | 
						|
    set_header (7,"%s@19g%s@117g%s@131g%s", 
 | 
						|
                trans("Operazione"), trans("Documento"), trans("Sotto"), trans("A"));
 | 
						|
    if (_stampa_mov_prov)
 | 
						|
      set_header(7,"@129gM");
 | 
						|
    set_header (8, trans("Data"));
 | 
						|
    if (_stampanum < 3)
 | 
						|
      set_header (8,"@11g%s", trans("Numero"));
 | 
						|
    set_header (8,"@19g%s@30g%s@38g%s@61g%s@95g%s@111g%s@117g%s@131g%s",
 | 
						|
                trans("Data"), trans("Numero"), trans("Cod.Causale"), trans("Descrizione"),
 | 
						|
                trans("Dare"), trans("Avere"), trans("Conto"), trans("C"));
 | 
						|
    if (_stampa_mov_prov)
 | 
						|
      set_header(8,"@129g%s", trans("P"));
 | 
						|
    sep.fill('-');
 | 
						|
    set_header (9, (const char *) sep);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
   sep1.fill('-');                    //Stampa 198 - (sep1(198))      
 | 
						|
   set_header (6,"@0g%s", (const char*)sep1);
 | 
						|
   set_header (7,"%s@23g%s@34g%s@169g%s@183g%s@190g%s@197g%s",
 | 
						|
               trans("Operazione"), trans("Data"), trans("Numero"), trans("Sotto"),
 | 
						|
               trans("Reg"), trans("Numero"), trans("A"));
 | 
						|
   if (_stampa_mov_prov)
 | 
						|
     set_header(7,"@195g%s", trans("M"));
 | 
						|
   set_header (8,trans("Data"));
 | 
						|
   if (_stampanum < 3)
 | 
						|
     set_header (8,"@11g%s", trans("Numero"));
 | 
						|
   set_header (8,"@23g%s@42g%s@70g%s@112g%s@127g%s@135g%s@152g%s@169g%s@183g%s@189g%s@197g%s",
 | 
						|
               trans("Documento"), trans("Cod.Causale"), trans("Descrizione"), trans("Dare"), trans("Avere"),
 | 
						|
               trans("Saldo progre."), trans("Saldo movim."), trans("Conto"), trans("Iva"),
 | 
						|
               trans("Protoc."), trans("C"));
 | 
						|
               
 | 
						|
   if (_stampa_mov_prov)
 | 
						|
     set_header(8,"@195g%s", trans("P"));
 | 
						|
   sep1.fill('-');
 | 
						|
   set_header (9,"@0g%s", (const char*)sep1);
 | 
						|
  } 
 | 
						|
       
 | 
						|
  calcola_progressivi();
 | 
						|
  // Il saldo dei progressivi va aggiornato solo se e' la prima pagina del mastrino!
 | 
						|
  if (_nummast == 1 && _stampa_progressivi_si) 
 | 
						|
    _saldo_progressivi += _saldo_progre_prec;          
 | 
						|
        
 | 
						|
  if (_stampa_progressivi_si)
 | 
						|
  {
 | 
						|
    if (_numcarat == 1)
 | 
						|
    { 
 | 
						|
      set_header (10,"@42g%s@66g%s", trans("PROGRESSIVI PRECEDENTI"), _saldo_progre_prec.string(_real_picture));
 | 
						|
      set_header (10,"@83g%s", _progredare.string(_real_picture));
 | 
						|
      set_header (10,"@100g%s", _progreavere.string(_real_picture));
 | 
						|
    }
 | 
						|
    if (_numcarat == 2)
 | 
						|
    {
 | 
						|
      set_header (10,"@70g%s@100g%s", trans("PROGRESSIVI PRECEDENTI"), _progredare.string(_real_picture));
 | 
						|
      set_header (10,"@117g%s", _progreavere.string(_real_picture));
 | 
						|
      set_header (10,"@134g%s", _saldo_progre_prec.string(_real_picture));
 | 
						|
    }
 | 
						|
    _riporto_dare = _progredare;
 | 
						|
    _riporto_avere = _progreavere;
 | 
						|
    _stampa_progressivi_si = FALSE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _riporto_dare += _riporto_parziale_dare;
 | 
						|
    _riporto_avere += _riporto_parziale_avere;
 | 
						|
 | 
						|
    real dep_dare,dep_avere,imp_d,imp_a;
 | 
						|
    imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
    imp_a = _sezione == "A" ? _importo : ZERO;
 | 
						|
    dep_dare = _stampato ? _riporto_dare : _riporto_dare - imp_d;
 | 
						|
    dep_avere = _stampato ? _riporto_avere : _riporto_avere - imp_a;
 | 
						|
 | 
						|
    if (_nummast != 3 || dep_dare != ZERO || dep_avere != 0)
 | 
						|
    {
 | 
						|
      if (_numcarat == 1)
 | 
						|
      {
 | 
						|
        set_header (10,"@32g%s@83g%s", trans("A RIPORTO"), dep_dare.string(_real_picture));
 | 
						|
        set_header (10,"@100g%s", dep_avere.string(_real_picture));
 | 
						|
      }
 | 
						|
      if (_numcarat == 2)
 | 
						|
      {
 | 
						|
        set_header (10,"@32g%s@100g%s", trans("A RIPORTO"), dep_dare.string(_real_picture));
 | 
						|
        set_header (10,"@117g%s", dep_avere.string(_real_picture));
 | 
						|
      }
 | 
						|
    }  
 | 
						|
    _riporto_parziale_dare = ZERO;
 | 
						|
    _riporto_parziale_avere = ZERO;
 | 
						|
  }
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    sep ="";
 | 
						|
    set_header(11,"@1g%s",(const char*) sep);
 | 
						|
  }
 | 
						|
  else if (_numcarat == 2)
 | 
						|
       {
 | 
						|
         sep1 ="";
 | 
						|
         set_header(11,"@1g%s",(const char*) sep1);
 | 
						|
       }
 | 
						|
  if (_pagina != np && _nummast == 3)
 | 
						|
    _pagina = np;       
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::crea_intestazione(int start_riga)
 | 
						|
{
 | 
						|
  TString   sep(132),sep1(198); 
 | 
						|
  int       r = start_riga + 2;
 | 
						|
  sep = "";
 | 
						|
 | 
						|
  reset_header();
 | 
						|
 | 
						|
  int np = get_page_number();
 | 
						|
    
 | 
						|
  _conta_mastrini++;
 | 
						|
    
 | 
						|
  if (_nummast == 3)
 | 
						|
    _gia_stampata_intestazione = TRUE;
 | 
						|
      
 | 
						|
  if (_nummast == 2)
 | 
						|
    if (_cambia_mastrino)
 | 
						|
    {
 | 
						|
      _numero_pag = 1;
 | 
						|
      _cambia_mastrino = FALSE;
 | 
						|
    }
 | 
						|
  if (_nummast == 3)
 | 
						|
  {
 | 
						|
    if (_pagina != np)
 | 
						|
    {
 | 
						|
      if (_numcarat == 1)
 | 
						|
      {
 | 
						|
        sep << "Pag. @#";
 | 
						|
        set_row(r,"@126g%s", (const char*) sep);
 | 
						|
      }     
 | 
						|
      else if (_numcarat == 2)
 | 
						|
      {
 | 
						|
        sep << "Pagina @#";
 | 
						|
        set_row(r,"@190g%s", (const char*) sep);
 | 
						|
      }       
 | 
						|
    }     
 | 
						|
  }          
 | 
						|
  else
 | 
						|
  {
 | 
						|
    if (_numcarat == 1)
 | 
						|
      set_row(r,"@126g%s %2d", trans("Pag."), _numero_pag++);
 | 
						|
    else if (_numcarat == 2)
 | 
						|
      set_row(r,"@190g%s %2d", trans("Pagina"),_numero_pag++);
 | 
						|
  }              
 | 
						|
  if (_nummast != 3 || _pagina != np)
 | 
						|
  {
 | 
						|
    set_row (r, "@0g%s@6g%5ld", trans("DITTA"), _codice_ditta);
 | 
						|
    set_row (r, "@12g%-45s", (const char*) _ragsoc);
 | 
						|
    set_row (r, "@59g%s", (const char*) _indulc);
 | 
						|
    //set_row (r, "@86g%-9s", (const char*) _civulc);
 | 
						|
    set_row (r, "@97g%-5s", (const char*) _capulc);
 | 
						|
    set_row (r, "@103g%-18s", (const char*) _com);
 | 
						|
    set_row (r, "@122g%-3s", (const char*) _prov);
 | 
						|
    r += 2;                 
 | 
						|
  }   
 | 
						|
  if (_nummast == 3)
 | 
						|
    set_row (r, "@0g%s@12g@b%3d %3d", trans("Conto"), _gruppo, _conto);
 | 
						|
  else
 | 
						|
    set_row (r, "@0g%s@12g%3d %3d", trans("Conto"), _gruppo, _conto);
 | 
						|
 | 
						|
/*  
 | 
						|
  if (_tmcf == 'C')                       
 | 
						|
    _tipo_mask = 1;                       
 | 
						|
  else if (_tmcf == 'F')                
 | 
						|
    _tipo_mask = 2;               
 | 
						|
  else if (_tmcf == '\0')        
 | 
						|
*/
 | 
						|
    _tipo_mask = 3;        
 | 
						|
  
 | 
						|
  switch (_tipo_mask)
 | 
						|
  {
 | 
						|
    case 1: r = ricerca_clifo(r);
 | 
						|
              break;
 | 
						|
    case 2: r = ricerca_clifo(r);
 | 
						|
              break;
 | 
						|
    case 3: r = ricerca_gruppo(r);
 | 
						|
              break;
 | 
						|
    default:  break;
 | 
						|
  }    
 | 
						|
  
 | 
						|
  r++;
 | 
						|
  
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    sep.fill('-');                            //Stampa 132 - (sep(132))      
 | 
						|
    set_row (r++,"@1g%s", (const char *) sep);
 | 
						|
    set_row (r++,"%s@19g%s@117g%s@131g%s",
 | 
						|
             trans("Operazione"), trans("Documento"), trans("Sotto"), trans("A"));
 | 
						|
    if (_stampa_mov_prov)
 | 
						|
      set_header(r-1,"@129g%s", trans("M"));
 | 
						|
    set_row (r, trans("Data"));
 | 
						|
    if (_stampanum < 3)
 | 
						|
      set_row (r,"@11g%s", trans("Numero"));
 | 
						|
    set_row (r++,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@95gDare@111gAvere@117gConto@131gC");
 | 
						|
    if (_stampa_mov_prov)
 | 
						|
      set_header(r-1,"@129gP");
 | 
						|
    sep.fill('-');
 | 
						|
    set_row (r++,"@1g%s", (const char*)sep);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
   sep1.fill('-');                    //Stampa 198 - (sep1(198))      
 | 
						|
   set_row (r++,"@0g%s", (const char*)sep1);
 | 
						|
   set_row (r++,"Operazione@23gData@34gNumero@169gContro@183gReg@190gNumero@197gA");
 | 
						|
   if (_stampa_mov_prov)
 | 
						|
     set_row(r-1,"@195gM");
 | 
						|
   set_row (r,"Data");
 | 
						|
   if (_stampanum < 3)
 | 
						|
     set_row (r,"@11gnumero");
 | 
						|
   set_row (r,"@23gDocumento@42gCod.Causale@70gDescrizione@112gDare@127gAvere");
 | 
						|
   set_row (r++,"@135gSaldo progre.@152gSaldo movim.@169gConto@183gIva@189gProtoc.@197gC");
 | 
						|
   if (_stampa_mov_prov)
 | 
						|
     set_row (r-1,"@195gP");
 | 
						|
   sep1.fill('-');
 | 
						|
   set_row (r++,"@0g%s", (const char*)sep1);
 | 
						|
  }   
 | 
						|
  _pagina = np;       
 | 
						|
  return r;     
 | 
						|
}
 | 
						|
          
 | 
						|
void TMastrini_application::stampa_progre_riporto()
 | 
						|
{ 
 | 
						|
  TString sep(132),sep1(198);
 | 
						|
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 1;
 | 
						|
             
 | 
						|
  if (_stampa_progressivi_si)
 | 
						|
  {
 | 
						|
    stampa_progressivi();
 | 
						|
    _riporto_dare = _progredare;
 | 
						|
    _riporto_avere = _progreavere;
 | 
						|
    _stampa_progressivi_si = FALSE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _riporto_dare += _riporto_parziale_dare;
 | 
						|
    _riporto_avere += _riporto_parziale_avere;
 | 
						|
    
 | 
						|
    real dep_dare,dep_avere,imp_d,imp_a;
 | 
						|
    imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
    imp_a = _sezione == "A" ? _importo : ZERO;
 | 
						|
    dep_dare = _stampato ? _riporto_dare : _riporto_dare - imp_d;
 | 
						|
    dep_avere = _stampato ? _riporto_avere : _riporto_avere - imp_a;
 | 
						|
    
 | 
						|
    if (_nummast != 3 || dep_dare != ZERO || dep_avere != 0)
 | 
						|
    {
 | 
						|
      if (_numcarat == 1)
 | 
						|
      {
 | 
						|
        set_row (_rw,"@32g%s@83g%r", trans("A RIPORTO"), &dep_dare);
 | 
						|
        set_row (_rw++,"@100g%r",&dep_avere);
 | 
						|
      }
 | 
						|
      if (_numcarat == 2)
 | 
						|
      {
 | 
						|
        set_row (_rw,"@32g%s@100g%r", trans("A RIPORTO"), &dep_dare);
 | 
						|
        set_row (_rw++,"@117g%r", &dep_avere);
 | 
						|
      }
 | 
						|
    }     
 | 
						|
    _riporto_parziale_dare = ZERO;
 | 
						|
    _riporto_parziale_avere = ZERO;
 | 
						|
  }
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    sep ="";
 | 
						|
    set_row(_rw,"@1g%s",(const char*)sep);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    sep1 ="";
 | 
						|
    set_row(_rw,"@1g%s",(const char*)sep1);
 | 
						|
  }
 | 
						|
} 
 | 
						|
 | 
						|
int TMastrini_application::stampa_progre_riporto(int start_riga)
 | 
						|
{ 
 | 
						|
  TString sep(132),sep1(198);                                  
 | 
						|
  int r = start_riga;
 | 
						|
  
 | 
						|
  if (_stampa_progressivi_si)
 | 
						|
  {
 | 
						|
    r = stampa_progressivi(r);
 | 
						|
    _riporto_dare = _progredare;
 | 
						|
    _riporto_avere = _progreavere;
 | 
						|
    _stampa_progressivi_si = FALSE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    _riporto_dare += _riporto_parziale_dare;
 | 
						|
    _riporto_avere += _riporto_parziale_avere;
 | 
						|
    
 | 
						|
    real dep_dare,dep_avere,imp_d,imp_a;
 | 
						|
    imp_d = _sezione == "D" ? _importo : ZERO;
 | 
						|
    imp_a = _sezione == "A" ? _importo : ZERO;
 | 
						|
    dep_dare = _stampato ? _riporto_dare : _riporto_dare - imp_d;
 | 
						|
    dep_avere = _stampato ? _riporto_avere : _riporto_avere - imp_a;
 | 
						|
 | 
						|
    if (_nummast != 3 || dep_dare != ZERO || dep_avere != ZERO)
 | 
						|
    {
 | 
						|
      if (_numcarat == 1)
 | 
						|
      {
 | 
						|
        set_row (r,"@32g%s@83g%r", trans("A RIPORTO"), &dep_dare);
 | 
						|
        set_row (r++,"@100g%r", &dep_avere);
 | 
						|
      }
 | 
						|
      if (_numcarat == 2)
 | 
						|
      {
 | 
						|
        set_row (r,"@32g%s@100g%r", trans("A RIPORTO"), &dep_dare);
 | 
						|
        set_row (r++,"@117g%r", &dep_avere);
 | 
						|
      }
 | 
						|
    }     
 | 
						|
    _riporto_parziale_dare = ZERO;
 | 
						|
    _riporto_parziale_avere = ZERO;
 | 
						|
  }
 | 
						|
  if (_numcarat == 1)
 | 
						|
  {
 | 
						|
    sep ="";
 | 
						|
    set_row(r++,"@1g%s",(const char*) sep);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
   sep1 ="";
 | 
						|
   set_row(r++,"@1g%s",(const char*) sep1);
 | 
						|
  }            
 | 
						|
  return r;
 | 
						|
} 
 | 
						|
         
 | 
						|
void TMastrini_application::calcola_progressivi_al()
 | 
						|
{
 | 
						|
  long record,annoes;
 | 
						|
//  long sottoc;
 | 
						|
  int  gruppo,conto;
 | 
						|
  TDate datareg, datacomp;
 | 
						|
  TLocalisamfile & rmov = current_cursor()->file(LF_RMOV);
 | 
						|
  char sezione;
 | 
						|
  real importo;       
 | 
						|
  TDate data;
 | 
						|
 | 
						|
  _totale_prima_dare  = ZERO;
 | 
						|
  _totale_prima_avere = ZERO;
 | 
						|
  
 | 
						|
  record = rmov.recno(); 
 | 
						|
  rmov.zero();
 | 
						|
  rmov.put(RMV_GRUPPO,     _gruppo);
 | 
						|
  rmov.put(RMV_CONTO,      _conto);
 | 
						|
//  rmov.put(RMV_SOTTOCONTO, _sottoc);
 | 
						|
  for (rmov.read();!rmov.eof() ;rmov.next())
 | 
						|
  {
 | 
						|
    annoes      = rmov.get_int (RMV_ANNOES);
 | 
						|
    datareg     = rmov.get_date(RMV_DATAREG);
 | 
						|
    sezione     = rmov.get     (RMV_SEZIONE)[0];
 | 
						|
    importo     = rmov.get_real(RMV_IMPORTO);
 | 
						|
    long numreg = rmov.get_long(RMV_NUMREG);
 | 
						|
 | 
						|
    _mov->setkey(1);
 | 
						|
    _mov->curr().zero();
 | 
						|
    _mov->curr().put(MOV_NUMREG,numreg);
 | 
						|
    _mov->read();
 | 
						|
    if (_mov->bad())
 | 
						|
      _mov->zero();
 | 
						|
    datacomp = (_mov->curr().get(MOV_DATACOMP));
 | 
						|
    TString provvis (_mov->curr().get(MOV_PROVVIS));
 | 
						|
    
 | 
						|
    if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty())))
 | 
						|
    {
 | 
						|
      if (_annomsk == 0)
 | 
						|
      {
 | 
						|
        datareg = rmov.get_date(RMV_DATAREG); 
 | 
						|
        data = _inizioes;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        datareg = datacomp;
 | 
						|
        data = _data_inizioese;
 | 
						|
      }  
 | 
						|
 | 
						|
      gruppo = rmov.get_int(RMV_GRUPPO);
 | 
						|
      conto  = rmov.get_int(RMV_CONTO);
 | 
						|
//      sottoc = rmov.get_long(RMV_SOTTOCONTO);
 | 
						|
      if ((gruppo != _gruppo)||(conto != _conto)/*||(sottoc != _sottoc)*/)
 | 
						|
        break;
 | 
						|
      else if (((annoes==_annomsk)||(_annomsk == 0))&&(datareg >= data)&&(datareg < _data_ini)) //Legge movimenti con data < data iniziale
 | 
						|
             if (sezione == 'D')
 | 
						|
               _totale_prima_dare += importo;
 | 
						|
             else
 | 
						|
               _totale_prima_avere += importo;
 | 
						|
    } // if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty())))              
 | 
						|
  }  
 | 
						|
  rmov.readat(record);
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::calcola_progressivi()
 | 
						|
{
 | 
						|
   /* fv 20/3/96: aggiustato per nuova struttura saldi - modificata ricerca
 | 
						|
    * record scaricati e assegnazione dare/avere relativo - Controllare che
 | 
						|
    * non occorra considerare il saldo di chiusura (SALDOFIN) aggiunto al
 | 
						|
    * record */
 | 
						|
 | 
						|
   TLocalisamfile saldi(LF_SALDI);
 | 
						|
   real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec;
 | 
						|
   real progredare_eseprec,progreavere_eseprec,pdarep,paverep;
 | 
						|
 | 
						|
   TImporto saldoini_attuale, saldofine_attuale;
 | 
						|
 | 
						|
   pdarep        = ZERO;
 | 
						|
   paverep       = ZERO;
 | 
						|
 | 
						|
// Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto
 | 
						|
// uguali a quelli di rmov per il calcolo dei progressivi precedenti
 | 
						|
 | 
						|
   saldi.setkey(2);
 | 
						|
   saldi.zero();
 | 
						|
   saldi.put(SLD_GRUPPO,     _gruppo);
 | 
						|
   saldi.put(SLD_CONTO,      _conto);
 | 
						|
//   saldi.put(SLD_SOTTOCONTO, _sottoc);
 | 
						|
 | 
						|
   const TRectype record(saldi.curr());
 | 
						|
 | 
						|
   for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next())
 | 
						|
   {             
 | 
						|
     if (saldi.get_bool(SLD_FLSCA))
 | 
						|
       continue;
 | 
						|
     int annoes_saldi = saldi.get_int(SLD_ANNOES);
 | 
						|
   
 | 
						|
//Calcola i progressivi dell'esercizio attuale
 | 
						|
 | 
						|
     if (annoes_saldi == _anno_corrente)
 | 
						|
     {
 | 
						|
       progdare_attuale  += saldi.get_real(SLD_PDARE);
 | 
						|
       progavere_attuale += saldi.get_real(SLD_PAVERE);
 | 
						|
       _ultima_data_reg  = saldi.get_date(SLD_DATAULMOV);
 | 
						|
       saldoini_attuale += TImporto(saldi.get_char(SLD_FLAGSALINI), saldi.get_real(SLD_SALDO));
 | 
						|
       saldofine_attuale += TImporto(saldi.get_char(SLD_FLAGSALFIN), saldi.get_real(SLD_SALDOFIN));
 | 
						|
     }
 | 
						|
 | 
						|
//Calcola i progressivi dell'esercizio precedente
 | 
						|
     if (annoes_saldi == _anno_precedente)
 | 
						|
     {
 | 
						|
       pdarep  += saldi.get_real(SLD_PDARE);
 | 
						|
       paverep += saldi.get_real(SLD_PAVERE);
 | 
						|
       
 | 
						|
       if (_stampa_mov_prov)
 | 
						|
       {
 | 
						|
         progredare_eseprec  += saldi.get_real(SLD_PDARE)  + saldi.get_real(SLD_PDAREPRO);
 | 
						|
         progreavere_eseprec += saldi.get_real(SLD_PAVERE) + saldi.get_real(SLD_PAVEREPRO);
 | 
						|
       }
 | 
						|
     }      
 | 
						|
   }   // FOR
 | 
						|
   
 | 
						|
//Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo
 | 
						|
// finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil
 | 
						|
                           
 | 
						|
   if (_annomsk != 0 /*&& saldo == ZERO*/)   // Guy: Non capisco perche' sia commentato!
 | 
						|
   {    
 | 
						|
     if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5))
 | 
						|
     {           
 | 
						|
/* Guy: cambio implementazione
 | 
						|
       const TRecnotype pos = saldi.recno();                                      
 | 
						|
       // W96SALDI del 18-07-96 saldofin_esprec usa il flag TRUE xche' deve
 | 
						|
       // considerare anche il saldo finale
 | 
						|
       saldo = _sld->saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc,TRUE);
 | 
						|
       saldi.readat(pos);
 | 
						|
           
 | 
						|
       if (saldo > ZERO)
 | 
						|
       {
 | 
						|
         progredare_eseprec  = saldo;
 | 
						|
         progdare_prec = saldo;
 | 
						|
       }
 | 
						|
       else 
 | 
						|
          if (saldo < ZERO)
 | 
						|
          {
 | 
						|
            saldo = -saldo;
 | 
						|
            progreavere_eseprec = saldo;
 | 
						|
            progavere_prec = saldo;
 | 
						|
          }
 | 
						|
*/
 | 
						|
       progredare_eseprec = progdare_prec = ZERO;
 | 
						|
       saldi.curr() = record;
 | 
						|
       for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next())
 | 
						|
       {             
 | 
						|
         if (saldi.get_bool(SLD_FLSCA))
 | 
						|
           continue;
 | 
						|
         _sottoc = saldi.get_long(SLD_SOTTOCONTO);
 | 
						|
         real saldoprec = _sld->saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc,TRUE);
 | 
						|
  
 | 
						|
         if (saldoprec > ZERO)
 | 
						|
         {
 | 
						|
           progredare_eseprec  += saldoprec;
 | 
						|
           progdare_prec       += saldoprec;
 | 
						|
         }
 | 
						|
         else 
 | 
						|
         {
 | 
						|
           progreavere_eseprec -= saldoprec;
 | 
						|
           progavere_prec      -= saldoprec;
 | 
						|
         }
 | 
						|
       }
 | 
						|
     }
 | 
						|
   }
 | 
						|
 | 
						|
   calcola_progressivi_al();
 | 
						|
  
 | 
						|
//Calcolo dei progressivi precedenti: somma di tutti quei movimenti di rmov
 | 
						|
//che hanno la data di registrazione inferiore alla data di inizio stampa,
 | 
						|
//dei progressivi dell'anno esercizio precedente, e dei progressivi dei
 | 
						|
//movimenti scaricati dell'esercizio attuale.
 | 
						|
 | 
						|
   _progredare  = progredare_eseprec   + _totale_prima_dare;
 | 
						|
   _progreavere = progreavere_eseprec + _totale_prima_avere;
 | 
						|
   _saldo_progre_prec = _progredare - _progreavere;
 | 
						|
 | 
						|
//Calcolo dei progressivi alla <ultima data registrazione>  
 | 
						|
 | 
						|
//Se sulla maschera e' stato selezionato il controllo competenza esercizio
 | 
						|
//Sommo i progressivi dell'esercizio precedente e quelli dell'esercizio attuale
 | 
						|
//altrimenti solo quelli dell'esercizio attuale
 | 
						|
 | 
						|
   _totprogre_dare_al  = progdare_attuale;
 | 
						|
   _totprogre_avere_al = progavere_attuale;
 | 
						|
   if (_annomsk != 0)
 | 
						|
   {
 | 
						|
     _totprogre_dare_al  += progdare_prec;
 | 
						|
     _totprogre_avere_al += progavere_prec;  
 | 
						|
   }
 | 
						|
 | 
						|
   saldoini_attuale.normalize();
 | 
						|
   if (saldoini_attuale.sezione() == 'D')
 | 
						|
     _totprogre_dare_al += saldoini_attuale.valore();
 | 
						|
   else
 | 
						|
     _totprogre_avere_al += saldoini_attuale.valore();
 | 
						|
   
 | 
						|
   saldofine_attuale.normalize();
 | 
						|
   if (saldofine_attuale.sezione() == 'D')
 | 
						|
     _totprogre_dare_al += saldofine_attuale.valore();
 | 
						|
   else 
 | 
						|
     _totprogre_avere_al += saldofine_attuale.valore();       
 | 
						|
}
 | 
						|
 | 
						|
void TMastrini_application::stampa_progressivi()
 | 
						|
{           
 | 
						|
  if (_nummast == 1 || _nummast == 3)
 | 
						|
    _rw = 1;
 | 
						|
 | 
						|
  if (_numcarat == 1)
 | 
						|
  { 
 | 
						|
   set_row (_rw,"@42gPROGRESSIVI PRECEDENTI@66g%r", &_saldo_progre_prec);
 | 
						|
   set_row (_rw,"@83g%r", &_progredare);
 | 
						|
   set_row (_rw++,"@100g%r", &_progreavere);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    set_row (_rw,"@70gPROGRESSIVI PRECEDENTI@100g%r", &_progredare);
 | 
						|
    set_row (_rw,"@117g%r", &_progreavere);
 | 
						|
    set_row (_rw++,"@134g%r", &_saldo_progre_prec);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::stampa_progressivi(int start_riga)
 | 
						|
{                                                           
 | 
						|
  int r = start_riga;
 | 
						|
  
 | 
						|
  if (_numcarat == 1)
 | 
						|
  { 
 | 
						|
    set_row (r,"@42gPROGRESSIVI PRECEDENTI@66g%r", &_saldo_progre_prec);
 | 
						|
    set_row (r,"@83g%r", &_progredare);
 | 
						|
    set_row (r++,"@100g%r", &_progreavere);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    set_row (r,"@70gPROGRESSIVI PRECEDENTI@100g%r", &_progredare);
 | 
						|
    set_row (r,"@117g%r", &_progreavere);
 | 
						|
    set_row (r++,"@134g%r", &_saldo_progre_prec);
 | 
						|
  }       
 | 
						|
         
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
// Se la ricerca selezionata nella maschera e' per clienti, oppure fornitori,  // allora ricerco su CLIFO i relativi dati, e su PCON il relativo gruppo,conto,// sottoconto e IV direttiva CEE
 | 
						|
 | 
						|
void TMastrini_application::ricerca_clifo()
 | 
						|
{
 | 
						|
  TString ragsoc,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep;
 | 
						|
  TLocalisamfile clifo(LF_CLIFO);
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
  TString16 dataini,datafine; 
 | 
						|
  TString   descriz,descriz2;
 | 
						|
  int     numrivd;
 | 
						|
  
 | 
						|
  indcf = "";
 | 
						|
  
 | 
						|
  clifo.setkey(1);
 | 
						|
  clifo.zero();
 | 
						|
  clifo.put(CLI_TIPOCF, _tmcf);
 | 
						|
  clifo.put(CLI_CODCF,  _sottoc);
 | 
						|
  clifo.read();
 | 
						|
  if (clifo.bad())
 | 
						|
    clifo.zero();
 | 
						|
  TConto tc (_gruppo,_conto,_sottoc,_tmcf);
 | 
						|
  
 | 
						|
  ragsoc  = tc.descrizione();
 | 
						|
  paiv    = clifo.get(CLI_PAIV);
 | 
						|
  cofi    = clifo.get(CLI_COFI);
 | 
						|
  indcf   = clifo.get(CLI_INDCF);
 | 
						|
  indcf.trim();
 | 
						|
  indcf << " " << clifo.get(CLI_CIVCF);
 | 
						|
  capcf   = clifo.get(CLI_CAPCF);
 | 
						|
  ptel    = clifo.get(CLI_PTEL);
 | 
						|
  tel     = clifo.get(CLI_TEL);
 | 
						|
  statocf = clifo.get(CLI_STATOCF);
 | 
						|
  comcf   = clifo.get(CLI_COMCF);
 | 
						|
 | 
						|
  _comuni->setkey(1);
 | 
						|
  _comuni->zero();
 | 
						|
  _comuni->put(COM_STATO, statocf);
 | 
						|
  _comuni->put(COM_COM, comcf);
 | 
						|
  _comuni->read();
 | 
						|
  if (_comuni->good())
 | 
						|
  {
 | 
						|
    dencom = _comuni->get(COM_DENCOM);
 | 
						|
    provcom = _comuni->get(COM_PROVCOM);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    //dencom="";
 | 
						|
    dencom = clifo.get(CLI_LOCCF);
 | 
						|
    provcom="";
 | 
						|
  }
 | 
						|
 | 
						|
  pconti.setkey(1);
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,     _gruppo);
 | 
						|
  pconti.put(PCN_CONTO,      _conto);
 | 
						|
  pconti.read();
 | 
						|
  _sezivd  = pconti.get_char(PCN_SEZIVD);
 | 
						|
  _lettivd = pconti.get_char(PCN_LETTIVD);
 | 
						|
  numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | 
						|
  _numrivd = itor(numrivd);
 | 
						|
  _numivd  = pconti.get_int(PCN_NUMIVD);
 | 
						|
 | 
						|
  descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);    
 | 
						|
 
 | 
						|
  if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | 
						|
  {                      //classe immediatamente precedente a quello appena
 | 
						|
   if (_numrivd != "")   //stampato
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | 
						|
   else
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_numrivd != "")
 | 
						|
      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);   
 | 
						|
    else
 | 
						|
      descriz2 = "";
 | 
						|
 
 | 
						|
  set_header(3,"@27g%-.30s",(const char*) descrizione_gruppo());
 | 
						|
  set_header(3,"@59g%-.30s",(const char*) descrizione_conto());
 | 
						|
  set_header(3, "@91g%-.41s",(const char*) ragsoc);
 | 
						|
 | 
						|
/*
 | 
						|
  if (_nummast == 3)
 | 
						|
    set_header(4, "@r%s@8g@b%c", trans("Classe"), _lettivd);
 | 
						|
  else
 | 
						|
    set_header(4, "%s@8g%c", trans("Classe") , _lettivd);  
 | 
						|
  set_header(4, "@10g%-8s", (const char*) _numrivd);
 | 
						|
  if (_numivd != 0)
 | 
						|
    set_header(4, "@19g%2d", _numivd);
 | 
						|
  if (descriz2 != "")                              
 | 
						|
  {
 | 
						|
    set_header(4,"@23g%-50s",(const char*) descriz2);
 | 
						|
    set_header(4,"@80g%-50s",(const char*) descriz);                                                  
 | 
						|
  }
 | 
						|
  else
 | 
						|
    set_header(4,"@23g%-50s",(const char*) descriz);
 | 
						|
*/
 | 
						|
  
 | 
						|
  dataini = _data_ini.string();   
 | 
						|
  datafine = _data_fine.string();
 | 
						|
 | 
						|
  if (_annomsk == 0)
 | 
						|
  {                         
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_header (5, "@rPeriodo@10g@b%s", (const char*) dataini);
 | 
						|
      set_header (5, "@22g@b%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_header (5, "Periodo@10g%s", (const char*) dataini);
 | 
						|
      set_header (5, "@22g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {                         
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_header (5, "@rComp. da@9g@b%s", (const char*) dataini);
 | 
						|
      set_header (5, "@20g@ra@22g@b%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_header (5, "Comp. da@9g%s", (const char*) dataini);
 | 
						|
      set_header (5, "@20ga@22g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv);
 | 
						|
  set_header (5, "@49gCF@52g%-16s",(const char*) cofi);
 | 
						|
  set_header (5, "@66g%-.25s",(const char*) indcf);
 | 
						|
  set_header (5, "@95g%-5s",(const char*) capcf);
 | 
						|
  set_header (5, "@101g%-.24s",(const char*) dencom);
 | 
						|
  set_header (5, "@126g%-5s",(const char*) provcom);
 | 
						|
 
 | 
						|
  if (_numcarat == 2)
 | 
						|
  {
 | 
						|
    set_header (5,"@134g%-4s",(const char*) ptel);
 | 
						|
    if (tel != "")
 | 
						|
      set_header (5,"@138g/@139g%-10s",(const char*) tel);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::ricerca_clifo(int start)
 | 
						|
{
 | 
						|
  TString ragsoc,paiv,cofi,indcf,capcf,ptel,tel,statocf,comcf,dencom,provcom,dep;
 | 
						|
  TLocalisamfile clifo(LF_CLIFO);
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
  TString16 dataini,datafine; 
 | 
						|
  TString   descriz,descriz2;
 | 
						|
  int     numrivd;
 | 
						|
  int   r = start;
 | 
						|
  
 | 
						|
  indcf = "";
 | 
						|
  
 | 
						|
  clifo.setkey(1);
 | 
						|
  clifo.zero();
 | 
						|
  clifo.put(CLI_TIPOCF, _tmcf);
 | 
						|
  clifo.put(CLI_CODCF,  _sottoc);
 | 
						|
  clifo.read();
 | 
						|
  if (clifo.bad())
 | 
						|
    clifo.zero();
 | 
						|
  TConto tc (_gruppo,_conto,_sottoc,_tmcf);
 | 
						|
  
 | 
						|
  ragsoc  = tc.descrizione();
 | 
						|
  paiv    = clifo.get(CLI_PAIV);
 | 
						|
  cofi    = clifo.get(CLI_COFI);
 | 
						|
  indcf   = clifo.get(CLI_INDCF);
 | 
						|
  indcf.trim();
 | 
						|
  indcf << " " << clifo.get(CLI_CIVCF);
 | 
						|
  capcf   = clifo.get(CLI_CAPCF);
 | 
						|
  ptel    = clifo.get(CLI_PTEL);
 | 
						|
  tel     = clifo.get(CLI_TEL);
 | 
						|
  statocf = clifo.get(CLI_STATOCF);
 | 
						|
  comcf   = clifo.get(CLI_COMCF);
 | 
						|
 | 
						|
  _comuni->setkey(1);
 | 
						|
  _comuni->zero();
 | 
						|
  _comuni->put(COM_STATO, statocf);
 | 
						|
  _comuni->put(COM_COM, comcf);
 | 
						|
  _comuni->read();
 | 
						|
  if (_comuni->good())
 | 
						|
  {
 | 
						|
    dencom = _comuni->get(COM_DENCOM);
 | 
						|
    provcom = _comuni->get(COM_PROVCOM);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    //dencom="";
 | 
						|
    dencom=clifo.get(CLI_LOCCF);
 | 
						|
    provcom="";
 | 
						|
  }
 | 
						|
 | 
						|
  pconti.setkey(1);
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,     _gruppo);
 | 
						|
  pconti.put(PCN_CONTO,      _conto);
 | 
						|
  pconti.read();
 | 
						|
  _sezivd  = pconti.get_char(PCN_SEZIVD);
 | 
						|
  _lettivd = pconti.get_char(PCN_LETTIVD);
 | 
						|
  numrivd  = pconti.get_int(PCN_NUMRIVD); 
 | 
						|
  _numrivd = itor(numrivd);
 | 
						|
  _numivd  = pconti.get_int(PCN_NUMIVD);
 | 
						|
 | 
						|
  descriz = descrizione_classe(_sezivd,_lettivd,numrivd,_numivd);    
 | 
						|
 
 | 
						|
  if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | 
						|
  {                      //classe immediatamente precedente a quello appena
 | 
						|
   if (_numrivd != "")   //stampato
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | 
						|
   else
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_numrivd != "")
 | 
						|
      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);   
 | 
						|
    else
 | 
						|
      descriz2 = "";
 | 
						|
 
 | 
						|
  set_row (r,"@27g%-30s",(const char*) descrizione_gruppo());
 | 
						|
  set_row (r,"@59g%-30s",(const char*) descrizione_conto());
 | 
						|
  set_row(r++, "@91g%-30s",(const char*) ragsoc);
 | 
						|
 | 
						|
/*
 | 
						|
  if (_nummast == 3)                  
 | 
						|
    set_row(r, "@r%s@8g@b%c", trans("Classe"), _lettivd);
 | 
						|
  else
 | 
						|
    set_row(r, "%s@8g%c", trans("Classe"), _lettivd);
 | 
						|
  set_row(r, "@10g%-8s", (const char*) _numrivd);
 | 
						|
  if (_numivd != 0)
 | 
						|
    set_row(r, "@19g%2d", _numivd);
 | 
						|
  if (descriz2 != "")                              
 | 
						|
  {
 | 
						|
    set_row(r,"@23g%-50s",(const char*) descriz2);
 | 
						|
    set_row(r++,"@80g%-50s",(const char*) descriz);                                                  
 | 
						|
  }
 | 
						|
  else
 | 
						|
    set_row(r++,"@23g%-50s",(const char*) descriz);
 | 
						|
*/
 | 
						|
  
 | 
						|
  dataini = _data_ini.string();   
 | 
						|
  datafine = _data_fine.string();
 | 
						|
 | 
						|
  if (_annomsk == 0)
 | 
						|
  {                          
 | 
						|
    if (_nummast == 3)       
 | 
						|
    {
 | 
						|
      set_row (r, "@r%s@10g@b%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_row (r, "@22g%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_row (r, "%s@10g%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_row (r, "@22g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {                        
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_row (r, "@r%s@9g@b%s", trans("Comp.dal"), (const char*) dataini);
 | 
						|
      set_row (r, "@20g@r%s@22g@b%s@r", trans("al"), (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_row (r, "%s@9g%s", trans("Comp.dal"), (const char*) dataini);
 | 
						|
      set_row (r, "@20g%s@22g%s", trans("al"), (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  set_row (r, "@33gP.I.@37g%-11s",(const char*) paiv);
 | 
						|
  set_row (r, "@49gCF@52g%-16s",(const char*) cofi);
 | 
						|
  set_row (r, "@66g%-.25s",(const char*) indcf);
 | 
						|
  set_row (r, "@95g%-5s",(const char*) capcf);
 | 
						|
  set_row (r, "@101g%-.24s",(const char*) dencom);
 | 
						|
  set_row (r, "@126g%-5s",(const char*) provcom);
 | 
						|
 
 | 
						|
  if (_numcarat == 2)
 | 
						|
  {
 | 
						|
    set_row (r,"@134g%-4s",(const char*) ptel);
 | 
						|
    if (tel != "")
 | 
						|
      set_row (r++,"@138g/@139g%-10s",(const char*) tel);
 | 
						|
  }
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
// Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto
 | 
						|
// ricerca i corrispondenti su PCON, con relativa IV direttiva CEE
 | 
						|
 | 
						|
void TMastrini_application::ricerca_classe_IV(bool scelta)
 | 
						|
{
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
  
 | 
						|
  pconti.setkey(1);
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,     _gruppo);
 | 
						|
  pconti.put(PCN_CONTO,      _conto); 
 | 
						|
  if (scelta)
 | 
						|
    pconti.put(PCN_SOTTOCONTO, _sottoc);
 | 
						|
  pconti.read();
 | 
						|
  _sezivd  = pconti.get_char(PCN_SEZIVD);
 | 
						|
  _lettivd = pconti.get_char(PCN_LETTIVD);
 | 
						|
  _numrivd_int  = pconti.get_int (PCN_NUMRIVD); 
 | 
						|
  _numrivd = itor(_numrivd_int);
 | 
						|
  _numivd  = pconti.get_int (PCN_NUMIVD);
 | 
						|
}
 | 
						|
 
 | 
						|
void TMastrini_application::ricerca_gruppo()
 | 
						|
{ 
 | 
						|
  TString80 descr,descriz,descriz2,dep;
 | 
						|
  TString dataini,datafine;
 | 
						|
                           
 | 
						|
  ricerca_classe_IV (TRUE);    //Esiste a livello di sottoconto
 | 
						|
  
 | 
						|
  if (_sezivd == '0')           //Non esiste a livello di sottoconto
 | 
						|
    ricerca_classe_IV (FALSE);  //Allora la cerco a livello di conto
 | 
						|
                             
 | 
						|
  descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd);
 | 
						|
  if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | 
						|
  {                      //classe immediatamente precedente a quello appena
 | 
						|
   if (_numrivd != "")   //stampato
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | 
						|
   else
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_numrivd != "")
 | 
						|
      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);   
 | 
						|
    else
 | 
						|
      descriz2 = "";
 | 
						|
 | 
						|
  set_header(3,"@27g%-.30s",(const char*) descrizione_gruppo());
 | 
						|
  set_header(3,"@59g%-.30s",(const char*) descrizione_conto());
 | 
						|
 | 
						|
//  set_header(3,"@91g%-.41s",(const char*) descrizione_sottoconto());
 | 
						|
 | 
						|
/*
 | 
						|
  if (_nummast == 3)
 | 
						|
    set_header(4, "@0g@r%s@12g@b%c", trans("Classe"), _lettivd);
 | 
						|
  else
 | 
						|
    set_header(4, "@0g%s@12g%c", trans("Classe"), _lettivd);
 | 
						|
  set_header(4, "@14g%-8s",(const char*) _numrivd); 
 | 
						|
  if (_numivd != 0)
 | 
						|
    set_header(4, "@23g%d", _numivd); 
 | 
						|
  if (descriz2 != "")
 | 
						|
  {
 | 
						|
    set_header(4,"@27g%-50s",(const char*) descriz2);
 | 
						|
    set_header(4,"@80g%-50s",(const char*) descriz);                                                  
 | 
						|
  }
 | 
						|
  else
 | 
						|
    set_header(4,"@27g%-50s",(const char*) descriz);
 | 
						|
*/
 | 
						|
  
 | 
						|
  dataini = _data_ini.string();
 | 
						|
  datafine = _data_fine.string();
 | 
						|
 | 
						|
  if (_annomsk == 0)
 | 
						|
  { 
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_header (5, "@r%s@12g@b%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_header (5, "@24g@b%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_header (5, "%s@12g%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_header (5, "@24g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {                             
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_header (5, "@r%s@23g@b%s", trans("Periodo di competenza"), (const char*) dataini);
 | 
						|
      set_header (5, "@35g%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_header (5, "%s@23g%s", trans("Periodo di competenza"), (const char*) dataini);
 | 
						|
      set_header (5, "@35g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int TMastrini_application::ricerca_gruppo(int start)
 | 
						|
{ 
 | 
						|
  TString dataini,datafine;
 | 
						|
  int   r = start;
 | 
						|
 | 
						|
/* Guy: non la stampo e non la ricerco nemmeno
 | 
						|
  TString80 descr,descriz,descriz2,dep;
 | 
						|
  ricerca_classe_IV (TRUE);    //Esiste a livello di sottoconto
 | 
						|
  
 | 
						|
  if (_sezivd == '0')           //Non esiste a livello di sottoconto
 | 
						|
    ricerca_classe_IV (FALSE);  //Allora la cerco a livello di conto
 | 
						|
                             
 | 
						|
  descriz = descrizione_classe(_sezivd,_lettivd,_numrivd_int,_numivd);
 | 
						|
  if (_numivd != 0)      //Ora devo stampare la descrizione del livello della
 | 
						|
  {                      //classe immediatamente precedente a quello appena
 | 
						|
   if (_numrivd != "")   //stampato
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,_numrivd_int,0);
 | 
						|
   else
 | 
						|
     descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (_numrivd != "")
 | 
						|
      descriz2 = descrizione_classe(_sezivd,_lettivd,0,0);   
 | 
						|
    else
 | 
						|
      descriz2 = "";
 | 
						|
*/
 | 
						|
 | 
						|
  set_row(r,"@27g%-.30s",(const char*) descrizione_gruppo());
 | 
						|
  set_row(r,"@59g%-.30s",(const char*) descrizione_conto());
 | 
						|
//  set_row(r,"@91g%-.41s",(const char*) descrizione_sottoconto());
 | 
						|
  r++;
 | 
						|
 | 
						|
/*
 | 
						|
  if (_nummast == 3)
 | 
						|
    set_row(r, "@0g@r%s@12g@b%c", trans("Classe"), _lettivd);
 | 
						|
  else
 | 
						|
    set_row(r, "@0g%s@12g%c", trans("Classe"), _lettivd);
 | 
						|
  set_row(r, "@14g%-8s",(const char*) _numrivd); 
 | 
						|
  if (_numivd != 0)
 | 
						|
    set_row(r, "@23g%d", _numivd); 
 | 
						|
  if (descriz2 != "")
 | 
						|
  {
 | 
						|
    set_row(r,"@27g%-50s",(const char*) descriz2);
 | 
						|
    set_row(r++,"@80g%-50s",(const char*) descriz);                                                  
 | 
						|
  }
 | 
						|
  else
 | 
						|
    set_row(r++,"@27g%-50s",(const char*) descriz);
 | 
						|
*/
 | 
						|
  
 | 
						|
  dataini = _data_ini.string();
 | 
						|
  datafine = _data_fine.string();
 | 
						|
 | 
						|
  if (_annomsk == 0)
 | 
						|
  {                              
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_row (r, "@r%s@12g@b%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_row (r, "@24g%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_row (r, "%s@12g%s", trans("Periodo"), (const char*) dataini);
 | 
						|
      set_row (r, "@24g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {                        
 | 
						|
    if (_nummast == 3)
 | 
						|
    {
 | 
						|
      set_row (r, "@r%s@23g@b%s", trans("Periodo di competenza"), (const char*) dataini);
 | 
						|
      set_row (r, "@35g%s@r", (const char*) datafine);    
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      set_row (r, "%s@23g%s", trans("Periodo di competenza"), (const char*) dataini);
 | 
						|
      set_row (r, "@35g%s", (const char*) datafine);
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
const char* TMastrini_application::descrizione_classe(char sezione, char lettera, int numr, int numero)
 | 
						|
{
 | 
						|
  TTable tabivd(TAB_IVD);
 | 
						|
  TString dep,dep2;
 | 
						|
 | 
						|
  tabivd.zero();   
 | 
						|
  if (numr == 0 && numero == 0)
 | 
						|
    dep = format("%c%c",sezione,lettera);
 | 
						|
  else                        
 | 
						|
    if (numero == 0)
 | 
						|
    {
 | 
						|
      if (numr != 0)
 | 
						|
        dep = format("%1c%1c%04d",sezione, lettera, numr);
 | 
						|
      else
 | 
						|
        dep = format("%c%c    ",sezione,lettera);
 | 
						|
     }
 | 
						|
     else                                         
 | 
						|
     {
 | 
						|
       if (numr != 0)
 | 
						|
         dep = format("%1c%1c%04d%02d",sezione, lettera, numr,numero);
 | 
						|
       else
 | 
						|
         dep = format("%c%c    %02d",sezione,lettera,numero);
 | 
						|
     }
 | 
						|
       
 | 
						|
  tabivd.put("CODTAB", dep);
 | 
						|
  tabivd.read();   
 | 
						|
  dep2 = tabivd.get("CODTAB");
 | 
						|
  if (dep == dep2)
 | 
						|
    TMP = tabivd.get("S0");
 | 
						|
  else
 | 
						|
    TMP = "";
 | 
						|
  return TMP;
 | 
						|
}     
 | 
						|
 | 
						|
//Ricerca la descrizione relativa al gruppo da stampare
 | 
						|
 | 
						|
const char* TMastrini_application::descrizione_gruppo()
 | 
						|
{  
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,_gruppo);
 | 
						|
  if (pconti.read() != NOERR) pconti.zero();
 | 
						|
  TMP = pconti.get(PCN_DESCR);
 | 
						|
  return TMP;
 | 
						|
}
 | 
						|
 | 
						|
// Ricerca la descrizione relativa al conto da stampare
 | 
						|
 | 
						|
const char* TMastrini_application::descrizione_conto()
 | 
						|
{ 
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,_gruppo);
 | 
						|
  pconti.put(PCN_CONTO,_conto);
 | 
						|
  if (pconti.read() != NOERR) pconti.zero();
 | 
						|
  TMP = pconti.get(PCN_DESCR);
 | 
						|
  return TMP;
 | 
						|
}
 | 
						|
 | 
						|
const char* TMastrini_application::descrizione_sottoconto()
 | 
						|
{ 
 | 
						|
  TLocalisamfile pconti(LF_PCON);
 | 
						|
 | 
						|
  pconti.zero();
 | 
						|
  pconti.put(PCN_GRUPPO,     _gruppo);
 | 
						|
  pconti.put(PCN_CONTO,      _conto);
 | 
						|
  pconti.put(PCN_SOTTOCONTO, _sottoc);
 | 
						|
  if (pconti.read() != NOERR) pconti.zero();
 | 
						|
  TMP = pconti.get(PCN_DESCR);
 | 
						|
  return TMP;
 | 
						|
}
 | 
						|
 | 
						|
// Funzione per settare tutti gli handlers della maschera principale
 | 
						|
// o di quella dello spreadsheet della seconda pagina
 | 
						|
void TMastrini_application::set_handlers(TMask* msk) const
 | 
						|
{
 | 
						|
  msk->set_handler(F_DATAINI,            data_inizio);
 | 
						|
  msk->set_handler(F_DATAFINE,           data_fine);
 | 
						|
  msk->set_handler(F_GRUPPOFINE,         gruppo_hnd);
 | 
						|
}
 | 
						|
 | 
						|
// Copia i parametri della prima pagina in una nuova riga dello spreadsheet
 | 
						|
// a meno che non ci siano gia'
 | 
						|
bool TMastrini_application::mask2sheet()
 | 
						|
{ 
 | 
						|
  bool ok = _msk->check_fields();
 | 
						|
  
 | 
						|
  if (ok)
 | 
						|
  {
 | 
						|
    TToken_string row(120);
 | 
						|
    short id = F_ANNO;
 | 
						|
    for (int pos = _msk->id2pos(id); pos >= 0; pos = _msk->id2pos(++id))
 | 
						|
      row.add(_msk->fld(pos).get());
 | 
						|
    
 | 
						|
    if (!row.empty_items())
 | 
						|
    {
 | 
						|
      TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE);
 | 
						|
      TString_array& rows = sht.rows_array();
 | 
						|
      ok = rows.find(row) < 0; // Aggiunge solo se non c'e' gia'
 | 
						|
      if (ok)              
 | 
						|
      {
 | 
						|
        rows.add(row);
 | 
						|
        sht.force_update();
 | 
						|
      }  
 | 
						|
    }
 | 
						|
  }
 | 
						|
  
 | 
						|
  return ok;  
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::sheet2mask()
 | 
						|
{ 
 | 
						|
  TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE);
 | 
						|
  bool ok = sht.items() > 0;
 | 
						|
  if (ok)
 | 
						|
  {
 | 
						|
    TString_array& rows = sht.rows_array();
 | 
						|
    TToken_string& row = rows.row(0);
 | 
						|
    row.restart();
 | 
						|
 | 
						|
    short id = F_ANNO;
 | 
						|
    for (int pos = _msk->id2pos(id); pos >= 0; pos = _msk->id2pos(++id))
 | 
						|
    {                                   
 | 
						|
      const char* val = row.get();        
 | 
						|
      _msk->fld(pos).set(val);
 | 
						|
    }
 | 
						|
 | 
						|
    rows.destroy(0, TRUE);
 | 
						|
  }
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::user_create()
 | 
						|
{
 | 
						|
  _rel = new TRelation (LF_SALDI);
 | 
						|
  TSortedfile* rmov = new TSortedfile(LF_RMOV, NULL, "GRUPPO|CONTO|DATAREG|SOTTOCONTO", "", 2);
 | 
						|
  _rel->add(rmov,"GRUPPO==GRUPPO|CONTO==CONTO",2,LF_SALDI);
 | 
						|
  
 | 
						|
/* Debugging purpose 
 | 
						|
  TCursor_sheet dbgsht(&rmov->cursor(), "GRUPPO|CONTO|DATAREG|SOTTOCONTO|NUMREG|NUMRIG",
 | 
						|
                       "Test sorter", "Gruppo|Conto|Data@10|Sottoconto|Numreg|Numrig");
 | 
						|
  dbgsht.run();                  
 | 
						|
*/ 
 | 
						|
//  rmov->cursor() = 0L;
 | 
						|
 | 
						|
  _cur1=add_cursor(new TCursor(_rel,"FLSCA=\" \"",2)); 
 | 
						|
  
 | 
						|
  _nditte = new TLocalisamfile (LF_NDITTE);
 | 
						|
  _unloc  = new TLocalisamfile (LF_UNLOC);
 | 
						|
  _comuni = new TLocalisamfile (LF_COMUNI);
 | 
						|
  _mov    = new TLocalisamfile (LF_MOV);
 | 
						|
  _clifo  = new TLocalisamfile (LF_CLIFO);
 | 
						|
  _caus   = new TLocalisamfile (LF_CAUSALI);
 | 
						|
  _tabivd = new TTable (TAB_IVD);
 | 
						|
  _tabtpd = new TTable (TAB_TPD);
 | 
						|
  _tabreg = new TTable (TAB_REG);
 | 
						|
  _sld    = new TSaldo ();
 | 
						|
  
 | 
						|
  _d18   = new TParagraph_string ("",18);
 | 
						|
  _d23   = new TParagraph_string ("",23);
 | 
						|
  _d30   = new TParagraph_string ("",30);
 | 
						|
  
 | 
						|
  _msk = new TMask("cgp3100a");     
 | 
						|
  set_handlers(_msk);
 | 
						|
  _msk->set_handler(F_MEMORIZZA, memorizza_handler);
 | 
						|
  
 | 
						|
  TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE);
 | 
						|
  sht.set_notify(scelte_notify);
 | 
						|
  TMask& sm = sht.sheet_mask();
 | 
						|
  set_handlers(&sm);
 | 
						|
    
 | 
						|
  _gia_stampata_intestazione = FALSE;
 | 
						|
  
 | 
						|
  _collins = new TConfig("cg3200.ini", "Main");
 | 
						|
  const TString& language = _collins->get("Language");
 | 
						|
  _collins->set_paragraph(language);
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TMastrini_application::user_destroy()
 | 
						|
{
 | 
						|
  delete _msk;
 | 
						|
  delete _mov;
 | 
						|
  delete _nditte;
 | 
						|
  delete _unloc;
 | 
						|
  delete _comuni;
 | 
						|
  delete _clifo;
 | 
						|
  delete _caus;
 | 
						|
  delete _tabreg;
 | 
						|
  delete _tabtpd;
 | 
						|
  delete _tabivd;
 | 
						|
  delete _sld;
 | 
						|
  delete _d18;
 | 
						|
  delete _d23;
 | 
						|
  delete _d30;
 | 
						|
  delete _rel;
 | 
						|
  
 | 
						|
  delete _collins;
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int cgp3100(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TMastrini_application a;
 | 
						|
  a.run(argc, argv, "Stampa Mastrini per Conti");
 | 
						|
  return 0;
 | 
						|
}
 | 
						|
 | 
						|
 |