function get_vendor_details($id) { log_debug("vendors_manage_soap", "Executing get_vendor_details({$id})"); if (user_permissions_get("vendors_view")) { $obj_vendor = new vendor(); // sanitise input $obj_vendor->id = @security_script_input_predefined("int", $id); if (!$obj_vendor->id || $obj_vendor->id == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } // verify that the ID is valid if (!$obj_vendor->verify_id()) { throw new SoapFault("Sender", "INVALID_ID"); } // load data from DB for this vendor if (!$obj_vendor->load_data()) { throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR"); } // load vendor contact information /* TODO: API Upgrade Required Since the API spec is limited in order to retain backwards compatibility, we currently only return the information for the accounts contact and ignore the others. At a future stage, we need to extend the API specification to handle the new flexible contact capabilities. */ if (!$obj_vendor->load_data_contacts()) { throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR"); } else { // fetch the contact name $obj_vendor->data["name_contact"] = $obj_vendor->data["contacts"][0]["contact"]; // fetch first phone, email and fax records as the primaries if (!empty($obj_vendor->data["contacts"][0]["records"])) { foreach ($obj_vendor->data["contacts"][0]["records"] as $record) { if (empty($obj_vendor->data["contact_email"])) { if ($record["type"] == "email") { $obj_vendor->data["contact_email"] = $record["detail"]; } } if (empty($obj_vendor->data["contact_phone"])) { if ($record["type"] == "phone") { $obj_vendor->data["contact_phone"] = $record["detail"]; } } if (empty($obj_vendor->data["contact_fax"])) { if ($record["type"] == "fax") { $obj_vendor->data["contact_fax"] = $record["detail"]; } } } } } // to save SOAP users from having to do another lookup to find out what the name // of the tax_default is, we do a lookup here. if ($obj_vendor->data["tax_default"]) { $obj_vendor->data["tax_default_label"] = sql_get_singlevalue("SELECT name_tax as value FROM account_taxes WHERE id='" . $obj_vendor->data["tax_default"] . "'"); } // return data $return = array($obj_vendor->data["code_vendor"], $obj_vendor->data["name_vendor"], $obj_vendor->data["name_contact"], $obj_vendor->data["contact_email"], $obj_vendor->data["contact_phone"], $obj_vendor->data["contact_fax"], $obj_vendor->data["date_start"], $obj_vendor->data["date_end"], $obj_vendor->data["tax_number"], $obj_vendor->data["tax_default"], $obj_vendor->data["tax_default_label"], $obj_vendor->data["address1_street"], $obj_vendor->data["address1_city"], $obj_vendor->data["address1_state"], $obj_vendor->data["address1_country"], $obj_vendor->data["address1_zipcode"], $obj_vendor->data["address2_street"], $obj_vendor->data["address2_city"], $obj_vendor->data["address2_state"], $obj_vendor->data["address2_country"], $obj_vendor->data["address2_zipcode"], $obj_vendor->data["discount"]); return $return; } else { throw new SoapFault("Sender", "ACCESS_DENIED"); } }