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 '
Sn | '; echo 'Account | '; echo 'Balance | '; echo '|
---|---|---|---|
' . $category['account_id'] . ' | '; echo '' . $category['account_name'] . ' | '; echo '' . myCurrency(getBalance($category['account_id'])) . ' | '; $BalanceTotal += getBalance($category['account_id']); echo '|
'; displayCategoryTree($category['children']); echo ' | '; echo '|||
Total | " . myCurrency($BalanceTotal) . " |