Joywork/ajax/getClientLogForEventsNew.php

1670 lines
101 KiB
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
/*error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1); */
$pdo = new MysqlPdo(hst, ndb, user, pass);
$sql = "SET NAMES 'utf8'";
$pdo->query($sql);
if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id']>0) || (isset($_GET['req_id']) && is_numeric($_GET['req_id']) && $_GET['req_id']>0))) {
$gmtmsk = get_time_zone_user();
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
$time_zone = '';
$time_zone_sql = 'INTERVAL 0 HOUR';
if($gmtmsk >= 0){
$time_zone = '+'.$gmtmsk.' hour';
$time_zone_sql = 'INTERVAL '.$gmtmsk.' HOUR';
} else {
$time_zone = '-'.$gmtmsk.' hour';
$time_zone_sql = 'INTERVAL -'.$gmtmsk.' HOUR';
}
$get = clearInputData($_GET);
$is_req = false;
// обновляем метку у меню календаря
// считаем события объектов
$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);
2026-06-25 12:53:43 +02:00
// суммарное количество событий по объектам, клиентам и найденным листингам
$sumCount = intval($objectEventCount) + intval($clientEventCount) + get_user_listing_tasks_count($_SESSION['id']);
2026-05-22 20:21:54 +02:00
echo "<script>$('#calendarCounter').html('".$sumCount."');</script>";
if($get['id'] > 0){
$client = new Clients;
$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_del = '';
if (isset($get['req_id']) && $get['req_id'] > 0){
$is_req = true;
$sql="SELECT *, created_at as date_add, name as fio FROM requisitions WHERE id=$get[req_id]";
$rez=mysql_query($sql);
$client = mysql_fetch_assoc($rez);
$dateAdd = date("d.m.Y", strtotime($client['date_add']));
list($d, $m, $y) = explode(".", $dateAdd);
if ($y == date("Y")) {
$y = "";
}
if($client['deleted'] > 0){
$sql_del = "SELECT date_update FROM `events_clients` WHERE req_id=$client[id] and event='delete' order by id desc limit 1";
$q_del = mysql_query($sql_del);
if(mysql_num_rows($q_del) > 0){
$r_del = mysql_fetch_assoc($q_del);
$dateDel = date("d.m.Y", strtotime($r_del['date_update']));
list($dd, $md, $yd) = explode(".", $dateDel);
if ($yd == date("Y")) {
$yd = "";
}
$date_del = $dd." ".getRusMonth($md)." ".$yd;
$reason = $client['reason'];
}
}
} else {
2026-06-21 06:52:31 +02:00
if($client->deleted > 0){
2026-05-22 20:21:54 +02:00
$client_id = $client->id;
$sql_del = "SELECT date_update FROM `events_clients` WHERE client_id=$client_id and event='delete' order by id desc limit 1";
$q_del = mysql_query($sql_del);
if(mysql_num_rows($q_del) > 0){
$r_del = mysql_fetch_assoc($q_del);
$dateDel = date("d.m.Y", strtotime($r_del['date_update']));
list($dd, $md, $yd) = explode(".", $dateDel);
if ($yd == date("Y")) {
$yd = "";
}
$date_del = $dd." ".getRusMonth($md)." ".$yd;
$reason = $client->reason;
}
}
}
$date_add = $d." ".getRusMonth($m)." ".$y;
echo '<div class="chat-date"><span>'.$date_add.'</span></div>';
$text = 'Клиент добавлен';
if($is_req){
$text = 'Заявка добавлена';
}
echo '<div class="chat-status added"><span>'.$text.'</span></div>';
$users = array();
$user = new User;
$user->get($_SESSION['id']);
$agency_id = $user->agencyId;
$usersIds = array();
$usersIds[] = $agency_id;
$sql_users = "SELECT id FROM users WHERE id in (select id from users where id=$agency_id or id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id)))";
$q_users = mysql_query($sql_users);
while($r_users = mysql_fetch_assoc($q_users)){
$usersIds[] = (int)$r_users['id'];
}
$usersIds = array_unique($usersIds);
$sql_users2 = "SELECT id, user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name) as user_fio FROM users WHERE id in (".implode(',',$usersIds).")";
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
$q_users2 = mysql_query($sql_users2);
while($r_users2 = mysql_fetch_assoc($q_users2)){
$users[$r_users2['id']] = $r_users2;
}
//Доступ к задаче
$user_access = $_SESSION['id'];
if($user->users_admin == 1){
$user_access = $user->agencyId;
}
$req = new Requisitions(null, true);
$usersCanEdit = $req->getIdsUsers($user_access);
// если смотрит руководитель - показываем все
2026-06-21 06:52:31 +02:00
// if ($_SESSION['agency'] || $_SESSION['manager'] || $_SESSION['users_admin']) {
2026-05-22 20:21:54 +02:00
2026-06-22 09:01:31 +02:00
$sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id "
2026-06-21 06:52:31 +02:00
. "FROM user_client_events as e WHERE e.client_id = $get[id] union
2026-06-22 09:46:08 +02:00
SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step, 0 as deal_id from events_clients as ev WHERE ev.client_id = $get[id] and event = 'transmitted_parallel'
2026-05-22 20:21:54 +02:00
ORDER BY date_sort ASC";
if(isset($get['req_id']) && $get['req_id'] > 0){
2026-06-22 09:01:31 +02:00
$sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id "
2026-05-22 20:21:54 +02:00
. "FROM user_client_events as e WHERE e.req_id = $get[req_id] union
2026-06-22 09:01:31 +02:00
SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step, 0 as deal_id
2026-05-22 20:21:54 +02:00
from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel'
ORDER BY date_sort ASC";
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
$arrSin = array();
$sql_obj_sin = "SELECT object_id FROM object_req_synchronization WHERE req_id = {$get['req_id']}";
$q_obj_sin = $pdo->query($sql_obj_sin);
while($r_obj_sin = $pdo->fetch_assoc($q_obj_sin)){
$arrSin[] = $r_obj_sin['object_id'];
}
if(!empty($arrSin)){
2026-06-22 09:01:31 +02:00
$sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id "
2026-06-21 06:52:31 +02:00
. "FROM user_client_events as e WHERE e.req_id = $get[req_id] union
2026-06-22 09:01:31 +02:00
SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step, 0 as deal_id from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel'
2026-05-22 20:21:54 +02:00
union
2026-06-21 06:52:31 +02:00
SELECT e.id, e.comment, '' as name, e.create_date, e.create_date as date_sort, '0' as checklist, 'show_object' as type, NULL as type_call, e.user_id, '' as record, e.object_id, 0 as client_id, e.document_id, e.req_id, 0 as old_req_id, e.schedule_date, '' as schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, e.cancel, 0 as open_step "
. "FROM user_object_events as e WHERE e.req_id={$get['req_id']} AND e.object_id in (".implode(',', $arrSin).") AND e.type='show'
2026-05-22 20:21:54 +02:00
ORDER BY date_sort ASC";
//echo $sql;
}
}
2026-06-25 12:53:43 +02:00
/* if($_SESSION['id'] == 5238){
echo $sql;
}*/
2026-05-22 20:21:54 +02:00
$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";
}
$sql_user = "SELECT user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name) as user_fio FROM users WHERE id = {$from_id}
UNION SELECT user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name, ' (удален)') as user_fio FROM users_delete WHERE user_id = {$from_id}";
2026-06-21 06:52:31 +02:00
// echo $sql_user."<br>";
2026-05-22 20:21:54 +02:00
$from_user = mysql_fetch_assoc(mysql_query($sql_user));
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
$event['user_logo'] = $from_user['user_logo'];
$event['user_fio'] = $from_user['user_fio'];
if ($event['partner_id'] > 0) {
$sql_partner = "SELECT name FROM `partners_employees` WHERE id = {$from_id} AND partner_id = {$event['partner_id']} LIMIT 1";
$q_partner = mysql_query($sql_partner);
if (mysql_num_rows($q_partner) > 0) {
$r_partner = mysql_fetch_assoc($q_partner);
if (!empty($r_partner['name'])) {
$event['user_fio'] = $r_partner['name'];
}
}
$sql_avatar = "SELECT avatar_logo, path FROM `partner_avatars` WHERE employee_id = {$from_id} AND partner_id = {$event['partner_id']} LIMIT 1";
$q_avatar = mysql_query($sql_avatar);
if (mysql_num_rows($q_avatar) > 0) {
$r_avatar = mysql_fetch_assoc($q_avatar);
if (!empty($r_avatar['path']) && strpos($r_avatar['path'], 'http') === 0) {
$event['user_logo'] = $r_avatar['path'];
}
elseif (!empty($r_avatar['avatar_logo'])) {
$event['user_logo'] = $r_avatar['avatar_logo'];
}
}
}
if ($event['type'] == 'comment') {
?>
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
$avatarSrc = (strpos($event['user_logo'], 'http') === 0)
2026-06-21 06:52:31 +02:00
? $event['user_logo']
: '/photos/agency/' . $event['user_logo'];
2026-05-22 20:21:54 +02:00
?>
<img src="<?=$avatarSrc?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message">
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head">
2026-05-22 20:21:54 +02:00
<span>Примечание</span>
2026-06-21 06:52:31 +02:00
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
2026-05-22 20:21:54 +02:00
</div>
<div class="message <?php echo (strpos($event['comment'], 'Статус объекта:') >= -1 && strpos($event['comment'], ', до') >= -1) ? 'message_change_date_tz' : '' ?>">
<?=$event['comment']?>
</div>
<script>
const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const message_change_date_tz = document.querySelectorAll('.message_change_date_tz')
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
message_change_date_tz.forEach((item) => {
const text = item.innerText.split(', до')
if(text[1]){
const secondPart = text[1].slice(0, -1).trim();
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
// Define the Moscow time
const moscowTime = moment.tz(secondPart, 'DD.MM.YYYY HH:mm:ss', 'Europe/Moscow');
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
// Convert the Moscow time to the local timezone
const localTime = moscowTime.clone().tz(localTimeZone).format('DD.MM.YYYY HH:mm');
2026-06-21 06:52:31 +02:00
2026-05-22 20:21:54 +02:00
item.innerHTML = `${text[0]} ${localTime}.`
}
})
</script>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Примечание добавлено автоматически при переходе на этап</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
<?php if($event['from_id'] == $_SESSION['id']){ ?>
2026-06-21 06:52:31 +02:00
<div class="message" style="margin-top: 10px;">
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
2026-05-22 20:21:54 +02:00
<?php } ?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if ($event['type'] == 'file' || $event['partner_id'] ) {
$file_list = '';
if($event['document_id']){
$n_docs_q = mysql_query("SELECT * FROM inner_docs WHERE id = '".$event['document_id']."'");
$row = mysql_fetch_assoc($n_docs_q);
if($row){
2026-06-21 06:52:31 +02:00
$file_list .= '
2026-05-22 20:21:54 +02:00
<div class="document doc-from-apartment">
<a href="javascript:{}" class="no-border pull-right doc-from-apartment-info">
<span class="jw__small-popup ti-more" data-id="document_' . $event['document_id'] . '"></span>
<div class="jw__popup actions-document" id="popup__document_' . $event['document_id'] . '">
<div class="actions-document__inner">
<a href="javascript:{}" onclick="previewInnerDoc(' . $event['document_id'] . ')">Предпросмотр</a>
<a href="javascript:{}" onclick="editInnerDoc(' . $event['document_id'] . ')">Редактировать</a>
<a href="javascript:{}" onclick="sendInnerDocWin(' . $event['document_id'] . ')">Отправить</a>
<a href="javascript:{}" onclick="confirmDeleteInnerDoc(' . $event['document_id'] . ')">Удалить</a>
</div>
</div>
</a>
<div class="doc-wrapper">
<li>
<a title="Скачать файл" download="" href="/ajax/getInnerDoc.php?id=' . $event['document_id'] . '&download_pdf=true&t=' . time() . '">
<span class="file-span ti-file"></span>
<span class="file-name" data-id="' . $event['document_id'] . '">' . $row['name'] . '.pdf</span>
</a>
</li>
</div>
</div>';
2026-06-21 06:52:31 +02:00
}
2026-05-22 20:21:54 +02:00
}
$docs_q = mysql_query("SELECT * FROM clients_files WHERE event_id = '".$event['id']."'");
$name_files = '';
while ($file = mysql_fetch_assoc($docs_q)) {
if($file['name_id'] > 0 && $name_files == ''){
2026-06-21 06:52:31 +02:00
$sql_n = "SELECT * FROM names_client_files WHERE id={$file['name_id']}";
$q_n = mysql_query($sql_n);
if(mysql_num_rows($q_n) > 0){
$r_n = mysql_fetch_assoc($q_n);
$name_files = $r_n['name'];
}
2026-05-22 20:21:54 +02:00
}
$name_doc = $_SERVER['DOCUMENT_ROOT'].'/upload/clients/'.$file['client_id'].'/'.$file['guid'].'.'.$file['type'];
if ($file['req_id'] > 0) {
$name_doc = $_SERVER['DOCUMENT_ROOT'].'/upload/reqs/'.$file['req_id'].'/'.$file['guid'].'.'.$file['type'];
}
if ($file['client_id'] > 0 && $event['partner_id']) {
$file_path = 'https://partner.joywork.ru/upload/clients/'.$file['client_id'].'/'.$file['guid'].'.'.$file['type'];
if (!empty($file_path) && !empty($file['name'])) {
$file_list .= '<li><a title="Скачать файл" target="_blank" href="'.$file_path.'">
<span class="file-span ti-file"></span>
<span class="file-name">' . $file['name'] . '</span>
</a></li>';
}
} else {
$file_path = '';
if ($file['client_id'] > 0)
$file_path = 'https://uf.joywork.ru/upload/clients/'.$file['client_id'].'/'.$file['guid'].'.'.$file['type'];
if ($file['req_id'] > 0)
$file_path = 'https://uf.joywork.ru/upload/reqs/'.$file['req_id'].'/'.$file['guid'].'.'.$file['type'];
if (!empty($file_path) && !empty($file['name'])) {
$file_list .= '<li><a title="Скачать файл" target="_blank" href="/download_file.php?id='.$file['id'].'&preview=1">
<span class="file-span ti-file"></span>
<span class="file-name">' . $file['name'] . '</span>
</a></li>';
}
}
}
if (!empty($file_list)) { ?>
2026-06-21 06:52:31 +02:00
<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 class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
</div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<div class="chat-message">
<div class="chat-content" id="chat_content_<?=$event['id']?>">
<div class="head"><span>Файл</span></div>
<div class="message"> <?= $name_files ?><?= (!empty($file_list)) ? '<br/><ul>' . $file_list . '</ul>' : ''; ?><?= $event['comment']; ?></div>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
<?php {
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Файл добавлен автоматически при переходе на этап</span>
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<?php
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
<?php
}
}?>
<?php if($event['from_id'] == $_SESSION['id']){ ?>
<div class="message" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="sendEventFilesWin('<?=$event['id']?>', 'clients')" title="Отправить">
<span class="simple-button send"><i class="ti-email"></i></span>
</a>
2026-06-26 09:58:53 +02:00
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>', null, 'file')" title="Удалить">
2026-06-21 06:52:31 +02:00
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
<?php } ?>
2026-05-22 20:21:54 +02:00
</div>
</div>
2026-06-21 06:52:31 +02:00
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
<?php }
}
if ($event['type'] == 'call') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
</div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> call">
<div class="chat-complete<?=!in_array($event['user_id'], $usersCanEdit) ? ' hidden' : '' ?>">
<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']?>" data-cancel="<?=$event['cancel']?>" 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>
2026-06-21 06:52:31 +02:00
<div class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
2026-05-22 20:21:54 +02:00
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
2026-06-21 06:52:31 +02:00
</a>
</div>
2026-05-22 20:21:54 +02:00
</div>
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head">
2026-05-22 20:21:54 +02:00
<span>Звонок</span>
2026-06-21 06:52:31 +02:00
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
2026-05-22 20:21:54 +02:00
</div>
<div class="message">Позвонить
2026-06-21 06:52:31 +02:00
<?php if( $event['tracking'] == 1){?>
c <?=date('d.m.Y H:i', strtotime($event['schedule_date_to']))?> <br>по <?=date('d.m.Y H:i', strtotime($event['schedule_date']))?>
<?php } else { ?>
<?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?>
<?php } ?>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php if($event['comment']){
2026-05-22 20:21:54 +02:00
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
2026-06-21 06:52:31 +02:00
if(!empty($event['type_call'])){
switch($event['type_call']){
case 1:{
$comment = '<img class="type_call" src="/images/call_in_on.svg"/><img class="type_call" src="/images/call_on.svg"/><span>'.$comment.'</span>';
break;
}
case 2:{
$comment = '<img class="type_call" src="/images/call_out_on.svg"/><img class="type_call" src="/images/call_on.svg"/><span>'.$comment.'</span>';
break;
}
case 3:{
$comment = '<img class="type_call" src="/images/call_in_off.svg"/><img class="type_call" src="/images/call_off.svg"/><span>'.$comment.'</span>';
break;
}
case 4:{
$comment = '<img class="type_call" src="/images/call_out_off.svg"/><img class="type_call" src="/images/call_off.svg"/><span>'.$comment.'</span>';
break;
}
}
}
2026-05-22 20:21:54 +02:00
?>
2026-06-21 06:52:31 +02:00
<div class="message"><span>Комментарий: </span><?=$comment?></div>
2026-05-22 20:21:54 +02:00
<?php } ?>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
if($event['mango']>0 || $event['megafon']>0 || $event['telphin']>0 || $event['beeline']>0 || $event['mts']>0 || $event['tele2']>0 || $event['allo']>0){ ?>
<span class="time"><?=date("H:i", strtotime($event['create_date']))?></span>
<?php } else { ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
<?php }
2026-06-21 06:52:31 +02:00
{
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
<?php
2026-06-21 06:52:31 +02:00
if(!empty($event['record'])){
if($event['megafon'] == 1){?>
2026-05-22 20:21:54 +02:00
<div class="message" style="margin-top: 10px;">
2026-06-21 06:52:31 +02:00
<?php
$path = '/server/mega/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$event['record'])){
$href = 'https://voice.joywork.ru/mega/';
$Headers = @get_headers($href.$event['record']);
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
if(!empty($path)){
?>
<audio controls="controls" src="<?=$path.$event['record']?>">
<!--<source src="<?=$path.$event['record']?>">
2026-05-22 20:21:54 +02:00
<p>Ваш браузер не поддерживает аудио</p>
<a href="<?=$path.$event['record']?>">Запись разговора</a>-->
2026-06-21 06:52:31 +02:00
</audio>
<?php } ?>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
} else {
2026-05-22 20:21:54 +02:00
$arr_rec = json_decode($event['record']);
if(!empty($arr_rec)){
2026-06-21 06:52:31 +02:00
?>
<div class="message" style="margin-top: 10px;">
<?php
foreach($arr_rec as $rec){
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
if(!empty($rec)){
2026-05-22 20:21:54 +02:00
$path = '';
2026-06-21 06:52:31 +02:00
if($event['telphin'] == 1){
$path = '/server/telphin/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/telphin/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
} else if($event['beeline'] == 1) {
$path = '/server/beeline/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/beeline/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
} else if($event['mts'] == 1) {
$path = '/server/mts/'.$user->agencyId."/";
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/mts/'.$user->agencyId.'/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
//echo $pach;
} else if($event['tele2'] == 1) {
$date_patch = date('Ymd', strtotime($event['create_date']));
$path = '/server/tele2/'.$user->agencyId.'/'.$date_patch.'/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/tele2/'.$user->agencyId.'/'.$date_patch.'/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
//echo $pach;
} else if($event['allo'] == 1) {
$date_patch = date('Ymd', strtotime($event['create_date']));
$path = '/server/allo/'.$user->agencyId.'/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/allo/'.$user->agencyId.'/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
//echo $pach;
}else {
$path = '/server/mango/';
if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){
$href = 'https://voice.joywork.ru/mango/';
$Headers = @get_headers($href.$rec.'.mp3');
if(strpos($Headers[0],'200')) {
$path = $href;
} else {
$path = '';
}
}
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
if(!empty($path)){
?>
<audio id="media_record_<?=$rec?>" controls="controls">
<source src="<?=$path?><?=$rec?>.mp3" type="audio/mp3"/>
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<p>Ваш браузер не поддерживает аудио</p>
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<a href="<?=$path?><?=$rec?>.mp3">Запись разговора</a>
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
</audio>
<?php
2026-05-22 20:21:54 +02:00
}
}
}
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}
2026-06-21 06:52:31 +02:00
}
2026-05-22 20:21:54 +02:00
?>
<?php if($event['from_id'] == $_SESSION['id']){ ?>
2026-06-21 06:52:31 +02:00
<div class="message" style="margin-top: 10px;">
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<a href="javascript:{}" class="no-border" onclick="editEvent('<?=$event['id']?>', '<?=$event['type']?>')" title="Редактировать">
<span class="simple-button settings"><i class="jw-action-icon-settings"></i></span>
</a>
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
2026-05-22 20:21:54 +02:00
<?php } ?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if ($event['type'] == 'meet') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> meeting">
<div class="chat-complete<?=!in_array($event['user_id'], $usersCanEdit) ? ' hidden' : '' ?>">
<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']?>" data-cancel="<?=$event['cancel']?>" 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 class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
</a>
</div>
</div>
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head">
2026-05-22 20:21:54 +02:00
<span>Встреча</span>
2026-06-21 06:52:31 +02:00
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
2026-05-22 20:21:54 +02:00
</div>
<div class="message">Встреча будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['address']) { ?>
2026-06-21 06:52:31 +02:00
<div class="message">Адрес: <?=$event['address']?></div>
<?php } if ($event['comment']) {
2026-05-22 20:21:54 +02:00
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);?>
2026-06-21 06:52:31 +02:00
<div class="message">Комментарий: <?=$comment?></div>
2026-05-22 20:21:54 +02:00
<?php } ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
<?php if($event['from_id'] == $_SESSION['id']){ ?>
2026-06-21 06:52:31 +02:00
<div class="message" style="margin-top: 10px;">
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<a href="javascript:{}" class="no-border" onclick="editEvent('<?=$event['id']?>', '<?=$event['type']?>')" title="Редактировать">
<span class="simple-button settings"><i class="jw-action-icon-settings"></i></span>
</a>
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
2026-05-22 20:21:54 +02:00
<?php } ?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if ($event['type'] == 'show') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
2026-05-22 20:21:54 +02:00
</div>
<div></div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> showing">
<div class="chat-complete<?=!in_array($event['user_id'], $usersCanEdit) ? ' hidden' : '' ?>">
<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']?>" data-cancel="<?=$event['cancel']?>" 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 class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
</a>
</div>
</div>
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head">
2026-05-22 20:21:54 +02:00
<span>Показ</span>
2026-06-21 06:52:31 +02:00
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
2026-05-22 20:21:54 +02:00
</div>
<div class="message">Показ будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['address']) { ?>
2026-06-21 06:52:31 +02:00
<div class="message">Адрес: <?=$event['address']?></div>
<?php } if ($event['comment']) {
2026-05-22 20:21:54 +02:00
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
?>
2026-06-21 06:52:31 +02:00
<div class="message">Комментарий: <?=$comment?></div>
2026-05-22 20:21:54 +02:00
<?php } ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
<?php if($event['from_id'] == $_SESSION['id']){ ?>
2026-06-21 06:52:31 +02:00
<div class="message" style="margin-top: 10px;">
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<a href="javascript:{}" class="no-border" onclick="editEvent('<?=$event['id']?>', '<?=$event['type']?>')" title="Редактировать">
<span class="simple-button settings"><i class="jw-action-icon-settings"></i></span>
</a>
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
2026-05-22 20:21:54 +02:00
<?php } ?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if ($event['type'] == 'show_object') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
2026-06-21 06:52:31 +02:00
$sql = "SELECT IF(IFNULL(s.sub_comment, '') = '', NULL, s.sub_comment) AS sub_comment,
2026-05-22 20:21:54 +02:00
IF(s.created_by <> 0, (
SELECT CONCAT(u.last_name, ' ', u.first_name, ' ', u.middle_name)
FROM users as u WHERE u.id = s.created_by
), NULL
) as sub_comment_author
FROM `user_sub_comments` AS s
WHERE s.event_id IN (
SELECT id AS event_id
FROM `user_object_events`
WHERE user_id = '$_SESSION[id]' AND
req_id = '$event[req_id]' AND
object_id = '$event[client_id]' AND
comment = '$event[comment]' AND
schedule_date = '$event[schedule_date]'
) AND s.section_id = 1 AND s.req_id = '$event[req_id]'
LIMIT 1";
2026-06-21 06:52:31 +02:00
//echo "<!-- ".$sql."-->";
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
if ($query = mysql_query($sql)) {
$row = mysql_fetch_assoc($query);
if (!empty($row['sub_comment']) && !empty($row['sub_comment_author'])) {
$event['sub_comment'] = $row['sub_comment'];
$event['sub_comment_author'] = $row['sub_comment_author'];
}
}
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
2026-05-22 20:21:54 +02:00
</div>
<div></div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> 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']?>" data-cancel="<?=$event['cancel']?>" 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 class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
</a>
</div>
</div>-->
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head"><span>Показ из объекта </span></div>
2026-05-22 20:21:54 +02:00
<div class="message"><a href="javascript:{}" onclick="openObjectModal(<?=$event['client_id']?>, 1)">Объект: ID <?=$event['client_id']?></a></div>
<div class="message">Показ будет <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['address']) { ?>
2026-06-21 06:52:31 +02:00
<div class="message">Адрес: <?=$event['address']?></div>
<?php } if ($event['comment']) {
2026-05-22 20:21:54 +02:00
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
?>
<div class="message">Комментарий: <?=$comment?></div>
<?php } if ($event['sub_comment']) { ?>
<div class="message">Комментарий к задаче: <?= $event['sub_comment'] ?> <span class="author">(<?= $event['sub_comment_author'] ?>)</span></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
2026-06-21 06:52:31 +02:00
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
if ($event['type'] == 'deal') {
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
2026-06-25 12:57:27 +02:00
// Получаем данные сделки, если есть deal_id
2026-06-25 12:53:43 +02:00
$deal_id_for_edit = !empty($event['deal_id']) ? intval($event['deal_id']) : null;
2026-06-25 12:57:27 +02:00
$deal_data = null;
if ($deal_id_for_edit) {
$sql_deal_data = "SELECT * FROM deals WHERE id = " . intval($deal_id_for_edit) . " LIMIT 1";
$rez_deal_data = mysql_query($sql_deal_data);
$deal_data = mysql_fetch_assoc($rez_deal_data);
}
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
2026-06-25 12:57:27 +02:00
<?php
if(empty($event['user_logo'])){
?>
2026-05-22 20:21:54 +02:00
<img src="/images/user-pic.svg"/>
2026-06-25 12:57:27 +02:00
<?php
} else {
?>
2026-05-22 20:21:54 +02:00
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-25 12:57:27 +02:00
<?php
}
?>
2026-06-21 06:52:31 +02:00
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> deal">
2026-06-22 09:01:31 +02:00
<?php if (!$deal_id_for_edit) { ?>
2026-06-25 12:57:27 +02:00
<!-- СТАРЫЙ ВАРИАНТ: показывается когда нет deal_id -->
2026-06-25 12:53:43 +02:00
<div class="chat-complete<?=!in_array($event['user_id'], $usersCanEdit) ? ' hidden' : '' ?>">
<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']?>" data-cancel="<?=$event['cancel']?>" 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">
2026-06-25 12:57:27 +02:00
<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>
2026-06-25 12:53:43 +02:00
</div>
</div>
<div class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
2026-06-25 12:57:27 +02:00
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
2026-06-25 12:53:43 +02:00
</a>
2026-05-22 20:21:54 +02:00
</div>
</div>
2026-06-21 06:59:22 +02:00
<?php } ?>
2026-05-22 20:21:54 +02:00
<div class="chat-content" id="chat_content_<?=$event['id']?>">
2026-06-21 06:52:31 +02:00
<div class="head">
2026-05-22 20:21:54 +02:00
<span>Сделка</span>
2026-06-25 12:53:43 +02:00
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
</div>
2026-05-22 20:21:54 +02:00
<div class="message">Запланирована сделка на <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
2026-06-25 12:57:27 +02:00
<?php if ($deal_data) { ?>
<!-- НОВЫЙ ВАРИАНТ: расширенная информация о сделке -->
2026-06-20 14:47:55 +02:00
<hr style="border:none;border-top:1px solid #e0e0e0;margin:6px 0;">
<?php if ($deal_data['contract_price']) { ?>
<div class="message" style="font-size:13px;">Сумма в договоре: <?=number_format($deal_data['contract_price'], 0, '', ' ')?><span class="rub"> руб.</span></div>
<?php } ?>
<?php if ($deal_data['agent_commission']) { ?>
<div class="message" style="font-size:13px;">Комиссия агента: <?=number_format($deal_data['agent_commission'], 0, '', ' ')?><span class="rub"> руб.</span></div>
<?php } ?>
<div class="message" style="margin-top:5px;font-size:13px;">
<b>Стороны сделки:</b><br/>
<?php
2026-06-25 12:57:27 +02:00
// Сторона 1
2026-06-20 14:59:31 +02:00
$side1_text = htmlspecialchars($deal_data['side_one']);
2026-06-20 14:47:55 +02:00
if (!empty($deal_data['side_one_requisition_id'])) {
2026-06-20 14:59:31 +02:00
$sql_req1 = "SELECT name, client_id FROM requisitions WHERE id = " . intval($deal_data['side_one_requisition_id']) . " LIMIT 1";
2026-06-20 14:47:55 +02:00
$rez_req1 = mysql_query($sql_req1);
if ($rez_req1 && mysql_num_rows($rez_req1) > 0) {
$row_req1 = mysql_fetch_assoc($rez_req1);
2026-06-20 14:59:31 +02:00
$side1_text .= ': Заявка «' . htmlspecialchars($row_req1['name']) . '»';
if (!empty($row_req1['client_id'])) {
$sql_cl1 = "SELECT id, fio FROM clients WHERE id = " . intval($row_req1['client_id']) . " LIMIT 1";
$rez_cl1 = mysql_query($sql_cl1);
if ($rez_cl1 && mysql_num_rows($rez_cl1) > 0) {
$row_cl1 = mysql_fetch_assoc($rez_cl1);
$side1_text .= ' — <a href="javascript:{}" data-id="' . intval($row_cl1['id']) . '" class="neweditClient" style="color:#1976d2;">' . htmlspecialchars($row_cl1['fio']) . '</a>';
}
}
2026-06-20 14:47:55 +02:00
}
}
2026-06-20 14:59:31 +02:00
echo '<span style="color:#666;">' . $side1_text . '</span><br/>';
2026-06-25 12:57:27 +02:00
// Сторона 2
2026-06-20 14:59:31 +02:00
$side2_text = htmlspecialchars($deal_data['side_two']);
2026-06-20 14:47:55 +02:00
if (!empty($deal_data['side_two_requisition_id'])) {
2026-06-20 14:59:31 +02:00
$sql_req2 = "SELECT name, client_id FROM requisitions WHERE id = " . intval($deal_data['side_two_requisition_id']) . " LIMIT 1";
2026-06-20 14:47:55 +02:00
$rez_req2 = mysql_query($sql_req2);
if ($rez_req2 && mysql_num_rows($rez_req2) > 0) {
$row_req2 = mysql_fetch_assoc($rez_req2);
2026-06-20 14:59:31 +02:00
$side2_text .= ': Заявка «' . htmlspecialchars($row_req2['name']) . '»';
if (!empty($row_req2['client_id'])) {
$sql_cl2 = "SELECT id, fio FROM clients WHERE id = " . intval($row_req2['client_id']) . " LIMIT 1";
$rez_cl2 = mysql_query($sql_cl2);
if ($rez_cl2 && mysql_num_rows($rez_cl2) > 0) {
$row_cl2 = mysql_fetch_assoc($rez_cl2);
$side2_text .= ' — <a href="javascript:{}" data-id="' . intval($row_cl2['id']) . '" class="neweditClient" style="color:#1976d2;">' . htmlspecialchars($row_cl2['fio']) . '</a>';
}
}
2026-06-20 14:47:55 +02:00
}
}
2026-06-20 14:59:31 +02:00
echo '<span style="color:#666;">' . $side2_text . '</span>';
2026-06-20 14:47:55 +02:00
?>
</div>
<?php
$side_one_obj_id = intval($deal_data['side_one_object_id']);
$side_two_obj_id = intval($deal_data['side_two_object_id']);
if ($side_one_obj_id || $side_two_obj_id) {
$obj_ids = array_filter([$side_one_obj_id, $side_two_obj_id]);
$sql_objs = "SELECT id, nazv, adres FROM objects WHERE id IN (" . implode(',', $obj_ids) . ")";
$rez_objs = mysql_query($sql_objs);
if ($rez_objs && mysql_num_rows($rez_objs) > 0) {
2026-06-25 14:08:38 +02:00
echo '<div class="message" style="margin-top:10px;font-size:13px;"><b>Объекты:</b><br/>';
2026-06-20 14:47:55 +02:00
while ($obj_row = mysql_fetch_assoc($rez_objs)) {
2026-06-25 12:53:43 +02:00
echo '<a href="javascript:{}" class="show_object" data-id="' . intval($obj_row['id']) . '" style="color:#1976d2;">' . htmlspecialchars($obj_row['nazv']) . ' (' . htmlspecialchars($obj_row['adres']) . ')</a><br/>';
2026-06-20 14:47:55 +02:00
}
echo '</div>';
}
}
2026-06-25 12:57:27 +02:00
// Документы сделки
2026-06-26 09:58:53 +02:00
$sql_inner_docs = "SELECT d.id, d.name, did.comment FROM inner_docs d JOIN deal_inner_doc did ON did.inner_doc_id = d.id WHERE did.deal_id = " . intval($deal_id_for_edit);
2026-06-20 14:47:55 +02:00
$rez_inner_docs = mysql_query($sql_inner_docs);
if ($rez_inner_docs && mysql_num_rows($rez_inner_docs) > 0) {
2026-06-25 14:08:38 +02:00
echo '<div class="message" style="margin-top:15px; padding-top: 0; font-size:13px;"><b>Документы:</b>';
2026-06-20 14:47:55 +02:00
while ($doc_row = mysql_fetch_assoc($rez_inner_docs)) {
2026-06-25 13:48:13 +02:00
echo '<div class="document" data-id="' . $doc_row['id'] . '" style="margin-top:5px;">';
2026-06-26 09:58:53 +02:00
echo '<a href="javascript:{}" class="no-border pull-right" style="border: none;color: #000 !important; padding-top: 5px; width: 30px;">';
2026-06-25 13:48:13 +02:00
echo '<span class="jw__small-popup ti-more" data-id="document_' . $doc_row['id'] . '"></span>';
echo '<div class="jw__popup actions-document" id="popup__document_' . $doc_row['id'] . '">';
echo '<div class="actions-document__inner">';
2026-06-25 14:08:38 +02:00
echo '<a href="javascript:{}" onclick="previewInnerDoc(' . $doc_row['id'] . ')" style="border: none;color: #000 !important;">Предпросмотр</a>';
echo '<a href="javascript:{}" onclick="editInnerDoc(' . $doc_row['id'] . ')" style="border: none;color: #000 !important;">Редактировать</a>';
echo '<a href="javascript:{}" onclick="sendInnerDocWin(' . $doc_row['id'] . ')" style="border: none;color: #000 !important;">Отправить</a>';
echo '<a href="javascript:{}" onclick="confirmDeleteInnerDoc(' . $doc_row['id'] . ')" style="border: none;color: #000 !important;">Удалить</a>';
2026-06-25 13:48:13 +02:00
echo '</div>';
echo '</div>';
echo '</a>';
echo '<ul style="margin:0;padding:0;list-style:none;">';
echo '<li>';
2026-06-26 09:58:53 +02:00
echo '<a style="color: #000 !important; border-bottom: 1px dashed #000; display: inline-flex;" title="Скачать файл" download="" href="/ajax/getInnerDoc.php?id=' . $doc_row['id'] . '&download_pdf=true&t=' . time() . '">';
2026-06-25 14:08:38 +02:00
echo '<span class="file-span ti-file" style="border: none;color: #000 !important;"></span>';
2026-06-26 09:58:53 +02:00
echo '<span style="border: none;color: #000 !important; max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle;" class="file-name" data-id="' . $doc_row['id'] . '" title="' . htmlspecialchars($doc_row['name']) . '.pdf">' . htmlspecialchars($doc_row['name']) . '.pdf</span>';
2026-06-25 13:48:13 +02:00
echo '</a>';
2026-06-26 09:58:53 +02:00
if (!empty($doc_row['comment'])) {
echo '<div style="font-size:12px;color:#888;margin-top:2px;padding-left:16px;">Примечание: ' . htmlspecialchars($doc_row['comment']) . '</div>';
}
2026-06-25 13:48:13 +02:00
echo '</li>';
echo '</ul>';
echo '</div>';
2026-06-20 14:47:55 +02:00
}
echo '</div>';
}
2026-06-25 12:57:27 +02:00
?>
<?php if (!$event['cancel']) { ?>
<div style="position:absolute;top:8px;right:8px;" class="d-flex gap-1">
<a href="javascript:{}" class="no-border" onclick="if(window.editDeal){window.editDeal(<?=intval($event['req_id'] ?: 0)?>, <?=$deal_id_for_edit?>)}" title="Редактировать сделку" style="color:#999;font-size:16px;line-height:1;">
<i class="jw-action-icon-settings"></i>
</a>
<a href="javascript:{}" class="no-border" onclick="cancelEvent(<?=$event['id']?>)" title="Отменить сделку" style="color:#e57373;font-size:16px;line-height:1;">
2026-06-25 13:48:13 +02:00
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
2026-06-25 12:57:27 +02:00
</a>
</div>
<?php } ?>
<?php } else { ?>
2026-06-25 13:48:13 +02:00
<!-- СТАРЫЙ ВАРИАНТ-->
2026-06-25 12:57:27 +02:00
<?php if ($event['sum']) { ?>
<div class="message" style="font-size:13px;">Сумма сделки: <?=$event['sum']?><span class="rub">p</span></div>
<?php } ?>
2026-06-26 09:58:53 +02:00
<?php if ($event['comment']) {
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
?>
<div class="message" style="font-size:12px;color:#888;margin-top:4px;padding-left:8px;border-left:2px solid #e0e0e0;">Комментарий: <?=$comment?></div>
<?php } ?>
2026-06-25 12:57:27 +02:00
<?php } ?>
<?php if ($event['document_id']) {
2026-05-22 20:21:54 +02:00
$doc_id = $event['document_id'];
$doc = Docs::getInnerDoc(null, $doc_id);
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
if (isset($doc['params'])) {
if ($params = json_decode($doc['params'], true)) {
if ($params['client_id'] && $params['object_id']) {
$doc_parties = '';
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
if (isset($params['client_ids'])) {
$client_ids = json_decode(html_entity_decode($params['client_ids']));
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
$sql_cls = "SELECT id, fio, phone, email FROM `clients` WHERE `id` in (".implode(',', $client_ids).")";
$rez_cls = mysql_query($sql_cls);
while($doc_cls = mysql_fetch_assoc($rez_cls)) {
mask_client_contacts_inplace($doc_cls);
$cls_contacts = [];
2026-06-25 12:57:27 +02:00
if ($doc_cls['email'])
$cls_contacts[] = $doc_cls['email'];
if ($doc_cl['phone'])
$cls_contacts[] = $doc_cls['phone'];
2026-05-22 20:21:54 +02:00
$doc_parties .= '<li>Клиент: <a href="javascript:{}" data-id="'.$doc_cls['id'].'" class="neweditClient">'.$doc_cls['fio'] . ((!empty($cls_contacts)) ? ' (' . implode(', ', $cls_contacts) . ')' : '') . '</a><li/>';
}
}
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
if (isset($params['client_id']) && (!isset($client_ids) || empty($client_ids))) {
$sql_cl = "SELECT id, fio, phone, email FROM `clients` WHERE `id` = '$params[client_id]' LIMIT 1";
$rez_cl = mysql_query($sql_cl);
if ($doc_cl = mysql_fetch_assoc($rez_cl)) {
mask_client_contacts_inplace($doc_cl);
$cl_contacts = [];
2026-06-25 12:57:27 +02:00
if ($doc_cl['email'])
$cl_contacts[] = $doc_cl['email'];
if ($doc_cl['phone'])
$cl_contacts[] = $doc_cl['phone'];
2026-05-22 20:21:54 +02:00
$doc_parties .= '<li>Клиент: <a href="javascript:{}" data-id="'.$doc_cl['id'].'" class="neweditClient">'.$doc_cl['fio'] . ((!empty($cl_contacts)) ? ' (' . implode(', ', $cl_contacts) . ')' : '') . '</a><li/>';
}
}
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
if (isset($params['object_id'])) {
$sql_obj = "SELECT id, nazv, adres FROM `objects` WHERE `id` = '$params[object_id]' LIMIT 1";
$rez_obj = mysql_query($sql_obj);
if ($doc_obj = mysql_fetch_assoc($rez_obj)) {
$doc_parties .= '<li>Объект: <a href="javascript:{}" data-id="'.$doc_obj['id'].'" data-client="'.$params['client_id'].'" class="show_object">'.$doc_obj['nazv'].' ('.$doc_obj['adres'].')</a><li/>';
}
}
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
if (!empty($doc_parties)) { ?>
<div class="message parties">Стороны сделки:<br/><ul><?= $doc_parties; ?></ul></div>
<?php }
}
}
}
2026-06-25 12:57:27 +02:00
if (isset($doc['id']) && isset($doc['name'])) {
?>
2026-05-22 20:21:54 +02:00
<div class="document" data-id="<?= $doc['id']; ?>">
Документ:
<a href="javascript:{}" class="no-border pull-right">
<span class="jw__small-popup ti-more" data-id="document_<?= $doc['id']; ?>"></span>
<div class="jw__popup actions-document" id="popup__document_<?= $doc['id']; ?>">
<div class="actions-document__inner">
<a href="javascript:{}" onclick="previewInnerDoc(<?= $doc['id']; ?>)">Предпросмотр</a>
<a href="javascript:{}" onclick="editInnerDoc(<?= $doc['id']; ?>)">Редактировать</a>
<a href="javascript:{}" onclick="sendInnerDocWin(<?= $doc['id']; ?>)">Отправить</a>
<a href="javascript:{}" onclick="confirmDeleteInnerDoc(<?= $doc['id']; ?>)">Удалить</a>
</div>
</div>
</a><br/>
<ul>
<li>
<a title="Скачать файл" download="" href="/ajax/getInnerDoc.php?id=<?= $doc['id']; ?>&download_pdf=true&t=<?= time(); ?>">
<span class="file-span ti-file"></span>
<span class="file-name" data-id="<?= $doc['id']; ?>"><?= $doc['name']; ?>.pdf</span>
</a>
</li>
</ul>
</div>
2026-06-25 12:57:27 +02:00
<?php }
} ?>
2026-05-22 20:21:54 +02:00
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
2026-06-25 12:57:27 +02:00
<?php {
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
<?php
}
}?>
<?php {
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
<?php
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
<?php
}
}?>
<?php if($event['from_id'] == $_SESSION['id'] && !$deal_id_for_edit){ ?>
<div class="message" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="editEvent('<?=$event['id']?>', '<?=$event['type']?>')" title="Редактировать">
<span class="simple-button settings"><i class="jw-action-icon-settings"></i></span>
</a>
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
<?php } ?>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
if ($event['type'] == 'even') {
$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">
2026-05-22 20:21:54 +02:00
<?php
2026-06-25 12:57:27 +02:00
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
<?php
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
<?php
}
?>
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
</div>
</div>
<div class="chat-message <?=($event['cancel']==1) ? 'cancel' : ''?> even">
<div class="chat-complete<?=!in_array($event['user_id'], $usersCanEdit) ? ' hidden' : '' ?>">
<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']?>" data-cancel="<?=$event['cancel']?>" 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 class="message evCancel<?=($event['calendar_view'] == 1) ? ' hidden' : ''?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelEvent('<?=$event['id']?>')" title="Отменить">
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
</a>
</div>
</div>
<div class="chat-content" id="chat_content_<?=$event['id']?>">
<div class="head">
<span><?=$event['name']?></span>
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
</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']) {
$pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
?>
<div class="message">Комментарий: <?=$comment?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
<?php {
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-25 12:57:27 +02:00
<?php
}
}?>
<?php {
2026-05-22 20:21:54 +02:00
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-06-25 12:57:27 +02:00
<?php
}
2026-05-22 20:21:54 +02:00
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-25 12:57:27 +02:00
<?php
}
}?>
2026-05-22 20:21:54 +02:00
<?php if($event['from_id'] == $_SESSION['id']){ ?>
2026-06-21 06:52:31 +02:00
<div class="message" style="margin-top: 10px;">
2026-06-25 12:57:27 +02:00
<a href="javascript:{}" class="no-border" onclick="editEvent('<?=$event['id']?>', '<?=$event['type']?>', '<?=$event['client_id']?>')" title="Редактировать">
2026-06-21 06:52:31 +02:00
<span class="simple-button settings"><i class="jw-action-icon-settings"></i></span>
</a>
<a href="javascript:{}" class="no-border" onclick="deleteEvent('<?=$event['id']?>')" title="Удалить">
<span class="simple-button delete"><i class="jw-action-icon-delete"></i></span>
</a>
</div>
2026-05-22 20:21:54 +02:00
<?php } ?>
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
2026-06-25 12:57:27 +02:00
<?php
}
if ($event['type'] == 'step') {
$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 class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
</div>
</div>
<div class="chat-message call">
<div class="chat-content" id="chat_content_<?=$event['id']?>">
<div class="head"><span style="color: #3446eb;">Этап &laquo;<?=$event['name']?>&raquo;</span></div>
<?php
if($event['checklist'] == 0){
?>
<div class="message">Закрыт со следующими событиями:</div>
<?php } else { ?>
<div class="message">Добавлено событие по чек листу:</div>
<?php } ?>
<?php if($event['comment']){
// меняем ссылку на файл (судя по всему она записана прямо в теле комментария)
$comment = $event['comment'];
$comment = str_replace('download href', 'target="_blank" href', $comment);
$comment = str_replace('?guid', '?preview=1&guid', $comment);
?>
<div class="message"><?=$comment?></div>
<?php } ?>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
<?php {
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
<?php
}
}?>
<?php {
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
<?php
}
if($event['old_req_id'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
<?php
}
}?>
</div>
</div>
<div class="clear"></div>
</div>
2026-06-21 06:52:31 +02:00
<?php
2026-06-25 12:57:27 +02:00
2026-05-22 20:21:54 +02:00
}
if($event['type'] == 'partner'){
$date = date("d.m.Y", strtotime($event['schedule_date']));
list($d, $m, $y) = explode(".", $date);
$doers=array();
if(!empty($client->doers)){
$doers_arr = json_decode(html_entity_decode($client->doers));
foreach($doers_arr as $key => $doer){
$doers[$key] = $doer;
}
} else if((isset($get['req_id']) && $get['req_id'] > 0) && !empty($client['doers'])){
$doers_arr = json_decode(html_entity_decode($client['doers']));
foreach($doers_arr as $key => $doer){
$doers[$key] = $doer;
}
}
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="chat-block<?=$class_ev?>">
2026-06-21 06:52:31 +02:00
<div class="chat-author">
2026-05-22 20:21:54 +02:00
<div class="pic">
<?php
if(empty($event['user_logo'])){
?>
<img src="/images/user-pic.svg"/>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
} else {
?>
<img src="/photos/agency/<?=$event['user_logo']?>">
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
?>
2026-05-22 20:21:54 +02:00
<div class="fio_user" title="<?=$event['user_fio']?>"><?=$event['user_fio']?></div>
</div>
2026-06-21 06:52:31 +02:00
</div>
2026-05-22 20:21:54 +02:00
<div class="chat-message <?=(!isset($doers[$event['from_id']])) ? 'cancel' : ''?> call">
<div class="chat-complete">
<div class="complete-button">
<input disabled type="checkbox" class="">
<div class="complete-action-button <?=(isset($doers[$event['from_id']]) && $doers[$event['from_id']] == 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"></path>
</g>
</g>
</svg>
</div>
<div class="message evCancel<?=(isset($doers[$event['from_id']]) && $doers[$event['from_id']] == 1) ? ' ' : ' hidden'?>" style="margin-top: 10px;">
<a href="javascript:{}" class="no-border" onclick="cancelPartner('<?=$event['from_id']?>', '<?=$get['id']?>', '<?=$get['req_id']?>')" title="Отменить">
<span class="simple-button tooltip-item">
<i class="ti-close"></i>
</span>
</a>
</div>
</div>
</div>
2026-06-21 06:52:31 +02:00
<div class="chat-content" id="chat_content_<?=$event['id']?>">
<div class="head">
<span style="color: #3446eb;">Партнер</span>
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?>
</div>
<div class="message">Добавлен к совместной работе</div>
<span class="time"><?=date("H:i", strtotime($time_zone, strtotime($event['create_date'])))?></span>
<?php {
2026-05-22 20:21:54 +02:00
if($event['user_id'] > 0 && isset($users[$event['user_id']])){?>
<br><span class="time"><i title="Ответственный" class="ti-user" style="margin-right: 5px"></i>
<?=$users[$event['user_id']]['user_fio']?>
</span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
}?>
2026-06-21 06:52:31 +02:00
<?php {
if($event['open_step'] > 0){?>
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Задача добавлена автоматически при переходе на этап</span>
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
<?php
}
2026-05-22 20:21:54 +02:00
2026-06-21 06:52:31 +02:00
if($event['old_req_id'] > 0){?>
2026-05-22 20:21:54 +02:00
<br><span class="time"><i class="ti-info-alt" style="margin-right: 5px"></i>Из заявки ID: <?=$event['old_req_id']?></span>
2026-06-21 06:52:31 +02:00
<?php
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
}?>
2026-05-22 20:21:54 +02:00
</div>
2026-06-21 06:52:31 +02:00
</div>
<div class="clear"></div>
2026-05-22 20:21:54 +02:00
</div>
<?php
2026-06-21 06:52:31 +02:00
}
2026-05-22 20:21:54 +02:00
}
2026-06-21 06:52:31 +02:00
if($date_del != ''){
echo '<div class="chat-date"><span>'.$date_del.'</span></div>';
$text2 = 'Клиент закрыт';
if($is_req){
$text2 = 'Заявка закрыта';
}
echo '<div class="chat-status added"><span>'.$text2;
if(isset($reason) && !empty($reason)){
2026-05-22 20:21:54 +02:00
echo " - ".$reason;
2026-06-21 06:52:31 +02:00
}
echo '</span></div>';
}
2026-05-22 20:21:54 +02:00
}
2026-06-25 12:53:43 +02:00