customer inbox
This commit is contained in:
parent
1843ff222d
commit
587437c93c
@ -222,7 +222,8 @@ CREATE TABLE `rad_acct` (
|
|||||||
`dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) 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,
|
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`customer_id` int NOT NULL,
|
`customer_id` int NOT NULL,
|
||||||
`date_created` datetime NOT NULL,
|
`date_created` datetime NOT NULL,
|
||||||
|
@ -45,6 +45,18 @@ switch ($action) {
|
|||||||
die('--');
|
die('--');
|
||||||
}
|
}
|
||||||
break;
|
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 '<li><a href="'.U.'mail/view/'.$inbox['id'].'">'.$inbox['subject'].'<br><sub class="text-muted">'.Lang::dateTimeFormat($inbox['date_created']).'</sub></a></li>';
|
||||||
|
}
|
||||||
|
die();
|
||||||
default:
|
default:
|
||||||
$ui->display('404.tpl');
|
$ui->display('404.tpl');
|
||||||
}
|
}
|
||||||
|
46
system/controllers/mail.php
Normal file
46
system/controllers/mail.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
|
* by https://t.me/ibnux
|
||||||
|
**/
|
||||||
|
|
||||||
|
_auth();
|
||||||
|
$action = $routes['1'];
|
||||||
|
$user = User::_info();
|
||||||
|
$ui->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');
|
||||||
|
}
|
@ -9,8 +9,7 @@
|
|||||||
<input type="text" name="q" class="form-control" placeholder="{Lang::T('Search')}..."
|
<input type="text" name="q" class="form-control" placeholder="{Lang::T('Search')}..."
|
||||||
value="{$q}">
|
value="{$q}">
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button type="submit" class="btn btn-danger" title="Clear Search Query"
|
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-search"></span></button>
|
||||||
href="{$_url}plan/list"><span class="glyphicon glyphicon-search"></span></button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -87,6 +87,19 @@
|
|||||||
</a>
|
</a>
|
||||||
<div class="navbar-custom-menu">
|
<div class="navbar-custom-menu">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="dropdown notifications-menu">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||||
|
<i class="fa fa-envelope-o"></i>
|
||||||
|
<span class="label label-warning" api-get-text="{$_url}autoload_user/inbox_unread"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<!-- inner menu: contains the actual data -->
|
||||||
|
<ul class="menu" api-get-text="{$_url}autoload_user/inbox"></ul>
|
||||||
|
</li>
|
||||||
|
<li class="footer"><a href="{$_url}mail">{Lang::T('Inbox')}</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="dropdown user user-menu">
|
<li class="dropdown user user-menu">
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
{if $_c['enable_balance'] == 'yes'}
|
{if $_c['enable_balance'] == 'yes'}
|
||||||
@ -146,6 +159,13 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{$_MENU_AFTER_DASHBOARD}
|
{$_MENU_AFTER_DASHBOARD}
|
||||||
|
<li {if $_system_menu eq 'inbox'}class="active" {/if}>
|
||||||
|
<a href="{$_url}mail">
|
||||||
|
<i class="fa fa-envelope"></i>
|
||||||
|
<span>{Lang::T('Inbox')}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{$_MENU_AFTER_INBOX}
|
||||||
{if $_c['disable_voucher'] != 'yes'}
|
{if $_c['disable_voucher'] != 'yes'}
|
||||||
<li {if $_system_menu eq 'voucher'}class="active" {/if}>
|
<li {if $_system_menu eq 'voucher'}class="active" {/if}>
|
||||||
<a href="{$_url}voucher/activation">
|
<a href="{$_url}voucher/activation">
|
||||||
|
75
ui/ui/user-inbox.tpl
Normal file
75
ui/ui/user-inbox.tpl
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{include file="sections/user-header.tpl"}
|
||||||
|
|
||||||
|
{if $tipe == 'view'}
|
||||||
|
|
||||||
|
{else}
|
||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">Inbox</h3>
|
||||||
|
<form method="post">
|
||||||
|
<div class="box-tools pull-right">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="q" class="form-control" placeholder="{Lang::T('Search')}..." value="{$q}">
|
||||||
|
<div class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-success"><span
|
||||||
|
class="glyphicon glyphicon-search"></span></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="box-body no-padding">
|
||||||
|
<div class="mailbox-controls">
|
||||||
|
<a href="{$_url}mail" class="btn btn-default btn-sm"><i class="fa fa-refresh"></i></a>
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="btn-group">
|
||||||
|
{if $p>0}
|
||||||
|
<a href="{$_url}mail&p={$p-1}&q={urlencode($q)}" class="btn btn-default btn-sm"><i
|
||||||
|
class="fa fa-chevron-left"></i></a>
|
||||||
|
{/if}
|
||||||
|
<a href="{$_url}mail&p={$p+1}&q={urlencode($q)}" class="btn btn-default btn-sm"><i
|
||||||
|
class="fa fa-chevron-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive mailbox-messages">
|
||||||
|
<table class="table table-hover table-striped table-bordered">
|
||||||
|
<tbody>
|
||||||
|
{foreach $mails as $mail}
|
||||||
|
<tr>
|
||||||
|
<td class="mailbox-subject">
|
||||||
|
{if $mail['date_read'] == null}
|
||||||
|
<i class="fa fa-envelope text-yellow" title="unread"></i>
|
||||||
|
{else}
|
||||||
|
<i class="fa fa-envelope-o text-yellow" title="read"></i>
|
||||||
|
{/if}<a href="{$_url}mail/view/{$mail['id']}"><b>{$mail['subject']}</b></a>
|
||||||
|
</td>
|
||||||
|
<td class="mailbox-name">{$mail['from']}</td>
|
||||||
|
<td class="mailbox-attachment"></td>
|
||||||
|
<td class="mailbox-date">{Lang::dateTimeFormat($mail['date_created'])}</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer no-padding">
|
||||||
|
<div class="mailbox-controls">
|
||||||
|
<a href="{$_url}mail" class="btn btn-default btn-sm"><i class="fa fa-refresh"></i></a>
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="btn-group">
|
||||||
|
{if $p>0}
|
||||||
|
<a href="{$_url}mail&p={$p-1}&q={urlencode($q)}" class="btn btn-default btn-sm"><i
|
||||||
|
class="fa fa-chevron-left"></i></a>
|
||||||
|
{/if}
|
||||||
|
<a href="{$_url}mail&p={$p+1}&q={urlencode($q)}" class="btn btn-default btn-sm"><i
|
||||||
|
class="fa fa-chevron-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{include file="sections/user-footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user