function erp_einheiten() {

    $pdo = erp_pdo();

    $action = $_GET['action'] ?? 'einheiten';
    $id     = intval($_GET['id'] ?? 0);

    /* =========================
       DELETE
    ========================= */
    if ($action === 'einheiten_delete' && $id > 0) {

        $stmt = $pdo->prepare("DELETE FROM tblEinheit WHERE EINH_ID = ?");
        $stmt->execute([$id]);

        wp_safe_redirect('?action=einheiten');
        exit;
    }

    /* =========================
       EDIT
    ========================= */
    $edit = null;

    if ($action === 'einheiten_edit' && $id > 0) {

        $stmt = $pdo->prepare("SELECT * FROM tblEinheit WHERE EINH_ID = ?");
        $stmt->execute([$id]);

        $edit = $stmt->fetch(PDO::FETCH_ASSOC);
    }

    /* =========================
       SAVE
    ========================= */
    if (isset($_POST['save'])) {

        $id   = intval($_POST['id']);
        $bez  = trim($_POST['einh_bez']);
        $kurz = trim($_POST['kurz']);

        if ($id > 0) {

            $stmt = $pdo->prepare("
                UPDATE tblEinheit
                SET EINH_BEZ = ?, KURZ = ?
                WHERE EINH_ID = ?
            ");

            $stmt->execute([$bez, $kurz, $id]);

        } else {

            $stmt = $pdo->prepare("
                INSERT INTO tblEinheit (EINH_BEZ, KURZ)
                VALUES (?, ?)
            ");

            $stmt->execute([$bez, $kurz]);
        }

        wp_safe_redirect('?action=einheiten');
        exit;
    }

    /* =========================
       LISTE
    ========================= */

    $liste = $pdo->query("
        SELECT * FROM tblEinheit ORDER BY EINH_BEZ
    ")->fetchAll(PDO::FETCH_ASSOC);

    ob_start();<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://janssen-oh.de/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://janssen-oh.de/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://janssen-oh.de/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://janssen-oh.de/wp-sitemap-posts-sureforms_form-1.xml</loc></sitemap><sitemap><loc>https://janssen-oh.de/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://janssen-oh.de/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
