";
foreach ($treeData as $node) {
if ($node['parent_id'] == $parentId) {
$html .= "
";
$html .= "" . $node['text'] . "";
// Check if the node has children
$hasChildren = in_array($node['id'], array_column($treeData, 'parent_id'));
// Add a toggle button if there are children
if ($hasChildren) {
$html .= "";
}
// Recursively build child nodes
$html .= buildTree($treeData, $node['id'], $collapseAll);
$html .= "
";
}
}
$html .= "
";
return $html;
}
$sql="";
if($_SESSION["language"]=="English")
{
$sql = "SELECT code as id, en_account_name label, en_account_name text,
concat('AccountsChart_list.php?q=(code~equal~',code,')&c=',code) link,
parent_code as parent_id
FROM acc_accounts_chart
ORDER BY code";
echo "";
echo ' ';
echo "";
}
else if($_SESSION["language"]=="Arabic")
{
$sql ="SELECT code as id, ar_account_name label, ar_account_name text,
concat('AccountsChart_list.php?q=(code~equal~',code,')&c=',code) link,
parent_code as parent_id
FROM acc_accounts_chart
ORDER BY code";
echo "";
echo ' ';
echo "";
}
echo "
";
$rs = CustomQuery($sql);
$treeData = array();
while ($row = db_fetch_array($rs)) {
$treeData[] = $row;
}
echo buildTree($treeData);