Skip to content

Commit

Permalink
Fix #727
Browse files Browse the repository at this point in the history
  • Loading branch information
tbar0970 committed Nov 23, 2021
1 parent 2644d5b commit b75ffb7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions views/view_8_services.class.php
Expand Up @@ -541,10 +541,17 @@ private function printComponentSelector()
$runsheetTitle = $this->service->replaceKeywords($runsheetTitle);
}
$comp['personnel'] = $this->service->replaceKeywords($comp['personnel']);
$weeks = '';
$lastUse = $lastUseSort = '';
if ($comp['lastused']) {
$weeks = floor(($serviceTS - strtotime($comp['lastused'])) / 60 / 60 / 24 / 7);
$weeks = "{$weeks}w";
$lastTS = strtotime($comp['lastused']);
$lastUseSort = (int)$lastTS;
if ($lastTS == $serviceTS) {
$lastUse = 'now';
} else if ($lastTS > $serviceTS) {
$lastUse = '+'.ceil(($lastTS - $serviceTS) / 60 / 60 / 24 / 7).'w';
} else {
$lastUse = ceil(($serviceTS - $lastTS) / 60 / 60 / 24 / 7).'w';
}
}

?>
Expand All @@ -562,8 +569,8 @@ private function printComponentSelector()
}
?>
</td>
<td data-sort-value="<?php echo (int)$weeks; ?>" class="hide-in-transit">
<?php echo $weeks; ?>
<td data-sort-value="<?php echo $lastUseSort; ?>" class="hide-in-transit">
<?php echo $lastUse; ?>
</td>
<td class="hide-in-transit">
<?php echo $comp['usage_12m']; ?>x
Expand Down

0 comments on commit b75ffb7

Please sign in to comment.