$totaleq_lib2 = 0;
 while ($row = $xoopsDB->fetchArray($query)) {
     $accountcode_full = $row['accountcode_full'];
     $accounts_name = $row['accounts_name'];
     $placeholder = $row['placeholder'];
     $accounts_id = $row['accounts_id'];
     $classtype = $row['classtype'];
     $treelevel = $row['treelevel'];
     $accounts_nameori = $row['accounts_name'];
     //$lastbalance1=$acc->getAccountLastBalanceOnPeriod($periodfrom_id,$accounts_id);
     //$lastbalance2=$acc->getAccountLastBalanceOnPeriod($periodto_id,$accounts_id);
     if ($placeholder == 0 || $placeholder == 1 && $treelevel < $reportlevel) {
         $lastbalance1 = $acc->getAccountLastBalanceOnPeriod($periodfrom_id, $accounts_id);
         $lastbalance2 = $acc->getAccountLastBalanceOnPeriod($periodto_id, $accounts_id);
     } else {
         $lastbalance1 = $acc->getAccountsPeriodLastBalanceSheet($periodfrom_id, $accounts_id);
         $lastbalance2 = $acc->getAccountsPeriodLastBalanceSheet($periodto_id, $accounts_id);
     }
     if ($showaccountcode == "on") {
         $accounts_name = $accountcode_full . '-' . $accounts_name;
     }
     $bracket1 = "";
     $bracket2 = "";
     if ($placeholder == 0) {
         if ($currentcategory == "5A") {
             if ($lastbalance1 < 0) {
                 $displayamt1 = number_format(abs($lastbalance1), 2);
                 $bracket1 = "(-)";
                 //$displayamt="(-)$displayamt";
             } else {
                 $displayamt1 = number_format(abs($lastbalance1), 2);
 if ($placeholder == 0) {
     if ($currentcategory == "5A") {
         if ($lastbalance < 0) {
             $displayamt = changeNegativeNumberFormat(abs($lastbalance), 2);
             $bracket = "(-)";
             //$displayamt="(-)$displayamt";
         } else {
             $displayamt = changeNegativeNumberFormat(abs($lastbalance), 2);
         }
     } else {
         $displayamt = changeNegativeNumberFormat(abs($lastbalance), 2);
     }
 } elseif ($placeholder == 1 && $treelevel < $reportlevel) {
     $displayamt = "";
 } else {
     $displayamt = $acc->getAccountsPeriodLastBalanceSheet($periodfrom_id, $accounts_id);
     $displayamt = changeNegativeNumberFormat($displayamt, 2);
 }
 if ($treelevel == 1) {
     $prefix = "";
 } elseif ($treelevel == 2) {
     $prefix = "  ";
 } elseif ($treelevel == 3) {
     $prefix = "    ";
 } elseif ($treelevel == 4) {
     $prefix = "       ";
 }
 if ($showplacefolderindicator == 1 && $placeholder == 1) {
     $displaytext = $prefix . "[" . $accounts_name . "]";
 } else {
     $displaytext = $prefix . $accounts_name;