|
|
@@ -68,55 +68,62 @@ class NotificationService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function notifyOrderCreated(Order $order): void
|
|
|
+ public function notifyOrderCreated(Order $order, ?User $author = null): void
|
|
|
{
|
|
|
$statusName = $order->orderStatus?->name ?? (Order::STATUS_NAMES[$order->order_status_id] ?? '-');
|
|
|
+ $authorSuffix = $author ? sprintf(' Изменил %s.', $author->name) : '';
|
|
|
+ $authorSuffixHtml = $author ? sprintf(' Изменил %s.', e($author->name)) : '';
|
|
|
|
|
|
$this->notifyOrderEvent(
|
|
|
$order,
|
|
|
UserNotification::EVENT_CREATED,
|
|
|
'Площадки',
|
|
|
- sprintf('Добавлена новая площадка %s', $order->object_address),
|
|
|
+ sprintf('Добавлена новая площадка %s.', $order->object_address) . $authorSuffix,
|
|
|
sprintf(
|
|
|
'Добавлена новая площадка <a href="%s">%s</a>.',
|
|
|
route('order.show', ['order' => $order->id, 'sync_year' => 1]),
|
|
|
e($order->object_address)
|
|
|
- ),
|
|
|
+ ) . $authorSuffixHtml,
|
|
|
$statusName,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function notifyOrderStatusChanged(Order $order): void
|
|
|
+ public function notifyOrderStatusChanged(Order $order, ?User $author = null): void
|
|
|
{
|
|
|
$statusName = $order->orderStatus?->name ?? (Order::STATUS_NAMES[$order->order_status_id] ?? '-');
|
|
|
+ $authorSuffix = $author ? sprintf(' Изменил %s.', $author->name) : '';
|
|
|
+ $authorSuffixHtml = $author ? sprintf(' Изменил %s.', e($author->name)) : '';
|
|
|
|
|
|
$this->notifyOrderEvent(
|
|
|
$order,
|
|
|
UserNotification::EVENT_STATUS_CHANGED,
|
|
|
'Площадки',
|
|
|
- sprintf('Статус площадки %s изменен на %s', $order->object_address, $statusName),
|
|
|
+ sprintf('Статус площадки %s изменен на %s.', $order->object_address, $statusName) . $authorSuffix,
|
|
|
sprintf(
|
|
|
'Статус площадки <a href="%s">%s</a> изменен на %s.',
|
|
|
route('order.show', ['order' => $order->id, 'sync_year' => 1]),
|
|
|
e($order->object_address),
|
|
|
e($statusName)
|
|
|
- ),
|
|
|
+ ) . $authorSuffixHtml,
|
|
|
$statusName,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function notifyReclamationCreated(Reclamation $reclamation): void
|
|
|
+ public function notifyReclamationCreated(Reclamation $reclamation, ?User $author = null): void
|
|
|
{
|
|
|
$order = $reclamation->order;
|
|
|
if (!$order) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ $authorSuffix = $author ? sprintf(' Изменил %s.', $author->name) : '';
|
|
|
+ $authorSuffixHtml = $author ? sprintf(' Изменил %s.', e($author->name)) : '';
|
|
|
+
|
|
|
$message = sprintf(
|
|
|
- 'Добавлена новая рекламация по адресу %s #%d',
|
|
|
+ 'Добавлена новая рекламация по адресу %s #%d.',
|
|
|
$order->object_address,
|
|
|
$reclamation->id,
|
|
|
- );
|
|
|
+ ) . $authorSuffix;
|
|
|
|
|
|
$messageHtml = sprintf(
|
|
|
'Добавлена новая рекламация по адресу <a href="%s">%s</a> <a href="%s">#%d</a>.',
|
|
|
@@ -124,7 +131,7 @@ class NotificationService
|
|
|
e($order->object_address),
|
|
|
route('reclamations.show', ['reclamation' => $reclamation->id]),
|
|
|
$reclamation->id,
|
|
|
- );
|
|
|
+ ) . $authorSuffixHtml;
|
|
|
|
|
|
$this->notifyReclamationEvent(
|
|
|
$reclamation,
|
|
|
@@ -136,7 +143,7 @@ class NotificationService
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function notifyReclamationStatusChanged(Reclamation $reclamation): void
|
|
|
+ public function notifyReclamationStatusChanged(Reclamation $reclamation, ?User $author = null): void
|
|
|
{
|
|
|
$order = $reclamation->order;
|
|
|
if (!$order) {
|
|
|
@@ -144,13 +151,15 @@ class NotificationService
|
|
|
}
|
|
|
|
|
|
$statusName = $reclamation->status?->name ?? (Reclamation::STATUS_NAMES[$reclamation->status_id] ?? '-');
|
|
|
+ $authorSuffix = $author ? sprintf(' Изменил %s.', $author->name) : '';
|
|
|
+ $authorSuffixHtml = $author ? sprintf(' Изменил %s.', e($author->name)) : '';
|
|
|
|
|
|
$message = sprintf(
|
|
|
- 'Статус рекламации %s #%d изменен на %s',
|
|
|
+ 'Статус рекламации %s #%d изменен на %s.',
|
|
|
$order->object_address,
|
|
|
$reclamation->id,
|
|
|
$statusName,
|
|
|
- );
|
|
|
+ ) . $authorSuffix;
|
|
|
|
|
|
$messageHtml = sprintf(
|
|
|
'Статус рекламации по адресу <a href="%s">%s</a> <a href="%s">#%d</a> изменен на %s.',
|
|
|
@@ -159,7 +168,7 @@ class NotificationService
|
|
|
route('reclamations.show', ['reclamation' => $reclamation->id]),
|
|
|
$reclamation->id,
|
|
|
e($statusName),
|
|
|
- );
|
|
|
+ ) . $authorSuffixHtml;
|
|
|
|
|
|
$this->notifyReclamationEvent(
|
|
|
$reclamation,
|
|
|
@@ -171,7 +180,7 @@ class NotificationService
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function notifyScheduleAdded(Schedule $schedule): void
|
|
|
+ public function notifyScheduleAdded(Schedule $schedule, ?User $author = null): void
|
|
|
{
|
|
|
$sourceKey = $this->sourceToSettingKey((string)$schedule->source);
|
|
|
if (!$sourceKey) {
|
|
|
@@ -180,6 +189,8 @@ class NotificationService
|
|
|
|
|
|
$brigadierName = $schedule->brigadier?->name ?? '-';
|
|
|
$date = DateHelper::getHumanDate((string)$schedule->installation_date, true);
|
|
|
+ $authorSuffix = $author ? sprintf(' Изменил %s.', $author->name) : '';
|
|
|
+ $authorSuffixHtml = $author ? sprintf(' Изменил %s.', e($author->name)) : '';
|
|
|
|
|
|
if ((string)$schedule->source === 'Рекламации') {
|
|
|
$reclamationId = $this->extractReclamationId((string)$schedule->address_code);
|
|
|
@@ -190,7 +201,7 @@ class NotificationService
|
|
|
$schedule->object_address,
|
|
|
$date,
|
|
|
$brigadierName,
|
|
|
- );
|
|
|
+ ) . $authorSuffix;
|
|
|
|
|
|
$reclamationLink = $reclamationId
|
|
|
? route('reclamations.show', ['reclamation' => $reclamationId])
|
|
|
@@ -210,14 +221,14 @@ class NotificationService
|
|
|
$addressHtml,
|
|
|
e($date),
|
|
|
e($brigadierName),
|
|
|
- );
|
|
|
+ ) . $authorSuffixHtml;
|
|
|
} else {
|
|
|
$message = sprintf(
|
|
|
'%s добавлено в график монтажей на %s, Бригадир %s.',
|
|
|
$schedule->object_address,
|
|
|
$date,
|
|
|
$brigadierName,
|
|
|
- );
|
|
|
+ ) . $authorSuffix;
|
|
|
|
|
|
$orderLink = $schedule->order_id
|
|
|
? route('order.show', ['order' => $schedule->order_id, 'sync_year' => 1])
|
|
|
@@ -229,7 +240,7 @@ class NotificationService
|
|
|
e($schedule->object_address),
|
|
|
e($date),
|
|
|
e($brigadierName),
|
|
|
- );
|
|
|
+ ) . $authorSuffixHtml;
|
|
|
}
|
|
|
|
|
|
$users = $this->scheduleRecipients($schedule);
|