bear Posted April 3, 2010 Share Posted April 3, 2010 Decided to go for the full integration with Kayako and WHMCS (can't believe how difficult the Kayako templates are to simplify and integrate, with table upon nested table...), and I find that the one important thing in that integration is the lack of a ticket count in the clients home page, as well as the admin home, but the client home page is more important. Has anyone ever made anything to check the Kayako db for a ticket count to be able to display it on the client's home page while using the full integration? I'd be interested in seeing that, if so. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 3, 2010 Share Posted April 3, 2010 I may have something from an old clientareahome mod... shoot me an email and if we work it out then we can posibly share it here for others. 0 Quote Link to comment Share on other sites More sharing options...
Victor Lugo Posted April 5, 2010 Share Posted April 5, 2010 Hi there, Because this isn't the first time such integration has been requested, I have taken a few minutes to create a script that will accomplish the basic integration of ticket counts in the client area page. If I see the demand for a more in depth integration and appreciation for the work below, I'll create scripts for native listing of open tickets on the client area page, and native ticket counts integration in the admin area. For now... CLIENT AREA: - Create a PHP file in the /includes/hooks folder of your WHMCS installation, paste the following therein. - Modify the $kayako_config_location variable to the location of your Kayako config.php file - this is very important. <?php /* Script: Kayako support ticket counts (open/total) in WHMCS client area Author: Victor Lugo (www.victorlugo.com) Last edited: April 4, 2010 Version: 1.0 */ add_hook("ClientAreaPage",1,"fixTicketCounts",""); function fixTicketCounts() { /************************EDIT*****************************/ $kayako_database_prefix = "sw"; //MODIFY ONLY IF DATABASE PREFIX DIFFERS FROM DEFAULT VALUE $kayako_config_location = "/path/to/kayako/config/config.php"; //MODIFY TO KAYAKO CONFIG.PHP LOCATION /************************EDIT*****************************/ global $smarty; //GET THE CLIENT'S WHMCS USER ID FROM SMARTY... $whmcs_user_id = $smarty->_tpl_vars['clientsdetails']['userid']; //GET THE KAYAKO CONFIG.PHP FILE... require($kayako_config_location); //GIVE MATCHING VARIABLES TO THE DATABASE PROPERTIES... (SO THAT I STAY SANE)... $kayako_database_hostname = $_DB["hostname"];$kayako_database_username = $_DB["username"];$kayako_database_password = $_DB["password"];$kayako_database_name = $_DB["name"];$kayako_database_users_table = $kayako_database_prefix . "users";$kayako_database_tickets_table = $kayako_database_prefix . "tickets"; //SET THE MYSQL CONNECTION TO THE KAYAKO DATABASE... $kayako_database = mysql_connect($kayako_database_hostname, $kayako_database_username, $kayako_database_password); //GET THE CLIENT'S KAYAKO USER ID... $kayako_user_id = mysql_query("SELECT userid FROM $kayako_database_name.$kayako_database_users_table WHERE loginapi_userid = '$whmcs_user_id'", $kayako_database);$kayako_user_id = mysql_fetch_row($kayako_user_id);$kayako_user_id = $kayako_user_id[0]; //GET THE ROWS THAT MATCH THE CLIENT'S KAYAKO USER ID AND THAT ARE NOT CLOSED... $result = mysql_query("SELECT * FROM $kayako_database_name.$kayako_database_tickets_table WHERE userid = '$kayako_user_id' AND ticketstatusid != '3'", $kayako_database); //COUNT THOSE ROWS, GIVE THE RESULT A VARIABLE... $number_open_tickets = mysql_num_rows($result); //TRICK SMARTY, INJECT THE NEW NUMBER INTO THE VARIABLE BEFORE THE PAGE LOADS... $smarty->_tpl_vars['clientsstats']['numactivetickets'] = $number_open_tickets; //MUST NOT FORGET TO ALSO SET THE NUMBER OF TOTAL TICKETS (OPEN AND CLOSED)... GET THE ROWS THAT MATCH THAT CLIENT'S KAYAKO USER ID... $result = mysql_query("SELECT * FROM $kayako_database_name.$kayako_database_tickets_table WHERE userid = '$kayako_user_id'", $kayako_database); //COUNT THOSE ROWS, GIVE THE RESULT A VARIABLE... $number_tickets = mysql_num_rows($result); //TRICK SMARTY, INJECT THE NEW NUMBER OF TOTAL TICKETS INTO THE VARIABLE BEFORE THE PAGE LOADS... $smarty->_tpl_vars['clientsstats']['numtickets'] = $number_tickets; } ?> 0 Quote Link to comment Share on other sites More sharing options...
echonex Posted April 9, 2010 Share Posted April 9, 2010 thank Victor but when i try your solution count fine ( it says 2 Open Support Tickets ) But under... it says No Records Found 0 Quote Link to comment Share on other sites More sharing options...
echonex Posted April 9, 2010 Share Posted April 9, 2010 also i get this error : Warning: Cannot modify header information - headers already sent by (output started at /............../whmcs/includes/hooks/tickets.php:56) in /................../whmcs/dologin.php on line 0 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted April 9, 2010 Share Posted April 9, 2010 also i get this error : Warning: Cannot modify header information - headers already sent by (output started at /............../whmcs/includes/hooks/tickets.php:56) in /................../whmcs/dologin.php on line 0 You probably have a space after the ?> in the tickets.php file. Remove it. 0 Quote Link to comment Share on other sites More sharing options...
echonex Posted April 9, 2010 Share Posted April 9, 2010 thankss m00 it solved my problem... but i dont solve the other one.. count fine ( it says 2 Open Support Tickets ) But under... it says No Records Found on client area page 0 Quote Link to comment Share on other sites More sharing options...
Victor Lugo Posted April 10, 2010 Share Posted April 10, 2010 Hi, As I mentioned in the initial post, this script does not include ticket listing in the client area, only counts. I may release additional scripts for ticket listing and admin area integration, we have yet to see. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted April 10, 2010 Author Share Posted April 10, 2010 I really should have updated, but Sparky had a script that allowed me to connect to Kayako and pull the counts and list the 5 most recent tickets within the client's home page. It didn't use actionhooks, so it's something that requires more effort to set up, and subsequent template updates will need to redo bits, but it works. I'll leave it to him if he wants to publish here, since it wasn't mine to share. I did create something that would count the tickets in admin home (right at the top as before) and link to the Kayako desk to manage tickets in a new window, if anyone's interested in that. Again, it's not using actionhooks, so template edits are required. 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.