$id > 1); foreach ($valid_ids as $val) { LOG_INFO($db_link, 'Remove building id: ' . $val . ' ' . dump_record($db_link, 'building', 'id=?', [$val])); delete_record($db_link, "building", "id=?", [$val]); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (getPOST("save")) { $r_id = getPOST("r_id",null, []); $f_building_name = getPOST("f_building_name", null, []); $f_building_description = getPOST("f_building_description", null, []); $save_flags = getPOST("save", null, []); $r_id = array_map('intval', $r_id); $save_flags = array_map('intval', $save_flags); foreach ($save_flags as $i => $save_id) { if ($save_id <= 0) continue; $found_index = array_search($save_id, $r_id, true); if ($found_index === false) continue; $name = trim($f_building_name[$found_index] ?? ''); $description = trim($f_building_description[$found_index] ?? ''); if ($name !== '') { $new = ['name' => $name, 'description' => $description]; LOG_INFO($db_link, "Change building id='{$save_id}': name=" . $name . " description=" . $description); update_record($db_link, "building", "id=?", $new, [$save_id]); } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (getPOST("create")) { $building_name = trim(getPOST("new_building", null, '')); if ($building_name !== '') { $new = ['name' => $building_name]; LOG_INFO($db_link, "Add building: " . $building_name); insert_record($db_link, "building", $new); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } unset($_POST); require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php"); print_control_submenu($page_url); ?>