prepare("SELECT * FROM shipments WHERE id = ?"); $stmt->execute([$id]); $shipment = $stmt->fetch(); if (!$shipment) { header('Location: admin_shipments.php'); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $shipper_name = trim($_POST['shipper_name'] ?? ''); $shipper_company = trim($_POST['shipper_company'] ?? ''); $origin_city = trim($_POST['origin_city'] ?? ''); $destination_city = trim($_POST['destination_city'] ?? ''); $cargo_description = trim($_POST['cargo_description'] ?? ''); $weight_tons = (float)($_POST['weight_tons'] ?? 0); $pickup_date = trim($_POST['pickup_date'] ?? ''); $delivery_date = trim($_POST['delivery_date'] ?? ''); $payment_method = trim($_POST['payment_method'] ?? 'thawani'); $status = trim($_POST['status'] ?? 'posted'); if ($shipper_name === '') $errors[] = "Shipper name is required."; if ($origin_city === '') $errors[] = "Origin city is required."; if ($destination_city === '') $errors[] = "Destination city is required."; if (empty($errors)) { $updateSql = " UPDATE shipments SET shipper_name = ?, shipper_company = ?, origin_city = ?, destination_city = ?, cargo_description = ?, weight_tons = ?, pickup_date = ?, delivery_date = ?, payment_method = ?, status = ? WHERE id = ? "; db()->prepare($updateSql)->execute([ $shipper_name, $shipper_company, $origin_city, $destination_city, $cargo_description, $weight_tons, $pickup_date, $delivery_date, $payment_method, $status, $id ]); $flash = "Shipment updated successfully."; // Refresh $stmt->execute([$id]); $shipment = $stmt->fetch(); } } render_header('Edit Shipment', 'admin'); ?>

Edit Shipment #

Update shipment details and status.