$ID = $_GET['ID'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['cancel'])) {
        header("Location: maps_trucks.php#Truck");
        exit;
    }
    $truck = new Trucks();
    $truck->ID = $_POST['ID'];
    $truck->TruckName = $_POST['TruckName'];
    $truck->TruckSerial = $_POST['Serial'];
    $truck->TruckPart = $_POST['Part'];
    $truck->TruckDriver = $_POST['Driver'];
    $truck->TruckID = $_POST['TruckID'];
    $truck->CustomerId = $_SESSION['customerId'];
    if ($truck->ID == '') {
        $truck->Insert();
        if ($truck->ID == -1) {
            $error = ERR_BAD_INSERT;
        }
    } else {
        if (!$truck->Update()) {
            $error = ERR_BAD_UPDATE;
        }
    }
    if ($error == 0) {
        header("Location: maps_trucks.php#Truck");
        exit;
    }
}
if ($mode == "edit") {
    $truck = Trucks::Retrieve($ID, $_SESSION['customerId']);