0) { $stmt = db()->prepare("SELECT * FROM shipments WHERE id = :id"); $stmt->execute([':id' => $shipmentId]); $shipment = $stmt->fetch(); } $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'submit_offer') { $offerOwner = trim($_POST['offer_owner'] ?? ''); $offerPrice = trim($_POST['offer_price'] ?? ''); if ($offerOwner === '' || $offerPrice === '') { $errors[] = t('error_required'); } elseif (!is_numeric($offerPrice)) { $errors[] = t('error_invalid'); } else { $stmt = db()->prepare( "UPDATE shipments SET offer_owner = :offer_owner, offer_price = :offer_price, status = 'offered' WHERE id = :id" ); $stmt->execute([ ':offer_owner' => $offerOwner, ':offer_price' => $offerPrice, ':id' => $shipmentId, ]); set_flash('success', t('success_offer')); header('Location: ' . url_with_lang('shipment_detail.php', ['id' => $shipmentId])); exit; } } $flash = get_flash(); render_header(t('shipment_detail')); ?>

#

: