Skip to content

Commit

Permalink
Merge pull request #3 from SynergyWholesale/develop
Browse files Browse the repository at this point in the history
Fixes #2: Domain sync not accounting for "Sync Next Due Date" setting
  • Loading branch information
Cameron Hall authored Feb 18, 2020
2 parents 0db21a6 + 290002f commit 661e73c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Synergy Wholesale WHMCS Domains Module
### Removed
-

## 2.0.2 [Updated 18/02/2020]
### Changed
- PHP Version sent in API requests no longer include the `[extra]` version details

### Fixed
- Fixed "Next Due Date" not accounting for `Sync Next Due Date` setting on domain sync. Fixes [#1](https://github.com/SynergyWholesale/WHMCS-Domains-Module/issues/2)

## 2.0.1 [Updated 07/02/2020]
### Fixed
- Fixed support for PHP 7.2 and below. Fixes [#1](https://github.com/SynergyWholesale/WHMCS-Domains-Module/issues/1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function synergywholesaledomains_apiRequest($command, array $params = [], array
* backwards compatability across WHMCS versions and PHP support.
*/
$analytics = [
'php_ver' => phpversion(),
'php_ver' => str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION),
'whmcs_ver' => $params['whmcsVersion'],
'whmcs_mod_ver' => SW_MODULE_VERSION,
];
Expand Down Expand Up @@ -2250,6 +2250,8 @@ function synergywholesaledomains_sync_adhoc(array $params)
*/
function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
{
global $_LANG, $CONFIG;

$response = synergywholesaledomains_TransferSync($params);
$update = $syncMessages = [];
if (isset($response['error'])) {
Expand All @@ -2270,11 +2272,11 @@ function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
if ($response['expirydate']) {
$newBillDate = $update['expirydate'] = $response['expirydate'];
if ($CONFIG['DomainSyncNextDueDate'] && $CONFIG['DomainSyncNextDueDateDays']) {
$timeCalculation = strtotime($response['expirydate']) - strtotime($CONFIG['DomainSyncNextDueDateDays'] . ' days');
$newBillDate = date('Y-m-d', $timeCalculation);
$unix_expiry = strtotime($response['expirydate']);
$newBillDate = date('Y-m-d', strtotime(sprintf('-%d days', $CONFIG['DomainSyncNextDueDateDays']), $unix_expiry));
}

$update['nextinvoicedate'] = $update['nextduedate'] = $newBillDate;
$update['nextinvoicedate'] = $update['nextduedate'] = $newBillDate;
}
}

Expand Down Expand Up @@ -2354,6 +2356,8 @@ function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
*/
function synergywholesaledomains_adhocSync(array $params, $domainInfo)
{
global $CONFIG;

$response = synergywholesaledomains_Sync($params);
$syncMessages = $update = [];
if (isset($response['error'])) {
Expand Down Expand Up @@ -2391,8 +2395,8 @@ function synergywholesaledomains_adhocSync(array $params, $domainInfo)
if ($response['expirydate']) {
$newBillDate = $update['expirydate'] = $response['expirydate'];
if ($CONFIG['DomainSyncNextDueDate'] && $CONFIG['DomainSyncNextDueDateDays']) {
$timeCalculation = strtotime($response['expirydate']) - strtotime($CONFIG['DomainSyncNextDueDateDays'] . ' days');
$newBillDate = date('Y-m-d', $timeCalculation);
$unix_expiry = strtotime($response['expirydate']);
$newBillDate = date('Y-m-d', strtotime(sprintf('-%d days', $CONFIG['DomainSyncNextDueDateDays']), $unix_expiry));
}

if ($newBillDate != $domainInfo->nextinvoicedate) {
Expand Down

0 comments on commit 661e73c

Please sign in to comment.