<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
function list_system_users()
{
require_role(ROLE_SYSADMIN);
$result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
$ret = [];
while ($item = $result->fetch(PDO::FETCH_OBJ)) {
array_push($ret, $item);
}
return $ret;
}
function list_customers()
{
require_role(ROLE_SYSADMIN);
$result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
$ret = [];
while ($item = $result->fetch(PDO::FETCH_OBJ)) {
array_push($ret, $item);
}
return $ret;
}
function customer_details($id)
{
$id = (int) $id;
$result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", [$id]);
if ($result->rowCount() < 1) {
return null;
}
$kunde = $result->fetch();
return $kunde;
}