Files
citrus-cms/app/Services/LineListTriggers/Triggers/SpoolStatusChangerFinalTrigger.php
2026-04-28 21:14:25 +03:00

52 lines
1.5 KiB
PHP

<?php
namespace App\Services\LineListTriggers\Triggers;
use App\Services\LineListTriggers\Base\BaseLineListTrigger;
use Illuminate\Support\Facades\Log;
/**
* Spool Status Changer Final Trigger
*
* Runs final spool status changer view at the end of all syncs
*/
class SpoolStatusChangerFinalTrigger extends BaseLineListTrigger
{
public function getName(): string
{
return 'Spool Status Changer Final';
}
public function getDependentFields(): array
{
return ['line_no', 'painting_cycle'];
}
protected function process($lineListData, $beforeData, array $context): array
{
$paintChanged = false;
// Check if painting_cycle changed (especially if old was filled and new is empty)
if((!empty($beforeData->painting_cycle) && empty($lineListData->painting_cycle)) ||
(isset($lineListData->painting_cycle) && $lineListData->painting_cycle != $beforeData->painting_cycle)) {
$paintChanged = true;
Log::info("Painting cycle changed", [
'before_painting_cycle' => $beforeData->painting_cycle,
'current_painting_cycle' => $lineListData->painting_cycle
]);
}
spoolStatusChanger($lineListData->line_no, null, $paintChanged);
Log::info("Spool Status Changer triggered", [
'line_no' => $lineListData->line_no
]);
return [
'success' => true,
'executed' => 'spool_status_changer_view'
];
}
}