Example #1
0
 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");
     }
 }
Example #2
0
    }
    // 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 {
            $_SESSION["error"]["form"]["tax_add"] = "failed";
            header("Location: ../../index.php?page=accounts/taxes/add.php");
            exit(0);
        }
    }
    /*
    	Apply Changes
    */
    $obj_tax->action_update();
    // display updated details
    header("Location: ../../index.php?page=accounts/taxes/view.php&id=" . $obj_tax->id);
    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);
}