Error editing (updating) Account Groups
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 22 Mar 2010 16:28:11 +0000 (16:28 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 22 Mar 2010 16:28:11 +0000 (16:28 +0000)
gl/includes/db/gl_db_account_types.inc
gl/manage/gl_account_classes.php
gl/manage/gl_account_types.php
includes/ui/ui_lists.inc

index a3771230116e2fc1d5d8b886216952a52c714a1c..b76b6efc81f820a41fe3497c1be7123baab950fc 100644 (file)
@@ -61,7 +61,7 @@ function get_account_types($all=false, $class_id=false, $parent=false)
        if ($class_id != false) 
                $sql .= " AND class_id=".db_escape($class_id);
        if ($parent == -1) 
-               $sql .= " AND parent <= 0";
+               $sql .= " AND (parent = '' OR parent = '-1')";
        elseif ($parent != false) 
                $sql .= " AND parent=".db_escape($parent);
        $sql .= " ORDER BY class_id, id, parent";
index 1ec62b88431965f4ab37d643fbcac3af19dfb1cf..a2d8bda46aeb7f258b115582c1bdc6cf71545c00 100644 (file)
@@ -19,7 +19,7 @@ include($path_to_root . "/gl/includes/gl_db.inc");
 
 include($path_to_root . "/includes/ui.inc");
 
-simple_page_mode(true);
+simple_page_mode(false);
 //-----------------------------------------------------------------------------------
 
 function can_process() 
@@ -50,7 +50,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        if (can_process()) 
        {
 
-       if ($selected_id != -1
+       if ($selected_id != ""
        {
                if(update_account_class($selected_id, $_POST['name'], $_POST['ctype']))
                                display_notification(_('Selected account class settings has been updated'));
@@ -69,7 +69,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
 
 function can_delete($selected_id)
 {
-       if ($selected_id == -1)
+       if ($selected_id == "")
                return false;
        if (key_in_foreign_table($selected_id, 'chart_types', 'class_id'))      
        {
@@ -97,7 +97,7 @@ if ($Mode == 'Delete')
 //-----------------------------------------------------------------------------------
 if ($Mode == 'RESET')
 {
-       $selected_id = -1;
+       $selected_id = "";
        $_POST['id']  = $_POST['name']  = $_POST['ctype'] =  '';
 }
 //-----------------------------------------------------------------------------------
@@ -138,7 +138,7 @@ end_table(1);
 
 start_table($table_style2);
 
-if ($selected_id != -1
+if ($selected_id != ""
 {
        if ($Mode == 'Edit') {
                //editing an existing status code
@@ -171,7 +171,7 @@ else
 
 end_table(1);
 
-submit_add_or_update_center($selected_id == -1, '', 'both');
+submit_add_or_update_center($selected_id == "", '', 'both');
 
 end_form();
 
index 171bf83f6504758b982d7352774830538fc6b953..6fbb9df59a0c3c64a36f13d0d1d011df3baae3a1 100644 (file)
@@ -19,7 +19,7 @@ include($path_to_root . "/gl/includes/gl_db.inc");
 
 include($path_to_root . "/includes/ui.inc");
 
-simple_page_mode(true);
+simple_page_mode(false);
 //-----------------------------------------------------------------------------------
 
 function can_process() 
@@ -56,7 +56,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        if (can_process()) 
        {
 
-       if ($selected_id != -1
+       if ($selected_id != ""
        {
                if (update_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent'], $_POST['old_id']))
                                display_notification(_('Selected account type has been updated'));
@@ -75,7 +75,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
 
 function can_delete($selected_id)
 {
-       if ($selected_id == -1)
+       if ($selected_id == "")
                return false;
        $type = db_escape($selected_id);
 
@@ -109,7 +109,7 @@ if ($Mode == 'Delete')
 }
 if ($Mode == 'RESET')
 {
-       $selected_id = -1;
+       $selected_id = "";
        $_POST['id']  = $_POST['name']  = '';
        unset($_POST['parent']);
        unset($_POST['class_id']);
@@ -132,7 +132,7 @@ while ($myrow = db_fetch($result))
 
        $bs_text = get_account_class_name($myrow["class_id"]);
 
-       if ($myrow["parent"] == '0' || $myrow["parent"] == '-1') 
+       if ($myrow["parent"] == '-1') 
        {
                $parent_text = "";
        } 
@@ -157,7 +157,7 @@ end_table(1);
 
 start_table($table_style2);
 
-if ($selected_id != -1)
+if ($selected_id != "")
 {
        if ($Mode == 'Edit') 
        {
@@ -167,15 +167,15 @@ if ($selected_id != -1)
                $_POST['id']  = $myrow["id"];
                $_POST['name']  = $myrow["name"];
                $_POST['parent']  = $myrow["parent"];
+               if ($_POST['parent'] == '-1')
+                       $_POST['parent'] == "";
                $_POST['class_id']  = $myrow["class_id"];
                hidden('selected_id', $selected_id);
                hidden('old_id', $myrow["id"]);
        }
        hidden('id');
-       text_row_ex(_("ID:"), 'id', 10);
 }
-else
-       text_row_ex(_("ID:"), 'id', 10);
+text_row_ex(_("ID:"), 'id', 10);
 text_row_ex(_("Name:"), 'name', 50);
 
 gl_account_types_list_row(_("Subgroup Of:"), 'parent', null, _("None"), true);
index a5a96b082b82e22df5d889bb7c9d0b75db909499..ca241361091c984b52ba9aab86e01998a43e4fea 100644 (file)
@@ -1530,7 +1530,7 @@ function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=f
 
 //-----------------------------------------------------------------------------------------------
 
-function gl_account_types_list($name, $selected_id=null, $all_option=false, $all_option_numeric=true)
+function gl_account_types_list($name, $selected_id=null, $all_option=false, $all=true)
 {
        global $all_items;
 
@@ -1540,26 +1540,24 @@ function gl_account_types_list($name, $selected_id=null, $all_option=false, $all
        array(
                'order' => 'class_id', 'id',
                'spec_option' =>$all_option,
-               'spec_id' => $all_option_numeric ? 0 : $all_items
+               'spec_id' => $all_items
        ) );
 }
 
-function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
-       $all_option_numeric=false)
+function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false, $all=false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
        echo "<td>";
-       echo gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
+       echo gl_account_types_list($name, $selected_id, $all_option, $all);
        echo "</td>\n";
 }
 
-function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
-       $all_option_numeric=false)
+function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,        $all=false)
 {
        echo "<tr><td class='label'>$label</td>";
        gl_account_types_list_cells(null, $name, $selected_id, $all_option,
-               $all_option_numeric);
+               $all);
        echo "</tr>\n";
 }