Fix share link view accounting and quote response handling

This commit is contained in:
johnnyq
2026-07-27 21:11:45 -04:00
parent f129311b2e
commit 22e93589cb
5 changed files with 34 additions and 13 deletions

View File

@@ -32,7 +32,15 @@ if (isset($_GET['accept_quote'], $_GET['url_key'])) {
$client_name = escapeSql($row['client_name']);
$client_id = intval($row['client_id']);
mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Accepted' WHERE quote_id = $quote_id");
// Claim the response - only a quote still awaiting one can be accepted,
// and only the first request through wins
mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Accepted' WHERE quote_id = $quote_id AND quote_status IN ('Sent', 'Viewed')");
if (mysqli_affected_rows($mysqli) !== 1) {
flashAlert("This quote is no longer awaiting a response", 'error');
redirect();
}
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Accepted', history_description = 'Client accepted Quote!', history_quote_id = $quote_id");
// Notification
@@ -97,7 +105,15 @@ if (isset($_GET['decline_quote'], $_GET['url_key'])) {
$client_name = escapeSql($row['client_name']);
$client_id = intval($row['client_id']);
mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Declined' WHERE quote_id = $quote_id");
// Claim the response - only a quote still awaiting one can be declined,
// and only the first request through wins
mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Declined' WHERE quote_id = $quote_id AND quote_status IN ('Sent', 'Viewed')");
if (mysqli_affected_rows($mysqli) !== 1) {
flashAlert("This quote is no longer awaiting a response", 'error');
redirect();
}
mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Declined', history_description = 'Client declined Quote!', history_quote_id = $quote_id");
// Notification