Joywork/admin/ajax/getClientLogForEventsNew.php

321 lines
16 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 = "SELECT count(id) FROM user_object_events WHERE user_id = $_SESSION[id] and calendar_view = 0
and schedule_date is not null AND DATE_FORMAT(e.schedule_date, '%Y-%m-%d %H:%i:%s') <= '".date("Y-m-d H:i:s")."'";
$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_FORMAT(e.schedule_date, '%Y-%m-%d %H:%i:%s') <= '".date("Y-m-d H:i:s")."'";
$rez = mysql_query($sql);
$clientEventCount = mysql_result($rez,0);
// суммарное количество событий по объектам и пользователям
$sumCount = intval($objectEventCount) + intval($clientEventCount);
echo "<script>$('#calendarCounter').html('".$sumCount."');</script>";
$client = new Clients_jw;
$client->get($get['id']);
$dateAdd = date("d.m.Y", strtotime($client->date_add));
list($d, $m, $y) = explode(".", $dateAdd);
if ($y == date("Y")) {
$y = "";
}
$date_add = $d." ".getRusMonth($m)." ".$y;
echo '<div class="chat-date"><span>'.$date_add.'</span></div>';
echo '<div class="chat-status added"><span>Клиент добавлен</span></div>';
$user = new User;
$user->get($_SESSION['id']);
// если смотрит руководитель - показываем все
if ($_SESSION['agency'] || $_SESSION['manager']) {
$sql = "SELECT e.id, e.comment, e.create_date, e.type, e.user_id, e.schedule_date, e.address, e.sum, e.from_id, e.calendar_view, If(e.from_id <> 0, (SELECT u.user_logo FROM users as u WHERE u.id = e.from_id), (SELECT u.user_logo FROM users as u WHERE u.id = e.user_id)) as user_logo FROM user_client_jw_events as e WHERE e.client_id = $get[id] ORDER BY e.create_date ASC";
} else {
$sql = "SELECT e.id, e.comment, e.create_date, e.type, e.user_id, e.schedule_date, e.address, e.sum, e.from_id, e.calendar_view, If(e.from_id <> 0, (SELECT u.user_logo FROM users as u WHERE u.id = e.from_id), (SELECT u.user_logo FROM users as u WHERE u.id = e.user_id)) as user_logo FROM user_client_jw_events as e WHERE e.user_id = $_SESSION[id] and e.client_id = $get[id] ORDER BY e.create_date ASC";
}
$rez = mysql_query($sql);
$date = null;
$createDate = null;
while ($event = mysql_fetch_assoc($rez)) {
if ($createDate == null || $createDate != date("d.m.Y", strtotime($event['create_date']))) {
$createDate = date("d.m.Y", strtotime($event['create_date']));
list($d, $m, $y) = explode(".", $createDate);
if ($y == date("Y")) {
$y = "";
}
echo '<div class="chat-date"><span>' . $d . " " . getRusMonth($m) . " " . $y . '</span></div>';
}
$class_ev = " is__right";
$from_id = $event['user_id'];
if(!empty($event['from_id'])) $from_id = $event['from_id'];
if($_SESSION['id'] == $from_id){
$class_ev = " is__left";
}
if ($event['type'] == 'comment') {
?>
<div class="chat-block<?=$class_ev?>">
<div class="chat-author">
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
</div>
</div>
<div class="chat-message">
<div class="chat-content">
<div class="head"><span>Примечание</span></div>
<div class="message"><?=$event['comment']?></div>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
if ($event['type'] == 'call') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
?>
<div class="chat-block<?=$class_ev?>">
<div class="chat-author">
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
</div>
</div>
<div class="chat-message call">
<div class="chat-complete">
<div class="complete-button" data-id="<?=$event['id']?>">
<input type="checkbox" class=""/>
<div class="complete-action-button<?=($event['calendar_view'] == 1) ? ' active' : ''?>" id="groupAB__<?=$event['id']?>" title="Выполнено">
<span class="check-button-box"></span>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="512px" height="512px">
<g>
<g>
<path d="M505.943,79.594c-8.077-8.077-21.172-8.077-29.249,0L167.755,388.532L35.306,256.083c-8.076-8.077-21.172-8.077-29.248,0 c-8.077,8.077-8.077,21.172,0,29.249l147.074,147.074c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.625-6.059 l323.562-323.562C514.019,100.767,514.019,87.672,505.943,79.594z" fill="#388e3c"/>
</g>
</g>
</svg>
</div>
</div>
</div>
<div class="chat-content">
<div class="head"><span>Звонок</span></div>
<div class="message">Позвонить <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if($event['comment']){ ?>
<div class="message">Комментарий: <?=$event['comment']?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
if ($event['type'] == 'meet') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
?>
<div class="chat-block<?=$class_ev?>">
<div class="chat-author">
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
</div>
</div>
<div class="chat-message meeting">
<div class="chat-complete">
<div class="complete-button" data-id="<?=$event['id']?>">
<input type="checkbox" class=""/>
<div class="complete-action-button<?=($event['calendar_view'] == 1) ? ' active' : ''?>" id="groupAB__<?=$event['id']?>" title="Выполнено">
<span class="check-button-box"></span>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="512px" height="512px">
<g>
<g>
<path d="M505.943,79.594c-8.077-8.077-21.172-8.077-29.249,0L167.755,388.532L35.306,256.083c-8.076-8.077-21.172-8.077-29.248,0 c-8.077,8.077-8.077,21.172,0,29.249l147.074,147.074c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.625-6.059 l323.562-323.562C514.019,100.767,514.019,87.672,505.943,79.594z" fill="#388e3c"/>
</g>
</g>
</svg>
</div>
</div>
</div>
<div class="chat-content">
<div class="head"><span>Встреча</span></div>
<div class="message">Встреча будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['address']) { ?>
<div class="message">Адрес: <?=$event['address']?></div>
<?php } if ($event['comment']) { ?>
<div class="message">Комментарий: <?=$event['comment']?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
if ($event['type'] == 'show') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
?>
<div class="chat-block<?=$class_ev?>">
<div class="chat-author">
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
</div>
</div>
<div class="chat-message showing">
<div class="chat-complete">
<div class="complete-button" data-id="<?=$event['id']?>">
<input type="checkbox" class=""/>
<div class="complete-action-button<?=($event['calendar_view'] == 1) ? ' active' : ''?>" id="groupAB__<?=$event['id']?>" title="Выполнено">
<span class="check-button-box"></span>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="512px" height="512px">
<g>
<g>
<path d="M505.943,79.594c-8.077-8.077-21.172-8.077-29.249,0L167.755,388.532L35.306,256.083c-8.076-8.077-21.172-8.077-29.248,0 c-8.077,8.077-8.077,21.172,0,29.249l147.074,147.074c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.625-6.059 l323.562-323.562C514.019,100.767,514.019,87.672,505.943,79.594z" fill="#388e3c"/>
</g>
</g>
</svg>
</div>
</div>
</div>
<div class="chat-content">
<div class="head"><span>Показ</span></div>
<div class="message">Показ будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['address']) { ?>
<div class="message">Адрес: <?=$event['address']?></div>
<?php } if ($event['comment']) { ?>
<div class="message">Комментарий: <?=$event['comment']?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
if ($event['type'] == 'deal') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
?>
<div class="chat-block<?=$class_ev?>">
<div class="chat-author">
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
</div>
</div>
<div class="chat-message deal">
<div class="chat-complete">
<div class="complete-button" data-id="<?=$event['id']?>">
<input type="checkbox" class=""/>
<div class="complete-action-button<?=($event['calendar_view'] == 1) ? ' active' : ''?>" id="groupAB__<?=$event['id']?>" title="Выполнено">
<span class="check-button-box"></span>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve" width="512px" height="512px">
<g>
<g>
<path d="M505.943,79.594c-8.077-8.077-21.172-8.077-29.249,0L167.755,388.532L35.306,256.083c-8.076-8.077-21.172-8.077-29.248,0 c-8.077,8.077-8.077,21.172,0,29.249l147.074,147.074c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.625-6.059 l323.562-323.562C514.019,100.767,514.019,87.672,505.943,79.594z" fill="#388e3c"/>
</g>
</g>
</svg>
</div>
</div>
</div>
<div class="chat-content">
<div class="head"><span>Сделка</span></div>
<div class="message">Сделка будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['sum']) { ?>
<div class="message">Сумма сделки: <?=$event['sum']?><span class="rub">p</span></div>
<?php } if ($event['comment']) { ?>
<div class="message">Комментарий: <?=$event['comment']?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
}
}