// 774200.h - Riporti dai quadri
#ifndef __774200_H
#define __774200_H

#include <mailbox.h>                

#include "base.h"
#include "basebis.h"
#include "quadroa.h"

bool filter_func (const TRelation *);

enum {A,A1,A2,A3,B,B1,C,D,D1,E,E1,E2,F,F1,F2,G,G1,H,I,L,N,P,Q,R,S,T,AB,DB,U};

const int CAMPI_IB1 = 79;
const int CAMPI_IB2 = 76;

HIDDEN const char* _campi_I1[CAMPI_IB1] = 
{
	"A0NFCOM",
	"A0NLDIP",
	"A0COBB",
	"A0NSRIT",
	"A0EPREV",
	"A0RETPEN",
	"A0CTER",
	"A0TIMP",
	"A0ILOR",
	"A0TDET",
	"A0EUROT",
	"A0RTER",
	"A0RDAT",
	"A0ERIT",
	"A0CARR",
	"A0AARR",
	"A0DARR",
	"A0RARR",
	"A0RITSI",
	"A0CINPS",
	"A0RITOPEVA",
	"A0RITOPESA",
	"A0CIIAUT",
	"ABNADLAV",
	"ABNACAAF",
	"A0CRIMPRAS",
	"A0CRIMP85",
	"A3NFCOM",
	"A3NUMPER",
	"A3REPT10",
	"A3REPT12",
	"B0NFCOM",
	"B0NLDIP",
	"B0TFR93",
	"B0AI",
	"B0COLAV",
	"B0TFR7492",
	"B0AI7492",
	"B0RITSI",
	"B0IMP",
	"B0TIMP",
	"B0ROP",
	"B0AIINPS",
	"B0ROPESA",
	"B0CIIAUT",
	"B0CRIMPRAS",
	"B0CRIMP85",
	"B1NFCOM",
	"B1NPER",
	"B1TIND",
	"B1TIRM",
	"B1TICOM",
	"C0NFCOM",
	"C0NLASS",
	"C0ACTOT",
	"C0CONTSSN",
	"C0SNSRIT",
	"C0ROPE",
	"C0CIIAUT",
	"C0CRIMPRAS",
	"D0NFCOM",
	"D0NLAUT",
	"D0ACTOT",
	"D0SNSRIT",
	"D0ROPE",
	"D0CIIAUT",
	"D0CRIMPRAS",
	"D0CRIMP85",
	"D1NFCOM",
	"D1NPER",
	"D1TACOR",
	"D1SNSRIT",
	"D1ROPE",
	"D1CRIMPRAS",
	"C0TOTIMP",
	"C0TOTDET",
	"C0RITOPE",
	"D0NSRITRC",
	"ABNFCOM"
};

HIDDEN const char* _campi_I2[CAMPI_IB2] = 
{
	"E0NFCOM",
	"E0NPER",
	"E0AIMP",
	"E0ROPE",
	"E0SNSRIT",
	"E0CRIMPRAS",
	"E1NFCOM",
	"E1NPER",
	"E1SCOR",
	"E1BCOM",
	"E1ROPE",
	"E1ACOM",
	"E1BCOM2",
	"E1ROPE2",
	"E1CRIMPRAS",
	"E2NFCOM",
	"E2NPER",
	"E2ROPE",
	"E2SSRIT",
	"E2CRIMPRAS",
	"F0AMMPRO",
	"F0PREOPE",
	"G1RITIV2",
	"G1UTNSR1S",
	"G1UTNSR2S",
	"F0SSRITBF",
	"F0ROPEBF",
	"ABIR2R",
	"ABCS2R",
	"F0CRIMPRAS",
	"F1NFCOM",
	"F1NPER",
	"F1SSRIT",
	"F1ROPE",
	"F1CRIMPRAS",
	"F2SSRIT",
	"F2ROPE",
	"F2CRIMPRAS",
	"G0NFCOM",
	"G0UTDACOR",
	"G0UTDELDIS",
	"G0UTCOR1S",
	"G0UTCOR2S",
	"G0ROPE",
	"G0UTDACOR2",
	"G0RACC3",
	"G0RIMP3",
	"G0UNSRIT3",
	"G0USPE",
	"G0RITSPET",
	"G0UPAG",
	"G0NPER",
	"G0CRIMPRAS",
	"G1UTCOR1S",
	"G1UTCOR2S",
	"G1RITAV1",
	"G1RITAV2",
	"G1RITIV1",
	"G1CRIMPRAS",
	"H0CODLAV",
	"H0COLDIP",
	"ABIRSA",
	"ABIR1R",
	"ABCSSA",
	"ABCS1R",
	"ABEURO",
	"ABACCTS",
	"DBNFCOM",
	"DBNPER",
	"DBAMMCOR",
	"DBNSRIT",
	"DBNSRITRC",
	"DBRITOPE",
	"DBCRIMAUT",
	"DBCRIMASS",
	"DBCRIML85"
};                                         
                                          

class TRiporti : public TObject
{ 
  friend bool filter_func (const TRelation *);
  
  long      _codditta;
  int       _annodic;
  TString16 _quadro;

protected:
  void  setta_flag_quadri_comp (const long codditta, const int posquadro, const bool aur, TLocalisamfile& basebis, const long dich=0L);
// Setta flag di compilato guardando se esistono i riporti sul quadro I
  void  setta_flag_quadro_I (const long codditta, const long dich=0L);
  
  void sum(TRectype& dst, const TRectype& src) const;

  void  calcola_riporti_A(TCursor* cur, const long dich=0L);  
  void  calcola_riporti_AB(TCursor* cur, const long dich=0L); 
  void  calcola_riporti_A1(TCursor* cur, const long dich=0L);   
  void  calcola_riporti_A2(TCursor* cur, const long dich=0L);     
  void  calcola_riporti_A3(TCursor* cur, const long dich=0L);       
  void  calcola_riporti_B(TCursor* cur, const long dich=0L); 
  void  calcola_riporti_B1(TCursor* cur, const long dich=0L); 
  void  calcola_riporti_H(TCursor* cur, const long dich=0L);  
  void  calcola_riporti_L(TCursor* cur, const long dich=0L); 
  void  calcola_riporti_C (const long dich=0L);
  void  calcola_riporti_D (const long dich=0L);
  void  calcola_riporti_Dbis(const long dich=0L);
  void  calcola_riporti_D1(const long dich=0L);  
  void  calcola_riporti_E (const long dich=0L);
  void  calcola_riporti_E1(const long dich=0L);
  void  calcola_riporti_E2(const long dich=0L);
  void  calcola_riporti_F (const long dich=0L);
  void  calcola_riporti_F1(const long dich=0L);
  void  calcola_riporti_F2(const long dich=0L);    
  void  calcola_riporti_G (const long dich=0L);                                                
  void  calcola_riporti_G1(const long dich=0L);      
public:                                        
  bool  riporta_I_globale(const long dich);
  bool  riporti_dich(const long dich, const int anno);
  bool  set(const TString& quadro, int anno=0, const long codditta=0L, const long dichiarante=0L);
  void  set_compilato(const long codditta, const int posquadro, const bool compilato);

  TRiporti() {}
  virtual ~TRiporti() {}
};

#endif