function btn_delete($id = 0) { global $db, $messageStack; if ($this->security_id < 4) { $messageStack->add(ERROR_NO_PERMISSION, 'error'); return false; } // error check // Departments have no pre-requisites to check prior to delete // OK to delete $db->Execute("delete from " . $this->db_table . " where id = '" . $this->id . "'"); modify_account_history_records($this->id, $add_acct = false); gen_add_audit_log(HR_LOG_DEPARTMENTS . TEXT_DELETE, $this->id); return true; }
function btn_delete() { global $db, $messageStack; if ($this->security_id < 4) { $messageStack->add_session(ERROR_NO_PERMISSION, 'error'); return false; } $id = db_prepare_input($_POST['rowSeq']); // Don't allow delete if there is account activity for this account $sql = "select max(debit_amount) as debit, max(credit_amount) as credit, max(beginning_balance) as beg_bal \r\n\t\tfrom " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " where account_id = '" . $id . "'"; $result = $db->Execute($sql); if ($result->fields['debit'] != 0 || $result->fields['credit'] != 0 || $result->fields['beg_bal'] != 0) { $messageStack->add(GL_ERROR_CANT_DELETE, 'error'); return false; } // OK to delete $db->Execute("delete from " . $this->db_table . " where id = '" . $id . "'"); modify_account_history_records($id, $add_acct = false); gen_add_audit_log(GL_LOG_CHART_OF_ACCOUNTS . TEXT_DELETE, $id); return true; }