Dgital Essence Posted October 14, 2015 Share Posted October 14, 2015 Hi, I'm not sure if this has already been done but I use Sticky Notes to record additional work that needs to be invoiced at a later date but kept on forgetting who I'd done extra work for. So I've created a widget for the Admin Summary page that displays all the Sticky Notes with links through to the Customers Note and also the customer summary. Just create a new file in modules/widgets and paste this code in. Then head over to Setup > Staff Management > Administrator Roles > Edit and scroll down to Widgets and then tick yours (in this example it's called "Display Customer\'s Sticky Notes". This was created in Version: 5.3.11 and is still working in 6.1.1 but it if breaks yours or makes the sky fall down, I'm not liable... ?php # WHMCS Widget to display sticky notes on the Admin Summary # Hedley Phillips - Digital Essence if (!defined("WHMCS")) die("This file cannot be accessed directly"); function widget_display_sticky_notes() { $content = '<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1"> <tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>Customer</td><td>Note</td><td>Modified</td></tr>'; $x=1; $range = "<= 364"; $result = mysql_query("SELECT * FROM `tblnotes` JOIN tblclients ON tblclients.id=tblnotes.userid WHERE `sticky` = '1'"); while ($data = @mysql_fetch_array ($result)) { $noteid = $data["id"]; $userid = $data["userid"]; $firstname = $data["firstname"]; $lastname = $data["lastname"]; $note = $data["note"]; $date = $data["modified"]; $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="/whmcsadmin/clientssummary.php?userid='.$userid.'">'.$firstname. ' ' .$lastname.'</a></td><td><a href="/whmcsadmin/clientsnotes.php?userid='.$userid.'&action=edit&id='.$noteid.'">'.$note.'</a></td><td>'.$date.'</td></tr>'; $x=0; } if($x) $content = '<tr bgcolor="#ffffff" style="text-align:center;"><td colspan="7">No Sticky Notes to display</td></tr>'; $content .= '</table>'; return array( 'title' => 'Display Customer\'s Sticky Notes', 'content' => $content ); } add_hook("AdminHomeWidgets",1,"widget_display_sticky_notes"); ?> NOTE: What I can't get to work and am looking for input from others on is the edit function. I'm using: <a href="/whmcsadmin/clientsnotes.php?userid='.$userid.'&action=edit&id='.$noteid.'"> where: $noteid = $data["id"]; $userid = $data["userid"]; but it keeps on putting the customer id in both $userid and $noteid and I can't work out why. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 14, 2015 Share Posted October 14, 2015 (edited) What I can't get to work and am looking for input from others on is the edit function - it keeps on putting the customer id in both $userid and $noteid and I can't work out why. it was because your SQL query contained two different 'id' fields and it was using the wrong one. i've taken the liberty of cleaning up the widget code... <?php # WHMCS Widget to display sticky notes on the Admin Summary # Hedley Phillips - Digital Essence if (!defined("WHMCS")) die("This file cannot be accessed directly"); function widget_sticky_notes() { global $_ADMINLANG; $content = '<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1"><tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['client'].'</td><td>'.$_ADMINLANG['fields']['note'].'</td><td>'.$_ADMINLANG['fields']['lastmodified'].'</td></tr>'; $x=1; $result = mysql_query("SELECT tblnotes.id,tblnotes.userid,tblnotes.modified,tblnotes.note,tblnotes.sticky,tblclients.firstname,tblclients.lastname FROM `tblnotes` JOIN tblclients ON tblclients.id=tblnotes.userid WHERE `sticky` = '1'"); while ($data = @mysql_fetch_array ($result)) { $noteid = $data["id"]; $userid = $data["userid"]; $firstname = $data["firstname"]; $lastname = $data["lastname"]; $note = $data["note"]; $date = $data["modified"]; $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientssummary.php?userid='.$userid.'">'.$firstname. ' ' .$lastname.'</a></td><td><a href="clientsnotes.php?userid='.$userid.'&action=edit&id='.$noteid.'">'.$note.'</a></td><td>'.$date.'</td></tr>'; $x=0; } if($x) $content = '<p style="text-align:center;">No Sticky Notes to display'; $content .= '</table>'; return array( 'title' => 'Sticky Notes', 'content' => $content ); } add_hook("AdminHomeWidgets",1,"widget_sticky_notes"); ?> Edited October 14, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
Dgital Essence Posted October 14, 2015 Author Share Posted October 14, 2015 it was because your SQL query contained two different 'id' fields and it was using the wrong one. i've taken the liberty of cleaning up the widget code... Liberty? The pleasure is all mine ;-) Although I'm testing this and still seeing the same The URL created is: Before: http://mydomain/whmcsadmin/clientsnotes.php?userid=59&action=edit&id=59 After: http://mydomain/whmcsadmin/clientsnotes.php?userid=59&action=edit&id=59 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 14, 2015 Share Posted October 14, 2015 ah - that might be occurring because I changed the widget name and title in the code - it's definitely working here! try the following - same code, but i've used your widget name and title... <?php # WHMCS Widget to display sticky notes on the Admin Summary # Hedley Phillips - Digital Essence if (!defined("WHMCS")) die("This file cannot be accessed directly"); function widget_display_sticky_notes() { global $_ADMINLANG; $content = '<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1"><tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['client'].'</td><td>'.$_ADMINLANG['fields']['note'].'</td><td>'.$_ADMINLANG['fields']['lastmodified'].'</td></tr>'; $x=1; $result = mysql_query("SELECT tblnotes.id,tblnotes.userid,tblnotes.modified,tblnotes.note,tblnotes.sticky,tblclients.firstname,tblclients.lastname FROM `tblnotes` JOIN tblclients ON tblclients.id=tblnotes.userid WHERE `sticky` = '1'"); while ($data = @mysql_fetch_array ($result)) { $noteid = $data["id"]; $userid = $data["userid"]; $firstname = $data["firstname"]; $lastname = $data["lastname"]; $note = $data["note"]; $date = $data["modified"]; $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientssummary.php?userid='.$userid.'">'.$firstname. ' ' .$lastname.'</a></td><td><a href="clientsnotes.php?userid='.$userid.'&action=edit&id='.$noteid.'">'.$note.'</a></td><td>'.$date.'</td></tr>'; $x=0; } if($x) $content = '<p style="text-align:center;">No Sticky Notes to display'; $content .= '</table>'; return array( 'title' => 'Display Customer\'s Sticky Notes', 'content' => $content ); } add_hook("AdminHomeWidgets",1,"widget_display_sticky_notes"); ?> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 14, 2015 Share Posted October 14, 2015 one further update - the date format was annoying me, so it's now set to use the Admin date settings. <?php # WHMCS Widget to display sticky notes on the Admin Summary # Hedley Phillips - Digital Essence if (!defined("WHMCS")) die("This file cannot be accessed directly"); function widget_sticky_notes() { global $_ADMINLANG; $content = '<table bgcolor="#cccccc" align="center" style="margin-bottom:5px;width:100%;" cellspacing="1"><tr bgcolor="#efefef" style="text-align:center;font-weight:bold;"><td>'.$_ADMINLANG['fields']['client'].'</td><td>'.$_ADMINLANG['fields']['note'].'</td><td>'.$_ADMINLANG['fields']['lastmodified'].'</td></tr>'; $x=1; $result = mysql_query("SELECT tblnotes.id,tblnotes.userid,tblnotes.modified,tblnotes.note,tblnotes.sticky,tblclients.firstname,tblclients.lastname FROM `tblnotes` JOIN tblclients ON tblclients.id=tblnotes.userid WHERE `sticky` = '1'"); while ($data = @mysql_fetch_array ($result)) { $noteid = $data["id"]; $userid = $data["userid"]; $firstname = $data["firstname"]; $lastname = $data["lastname"]; $note = $data["note"]; $date = $data["modified"]; $content .= '<tr bgcolor="#ffffff" style="text-align:center;"><td><a href="clientssummary.php?userid='.$userid.'">'.$firstname. ' ' .$lastname.'</a></td><td><a href="clientsnotes.php?userid='.$userid.'&action=edit&id='.$noteid.'">'.$note.'</a></td><td>'.fromMySQLDate($date,$date).'</td></tr>'; $x=0; } if($x) $content = '<p style="text-align:center;">No Sticky Notes to display'; $content .= '</table>'; return array( 'title' => 'Sticky Notes', 'content' => $content ); } add_hook("AdminHomeWidgets",1,"widget_sticky_notes"); ?> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 23, 2015 Share Posted October 23, 2015 Is this script provided by Dgital and corrected by brian work? it's working quite happily on my v6 dev site I mean also I want to show sticky note to all customers. I already use homepage.tpl to display but want to display note from admin area. are you sure - Admin notes tend to be private for admins only...? http://docs.whmcs.com/Clients:Emails/Notes/Logs_Tabs Notes tab Here staff can enter private notes about the client to be displayed to whoever views this Notes tab. The tab itself will display the number of notes in brackets. Separate notes sections are available available under the Products/Services, Domains and Profile tab. Tick the Make Sticky checkbox and this note will be displayed throughout the client's account and on any tickets they submit in the admin area. there's nothing to stop you from doing it (as it's just a query to the database), i'm just unsure if we're talking about the same thing, or whether you're talking about Notifications or a Home Page Panel ? 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.