Joywork/ajax/addEventSubComment.php
2026-05-22 21:21:54 +03:00

42 lines
2.3 KiB
PHP

<?php
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
if ($_SESSION['id'] && isset($_POST['eventId'])) {
$post = clearInputData($_POST);
$event_id = (int)$post['eventId'];
$req_id = (int)$post['reqId'];
$from = $post['from'];
$sub_comment = $post['sub_comment'];
$type = $post['type'];
$user_for = $post['user_for'];
$sub_id = (int)$post['sub_id'];
if (!empty($sub_comment) && !empty($from)) {
if ($from == "objects") {
if($type == 'moderation'){
if($sub_id > 0){
mysql_query("UPDATE user_sub_comments SET sub_comment='{$sub_comment}', user_for='{$user_for}' WHERE id={$sub_id}");
} else {
mysql_query("INSERT INTO `user_sub_comments` (`event_id`, `req_id`, `section_id`, `sub_comment`, `created_by`, `user_for`) VALUES ('$event_id', '$req_id', 1, '$sub_comment', '$_SESSION[id]', '$user_for')");
}
} else {
mysql_query("DELETE FROM `user_sub_comments` WHERE `event_id` = '$event_id' AND `section_id` = 1 AND `created_by` = '$_SESSION[id]'");
mysql_query("INSERT INTO `user_sub_comments` (`event_id`, `req_id`, `section_id`, `sub_comment`, `created_by`) VALUES ('$event_id', '$req_id', 1, '$sub_comment', '$_SESSION[id]')");
}
} else if ($from == "clients") {
mysql_query("DELETE FROM `user_sub_comments` WHERE `event_id` = '$event_id' AND `section_id` = 2 AND `created_by` = '$_SESSION[id]'");
mysql_query("INSERT INTO `user_sub_comments` (`event_id`, `req_id`, `section_id`, `sub_comment`, `created_by`) VALUES ('$event_id', '$req_id', 2, '$sub_comment', '$_SESSION[id]')");
} else if ($from == "requisitions") {
mysql_query("DELETE FROM `user_sub_comments` WHERE `event_id` = '$event_id' AND `section_id` = 3 AND `created_by` = '$_SESSION[id]'");
mysql_query("INSERT INTO `user_sub_comments` (`event_id`, `req_id`, `section_id`, `sub_comment`, `created_by`) VALUES ('$event_id', '$req_id', 3, '$sub_comment', '$_SESSION[id]')");
}
if ($req_id > 0) {
//mysql_query("INSERT INTO `user_client_events` (`user_id`, `req_id`, `from_id`, `type`, `comment`) VALUES ('$_SESSION[id]', '$req_id', '$_SESSION[id]', 'sub_comment', '{$sub_comment}')");
mysql_query("INSERT INTO `events_clients` (`user_id`, `req_id`, `from_id`, `event`, `read`, `dop_text`) VALUES ('$_SESSION[id]', '$req_id', '0', 'sub_comment', '1', '{$sub_comment}')");
}
}
}