Rev 27754 | Rev 31414 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
var TEAM_ACTIVITY = ["COMMUNICATION_OUT", "COMMUNICATION_INTERNAL","ESCALATED", "ASSIGNED", "CATEGORY_CHANGED"];$(function() {$(document).on('click', ".create-ticket-category", function() {console.log("create ticket category clicked......");loadCreateCategory("main-content");});$(document).on('click', ".create-region", function() {loadCreateRegion("main-content");});$(document).on('click', "#manager-ticket-search-by-partner-name",function() {var searchContent = $(this).data('id');var searchValue = $("#typeaheadpartnername").val();var searchType = $("#managersearchType").val();var managerTicketStatus = $("#managerTicketStatus").val();var managerTicketorderBy = $("#managerTicketorderBy").val();if (typeof (searchContent) == "undefined" || !searchContent) {searchContent = "";}loadManagerTicket("main-content", managerTicketStatus,managerTicketorderBy, searchType, searchContent,searchValue);});$(document).on('click', "#retailer-details-search-button-by-ticketId",function() {var searchContent = $("#search-by-ticketId").val();var searchType = $("#managersearchType").val();var managerTicketStatus = $("#managerTicketStatus").val();var managerTicketorderBy = $("#managerTicketorderBy").val();if (typeof (searchContent) == "undefined" || !searchContent) {searchContent = "";}if (searchContent == "" || searchContent == undefined|| searchContent == null) {alert("Input field can't be empty");return false;}loadManagerTicket("main-content", managerTicketStatus,managerTicketorderBy, searchType, searchContent, null);});$(document).on('click', "#assignee-ticket-search-by-partner-name",function() {var searchContent = $(this).data('id');var searchValue = $("#typeaheadpartnernameforassignee").val();var searchType = $("#assigneesearchType").val();var ticketStatus = $("#ticketStatus").val();var ticketorderBy = $("#orderBy").val();console.log(ticketStatus);console.log(ticketorderBy);console.log(searchValue);if (typeof (searchContent) == "undefined" || !searchContent) {searchContent = "";}loadMyTicket("main-content", ticketStatus, ticketorderBy,searchType, searchContent, searchValue);});$(document).on('click', "#assignee-retailer-details-search-button-by-ticketId",function() {var searchContent = $("#assignee-search-by-ticketId").val();var searchType = $("#assigneesearchType").val();var ticketStatus = $("#ticketStatus").val();var ticketorderBy = $("#orderBy").val();if (typeof (searchContent) == "undefined" || !searchContent) {searchContent = "";}if (searchContent == "" || searchContent == undefined|| searchContent == null) {alert("Input field can't be empty");return false;}console.log(ticketStatus);console.log(ticketorderBy);loadMyTicket("main-content", ticketStatus, ticketorderBy,searchType, searchContent, null);});$(document).on('click', "#ticket-last-activity", function() {var ticketId = $(this).data('ticketid');var activity = $(this).data('activity');console.log(ticketId);console.log(activity);if (confirm("Are you sure!") == true) {createLastActivity(ticketId, activity);}});$(document).on('change', "#region", function() {var regionId = $("#region").val();console.log(regionId);loadPartnerForRegion(regionId);});$(document).on('change', "#regionPosition", function() {var regionId = $("#regionPosition").val();console.log(regionId);loadPartnerForRegionId(regionId);});$(document).on('change', "#managersearchType", function() {var searchType = $("#managersearchType").val();console.log(searchType);var html;if (searchType == "PARTNER_NAME") {$('.byPartnerName').css('display', 'inline-block');$('.byTicketId').css('display', 'none');$("#search-by-ticketId").val("");} else {$('.byPartnerName').css('display', 'none');$('.byTicketId').css('display', 'inline-block');$('#manager-ticket-search-by-partner-name').data('id', "");}});$(document).on('change', "#assigneesearchType", function() {var searchType = $("#assigneesearchType").val();console.log(searchType);var html;if (searchType == "PARTNER_NAME") {$('.assigneebyPartnerName').css('display', 'inline-block');$('.assigneebyTicketId').css('display', 'none');$("#assignee-search-by-ticketId").val("");} else {$('.assigneebyPartnerName').css('display', 'none');$('.assigneebyTicketId').css('display', 'inline-block');$("#assignee-ticket-search-by-partner-name").data('id', '');}});$(document).on('click', ".change-ticket-button",function() {var ticketId = $("#ticketId").val();var subCategory = $("#subCategory").val();var authUserId = $("#authUser").val();var categoryId = $("#category").val();console.log(ticketId);if (subCategory == null || subCategory == ""|| subCategory == undefined) {alert("Choose appropriate subCategory");return false;}console.log(authUserId);if (confirm("Are you sure you want to change ticket!") == true) {changeTicket(ticketId, subCategory, authUserId,categoryId);}});$(document).on('click', "#edit-ticket", function() {var ticketId = $(this).data('ticketid1');loadEditTicket(ticketId);});$(document).on('click', ".manager-ticket", function() {loadManagerTicket("main-content", null, null);});$(document).on('click', ".access-management", function() {loadAccessManagement("main-content", null, null);});$(document).on('click', ".ticketType", function() {console.log("create Region");loadCreateRegion("main-content");});$(document).on('click', "#activities", function() {var ticketId = $(this).data('ticketid');var assignee = $(this).data('assignee');var internal = $(this).data('internal');var roleType = $(this).data('role');console.log(assignee);loadActivities(ticketId, assignee, internal, roleType);});$(document).on('click', ".my-ticket", function() {loadMyTicket("main-content", null, null, null, null, null);});$(document).on('click', "#close-ticket", function() {var ticketId = $(this).data('ticketid');closeTicket(ticketId);});$(document).on('change', '.partners', function() {console.log("Hello");});var documentIds = [];var count = 0;$(document).on('click', ".submit-message-button",function() {var message = $("#activityMessage").val();var internal = $("#internalCommunication").prop("checked");if (message == "" || message == null || message == undefined) {alert("message field can't be empty");return false;}var ticketId = $("#ticketIdforactivity").val();var assignee = $("#assigneeUser").val();var roleType = $("#role").val();count = 0;console.log(message, ticketId, assignee);createActivity(message, ticketId, assignee, internal, roleType,documentIds);});$(document).on('click', ".uploadFile", function() {$("#file1").trigger('click');});$(document).on('change', "input[name=file1]",function(evt) {var output = [];var fileBundle = [];for (var i = 0, f; f = evt.target.files[i]; i++) {count++;console.log(count);if (evt.target.files[i].size > 5000000) {alert("Size should be less than 5MB");return false;}if (count > "5") {alert("five files send at a time");var lilength = $('.fileList li').size();console.log(lilength);count = lilength;console.log(lilength)return false;}var file = evt.target.files[i];fileBundle.push(file);console.log(fileBundle);var removeLink = "<a class=\"removeFile\" href=\"#\" data-fileid=\""+ i + "\">Remove</a>";output.push("<li><strong>", file.name,"</strong> - ", " ",removeLink, "</li> ");}for (var j = 0; j < fileBundle.length; j++) {console.log(fileBundle[j])var url = context + '/document-upload';doAjaxUploadRequestHandler(url,'POST',fileBundle[j],function(response) {console.log(response);var documentId = response.response.document_id;console.log("documentId : "+ documentId);documentIds.push(documentId);});}console.log(documentIds);$(".fileList").append(output.join(""));});$(document).on('click', ".removeFile", function(e) {e.preventDefault();console.log("Hello")var fileId = $(this).parent().children("a").data("fileid");for (var i = 0; i < documentIds.length; ++i) {if (documentIds[i].id === fileId)documentIds.splice(i, 1);}console.log(documentIds)$(this).parent().remove();var lilen = $('.fileList li').size();count = lilen;console.log(count)/** var lilength = $('.fileList li').size(); if (lilength == 1) {* console.log(lilength) $(".fileList li").remove(); } else {* console.log(lilength) $(".fileList li").eq(fileId).remove(); } var* lilen = $('.fileList li').size();** count = lilen; console.log(count)** console.log(documentIds);*/});$(document).on('click', "#tickets-paginated .next",function() {var searchType = $("#assigneesearchType").val();var ticketStatus = $("#ticketStatus").val();var ticketStatus = $("#ticketStatus").val();var orderBy = $("#orderBy").val();var params;if (searchType == "" || searchType == undefined|| searchType == null || searchType == "TICKET_ID") {params = {"ticketStatus": ticketStatus,"orderby": orderBy};} else {var searchTerm = $("#assignee-partner-name-input").val();console.log(searchTerm);params = {"ticketStatus": ticketStatus,"orderby": orderBy,"ticketSearchType": searchType,"searchTerm": searchTerm};}loadPaginatedNextItems('/cs/myticketPaginated', params,'tickets-paginated', 'my-ticket-table','ticket-details-container');$(this).blur();});$(document).on('click', "#manager-tickets-paginated .previous",function() {var ticketStatus = $("#managerTicketStatus").val();var orderBy = $("#managerTicketorderBy").val();var searchType = $("#managersearchType").val();var params;if (searchType == "" || searchType == undefined|| searchType == null || searchType == "TICKET_ID") {params = {"ticketStatus": ticketStatus,"orderby": orderBy};} else {var searchTerm = $("#partner-name-input").val();console.log(searchTerm);params = {"ticketStatus": ticketStatus,"orderby": orderBy,"ticketSearchType": searchType,"searchTerm": searchTerm};}loadPaginatedPreviousItems('/cs/managerTicket-paginated',params, 'manager-tickets-paginated','manager-ticket-table','manager-ticket-details-container');$(this).blur();});$(document).on('click', "#manager-tickets-paginated .next",function() {var ticketStatus = $("#managerTicketStatus").val();var orderBy = $("#managerTicketorderBy").val();var searchType = $("#managersearchType").val();var params;if (searchType == "" || searchType == undefined|| searchType == null || searchType == "TICKET_ID") {params = {"ticketStatus": ticketStatus,"orderby": orderBy};} else {var searchTerm = $("#partner-name-input").val();console.log(searchTerm);params = {"ticketStatus": ticketStatus,"orderby": orderBy,"ticketSearchType": searchType,"searchTerm": searchTerm};}loadPaginatedNextItems('/cs/managerTicket-paginated', params,'manager-tickets-paginated', 'manager-ticket-table','manager-ticket-details-container');$(this).blur();});$(document).on('click', "#tickets-paginated .previous",function() {var searchType = $("#assigneesearchType").val();var ticketStatus = $("#ticketStatus").val();var ticketStatus = $("#ticketStatus").val();var orderBy = $("#orderBy").val();var params;if (searchType == "" || searchType == undefined|| searchType == null || searchType == "TICKET_ID") {params = {"ticketStatus": ticketStatus,"orderby": orderBy};} else {var searchTerm = $("#assignee-partner-name-input").val();console.log(searchTerm);params = {"ticketStatus": ticketStatus,"orderby": orderBy,"ticketSearchType": searchType,"searchTerm": searchTerm};}loadPaginatedPreviousItems('/cs/myticketPaginated', params,'tickets-paginated', 'my-ticket-table','ticket-details-container');$(this).blur();});$(document).on('click', "#positions-paginated .next",function() {loadPaginatedNextItems('/cs/position-paginated', null,'positions-paginated', 'position-table','position-details-container');$(this).blur();});$(document).on('click', "#positions-paginated .previous",function() {loadPaginatedPreviousItems('/cs/position-paginated', null,'positions-paginated', 'position-table','position-details-container');$(this).blur();});$(document).on('click', ".create-partner-region", function() {loadCreatePartnerRegion("main-content");});$(document).on('click', ".create-ticket", function() {loadCreateTicket("main-content");});$(document).on('click', ".create-ticket-button",function() {var categoryId = $('#category').val();var subCategoryId = $('#subCategory').val();if (categoryId == "" || categoryId == null|| categoryId == undefined) {alert("select appropriate category");return false;}if (subCategoryId == "" || subCategoryId == null|| subCategoryId == undefined) {alert("select appropriate subCategoryId");return false;}var dialog = bootbox.dialog({title: "Are you sure want to change create ticket!",message: "<div class=form-inline'>"+ "<label for='message'>Message:</label>"+ "<textarea class='form-control' rows='2' id='message'></textarea>"+ "</div>",buttons: {cancel: {label: "cancel",className: 'btn-danger',callback: function() {loadCreateTicket("main-content");}},ok: {label: "ok",className: 'btn-info',callback: function() {message = $('#message').val();console.log(message);if (message == ""|| message == null|| message == undefined) {alert("message field can't be empty");return false;}var params = {"categoryId": categoryId,"subCategoryId": subCategoryId,"message": message}doPostAjaxRequestWithParamsHandler(context+ "/cs/createTicket",params,function(response) {if (response == "true") {alert("successfully created");loadCreateTicket("main-content");} else {alert("You have reached maximum number of tickets Resolved , pls click on Resolved for the resolved tickets to create new.");}});}}}});});$(document).on('click', ".create-position", function() {loadCreatePosition("main-content");});$(document).on('click', ".positionPartnerView", function() {$clickedElement = $(this);var positionId = $clickedElement.data("positionid");$tdElement = $(this).closest('td');doGetAjaxRequestHandler(context + "/cs/getPosition?positionId=" + positionId, function(response) {$tdElement.html(response);$tdElement.find('.partners').multiselect({includeSelectAllOption: true,multiple: true,maxHeight: 200,buttonWidth: '180px',numberDisplayed: 1,nonSelectedText: 'Partners',nSelectedText: ' - Users Selected',allSelectedText: 'All Users Selected',enableFiltering: true,enableCaseInsensitiveFiltering: true});});});$(document).on('change', "#ticketStatus",function() {var ticketStatus = $("#ticketStatus").val();var orderBy = $("#orderBy").val();var searchType = $("#assigneesearchType").val();if (searchType == "" || searchType == undefined|| searchType == null) {loadMyTicket("main-content", ticketStatus, orderBy, null,null, null);} else {if (searchType == "PARTNER_NAME") {var searchTerm = $("#assignee-partner-name-input").val();var searchValue = $("#typeaheadpartnernameforassignee").val();loadMyTicket("main-content", ticketStatus, orderBy,searchType, searchTerm, searchValue);} else {var searchTerm = $("#assignee-search-by-ticketId").val();loadMyTicket("main-content", ticketStatus, orderBy,searchType, searchTerm, null);}}});$(document).on('change', "#orderBy",function() {var ticketStatus = $("#ticketStatus").val();var orderBy = $("#orderBy").val();var searchType = $("#assigneesearchType").val();if (searchType == "" || searchType == undefined|| searchType == null) {loadMyTicket("main-content", ticketStatus, orderBy, null,null, null);} else {if (searchType == "PARTNER_NAME") {var searchTerm = $("#assignee-partner-name-input").val();var searchValue = $("#typeaheadpartnernameforassignee").val();loadMyTicket("main-content", ticketStatus, orderBy,searchType, searchTerm, searchValue);} else {var searchTerm = $("#assignee-search-by-ticketId").val();loadMyTicket("main-content", ticketStatus, orderBy,searchType, searchTerm, null);}}});$(document).on('change', "#managerTicketStatus",function() {var ticketStatus = $("#managerTicketStatus").val();var orderBy = $("#managerTicketorderBy").val();var searchType = $("#managersearchType").val();if (searchType == "" || searchType == undefined|| searchType == null) {loadManagerTicket("main-content", ticketStatus, orderBy,null, null, null);} else {if (searchType == "PARTNER_NAME") {var searchTerm = $("#partner-name-input").val();var searchValue = $("#typeaheadpartnername").val();loadManagerTicket("main-content", ticketStatus,orderBy, searchType, searchTerm, searchValue);} else {var searchTerm = $("#search-by-ticketId").val();loadManagerTicket("main-content", ticketStatus,orderBy, searchType, searchTerm, null);}}});$(document).on('change', "#managerTicketorderBy",function() {var ticketStatus = $("#managerTicketStatus").val();var orderBy = $("#managerTicketorderBy").val();var searchType = $("#managersearchType").val();var searchType = $("#managersearchType").val();if (searchType == "" || searchType == undefined|| searchType == null) {loadManagerTicket("main-content", ticketStatus, orderBy,null, null, null);} else {if (searchType == "PARTNER_NAME") {var searchTerm = $("#partner-name-input").val();var searchValue = $("#typeaheadpartnername").val();loadManagerTicket("main-content", ticketStatus,orderBy, searchType, searchTerm, searchValue);} else {var searchTerm = $("#search-by-ticketId").val();loadManagerTicket("main-content", ticketStatus,orderBy, searchType, searchTerm, null);}}});$(document).on('change', "#category", function() {var categoryId = $("#category").val();$("#auth-user-for-category").hide();loadSubCategories(categoryId);});$(document).on('click', ".create-ticket-category-button",function() {console.log("create-ticket-category-button clicked......");var name = $("#categoryName").val();var description = $("#categorydescription").val();console.log(name, description);if (name == "" || name == null || name == undefined) {alert("Name field can't be empty");return false;}if (description == "" || description == null|| description == undefined) {alert("Description field can't be empty");return false;}if (confirm("Are you sure you want to create ticket category!") == true) {createCategory("main-content", name, description);}});$(document).on('click', ".create-region-button",function() {var name = $("#regionName").val();var description = $("#regiondescription").val();if (name == "" || name == null || name == undefined) {alert("Name field can't be empty");return false;}if (description == "" || description == null|| description == undefined) {alert("Description field can't be empty");return false;}if (confirm("Are you sure you want to create region!") == true) {createRegion("main-content", name, description);}});$(document).on('click', ".create-partner-region-button",function() {var regionId = $("#region").val();var fofoIds = $("#partner").val();console.log(regionId, fofoIds);if (regionId == "" || regionId == null|| regionId == undefined) {alert("regionId field can't be empty");return false;}if (fofoIds == "" || fofoIds == null|| fofoIds == undefined) {alert("select appropriate partner");return false;}if (confirm("Are you sure you want to create partner region!") == true) {createPartnerRegion("main-content", regionId,fofoIds);}});$(document).on('click', ".create-position-button",function() {var authUser = $("#authUser").val();var ticketCategoryPosition = $("#ticketCategoryPosition").val();var escalationType = $("#escalationType").val();var regionPosition = $("#regionPosition").val();var fofoIds = $("#partner").val();if (fofoIds.includes("0")) {fofoIds = [0];console.log(fofoIds);} else {console.log(fofoIds);}console.log(authUser, ticketCategoryPosition,escalationType, regionPosition);if (authUser == "" || authUser == null|| authUser == undefined) {alert("select appropriate authUser");return false;}if (ticketCategoryPosition == ""|| ticketCategoryPosition == null|| ticketCategoryPosition == undefined) {alert("select appropriate category");return false;}if (escalationType == "" || escalationType == null|| escalationType == undefined) {alert("select appropriate escalationType");return false;}if (regionPosition == "" || regionPosition == null|| regionPosition == undefined) {alert("select appropriate Region");return false;}if (confirm("Are you sure you want to create Position!") == true) {createPosition("main-content", authUser,ticketCategoryPosition, escalationType,regionPosition, fofoIds);}});$(document).on('change', "#ticketCategory", function() {console.log("change ticket category clicked......");var ticketCategoryId = $(this).val();console.log(ticketCategoryId);loadticketSubCategoryById(ticketCategoryId);});$(document).on('click', ".create-ticket-sub-category", function() {console.log("create ticket category clicked......");loadCreateSubCategory("main-content");});$(document).on('click', ".create-ticket-sub-category-button",function() {console.log("create-ticket-category-button clicked......");var name = $("#subcategoryName").val();var description = $("#subcategorydescription").val();var ticketCategoryId = $("#ticketCategory").val();console.log(name, description);if (name == "" || name == null || name == undefined) {alert("Name field can't be empty");return false;}if (description == "" || description == null|| description == undefined) {alert("Description field can't be empty");return false;}if (ticketCategoryId == "" || ticketCategoryId == null|| ticketCategoryId == undefined) {alert("select appropriate category name");return false;}if (confirm("Are you sure you want to create ticket category!") == true) {createSubCategory("main-content", name,description, ticketCategoryId);}});$(document).on('click', ".remove-position", function() {var positionId = $(this).data('positionid');if (confirm("Are you sure you want to remove position!") == true) {removePosition(positionId);}});$(document).on('click', ".update-position",function() {var positionId = $(this).data('positionid');var regionId = $(this).data('regionid');var row = $(this);var selectedFofoIds = $(this).closest("tr").find('#partners').val();if (selectedFofoIds.includes("0")) {selectedFofoIds = [0];console.log(selectedFofoIds);} else {console.log(selectedFofoIds);}if (confirm("Are you sure you want to update the partners!") == true) {doPostAjaxRequestWithJsonHandler(context+ "/cs/updatePartnerPosition?regionId="+ regionId + "&positionId=" + positionId,JSON.stringify(selectedFofoIds), function(response) {if (response == "true") {alert("Update successfully");loadCreatePosition("main-content");}});}});});function loadCreateCategory(domId) {doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {$('#' + domId).html(response);});}function removePosition(positionId) {doDeleteAjaxRequestHandler(context + "/cs/removePosition?positionId="+ positionId, function(response) {if (response == "true") {alert("Position removed successfully");loadCreatePosition("main-content");}});}function loadCreateRegion(domId) {doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {$('#' + domId).html(response);});}function loadMyTicket(domId, ticketStatus, sortOrder, ticketSearchType,searchTerm, searchValue) {if (ticketStatus == null && sortOrder == null) {doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {$('#' + domId).html(response);});} else if (ticketSearchType == null) {doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="+ ticketStatus + "&orderby=" + sortOrder, function(response) {$('#' + domId).html(response);});} else {doGetAjaxRequestHandler(context + "/cs/myticket?ticketStatus="+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="+ ticketSearchType + "&searchTerm=" + searchTerm, function(response) {$('#' + domId).html(response);if (ticketSearchType == "PARTNER_NAME") {$('.assigneebyPartnerName').css('display', 'inline-block');$('.assingeebyTicketId').css('display', 'none');$("#typeaheadpartnernameforassignee").val(searchValue);$("#assignee-partner-name-input").val(searchTerm);} else {$('.assigneebyPartnerName').css('display', 'none');$('.assigneebyTicketId').css('display', 'inline-block');$("#assignee-search-by-ticketId").val(searchTerm);}});}}function loadCreatePartnerRegion(domId) {doGetAjaxRequestHandler(context + "/cs/createPartnerRegion", function(response) {$('#' + domId).html(response);});}function loadCreatePosition(domId) {doGetAjaxRequestHandler(context + "/cs/createPosition", function(response) {$('#' + domId).html(response);});}function loadSubCategories(categoryId) {doGetAjaxRequestHandler(context+ "/cs/getSubCategoriesByCategoryId?categoryId=" + categoryId,function(response) {$('#' + "create-ticket-sub-categories").html(response);});}function createCategory(domId, name, description) {var params = {"name": name,"description": description}doPostAjaxRequestWithParamsHandler(context + "/cs/createCategory", params,function(response) {alert("Category created successfully");loadCreateCategory(domId);});}function changeTicket(ticketId, subCategoryId, authUserId, categoryId) {var params = {"ticketId": ticketId,"subCategoryId": subCategoryId,"authUserId": authUserId,"categoryId": categoryId}doPostAjaxRequestWithParamsHandler(context + "/cs/edit-ticket", params,function(response) {if (response == "true") {alert("Ticket changed successfully");loadManagerTicket("main-content", null, null, null, null,null);}});}function createRegion(domId, name, description) {var params = {"name": name,"description": description}doPostAjaxRequestWithParamsHandler(context + "/cs/createRegion", params,function(response) {if (response == "true") {alert("Region created successfully");loadCreateRegion(domId);}});}function loadCreateSubCategory(domId) {doGetAjaxRequestHandler(context + "/cs/createSubCategory", function(response) {$('#' + domId).html(response);});}function loadManagerTicket(domId, ticketStatus, sortOrder, ticketSearchType,searchTerm, searchValue) {if (ticketStatus == null && sortOrder == null) {doGetAjaxRequestHandler(context + "/cs/managerTicket", function(response) {$('#' + domId).html(response);});} else if (ticketSearchType == null) {doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="+ ticketStatus + "&orderby=" + sortOrder, function(response) {$('#' + domId).html(response);});} else {doGetAjaxRequestHandler(context + "/cs/managerTicket?ticketStatus="+ ticketStatus + "&orderby=" + sortOrder + "&ticketSearchType="+ ticketSearchType + "&searchTerm=" + searchTerm, function(response) {$('#' + domId).html(response);if (ticketSearchType == "PARTNER_NAME") {$('.byPartnerName').css('display', 'inline-block');$('.byTicketId').css('display', 'none');$("#typeaheadpartnername").val(searchValue);$("#partner-name-input").val(searchTerm);} else {$('.byPartnerName').css('display', 'none');$('.byTicketId').css('display', 'inline-block');$("#search-by-ticketId").val(searchTerm);}});}}function loadCreateTicket(domId) {doGetAjaxRequestHandler(context + "/cs/createTicket", function(response) {$('#' + domId).html(response);});}function loadticketSubCategoryById(ticketCategoryId) {doGetAjaxRequestHandler(context+ "/cs/getSubCategoryByCategoryId?ticketCategoryId="+ ticketCategoryId, function(response) {$(".ticket-sub-category-container").html(response);});}function createPartnerRegion(domId, regionId, fofoIds) {doPostAjaxRequestWithJsonHandler(context+ "/cs/createPartnerRegion?regionId=" + regionId, JSON.stringify(fofoIds), function(response) {if (response == "true") {alert("added region to partner successfully");loadCreatePartnerRegion(domId);}});}function createSubCategory(domId, name, description, categoryId) {var params = {"categoryId": categoryId,"name": name,"description": description}doPostAjaxRequestWithParamsHandler(context + "/cs/createSubCategory",params, function(response) {alert("Sub Category created successfully");loadCreateSubCategory(domId);});}function createLastActivity(ticketId, activity) {var params = {"ticketId": ticketId,"lastactivity": activity}doPostAjaxRequestWithParamsHandler(context + "/cs/create-last-activity",params, function(response) {if (response == "true") {alert("successfully mark last activity");loadMyTicket("main-content", null, null);}});}function createPosition(domId, authUserId, categoryId, escalationType,regionId, fofoIds) {var createPositionModel = {};createPositionModel['authUserId'] = authUserId;createPositionModel['categoryId'] = categoryIdcreatePositionModel['escalationType'] = escalationType;createPositionModel['regionId'] = regionId,createPositionModel['fofoIds'] = fofoIdsconsole.log(createPositionModel);doPostAjaxRequestWithJsonHandler(context + "/cs/createPosition", JSON.stringify(createPositionModel), function(response) {if (response == "true") {alert("Position created successfully");loadCreatePosition(domId);}});}function createActivity(message, ticketId, assigneeId, internal, roleType,documentIds) {var params = {"message": message,"ticketId": ticketId,"assigneeId": assigneeId,"internal": internal,"documentIds": documentIds,}if (documentIds.includes("0")) {documentIds = [0];console.log(documentIds);} else {console.log(documentIds);}console.log(JSON.stringify(documentIds))doPostAjaxRequestWithJsonHandler(context + "/cs/createActivity?message="+ message + "&ticketId=" + ticketId + "&assigneeId=" + assigneeId+ "&internal=" + internal, JSON.stringify(documentIds), function(response) {response = JSON.parse(response);documentIds.splice(0, documentIds.length);console.log(documentIds)$(".fileList li").remove();var assigneeName = response.firstName;loadActivities(ticketId, assigneeName, internal, roleType)});}function loadEditTicket(ticketId) {doGetAjaxRequestHandler(context + "/cs/edit-ticket?ticketId=" + ticketId,function(response) {$("#theModal .modal-content").html(response);});}function loadPartnerForRegion(regionId) {doGetAjaxRequestHandler(context + "/cs/getPartners?regionId=" + regionId,function(response) {$("#partner-region-container").html(response);});}function loadPartnerForRegionId(regionId) {doGetAjaxRequestHandler(context + "/cs/getPartnersByRegion?regionId="+ regionId, function(response) {$("#partner-subregion-container").html(response);});}function loadAccessManagement(domId) {doGetAjaxRequestHandler(context + "/admin/access-management", function(response) {$('#' + domId).html(response);});}function loadActivities(ticketId, assignee, internal, roleType) {$(".activity-container .modal-body").empty();$("#activityMessage").val("");$("#ticketIdforactivity").val(ticketId);$("#role").val(roleType);$(".activity-container .modal-title").html("Activity history for Ticket Id " + ticketId)console.log(ticketId);doGetAjaxRequestHandler(context + "/cs/getActivities?ticketId=" + ticketId,function(response) {response = JSON.parse(response);console.log(response);for (var i = 0; i < response.length; i++) {console.log(response[i].activityAttachment.length);var activityAttachment = []var attachments = "";if (response[i].activityAttachment.length > 0) {for (var j = 0; j < response[i].activityAttachment.length; j++) {var assigneeAttachment = "<a href=\"javascript:void(0)\" style=\"color:#337ab7;float:right;\"onclick=\"downloadDocument("+ response[i].activityAttachment[j].documentId+ ",\`"+ response[i].activityAttachment[j].documentName+ "\`)\">"+ response[i].activityAttachment[j].documentName+ " <i class=\"fa fa-download\"></i>"+ "</a>"activityAttachment.push(assigneeAttachment);}attachments = activityAttachment.join("");console.log(attachments);}if (response[i].type == "OPENED"|| response[i].type == "COMMUNICATION_IN") {var partnerMessage = "<div class=\"incoming_msg\">"+ "<div class=\"received_msg\">"+ "<div class=\"received_withd_msg\">" + "<p>"+ response[i].message + "</p><div>"+ `${attachments}`+ "</div> <span class=\"time_date\"> "+ response[i].createTimestamp.hour + ":"+ response[i].createTimestamp.minute + "|"+ response[i].createTimestamp.dayOfMonth + "/"+ response[i].createTimestamp.monthValue + "/"+ response[i].createTimestamp.year+ "</span></div>" + "</div>" + "</div>";$(".activity-container .modal-body").append(partnerMessage);} else if (response[i].type == "COMMUNICATION_OUT") {var assigneeMessage = "<div class=\"outgoing_msg\">"+ "<div class=\"sent_msg\">"+ "<span style=color:green>"+ "~"+ (response[i].name ? response[i].name: "Support") + "<p>"+ response[i].message + "</span> </p><div>"+ `${attachments}`+ "</div> <span class=\"time_date\">"+ response[i].createTimestamp.hour + ":"+ response[i].createTimestamp.minute + "|"+ response[i].createTimestamp.dayOfMonth + "/"+ response[i].createTimestamp.monthValue + "/"+ response[i].createTimestamp.year+ "</span> </div>" + "</div>";$(".activity-container .modal-body").append(assigneeMessage);} else if (response[i].name&& response[i].type == "COMMUNICATION_INTERNAL") {var assigneeMessage = "<div class=\"outgoing_msg\">"+ "<div class=\"sent_msg\">"+ "<span style=color:green>"+ "~"+ response[i].name+ "<p style=\"color: white;background: #b75454;\">"+ response[i].message + "</span> </p> <div>"+ `${attachments}`+ "</div> <span class=\"time_date\">"+ response[i].createTimestamp.hour + ":"+ response[i].createTimestamp.minute + "|"+ response[i].createTimestamp.dayOfMonth + "/"+ response[i].createTimestamp.monthValue + "/"+ response[i].createTimestamp.year+ "</span> </div>" + "</div>";$(".activity-container .modal-body").append(assigneeMessage);} else {var assigneeMessage = "<div class=\"outgoing_msg\">"+ "<div class=\"sent_msg\">" + "<p>"+ response[i].message + "</span> </p> <div>"+ `${attachments}`+ "</div> <span class=\"time_date\">"+ response[i].createTimestamp.hour + ":"+ response[i].createTimestamp.minute + "|"+ response[i].createTimestamp.dayOfMonth + "/"+ response[i].createTimestamp.monthValue + "/"+ response[i].createTimestamp.year+ "</span> </div>" + "</div>";$(".activity-container .modal-body").append(assigneeMessage);}}if (roleType == "true" || roleType == true) {$('.internalCheckBox').css('display', 'block');if (internal == true || internal == "true") {$('#internalCommunication').prop('checked', true);} else {$('#internalCommunication').prop('checked', false);}} else {$('.internalCheckBox').css('display', 'none');}});}function downloadDocument(documentId, documentName) {console.log(documentName)doAjaxGetDownload(context + "/download?documentId=" + documentId,documentName);}