#include <prefix.h>

#include "sc2101.h"                    
#include "sc2100a.h"                    

#include <comuni.h>

TEC_mask::TEC_mask(const char* name) : TSelection_mask(name), _ditta(LF_NDITTE)
{
  _ditta.add(LF_ANAG,   "TIPOA==TIPOA|CODANAGR==CODANAGR");
  _ditta.add(LF_COMUNI, "COM==COMRF(COMRES)", 1, LF_ANAG, 101);
  _ditta.add(LF_COMUNI, "COM==COMRES", 1, LF_ANAG, 102);
}

TEC_mask::~TEC_mask()
{
}             

void TEC_mask::on_firm_change()
{    
  TMask::on_firm_change();

  _ditta[0].put("CODDITTA", prefix().get_codditta());
  if (_ditta.read() == NOERR)
  {                        
    const int alias = _ditta[LF_ANAG].get_char("TIPOA") == 'F' ? -101 : -102;
    set(F_LUOGOSEND, _ditta.lfile(alias).get("DENCOM"));  
  }    
}

void TEC_mask::start_run()
{
  on_firm_change();
}

const char* TEC_mask::get_prof_base() const
{
  return BASE_EC_PROFILE;
} 

const TString& TEC_mask::get_prof_code() const
{
  return get(F_CODPROF);
} 

const TString& TEC_mask::get_prof_lang() const
{
  return get(F_LINPROF);
}
