<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\Classes\Datamodul;


class HonorarAbnahmeReklamation extends \Datamodul
{
  public $hon_abnahme_eintrag_id;
  public $hon_detail_id;
  public $field;
  public $value; 
  public $old_value = '';
  public $custom_value = '';
  public $status = 0;
  
  public $honDetail;

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'hon_abnahme_eintrag_id':
      case 'hon_detail_id':
      case 'status':
        return \DatamodulVarType::TYPE_INT;
    }
  }

  public function getDmzVarnameMappingForReceivingData(): array
  {
    return array(
      'HonorarAbnahmeEintragId' => 'hon_abnahme_eintrag_id',
      'HonDetailId' => 'hon_detail_id',
      'OldValue' => 'old_value',
      'CustomValue' => 'custom_value'
    );
  }

  public function updateHonDetailWithNewValue(\HonDetail &$pHonDetail)
  {
    if ($pHonDetail->getTyp($this->field) === \DatamodulVarType::TYPE_FLOAT_DOT) {
      $pHonDetail->{$this->field} = \MathOperations::stringToFloat($this->value);
    } else {
      $pHonDetail->{$this->field} = $this->value;
    }
  }
}