Joywork/ajax/setEventViewed.php

31 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
if ($_SESSION['id'] && $_GET['id'] && is_numeric($_GET['id'])) {
$get = clearInputData($_GET);
$sql = "UPDATE user_object_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';
}