#ifndef __TCLIFOR_H
#define __TCLIFOR_H

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

#ifndef __VARMASK_H
#include <varmask.h>
#endif

class TData_picker : public TRelation
{
public:
  TData_picker( const int mainfile ) : TRelation ( mainfile ) { }
  virtual ~TData_picker() {}
  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& 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;
  bool _valid;
  
protected:
  
  char _tipocf;
  long _codcf;
  
public:

  TCliFor( );
  bool 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; } 
  bool ok() { return _valid;}
};

class TCliForVendite : public TCliFor
{    

public:

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

#endif
