diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql
index 73a3be1b..f66eb5c4 100644
--- a/install/phpnuxbill.sql
+++ b/install/phpnuxbill.sql
@@ -222,7 +222,8 @@ CREATE TABLE `rad_acct` (
`dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (
+DROP TABLE IF EXISTS `tbl_customers_inbox`;
+CREATE TABLE `tbl_customers_inbox` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`customer_id` int NOT NULL,
`date_created` datetime NOT NULL,
diff --git a/system/controllers/autoload_user.php b/system/controllers/autoload_user.php
index 6e67f7c3..78b51c14 100644
--- a/system/controllers/autoload_user.php
+++ b/system/controllers/autoload_user.php
@@ -45,6 +45,18 @@ switch ($action) {
die('--');
}
break;
+ case 'inbox_unread':
+ $count = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->whereRaw('date_read is null')->count('id');
+ if($count>0){
+ echo $count;
+ }
+ die();
+ case 'inbox':
+ $inboxs = ORM::for_table('tbl_customers_inbox')->selects(['id', 'subject', 'date_created'])->where('customer_id', $user['id'])->whereRaw('date_read is null')->order_by_desc('date_created')->limit(10)->find_many();
+ foreach($inboxs as $inbox){
+ echo '
'.$inbox['subject'].'
'.Lang::dateTimeFormat($inbox['date_created']).'';
+ }
+ die();
default:
$ui->display('404.tpl');
}
diff --git a/system/controllers/mail.php b/system/controllers/mail.php
new file mode 100644
index 00000000..c47f0b9d
--- /dev/null
+++ b/system/controllers/mail.php
@@ -0,0 +1,46 @@
+assign('_user', $user);
+
+switch ($action) {
+ case 'view':
+ $mail = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->find_one($routes['2']);
+ if(!$mail){
+ r2(U. 'mail', 'e', Lang::T('Message Not Found'));
+ }
+ if($mail['date_read'] == null){
+ $mail->date_read = date('Y-m-d H:i:s');
+ $mail->save();
+ }
+ $ui->assign('mail', $mail);
+ $ui->assign('tipe', 'view');
+ $ui->assign('_system_menu', 'inbox');
+ $ui->assign('_title', Lang::T('Inbox'));
+ $ui->display('user-inbox.tpl');
+ default:
+ $q = _req('q');
+ $limit = 40;
+ $p = (int) _req('p', 0);
+ $offset = $p * $limit;
+ $query = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->order_by_desc('date_created');
+ $query->limit($limit)->offset($offset);
+ if(!empty($q)){
+ $query->whereRaw("(subject like '%$q%' or body like '%$q%')");
+ }
+ $mails = $query->find_array();
+ $ui->assign('tipe', '');
+ $ui->assign('q', $q);
+ $ui->assign('p', $p);
+ $ui->assign('mails', $mails);
+ $ui->assign('_system_menu', 'inbox');
+ $ui->assign('_title', Lang::T('Inbox'));
+ $ui->display('user-inbox.tpl');
+}
\ No newline at end of file
diff --git a/ui/ui/paymentgateway-audit.tpl b/ui/ui/paymentgateway-audit.tpl
index 7c97a2f0..e10de7d3 100644
--- a/ui/ui/paymentgateway-audit.tpl
+++ b/ui/ui/paymentgateway-audit.tpl
@@ -9,8 +9,7 @@
-
+
diff --git a/ui/ui/sections/user-header.tpl b/ui/ui/sections/user-header.tpl
index e625871f..ffde8b59 100644
--- a/ui/ui/sections/user-header.tpl
+++ b/ui/ui/sections/user-header.tpl
@@ -87,6 +87,19 @@