User Inbox

This commit is contained in:
Ibnu Maksum 2024-08-05 10:05:10 +07:00
parent 150f9a5c41
commit be507a013a
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
6 changed files with 130 additions and 69 deletions

View File

@ -229,7 +229,7 @@ CREATE TABLE `tbl_customers_inbox` (
`date_created` datetime NOT NULL,
`date_read` datetime DEFAULT NULL,
`subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL,
`body` varchar(512) COLLATE utf8mb4_general_ci NOT NULL,
`body` TEXT NULL DEFAULT NULL,
`from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',
`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0',
PRIMARY KEY (`id`)

View File

@ -44,16 +44,17 @@ class Text
return $result;
}
public static function maskText($text){
public static function maskText($text)
{
$len = strlen($text);
if($len < 3){
if ($len < 3) {
return "***";
}else if($len<5){
return substr($text,0,1)."***".substr($text,-1,1);
}else if($len<8){
return substr($text,0,2)."***".substr($text,-2,2);
}else{
return substr($text,0,4)."******".substr($text,-3,3);
} else if ($len < 5) {
return substr($text, 0, 1) . "***" . substr($text, -1, 1);
} else if ($len < 8) {
return substr($text, 0, 2) . "***" . substr($text, -2, 2);
} else {
return substr($text, 0, 4) . "******" . substr($text, -3, 3);
}
}
@ -61,4 +62,9 @@ class Text
{
return preg_replace("/[^A-Za-z0-9]/", '_', $str);;
}
public static function is_html($string)
{
return preg_match("/<[^<]+>/", $string, $m) != 0;
}
}

View File

@ -20,11 +20,26 @@ switch ($action) {
$mail->date_read = date('Y-m-d H:i:s');
$mail->save();
}
$next = ORM::for_table('tbl_customers_inbox')->select("id")->where('customer_id', $user['id'])->where_gt("id", $routes['2'])->order_by_asc("id")->find_one();
$prev = ORM::for_table('tbl_customers_inbox')->select("id")->where('customer_id', $user['id'])->where_lt("id", $routes['2'])->order_by_desc("id")->find_one();
$ui->assign('next', $next['id']);
$ui->assign('prev', $prev['id']);
$ui->assign('mail', $mail);
$ui->assign('tipe', 'view');
$ui->assign('_system_menu', 'inbox');
$ui->assign('_title', Lang::T('Inbox'));
$ui->display('user-inbox.tpl');
break;
case 'delete':
if($routes['2']){
if(ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->where('id', $routes['2'])->find_one()->delete()){
r2(U. 'mail', 's', Lang::T('Mail Deleted Successfully'));
}else{
r2(U. 'home', 'e', Lang::T('Failed to Delete Message'));
}
break;
}
default:
$q = _req('q');
$limit = 40;

View File

@ -685,6 +685,8 @@
"Channel": "Channel",
"Payment_Link": "Payment Link",
"Created": "Created",
"2": "2",
"_": "-"
"Previous": "Previous",
"Share": "Share",
"Mail_Deleted_Successfully": "Mail Deleted Successfully",
"Message_Not_Found": "Message Not Found"
}

View File

@ -135,6 +135,6 @@
"ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';"
],
"2024.8.2" : [
"CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` varchar(512) COLLATE utf8mb4_general_ci NOT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"
"CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;"
]
}

View File

@ -1,74 +1,112 @@
{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 class="mailbox-read-info">
<h3>{$mail['subject']}</h3>
<h5>From: {$mail['from']}
<span class="mailbox-read-time pull-right" data-toggle="tooltip" data-placement="top"
title="Read at {Lang::dateTimeFormat($mail['date_read'])}">{Lang::dateTimeFormat($mail['date_created'])}</span>
</h5>
</div>
<div class="mailbox-read-message">
{if Text::is_html($mail['body'])}
{$mail['body']}
{else}
{nl2br($mail['body'])}
{/if}
</div>
</div>
<div class="box-footer">
<div class="pull-right">
{if $prev}
<a href="{$_url}mail/view/{$prev}" class="btn btn-default"><i class="fa fa-chevron-left"></i>
{Lang::T("Previous")}</a>
{/if}
{if $next}
<a href="{$_url}mail/view/{$next}" class="btn btn-default"><i class="fa fa-chevron-right"></i>
{Lang::T("Next")}</a>
{/if}
</div>
<a href="{$_url}mail/delete/{$mail['id']}" class="btn btn-danger"
onclick="return confirm('{Lang::T("Delete")}?')"><i class="fa fa-trash-o"></i>
{Lang::T("Delete")}</a>
<a href="https://api.whatsapp.com/send?text={if Text::is_html($mail['body'])}{urlencode(strip_tags($mail['body']))}{else}{urlencode($mail['body'])}{/if}" class="btn btn-primary"><i class="fa fa-share"></i> {Lang::T("Share")}</a>
</div>
<!-- /.box-footer -->
</div>
{else}
<div class="box box-primary">
<div class="box-header with-border">
<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>
<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>
</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="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 class="table-responsive mailbox-messages">
<table class="table table-hover table-striped table-bordered">
<tbody>
{foreach $mails as $mail}
<tr>
<td class="mailbox-subject">
<a href="{$_url}mail/view/{$mail['id']}">
<div>
{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}
<b>{$mail['subject']}</b>
</div>
</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}