. ***********************************************************************/ $page_security = 'SA_GLANALYTIC'; $path_to_root="../.."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/gl/includes/gl_db.inc"); $js = ""; if ($use_date_picker) $js = get_js_date_picker(); page(_($help_context = "Profit & Loss Drilldown"), false, false, "", $js); //---------------------------------------------------------------------------------------------------- // Ajax updates if (get_post('Show')) { $Ajax->activate('pl_tbl'); } if (isset($_GET["TransFromDate"])) $_POST["TransFromDate"] = $_GET["TransFromDate"]; if (isset($_GET["TransToDate"])) $_POST["TransToDate"] = $_GET["TransToDate"]; if (isset($_GET["Compare"])) $_POST["Compare"] = $_GET["Compare"]; if (isset($_GET["Dimension"])) $_POST["Dimension"] = $_GET["Dimension"]; if (isset($_GET["Dimension2"])) $_POST["Dimension2"] = $_GET["Dimension2"]; if (isset($_GET["AccGrp"])) $_POST["AccGrp"] = $_GET["AccGrp"]; //---------------------------------------------------------------------------------------------------- function display_type ($type, $typename, $from, $to, $begin, $end, $compare, $convert, &$dec, &$pdec, &$rep, $dimension=0, $dimension2=0, $drilldown, $path_to_root) { global $levelptr, $k; $code_per_balance = 0; $code_acc_balance = 0; $per_balance_total = 0; $acc_balance_total = 0; unset($totals_arr); $totals_arr = array(); //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account=db_fetch($result)) { $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); if ($compare == 2) $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); else $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2); if (!$per_balance && !$acc_balance) continue; if ($drilldown && $levelptr == 0) { $url = "" . $account['account_code'] ." ". $account['account_name'] .""; start_row("class='stockmankobg'"); label_cell($url); amount_cell($per_balance * $convert); amount_cell($acc_balance * $convert); amount_cell(Achieve($per_balance, $acc_balance)); end_row(); } $code_per_balance += $per_balance; $code_acc_balance += $acc_balance; } $levelptr = 1; //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype=db_fetch($result)) { $totals_arr = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec, $pdec, $rep, $dimension, $dimension2, $drilldown, $path_to_root); $per_balance_total += $totals_arr[0]; $acc_balance_total += $totals_arr[1]; } //Display Type Summary if total is != 0 if (($code_per_balance + $per_balance_total + $code_acc_balance + $acc_balance_total) != 0) { if ($drilldown && $type == $_POST["AccGrp"]) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_('Total') . " " . $typename); amount_cell(($code_per_balance + $per_balance_total) * $convert); amount_cell(($code_acc_balance + $acc_balance_total) * $convert); amount_cell(Achieve(($code_per_balance + $per_balance_total), ($code_acc_balance + $acc_balance_total))); end_row(); } //START Patch#1 : Display only direct child types $acctype1 = get_account_type($type); $parent1 = $acctype1["parent"]; if ($drilldown && $parent1 == $_POST["AccGrp"]) //END Patch#2 //elseif ($drilldown && $type != $_POST["AccGrp"]) { $url = "" . $type . " " . $typename .""; alt_table_row_color($k); label_cell($url); amount_cell(($code_per_balance + $per_balance_total) * $convert); amount_cell(($code_acc_balance + $acc_balance_total) * $convert); amount_cell(Achieve(($code_per_balance + $per_balance_total), ($code_acc_balance + $acc_balance_total))); end_row(); } } $totals_arr[0] = $code_per_balance + $per_balance_total; $totals_arr[1] = $code_acc_balance + $acc_balance_total; return $totals_arr; } function Achieve($d1, $d2) { if ($d1 == 0 && $d2 == 0) return 0; elseif ($d2 == 0) return 999; $ret = ($d1 / $d2 * 100.0); if ($ret > 999) $ret = 999; return $ret; } function inquiry_controls() { $dim = get_company_pref('use_dimension'); start_table(TABLESTYLE_NOBORDER); date_cells(_("From:"), 'TransFromDate', '', null, -30); date_cells(_("To:"), 'TransToDate'); //Compare Combo global $sel; $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget")); echo "