#ifndef __TCLIFOR_H
#define __TCLIFOR_H

#ifndef __CHECKS_H
#include <checks.h>
#endif

#ifndef __RELATION_H
#include <relation.h>
#endif

#ifndef __TABUTIL_H
#include <tabutil.h>
#endif


#ifndef __TMASKVEN_H
#include "tmaskven.h"
#endif

class TData_picker : public TRelation
{
private:
  
  TTable* _table;
  TString16 _tablename;
  
public:
  TData_picker( const int mainfile ) : TRelation ( mainfile ) { }
  const TString& get( const TString& table, const TString& codtab, const TString& field );
  const TString& get( const int file, const TString& fieldname );
  int get_int( const int file, const TString& fieldname );
  long get_long( const int file, const TString& fieldname );
  bool get_bool( const int file, const TString& fieldname );
  void set( TMask_vendite& m, const int mskfield, const int file, const TString& filefield ){ m.set( mskfield, get( file, filefield ) ); };
};

class TCliFor : public TData_picker
{ 
private:

  bool _occas;
  TMask _occas_mask;
  
protected:
  
  char _tipocf;
  long _codcf;
  
public:

  TCliFor( );
  void load( const char tipocf, const long codcf, const TString& ocfpi  );
  bool occasionale( ){ return get_bool( LF_CLIFO, "OCCAS" ); };
  TMask& occas_mask( ){ return _occas_mask; };
  static bool occas_code_handler(TMask_field& f, KEY key);
  int write_occas( );
  void edita_occasionale( );
  char tipocf( ){ return _tipocf; } 
  long codcf( ){ return _codcf; } 
};

class TCliForVendite : public TCliFor
{    

public:

  void update_mask( TMask_vendite& m, bool onload = FALSE );
  void imposta_dati_comune( TMask_vendite& m );
  void imposta_valuta( TMask_vendite& m );
  void imposta_indirizzo_spedizione( TMask_vendite& m );
  void imposta_sconto_testa( TMask_vendite& m );
  
};

#endif
