Jump to content

Hide close ticket button


yarantoos

Recommended Posts

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

Link to comment
Share on other sites

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 by brian!
Link to comment
Share on other sites

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);                
           }
       }
});

Link to comment
Share on other sites

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. :idea:

Link to comment
Share on other sites

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. :idea:

 

Very good.

 

Thanks

Link to comment
Share on other sites

  • 4 years later...
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 months later...

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 by hoya8
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 🙂

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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")
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 }

Link to comment
Share on other sites

<?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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated