From 96fccecbcf74b5335c5083f52d40ad1f36784cb2 Mon Sep 17 00:00:00 2001 From: AGSTR <144728914+agstrxyz@users.noreply.github.com> Date: Wed, 1 Jan 2025 20:44:10 +0700 Subject: [PATCH 1/7] Update Package.php --- system/autoload/Package.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index e763be6f..2d30465d 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -283,7 +283,7 @@ class Package $t = ORM::for_table('tbl_transactions')->create(); $t->invoice = $inv = "INV-" . Package::_raid(); $t->username = $c['username']; - $t->user_id = $c['id']; + $t->user_id = $id_customer; $t->plan_name = $p['name_plan']; if ($gateway == 'Voucher' && User::isUserVoucher($channel)) { //its already paid @@ -399,7 +399,7 @@ class Package $t = ORM::for_table('tbl_transactions')->create(); $t->invoice = $inv = "INV-" . Package::_raid(); $t->username = $c['username']; - $t->user_id = $c['id']; + $t->user_id = $id_customer; $t->plan_name = $p['name_plan']; if ($gateway == 'Voucher' && User::isUserVoucher($channel)) { $t->price = 0; From 1a5a7124f72b7cb49b0fcbaa5597e55d55418399 Mon Sep 17 00:00:00 2001 From: AGSTR <144728914+agstrxyz@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:59:20 +0700 Subject: [PATCH 2/7] Update plan.php --- system/controllers/plan.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/system/controllers/plan.php b/system/controllers/plan.php index d10bf624..d48a269d 100644 --- a/system/controllers/plan.php +++ b/system/controllers/plan.php @@ -604,6 +604,17 @@ switch ($action) { ->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) ->where('tbl_voucher.status', '0'); } + if (!empty($selected_datetime)) { + $v = ORM::for_table('tbl_plans') + ->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) + ->where('tbl_voucher.status', '0') + ->where('tbl_voucher.created_at', $selected_datetime) + ->limit($limit); + $vc = ORM::for_table('tbl_plans') + ->left_outer_join('tbl_voucher', array('tbl_plans.id', '=', 'tbl_voucher.id_plan')) + ->where('tbl_voucher.status', '0'); + + } if (in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { $v = $v->find_many(); $vc = $vc->count(); @@ -617,11 +628,6 @@ switch ($action) { $v = $v->where_in('generated_by', $sales)->find_many(); $vc = $vc->where_in('generated_by', $sales)->count(); } - if (!empty($selected_datetime)) { - $v = ORM::for_table('tbl_voucher') - ->where('created_at', $selected_datetime) - ->find_many(); - } $template = file_get_contents("pages/Voucher.html"); $template = str_replace('[[company_name]]', $config['CompanyName'], $template); From 1cbdf5a9b21f67ef8a3a9064898905930c8eee5e Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Mon, 30 Dec 2024 10:15:26 +0700 Subject: [PATCH 3/7] send back plan on update accounting --- radius.php | 1 + 1 file changed, 1 insertion(+) diff --git a/radius.php b/radius.php index 7c9898f4..69dfec41 100644 --- a/radius.php +++ b/radius.php @@ -316,6 +316,7 @@ try { } } } + process_radiust_rest($tur, 200); } show_radius_result([ "control:Auth-Type" => "Accept", From 5b7ffec11588bd2ee4d82138dca5e4d6fbf9965b Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Tue, 7 Jan 2025 16:16:38 +0700 Subject: [PATCH 4/7] merge coupon and voucer menu --- system/lan/english.json | 15 +++++++++++++- ui/ui/sections/header.tpl | 42 +++++++++------------------------------ version.json | 2 +- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/system/lan/english.json b/system/lan/english.json index b8e4bba2..68d9f0c0 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -930,5 +930,18 @@ "Send_yours_balance___": "Send yours balance ? ", "Cards": "Cards", "CRM": "CRM", - "Coupons": "Coupons" + "Coupons": "Coupons", + "Search_Coupons": "Search Coupons", + "Add_Coupon": "Add Coupon", + "Value": "Value", + "Max_Usage": "Max Usage", + "Usage_Count": "Usage Count", + "Min_Order": "Min Order", + "Max_Discount": "Max Discount", + "Updated_Date": "Updated Date", + "Action": "Action", + "No_coupons_found_": "No coupons found.", + "Delete_Selected": "Delete Selected", + "Voucher_Cards": "Voucher Cards", + "Create_Date": "Create Date" } \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index f4993f15..ee83736e 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -1254,7 +1254,7 @@ {$_MENU_AFTER_CUSTOMERS} -
  • +
  • {Lang::T('Services')} @@ -1268,6 +1268,14 @@
  • {Lang::T('Refill Customer')}
  • {/if} + {if $_c['disable_voucher'] != 'yes'} +
  • {Lang::T('Vouchers')}
  • + {/if} + {if $_c['disable_coupons'] != 'yes'} +
  • {Lang::T('Coupons')}
  • + {/if}
  • {Lang::T('Recharge Customer')}
  • {if $_c['enable_balance'] == 'yes'} @@ -1305,38 +1313,6 @@ {/if} {$_MENU_AFTER_PLANS} -
  • - - {Lang::T('Cards')} - - - - - -
  • - {$_MENU_AFTER_CRM} -
  • - - {Lang::T('CRM')} - - - - - -
  • - {$_MENU_AFTER_CARDS}
  • {if in_array($_admin['user_type'],['SuperAdmin','Admin', 'Report'])} diff --git a/version.json b/version.json index 82742c92..80f132cc 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "2024.12.6.1" + "version": "2025.1.7" } \ No newline at end of file From f997ecc702f774d576eda3024b8632a32979f2e7 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Tue, 7 Jan 2025 16:19:28 +0700 Subject: [PATCH 5/7] change active users to active customers --- system/lan/english.json | 7 ++++++- ui/ui/sections/header.tpl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/system/lan/english.json b/system/lan/english.json index 68d9f0c0..efd99082 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -943,5 +943,10 @@ "No_coupons_found_": "No coupons found.", "Delete_Selected": "Delete Selected", "Voucher_Cards": "Voucher Cards", - "Create_Date": "Create Date" + "Create_Date": "Create Date", + "Message_Results": "Message Results", + "Total_SMS_Sent": "Total SMS Sent", + "Total_SMS_Failed": "Total SMS Failed", + "Total_WhatsApp_Sent": "Total WhatsApp Sent", + "Total_WhatsApp_Failed": "Total WhatsApp Failed" } \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index ee83736e..c6c9fa1b 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -1263,7 +1263,7 @@
    • {Lang::T('Active Users')}
    • + href="{$_url}plan/list">{Lang::T('Active Customers')} {if $_c['disable_voucher'] != 'yes'}
    • {Lang::T('Refill Customer')}
    • From 754b23b53ff458fdef5887cd85e439b1e1ecb863 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Tue, 7 Jan 2025 16:26:33 +0700 Subject: [PATCH 6/7] change disable_coupons != yes to enable_coupons == yes --- system/controllers/order.php | 154 ++++++++++----------- ui/ui/customer/selectGateway.tpl | 222 +++++++++++++++---------------- ui/ui/sections/header.tpl | 2 +- 3 files changed, 190 insertions(+), 188 deletions(-) diff --git a/system/controllers/order.php b/system/controllers/order.php index 2b5a83ba..68e95a10 100644 --- a/system/controllers/order.php +++ b/system/controllers/order.php @@ -411,89 +411,91 @@ switch ($action) { list($bills, $add_cost) = User::getBills($id_customer); } - if (!isset($_SESSION['coupon_attempts'])) { - $_SESSION['coupon_attempts'] = 0; - $_SESSION['last_attempt_time'] = time(); - } - - if ($_SESSION['coupon_attempts'] >= 5) { - $timeout = 10 * 60; // 10 minutes in seconds - $time_diff = time() - $_SESSION['last_attempt_time']; - - if ($time_diff >= $timeout) { + if($config['enable_coupons']){ + if (!isset($_SESSION['coupon_attempts'])) { $_SESSION['coupon_attempts'] = 0; $_SESSION['last_attempt_time'] = time(); - } else { - $remaining_time = ceil(($timeout - $time_diff) / 60); - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Too many invalid attempts. Please try again after $remaining_time minutes.")); - } - } - - if (_post('coupon')) { - if ($plan['routers'] === 'balance') { - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon not available for Balance")); } - $coupon = ORM::for_table('tbl_coupons')->where('code', _post('coupon'))->find_one(); + if ($_SESSION['coupon_attempts'] >= 5) { + $timeout = 10 * 60; // 10 minutes in seconds + $time_diff = time() - $_SESSION['last_attempt_time']; - if (!$coupon) { - $_SESSION['coupon_attempts']++; + if ($time_diff >= $timeout) { + $_SESSION['coupon_attempts'] = 0; + $_SESSION['last_attempt_time'] = time(); + } else { + $remaining_time = ceil(($timeout - $time_diff) / 60); + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Too many invalid attempts. Please try again after $remaining_time minutes.")); + } + } + + if (_post('coupon')) { + if ($plan['routers'] === 'balance') { + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon not available for Balance")); + } + + $coupon = ORM::for_table('tbl_coupons')->where('code', _post('coupon'))->find_one(); + + if (!$coupon) { + $_SESSION['coupon_attempts']++; + $_SESSION['last_attempt_time'] = time(); + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon not found")); + } + + if ($coupon['status'] != 'active') { + $_SESSION['coupon_attempts']++; + $_SESSION['last_attempt_time'] = time(); + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon is not active")); + } + + // Reset attempts after a successful coupon validation + $_SESSION['coupon_attempts'] = 0; $_SESSION['last_attempt_time'] = time(); - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon not found")); + + $today = date('Y-m-d'); + if ($today < $coupon['start_date'] || $today > $coupon['end_date']) { + $_SESSION['coupon_attempts']++; + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon is not valid for today")); + } + + if ($coupon['max_usage'] > 0 && $coupon['usage_count'] >= $coupon['max_usage']) { + $_SESSION['coupon_attempts']++; + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon usage limit reached")); + } + + if ($plan['price'] < $coupon['min_order_amount']) { + $_SESSION['coupon_attempts']++; + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("The order amount does not meet the minimum requirement for this coupon")); + } + + // Calculate discount value + $discount = 0; + switch ($coupon['type']) { + case 'percent': + $discount = ($coupon['value'] / 100) * $plan['price']; + if ($discount > $coupon['max_discount_amount']) { + $discount = $coupon['max_discount_amount']; + } + break; + case 'fixed': + $discount = $coupon['value']; + break; + } + + // Ensure discount does not exceed the plan price + if ($discount >= $plan['price']) { + r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Discount value exceeds the plan price")); + } + + $plan['price'] -= $discount; + $coupon->usage_count = $coupon['usage_count'] + 1; + $coupon->save(); + + $ui->assign('discount', $discount); + $ui->assign('notify', Lang::T("Coupon applied successfully. You saved " . Lang::moneyFormat($discount))); + $ui->assign('notify_t', 's'); } - - if ($coupon['status'] != 'active') { - $_SESSION['coupon_attempts']++; - $_SESSION['last_attempt_time'] = time(); - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon is not active")); - } - - // Reset attempts after a successful coupon validation - $_SESSION['coupon_attempts'] = 0; - $_SESSION['last_attempt_time'] = time(); - - $today = date('Y-m-d'); - if ($today < $coupon['start_date'] || $today > $coupon['end_date']) { - $_SESSION['coupon_attempts']++; - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon is not valid for today")); - } - - if ($coupon['max_usage'] > 0 && $coupon['usage_count'] >= $coupon['max_usage']) { - $_SESSION['coupon_attempts']++; - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Coupon usage limit reached")); - } - - if ($plan['price'] < $coupon['min_order_amount']) { - $_SESSION['coupon_attempts']++; - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("The order amount does not meet the minimum requirement for this coupon")); - } - - // Calculate discount value - $discount = 0; - switch ($coupon['type']) { - case 'percent': - $discount = ($coupon['value'] / 100) * $plan['price']; - if ($discount > $coupon['max_discount_amount']) { - $discount = $coupon['max_discount_amount']; - } - break; - case 'fixed': - $discount = $coupon['value']; - break; - } - - // Ensure discount does not exceed the plan price - if ($discount >= $plan['price']) { - r2($_SERVER['HTTP_REFERER'], 'e', Lang::T("Discount value exceeds the plan price")); - } - - $plan['price'] -= $discount; - $coupon->usage_count = $coupon['usage_count'] + 1; - $coupon->save(); - - $ui->assign('discount', $discount); - $ui->assign('notify', Lang::T("Coupon applied successfully. You saved " . Lang::moneyFormat($discount))); - $ui->assign('notify_t', 's'); } $tax = Package::tax($plan['price'] + $add_cost, $tax_rate); diff --git a/ui/ui/customer/selectGateway.tpl b/ui/ui/customer/selectGateway.tpl index e98b3d66..2323ffff 100644 --- a/ui/ui/customer/selectGateway.tpl +++ b/ui/ui/customer/selectGateway.tpl @@ -2,12 +2,12 @@
      {if file_exists("$PAGES_PATH/Payment_Info.html")} -
      -
      -
      {Lang::T('Payment Info')}
      -
      {include file="$PAGES_PATH/Payment_Info.html"}
      +
      +
      +
      {Lang::T('Payment Info')}
      +
      {include file="$PAGES_PATH/Payment_Info.html"}
      +
      -
      {/if}
      @@ -16,129 +16,129 @@
      {Lang::T('Package Details')}
      {if !$custom} -
        -
      • - {Lang::T('Package Name')} - {$plan['name_plan']} -
      • +
          +
        • + {Lang::T('Package Name')} + {$plan['name_plan']} +
        • - {if $plan['is_radius'] or $plan['routers']} -
        • - {Lang::T('Location')} - {if $plan['is_radius']}Radius{else}{$plan['routers']}{/if} -
        • - {/if} + {if $plan['is_radius'] or $plan['routers']} +
        • + {Lang::T('Location')} + {if $plan['is_radius']}Radius{else}{$plan['routers']}{/if} +
        • + {/if} -
        • - {Lang::T('Type')} - - {if $plan['prepaid'] eq 'yes'}{Lang::T('Prepaid')}{else}{Lang::T('Postpaid')}{/if} - {$plan['type']} - -
        • +
        • + {Lang::T('Type')} + + {if $plan['prepaid'] eq 'yes'}{Lang::T('Prepaid')}{else}{Lang::T('Postpaid')}{/if} + {$plan['type']} + +
        • -
        • - {Lang::T('Package Price')} - - {if !empty($plan['price_old'])} - - {Lang::moneyFormat($plan['price_old'])} - - {/if} - {Lang::moneyFormat($plan['price'])} - -
        • +
        • + {Lang::T('Package Price')} + + {if !empty($plan['price_old'])} + + {Lang::moneyFormat($plan['price_old'])} + + {/if} + {Lang::moneyFormat($plan['price'])} + +
        • - {if $plan['validity']} -
        • - {Lang::T('Validity Period')} - {$plan['validity']} {$plan['validity_unit']} -
        • - {/if} -
        + {if $plan['validity']} +
      • + {Lang::T('Validity Period')} + {$plan['validity']} {$plan['validity_unit']} +
      • + {/if} +
      {else} -
        -
      • - {Lang::T('Package Name')} - {Lang::T('Custom Balance')} -
      • +
          +
        • + {Lang::T('Package Name')} + {Lang::T('Custom Balance')} +
        • -
        • - {Lang::T('Amount')} - - {Lang::moneyFormat($amount)} - -
        • -
        +
      • + {Lang::T('Amount')} + + {Lang::moneyFormat($amount)} + +
      • +
      {/if} - {if $discount == '' && $plan['type'] neq 'Balance' && $custom == ''} - -
      -
      - -
      -
      - - - - + {if $discount == '' && $plan['type'] neq 'Balance' && $custom == '' && $_c['enable_coupons'] == 'yes'} + + +
      + +
      +
      + + + + +
      -
      - + {/if}
      {Lang::T('Summary')}
        - + {if $add_cost != 0} - {foreach $bills as $k => $v} -
      • - {$k} - {Lang::moneyFormat($v)} -
      • - {/foreach} -
      • - {Lang::T('Additional Cost')} - {Lang::moneyFormat($add_cost)} -
      • + {foreach $bills as $k => $v} +
      • + {$k} + {Lang::moneyFormat($v)} +
      • + {/foreach} +
      • + {Lang::T('Additional Cost')} + {Lang::moneyFormat($add_cost)} +
      • {/if} {if $discount} -
      • - {Lang::T('Discount Applied')} - {Lang::moneyFormat($discount)} -
      • +
      • + {Lang::T('Discount Applied')} + {Lang::moneyFormat($discount)} +
      • {/if} {if $amount neq '' && $custom == '1'} -
      • - {Lang::T('Total')} - - {Lang::moneyFormat($amount)} - -
      • +
      • + {Lang::T('Total')} + + {Lang::moneyFormat($amount)} + +
      • {elseif $plan['type'] eq 'Balance'} -
      • - {Lang::T('Total')} - - {Lang::moneyFormat($plan['price'] + $add_cost)} - -
      • +
      • + {Lang::T('Total')} + + {Lang::moneyFormat($plan['price'] + $add_cost)} + +
      • {else} - {if $tax} -
      • - {Lang::T('Tax')} - {Lang::moneyFormat($tax)} -
      • - {/if} -
      • - {Lang::T('Total')} - - {Lang::moneyFormat($plan['price'] + $add_cost + $tax)} - -
      • + {if $tax} +
      • + {Lang::T('Tax')} + {Lang::moneyFormat($tax)} +
      • + {/if} +
      • + {Lang::T('Total')} + + {Lang::moneyFormat($plan['price'] + $add_cost + $tax)} + +
      • {/if}
      @@ -146,8 +146,8 @@
      {if $custom == '1' && $amount neq ''} - - + + {/if}
      @@ -159,7 +159,7 @@ {/if} {foreach $pgs as $pg} - + {/foreach}
      @@ -176,4 +176,4 @@
      -{include file="customer/footer.tpl"} +{include file="customer/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index c6c9fa1b..20d81202 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -1272,7 +1272,7 @@
    • {Lang::T('Vouchers')}
    • {/if} - {if $_c['disable_coupons'] != 'yes'} + {if $_c['enable_coupons'] == 'yes'}
    • {Lang::T('Coupons')}
    • {/if} From da84015aab16cabf0f3291974b7ded3a27cad4ca Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Tue, 7 Jan 2025 16:41:52 +0700 Subject: [PATCH 7/7] change status online to • --- system/controllers/autoload.php | 12 ++++++++---- system/lan/english.json | 7 ++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/system/controllers/autoload.php b/system/controllers/autoload.php index c5ec2afd..b9c686f5 100644 --- a/system/controllers/autoload.php +++ b/system/controllers/autoload.php @@ -114,10 +114,12 @@ switch ($action) { //don't wait more than 5 seconds for response from device, otherwise we get timeout error. ini_set('default_socket_timeout', 5); if ((new $p['device'])->online_customer($c, $p['routers'])) { - echo ' '; + echo ''; + }else{ + echo ''; } } catch (Exception $e) { - echo ' '; + echo ''; } } } @@ -141,10 +143,12 @@ switch ($action) { //don't wait more than 5 seconds for response from device, otherwise we get timeout error. ini_set('default_socket_timeout', 5); if ((new $p['device'])->online_customer($c, $p['routers'])) { - $status = ' '; + $status = ''; + }else{ + $status = ''; } } catch (Exception $e) { - $status = ' '; + $status = ''; } } } diff --git a/system/lan/english.json b/system/lan/english.json index efd99082..8748413e 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -948,5 +948,10 @@ "Total_SMS_Sent": "Total SMS Sent", "Total_SMS_Failed": "Total SMS Failed", "Total_WhatsApp_Sent": "Total WhatsApp Sent", - "Total_WhatsApp_Failed": "Total WhatsApp Failed" + "Total_WhatsApp_Failed": "Total WhatsApp Failed", + "First_Name": "First Name", + "Last_Name": "Last Name", + "Not_Working_with_Freeradius_Mysql": "Not Working with Freeradius Mysql", + "Radius_Rest_Interim_Update": "Radius Rest Interim-Update", + "in_minutes__leave_0_to_disable_this_feature_": "in minutes, leave 0 to disable this feature." } \ No newline at end of file