Rev 24439 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(".create-ticket-category").live('click', function() {console.log("create ticket category clicked......");loadCreateCategory("main-content");});$(".create-region").live('click', function() {loadCreateRegion("main-content");});$(".ticketType").live('click', function() {loadCreateRegion("main-content");});$(".activities").live('click', function() {var ticketId = $(this).data('ticketid');var assignee = $(this).data('assignee');console.log(assignee);loadActivities(ticketId, assignee);});$(".my-ticket").live('click', function() {loadMyTicket("main-content");});$("#close-ticket").live('click', function() {var ticketId = $(this).data('ticketid');if (confirm("Are you sure you want to close ticket!") == true) {closeTicket(ticketId);}});$(".submit-message-button").live('click', function() {var message = $("#activityMessage").val();if (message == "" || message == null || message == undefined) {alert("message field can't be empty");}var ticketId = $("#ticketIdforactivity").val();var assignee = $("#assigneeUser").val();console.log(message, ticketId, assignee);createActivity(message, ticketId, assignee);});$("#tickets-paginated .next").live('click',function() {loadPaginatedNextItems('/cs/myticketPaginated', null,'tickets-paginated', 'my-ticket-table','ticket-details-container');$(this).blur();});$("#tickets-paginated .previous").live('click',function() {loadPaginatedPreviousItems('/cs/myticketPaginated', null,'tickets-paginated', 'my-ticket-table','ticket-details-container');});$(".create-partner-region").live('click', function() {loadCreatePartnerRegion("main-content");});$(".create-ticket").live('click', function() {loadCreateTicket("main-content");});$(".create-ticket-button").live('click',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");}});}}}});});$(".create-position").live('click', function() {loadCreatePosition("main-content");});$("#category").live('change', function() {var categoryId = $("#category").val();loadSubCategories(categoryId);});$(".create-ticket-category-button").live('click',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);}});$(".create-region-button").live('click',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);}});$(".create-partner-region-button").live('click',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);}});$(".create-position-button").live('click',function() {var authUser = $("#authUser").val();var ticketCategoryPosition = $("#ticketCategoryPosition").val();var escalationType = $("#escalationType").val();var regionPosition = $("#regionPosition").val();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);}});$("#ticketCategory").live('change', function() {console.log("change ticket category clicked......");var ticketCategoryId = $(this).val();console.log(ticketCategoryId);loadticketSubCategoryById(ticketCategoryId);});$(".create-ticket-sub-category").live('click', function() {console.log("create ticket category clicked......");loadCreateSubCategory("main-content");});$(".create-ticket-sub-category-button").live('click',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);}});});function loadCreateCategory(domId) {doGetAjaxRequestHandler(context + "/cs/createCategory", function(response) {$('#' + domId).html(response);});}function loadCreateRegion(domId) {doGetAjaxRequestHandler(context + "/cs/createRegion", function(response) {$('#' + domId).html(response);});}function loadMyTicket(domId) {doGetAjaxRequestHandler(context + "/cs/myticket", function(response) {$('#' + domId).html(response);});}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 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 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 closeTicket(ticketId) {var params = {"ticketId" : ticketId}doPostAjaxRequestWithParamsHandler(context + "/cs/closeTicket", params,function(response) {alert("Ticket close successfully");loadMyTicket("main-content");});}function createPosition(domId, authUserId, categoryId, escalationType, regionId) {var params = {"authUserId" : authUserId,"categoryId" : categoryId,"escalationType" : escalationType,"regionId" : regionId}doPostAjaxRequestWithParamsHandler(context + "/cs/createPosition", params,function(response) {if (response == "true") {alert("Position created successfully");loadCreatePosition(domId);}});}function createActivity(message, ticketId, assigneeId) {var params = {"message" : message,"ticketId" : ticketId,}doPostAjaxRequestWithParamsHandler(context + "/cs/createActivity", params,function(response) {response = JSON.parse(response);var assigneeName = response.firstName;loadActivities(ticketId, assigneeName)});}function loadActivities(ticketId, assignee) {$(".modal-body").empty();$("#activityMessage").val("");$("#ticketIdforactivity").val(ticketId);var assigned = "<div class=\"white_box\"><span>AssignedTo:-" + assignee+ "</span></div>";$(".modal-body").append(assigned);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++) {if ((response[i].type == "OPENED" || response[i].type == "COMMUNICATION_IN")&& response[i].createdBy == 0) {var partnerMessage = "<div class=\"incoming_msg\">"+ "<div class=\"received_msg\">"+ "<div class=\"received_withd_msg\">" + "<p>"+ response[i].message + "</p>"+ "<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>";$(".modal-body").append(partnerMessage);}if (response[i].type = "COMMUNICATION_OUT"&& response[i].createdBy > 0) {var assigneeMessage = "<div class=\"outgoing_msg\">"+ "<div class=\"sent_msg\">" + "<p>"+ response[i].message + "</p>"+ "<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>";$(".modal-body").append(assigneeMessage);}}});}