diff --git a/system/controllers/home.php b/system/controllers/home.php index cf8c5b67..f5b1214c 100644 --- a/system/controllers/home.php +++ b/system/controllers/home.php @@ -95,8 +95,7 @@ if (_post('send') == 'balance') { } r2(getUrl('home'), 'w', Lang::T('Your friend do not have active package')); } -$_bill = User::_billing(); -$ui->assign('_bills', $_bill); + // Sync plan to router if (isset($_GET['sync']) && !empty($_GET['sync'])) { @@ -310,46 +309,25 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'] && !empty($_SESSI } } -$tcf = ORM::for_table('tbl_customers_fields') - ->where('customer_id', $user['id']) - ->find_many(); -$vpn = ORM::for_table('tbl_port_pool') - ->find_one(); -$ui->assign('cf', $tcf); -$ui->assign('vpn', $vpn); -$unpaid = ORM::for_table('tbl_payment_gateway') - ->where('username', $user['username']) - ->where('status', 1) - ->find_one(); - -// check expired payments -if ($unpaid) { - try { - if (strtotime($unpaid['expired_date']) < time()) { - $unpaid->status = 4; - $unpaid->save(); - $unpaid = []; +$widgets = ORM::for_table('tbl_widgets')->where("enabled", 1)->where('user', 'Customer')->order_by_asc("orders")->findArray(); +$count = count($widgets); +for ($i = 0; $i < $count; $i++) { + try{ + if(file_exists($WIDGET_PATH . DIRECTORY_SEPARATOR . 'customer' . DIRECTORY_SEPARATOR . $widgets[$i]['widget'].".php")){ + require_once $WIDGET_PATH . DIRECTORY_SEPARATOR . 'customer' . DIRECTORY_SEPARATOR . $widgets[$i]['widget'].".php"; + $widgets[$i]['content'] = (new $widgets[$i]['widget'])->getWidget($widgets[$i]); + }else{ + $widgets[$i]['content'] = "Widget not found"; } } catch (Throwable $e) { - } catch (Exception $e) { - } - try { - if (strtotime($unpaid['created_date'], "+24 HOUR") < time()) { - $unpaid->status = 4; - $unpaid->save(); - $unpaid = []; - } - } catch (Throwable $e) { - } catch (Exception $e) { + $widgets[$i]['content'] = $e->getMessage(); } } -$ui->assign('unpaid', $unpaid); -$ui->assign('code', alphanumeric(_get('code'), "-")); +$ui->assign('widgets', $widgets); -$abills = User::getAttributes("Bill"); -$ui->assign('abills', $abills); +$ui->assign('code', alphanumeric(_get('code'), "-")); run_hook('view_customer_dashboard'); #HOOK $ui->display('customer/dashboard.tpl'); diff --git a/system/widgets/customer/account_info.php b/system/widgets/customer/account_info.php new file mode 100644 index 00000000..53cb953c --- /dev/null +++ b/system/widgets/customer/account_info.php @@ -0,0 +1,14 @@ +assign('abills', $abills); + return $ui->fetch('widget/customers/account_info.tpl'); + } +} diff --git a/system/widgets/customer/active_internet_plan.php b/system/widgets/customer/active_internet_plan.php new file mode 100644 index 00000000..8bf0501f --- /dev/null +++ b/system/widgets/customer/active_internet_plan.php @@ -0,0 +1,20 @@ +assign('_bills', $_bill); + $tcf = ORM::for_table('tbl_customers_fields') + ->where('customer_id', $user['id']) + ->find_many(); + $vpn = ORM::for_table('tbl_port_pool') + ->find_one(); + $ui->assign('cf', $tcf); + $ui->assign('vpn', $vpn); + return $ui->fetch('widget/customers/active_internet_plan.tpl'); + } +} diff --git a/system/widgets/customer/announcement.php b/system/widgets/customer/announcement.php new file mode 100644 index 00000000..348cd368 --- /dev/null +++ b/system/widgets/customer/announcement.php @@ -0,0 +1,11 @@ +fetch('widget/customers/announcement.tpl'); + } +} diff --git a/system/widgets/customer/balance_transfer.php b/system/widgets/customer/balance_transfer.php new file mode 100644 index 00000000..e424c20f --- /dev/null +++ b/system/widgets/customer/balance_transfer.php @@ -0,0 +1,11 @@ +fetch('widget/customers/balance_transfer.tpl'); + } +} diff --git a/system/widgets/customer/button_order_internet_plan.php b/system/widgets/customer/button_order_internet_plan.php new file mode 100644 index 00000000..5e6bc4f5 --- /dev/null +++ b/system/widgets/customer/button_order_internet_plan.php @@ -0,0 +1,11 @@ +fetch('widget/customers/button_order_internet_plan.tpl'); + } +} diff --git a/system/widgets/customer/html_only.php b/system/widgets/customer/html_only.php new file mode 100644 index 00000000..b7131c01 --- /dev/null +++ b/system/widgets/customer/html_only.php @@ -0,0 +1,11 @@ +assign('card_header', $data['title']); + ob_start(); + try{ + eval('?>'. $data['content']); + }catch(Exception $e){ + echo $e->getMessage(); + echo "
"; + echo $e->getTraceAsString(); + } + $content = ob_get_clean(); + $ui->assign('card_body', $content); + return $ui->fetch('widget/card_html.tpl'); + } +} \ No newline at end of file diff --git a/system/widgets/customer/recharge_a_friend.php b/system/widgets/customer/recharge_a_friend.php new file mode 100644 index 00000000..5d6ccb45 --- /dev/null +++ b/system/widgets/customer/recharge_a_friend.php @@ -0,0 +1,11 @@ +fetch('widget/customers/recharge_a_friend.tpl'); + } +} diff --git a/system/widgets/customer/unpaid_order.php b/system/widgets/customer/unpaid_order.php new file mode 100644 index 00000000..b4b5abbd --- /dev/null +++ b/system/widgets/customer/unpaid_order.php @@ -0,0 +1,39 @@ +where('username', $user['username']) + ->where('status', 1) + ->find_one(); + + // check expired payments + if ($unpaid) { + try { + if (strtotime($unpaid['expired_date']) < time()) { + $unpaid->status = 4; + $unpaid->save(); + $unpaid = []; + } + } catch (Throwable $e) { + } catch (Exception $e) { + } + try { + if (strtotime($unpaid['created_date'], "+24 HOUR") < time()) { + $unpaid->status = 4; + $unpaid->save(); + $unpaid = []; + } + } catch (Throwable $e) { + } catch (Exception $e) { + } + } + + $ui->assign('unpaid', $unpaid); + return $ui->fetch('widget/customers/unpaid_order.tpl'); + } +} diff --git a/system/widgets/customer/voucher_activation.php b/system/widgets/customer/voucher_activation.php new file mode 100644 index 00000000..5674feeb --- /dev/null +++ b/system/widgets/customer/voucher_activation.php @@ -0,0 +1,11 @@ +fetch('widget/customers/voucher_activation.tpl'); + } +} diff --git a/ui/ui/customer/dashboard.tpl b/ui/ui/customer/dashboard.tpl index 6cf5aa89..53efb76a 100644 --- a/ui/ui/customer/dashboard.tpl +++ b/ui/ui/customer/dashboard.tpl @@ -1,436 +1,39 @@ {include file="customer/header.tpl"} -
-
- {if $unpaid } -
-
-

{Lang::T('Unpaid Order')}

-
-
- - - - - - - - - - - - - - - - - - - -
{Lang::T('expired')}{Lang::dateTimeFormat($unpaid['expired_date'])}
{Lang::T('Package Name')}{$unpaid['plan_name']}
{Lang::T('Package Price')}{$unpaid['price']}
{Lang::T('Routers')}{$unpaid['routers']}
  -
-    -
+{function showWidget pos=0} + {foreach $widgets as $w} + {if $w['position'] == $pos} + {$w['content']} {/if} -
-
-

{Lang::T('Announcement')}

-
-
- {$Announcement_Customer = "{$PAGES_PATH}/Announcement_Customer.html"} - {if file_exists($Announcement_Customer)} - {include file=$Announcement_Customer} - {/if} + {/foreach} +{/function} + + +{assign rows explode(".", $_c['dashboard_Customer'])} +{assign pos 1} +{foreach $rows as $cols} + {if $cols == 12} +
+
+ {showWidget widgets=$widgets pos=$pos}
-
-
-
-
-

{Lang::T('Your Account Information')}

-
-
- - - - - - - - - - - - - - - {if $_c['enable_balance'] == 'yes'} - - - - - {/if} -
{Lang::T('Usernames')}{$_user['username']}
{Lang::T('Password')}
{Lang::T('Service Type')} - {if $_user.service_type == 'Hotspot'} - Hotspot - {elseif $_user.service_type == 'PPPoE'} - PPPoE - {elseif $_user.service_type == 'VPN'} - VPN - {elseif $_user.service_type == 'Others' || $_user.service_type == null} - Others - {/if} -
{Lang::T('Yours Balance')} - {Lang::moneyFormat($_user['balance'])} - {if $_user['auto_renewal'] == 1} - {Lang::T('Auto Renewal - On')} - {else} - {Lang::T('Auto Renewal - Off')} - {/if} -
   -
- {if $abills && count($abills)>0} -
-

{Lang::T('Additional Billing')}

+ {assign pos value=$pos+1} + {else} + {assign colss explode(",", $cols)} +
+ {foreach $colss as $c} +
+ {showWidget widgets=$widgets pos=$pos}
- -
- - {assign var="total" value=0} - {foreach $abills as $k => $v} - - - - - {/foreach} - - - - -
{str_replace(' Bill', '', $k)} - {if strpos($v, ':') === false} - {Lang::moneyFormat($v)} - - {assign var="total" value=$v+$total} - {else} - {assign var="exp" value=explode(':',$v)} - {Lang::moneyFormat($exp[0])} - {if $exp[1]==0}{Lang::T('paid - off')}{else}{$exp[1]}x{/if} - {if $exp[1]>0} - {assign var="total" value=$exp[0]+$total} - {/if} - {/if} -
{Lang::T('Total')} - {if $total==0} - {ucwords(Lang::T('paid off'))} - {else} - {Lang::moneyFormat($total)} - {/if} -
-
   - {/if} -
- {if $_bills} -
- {foreach $_bills as $_bill} - {if $_bill['routers'] != 'radius'} -
-

{$_bill['routers']}

-
- {if $_bill['type'] == 'Hotspot'} - {if $_c['hotspot_plan']==''}Hotspot Plan{else}{$_c['hotspot_plan']}{/if} - {else if $_bill['type'] == 'PPPOE'} - {if $_c['pppoe_plan']==''}PPPOE Plan{else}{$_c['pppoe_plan']}{/if} - {else if $_bill['type'] == 'VPN'} - {if $_c['pppoe_plan']==''}VPN Plan{else}{$_c['vpn_plan']}{/if} - {/if} -
-
- {else} -
-

{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}

-
- {/if} -
- - - - - - {if $_c['show_bandwidth_plan'] == 'yes'} - - - - - {/if} - - - - - - - - - - - - - {if $_bill['type'] == 'VPN' && $_bill['routers'] == $vpn['routers']} - - - - - - - - - {foreach $cf as $tcf} - - {if $tcf['field_name'] == 'Winbox' or $tcf['field_name'] == 'Api' or $tcf['field_name'] == 'Web'} - - - - {/if} - {/foreach} - {/if} - - {if $nux_ip neq ''} - - - - - {/if} - {if $nux_mac neq ''} - - - - - {/if} - {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on' && $_bill['routers'] != 'radius' && - $_c['hs_auth_method'] != 'hchap'} - - - - - {/if} - {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on' && $_c['hs_auth_method'] == 'hchap'} - - - - - {/if} - - - - -
{Lang::T('Package Name')} - {$_bill['namebp']} - {if $_bill['status'] != 'on'} - {Lang::T('Expired')} - {/if} -
{Lang::T('Bandwidth')} - {$_bill['name_bw']} -
{Lang::T('Created On')} - {if $_bill['time'] ne - ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])} - {/if} 
{Lang::T('Expires On')} - {if $_bill['time'] ne - ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}  -
{Lang::T('Type')} - {if $_bill['prepaid'] eq yes}Prepaid{else}Postpaid{/if} - {$_bill['plan_type']} -
{Lang::T('Public IP')}{$vpn['public_ip']} / {$vpn['port_name']}
{Lang::T('Private IP')}{$_user['pppoe_ip']}
{$tcf['field_name']} - Port{$tcf['field_value']}
{Lang::T('Current IP')}{$nux_ip}
{Lang::T('Current MAC')}{$nux_mac}
{Lang::T('Login Status')} - -
{Lang::T('Login Status')} - {if $logged == '1'} - {Lang::T('You - are - Online, Check Status')} - {else} - {Lang::T('Not Online, Login now?')} - {/if} -
- {if $_bill['status'] == 'on' && $_bill['prepaid'] != 'YES'} - - {/if} - - {if $_bill['status'] != 'on' && $_bill['prepaid'] != 'yes' && $_c['extend_expired']} - {Lang::T('Extend')} - {/if} - {Lang::T('Recharge')} - {Lang::T('Sync')} -
-
-    + {assign pos value=$pos+1} {/foreach}
- {/if} - {if $_c['disable_voucher'] == 'yes'} - - {/if} - {if $_bills} - {foreach $_bills as $_bill} - {if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on' && $_c['hs_auth_method'] != 'hchap'} - - {/if} - {/foreach} - {/if} - {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes'} -
-
-

{Lang::T("Transfer Balance")}

-
-
-
-
-
- -
-
- -
-
- -
-
-
- -
-
-

{Lang::T("Recharge a friend")}

-
-
-
-
-
- -
-
- -
-
-
-
-
- {/if} -
- {if $_c['disable_voucher'] != 'yes'} -
-
-

{Lang::T('Voucher Activation')}

-
-
-
-
- - - - - - - -
-
-
-
-
- - - {Lang::T('Order Voucher')} - - {if $_c['payment_gateway'] != 'none' or $_c['payment_gateway'] == '' } - - - {Lang::T('Order Package')} - - {/if} -
-
-
- {/if} -
-
+ {/if} +{/foreach} + + {if isset($hostname) && $hchap == 'true' && $_c['hs_auth_method'] == 'hchap'} + {/if} + {/foreach} +{/if} \ No newline at end of file diff --git a/ui/ui/widget/customers/announcement.tpl b/ui/ui/widget/customers/announcement.tpl new file mode 100644 index 00000000..8525df4d --- /dev/null +++ b/ui/ui/widget/customers/announcement.tpl @@ -0,0 +1,11 @@ +
+
+

{Lang::T('Announcement')}

+
+
+ {$Announcement_Customer = "{$PAGES_PATH}/Announcement_Customer.html"} + {if file_exists($Announcement_Customer)} + {include file=$Announcement_Customer} + {/if} +
+
\ No newline at end of file diff --git a/ui/ui/widget/customers/balance_transfer.tpl b/ui/ui/widget/customers/balance_transfer.tpl new file mode 100644 index 00000000..f7db2bd8 --- /dev/null +++ b/ui/ui/widget/customers/balance_transfer.tpl @@ -0,0 +1,38 @@ + +{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes'} +
+
+

{Lang::T("Transfer Balance")}

+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+{/if} \ No newline at end of file diff --git a/ui/ui/widget/customers/button_order_internet_plan.tpl b/ui/ui/widget/customers/button_order_internet_plan.tpl new file mode 100644 index 00000000..93393110 --- /dev/null +++ b/ui/ui/widget/customers/button_order_internet_plan.tpl @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/ui/ui/widget/customers/recharge_a_friend.tpl b/ui/ui/widget/customers/recharge_a_friend.tpl new file mode 100644 index 00000000..e0705f19 --- /dev/null +++ b/ui/ui/widget/customers/recharge_a_friend.tpl @@ -0,0 +1,20 @@ +
+
+

{Lang::T("Recharge a friend")}

+
+
+
+
+
+ +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/ui/ui/widget/customers/unpaid_order.tpl b/ui/ui/widget/customers/unpaid_order.tpl new file mode 100644 index 00000000..a49bb469 --- /dev/null +++ b/ui/ui/widget/customers/unpaid_order.tpl @@ -0,0 +1,48 @@ +{if $unpaid } +
+
+

{Lang::T('Unpaid Order')}

+
+
+ + + + + + + + + + + + + + + + + + + +
{Lang::T('expired')}{Lang::dateTimeFormat($unpaid['expired_date'])}
{Lang::T('Package Name')}{$unpaid['plan_name']}
{Lang::T('Package Price')}{$unpaid['price']}
{Lang::T('Routers')}{$unpaid['routers']}
  +
+    +
+{/if} \ No newline at end of file diff --git a/ui/ui/widget/customers/voucher_activation.tpl b/ui/ui/widget/customers/voucher_activation.tpl new file mode 100644 index 00000000..bb43c29d --- /dev/null +++ b/ui/ui/widget/customers/voucher_activation.tpl @@ -0,0 +1,38 @@ + +{if $_c['disable_voucher'] != 'yes'} +
+
+

{Lang::T('Voucher Activation')}

+
+
+
+
+ + + + + + + +
+
+
+
+
+ + + {Lang::T('Order Voucher')} + + {if $_c['payment_gateway'] != 'none' or $_c['payment_gateway'] == '' } + + + {Lang::T('Order Package')} + + {/if} +
+
+
+{/if} \ No newline at end of file