[UPDATE] added notifications to header
This commit is contained in:
parent
872661704d
commit
8f4c5cc570
@ -58,10 +58,10 @@ class Notification extends Mail {
|
|||||||
* @param id int Account ID
|
* @param id int Account ID
|
||||||
* @return array Notification data
|
* @return array Notification data
|
||||||
**/
|
**/
|
||||||
public function getNofifications($account_id) {
|
public function getNofifications($account_id,$limit=50) {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? ORDER BY time DESC");
|
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? ORDER BY time DESC LIMIT ?");
|
||||||
if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
if ($stmt && $stmt->bind_param('ii', $account_id, $limit) && $stmt->execute() && $result = $stmt->get_result())
|
||||||
return $result->fetch_all(MYSQLI_ASSOC);
|
return $result->fetch_all(MYSQLI_ASSOC);
|
||||||
return $this->getError();
|
return $this->getError();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Smarty plugin
|
||||||
|
* -------------------------------------------------------------
|
||||||
|
* Type: modifier
|
||||||
|
* Name: relative_date
|
||||||
|
* Version: 1.1
|
||||||
|
* Date: November 28, 2008
|
||||||
|
* Author: Chris Wheeler <chris@haydendigital.com>
|
||||||
|
* Purpose: Output dates relative to the current time
|
||||||
|
* Input: timestamp = UNIX timestamp or a date which can be converted by strtotime()
|
||||||
|
* days = use date only and ignore the time
|
||||||
|
* format = (optional) a php date format (for dates over 1 year)
|
||||||
|
* -------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
function smarty_modifier_relative_date($timestamp, $days = false, $format = "M j, Y") {
|
||||||
|
|
||||||
|
if (!is_numeric($timestamp)) {
|
||||||
|
// It's not a time stamp, so try to convert it...
|
||||||
|
$timestamp = strtotime($timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($timestamp)) {
|
||||||
|
// If its still not numeric, the format is not valid
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the difference in seconds
|
||||||
|
$difference = time() - $timestamp;
|
||||||
|
|
||||||
|
// Check if we only want to calculate based on the day
|
||||||
|
if ($days && $difference < (60*60*24)) {
|
||||||
|
return "Today";
|
||||||
|
}
|
||||||
|
if ($difference < 3) {
|
||||||
|
return "Just now";
|
||||||
|
}
|
||||||
|
if ($difference < 60) {
|
||||||
|
return $difference . " seconds ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*2)) {
|
||||||
|
return "1 minute ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60)) {
|
||||||
|
return intval($difference / 60) . " minutes ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*2)) {
|
||||||
|
return "1 hour ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24)) {
|
||||||
|
return intval($difference / (60*60)) . " hours ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*2)) {
|
||||||
|
return "1 day ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*7)) {
|
||||||
|
return intval($difference / (60*60*24)) . " days ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*7*2)) {
|
||||||
|
return "1 week ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*7*(52/12))) {
|
||||||
|
return intval($difference / (60*60*24*7)) . " weeks ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*7*(52/12)*2)) {
|
||||||
|
return "1 month ago";
|
||||||
|
}
|
||||||
|
if ($difference < (60*60*24*364)) {
|
||||||
|
return intval($difference / (60*60*24*7*(52/12))) . " months ago";
|
||||||
|
}
|
||||||
|
|
||||||
|
// More than a year ago, just return the formatted date
|
||||||
|
return @date($format, $timestamp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -42,6 +42,9 @@ $iCurrentPoolShareRate = $statistics->getCurrentShareRate();
|
|||||||
// Active workers
|
// Active workers
|
||||||
if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0;
|
if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0;
|
||||||
|
|
||||||
|
// Fetch Last 5 notifications
|
||||||
|
$iLastNotifications = $notification->getNofifications($_SESSION['USERDATA']['id'], 5);
|
||||||
|
|
||||||
// Some settings to propagate to template
|
// Some settings to propagate to template
|
||||||
if (! $statistics_ajax_refresh_interval = $setting->getValue('statistics_ajax_refresh_interval')) $statistics_ajax_refresh_interval = 10;
|
if (! $statistics_ajax_refresh_interval = $setting->getValue('statistics_ajax_refresh_interval')) $statistics_ajax_refresh_interval = 10;
|
||||||
if (! $statistics_ajax_long_refresh_interval = $setting->getValue('statistics_ajax_long_refresh_interval')) $statistics_ajax_long_refresh_interval = 10;
|
if (! $statistics_ajax_long_refresh_interval = $setting->getValue('statistics_ajax_long_refresh_interval')) $statistics_ajax_long_refresh_interval = 10;
|
||||||
@ -56,6 +59,7 @@ $aGlobal = array(
|
|||||||
'hashrate' => $iCurrentPoolHashrate,
|
'hashrate' => $iCurrentPoolHashrate,
|
||||||
'nethashrate' => $dNetworkHashrate,
|
'nethashrate' => $dNetworkHashrate,
|
||||||
'sharerate' => $iCurrentPoolShareRate,
|
'sharerate' => $iCurrentPoolShareRate,
|
||||||
|
'lastnotifications' => $iLastNotifications,
|
||||||
'workers' => $iCurrentActiveWorkers,
|
'workers' => $iCurrentActiveWorkers,
|
||||||
'roundshares' => $aRoundShares,
|
'roundshares' => $aRoundShares,
|
||||||
'fees' => $config['fees'],
|
'fees' => $config['fees'],
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<i class="fa-{if $NOTIFICATIONS[notification].active}check{else}times{/if} fa-fw"></i>
|
<i class="fa fa-{if $NOTIFICATIONS[notification].active}check{else}times{/if} fa-fw"></i>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/section}
|
{/section}
|
||||||
|
|||||||
@ -11,6 +11,43 @@
|
|||||||
<!-- /.navbar-header -->
|
<!-- /.navbar-header -->
|
||||||
|
|
||||||
<ul class="nav navbar-top-links navbar-right">
|
<ul class="nav navbar-top-links navbar-right">
|
||||||
|
{if $smarty.session.AUTHENTICATED|default:"0" == 1 && $GLOBAL.lastnotifications|@count != 0}
|
||||||
|
<!-- /.dropdown -->
|
||||||
|
<li class="dropdown">
|
||||||
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu dropdown-alerts">
|
||||||
|
|
||||||
|
|
||||||
|
{section notification $GLOBAL.lastnotifications}
|
||||||
|
<li>
|
||||||
|
<a href="#">
|
||||||
|
<div>
|
||||||
|
{if $GLOBAL.lastnotifications[notification].type == new_block}<i class="fa fa-th-large fa-fw"></i> New Block
|
||||||
|
{else if $GLOBAL.lastnotifications[notification].type == auto_payout}<i class="fa fa-money fa-fw"></i> Auto Payout
|
||||||
|
{else if $GLOBAL.lastnotifications[notification].type == payout}<i class="fa fa-money fa-fw"></i> Manual Payout
|
||||||
|
{else if $GLOBAL.lastnotifications[notification].type == idle_worker}<i class="fa fa-desktop fa-fw"></i> IDLE Worker
|
||||||
|
{else if $GLOBAL.lastnotifications[notification].type == manual_payout}<i class="fa fa-money fa-fw"></i> Manual Payout
|
||||||
|
{else if $GLOBAL.lastnotifications[notification].type == success_login}<i class="fa fa-sign-in fa-fw"></i> Successful Login
|
||||||
|
{/if}
|
||||||
|
<span class="pull-right text-muted small">{$GLOBAL.lastnotifications[notification].time|relative_date}</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="divider"></li>
|
||||||
|
{/section}
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a class="text-center" href="{$smarty.server.SCRIPT_NAME}?page=account&action=notifications">
|
||||||
|
<strong>See All Notifications</strong>
|
||||||
|
<i class="fa fa-angle-right"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- /.dropdown-alerts -->
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
<!-- /.dropdown -->
|
<!-- /.dropdown -->
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
|||||||
@ -11,10 +11,7 @@
|
|||||||
<![endif]-->
|
<![endif]-->
|
||||||
<script type="text/javascript" src="{$PATH}/js/jquery-2.0.3.min.js"></script>
|
<script type="text/javascript" src="{$PATH}/js/jquery-2.0.3.min.js"></script>
|
||||||
<script type="text/javascript" src="{$PATH}/js/jquery-migrate-1.2.1.min.js"></script>
|
<script type="text/javascript" src="{$PATH}/js/jquery-migrate-1.2.1.min.js"></script>
|
||||||
<script type="text/javascript" src="{$PATH}/js/hideshow.js" type="text/javascript"></script>
|
|
||||||
<script type="text/javascript" src="{$PATH}/js/jquery.equalHeight.js"></script>
|
<script type="text/javascript" src="{$PATH}/js/jquery.equalHeight.js"></script>
|
||||||
<script type="text/javascript" src="{$PATH}/js/custom.js"></script>
|
|
||||||
<script type="text/javascript" src="{$PATH}/js/tinybox.js"></script>
|
|
||||||
<script type="text/javascript" src="{$PATH}/../global/js/number_format.js"></script>
|
<script type="text/javascript" src="{$PATH}/../global/js/number_format.js"></script>
|
||||||
<!--[if IE]><script type="text/javascript" src="{$PATH}/js/excanvas.js"></script><![endif]-->
|
<!--[if IE]><script type="text/javascript" src="{$PATH}/js/excanvas.js"></script><![endif]-->
|
||||||
{literal}<script>
|
{literal}<script>
|
||||||
@ -64,5 +61,4 @@
|
|||||||
<script src="{$PATH}/js/plugins/morris/morris.js"></script>
|
<script src="{$PATH}/js/plugins/morris/morris.js"></script>
|
||||||
|
|
||||||
<script src="{$PATH}/js/mpos.js"></script>
|
<script src="{$PATH}/js/mpos.js"></script>
|
||||||
<script type="text/javascript" src="{$PATH}/js/justgage.1.0.1.min.js"></script>
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user