$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
-page(_("GL Account Classes"));
+page(_($help_context = "GL Account Classes"));
include($path_to_root . "/gl/includes/gl_db.inc");
function can_process()
{
global $use_oldstyle_convert;
- if (!is_numeric($_POST['id']))
+ /*if (!is_numeric($_POST['id']))
{
display_error( _("The account class ID must be numeric."));
set_focus('id');
return false;
- }
+ }*/
if (strlen($_POST['name']) == 0)
{
display_error( _("The account class name cannot be empty."));
if ($selected_id != -1)
{
- update_account_class($selected_id, $_POST['name'], $_POST['ctype']);
- display_notification(_('Selected account class settings has been updated'));
+ if(update_account_class($selected_id, $_POST['name'], $_POST['ctype']))
+ display_notification(_('Selected account class settings has been updated'));
}
else
{
- add_account_class($_POST['id'], $_POST['name'], $_POST['ctype']);
- display_notification(_('New account class has been added'));
+ if(add_account_class($_POST['id'], $_POST['name'], $_POST['ctype'])) {
+ display_notification(_('New account class has been added'));
+ $Mode = 'RESET';
+ }
}
- $Mode = 'RESET';
}
}
{
if ($selected_id == -1)
return false;
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."chart_types
- WHERE class_id=$selected_id";
- $result = db_query($sql, "could not query chart master");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'chart_types', 'class_id'))
{
display_error(_("Cannot delete this account class because GL account types have been created referring to it."));
return false;
if ($selected_id != -1)
{
- if ($Mode == 'Edit') {
- //editing an existing status code
- $myrow = get_account_class($selected_id);
-
- $_POST['id'] = $myrow["cid"];
- $_POST['name'] = $myrow["class_name"];
- if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
- $_POST['ctype'] = ($myrow["ctype"] >= CL_ASSETS && $myrow["ctype"] < CL_INCOME ? 1 : 0);
- else
- $_POST['ctype'] = $myrow["ctype"];
- hidden('selected_id', $selected_id);
- }
+ if ($Mode == 'Edit') {
+ //editing an existing status code
+ $myrow = get_account_class($selected_id);
+
+ $_POST['id'] = $myrow["cid"];
+ $_POST['name'] = $myrow["class_name"];
+ if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1)
+ $_POST['ctype'] = ($myrow["ctype"] >= CL_ASSETS && $myrow["ctype"] < CL_INCOME ? 1 : 0);
+ else
+ $_POST['ctype'] = $myrow["ctype"];
+ hidden('selected_id', $selected_id);
+ }
hidden('id');
label_row(_("Class ID:"), $_POST['id']);