ssp setting a parameter from a column in array
ssp setting a parameter from a column in array
bbrindza
Posts: 316Questions: 73Answers: 1
I need to set a variable based on the the value of column in a ssp script , but for some reason it is not returning the value.
$outOfOffice = '';
$columns[] = array( 'db' => 'OUT_OF_OFFICE', 'dt' => 'out_of_office',
'formatter' => function($d, $row) use ($outOfOffice) {
$outOfOffice = trim($row['OUT_OF_OFFICE']);
return trim($row['OUT_OF_OFFICE']);
}
);
if($outOfOffice == 'Vacation Day'){
$columns[] = array( 'db' => 'TOTAL_HOURS_SECONDS', 'dt' => 'total_vacation_hours',
'formatter' => function($d, $row){
$totalVacationhours = floor($row['TOTAL_HOURS_SECONDS'] / 3600);
return $totalVacationhours;
}
);
}else if ($outOfOffice == 'Paid Leave Vacation'){
$columns[] = array( 'db' => 'TOTAL_HOURS_SECONDS', 'dt' => 'total_paid_leave_vacation_hours',
'formatter' => function($d, $row){
$totalPaidLeaveVacationHours = floor($row['TOTAL_HOURS_SECONDS'] / 3600);
return $totalPaidLeaveVacationHours;
}
);
}
Replies
I figured it out . Unless there is a better way of doing this.
That looks good to me. Personally I'd use a ternary to shorten the code a little:
But that's just a code style thing.
Allan