function delete_tax($id) { log_debug("taxes", "Executing delete_tax_details({$id}, values...)"); if (user_permissions_get("accounts_taxes_write")) { $obj_tax = new tax(); /* Load SOAP Data */ $obj_tax->id = @security_script_input_predefined("int", $id); if (!$obj_tax->id || $obj_tax->id == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } /* Error Handling */ // verify tax ID if (!$obj_tax->verify_id()) { throw new SoapFault("Sender", "INVALID_ID"); } // check that the tax can be safely deleted if ($obj_tax->check_delete_lock()) { throw new SoapFault("Sender", "LOCKED"); } /* Perform Changes */ if ($obj_tax->action_delete()) { return 1; } else { throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR"); } } else { throw new SoapFault("Sender", "ACCESS DENIED"); } }
$obj_tax->data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion"); /* Error Handling */ // make sure the tax actually exists if (!$obj_tax->verify_id()) { log_write("error", "process", "The tax you have attempted to edit - " . $obj_tax->id . " - does not exist in this system."); } // make sure tax is safe to delete if ($obj_tax->check_delete_lock()) { log_write("error", "process", "This tax can not be deleted due to it being used by invoices."); } // if there was an error, go back to the entry page if ($_SESSION["error"]["message"]) { $_SESSION["error"]["form"]["tax_delete"] = "failed"; header("Location: ../../index.php?page=accounts/taxes/delete.php&id=" . $obj_tax->id); exit(0); } /* Apply Changes */ $obj_tax->action_delete(); // return to taxes list header("Location: ../../index.php?page=accounts/taxes/taxes.php"); exit(0); } else { // user does not have perms to view this page/isn't logged on error_render_noperms(); header("Location: ../index.php?page=message.php"); exit(0); }