Add classes for future processing
[infodrom.org/service.infodrom.org] / class / accountname.class.php
1 <?php
2
3 class AccountName extends DatabaseTable {
4
5   public function __construct($id)
6   {
7     if (is_numeric($id))
8       parent::__construct('account_names', $id);
9     else
10       parent::__construct('account_names', $id, 'blz_kto');
11   }
12
13   public function getAccounts($currency, $display=false)
14   {
15     if ($currency == "eur")
16       $table = "account";
17     else
18       $table = "account_dm";
19
20     $sql = sprintf("SELECT DISTINCT %s.blz_kto,name FROM %s JOIN account_names using(blz_kto)%s ORDER BY name",
21                    $table, $table,
22                    $display === false ? '' : ' WHERE display = '.$display);
23     return $this->db->fetchObjectList($sql);
24   }
25
26   public function name()
27   {
28     if (!$this->data)
29       return 'Unbekannt';
30
31     $both = explode (":", $this->data->blz_kto);
32     if (count($both) > 1)
33       return sprintf ("%s (BLZ %s, Konto %s)", $this->data->name, $both[0], $both[1]);
34     else
35       return sprintf ("%s (%s)", $this->data->name, $this->data->blz_kto);
36   }
37
38 }
39
40 ?>