Fix undefined variable - use \ not \

BUGFIX: Uncaught SyntaxError expected expression, got ')'

PROBLEM: JavaScript syntax error on page load caused by undefined PHP variable

ROOT CAUSE: Controller passes 'complaint_rows' to view but JavaScript code
tried to use \ (camelCase). PHP is case-sensitive, so:
- Controller: 'complaint_rows' => \
- View variable name: \ (snake_case)
- Used in view: \ (wrong!)

When \ was undefined, the !empty() check failed and PHP
tried to iterate over undefined variable, generating malformed JavaScript
that caused syntax errors.

SOLUTION: Changed \ to \ in foreach loop

Now the existing complaints will load correctly from database into
the selectedDischargeComplaints JavaScript array.
This commit is contained in:
DevSoftTech Server 2026-06-06 05:58:04 +05:30
parent dde54ab80b
commit f6749d2664

View File

@ -1668,9 +1668,9 @@ $allergyStatusNoKnown = in_array($allergyStatusNormalized, ['no known drug aller
function initDischargeComplaintsTable() {
// Load existing complaints from PHP (if any)
<?php if (!empty($complaintRows)): ?>
<?php if (!empty($complaint_rows)): ?>
selectedDischargeComplaints = [
<?php foreach ($complaintRows as $row): ?>
<?php foreach ($complaint_rows as $row): ?>
{
id: <?= (int) ($row['id'] ?? 0) ?>,
term: <?= json_encode((string) ($row['comp_report'] ?? '')) ?>,