function set_tax_details($id, $name_tax, $taxrate, $chartid, $taxnumber, $description, $autoenable_tax_customers, $autoenable_tax_vendors) { log_debug("accounts_taxes_manage", "Executing set_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); $obj_tax->data["name_tax"] = @security_script_input_predefined("any", $name_tax); $obj_tax->data["taxrate"] = @security_script_input_predefined("any", $taxrate); $obj_tax->data["chartid"] = @security_script_input_predefined("int", $chartid); $obj_tax->data["taxnumber"] = @security_script_input_predefined("any", $taxnumber); $obj_tax->data["description"] = @security_script_input_predefined("any", $description); $obj_tax->data["autoenable_tax_customers"] = @security_script_input_predefined("any", $autoenable_tax_customers); $obj_tax->data["autoenable_tax_vendors"] = @security_script_input_predefined("any", $autoenable_tax_vendors); foreach (array_keys($obj_tax->data) as $key) { if ($obj_tax->data[$key] == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } } /* Error Handling */ // verify tax ID (if editing an existing tax) if ($obj_tax->id) { if (!$obj_tax->verify_id()) { throw new SoapFault("Sender", "INVALID_ID"); } } // make sure we choose a unique tax name if (!$obj_tax->verify_name_tax()) { throw new SoapFault("Sender", "DUPLICATE_NAME_TAX"); } // make sure that the chartid is valid if (!$obj_tax->verify_valid_chart()) { throw new SoapFault("Sender", "INVALID_CHARTID"); } /* Perform Changes */ if ($obj_tax->action_update()) { return $obj_tax->id; } else { throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR"); } } else { throw new SoapFault("Sender", "ACCESS DENIED"); } }
// only used when adding new taxes $obj_tax->data["autoenable_tax_customers"] = @security_form_input_predefined("checkbox", "autoenable_tax_customers", 0, ""); $obj_tax->data["autoenable_tax_vendors"] = @security_form_input_predefined("checkbox", "autoenable_tax_vendors", 0, ""); $obj_tax->data["autoenable_tax_services"] = @security_form_input_predefined("checkbox", "autoenable_tax_services", 0, ""); $obj_tax->data["autoenable_tax_products"] = @security_form_input_predefined("checkbox", "autoenable_tax_products", 0, ""); /* Error Handling */ if ($obj_tax->id) { // 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 we don't choose a tax name that is already in use if (!$obj_tax->verify_name_tax()) { log_write("error", "process", "Another tax already exists with the same name - please choose a unique name."); $_SESSION["error"]["name_tax-error"] = 1; } // make sure the selected chart exists if (!$obj_tax->verify_valid_chart()) { log_write("error", "process", "The requested chart ID does not exist"); $_SESSION["error"]["chartid-error"] = 1; } // return to input page in the event of an error if ($_SESSION["error"]["message"]) { if ($obj_tax->id) { $_SESSION["error"]["form"]["tax_view"] = "failed"; header("Location: ../../index.php?page=accounts/taxes/view.php&id=" . $obj_tax->id); exit(0); } else {