本文整理汇总了PHP中api::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP api::hasErrors方法的具体用法?PHP api::hasErrors怎么用?PHP api::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::hasErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCustomer
/**
* Updates a customer at Acumulus
* @param $vars : $vars from the hook for API credentials
* @param $clientid : clientid to update
* @param null $customerid : customerid at Acumulus to update
* @throws Exception
* @return $customerid : new/updated customerid at Acumulus
*/
function updateCustomer($vars, $clientid, $customerid = null)
{
global $whmcs;
$whmcs->load_function('invoice');
$clientQuery = mysql_query('SELECT tblclients.*, tblcustomfieldsvalues.value AS vatnumber FROM tblclients LEFT JOIN tblcustomfieldsvalues ON tblclients.id = tblcustomfieldsvalues.relid AND tblcustomfieldsvalues.fieldid = (SELECT id FROM tblcustomfields WHERE type = "client" AND fieldname = "' . $vars['vat_field'] . '" LIMIT 1) WHERE tblclients.id = ' . $clientid . ' LIMIT 1');
if (mysql_num_rows($clientQuery) != 1) {
throw new Exception('Failed to receive client ' . $clientid);
}
$clientFetch = mysql_fetch_assoc($clientQuery);
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('contacts')->setAction('contact_manage');
if (isset($vars['debug']) && $vars['debug'] == 'on') {
$api->enableDebug($vars['debug_email']);
}
if ($clientFetch['acumulusid'] != null) {
$api->setParam('contact/contactid', $clientFetch['acumulusid']);
}
if ($customerid != null) {
$api->setParam('contact/contactid', $customerid);
}
if ($clientFetch['country'] == 'NL') {
$api->setParam('contact/contactlocationcode', 1);
} elseif (inEurope($clientFetch['country'])) {
$api->setParam('contact/contactlocationcode', 2);
} else {
$api->setParam('contact/contactlocationcode', 3);
}
$taxData = getTaxRate(1, $clientQuery['state'], $clientQuery['country']);
$api->setParams(array('contact' => array('contactemail' => $clientFetch['email'], 'contacttype' => 1, 'overwriteifexists' => 1, 'contactname1' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'], 'contactname2' => '', 'contactperson' => '', 'contactsalutation' => '', 'contactaddress1' => $clientFetch['address1'], 'contactaddress2' => $clientFetch['address2'], 'contactpostalcode' => $clientFetch['postcode'], 'contactcity' => $clientFetch['city'], 'contactcountrycode' => inEurope($clientFetch['country']) ? $clientFetch['country'] : '', 'contactvatnumber' => $clientFetch['vatnumber'], 'contactvatratebase' => $clientFetch['taxexempt'] == 'on' ? -1 : round($taxData['rate']), 'contacttelephone' => $clientFetch['phonenumber'], 'contactfax' => '', 'contactsepaincassostatus' => 'FRST', 'contactinvoicetemplateid' => '', 'contactstatus' => 1)));
if (!empty($clientFetch['companyname'])) {
$api->setParams(array('contact' => array('contactname1' => $clientFetch['companyname'], 'contactperson' => ucfirst($clientFetch['firstname']) . ' ' . $clientFetch['lastname'])));
}
$api->execute();
$response = $api->getResponse();
if ($api->hasErrors()) {
$errors = '';
foreach ($api->getErrors() as $error) {
$errors = $error['code'] . ' - ' . $error['message'] . ', ';
}
logActivity('Acumulus API error(s): ' . substr($errors, 0, -2));
return false;
} else {
mysql_query('UPDATE tblclients SET acumulusid = ' . $response['contact']['contactid'] . ' WHERE id = ' . $clientid . ' LIMIT 1');
return $response['contact']['contactid'];
}
}
示例2: acumulus_output
function acumulus_output($vars)
{
if (isset($_GET['sync'])) {
if (acumulus_sync($vars)) {
return;
}
}
?>
<h2>Openstaande facturen (van creditors)</h2>
<table id="sortabletbl2" class="datatable" width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<th width="20">
<input type="checkbox" onclick="$('#sortabletbl2 .checkall').attr('checked',this.checked);">
</th>
<th width="150">Datum</th>
<th>Contact</th>
<th width="200">Rekening</th>
<th width="200">Bedrag</th>
<th width="150"> </th>
</tr>
<tr>
<?php
function invoice($entry)
{
?>
<tr>
<td><input type="checkbox" name="selectedRequests[]" value="<?php
echo $entry['entryid'];
?>
"
class="checkall"></td>
<td><?php
echo $entry['issuedate'];
?>
</td>
<td><?php
echo $entry['contactid'];
?>
- <?php
echo $entry['contactname'];
?>
</td>
<td><?php
echo $entry['accountnumber'];
?>
</td>
<td><?php
echo $entry['amount'];
?>
</td>
<td>
<a href="https://www.sielsystems.nl/acumulus/editboeking.php?boeking_ID=<?php
echo $entry['entryid'];
?>
"
onclick="javascript:void window.open('https://www.sielsystems.nl/acumulus/editboeking.php?boeking_ID=<?php
echo $entry['entryid'];
?>
','boeking wijzigen','width=820,height=700,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;">Bekijk</a>
</td>
</tr>
<?php
}
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('reports')->setAction('report_unpaid_creditors');
$api->execute();
$response = $api->getResponse();
if ($api->hasErrors()) {
?>
<td colspan="6" align="middle">
<strong>Error(s) on API</strong><br/>
<?php
foreach ($api->getErrors() as $error) {
echo $error['code'] . ' | ' . $error['message'] . '<br/>';
}
?>
</td>
<?php
} else {
if (isset($response['unpaidcreditorinvoices']['entry'][0])) {
foreach ($response['unpaidcreditorinvoices']['entry'] as $entry) {
invoice($entry);
}
} else {
if (isset($response['unpaidcreditorinvoices']['entry'])) {
invoice($response['unpaidcreditorinvoices']['entry']);
} else {
?>
<td colspan="6" align="middle">
Geen openstaande facturen
</td>
<?php
}
}
}
?>
</tr>
</table><br/><br/>
<h1>Acumulus - Tools</h1>
//.........这里部分代码省略.........
示例3: acumulus_inject_gateway
function acumulus_inject_gateway($vars)
{
$vars = array_merge($vars, getAddonVars());
if ($vars['filename'] != 'configgateways') {
return;
}
$api = new api($vars['code'], $vars['username'], $vars['password']);
$api->setCategory('picklists')->setAction('picklist_accounts');
$api->execute();
$response = $api->getResponse();
if ($api->hasErrors()) {
$response = array();
$response['accounts'] = array();
$response['accounts']['account'] = array();
$response['accounts']['account'][] = array('accountid' => '', 'accountnumber' => 'API errors', 'accountdescription' => null);
foreach ($api->getErrors() as $error) {
$response['accounts']['account'][] = array('accountid' => '', 'accountnumber' => $error['code'], 'accountdescription' => $error['message']);
}
}
$inject = '<script>';
$gatewayQuery = mysql_query('SELECT name.gateway, acumulus_account.value AS acumulus_account FROM tblpaymentgateways AS name LEFT JOIN tblpaymentgateways AS acumulus_account ON acumulus_account.setting = "acumulusAccount" AND acumulus_account.gateway = name.gateway WHERE name.setting = "name"');
while ($gatewayFetch = mysql_fetch_assoc($gatewayQuery)) {
$inject .= '$(\'#Payment-Gateway-Config-' . $gatewayFetch['gateway'] . '\').find(\'tr:last\').before(\'<tr><td class="fieldlabel">Acumulus rekening</td><td class="fieldarea"><select name="field[acumulusAccount]">';
foreach ($response['accounts']['account'] as $action) {
$inject .= '<option value="' . $action['accountid'] . '" ' . ($gatewayFetch['acumulus_account'] == $action['accountid'] ? 'selected="selected"' : '') . '>' . $action['accountnumber'] . '' . (is_string($action['accountdescription']) ? ' - ' . $action['accountdescription'] : '') . '</option>';
}
$inject .= '</select>Voeg alle facturen met deze betaalmethode toe aan een bepaalde rekening, <a href="https://wiki.acumulus.nl/index.php?page=payment-service-provider" target="_blank">zie hier waarom</a>.</td></tr>\');';
}
$inject .= '</script>';
return $inject;
}