diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 1cf8b903..41827e1f 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -820,4 +820,11 @@ class Package $ui->assign('whatsapp', urlencode("```$invoice```")); $ui->assign('in', $in); } + public static function tax($price, $tax_rate = 1) + { + // Convert tax rate to decimal + $tax_rate_decimal = $tax_rate / 100; + $tax = $price * $tax_rate_decimal; + return $tax; + } } diff --git a/system/controllers/order.php b/system/controllers/order.php index 4aa29efb..61f730c7 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -131,7 +131,7 @@ switch ($action) { $router = Mikrotik::info($trx['routers']); $plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']); $bandw = ORM::for_table('tbl_bandwidth')->find_one($plan['id_bw']); - $invoice = ORM::for_table('tbl_transactions')->where("invoice",$trx['trx_invoice'])->find_one(); + $invoice = ORM::for_table('tbl_transactions')->where("invoice", $trx['trx_invoice'])->find_one(); $ui->assign('invoice', $invoice); $ui->assign('trx', $trx); $ui->assign('router', $router); @@ -280,6 +280,16 @@ switch ($action) { if (strpos($user['email'], '@') === false) { r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); } + $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; + $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : null; + $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : null; + if ($tax_rate_setting === 'custom') { + $tax_rate = $custom_tax_rate; + } else { + $tax_rate = $tax_rate_setting; + } + $plan = ORM::for_table('tbl_plans')->find_one($routes['3']); + $tax = Package::tax($plan['price'], $tax_rate); $pgs = array_values(explode(',', $config['payment_gateway'])); if (count($pgs) == 0) { sendTelegram("Payment Gateway not set, please set it in Settings"); @@ -288,11 +298,12 @@ switch ($action) { } if (count($pgs) > 1) { $ui->assign('pgs', $pgs); - //$ui->assign('pgs', $pgs); + if ($tax_enable === 'yes') { + $ui->assign('tax', $tax); + } $ui->assign('route2', $routes[2]); $ui->assign('route3', $routes[3]); - - //$ui->assign('plan', $plan); + $ui->assign('plan', $plan); $ui->display('user-selectGateway.tpl'); break; } else { diff --git a/system/controllers/services.php b/system/controllers/services.php index dadfb0cf..a0f85ec2 100644 --- a/system/controllers/services.php +++ b/system/controllers/services.php @@ -244,37 +244,6 @@ switch ($action) { $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown . '/' . $b['burst']; $rate = trim($rate . " " . $b['burst']); - - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } - // Create new plan $d = ORM::for_table('tbl_plans')->create(); $d->name_plan = $name; @@ -391,37 +360,6 @@ switch ($action) { Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired); } } - - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } - $d->name_plan = $name; $d->id_bw = $id_bw; $d->price = $price_with_tax; // Set price with or without tax based on configuration @@ -578,38 +516,6 @@ switch ($action) { $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown . '/' . $b['burst']; $rate = trim($rate . " " . $b['burst']); - - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } - - $d = ORM::for_table('tbl_plans')->create(); $d->type = 'PPPOE'; $d->name_plan = $name; @@ -712,37 +618,6 @@ switch ($action) { Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K'); } } - - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } - $d->name_plan = $name; $d->id_bw = $id_bw; $d->price = $price_with_tax; @@ -822,35 +697,6 @@ switch ($action) { } run_hook('edit_ppoe'); #HOOK if ($msg == '') { - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } $d->name_plan = $name; $d->price = $price_with_tax; $d->enabled = $enabled; @@ -881,38 +727,6 @@ switch ($action) { } run_hook('add_ppoe'); #HOOK if ($msg == '') { - - // Check if tax is enabled in config - $tax_enable = isset($config['enable_tax']) ? $config['enable_tax'] : 'no'; - - // Default tax rate - $default_tax_rate = 0.01; // Default tax rate 1% - - // Check if tax rate is set to custom in config - $tax_rate_setting = isset($config['tax_rate']) ? $config['tax_rate'] : $default_tax_rate; - - // Check if tax rate is custom - if ($tax_rate_setting === 'custom') { - // Check if custom tax rate is set in config - $custom_tax_rate = isset($config['custom_tax_rate']) ? (float)$config['custom_tax_rate'] : $default_tax_rate; - // Convert custom tax rate to decimal - $custom_tax_rate_decimal = $custom_tax_rate / 100; - $tax_rate = $custom_tax_rate_decimal; - } else { - // Use tax rate - $tax_rate = $tax_rate_setting; - } - - - // Calculate the new price with tax if tax is enabled - if ($tax_enable === 'yes') { - $price_with_tax = $price + ($price * $tax_rate); - } else { - // If tax is not enabled, use the original price - $price_with_tax = $price; - } - - $d = ORM::for_table('tbl_plans')->create(); $d->type = 'Balance'; $d->name_plan = $name; diff --git a/ui/ui/app-settings.tpl b/ui/ui/app-settings.tpl index c47db57e..a83c1609 100644 --- a/ui/ui/app-settings.tpl +++ b/ui/ui/app-settings.tpl @@ -631,22 +631,22 @@
{foreach $pgs as $pg} - + {/foreach}
-
- -
+ +
+
{Lang::T('Package Details')}
+ +
{Lang::T('Summary')}
+ +
+
+ {Lang::T('Cancel')} +