<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */






class DBWorkHLGebuehrenArten extends DBWorkHLBasis
{
  
  public function getNewObject()
  {
    return new GebuehrArt();
  }

  public function getTableName(): string
  {
    return 'hlgebarten';
  }

  
  public function getCurrentRow($pRefreshCache = false)
  {
    $tmp = $this->getNewObject();
    $tmp->id = $this->getDatamodulValue('id');
    $tmp->schluessel = $this->getDatamodulValue('schluessel');
    $tmp->text = $this->getDatamodulValue('text');
    $tmp->ermaessigbar = ($this->getDatamodulValue('ermaessigbar') == 'F');
    $tmp->betrag = $this->getDatamodulValue('betrag');
    $tmp->betrag_ermaessigt = $this->getDatamodulValue('ermaessigt');
    $tmp->mwst = $this->getDatamodulValue('mwst');
    $tmp->konto = $this->getDatamodulValue('konto');
    $tmp->kostenst = $this->getDatamodulValue('kostenst');
    $tmp->dp = $this->getDatamodulValue('dp');

    return $tmp;
  }

  
  public function getAll()
  {
    $this->dboperation->clear();
    $this->dboperation->query('SELECT * FROM hlgebarten');

    return $this->getAllRows();
  }

  
  public function getOne($pId)
  {
    $id = $this->dboperation->getInt4Sql($pId);
    $this->dboperation->clear();
    $this->dboperation->query("SELECT * FROM hlgebarten WHERE id='" . $id . "'");

    return $this->getFirstRow();
  }

  public function getBySchluessel($pSchluessel)
  {
    $schluessel = $this->dboperation->getInt4Sql($pSchluessel);
    $this->dboperation->clear();
    $this->dboperation->query("SELECT * FROM hlgebarten WHERE schluessel='" . $schluessel . "'");

    return $this->getFirstRow();
  }
}