OTRS: adding a new button to move all messages that you want to Spam

It’s a good ideia to use OTRS to manage tickets and have a good Service Desk in your business, but sometimes you a have a lot of bad messages and you need to move them to Spam. It turns into a nightmare on OTRS, ’cause you can only select a single message and move that. I didn’t know about that before a see a guy using it, so I decided to make his life better and I made this little code and think that it can helps you too.
Edit your OTRS file {YOUR_INSTALL_PATH}/Kernel/Output/HTML/Standard/AgentTicketOverviewPreview.dtl and insert the code below after 27th line:

<ul style="float:left;margin:6px 0 0 5px;">
<li>
<a href="javascript:void(0);" id="spam-all" style="display:inline;">Spam All</a>
<script type="text/javascript">
$(document).ready(function(){
  $('#spam-all').click(function() {
     var t = $("input[name='TicketID']:checked").length;

     if( t > 1 ) {
       var d=0,f=0;

       for(i=0;i<t;i++) {
          var msg = $("input[name='TicketID']:checked").eq(i).val();

          $.ajax({
             url: '/index.pl?Action=AgentTicketMove;TicketID='+msg+';DestQueue=Spam',
             type: 'GET',
             error: function() { f++; }
          });
       }

       if(f == 0) {
          alert('All messages moved!');
       } else {
          alert(f+' messages failed');
       }

       location.reload();
     }
  });
});
</script>
</li>
</ul>
Advertisements

One thought on “OTRS: adding a new button to move all messages that you want to Spam

  1. Would you tell us clearly where to post this code? Its possible that its not exactly after line 27 in newer version of AgentTicketOverviewPreview.dtl file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s