Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. // ==UserScript==
  2. // @name OTRS Auto label ticket & Owner
  3. // @namespace https://campaigns.rtbhouse.biz/
  4. // @version 0.3
  5. // @description Automatically label tickets And automatically set you as owner
  6. // @author Faisal Achmad
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
  8. // @include https://otrs.rtbhouse.com/*
  9. // ==/UserScript==
  10. $( document ).ready(function() {
  11. var tixID = GetURLParameter('TicketID');
  12. var type = window.location.search.substring(1).split(";").pop();
  13. var note = document.getElementById('nav-Note');
  14. var owner = document.getElementById('nav-Owner');
  15. if($.isEmptyObject(note)){
  16. $( "li#nav-Watch").parent().append('<li><a href="https://otrs.rtbhouse.com/otrs/index.pl?Action=AgentTicketLabel;TicketID='+tixID+';Internal" class="AsPopup PopupType_TicketAction" style="color:blue !important">Internal Request</a></li>' );
  17. $( "li#nav-Watch").parent().append('<li><a href="https://otrs.rtbhouse.com/otrs/index.pl?Action=AgentTicketLabel;TicketID='+tixID+';Client" class="AsPopup PopupType_TicketAction" style="color:blue !important">Client Request</a></li>' );
  18. if(type=='Internal'){
  19. $('input[type=checkbox]:eq(1)').prop('checked', true);
  20. $('#LabelStructure option[value="401||1 Request type::Internal request"]').prop('selected',true);
  21. $( "form" ).submit();
  22. }else if(type=='Client'){
  23. $('input[type=checkbox]:eq(0)').prop('checked', true);
  24. $('#LabelStructure option[value="400||1 Request type::Client request"]').prop('selected',true);
  25. $( "form" ).submit();
  26. }
  27. }
  28. if(!$.isEmptyObject(owner)){
  29. $( "li#nav-Owner").before().append('<li><a href="https://otrs.rtbhouse.com/otrs/index.pl?Action=AgentTicketOwner;TicketID='+tixID+';boss" class="AsPopup PopupType_TicketAction" style="color:blue !important">I\'m the boss!</a></li>' );
  30. }
  31. if(type=='boss'){
  32. $('#NewOwnerID_Search').val('').focus();
  33. var checkExist = setInterval(function() {
  34. if ($('#j1_11_anchor').length) {
  35. $('[data-id="264"] a')[0].click();
  36. $( "form" ).submit();
  37. clearInterval(checkExist);
  38. }
  39. }, 100);
  40. }
  41. function GetURLParameter(sParam)
  42. {
  43. var sPageURL = window.location.search.substring(1);
  44. var sURLVariables = sPageURL.split(';');
  45. for (var i = 0; i < sURLVariables.length; i++)
  46. {
  47. var sParameterName = sURLVariables[i].split('=');
  48. if (sParameterName[0] == sParam)
  49. {
  50. return sParameterName[1];
  51. }
  52. }
  53. }
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement