X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Finquiry%2Fbalance_sheet.php;h=e2cd107536108864a5b4e74d0b9724d2eb9545d5;hb=8d3c6352a53d725389de634469ca2383a4baa867;hp=c08183d74d5a47d915d628087795c1b60ce03af9;hpb=648933d504efd675f49e4e07942ebafb9492745d;p=fa-stable.git diff --git a/gl/inquiry/balance_sheet.php b/gl/inquiry/balance_sheet.php index c08183d7..e2cd1075 100644 --- a/gl/inquiry/balance_sheet.php +++ b/gl/inquiry/balance_sheet.php @@ -21,7 +21,7 @@ include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/gl/includes/gl_db.inc"); $js = ""; -if ($use_date_picker) +if (user_use_date_picker()) $js = get_js_date_picker(); page(_($help_context = "Balance Sheet Drilldown"), false, false, "", $js); @@ -38,44 +38,46 @@ if (isset($_GET["TransFromDate"])) $_POST["TransFromDate"] = $_GET["TransFromDate"]; if (isset($_GET["TransToDate"])) $_POST["TransToDate"] = $_GET["TransToDate"]; +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, $convert, $drilldown, $path_to_root) +function display_type ($type, $typename, $from, $to, $convert, $dimension, $dimension2, $drilldown) { - global $levelptr, $k; + global $path_to_root, $levelptr, $k; - $dimension = $dimension2 = 0; $acctstotal = 0; $typestotal = 0; //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); - while ($account=db_fetch($result)) - { - $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2); - $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); - if (!$prev_balance && !$curr_balance) - continue; - - if ($drilldown && $levelptr == 0) - { - $url = "" . $account['account_code'] - ." ". $account['account_name'] .""; - - start_row("class='stockmankobg'"); - label_cell($url); - amount_cell(($curr_balance + $prev_balance) * $convert); - end_row(); - } - - $acctstotal += $curr_balance + $prev_balance; - } + while ($account=db_fetch($result)) + { + $net_balance = get_gl_trans_from_to("", $to, $account["account_code"], $dimension, $dimension2); + if (!$net_balance) + continue; + + if ($drilldown && $levelptr == 0) + { + $url = "" . $account['account_code'] + ." ". $account['account_name'] .""; + + start_row("class='stockmankobg'"); + label_cell($url); + amount_cell(($net_balance) * $convert); + end_row(); + } + + $acctstotal += $net_balance; + } $levelptr = 1; @@ -84,7 +86,7 @@ function display_type ($type, $typename, $from, $to, $convert, $drilldown, $path while ($accounttype=db_fetch($result)) { $typestotal += display_type($accounttype["id"], $accounttype["name"], $from, $to, - $convert, $drilldown, $path_to_root); + $convert, $dimension, $dimension2, $drilldown); } //Display Type Summary if total is != 0 @@ -97,11 +99,15 @@ function display_type ($type, $typename, $from, $to, $convert, $drilldown, $path amount_cell(($acctstotal + $typestotal) * $convert); end_row(); } - elseif ($drilldown && $type != $_POST["AccGrp"]) + //START Patch#1 : Display only direct child types + $acctype1 = get_account_type($type); + $parent1 = $acctype1["parent"]; + if ($drilldown && $parent1 == $_POST["AccGrp"]) + //END Patch#2 { $url = "" . $typename .""; + . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 + . "&AccGrp=" . $type ."'>" . $type . " " . $typename .""; alt_table_row_color($k); label_cell($url); @@ -114,8 +120,13 @@ function display_type ($type, $typename, $from, $to, $convert, $drilldown, $path function inquiry_controls() { - start_table("class='tablestyle_noborder'"); + $dim = get_company_pref('use_dimension'); + start_table(TABLESTYLE_NOBORDER); date_cells(_("As at:"), 'TransToDate'); + if ($dim >= 1) + dimensions_list_cells(_("Dimension")." 1:", 'Dimension', null, true, " ", false, 1); + if ($dim > 1) + dimensions_list_cells(_("Dimension")." 2:", 'Dimension2', null, true, " ", false, 2); submit_cells('Show',_("Show"),'','', 'default'); end_table(); @@ -125,13 +136,17 @@ function inquiry_controls() function display_balance_sheet() { - global $comp_path, $path_to_root, $table_style; + global $path_to_root; $from = begin_fiscalyear(); $to = $_POST['TransToDate']; - $dim = get_company_pref('use_dimension'); - $dimension = $dimension2 = 0; + if (!isset($_POST['Dimension'])) + $_POST['Dimension'] = 0; + if (!isset($_POST['Dimension2'])) + $_POST['Dimension2'] = 0; + $dimension = $_POST['Dimension']; + $dimension2 = $_POST['Dimension2']; $lconvert = $econvert = 1; if (isset($_POST["AccGrp"]) && (strlen($_POST['AccGrp']) > 0)) $drilldown = 1; // Deeper Level @@ -140,7 +155,7 @@ function display_balance_sheet() div_start('balance_tbl'); - start_table("width=30% $table_style"); + start_table(TABLESTYLE, "width='30%'"); if (!$drilldown) //Root Level { @@ -148,33 +163,32 @@ function display_balance_sheet() $lclose = 0.0; $calculateclose = 0.0; - $parent = -1; - //Get classes for BS $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $classclose = 0.0; - $convert = get_class_type_convert($class["ctype"]); + $convert = get_class_type_convert($class["ctype"]); $ctype = $class["ctype"]; - $classname = $class["class_name"]; //Print Class Name table_section_title($class["class_name"]); //Get Account groups/types under this group/type $typeresult = get_account_types(false, $class['cid'], -1); - + + $k = 0; while ($accounttype=db_fetch($typeresult)) { $TypeTotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, - $convert, $drilldown, $path_to_root); + $convert, $dimension, $dimension2, $drilldown); //Print Summary if ($TypeTotal != 0 ) { $url = "" . $accounttype['name'] .""; + . $from . "&TransToDate=" . $to . "&Dimension=" . $dimension . "&Dimension2=" . $dimension2 + . "&AccGrp=" . $accounttype['id'] ."'>" . $accounttype['id']." ".$accounttype['name'] .""; alt_table_row_color($k); label_cell($url); amount_cell($TypeTotal * $convert); @@ -207,7 +221,7 @@ function display_balance_sheet() $calculateclose *= -1; //Final Report Summary $url = ""._('Calculated Return').""; start_row("class='inquirybg' style='font-weight:bold'"); @@ -232,10 +246,10 @@ function display_balance_sheet() $convert = get_class_type_convert($class["ctype"]); //Print Class Name - table_section_title(get_account_type_name($_POST["AccGrp"])); + table_section_title($_POST["AccGrp"]. " " . get_account_type_name($_POST["AccGrp"])); $classclose = display_type($accounttype["id"], $accounttype["name"], $from, $to, - $convert, $drilldown, $path_to_root); + $convert, $dimension, $dimension2, $drilldown); } end_table(1); // outer table @@ -254,5 +268,3 @@ end_form(); end_page(); -?> -