$sql = "INSERT INTO ".TB_PREF."chart_types (id, name, class_id, parent)
VALUES ($id, ".db_escape($name).", $class_id, $parent)";
- db_query($sql, "could not add account type");
+ return db_query($sql);
}
function update_account_type($id, $name, $class_id, $parent)
$sql = "UPDATE ".TB_PREF."chart_types SET name=".db_escape($name).",
class_id=$class_id, parent=$parent WHERE id = $id";
- db_query($sql, "could not update account type");
+ return db_query($sql, "could not update account type");
}
function get_account_types($all=false)
$sql = "INSERT INTO ".TB_PREF."chart_class (cid, class_name, ctype)
VALUES ($id, ".db_escape($name).", $ctype)";
- db_query($sql, "could not add account type");
+ return db_query($sql);
}
function update_account_class($id, $name, $ctype)
$sql = "UPDATE ".TB_PREF."chart_class SET class_name=".db_escape($name).",
ctype=$ctype WHERE cid = $id";
- db_query($sql, "could not update account type");
+ return db_query($sql);
}
function get_account_classes($all=false)
$sql = "INSERT INTO ".TB_PREF."chart_master (account_code, account_code2, account_name, account_type)
VALUES (".db_escape($account_code).", ".db_escape($account_code2).", $account_name, $account_type)";
- db_query($sql, "could not add gl account");
+ return db_query($sql);
}
function update_gl_account($account_code, $account_name, $account_type, $account_code2)
account_type=$account_type, account_code2=".db_escape($account_code2)
." WHERE account_code = '$account_code'";
- db_query($sql, "could not update gl account");
+ return db_query($sql);
}
function delete_gl_account($code)
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)
{
- update_account_type($selected_id, $_POST['name'], $_POST['class_id'], $_POST['parent']);
- display_notification(_('Selected account type has been updated'));
+ if (update_account_type($selected_id, $_POST['name'], $_POST['class_id'], $_POST['parent']))
+ display_notification(_('Selected account type has been updated'));
}
else
{
- add_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent']);
- display_notification(_('New account type has been added'));
+ if (add_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent'])) {
+ display_notification(_('New account type has been added'));
+ $Mode = 'RESET';
+ }
}
- $Mode = 'RESET';
}
}
if (isset($_POST['_AccountList_update']))
{
$_POST['selected_account'] = $_POST['AccountList'];
+ unset($_POST['account_code']);
}
if (isset($_POST['selected_account']))
$_POST['account_code'] = strtoupper($_POST['account_code']);
if ($selected_account)
{
- update_gl_account($_POST['account_code'], $_POST['account_name'],
- $_POST['account_type'], $_POST['account_code2']);
- update_record_status($_POST['account_code'], $_POST['inactive'],
- 'chart_master', 'account_code');
- $Ajax->activate('account_code'); // in case of status change
- display_notification(_("Account data has been updated."));
+ if (update_gl_account($_POST['account_code'], $_POST['account_name'],
+ $_POST['account_type'], $_POST['account_code2'])) {
+ update_record_status($_POST['account_code'], $_POST['inactive'],
+ 'chart_master', 'account_code');
+ $Ajax->activate('account_code'); // in case of status change
+ display_notification(_("Account data has been updated."));
+ }
}
else
{
- add_gl_account($_POST['account_code'], $_POST['account_name'],
- $_POST['account_type'], $_POST['account_code2']);
- $selected_account = $_POST['AccountList'] = $_POST['account_code'];
- display_notification(_("New account has been added."));
+ if (add_gl_account($_POST['account_code'], $_POST['account_name'],
+ $_POST['account_type'], $_POST['account_code2']))
+ {
+ display_notification(_("New account has been added."));
+ $selected_account = $_POST['AccountList'] = $_POST['account_code'];
+ }
}
$Ajax->activate('_page_body');
}
if (can_delete($selected_account))
{
delete_gl_account($selected_account);
- $selected_account = $_POST['account_code'] = $_POST['AccountList'] = '';
+ $selected_account = $_POST['AccountList'] = '';
display_notification(_("Selected account has been deleted"));
+ unset($_POST['account_code']);
$Ajax->activate('_page_body');
}
}
label_row(_("Account Code:"), $_POST['account_code']);
}
-else
+else
{
- $_POST['account_code'] = $_POST['account_code2'] = '';
- $_POST['account_name'] = $_POST['account_type'] = '';
- $_POST['inactive'] = 0;
+ if (!isset($_POST['account_code'])) {
+ $_POST['account_code'] = $_POST['account_code2'] = '';
+ $_POST['account_name'] = $_POST['account_type'] = '';
+ $_POST['inactive'] = 0;
+ }
text_row_ex(_("Account Code:"), 'account_code', 11);
}