| @@ -1,1416 +1,6354 @@ | ||
| 1 | +/** | |
| 2 | + * Get ticket list | |
| 3 | + */ | |
| 4 | +function wpsc_get_ticket_list(is_humbargar = false) { | |
| 5 | + supportcandy.current_section = "ticket-list"; | |
| 1 | 6 | |
| 2 | -/* | |
| 3 | - * General Settings | |
| 7 | + if (is_humbargar) { | |
| 8 | + wpsc_toggle_humbargar(); | |
| 9 | + } | |
| 10 | + | |
| 11 | + if (wpsc_is_description_text()) { | |
| 12 | + if (!confirm(supportcandy.translations.warning_message)) { | |
| 13 | + return; | |
| 14 | + } else { | |
| 15 | + var is_tinymce = | |
| 16 | + typeof tinyMCE != "undefined" && | |
| 17 | + tinyMCE.activeEditor && | |
| 18 | + !tinyMCE.activeEditor.isHidden(); | |
| 19 | + if (is_tinymce && tinymce.get("description")) { | |
| 20 | + var description = tinyMCE.get("description").setContent(""); | |
| 21 | + } else { | |
| 22 | + var description = jQuery("#description").val(""); | |
| 23 | + } | |
| 24 | + ticket_id = jQuery("#wpsc-current-ticket").val(); | |
| 25 | + wpsc_clear_saved_draft_reply(ticket_id); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + | |
| 29 | + var id = supportcandy.current_ticket_id; | |
| 30 | + if (id) { | |
| 31 | + delete supportcandy.current_ticket_id; | |
| 32 | + wpsc_get_individual_ticket(id); | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + | |
| 36 | + wpsc_update_live_agents(); | |
| 37 | + | |
| 38 | + // set flag to differenciate between ticket list and individual ticket. | |
| 39 | + supportcandy.ticketListIsIndividual = false; | |
| 40 | + | |
| 41 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 42 | + jQuery( | |
| 43 | + ".wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list" | |
| 44 | + ).addClass("active"); | |
| 45 | + jQuery(".wpsc-humbargar-title").html( | |
| 46 | + supportcandy.humbargar_titles.ticket_list | |
| 47 | + ); | |
| 48 | + | |
| 49 | + window.history.replaceState( | |
| 50 | + {}, | |
| 51 | + null, | |
| 52 | + "admin.php?page=wpsc-tickets§ion=ticket-list" | |
| 53 | + ); | |
| 54 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 55 | + | |
| 56 | + wpsc_scroll_top(); | |
| 57 | + | |
| 58 | + var data = { | |
| 59 | + action: "wpsc_get_ticket_list", | |
| 60 | + _ajax_nonce: supportcandy.nonce, | |
| 61 | + is_frontend: supportcandy.is_frontend, | |
| 62 | + }; | |
| 63 | + if ( | |
| 64 | + typeof supportcandy.ticketList != "undefined" && | |
| 65 | + typeof supportcandy.ticketList.filters != "undefined" | |
| 66 | + ) { | |
| 67 | + data.filters = supportcandy.ticketList.filters; | |
| 68 | + } | |
| 69 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 70 | + jQuery(".wpsc-body").html(response); | |
| 71 | + wpsc_reset_responsive_style(); | |
| 72 | + }); | |
| 73 | + wpsc_delete_auto_draft(); | |
| 74 | +} | |
| 75 | + | |
| 76 | +/** | |
| 77 | + * Get individual ticket | |
| 4 | 78 | */ |
| 5 | -function wpsc_get_general_settings(){ | |
| 6 | - | |
| 7 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 8 | - jQuery('#wpsc_settings_general').addClass('active'); | |
| 9 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 10 | - | |
| 79 | +function wpsc_get_individual_ticket(id) { | |
| 80 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 81 | + jQuery( | |
| 82 | + ".wpsc-tickets-nav.ticket-list, .wpsc-humbargar-menu-item.ticket-list" | |
| 83 | + ).addClass("active"); | |
| 84 | + jQuery(".wpsc-humbargar-title").html( | |
| 85 | + supportcandy.humbargar_titles.ticket_list | |
| 86 | + ); | |
| 87 | + | |
| 88 | + window.history.replaceState( | |
| 89 | + {}, | |
| 90 | + null, | |
| 91 | + "admin.php?page=wpsc-tickets§ion=ticket-list&id=" + id | |
| 92 | + ); | |
| 93 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 94 | + | |
| 95 | + wpsc_scroll_top(); | |
| 96 | + | |
| 97 | + // set flag to differenciate between ticket list and individual ticket. | |
| 98 | + supportcandy.ticketListIsIndividual = true; | |
| 99 | + | |
| 11 | 100 | var data = { |
| 12 | - action: 'wpsc_settings', | |
| 13 | - setting_action : 'get_general_settings' | |
| 101 | + action: "wpsc_get_individual_ticket", | |
| 102 | + ticket_id: id, | |
| 14 | 103 | }; |
| 104 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 105 | + jQuery(".wpsc-body").html(response); | |
| 106 | + wpsc_reset_responsive_style(); | |
| 107 | + }); | |
| 108 | +} | |
| 15 | 109 | |
| 16 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 17 | - jQuery('.wpsc_setting_col2').html(response); | |
| 110 | +/** | |
| 111 | + * Get create ticket form | |
| 112 | + */ | |
| 113 | +function wpsc_get_ticket_form(is_humbargar = false) { | |
| 114 | + supportcandy.current_section = "new-ticket"; | |
| 115 | + | |
| 116 | + if (is_humbargar) { | |
| 117 | + wpsc_toggle_humbargar(); | |
| 118 | + } | |
| 119 | + | |
| 120 | + if (wpsc_is_description_text()) { | |
| 121 | + if (confirm(supportcandy.translations.warning_message)) { | |
| 122 | + current_ticket = jQuery("#wpsc-current-ticket").val(); | |
| 123 | + wpsc_clear_saved_draft_reply(current_ticket); | |
| 124 | + } else { | |
| 125 | + return; | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | + wpsc_update_live_agents(); | |
| 130 | + | |
| 131 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 132 | + jQuery( | |
| 133 | + ".wpsc-tickets-nav.new-ticket, .wpsc-humbargar-menu-item.new-ticket" | |
| 134 | + ).addClass("active"); | |
| 135 | + jQuery(".wpsc-humbargar-title").html( | |
| 136 | + supportcandy.humbargar_titles.new_ticket | |
| 137 | + ); | |
| 138 | + | |
| 139 | + // set url. | |
| 140 | + var url = new URL(window.location.href); | |
| 141 | + var search_params = url.searchParams; | |
| 142 | + search_params.set("section", "new-ticket"); | |
| 143 | + search_params.delete("id"); | |
| 144 | + url.search = search_params.toString(); | |
| 145 | + window.history.replaceState({}, null, url.toString()); | |
| 146 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 147 | + | |
| 148 | + wpsc_scroll_top(); | |
| 149 | + | |
| 150 | + var data = { | |
| 151 | + action: "wpsc_get_ticket_form", | |
| 152 | + _ajax_nonce: supportcandy.nonce, | |
| 153 | + }; | |
| 154 | + search_params.forEach(function (value, key) { | |
| 155 | + data[key] = value; | |
| 18 | 156 | }); |
| 19 | - | |
| 157 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 158 | + jQuery(".wpsc-body").html(response); | |
| 159 | + wpsc_reset_responsive_style(); | |
| 160 | + }); | |
| 20 | 161 | } |
| 21 | 162 | |
| 22 | -function wpsc_set_general_settings(){ | |
| 23 | - | |
| 24 | - jQuery('.wpsc_submit_wait').show(); | |
| 25 | - var dataform = new FormData(jQuery('#wpsc_frm_general_settings')[0]); | |
| 26 | - | |
| 27 | - jQuery.ajax({ | |
| 28 | - url: wpsc_admin.ajax_url, | |
| 29 | - type: 'POST', | |
| 30 | - data: dataform, | |
| 31 | - processData: false, | |
| 32 | - contentType: false | |
| 33 | - }) | |
| 34 | - .done(function (response_str) { | |
| 35 | - var response = JSON.parse(response_str); | |
| 36 | - jQuery('.wpsc_submit_wait').hide(); | |
| 37 | - if (response.sucess_status=='1') { | |
| 38 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 39 | - } | |
| 40 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 41 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 163 | +/** | |
| 164 | + * Get agent settings | |
| 165 | + */ | |
| 166 | +function wpsc_get_user_profile(is_humbargar = false) { | |
| 167 | + supportcandy.current_section = "my-profile"; | |
| 168 | + | |
| 169 | + if (is_humbargar) { | |
| 170 | + wpsc_toggle_humbargar(); | |
| 171 | + } | |
| 172 | + | |
| 173 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 174 | + jQuery( | |
| 175 | + ".wpsc-tickets-nav.my-profile, .wpsc-humbargar-menu-item.my-profile" | |
| 176 | + ).addClass("active"); | |
| 177 | + jQuery(".wpsc-humbargar-title").html( | |
| 178 | + supportcandy.humbargar_titles.my_profile | |
| 179 | + ); | |
| 180 | + | |
| 181 | + wpsc_update_live_agents(); | |
| 182 | + | |
| 183 | + window.history.replaceState( | |
| 184 | + {}, | |
| 185 | + null, | |
| 186 | + "admin.php?page=wpsc-tickets§ion=my-profile" | |
| 187 | + ); | |
| 188 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 189 | + | |
| 190 | + wpsc_scroll_top(); | |
| 191 | + | |
| 192 | + var data = { action: "wpsc_get_user_profile" }; | |
| 193 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 194 | + jQuery(".wpsc-body").html(response); | |
| 195 | + wpsc_reset_responsive_style(); | |
| 42 | 196 | }); |
| 43 | - | |
| 44 | 197 | } |
| 45 | 198 | |
| 46 | -function wpsc_set_terms_and_condition_settings(){ | |
| 47 | - | |
| 48 | - jQuery('.wpsc_submit_wait').show(); | |
| 49 | - var dataform = new FormData(jQuery('#wpsc_terms_and_cond_settings')[0]); | |
| 50 | - jQuery.ajax({ | |
| 51 | - url: wpsc_admin.ajax_url, | |
| 52 | - type: 'POST', | |
| 53 | - data: dataform, | |
| 54 | - processData: false, | |
| 55 | - contentType: false | |
| 56 | - }) | |
| 57 | - .done(function (response_str) { | |
| 58 | - var response = JSON.parse(response_str); | |
| 59 | - jQuery('.wpsc_submit_wait').hide(); | |
| 60 | - if (response.sucess_status=='1') { | |
| 61 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 62 | - } | |
| 63 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 64 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 199 | +/** | |
| 200 | + * Get agent settings | |
| 201 | + */ | |
| 202 | +function wpsc_get_agent_profile(is_humbargar = false) { | |
| 203 | + supportcandy.current_section = "agent-profile"; | |
| 204 | + | |
| 205 | + if (is_humbargar) { | |
| 206 | + wpsc_toggle_humbargar(); | |
| 207 | + } | |
| 208 | + | |
| 209 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 210 | + jQuery( | |
| 211 | + ".wpsc-tickets-nav.agent-profile, .wpsc-humbargar-menu-item.agent-profile" | |
| 212 | + ).addClass("active"); | |
| 213 | + jQuery(".wpsc-humbargar-title").html( | |
| 214 | + supportcandy.humbargar_titles.agent_profile | |
| 215 | + ); | |
| 216 | + | |
| 217 | + wpsc_update_live_agents(); | |
| 218 | + | |
| 219 | + window.history.replaceState( | |
| 220 | + {}, | |
| 221 | + null, | |
| 222 | + "admin.php?page=wpsc-tickets§ion=agent-profile" | |
| 223 | + ); | |
| 224 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 225 | + | |
| 226 | + wpsc_scroll_top(); | |
| 227 | + | |
| 228 | + var data = { action: "wpsc_get_agent_profile" }; | |
| 229 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 230 | + jQuery(".wpsc-body").html(response); | |
| 231 | + wpsc_reset_responsive_style(); | |
| 232 | + jQuery(".wpsc-ap-nav.general").trigger("click"); | |
| 65 | 233 | }); |
| 66 | - | |
| 67 | 234 | } |
| 68 | 235 | |
| 69 | -/* | |
| 70 | - * Category Settings | |
| 236 | +/** | |
| 237 | + * Get agent dashboard | |
| 71 | 238 | */ |
| 72 | -function wpsc_get_category_settings(){ | |
| 73 | - | |
| 74 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 75 | - jQuery('#wpsc_settings_category').addClass('active'); | |
| 76 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 77 | - | |
| 239 | +function wpsc_get_agent_dashboard(is_humbargar = false) { | |
| 240 | + supportcandy.current_section = "dashboard"; | |
| 241 | + | |
| 242 | + if (is_humbargar) { | |
| 243 | + wpsc_toggle_humbargar(); | |
| 244 | + } | |
| 245 | + | |
| 246 | + wpsc_update_live_agents(); | |
| 247 | + | |
| 248 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 249 | + jQuery( | |
| 250 | + ".wpsc-tickets-nav.dashboard, .wpsc-humbargar-menu-item.dashboard" | |
| 251 | + ).addClass("active"); | |
| 252 | + jQuery(".wpsc-humbargar-title").html(supportcandy.humbargar_titles.dashboard); | |
| 253 | + | |
| 254 | + window.history.replaceState( | |
| 255 | + {}, | |
| 256 | + null, | |
| 257 | + "admin.php?page=wpsc-tickets§ion=dashboard" | |
| 258 | + ); | |
| 259 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 260 | + | |
| 261 | + wpsc_scroll_top(); | |
| 262 | + | |
| 263 | + var data = { action: "wpsc_get_agent_dashboard" }; | |
| 264 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 265 | + jQuery(".wpsc-body").html(response); | |
| 266 | + wpsc_reset_responsive_style(); | |
| 267 | + jQuery(".wpsc-ap-nav.general").trigger("click"); | |
| 268 | + }); | |
| 269 | +} | |
| 270 | + | |
| 271 | +/** | |
| 272 | + * Show other actions popover | |
| 273 | + */ | |
| 274 | +function wpsc_show_tl_other_actions() { | |
| 275 | + jQuery("#wpsc-more-actions").gpopover("show"); | |
| 276 | +} | |
| 277 | + | |
| 278 | +/** | |
| 279 | + * Get agent list | |
| 280 | + */ | |
| 281 | +function wpsc_get_agent_list(is_humbargar = false) { | |
| 282 | + if (is_humbargar) { | |
| 283 | + wpsc_toggle_humbargar(); | |
| 284 | + } | |
| 285 | + | |
| 286 | + var id = supportcandy.current_id; | |
| 287 | + if (id) { | |
| 288 | + delete supportcandy.current_id; | |
| 289 | + wpsc_get_individual_agent(id); | |
| 290 | + return; | |
| 291 | + } | |
| 292 | + | |
| 293 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 294 | + jQuery(".wpsc-setting-nav.agents, .wpsc-humbargar-menu-item.agents").addClass( | |
| 295 | + "active" | |
| 296 | + ); | |
| 297 | + jQuery(".wpsc-humbargar-title").html(supportcandy.humbargar_titles.agents); | |
| 298 | + | |
| 299 | + window.history.replaceState( | |
| 300 | + {}, | |
| 301 | + null, | |
| 302 | + "admin.php?page=wpsc-support-agents§ion=agents" | |
| 303 | + ); | |
| 304 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 305 | + | |
| 306 | + wpsc_scroll_top(); | |
| 307 | + | |
| 308 | + var data = { action: "wpsc_get_agent_list" }; | |
| 309 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 310 | + jQuery(".wpsc-setting-body").html(response); | |
| 311 | + wpsc_reset_responsive_style(); | |
| 312 | + }); | |
| 313 | +} | |
| 314 | + | |
| 315 | +/** | |
| 316 | + * Create an agent | |
| 317 | + */ | |
| 318 | +function wpsc_set_add_agent(el) { | |
| 319 | + var user = jQuery(".wpsc-frm-add-agent #wpsc-select-user-input").val(); | |
| 320 | + if (!user) { | |
| 321 | + alert(supportcandy.translations.req_fields_missing); | |
| 322 | + return; | |
| 323 | + } | |
| 324 | + var form = jQuery(".wpsc-frm-add-agent")[0]; | |
| 325 | + var dataform = new FormData(form); | |
| 326 | + | |
| 327 | + var users = dataform.getAll("users[]"); | |
| 328 | + if (!users.length) { | |
| 329 | + alert(supportcandy.translations.req_fields_missing); | |
| 330 | + return; | |
| 331 | + } | |
| 332 | + | |
| 333 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 334 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 335 | + jQuery | |
| 336 | + .ajax({ | |
| 337 | + url: supportcandy.ajax_url, | |
| 338 | + type: "POST", | |
| 339 | + data: dataform, | |
| 340 | + processData: false, | |
| 341 | + contentType: false, | |
| 342 | + }) | |
| 343 | + .done(function (res) { | |
| 344 | + wpsc_close_modal(); | |
| 345 | + wpsc_get_agent_list(); | |
| 346 | + }); | |
| 347 | +} | |
| 348 | + | |
| 349 | +/** | |
| 350 | + * Get edit agent modal popup | |
| 351 | + */ | |
| 352 | +function wpsc_get_edit_agent(id, _ajax_nonce) { | |
| 353 | + wpsc_show_modal(); | |
| 78 | 354 | var data = { |
| 79 | - action: 'wpsc_settings', | |
| 80 | - setting_action : 'get_category_settings' | |
| 355 | + action: "wpsc_get_edit_agent", | |
| 356 | + id, | |
| 357 | + _ajax_nonce, | |
| 81 | 358 | }; |
| 359 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 360 | + // Set to modal. | |
| 361 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 362 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 363 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 364 | + // Display modal. | |
| 365 | + wpsc_show_modal_inner_container(); | |
| 366 | + }); | |
| 367 | +} | |
| 82 | 368 | |
| 83 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 84 | - jQuery('.wpsc_setting_col2').html(response); | |
| 85 | - }); | |
| 86 | - | |
| 369 | +/** | |
| 370 | + * Submit changes made to an agent | |
| 371 | + */ | |
| 372 | +function wpsc_set_edit_agent(el) { | |
| 373 | + var form = jQuery(".wpsc-frm-edit-agent")[0]; | |
| 374 | + var dataform = new FormData(form); | |
| 375 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 376 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 377 | + jQuery | |
| 378 | + .ajax({ | |
| 379 | + url: supportcandy.ajax_url, | |
| 380 | + type: "POST", | |
| 381 | + data: dataform, | |
| 382 | + processData: false, | |
| 383 | + contentType: false, | |
| 384 | + }) | |
| 385 | + .done(function (res) { | |
| 386 | + wpsc_close_modal(); | |
| 387 | + wpsc_get_agent_list(); | |
| 388 | + }); | |
| 87 | 389 | } |
| 88 | 390 | |
| 89 | -/* | |
| 90 | - * Status Settings | |
| 391 | +/** | |
| 392 | + * Get delete agent modal popup | |
| 91 | 393 | */ |
| 92 | -function wpsc_get_status_settings(){ | |
| 93 | - | |
| 94 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 95 | - jQuery('#wpsc_settings_status').addClass('active'); | |
| 96 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 97 | - | |
| 394 | +function wpsc_get_delete_agent(id, nonce) { | |
| 395 | + var flag = confirm(supportcandy.translations.confirm); | |
| 396 | + if (!flag) { | |
| 397 | + return; | |
| 398 | + } | |
| 399 | + | |
| 98 | 400 | var data = { |
| 99 | - action: 'wpsc_settings', | |
| 100 | - setting_action : 'get_status_settings' | |
| 401 | + action: "wpsc_delete_agent", | |
| 402 | + id, | |
| 403 | + _ajax_nonce: nonce, | |
| 101 | 404 | }; |
| 405 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 406 | + wpsc_get_agent_list(); | |
| 407 | + }); | |
| 408 | +} | |
| 102 | 409 | |
| 103 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 104 | - jQuery('.wpsc_setting_col2').html(response); | |
| 410 | +/** | |
| 411 | + * Submit delete an agent request | |
| 412 | + */ | |
| 413 | +function wpsc_set_delete_agent(el) { | |
| 414 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 415 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 416 | + setTimeout(function () { | |
| 417 | + wpsc_close_modal(); | |
| 418 | + wpsc_get_agent_list(); | |
| 419 | + }, 500); | |
| 420 | +} | |
| 421 | + | |
| 422 | +/** | |
| 423 | + * Get agent roles | |
| 424 | + */ | |
| 425 | +function wpsc_get_agent_roles(is_humbargar = false) { | |
| 426 | + if (is_humbargar) { | |
| 427 | + wpsc_toggle_humbargar(); | |
| 428 | + } | |
| 429 | + | |
| 430 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 431 | + jQuery( | |
| 432 | + ".wpsc-setting-nav.agent-roles, .wpsc-humbargar-menu-item.agent-roles" | |
| 433 | + ).addClass("active"); | |
| 434 | + jQuery(".wpsc-humbargar-title").html( | |
| 435 | + supportcandy.humbargar_titles.agent_roles | |
| 436 | + ); | |
| 437 | + | |
| 438 | + window.history.replaceState( | |
| 439 | + {}, | |
| 440 | + null, | |
| 441 | + "admin.php?page=wpsc-support-agents§ion=agent-roles" | |
| 442 | + ); | |
| 443 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 444 | + | |
| 445 | + wpsc_scroll_top(); | |
| 446 | + | |
| 447 | + var data = { action: "wpsc_get_agent_roles" }; | |
| 448 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 449 | + jQuery(".wpsc-setting-body").html(response); | |
| 450 | + wpsc_reset_responsive_style(); | |
| 105 | 451 | }); |
| 106 | - | |
| 107 | 452 | } |
| 108 | 453 | |
| 109 | -function wpsc_get_priority_settings(){ | |
| 110 | - | |
| 111 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 112 | - jQuery('#wpsc_settings_priority').addClass('active'); | |
| 113 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 114 | - | |
| 454 | +/** | |
| 455 | + * Create an agent | |
| 456 | + */ | |
| 457 | +function wpsc_set_add_agent_role(el) { | |
| 458 | + var label = jQuery(".frm-add-agent-role #label").val().trim(); | |
| 459 | + if (!label) { | |
| 460 | + alert(supportcandy.translations.req_fields_missing); | |
| 461 | + return; | |
| 462 | + } | |
| 463 | + jQuery("#wpsc_add_agent_role").DataTable().search("").draw(); | |
| 464 | + var form = jQuery(".frm-add-agent-role")[0]; | |
| 465 | + var dataform = new FormData(form); | |
| 466 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 467 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 468 | + jQuery | |
| 469 | + .ajax({ | |
| 470 | + url: supportcandy.ajax_url, | |
| 471 | + type: "POST", | |
| 472 | + data: dataform, | |
| 473 | + processData: false, | |
| 474 | + contentType: false, | |
| 475 | + }) | |
| 476 | + .done(function (res) { | |
| 477 | + wpsc_get_agent_roles(); | |
| 478 | + }); | |
| 479 | +} | |
| 480 | + | |
| 481 | +/** | |
| 482 | + * Get clone agent role | |
| 483 | + */ | |
| 484 | +function wpsc_get_clone_agent_role(id, nonce) { | |
| 485 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 486 | + var data = { action: "wpsc_get_clone_agent_role", id, _ajax_nonce: nonce }; | |
| 487 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 488 | + wpsc_get_agent_roles(); | |
| 489 | + }); | |
| 490 | +} | |
| 491 | + | |
| 492 | +/** | |
| 493 | + * Get edit agent roles | |
| 494 | + */ | |
| 495 | +function wpsc_get_edit_agent_role(id, nonce) { | |
| 496 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 115 | 497 | var data = { |
| 116 | - action: 'wpsc_settings', | |
| 117 | - setting_action : 'get_priority_settings' | |
| 498 | + action: "wpsc_get_edit_agent_role", | |
| 499 | + role_id: id, | |
| 500 | + _ajax_nonce: nonce, | |
| 118 | 501 | }; |
| 502 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 503 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 504 | + }); | |
| 505 | +} | |
| 119 | 506 | |
| 120 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 121 | - jQuery('.wpsc_setting_col2').html(response); | |
| 122 | - }); | |
| 123 | - | |
| 507 | +/** | |
| 508 | + * Submit changes made to an agent | |
| 509 | + */ | |
| 510 | +function wpsc_set_edit_agent_role(el) { | |
| 511 | + var label = jQuery(".frm-edit-agent-role #label").val().trim(); | |
| 512 | + if (!label) { | |
| 513 | + alert(supportcandy.translations.req_fields_missing); | |
| 514 | + return; | |
| 515 | + } | |
| 516 | + jQuery("#wpsc_edit_agent_role").DataTable().search("").draw(); | |
| 517 | + var form = jQuery(".frm-edit-agent-role")[0]; | |
| 518 | + var dataform = new FormData(form); | |
| 519 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 520 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 521 | + jQuery | |
| 522 | + .ajax({ | |
| 523 | + url: supportcandy.ajax_url, | |
| 524 | + type: "POST", | |
| 525 | + data: dataform, | |
| 526 | + processData: false, | |
| 527 | + contentType: false, | |
| 528 | + }) | |
| 529 | + .done(function (res) { | |
| 530 | + wpsc_get_agent_roles(); | |
| 531 | + }); | |
| 124 | 532 | } |
| 125 | 533 | |
| 126 | -function wpsc_get_ticket_widget_settings() { | |
| 127 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 128 | - jQuery('#wpsc_settings_ticket_widget').addClass('active'); | |
| 129 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 130 | - | |
| 131 | - var data={ | |
| 132 | - action: 'wpsc_settings', | |
| 133 | - setting_action:'get_ticket_widget_settings' | |
| 534 | +/** | |
| 535 | + * Delete agent role | |
| 536 | + */ | |
| 537 | +function wpsc_delete_agent_role(id, nonce) { | |
| 538 | + if (!confirm(supportcandy.translations.confirm)) { | |
| 539 | + return; | |
| 540 | + } | |
| 541 | + | |
| 542 | + var data = { | |
| 543 | + action: "wpsc_delete_agent_role", | |
| 544 | + role_id: id, | |
| 545 | + _ajax_nonce: nonce, | |
| 134 | 546 | }; |
| 135 | - jQuery.post(wpsc_admin.ajax_url,data,function(response) { | |
| 136 | - jQuery('.wpsc_setting_col2').html(response); | |
| 137 | - }); | |
| 138 | - | |
| 547 | + jQuery | |
| 548 | + .post(supportcandy.ajax_url, data, function (res) { | |
| 549 | + wpsc_get_agent_roles(); | |
| 550 | + }) | |
| 551 | + .fail(function (xhr) { | |
| 552 | + var response = JSON.parse(xhr.responseText); | |
| 553 | + alert(response.data); | |
| 554 | + }); | |
| 139 | 555 | } |
| 140 | 556 | |
| 141 | -function wpsc_get_thank_you_settings(){ | |
| 142 | - | |
| 143 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 144 | - jQuery('#wpsc_settings_thank_you').addClass('active'); | |
| 145 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 146 | - | |
| 557 | +/** | |
| 558 | + * Get general settings | |
| 559 | + */ | |
| 560 | +function wpsc_get_general_settings(is_humbargar = false) { | |
| 561 | + if (is_humbargar) { | |
| 562 | + wpsc_toggle_humbargar(); | |
| 563 | + } | |
| 564 | + | |
| 565 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 566 | + jQuery( | |
| 567 | + ".wpsc-setting-nav.general-settings, .wpsc-humbargar-menu-item.general-settings" | |
| 568 | + ).addClass("active"); | |
| 569 | + jQuery(".wpsc-humbargar-title").html( | |
| 570 | + supportcandy.humbargar_titles.general_settings | |
| 571 | + ); | |
| 572 | + | |
| 573 | + if (supportcandy.current_section !== "general-settings") { | |
| 574 | + supportcandy.current_section = "general-settings"; | |
| 575 | + supportcandy.current_tab = "general"; | |
| 576 | + } | |
| 577 | + | |
| 578 | + window.history.replaceState( | |
| 579 | + {}, | |
| 580 | + null, | |
| 581 | + "admin.php?page=wpsc-settings§ion=" + | |
| 582 | + supportcandy.current_section + | |
| 583 | + "&tab=" + | |
| 584 | + supportcandy.current_tab | |
| 585 | + ); | |
| 586 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 587 | + | |
| 588 | + wpsc_scroll_top(); | |
| 589 | + | |
| 147 | 590 | var data = { |
| 148 | - action: 'wpsc_settings', | |
| 149 | - setting_action : 'get_thankyou_settings' | |
| 591 | + action: "wpsc_get_general_settings", | |
| 592 | + tab: supportcandy.current_tab, | |
| 150 | 593 | }; |
| 594 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 595 | + jQuery(".wpsc-setting-body").html(response); | |
| 596 | + wpsc_reset_responsive_style(); | |
| 597 | + jQuery( | |
| 598 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 599 | + ).trigger("click"); | |
| 600 | + }); | |
| 601 | +} | |
| 151 | 602 | |
| 152 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 153 | - jQuery('.wpsc_setting_col2').html(response); | |
| 603 | +/** | |
| 604 | + * Load general tab ui | |
| 605 | + */ | |
| 606 | +function wpsc_get_gs_general() { | |
| 607 | + supportcandy.current_tab = "general"; | |
| 608 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 609 | + jQuery( | |
| 610 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 611 | + ).addClass("active"); | |
| 612 | + | |
| 613 | + window.history.replaceState( | |
| 614 | + {}, | |
| 615 | + null, | |
| 616 | + "admin.php?page=wpsc-settings§ion=" + | |
| 617 | + supportcandy.current_section + | |
| 618 | + "&tab=" + | |
| 619 | + supportcandy.current_tab | |
| 620 | + ); | |
| 621 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 622 | + | |
| 623 | + wpsc_scroll_top(); | |
| 624 | + | |
| 625 | + var data = { action: "wpsc_get_gs_general" }; | |
| 626 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 627 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 628 | + wpsc_reset_responsive_style(); | |
| 154 | 629 | }); |
| 155 | - | |
| 156 | 630 | } |
| 157 | 631 | |
| 158 | -function wpsc_get_agent_roles(){ | |
| 159 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 160 | - jQuery('#wpsc_settings_agent_roles').addClass('active'); | |
| 161 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 162 | - | |
| 632 | +/** | |
| 633 | + * Save general settings | |
| 634 | + */ | |
| 635 | +function wpsc_set_gs_general(el) { | |
| 636 | + var form = jQuery(".wpsc-frm-gs-general")[0]; | |
| 637 | + var dataform = new FormData(form); | |
| 638 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 639 | + jQuery | |
| 640 | + .ajax({ | |
| 641 | + url: supportcandy.ajax_url, | |
| 642 | + type: "POST", | |
| 643 | + data: dataform, | |
| 644 | + processData: false, | |
| 645 | + contentType: false, | |
| 646 | + }) | |
| 647 | + .done(function (res) { | |
| 648 | + wpsc_get_gs_general(); | |
| 649 | + }); | |
| 650 | +} | |
| 651 | + | |
| 652 | +/** | |
| 653 | + * Reset general settings | |
| 654 | + */ | |
| 655 | +function wpsc_reset_gs_general(el, nonce) { | |
| 656 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 657 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 658 | + var data = { action: "wpsc_reset_gs_general", _ajax_nonce: nonce }; | |
| 659 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 660 | + wpsc_get_gs_general(); | |
| 661 | + }); | |
| 662 | +} | |
| 663 | + | |
| 664 | +/** | |
| 665 | + * Load page settings tab ui | |
| 666 | + */ | |
| 667 | +function wpsc_get_gs_page_settings() { | |
| 668 | + supportcandy.current_tab = "page-settings"; | |
| 669 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 670 | + jQuery( | |
| 671 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 672 | + ).addClass("active"); | |
| 673 | + | |
| 674 | + window.history.replaceState( | |
| 675 | + {}, | |
| 676 | + null, | |
| 677 | + "admin.php?page=wpsc-settings§ion=" + | |
| 678 | + supportcandy.current_section + | |
| 679 | + "&tab=" + | |
| 680 | + supportcandy.current_tab | |
| 681 | + ); | |
| 682 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 683 | + | |
| 684 | + wpsc_scroll_top(); | |
| 685 | + | |
| 686 | + var data = { action: "wpsc_get_gs_page_settings" }; | |
| 687 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 688 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 689 | + wpsc_reset_responsive_style(); | |
| 690 | + }); | |
| 691 | +} | |
| 692 | + | |
| 693 | +/** | |
| 694 | + * Save page settings | |
| 695 | + */ | |
| 696 | +function wpsc_set_gs_page_settings(el) { | |
| 697 | + var form = jQuery(".wpsc-frm-gs-ps")[0]; | |
| 698 | + var dataform = new FormData(form); | |
| 699 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 700 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 701 | + jQuery | |
| 702 | + .ajax({ | |
| 703 | + url: supportcandy.ajax_url, | |
| 704 | + type: "POST", | |
| 705 | + data: dataform, | |
| 706 | + processData: false, | |
| 707 | + contentType: false, | |
| 708 | + }) | |
| 709 | + .done(function (res) { | |
| 710 | + wpsc_get_gs_page_settings(); | |
| 711 | + }); | |
| 712 | +} | |
| 713 | + | |
| 714 | +/** | |
| 715 | + * Reset page settings | |
| 716 | + */ | |
| 717 | +function wpsc_reset_gs_page_settings(el, nonce) { | |
| 718 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 719 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 720 | + var data = { action: "wpsc_reset_gs_page_settings", _ajax_nonce: nonce }; | |
| 721 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 722 | + wpsc_get_gs_page_settings(); | |
| 723 | + }); | |
| 724 | +} | |
| 725 | + | |
| 726 | +/** | |
| 727 | + * Get category settings | |
| 728 | + */ | |
| 729 | +function wpsc_get_ticket_categories(is_humbargar = false) { | |
| 730 | + if (is_humbargar) { | |
| 731 | + wpsc_toggle_humbargar(); | |
| 732 | + } | |
| 733 | + | |
| 734 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 735 | + jQuery( | |
| 736 | + ".wpsc-setting-nav.ticket-categories, .wpsc-humbargar-menu-item.ticket-categories" | |
| 737 | + ).addClass("active"); | |
| 738 | + jQuery(".wpsc-humbargar-title").html( | |
| 739 | + supportcandy.humbargar_titles.ticket_categories | |
| 740 | + ); | |
| 741 | + | |
| 742 | + window.history.replaceState( | |
| 743 | + {}, | |
| 744 | + null, | |
| 745 | + "admin.php?page=wpsc-settings§ion=ticket-categories" | |
| 746 | + ); | |
| 747 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 748 | + | |
| 749 | + wpsc_scroll_top(); | |
| 750 | + | |
| 751 | + var data = { action: "wpsc_get_ticket_categories" }; | |
| 752 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 753 | + jQuery(".wpsc-setting-body").html(response); | |
| 754 | + wpsc_reset_responsive_style(); | |
| 755 | + }); | |
| 756 | +} | |
| 757 | + | |
| 758 | +/** | |
| 759 | + * Get working hrs settings | |
| 760 | + */ | |
| 761 | +function wpsc_get_working_hrs_settings(is_humbargar = false) { | |
| 762 | + if (is_humbargar) { | |
| 763 | + wpsc_toggle_humbargar(); | |
| 764 | + } | |
| 765 | + | |
| 766 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 767 | + jQuery( | |
| 768 | + ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs" | |
| 769 | + ).addClass("active"); | |
| 770 | + jQuery(".wpsc-humbargar-title").html( | |
| 771 | + supportcandy.humbargar_titles.working_hrs | |
| 772 | + ); | |
| 773 | + | |
| 774 | + if (supportcandy.current_section !== "working-hrs") { | |
| 775 | + supportcandy.current_section = "working-hrs"; | |
| 776 | + supportcandy.current_tab = "working-hrs"; | |
| 777 | + } | |
| 778 | + | |
| 779 | + window.history.replaceState( | |
| 780 | + {}, | |
| 781 | + null, | |
| 782 | + "admin.php?page=wpsc-settings§ion=" + | |
| 783 | + supportcandy.current_section + | |
| 784 | + "&tab=" + | |
| 785 | + supportcandy.current_tab | |
| 786 | + ); | |
| 787 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 788 | + | |
| 789 | + wpsc_scroll_top(); | |
| 790 | + | |
| 163 | 791 | var data = { |
| 164 | - action: 'wpsc_settings', | |
| 165 | - setting_action : 'get_agent_roles' | |
| 792 | + action: "wpsc_get_working_hrs_settings", | |
| 793 | + tab: supportcandy.current_tab, | |
| 166 | 794 | }; |
| 795 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 796 | + jQuery(".wpsc-setting-body").html(response); | |
| 797 | + wpsc_reset_responsive_style(); | |
| 798 | + jQuery( | |
| 799 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 800 | + ).trigger("click"); | |
| 801 | + }); | |
| 802 | +} | |
| 167 | 803 | |
| 168 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 169 | - jQuery('.wpsc_setting_col2').html(response); | |
| 804 | +/** | |
| 805 | + * Get working hrs | |
| 806 | + */ | |
| 807 | +function wpsc_get_working_hrs() { | |
| 808 | + supportcandy.current_tab = "working-hrs"; | |
| 809 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 810 | + jQuery( | |
| 811 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 812 | + ).addClass("active"); | |
| 813 | + | |
| 814 | + window.history.replaceState( | |
| 815 | + {}, | |
| 816 | + null, | |
| 817 | + "admin.php?page=wpsc-settings§ion=" + | |
| 818 | + supportcandy.current_section + | |
| 819 | + "&tab=" + | |
| 820 | + supportcandy.current_tab | |
| 821 | + ); | |
| 822 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 823 | + | |
| 824 | + wpsc_scroll_top(); | |
| 825 | + var data = { action: "wpsc_get_working_hrs" }; | |
| 826 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 827 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 828 | + wpsc_reset_responsive_style(); | |
| 170 | 829 | }); |
| 171 | 830 | } |
| 172 | 831 | |
| 173 | -function wpsc_get_templates(){ | |
| 174 | - | |
| 175 | - wpsc_modal_open(wpsc_admin.templates); | |
| 832 | +/** | |
| 833 | + * Get working hrs | |
| 834 | + */ | |
| 835 | +function wpsc_set_working_hrs(el) { | |
| 836 | + var form = jQuery("form.wpsc-wh-settings")[0]; | |
| 837 | + var dataform = new FormData(form); | |
| 838 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 839 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 840 | + jQuery | |
| 841 | + .ajax({ | |
| 842 | + url: supportcandy.ajax_url, | |
| 843 | + type: "POST", | |
| 844 | + data: dataform, | |
| 845 | + processData: false, | |
| 846 | + contentType: false, | |
| 847 | + }) | |
| 848 | + .done(function (res) { | |
| 849 | + wpsc_get_working_hrs(); | |
| 850 | + }); | |
| 851 | +} | |
| 852 | + | |
| 853 | +/** | |
| 854 | + * Get holidays | |
| 855 | + */ | |
| 856 | +function wpsc_get_holidays() { | |
| 857 | + supportcandy.current_tab = "holidays"; | |
| 858 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 859 | + jQuery( | |
| 860 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 861 | + ).addClass("active"); | |
| 862 | + | |
| 863 | + window.history.replaceState( | |
| 864 | + {}, | |
| 865 | + null, | |
| 866 | + "admin.php?page=wpsc-settings§ion=" + | |
| 867 | + supportcandy.current_section + | |
| 868 | + "&tab=" + | |
| 869 | + supportcandy.current_tab | |
| 870 | + ); | |
| 871 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 872 | + | |
| 873 | + wpsc_scroll_top(); | |
| 874 | + var data = { action: "wpsc_get_holidays" }; | |
| 875 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 876 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 877 | + wpsc_reset_responsive_style(); | |
| 878 | + }); | |
| 879 | +} | |
| 880 | + | |
| 881 | +/** | |
| 882 | + * Get company holiday actions | |
| 883 | + */ | |
| 884 | +function wpsc_get_company_holiday_actions(dateSelected, nonce) { | |
| 885 | + supportcandy.temp.dateSelected = dateSelected; | |
| 886 | + wpsc_show_modal(); | |
| 176 | 887 | var data = { |
| 177 | - action: 'wpsc_settings', | |
| 178 | - setting_action : 'get_templates' | |
| 888 | + action: "wpsc_get_company_holiday_actions", | |
| 889 | + dateSelected, | |
| 890 | + _ajax_nonce: nonce, | |
| 179 | 891 | }; |
| 180 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 181 | - jQuery('#wpsc_popup_body').html(response.body); | |
| 182 | - jQuery('#wpsc_popup_footer').html(response.footer); | |
| 183 | - jQuery('#wpsc_cat_name').focus(); | |
| 892 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 893 | + // Set to modal. | |
| 894 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 895 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 896 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 897 | + // Display modal. | |
| 898 | + wpsc_show_modal_inner_container(); | |
| 184 | 899 | }); |
| 185 | - | |
| 186 | 900 | } |
| 187 | 901 | |
| 188 | -function wpsc_set_thankyou_settings(){ | |
| 189 | - | |
| 190 | - jQuery('.wpsc_submit_wait').show(); | |
| 191 | - var dataform = new FormData(jQuery('#wpsc_frm_thankyou_settings')[0]); | |
| 192 | - | |
| 193 | - jQuery.ajax({ | |
| 194 | - url: wpsc_admin.ajax_url, | |
| 195 | - type: 'POST', | |
| 196 | - data: dataform, | |
| 197 | - processData: false, | |
| 198 | - contentType: false | |
| 199 | - }) | |
| 200 | - .done(function (response_str) { | |
| 201 | - var response = JSON.parse(response_str); | |
| 202 | - jQuery('.wpsc_submit_wait').hide(); | |
| 203 | - if (response.sucess_status=='1') { | |
| 204 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 205 | - } | |
| 206 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 207 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 902 | +/** | |
| 903 | + * Set company holiday actions | |
| 904 | + */ | |
| 905 | +function wpsc_set_company_holiday_actions(el) { | |
| 906 | + const form = jQuery(".wpsc-frm-comp-holiday-actions")[0]; | |
| 907 | + const dataform = new FormData(form); | |
| 908 | + dataform.append("dateSelected", supportcandy.temp.dateSelected); | |
| 909 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 910 | + jQuery | |
| 911 | + .ajax({ | |
| 912 | + url: supportcandy.ajax_url, | |
| 913 | + type: "POST", | |
| 914 | + data: dataform, | |
| 915 | + processData: false, | |
| 916 | + contentType: false, | |
| 917 | + }) | |
| 918 | + .done(function (response) { | |
| 919 | + jQuery.each(supportcandy.temp.dateSelected, function (index, value) { | |
| 920 | + if (response.action == "add" && response.is_recurring == 1) { | |
| 921 | + jQuery("td") | |
| 922 | + .find("[data-date=" + value + "]") | |
| 923 | + .css({ "background-color": "#eb4d4b" }); | |
| 924 | + } else if (response.action == "add" && response.is_recurring == 0) { | |
| 925 | + jQuery("td") | |
| 926 | + .find("[data-date=" + value + "]") | |
| 927 | + .css({ "background-color": "#f0932b" }); | |
| 928 | + } else { | |
| 929 | + jQuery("td") | |
| 930 | + .find("[data-date=" + value + "]") | |
| 931 | + .css("background-color", "unset"); | |
| 932 | + } | |
| 933 | + }); | |
| 934 | + supportcandy.temp.holidayList = response.holidayList; | |
| 935 | + wpsc_close_modal(); | |
| 936 | + }); | |
| 937 | +} | |
| 938 | + | |
| 939 | +/** | |
| 940 | + * Get working hrs exceptions | |
| 941 | + */ | |
| 942 | +function wpsc_get_wh_exceptions() { | |
| 943 | + supportcandy.current_tab = "exceptions"; | |
| 944 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 945 | + jQuery( | |
| 946 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 947 | + ).addClass("active"); | |
| 948 | + | |
| 949 | + window.history.replaceState( | |
| 950 | + {}, | |
| 951 | + null, | |
| 952 | + "admin.php?page=wpsc-settings§ion=" + | |
| 953 | + supportcandy.current_section + | |
| 954 | + "&tab=" + | |
| 955 | + supportcandy.current_tab | |
| 956 | + ); | |
| 957 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 958 | + | |
| 959 | + wpsc_scroll_top(); | |
| 960 | + var data = { action: "wpsc_get_wh_exceptions" }; | |
| 961 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 962 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 963 | + wpsc_reset_responsive_style(); | |
| 208 | 964 | }); |
| 209 | - | |
| 210 | 965 | } |
| 211 | 966 | |
| 212 | -function wpsc_insert_editor_text( text_to_insert ){ | |
| 213 | - var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); | |
| 214 | - if (is_tinymce) { | |
| 215 | - tinymce.activeEditor.execCommand('mceInsertContent', false, text_to_insert); | |
| 216 | - } else { | |
| 967 | +/** | |
| 968 | + * Add company holiday | |
| 969 | + */ | |
| 970 | +function wpsc_set_add_holiday(el) { | |
| 971 | + var title = jQuery("input[name=title]").val().trim(); | |
| 972 | + if (title.length === 0) { | |
| 973 | + return; | |
| 974 | + } | |
| 217 | 975 | |
| 218 | - var $txt = jQuery(".wpsc_textarea"); | |
| 219 | - var caretPos = $txt[0].selectionStart; | |
| 220 | - var textAreaTxt = $txt.val(); | |
| 221 | - $txt.val(textAreaTxt.substring(0, caretPos) + text_to_insert + textAreaTxt.substring(caretPos) ); | |
| 222 | - } | |
| 223 | - wpsc_modal_close(); | |
| 976 | + var startDate = jQuery("input.start_date").val().trim(); | |
| 977 | + if (startDate.length === 0) { | |
| 978 | + return; | |
| 979 | + } | |
| 980 | + | |
| 981 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 982 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 983 | + var form = jQuery(".wpsc-frm-add-holiday")[0]; | |
| 984 | + var dataform = new FormData(form); | |
| 985 | + jQuery | |
| 986 | + .ajax({ | |
| 987 | + url: supportcandy.ajax_url, | |
| 988 | + type: "POST", | |
| 989 | + data: dataform, | |
| 990 | + processData: false, | |
| 991 | + contentType: false, | |
| 992 | + }) | |
| 993 | + .done(function (res) { | |
| 994 | + wpsc_close_modal(); | |
| 995 | + wpsc_get_holidays(); | |
| 996 | + }); | |
| 224 | 997 | } |
| 225 | 998 | |
| 226 | -function wpsc_get_ticket_form_fields(){ | |
| 227 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 228 | - jQuery('#wpsc_ticket_custom_fields').addClass('active'); | |
| 229 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 230 | - | |
| 999 | +/** | |
| 1000 | + * Add company holiday | |
| 1001 | + */ | |
| 1002 | +function wpsc_set_edit_holiday(el) { | |
| 1003 | + var title = jQuery("input[name=title]").val().trim(); | |
| 1004 | + if (title.length === 0) { | |
| 1005 | + return; | |
| 1006 | + } | |
| 1007 | + | |
| 1008 | + var startDate = jQuery("input.start_date").val().trim(); | |
| 1009 | + if (startDate.length === 0) { | |
| 1010 | + return; | |
| 1011 | + } | |
| 1012 | + | |
| 1013 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1014 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1015 | + var form = jQuery(".wpsc-frm-edit-holiday")[0]; | |
| 1016 | + var dataform = new FormData(form); | |
| 1017 | + jQuery | |
| 1018 | + .ajax({ | |
| 1019 | + url: supportcandy.ajax_url, | |
| 1020 | + type: "POST", | |
| 1021 | + data: dataform, | |
| 1022 | + processData: false, | |
| 1023 | + contentType: false, | |
| 1024 | + }) | |
| 1025 | + .done(function (res) { | |
| 1026 | + wpsc_close_modal(); | |
| 1027 | + wpsc_get_holidays(); | |
| 1028 | + }); | |
| 1029 | +} | |
| 1030 | + | |
| 1031 | +/** | |
| 1032 | + * Add company holiday | |
| 1033 | + */ | |
| 1034 | +function wpsc_set_add_wh_exception(el) { | |
| 1035 | + var title = jQuery("input[name=title]").val().trim(); | |
| 1036 | + if (title.length === 0) { | |
| 1037 | + return; | |
| 1038 | + } | |
| 1039 | + | |
| 1040 | + var startDate = jQuery("input.exception_date").val().trim(); | |
| 1041 | + if (startDate.length === 0) { | |
| 1042 | + return; | |
| 1043 | + } | |
| 1044 | + | |
| 1045 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1046 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1047 | + var form = jQuery(".wpsc-frm-add-exception")[0]; | |
| 1048 | + var dataform = new FormData(form); | |
| 1049 | + jQuery | |
| 1050 | + .ajax({ | |
| 1051 | + url: supportcandy.ajax_url, | |
| 1052 | + type: "POST", | |
| 1053 | + data: dataform, | |
| 1054 | + processData: false, | |
| 1055 | + contentType: false, | |
| 1056 | + }) | |
| 1057 | + .done(function (res) { | |
| 1058 | + wpsc_close_modal(); | |
| 1059 | + wpsc_get_wh_exceptions(); | |
| 1060 | + }); | |
| 1061 | +} | |
| 1062 | + | |
| 1063 | +/** | |
| 1064 | + * Add company holiday | |
| 1065 | + */ | |
| 1066 | +function wpsc_set_edit_wh_exception(el) { | |
| 1067 | + var title = jQuery("input[name=title]").val().trim(); | |
| 1068 | + if (title.length === 0) { | |
| 1069 | + return; | |
| 1070 | + } | |
| 1071 | + | |
| 1072 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1073 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1074 | + var form = jQuery(".wpsc-frm-edit-exception")[0]; | |
| 1075 | + var dataform = new FormData(form); | |
| 1076 | + jQuery | |
| 1077 | + .ajax({ | |
| 1078 | + url: supportcandy.ajax_url, | |
| 1079 | + type: "POST", | |
| 1080 | + data: dataform, | |
| 1081 | + processData: false, | |
| 1082 | + contentType: false, | |
| 1083 | + }) | |
| 1084 | + .done(function (res) { | |
| 1085 | + wpsc_close_modal(); | |
| 1086 | + wpsc_get_wh_exceptions(); | |
| 1087 | + }); | |
| 1088 | +} | |
| 1089 | + | |
| 1090 | +/** | |
| 1091 | + * Get working hrs settings | |
| 1092 | + */ | |
| 1093 | +function wpsc_get_wh_settings() { | |
| 1094 | + supportcandy.current_tab = "settings"; | |
| 1095 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 1096 | + jQuery( | |
| 1097 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1098 | + ).addClass("active"); | |
| 1099 | + | |
| 1100 | + window.history.replaceState( | |
| 1101 | + {}, | |
| 1102 | + null, | |
| 1103 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1104 | + supportcandy.current_section + | |
| 1105 | + "&tab=" + | |
| 1106 | + supportcandy.current_tab | |
| 1107 | + ); | |
| 1108 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1109 | + | |
| 1110 | + wpsc_scroll_top(); | |
| 1111 | + var data = { action: "wpsc_get_wh_settings" }; | |
| 1112 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1113 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 1114 | + wpsc_reset_responsive_style(); | |
| 1115 | + }); | |
| 1116 | +} | |
| 1117 | + | |
| 1118 | +/** | |
| 1119 | + * Set working hrs setting | |
| 1120 | + */ | |
| 1121 | +function wpsc_set_wh_settings(el) { | |
| 1122 | + var form = jQuery(".wpsc-frm-wh-settings")[0]; | |
| 1123 | + var dataform = new FormData(form); | |
| 1124 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1125 | + jQuery | |
| 1126 | + .ajax({ | |
| 1127 | + url: supportcandy.ajax_url, | |
| 1128 | + type: "POST", | |
| 1129 | + data: dataform, | |
| 1130 | + processData: false, | |
| 1131 | + contentType: false, | |
| 1132 | + }) | |
| 1133 | + .done(function (res) { | |
| 1134 | + wpsc_get_wh_settings(); | |
| 1135 | + }); | |
| 1136 | +} | |
| 1137 | + | |
| 1138 | +/** | |
| 1139 | + * Set working hrs setting | |
| 1140 | + */ | |
| 1141 | +function wpsc_reset_wh_settings(el, nonce) { | |
| 1142 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1143 | + var data = { action: "wpsc_reset_wh_settings", _ajax_nonce: nonce }; | |
| 1144 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1145 | + wpsc_get_wh_settings(); | |
| 1146 | + }); | |
| 1147 | +} | |
| 1148 | + | |
| 1149 | +/** | |
| 1150 | + * Get appearence settings | |
| 1151 | + */ | |
| 1152 | +function wpsc_get_appearence_settings(is_humbargar = false) { | |
| 1153 | + if (is_humbargar) { | |
| 1154 | + wpsc_toggle_humbargar(); | |
| 1155 | + } | |
| 1156 | + | |
| 1157 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 1158 | + jQuery( | |
| 1159 | + ".wpsc-setting-nav.appearence, .wpsc-humbargar-menu-item.appearence" | |
| 1160 | + ).addClass("active"); | |
| 1161 | + jQuery(".wpsc-humbargar-title").html( | |
| 1162 | + supportcandy.humbargar_titles.appearence | |
| 1163 | + ); | |
| 1164 | + | |
| 1165 | + if (supportcandy.current_section !== "appearence") { | |
| 1166 | + supportcandy.current_section = "appearence"; | |
| 1167 | + supportcandy.current_tab = "general"; | |
| 1168 | + } | |
| 1169 | + | |
| 1170 | + window.history.replaceState( | |
| 1171 | + {}, | |
| 1172 | + null, | |
| 1173 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1174 | + supportcandy.current_section + | |
| 1175 | + "&tab=" + | |
| 1176 | + supportcandy.current_tab | |
| 1177 | + ); | |
| 1178 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 1179 | + | |
| 1180 | + wpsc_scroll_top(); | |
| 1181 | + | |
| 231 | 1182 | var data = { |
| 232 | - action: 'wpsc_custom_fields', | |
| 233 | - setting_action : 'get_ticket_form_fields' | |
| 1183 | + action: "wpsc_get_appearence_settings", | |
| 1184 | + tab: supportcandy.current_tab, | |
| 234 | 1185 | }; |
| 1186 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1187 | + jQuery(".wpsc-setting-body").html(response); | |
| 1188 | + wpsc_reset_responsive_style(); | |
| 1189 | + jQuery( | |
| 1190 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1191 | + ).trigger("click"); | |
| 1192 | + }); | |
| 1193 | +} | |
| 235 | 1194 | |
| 236 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 237 | - jQuery('.wpsc_setting_col2').html(response); | |
| 238 | - }); | |
| 1195 | +/** | |
| 1196 | + * Get general appearence settings | |
| 1197 | + */ | |
| 1198 | +function wpsc_get_ap_general() { | |
| 1199 | + supportcandy.current_tab = "general"; | |
| 1200 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 1201 | + jQuery( | |
| 1202 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1203 | + ).addClass("active"); | |
| 1204 | + | |
| 1205 | + window.history.replaceState( | |
| 1206 | + {}, | |
| 1207 | + null, | |
| 1208 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1209 | + supportcandy.current_section + | |
| 1210 | + "&tab=" + | |
| 1211 | + supportcandy.current_tab | |
| 1212 | + ); | |
| 1213 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1214 | + | |
| 1215 | + wpsc_scroll_top(); | |
| 1216 | + var data = { action: "wpsc_get_ap_general" }; | |
| 1217 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1218 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 1219 | + wpsc_reset_responsive_style(); | |
| 1220 | + }); | |
| 239 | 1221 | } |
| 240 | 1222 | |
| 241 | -function wpsc_add_field_condition(){ | |
| 242 | - var wpsc_tf_vcf = jQuery('#wpsc_tf_vcf').val().trim(); | |
| 243 | - if (!wpsc_tf_vcf) { | |
| 244 | - jQuery('#wpsc_tf_vcf').focus(); | |
| 1223 | +/** | |
| 1224 | + * Set general appearence settings | |
| 1225 | + */ | |
| 1226 | +function wpsc_set_ap_general(el) { | |
| 1227 | + var form = jQuery(".wpsc-frm-ap-general")[0]; | |
| 1228 | + var dataform = new FormData(form); | |
| 1229 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1230 | + jQuery | |
| 1231 | + .ajax({ | |
| 1232 | + url: supportcandy.ajax_url, | |
| 1233 | + type: "POST", | |
| 1234 | + data: dataform, | |
| 1235 | + processData: false, | |
| 1236 | + contentType: false, | |
| 1237 | + }) | |
| 1238 | + .done(function (res) { | |
| 1239 | + wpsc_get_ap_general(); | |
| 1240 | + }); | |
| 1241 | +} | |
| 1242 | + | |
| 1243 | +/** | |
| 1244 | + * Reset appearence general settings | |
| 1245 | + */ | |
| 1246 | +function wpsc_reset_ap_general(el, nonce) { | |
| 1247 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1248 | + var data = { action: "wpsc_reset_ap_general", _ajax_nonce: nonce }; | |
| 1249 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1250 | + wpsc_get_ap_general(); | |
| 1251 | + }); | |
| 1252 | +} | |
| 1253 | + | |
| 1254 | +/** | |
| 1255 | + * Get appearence ticket list settings | |
| 1256 | + */ | |
| 1257 | +function wpsc_get_ap_ticket_list() { | |
| 1258 | + supportcandy.current_tab = "ticket-list"; | |
| 1259 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 1260 | + jQuery( | |
| 1261 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1262 | + ).addClass("active"); | |
| 1263 | + | |
| 1264 | + window.history.replaceState( | |
| 1265 | + {}, | |
| 1266 | + null, | |
| 1267 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1268 | + supportcandy.current_section + | |
| 1269 | + "&tab=" + | |
| 1270 | + supportcandy.current_tab | |
| 1271 | + ); | |
| 1272 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1273 | + | |
| 1274 | + wpsc_scroll_top(); | |
| 1275 | + var data = { action: "wpsc_get_ap_ticket_list" }; | |
| 1276 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1277 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 1278 | + wpsc_reset_responsive_style(); | |
| 1279 | + }); | |
| 1280 | +} | |
| 1281 | + | |
| 1282 | +/** | |
| 1283 | + * Set appearence ticket list settings | |
| 1284 | + */ | |
| 1285 | +function wpsc_set_ap_ticket_list(el) { | |
| 1286 | + var form = jQuery(".wpsc-frm-ap-tl")[0]; | |
| 1287 | + var dataform = new FormData(form); | |
| 1288 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1289 | + jQuery | |
| 1290 | + .ajax({ | |
| 1291 | + url: supportcandy.ajax_url, | |
| 1292 | + type: "POST", | |
| 1293 | + data: dataform, | |
| 1294 | + processData: false, | |
| 1295 | + contentType: false, | |
| 1296 | + }) | |
| 1297 | + .done(function (res) { | |
| 1298 | + wpsc_get_ap_ticket_list(); | |
| 1299 | + }); | |
| 1300 | +} | |
| 1301 | + | |
| 1302 | +/** | |
| 1303 | + * Reset appearence ticket list settings | |
| 1304 | + */ | |
| 1305 | +function wpsc_reset_ap_ticket_list(el, nonce) { | |
| 1306 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1307 | + var data = { action: "wpsc_reset_ap_ticket_list", _ajax_nonce: nonce }; | |
| 1308 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1309 | + wpsc_get_ap_ticket_list(); | |
| 1310 | + }); | |
| 1311 | +} | |
| 1312 | + | |
| 1313 | +/** | |
| 1314 | + * Get appearence individual ticket settings | |
| 1315 | + */ | |
| 1316 | +function wpsc_get_ap_individual_ticket() { | |
| 1317 | + supportcandy.current_tab = "individual-ticket"; | |
| 1318 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 1319 | + jQuery( | |
| 1320 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1321 | + ).addClass("active"); | |
| 1322 | + | |
| 1323 | + window.history.replaceState( | |
| 1324 | + {}, | |
| 1325 | + null, | |
| 1326 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1327 | + supportcandy.current_section + | |
| 1328 | + "&tab=" + | |
| 1329 | + supportcandy.current_tab | |
| 1330 | + ); | |
| 1331 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1332 | + | |
| 1333 | + wpsc_scroll_top(); | |
| 1334 | + var data = { action: "wpsc_get_ap_individual_ticket" }; | |
| 1335 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1336 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 1337 | + wpsc_reset_responsive_style(); | |
| 1338 | + }); | |
| 1339 | +} | |
| 1340 | + | |
| 1341 | +/** | |
| 1342 | + * Set appearence individual ticket settings | |
| 1343 | + */ | |
| 1344 | +function wpsc_set_ap_individual_ticket(el) { | |
| 1345 | + var form = jQuery(".wpsc-frm-ap-it")[0]; | |
| 1346 | + var dataform = new FormData(form); | |
| 1347 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1348 | + jQuery | |
| 1349 | + .ajax({ | |
| 1350 | + url: supportcandy.ajax_url, | |
| 1351 | + type: "POST", | |
| 1352 | + data: dataform, | |
| 1353 | + processData: false, | |
| 1354 | + contentType: false, | |
| 1355 | + }) | |
| 1356 | + .done(function (res) { | |
| 1357 | + wpsc_get_ap_individual_ticket(); | |
| 1358 | + }); | |
| 1359 | +} | |
| 1360 | + | |
| 1361 | +/** | |
| 1362 | + * Reset appearence individual ticket settings | |
| 1363 | + */ | |
| 1364 | +function wpsc_reset_ap_individual_ticket(el, nonce) { | |
| 1365 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1366 | + var data = { action: "wpsc_reset_ap_individual_ticket", _ajax_nonce: nonce }; | |
| 1367 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1368 | + wpsc_get_ap_individual_ticket(); | |
| 1369 | + }); | |
| 1370 | +} | |
| 1371 | + | |
| 1372 | +/** | |
| 1373 | + * Get appearence modal popup settigns | |
| 1374 | + */ | |
| 1375 | +function wpsc_get_ap_modal_popup() { | |
| 1376 | + supportcandy.current_tab = "modal-popup"; | |
| 1377 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 1378 | + jQuery( | |
| 1379 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 1380 | + ).addClass("active"); | |
| 1381 | + | |
| 1382 | + window.history.replaceState( | |
| 1383 | + {}, | |
| 1384 | + null, | |
| 1385 | + "admin.php?page=wpsc-settings§ion=" + | |
| 1386 | + supportcandy.current_section + | |
| 1387 | + "&tab=" + | |
| 1388 | + supportcandy.current_tab | |
| 1389 | + ); | |
| 1390 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1391 | + | |
| 1392 | + wpsc_scroll_top(); | |
| 1393 | + var data = { action: "wpsc_get_ap_modal_popup" }; | |
| 1394 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1395 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 1396 | + wpsc_reset_responsive_style(); | |
| 1397 | + }); | |
| 1398 | +} | |
| 1399 | + | |
| 1400 | +/** | |
| 1401 | + * Set appearence modal settings | |
| 1402 | + */ | |
| 1403 | +function wpsc_set_ap_modal_popup(el) { | |
| 1404 | + var form = jQuery(".wpsc-frm-ap-modal")[0]; | |
| 1405 | + var dataform = new FormData(form); | |
| 1406 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1407 | + jQuery | |
| 1408 | + .ajax({ | |
| 1409 | + url: supportcandy.ajax_url, | |
| 1410 | + type: "POST", | |
| 1411 | + data: dataform, | |
| 1412 | + processData: false, | |
| 1413 | + contentType: false, | |
| 1414 | + }) | |
| 1415 | + .done(function (res) { | |
| 1416 | + wpsc_get_ap_modal_popup(); | |
| 1417 | + }); | |
| 1418 | +} | |
| 1419 | + | |
| 1420 | +/** | |
| 1421 | + * Reset appearence modal settings | |
| 1422 | + */ | |
| 1423 | +function wpsc_reset_ap_modal_popup(el, nonce) { | |
| 1424 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1425 | + var data = { action: "wpsc_reset_ap_modal_popup", _ajax_nonce: nonce }; | |
| 1426 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1427 | + wpsc_get_ap_modal_popup(); | |
| 1428 | + }); | |
| 1429 | +} | |
| 1430 | + | |
| 1431 | +/** | |
| 1432 | + * Set add new category | |
| 1433 | + */ | |
| 1434 | +function wpsc_set_add_category(el) { | |
| 1435 | + var form = jQuery(".wpsc-frm-add-category")[0]; | |
| 1436 | + var dataform = new FormData(form); | |
| 1437 | + | |
| 1438 | + if (dataform.get("label").trim() == "") { | |
| 1439 | + alert(supportcandy.translations.req_fields_missing); | |
| 245 | 1440 | return; |
| 246 | 1441 | } |
| 247 | - var wpsc_tf_vco = jQuery('#wpsc_tf_vco').val().trim(); | |
| 248 | - if (!wpsc_tf_vco) { | |
| 249 | - jQuery('#wpsc_tf_vco').focus(); | |
| 1442 | + | |
| 1443 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1444 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1445 | + | |
| 1446 | + jQuery | |
| 1447 | + .ajax({ | |
| 1448 | + url: supportcandy.ajax_url, | |
| 1449 | + type: "POST", | |
| 1450 | + data: dataform, | |
| 1451 | + processData: false, | |
| 1452 | + contentType: false, | |
| 1453 | + }) | |
| 1454 | + .done(function (res) { | |
| 1455 | + wpsc_close_modal(); | |
| 1456 | + wpsc_get_ticket_categories(); | |
| 1457 | + }); | |
| 1458 | +} | |
| 1459 | + | |
| 1460 | +/** | |
| 1461 | + * Get edit category modal | |
| 1462 | + */ | |
| 1463 | +function wpsc_get_edit_category(id, nonce) { | |
| 1464 | + wpsc_show_modal(); | |
| 1465 | + var data = { action: "wpsc_get_edit_category", id, _ajax_nonce: nonce }; | |
| 1466 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1467 | + // Set to modal. | |
| 1468 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1469 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1470 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1471 | + // Display modal. | |
| 1472 | + wpsc_show_modal_inner_container(); | |
| 1473 | + }); | |
| 1474 | +} | |
| 1475 | + | |
| 1476 | +/** | |
| 1477 | + * Update category | |
| 1478 | + */ | |
| 1479 | +function wpsc_set_edit_category(el) { | |
| 1480 | + var form = jQuery(".wpsc-frm-edit-category")[0]; | |
| 1481 | + var dataform = new FormData(form); | |
| 1482 | + | |
| 1483 | + if (dataform.get("label").trim() == "") { | |
| 1484 | + alert(supportcandy.translations.req_fields_missing); | |
| 250 | 1485 | return; |
| 251 | 1486 | } |
| 252 | - | |
| 253 | - var flag = true; | |
| 254 | - jQuery('#wpsc_tf_condition_container').find('input').each(function(){ | |
| 255 | - var current_condition = ''+wpsc_tf_vcf+'--'+wpsc_tf_vco+''; | |
| 256 | - if(jQuery(this).val() == current_condition ){ | |
| 257 | - flag = false; | |
| 258 | - } | |
| 1487 | + | |
| 1488 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1489 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1490 | + | |
| 1491 | + jQuery | |
| 1492 | + .ajax({ | |
| 1493 | + url: supportcandy.ajax_url, | |
| 1494 | + type: "POST", | |
| 1495 | + data: dataform, | |
| 1496 | + processData: false, | |
| 1497 | + contentType: false, | |
| 1498 | + }) | |
| 1499 | + .done(function (res) { | |
| 1500 | + wpsc_close_modal(); | |
| 1501 | + wpsc_get_ticket_categories(); | |
| 1502 | + }); | |
| 1503 | +} | |
| 1504 | + | |
| 1505 | +/** | |
| 1506 | + * Delete category modal | |
| 1507 | + */ | |
| 1508 | +function wpsc_get_delete_category(id, nonce) { | |
| 1509 | + var flag = confirm(supportcandy.translations.confirm); | |
| 1510 | + if (!flag) { | |
| 1511 | + return; | |
| 1512 | + } | |
| 1513 | + | |
| 1514 | + wpsc_show_modal(); | |
| 1515 | + var data = { action: "wpsc_get_delete_category", id, _ajax_nonce: nonce }; | |
| 1516 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1517 | + // Set to modal. | |
| 1518 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1519 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1520 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1521 | + // Display modal. | |
| 1522 | + wpsc_show_modal_inner_container(); | |
| 259 | 1523 | }); |
| 260 | - | |
| 261 | - if(flag){ | |
| 262 | - var selected_field_label = jQuery('#wpsc_tf_vcf option:selected').text(); | |
| 263 | - var selected_option_label = jQuery('#wpsc_tf_vco option:selected').text(); | |
| 264 | - var str_html = '' | |
| 265 | - +'<li class="wpsp_filter_display_element">' | |
| 266 | - +'<div class="flex-container">' | |
| 267 | - +'<div class="wpsp_filter_display_text">' | |
| 268 | - +selected_field_label+': '+selected_option_label | |
| 269 | - +'<input type="hidden" name="wpsp_tf_condition[]" value="'+wpsc_tf_vcf+'--'+wpsc_tf_vco+'" />' | |
| 270 | - +'</div>' | |
| 271 | - +'<div class="wpsp_filter_display_remove" onclick="wpsc_remove_filter(this);"><i class="fa fa-times"></i></div>' | |
| 272 | - +'</div>' | |
| 273 | - +'</li>'; | |
| 274 | - | |
| 275 | - jQuery('#wpsc_tf_condition_container').append(str_html); | |
| 1524 | +} | |
| 1525 | + | |
| 1526 | +/** | |
| 1527 | + * Delete category | |
| 1528 | + */ | |
| 1529 | +function wpsc_set_delete_category(el) { | |
| 1530 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1531 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1532 | + | |
| 1533 | + var form = jQuery(".wpsc-frm-delete-category")[0]; | |
| 1534 | + var dataform = new FormData(form); | |
| 1535 | + jQuery | |
| 1536 | + .ajax({ | |
| 1537 | + url: supportcandy.ajax_url, | |
| 1538 | + type: "POST", | |
| 1539 | + data: dataform, | |
| 1540 | + processData: false, | |
| 1541 | + contentType: false, | |
| 1542 | + }) | |
| 1543 | + .done(function (res) { | |
| 1544 | + wpsc_close_modal(); | |
| 1545 | + wpsc_get_ticket_categories(); | |
| 1546 | + }); | |
| 1547 | +} | |
| 1548 | + | |
| 1549 | +/** | |
| 1550 | + * Get status settings | |
| 1551 | + */ | |
| 1552 | +function wpsc_get_ticket_statuses(is_humbargar = false) { | |
| 1553 | + if (is_humbargar) { | |
| 1554 | + wpsc_toggle_humbargar(); | |
| 276 | 1555 | } |
| 277 | - | |
| 278 | - jQuery('#wpsc_tf_vcf').val(''); | |
| 279 | - jQuery('#wpsc_tf_vco').html(''); | |
| 280 | - | |
| 1556 | + | |
| 1557 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 1558 | + jQuery( | |
| 1559 | + ".wpsc-setting-nav.ticket-statuses, .wpsc-humbargar-menu-item.ticket-statuses" | |
| 1560 | + ).addClass("active"); | |
| 1561 | + jQuery(".wpsc-humbargar-title").html( | |
| 1562 | + supportcandy.humbargar_titles.ticket_statuses | |
| 1563 | + ); | |
| 1564 | + | |
| 1565 | + window.history.replaceState( | |
| 1566 | + {}, | |
| 1567 | + null, | |
| 1568 | + "admin.php?page=wpsc-settings§ion=ticket-statuses" | |
| 1569 | + ); | |
| 1570 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 1571 | + | |
| 1572 | + wpsc_scroll_top(); | |
| 1573 | + | |
| 1574 | + var data = { action: "wpsc_get_ticket_statuses" }; | |
| 1575 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1576 | + jQuery(".wpsc-setting-body").html(response); | |
| 1577 | + wpsc_reset_responsive_style(); | |
| 1578 | + }); | |
| 281 | 1579 | } |
| 282 | 1580 | |
| 283 | -function wpsc_remove_filter(e){ | |
| 284 | - jQuery(e).parent().parent().remove(); | |
| 1581 | +/** | |
| 1582 | + * Set add new status | |
| 1583 | + */ | |
| 1584 | +function wpsc_set_add_status(el) { | |
| 1585 | + var form = jQuery(".wpsc-frm-add-status")[0]; | |
| 1586 | + var dataform = new FormData(form); | |
| 1587 | + | |
| 1588 | + if (dataform.get("name").trim() == "") { | |
| 1589 | + alert(supportcandy.translations.req_fields_missing); | |
| 1590 | + return; | |
| 1591 | + } | |
| 1592 | + | |
| 1593 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1594 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1595 | + | |
| 1596 | + jQuery | |
| 1597 | + .ajax({ | |
| 1598 | + url: supportcandy.ajax_url, | |
| 1599 | + type: "POST", | |
| 1600 | + data: dataform, | |
| 1601 | + processData: false, | |
| 1602 | + contentType: false, | |
| 1603 | + }) | |
| 1604 | + .done(function (res) { | |
| 1605 | + wpsc_close_modal(); | |
| 1606 | + wpsc_get_ticket_statuses(); | |
| 1607 | + }); | |
| 285 | 1608 | } |
| 286 | 1609 | |
| 287 | -function wpsc_get_agentonly_fields(){ | |
| 288 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 289 | - jQuery('#wpsc_agentonly_fields').addClass('active'); | |
| 290 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 291 | - | |
| 1610 | +/** | |
| 1611 | + * Get edit status modal | |
| 1612 | + */ | |
| 1613 | +function wpsc_get_edit_status(id, nonce) { | |
| 1614 | + wpsc_show_modal(); | |
| 1615 | + var data = { action: "wpsc_get_edit_status", id, _ajax_nonce: nonce }; | |
| 1616 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1617 | + // Set to modal. | |
| 1618 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1619 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1620 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1621 | + // Display modal. | |
| 1622 | + wpsc_show_modal_inner_container(); | |
| 1623 | + }); | |
| 1624 | +} | |
| 1625 | + | |
| 1626 | +/** | |
| 1627 | + * Update status | |
| 1628 | + */ | |
| 1629 | +function wpsc_set_edit_status(el) { | |
| 1630 | + var form = jQuery(".wpsc-frm-edit-status")[0]; | |
| 1631 | + var dataform = new FormData(form); | |
| 1632 | + | |
| 1633 | + if (dataform.get("name").trim() == "") { | |
| 1634 | + alert(supportcandy.translations.req_fields_missing); | |
| 1635 | + return; | |
| 1636 | + } | |
| 1637 | + | |
| 1638 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1639 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1640 | + | |
| 1641 | + jQuery | |
| 1642 | + .ajax({ | |
| 1643 | + url: supportcandy.ajax_url, | |
| 1644 | + type: "POST", | |
| 1645 | + data: dataform, | |
| 1646 | + processData: false, | |
| 1647 | + contentType: false, | |
| 1648 | + }) | |
| 1649 | + .done(function (res) { | |
| 1650 | + wpsc_close_modal(); | |
| 1651 | + wpsc_get_ticket_statuses(); | |
| 1652 | + }); | |
| 1653 | +} | |
| 1654 | + | |
| 1655 | +/** | |
| 1656 | + * Delete status modal | |
| 1657 | + */ | |
| 1658 | +function wpsc_get_delete_status(id, nonce) { | |
| 1659 | + var flag = confirm(supportcandy.translations.confirm); | |
| 1660 | + if (!flag) { | |
| 1661 | + return; | |
| 1662 | + } | |
| 1663 | + | |
| 1664 | + wpsc_show_modal(); | |
| 1665 | + var data = { action: "wpsc_get_delete_status", id, _ajax_nonce: nonce }; | |
| 1666 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1667 | + // Set to modal. | |
| 1668 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1669 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1670 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1671 | + // Display modal. | |
| 1672 | + wpsc_show_modal_inner_container(); | |
| 1673 | + }); | |
| 1674 | +} | |
| 1675 | + | |
| 1676 | +/** | |
| 1677 | + * Delete status | |
| 1678 | + */ | |
| 1679 | +function wpsc_set_delete_status(el) { | |
| 1680 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1681 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1682 | + | |
| 1683 | + var form = jQuery(".wpsc-frm-delete-status")[0]; | |
| 1684 | + var dataform = new FormData(form); | |
| 1685 | + jQuery | |
| 1686 | + .ajax({ | |
| 1687 | + url: supportcandy.ajax_url, | |
| 1688 | + type: "POST", | |
| 1689 | + data: dataform, | |
| 1690 | + processData: false, | |
| 1691 | + contentType: false, | |
| 1692 | + }) | |
| 1693 | + .done(function (res) { | |
| 1694 | + wpsc_close_modal(); | |
| 1695 | + wpsc_get_ticket_statuses(); | |
| 1696 | + }); | |
| 1697 | +} | |
| 1698 | + | |
| 1699 | +/** | |
| 1700 | + * Get priority settings | |
| 1701 | + */ | |
| 1702 | +function wpsc_get_ticket_priorities(is_humbargar = false) { | |
| 1703 | + if (is_humbargar) { | |
| 1704 | + wpsc_toggle_humbargar(); | |
| 1705 | + } | |
| 1706 | + | |
| 1707 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 1708 | + jQuery( | |
| 1709 | + ".wpsc-setting-nav.ticket-priorities, .wpsc-humbargar-menu-item.ticket-priorities" | |
| 1710 | + ).addClass("active"); | |
| 1711 | + jQuery(".wpsc-humbargar-title").html( | |
| 1712 | + supportcandy.humbargar_titles.ticket_priorities | |
| 1713 | + ); | |
| 1714 | + | |
| 1715 | + window.history.replaceState( | |
| 1716 | + {}, | |
| 1717 | + null, | |
| 1718 | + "admin.php?page=wpsc-settings§ion=ticket-priorities" | |
| 1719 | + ); | |
| 1720 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 1721 | + | |
| 1722 | + wpsc_scroll_top(); | |
| 1723 | + | |
| 1724 | + var data = { action: "wpsc_get_ticket_priorities" }; | |
| 1725 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1726 | + jQuery(".wpsc-setting-body").html(response); | |
| 1727 | + wpsc_reset_responsive_style(); | |
| 1728 | + }); | |
| 1729 | +} | |
| 1730 | + | |
| 1731 | +/** | |
| 1732 | + * Set add new priority | |
| 1733 | + */ | |
| 1734 | +function wpsc_set_add_priority(el) { | |
| 1735 | + var form = jQuery(".wpsc-frm-add-priority")[0]; | |
| 1736 | + var dataform = new FormData(form); | |
| 1737 | + | |
| 1738 | + if (dataform.get("name").trim() == "") { | |
| 1739 | + alert(supportcandy.translations.req_fields_missing); | |
| 1740 | + return; | |
| 1741 | + } | |
| 1742 | + | |
| 1743 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1744 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1745 | + | |
| 1746 | + jQuery | |
| 1747 | + .ajax({ | |
| 1748 | + url: supportcandy.ajax_url, | |
| 1749 | + type: "POST", | |
| 1750 | + data: dataform, | |
| 1751 | + processData: false, | |
| 1752 | + contentType: false, | |
| 1753 | + }) | |
| 1754 | + .done(function (res) { | |
| 1755 | + wpsc_close_modal(); | |
| 1756 | + wpsc_get_ticket_priorities(); | |
| 1757 | + }); | |
| 1758 | +} | |
| 1759 | + | |
| 1760 | +/** | |
| 1761 | + * Get edit priority modal | |
| 1762 | + */ | |
| 1763 | +function wpsc_get_edit_priority(id, nonce) { | |
| 1764 | + wpsc_show_modal(); | |
| 1765 | + var data = { action: "wpsc_get_edit_priority", id, _ajax_nonce: nonce }; | |
| 1766 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1767 | + // Set to modal. | |
| 1768 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1769 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1770 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1771 | + // Display modal. | |
| 1772 | + wpsc_show_modal_inner_container(); | |
| 1773 | + }); | |
| 1774 | +} | |
| 1775 | + | |
| 1776 | +/** | |
| 1777 | + * Update an priority | |
| 1778 | + */ | |
| 1779 | +function wpsc_set_edit_priority(el) { | |
| 1780 | + var form = jQuery(".wpsc-frm-edit-priority")[0]; | |
| 1781 | + var dataform = new FormData(form); | |
| 1782 | + | |
| 1783 | + if (dataform.get("name").trim() == "") { | |
| 1784 | + alert(supportcandy.translations.req_fields_missing); | |
| 1785 | + return; | |
| 1786 | + } | |
| 1787 | + | |
| 1788 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1789 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1790 | + | |
| 1791 | + jQuery | |
| 1792 | + .ajax({ | |
| 1793 | + url: supportcandy.ajax_url, | |
| 1794 | + type: "POST", | |
| 1795 | + data: dataform, | |
| 1796 | + processData: false, | |
| 1797 | + contentType: false, | |
| 1798 | + }) | |
| 1799 | + .done(function (res) { | |
| 1800 | + wpsc_close_modal(); | |
| 1801 | + wpsc_get_ticket_priorities(); | |
| 1802 | + }); | |
| 1803 | +} | |
| 1804 | + | |
| 1805 | +/** | |
| 1806 | + * Delete priority modal | |
| 1807 | + */ | |
| 1808 | +function wpsc_get_delete_priority(id, nonce) { | |
| 1809 | + var flag = confirm(supportcandy.translations.confirm); | |
| 1810 | + if (!flag) { | |
| 1811 | + return; | |
| 1812 | + } | |
| 1813 | + | |
| 1814 | + wpsc_show_modal(); | |
| 1815 | + var data = { action: "wpsc_get_delete_priority", id, _ajax_nonce: nonce }; | |
| 1816 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1817 | + // Set to modal. | |
| 1818 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1819 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1820 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1821 | + // Display modal. | |
| 1822 | + wpsc_show_modal_inner_container(); | |
| 1823 | + }); | |
| 1824 | +} | |
| 1825 | + | |
| 1826 | +/** | |
| 1827 | + * Delete priority | |
| 1828 | + */ | |
| 1829 | +function wpsc_set_delete_priority(el) { | |
| 1830 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1831 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1832 | + | |
| 1833 | + var form = jQuery(".wpsc-frm-delete-priority")[0]; | |
| 1834 | + var dataform = new FormData(form); | |
| 1835 | + jQuery | |
| 1836 | + .ajax({ | |
| 1837 | + url: supportcandy.ajax_url, | |
| 1838 | + type: "POST", | |
| 1839 | + data: dataform, | |
| 1840 | + processData: false, | |
| 1841 | + contentType: false, | |
| 1842 | + }) | |
| 1843 | + .done(function (res) { | |
| 1844 | + wpsc_close_modal(); | |
| 1845 | + wpsc_get_ticket_priorities(); | |
| 1846 | + }); | |
| 1847 | +} | |
| 1848 | + | |
| 1849 | +/** | |
| 1850 | + * Get ticket form fields | |
| 1851 | + */ | |
| 1852 | +function wpsc_get_tff(is_humbargar = false) { | |
| 1853 | + if (is_humbargar) { | |
| 1854 | + wpsc_toggle_humbargar(); | |
| 1855 | + } | |
| 1856 | + | |
| 1857 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 1858 | + jQuery( | |
| 1859 | + ".wpsc-setting-nav.ticket-form-fields, .wpsc-humbargar-menu-item.ticket-form-fields" | |
| 1860 | + ).addClass("active"); | |
| 1861 | + jQuery(".wpsc-humbargar-title").html( | |
| 1862 | + supportcandy.humbargar_titles.ticket_form_fields | |
| 1863 | + ); | |
| 1864 | + | |
| 1865 | + window.history.replaceState( | |
| 1866 | + {}, | |
| 1867 | + null, | |
| 1868 | + "admin.php?page=wpsc-ticket-form§ion=ticket-form-fields" | |
| 1869 | + ); | |
| 1870 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 1871 | + | |
| 1872 | + wpsc_scroll_top(); | |
| 1873 | + | |
| 1874 | + var data = { action: "wpsc_get_tff" }; | |
| 1875 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1876 | + jQuery(".wpsc-setting-body").html(response); | |
| 1877 | + wpsc_reset_responsive_style(); | |
| 1878 | + }); | |
| 1879 | +} | |
| 1880 | + | |
| 1881 | +/** | |
| 1882 | + * Set add new ticket form field | |
| 1883 | + */ | |
| 1884 | +function wpsc_set_add_new_tff(el) { | |
| 1885 | + if (!jQuery("#wpsc-select-ticket-form-field").val()) { | |
| 1886 | + alert(supportcandy.translations.req_fields_missing); | |
| 1887 | + return; | |
| 1888 | + } | |
| 1889 | + | |
| 1890 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1891 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1892 | + | |
| 1893 | + var form = jQuery(".frm-add-new-ticket-form-field")[0]; | |
| 1894 | + var dataform = new FormData(form); | |
| 1895 | + | |
| 1896 | + dataform.append( | |
| 1897 | + "visibility", | |
| 1898 | + JSON.stringify(wpsc_get_condition_json("visibility")) | |
| 1899 | + ); | |
| 1900 | + | |
| 1901 | + jQuery | |
| 1902 | + .ajax({ | |
| 1903 | + url: supportcandy.ajax_url, | |
| 1904 | + type: "POST", | |
| 1905 | + data: dataform, | |
| 1906 | + processData: false, | |
| 1907 | + contentType: false, | |
| 1908 | + }) | |
| 1909 | + .done(function (res) { | |
| 1910 | + wpsc_close_modal(); | |
| 1911 | + wpsc_get_tff(); | |
| 1912 | + }); | |
| 1913 | +} | |
| 1914 | + | |
| 1915 | +/** | |
| 1916 | + * Get edit ticket form field modal | |
| 1917 | + */ | |
| 1918 | +function wpsc_get_edit_tff(id, nonce) { | |
| 1919 | + wpsc_show_modal(); | |
| 1920 | + var data = { action: "wpsc_get_edit_tff", id, _ajax_nonce: nonce }; | |
| 1921 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 1922 | + // Set to modal. | |
| 1923 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 1924 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 1925 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 1926 | + // Display modal. | |
| 1927 | + wpsc_show_modal_inner_container(); | |
| 1928 | + }); | |
| 1929 | +} | |
| 1930 | + | |
| 1931 | +/** | |
| 1932 | + * Update ticket form field | |
| 1933 | + */ | |
| 1934 | +function wpsc_set_edit_tff(el) { | |
| 1935 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 1936 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1937 | + | |
| 1938 | + var form = jQuery(".frm-edit-ticket-form-field")[0]; | |
| 1939 | + var dataform = new FormData(form); | |
| 1940 | + | |
| 1941 | + dataform.append( | |
| 1942 | + "visibility", | |
| 1943 | + JSON.stringify(wpsc_get_condition_json("visibility")) | |
| 1944 | + ); | |
| 1945 | + | |
| 1946 | + jQuery | |
| 1947 | + .ajax({ | |
| 1948 | + url: supportcandy.ajax_url, | |
| 1949 | + type: "POST", | |
| 1950 | + data: dataform, | |
| 1951 | + processData: false, | |
| 1952 | + contentType: false, | |
| 1953 | + }) | |
| 1954 | + .done(function (res) { | |
| 1955 | + wpsc_close_modal(); | |
| 1956 | + wpsc_get_tff(); | |
| 1957 | + }); | |
| 1958 | +} | |
| 1959 | + | |
| 1960 | +/** | |
| 1961 | + * Delete ticket form field | |
| 1962 | + */ | |
| 1963 | +function wpsc_delete_tff(id, nonce) { | |
| 1964 | + var flag = confirm(supportcandy.translations.confirm); | |
| 1965 | + if (!flag) { | |
| 1966 | + return; | |
| 1967 | + } | |
| 1968 | + | |
| 1969 | + var data = { action: "wpsc_delete_tff", id, _ajax_nonce: nonce }; | |
| 1970 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 1971 | + wpsc_get_tff(); | |
| 1972 | + }); | |
| 1973 | +} | |
| 1974 | + | |
| 1975 | +/** | |
| 1976 | + * Get ticket fields | |
| 1977 | + */ | |
| 1978 | +function wpsc_get_ticket_fields(is_humbargar = false) { | |
| 1979 | + if (is_humbargar) { | |
| 1980 | + wpsc_toggle_humbargar(); | |
| 1981 | + } | |
| 1982 | + | |
| 1983 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 1984 | + jQuery( | |
| 1985 | + ".wpsc-setting-nav.ticket-fields, .wpsc-humbargar-menu-item.ticket-fields" | |
| 1986 | + ).addClass("active"); | |
| 1987 | + jQuery(".wpsc-humbargar-title").html( | |
| 1988 | + supportcandy.humbargar_titles.ticket_fields | |
| 1989 | + ); | |
| 1990 | + | |
| 1991 | + window.history.replaceState( | |
| 1992 | + {}, | |
| 1993 | + null, | |
| 1994 | + "admin.php?page=wpsc-ticket-form§ion=ticket-fields" | |
| 1995 | + ); | |
| 1996 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 1997 | + | |
| 1998 | + wpsc_scroll_top(); | |
| 1999 | + | |
| 2000 | + var data = { action: "wpsc_get_ticket_fields" }; | |
| 2001 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2002 | + jQuery(".wpsc-setting-body").html(response); | |
| 2003 | + wpsc_reset_responsive_style(); | |
| 2004 | + }); | |
| 2005 | +} | |
| 2006 | + | |
| 2007 | +/** | |
| 2008 | + * Get customer fields | |
| 2009 | + */ | |
| 2010 | +function wpsc_get_customer_fields(is_humbargar = false) { | |
| 2011 | + if (is_humbargar) { | |
| 2012 | + wpsc_toggle_humbargar(); | |
| 2013 | + } | |
| 2014 | + | |
| 2015 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 2016 | + jQuery( | |
| 2017 | + ".wpsc-setting-nav.customer-fields, .wpsc-humbargar-menu-item.customer-fields" | |
| 2018 | + ).addClass("active"); | |
| 2019 | + jQuery(".wpsc-humbargar-title").html( | |
| 2020 | + supportcandy.humbargar_titles.customer_fields | |
| 2021 | + ); | |
| 2022 | + | |
| 2023 | + window.history.replaceState( | |
| 2024 | + {}, | |
| 2025 | + null, | |
| 2026 | + "admin.php?page=wpsc-ticket-form§ion=customer-fields" | |
| 2027 | + ); | |
| 2028 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2029 | + | |
| 2030 | + wpsc_scroll_top(); | |
| 2031 | + | |
| 2032 | + var data = { action: "wpsc_get_customer_fields" }; | |
| 2033 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2034 | + jQuery(".wpsc-setting-body").html(response); | |
| 2035 | + wpsc_reset_responsive_style(); | |
| 2036 | + }); | |
| 2037 | +} | |
| 2038 | + | |
| 2039 | +/** | |
| 2040 | + * Get agent only fields | |
| 2041 | + */ | |
| 2042 | +function wpsc_get_agent_only_fields(is_humbargar = false) { | |
| 2043 | + if (is_humbargar) { | |
| 2044 | + wpsc_toggle_humbargar(); | |
| 2045 | + } | |
| 2046 | + | |
| 2047 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 2048 | + jQuery( | |
| 2049 | + ".wpsc-setting-nav.agent-only-fields, .wpsc-humbargar-menu-item.agent-only-fields" | |
| 2050 | + ).addClass("active"); | |
| 2051 | + jQuery(".wpsc-humbargar-title").html( | |
| 2052 | + supportcandy.humbargar_titles.agent_only_fields | |
| 2053 | + ); | |
| 2054 | + | |
| 2055 | + window.history.replaceState( | |
| 2056 | + {}, | |
| 2057 | + null, | |
| 2058 | + "admin.php?page=wpsc-ticket-form§ion=agent-only-fields" | |
| 2059 | + ); | |
| 2060 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2061 | + | |
| 2062 | + wpsc_scroll_top(); | |
| 2063 | + | |
| 2064 | + var data = { action: "wpsc_get_agent_only_fields" }; | |
| 2065 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2066 | + jQuery(".wpsc-setting-body").html(response); | |
| 2067 | + wpsc_reset_responsive_style(); | |
| 2068 | + }); | |
| 2069 | +} | |
| 2070 | + | |
| 2071 | +/** | |
| 2072 | + * Get add new ticket field | |
| 2073 | + */ | |
| 2074 | +function wpsc_get_add_new_custom_field(field, nonce) { | |
| 2075 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 292 | 2076 | var data = { |
| 293 | - action: 'wpsc_custom_fields', | |
| 294 | - setting_action : 'get_agentonly_fields' | |
| 2077 | + action: "wpsc_get_add_new_custom_field", | |
| 2078 | + field, | |
| 2079 | + _ajax_nonce: nonce, | |
| 295 | 2080 | }; |
| 296 | - | |
| 297 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 298 | - jQuery('.wpsc_setting_col2').html(response); | |
| 299 | - }); | |
| 2081 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2082 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2083 | + }); | |
| 300 | 2084 | } |
| 301 | 2085 | |
| 302 | -function wpsc_get_agent_ticket_list(){ | |
| 303 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 304 | - jQuery('#wpsc_agent_ticket_list').addClass('active'); | |
| 305 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 306 | - | |
| 2086 | +/** | |
| 2087 | + * Get edit ticket field modal | |
| 2088 | + */ | |
| 2089 | +function wpsc_get_edit_custom_field(id, nonce) { | |
| 2090 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 307 | 2091 | var data = { |
| 308 | - action: 'wpsc_ticket_list', | |
| 309 | - setting_action : 'get_agent_ticket_list' | |
| 2092 | + action: "wpsc_get_edit_custom_field", | |
| 2093 | + cf_id: id, | |
| 2094 | + _ajax_nonce: nonce, | |
| 310 | 2095 | }; |
| 2096 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2097 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2098 | + }); | |
| 2099 | +} | |
| 311 | 2100 | |
| 312 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 313 | - jQuery('.wpsc_setting_col2').html(response); | |
| 314 | - }); | |
| 315 | -} | |
| 2101 | +/** | |
| 2102 | + * Submit delete an ticket form field | |
| 2103 | + */ | |
| 2104 | +function wpsc_delete_custom_field(id, nonce) { | |
| 2105 | + var flag = confirm(supportcandy.translations.confirm); | |
| 2106 | + if (!flag) { | |
| 2107 | + return; | |
| 2108 | + } | |
| 316 | 2109 | |
| 317 | -function wpsc_get_customer_ticket_list(){ | |
| 318 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 319 | - jQuery('#wpsc_customer_ticket_list').addClass('active'); | |
| 320 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 321 | - | |
| 2110 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2111 | + | |
| 322 | 2112 | var data = { |
| 323 | - action: 'wpsc_ticket_list', | |
| 324 | - setting_action : 'get_customer_ticket_list' | |
| 2113 | + action: "wpsc_delete_custom_field", | |
| 2114 | + cf_id: id, | |
| 2115 | + _ajax_nonce: nonce, | |
| 325 | 2116 | }; |
| 326 | - | |
| 327 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 328 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2117 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 2118 | + jQuery(".wpsc-setting-nav.active").trigger("click"); | |
| 329 | 2119 | }); |
| 330 | 2120 | } |
| 331 | 2121 | |
| 332 | -function wpsc_get_agent_ticket_filters(){ | |
| 333 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 334 | - jQuery('#wpsc_agent_ticket_filters').addClass('active'); | |
| 335 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 336 | - | |
| 2122 | +/** | |
| 2123 | + * Get agent ticket list settings | |
| 2124 | + */ | |
| 2125 | +function wpsc_get_agent_tl_settings(is_humbargar = false) { | |
| 2126 | + if (is_humbargar) { | |
| 2127 | + wpsc_toggle_humbargar(); | |
| 2128 | + } | |
| 2129 | + | |
| 2130 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 2131 | + jQuery( | |
| 2132 | + ".wpsc-setting-nav.agent-ticket-list, .wpsc-humbargar-menu-item.agent-ticket-list" | |
| 2133 | + ).addClass("active"); | |
| 2134 | + jQuery(".wpsc-humbargar-title").html( | |
| 2135 | + supportcandy.humbargar_titles.agent_ticket_list | |
| 2136 | + ); | |
| 2137 | + | |
| 2138 | + if (supportcandy.current_section !== "agent-ticket-list") { | |
| 2139 | + supportcandy.current_section = "agent-ticket-list"; | |
| 2140 | + supportcandy.current_tab = "list-items"; | |
| 2141 | + } | |
| 2142 | + | |
| 2143 | + window.history.replaceState( | |
| 2144 | + {}, | |
| 2145 | + null, | |
| 2146 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2147 | + supportcandy.current_section + | |
| 2148 | + "&tab=" + | |
| 2149 | + supportcandy.current_tab | |
| 2150 | + ); | |
| 2151 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2152 | + | |
| 2153 | + wpsc_scroll_top(); | |
| 2154 | + | |
| 337 | 2155 | var data = { |
| 338 | - action: 'wpsc_ticket_list', | |
| 339 | - setting_action : 'get_agent_ticket_filters' | |
| 2156 | + action: "wpsc_get_agent_tl_settings", | |
| 2157 | + tab: supportcandy.current_tab, | |
| 340 | 2158 | }; |
| 341 | - | |
| 342 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 343 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2159 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2160 | + jQuery(".wpsc-setting-body").html(response); | |
| 2161 | + wpsc_reset_responsive_style(); | |
| 2162 | + jQuery( | |
| 2163 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2164 | + ).trigger("click"); | |
| 344 | 2165 | }); |
| 345 | 2166 | } |
| 346 | 2167 | |
| 347 | -function wpsc_get_customer_ticket_filters(){ | |
| 348 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 349 | - jQuery('#wpsc_customer_ticket_filters').addClass('active'); | |
| 350 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 351 | - | |
| 2168 | +/** | |
| 2169 | + * Get customer ticket list | |
| 2170 | + */ | |
| 2171 | +function wpsc_get_customer_tl_settings(is_humbargar = false) { | |
| 2172 | + if (is_humbargar) { | |
| 2173 | + wpsc_toggle_humbargar(); | |
| 2174 | + } | |
| 2175 | + | |
| 2176 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 2177 | + jQuery( | |
| 2178 | + ".wpsc-setting-nav.customer-ticket-list, .wpsc-humbargar-menu-item.customer-ticket-list" | |
| 2179 | + ).addClass("active"); | |
| 2180 | + jQuery(".wpsc-humbargar-title").html( | |
| 2181 | + supportcandy.humbargar_titles.customer_ticket_list | |
| 2182 | + ); | |
| 2183 | + | |
| 2184 | + if (supportcandy.current_section !== "customer-ticket-list") { | |
| 2185 | + supportcandy.current_section = "customer-ticket-list"; | |
| 2186 | + supportcandy.current_tab = "list-items"; | |
| 2187 | + } | |
| 2188 | + | |
| 2189 | + window.history.replaceState( | |
| 2190 | + {}, | |
| 2191 | + null, | |
| 2192 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2193 | + supportcandy.current_section + | |
| 2194 | + "&tab=" + | |
| 2195 | + supportcandy.current_tab | |
| 2196 | + ); | |
| 2197 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2198 | + | |
| 2199 | + wpsc_scroll_top(); | |
| 2200 | + | |
| 352 | 2201 | var data = { |
| 353 | - action: 'wpsc_ticket_list', | |
| 354 | - setting_action : 'get_customer_ticket_filters' | |
| 2202 | + action: "wpsc_get_customer_tl_settings", | |
| 2203 | + tab: supportcandy.current_tab, | |
| 355 | 2204 | }; |
| 2205 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2206 | + jQuery(".wpsc-setting-body").html(response); | |
| 2207 | + wpsc_reset_responsive_style(); | |
| 2208 | + jQuery( | |
| 2209 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2210 | + ).trigger("click"); | |
| 2211 | + }); | |
| 2212 | +} | |
| 356 | 2213 | |
| 357 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 358 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2214 | +/** | |
| 2215 | + * Get ticket list more settings | |
| 2216 | + */ | |
| 2217 | +function wpsc_get_tl_more_settigns(is_humbargar = false) { | |
| 2218 | + if (is_humbargar) { | |
| 2219 | + wpsc_toggle_humbargar(); | |
| 2220 | + } | |
| 2221 | + | |
| 2222 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 2223 | + jQuery( | |
| 2224 | + ".wpsc-setting-nav.more-settings, .wpsc-humbargar-menu-item.more-settings" | |
| 2225 | + ).addClass("active"); | |
| 2226 | + jQuery(".wpsc-humbargar-title").html( | |
| 2227 | + supportcandy.humbargar_titles.more_settings | |
| 2228 | + ); | |
| 2229 | + | |
| 2230 | + if (supportcandy.current_section !== "more-settings") { | |
| 2231 | + supportcandy.current_section = "more-settings"; | |
| 2232 | + supportcandy.current_tab = "agent-view"; | |
| 2233 | + } | |
| 2234 | + | |
| 2235 | + window.history.replaceState( | |
| 2236 | + {}, | |
| 2237 | + null, | |
| 2238 | + "admin.php?page=wpsc-ticket-list§ion=more-settings" | |
| 2239 | + ); | |
| 2240 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 2241 | + | |
| 2242 | + wpsc_scroll_top(); | |
| 2243 | + | |
| 2244 | + var data = { action: "wpsc_get_tl_more_settigns" }; | |
| 2245 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2246 | + jQuery(".wpsc-setting-body").html(response); | |
| 2247 | + wpsc_reset_responsive_style(); | |
| 2248 | + jQuery( | |
| 2249 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2250 | + ).trigger("click"); | |
| 359 | 2251 | }); |
| 360 | 2252 | } |
| 361 | 2253 | |
| 362 | -function wpsc_get_ticket_list_additional_settings(){ | |
| 363 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 364 | - jQuery('#wpsc_ticket_list_additional_settings').addClass('active'); | |
| 365 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 366 | - | |
| 367 | - var data = { | |
| 368 | - action: 'wpsc_ticket_list', | |
| 369 | - setting_action : 'get_ticket_list_additional_settings' | |
| 370 | - }; | |
| 2254 | +/** | |
| 2255 | + * Get agent ticket list items | |
| 2256 | + */ | |
| 2257 | +function wpsc_get_agent_tl_items() { | |
| 2258 | + supportcandy.current_tab = "list-items"; | |
| 2259 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2260 | + jQuery( | |
| 2261 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2262 | + ).addClass("active"); | |
| 371 | 2263 | |
| 372 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 373 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2264 | + window.history.replaceState( | |
| 2265 | + {}, | |
| 2266 | + null, | |
| 2267 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2268 | + supportcandy.current_section + | |
| 2269 | + "&tab=" + | |
| 2270 | + supportcandy.current_tab | |
| 2271 | + ); | |
| 2272 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2273 | + | |
| 2274 | + wpsc_scroll_top(); | |
| 2275 | + | |
| 2276 | + var data = { action: "wpsc_get_agent_tl_items" }; | |
| 2277 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2278 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2279 | + wpsc_reset_responsive_style(); | |
| 374 | 2280 | }); |
| 375 | 2281 | } |
| 376 | 2282 | |
| 377 | -function set_ticket_list_additional_settings(){ | |
| 378 | - var check = false; | |
| 379 | - jQuery('#wpsc_agent_unresolved_statuses').find('input:checked').each(function(){ | |
| 380 | - check=true; | |
| 381 | - }); | |
| 2283 | +/** | |
| 2284 | + * Set add new agent list items | |
| 2285 | + */ | |
| 2286 | +function wpsc_set_add_agent_tl_item(el) { | |
| 2287 | + var form = jQuery(".frm-add-agent-tl-items")[0]; | |
| 2288 | + var dataform = new FormData(form); | |
| 382 | 2289 | |
| 383 | - if(!check){ | |
| 384 | - alert(wpsc_admin.unresolve_agent); | |
| 385 | - return; | |
| 2290 | + var cf_id = dataform.getAll("cf_id[]"); | |
| 2291 | + if (!cf_id.length) { | |
| 2292 | + alert(supportcandy.translations.req_fields_missing); | |
| 2293 | + return; | |
| 386 | 2294 | } |
| 387 | - | |
| 388 | - var check=false; | |
| 389 | - jQuery('#wpsc_customer_unresolved_statuses').find('input:checked').each(function(){ | |
| 390 | - check=true; | |
| 2295 | + | |
| 2296 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2297 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2298 | + | |
| 2299 | + jQuery | |
| 2300 | + .ajax({ | |
| 2301 | + url: supportcandy.ajax_url, | |
| 2302 | + type: "POST", | |
| 2303 | + data: dataform, | |
| 2304 | + processData: false, | |
| 2305 | + contentType: false, | |
| 2306 | + }) | |
| 2307 | + .done(function (res) { | |
| 2308 | + wpsc_close_modal(); | |
| 2309 | + wpsc_get_agent_tl_items(); | |
| 2310 | + }); | |
| 2311 | +} | |
| 2312 | + | |
| 2313 | +/** | |
| 2314 | + * Set delete agent ticket list item | |
| 2315 | + */ | |
| 2316 | +function wpsc_delete_agent_tl_item(slug, nonce) { | |
| 2317 | + if (confirm(supportcandy.translations.confirm)) { | |
| 2318 | + var data = { | |
| 2319 | + action: "wpsc_delete_agent_tl_item", | |
| 2320 | + slug: slug, | |
| 2321 | + _ajax_nonce: nonce, | |
| 2322 | + }; | |
| 2323 | + | |
| 2324 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2325 | + jQuery(slug).text(supportcandy.translations.please_wait); | |
| 2326 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 2327 | + wpsc_get_agent_tl_items(); | |
| 2328 | + }); | |
| 2329 | + } else { | |
| 2330 | + return false; | |
| 2331 | + } | |
| 2332 | +} | |
| 2333 | + | |
| 2334 | +/** | |
| 2335 | + * Get agent filter items | |
| 2336 | + */ | |
| 2337 | +function wpsc_get_agent_filter_items() { | |
| 2338 | + supportcandy.current_tab = "filter-items"; | |
| 2339 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2340 | + jQuery( | |
| 2341 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2342 | + ).addClass("active"); | |
| 2343 | + | |
| 2344 | + window.history.replaceState( | |
| 2345 | + {}, | |
| 2346 | + null, | |
| 2347 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2348 | + supportcandy.current_section + | |
| 2349 | + "&tab=" + | |
| 2350 | + supportcandy.current_tab | |
| 2351 | + ); | |
| 2352 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2353 | + | |
| 2354 | + wpsc_scroll_top(); | |
| 2355 | + | |
| 2356 | + var data = { action: "wpsc_get_agent_filter_items" }; | |
| 2357 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2358 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2359 | + wpsc_reset_responsive_style(); | |
| 391 | 2360 | }); |
| 392 | - | |
| 393 | - if(!check){ | |
| 394 | - alert(wpsc_admin.unresolve_customer); | |
| 395 | - return; | |
| 2361 | +} | |
| 2362 | + | |
| 2363 | +/** | |
| 2364 | + * Set add new agent list items | |
| 2365 | + */ | |
| 2366 | +function wpsc_set_add_atl_filter_item(el) { | |
| 2367 | + var form = jQuery(".frm-add-agent-tl-filter-items")[0]; | |
| 2368 | + var dataform = new FormData(form); | |
| 2369 | + | |
| 2370 | + var cf_id = dataform.getAll("agent-tl-filter-id[]"); | |
| 2371 | + if (!cf_id.length) { | |
| 2372 | + alert(supportcandy.translations.req_fields_missing); | |
| 2373 | + return; | |
| 396 | 2374 | } |
| 397 | - jQuery('.wpsc_submit_wait').show(); | |
| 398 | - var dataform = new FormData(jQuery('#wpsc_frm_general_settings')[0]); | |
| 399 | - | |
| 400 | - jQuery.ajax({ | |
| 401 | - url: wpsc_admin.ajax_url, | |
| 402 | - type: 'POST', | |
| 403 | - data: dataform, | |
| 404 | - processData: false, | |
| 405 | - contentType: false | |
| 406 | - }) | |
| 407 | - .done(function (response_str) { | |
| 408 | - var response = JSON.parse(response_str); | |
| 409 | - jQuery('.wpsc_submit_wait').hide(); | |
| 410 | - if (response.sucess_status=='1') { | |
| 411 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 412 | - } | |
| 413 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 414 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 2375 | + | |
| 2376 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2377 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2378 | + jQuery | |
| 2379 | + .ajax({ | |
| 2380 | + url: supportcandy.ajax_url, | |
| 2381 | + type: "POST", | |
| 2382 | + data: dataform, | |
| 2383 | + processData: false, | |
| 2384 | + contentType: false, | |
| 2385 | + }) | |
| 2386 | + .done(function (res) { | |
| 2387 | + wpsc_close_modal(); | |
| 2388 | + wpsc_get_agent_filter_items(); | |
| 2389 | + }); | |
| 2390 | +} | |
| 2391 | + | |
| 2392 | +/** | |
| 2393 | + * Get delete agent ticket list item | |
| 2394 | + * | |
| 2395 | + * @param {*} slug | |
| 2396 | + */ | |
| 2397 | +function wpsc_delete_atl_filter_item(slug, nonce) { | |
| 2398 | + if (confirm(supportcandy.translations.confirm)) { | |
| 2399 | + var data = { | |
| 2400 | + action: "wpsc_delete_atl_filter_item", | |
| 2401 | + slug: slug, | |
| 2402 | + _ajax_nonce: nonce, | |
| 2403 | + }; | |
| 2404 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 2405 | + wpsc_get_agent_filter_items(); | |
| 2406 | + }); | |
| 2407 | + } | |
| 2408 | +} | |
| 2409 | + | |
| 2410 | +/** | |
| 2411 | + * Get agent default filters | |
| 2412 | + */ | |
| 2413 | +function wpsc_get_atl_default_filters() { | |
| 2414 | + supportcandy.current_tab = "default-filters"; | |
| 2415 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2416 | + jQuery( | |
| 2417 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2418 | + ).addClass("active"); | |
| 2419 | + | |
| 2420 | + window.history.replaceState( | |
| 2421 | + {}, | |
| 2422 | + null, | |
| 2423 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2424 | + supportcandy.current_section + | |
| 2425 | + "&tab=" + | |
| 2426 | + supportcandy.current_tab | |
| 2427 | + ); | |
| 2428 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2429 | + | |
| 2430 | + wpsc_scroll_top(); | |
| 2431 | + | |
| 2432 | + var data = { action: "wpsc_get_atl_default_filters" }; | |
| 2433 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2434 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2435 | + wpsc_reset_responsive_style(); | |
| 415 | 2436 | }); |
| 416 | - | |
| 417 | 2437 | } |
| 418 | 2438 | |
| 419 | -function wpsc_get_support_agents(){ | |
| 420 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 421 | - jQuery('#wpsc_support_agents').addClass('active'); | |
| 422 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 423 | - | |
| 2439 | +/** | |
| 2440 | + * Add agent default filter | |
| 2441 | + */ | |
| 2442 | +function wpsc_get_add_atl_default_filter() { | |
| 2443 | + wpsc_show_modal(); | |
| 2444 | + var data = { action: "wpsc_get_add_atl_default_filter" }; | |
| 2445 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2446 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 2447 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 2448 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 2449 | + jQuery(".wpsc-form-filter-container").append( | |
| 2450 | + jQuery(".wpsc-form-filter-snippet").html() | |
| 2451 | + ); | |
| 2452 | + jQuery(".wpsc-form-filter-container select").selectWoo(); | |
| 2453 | + wpsc_show_modal_inner_container(); | |
| 2454 | + }); | |
| 2455 | +} | |
| 2456 | + | |
| 2457 | +/** | |
| 2458 | + * Set add agent default filters | |
| 2459 | + */ | |
| 2460 | +function wpsc_set_add_atl_default_filter(el) { | |
| 2461 | + var label = jQuery("#wpsc-atl-df-label").val().trim(); | |
| 2462 | + if (!label) { | |
| 2463 | + alert(supportcandy.translations.req_fields_missing); | |
| 2464 | + return; | |
| 2465 | + } | |
| 2466 | + | |
| 2467 | + var filters = wpsc_get_condition_json("default_filters"); | |
| 2468 | + if ( | |
| 2469 | + filters.length === 0 || | |
| 2470 | + (filters.length === 1 && filters[0].length === 0) | |
| 2471 | + ) { | |
| 2472 | + alert(supportcandy.translations.req_fields_missing); | |
| 2473 | + return; | |
| 2474 | + } | |
| 2475 | + | |
| 2476 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2477 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2478 | + | |
| 2479 | + var form = jQuery(".wpsc-frm-add-atl-default-filter")[0]; | |
| 2480 | + var dataform = new FormData(form); | |
| 2481 | + dataform.append("filters", JSON.stringify(filters)); | |
| 2482 | + | |
| 2483 | + jQuery | |
| 2484 | + .ajax({ | |
| 2485 | + url: supportcandy.ajax_url, | |
| 2486 | + type: "POST", | |
| 2487 | + data: dataform, | |
| 2488 | + processData: false, | |
| 2489 | + contentType: false, | |
| 2490 | + }) | |
| 2491 | + .done(function (res) { | |
| 2492 | + wpsc_close_modal(); | |
| 2493 | + wpsc_get_atl_default_filters(); | |
| 2494 | + }); | |
| 2495 | +} | |
| 2496 | + | |
| 2497 | +/** | |
| 2498 | + * Get edit agent defualt filter | |
| 2499 | + */ | |
| 2500 | +function wpsc_get_edit_atl_default_filter(slug, nonce) { | |
| 2501 | + wpsc_show_modal(); | |
| 424 | 2502 | var data = { |
| 425 | - action: 'wpsc_support_agents', | |
| 426 | - setting_action : 'get_support_agents' | |
| 2503 | + action: "wpsc_get_edit_atl_default_filter", | |
| 2504 | + slug, | |
| 2505 | + _ajax_nonce: nonce, | |
| 427 | 2506 | }; |
| 2507 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2508 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 2509 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 2510 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 2511 | + wpsc_show_modal_inner_container(); | |
| 2512 | + }); | |
| 2513 | +} | |
| 428 | 2514 | |
| 429 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 430 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2515 | +/** | |
| 2516 | + * Set edit agent default filter | |
| 2517 | + */ | |
| 2518 | +function wpsc_set_edit_atl_default_filter(el, flag) { | |
| 2519 | + var label = jQuery("#wpsc-atl-df-label").val().trim(); | |
| 2520 | + if (!label) { | |
| 2521 | + alert(supportcandy.translations.req_fields_missing); | |
| 2522 | + return; | |
| 2523 | + } | |
| 2524 | + | |
| 2525 | + var form = jQuery(".wpsc-frm-edit-atl-default-filter")[0]; | |
| 2526 | + var dataform = new FormData(form); | |
| 2527 | + | |
| 2528 | + if (flag) { | |
| 2529 | + var filters = wpsc_get_condition_json("default_filters"); | |
| 2530 | + if ( | |
| 2531 | + filters.length === 0 || | |
| 2532 | + (filters.length === 1 && filters[0].length === 0) | |
| 2533 | + ) { | |
| 2534 | + alert(supportcandy.translations.req_fields_missing); | |
| 2535 | + return; | |
| 2536 | + } | |
| 2537 | + dataform.append("filters", JSON.stringify(filters)); | |
| 2538 | + } | |
| 2539 | + | |
| 2540 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2541 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2542 | + | |
| 2543 | + jQuery | |
| 2544 | + .ajax({ | |
| 2545 | + url: supportcandy.ajax_url, | |
| 2546 | + type: "POST", | |
| 2547 | + data: dataform, | |
| 2548 | + processData: false, | |
| 2549 | + contentType: false, | |
| 2550 | + }) | |
| 2551 | + .done(function (res) { | |
| 2552 | + wpsc_close_modal(); | |
| 2553 | + wpsc_get_atl_default_filters(); | |
| 2554 | + }); | |
| 2555 | +} | |
| 2556 | + | |
| 2557 | +/** | |
| 2558 | + * Delete agent default filter | |
| 2559 | + */ | |
| 2560 | +function wpsc_delete_atl_default_filter(slug, nonce) { | |
| 2561 | + var flag = confirm(supportcandy.translations.confirm); | |
| 2562 | + if (!flag) { | |
| 2563 | + return; | |
| 2564 | + } | |
| 2565 | + | |
| 2566 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2567 | + | |
| 2568 | + var data = { | |
| 2569 | + action: "wpsc_delete_atl_default_filter", | |
| 2570 | + slug, | |
| 2571 | + _ajax_nonce: nonce, | |
| 2572 | + }; | |
| 2573 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2574 | + wpsc_get_atl_default_filters(); | |
| 431 | 2575 | }); |
| 432 | 2576 | } |
| 433 | 2577 | |
| 434 | -function wpsc_get_en_general_setting(){ | |
| 435 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 436 | - jQuery('#wpsc_en_setting_general').addClass('active'); | |
| 437 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 438 | - | |
| 2578 | +/** | |
| 2579 | + * Toggle enable/disable status of a single default filter. | |
| 2580 | + * Note: the currently active default filter can't be disabled - if the | |
| 2581 | + * server refuses the disable, it sends back is_enable: 1 and we resync | |
| 2582 | + * the checkbox/row to reflect that. | |
| 2583 | + */ | |
| 2584 | +function wpsc_toggle_atl_default_filter_status(el, slug, nonce) { | |
| 2585 | + var checkbox = jQuery(el); | |
| 2586 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 2587 | + var filter = checkbox.closest(".wpsc-setting-card"); | |
| 2588 | + | |
| 439 | 2589 | var data = { |
| 440 | - action: 'wpsc_email_notifications', | |
| 441 | - setting_action : 'get_en_general_setting' | |
| 2590 | + action: "wpsc_toggle_atl_default_filter_status", | |
| 2591 | + slug, | |
| 2592 | + is_enable, | |
| 2593 | + _ajax_nonce: nonce, | |
| 442 | 2594 | }; |
| 2595 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2596 | + var saved_enable = response.data.is_enable; | |
| 2597 | + checkbox.prop("checked", !!saved_enable); | |
| 2598 | + filter.attr( | |
| 2599 | + "style", | |
| 2600 | + saved_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 2601 | + ); | |
| 2602 | + var total = jQuery(".wpsc-toggle-atl-default-filter").length; | |
| 2603 | + var checked = jQuery(".wpsc-toggle-atl-default-filter:checked").length; | |
| 2604 | + jQuery(".wpsc-toggle-all-atl-default-filters").prop( | |
| 2605 | + "checked", | |
| 2606 | + total > 0 && total === checked | |
| 2607 | + ); | |
| 2608 | + }).fail(function () { | |
| 2609 | + // Revert checkbox on failure. | |
| 2610 | + checkbox.prop("checked", !is_enable); | |
| 2611 | + }); | |
| 2612 | +} | |
| 443 | 2613 | |
| 444 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 445 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2614 | +/** | |
| 2615 | + * Get customer ticket list items | |
| 2616 | + */ | |
| 2617 | +function wpsc_get_customer_tl_items() { | |
| 2618 | + supportcandy.current_tab = "list-items"; | |
| 2619 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2620 | + jQuery( | |
| 2621 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2622 | + ).addClass("active"); | |
| 2623 | + | |
| 2624 | + window.history.replaceState( | |
| 2625 | + {}, | |
| 2626 | + null, | |
| 2627 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2628 | + supportcandy.current_section + | |
| 2629 | + "&tab=" + | |
| 2630 | + supportcandy.current_tab | |
| 2631 | + ); | |
| 2632 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2633 | + | |
| 2634 | + wpsc_scroll_top(); | |
| 2635 | + | |
| 2636 | + var data = { action: "wpsc_get_customer_tl_items" }; | |
| 2637 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2638 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2639 | + wpsc_reset_responsive_style(); | |
| 446 | 2640 | }); |
| 447 | 2641 | } |
| 448 | 2642 | |
| 449 | -function wpsc_set_en_general_settings(){ | |
| 450 | - jQuery('.wpsc_submit_wait').show(); | |
| 451 | - var dataform = new FormData(jQuery('#wpsc_frm_general_settings')[0]); | |
| 452 | - | |
| 453 | - jQuery.ajax({ | |
| 454 | - url: wpsc_admin.ajax_url, | |
| 455 | - type: 'POST', | |
| 456 | - data: dataform, | |
| 457 | - processData: false, | |
| 458 | - contentType: false | |
| 459 | - }) | |
| 460 | - .done(function (response_str) { | |
| 461 | - var response = JSON.parse(response_str); | |
| 462 | - jQuery('.wpsc_submit_wait').hide(); | |
| 463 | - if (response.sucess_status=='1') { | |
| 464 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 465 | - } | |
| 466 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 467 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 2643 | +/** | |
| 2644 | + * Get customer default filters | |
| 2645 | + */ | |
| 2646 | +function wpsc_get_ctl_default_filters() { | |
| 2647 | + supportcandy.current_tab = "default-filters"; | |
| 2648 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2649 | + jQuery( | |
| 2650 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2651 | + ).addClass("active"); | |
| 2652 | + | |
| 2653 | + window.history.replaceState( | |
| 2654 | + {}, | |
| 2655 | + null, | |
| 2656 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2657 | + supportcandy.current_section + | |
| 2658 | + "&tab=" + | |
| 2659 | + supportcandy.current_tab | |
| 2660 | + ); | |
| 2661 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2662 | + | |
| 2663 | + wpsc_scroll_top(); | |
| 2664 | + | |
| 2665 | + var data = { action: "wpsc_get_ctl_default_filters" }; | |
| 2666 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2667 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2668 | + wpsc_reset_responsive_style(); | |
| 468 | 2669 | }); |
| 469 | 2670 | } |
| 470 | 2671 | |
| 471 | -function wpsc_get_en_ticket_notifications(){ | |
| 472 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 473 | - jQuery('#wpsc_en_ticket_notifications').addClass('active'); | |
| 474 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 475 | - | |
| 476 | - var data = { | |
| 477 | - action: 'wpsc_email_notifications', | |
| 478 | - setting_action : 'get_en_ticket_notifications' | |
| 479 | - }; | |
| 2672 | +/** | |
| 2673 | + * Add customer default filter | |
| 2674 | + */ | |
| 2675 | +function wpsc_get_add_ctl_default_filter() { | |
| 2676 | + wpsc_show_modal(); | |
| 2677 | + var data = { action: "wpsc_get_add_ctl_default_filter" }; | |
| 2678 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2679 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 2680 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 2681 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 2682 | + jQuery(".wpsc-form-filter-container").append( | |
| 2683 | + jQuery(".wpsc-form-filter-snippet").html() | |
| 2684 | + ); | |
| 2685 | + jQuery(".wpsc-form-filter-container select").selectWoo(); | |
| 2686 | + wpsc_show_modal_inner_container(); | |
| 2687 | + }); | |
| 2688 | +} | |
| 480 | 2689 | |
| 481 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 482 | - jQuery('.wpsc_setting_col2').html(response); | |
| 483 | - }); | |
| 2690 | +/** | |
| 2691 | + * Set add customer default filters | |
| 2692 | + */ | |
| 2693 | +function wpsc_set_add_ctl_default_filter(el) { | |
| 2694 | + var label = jQuery("#wpsc-ctl-df-label").val().trim(); | |
| 2695 | + if (!label) { | |
| 2696 | + alert(supportcandy.translations.req_fields_missing); | |
| 2697 | + return; | |
| 2698 | + } | |
| 2699 | + | |
| 2700 | + var filters = wpsc_get_condition_json("default_filters"); | |
| 2701 | + if ( | |
| 2702 | + filters.length === 0 || | |
| 2703 | + (filters.length === 1 && filters[0].length === 0) | |
| 2704 | + ) { | |
| 2705 | + alert(supportcandy.translations.req_fields_missing); | |
| 2706 | + return; | |
| 2707 | + } | |
| 2708 | + | |
| 2709 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2710 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2711 | + | |
| 2712 | + var form = jQuery(".wpsc-frm-add-ctl-default-filter")[0]; | |
| 2713 | + var dataform = new FormData(form); | |
| 2714 | + dataform.append("filters", JSON.stringify(filters)); | |
| 2715 | + | |
| 2716 | + jQuery | |
| 2717 | + .ajax({ | |
| 2718 | + url: supportcandy.ajax_url, | |
| 2719 | + type: "POST", | |
| 2720 | + data: dataform, | |
| 2721 | + processData: false, | |
| 2722 | + contentType: false, | |
| 2723 | + }) | |
| 2724 | + .done(function (res) { | |
| 2725 | + wpsc_close_modal(); | |
| 2726 | + wpsc_get_ctl_default_filters(); | |
| 2727 | + }); | |
| 484 | 2728 | } |
| 485 | 2729 | |
| 486 | -function wpsc_get_add_ticket_notification(){ | |
| 487 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 2730 | +/** | |
| 2731 | + * Get edit customer defualt filter | |
| 2732 | + */ | |
| 2733 | +function wpsc_get_edit_ctl_default_filter(slug, nonce) { | |
| 2734 | + wpsc_show_modal(); | |
| 488 | 2735 | var data = { |
| 489 | - action: 'wpsc_email_notifications', | |
| 490 | - setting_action : 'get_add_ticket_notification' | |
| 2736 | + action: "wpsc_get_edit_ctl_default_filter", | |
| 2737 | + slug, | |
| 2738 | + _ajax_nonce: nonce, | |
| 491 | 2739 | }; |
| 492 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 493 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2740 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2741 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 2742 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 2743 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 2744 | + wpsc_show_modal_inner_container(); | |
| 494 | 2745 | }); |
| 495 | 2746 | } |
| 496 | 2747 | |
| 497 | -function wpsc_set_add_ticket_notification(){ | |
| 498 | - | |
| 499 | - var conditions = wpsc_condition_parse('wpsc_add_en_conditions'); | |
| 500 | - if(!wpsc_condition_validate(conditions)) { | |
| 501 | - alert('Incorrect Conditions'); | |
| 2748 | +/** | |
| 2749 | + * Set edit customer default filter | |
| 2750 | + */ | |
| 2751 | +function wpsc_set_edit_ctl_default_filter(el, flag) { | |
| 2752 | + var label = jQuery("#wpsc-ctl-df-label").val().trim(); | |
| 2753 | + if (!label) { | |
| 2754 | + alert(supportcandy.translations.req_fields_missing); | |
| 502 | 2755 | return; |
| 503 | 2756 | } |
| 504 | - | |
| 505 | - jQuery('.wpsc_submit_wait').show(); | |
| 506 | - var dataform = new FormData(jQuery('#wpsc_frm_general_settings')[0]); | |
| 507 | - | |
| 508 | - dataform.append('conditions',JSON.stringify(conditions)); | |
| 509 | - | |
| 510 | - jQuery.ajax({ | |
| 511 | - url: wpsc_admin.ajax_url, | |
| 512 | - type: 'POST', | |
| 513 | - data: dataform, | |
| 514 | - processData: false, | |
| 515 | - contentType: false | |
| 516 | - }) | |
| 517 | - .done(function (response_str) { | |
| 518 | - var response = JSON.parse(response_str); | |
| 519 | - if (response.sucess_status=='1') { | |
| 520 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 521 | - } else { | |
| 522 | - jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege); | |
| 2757 | + | |
| 2758 | + var form = jQuery(".wpsc-frm-edit-ctl-default-filter")[0]; | |
| 2759 | + var dataform = new FormData(form); | |
| 2760 | + | |
| 2761 | + if (flag) { | |
| 2762 | + var filters = wpsc_get_condition_json("default_filters"); | |
| 2763 | + if ( | |
| 2764 | + filters.length === 0 || | |
| 2765 | + (filters.length === 1 && filters[0].length === 0) | |
| 2766 | + ) { | |
| 2767 | + alert(supportcandy.translations.req_fields_missing); | |
| 2768 | + return; | |
| 523 | 2769 | } |
| 524 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 525 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 526 | - wpsc_get_en_ticket_notifications(); | |
| 2770 | + dataform.append("filters", JSON.stringify(filters)); | |
| 2771 | + } | |
| 2772 | + | |
| 2773 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2774 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2775 | + | |
| 2776 | + jQuery | |
| 2777 | + .ajax({ | |
| 2778 | + url: supportcandy.ajax_url, | |
| 2779 | + type: "POST", | |
| 2780 | + data: dataform, | |
| 2781 | + processData: false, | |
| 2782 | + contentType: false, | |
| 2783 | + }) | |
| 2784 | + .done(function (res) { | |
| 2785 | + wpsc_close_modal(); | |
| 2786 | + wpsc_get_ctl_default_filters(); | |
| 2787 | + }); | |
| 2788 | +} | |
| 2789 | + | |
| 2790 | +/** | |
| 2791 | + * Delete customer default filter | |
| 2792 | + */ | |
| 2793 | +function wpsc_delete_ctl_default_filter(slug, nonce) { | |
| 2794 | + var flag = confirm(supportcandy.translations.confirm); | |
| 2795 | + if (!flag) { | |
| 2796 | + return; | |
| 2797 | + } | |
| 2798 | + | |
| 2799 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2800 | + | |
| 2801 | + var data = { | |
| 2802 | + action: "wpsc_delete_ctl_default_filter", | |
| 2803 | + slug, | |
| 2804 | + _ajax_nonce: nonce, | |
| 2805 | + }; | |
| 2806 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2807 | + wpsc_get_ctl_default_filters(); | |
| 527 | 2808 | }); |
| 528 | 2809 | } |
| 529 | 2810 | |
| 530 | -function wpsc_get_edit_ticket_notification(term_id){ | |
| 531 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 2811 | +/** | |
| 2812 | + * Toggle enable/disable status of a single default filter. | |
| 2813 | + * Note: the currently active default filter can't be disabled - if the | |
| 2814 | + * server refuses the disable, it sends back is_enable: 1 and we resync | |
| 2815 | + * the checkbox/row to reflect that. | |
| 2816 | + */ | |
| 2817 | +function wpsc_toggle_ctl_default_filter_status(el, slug, nonce) { | |
| 2818 | + var checkbox = jQuery(el); | |
| 2819 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 2820 | + var filter = checkbox.closest(".wpsc-setting-card"); | |
| 2821 | + | |
| 532 | 2822 | var data = { |
| 533 | - action: 'wpsc_email_notifications', | |
| 534 | - setting_action : 'get_edit_ticket_notification', | |
| 535 | - term_id : term_id | |
| 2823 | + action: "wpsc_toggle_ctl_default_filter_status", | |
| 2824 | + slug, | |
| 2825 | + is_enable, | |
| 2826 | + _ajax_nonce: nonce, | |
| 536 | 2827 | }; |
| 537 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 538 | - jQuery('.wpsc_setting_col2').html(response); | |
| 2828 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2829 | + var saved_enable = response.data.is_enable; | |
| 2830 | + checkbox.prop("checked", !!saved_enable); | |
| 2831 | + filter.attr( | |
| 2832 | + "style", | |
| 2833 | + saved_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 2834 | + ); | |
| 2835 | + }).fail(function () { | |
| 2836 | + // Revert checkbox on failure. | |
| 2837 | + checkbox.prop("checked", !is_enable); | |
| 539 | 2838 | }); |
| 540 | 2839 | } |
| 541 | 2840 | |
| 542 | -function wpsc_set_edit_ticket_notification(){ | |
| 543 | - | |
| 544 | - var conditions = wpsc_condition_parse('wpsc_edit_en_conditions'); | |
| 545 | - if(!wpsc_condition_validate(conditions)) { | |
| 546 | - alert('Incorrect Conditions'); | |
| 2841 | +/** | |
| 2842 | + * Set add new customer list items | |
| 2843 | + */ | |
| 2844 | +function wpsc_set_add_customer_tl_item(el) { | |
| 2845 | + var form = jQuery(".frm-add-customer-tl-items")[0]; | |
| 2846 | + var dataform = new FormData(form); | |
| 2847 | + | |
| 2848 | + var cf_id = dataform.getAll("cf_id[]"); | |
| 2849 | + if (!cf_id.length) { | |
| 2850 | + alert(supportcandy.translations.req_fields_missing); | |
| 547 | 2851 | return; |
| 548 | 2852 | } |
| 549 | - | |
| 550 | - jQuery('.wpsc_submit_wait').show(); | |
| 551 | - var dataform = new FormData(jQuery('#wpsc_frm_general_settings')[0]); | |
| 552 | - | |
| 553 | - dataform.append('conditions',JSON.stringify(conditions)); | |
| 554 | - | |
| 555 | - jQuery.ajax({ | |
| 556 | - url: wpsc_admin.ajax_url, | |
| 557 | - type: 'POST', | |
| 558 | - data: dataform, | |
| 559 | - processData: false, | |
| 560 | - contentType: false | |
| 561 | - }) | |
| 562 | - .done(function (response_str) { | |
| 563 | - var response = JSON.parse(response_str); | |
| 564 | - if (response.sucess_status=='1') { | |
| 565 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 566 | - } | |
| 567 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 568 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 569 | - wpsc_get_en_ticket_notifications(); | |
| 2853 | + | |
| 2854 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2855 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2856 | + jQuery | |
| 2857 | + .ajax({ | |
| 2858 | + url: supportcandy.ajax_url, | |
| 2859 | + type: "POST", | |
| 2860 | + data: dataform, | |
| 2861 | + processData: false, | |
| 2862 | + contentType: false, | |
| 2863 | + }) | |
| 2864 | + .done(function (res) { | |
| 2865 | + wpsc_close_modal(); | |
| 2866 | + wpsc_get_customer_tl_items(); | |
| 2867 | + }); | |
| 2868 | +} | |
| 2869 | + | |
| 2870 | +/** | |
| 2871 | + * Set delete customer ticket list item | |
| 2872 | + */ | |
| 2873 | +function wpsc_delete_customer_tl_item(slug, nonce) { | |
| 2874 | + if (confirm(supportcandy.translations.confirm)) { | |
| 2875 | + var data = { | |
| 2876 | + action: "wpsc_delete_customer_tl_item", | |
| 2877 | + slug: slug, | |
| 2878 | + _ajax_nonce: nonce, | |
| 2879 | + }; | |
| 2880 | + | |
| 2881 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2882 | + jQuery(slug).text(supportcandy.translations.please_wait); | |
| 2883 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 2884 | + wpsc_get_customer_tl_items(); | |
| 2885 | + }); | |
| 2886 | + } else { | |
| 2887 | + return false; | |
| 2888 | + } | |
| 2889 | +} | |
| 2890 | + | |
| 2891 | +/** | |
| 2892 | + * Get customer filter items | |
| 2893 | + */ | |
| 2894 | +function wpsc_get_customer_filter_items() { | |
| 2895 | + supportcandy.current_tab = "filter-items"; | |
| 2896 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2897 | + jQuery( | |
| 2898 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2899 | + ).addClass("active"); | |
| 2900 | + | |
| 2901 | + window.history.replaceState( | |
| 2902 | + {}, | |
| 2903 | + null, | |
| 2904 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 2905 | + supportcandy.current_section + | |
| 2906 | + "&tab=" + | |
| 2907 | + supportcandy.current_tab | |
| 2908 | + ); | |
| 2909 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 2910 | + | |
| 2911 | + wpsc_scroll_top(); | |
| 2912 | + | |
| 2913 | + var data = { action: "wpsc_get_customer_filter_items" }; | |
| 2914 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2915 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 2916 | + wpsc_reset_responsive_style(); | |
| 570 | 2917 | }); |
| 571 | 2918 | } |
| 572 | 2919 | |
| 573 | -function wpsc_clone_ticket_notification(term_id, nonce){ | |
| 574 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 575 | - var data = { | |
| 576 | - action: 'wpsc_email_notifications', | |
| 577 | - setting_action : 'clone_ticket_notification', | |
| 578 | - term_id : term_id, | |
| 579 | - _ajax_nonce: nonce | |
| 580 | - }; | |
| 581 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 582 | - var response = JSON.parse(response_str); | |
| 583 | - if (response.sucess_status=='1') { | |
| 584 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 585 | - } else { | |
| 586 | - jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege); | |
| 587 | - } | |
| 588 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 589 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 590 | - wpsc_get_en_ticket_notifications(); | |
| 2920 | +/** | |
| 2921 | + * Get add customer ticket list filter items modal UI | |
| 2922 | + */ | |
| 2923 | +function wpsc_get_add_ctl_filter_item() { | |
| 2924 | + wpsc_show_modal(); | |
| 2925 | + var data = { action: "wpsc_get_add_ctl_filter_item" }; | |
| 2926 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 2927 | + // Set to modal. | |
| 2928 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 2929 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 2930 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 2931 | + // Display modal. | |
| 2932 | + wpsc_show_modal_inner_container(); | |
| 591 | 2933 | }); |
| 592 | 2934 | } |
| 593 | 2935 | |
| 594 | -function wpsc_delete_ticket_notification(term_id, nonce){ | |
| 595 | - if(confirm(wpsc_admin.are_you_sure)){ | |
| 596 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 2936 | +/** | |
| 2937 | + * Set add new customer list items | |
| 2938 | + */ | |
| 2939 | +function wpsc_set_add_ctl_filter_item(el) { | |
| 2940 | + var form = jQuery(".frm-add-customer-tl-filter-items")[0]; | |
| 2941 | + var dataform = new FormData(form); | |
| 2942 | + | |
| 2943 | + var cf_id = dataform.getAll("customer-tl-filter-id[]"); | |
| 2944 | + if (!cf_id.length) { | |
| 2945 | + alert(supportcandy.translations.req_fields_missing); | |
| 2946 | + return; | |
| 2947 | + } | |
| 2948 | + | |
| 2949 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 2950 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 2951 | + jQuery | |
| 2952 | + .ajax({ | |
| 2953 | + url: supportcandy.ajax_url, | |
| 2954 | + type: "POST", | |
| 2955 | + data: dataform, | |
| 2956 | + processData: false, | |
| 2957 | + contentType: false, | |
| 2958 | + }) | |
| 2959 | + .done(function (res) { | |
| 2960 | + wpsc_close_modal(); | |
| 2961 | + wpsc_get_customer_filter_items(); | |
| 2962 | + }); | |
| 2963 | +} | |
| 2964 | + | |
| 2965 | +/** | |
| 2966 | + * Get delete customer ticket list item | |
| 2967 | + * | |
| 2968 | + * @param {*} slug | |
| 2969 | + */ | |
| 2970 | +function wpsc_delete_ctl_filter_item(slug, nonce) { | |
| 2971 | + if (confirm(supportcandy.translations.confirm)) { | |
| 597 | 2972 | var data = { |
| 598 | - action: 'wpsc_email_notifications', | |
| 599 | - setting_action : 'delete_ticket_notification', | |
| 600 | - term_id : term_id, | |
| 601 | - _ajax_nonce: nonce | |
| 2973 | + action: "wpsc_delete_ctl_filter_item", | |
| 2974 | + slug: slug, | |
| 2975 | + _ajax_nonce: nonce, | |
| 602 | 2976 | }; |
| 603 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 604 | - var response = JSON.parse(response_str); | |
| 605 | - if (response.sucess_status=='1') { | |
| 606 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 607 | - } else { | |
| 608 | - jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege); | |
| 609 | - } | |
| 610 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 611 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 612 | - wpsc_get_en_ticket_notifications(); | |
| 2977 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 2978 | + wpsc_get_customer_filter_items(); | |
| 613 | 2979 | }); |
| 614 | 2980 | } |
| 615 | 2981 | } |
| 616 | 2982 | |
| 617 | -/* | |
| 618 | - * Appearance General Settings | |
| 2983 | +/** | |
| 2984 | + * Get Thank You Page Settings | |
| 619 | 2985 | */ |
| 620 | -function wpsc_get_appearance_general_settings(){ | |
| 621 | - | |
| 622 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 623 | - jQuery('#wpsc_appearance_general').addClass('active'); | |
| 624 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 625 | - | |
| 2986 | +function wpsc_get_gs_thankyou() { | |
| 2987 | + supportcandy.current_tab = "thank-you-page"; | |
| 2988 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 2989 | + jQuery( | |
| 2990 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 2991 | + ).addClass("active"); | |
| 2992 | + | |
| 2993 | + window.history.replaceState( | |
| 2994 | + {}, | |
| 2995 | + null, | |
| 2996 | + "admin.php?page=wpsc-settings§ion=" + | |
| 2997 | + supportcandy.current_section + | |
| 2998 | + "&tab=" + | |
| 2999 | + supportcandy.current_tab | |
| 3000 | + ); | |
| 3001 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3002 | + | |
| 3003 | + wpsc_scroll_top(); | |
| 3004 | + | |
| 3005 | + var data = { action: "wpsc_get_gs_thankyou" }; | |
| 3006 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3007 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3008 | + wpsc_reset_responsive_style(); | |
| 3009 | + }); | |
| 3010 | +} | |
| 3011 | + | |
| 3012 | +/** | |
| 3013 | + * Reset Thankyou page settings | |
| 3014 | + */ | |
| 3015 | +function wpsc_reset_gs_thankyou(el, nonce) { | |
| 3016 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3017 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3018 | + var data = { action: "wpsc_reset_gs_thankyou", _ajax_nonce: nonce }; | |
| 3019 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3020 | + wpsc_get_gs_thankyou(); | |
| 3021 | + }); | |
| 3022 | +} | |
| 3023 | + | |
| 3024 | +/** | |
| 3025 | + * Set Thankyou Page Settings | |
| 3026 | + */ | |
| 3027 | +function wpsc_set_gs_thankyou(el) { | |
| 3028 | + var form = jQuery(".wpsc-frm-gs-thankyoupage")[0]; | |
| 3029 | + var dataform = new FormData(form); | |
| 3030 | + | |
| 3031 | + var is_tinymce = | |
| 3032 | + typeof tinyMCE !== "undefined" && | |
| 3033 | + tinyMCE.get("wpsc-html-agent") && | |
| 3034 | + !tinyMCE.get("wpsc-html-agent").isHidden(); | |
| 3035 | + var description = is_tinymce | |
| 3036 | + ? tinyMCE.get("wpsc-html-agent").getContent().trim() | |
| 3037 | + : jQuery("#wpsc-html-agent").val(); | |
| 3038 | + dataform.append("html-agent", description); | |
| 3039 | + | |
| 3040 | + var is_tinymce = | |
| 3041 | + typeof tinyMCE !== "undefined" && | |
| 3042 | + tinyMCE.get("wpsc-html-customer") && | |
| 3043 | + !tinyMCE.get("wpsc-html-customer").isHidden(); | |
| 3044 | + description = is_tinymce | |
| 3045 | + ? tinyMCE.get("wpsc-html-customer").getContent().trim() | |
| 3046 | + : jQuery("#wpsc-html-customer").val(); | |
| 3047 | + dataform.append("html-customer", description); | |
| 3048 | + | |
| 3049 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3050 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3051 | + jQuery | |
| 3052 | + .ajax({ | |
| 3053 | + url: supportcandy.ajax_url, | |
| 3054 | + type: "POST", | |
| 3055 | + data: dataform, | |
| 3056 | + processData: false, | |
| 3057 | + contentType: false, | |
| 3058 | + }) | |
| 3059 | + .done(function (res) { | |
| 3060 | + wpsc_get_gs_thankyou(); | |
| 3061 | + }); | |
| 3062 | +} | |
| 3063 | + | |
| 3064 | +/** | |
| 3065 | + * File attachment settings | |
| 3066 | + */ | |
| 3067 | +function wpsc_get_gs_file_attachments() { | |
| 3068 | + supportcandy.current_tab = "file-attachments"; | |
| 3069 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 3070 | + jQuery( | |
| 3071 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3072 | + ).addClass("active"); | |
| 3073 | + | |
| 3074 | + window.history.replaceState( | |
| 3075 | + {}, | |
| 3076 | + null, | |
| 3077 | + "admin.php?page=wpsc-settings§ion=" + | |
| 3078 | + supportcandy.current_section + | |
| 3079 | + "&tab=" + | |
| 3080 | + supportcandy.current_tab | |
| 3081 | + ); | |
| 3082 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3083 | + | |
| 3084 | + wpsc_scroll_top(); | |
| 3085 | + | |
| 3086 | + var data = { action: "wpsc_get_gs_file_attachments" }; | |
| 3087 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3088 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3089 | + wpsc_reset_responsive_style(); | |
| 3090 | + }); | |
| 3091 | +} | |
| 3092 | + | |
| 3093 | +/** | |
| 3094 | + * Save page settings | |
| 3095 | + */ | |
| 3096 | +function wpsc_set_gs_file_attachments(el) { | |
| 3097 | + var form = jQuery(".wpsc-frm-gs-fa")[0]; | |
| 3098 | + var dataform = new FormData(form); | |
| 3099 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3100 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3101 | + jQuery | |
| 3102 | + .ajax({ | |
| 3103 | + url: supportcandy.ajax_url, | |
| 3104 | + type: "POST", | |
| 3105 | + data: dataform, | |
| 3106 | + processData: false, | |
| 3107 | + contentType: false, | |
| 3108 | + }) | |
| 3109 | + .done(function (res) { | |
| 3110 | + wpsc_get_gs_file_attachments(); | |
| 3111 | + }); | |
| 3112 | +} | |
| 3113 | + | |
| 3114 | +/** | |
| 3115 | + * Reset file attachments | |
| 3116 | + */ | |
| 3117 | +function wpsc_reset_gs_file_attachments(el, nonce) { | |
| 3118 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3119 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3120 | + var data = { action: "wpsc_reset_gs_file_attachments", _ajax_nonce: nonce }; | |
| 3121 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3122 | + wpsc_get_gs_file_attachments(); | |
| 3123 | + }); | |
| 3124 | +} | |
| 3125 | + | |
| 3126 | +/** | |
| 3127 | + * Get email notifications general setting | |
| 3128 | + */ | |
| 3129 | +function wpsc_get_en_general_setting(is_humbargar = false) { | |
| 3130 | + if (is_humbargar) { | |
| 3131 | + wpsc_toggle_humbargar(); | |
| 3132 | + } | |
| 3133 | + | |
| 3134 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 3135 | + jQuery( | |
| 3136 | + ".wpsc-setting-nav.general-settings, .wpsc-humbargar-menu-item.general-settings" | |
| 3137 | + ).addClass("active"); | |
| 3138 | + jQuery(".wpsc-humbargar-title").html( | |
| 3139 | + supportcandy.humbargar_titles.general_settings | |
| 3140 | + ); | |
| 3141 | + | |
| 3142 | + window.history.replaceState( | |
| 3143 | + {}, | |
| 3144 | + null, | |
| 3145 | + "admin.php?page=wpsc-email-notifications§ion=general-settings" | |
| 3146 | + ); | |
| 3147 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 3148 | + | |
| 3149 | + wpsc_scroll_top(); | |
| 3150 | + | |
| 3151 | + var data = { action: "wpsc_get_en_general_setting" }; | |
| 3152 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3153 | + jQuery(".wpsc-setting-body").html(response); | |
| 3154 | + wpsc_reset_responsive_style(); | |
| 3155 | + }); | |
| 3156 | +} | |
| 3157 | + | |
| 3158 | +/** | |
| 3159 | + * Save email notification general settings | |
| 3160 | + */ | |
| 3161 | +function wpsc_set_en_general(el) { | |
| 3162 | + var form = jQuery(".wpsc-frm-en-general")[0]; | |
| 3163 | + var dataform = new FormData(form); | |
| 3164 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3165 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3166 | + jQuery | |
| 3167 | + .ajax({ | |
| 3168 | + url: supportcandy.ajax_url, | |
| 3169 | + type: "POST", | |
| 3170 | + data: dataform, | |
| 3171 | + processData: false, | |
| 3172 | + contentType: false, | |
| 3173 | + }) | |
| 3174 | + .done(function (res) { | |
| 3175 | + wpsc_get_en_general_setting(); | |
| 3176 | + }); | |
| 3177 | +} | |
| 3178 | + | |
| 3179 | +/** | |
| 3180 | + * Reset email notification general settings | |
| 3181 | + */ | |
| 3182 | +function wpsc_reset_en_general(el, nonce) { | |
| 3183 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3184 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3185 | + var data = { action: "wpsc_reset_en_general", _ajax_nonce: nonce }; | |
| 3186 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3187 | + wpsc_get_en_general_setting(); | |
| 3188 | + }); | |
| 3189 | +} | |
| 3190 | + | |
| 3191 | +/** | |
| 3192 | + * Get ticket notifications setting | |
| 3193 | + */ | |
| 3194 | +function wpsc_get_ticket_notifications(is_humbargar = false) { | |
| 3195 | + if (is_humbargar) { | |
| 3196 | + wpsc_toggle_humbargar(); | |
| 3197 | + } | |
| 3198 | + | |
| 3199 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 3200 | + jQuery( | |
| 3201 | + ".wpsc-setting-nav.ticket-notifications, .wpsc-humbargar-menu-item.ticket-notifications" | |
| 3202 | + ).addClass("active"); | |
| 3203 | + jQuery(".wpsc-humbargar-title").html( | |
| 3204 | + supportcandy.humbargar_titles.ticket_notifications | |
| 3205 | + ); | |
| 3206 | + | |
| 3207 | + window.history.replaceState( | |
| 3208 | + {}, | |
| 3209 | + null, | |
| 3210 | + "admin.php?page=wpsc-email-notifications§ion=ticket-notifications" | |
| 3211 | + ); | |
| 3212 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 3213 | + | |
| 3214 | + wpsc_scroll_top(); | |
| 3215 | + | |
| 3216 | + var data = { action: "wpsc_get_ticket_notifications" }; | |
| 3217 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3218 | + jQuery(".wpsc-setting-body").html(response); | |
| 3219 | + wpsc_reset_responsive_style(); | |
| 3220 | + }); | |
| 3221 | +} | |
| 3222 | + | |
| 3223 | +/** | |
| 3224 | + * Set add ticket notification | |
| 3225 | + */ | |
| 3226 | +function wpsc_en_set_add_ticket_notification(el) { | |
| 3227 | + var title = jQuery(el) | |
| 3228 | + .closest(".modal") | |
| 3229 | + .find("input[name=title]") | |
| 3230 | + .val() | |
| 3231 | + .trim(); | |
| 3232 | + if (!title) { | |
| 3233 | + alert(supportcandy.translations.req_fields_missing); | |
| 3234 | + return; | |
| 3235 | + } | |
| 3236 | + | |
| 3237 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3238 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3239 | + | |
| 3240 | + var form = jQuery(".wpsc-frm-add-en")[0]; | |
| 3241 | + var dataform = new FormData(form); | |
| 3242 | + jQuery | |
| 3243 | + .ajax({ | |
| 3244 | + url: supportcandy.ajax_url, | |
| 3245 | + type: "POST", | |
| 3246 | + data: dataform, | |
| 3247 | + processData: false, | |
| 3248 | + contentType: false, | |
| 3249 | + }) | |
| 3250 | + .done(function (response) { | |
| 3251 | + wpsc_close_modal(); | |
| 3252 | + wpsc_en_get_edit_ticket_notification(response.index, response.nonce); | |
| 3253 | + }); | |
| 3254 | +} | |
| 3255 | + | |
| 3256 | +/** | |
| 3257 | + * Get edit email notification | |
| 3258 | + * | |
| 3259 | + * @param {int} id | |
| 3260 | + */ | |
| 3261 | +function wpsc_en_get_edit_ticket_notification(template_id, nonce) { | |
| 3262 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 626 | 3263 | var data = { |
| 627 | - action: 'wpsc_appearance_settings', | |
| 628 | - setting_action : 'get_appearance_general_settings' | |
| 3264 | + action: "wpsc_en_get_edit_ticket_notification", | |
| 3265 | + template_id, | |
| 3266 | + _ajax_nonce: nonce, | |
| 629 | 3267 | }; |
| 3268 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 3269 | + jQuery(".wpsc-setting-section-body").html(res); | |
| 3270 | + }); | |
| 3271 | +} | |
| 630 | 3272 | |
| 631 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 632 | - jQuery('.wpsc_setting_col2').html(response); | |
| 3273 | +/** | |
| 3274 | + * Set edit email notification | |
| 3275 | + */ | |
| 3276 | +function wpsc_en_set_edit_ticket_notification() { | |
| 3277 | + var form = jQuery(".wpsc-frm-edit-en")[0]; | |
| 3278 | + var dataform = new FormData(form); | |
| 3279 | + | |
| 3280 | + var title = dataform.get("title").trim(); | |
| 3281 | + if (!title) { | |
| 3282 | + alert(supportcandy.translations.req_fields_missing); | |
| 3283 | + return; | |
| 3284 | + } | |
| 3285 | + | |
| 3286 | + var subject = dataform.get("subject").trim(); | |
| 3287 | + if (!subject) { | |
| 3288 | + alert(supportcandy.translations.req_fields_missing); | |
| 3289 | + return; | |
| 3290 | + } | |
| 3291 | + | |
| 3292 | + var is_tinymce = | |
| 3293 | + typeof tinyMCE != "undefined" && | |
| 3294 | + tinyMCE.activeEditor && | |
| 3295 | + !tinyMCE.activeEditor.isHidden(); | |
| 3296 | + var body = is_tinymce | |
| 3297 | + ? tinyMCE.get("wpsc-en-body").getContent().trim() | |
| 3298 | + : dataform.get("body").trim(); | |
| 3299 | + dataform.append("body", body); | |
| 3300 | + | |
| 3301 | + if (!body) { | |
| 3302 | + alert(supportcandy.translations.req_fields_missing); | |
| 3303 | + return; | |
| 3304 | + } | |
| 3305 | + | |
| 3306 | + // to. | |
| 3307 | + var toGeneral = dataform.getAll("to[general-recipients][]"); | |
| 3308 | + var toRoles = dataform.getAll("to[agent-roles][]"); | |
| 3309 | + var toCustom = dataform.get("to[custom]").trim(); | |
| 3310 | + if (!(toGeneral.length || toRoles.length || toCustom)) { | |
| 3311 | + alert(supportcandy.translations.req_fields_missing); | |
| 3312 | + return; | |
| 3313 | + } | |
| 3314 | + | |
| 3315 | + dataform.append( | |
| 3316 | + "conditions", | |
| 3317 | + JSON.stringify(wpsc_get_condition_json("conditions")) | |
| 3318 | + ); | |
| 3319 | + | |
| 3320 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3321 | + jQuery | |
| 3322 | + .ajax({ | |
| 3323 | + url: supportcandy.ajax_url, | |
| 3324 | + type: "POST", | |
| 3325 | + data: dataform, | |
| 3326 | + processData: false, | |
| 3327 | + contentType: false, | |
| 3328 | + }) | |
| 3329 | + .done(function (res) { | |
| 3330 | + wpsc_get_ticket_notifications(); | |
| 3331 | + }); | |
| 3332 | +} | |
| 3333 | + | |
| 3334 | +/** | |
| 3335 | + * Get clone ticket notification | |
| 3336 | + * | |
| 3337 | + * @param {INT} template_id | |
| 3338 | + */ | |
| 3339 | +function wpsc_en_get_clone_ticket_notification(template_id, nonce) { | |
| 3340 | + wpsc_show_modal(); | |
| 3341 | + var data = { | |
| 3342 | + action: "wpsc_en_get_clone_ticket_notification", | |
| 3343 | + template_id, | |
| 3344 | + _ajax_nonce: nonce, | |
| 3345 | + }; | |
| 3346 | + | |
| 3347 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3348 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 3349 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 3350 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 3351 | + | |
| 3352 | + wpsc_show_modal_inner_container(); | |
| 633 | 3353 | }); |
| 634 | - | |
| 635 | 3354 | } |
| 636 | 3355 | |
| 637 | -function wpsc_set_appearance_general_settings(){ | |
| 638 | - | |
| 639 | - jQuery('.wpsc_submit_wait').show(); | |
| 640 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_general_settings')[0]); | |
| 641 | - | |
| 642 | - jQuery.ajax({ | |
| 643 | - url: wpsc_admin.ajax_url, | |
| 644 | - type: 'POST', | |
| 645 | - data: dataform, | |
| 646 | - processData: false, | |
| 647 | - contentType: false | |
| 648 | - }) | |
| 649 | - .done(function (response_str) { | |
| 650 | - var response = JSON.parse(response_str); | |
| 651 | - jQuery('.wpsc_submit_wait').hide(); | |
| 652 | - if (response.sucess_status=='1') { | |
| 653 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 654 | - } | |
| 655 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 656 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 657 | - }); | |
| 658 | - | |
| 3356 | +/** | |
| 3357 | + * Set clone ticket notification | |
| 3358 | + */ | |
| 3359 | +function wpsc_en_set_clone_ticket_notification(el) { | |
| 3360 | + var form = jQuery(".wpsc-en-add-clone")[0]; | |
| 3361 | + var dataform = new FormData(form); | |
| 3362 | + | |
| 3363 | + if (dataform.get("title").trim() == "") { | |
| 3364 | + alert(supportcandy.translations.req_fields_missing); | |
| 3365 | + return; | |
| 3366 | + } | |
| 3367 | + | |
| 3368 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3369 | + jQuery | |
| 3370 | + .ajax({ | |
| 3371 | + url: supportcandy.ajax_url, | |
| 3372 | + type: "POST", | |
| 3373 | + data: dataform, | |
| 3374 | + processData: false, | |
| 3375 | + contentType: false, | |
| 3376 | + }) | |
| 3377 | + .done(function (response) { | |
| 3378 | + wpsc_close_modal(); | |
| 3379 | + wpsc_en_get_edit_ticket_notification(response.index, response.nonce); | |
| 3380 | + }); | |
| 659 | 3381 | } |
| 660 | 3382 | |
| 661 | -/* | |
| 662 | - * Appearance General reset Settings | |
| 3383 | +/** | |
| 3384 | + * Disable ticket notification | |
| 663 | 3385 | */ |
| 664 | -function wpsc_reset_default_general_settings(nonce) { | |
| 665 | - | |
| 3386 | +function wpsc_en_enable_disable_template(template_id, status, nonce) { | |
| 666 | 3387 | var data = { |
| 667 | - action: 'wpsc_appearance_settings', | |
| 668 | - setting_action : 'get_reset_default_general_settings', | |
| 669 | - _ajax_nonce: nonce | |
| 3388 | + action: "wpsc_en_enable_disable_template", | |
| 3389 | + template_id, | |
| 3390 | + status, | |
| 3391 | + _ajax_nonce: nonce, | |
| 670 | 3392 | }; |
| 671 | 3393 | |
| 672 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 673 | - var response = JSON.parse(response_str); | |
| 674 | - if (response.sucess_status=='1') { | |
| 675 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 676 | - } | |
| 677 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 678 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 679 | - wpsc_get_appearance_general_settings() | |
| 3394 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3395 | + wpsc_get_ticket_notifications(); | |
| 680 | 3396 | }); |
| 681 | 3397 | } |
| 682 | 3398 | |
| 683 | -/* | |
| 684 | - * Appearance Ticket List Settings | |
| 3399 | +/** | |
| 3400 | + * Delete email notification | |
| 3401 | + * | |
| 3402 | + * @param {int} template_id | |
| 685 | 3403 | */ |
| 686 | -function wpsc_get_appearance_ticket_list(){ | |
| 687 | - | |
| 688 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 689 | - jQuery('#wpsc_appearance_ticket_list').addClass('active'); | |
| 690 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 691 | - | |
| 3404 | +function wpsc_en_delete_ticket_notification(template_id, nonce) { | |
| 3405 | + var flag = confirm(supportcandy.translations.confirm); | |
| 3406 | + if (!flag) { | |
| 3407 | + return; | |
| 3408 | + } | |
| 3409 | + | |
| 692 | 3410 | var data = { |
| 693 | - action: 'wpsc_appearance_settings', | |
| 694 | - setting_action : 'get_appearance_ticket_list' | |
| 3411 | + action: "wpsc_en_delete_ticket_notification", | |
| 3412 | + template_id, | |
| 3413 | + _ajax_nonce: nonce, | |
| 695 | 3414 | }; |
| 3415 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 3416 | + wpsc_get_ticket_notifications(); | |
| 3417 | + }); | |
| 3418 | +} | |
| 696 | 3419 | |
| 697 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 698 | - jQuery('.wpsc_setting_col2').html(response); | |
| 3420 | +/** | |
| 3421 | + * Get miscellaneous settings | |
| 3422 | + * | |
| 3423 | + * @param {*} is_humbargar | |
| 3424 | + */ | |
| 3425 | +function wpsc_get_miscellaneous_settings(is_humbargar = false) { | |
| 3426 | + if (is_humbargar) { | |
| 3427 | + wpsc_toggle_humbargar(); | |
| 3428 | + } | |
| 3429 | + | |
| 3430 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 3431 | + jQuery( | |
| 3432 | + ".wpsc-setting-nav.miscellaneous-settings, .wpsc-humbargar-menu-item.miscellaneous-settings" | |
| 3433 | + ).addClass("active"); | |
| 3434 | + jQuery(".wpsc-humbargar-title").html( | |
| 3435 | + supportcandy.humbargar_titles.miscellaneous_settings | |
| 3436 | + ); | |
| 3437 | + | |
| 3438 | + if (supportcandy.current_section !== "miscellaneous-settings") { | |
| 3439 | + supportcandy.current_section = "miscellaneous-settings"; | |
| 3440 | + supportcandy.current_tab = "term-and-conditions"; | |
| 3441 | + } | |
| 3442 | + | |
| 3443 | + window.history.replaceState( | |
| 3444 | + {}, | |
| 3445 | + null, | |
| 3446 | + "admin.php?page=wpsc-settings§ion=miscellaneous-settings" | |
| 3447 | + ); | |
| 3448 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 3449 | + | |
| 3450 | + wpsc_scroll_top(); | |
| 3451 | + | |
| 3452 | + var data = { action: "wpsc_get_miscellaneous_settings" }; | |
| 3453 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3454 | + jQuery(".wpsc-setting-body").html(response); | |
| 3455 | + wpsc_reset_responsive_style(); | |
| 3456 | + jQuery( | |
| 3457 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3458 | + ).trigger("click"); | |
| 699 | 3459 | }); |
| 700 | - | |
| 701 | 3460 | } |
| 702 | 3461 | |
| 703 | -function wpsc_set_appearance_ticket_list_settings(){ | |
| 704 | - | |
| 705 | - jQuery('.wpsc_submit_wait').show(); | |
| 706 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_ticket_list_settings')[0]); | |
| 707 | - | |
| 708 | - jQuery.ajax({ | |
| 709 | - url: wpsc_admin.ajax_url, | |
| 710 | - type: 'POST', | |
| 711 | - data: dataform, | |
| 712 | - processData: false, | |
| 713 | - contentType: false | |
| 714 | - }) | |
| 715 | - .done(function (response_str) { | |
| 716 | - var response = JSON.parse(response_str); | |
| 717 | - jQuery('.wpsc_submit_wait').hide(); | |
| 718 | - if (response.sucess_status=='1') { | |
| 719 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 720 | - } | |
| 721 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 722 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 3462 | +/** | |
| 3463 | + * Get ticket widget | |
| 3464 | + */ | |
| 3465 | +function wpsc_get_ticket_widget(is_humbargar) { | |
| 3466 | + if (is_humbargar) { | |
| 3467 | + wpsc_toggle_humbargar(); | |
| 3468 | + } | |
| 3469 | + | |
| 3470 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 3471 | + jQuery( | |
| 3472 | + ".wpsc-setting-nav.ticket-widgets, .wpsc-humbargar-menu-item.ticket-widgets" | |
| 3473 | + ).addClass("active"); | |
| 3474 | + jQuery(".wpsc-humbargar-title").html( | |
| 3475 | + supportcandy.humbargar_titles.ticket_widget | |
| 3476 | + ); | |
| 3477 | + | |
| 3478 | + window.history.replaceState( | |
| 3479 | + {}, | |
| 3480 | + null, | |
| 3481 | + "admin.php?page=wpsc-settings§ion=ticket-widgets" | |
| 3482 | + ); | |
| 3483 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 3484 | + | |
| 3485 | + wpsc_scroll_top(); | |
| 3486 | + | |
| 3487 | + var data = { action: "wpsc_get_ticket_widget" }; | |
| 3488 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3489 | + jQuery(".wpsc-setting-body").html(response); | |
| 3490 | + wpsc_reset_responsive_style(); | |
| 723 | 3491 | }); |
| 724 | 3492 | } |
| 725 | 3493 | |
| 726 | -/* | |
| 727 | - * Appearance Ticket List reset Settings | |
| 3494 | +/** | |
| 3495 | + * Get Terms and conditions settings | |
| 728 | 3496 | */ |
| 729 | -function wpsc_reset_default_ticket_list_settings(nonce) { | |
| 3497 | +function wpsc_get_ms_term_and_conditions() { | |
| 3498 | + supportcandy.current_tab = "term-and-conditions"; | |
| 3499 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 3500 | + jQuery( | |
| 3501 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3502 | + ).addClass("active"); | |
| 730 | 3503 | |
| 3504 | + window.history.replaceState( | |
| 3505 | + {}, | |
| 3506 | + null, | |
| 3507 | + "admin.php?page=wpsc-settings§ion=" + | |
| 3508 | + supportcandy.current_section + | |
| 3509 | + "&tab=" + | |
| 3510 | + supportcandy.current_tab | |
| 3511 | + ); | |
| 3512 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3513 | + | |
| 3514 | + wpsc_scroll_top(); | |
| 3515 | + var data = { action: "wpsc_get_ms_term_and_conditions" }; | |
| 3516 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3517 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3518 | + wpsc_reset_responsive_style(); | |
| 3519 | + }); | |
| 3520 | +} | |
| 3521 | + | |
| 3522 | +/** | |
| 3523 | + * Get agent view settings | |
| 3524 | + */ | |
| 3525 | +function wpsc_tl_ms_get_agent_view() { | |
| 3526 | + supportcandy.current_tab = "agent-view"; | |
| 3527 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 3528 | + jQuery( | |
| 3529 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3530 | + ).addClass("active"); | |
| 3531 | + | |
| 3532 | + window.history.replaceState( | |
| 3533 | + {}, | |
| 3534 | + null, | |
| 3535 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 3536 | + supportcandy.current_section + | |
| 3537 | + "&tab=" + | |
| 3538 | + supportcandy.current_tab | |
| 3539 | + ); | |
| 3540 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3541 | + | |
| 3542 | + wpsc_scroll_top(); | |
| 3543 | + | |
| 3544 | + var data = { action: "wpsc_tl_ms_get_agent_view" }; | |
| 3545 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3546 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3547 | + wpsc_reset_responsive_style(); | |
| 3548 | + }); | |
| 3549 | +} | |
| 3550 | + | |
| 3551 | +/** | |
| 3552 | + * Save terms and conditions | |
| 3553 | + * | |
| 3554 | + * @param {*} el | |
| 3555 | + */ | |
| 3556 | +function wpsc_set_ms_term_and_conditions(el) { | |
| 3557 | + var form = jQuery(".wpsc-frm-ms-tandc")[0]; | |
| 3558 | + var dataform = new FormData(form); | |
| 3559 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3560 | + var is_tinymce_ct = | |
| 3561 | + typeof tinyMCE != "undefined" && | |
| 3562 | + tinyMCE.get("tandc-text") && | |
| 3563 | + !tinyMCE.get("tandc-text").isHidden(); | |
| 3564 | + | |
| 3565 | + if (is_tinymce_ct) { | |
| 3566 | + var description = tinyMCE.get("tandc-text").getContent().trim(); | |
| 3567 | + } else { | |
| 3568 | + var description = jQuery("#tandc-text").val(); | |
| 3569 | + } | |
| 3570 | + dataform.append("tandc-text", description); | |
| 3571 | + | |
| 3572 | + var is_tinymce_reg = | |
| 3573 | + typeof tinyMCE != "undefined" && | |
| 3574 | + tinyMCE.get("tandc-text-reg-user") && | |
| 3575 | + !tinyMCE.get("tandc-text-reg-user").isHidden(); | |
| 3576 | + | |
| 3577 | + if (is_tinymce_reg) { | |
| 3578 | + var description = tinyMCE.get("tandc-text-reg-user").getContent().trim(); | |
| 3579 | + } else { | |
| 3580 | + var description = jQuery("#tandc-text-reg-user").val(); | |
| 3581 | + } | |
| 3582 | + dataform.append("tandc-text-reg-user", description); | |
| 3583 | + | |
| 3584 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3585 | + jQuery | |
| 3586 | + .ajax({ | |
| 3587 | + url: supportcandy.ajax_url, | |
| 3588 | + type: "POST", | |
| 3589 | + data: dataform, | |
| 3590 | + processData: false, | |
| 3591 | + contentType: false, | |
| 3592 | + }) | |
| 3593 | + .done(function (res) { | |
| 3594 | + wpsc_get_ms_term_and_conditions(); | |
| 3595 | + }); | |
| 3596 | +} | |
| 3597 | + | |
| 3598 | +/** | |
| 3599 | + * Sort ticket widget | |
| 3600 | + */ | |
| 3601 | +function wpsc_set_tw_load_order(slugs, nonce) { | |
| 3602 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3603 | + var data = { action: "wpsc_set_tw_load_order", slugs, _ajax_nonce: nonce }; | |
| 3604 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 3605 | + wpsc_get_ticket_widget(); | |
| 3606 | + }); | |
| 3607 | +} | |
| 3608 | + | |
| 3609 | +/** | |
| 3610 | + * Toggle enable/disable status of a single ticket widget | |
| 3611 | + */ | |
| 3612 | +function wpsc_toggle_ticket_widget_status(el, slug, nonce) { | |
| 3613 | + var checkbox = jQuery(el); | |
| 3614 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 3615 | + var widget = checkbox.closest(".wpsc-setting-card"); | |
| 3616 | + | |
| 731 | 3617 | var data = { |
| 732 | - action: 'wpsc_appearance_settings', | |
| 733 | - setting_action : 'get_reset_default_ticket_list_settings', | |
| 734 | - _ajax_nonce: nonce | |
| 3618 | + action: "wpsc_toggle_ticket_widget_status", | |
| 3619 | + slug, | |
| 3620 | + is_enable, | |
| 3621 | + _ajax_nonce: nonce, | |
| 735 | 3622 | }; |
| 3623 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 3624 | + widget.attr( | |
| 3625 | + "style", | |
| 3626 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 3627 | + ); | |
| 3628 | + var total = jQuery(".wpsc-toggle-ticket-widget").length; | |
| 3629 | + var checked = jQuery(".wpsc-toggle-ticket-widget:checked").length; | |
| 3630 | + jQuery(".wpsc-toggle-all-ticket-widgets").prop( | |
| 3631 | + "checked", | |
| 3632 | + total > 0 && total === checked | |
| 3633 | + ); | |
| 3634 | + }).fail(function () { | |
| 3635 | + // Revert checkbox on failure. | |
| 3636 | + checkbox.prop("checked", !is_enable); | |
| 3637 | + }); | |
| 3638 | +} | |
| 736 | 3639 | |
| 737 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 738 | - var response = JSON.parse(response_str); | |
| 739 | - if (response.sucess_status=='1') { | |
| 740 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 741 | - } | |
| 742 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 743 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 744 | - wpsc_get_appearance_ticket_list() | |
| 3640 | +/** | |
| 3641 | + * Enable or disable all ticket widgets at once | |
| 3642 | + */ | |
| 3643 | +function wpsc_toggle_all_ticket_widgets(el, nonce) { | |
| 3644 | + var checkbox = jQuery(el); | |
| 3645 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 3646 | + | |
| 3647 | + var data = { | |
| 3648 | + action: "wpsc_toggle_all_ticket_widgets_status", | |
| 3649 | + is_enable, | |
| 3650 | + _ajax_nonce: nonce, | |
| 3651 | + }; | |
| 3652 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 3653 | + jQuery(".wpsc-toggle-ticket-widget").prop("checked", !!is_enable); | |
| 3654 | + jQuery(".wpsc-setting-card").attr( | |
| 3655 | + "style", | |
| 3656 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 3657 | + ); | |
| 3658 | + }).fail(function () { | |
| 3659 | + // Revert checkbox on failure. | |
| 3660 | + checkbox.prop("checked", !is_enable); | |
| 745 | 3661 | }); |
| 746 | 3662 | } |
| 747 | 3663 | |
| 748 | -/* | |
| 749 | - * Appearance individual Ticket Page Settings | |
| 3664 | +/** | |
| 3665 | + * Get edit Agent Collision widget | |
| 750 | 3666 | */ |
| 751 | -function wpsc_get_appearance_individual_ticket(){ | |
| 752 | - | |
| 753 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 754 | - jQuery('#wpsc_appearance_individual_ticket').addClass('active'); | |
| 755 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 756 | - | |
| 3667 | +function wpsc_get_tw_agent_collision() { | |
| 3668 | + | |
| 3669 | + wpsc_show_modal(); | |
| 3670 | + var data = { action: 'wpsc_get_tw_agent_collision' }; | |
| 3671 | + jQuery.post( | |
| 3672 | + supportcandy.ajax_url, | |
| 3673 | + data, | |
| 3674 | + function (response) { | |
| 3675 | + | |
| 3676 | + // Set to modal. | |
| 3677 | + jQuery( '.wpsc-modal-header' ).text( response.title ); | |
| 3678 | + jQuery( '.wpsc-modal-body' ).html( response.body ); | |
| 3679 | + jQuery( '.wpsc-modal-footer' ).html( response.footer ); | |
| 3680 | + // Display modal. | |
| 3681 | + wpsc_show_modal_inner_container(); | |
| 3682 | + } | |
| 3683 | + ); | |
| 3684 | +} | |
| 3685 | + | |
| 3686 | +/** | |
| 3687 | + * Set edit Agent Collision widget | |
| 3688 | + */ | |
| 3689 | +function wpsc_set_tw_agent_collision(el) { | |
| 3690 | + var form = jQuery( '.wpsc-frm-edit-ac' )[0]; | |
| 3691 | + var dataform = new FormData( form ); | |
| 3692 | + | |
| 3693 | + if (dataform.get( 'label' ).trim() == '') { | |
| 3694 | + alert( supportcandy.translations.req_fields_missing ); | |
| 3695 | + return; | |
| 3696 | + } | |
| 3697 | + | |
| 3698 | + jQuery( '.wpsc-modal-footer button' ).attr( 'disabled', true ); | |
| 3699 | + jQuery( el ).text( supportcandy.translations.please_wait ); | |
| 3700 | + | |
| 3701 | + jQuery.ajax( | |
| 3702 | + { | |
| 3703 | + url: supportcandy.ajax_url, | |
| 3704 | + type: 'POST', | |
| 3705 | + data: dataform, | |
| 3706 | + processData: false, | |
| 3707 | + contentType: false | |
| 3708 | + } | |
| 3709 | + ).done( | |
| 3710 | + function (res) { | |
| 3711 | + wpsc_close_modal(); | |
| 3712 | + wpsc_get_ticket_widget(); | |
| 3713 | + } | |
| 3714 | + ); | |
| 3715 | +} | |
| 3716 | + | |
| 3717 | +/** | |
| 3718 | + * Ticket widget status | |
| 3719 | + */ | |
| 3720 | +function wpsc_get_tw_ticket_status() { | |
| 3721 | + wpsc_show_modal(); | |
| 3722 | + var data = { action: "wpsc_get_tw_ticket_status" }; | |
| 3723 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3724 | + // Set to modal. | |
| 3725 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 3726 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 3727 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 3728 | + // Display modal. | |
| 3729 | + wpsc_show_modal_inner_container(); | |
| 3730 | + }); | |
| 3731 | +} | |
| 3732 | + | |
| 3733 | +/** | |
| 3734 | + * Set ticket widget status | |
| 3735 | + */ | |
| 3736 | +function wpsc_set_tw_ticket_status(el) { | |
| 3737 | + var form = jQuery(".wpsc-frm-edit-ticket-status")[0]; | |
| 3738 | + var dataform = new FormData(form); | |
| 3739 | + | |
| 3740 | + if (dataform.get("label").trim() == "") { | |
| 3741 | + alert(supportcandy.translations.req_fields_missing); | |
| 3742 | + return; | |
| 3743 | + } | |
| 3744 | + | |
| 3745 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3746 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3747 | + | |
| 3748 | + jQuery | |
| 3749 | + .ajax({ | |
| 3750 | + url: supportcandy.ajax_url, | |
| 3751 | + type: "POST", | |
| 3752 | + data: dataform, | |
| 3753 | + processData: false, | |
| 3754 | + contentType: false, | |
| 3755 | + }) | |
| 3756 | + .done(function (res) { | |
| 3757 | + wpsc_close_modal(); | |
| 3758 | + wpsc_get_ticket_widget(); | |
| 3759 | + }); | |
| 3760 | +} | |
| 3761 | + | |
| 3762 | +/** | |
| 3763 | + * Set agent view settings | |
| 3764 | + * | |
| 3765 | + * @param {*} el | |
| 3766 | + */ | |
| 3767 | +function wpsc_tl_ms_set_agent_view(el) { | |
| 3768 | + var form = jQuery(".wpsc-frm-tl-ms-agent-view")[0]; | |
| 3769 | + var dataform = new FormData(form); | |
| 3770 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3771 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3772 | + jQuery | |
| 3773 | + .ajax({ | |
| 3774 | + url: supportcandy.ajax_url, | |
| 3775 | + type: "POST", | |
| 3776 | + data: dataform, | |
| 3777 | + processData: false, | |
| 3778 | + contentType: false, | |
| 3779 | + }) | |
| 3780 | + .done(function (res) { | |
| 3781 | + wpsc_tl_ms_get_agent_view(); | |
| 3782 | + }); | |
| 3783 | +} | |
| 3784 | + | |
| 3785 | +/** | |
| 3786 | + * Reset terms and conditions | |
| 3787 | + * | |
| 3788 | + * @param {*} el | |
| 3789 | + */ | |
| 3790 | +function wpsc_reset_ms_term_and_conditions(el, nonce) { | |
| 3791 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3792 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 757 | 3793 | var data = { |
| 758 | - action: 'wpsc_appearance_settings', | |
| 759 | - setting_action : 'get_appearance_individual_ticket_page' | |
| 3794 | + action: "wpsc_reset_ms_term_and_conditions", | |
| 3795 | + _ajax_nonce: nonce, | |
| 760 | 3796 | }; |
| 3797 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3798 | + wpsc_get_ms_term_and_conditions(); | |
| 3799 | + }); | |
| 3800 | +} | |
| 761 | 3801 | |
| 762 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 763 | - jQuery('.wpsc_setting_col2').html(response); | |
| 3802 | +/** | |
| 3803 | + * Get ticket widget raised by | |
| 3804 | + */ | |
| 3805 | +function wpsc_get_tw_raised_by() { | |
| 3806 | + wpsc_show_modal(); | |
| 3807 | + var data = { action: "wpsc_get_tw_raised_by" }; | |
| 3808 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3809 | + // Set to modal. | |
| 3810 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 3811 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 3812 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 3813 | + // Display modal. | |
| 3814 | + wpsc_show_modal_inner_container(); | |
| 764 | 3815 | }); |
| 765 | 3816 | } |
| 766 | 3817 | |
| 767 | -function wpsc_set_appearance_individual_ticket_settings(){ | |
| 768 | - | |
| 769 | - jQuery('.wpsc_submit_wait').show(); | |
| 770 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_individual_ticket_settings')[0]); | |
| 771 | - | |
| 772 | - jQuery.ajax({ | |
| 773 | - url: wpsc_admin.ajax_url, | |
| 774 | - type: 'POST', | |
| 775 | - data: dataform, | |
| 776 | - processData: false, | |
| 777 | - contentType: false | |
| 778 | - }) | |
| 779 | - .done(function (response_str) { | |
| 780 | - var response = JSON.parse(response_str); | |
| 781 | - jQuery('.wpsc_submit_wait').hide(); | |
| 782 | - if (response.sucess_status=='1') { | |
| 783 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 784 | - } | |
| 785 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 786 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 3818 | +/** | |
| 3819 | + * Reset agent view settings | |
| 3820 | + * | |
| 3821 | + * @param {*} el | |
| 3822 | + */ | |
| 3823 | +function wpsc_tl_ms_reset_agent_view(el, nonce) { | |
| 3824 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3825 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3826 | + var data = { action: "wpsc_tl_ms_reset_agent_view", _ajax_nonce: nonce }; | |
| 3827 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3828 | + wpsc_tl_ms_get_agent_view(); | |
| 787 | 3829 | }); |
| 788 | 3830 | } |
| 789 | 3831 | |
| 790 | -/* | |
| 791 | - * Appearance individual Ticket reset Settings | |
| 3832 | +/** | |
| 3833 | + * Get reCaptcha settings | |
| 792 | 3834 | */ |
| 793 | -function wpsc_reset_default_individual_ticket_settings(nonce) { | |
| 3835 | +function wpsc_get_ms_recaptcha() { | |
| 3836 | + supportcandy.current_tab = "recaptcha"; | |
| 3837 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 3838 | + jQuery( | |
| 3839 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3840 | + ).addClass("active"); | |
| 794 | 3841 | |
| 3842 | + window.history.replaceState( | |
| 3843 | + {}, | |
| 3844 | + null, | |
| 3845 | + "admin.php?page=wpsc-settings§ion=" + | |
| 3846 | + supportcandy.current_section + | |
| 3847 | + "&tab=" + | |
| 3848 | + supportcandy.current_tab | |
| 3849 | + ); | |
| 3850 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3851 | + | |
| 3852 | + wpsc_scroll_top(); | |
| 3853 | + | |
| 3854 | + var data = { action: "wpsc_get_ms_recaptcha" }; | |
| 3855 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3856 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3857 | + wpsc_reset_responsive_style(); | |
| 3858 | + }); | |
| 3859 | +} | |
| 3860 | + | |
| 3861 | +/** | |
| 3862 | + * Set ticket widget raised by | |
| 3863 | + */ | |
| 3864 | +function wpsc_set_tw_raised_by(el) { | |
| 3865 | + var form = jQuery(".wpsc-frm-edit-ticket-raised-by")[0]; | |
| 3866 | + var dataform = new FormData(form); | |
| 3867 | + | |
| 3868 | + if (dataform.get("label").trim() == "") { | |
| 3869 | + alert(supportcandy.translations.req_fields_missing); | |
| 3870 | + return; | |
| 3871 | + } | |
| 3872 | + | |
| 3873 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3874 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3875 | + | |
| 3876 | + jQuery | |
| 3877 | + .ajax({ | |
| 3878 | + url: supportcandy.ajax_url, | |
| 3879 | + type: "POST", | |
| 3880 | + data: dataform, | |
| 3881 | + processData: false, | |
| 3882 | + contentType: false, | |
| 3883 | + }) | |
| 3884 | + .done(function (res) { | |
| 3885 | + wpsc_close_modal(); | |
| 3886 | + wpsc_get_ticket_widget(); | |
| 3887 | + }); | |
| 3888 | +} | |
| 3889 | + | |
| 3890 | +/** | |
| 3891 | + * Get customer view settings | |
| 3892 | + */ | |
| 3893 | +function wpsc_tl_ms_get_customer_view() { | |
| 3894 | + supportcandy.current_tab = "customer-view"; | |
| 3895 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 3896 | + jQuery( | |
| 3897 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 3898 | + ).addClass("active"); | |
| 3899 | + | |
| 3900 | + window.history.replaceState( | |
| 3901 | + {}, | |
| 3902 | + null, | |
| 3903 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 3904 | + supportcandy.current_section + | |
| 3905 | + "&tab=" + | |
| 3906 | + supportcandy.current_tab | |
| 3907 | + ); | |
| 3908 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 3909 | + | |
| 3910 | + wpsc_scroll_top(); | |
| 3911 | + | |
| 3912 | + var data = { action: "wpsc_tl_ms_get_customer_view" }; | |
| 3913 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3914 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 3915 | + wpsc_reset_responsive_style(); | |
| 3916 | + }); | |
| 3917 | +} | |
| 3918 | + | |
| 3919 | +/** | |
| 3920 | + * Save reCaptcha | |
| 3921 | + * | |
| 3922 | + * @param {*} el | |
| 3923 | + */ | |
| 3924 | +function wpsc_set_ms_recaptcha(el) { | |
| 3925 | + var form = jQuery(".wpsc-frm-ms-recaptcha")[0]; | |
| 3926 | + var dataform = new FormData(form); | |
| 3927 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 3928 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 3929 | + jQuery | |
| 3930 | + .ajax({ | |
| 3931 | + url: supportcandy.ajax_url, | |
| 3932 | + type: "POST", | |
| 3933 | + data: dataform, | |
| 3934 | + processData: false, | |
| 3935 | + contentType: false, | |
| 3936 | + }) | |
| 3937 | + .done(function (res) { | |
| 3938 | + wpsc_get_ms_recaptcha(); | |
| 3939 | + }); | |
| 3940 | +} | |
| 3941 | + | |
| 3942 | +/** | |
| 3943 | + * Get ticket widget ticket info | |
| 3944 | + */ | |
| 3945 | +function wpsc_get_tw_ticket_info() { | |
| 3946 | + wpsc_show_modal(); | |
| 3947 | + var data = { action: "wpsc_get_tw_ticket_info" }; | |
| 3948 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3949 | + // Set to modal. | |
| 3950 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 3951 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 3952 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 3953 | + // Display modal. | |
| 3954 | + wpsc_show_modal_inner_container(); | |
| 3955 | + }); | |
| 3956 | +} | |
| 3957 | + | |
| 3958 | +/** | |
| 3959 | + * Add new option snippet | |
| 3960 | + */ | |
| 3961 | +function wpsc_get_add_new_option() { | |
| 3962 | + jQuery(".wpsc-options-container").append(jQuery(".wpsc-add-option").html()); | |
| 3963 | + jQuery(".wpsc-options-container") | |
| 3964 | + .children() | |
| 3965 | + .last() | |
| 3966 | + .find(".wpsc-add-option-container input:first") | |
| 3967 | + .focus(); | |
| 3968 | +} | |
| 3969 | + | |
| 3970 | +/** | |
| 3971 | + * Add new option for custom field | |
| 3972 | + */ | |
| 3973 | +function wpsc_add_new_option(el, nonce) { | |
| 3974 | + var submitBtn = jQuery(el); | |
| 3975 | + var inputField = jQuery(el).parent().find("input").first(); | |
| 3976 | + | |
| 3977 | + var name = inputField.val().trim(); | |
| 3978 | + if (!name) { | |
| 3979 | + return; | |
| 3980 | + } | |
| 3981 | + | |
| 3982 | + submitBtn.attr("disabled", true); | |
| 3983 | + inputField.attr("disabled", true); | |
| 3984 | + submitBtn.html(supportcandy.inline_loader); | |
| 3985 | + | |
| 3986 | + var data = { action: "wpsc_add_new_option", name, _ajax_nonce: nonce }; | |
| 3987 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 3988 | + submitBtn | |
| 3989 | + .closest(".wpsc-option-item") | |
| 3990 | + .find(".wpsc-option-listing-container .text") | |
| 3991 | + .text(response.name); | |
| 3992 | + submitBtn | |
| 3993 | + .closest(".wpsc-option-item") | |
| 3994 | + .append( | |
| 3995 | + '<input type="hidden" class="option_id" name="options[]" value="' + | |
| 3996 | + response.id + | |
| 3997 | + '">' | |
| 3998 | + ); | |
| 3999 | + submitBtn.parent().hide(); | |
| 4000 | + submitBtn.closest(".content").find(".wpsc-option-listing-container").show(); | |
| 4001 | + wpsc_change_def_val_option_single(); | |
| 4002 | + }); | |
| 4003 | +} | |
| 4004 | + | |
| 4005 | +/** | |
| 4006 | + * Set ticket widget ticket info | |
| 4007 | + */ | |
| 4008 | +function wpsc_set_tw_ticket_info(el) { | |
| 4009 | + var form = jQuery(".wpsc-frm-edit-ticket-info")[0]; | |
| 4010 | + var dataform = new FormData(form); | |
| 4011 | + | |
| 4012 | + if (dataform.get("label").trim() == "") { | |
| 4013 | + alert(supportcandy.translations.req_fields_missing); | |
| 4014 | + return; | |
| 4015 | + } | |
| 4016 | + | |
| 4017 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4018 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4019 | + | |
| 4020 | + jQuery | |
| 4021 | + .ajax({ | |
| 4022 | + url: supportcandy.ajax_url, | |
| 4023 | + type: "POST", | |
| 4024 | + data: dataform, | |
| 4025 | + processData: false, | |
| 4026 | + contentType: false, | |
| 4027 | + }) | |
| 4028 | + .done(function (res) { | |
| 4029 | + wpsc_close_modal(); | |
| 4030 | + wpsc_get_ticket_widget(); | |
| 4031 | + }); | |
| 4032 | +} | |
| 4033 | + | |
| 4034 | +/** | |
| 4035 | + * Reset reCaptcha | |
| 4036 | + * | |
| 4037 | + * @param {*} el | |
| 4038 | + */ | |
| 4039 | +function wpsc_reset_ms_recaptcha(el, nonce) { | |
| 4040 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4041 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4042 | + var data = { action: "wpsc_reset_ms_recaptcha", _ajax_nonce: nonce }; | |
| 4043 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4044 | + wpsc_get_ms_recaptcha(); | |
| 4045 | + }); | |
| 4046 | +} | |
| 4047 | + | |
| 4048 | +/** | |
| 4049 | + * Set customer view settings | |
| 4050 | + * | |
| 4051 | + * @param {*} el | |
| 4052 | + */ | |
| 4053 | +function wpsc_tl_ms_set_customer_view(el) { | |
| 4054 | + var form = jQuery(".wpsc-frm-tl-ms-customer-view")[0]; | |
| 4055 | + var dataform = new FormData(form); | |
| 4056 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4057 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4058 | + jQuery | |
| 4059 | + .ajax({ | |
| 4060 | + url: supportcandy.ajax_url, | |
| 4061 | + type: "POST", | |
| 4062 | + data: dataform, | |
| 4063 | + processData: false, | |
| 4064 | + contentType: false, | |
| 4065 | + }) | |
| 4066 | + .done(function (res) { | |
| 4067 | + wpsc_tl_ms_get_customer_view(); | |
| 4068 | + }); | |
| 4069 | +} | |
| 4070 | + | |
| 4071 | +/** | |
| 4072 | + * Get ticket widget agents | |
| 4073 | + */ | |
| 4074 | +function wpsc_get_tw_agents() { | |
| 4075 | + wpsc_show_modal(); | |
| 4076 | + var data = { action: "wpsc_get_tw_agents" }; | |
| 4077 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4078 | + // Set to modal. | |
| 4079 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 4080 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 4081 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 4082 | + // Display modal. | |
| 4083 | + wpsc_show_modal_inner_container(); | |
| 4084 | + }); | |
| 4085 | +} | |
| 4086 | + | |
| 4087 | +/** | |
| 4088 | + * Reset customer view settings | |
| 4089 | + * | |
| 4090 | + * @param {*} el | |
| 4091 | + */ | |
| 4092 | +function wpsc_tl_ms_reset_customer_view(el, nonce) { | |
| 4093 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4094 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4095 | + var data = { action: "wpsc_tl_ms_reset_customer_view", _ajax_nonce: nonce }; | |
| 4096 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4097 | + wpsc_tl_ms_get_customer_view(); | |
| 4098 | + }); | |
| 4099 | +} | |
| 4100 | + | |
| 4101 | +/** | |
| 4102 | + * Set ticket widget agents | |
| 4103 | + */ | |
| 4104 | +function wpsc_set_tw_agents(el) { | |
| 4105 | + var form = jQuery(".wpsc-frm-edit-agents")[0]; | |
| 4106 | + var dataform = new FormData(form); | |
| 4107 | + | |
| 4108 | + if (dataform.get("label").trim() == "") { | |
| 4109 | + alert(supportcandy.translations.req_fields_missing); | |
| 4110 | + return; | |
| 4111 | + } | |
| 4112 | + | |
| 4113 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4114 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4115 | + | |
| 4116 | + jQuery | |
| 4117 | + .ajax({ | |
| 4118 | + url: supportcandy.ajax_url, | |
| 4119 | + type: "POST", | |
| 4120 | + data: dataform, | |
| 4121 | + processData: false, | |
| 4122 | + contentType: false, | |
| 4123 | + }) | |
| 4124 | + .done(function (res) { | |
| 4125 | + wpsc_close_modal(); | |
| 4126 | + wpsc_get_ticket_widget(); | |
| 4127 | + }); | |
| 4128 | +} | |
| 4129 | + | |
| 4130 | +/** | |
| 4131 | + * Get ticket widget ticket fields | |
| 4132 | + */ | |
| 4133 | +function wpsc_get_tw_ticket_fields() { | |
| 4134 | + wpsc_show_modal(); | |
| 4135 | + var data = { action: "wpsc_get_tw_ticket_fields" }; | |
| 4136 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4137 | + // Set to modal. | |
| 4138 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 4139 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 4140 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 4141 | + // Display modal. | |
| 4142 | + wpsc_show_modal_inner_container(); | |
| 4143 | + }); | |
| 4144 | +} | |
| 4145 | + | |
| 4146 | +/** | |
| 4147 | + * Load edit option view | |
| 4148 | + */ | |
| 4149 | +function wpsc_edit_option(el) { | |
| 4150 | + var editBtn = jQuery(el); | |
| 4151 | + var text = editBtn | |
| 4152 | + .closest(".wpsc-option-listing-container") | |
| 4153 | + .find(".text") | |
| 4154 | + .text(); | |
| 4155 | + editBtn.closest(".content").find(".edit-option-text").val(text); | |
| 4156 | + editBtn.closest(".wpsc-option-listing-container").hide(); | |
| 4157 | + editBtn.closest(".content").find(".wpsc-edit-option-container").show(); | |
| 4158 | +} | |
| 4159 | + | |
| 4160 | +/** | |
| 4161 | + * Update option | |
| 4162 | + */ | |
| 4163 | +function wpsc_set_edit_option(el, nonce) { | |
| 4164 | + var submitBtn = jQuery(el); | |
| 4165 | + var inputField = jQuery(el).parent().find("input").first(); | |
| 4166 | + | |
| 4167 | + var option_id = submitBtn | |
| 4168 | + .closest(".wpsc-option-item") | |
| 4169 | + .find(".option_id") | |
| 4170 | + .val() | |
| 4171 | + .trim(); | |
| 4172 | + if (!option_id) { | |
| 4173 | + return; | |
| 4174 | + } | |
| 4175 | + | |
| 4176 | + var name = inputField.val().trim(); | |
| 4177 | + if (!name) { | |
| 4178 | + return; | |
| 4179 | + } | |
| 4180 | + | |
| 4181 | + submitBtn.attr("disabled", true); | |
| 4182 | + inputField.attr("disabled", true); | |
| 4183 | + | |
| 4184 | + var submitHtml = submitBtn.html(); | |
| 4185 | + submitBtn.html(supportcandy.inline_loader); | |
| 4186 | + | |
| 795 | 4187 | var data = { |
| 796 | - action: 'wpsc_appearance_settings', | |
| 797 | - setting_action : 'get_reset_default_individual_ticket_settings', | |
| 798 | - _ajax_nonce: nonce | |
| 4188 | + action: "wpsc_set_edit_option", | |
| 4189 | + id: option_id, | |
| 4190 | + name, | |
| 4191 | + _ajax_nonce: nonce, | |
| 799 | 4192 | }; |
| 4193 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4194 | + submitBtn | |
| 4195 | + .closest(".wpsc-option-item") | |
| 4196 | + .find(".wpsc-option-listing-container .text") | |
| 4197 | + .text(response.name); | |
| 4198 | + submitBtn.attr("disabled", false); | |
| 4199 | + inputField.attr("disabled", false); | |
| 4200 | + submitBtn.html(submitHtml); | |
| 4201 | + submitBtn.parent().hide(); | |
| 4202 | + submitBtn.closest(".content").find(".wpsc-option-listing-container").show(); | |
| 4203 | + wpsc_change_def_val_option_single(); | |
| 4204 | + }); | |
| 4205 | +} | |
| 800 | 4206 | |
| 801 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 802 | - var response = JSON.parse(response_str); | |
| 803 | - if (response.sucess_status=='1') { | |
| 804 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 805 | - } | |
| 806 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 807 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 808 | - wpsc_get_appearance_individual_ticket() | |
| 4207 | +/** | |
| 4208 | + * Set ticket widget ticket fields | |
| 4209 | + */ | |
| 4210 | +function wpsc_set_tw_ticket_fields(el) { | |
| 4211 | + var form = jQuery(".wpsc-frm-edit-ticket-fields")[0]; | |
| 4212 | + var dataform = new FormData(form); | |
| 4213 | + | |
| 4214 | + if (dataform.get("label").trim() == "") { | |
| 4215 | + alert(supportcandy.translations.req_fields_missing); | |
| 4216 | + return; | |
| 4217 | + } | |
| 4218 | + | |
| 4219 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4220 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4221 | + | |
| 4222 | + jQuery | |
| 4223 | + .ajax({ | |
| 4224 | + url: supportcandy.ajax_url, | |
| 4225 | + type: "POST", | |
| 4226 | + data: dataform, | |
| 4227 | + processData: false, | |
| 4228 | + contentType: false, | |
| 4229 | + }) | |
| 4230 | + .done(function (res) { | |
| 4231 | + wpsc_close_modal(); | |
| 4232 | + wpsc_get_ticket_widget(); | |
| 4233 | + }); | |
| 4234 | +} | |
| 4235 | + | |
| 4236 | +/** | |
| 4237 | + * Get gdpr settings | |
| 4238 | + */ | |
| 4239 | +function wpsc_get_ms_gdpr() { | |
| 4240 | + supportcandy.current_tab = "gdpr"; | |
| 4241 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4242 | + jQuery( | |
| 4243 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4244 | + ).addClass("active"); | |
| 4245 | + | |
| 4246 | + window.history.replaceState( | |
| 4247 | + {}, | |
| 4248 | + null, | |
| 4249 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4250 | + supportcandy.current_section + | |
| 4251 | + "&tab=" + | |
| 4252 | + supportcandy.current_tab | |
| 4253 | + ); | |
| 4254 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4255 | + | |
| 4256 | + wpsc_scroll_top(); | |
| 4257 | + | |
| 4258 | + var data = { action: "wpsc_get_ms_gdpr" }; | |
| 4259 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4260 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4261 | + wpsc_reset_responsive_style(); | |
| 809 | 4262 | }); |
| 810 | 4263 | } |
| 811 | 4264 | |
| 4265 | +/** | |
| 4266 | + * Get advanced settings of tl more settings | |
| 4267 | + */ | |
| 4268 | +function wpsc_tl_ms_get_advanced() { | |
| 4269 | + supportcandy.current_tab = "advanced"; | |
| 4270 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4271 | + jQuery( | |
| 4272 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4273 | + ).addClass("active"); | |
| 812 | 4274 | |
| 813 | -/* | |
| 814 | - * Appearance Create Ticket Page Settings | |
| 4275 | + window.history.replaceState( | |
| 4276 | + {}, | |
| 4277 | + null, | |
| 4278 | + "admin.php?page=wpsc-ticket-list§ion=" + | |
| 4279 | + supportcandy.current_section + | |
| 4280 | + "&tab=" + | |
| 4281 | + supportcandy.current_tab | |
| 4282 | + ); | |
| 4283 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4284 | + | |
| 4285 | + wpsc_scroll_top(); | |
| 4286 | + | |
| 4287 | + var data = { action: "wpsc_tl_ms_get_advanced" }; | |
| 4288 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4289 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4290 | + wpsc_reset_responsive_style(); | |
| 4291 | + }); | |
| 4292 | +} | |
| 4293 | + | |
| 4294 | +/** | |
| 4295 | + * Save gdpr | |
| 4296 | + * | |
| 4297 | + * @param {*} el | |
| 815 | 4298 | */ |
| 816 | -function wpsc_get_appearance_create_ticket(){ | |
| 817 | - | |
| 818 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 819 | - jQuery('#wpsc_appearance_create_ticket').addClass('active'); | |
| 820 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 821 | - | |
| 4299 | +function wpsc_set_ms_gdpr(el) { | |
| 4300 | + var form = jQuery(".wpsc-frm-ms-gdpr")[0]; | |
| 4301 | + var dataform = new FormData(form); | |
| 4302 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4303 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4304 | + var is_tinymce_ct = | |
| 4305 | + typeof tinyMCE != "undefined" && | |
| 4306 | + tinyMCE.get("gdpr-text") && | |
| 4307 | + !tinyMCE.get("gdpr-text").isHidden(); | |
| 4308 | + | |
| 4309 | + if (is_tinymce_ct) { | |
| 4310 | + var description = tinyMCE.get("gdpr-text").getContent().trim(); | |
| 4311 | + } else { | |
| 4312 | + var description = jQuery("#gdpr-text").val(); | |
| 4313 | + } | |
| 4314 | + dataform.append("gdpr-text", description); | |
| 4315 | + | |
| 4316 | + var is_tinymce_reg = | |
| 4317 | + typeof tinyMCE != "undefined" && | |
| 4318 | + tinyMCE.get("gdpr-text-reg-user") && | |
| 4319 | + !tinyMCE.get("gdpr-text-reg-user").isHidden(); | |
| 4320 | + | |
| 4321 | + if (is_tinymce_reg) { | |
| 4322 | + var description = tinyMCE.get("gdpr-text-reg-user").getContent().trim(); | |
| 4323 | + } else { | |
| 4324 | + var description = jQuery("#gdpr-text-reg-user").val(); | |
| 4325 | + } | |
| 4326 | + dataform.append("gdpr-text-reg-user", description); | |
| 4327 | + | |
| 4328 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4329 | + jQuery | |
| 4330 | + .ajax({ | |
| 4331 | + url: supportcandy.ajax_url, | |
| 4332 | + type: "POST", | |
| 4333 | + data: dataform, | |
| 4334 | + processData: false, | |
| 4335 | + contentType: false, | |
| 4336 | + }) | |
| 4337 | + .done(function (res) { | |
| 4338 | + wpsc_get_ms_gdpr(); | |
| 4339 | + }); | |
| 4340 | +} | |
| 4341 | + | |
| 4342 | +/** | |
| 4343 | + * Set advanced settings of tl more settings | |
| 4344 | + * | |
| 4345 | + * @param {*} el | |
| 4346 | + */ | |
| 4347 | +function wpsc_tl_ms_set_advanced(el) { | |
| 4348 | + var form = jQuery(".wpsc-frm-advanced-settings")[0]; | |
| 4349 | + var dataform = new FormData(form); | |
| 4350 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4351 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4352 | + jQuery | |
| 4353 | + .ajax({ | |
| 4354 | + url: supportcandy.ajax_url, | |
| 4355 | + type: "POST", | |
| 4356 | + data: dataform, | |
| 4357 | + processData: false, | |
| 4358 | + contentType: false, | |
| 4359 | + }) | |
| 4360 | + .done(function (res) { | |
| 4361 | + wpsc_tl_ms_get_advanced(); | |
| 4362 | + }); | |
| 4363 | +} | |
| 4364 | + | |
| 4365 | +/** | |
| 4366 | + * Get ticket widget agentOnly fields | |
| 4367 | + */ | |
| 4368 | +function wpsc_get_tw_agentonly_fields() { | |
| 4369 | + wpsc_show_modal(); | |
| 4370 | + var data = { action: "wpsc_get_tw_agentonly_fields" }; | |
| 4371 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4372 | + // Set to modal. | |
| 4373 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 4374 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 4375 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 4376 | + // Display modal. | |
| 4377 | + wpsc_show_modal_inner_container(); | |
| 4378 | + }); | |
| 4379 | +} | |
| 4380 | + | |
| 4381 | +/** | |
| 4382 | + * Reset gdpr | |
| 4383 | + * | |
| 4384 | + * @param {*} el | |
| 4385 | + */ | |
| 4386 | +function wpsc_reset_ms_gdpr(el, nonce) { | |
| 4387 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4388 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4389 | + var data = { action: "wpsc_reset_ms_gdpr", _ajax_nonce: nonce }; | |
| 4390 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4391 | + wpsc_get_ms_gdpr(); | |
| 4392 | + }); | |
| 4393 | +} | |
| 4394 | + | |
| 4395 | +/** | |
| 4396 | + * Reset advanced settings of tl more settings | |
| 4397 | + * | |
| 4398 | + * @param {*} el | |
| 4399 | + */ | |
| 4400 | +function wpsc_tl_ms_reset_advanced(el, nonce) { | |
| 4401 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4402 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4403 | + var data = { action: "wpsc_tl_ms_reset_advanced", _ajax_nonce: nonce }; | |
| 4404 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4405 | + wpsc_tl_ms_get_advanced(); | |
| 4406 | + }); | |
| 4407 | +} | |
| 4408 | + | |
| 4409 | +/** | |
| 4410 | + * Get advanced miscellaneous settings | |
| 4411 | + */ | |
| 4412 | +function wpsc_get_ms_advanced() { | |
| 4413 | + supportcandy.current_tab = "advanced"; | |
| 4414 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4415 | + jQuery( | |
| 4416 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4417 | + ).addClass("active"); | |
| 4418 | + | |
| 4419 | + window.history.replaceState( | |
| 4420 | + {}, | |
| 4421 | + null, | |
| 4422 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4423 | + supportcandy.current_section + | |
| 4424 | + "&tab=" + | |
| 4425 | + supportcandy.current_tab | |
| 4426 | + ); | |
| 4427 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4428 | + | |
| 4429 | + wpsc_scroll_top(); | |
| 4430 | + | |
| 4431 | + var data = { action: "wpsc_get_ms_advanced" }; | |
| 4432 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4433 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4434 | + wpsc_reset_responsive_style(); | |
| 4435 | + }); | |
| 4436 | +} | |
| 4437 | + | |
| 4438 | +/** | |
| 4439 | + * Set ticket widget agentOnly fields | |
| 4440 | + */ | |
| 4441 | +function wpsc_set_tw_agentonly_fields(el) { | |
| 4442 | + var form = jQuery(".wpsc-frm-edit-agentonly-fields")[0]; | |
| 4443 | + var dataform = new FormData(form); | |
| 4444 | + | |
| 4445 | + if (dataform.get("label").trim() == "") { | |
| 4446 | + alert(supportcandy.translations.req_fields_missing); | |
| 4447 | + return; | |
| 4448 | + } | |
| 4449 | + | |
| 4450 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4451 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4452 | + | |
| 4453 | + jQuery | |
| 4454 | + .ajax({ | |
| 4455 | + url: supportcandy.ajax_url, | |
| 4456 | + type: "POST", | |
| 4457 | + data: dataform, | |
| 4458 | + processData: false, | |
| 4459 | + contentType: false, | |
| 4460 | + }) | |
| 4461 | + .done(function (res) { | |
| 4462 | + wpsc_close_modal(); | |
| 4463 | + wpsc_get_ticket_widget(); | |
| 4464 | + }); | |
| 4465 | +} | |
| 4466 | + | |
| 4467 | +/** | |
| 4468 | + * Get ticket widget additional recipients | |
| 4469 | + */ | |
| 4470 | +function wpsc_get_tw_additional_recipients() { | |
| 4471 | + wpsc_show_modal(); | |
| 4472 | + var data = { action: "wpsc_get_tw_additional_recipients" }; | |
| 4473 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4474 | + // Set to modal. | |
| 4475 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 4476 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 4477 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 4478 | + // Display modal. | |
| 4479 | + wpsc_show_modal_inner_container(); | |
| 4480 | + }); | |
| 4481 | +} | |
| 4482 | + | |
| 4483 | +/** | |
| 4484 | + * Save advanced miscellaneous settings | |
| 4485 | + * | |
| 4486 | + * @param {*} el | |
| 4487 | + */ | |
| 4488 | +function wpsc_set_ms_advanced(el) { | |
| 4489 | + var form = jQuery(".wpsc-frm-ms-advanced")[0]; | |
| 4490 | + var dataform = new FormData(form); | |
| 4491 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4492 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4493 | + jQuery | |
| 4494 | + .ajax({ | |
| 4495 | + url: supportcandy.ajax_url, | |
| 4496 | + type: "POST", | |
| 4497 | + data: dataform, | |
| 4498 | + processData: false, | |
| 4499 | + contentType: false, | |
| 4500 | + }) | |
| 4501 | + .done(function (res) { | |
| 4502 | + wpsc_get_ms_advanced(); | |
| 4503 | + }); | |
| 4504 | +} | |
| 4505 | + | |
| 4506 | +/** | |
| 4507 | + * Set ticket widget additional recipients | |
| 4508 | + */ | |
| 4509 | +function wpsc_set_tw_additional_recipients(el) { | |
| 4510 | + var form = jQuery(".wpsc-frm-edit-additional-recipients")[0]; | |
| 4511 | + var dataform = new FormData(form); | |
| 4512 | + | |
| 4513 | + if (dataform.get("label").trim() == "") { | |
| 4514 | + alert(supportcandy.translations.req_fields_missing); | |
| 4515 | + return; | |
| 4516 | + } | |
| 4517 | + | |
| 4518 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4519 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4520 | + | |
| 4521 | + jQuery | |
| 4522 | + .ajax({ | |
| 4523 | + url: supportcandy.ajax_url, | |
| 4524 | + type: "POST", | |
| 4525 | + data: dataform, | |
| 4526 | + processData: false, | |
| 4527 | + contentType: false, | |
| 4528 | + }) | |
| 4529 | + .done(function (res) { | |
| 4530 | + wpsc_close_modal(); | |
| 4531 | + wpsc_get_ticket_widget(); | |
| 4532 | + }); | |
| 4533 | +} | |
| 4534 | + | |
| 4535 | +/** | |
| 4536 | + * Reset advanced miscellaneous settings | |
| 4537 | + * | |
| 4538 | + * @param {*} el | |
| 4539 | + */ | |
| 4540 | +function wpsc_reset_ms_advanced(el, nonce) { | |
| 4541 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4542 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4543 | + var data = { action: "wpsc_reset_ms_advanced", _ajax_nonce: nonce }; | |
| 4544 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4545 | + wpsc_get_ms_advanced(); | |
| 4546 | + }); | |
| 4547 | +} | |
| 4548 | + | |
| 4549 | +/** | |
| 4550 | + * Cancel edit | |
| 4551 | + */ | |
| 4552 | +function wpsc_edit_option_cancel(el) { | |
| 4553 | + var cancelBtn = jQuery(el); | |
| 4554 | + cancelBtn.closest(".wpsc-edit-option-container").hide(); | |
| 4555 | + cancelBtn.closest(".content").find(".wpsc-option-listing-container").show(); | |
| 4556 | +} | |
| 4557 | + | |
| 4558 | +/** | |
| 4559 | + * Remove an item | |
| 4560 | + */ | |
| 4561 | +function wpsc_remove_option_item(el) { | |
| 4562 | + jQuery(el).closest(".wpsc-option-item").remove(); | |
| 4563 | + wpsc_change_def_val_option_single(); | |
| 4564 | +} | |
| 4565 | + | |
| 4566 | +/** | |
| 4567 | + * Change default value options | |
| 4568 | + */ | |
| 4569 | +function wpsc_change_def_val_option_single() { | |
| 4570 | + var options = []; | |
| 4571 | + jQuery(".wpsc-options-container .option_id").each(function (index, el) { | |
| 4572 | + var key = jQuery(el).val().trim(); | |
| 4573 | + var value = jQuery(el) | |
| 4574 | + .closest(".wpsc-option-item") | |
| 4575 | + .find(".wpsc-option-listing-container .text") | |
| 4576 | + .text(); | |
| 4577 | + options.push({ key, value }); | |
| 4578 | + }); | |
| 4579 | + var optionStr = '<option value=""></option>'; | |
| 4580 | + jQuery(options).each(function (index, el) { | |
| 4581 | + optionStr += '<option value="' + el.key + '">' + el.value + "</option>"; | |
| 4582 | + }); | |
| 4583 | + | |
| 4584 | + var fieldType = jQuery("#wpsc-select-ticket-field").val(); | |
| 4585 | + | |
| 4586 | + var optionSingleTypes = ["cf_single_select", "cf_radio_button"]; | |
| 4587 | + if (jQuery.inArray(fieldType, optionSingleTypes) != -1) { | |
| 4588 | + jQuery("#wpsc-default-val-option-single").html(optionStr); | |
| 4589 | + jQuery("#wpsc-default-val-option-single").selectWoo(); | |
| 4590 | + } | |
| 4591 | + | |
| 4592 | + var optionMultiTypes = ["cf_multi_select", "cf_checkbox"]; | |
| 4593 | + if (jQuery.inArray(fieldType, optionMultiTypes) != -1) { | |
| 4594 | + var preValue = jQuery("#wpsc-default-val-option-multi").val(); | |
| 4595 | + | |
| 4596 | + jQuery("#wpsc-default-val-option-multi").html(optionStr); | |
| 4597 | + jQuery("#wpsc-default-val-option-multi").selectWoo(); | |
| 4598 | + | |
| 4599 | + if (preValue) { | |
| 4600 | + jQuery("#wpsc-default-val-option-multi").val(preValue); | |
| 4601 | + jQuery("#wpsc-default-val-option-multi").trigger("change"); | |
| 4602 | + } | |
| 4603 | + } | |
| 4604 | +} | |
| 4605 | + | |
| 4606 | +/** | |
| 4607 | + * Get rich text settings | |
| 4608 | + */ | |
| 4609 | +function wpsc_get_rich_text_editor(is_humbargar = false) { | |
| 4610 | + if (is_humbargar) { | |
| 4611 | + wpsc_toggle_humbargar(); | |
| 4612 | + } | |
| 4613 | + | |
| 4614 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 4615 | + jQuery( | |
| 4616 | + ".wpsc-setting-nav.rich-text-editor, .wpsc-humbargar-menu-item.rich-text-editor" | |
| 4617 | + ).addClass("active"); | |
| 4618 | + jQuery(".wpsc-humbargar-title").html( | |
| 4619 | + supportcandy.humbargar_titles.rich_text_editor | |
| 4620 | + ); | |
| 4621 | + | |
| 4622 | + if (supportcandy.current_section !== "rich-text-editor") { | |
| 4623 | + supportcandy.current_section = "rich-text-editor"; | |
| 4624 | + supportcandy.current_tab = "agent"; | |
| 4625 | + } | |
| 4626 | + | |
| 4627 | + window.history.replaceState( | |
| 4628 | + {}, | |
| 4629 | + null, | |
| 4630 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4631 | + supportcandy.current_section + | |
| 4632 | + "&tab=" + | |
| 4633 | + supportcandy.current_tab | |
| 4634 | + ); | |
| 4635 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 4636 | + | |
| 4637 | + wpsc_scroll_top(); | |
| 4638 | + | |
| 822 | 4639 | var data = { |
| 823 | - action: 'wpsc_appearance_settings', | |
| 824 | - setting_action : 'get_appearance_create_ticket' | |
| 4640 | + action: "wpsc_get_rich_text_editor", | |
| 4641 | + tab: supportcandy.current_tab, | |
| 825 | 4642 | }; |
| 4643 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4644 | + jQuery(".wpsc-setting-body").html(response); | |
| 4645 | + wpsc_reset_responsive_style(); | |
| 4646 | + jQuery( | |
| 4647 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4648 | + ).trigger("click"); | |
| 4649 | + }); | |
| 4650 | +} | |
| 826 | 4651 | |
| 827 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 828 | - jQuery('.wpsc_setting_col2').html(response); | |
| 4652 | +/** | |
| 4653 | + * Load agent tab ui | |
| 4654 | + */ | |
| 4655 | +function wpsc_get_te_agent() { | |
| 4656 | + supportcandy.current_tab = "agent"; | |
| 4657 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4658 | + jQuery( | |
| 4659 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4660 | + ).addClass("active"); | |
| 4661 | + | |
| 4662 | + window.history.replaceState( | |
| 4663 | + {}, | |
| 4664 | + null, | |
| 4665 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4666 | + supportcandy.current_section + | |
| 4667 | + "&tab=" + | |
| 4668 | + supportcandy.current_tab | |
| 4669 | + ); | |
| 4670 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4671 | + | |
| 4672 | + wpsc_scroll_top(); | |
| 4673 | + | |
| 4674 | + const data = { action: "wpsc_get_te_agent" }; | |
| 4675 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4676 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4677 | + wpsc_reset_responsive_style(); | |
| 829 | 4678 | }); |
| 830 | 4679 | } |
| 831 | 4680 | |
| 4681 | +/** | |
| 4682 | + * Save agent settings | |
| 4683 | + */ | |
| 4684 | +function wpsc_set_te_agent(el) { | |
| 4685 | + const form = jQuery(".wpsc-frm-te-agent")[0]; | |
| 4686 | + const dataform = new FormData(form); | |
| 4687 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4688 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4689 | + jQuery | |
| 4690 | + .ajax({ | |
| 4691 | + url: supportcandy.ajax_url, | |
| 4692 | + type: "POST", | |
| 4693 | + data: dataform, | |
| 4694 | + processData: false, | |
| 4695 | + contentType: false, | |
| 4696 | + }) | |
| 4697 | + .done(function (res) { | |
| 4698 | + wpsc_get_te_agent(); | |
| 4699 | + }); | |
| 4700 | +} | |
| 832 | 4701 | |
| 833 | -function wpsc_set_appearance_create_ticket_settings(){ | |
| 834 | - | |
| 835 | - jQuery('.wpsc_submit_wait').show(); | |
| 836 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_create_ticket_settings')[0]); | |
| 837 | - | |
| 838 | - jQuery.ajax({ | |
| 839 | - url: wpsc_admin.ajax_url, | |
| 840 | - type: 'POST', | |
| 841 | - data: dataform, | |
| 842 | - processData: false, | |
| 843 | - contentType: false | |
| 844 | - }) | |
| 845 | - .done(function (response_str) { | |
| 846 | - var response = JSON.parse(response_str); | |
| 847 | - jQuery('.wpsc_submit_wait').hide(); | |
| 848 | - if (response.sucess_status=='1') { | |
| 849 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 850 | - } | |
| 851 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 852 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 4702 | +/** | |
| 4703 | + * Reset agent settings | |
| 4704 | + */ | |
| 4705 | +function wpsc_reset_te_agent(el, nonce) { | |
| 4706 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4707 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4708 | + const data = { action: "wpsc_reset_te_agent", _ajax_nonce: nonce }; | |
| 4709 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4710 | + wpsc_get_te_agent(); | |
| 853 | 4711 | }); |
| 854 | 4712 | } |
| 855 | 4713 | |
| 856 | -function wpsc_get_appearance_login_form(){ | |
| 857 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 858 | - jQuery('#wpsc_appearance_login_form').addClass('active'); | |
| 859 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 860 | - | |
| 4714 | +/** | |
| 4715 | + * Load registered user tab ui | |
| 4716 | + */ | |
| 4717 | +function wpsc_get_te_registered_user() { | |
| 4718 | + supportcandy.current_tab = "registered-user"; | |
| 4719 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4720 | + jQuery( | |
| 4721 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4722 | + ).addClass("active"); | |
| 4723 | + | |
| 4724 | + window.history.replaceState( | |
| 4725 | + {}, | |
| 4726 | + null, | |
| 4727 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4728 | + supportcandy.current_section + | |
| 4729 | + "&tab=" + | |
| 4730 | + supportcandy.current_tab | |
| 4731 | + ); | |
| 4732 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4733 | + | |
| 4734 | + wpsc_scroll_top(); | |
| 4735 | + | |
| 4736 | + const data = { action: "wpsc_get_te_registered_user" }; | |
| 4737 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4738 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4739 | + wpsc_reset_responsive_style(); | |
| 4740 | + }); | |
| 4741 | +} | |
| 4742 | + | |
| 4743 | +/** | |
| 4744 | + * Save registered user settings | |
| 4745 | + */ | |
| 4746 | +function wpsc_set_te_registered_user(el) { | |
| 4747 | + const form = jQuery(".wpsc-frm-te-registered-user")[0]; | |
| 4748 | + const dataform = new FormData(form); | |
| 4749 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4750 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4751 | + jQuery | |
| 4752 | + .ajax({ | |
| 4753 | + url: supportcandy.ajax_url, | |
| 4754 | + type: "POST", | |
| 4755 | + data: dataform, | |
| 4756 | + processData: false, | |
| 4757 | + contentType: false, | |
| 4758 | + }) | |
| 4759 | + .done(function (res) { | |
| 4760 | + wpsc_get_te_registered_user(); | |
| 4761 | + }); | |
| 4762 | +} | |
| 4763 | + | |
| 4764 | +/** | |
| 4765 | + * Reset registered user settings | |
| 4766 | + */ | |
| 4767 | +function wpsc_reset_te_registered_user(el, nonce) { | |
| 4768 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4769 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4770 | + const data = { action: "wpsc_reset_te_registered_user", _ajax_nonce: nonce }; | |
| 4771 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4772 | + wpsc_get_te_registered_user(); | |
| 4773 | + }); | |
| 4774 | +} | |
| 4775 | + | |
| 4776 | +/** | |
| 4777 | + * Load guest user tab ui | |
| 4778 | + */ | |
| 4779 | +function wpsc_get_te_guest_user() { | |
| 4780 | + supportcandy.current_tab = "guest-user"; | |
| 4781 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4782 | + jQuery( | |
| 4783 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4784 | + ).addClass("active"); | |
| 4785 | + | |
| 4786 | + window.history.replaceState( | |
| 4787 | + {}, | |
| 4788 | + null, | |
| 4789 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4790 | + supportcandy.current_section + | |
| 4791 | + "&tab=" + | |
| 4792 | + supportcandy.current_tab | |
| 4793 | + ); | |
| 4794 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4795 | + | |
| 4796 | + wpsc_scroll_top(); | |
| 4797 | + | |
| 4798 | + const data = { action: "wpsc_get_te_guest_user" }; | |
| 4799 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4800 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4801 | + wpsc_reset_responsive_style(); | |
| 4802 | + }); | |
| 4803 | +} | |
| 4804 | + | |
| 4805 | +/** | |
| 4806 | + * Save guest user settings | |
| 4807 | + */ | |
| 4808 | +function wpsc_set_te_guest_user(el) { | |
| 4809 | + const form = jQuery(".wpsc-frm-te-guest-user")[0]; | |
| 4810 | + const dataform = new FormData(form); | |
| 4811 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4812 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4813 | + jQuery | |
| 4814 | + .ajax({ | |
| 4815 | + url: supportcandy.ajax_url, | |
| 4816 | + type: "POST", | |
| 4817 | + data: dataform, | |
| 4818 | + processData: false, | |
| 4819 | + contentType: false, | |
| 4820 | + }) | |
| 4821 | + .done(function (res) { | |
| 4822 | + wpsc_get_te_guest_user(); | |
| 4823 | + }); | |
| 4824 | +} | |
| 4825 | + | |
| 4826 | +/** | |
| 4827 | + * Reset guest user settings | |
| 4828 | + */ | |
| 4829 | +function wpsc_reset_te_guest_user(el, nonce) { | |
| 4830 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4831 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4832 | + const data = { action: "wpsc_reset_te_guest_user", _ajax_nonce: nonce }; | |
| 4833 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4834 | + wpsc_get_te_guest_user(); | |
| 4835 | + }); | |
| 4836 | +} | |
| 4837 | + | |
| 4838 | +/** | |
| 4839 | + * Load advanced tab ui | |
| 4840 | + */ | |
| 4841 | +function wpsc_get_te_advanced() { | |
| 4842 | + supportcandy.current_tab = "advanced"; | |
| 4843 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 4844 | + jQuery( | |
| 4845 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 4846 | + ).addClass("active"); | |
| 4847 | + | |
| 4848 | + window.history.replaceState( | |
| 4849 | + {}, | |
| 4850 | + null, | |
| 4851 | + "admin.php?page=wpsc-settings§ion=" + | |
| 4852 | + supportcandy.current_section + | |
| 4853 | + "&tab=" + | |
| 4854 | + supportcandy.current_tab | |
| 4855 | + ); | |
| 4856 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4857 | + | |
| 4858 | + wpsc_scroll_top(); | |
| 4859 | + | |
| 4860 | + const data = { action: "wpsc_get_te_advanced" }; | |
| 4861 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4862 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4863 | + wpsc_reset_responsive_style(); | |
| 4864 | + }); | |
| 4865 | +} | |
| 4866 | + | |
| 4867 | +/** | |
| 4868 | + * Save advanced settings | |
| 4869 | + */ | |
| 4870 | +function wpsc_set_te_advanced(el) { | |
| 4871 | + const form = jQuery(".wpsc-frm-te-advanced")[0]; | |
| 4872 | + const dataform = new FormData(form); | |
| 4873 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4874 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4875 | + jQuery | |
| 4876 | + .ajax({ | |
| 4877 | + url: supportcandy.ajax_url, | |
| 4878 | + type: "POST", | |
| 4879 | + data: dataform, | |
| 4880 | + processData: false, | |
| 4881 | + contentType: false, | |
| 4882 | + }) | |
| 4883 | + .done(function (res) { | |
| 4884 | + wpsc_get_te_advanced(); | |
| 4885 | + }); | |
| 4886 | +} | |
| 4887 | + | |
| 4888 | +/** | |
| 4889 | + * Reset advanced settings | |
| 4890 | + */ | |
| 4891 | +function wpsc_reset_te_advanced(el, nonce) { | |
| 4892 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 4893 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 4894 | + const data = { action: "wpsc_reset_te_advanced", _ajax_nonce: nonce }; | |
| 4895 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4896 | + wpsc_get_te_advanced(); | |
| 4897 | + }); | |
| 4898 | +} | |
| 4899 | + | |
| 4900 | +/** | |
| 4901 | + * Get agent working hrs settings | |
| 4902 | + */ | |
| 4903 | +function wpsc_get_agents_working_hrs(is_humbargar = false) { | |
| 4904 | + if (is_humbargar) { | |
| 4905 | + wpsc_toggle_humbargar(); | |
| 4906 | + } | |
| 4907 | + | |
| 4908 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 4909 | + jQuery( | |
| 4910 | + ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs" | |
| 4911 | + ).addClass("active"); | |
| 4912 | + jQuery(".wpsc-humbargar-title").html( | |
| 4913 | + supportcandy.humbargar_titles.working_hrs | |
| 4914 | + ); | |
| 4915 | + | |
| 4916 | + window.history.replaceState( | |
| 4917 | + {}, | |
| 4918 | + null, | |
| 4919 | + "admin.php?page=wpsc-support-agents§ion=working-hrs" | |
| 4920 | + ); | |
| 4921 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 4922 | + | |
| 4923 | + wpsc_scroll_top(); | |
| 4924 | + | |
| 4925 | + var data = { action: "wpsc_get_agents_working_hrs" }; | |
| 4926 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4927 | + jQuery(".wpsc-setting-body").html(response); | |
| 4928 | + wpsc_reset_responsive_style(); | |
| 4929 | + wpsc_get_agents_wh_hrs(); | |
| 4930 | + }); | |
| 4931 | +} | |
| 4932 | + | |
| 4933 | +/** | |
| 4934 | + * Get working hrs of given agent id | |
| 4935 | + */ | |
| 4936 | +function wpsc_get_agents_wh_hrs() { | |
| 4937 | + jQuery("button.tab.exceptions").removeClass("active"); | |
| 4938 | + jQuery("button.tab.working-hrs").addClass("active"); | |
| 4939 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 861 | 4940 | var data = { |
| 862 | - action: 'wpsc_appearance_settings', | |
| 863 | - setting_action : 'get_appearance_login_form' | |
| 4941 | + action: "wpsc_get_agents_wh_hrs", | |
| 4942 | + agent_id: supportcandy.temp.agent_id, | |
| 4943 | + _ajax_nonce: supportcandy.nonce, | |
| 864 | 4944 | }; |
| 4945 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4946 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 4947 | + }); | |
| 4948 | +} | |
| 865 | 4949 | |
| 866 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 867 | - jQuery('.wpsc_setting_col2').html(response); | |
| 4950 | +/** | |
| 4951 | + * Get agent working hrs exceptions | |
| 4952 | + */ | |
| 4953 | +function wpsc_get_agents_wh_exceptions() { | |
| 4954 | + jQuery("button.tab.working-hrs").removeClass("active"); | |
| 4955 | + jQuery("button.tab.exceptions").addClass("active"); | |
| 4956 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 4957 | + var data = { | |
| 4958 | + action: "wpsc_get_agents_wh_exceptions", | |
| 4959 | + agent_id: supportcandy.temp.agent_id, | |
| 4960 | + _ajax_nonce: supportcandy.nonce, | |
| 4961 | + }; | |
| 4962 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4963 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 868 | 4964 | }); |
| 869 | 4965 | } |
| 870 | 4966 | |
| 871 | -function wpsc_set_appearance_login_form(){ | |
| 872 | - jQuery('.wpsc_submit_wait').show(); | |
| 873 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_login_form')[0]); | |
| 874 | - | |
| 875 | - jQuery.ajax({ | |
| 876 | - url: wpsc_admin.ajax_url, | |
| 877 | - type: 'POST', | |
| 878 | - data: dataform, | |
| 879 | - processData: false, | |
| 880 | - contentType: false | |
| 881 | - }) | |
| 882 | - .done(function (response_str) { | |
| 883 | - var response = JSON.parse(response_str); | |
| 884 | - jQuery('.wpsc_submit_wait').hide(); | |
| 885 | - if (response.sucess_status=='1') { | |
| 886 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 887 | - } | |
| 888 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 889 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 4967 | +/** | |
| 4968 | + * Get agent working hrs settings | |
| 4969 | + */ | |
| 4970 | +function wpsc_get_agent_working_hrs(is_humbargar = false) { | |
| 4971 | + if (is_humbargar) { | |
| 4972 | + wpsc_toggle_humbargar(); | |
| 4973 | + } | |
| 4974 | + | |
| 4975 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 4976 | + jQuery( | |
| 4977 | + ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs" | |
| 4978 | + ).addClass("active"); | |
| 4979 | + jQuery(".wpsc-humbargar-title").html( | |
| 4980 | + supportcandy.humbargar_titles.working_hrs | |
| 4981 | + ); | |
| 4982 | + | |
| 4983 | + window.history.replaceState( | |
| 4984 | + {}, | |
| 4985 | + null, | |
| 4986 | + "admin.php?page=wpsc-support-agents§ion=working-hrs" | |
| 4987 | + ); | |
| 4988 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 4989 | + | |
| 4990 | + wpsc_scroll_top(); | |
| 4991 | + | |
| 4992 | + var data = { action: "wpsc_get_agent_working_hrs" }; | |
| 4993 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 4994 | + jQuery(".wpsc-setting-body").html(response); | |
| 4995 | + wpsc_reset_responsive_style(); | |
| 4996 | + window.location.reload(); | |
| 890 | 4997 | }); |
| 891 | 4998 | } |
| 892 | -/* | |
| 893 | - * Appearance Create Ticket reset Settings | |
| 4999 | + | |
| 5000 | +/** | |
| 5001 | + * Get all agent leaves | |
| 894 | 5002 | */ |
| 895 | -function wpsc_reset_default_create_ticket_settings(nonce) { | |
| 5003 | +function wpsc_get_agent_leaves(is_humbargar = false) { | |
| 5004 | + if (is_humbargar) { | |
| 5005 | + wpsc_toggle_humbargar(); | |
| 5006 | + } | |
| 896 | 5007 | |
| 5008 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 5009 | + jQuery(".wpsc-setting-nav.leaves, .wpsc-humbargar-menu-item.leaves").addClass( | |
| 5010 | + "active" | |
| 5011 | + ); | |
| 5012 | + jQuery(".wpsc-humbargar-title").html(supportcandy.humbargar_titles.leaves); | |
| 5013 | + | |
| 5014 | + window.history.replaceState( | |
| 5015 | + {}, | |
| 5016 | + null, | |
| 5017 | + "admin.php?page=wpsc-support-agents§ion=leaves" | |
| 5018 | + ); | |
| 5019 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 5020 | + | |
| 5021 | + wpsc_scroll_top(); | |
| 5022 | + | |
| 5023 | + var data = { action: "wpsc_get_agent_leaves" }; | |
| 5024 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5025 | + jQuery(".wpsc-setting-body").html(response); | |
| 5026 | + wpsc_reset_responsive_style(); | |
| 5027 | + }); | |
| 5028 | +} | |
| 5029 | + | |
| 5030 | +/** | |
| 5031 | + * Get add agent leaves | |
| 5032 | + */ | |
| 5033 | +function wpsc_get_add_agent_leaves(dateSelected, _ajax_nonce) { | |
| 5034 | + supportcandy.temp.dateSelected = dateSelected; | |
| 5035 | + wpsc_show_modal(); | |
| 897 | 5036 | var data = { |
| 898 | - action: 'wpsc_appearance_settings', | |
| 899 | - setting_action : 'get_reset_default_create_ticket_settings', | |
| 900 | - _ajax_nonce: nonce | |
| 5037 | + action: "wpsc_get_add_agent_leaves", | |
| 5038 | + dateSelected, | |
| 5039 | + _ajax_nonce, | |
| 901 | 5040 | }; |
| 5041 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5042 | + // Set to modal. | |
| 5043 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5044 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5045 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5046 | + // Display modal. | |
| 5047 | + wpsc_show_modal_inner_container(); | |
| 5048 | + }); | |
| 5049 | +} | |
| 902 | 5050 | |
| 903 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 904 | - var response = JSON.parse(response_str); | |
| 905 | - if (response.sucess_status=='1') { | |
| 906 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 907 | - } | |
| 908 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 909 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 910 | - wpsc_get_appearance_create_ticket() | |
| 911 | - }); | |
| 5051 | +/** | |
| 5052 | + * Set add agent leaves | |
| 5053 | + */ | |
| 5054 | +function wpsc_set_add_agent_leaves(el) { | |
| 5055 | + const form = jQuery(".wpsc-frm-agent-holiday-actions")[0]; | |
| 5056 | + const dataform = new FormData(form); | |
| 5057 | + | |
| 5058 | + var agents = dataform.getAll("agents[]"); | |
| 5059 | + if (!agents.length) { | |
| 5060 | + alert(supportcandy.translations.req_fields_missing); | |
| 5061 | + return; | |
| 5062 | + } | |
| 5063 | + | |
| 5064 | + dataform.append("dateSelected", supportcandy.temp.dateSelected); | |
| 5065 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5066 | + jQuery | |
| 5067 | + .ajax({ | |
| 5068 | + url: supportcandy.ajax_url, | |
| 5069 | + type: "POST", | |
| 5070 | + data: dataform, | |
| 5071 | + processData: false, | |
| 5072 | + contentType: false, | |
| 5073 | + }) | |
| 5074 | + .done(function (response) { | |
| 5075 | + calendar.refetchEvents(); | |
| 5076 | + wpsc_close_modal(); | |
| 5077 | + }); | |
| 912 | 5078 | } |
| 913 | -/* | |
| 914 | - * Appearance Madal Window Settings | |
| 5079 | + | |
| 5080 | +/** | |
| 5081 | + * Delete agent leave | |
| 915 | 5082 | */ |
| 916 | -function wpsc_get_appearance_madal_window(){ | |
| 917 | - | |
| 918 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 919 | - jQuery('#wpsc_appearance_modal_window').addClass('active'); | |
| 920 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 921 | - | |
| 5083 | +function wpsc_delete_agent_leave(id, nonce) { | |
| 5084 | + var flag = confirm(supportcandy.translations.deleteLeaveConfirmation); | |
| 5085 | + if (!flag) { | |
| 5086 | + return; | |
| 5087 | + } | |
| 5088 | + | |
| 922 | 5089 | var data = { |
| 923 | - action: 'wpsc_appearance_settings', | |
| 924 | - setting_action : 'get_appearance_modal_window' | |
| 5090 | + action: "wpsc_delete_agent_leave", | |
| 5091 | + holidayId: id, | |
| 5092 | + _ajax_nonce: nonce, | |
| 925 | 5093 | }; |
| 5094 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5095 | + calendar.refetchEvents(); | |
| 5096 | + }); | |
| 5097 | +} | |
| 926 | 5098 | |
| 927 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 928 | - jQuery('.wpsc_setting_col2').html(response); | |
| 5099 | +/** | |
| 5100 | + * User registration otp email template | |
| 5101 | + */ | |
| 5102 | +function wpsc_get_en_user_reg_otp(is_humbargar = false) { | |
| 5103 | + if (is_humbargar) { | |
| 5104 | + wpsc_toggle_humbargar(); | |
| 5105 | + } | |
| 5106 | + | |
| 5107 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 5108 | + jQuery( | |
| 5109 | + ".wpsc-setting-nav.registration-otp, .wpsc-humbargar-menu-item.registration-otp" | |
| 5110 | + ).addClass("active"); | |
| 5111 | + jQuery(".wpsc-humbargar-title").html( | |
| 5112 | + supportcandy.humbargar_titles.registration_otp | |
| 5113 | + ); | |
| 5114 | + | |
| 5115 | + window.history.replaceState( | |
| 5116 | + {}, | |
| 5117 | + null, | |
| 5118 | + "admin.php?page=wpsc-email-notifications§ion=registration-otp" | |
| 5119 | + ); | |
| 5120 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 5121 | + | |
| 5122 | + wpsc_scroll_top(); | |
| 5123 | + | |
| 5124 | + var data = { action: "wpsc_get_en_user_reg_otp" }; | |
| 5125 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5126 | + jQuery(".wpsc-setting-body").html(response); | |
| 5127 | + wpsc_reset_responsive_style(); | |
| 929 | 5128 | }); |
| 930 | 5129 | } |
| 931 | 5130 | |
| 932 | -function wpsc_set_appearance_modal_window_settings(){ | |
| 933 | - | |
| 934 | - jQuery('.wpsc_submit_wait').show(); | |
| 935 | - var dataform = new FormData(jQuery('#wpsc_frm_appearance_modal_window_settings')[0]); | |
| 936 | - | |
| 937 | - jQuery.ajax({ | |
| 938 | - url: wpsc_admin.ajax_url, | |
| 939 | - type: 'POST', | |
| 940 | - data: dataform, | |
| 941 | - processData: false, | |
| 942 | - contentType: false | |
| 943 | - }) | |
| 944 | - .done(function (response_str) { | |
| 945 | - var response = JSON.parse(response_str); | |
| 946 | - jQuery('.wpsc_submit_wait').hide(); | |
| 947 | - if (response.sucess_status=='1') { | |
| 948 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 949 | - } | |
| 950 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 951 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 5131 | +/** | |
| 5132 | + * Set user registration otp email template | |
| 5133 | + */ | |
| 5134 | +function wpsc_set_en_user_reg_otp(el) { | |
| 5135 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5136 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5137 | + var form = jQuery(".wpsc-frm-en-user-reg-otp")[0]; | |
| 5138 | + var dataform = new FormData(form); | |
| 5139 | + if (dataform.get("editor") == "html") { | |
| 5140 | + dataform.append("body", tinyMCE.get("wpsc-en-body").getContent()); | |
| 5141 | + } | |
| 5142 | + jQuery | |
| 5143 | + .ajax({ | |
| 5144 | + url: supportcandy.ajax_url, | |
| 5145 | + type: "POST", | |
| 5146 | + data: dataform, | |
| 5147 | + processData: false, | |
| 5148 | + contentType: false, | |
| 5149 | + }) | |
| 5150 | + .done(function (res) { | |
| 5151 | + wpsc_get_en_user_reg_otp(); | |
| 5152 | + }); | |
| 5153 | +} | |
| 5154 | + | |
| 5155 | +/** | |
| 5156 | + * Reset user registration otp email template | |
| 5157 | + */ | |
| 5158 | +function wpsc_reset_en_user_reg_otp(el, nonce) { | |
| 5159 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5160 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5161 | + const data = { action: "wpsc_reset_en_user_reg_otp", _ajax_nonce: nonce }; | |
| 5162 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5163 | + wpsc_get_en_user_reg_otp(); | |
| 952 | 5164 | }); |
| 953 | 5165 | } |
| 954 | 5166 | |
| 955 | -function wpsc_get_appearance_signup(){ | |
| 956 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 957 | - jQuery('#wpsc_appearance_signup_form').addClass('active'); | |
| 958 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 959 | - | |
| 5167 | +/** | |
| 5168 | + * Get guest login otp email template | |
| 5169 | + * | |
| 5170 | + * @param {boolean} is_humbargar | |
| 5171 | + */ | |
| 5172 | +function wpsc_get_en_guest_login_otp(is_humbargar = false) { | |
| 5173 | + if (is_humbargar) { | |
| 5174 | + wpsc_toggle_humbargar(); | |
| 5175 | + } | |
| 5176 | + | |
| 5177 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 5178 | + jQuery( | |
| 5179 | + ".wpsc-setting-nav.guest-login-otp, .wpsc-humbargar-menu-item.guest-login-otp" | |
| 5180 | + ).addClass("active"); | |
| 5181 | + jQuery(".wpsc-humbargar-title").html( | |
| 5182 | + supportcandy.humbargar_titles.registration_otp | |
| 5183 | + ); | |
| 5184 | + | |
| 5185 | + window.history.replaceState( | |
| 5186 | + {}, | |
| 5187 | + null, | |
| 5188 | + "admin.php?page=wpsc-email-notifications§ion=guest-login-otp" | |
| 5189 | + ); | |
| 5190 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 5191 | + | |
| 5192 | + wpsc_scroll_top(); | |
| 5193 | + | |
| 5194 | + var data = { action: "wpsc_get_en_guest_login_otp" }; | |
| 5195 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5196 | + jQuery(".wpsc-setting-body").html(response); | |
| 5197 | + wpsc_reset_responsive_style(); | |
| 5198 | + }); | |
| 5199 | +} | |
| 5200 | + | |
| 5201 | +/** | |
| 5202 | + * Set guest login otp email template | |
| 5203 | + */ | |
| 5204 | +function wpsc_set_en_guest_login_otp(el) { | |
| 5205 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5206 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5207 | + var form = jQuery(".wpsc-frm-en-guest-login-otp")[0]; | |
| 5208 | + var dataform = new FormData(form); | |
| 5209 | + if (dataform.get("editor") == "html") { | |
| 5210 | + dataform.append("body", tinyMCE.get("wpsc-en-body").getContent()); | |
| 5211 | + } | |
| 5212 | + jQuery | |
| 5213 | + .ajax({ | |
| 5214 | + url: supportcandy.ajax_url, | |
| 5215 | + type: "POST", | |
| 5216 | + data: dataform, | |
| 5217 | + processData: false, | |
| 5218 | + contentType: false, | |
| 5219 | + }) | |
| 5220 | + .done(function (res) { | |
| 5221 | + wpsc_get_en_guest_login_otp(); | |
| 5222 | + }); | |
| 5223 | +} | |
| 5224 | + | |
| 5225 | +/** | |
| 5226 | + * Reset guest login otp email template | |
| 5227 | + */ | |
| 5228 | +function wpsc_reset_en_guest_login_otp(el, nonce) { | |
| 5229 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5230 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5231 | + const data = { action: "wpsc_reset_en_guest_login_otp", _ajax_nonce: nonce }; | |
| 5232 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5233 | + wpsc_get_en_guest_login_otp(); | |
| 5234 | + }); | |
| 5235 | +} | |
| 5236 | + | |
| 5237 | +/** | |
| 5238 | + * Get ticket widget biographical info | |
| 5239 | + */ | |
| 5240 | +function wpsc_get_tw_biographical_info() { | |
| 5241 | + wpsc_show_modal(); | |
| 5242 | + var data = { action: "wpsc_get_tw_biographical_info" }; | |
| 5243 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5244 | + // Set to modal. | |
| 5245 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5246 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5247 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5248 | + // Display modal. | |
| 5249 | + wpsc_show_modal_inner_container(); | |
| 5250 | + }); | |
| 5251 | +} | |
| 5252 | + | |
| 5253 | +/** | |
| 5254 | + * Set ticket widget biographical info | |
| 5255 | + */ | |
| 5256 | +function wpsc_set_tw_biographical_info(el) { | |
| 5257 | + var form = jQuery(".wpsc-frm-edit-biographical-info")[0]; | |
| 5258 | + var dataform = new FormData(form); | |
| 5259 | + | |
| 5260 | + if (dataform.get("label").trim() == "") { | |
| 5261 | + alert(supportcandy.translations.req_fields_missing); | |
| 5262 | + return; | |
| 5263 | + } | |
| 5264 | + | |
| 5265 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5266 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5267 | + | |
| 5268 | + jQuery | |
| 5269 | + .ajax({ | |
| 5270 | + url: supportcandy.ajax_url, | |
| 5271 | + type: "POST", | |
| 5272 | + data: dataform, | |
| 5273 | + processData: false, | |
| 5274 | + contentType: false, | |
| 5275 | + }) | |
| 5276 | + .done(function (res) { | |
| 5277 | + wpsc_close_modal(); | |
| 5278 | + wpsc_get_ticket_widget(); | |
| 5279 | + }); | |
| 5280 | +} | |
| 5281 | + | |
| 5282 | +/** | |
| 5283 | + * Get edit agent ticket list items | |
| 5284 | + */ | |
| 5285 | +function wpsc_get_edit_agent_tl_item(slug, _ajax_nonce) { | |
| 5286 | + wpsc_show_modal(); | |
| 5287 | + var data = { action: "wpsc_get_edit_agent_tl_item", slug, _ajax_nonce }; | |
| 5288 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5289 | + // Set to modal. | |
| 5290 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5291 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5292 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5293 | + // Display modal. | |
| 5294 | + wpsc_show_modal_inner_container(); | |
| 5295 | + }); | |
| 5296 | +} | |
| 5297 | + | |
| 5298 | +/** | |
| 5299 | + * Set edit agent ticket list items | |
| 5300 | + */ | |
| 5301 | +function wpsc_set_edit_agent_tl_item(el) { | |
| 5302 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5303 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5304 | + | |
| 5305 | + var form = jQuery(".frm-edit-agent-tl-items")[0]; | |
| 5306 | + var dataform = new FormData(form); | |
| 5307 | + jQuery | |
| 5308 | + .ajax({ | |
| 5309 | + url: supportcandy.ajax_url, | |
| 5310 | + type: "POST", | |
| 5311 | + data: dataform, | |
| 5312 | + processData: false, | |
| 5313 | + contentType: false, | |
| 5314 | + }) | |
| 5315 | + .done(function (res) { | |
| 5316 | + wpsc_close_modal(); | |
| 5317 | + wpsc_get_agent_tl_items(); | |
| 5318 | + }); | |
| 5319 | +} | |
| 5320 | + | |
| 5321 | +/** | |
| 5322 | + * Get edit agent filter list items | |
| 5323 | + */ | |
| 5324 | +function wpsc_get_edit_agent_filter_item(slug, _ajax_nonce) { | |
| 5325 | + wpsc_show_modal(); | |
| 5326 | + var data = { action: "wpsc_get_edit_agent_filter_item", slug, _ajax_nonce }; | |
| 5327 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5328 | + // Set to modal. | |
| 5329 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5330 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5331 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5332 | + // Display modal. | |
| 5333 | + wpsc_show_modal_inner_container(); | |
| 5334 | + }); | |
| 5335 | +} | |
| 5336 | + | |
| 5337 | +/** | |
| 5338 | + * Set edit agent filter list items | |
| 5339 | + */ | |
| 5340 | +function wpsc_set_edit_agent_filter_item(el) { | |
| 5341 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5342 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5343 | + | |
| 5344 | + var form = jQuery(".frm-edit-agent-fl-items")[0]; | |
| 5345 | + var dataform = new FormData(form); | |
| 5346 | + jQuery | |
| 5347 | + .ajax({ | |
| 5348 | + url: supportcandy.ajax_url, | |
| 5349 | + type: "POST", | |
| 5350 | + data: dataform, | |
| 5351 | + processData: false, | |
| 5352 | + contentType: false, | |
| 5353 | + }) | |
| 5354 | + .done(function (res) { | |
| 5355 | + wpsc_close_modal(); | |
| 5356 | + wpsc_get_agent_filter_items(); | |
| 5357 | + }); | |
| 5358 | +} | |
| 5359 | + | |
| 5360 | +/** | |
| 5361 | + * Get edit company working hrs exception | |
| 5362 | + */ | |
| 5363 | +function wpsc_get_edit_wh_exception(exception_id, _ajax_nonce) { | |
| 5364 | + wpsc_show_modal(); | |
| 960 | 5365 | var data = { |
| 961 | - action: 'wpsc_appearance_settings', | |
| 962 | - setting_action : 'get_appearance_signup' | |
| 5366 | + action: "wpsc_get_edit_wh_exception", | |
| 5367 | + exception_id, | |
| 5368 | + _ajax_nonce, | |
| 963 | 5369 | }; |
| 5370 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5371 | + // Set to modal. | |
| 5372 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5373 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5374 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5375 | + // Display modal. | |
| 5376 | + wpsc_show_modal_inner_container(); | |
| 5377 | + }); | |
| 5378 | +} | |
| 964 | 5379 | |
| 965 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 966 | - jQuery('.wpsc_setting_col2').html(response); | |
| 5380 | +/** | |
| 5381 | + * Delete company working hrs exception | |
| 5382 | + */ | |
| 5383 | +function wpsc_delete_wh_exception(exception_id, _ajax_nonce) { | |
| 5384 | + var flag = confirm(supportcandy.translations.confirm); | |
| 5385 | + if (!flag) { | |
| 5386 | + return; | |
| 5387 | + } | |
| 5388 | + var data = { action: "wpsc_delete_wh_exception", exception_id, _ajax_nonce }; | |
| 5389 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 5390 | + wpsc_get_wh_exceptions(); | |
| 967 | 5391 | }); |
| 968 | 5392 | } |
| 969 | 5393 | |
| 970 | -function wpsc_set_appearance_sign_up(){ | |
| 971 | - jQuery('.wpsc_submit_wait').show(); | |
| 972 | - var dataform = new FormData(jQuery('#wpsc_frm_appearnce_signup_settings')[0]); | |
| 973 | - | |
| 974 | - jQuery.ajax({ | |
| 975 | - url: wpsc_admin.ajax_url, | |
| 976 | - type: 'POST', | |
| 977 | - data: dataform, | |
| 978 | - processData: false, | |
| 979 | - contentType: false | |
| 980 | - }) | |
| 981 | - | |
| 982 | - .done(function (response_str) | |
| 983 | - { | |
| 984 | - var response = JSON.parse(response_str); | |
| 985 | - jQuery('.wpsc_submit_wait').hide(); | |
| 986 | - if (response.sucess_status=='1') { | |
| 987 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 988 | - } | |
| 989 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 990 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 5394 | +/** | |
| 5395 | + * Get edit customer ticket list items | |
| 5396 | + */ | |
| 5397 | +function wpsc_get_edit_customer_tl_item(slug, _ajax_nonce) { | |
| 5398 | + wpsc_show_modal(); | |
| 5399 | + var data = { action: "wpsc_get_edit_customer_tl_item", slug, _ajax_nonce }; | |
| 5400 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5401 | + // Set to modal. | |
| 5402 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5403 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5404 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5405 | + // Display modal. | |
| 5406 | + wpsc_show_modal_inner_container(); | |
| 991 | 5407 | }); |
| 992 | 5408 | } |
| 993 | -/* | |
| 994 | - * Appearance Modal Window reset Settings | |
| 5409 | + | |
| 5410 | +/** | |
| 5411 | + * Set edit customer ticket list items | |
| 995 | 5412 | */ |
| 996 | -function wpsc_reset_default_modal_window_settings(nonce) { | |
| 5413 | +function wpsc_set_edit_customer_tl_item(el) { | |
| 5414 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5415 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 997 | 5416 | |
| 5417 | + var form = jQuery(".frm-edit-customer-tl-items")[0]; | |
| 5418 | + var dataform = new FormData(form); | |
| 5419 | + jQuery | |
| 5420 | + .ajax({ | |
| 5421 | + url: supportcandy.ajax_url, | |
| 5422 | + type: "POST", | |
| 5423 | + data: dataform, | |
| 5424 | + processData: false, | |
| 5425 | + contentType: false, | |
| 5426 | + }) | |
| 5427 | + .done(function (res) { | |
| 5428 | + wpsc_close_modal(); | |
| 5429 | + wpsc_get_customer_tl_items(); | |
| 5430 | + }); | |
| 5431 | +} | |
| 5432 | + | |
| 5433 | +/** | |
| 5434 | + * Get edit coustomer ticket filter items | |
| 5435 | + */ | |
| 5436 | +function wpsc_get_edit_ctl_filter_item(slug, _ajax_nonce) { | |
| 5437 | + wpsc_show_modal(); | |
| 5438 | + var data = { action: "wpsc_get_edit_ctl_filter_item", slug, _ajax_nonce }; | |
| 5439 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5440 | + // Set to modal. | |
| 5441 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5442 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5443 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5444 | + // Display modal. | |
| 5445 | + wpsc_show_modal_inner_container(); | |
| 5446 | + }); | |
| 5447 | +} | |
| 5448 | + | |
| 5449 | +/** | |
| 5450 | + * Set edit coustomer ticket filter items | |
| 5451 | + */ | |
| 5452 | +function wpsc_set_edit_ctl_filter_item(el) { | |
| 5453 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5454 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5455 | + | |
| 5456 | + var form = jQuery(".frm-edit-customer-fl-items")[0]; | |
| 5457 | + var dataform = new FormData(form); | |
| 5458 | + jQuery | |
| 5459 | + .ajax({ | |
| 5460 | + url: supportcandy.ajax_url, | |
| 5461 | + type: "POST", | |
| 5462 | + data: dataform, | |
| 5463 | + processData: false, | |
| 5464 | + contentType: false, | |
| 5465 | + }) | |
| 5466 | + .done(function (res) { | |
| 5467 | + wpsc_close_modal(); | |
| 5468 | + wpsc_get_customer_filter_items(); | |
| 5469 | + }); | |
| 5470 | +} | |
| 5471 | + | |
| 5472 | +/** | |
| 5473 | + * Get ticket tag settings | |
| 5474 | + */ | |
| 5475 | +function wpsc_get_ticket_tags() { | |
| 5476 | + supportcandy.current_tab = "ticket-tags-list"; | |
| 5477 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 5478 | + jQuery( | |
| 5479 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5480 | + ).addClass("active"); | |
| 5481 | + | |
| 5482 | + window.history.replaceState( | |
| 5483 | + {}, | |
| 5484 | + null, | |
| 5485 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5486 | + supportcandy.current_section + | |
| 5487 | + "&tab=" + | |
| 5488 | + supportcandy.current_tab | |
| 5489 | + ); | |
| 5490 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 5491 | + | |
| 5492 | + wpsc_scroll_top(); | |
| 5493 | + | |
| 5494 | + var data = { action: "wpsc_get_ticket_tags" }; | |
| 5495 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5496 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 5497 | + wpsc_reset_responsive_style(); | |
| 5498 | + }); | |
| 5499 | +} | |
| 5500 | + | |
| 5501 | +/** | |
| 5502 | + * Set add ticket tag | |
| 5503 | + */ | |
| 5504 | +function wpsc_set_add_ticket_tags(el) { | |
| 5505 | + var form = jQuery(".wpsc-frm-add-ms-ticket-tags")[0]; | |
| 5506 | + var dataform = new FormData(form); | |
| 5507 | + | |
| 5508 | + if (!dataform.get("name")) { | |
| 5509 | + alert(supportcandy.translations.req_fields_missing); | |
| 5510 | + return; | |
| 5511 | + } | |
| 5512 | + | |
| 5513 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5514 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5515 | + | |
| 5516 | + jQuery | |
| 5517 | + .ajax({ | |
| 5518 | + url: supportcandy.ajax_url, | |
| 5519 | + type: "POST", | |
| 5520 | + data: dataform, | |
| 5521 | + processData: false, | |
| 5522 | + contentType: false, | |
| 5523 | + }) | |
| 5524 | + .done(function (res) { | |
| 5525 | + wpsc_close_modal(); | |
| 5526 | + wpsc_get_ticket_tags(); | |
| 5527 | + }); | |
| 5528 | +} | |
| 5529 | + | |
| 5530 | +/** | |
| 5531 | + * Update tag | |
| 5532 | + */ | |
| 5533 | +function wpsc_get_edit_ticket_tags(id, nonce) { | |
| 5534 | + wpsc_show_modal(); | |
| 5535 | + var data = { action: "wpsc_get_edit_ticket_tags", id, _ajax_nonce: nonce }; | |
| 5536 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 5537 | + // Set to modal. | |
| 5538 | + jQuery(".wpsc-modal-header").text(res.title); | |
| 5539 | + jQuery(".wpsc-modal-body").html(res.body); | |
| 5540 | + jQuery(".wpsc-modal-footer").html(res.footer); | |
| 5541 | + // Display modal. | |
| 5542 | + wpsc_show_modal_inner_container(); | |
| 5543 | + }); | |
| 5544 | +} | |
| 5545 | + | |
| 5546 | +function wpsc_set_edit_ticket_tags(el) { | |
| 5547 | + var form = jQuery(".wpsc-frm-edit-ticket-tag")[0]; | |
| 5548 | + var dataform = new FormData(form); | |
| 5549 | + | |
| 5550 | + if (!dataform.get("name")) { | |
| 5551 | + alert(supportcandy.translations.req_fields_missing); | |
| 5552 | + return; | |
| 5553 | + } | |
| 5554 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5555 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5556 | + | |
| 5557 | + jQuery | |
| 5558 | + .ajax({ | |
| 5559 | + url: supportcandy.ajax_url, | |
| 5560 | + type: "POST", | |
| 5561 | + data: dataform, | |
| 5562 | + processData: false, | |
| 5563 | + contentType: false, | |
| 5564 | + }) | |
| 5565 | + .done(function (res) { | |
| 5566 | + wpsc_close_modal(); | |
| 5567 | + wpsc_get_ticket_tags(); | |
| 5568 | + }); | |
| 5569 | +} | |
| 5570 | + | |
| 5571 | +/** | |
| 5572 | + * Delete ticket tag modal | |
| 5573 | + */ | |
| 5574 | +function wpsc_set_delete_ticket_tags(id, nonce) { | |
| 5575 | + var flag = confirm(supportcandy.translations.confirm); | |
| 5576 | + if (!flag) { | |
| 5577 | + return; | |
| 5578 | + } | |
| 5579 | + | |
| 5580 | + var data = { action: "wpsc_set_delete_ticket_tags", id, _ajax_nonce: nonce }; | |
| 5581 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5582 | + wpsc_get_ticket_tags(); | |
| 5583 | + }); | |
| 5584 | +} | |
| 5585 | + | |
| 5586 | +/** | |
| 5587 | + * Get ticket widget ticket tags | |
| 5588 | + */ | |
| 5589 | +function wpsc_get_tw_ticket_tags() { | |
| 5590 | + wpsc_show_modal(); | |
| 5591 | + var data = { action: "wpsc_get_tw_ticket_tags" }; | |
| 5592 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5593 | + // Set to modal. | |
| 5594 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5595 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5596 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5597 | + // Display modal. | |
| 5598 | + wpsc_show_modal_inner_container(); | |
| 5599 | + }); | |
| 5600 | +} | |
| 5601 | + | |
| 5602 | +/** | |
| 5603 | + * Set ticket widget ticket tags | |
| 5604 | + */ | |
| 5605 | +function wpsc_set_tw_ticket_tags(el) { | |
| 5606 | + var form = jQuery(".wpsc-frm-edit-tags")[0]; | |
| 5607 | + var dataform = new FormData(form); | |
| 5608 | + | |
| 5609 | + if (dataform.get("label").trim() == "") { | |
| 5610 | + alert(supportcandy.translations.req_fields_missing); | |
| 5611 | + return; | |
| 5612 | + } | |
| 5613 | + | |
| 5614 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5615 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5616 | + | |
| 5617 | + jQuery | |
| 5618 | + .ajax({ | |
| 5619 | + url: supportcandy.ajax_url, | |
| 5620 | + type: "POST", | |
| 5621 | + data: dataform, | |
| 5622 | + processData: false, | |
| 5623 | + contentType: false, | |
| 5624 | + }) | |
| 5625 | + .done(function (res) { | |
| 5626 | + wpsc_close_modal(); | |
| 5627 | + wpsc_get_ticket_widget(); | |
| 5628 | + }); | |
| 5629 | +} | |
| 5630 | + | |
| 5631 | +/** | |
| 5632 | + * Get ticket tags modal UI | |
| 5633 | + */ | |
| 5634 | +function wpsc_it_get_edit_ticket_tags(ticket_id, nonce) { | |
| 5635 | + wpsc_show_modal(); | |
| 998 | 5636 | var data = { |
| 999 | - action: 'wpsc_appearance_settings', | |
| 1000 | - setting_action : 'get_reset_default_modal_window_settings', | |
| 1001 | - _ajax_nonce: nonce | |
| 5637 | + action: "wpsc_it_get_edit_ticket_tags", | |
| 5638 | + ticket_id, | |
| 5639 | + _ajax_nonce: nonce, | |
| 1002 | 5640 | }; |
| 1003 | - | |
| 1004 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 1005 | - var response = JSON.parse(response_str); | |
| 1006 | - if (response.sucess_status=='1') { | |
| 1007 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1008 | - } | |
| 1009 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1010 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1011 | - wpsc_get_appearance_madal_window() | |
| 5641 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5642 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 5643 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 5644 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 5645 | + wpsc_show_modal_inner_container(); | |
| 1012 | 5646 | }); |
| 1013 | 5647 | } |
| 1014 | 5648 | |
| 1015 | -function wpsc_get_terms_and_condition_settings(){ | |
| 1016 | - | |
| 1017 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1018 | - jQuery('#wpsc_settings_term_and_conditions').addClass('active'); | |
| 1019 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 1020 | - | |
| 5649 | +/** | |
| 5650 | + * Get appearence settings | |
| 5651 | + */ | |
| 5652 | +function wpsc_get_ticket_tags_settings(is_humbargar = false) { | |
| 5653 | + if (is_humbargar) { | |
| 5654 | + wpsc_toggle_humbargar(); | |
| 5655 | + } | |
| 5656 | + | |
| 5657 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 5658 | + jQuery( | |
| 5659 | + ".wpsc-setting-nav.ticket-tags, .wpsc-humbargar-menu-item.ticket-tags" | |
| 5660 | + ).addClass("active"); | |
| 5661 | + jQuery(".wpsc-humbargar-title").html( | |
| 5662 | + supportcandy.humbargar_titles.tickettags | |
| 5663 | + ); | |
| 5664 | + | |
| 5665 | + if (supportcandy.current_section !== "ticket-tags") { | |
| 5666 | + supportcandy.current_section = "ticket-tags"; | |
| 5667 | + supportcandy.current_tab = "general"; | |
| 5668 | + } | |
| 5669 | + | |
| 5670 | + window.history.replaceState( | |
| 5671 | + {}, | |
| 5672 | + null, | |
| 5673 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5674 | + supportcandy.current_section + | |
| 5675 | + "&tab=" + | |
| 5676 | + supportcandy.current_tab | |
| 5677 | + ); | |
| 5678 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 5679 | + | |
| 5680 | + wpsc_scroll_top(); | |
| 5681 | + | |
| 1021 | 5682 | var data = { |
| 1022 | - action: 'wpsc_settings', | |
| 1023 | - setting_action : 'get_terms_and_condition_settings' | |
| 5683 | + action: "wpsc_get_ticket_tags_settings", | |
| 5684 | + tab: supportcandy.current_tab, | |
| 1024 | 5685 | }; |
| 5686 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5687 | + jQuery(".wpsc-setting-body").html(response); | |
| 5688 | + wpsc_reset_responsive_style(); | |
| 5689 | + jQuery( | |
| 5690 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5691 | + ).trigger("click"); | |
| 5692 | + }); | |
| 5693 | +} | |
| 1025 | 5694 | |
| 1026 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1027 | - jQuery('.wpsc_setting_col2').html(response); | |
| 5695 | +/** | |
| 5696 | + * Get general appearence settings | |
| 5697 | + */ | |
| 5698 | +function wpsc_ticket_tags_get_general_settings() { | |
| 5699 | + supportcandy.current_tab = "general"; | |
| 5700 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 5701 | + jQuery( | |
| 5702 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5703 | + ).addClass("active"); | |
| 5704 | + | |
| 5705 | + window.history.replaceState( | |
| 5706 | + {}, | |
| 5707 | + null, | |
| 5708 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5709 | + supportcandy.current_section + | |
| 5710 | + "&tab=" + | |
| 5711 | + supportcandy.current_tab | |
| 5712 | + ); | |
| 5713 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 5714 | + | |
| 5715 | + wpsc_scroll_top(); | |
| 5716 | + var data = { action: "wpsc_ticket_tags_get_general_settings" }; | |
| 5717 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5718 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 5719 | + wpsc_reset_responsive_style(); | |
| 1028 | 5720 | }); |
| 1029 | - | |
| 1030 | 5721 | } |
| 1031 | 5722 | |
| 1032 | -function wpsc_reset_appearance_signup_form(nonce){ | |
| 1033 | - | |
| 5723 | +/** | |
| 5724 | + * Set general settings | |
| 5725 | + */ | |
| 5726 | +function wpsc_ticket_tags_set_general_settings(el) { | |
| 5727 | + var form = jQuery(".wpsc-ticket-tags-general-settings")[0]; | |
| 5728 | + var dataform = new FormData(form); | |
| 5729 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5730 | + jQuery | |
| 5731 | + .ajax({ | |
| 5732 | + url: supportcandy.ajax_url, | |
| 5733 | + type: "POST", | |
| 5734 | + data: dataform, | |
| 5735 | + processData: false, | |
| 5736 | + contentType: false, | |
| 5737 | + }) | |
| 5738 | + .done(function (res) { | |
| 5739 | + wpsc_ticket_tags_get_general_settings(); | |
| 5740 | + }); | |
| 5741 | +} | |
| 5742 | + | |
| 5743 | +/** | |
| 5744 | + * Reset general settings | |
| 5745 | + */ | |
| 5746 | +function wpsc_ticket_tags_reset_general_settings(el, nonce) { | |
| 5747 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1034 | 5748 | var data = { |
| 1035 | - action: 'wpsc_appearance_settings', | |
| 1036 | - setting_action : 'get_reset_default_signup_settings', | |
| 1037 | - _ajax_nonce: nonce | |
| 5749 | + action: "wpsc_ticket_tags_reset_general_settings", | |
| 5750 | + _ajax_nonce: nonce, | |
| 1038 | 5751 | }; |
| 1039 | - | |
| 1040 | - jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { | |
| 1041 | - var response = JSON.parse(response_str); | |
| 1042 | - if (response.sucess_status=='1') | |
| 1043 | - { | |
| 1044 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1045 | - } | |
| 1046 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1047 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1048 | - wpsc_get_appearance_signup(); | |
| 5752 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5753 | + wpsc_ticket_tags_get_general_settings(); | |
| 1049 | 5754 | }); |
| 1050 | 5755 | } |
| 1051 | 5756 | |
| 1052 | -function wpsc_get_advanced_settings(){ | |
| 1053 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1054 | - jQuery('#wpsc_advanced_settings').addClass('active'); | |
| 1055 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 5757 | +/** | |
| 5758 | + * Get dashboard settings | |
| 5759 | + */ | |
| 5760 | +function wpsc_get_dashboard_settings(is_humbargar = false) { | |
| 5761 | + if (is_humbargar) { | |
| 5762 | + wpsc_toggle_humbargar(); | |
| 5763 | + } | |
| 5764 | + | |
| 5765 | + jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 5766 | + jQuery( | |
| 5767 | + ".wpsc-setting-nav.dashboard-settings, .wpsc-humbargar-menu-item.dashboard-settings" | |
| 5768 | + ).addClass("active"); | |
| 5769 | + jQuery(".wpsc-humbargar-title").html( | |
| 5770 | + supportcandy.humbargar_titles.tickettags | |
| 5771 | + ); | |
| 5772 | + | |
| 5773 | + if (supportcandy.current_section !== "dashboard-settings") { | |
| 5774 | + supportcandy.current_section = "dashboard-settings"; | |
| 5775 | + supportcandy.current_tab = "dashboard-general"; | |
| 5776 | + } | |
| 5777 | + | |
| 5778 | + window.history.replaceState( | |
| 5779 | + {}, | |
| 5780 | + null, | |
| 5781 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5782 | + supportcandy.current_section + | |
| 5783 | + "&tab=" + | |
| 5784 | + supportcandy.current_tab | |
| 5785 | + ); | |
| 5786 | + jQuery(".wpsc-setting-body").html(supportcandy.loader_html); | |
| 5787 | + | |
| 5788 | + wpsc_scroll_top(); | |
| 5789 | + | |
| 1056 | 5790 | var data = { |
| 1057 | - action: 'wpsc_settings', | |
| 1058 | - setting_action : 'get_advanced_settings' | |
| 5791 | + action: "wpsc_get_dashboard_settings", | |
| 5792 | + tab: supportcandy.current_tab, | |
| 1059 | 5793 | }; |
| 1060 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1061 | - jQuery('.wpsc_setting_col2').html(response); | |
| 1062 | - }); | |
| 5794 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5795 | + jQuery(".wpsc-setting-body").html(response); | |
| 5796 | + wpsc_reset_responsive_style(); | |
| 5797 | + jQuery( | |
| 5798 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5799 | + ).trigger("click"); | |
| 5800 | + }); | |
| 1063 | 5801 | } |
| 1064 | 5802 | |
| 1065 | -function wpsc_set_advanced_settings(){ | |
| 1066 | - jQuery('.wpsc_submit_wait').show(); | |
| 1067 | - var dataform = new FormData(jQuery('#wpsc_frm_advanced_settings')[0]); | |
| 1068 | - jQuery.ajax({ | |
| 1069 | - url: wpsc_admin.ajax_url, | |
| 1070 | - type: 'POST', | |
| 1071 | - data: dataform, | |
| 1072 | - processData: false, | |
| 1073 | - contentType: false | |
| 1074 | - }) | |
| 1075 | - .done(function (response_str) { | |
| 1076 | - var response = JSON.parse(response_str); | |
| 1077 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1078 | - if (response.sucess_status=='1') { | |
| 1079 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1080 | - }else { | |
| 1081 | - jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege); | |
| 1082 | - jQuery('#wpsc_alert_error').slideDown('fast',function(){}); | |
| 1083 | - setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000); | |
| 1084 | - } | |
| 1085 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1086 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1087 | - }); | |
| 5803 | +/** | |
| 5804 | + * Get dashboard cards settings | |
| 5805 | + */ | |
| 5806 | +function wpsc_get_dashboard_cards_settings() { | |
| 5807 | + supportcandy.current_tab = "dashboard-cards"; | |
| 5808 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 5809 | + jQuery( | |
| 5810 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5811 | + ).addClass("active"); | |
| 5812 | + | |
| 5813 | + window.history.replaceState( | |
| 5814 | + {}, | |
| 5815 | + null, | |
| 5816 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5817 | + supportcandy.current_section + | |
| 5818 | + "&tab=" + | |
| 5819 | + supportcandy.current_tab | |
| 5820 | + ); | |
| 5821 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 5822 | + | |
| 5823 | + wpsc_scroll_top(); | |
| 5824 | + var data = { action: "wpsc_get_dashboard_cards_settings" }; | |
| 5825 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5826 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 5827 | + wpsc_reset_responsive_style(); | |
| 5828 | + }); | |
| 1088 | 5829 | } |
| 1089 | 5830 | |
| 1090 | -function wpsc_get_captcha_settings(){ | |
| 1091 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1092 | - jQuery('#wpsc_captcha_settings').addClass('active'); | |
| 1093 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 5831 | +/** | |
| 5832 | + * Sort dashboard cards | |
| 5833 | + */ | |
| 5834 | +function wpsc_set_dashboard_card_load_order(slugs, nonce) { | |
| 5835 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1094 | 5836 | var data = { |
| 1095 | - action: 'wpsc_settings', | |
| 1096 | - setting_action : 'get_captcha_settings' | |
| 5837 | + action: "wpsc_set_dashboard_card_load_order", | |
| 5838 | + slugs, | |
| 5839 | + _ajax_nonce: nonce, | |
| 1097 | 5840 | }; |
| 1098 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1099 | - jQuery('.wpsc_setting_col2').html(response); | |
| 1100 | - }); | |
| 5841 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 5842 | + wpsc_get_dashboard_cards_settings(); | |
| 5843 | + }); | |
| 1101 | 5844 | } |
| 1102 | 5845 | |
| 1103 | -function wpsc_set_captcha_settings(){ | |
| 1104 | - jQuery('.wpsc_submit_wait').show(); | |
| 1105 | - var dataform = new FormData(jQuery('#wpsc_frm_captcha_settings')[0]); | |
| 1106 | - jQuery.ajax({ | |
| 1107 | - url: wpsc_admin.ajax_url, | |
| 1108 | - type: 'POST', | |
| 1109 | - data: dataform, | |
| 1110 | - processData: false, | |
| 1111 | - contentType: false | |
| 1112 | - }) | |
| 1113 | - .done(function (response_str) { | |
| 1114 | - var response = JSON.parse(response_str); | |
| 1115 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1116 | - if (response.sucess_status=='1') { | |
| 1117 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1118 | - } | |
| 1119 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1120 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1121 | - }); | |
| 5846 | +/** | |
| 5847 | + * Toggle enable/disable status of a single dashboard card | |
| 5848 | + */ | |
| 5849 | +function wpsc_toggle_dashboard_card_status(el, slug, nonce) { | |
| 5850 | + var checkbox = jQuery(el); | |
| 5851 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 5852 | + var card = checkbox.closest(".wpsc-setting-card"); | |
| 5853 | + | |
| 5854 | + var data = { | |
| 5855 | + action: "wpsc_toggle_dashboard_card_status", | |
| 5856 | + slug, | |
| 5857 | + is_enable, | |
| 5858 | + _ajax_nonce: nonce, | |
| 5859 | + }; | |
| 5860 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 5861 | + card.attr( | |
| 5862 | + "style", | |
| 5863 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 5864 | + ); | |
| 5865 | + var total = jQuery(".wpsc-toggle-dashboard-card").length; | |
| 5866 | + var checked = jQuery(".wpsc-toggle-dashboard-card:checked").length; | |
| 5867 | + jQuery(".wpsc-toggle-all-dashboard-cards").prop( | |
| 5868 | + "checked", | |
| 5869 | + total > 0 && total === checked | |
| 5870 | + ); | |
| 5871 | + }).fail(function () { | |
| 5872 | + // Revert checkbox on failure. | |
| 5873 | + checkbox.prop("checked", !is_enable); | |
| 5874 | + }); | |
| 1122 | 5875 | } |
| 1123 | 5876 | |
| 1124 | -function wpsc_get_rest_api_settings(){ | |
| 1125 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1126 | - jQuery('#wpsc_rest_settings').addClass('active'); | |
| 1127 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 5877 | +/** | |
| 5878 | + * Enable or disable all dashboard cards at once | |
| 5879 | + */ | |
| 5880 | +function wpsc_toggle_all_dashboard_cards(el, nonce) { | |
| 5881 | + var checkbox = jQuery(el); | |
| 5882 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 5883 | + | |
| 1128 | 5884 | var data = { |
| 1129 | - action: 'wpsc_settings', | |
| 1130 | - setting_action : 'get_rest_api_settings' | |
| 5885 | + action: "wpsc_toggle_all_dashboard_cards_status", | |
| 5886 | + is_enable, | |
| 5887 | + _ajax_nonce: nonce, | |
| 1131 | 5888 | }; |
| 1132 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1133 | - jQuery('.wpsc_setting_col2').html(response); | |
| 1134 | - }); | |
| 5889 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 5890 | + jQuery(".wpsc-toggle-dashboard-card").prop("checked", !!is_enable); | |
| 5891 | + jQuery(".wpsc-setting-card").attr( | |
| 5892 | + "style", | |
| 5893 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 5894 | + ); | |
| 5895 | + }).fail(function () { | |
| 5896 | + // Revert checkbox on failure. | |
| 5897 | + checkbox.prop("checked", !is_enable); | |
| 5898 | + }); | |
| 1135 | 5899 | } |
| 1136 | 5900 | |
| 1137 | -function wpsc_set_rest_api_settings(){ | |
| 1138 | - jQuery('.wpsc_submit_wait').show(); | |
| 1139 | - var dataform = new FormData(jQuery('#wpsc_frm_rest_api_settings')[0]); | |
| 1140 | - jQuery.ajax({ | |
| 1141 | - url: wpsc_admin.ajax_url, | |
| 1142 | - type: 'POST', | |
| 1143 | - data: dataform, | |
| 1144 | - processData: false, | |
| 1145 | - contentType: false | |
| 1146 | - }) | |
| 1147 | - .done(function (response_str) { | |
| 1148 | - var response = JSON.parse(response_str); | |
| 1149 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1150 | - if (response.sucess_status=='1') { | |
| 1151 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1152 | - } | |
| 1153 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1154 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1155 | - }); | |
| 5901 | +/** | |
| 5902 | + * Get dashboard widgets settings | |
| 5903 | + */ | |
| 5904 | +function wpsc_get_dashboard_widgets_settings() { | |
| 5905 | + supportcandy.current_tab = "dashboard-widgets"; | |
| 5906 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 5907 | + jQuery( | |
| 5908 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5909 | + ).addClass("active"); | |
| 5910 | + | |
| 5911 | + window.history.replaceState( | |
| 5912 | + {}, | |
| 5913 | + null, | |
| 5914 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5915 | + supportcandy.current_section + | |
| 5916 | + "&tab=" + | |
| 5917 | + supportcandy.current_tab | |
| 5918 | + ); | |
| 5919 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 5920 | + | |
| 5921 | + wpsc_scroll_top(); | |
| 5922 | + var data = { action: "wpsc_get_dashboard_widgets_settings" }; | |
| 5923 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5924 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 5925 | + wpsc_reset_responsive_style(); | |
| 5926 | + }); | |
| 1156 | 5927 | } |
| 1157 | 5928 | |
| 1158 | -function wpsc_custom_ticket_number(nonce){ | |
| 1159 | - jQuery('.wpsc_submit_wait_1').show(); | |
| 1160 | - var new_count = document.getElementById("wpsc_custom_ticket_count").value; | |
| 5929 | +/** | |
| 5930 | + * Get dashboard widgets settings | |
| 5931 | + */ | |
| 5932 | +function wpsc_get_dashboard_general_settings() { | |
| 5933 | + supportcandy.current_tab = "dashboard-general"; | |
| 5934 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 5935 | + jQuery( | |
| 5936 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 5937 | + ).addClass("active"); | |
| 5938 | + | |
| 5939 | + window.history.replaceState( | |
| 5940 | + {}, | |
| 5941 | + null, | |
| 5942 | + "admin.php?page=wpsc-settings§ion=" + | |
| 5943 | + supportcandy.current_section + | |
| 5944 | + "&tab=" + | |
| 5945 | + supportcandy.current_tab | |
| 5946 | + ); | |
| 5947 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 5948 | + | |
| 5949 | + wpsc_scroll_top(); | |
| 5950 | + var data = { action: "wpsc_get_dashboard_general_settings" }; | |
| 5951 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5952 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 5953 | + wpsc_reset_responsive_style(); | |
| 5954 | + }); | |
| 5955 | +} | |
| 5956 | + | |
| 5957 | +/** | |
| 5958 | + * Save dashboard general settings | |
| 5959 | + * | |
| 5960 | + * @param {*} el | |
| 5961 | + */ | |
| 5962 | +function wpsc_set_dashboard_general_settings(el) { | |
| 5963 | + var form = jQuery(".wpsc-frm-db-gs")[0]; | |
| 5964 | + var dataform = new FormData(form); | |
| 5965 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5966 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 5967 | + jQuery | |
| 5968 | + .ajax({ | |
| 5969 | + url: supportcandy.ajax_url, | |
| 5970 | + type: "POST", | |
| 5971 | + data: dataform, | |
| 5972 | + processData: false, | |
| 5973 | + contentType: false, | |
| 5974 | + }) | |
| 5975 | + .done(function (res) { | |
| 5976 | + wpsc_get_dashboard_general_settings(); | |
| 5977 | + }); | |
| 5978 | +} | |
| 5979 | + | |
| 5980 | +/** | |
| 5981 | + * Reset dashboard general settings | |
| 5982 | + * | |
| 5983 | + * @param {*} el | |
| 5984 | + */ | |
| 5985 | +function wpsc_reset_dashboard_general_settings(el, nonce) { | |
| 5986 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 5987 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 1161 | 5988 | var data = { |
| 1162 | - action: 'wpsc_settings', | |
| 1163 | - setting_action : 'custom_start_ticket_number', | |
| 1164 | - new_count : new_count, | |
| 1165 | - _ajax_nonce: nonce | |
| 5989 | + action: "wpsc_reset_dashboard_general_settings", | |
| 5990 | + _ajax_nonce: nonce, | |
| 1166 | 5991 | }; |
| 1167 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1168 | - var response = JSON.parse(response); | |
| 1169 | - jQuery('.wpsc_submit_wait_1').hide(); | |
| 1170 | - if (response.sucess_status=='1') { | |
| 1171 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1172 | - } else { | |
| 1173 | - alert(response.msg); | |
| 1174 | - return; | |
| 1175 | - } | |
| 1176 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1177 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 5992 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 5993 | + wpsc_get_dashboard_general_settings(); | |
| 1178 | 5994 | }); |
| 1179 | 5995 | } |
| 1180 | 5996 | |
| 1181 | 5997 | /** |
| 1182 | - * Adds new condition element. | |
| 5998 | + * Add new dashboard widget | |
| 1183 | 5999 | */ |
| 1184 | -function wpsc_add_new_condition(id) { | |
| 1185 | - jQuery('#'+ id +' .wpsc_conditions_container').append(jQuery('.wpsc_condition_template').html()); | |
| 6000 | +function wpsc_get_new_dashboard_widget(nonce) { | |
| 6001 | + wpsc_show_modal(); | |
| 6002 | + var data = { action: "wpsc_get_new_dashboard_widget", _ajax_nonce: nonce }; | |
| 6003 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6004 | + // Set to modal. | |
| 6005 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 6006 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 6007 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 6008 | + // Display modal. | |
| 6009 | + wpsc_show_modal_inner_container(); | |
| 6010 | + }); | |
| 1186 | 6011 | } |
| 1187 | 6012 | |
| 1188 | 6013 | /** |
| 1189 | - * Remove condition element. | |
| 6014 | + * Set new dashboard widget | |
| 1190 | 6015 | */ |
| 1191 | -function wpsc_remove_condition(obj){ | |
| 1192 | - jQuery(obj).parent().parent().remove(); | |
| 6016 | +function wpsc_set_new_dashboard_widget(el) { | |
| 6017 | + var form = jQuery(".wpsc-add-new-dashboard-widget")[0]; | |
| 6018 | + var dataform = new FormData(form); | |
| 6019 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 6020 | + jQuery | |
| 6021 | + .ajax({ | |
| 6022 | + url: supportcandy.ajax_url, | |
| 6023 | + type: "POST", | |
| 6024 | + data: dataform, | |
| 6025 | + processData: false, | |
| 6026 | + contentType: false, | |
| 6027 | + }) | |
| 6028 | + .done(function (res) { | |
| 6029 | + wpsc_close_modal(); | |
| 6030 | + wpsc_get_dashboard_settings(); | |
| 6031 | + }); | |
| 1193 | 6032 | } |
| 1194 | 6033 | |
| 1195 | 6034 | /** |
| 1196 | - * Change condition option. | |
| 6035 | + * Delete dashboard widget | |
| 1197 | 6036 | */ |
| 1198 | -function wpsc_condition_change(obj){ | |
| 1199 | - | |
| 1200 | - jQuery(obj).parent().parent().find('.wpsc_condition_compare_container').first().html(''); | |
| 1201 | - jQuery(obj).parent().parent().find('.wpsc_condition_value_container').first().html(''); | |
| 1202 | - | |
| 1203 | - var key = jQuery(obj).val(); | |
| 1204 | - var has_options = jQuery(obj).find(':selected').first().data('hasoptions'); | |
| 1205 | - | |
| 1206 | - if( has_options == 1 ){ | |
| 1207 | - | |
| 1208 | - var data = { | |
| 1209 | - action: 'wpsc_custom_fields', | |
| 1210 | - setting_action : 'get_conditional_options', | |
| 1211 | - key : key | |
| 1212 | - }; | |
| 1213 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1214 | - | |
| 1215 | - jQuery(obj).parent().parent().find('.wpsc_condition_compare_container').first().html(jQuery('.wpsc_cond_compare_dd_template').html()); | |
| 1216 | - jQuery(obj).parent().parent().find('.wpsc_condition_value_container').first().html(jQuery('.wpsc_cond_val_dd_template').html()); | |
| 1217 | - jQuery(obj).parent().parent().find('.wpsc_condition_value').first().html(response); | |
| 1218 | - | |
| 1219 | - }); | |
| 1220 | - | |
| 1221 | - } else { | |
| 1222 | - | |
| 1223 | - jQuery(obj).parent().parent().find('.wpsc_condition_compare_container').first().html(jQuery('.wpsc_cond_compare_tf_template').html()); | |
| 1224 | - jQuery(obj).parent().parent().find('.wpsc_condition_value_container').first().html(jQuery('.wpsc_cond_val_tf_template').html()); | |
| 1225 | - | |
| 1226 | - } | |
| 1227 | - | |
| 6037 | +function wpsc_delete_dashboard_widget(slug, nonce) { | |
| 6038 | + var flag = confirm(supportcandy.translations.confirm); | |
| 6039 | + if (!flag) { | |
| 6040 | + return; | |
| 6041 | + } | |
| 6042 | + | |
| 6043 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 6044 | + var data = { | |
| 6045 | + action: "wpsc_delete_dashboard_widget", | |
| 6046 | + slug, | |
| 6047 | + _ajax_nonce: nonce, | |
| 6048 | + }; | |
| 6049 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6050 | + wpsc_get_dashboard_settings(); | |
| 6051 | + }); | |
| 1228 | 6052 | } |
| 1229 | 6053 | |
| 1230 | 6054 | /** |
| 1231 | - * Return array of conditions found for condition element of given id | |
| 1232 | - * @param {String} id Condition element id | |
| 1233 | - * @return {Array} conditions parsed in an array | |
| 6055 | + * Sort dashboard widgets | |
| 1234 | 6056 | */ |
| 1235 | -function wpsc_condition_parse(id){ | |
| 1236 | - | |
| 1237 | - var conditions = new Array(); | |
| 1238 | - | |
| 1239 | - jQuery('#'+id).find('.wpsc_condition_element').each(function(){ | |
| 1240 | - | |
| 1241 | - var field = jQuery(this).find('.wpsc_condition_field').first().val().trim(); | |
| 1242 | - var compare = ''; | |
| 1243 | - var cond_val = ''; | |
| 1244 | - | |
| 1245 | - if( field != '' ){ | |
| 1246 | - compare = jQuery(this).find('.wpsc_condition_compare').first().val().trim(); | |
| 1247 | - cond_val = jQuery(this).find('.wpsc_condition_value').first().val().trim(); | |
| 1248 | - } | |
| 1249 | - | |
| 1250 | - conditions.push( { field: field, compare: compare, cond_val: cond_val } ); | |
| 1251 | - | |
| 1252 | - }); | |
| 1253 | - | |
| 1254 | - return conditions; | |
| 1255 | - | |
| 6057 | +function wpsc_set_dashboard_widget_load_order(slugs, nonce) { | |
| 6058 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 6059 | + var data = { | |
| 6060 | + action: "wpsc_set_dashboard_widget_load_order", | |
| 6061 | + slugs, | |
| 6062 | + _ajax_nonce: nonce, | |
| 6063 | + }; | |
| 6064 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 6065 | + wpsc_get_dashboard_widgets_settings(); | |
| 6066 | + }); | |
| 1256 | 6067 | } |
| 1257 | 6068 | |
| 1258 | 6069 | /** |
| 1259 | - * Validate whether conditions are entered correctly or not | |
| 1260 | - * @param {Array} conditions Array contains condition objects | |
| 1261 | - * @return {Boolean} True or False | |
| 6070 | + * Toggle enable/disable status of a single dashboard widget | |
| 1262 | 6071 | */ |
| 1263 | -function wpsc_condition_validate(conditions){ | |
| 1264 | - | |
| 1265 | - var is_correct = true; | |
| 1266 | - if( conditions.length > 0 ){ | |
| 1267 | - jQuery.each( conditions, function( key, condition ){ | |
| 1268 | - if( condition.field =='' || condition.cond_val =='' ){ | |
| 1269 | - is_correct = false; | |
| 1270 | - return; | |
| 1271 | - } | |
| 1272 | - }); | |
| 1273 | - } | |
| 1274 | - | |
| 1275 | - return is_correct; | |
| 1276 | - | |
| 6072 | +function wpsc_toggle_dashboard_widget_status(el, slug, nonce) { | |
| 6073 | + var checkbox = jQuery(el); | |
| 6074 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 6075 | + var widget = checkbox.closest(".wpsc-setting-card"); | |
| 6076 | + | |
| 6077 | + var data = { | |
| 6078 | + action: "wpsc_toggle_dashboard_widget_status", | |
| 6079 | + slug, | |
| 6080 | + is_enable, | |
| 6081 | + _ajax_nonce: nonce, | |
| 6082 | + }; | |
| 6083 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 6084 | + widget.attr( | |
| 6085 | + "style", | |
| 6086 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 6087 | + ); | |
| 6088 | + var total = jQuery(".wpsc-toggle-dashboard-widget").length; | |
| 6089 | + var checked = jQuery(".wpsc-toggle-dashboard-widget:checked").length; | |
| 6090 | + jQuery(".wpsc-toggle-all-dashboard-widgets").prop( | |
| 6091 | + "checked", | |
| 6092 | + total > 0 && total === checked | |
| 6093 | + ); | |
| 6094 | + }).fail(function () { | |
| 6095 | + // Revert checkbox on failure. | |
| 6096 | + checkbox.prop("checked", !is_enable); | |
| 6097 | + }); | |
| 1277 | 6098 | } |
| 1278 | 6099 | |
| 1279 | -function wpsc_get_conditional_options(e){ | |
| 1280 | - jQuery('#wpsc_tf_vco').html(''); | |
| 1281 | - var field_id = jQuery(e).val(); | |
| 6100 | +/** | |
| 6101 | + * Enable or disable all dashboard widgets at once | |
| 6102 | + */ | |
| 6103 | +function wpsc_toggle_all_dashboard_widgets(el, nonce) { | |
| 6104 | + var checkbox = jQuery(el); | |
| 6105 | + var is_enable = checkbox.is(":checked") ? 1 : 0; | |
| 6106 | + | |
| 1282 | 6107 | var data = { |
| 1283 | - action: 'wpsc_custom_fields', | |
| 1284 | - setting_action : 'get_conditional_options_fields', | |
| 1285 | - field_id : field_id | |
| 6108 | + action: "wpsc_toggle_all_dashboard_widgets_status", | |
| 6109 | + is_enable, | |
| 6110 | + _ajax_nonce: nonce, | |
| 1286 | 6111 | }; |
| 1287 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1288 | - jQuery('#wpsc_tf_vco').html(response); | |
| 1289 | - }); | |
| 6112 | + jQuery.post(supportcandy.ajax_url, data, function () { | |
| 6113 | + jQuery(".wpsc-toggle-dashboard-widget").prop("checked", !!is_enable); | |
| 6114 | + jQuery(".wpsc-setting-card").attr( | |
| 6115 | + "style", | |
| 6116 | + is_enable ? "" : "background-color:#eec7ca;color:#dc2222" | |
| 6117 | + ); | |
| 6118 | + }).fail(function () { | |
| 6119 | + // Revert checkbox on failure. | |
| 6120 | + checkbox.prop("checked", !is_enable); | |
| 6121 | + }); | |
| 1290 | 6122 | } |
| 1291 | 6123 | |
| 1292 | -function wpsc_get_ticket_list_advanced_settings(){ | |
| 1293 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1294 | - jQuery('#wpsc_ticket_list_advanced_settings').addClass('active'); | |
| 1295 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 1296 | - | |
| 6124 | +/** | |
| 6125 | + * Edit bashboard widget | |
| 6126 | + */ | |
| 6127 | +function wpsc_get_edit_dashboard_card_widget(type, slug, nonce) { | |
| 6128 | + wpsc_show_modal(); | |
| 1297 | 6129 | var data = { |
| 1298 | - action: 'wpsc_ticket_list', | |
| 1299 | - setting_action : 'get_ticket_list_advanced_settings' | |
| 6130 | + action: "wpsc_get_edit_dashboard_card_widget", | |
| 6131 | + type, | |
| 6132 | + slug, | |
| 6133 | + _ajax_nonce: nonce, | |
| 1300 | 6134 | }; |
| 6135 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6136 | + // Set to modal. | |
| 6137 | + jQuery(".wpsc-modal-header").text(response.title); | |
| 6138 | + jQuery(".wpsc-modal-body").html(response.body); | |
| 6139 | + jQuery(".wpsc-modal-footer").html(response.footer); | |
| 6140 | + // Display modal. | |
| 6141 | + wpsc_show_modal_inner_container(); | |
| 6142 | + }); | |
| 6143 | +} | |
| 1301 | 6144 | |
| 1302 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1303 | - jQuery('.wpsc_setting_col2').html(response); | |
| 6145 | +/** | |
| 6146 | + * Set edit bashboard widget | |
| 6147 | + */ | |
| 6148 | +function wpsc_set_edit_dashboard_card_widget(el) { | |
| 6149 | + var form = jQuery(".wpsc-frm-edit-dashboard-cards-widgets")[0]; | |
| 6150 | + var dataform = new FormData(form); | |
| 6151 | + | |
| 6152 | + if (dataform.get("label").trim() == "") { | |
| 6153 | + alert(supportcandy.translations.req_fields_missing); | |
| 6154 | + return; | |
| 6155 | + } | |
| 6156 | + | |
| 6157 | + jQuery(".wpsc-modal-footer button").attr("disabled", true); | |
| 6158 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 6159 | + | |
| 6160 | + jQuery | |
| 6161 | + .ajax({ | |
| 6162 | + url: supportcandy.ajax_url, | |
| 6163 | + type: "POST", | |
| 6164 | + data: dataform, | |
| 6165 | + processData: false, | |
| 6166 | + contentType: false, | |
| 6167 | + }) | |
| 6168 | + .done(function (res) { | |
| 6169 | + wpsc_close_modal(); | |
| 6170 | + wpsc_get_dashboard_settings(); | |
| 6171 | + }); | |
| 6172 | +} | |
| 6173 | + | |
| 6174 | +/** | |
| 6175 | + * Get appearence dashboard | |
| 6176 | + */ | |
| 6177 | +function wpsc_get_ap_dashboard() { | |
| 6178 | + supportcandy.current_tab = "dashboard"; | |
| 6179 | + jQuery(".wpsc-setting-tab-container button").removeClass("active"); | |
| 6180 | + jQuery( | |
| 6181 | + ".wpsc-setting-tab-container button." + supportcandy.current_tab | |
| 6182 | + ).addClass("active"); | |
| 6183 | + | |
| 6184 | + window.history.replaceState( | |
| 6185 | + {}, | |
| 6186 | + null, | |
| 6187 | + "admin.php?page=wpsc-settings§ion=" + | |
| 6188 | + supportcandy.current_section + | |
| 6189 | + "&tab=" + | |
| 6190 | + supportcandy.current_tab | |
| 6191 | + ); | |
| 6192 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 6193 | + | |
| 6194 | + wpsc_scroll_top(); | |
| 6195 | + var data = { action: "wpsc_get_ap_dashboard" }; | |
| 6196 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6197 | + jQuery(".wpsc-setting-section-body").html(response); | |
| 6198 | + wpsc_reset_responsive_style(); | |
| 1304 | 6199 | }); |
| 1305 | 6200 | } |
| 1306 | 6201 | |
| 1307 | -function set_ticket_list_advanced_settings(){ | |
| 1308 | - var check = false; | |
| 1309 | - | |
| 1310 | - jQuery('#wpsc_agent_close_statuses').find('input:checked').each(function () { | |
| 1311 | - check = true; | |
| 1312 | - }); | |
| 6202 | +/** | |
| 6203 | + * Set appearence dashboard | |
| 6204 | + */ | |
| 6205 | +function wpsc_set_ap_dashboard(el) { | |
| 6206 | + var form = jQuery(".wpsc-frm-ap-dash")[0]; | |
| 6207 | + var dataform = new FormData(form); | |
| 6208 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 6209 | + jQuery | |
| 6210 | + .ajax({ | |
| 6211 | + url: supportcandy.ajax_url, | |
| 6212 | + type: "POST", | |
| 6213 | + data: dataform, | |
| 6214 | + processData: false, | |
| 6215 | + contentType: false, | |
| 6216 | + }) | |
| 6217 | + .done(function (res) { | |
| 6218 | + wpsc_get_ap_dashboard(); | |
| 6219 | + }); | |
| 6220 | +} | |
| 1313 | 6221 | |
| 1314 | - if(!check){ | |
| 1315 | - alert(wpsc_admin.agent_close_statuses); | |
| 1316 | - return; | |
| 1317 | - } | |
| 1318 | - | |
| 1319 | - jQuery('.wpsc_submit_wait').show(); | |
| 1320 | - var dataform = new FormData(jQuery('#wpsc_frm_ticket_list_advanced_settings')[0]); | |
| 1321 | - | |
| 1322 | - jQuery.ajax({ | |
| 1323 | - url: wpsc_admin.ajax_url, | |
| 1324 | - type: 'POST', | |
| 1325 | - data: dataform, | |
| 1326 | - processData: false, | |
| 1327 | - contentType: false | |
| 1328 | - }) | |
| 1329 | - .done(function (response_str) { | |
| 1330 | - var response = JSON.parse(response_str); | |
| 1331 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1332 | - if (response.sucess_status=='1') { | |
| 1333 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1334 | - } | |
| 1335 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1336 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 6222 | +/** | |
| 6223 | + * Reset appearence dashboard | |
| 6224 | + */ | |
| 6225 | +function wpsc_reset_ap_dashboard(el, nonce) { | |
| 6226 | + jQuery(el).text(supportcandy.translations.please_wait); | |
| 6227 | + var data = { action: "wpsc_reset_ap_dashboard", _ajax_nonce: nonce }; | |
| 6228 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 6229 | + wpsc_get_ap_dashboard(); | |
| 1337 | 6230 | }); |
| 1338 | - | |
| 1339 | 6231 | } |
| 1340 | 6232 | |
| 1341 | -function wpsc_get_attachment_settings(){ | |
| 1342 | - | |
| 1343 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1344 | - jQuery('#wpsc_settings_attachment').addClass('active'); | |
| 1345 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 1346 | - | |
| 6233 | +/** | |
| 6234 | + * Get customer profile | |
| 6235 | + * | |
| 6236 | + * @param {int} id | |
| 6237 | + */ | |
| 6238 | +function wpsc_view_customer_detailed_info(customer_id, nonce) { | |
| 6239 | + jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html); | |
| 1347 | 6240 | var data = { |
| 1348 | - action: 'wpsc_settings', | |
| 1349 | - setting_action : 'get_attachment_settings' | |
| 6241 | + action: "wpsc_view_customer_detailed_info", | |
| 6242 | + customer_id, | |
| 6243 | + _ajax_nonce: nonce, | |
| 1350 | 6244 | }; |
| 1351 | - | |
| 1352 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1353 | - jQuery('.wpsc_setting_col2').html(response); | |
| 6245 | + jQuery.post(supportcandy.ajax_url, data, function (res) { | |
| 6246 | + jQuery(".wpsc-setting-section-body").html(res); | |
| 1354 | 6247 | }); |
| 1355 | 6248 | } |
| 1356 | 6249 | |
| 1357 | -function wpsc_set_attachment_settings(){ | |
| 6250 | +function wpsc_update_live_agents() { | |
| 1358 | 6251 | |
| 1359 | - jQuery('.wpsc_submit_wait').show(); | |
| 1360 | - var dataform = new FormData(jQuery('#wpsc_frm_attachment_settings')[0]); | |
| 1361 | - jQuery.ajax({ | |
| 1362 | - url: wpsc_admin.ajax_url, | |
| 1363 | - type: 'POST', | |
| 1364 | - data: dataform, | |
| 1365 | - processData: false, | |
| 1366 | - contentType: false | |
| 1367 | - }) | |
| 1368 | - .done(function (response_str) { | |
| 1369 | - var response = JSON.parse(response_str); | |
| 1370 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1371 | - if (response.sucess_status=='1') { | |
| 1372 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1373 | - } | |
| 1374 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1375 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 1376 | - }); | |
| 1377 | - | |
| 6252 | + if (!supportcandy.ticketListIsIndividual) { | |
| 6253 | + return; | |
| 6254 | + } | |
| 6255 | + agent_id = jQuery("#wpsc-current-agent").val(); | |
| 6256 | + if (!agent_id) { | |
| 6257 | + return; | |
| 6258 | + } | |
| 6259 | + if (typeof supportcandy.agent_collision === "undefined" || !supportcandy.agent_collision) { | |
| 6260 | + return; | |
| 6261 | + } | |
| 6262 | + | |
| 6263 | + ticket_id = jQuery("#wpsc-current-ticket").val(); | |
| 6264 | + var data = { action: 'wpsc_check_live_agents', agent_id, ticket_id, operation: 'leave', _ajax_nonce: supportcandy.nonce }; | |
| 6265 | + jQuery.post( | |
| 6266 | + supportcandy.ajax_url, | |
| 6267 | + data, | |
| 6268 | + function (response) { | |
| 6269 | + } | |
| 6270 | + ); | |
| 1378 | 6271 | } |
| 1379 | 6272 | |
| 1380 | -function wpsc_get_tinymce_settings(){ | |
| 1381 | - jQuery('.wpsc_setting_pills li').removeClass('active'); | |
| 1382 | - jQuery('#wpsc_tinymce_settings').addClass('active'); | |
| 1383 | - jQuery('.wpsc_setting_col2').html(wpsc_admin.loading_html); | |
| 1384 | - | |
| 6273 | +/** | |
| 6274 | + * Get ticket list | |
| 6275 | + */ | |
| 6276 | +function wpsc_get_archive_ticket_list(is_humbargar = false) { | |
| 6277 | + | |
| 6278 | + supportcandy.current_section = "archive-ticket-list"; | |
| 6279 | + if (is_humbargar) { | |
| 6280 | + wpsc_toggle_humbargar(); | |
| 6281 | + } | |
| 6282 | + | |
| 6283 | + var id = supportcandy.current_archived_ticket_id; | |
| 6284 | + if (id) { | |
| 6285 | + delete supportcandy.current_archived_ticket_id; | |
| 6286 | + wpsc_get_individual_archive_ticket(id); | |
| 6287 | + return; | |
| 6288 | + } | |
| 6289 | + | |
| 6290 | + // set flag to differenciate between ticket list and individual ticket. | |
| 6291 | + supportcandy.ticketListIsIndividual = false; | |
| 6292 | + | |
| 6293 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 6294 | + jQuery( | |
| 6295 | + ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list" | |
| 6296 | + ).addClass("active"); | |
| 6297 | + jQuery(".wpsc-humbargar-title").html( | |
| 6298 | + supportcandy.humbargar_titles.archived_ticket_list | |
| 6299 | + ); | |
| 6300 | + | |
| 6301 | + window.history.replaceState( | |
| 6302 | + {}, | |
| 6303 | + null, | |
| 6304 | + "admin.php?page=wpsc-archive-tickets§ion=archive-ticket-list" | |
| 6305 | + ); | |
| 6306 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 6307 | + | |
| 6308 | + wpsc_scroll_top(); | |
| 6309 | + | |
| 1385 | 6310 | var data = { |
| 1386 | - action: 'wpsc_settings', | |
| 1387 | - setting_action : 'get_tinymce_settings' | |
| 6311 | + action: "wpsc_get_archive_ticket_list", | |
| 6312 | + _ajax_nonce: supportcandy.nonce, | |
| 6313 | + is_frontend: supportcandy.is_frontend, | |
| 1388 | 6314 | }; |
| 1389 | - | |
| 1390 | - jQuery.post(wpsc_admin.ajax_url, data, function(response) { | |
| 1391 | - jQuery('.wpsc_setting_col2').html(response); | |
| 6315 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6316 | + jQuery(".wpsc-body").html(response); | |
| 6317 | + wpsc_reset_responsive_style(); | |
| 1392 | 6318 | }); |
| 6319 | + wpsc_delete_auto_draft(); | |
| 1393 | 6320 | } |
| 1394 | 6321 | |
| 1395 | -function wpsc_set_tinymce_settings(){ | |
| 6322 | +/** | |
| 6323 | + * Get individual ticket | |
| 6324 | + */ | |
| 6325 | +function wpsc_get_individual_archive_ticket(id) { | |
| 6326 | + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active"); | |
| 6327 | + jQuery( | |
| 6328 | + ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list" | |
| 6329 | + ).addClass("active"); | |
| 6330 | + jQuery(".wpsc-humbargar-title").html( | |
| 6331 | + supportcandy.humbargar_titles.archived_ticket_list | |
| 6332 | + ); | |
| 1396 | 6333 | |
| 1397 | - jQuery('.wpsc_submit_wait').show(); | |
| 1398 | - var dataform = new FormData(jQuery('#wpsc_get_tinymce_settings')[0]); | |
| 1399 | - | |
| 1400 | - jQuery.ajax({ | |
| 1401 | - url: wpsc_admin.ajax_url, | |
| 1402 | - type: 'POST', | |
| 1403 | - data: dataform, | |
| 1404 | - processData: false, | |
| 1405 | - contentType: false | |
| 1406 | - }) | |
| 1407 | - .done(function (response_str) { | |
| 1408 | - var response = JSON.parse(response_str); | |
| 1409 | - jQuery('.wpsc_submit_wait').hide(); | |
| 1410 | - if (response.sucess_status=='1') { | |
| 1411 | - jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege); | |
| 1412 | - } | |
| 1413 | - jQuery('#wpsc_alert_success').slideDown('fast',function(){}); | |
| 1414 | - setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000); | |
| 6334 | + window.history.replaceState( | |
| 6335 | + {}, | |
| 6336 | + null, | |
| 6337 | + "admin.php?page=wpsc-archive-tickets§ion=archive-ticket-list&id=" + id | |
| 6338 | + ); | |
| 6339 | + jQuery(".wpsc-body").html(supportcandy.loader_html); | |
| 6340 | + | |
| 6341 | + wpsc_scroll_top(); | |
| 6342 | + | |
| 6343 | + // set flag to differenciate between ticket list and individual ticket. | |
| 6344 | + supportcandy.ticketListIsIndividual = true; | |
| 6345 | + | |
| 6346 | + var data = { | |
| 6347 | + action: "wpsc_get_individual_archive_ticket", | |
| 6348 | + ticket_id: id, | |
| 6349 | + }; | |
| 6350 | + jQuery.post(supportcandy.ajax_url, data, function (response) { | |
| 6351 | + jQuery(".wpsc-body").html(response); | |
| 6352 | + wpsc_reset_responsive_style(); | |
| 1415 | 6353 | }); |
| 1416 | 6354 | } |