Jump to content
Tom Wilson

Remove option to upload attachment for a specific department

Recommended Posts

Hello!

Is there a way to remove the attachment box when creating a ticket if it's being created for department x?

 

Thanks

Tom

Share this post


Link to post
Share on other sites
Posted (edited)

There are probably better ways and I'm not that good with jQuery but this is how I would do it. Depending on the selected department the script hides/shows attachments section. It also clears any existing attachment when vistors switch department. I tested it on Six template. Use it as a starting point since as I already said my jQuery skills are... 🤢

<?php

add_hook('ClientAreaHeadOutput', 1, function($vars)
{
	$deptID = '1'; // Hide Attachment for the given Department ID

	return <<<HTML
<script>
$(document).ready(function() {
	if ($('select#inputDepartment').val() == '{$deptID}') toggleAttachments('show'); else toggleAttachments('hide');

	$('#inputDepartment').on('change', function() {
    	if ($('select#inputDepartment').val() == '{$deptID}') toggleAttachments('show'); else toggleAttachments('hide');
    });
});

function toggleAttachments(e) {

	if (e == 'hide') {
		$('#inputAttachments').closest('.form-group').hide();
		$('#inputAttachments').val(''); 
	}

	if (e == 'show') {
		$('#inputAttachments').closest('.form-group').show();
	}
}
</script>
HTML;
});

 

Edited by Kian

Share this post


Link to post
Share on other sites
12 hours ago, Kian said:

There are probably better ways and I'm not that good with jQuery but this is how I would do it.

if the templates used IDs correctly (or even at all), then CSS would be simpler... but with that flaw to contend with, you're hooking - and I suspect it would have to be JS because the page doesn't refresh on a department change, so Smarty solutions would be limited.

12 hours ago, Kian said:

Depending on the selected department the script hides/shows attachments section. It also clears any existing attachment when visitors switch department. I tested it on Six template.

I think it shows the attachments for the specified depts, but hides it for others (e.g the reverse of what you want) - it also seems to hide the custom fields too...

12 hours ago, Kian said:

Use it as a starting point since as I already said my jQuery skills are...

they won't be as bad as mine! 🙄

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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