display_error(_("This account group id is already in use.")); set_focus('id'); return false; } //if (strcmp($_POST['id'], $_POST['parent']) == 0) if ($_POST['id'] === $_POST['parent']) { display_error(_("You cannot set an account group to be a subgroup of itself.")); return false; } return true; } //----------------------------------------------------------------------------------- if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { if (can_process($selected_id)) { 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')); } } else { if (add_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent'])) { display_notification(_('New account type has been added')); } } $Mode = 'RESET'; } } //----------------------------------------------------------------------------------- function can_delete($type) { if ($type == "") { return false;
if (strlen($_POST['name']) == 0) { display_error(tr("The account group name cannot be empty.")); set_focus('name'); return false; } if (isset($selected_id) && $selected_id == $_POST['parent']) { display_error(tr("You cannot set an account group to be a subgroup of itself.")); return false; } return true; } //----------------------------------------------------------------------------------- if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { if (can_process()) { if ($selected_id != "") { update_account_type($selected_id, $_POST['name'], $_POST['class_id'], $_POST['parent']); } else { add_account_type($_POST['name'], $_POST['class_id'], $_POST['parent']); } meta_forward($_SERVER['PHP_SELF']); } } //----------------------------------------------------------------------------------- function can_delete($selected_id) { if ($selected_id == "") { return false; } $sql = "SELECT COUNT(*) FROM chart_master\n\t\tWHERE account_type={$selected_id}"; $result = db_query($sql, "could not query chart master"); $myrow = db_fetch_row($result);