+ pivot: add function to process the properties of execution.
This commit is contained in:
@@ -10,6 +10,31 @@ declare(strict_types = 1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
$getDeviationHtml = function(float $deviation): string
|
||||
{
|
||||
if($deviation > 0) return "<span class='up'>↑</span>" . $deviation;
|
||||
if($deviation < 0) return "<span class='down'>↓</span>" . abs($deviation);
|
||||
return "<span class='zero'>0</span>";
|
||||
};
|
||||
|
||||
$getDeviationRateHtml = function(float $deviationRate): string
|
||||
{
|
||||
if($deviationRate >= 50) return "<span class='u50'>" . $deviationRate . '%</span>';
|
||||
if($deviationRate >= 30) return "<span class='u30'>" . $deviationRate . '%</span>';
|
||||
if($deviationRate >= 10) return "<span class='u10'>" . $deviationRate . '%</span>';
|
||||
if($deviationRate > 0) return "<span class='u0'>" . abs($deviationRate) . '%</span>';
|
||||
if($deviationRate <= -20) return "<span class='d20'>" . abs($deviationRate) . '%</span>';
|
||||
if($deviationRate < 0) return "<span class='d0'>" . abs($deviationRate) . '%</span>';
|
||||
if($deviationRate == 'n/a') return "<span class='zero'>" . $deviationRate . '</span>';
|
||||
return "<span class='zero'>" . abs($deviationRate) . '%</span>';
|
||||
};
|
||||
|
||||
foreach($executions as $execution)
|
||||
{
|
||||
$execution->deviation = $getDeviationHtml($execution->deviation);
|
||||
$execution->deviationRate = $getDeviationRateHtml($execution->deviationRate);
|
||||
}
|
||||
|
||||
$cols = $config->pivot->dtable->projectDeviation->fieldList;
|
||||
|
||||
$generateData = function() use ($module, $method, $lang, $cols, $executions)
|
||||
|
||||
Reference in New Issue
Block a user