cdeese8 Posted March 8, 2018 Share Posted March 8, 2018 Is it possible, the way WHMCS is coded, to display the TODO List to public / logged in clients? I was thinking I could create a specific user, called "Public" for example and any TODO items added to that specific admin ID would be displayed using {include file="$template/includes/tablelist.tpl"}. I've logged into Adminer and I started digging into tbltodolist so I know Admin ID #4 is the "Public" user too. here is my /public/inc/hooks/ file so far: <?php # Todo Logs For Public / Client Area # Written by WHMCS Community (or hopefully brian! / sentq) use Illuminate\Database\Capsule\Manager as Capsule; function hook_client_todo_logs($vars) { $admin = Menu::context('admin'); $todologs = Capsule::table('tbltodolist') ->where('adminid', $admin->id) ->get(); $encodedata = json_encode($todologs); $decodedata = json_decode($encodedata, true); return array("todologs" => $decodedata); } add_hook("AdminAreaPage", 1, "hook_client_todo_logs"); ?> Here is code pasted into a .tpl file, I've tried... clientareahome.tpl and homepage.tpl {include file="$template/includes/tablelist.tpl" tableName="TodosLog" noPagination=true noSearch=true noInfo=true} <div class="table-container clearfix"> <table id="tableTodoList" class="table table-list"> <thead> <tr> <th style="min-width:55px;">Date</th> <th>Title</th> <th>Description</th> <th>Status</th> </tr> </thead> <tbody> {foreach from=$todologs item=todolog} <tr> <td align="">{$todolog.date|date_format:"%m/%d/%y"}</td> <td align="center">{$todolog.title}</td> <td align="">{$todolog.description}</td> <td align="">{$todolog.status}</td> </tr> {/foreach} </tbody> </table> </div> --- I've been referencing these links but so far, I feel kinda burnt. I'm starting to think maybe this isn't even possible. I mean it's gotta be possible right? My experience and lack of wisdom must be getting the best of me. https://developers.whmcs.com/api-reference/gettodoitems/ https://whmcs.community/topic/269677-client-area-display-balance/ https://whmcs.community/topic/247841-display-credit-balance-in-six-template/ https://whmcs.community/topic/267269-adding-a-quotcredit-balancequot-panel-to-the-client-area-home-page/?tab=comments#comment-1224793 If you reply thanks in advance for your input and feedback. Link to comment Share on other sites More sharing options...
brian! Posted March 9, 2018 Share Posted March 9, 2018 1 hour ago, cdeese8 said: Is it possible, the way WHMCS is coded, to display the TODO List to public / logged in clients? yesss... but why would you want to ? it's an admin reminder tool, why would clients ever need to see its content? I suppose they could see to-dos related to themselves (pulled from description field), but even then... why?? I can't get my head around it. 1 hour ago, cdeese8 said: I was thinking I could create a specific user, called "Public" for example and any TODO items added to that specific admin ID would be displayed using {include file="$template/includes/tablelist.tpl"}. I've logged into Adminer and I started digging into tbltodolist so I know Admin ID #4 is the "Public" user too. err ok... 1 hour ago, cdeese8 said: here is my /public/inc/hooks/ file so far: I can immediately see a number of errors... 1 hour ago, cdeese8 said: $admin = Menu::context('admin'); ... would only work if an admin was logged in and viewing a page, not clients in general.... if you're going to go down your specific admin route, just hardcode the value into the query. 1 hour ago, cdeese8 said: ->where('adminid', $admin->id) the field is called 'admin', so your query would never find any results. 1 hour ago, cdeese8 said: add_hook("AdminAreaPage", 1, "hook_client_todo_logs"); if it's for a client area page, then don't use an admin area hook - it would never get called... you would use ClientAreaPage and, ideally, limit it to only be called on your specific todo page. 1 hour ago, cdeese8 said: Here is code pasted into a .tpl file, I've tried... clientareahome.tpl and homepage.tpl this part is fine... well it's at least functional and will output the array... would ideally need cleaning up with regards to layout.. I suspect the hook you're looking for is closer to the one below... <?php # Todo Logs For Public / Client Area # Written by WHMCS Community (or hopefully brian! / sentq) use Illuminate\Database\Capsule\Manager as Capsule; function hook_client_todo_logs($vars) { $client = Menu::context('client'); $user = 'Client ID '.$client->id; $todologs = Capsule::table('tbltodolist') ->where('description', 'like', $user.'%') ->get(); $encodedata = json_encode($todologs); $decodedata = json_decode($encodedata, true); return array("todologs" => $decodedata); } add_hook("ClientAreaPage", 1, "hook_client_todo_logs"); ?> so this queries the table for mentions of the current logged in client's ID and sends the resulting array back to the template - where you can output it in your table. if you still want to go down your route of using an assigned admin, then just change the where to... ->where('admin', '4') 2 Link to comment Share on other sites More sharing options...
cdeese8 Posted March 9, 2018 Author Share Posted March 9, 2018 WE GOT RESULTS!!! Thanks @brian! --- How do I parse HTML from a To-Do description into the hooked output? Is this a limitation by WHMCS 7.1? If I visit mydomain.com/todolist.php and in the description of a To-Do item I use <a href="#">link</a> and / or <img src="/image.png"> and save, it doesn't display on public page. Also, is there such thing as a "PublicAreaPage" hook? I guess it's just assumed if it isn't clientarea or admin it's public? https://developers.whmcs.com/hooks/hook-index/ Thanks again! Two hour response is no joke...wicked fast! -- You think this makes sense? So I see the added value from the todo module as being able to offer transparency and show people a constant "changelog" or "patch notes" getting done. For example, if one has a ticket department called feedback, it can be used to collect info. One could take the collected feedback and add it to the to-do list (assigned to public admin #4). Now, people know work is getting done, they can just visit http://domin.com/changelog Thanks to your hooked input, people can now see the collected feedback and the progress. I thought about using a public Trello board, but I think the todo module in WHMCS works good... even better now! ...you know, I had a feeling you might say something like this... hahahaha.... "I can immediately see a number of errors... ". Thanks for your quoted breakdown, everything is easier to comprehend. When you say things like "this field is called admin", so the query wouldn't work. I understand now.. what's going on in the background. Being able to think more like a computer helps me out. Link to comment Share on other sites More sharing options...
twhiting9275 Posted March 9, 2018 Share Posted March 9, 2018 12 minutes ago, cdeese8 said: guess it's just assumed if it isn't clientarea or admin it's public? From the clientareapage manual Quote Executes on all pages of the client area Pretty easy to test this one out, just create a hook, add your function in there, and go to town. This works whether the client is logged in, or not, yes it might be a good idea to get clarification on that, absolutely So, if you're after something, say, verifying that the client is logged in, check the session, or client vars in PHP Link to comment Share on other sites More sharing options...
brian! Posted March 9, 2018 Share Posted March 9, 2018 26 minutes ago, cdeese8 said: How do I parse HTML from a To-Do description into the hooked output? Is this a limitation by WHMCS 7.1? If I visit mydomain.com/todolist.php and in the description of a To-Do item I use <a href="#">link</a> and / or <img src="/image.png"> and save, it doesn't display on public page. one quick way to do it in your template, would be to change... <td align="">{$todolog.description}</td> to... <td align="">{$todolog.description|html_entity_decode}</td> 27 minutes ago, cdeese8 said: Also, is there such thing as a "PublicAreaPage" hook? I guess it's just assumed if it isn't clientarea or admin it's public? https://developers.whmcs.com/hooks/hook-index/ as Tom says, it's going to be ClientAreaPage... and ideally, you'd check templatefile so that the array is only used on your todo template and not loaded on every page... 30 minutes ago, cdeese8 said: So I see the added value from the todo module as being able to offer transparency and show people a constant "changelog" or "patch notes" getting done. For example, if one has a ticket department called feedback, it can be used to collect info. One could take the collected feedback and add it to the to-do list (assigned to public admin #4). Now, people know work is getting done, they can just visit http://domin.com/changelog well you could do that with any database table... I merely questioned the use of todos... though I can see the convenience for you. Link to comment Share on other sites More sharing options...
sentq Posted March 10, 2018 Share Posted March 10, 2018 22 hours ago, cdeese8 said: Also, is there such thing as a "PublicAreaPage" hook? ClientAreaPage action hook point triggered when anyone browse your client area (Admins, Clients, Contacts and normal clients) if you need to display these Todos to logged-in clients only (this includes Admins, Clients and Contacts) all you need to do is to change the following line from: $client = Menu::context('client'); to: $client = Menu::context('client'); # Return empty todolist if client not loggedin, admins still able to browse this section if (is_null($client) && !isset($_SESSION['adminid'])){ return array("todologs" => array()); } Link to comment Share on other sites More sharing options...
othellotech Posted March 19, 2018 Share Posted March 19, 2018 Isnt the most logical way to do this with a 'feed' ? Link to comment Share on other sites More sharing options...
brian! Posted March 19, 2018 Share Posted March 19, 2018 5 minutes ago, othellotech said: Isnt the most logical way to do this with a 'feed' ? that would depend where it's going to be shown... if it's outside of WHMCS, then yes... but within a WHMCS page, probably not. Link to comment Share on other sites More sharing options...
Recommended Posts