Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name OTRS Auto label ticket & Owner
- // @namespace https://campaigns.rtbhouse.biz/
- // @version 0.3
- // @description Automatically label tickets And automatically set you as owner
- // @author Faisal Achmad
- // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js
- // @include https://otrs.rtbhouse.com/*
- // ==/UserScript==
- $( document ).ready(function() {
- var tixID = GetURLParameter('TicketID');
- var type = window.location.search.substring(1).split(";").pop();
- var note = document.getElementById('nav-Note');
- var owner = document.getElementById('nav-Owner');
- if($.isEmptyObject(note)){
- $( "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>' );
- $( "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>' );
- if(type=='Internal'){
- $('input[type=checkbox]:eq(1)').prop('checked', true);
- $('#LabelStructure option[value="401||1 Request type::Internal request"]').prop('selected',true);
- $( "form" ).submit();
- }else if(type=='Client'){
- $('input[type=checkbox]:eq(0)').prop('checked', true);
- $('#LabelStructure option[value="400||1 Request type::Client request"]').prop('selected',true);
- $( "form" ).submit();
- }
- }
- if(!$.isEmptyObject(owner)){
- $( "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>' );
- }
- if(type=='boss'){
- $('#NewOwnerID_Search').val('').focus();
- var checkExist = setInterval(function() {
- if ($('#j1_11_anchor').length) {
- $('[data-id="264"] a')[0].click();
- $( "form" ).submit();
- clearInterval(checkExist);
- }
- }, 100);
- }
- function GetURLParameter(sParam)
- {
- var sPageURL = window.location.search.substring(1);
- var sURLVariables = sPageURL.split(';');
- for (var i = 0; i < sURLVariables.length; i++)
- {
- var sParameterName = sURLVariables[i].split('=');
- if (sParameterName[0] == sParam)
- {
- return sParameterName[1];
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement