acc->getAccountsByCategory($accategory_id); $array = json_decode(json_encode($Accounts), true); // print_r($array);die; $tree = buildCategoryTree($array, false); function buildCategoryTree($categories, $parent_id = 0, $showZero = true) { $tree = array(); foreach ($categories as $category) { // print_r($category);die; // print_r(myCurrency(getBalance($category['account_id'])));die; $category['dr'] = getDrTotal('account_id'); $category['cr'] = getCrTotal('account_id'); if ($showZero && ($category['dr'] !== 0 || $category['cr'] !== 0)) { $tree[] = $category; } elseif (!$showZero && ($category['dr'] !== 0 && $category['cr'] !== 0)) { $tree[] = $category; } } return $tree; } function displayCategoryTree($tree) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $BalanceTotal = 0; foreach ($tree as $category) { echo ''; echo ''; echo ''; echo ''; $BalanceTotal += getBalance($category['account_id']); echo ''; if (isset($category['children']) && !empty($category['children'])) { echo ''; echo ''; echo ''; } } echo ''; echo ''; echo ""; echo '
SnAccountBalance
' . $category['account_id'] . '' . $category['account_name'] . '' . myCurrency(getBalance($category['account_id'])) . '
'; displayCategoryTree($category['children']); echo '
Total" . myCurrency($BalanceTotal) . "
'; } $html = ""; $html .= "
Ledger Details
Ledger Details Goes Here
"; $html .= ''; echo $html; ?>