diff --git a/system/controllers/order.php b/system/controllers/order.php index 19ee3e2d..8d1184fe 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -97,7 +97,7 @@ switch ($action) { } } if (empty($trx)) { - r2(U . "home", 'e', Lang::T("Transaction Not found")); + r2(U . "order", 'e', Lang::T("Transaction Not found")); } $router = ORM::for_table('tbl_routers')->find_one($trx['routers_id']); $plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']); @@ -109,6 +109,30 @@ switch ($action) { $ui->assign('_title', 'TRX #' . $trxid); $ui->display('user-orderView.tpl'); break; + case 'pay': + if ($_c['enable_balance'] != 'yes'){ + r2(U . "order", 'e', Lang::T("Balance not enabled")); + } + $plan = ORM::for_table('tbl_plans')->where('enabled', '1')->find_one($routes['3']); + $router = ORM::for_table('tbl_routers')->where('enabled', '1')->find_one($routes['2']); + if (empty($router) || empty($plan)) { + r2(U . "order/package", 'e', Lang::T("Plan Not found")); + } + if ($plan && $plan['enabled'] && $user['balance'] >= $plan['price']) { + if (Package::rechargeUser($user['id'], $plan['routers'], $plan['id'], 'Customer', 'Balance')) { + // if success, then get the balance + Balance::min($user['id'], $plan['price']); + r2(U . "home", 's', Lang::T("Success to buy package")); + } else { + r2(U . "order/package", 'e', Lang::T("Failed to buy package")); + Message::sendTelegram("Buy Package with Balance Failed\n\n#u$c[username] #buy \n" . $plan['name_plan'] . + "\nRouter: " . $router_name . + "\nPrice: " . $p['price']); + } + }else{ + echo "no renewall | plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n"; + } + break; case 'buy': if (strpos($user['email'], '@') === false) { r2(U . 'accounts/profile', 'e', Lang::T("Please enter your email address")); diff --git a/system/cron.php b/system/cron.php index 750e85b4..dc2bf026 100644 --- a/system/cron.php +++ b/system/cron.php @@ -142,7 +142,7 @@ foreach ($d as $ds) { // if success, then get the balance Balance::min($ds['customer_id'], $p['price']); } else { - Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] . + Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #PPPOE \n" . $p['name_plan'] . "\nRouter: " . $router_name . "\nPrice: " . $p['price']); } diff --git a/system/lan/english/common.lan.php b/system/lan/english/common.lan.php index 4e6ca82a..6032447e 100644 --- a/system/lan/english/common.lan.php +++ b/system/lan/english/common.lan.php @@ -365,3 +365,6 @@ $_L['Enable_auto_renewal'] = 'Enable auto renewal?'; $_L['Auto_Renewal_Off'] = 'Auto Renewal Off'; $_L['Refill_Balance'] = 'Refill Balance'; $_L['Invoice_Footer'] = 'Invoice Footer'; +$_L['Pay_With_Balance'] = 'Pay With Balance'; +$_L['Pay_this_with_Balance_your_active_package_will_be_overwrite'] = 'Pay this with Balance? your active package will be overwrite'; +$_L['Success_to_buy_package'] = 'Success to buy package'; diff --git a/ui/ui/user-orderPlan.tpl b/ui/ui/user-orderPlan.tpl index 6315baad..d8a2c91b 100644 --- a/ui/ui/user-orderPlan.tpl +++ b/ui/ui/user-orderPlan.tpl @@ -33,6 +33,10 @@ {/foreach} + +