Jump to content

Removing cancelled/terminated services from "Related Service" on ticket form


Daniel

Recommended Posts

Hey guys,

Is anyone aware of a way to remove the cancelled/terminated services from the related services dropdown menu of step 2 of the submit ticket page?

Some of our clients have a lot of terminated or cancelled services that they don't want listed and I can't see a way to remove those.

 

Thanks

Link to comment
Share on other sites

Hi Daniel,

19 hours ago, Daniel said:

Is anyone aware of a way to remove the cancelled/terminated services from the related services dropdown menu of step 2 of the submit ticket page?

the usual two ways would be to either edit the supportticketsibmit-steptwo.tpl template, or use an action hook...

to edit the template, you could just put an if statement in the foreach loop that generates the relatedservices dropdown content, e.g change...

{foreach from=$relatedservices item=relatedservice}
	<option value="{$relatedservice.id}">{$relatedservice.name} ({$relatedservice.status})</option>
{/foreach}

to...

{foreach from=$relatedservices item=relatedservice}
	{if !in_array($relatedservice.status,array('Cancelled','Terminated'))}
		<option value="{$relatedservice.id}">{$relatedservice.name} ({$relatedservice.status})</option>
	{/if}
{/foreach}

if you want to avoid editing the template, then you could use a hook to modify the array and remove the cancelled/terminated services...

<?php

# Filter & Sort Ticket Related Services Hook
# Written by brian!

function filter_related_services_hook($vars){
	
	if ($vars['templatefile']=='supportticketsubmit-steptwo'){
		$relatedservices = $vars['relatedservices'];
		$cancelled = array('Cancelled','Terminated');
		foreach($relatedservices as $key => $service) {
			if (in_array($service['status'],$cancelled)) {
				unset($relatedservices[$key]);
			}
		}
		array_multisort(array_column($relatedservices, 'status'), SORT_ASC, array_column($relatedservices, 'name'), SORT_ASC, $relatedservices);
		return array("relatedservices" => $relatedservices);
	}
}
add_hook("ClientAreaPageSubmitTicket", 1, "filter_related_services_hook");

i've also added sort functionality to the hook that will sort the array by status (e.g Active services will be first), and then sorted by name... if you don't want/need this, then just remove the array_multisort line.

that sorting idea is from another step2 hook that I posted in the thread below - no point letting it go to waste if you want to use the feature! thanks.png

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