32 lines
956 B
PHP
32 lines
956 B
PHP
<?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;
|
||
}
|
||
|
||
?>
|