Skip to content

Commit 4794e40

Browse files
author
Cameron Hall
committed
Fixes #2: Domain sync not accounting for "Sync Next Due Date" setting
1 parent 0db21a6 commit 4794e40

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Synergy Wholesale WHMCS Domains Module
1515
### Removed
1616
-
1717

18+
## 2.0.2 [Updated 18/02/2020]
19+
### Fixed
20+
- 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)
21+
1822
## 2.0.1 [Updated 07/02/2020]
1923
### Fixed
2024
- Fixed support for PHP 7.2 and below. Fixes [#1](https://github.com/SynergyWholesale/WHMCS-Domains-Module/issues/1)

modules/registrars/synergywholesaledomains/synergywholesaledomains.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,8 @@ function synergywholesaledomains_sync_adhoc(array $params)
22502250
*/
22512251
function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
22522252
{
2253+
global $_LANG, $CONFIG;
2254+
22532255
$response = synergywholesaledomains_TransferSync($params);
22542256
$update = $syncMessages = [];
22552257
if (isset($response['error'])) {
@@ -2270,11 +2272,11 @@ function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
22702272
if ($response['expirydate']) {
22712273
$newBillDate = $update['expirydate'] = $response['expirydate'];
22722274
if ($CONFIG['DomainSyncNextDueDate'] && $CONFIG['DomainSyncNextDueDateDays']) {
2273-
$timeCalculation = strtotime($response['expirydate']) - strtotime($CONFIG['DomainSyncNextDueDateDays'] . ' days');
2274-
$newBillDate = date('Y-m-d', $timeCalculation);
2275+
$unix_expiry = strtotime($response['expirydate']);
2276+
$newBillDate = date('Y-m-d', strtotime(sprintf('-%d days', $CONFIG['DomainSyncNextDueDateDays']), $unix_expiry));
22752277
}
22762278

2277-
$update['nextinvoicedate'] = $update['nextduedate'] = $newBillDate;
2279+
$update['nextinvoicedate'] = $update['nextduedate'] = $newBillDate;
22782280
}
22792281
}
22802282

@@ -2354,6 +2356,8 @@ function synergywholesaledomains_adhocTransferSync(array $params, $domainInfo)
23542356
*/
23552357
function synergywholesaledomains_adhocSync(array $params, $domainInfo)
23562358
{
2359+
global $CONFIG;
2360+
23572361
$response = synergywholesaledomains_Sync($params);
23582362
$syncMessages = $update = [];
23592363
if (isset($response['error'])) {
@@ -2391,8 +2395,8 @@ function synergywholesaledomains_adhocSync(array $params, $domainInfo)
23912395
if ($response['expirydate']) {
23922396
$newBillDate = $update['expirydate'] = $response['expirydate'];
23932397
if ($CONFIG['DomainSyncNextDueDate'] && $CONFIG['DomainSyncNextDueDateDays']) {
2394-
$timeCalculation = strtotime($response['expirydate']) - strtotime($CONFIG['DomainSyncNextDueDateDays'] . ' days');
2395-
$newBillDate = date('Y-m-d', $timeCalculation);
2398+
$unix_expiry = strtotime($response['expirydate']);
2399+
$newBillDate = date('Y-m-d', strtotime(sprintf('-%d days', $CONFIG['DomainSyncNextDueDateDays']), $unix_expiry));
23962400
}
23972401

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

0 commit comments

Comments
 (0)