if ($pyear == '') {
    $pyear = date('Y');
}
$t_date = $pday . '.' . $pmonth . '.' . $pyear;
if ($mode) {
    $dbtable = 'care_ward';
    if (!isset($db) || !$db) {
        include $root_path . 'include/inc_db_makelink.php';
    }
    if ($dblink_ok) {
        switch ($mode) {
            case 'create':
                //$db->debug=1;
                /* check if ward already exists */
                if (!$ward->IDExists($ward_id)) {
                    if ($ergebnis = $ward->saveWard($_POST)) {
                        if ($dbtype == 'mysql') {
                            $ward_nr = $db->Insert_ID();
                        } else {
                            $ward_nr = $ward->postgre_Insert_ID($dbtable, 'nr', $db->Insert_ID());
                        }
                        header("location:nursing-station-new-createbeds.php?sid={$sid}&lang={$lang}&ward_nr={$ward_nr}");
                        exit;
                    } else {
                        echo "{$sql}<br>{$LDDbNoSave}";
                    }
                } else {
                    $ward_exists = true;
                }
                break;
        }