Files
citrus-cms/app/Functions/getLowestSpoolStatus.php
2026-04-28 21:14:25 +03:00

32 lines
956 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
function getLowestSpoolStatus($spoolStatuses) {
// Eğer tüm spool_status değerleri "Completed" ise
if (count(array_filter($spoolStatuses, fn($status) => $status !== 'Completed')) === 0) {
return 'Completed';
}
// Spool durumlarını sayısal değerlere göre sıralayıp en düşük olanı döndür
$statusValues = [
'Waiting',
'On Going',
'Spool Release',
'NDT Release',
'Paint',
'Completed'
];
// Geçerli spool durumlarını kontrol et ve en düşük durumu bul
$lowestStatus = null; // Başlangıçta en düşük durum yok
foreach ($statusValues as $status) {
if (in_array($status, $spoolStatuses)) {
if ($lowestStatus === null || array_search($status, $statusValues) < array_search($lowestStatus, $statusValues)) {
$lowestStatus = $status;
}
}
}
return $lowestStatus;
}
?>