Hello,
As the title says, my question is: how I can get the values for specific ID? For example, my plugin creates a PDF that automatically fills in with information that I get using API from my CRM platform. So, what I am trying to do now, is that in my contract template I have a section where the information must be filled in with custom attributes information (NAME of the custom attribute ID 20 = VALUE of the custom attribute ID 20).
Down below is a foreach code that get me all the custom attributes at once:
foreach ($response['attributes'] as $set) {
echo "ID: {$set['id']},\r\n"
. "Client ID: {$set['clientId']},\r\n"
. "Custom Attribute ID: {$set['customAttributeId']},\r\n"
. "Name: {$set['name']},\r\n"
. "Key: {$set['key']},\r\n"
. "Value: {$set['value']},\r\n"
. "Client Zone Visible: " . ($set['clientZoneVisible'] ? "true" : "false") . "\r\n";
}
This is the message that I get from the foreach code when I am accessing the plugin page on my platform:
ID: 11, Client ID: 1238, Custom Attribute ID: 18, Name: USER, Key: user, Value: CT565244, Client Zone Visible: true ID: 12, Client ID: 1238, Custom Attribute ID: 19, Name: PAROLA, Key: parola, Value: qwerty1234, Client Zone Visible: true ID: 13, Client ID: 1238, Custom Attribute ID: 20, Name: Serie C.I., Key: serieCI, Value: KZ, Client Zone Visible: true ID: 14, Client ID: 1238, Custom Attribute ID: 21, Name: Numar C.I., Key: numarCI, Value: 565244, Client Zone Visible: true ID: 15, Client ID: 1238, Custom Attribute ID: 22, Name: CNP, Key: cnp, Value: 5010214261989, Client Zone Visible: true ID: 16, Client ID: 1238, Custom Attribute ID: 23, Name: Emis de, Key: emisDe, Value: SPCLEP Navodari, Client Zone Visible: true ID: 17, Client ID: 1238, Custom Attribute ID: 24, Name: Data emiterii, Key: dataEmiterii, Value: 2019-02-21, Client Zone Visible: true
And here is the HTML code where I want to get the name and value for custom attribute ID X:
<strong>Seria: </strong>SERIA BULETIN // CUSTOM ATTRIBUTE ID 20
<strong>NR.: </strong>NR. BULETIN // CUSTOM ATTRIBUTE ID 21
<strong>CNP: </strong>COD NUMERIC PERSONAL // CUSTOM ATTRIBUTE ID 22
Here is the code for $response
contents:
// API doRequest - Client Information & Custom Attributes
$response = UCRMAPIAccess::doRequest(sprintf('clients/%d', $clientId),
'GET',
[
'fullAddress' => $cFAddress,
'firstName' => $cFName,
'lastName' => $cLName,
'companyTaxId' => $cCompanyTaxID,
'companyRegistrationNumber' => $cCompanyRegistrationNumber,
'city' => $cCity,
'street1' => $cStreet1,
'street2' => $cStreet2,
'organizationName' => $cOrganizationName,
'invoiceStreet1' => $cInvoiceStreet1,
'invoiceStreet2' => $cInvoiceStreet2,
'invoiceCity' => $cInvoiceCity,
'invoiceZipCode' => $cInvoiceZipCode,
'attributes' => $cAttributes = [
'name' => $cAttrName,
'value' => $cAttrValue,
'key' => $cAttrKey,
'id' => $cAttributeID,
],
]
);