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


class DBWorkUhrzeit extends DBWork
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = 'id, beginn, ende, pausen_min ';
  }

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

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

  
  public function getCurrentRow($pRefreshCache = false)
  {
    $ret = $this->getNewObject();
    $ret->beginn = $this->getDatamodulValue('beginn');
    $ret->ende = $this->getDatamodulValue('ende');
    $ret->pausen_min = $this->getDatamodulValue('pausen_min');

    return $ret;
  }

  
  public function getUhrzeiten()
  {
    $sql = 'select ' . $this->select . ' from uhrzeit';
    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return  $this->getAllRows();
  }

  
  public function getBeginnUhrzeiten()
  {
    $sql = 'SELECT DISTINCT beginn FROM uhrzeit ORDER BY beginn';
    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return $this->getAllRowsSingleColumn('beginn');
  }

  
  public function getEndeUhrzeiten()
  {
    $sql = 'SELECT DISTINCT ende FROM uhrzeit ORDER BY ende';
    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return $this->getAllRowsSingleColumn('ende');
  }
}