From 92491e22ec5ed7bd38c7219f098a8ec9352a6073 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Tue, 3 Dec 2024 13:38:29 +0700 Subject: [PATCH] check if method exists --- system/controllers/customers.php | 6 +++++- system/controllers/home.php | 6 +++++- system/controllers/plan.php | 16 ++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 02957a89..d1798d99 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -284,7 +284,11 @@ switch ($action) { if ($_app_stage != 'demo') { if (file_exists($dvc)) { require_once $dvc; - (new $p['device'])->sync_customer($c, $p); + if (method_exists($dvc, 'sync_customer')) { + (new $p['device'])->sync_customer($c, $p); + }else{ + (new $p['device'])->add_customer($c, $p); + } } else { new Exception(Lang::T("Devices Not Found")); } diff --git a/system/controllers/home.php b/system/controllers/home.php index 3e8649b7..33825a13 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -110,7 +110,11 @@ if (isset($_GET['sync']) && !empty($_GET['sync'])) { if ($_app_stage != 'demo') { if (file_exists($dvc)) { require_once $dvc; - (new $p['device'])->sync_customer($c, $p); + if (method_exists($dvc, 'sync_customer')) { + (new $p['device'])->sync_customer($c, $p); + }else{ + (new $p['device'])->add_customer($c, $p); + } } else { new Exception(Lang::T("Devices Not Found")); } diff --git a/system/controllers/plan.php b/system/controllers/plan.php index 5af4e848..c19e37e5 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -49,7 +49,11 @@ switch ($action) { if ($_app_stage != 'demo') { if (file_exists($dvc)) { require_once $dvc; - (new $p['device'])->sync_customer($c, $p); + if (method_exists($dvc, 'sync_customer')) { + (new $p['device'])->sync_customer($c, $p); + }else{ + (new $p['device'])->add_customer($c, $p); + } } else { new Exception(Lang::T("Devices Not Found")); } @@ -101,7 +105,7 @@ switch ($action) { $cust = User::_info($id_customer); $plan = ORM::for_table('tbl_plans')->find_one($planId); list($bills, $add_cost) = User::getBills($id_customer); - + // Tax calculation start $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null; @@ -120,7 +124,7 @@ switch ($action) { } // Tax calculation stop $total_cost = $plan['price'] + $add_cost + $tax; - + if ($using == 'balance' && $config['enable_balance'] == 'yes') { if (!$cust) { r2(U . 'plan/recharge', 'e', Lang::T('Customer not found')); @@ -169,7 +173,7 @@ switch ($action) { $planId = _post('plan'); $using = _post('using'); $stoken = _post('stoken'); - + $plan = ORM::for_table('tbl_plans')->find_one($planId); if (!empty(App::getTokenValue($stoken))) { @@ -190,7 +194,7 @@ switch ($action) { $channel = $admin['fullname']; $cust = User::_info($id_customer); list($bills, $add_cost) = User::getBills($id_customer); - + // Tax calculation start $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null; @@ -209,7 +213,7 @@ switch ($action) { } // Tax calculation stop $total_cost = $plan['price'] + $add_cost + $tax; - + if ($using == 'balance' && $config['enable_balance'] == 'yes') { //$plan = ORM::for_table('tbl_plans')->find_one($planId); if (!$cust) {