update
postpaid logic for more than 1 period fix mikrotiksms not working
This commit is contained in:
parent
dbf1623ca6
commit
5ccddf11be
@ -48,7 +48,7 @@ class Message
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
self::sendSMS($config['sms_url'], $phone, $txt);
|
self::MikrotikSendSMS($config['sms_url'], $phone, $txt);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// ignore, add to logs
|
// ignore, add to logs
|
||||||
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||||
|
@ -149,24 +149,18 @@ class Package
|
|||||||
$exp_date->modify('first day of next month');
|
$exp_date->modify('first day of next month');
|
||||||
$exp_date->setDate($exp_date->format('Y'), $exp_date->format('m'), $day_exp);
|
$exp_date->setDate($exp_date->format('Y'), $exp_date->format('m'), $day_exp);
|
||||||
|
|
||||||
$min_days = 7;
|
$min_days = 7 * $p['validity'];
|
||||||
$max_days = 35;
|
$max_days = 35 * $p['validity'];
|
||||||
|
|
||||||
// If validity is more than 2 months, multiply the limit days
|
|
||||||
if ($p['validity'] >= 2) {
|
|
||||||
$min_days *= $p['validity'];
|
|
||||||
$max_days *= $p['validity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$days_until_exp = $exp_date->diff($current_date)->days;
|
$days_until_exp = $exp_date->diff($current_date)->days;
|
||||||
|
|
||||||
// If less than min_days away, move to the next month
|
// If less than min_days away, move to the next period
|
||||||
while ($days_until_exp < $min_days) {
|
while ($days_until_exp < $min_days) {
|
||||||
$exp_date->modify('+1 month');
|
$exp_date->modify('+1 month');
|
||||||
$days_until_exp = $exp_date->diff($current_date)->days;
|
$days_until_exp = $exp_date->diff($current_date)->days;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If more than max_days away, move to the previous month
|
// If more than max_days away, move to the previous period
|
||||||
while ($days_until_exp > $max_days) {
|
while ($days_until_exp > $max_days) {
|
||||||
$exp_date->modify('-1 month');
|
$exp_date->modify('-1 month');
|
||||||
$days_until_exp = $exp_date->diff($current_date)->days;
|
$days_until_exp = $exp_date->diff($current_date)->days;
|
||||||
@ -177,6 +171,11 @@ class Package
|
|||||||
$exp_date->modify('+1 month');
|
$exp_date->modify('+1 month');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adjust for multiple periods
|
||||||
|
if ($p['validity'] > 1) {
|
||||||
|
$exp_date->modify('+' . ($p['validity'] - 1) . ' months');
|
||||||
|
}
|
||||||
|
|
||||||
$date_exp = $exp_date->format('Y-m-d');
|
$date_exp = $exp_date->format('Y-m-d');
|
||||||
$time = "23:59:59";
|
$time = "23:59:59";
|
||||||
} else if ($p['validity_unit'] == 'Days') {
|
} else if ($p['validity_unit'] == 'Days') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user