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






class DBWorkDozentenVertrag extends DBWork
{ 

  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = "wdv.id,wdv.tan_id,wdv.dozkurs_id,\n"
                     . $this->clob('wdv.vertrag');
  }

  
  public function getNewObject()
  {
    return new DozentenVertrag();
  }

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

  
  public function getCurrentRow($pRefreshCache = false)
  {
    $tmp = $this->getNewObject();
    $tmp->id = $this->getDatamodulValue('id');
    $tmp->tan_id = $this->getDatamodulValue('tan_id');
    $tmp->dozkurs_id = $this->getDatamodulValue('dozkurs_id');
    $tmp->vertrag = $this->getDatamodulValue('vertrag');

    return $tmp;
  }

  public function getDozentenVertrag($pId)
  {
    $id = $this->dboperation->getInt4Sql($pId);
    $this->dboperation->clear();
    $this->dboperation->query("SELECT $this->select FROM web_dozentenvertraege wdv WHERE wdv.id=$id");

    return $this->getFirstRow();
  }

  public function insertDozentenVertrag($dozvertrag)
  {
    $dozvertrag->id = $this->insertRecord('web_dozentenvertraege', 'id', 'vertrag');
    $this->saveChanging('web_dozentenvertraege', '', '', $dozvertrag->id, 'id', 'I');
    $orgdozvertrag = $this->getDozentenVertrag($dozvertrag->id);
    $this->updateObject($dozvertrag, $orgdozvertrag, 'web_dozentenvertraege', 'id', 'A');
    $this->setActionIDs();

    return $dozvertrag->id;
  }
}