From: Joe Hunt Date: Mon, 22 Mar 2010 16:28:11 +0000 (+0000) Subject: Error editing (updating) Account Groups X-Git-Tag: v2.4.2~19^2~933 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=ee7852fefd8a0f5f47f7a3930cc6c35c4b4582ad;p=fa-stable.git Error editing (updating) Account Groups --- diff --git a/gl/includes/db/gl_db_account_types.inc b/gl/includes/db/gl_db_account_types.inc index a3771230..b76b6efc 100644 --- a/gl/includes/db/gl_db_account_types.inc +++ b/gl/includes/db/gl_db_account_types.inc @@ -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"; diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index 1ec62b88..a2d8bda4 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -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(); diff --git a/gl/manage/gl_account_types.php b/gl/manage/gl_account_types.php index 171bf83f..6fbb9df5 100644 --- a/gl/manage/gl_account_types.php +++ b/gl/manage/gl_account_types.php @@ -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); diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index a5a96b08..ca241361 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -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 "$label\n"; echo ""; - 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 "\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 "$label"; gl_account_types_list_cells(null, $name, $selected_id, $all_option, - $all_option_numeric); + $all); echo "\n"; }