yarantoos Posted March 30, 2016 Share Posted March 30, 2016 Hello, I don;t want my client close tickets. I created a hook but it doesn't work function my_ticket_hide_close_button (){ global $smarty; $smarty->assign('showclosebutton',false); if($_REQUEST['closeticket']){ $smarty->assign('errormessage','This Ticket can be closed only by Support Staff!'); } } add_hook("ClientAreaPage",0,"my_ticket_hide_close_button"); Please help me 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 31, 2016 Share Posted March 31, 2016 (edited) if you were using the Six theme, it would probably be simpler to remove the "Close" button from the "Ticket Information" sidebar... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> '.Lang::trans('supportticketsreply').'</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } }); if you were using an older template, then you'd probably need to edit the template and i've previously posted threads on how to do that... Edited March 31, 2016 by brian! 0 Quote Link to comment Share on other sites More sharing options...
yarantoos Posted March 31, 2016 Author Share Posted March 31, 2016 It works. Thanks 0 Quote Link to comment Share on other sites More sharing options...
yarantoos Posted April 2, 2016 Author Share Posted April 2, 2016 If we want to hide close bottom in special department only , what we should do ? Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 2, 2016 Share Posted April 2, 2016 If we want to hide close bottom in special department only , what we should do ? let's say you have a support department called "Technical Support" - the following will remove the "Close" button from that department only - all other departments will see the "Close" button. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($department=="Technical Support") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); 2 Quote Link to comment Share on other sites More sharing options...
yarantoos Posted April 2, 2016 Author Share Posted April 2, 2016 Thank you for your help. You checked condition by "department name" . Is it possible to check by "department id " ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 2, 2016 Share Posted April 2, 2016 I don't think so - i'd have preferred to check by ID, but I don't believe that the variable is available to that page, but I knew "department" was. 0 Quote Link to comment Share on other sites More sharing options...
yarantoos Posted April 6, 2016 Author Share Posted April 6, 2016 What about status ? Is it possible to hide "Close Button" When the ticket is on-hold ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 6, 2016 Share Posted April 6, 2016 What about status ?Is it possible to hide "Close Button" When the ticket is on-hold ? yes, ticket status can be obtained from the $status variable, but it contains HTML code along with the status value - so you check for the $status variable containing the required string and not equal to it... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $status; if (strpos($status, Lang::trans('supportticketsstatusonhold')) !== false) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); ...and because the ticket status output uses the client's language choice, i've used the Lang:trans feature to ensure it should work in all the default languages. 3 Quote Link to comment Share on other sites More sharing options...
yarantoos Posted April 6, 2016 Author Share Posted April 6, 2016 yes, ticket status can be obtained from the $status variable, but it contains HTML code along with the status value - so you check for the $status variable containing the required string and not equal to it... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $status; if (strpos($status, Lang::trans('supportticketsstatusonhold')) !== false) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); ...and because the ticket status output uses the client's language choice, i've used the Lang:trans feature to ensure it should work in all the default languages. Very good. Thanks 0 Quote Link to comment Share on other sites More sharing options...
Georgesosk Posted November 6, 2020 Share Posted November 6, 2020 On 4/2/2016 at 3:23 PM, brian! said: let's say you have a support department called "Technical Support" - the following will remove the "Close" button from that department only - all other departments will see the "Close" button. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($department=="Technical Support") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); It seems this no longer works, just tested with WHMCS 8.0.4 and the Six theme. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 6, 2020 Share Posted November 6, 2020 6 minutes ago, Georgesosk said: It seems this no longer works, just tested with WHMCS 8.0.4 and the Six theme. it's working for me in v8.0.4 & Six - but bear in mind that as written, it would only work if the support dept was called "Technical Support" - if you checking with a dept called something else, then the hook will do nothing. 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 Hi Brian thanks again, seriously WHMCS should collect all of your posts as a KNOWLEDGEBASE My dept is not in English, looking up dept name is not working for us (tried) , any other solution please? 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 (edited) I can;t get this to work on WHMCS8.1 with a third party 's template This one ""Is it possible to hide "Close Button" When the ticket is on-hold ?"" is there any way I should look it up? viewticket.tpl ? tried several time but failed... We do want when ticket is set to "on hold" , clients are not able to edit/close it Edited January 28, 2021 by hoya8 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 On 4/2/2016 at 3:23 PM, brian! said: let's say you have a support department called "Technical Support" - the following will remove the "Close" button from that department only - all other departments will see the "Close" button. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($department=="Technical Support") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); looks like WHMCS 8 has department id? I saw a number after url , my department number is 4 , how to look this up by ID? 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 too people who wants to disable client's "close ticket" ability, this is the book with department id <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($deptid="4") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); This is working on my WHMCS 8.1 🙂 anyone knows how to make multiple departments in better ways? if ($deptid="4", "7") seems not working sorry for this naive question 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 28, 2021 Share Posted January 28, 2021 1 hour ago, hoya8 said: thanks again, seriously WHMCS should collect all of your posts as a KNOWLEDGEBASE you're in it 😜 one day i'll do it myself... my greatest hits collection. 🤪 1 hour ago, hoya8 said: My dept is not in English, looking up dept name is not working for us (tried) , any other solution please? I would have thought it should still work, just as long as what WHMCS had as the department name was what you were checking for. 1 hour ago, hoya8 said: is there any way I should look it up? viewticket.tpl ? tried several time but failed... I don't think v8.1 likes how the hook is trying to access the department value from the template... 1 hour ago, hoya8 said: We do want when ticket is set to "on hold" , clients are not able to edit/close it can they reply ? assuming the answer to that question is yes, then... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $departmentid = $smarty->getVariable('departmentid'); $status = $smarty->getVariable('status'); $validdepts = array(4,7); $statuslabel = Lang::trans('supportticketsstatusonhold'); if (in_array($departmentid,$validdepts) && strpos($status,$statuslabel) !== false) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fas fa-pencil-alt"></i> '.Lang::trans('supportticketsreply').'</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information')->setFooterHtml($footer); } } }); which basically says, if dept is either 4 or 7 AND the status of the ticket is on hold, then do something - in this case, modify the footer... 1 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 great thanks again! 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 28, 2021 Share Posted January 28, 2021 you should really make a website for your collections 🙂 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 29, 2021 Share Posted January 29, 2021 21 hours ago, hoya8 said: too people who wants to disable client's "close ticket" ability, this is the book with department id <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($deptid="4") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); This is working on my WHMCS 8.1 🙂 anyone knows how to make multiple departments in better ways? if ($deptid="4", "7") seems not working sorry for this naive question 🙂 to answer to myself's port this is not working to filter dept ID if ($deptid="4") 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 29, 2021 Share Posted January 29, 2021 20 hours ago, brian! said: you're in it 😜 one day i'll do it myself... my greatest hits collection. 🤪 I would have thought it should still work, just as long as what WHMCS had as the department name was what you were checking for. I don't think v8.1 likes how the hook is trying to access the department value from the template... can they reply ? assuming the answer to that question is yes, then... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $departmentid = $smarty->getVariable('departmentid'); $status = $smarty->getVariable('status'); $validdepts = array(4,7); $statuslabel = Lang::trans('supportticketsstatusonhold'); if (in_array($departmentid,$validdepts) && strpos($status,$statuslabel) !== false) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fas fa-pencil-alt"></i> '.Lang::trans('supportticketsreply').'</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information')->setFooterHtml($footer); } } }); which basically says, if dept is either 4 or 7 AND the status of the ticket is on hold, then do something - in this case, modify the footer... Hi Andy how to remove your "onhold" status filter and just let dept 4 and 7 's tickets NOT able to close ticket? thank you! ( my one was not working, I was wrong) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 29, 2021 Share Posted January 29, 2021 2 hours ago, hoya8 said: how to remove your "onhold" status filter and just let dept 4 and 7 's tickets NOT able to close ticket? i'll answer on Andy's behalf.. 😜 just remove the strpos part of the if statement... if (in_array($departmentid,$validdepts)) { 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 29, 2021 Share Posted January 29, 2021 sooooo sorry BRIAN! my bad 😅😅 minds was too blown away with kids I just tried <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $departmentid = $smarty->getVariable('departmentid'); $status = $smarty->getVariable('status'); $validdepts = array(4,7); $statuslabel = Lang::trans('supportticketsstatusonhold'); if (in_array($departmentid,$validdepts) !== false) { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information')->setFooterHtml($footer); } } }); still show close button So now we decided to "disable ALL departments"'s close ability your post in 2016 (such a long time for you being still active!) function my_ticket_hide_close_button (){ global $smarty; $smarty->assign('showclosebutton',false); if($_REQUEST['closeticket']){ $smarty->assign('errormessage','This Ticket can be closed only by Support Staff!'); } } add_hook("ClientAreaPage",0,"my_ticket_hide_close_button"); did not work on our whmcs 8.1 though , BUT following somewhat works to disable ALL depts 's close ability (not only dept4) however I know something wrong with this code as its "if ($deptid="4") " looks odd to me... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; if ($deptid="4") { $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } } }); any suggestions please? thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 29, 2021 Share Posted January 29, 2021 35 minutes ago, hoya8 said: still show close button why is the !== false still in that if statement? it should be as I gave you previously.... if (in_array($departmentid,$validdepts)) { if it still doesn't work, try it in Six - because it's definitely working locally for me... then if it works in Six, but not your theme, we can figure out the cause. and if you want the close button removed on all departments, then you just remove the above if statement and its corresponding closing } 0 Quote Link to comment Share on other sites More sharing options...
hoya8 Posted January 31, 2021 Share Posted January 31, 2021 <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { global $department; $footer = '<div><button class="btn btn-success btn-sm btn-block" onclick="jQuery(\'#ticketReply\').click()"><i class="fa fa-pencil"></i> Reply</button></div>'; if (!is_null($primarySidebar->getChild('Ticket Information'))) { $primarySidebar->getChild('Ticket Information') ->setFooterHtml($footer); } }); Hi Brian You meant like this will remove "close" for all departments right? 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.