{{-- components/cell.blade.php --}} {{-- Reproduces legacy CellAdd() / wrr_CellAdd() rendering --}} {{-- See UI Spec ยง3.2 --}} @php $mark = $mark ?? 'TD'; $type = $type ?? null; $class = $class ?? null; $colspan = $colspan ?? null; $rowspan = $rowspan ?? null; $value = $value ?? ''; // Determine alignment based on type $align = match($type) { 'NUM', 'INT', 'FXR', 'TWO_DECI', 'THREE_DECI', 'TWO_DECI_PERCENT', 'NO_DECI_PERCENT', 'MNT', 'MNT_LIM', 'DIFF', 'CROSS', 'CROSS_FR' => 'RIGHT', 'DATE', 'DBDATE', 'MDATE', 'EDATE', 'MTIME', 'FINDATE', 'CHOICE' => 'CENTER', default => 'LEFT', }; // Format value based on type $formatted = $value; $bgColor = null; $fontColor = null; $decPoint = config('kms.number.dec_point', ','); $thousandsSep = config('kms.number.thousands_sep', ''); $negColor = config('kms.number.neg_color', 'RED'); if ($value === null || $value === '') { $formatted = ' '; } else { switch ($type) { case 'NUM': $formatted = number_format((float) $value, 0, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; break; case 'INT' : $formatted=number_format((int) $value, 0, $decPoint, $thousandsSep); if ((int) $value < 0) $fontColor=$negColor; break; case 'FXR' : $formatted=number_format((float) $value, 6, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; break; case 'TWO_DECI' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; break; case 'THREE_DECI' : $formatted=number_format((float) $value, 3, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; break; case 'TWO_DECI_PERCENT' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep) . '%' ; if ((float) $value < 0) $fontColor=$negColor; break; case 'NO_DECI_PERCENT' : $formatted=number_format((float) $value, 0, $decPoint, $thousandsSep) . '%' ; if ((float) $value < 0) $fontColor=$negColor; break; case 'MNT' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; if ((float) $value> 0) $bgColor = '#00CC00'; if ((float) $value < 0) $bgColor='RED' ; break; case 'MNT_LIM' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep); // MNT_LIM uses thresholds from context (min/max) break; case 'DIFF' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep); break; case 'CROSS' : case 'CROSS_FR' : $formatted=number_format((float) $value, 2, $decPoint, $thousandsSep); if ((float) $value < 0) $fontColor=$negColor; break; case 'DATE' : case 'MDATE' : if ($value && $value !=='0000-00-00' ) { try { $dt=\Carbon\Carbon::parse($value); $formatted=$dt->format('d/m/Y'); } catch (\Exception $e) { $formatted = e($value); } } else { $formatted = ' '; } break; case 'DBDATE': if ($value && $value !== '0000-00-00') { try { $dt = \Carbon\Carbon::parse($value); $formatted = $dt->format('d/m/Y'); } catch (\Exception $e) { $formatted = e($value); } } else { $formatted = ' '; } break; case 'EDATE': if ($value && $value !== '0000-00-00') { try { $dt = \Carbon\Carbon::parse($value); $formatted = $dt->format('m/d/Y'); } catch (\Exception $e) { $formatted = e($value); } } else { $formatted = ' '; } break; case 'MTIME': if ($value) { try { $dt = \Carbon\Carbon::parse($value); $formatted = $dt->format('H:i'); } catch (\Exception $e) { $formatted = e($value); } } else { $formatted = ' '; } break; case 'FINDATE': if ($value && $value !== '0000-00-00') { try { $dt = \Carbon\Carbon::parse($value); $formatted = $dt->format('d/m/Y'); } catch (\Exception $e) { $formatted = e($value); } } else { $formatted = ' '; } break; case 'TEXT': $formatted = '
' . e($value) . '
'; break; case 'IMG': $formatted = ''; break; case 'POP_UP': $formatted = '' . e($value) . ''; break; case 'POP_UP_REPORT': $formatted = '' . e($value) . ''; break; case 'URL': $formatted = '' . e($value) . ''; break; case 'CHOICE': // Lookup from array if provided if (isset($choices) && is_array($choices) && isset($choices[$value])) { $formatted = e($choices[$value]); } else { $formatted = e($value); } break; default: $formatted = $value === '' ? ' ' : e($value); break; } } @endphp <{{ $mark }}@if($class) CLASS="{{ $class }}" @endif @if($colspan) COLSPAN="{{ $colspan }}" @endif @if($rowspan) ROWSPAN="{{ $rowspan }}" @endif @if($bgColor) BGCOLOR="{{ $bgColor }}" @endif NOWRAP ALIGN="{{ $align }}">@if($fontColor)@endif{!! $formatted !!}@if($fontColor)@endif