sol2010 Posted August 21, 2018 Share Posted August 21, 2018 Hi @brian! Hope you're doing well. The wonderful hook you wrote here: https://whmcs.community/topic/261921-network-announcement-on-client-area/ has stopped working in the recent version of WHMCS v 7.6 Does yours still work? Just to clarify, I've added the following code into a hook page in the /hooks folder. Do I also need to add additional code in the template? <?php # Network Issues HomePagePanel # Written by brian! use Illuminate\Database\Capsule\Manager as Capsule; use Carbon\Carbon; add_hook('ClientAreaHomepagePanels', 1, function($homePagePanels) { $client = Menu::context('client'); $networkissues = Capsule::table('tblnetworkissues') ->join('tblhosting', 'tblnetworkissues.server', '=', 'tblhosting.server') ->leftjoin('tblservers','tblnetworkissues.server', '=', 'tblservers.id') ->select('tblnetworkissues.*','tblservers.name') ->where('tblhosting.userid', $client->id) ->whereDate('tblnetworkissues.enddate', '>=', Carbon::today()) ->orwhereIn('tblnetworkissues.status',['Investigating','Reported','In Progress','Outage']) ->where('tblnetworkissues.type','Server') ->orderby('tblnetworkissues.lastupdate','desc') ->groupby('tblnetworkissues.id') ->take(3) ->get(); if (count($networkissues) > 0) { $bodyhtml = '<div class="list-group">'; foreach ($networkissues as $issue) { if ($issue->priority == "Critical") {$prioritycolor = 'red';} elseif ($issue->priority == "High") {$prioritycolor = 'magenta';} elseif ($issue->priority == "Medium") {$prioritycolor = 'orange';} elseif ($issue->priority == "Low") {$prioritycolor = 'green';} else {$prioritycolor = 'grey';} if ($issue->enddate) { $bodyhtml .= '<li class="list-group-item"><a href="serverstatus.php"><b>'.$issue->title.'</b></a> <label class="label" style="background-color: lightgrey; color: black">'.$issue->status.'</label> <label class="label" style="background-color: '.$prioritycolor.'">'.$issue->priority.'</label><br>'.Lang::trans('networkissuesaffecting').' '.$issue->type.' - '.$issue->affecting.' '.$issue->name.'<br><span style="color: black">'.$issue->description.'</span><br>'.Lang::trans('networkissuesstatusscheduled').': '.fromMySQLDate($issue->startdate, true, true).' - '.fromMySQLDate($issue->enddate, true, true).'</li>'; } elseif ($issue->lastupdate) { $bodyhtml .= '<li class="list-group-item"><a href="serverstatus.php"><b>'.$issue->title.'</b></a> <label class="label" style="background-color: lightgrey; color: black">'.$issue->status.'</label> <label class="label" style="background-color: '.$prioritycolor.'">'.$issue->priority.'</label><br>'.Lang::trans('networkissuesaffecting').' '.$issue->type.' - '.$issue->affecting.' '.$issue->name.'<br><span style="color: black">'.$issue->description.'</span><br>'.Lang::trans('networkissueslastupdated').' - '.fromMySQLDate($issue->lastupdate, true, true).'</li>'; } } $bodyhtml .= '</div>'; $homePagePanels->addChild('networkissues', array( 'label' => Lang::trans('networkissuestitle'), 'icon' => 'fa-exclamation-triangle', 'order' => 3, 'extras' => array( 'color' => 'red', 'btn-link' => 'serverstatus.php', 'btn-text' => Lang::trans('viewAll'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml, )); } }); 0 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted August 21, 2018 Author Share Posted August 21, 2018 Opps - my bad it is still working on the clientarea.php (clientareahome.tpl) However, it's stopped working on the homepage.tpl - I was using the following code which no longer seems to work. Any ideas? {foreach $networkissues as $issue} <div id="homePage-Notification"> <div class='alert alert-{if $issue.priority eq 'Critical'}danger{elseif $issue.priority eq 'Low'}success{elseif $issue.priority eq 'High'}warning{else}info{/if}'> <a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a> <h4 class="title">Network Status Notifications Affecting Your Services</h4> <a href='serverstatus.php'><h4 class="issue_title"> {$issue.title} <div class="posteddate">Last Updated: {$issue.lastupdate|date_format:"%d/%m/%Y %H:%M "}</div></h4> </a> {$issue.description} <a href='serverstatus.php' class="readmore">Click to read more</a> </div> </div> {/foreach} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 21, 2018 Share Posted August 21, 2018 8 hours ago, sol2010 said: However, it's stopped working on the homepage.tpl - I was using the following code which no longer seems to work. Any ideas? still works on my v7.6 dev - but don't forget, as the hook is written, the client would need to be logged in for this to work (otherwise the array will always be empty). 0 Quote Link to comment Share on other sites More sharing options...
sol2010 Posted August 21, 2018 Author Share Posted August 21, 2018 Thanks for the confirmation. I will try to figure it out. I am using a custom theme template, not sure if that has any relevance. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 21, 2018 Share Posted August 21, 2018 Just now, sol2010 said: I am using a custom theme template, not sure if that has any relevance. it shouldn't do - the hook needs a client ID to look for appropriate servers... if it's outputting nothing, that should mean the query result is empty and the resulting $networkissues array will be empty... it's also possible that the client you're testing with doesn't have any applicable servers with network issues... so you should probably check with multiple clients just to ensure that isn't the case. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.