diff --git a/system/autoload/Package.php b/system/autoload/Package.php
index dcd296eb..a2f9039a 100644
--- a/system/autoload/Package.php
+++ b/system/autoload/Package.php
@@ -64,20 +64,12 @@ class Package
}
}
- if ($p['validity_unit'] == 'Period') {
- $day_exp = User::getAttribute("Expired Date", $c['id']); //ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one();
- if (!$day_exp) {
- $day_exp = 20;
- // $day_exp = date('d', strtotime($c['created_at']));
- // if (empty($day_exp) || $day_exp > 28) {
- // $day_exp = 1;
- // }
- $f = ORM::for_table('tbl_customers_fields')->create();
- $f->customer_id = $c['id'];
- $f->field_name = 'Expired Date';
- $f->field_value = $day_exp;
- $f->save();
- }
+ $day_exp = 20;
+ if ($p['prepaid'] == 'no') {
+ $day_exp = $p['expired_date'];
+ }
+ if(empty($day_exp)){
+ $day_exp = 20;
}
if ($router_name == 'balance') {
diff --git a/system/controllers/codecanyon.php b/system/controllers/codecanyon.php
deleted file mode 100644
index 171c5d62..00000000
--- a/system/controllers/codecanyon.php
+++ /dev/null
@@ -1,126 +0,0 @@
-assign('_title', 'CodeCanyon.net');
-$ui->assign('_system_menu', 'settings');
-
-$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json';
-
-$action = $routes['1'];
-$ui->assign('_admin', $admin);
-$cache = File::pathFixer($CACHE_PATH . '/codecanyon.json');
-
-if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
- _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
-}
-if (empty($config['envato_token'])) {
- r2(U . 'settings/app', 'w', 'Envato Personal Access Token is not set');
-}
-
-switch ($action) {
-
- case 'install':
- if (!is_writeable(File::pathFixer($CACHE_PATH . '/'))) {
- r2(U . "codecanyon", 'e', 'Folder system/cache/ is not writable');
- }
- if (!is_writeable($PLUGIN_PATH)) {
- r2(U . "codecanyon", 'e', 'Folder plugin/ is not writable');
- }
- if (!is_writeable($PAYMENTGATEWAY_PATH)) {
- r2(U . "codecanyon", 'e', 'Folder paymentgateway/ is not writable');
- }
- set_time_limit(-1);
- $item_id = $routes['2'];
- $tipe = $routes['3'];
- $result = Http::getData('https://api.envato.com/v3/market/buyer/download?item_id=' . $item_id, ['Authorization: Bearer ' . $config['envato_token']]);
- $json = json_decode($result, true);
- if (!isset($json['download_url'])) {
- r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']);
- }
- $file = File::pathFixer($CACHE_PATH . '/codecanyon/');
- if (!file_exists($file)) {
- mkdir($file);
- }
- $file .= $item_id . '.zip';
- if (file_exists($file))
- unlink($file);
- //download
- $fp = fopen($file, 'w+');
- $ch = curl_init($json['download_url']);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
- curl_setopt($ch, CURLOPT_TIMEOUT, 120);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_FILE, $fp);
- curl_exec($ch);
- curl_close($ch);
- fclose($fp);
- //extract
- $target = File::pathFixer($CACHE_PATH . '/codecanyon/' . $item_id . '/');
- $zip = new ZipArchive();
- $zip->open($file);
- $zip->extractTo($target);
- $zip->close();
- //moving
- if (file_exists($target . 'plugin')) {
- File::copyFolder($target . 'plugin', $PLUGIN_PATH . DIRECTORY_SEPARATOR);
- } else if (file_exists($target . 'paymentgateway')) {
- File::copyFolder($target . 'paymentgateway', $PAYMENTGATEWAY_PATH . DIRECTORY_SEPARATOR);
- } else if (file_exists($target . 'theme')) {
- File::copyFolder($target . 'theme', File::pathFixer('ui/themes/'));
- }
- //Cleaning
- File::deleteFolder($target);
- unlink($file);
- r2(U . "codecanyon", 's', 'Installation success');
- case 'reload':
- if (file_exists($cache))
- unlink($cache);
- default:
- if (class_exists('ZipArchive')) {
- $zipExt = true;
- } else {
- $zipExt = false;
- }
- $ui->assign('zipExt', $zipExt);
-
- if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
- $txt = file_get_contents($cache);
- $plugins = json_decode($txt, true);
- $ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
- if (count($plugins) == 0) {
- unlink($cache);
- r2(U . 'codecanyon');
- }
- } else {
- $plugins = [];
- $page = _get('page', 1);
- back:
- $result = Http::getData('https://api.envato.com/v3/market/buyer/list-purchases?&page=' . $page, ['Authorization: Bearer ' . $config['envato_token']]);
- $items = json_decode($result, true);
- if ($items && count($items['results']) > 0) {
- foreach ($items['results'] as $item) {
- $name = strtolower($item['item']['name']);
- if (strpos($name, 'phpnuxbill') !== false) {
- $plugins[] = $item;
- }
- }
- $page++;
- goto back;
- }
- if (count($plugins) > 0) {
- file_put_contents($cache, json_encode($plugins));
- if (file_exists($cache)) {
- $ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
- }
- }
- }
- $ui->assign('plugins', $plugins);
- $ui->display('codecanyon.tpl');
-}
diff --git a/system/controllers/services.php b/system/controllers/services.php
index c2bf7a9e..5aae6b50 100644
--- a/system/controllers/services.php
+++ b/system/controllers/services.php
@@ -159,6 +159,7 @@ switch ($action) {
$device = _post('device');
$enabled = _post('enabled');
$prepaid = _post('prepaid');
+ $expired_date = _post('expired_date');
$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
@@ -209,6 +210,14 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
+ if($prepaid == 'no'){
+ if($expired_date>28 && $expired_date < 1){
+ $expired_date = 20;
+ }
+ $d->expired_date = $expired_date;
+ }else{
+ $d->expired_date = 0;
+ }
$d->save();
$dvc = Package::getDevice($d);
@@ -246,6 +255,7 @@ switch ($action) {
$enabled = _post('enabled');
$prepaid = _post('prepaid');
$routers = _post('routers');
+ $expired_date = _post('expired_date');
$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '
';
@@ -301,6 +311,14 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
+ if($prepaid == 'no'){
+ if($expired_date>28 && $expired_date < 1){
+ $expired_date = 20;
+ }
+ $d->expired_date = $expired_date;
+ }else{
+ $d->expired_date = 0;
+ }
$d->save();
$dvc = Package::getDevice($d);
@@ -433,6 +451,7 @@ switch ($action) {
$pool = _post('pool_name');
$enabled = _post('enabled');
$prepaid = _post('prepaid');
+ $expired_date = _post('expired_date');
$msg = '';
@@ -491,6 +510,14 @@ switch ($action) {
$d->is_radius = 0;
$d->routers = $routers;
}
+ if($prepaid == 'no'){
+ if($expired_date>28 && $expired_date < 1){
+ $expired_date = 20;
+ }
+ $d->expired_date = $expired_date;
+ }else{
+ $d->expired_date = 0;
+ }
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
@@ -524,6 +551,7 @@ switch ($action) {
$plan_expired = _post('plan_expired');
$enabled = _post('enabled');
$prepaid = _post('prepaid');
+ $expired_date = _post('expired_date');
$msg = '';
if (Validator::UnsignedNumber($validity) == false) {
@@ -575,6 +603,14 @@ switch ($action) {
$d->enabled = $enabled;
$d->prepaid = $prepaid;
$d->device = $device;
+ if($prepaid == 'no'){
+ if($expired_date>28 && $expired_date < 1){
+ $expired_date = 20;
+ }
+ $d->expired_date = $expired_date;
+ }else{
+ $d->expired_date = 0;
+ }
$d->save();
$dvc = Package::getDevice($d);
diff --git a/system/lan/english.json b/system/lan/english.json
index 07b5245f..b321a49f 100644
--- a/system/lan/english.json
+++ b/system/lan/english.json
@@ -636,5 +636,11 @@
"Device": "Device",
"Expired_Internet_Plan": "Expired Internet Plan",
"When_Expired__customer_will_be_move_to_selected_internet_plan": "When Expired, customer will be move to selected internet plan",
- "Plugin_Installer": "Plugin Installer"
+ "Plugin_Installer": "Plugin Installer",
+ "Expired_Date": "Expired Date",
+ "Expired": "Expired",
+ "Time": "Time",
+ "Data": "Data",
+ "Category": "Category",
+ "later": "later"
}
\ No newline at end of file
diff --git a/ui/ui/codecanyon.tpl b/ui/ui/codecanyon.tpl
deleted file mode 100644
index 39a4e676..00000000
--- a/ui/ui/codecanyon.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-{include file="sections/header.tpl"}
-
{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}
{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}
{Lang::T('1 Period = 1 Month, Expires the 20th of each month')}
+ | {Lang::T('Internet Plan')} | ++ | {Lang::T('Expired')} | ++ | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{Lang::T('Plan Name')} | {Lang::T('Plan Type')} | @@ -41,7 +48,8 @@{Lang::T('Plan Price')} | {Lang::T('Plan Validity')} | {Lang::T('IP Pool')} | -{Lang::T('Expired Internet Plan')} | +{Lang::T('Internet Plan')} | +{Lang::T('Date')} | {Lang::T('Routers')} | {Lang::T('Device')} | {Lang::T('Manage')} | @@ -58,6 +66,7 @@{$ds['validity']} {$ds['validity_unit']} | {$ds['pool']} | {if $ds['plan_expired']}Yes{else}No{/if} | +{if $ds['prepaid'] == no}{$ds['expired_date']}{/if} |
{if $ds['is_radius']}
RADIUS
diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl
index f71d8889..ae519bad 100644
--- a/ui/ui/sections/header.tpl
+++ b/ui/ui/sections/header.tpl
@@ -451,10 +451,6 @@
{Lang::T('Plugin Manager')} Free
- {* |