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

29 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if ($_SESSION['id'] && $_GET['id'] && is_numeric($_GET['id'])) {
$get = clearInputData($_GET);
$sql = "UPDATE user_client_events SET calendar_view = 1
where id = $get[id] and user_id = $_SESSION[id] and DATE(schedule_date) <= '".date("Y-m-d")."'";
mysql_query($sql);
// обновляем метку у меню календаря
// считаем события объектов
$sql = "SELECT count(id) FROM user_object_events WHERE user_id = $_SESSION[id] and calendar_view = 0
and schedule_date is not null and DATE(schedule_date) <= '".date("Y-m-d")."'";
$rez = mysql_query($sql);
$objectEventCount = mysql_result($rez,0);
// считаем события клиентов
$sql = "SELECT count(id) FROM user_client_events WHERE user_id = $_SESSION[id] and calendar_view = 0 and cancel = 0
and schedule_date is not null and DATE(schedule_date) <= '".date("Y-m-d")."'";
$rez = mysql_query($sql);
$clientEventCount = mysql_result($rez,0);
// суммарное количество событий по объектам и пользователям
$sumCount = intval($objectEventCount) + intval($clientEventCount);
echo $sumCount;
} else {
echo '0';
}