|
|
@@ -248,6 +248,7 @@ class ScheduleController extends Controller
|
|
|
->first();
|
|
|
|
|
|
$order = $reclamation->order;
|
|
|
+ $scheduleComment = $this->buildScheduleCommentFromReclamation($reclamation);
|
|
|
|
|
|
$mafs = [];
|
|
|
if(empty($validated['skus'])) {
|
|
|
@@ -284,7 +285,7 @@ class ScheduleController extends Controller
|
|
|
'mafs' => $mafsText,
|
|
|
'mafs_count' => $mafsCount,
|
|
|
'brigadier_id' => $reclamation->brigadier_id,
|
|
|
- 'comment' => $reclamation->guarantee,
|
|
|
+ 'comment' => $scheduleComment,
|
|
|
]);
|
|
|
if($first && isset($validated['send_notifications'])) {
|
|
|
$first = false;
|
|
|
@@ -295,6 +296,39 @@ class ScheduleController extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private function buildScheduleCommentFromReclamation(Reclamation $reclamation): string
|
|
|
+ {
|
|
|
+ $guarantee = trim((string) $reclamation->guarantee);
|
|
|
+
|
|
|
+ $parts = $reclamation->sparePartReservations()
|
|
|
+ ->whereIn('status', ['active', 'issued'])
|
|
|
+ ->with(['sparePart:id,article', 'sparePartOrder:id,order_number'])
|
|
|
+ ->orderBy('created_at')
|
|
|
+ ->get()
|
|
|
+ ->map(static function ($reservation): ?string {
|
|
|
+ $article = trim((string) $reservation->sparePart?->article);
|
|
|
+
|
|
|
+ if ($article === '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ $orderNumber = $reservation->sparePartOrder?->display_order_number ?? '-';
|
|
|
+
|
|
|
+ return $article . ' - ' . $orderNumber;
|
|
|
+ })
|
|
|
+ ->filter()
|
|
|
+ ->values();
|
|
|
+
|
|
|
+ $lines = array_filter([
|
|
|
+ $guarantee !== '' ? $guarantee : null,
|
|
|
+ $parts->isNotEmpty()
|
|
|
+ ? 'Используемые детали: ' . $parts->implode(', ') . '.'
|
|
|
+ : null,
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return implode(PHP_EOL, $lines);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public function update(UpdateScheduleRequest $request, NotificationService $notificationService)
|
|
|
{
|