5 include($path_to_root . "/includes/session.inc");
7 page(_("GL Account Classes"));
9 include($path_to_root . "/gl/includes/gl_db.inc");
11 include($path_to_root . "/includes/ui.inc");
13 if (isset($_GET['selected_id']))
15 $selected_id = $_GET['selected_id'];
17 elseif(isset($_POST['selected_id']))
19 $selected_id = $_POST['selected_id'];
23 //-----------------------------------------------------------------------------------
25 function can_process()
28 if (strlen($_POST['name']) == 0)
30 display_error( _("The account class name cannot be empty."));
38 //-----------------------------------------------------------------------------------
40 if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
46 if ($selected_id != -1)
49 update_account_class($selected_id, $_POST['name'], $_POST['Balance']);
55 add_account_class($_POST['id'], $_POST['name'], $_POST['Balance']);
57 meta_forward($_SERVER['PHP_SELF']);
61 //-----------------------------------------------------------------------------------
63 function can_delete($selected_id)
65 if ($selected_id == -1)
67 $sql= "SELECT COUNT(*) FROM ".TB_PREF."chart_types
68 WHERE class_id=$selected_id";
69 $result = db_query($sql, "could not query chart master");
70 $myrow = db_fetch_row($result);
73 display_error(_("Cannot delete this account class because GL account types have been created referring to it."));
81 //-----------------------------------------------------------------------------------
83 if (isset($_GET['delete']))
86 if (can_delete($selected_id))
88 delete_account_class($selected_id);
89 meta_forward($_SERVER['PHP_SELF']);
93 //-----------------------------------------------------------------------------------
95 $result = get_account_classes();
97 start_table($table_style);
98 $th = array(_("Class ID"), _("Class Name"), _("Balance Sheet"), "", "");
102 while ($myrow = db_fetch($result))
105 alt_table_row_color($k);
107 if ($myrow["balance_sheet"] == 0)
115 label_cell($myrow["cid"]);
116 label_cell($myrow['class_name']);
117 label_cell($bs_text);
118 edit_link_cell("selected_id=" . $myrow["cid"]);
119 delete_link_cell("selected_id=" . $myrow["cid"]. "&delete=1");
125 //-----------------------------------------------------------------------------------
127 hyperlink_no_params($_SERVER['PHP_SELF'], _("New Account Class"));
131 start_table($table_style2);
133 if ($selected_id != -1)
135 //editing an existing status code
137 $myrow = get_account_class($selected_id);
139 $_POST['id'] = $myrow["cid"];
140 $_POST['name'] = $myrow["class_name"];
141 $_POST['Balance'] = $myrow["balance_sheet"];
142 hidden('selected_id', $selected_id);
143 label_row(_("Class ID:"), $_POST['id']);
149 text_row_ex(_("Class ID:"), 'id', 3);
152 text_row_ex(_("Class Name:"), 'name', 50);
154 yesno_list_row(_("Balance Sheet:"), 'Balance', null, "", "", false);
158 submit_add_or_update_center($selected_id == -1);
162 //------------------------------------------------------------------------------------