Fix event template

This commit is contained in:
mac 2026-06-20 15:47:55 +03:00
parent de49ff77c3
commit 16e17c6865

View File

@ -1091,28 +1091,110 @@ ORDER BY date_sort ASC";
<?php <?php
$deal_id_for_edit = null; $deal_id_for_edit = null;
if (!empty($event['req_id'])) { if (!empty($event['req_id'])) {
$sql_deal = "SELECT id FROM deals WHERE side_one_requisition_id = " . intval($event['req_id']) . " LIMIT 1"; $sql_deal = "SELECT id FROM deals WHERE (side_one_requisition_id = " . intval($event['req_id']) . " OR side_two_requisition_id = " . intval($event['req_id']) . ") AND status != 2 LIMIT 1";
$rez_deal = mysql_query($sql_deal); $rez_deal = mysql_query($sql_deal);
if ($rez_deal && mysql_num_rows($rez_deal) > 0) { if ($rez_deal && mysql_num_rows($rez_deal) > 0) {
$row_deal = mysql_fetch_assoc($rez_deal); $row_deal = mysql_fetch_assoc($rez_deal);
$deal_id_for_edit = $row_deal['id']; $deal_id_for_edit = $row_deal['id'];
} }
} }
if ($deal_id_for_edit) { ?> if (!$deal_id_for_edit && !empty($event['client_id'])) {
<a href="javascript:{}" class="no-border" onclick="if(window.editDeal){window.editDeal(<?=intval($event['req_id'])?>, <?=$deal_id_for_edit?>)}" title="Редактировать сделку" style="color:#9e9e9e;font-size:14px;"> $sql_deal_client = "SELECT d.id FROM deals d JOIN requisitions r ON (r.id = d.side_one_requisition_id OR r.id = d.side_two_requisition_id) WHERE r.client_id = " . intval($event['client_id']) . " AND d.status != 2 LIMIT 1";
$rez_deal_client = mysql_query($sql_deal_client);
if ($rez_deal_client && mysql_num_rows($rez_deal_client) > 0) {
$row_deal_client = mysql_fetch_assoc($rez_deal_client);
$deal_id_for_edit = $row_deal_client['id'];
}
}
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);
?>
<a href="javascript:{}" class="no-border" onclick="if(window.editDeal){window.editDeal(<?=intval($event['req_id'] ?: 0)?>, <?=$deal_id_for_edit?>)}" title="Редактировать сделку" style="color:#9e9e9e;font-size:14px;">
<i class="ti-pencil"></i> <i class="ti-pencil"></i>
</a> </a>
<?php } ?> <?php } ?>
<?php if ($event['partner_id']) : ?><sup style="padding-left:3px; font-weight:normal;color:#dea847;" data-partner-id="<?= $event['partner_id'] ?>">от партнёра</sup><?php endif; ?> <?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>
<div class="message">Запланирована сделка на <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div> <div class="message">Запланирована сделка на <?=$d?> <?=getRusMonth($m)?> <?=$y?> в <?=date("H:i", strtotime($event['schedule_date']))?></div>
<?php if ($event['sum']) { ?> <?php if (!empty($deal_data)) { ?>
<div class="message">Сумма сделки: <?=$event['sum']?><span class="rub">p</span></div> <hr style="border:none;border-top:1px solid #e0e0e0;margin:6px 0;">
<?php } if ($event['comment']) { <?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
// Сторона 1
$side1_name = htmlspecialchars($deal_data['side_one']);
if (!empty($deal_data['side_one_requisition_id'])) {
$sql_req1 = "SELECT name FROM requisitions WHERE id = " . intval($deal_data['side_one_requisition_id']) . " LIMIT 1";
$rez_req1 = mysql_query($sql_req1);
if ($rez_req1 && mysql_num_rows($rez_req1) > 0) {
$row_req1 = mysql_fetch_assoc($rez_req1);
$side1_name .= ': Заявка «' . htmlspecialchars($row_req1['name']) . '»';
}
}
echo '<span style="color:#666;">' . $side1_name . '</span><br/>';
// Сторона 2
$side2_name = htmlspecialchars($deal_data['side_two']);
if (!empty($deal_data['side_two_requisition_id'])) {
$sql_req2 = "SELECT name FROM requisitions WHERE id = " . intval($deal_data['side_two_requisition_id']) . " LIMIT 1";
$rez_req2 = mysql_query($sql_req2);
if ($rez_req2 && mysql_num_rows($rez_req2) > 0) {
$row_req2 = mysql_fetch_assoc($rez_req2);
$side2_name .= ': Заявка «' . htmlspecialchars($row_req2['name']) . '»';
}
}
echo '<span style="color:#666;">' . $side2_name . '</span>';
?>
</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) {
echo '<div class="message" style="margin-top:5px;font-size:13px;"><b>Объекты:</b><br/>';
while ($obj_row = mysql_fetch_assoc($rez_objs)) {
echo '<span style="color:#666;">' . htmlspecialchars($obj_row['nazv']) . ' (' . htmlspecialchars($obj_row['adres']) . ')</span><br/>';
}
echo '</div>';
}
}
// Документы сделки
$sql_inner_docs = "SELECT d.id, d.name 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);
$rez_inner_docs = mysql_query($sql_inner_docs);
if ($rez_inner_docs && mysql_num_rows($rez_inner_docs) > 0) {
echo '<div class="message" style="margin-top:5px;font-size:13px;"><b>Документы:</b><br/>';
while ($doc_row = mysql_fetch_assoc($rez_inner_docs)) {
echo '<span style="color:#666;">📄 ' . htmlspecialchars($doc_row['name']) . '</span><br/>';
}
echo '</div>';
}
?>
<div style="margin-top:8px;text-align:right;">
<a href="javascript:{}" class="no-border" onclick="if(window.editDeal){window.editDeal(<?=intval($event['req_id'] ?: 0)?>, <?=$deal_id_for_edit?>)}" style="color:#43A047;font-size:13px;font-weight:500;">
Подробнее
</a>
</div>
<?php } else { ?>
<?php if ($event['sum']) { ?>
<div class="message" style="font-size:13px;">Сумма сделки: <?=$event['sum']?><span class="rub">p</span></div>
<?php } ?>
<?php } ?>
<?php if ($event['comment']) {
$pattern = '/(https?:\/\/\S+)/i'; $pattern = '/(https?:\/\/\S+)/i';
$comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']); $comment = preg_replace($pattern, '<a target="_blank" href="$1">ссылка</a>', $event['comment']);
?> ?>
<div class="message">Комментарий: <?=$comment?></div> <div class="message" style="font-size:12px;color:#888;margin-top:4px;padding-left:8px;border-left:2px solid #e0e0e0;">Комментарий: <?=$comment?></div>
<?php } if ($event['document_id']) { <?php } if ($event['document_id']) {
$doc_id = $event['document_id']; $doc_id = $event['document_id'];
$doc = Docs::getInnerDoc(null, $doc_id); $doc = Docs::getInnerDoc(null, $doc_id);