/** * Get ticket list */ function wpsc_get_ticket_list(is_humbargar = false) {
supportcandy.current_section = 'ticket-list';
if (is_humbargar) wpsc_toggle_humbargar();
if (wpsc_is_description_text()) { if ( !confirm(supportcandy.translations.warning_message)){ return; } else { var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); if (is_tinymce && tinymce.get('description')) { var description = tinyMCE.get('description').setContent(''); } else { var description = jQuery('#description').val(''); } ticket_id = jQuery('#wpsc-current-ticket').val(); wpsc_clear_saved_draft_reply( ticket_id ); } }
var id = supportcandy.current_ticket_id; if (id) { delete supportcandy.current_ticket_id; wpsc_get_individual_ticket(id); return; }
// set flag to differenciate between ticket list and individual ticket supportcandy.ticketListIsIndividual = false;
jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active'); jQuery('.wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list').addClass('active'); jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.ticket_list);
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'ticket-list'); search_params.delete('ticket-id'); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString());
jQuery('.wpsc-body').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_ticket_list', _ajax_nonce: supportcandy.nonce, is_frontend: supportcandy.is_frontend }; search_params.forEach(function(value, key) { data[key] = value; }); if (typeof supportcandy.ticketList != 'undefined' && typeof supportcandy.ticketList.filters != 'undefined') { data.filters = supportcandy.ticketList.filters; } jQuery.post(supportcandy.ajax_url, data, function (response) { jQuery('.wpsc-body').html(response); wpsc_reset_responsive_style(); }); wpsc_delete_auto_draft(); }
/** * Get individual ticket */ function wpsc_get_individual_ticket(id) {
jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active'); jQuery('.wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list').addClass('active'); jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.ticket_list);
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'ticket-list'); search_params.set('ticket-id', id); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString());
jQuery('.wpsc-body').html(supportcandy.loader_html);
// set flag to differenciate between ticket list and individual ticket supportcandy.ticketListIsIndividual = true;
var data = { action: 'wpsc_get_individual_ticket', ticket_id: id, }; search_params.forEach(function(value, key) { data[key] = value; }); jQuery.post(supportcandy.ajax_url, data, function (response) { jQuery('.wpsc-body').html(response); wpsc_reset_responsive_style(); }); }
/** * Get create ticket form */ function wpsc_get_ticket_form(is_humbargar = false) {
supportcandy.current_section = 'new-ticket';
if (is_humbargar) wpsc_toggle_humbargar();
if (wpsc_is_description_text()) { if ( confirm(supportcandy.translations.warning_message)){ current_ticket = jQuery('#wpsc-current-ticket').val(); wpsc_clear_saved_draft_reply( current_ticket ); } else{ return; } }
jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active'); jQuery('.wpsc-tickets-nav.new-ticket, .wpsc-humbargar-menu-item.new-ticket').addClass('active'); jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.new_ticket);
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'new-ticket'); search_params.delete('ticket-id'); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString());
jQuery('.wpsc-body').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_ticket_form', _ajax_nonce: supportcandy.nonce }; search_params.forEach(function(value, key) { data[key] = value; }); jQuery.post(supportcandy.ajax_url, data, function (response) { jQuery('.wpsc-body').html(response); wpsc_reset_responsive_style(); }); }
/** * Get agent settings */ function wpsc_get_user_profile(is_humbargar = false) {
supportcandy.current_section = 'my-profile';
if (is_humbargar) wpsc_toggle_humbargar();
jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active'); jQuery('.wpsc-tickets-nav.my-profile, .wpsc-humbargar-menu-item.my-profile').addClass('active'); jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.my_profile);
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'my-profile'); search_params.delete('ticket-id'); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString());
jQuery('.wpsc-body').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_user_profile' }; search_params.forEach(function(value, key) { data[key] = value; }); jQuery.post(supportcandy.ajax_url, data, function (response) { jQuery('.wpsc-body').html(response); wpsc_reset_responsive_style(); }); }
/** * Get agent settings */ function wpsc_get_agent_profile(is_humbargar = false) {
supportcandy.current_section = 'agent-profile';
if (is_humbargar) wpsc_toggle_humbargar();
jQuery('.wpsc-tickets-nav, .wpsc-humbargar-menu-item').removeClass('active'); jQuery('.wpsc-tickets-nav.agent-profile, .wpsc-humbargar-menu-item.agent-profile').addClass('active'); jQuery('.wpsc-humbargar-title').html(supportcandy.humbargar_titles.agent_profile);
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'agent-profile'); search_params.delete('ticket-id'); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString());
jQuery('.wpsc-body').html(supportcandy.loader_html);
var data = { action: 'wpsc_get_agent_profile' }; search_params.forEach(function(value, key) { data[key] = value; }); jQuery.post(supportcandy.ajax_url, data, function (response) { jQuery('.wpsc-body').html(response); wpsc_reset_responsive_style(); jQuery('.wpsc-ap-nav.general').trigger('click'); }); }
/** * Get agent dashboard */ function wpsc_get_agent_dashboard(is_humbargar = false) {
supportcandy.current_section = 'dashboard';
if (is_humbargar) { wpsc_toggle_humbargar(); }
jQuery( '.wpsc-tickets-nav, .wpsc-humbargar-menu-item' ).removeClass( 'active' ); jQuery( '.wpsc-tickets-nav.dashboard, .wpsc-humbargar-menu-item.dashboard' ).addClass( 'active' ); jQuery( '.wpsc-humbargar-title' ).html( supportcandy.humbargar_titles.dashboard );
// set url var url = new URL(window.location.href); var search_params = url.searchParams; search_params.set('wpsc-section', 'dashboard'); search_params.delete('ticket-id'); url.search = search_params.toString(); window.history.replaceState({}, null, url.toString()); jQuery( '.wpsc-body' ).html( supportcandy.loader_html );
var data = { action: 'wpsc_get_agent_dashboard' }; search_params.forEach(function(value, key) { data[key] = value; });
jQuery.post( supportcandy.ajax_url, data, function (response) { jQuery( '.wpsc-body' ).html( response ); wpsc_reset_responsive_style(); jQuery( '.wpsc-ap-nav.general' ).trigger( 'click' ); } ); }
/** * Get create ticket as guest */ function wpsc_get_guest_ticket_form() {
jQuery('.wpsc-shortcode-container').html('
'); wpsc_get_ticket_form(); }