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


class HinterlegungGemeindenDialog extends HinterlegungDialogBasis
{
  public $data;

  public function __construct()
  {
    parent::__construct();
    $dbw = new DBWorkHLGemeinde(1, true);
    $this->data = $dbw->getAll();
  }

  public function GetColumnCount()
  {
    
    return 2;
  }

  public function GetColumnTitle($index)
  {
    switch ($index) {
      case 0: return 'Gemeinde';
      
      case 1: return 'Bezirk';
      
      default: return parent::GetColumnTitle($index);
    }
  }

  public function GetRowCount()
  {
    return count($this->data);
  }

  public function GetIdColumnIndices()
  {
    return array(0, 1, 2, 3, 4, 5);
  }

  public function GetValueAt($row, $column)
  {
    switch ($column) {
      case 0:
        return $this->data[$row]->gemeinde;
      case 1:
        return $this->data[$row]->bezirk;
      case 2:
        return $this->data[$row]->stadtteil;
      case 3:
        return $this->data[$row]->bundesland;
      case 4: 
        $found = array();
        preg_match('/(\\d*)(.*)/', $this->data[$row]->gemeinde, $found);
        if (isset($found[1])) {
          return $found[1];
        }

        return '';
      case 5: 
        $found = array();
        preg_match('/(\\d*)(.*)/', $this->data[$row]->gemeinde, $found);
        if (isset($found[2])) {
          return trim($found[2]);
        }

        return '';
    }
  }
}