Account Class/Group drill down added according to Apmuthu.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 27 Nov 2017 08:37:22 +0000 (09:37 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 27 Nov 2017 08:37:22 +0000 (09:37 +0100)
gl/manage/gl_account_classes.php
gl/manage/gl_account_types.php
gl/manage/gl_accounts.php
includes/ui/ui_lists.inc

index 512887816bec2fcb1bc6c5bfc4639e851c595143..a08a17e4652e40bdc22a97819daec91f6afaec68 100644 (file)
@@ -119,7 +119,7 @@ while ($myrow = db_fetch($result))
        alt_table_row_color($k);
 
        label_cell($myrow["cid"]);
-       label_cell($myrow['class_name']);
+       label_cell('<a href="./gl_account_types.php?cid='.$myrow["cid"].'">'.$myrow['class_name'].'</a>');
        if (isset($SysPrefs->use_oldstyle_convert) && $SysPrefs->use_oldstyle_convert == 1)
        {
                $myrow['ctype'] = ($myrow["ctype"] >= CL_ASSETS && $myrow["ctype"] < CL_INCOME ? 1 : 0);
index 0a1791bc97efd5d18ef09d24c2a9202c9772243e..1358cae8d98dc1daccbac5efa4d0a9c599560434 100644 (file)
@@ -19,6 +19,9 @@ include($path_to_root . "/gl/includes/gl_db.inc");
 
 include($path_to_root . "/includes/ui.inc");
 
+if (isset($_GET["cid"]))
+       $_POST["cid"] = $_GET["cid"];   
+
 simple_page_mode(false);
 //-----------------------------------------------------------------------------------
 
@@ -119,8 +122,11 @@ if ($Mode == 'RESET')
        unset($_POST['class_id']);
 }
 //-----------------------------------------------------------------------------------
-
-$result = get_account_types(check_value('show_inactive'));
+$filter_cid = (isset($_POST["cid"]));
+if ($filter_cid)
+       $result = get_account_types(check_value('show_inactive'), $_POST["cid"]);
+else
+       $result = get_account_types(check_value('show_inactive'));
 
 start_form();
 start_table(TABLESTYLE);
@@ -146,7 +152,7 @@ while ($myrow = db_fetch($result))
        }
 
        label_cell($myrow["id"]);
-       label_cell($myrow["name"]);
+       label_cell('<a href="./gl_accounts.php?id='.$myrow["id"].'">'.$myrow["name"].'</a>');
        label_cell($parent_text);
        label_cell($bs_text);
        inactive_control_cell($myrow["id"], $myrow["inactive"], 'chart_types', 'id');
@@ -188,7 +194,10 @@ text_row_ex(_("Name:"), 'name', 50);
 
 gl_account_types_list_row(_("Subgroup Of:"), 'parent', null, _("None"), true);
 
-class_list_row(_("Class:"), 'class_id', null);
+if ($filter_cid)
+       class_list_row(_("Class:"), 'class_id', $_POST['cid']);
+else
+       class_list_row(_("Class:"), 'class_id', null);
 
 end_table(1);
 
index 5bda0dcdff4047d4e6daa5d6b1886fc0b3e8556c..9d7e09189b3378a675d9aaefc634ae5c11c3f679 100644 (file)
@@ -26,6 +26,9 @@ include_once($path_to_root . "/includes/data_checks.inc");
 
 check_db_has_gl_account_groups(_("There are no account groups defined. Please define at least one account group before entering accounts."));
 
+if (isset($_GET["id"]))
+       $_POST["id"] = $_GET["id"];     
+
 //-------------------------------------------------------------------------------------
 
 if (isset($_POST['_AccountList_update'])) 
@@ -190,6 +193,7 @@ if (isset($_POST['delete']))
 } 
 
 //-------------------------------------------------------------------------------------
+$filter_id = (isset($_POST["id"]));
 
 start_form();
 
@@ -197,8 +201,10 @@ if (db_has_gl_accounts())
 {
        start_table(TABLESTYLE_NOBORDER);
        start_row();
-    gl_all_accounts_list_cells(null, 'AccountList', null, false, false,
-               _('New account'), true, check_value('show_inactive'));
+       if ($filter_id)
+               gl_all_accounts_list_cells(null, 'AccountList', null, false, false, _('New account'), true, check_value('show_inactive'), $_POST['id']);
+       else
+               gl_all_accounts_list_cells(null, 'AccountList', null, false, false, _('New account'), true, check_value('show_inactive'));
        check_cells(_("Show inactive:"), 'show_inactive', null, true);
        end_row();
        end_table();
@@ -240,6 +246,7 @@ else
                $_POST['account_code'] = $_POST['account_code2'] = '';
                $_POST['account_name']  = $_POST['account_type'] = '';
                $_POST['inactive'] = 0;
+               if ($filter_id) $_POST['account_type'] = $_POST['id'];
        }
        text_row_ex(_("Account Code:"), 'account_code', 15);
 }
index 351fc5da075dc0c5c3c8bd543d57b888aceaa9e6..eab6f4fa7cf5d58e09528184931a00805ba99f36 100644 (file)
@@ -1805,7 +1805,7 @@ function gl_account_types_list_row($label, $name, $selected_id=null, $all_option
 
 //-----------------------------------------------------------------------------------------------
 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
-       $cells=false, $all_option=false, $submit_on_change=false, $all=false)
+       $cells=false, $all_option=false, $submit_on_change=false, $all=false, $type_id=false)
 {
        if ($skip_bank_accounts)
                $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
@@ -1818,6 +1818,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals
                $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
                        FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
                        WHERE chart.account_type=type.id";
+       if ($type_id ) $sql .= " AND chart.account_type=".db_escape($type_id);
 
        return combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
                array(
@@ -1845,22 +1846,22 @@ function _format_account($row)
 
 function gl_all_accounts_list_cells($label, $name, $selected_id=null, 
        $skip_bank_accounts=false, $cells=false, $all_option=false, 
-       $submit_on_change=false, $all=false)
+       $submit_on_change=false, $all=false, $type_id=false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
        echo "<td>";
        echo gl_all_accounts_list($name, $selected_id, 
-               $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all);
+               $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all, $type_id);
        echo "</td>\n";
 }
 
 function gl_all_accounts_list_row($label, $name, $selected_id=null, 
-       $skip_bank_accounts=false, $cells=false, $all_option=false)
+       $skip_bank_accounts=false, $cells=false, $all_option=false, $type_id=false)
 {
        echo "<tr><td class='label'>$label</td>";
        gl_all_accounts_list_cells(null, $name, $selected_id, 
-               $skip_bank_accounts, $cells, $all_option);
+               $skip_bank_accounts, $cells, $all_option, $type_id);
        echo "</tr>\n";
 }