diff --git a/ajax/cancelEvent.php b/ajax/cancelEvent.php index c56924b..8ccd4fe 100644 --- a/ajax/cancelEvent.php +++ b/ajax/cancelEvent.php @@ -2,6 +2,23 @@ require_once($_SERVER['DOCUMENT_ROOT']."/config.php"); if(isset($_POST['cancelId'])){ $id = (int)$_POST['cancelId']; + + // Помечаем событие как отменённое $sql = "UPDATE user_client_events SET cancel=1 WHERE id = $id"; mysql_query($sql); + + // Если событие привязано к сделке — отменяем сделку тоже + $sql_deal = "SELECT deal_id FROM user_client_events WHERE id = $id AND deal_id IS NOT NULL AND deal_id > 0 LIMIT 1"; + $rez = mysql_query($sql_deal); + if ($rez && mysql_num_rows($rez) > 0) { + $row = mysql_fetch_assoc($rez); + $deal_id = intval($row['deal_id']); + + // Помечаем сделку как отменённую (status = 2) + mysql_query("UPDATE deals SET status = 2 WHERE id = $deal_id"); + + // Помечаем все остальные события этой сделки как отменённые + mysql_query("UPDATE user_client_events SET cancel = 1 WHERE deal_id = $deal_id AND cancel = 0"); + mysql_query("UPDATE user_object_events SET cancel = 1 WHERE deal_id = $deal_id AND cancel = 0"); + } } diff --git a/ajax/getClientLogForEventsNew.php b/ajax/getClientLogForEventsNew.php index 0f04de8..23a2c04 100644 --- a/ajax/getClientLogForEventsNew.php +++ b/ajax/getClientLogForEventsNew.php @@ -1203,10 +1203,13 @@ ORDER BY date_sort ASC"; } ?> -