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 simple_page_mode(true);
14 //-----------------------------------------------------------------------------------
16 function can_process()
19 if (strlen($_POST['name']) == 0)
21 display_error( _("The account class name cannot be empty."));
29 //-----------------------------------------------------------------------------------
31 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
37 if ($selected_id != -1)
39 update_account_class($selected_id, $_POST['name'], $_POST['Balance']);
40 display_notification(_('Selected account class settings has been updated'));
44 add_account_class($_POST['id'], $_POST['name'], $_POST['Balance']);
45 display_notification(_('New account class has been added'));
51 //-----------------------------------------------------------------------------------
53 function can_delete($selected_id)
55 if ($selected_id == -1)
57 $sql= "SELECT COUNT(*) FROM ".TB_PREF."chart_types
58 WHERE class_id=$selected_id";
59 $result = db_query($sql, "could not query chart master");
60 $myrow = db_fetch_row($result);
63 display_error(_("Cannot delete this account class because GL account types have been created referring to it."));
71 //-----------------------------------------------------------------------------------
73 if ($Mode == 'Delete')
76 if (can_delete($selected_id))
78 delete_account_class($selected_id);
79 display_notification(_('Selected account class has been deleted'));
84 //-----------------------------------------------------------------------------------
88 $_POST['id'] = $_POST['name'] = $_POST['Balance'] = '';
90 //-----------------------------------------------------------------------------------
92 $result = get_account_classes();
94 start_table($table_style);
95 $th = array(_("Class ID"), _("Class Name"), _("Balance Sheet"), "", "");
99 while ($myrow = db_fetch($result))
102 alt_table_row_color($k);
104 if ($myrow["balance_sheet"] == 0)
112 label_cell($myrow["cid"]);
113 label_cell($myrow['class_name']);
114 label_cell($bs_text);
115 edit_button_cell("Edit".$myrow["cid"], _("Edit"));
116 edit_button_cell("Delete".$myrow["cid"], _("Delete"));
123 //-----------------------------------------------------------------------------------
127 start_table($table_style2);
129 if ($selected_id != -1)
131 if ($Mode == 'Edit') {
132 //editing an existing status code
133 $myrow = get_account_class($selected_id);
135 $_POST['id'] = $myrow["cid"];
136 $_POST['name'] = $myrow["class_name"];
137 $_POST['Balance'] = $myrow["balance_sheet"];
138 hidden('selected_id', $selected_id);
141 label_row(_("Class ID:"), $_POST['id']);
147 text_row_ex(_("Class ID:"), 'id', 3);
150 text_row_ex(_("Class Name:"), 'name', 50, 60);
152 yesno_list_row(_("Balance Sheet:"), 'Balance', null, "", "", false);
156 submit_add_or_update_center($selected_id == -1, '', true);
160 //------------------------------------------------------------------------------------