if it the same internet plan, expiry date will extend, now optional and can be enabled/disable in general settings [ Miscellaneous Tab]
This commit is contained in:
Focuslinkstech 2024-05-17 16:24:48 +01:00
parent ea51fa24d0
commit 749ec8509f
2 changed files with 56 additions and 61 deletions

View File

@ -34,8 +34,8 @@ class Package
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
if($c['status'] != 'Active'){ if ($c['status'] != 'Active') {
_alert(Lang::T('This account status').' : '.Lang::T($c['status']),'danger', ""); _alert(Lang::T('This account status') . ' : ' . Lang::T($c['status']), 'danger', "");
} }
$add_cost = 0; $add_cost = 0;
@ -197,48 +197,29 @@ class Package
if ($plan_id != $b['plan_id']) { if ($plan_id != $b['plan_id']) {
$isChangePlan = true; $isChangePlan = true;
} }
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') { if ($config['extend_expiry'] === 'yes') {
// if it same internet plan, expired will extend if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
if ($p['validity_unit'] == 'Months') { // if it same internet plan, expired will extend
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); if ($p['validity_unit'] == 'Months') {
$time = $b['time']; $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
} else if ($p['validity_unit'] == 'Period') { $time = $b['time'];
$date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); } else if ($p['validity_unit'] == 'Period') {
$time = date("23:59:00"); $date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
} else if ($p['validity_unit'] == 'Days') { $time = date("23:59:00");
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); } else if ($p['validity_unit'] == 'Days') {
$time = $b['time']; $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days'));
} else if ($p['validity_unit'] == 'Hrs') { $time = $b['time'];
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); } else if ($p['validity_unit'] == 'Hrs') {
$date_exp = $datetime[0]; $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours')));
$time = $datetime[1]; $date_exp = $datetime[0];
} else if ($p['validity_unit'] == 'Mins') { $time = $datetime[1];
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); } else if ($p['validity_unit'] == 'Mins') {
$date_exp = $datetime[0]; $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes')));
$time = $datetime[1]; $date_exp = $datetime[0];
} $time = $datetime[1];
} elseif ($b['namebp'] == $p['name_plan'] && $b['status'] == 'off') { }
// if it same internet plan but has expired, it will not extend expiry date
if ($p['validity_unit'] == 'Months') {
$date_exp = date("Y-m-d", strtotime($p['validity'] . ' months'));
$time = $b['time'];
} else if ($p['validity_unit'] == 'Period') {
$date_exp = date("Y-m-$day_exp", strtotime($p['validity'] . ' months'));
$time = date("23:59:00");
} else if ($p['validity_unit'] == 'Days') {
$date_exp = date("Y-m-d", strtotime($p['validity'] . ' days'));
$time = $b['time'];
} else if ($p['validity_unit'] == 'Hrs') {
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($p['validity'] . ' hours')));
$date_exp = $datetime[0];
$time = $datetime[1];
} else if ($p['validity_unit'] == 'Mins') {
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($p['validity'] . ' minutes')));
$date_exp = $datetime[0];
$time = $datetime[1];
} }
} }
if ($isChangePlan || $b['status'] == 'off') { if ($isChangePlan || $b['status'] == 'off') {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, "$date_exp $time"); Radius::customerAddPlan($c, $p, "$date_exp $time");
@ -418,25 +399,27 @@ class Package
if ($plan_id != $b['plan_id']) { if ($plan_id != $b['plan_id']) {
$isChangePlan = true; $isChangePlan = true;
} }
if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') { if ($config['extend_expiry'] === 'yes') {
// if it same internet plan, expired will extend if ($b['namebp'] == $p['name_plan'] && $b['status'] == 'on') {
if ($p['validity_unit'] == 'Months') { // if it same internet plan, expired will extend
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); if ($p['validity_unit'] == 'Months') {
$time = $b['time']; $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
} else if ($p['validity_unit'] == 'Period') { $time = $b['time'];
$date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months')); } else if ($p['validity_unit'] == 'Period') {
$time = date("23:59:00"); $date_exp = date("Y-m-$day_exp", strtotime($b['expiration'] . ' +' . $p['validity'] . ' months'));
} else if ($p['validity_unit'] == 'Days') { $time = date("23:59:00");
$date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days')); } else if ($p['validity_unit'] == 'Days') {
$time = $b['time']; $date_exp = date("Y-m-d", strtotime($b['expiration'] . ' +' . $p['validity'] . ' days'));
} else if ($p['validity_unit'] == 'Hrs') { $time = $b['time'];
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours'))); } else if ($p['validity_unit'] == 'Hrs') {
$date_exp = $datetime[0]; $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' hours')));
$time = $datetime[1]; $date_exp = $datetime[0];
} else if ($p['validity_unit'] == 'Mins') { $time = $datetime[1];
$datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes'))); } else if ($p['validity_unit'] == 'Mins') {
$date_exp = $datetime[0]; $datetime = explode(' ', date("Y-m-d H:i:s", strtotime($b['expiration'] . ' ' . $b['time'] . ' +' . $p['validity'] . ' minutes')));
$time = $datetime[1]; $date_exp = $datetime[0];
$time = $datetime[1];
}
} }
} }

View File

@ -602,6 +602,18 @@
</div> </div>
<p class="help-block col-md-4">{Lang::T('The method which OTP will be sent to user')}</p> <p class="help-block col-md-4">{Lang::T('The method which OTP will be sent to user')}</p>
</div> </div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Extend Package Expiry')}</label>
<div class="col-md-6">
<select name="extend_expiry" id="extend_expiry" class="form-control">
<option value="no" {if $_c['extend_expiry']=='no' }selected="selected" {/if}>
{Lang::T('No')}
<option value="yes" {if $_c['extend_expiry']=='yes' }selected="selected"
{/if}> {Lang::T('Yes')}
</select>
</div>
<p class="help-block col-md-4">{Lang::T('If user buy same internet plan, expiry date will extend')}</p>
</div>
</div> </div>
<div class="panel-heading"> <div class="panel-heading">