Ragonz Posted August 15, 2020 Share Posted August 15, 2020 Would anyone know if I can run a report showing the number of new Knowledgebase guides created during a specific date range and who created them? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 15, 2020 Share Posted August 15, 2020 1 hour ago, Ragonz said: Would anyone know if I can run a report showing the number of new Knowledgebase guides created during a specific date range and who created them? yes... but WHMCS doesn't store those details in any of the kb database tables - I think the only source would be the activity log... that should tell you a) when an article/category was created/modified, b) which admin user did it. so the quick solution, although you couldn't specify a date range, would be to just view the activity log and filter on knowledgebase, and/or admin. the longer way if you need a date range to search with, would be a report that queried the activity log tables. 0 Quote Link to comment Share on other sites More sharing options...
Ragonz Posted August 15, 2020 Author Share Posted August 15, 2020 Activity log is a good shout, however whmcs doesnt seem to record the adding of knowledgebase articles, only the modification/deletion of them? I have an example KB article created on the 11th and I know who created it but it does not show up within activity logs. Is there a way to change what WHMCS records? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 15, 2020 Share Posted August 15, 2020 You could start with this hook. It automatically add kt_author column to tblknowledgebase table. The kt_ prefix is important as we don't know if one day in the future WHMCS will add author column so it's better to avoid naming collision. When an administrator adds a new KB article, the hook stores admin ID in the newly added column. This way each of your articles will be assigned to an administrator (the author). The hook also adds author information directly on page with jQuery as follows. <?php /** * @writtenby Kian */ use WHMCS\Database\Capsule; add_hook('AdminAreaHeadOutput', 1, function($vars) { if ($vars['filename'] == 'supportkb' AND $_GET['action'] == 'edit' AND $_GET['id']) { if (!Capsule::schema()->hasColumn('tblknowledgebase', 'kt_author')) { Capsule::select(Capsule::raw('ALTER TABLE `tblknowledgebase` ADD `kt_author` INT NULL AFTER `language`')); } $adminID = Capsule::table('tblknowledgebase')->where('id', $_GET['id'])->pluck('kt_author')[0]; if (!$adminID) { $adminID = $_SESSION['adminid']; Capsule::table('tblknowledgebase')->where('id', $_GET['id'])->update(['kt_author' => $adminID]); } $adminUsername = Capsule::table('tbladmins')->where('id', $adminID)->pluck('username')[0]; return <<<HTML <script> $(document).ready(function(){ $('table[class="form"] > tbody tr:first').after(('<tr><td class="fieldlabel" width="15%">Author</td><td class="fieldarea"><a href="configadmins.php?action=manage&id={$adminID}"><i class="fas fa-user"></i> {$adminUsername}</a></td></tr>')); }) </script> HTML; } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 15, 2020 Share Posted August 15, 2020 1 hour ago, Ragonz said: Activity log is a good shout, however whmcs doesn't seem to record the adding of knowledgebase articles, only the modification/deletion of them? it should record both... 1 hour ago, Ragonz said: I have an example KB article created on the 11th and I know who created it but it does not show up within activity logs. it's working for me whether i'm an admin or support operator - kb creation is being logged after creation. 1 hour ago, Ragonz said: Is there a way to change what WHMCS records? to change what WHMCS internally records, I doubt - they tend to be hardcoded within encrypted files... you can add custom entries to the log (logactivity), but there aren't any kb hooks, so there's no simple way to trigger adding a log after article creation. I suppose you could run the logactivity hook to add a custom log entry after kb article creation, but that relies on WHMCS adding a default entry in the first place... actually, you could probably use the hook to modify the default entry if it exists... though i'm not keen on modifying log entries. is it possible the activity log has been trimmed in some way?? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 15, 2020 Share Posted August 15, 2020 7 minutes ago, Kian said: You could start with this hook. it wouldn't help with solving the OP question of generating reports, or logging authors & times - it's just an unnecessary complication... even if you ran a query on the table, it would just tell you the last person to edit it (or maybe the last person to just go to the edit page whether they made changes or not)... 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 15, 2020 Share Posted August 15, 2020 (edited) That's why I said "you could start with this hook" 😛 He can retreive both created and last edit dates from tblactivitylog and then JOIN everything with author column. With a single query he can get all he wants. Alternatively he could get rid of tblactivitylog entirely replicating the same thing I did for author column (adding created and lastmodified columns). This way it's even easier. Edited August 15, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 15, 2020 Share Posted August 15, 2020 3 minutes ago, Kian said: That's why I said "you could start with this hook" 😛 and one of these days, you'll learn that users want end points, not starting points. 💡 3 minutes ago, Kian said: He can retrieve both created and last edit dates from tblactivitylog assuming they're being logged correctly on his install - that seems debatable at this point... in any event, if it's being logged correctly, he can get who created, modified and date from the logs without the need for the hook. 5 minutes ago, Kian said: With a single query he can get all he wants. Alternatively he could get rid of tblactivitylog entirely replicating the same thing I did for author column (adding created and lastmodified columns). This way it's even easier. https://developers.whmcs.com/advanced/db-interaction/ Quote Note: WHMCS does not recommend changing default table schema as that can affect product functionality. i'm not suggesting that the hook doesn't have its merits, just not for answering this question.... at least not in my eyes... now if it logged article creation/modification/dates etc in a separate table, referencing the kb article or parent id, then you may have something useful on your hands... 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted August 15, 2020 Share Posted August 15, 2020 Hi @brian! I have just sent a PM can you please check once... Thank you 0 Quote Link to comment Share on other sites More sharing options...
ManagedCloud-Hosting Posted August 18, 2020 Share Posted August 18, 2020 (edited) I have now started using a WordPress based Knowledgebase plugin as that was easier for me to manage. For CRM & Task Management I have started using Freedcamp much cheaper and feature rich... Edited August 18, 2020 by VirtualWorldGlobal Update 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.