lims Posted March 23, 2019 Share Posted March 23, 2019 i want show recent client login widget in admin using gravatar like ==> modules/widgets/Staff.php example image below from adminLTE anyone please help me 0 Quote Link to comment Share on other sites More sharing options...
lims Posted March 23, 2019 Author Share Posted March 23, 2019 example widget <?php namespace WHMCS\Module\Widget; use WHMCS\Carbon; use WHMCS\Module\AbstractWidget; use WHMCS\User\Client; class ClientOnline extends AbstractWidget { protected $title = 'Client Online'; protected $description = 'Recent online clients.'; protected $weight = 50; protected $cache = true; protected $cacheExpiry = 60; protected $requiredPermission = 'List Clients'; public function getData() { return array( 'recentActiveClients' => Client::orderBy('lastlogin', 'desc')->limit(25) ->get(array('id', 'firstname', 'lastname', 'companyname', 'ip', 'lastlogin'))->toArray(), ); } public function generateOutput($data) { $clientOutput = ''; foreach ($data['recentActiveClients'] as $client) { $clientOutput .= '<div class="client">' . '<img src="https://www.gravatar.com/avatar/' . $client['email']['gravatarHash'] . '?s=60&d=mm" width="60" height="60" />' . '<div class="name">' . $client['lastlogin']['firstname'] . ' ' . $client['lastlogin']['lastname'] . '</div>' . '<div class="note text-muted">' . Carbon::createFromFormat('Y-m-d H:i:s', $client['lastvisit'])->diffForHumans() . '</div>' . '</div>'; } return <<<EOF <div class="clients-list"> {$clientOutput} </div> EOF; } } 0 Quote Link to comment Share on other sites More sharing options...
lims Posted March 23, 2019 Author Share Posted March 23, 2019 already fixed with my self using return array( 'client' => Client::orderBy('lastlogin', 'desc')->limit(6) ->get(array('email', 'id', 'firstname', 'lastname', 'ip', 'lastlogin'))->toArray(), ); $client['email']['gravatarHash'] change to md5($client['email']) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 24, 2019 Share Posted March 24, 2019 @lims - can you post the entire file, as this doesn't work for me when I test it locally. 0 Quote Link to comment Share on other sites More sharing options...
lims Posted March 24, 2019 Author Share Posted March 24, 2019 9 minutes ago, brian! said: @lims - can you post the entire file, as this doesn't work for me when I test it locally. @brian! here this full custom already modified <?php namespace WHMCS\Module\Widget; use WHMCS\Carbon; use WHMCS\Module\AbstractWidget; use WHMCS\User\Client; class ClientOnline extends AbstractWidget { protected $title = 'Client Last Login'; protected $weight = 80; protected $cache = true; protected $cacheExpiry = 60; protected $requiredPermission = 'List Clients'; public function getData() { return array( 'client' => Client::orderBy('lastlogin', 'desc')->limit(24) ->get(array('email', 'id', 'firstname', 'lastname', 'ip', 'lastlogin'))->toArray(), ); } public function generateOutput($data) { $clientOutput = ''; $clients = array(); foreach ($data['client'] as $client) { $clientOutput .= '<div class="staff">' . '<a href="clientssummary.php?userid='.$client['id'].'"><img class="body-avatar" src="https://www.gravatar.com/avatar/'.md5($client['email']).'?s=60&d=mm" width="60" height="60"/></a>' . '<div class="name">'.$client['firstname'].' '.$client['lastname'].'</div>' . '<small><a href="http://www.geoiptool.com/en/?IP='.$client['ip'].'" target="_blank" class="name" style="color:red">'.$client['ip'].'</a></small>' . '<div class="note text-muted">' . Carbon::createFromFormat('Y-m-d H:i:s', $client['lastlogin'])->diffForHumans().'</div>' . '</div>'; } return <<<EOF <div class="widget-staff-container clearfix"> {$clientOutput} </div> EOF; } } 2 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.