PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.2
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.2
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / asset / js / admin.js

admin.js in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.2, at asset/js/admin.js

6,182 lines 158.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Get ticket list
3 */
4 function wpsc_get_ticket_list(is_humbargar = false) {
5 supportcandy.current_section = "ticket-list";
6
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&section=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
78 */
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&section=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
100 var data = {
101 action: "wpsc_get_individual_ticket",
102 ticket_id: id,
103 };
104 jQuery.post(supportcandy.ajax_url, data, function (response) {
105 jQuery(".wpsc-body").html(response);
106 wpsc_reset_responsive_style();
107 });
108 }
109
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;
156 });
157 jQuery.post(supportcandy.ajax_url, data, function (response) {
158 jQuery(".wpsc-body").html(response);
159 wpsc_reset_responsive_style();
160 });
161 }
162
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&section=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();
196 });
197 }
198
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&section=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");
233 });
234 }
235
236 /**
237 * Get agent dashboard
238 */
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&section=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&section=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();
354 var data = {
355 action: "wpsc_get_edit_agent",
356 id,
357 _ajax_nonce,
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 }
368
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 });
389 }
390
391 /**
392 * Get delete agent modal popup
393 */
394 function wpsc_get_delete_agent(id, nonce) {
395 var flag = confirm(supportcandy.translations.confirm);
396 if (!flag) {
397 return;
398 }
399
400 var data = {
401 action: "wpsc_delete_agent",
402 id,
403 _ajax_nonce: nonce,
404 };
405 jQuery.post(supportcandy.ajax_url, data, function (res) {
406 wpsc_get_agent_list();
407 });
408 }
409
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&section=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();
451 });
452 }
453
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);
497 var data = {
498 action: "wpsc_get_edit_agent_role",
499 role_id: id,
500 _ajax_nonce: nonce,
501 };
502 jQuery.post(supportcandy.ajax_url, data, function (response) {
503 jQuery(".wpsc-setting-section-body").html(response);
504 });
505 }
506
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 });
532 }
533
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,
546 };
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 });
555 }
556
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&section=" +
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
590 var data = {
591 action: "wpsc_get_general_settings",
592 tab: supportcandy.current_tab,
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 }
602
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&section=" +
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();
629 });
630 }
631
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&section=" +
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&section=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&section=" +
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
791 var data = {
792 action: "wpsc_get_working_hrs_settings",
793 tab: supportcandy.current_tab,
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 }
803
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&section=" +
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();
829 });
830 }
831
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&section=" +
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();
887 var data = {
888 action: "wpsc_get_company_holiday_actions",
889 dateSelected,
890 _ajax_nonce: nonce,
891 };
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();
899 });
900 }
901
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&section=" +
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();
964 });
965 }
966
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 }
975
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 });
997 }
998
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&section=" +
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&section=" +
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
1182 var data = {
1183 action: "wpsc_get_appearence_settings",
1184 tab: supportcandy.current_tab,
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 }
1194
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&section=" +
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 });
1221 }
1222
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&section=" +
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&section=" +
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&section=" +
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 * Get appearence agent collision settigns
1433 */
1434 function wpsc_get_ap_agent_collision() {
1435 supportcandy.current_tab = "agent-collision";
1436 jQuery(".wpsc-setting-tab-container button").removeClass("active");
1437 jQuery(
1438 ".wpsc-setting-tab-container button." + supportcandy.current_tab
1439 ).addClass("active");
1440
1441 window.history.replaceState(
1442 {},
1443 null,
1444 "admin.php?page=wpsc-settings&section=" +
1445 supportcandy.current_section +
1446 "&tab=" +
1447 supportcandy.current_tab
1448 );
1449 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
1450
1451 wpsc_scroll_top();
1452 var data = { action: "wpsc_get_ap_agent_collision" };
1453 jQuery.post(supportcandy.ajax_url, data, function (response) {
1454 jQuery(".wpsc-setting-section-body").html(response);
1455 wpsc_reset_responsive_style();
1456 });
1457 }
1458
1459 /**
1460 * Set appearence agent collision settings
1461 */
1462 function wpsc_set_ap_agent_collision(el) {
1463 var form = jQuery(".wpsc-frm-ap-agent-collision")[0];
1464 var dataform = new FormData(form);
1465 jQuery(el).text(supportcandy.translations.please_wait);
1466 jQuery
1467 .ajax({
1468 url: supportcandy.ajax_url,
1469 type: "POST",
1470 data: dataform,
1471 processData: false,
1472 contentType: false,
1473 })
1474 .done(function (res) {
1475 wpsc_get_ap_agent_collision();
1476 });
1477 }
1478
1479 /**
1480 * Reset appearence agent collision settings
1481 */
1482 function wpsc_reset_ap_agent_collision(el, nonce) {
1483 jQuery(el).text(supportcandy.translations.please_wait);
1484 var data = { action: "wpsc_reset_ap_agent_collision", _ajax_nonce: nonce };
1485 jQuery.post(supportcandy.ajax_url, data, function (res) {
1486 wpsc_get_ap_agent_collision();
1487 });
1488 }
1489
1490 /**
1491 * Set add new category
1492 */
1493 function wpsc_set_add_category(el) {
1494 var form = jQuery(".wpsc-frm-add-category")[0];
1495 var dataform = new FormData(form);
1496
1497 if (dataform.get("label").trim() == "") {
1498 alert(supportcandy.translations.req_fields_missing);
1499 return;
1500 }
1501
1502 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1503 jQuery(el).text(supportcandy.translations.please_wait);
1504
1505 jQuery
1506 .ajax({
1507 url: supportcandy.ajax_url,
1508 type: "POST",
1509 data: dataform,
1510 processData: false,
1511 contentType: false,
1512 })
1513 .done(function (res) {
1514 wpsc_close_modal();
1515 wpsc_get_ticket_categories();
1516 });
1517 }
1518
1519 /**
1520 * Get edit category modal
1521 */
1522 function wpsc_get_edit_category(id, nonce) {
1523 wpsc_show_modal();
1524 var data = { action: "wpsc_get_edit_category", id, _ajax_nonce: nonce };
1525 jQuery.post(supportcandy.ajax_url, data, function (response) {
1526 // Set to modal.
1527 jQuery(".wpsc-modal-header").text(response.title);
1528 jQuery(".wpsc-modal-body").html(response.body);
1529 jQuery(".wpsc-modal-footer").html(response.footer);
1530 // Display modal.
1531 wpsc_show_modal_inner_container();
1532 });
1533 }
1534
1535 /**
1536 * Update category
1537 */
1538 function wpsc_set_edit_category(el) {
1539 var form = jQuery(".wpsc-frm-edit-category")[0];
1540 var dataform = new FormData(form);
1541
1542 if (dataform.get("label").trim() == "") {
1543 alert(supportcandy.translations.req_fields_missing);
1544 return;
1545 }
1546
1547 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1548 jQuery(el).text(supportcandy.translations.please_wait);
1549
1550 jQuery
1551 .ajax({
1552 url: supportcandy.ajax_url,
1553 type: "POST",
1554 data: dataform,
1555 processData: false,
1556 contentType: false,
1557 })
1558 .done(function (res) {
1559 wpsc_close_modal();
1560 wpsc_get_ticket_categories();
1561 });
1562 }
1563
1564 /**
1565 * Delete category modal
1566 */
1567 function wpsc_get_delete_category(id, nonce) {
1568 var flag = confirm(supportcandy.translations.confirm);
1569 if (!flag) {
1570 return;
1571 }
1572
1573 wpsc_show_modal();
1574 var data = { action: "wpsc_get_delete_category", id, _ajax_nonce: nonce };
1575 jQuery.post(supportcandy.ajax_url, data, function (response) {
1576 // Set to modal.
1577 jQuery(".wpsc-modal-header").text(response.title);
1578 jQuery(".wpsc-modal-body").html(response.body);
1579 jQuery(".wpsc-modal-footer").html(response.footer);
1580 // Display modal.
1581 wpsc_show_modal_inner_container();
1582 });
1583 }
1584
1585 /**
1586 * Delete category
1587 */
1588 function wpsc_set_delete_category(el) {
1589 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1590 jQuery(el).text(supportcandy.translations.please_wait);
1591
1592 var form = jQuery(".wpsc-frm-delete-category")[0];
1593 var dataform = new FormData(form);
1594 jQuery
1595 .ajax({
1596 url: supportcandy.ajax_url,
1597 type: "POST",
1598 data: dataform,
1599 processData: false,
1600 contentType: false,
1601 })
1602 .done(function (res) {
1603 wpsc_close_modal();
1604 wpsc_get_ticket_categories();
1605 });
1606 }
1607
1608 /**
1609 * Get status settings
1610 */
1611 function wpsc_get_ticket_statuses(is_humbargar = false) {
1612 if (is_humbargar) {
1613 wpsc_toggle_humbargar();
1614 }
1615
1616 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
1617 jQuery(
1618 ".wpsc-setting-nav.ticket-statuses, .wpsc-humbargar-menu-item.ticket-statuses"
1619 ).addClass("active");
1620 jQuery(".wpsc-humbargar-title").html(
1621 supportcandy.humbargar_titles.ticket_statuses
1622 );
1623
1624 window.history.replaceState(
1625 {},
1626 null,
1627 "admin.php?page=wpsc-settings&section=ticket-statuses"
1628 );
1629 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
1630
1631 wpsc_scroll_top();
1632
1633 var data = { action: "wpsc_get_ticket_statuses" };
1634 jQuery.post(supportcandy.ajax_url, data, function (response) {
1635 jQuery(".wpsc-setting-body").html(response);
1636 wpsc_reset_responsive_style();
1637 });
1638 }
1639
1640 /**
1641 * Set add new status
1642 */
1643 function wpsc_set_add_status(el) {
1644 var form = jQuery(".wpsc-frm-add-status")[0];
1645 var dataform = new FormData(form);
1646
1647 if (dataform.get("name").trim() == "") {
1648 alert(supportcandy.translations.req_fields_missing);
1649 return;
1650 }
1651
1652 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1653 jQuery(el).text(supportcandy.translations.please_wait);
1654
1655 jQuery
1656 .ajax({
1657 url: supportcandy.ajax_url,
1658 type: "POST",
1659 data: dataform,
1660 processData: false,
1661 contentType: false,
1662 })
1663 .done(function (res) {
1664 wpsc_close_modal();
1665 wpsc_get_ticket_statuses();
1666 });
1667 }
1668
1669 /**
1670 * Get edit status modal
1671 */
1672 function wpsc_get_edit_status(id, nonce) {
1673 wpsc_show_modal();
1674 var data = { action: "wpsc_get_edit_status", id, _ajax_nonce: nonce };
1675 jQuery.post(supportcandy.ajax_url, data, function (response) {
1676 // Set to modal.
1677 jQuery(".wpsc-modal-header").text(response.title);
1678 jQuery(".wpsc-modal-body").html(response.body);
1679 jQuery(".wpsc-modal-footer").html(response.footer);
1680 // Display modal.
1681 wpsc_show_modal_inner_container();
1682 });
1683 }
1684
1685 /**
1686 * Update status
1687 */
1688 function wpsc_set_edit_status(el) {
1689 var form = jQuery(".wpsc-frm-edit-status")[0];
1690 var dataform = new FormData(form);
1691
1692 if (dataform.get("name").trim() == "") {
1693 alert(supportcandy.translations.req_fields_missing);
1694 return;
1695 }
1696
1697 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1698 jQuery(el).text(supportcandy.translations.please_wait);
1699
1700 jQuery
1701 .ajax({
1702 url: supportcandy.ajax_url,
1703 type: "POST",
1704 data: dataform,
1705 processData: false,
1706 contentType: false,
1707 })
1708 .done(function (res) {
1709 wpsc_close_modal();
1710 wpsc_get_ticket_statuses();
1711 });
1712 }
1713
1714 /**
1715 * Delete status modal
1716 */
1717 function wpsc_get_delete_status(id, nonce) {
1718 var flag = confirm(supportcandy.translations.confirm);
1719 if (!flag) {
1720 return;
1721 }
1722
1723 wpsc_show_modal();
1724 var data = { action: "wpsc_get_delete_status", id, _ajax_nonce: nonce };
1725 jQuery.post(supportcandy.ajax_url, data, function (response) {
1726 // Set to modal.
1727 jQuery(".wpsc-modal-header").text(response.title);
1728 jQuery(".wpsc-modal-body").html(response.body);
1729 jQuery(".wpsc-modal-footer").html(response.footer);
1730 // Display modal.
1731 wpsc_show_modal_inner_container();
1732 });
1733 }
1734
1735 /**
1736 * Delete status
1737 */
1738 function wpsc_set_delete_status(el) {
1739 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1740 jQuery(el).text(supportcandy.translations.please_wait);
1741
1742 var form = jQuery(".wpsc-frm-delete-status")[0];
1743 var dataform = new FormData(form);
1744 jQuery
1745 .ajax({
1746 url: supportcandy.ajax_url,
1747 type: "POST",
1748 data: dataform,
1749 processData: false,
1750 contentType: false,
1751 })
1752 .done(function (res) {
1753 wpsc_close_modal();
1754 wpsc_get_ticket_statuses();
1755 });
1756 }
1757
1758 /**
1759 * Get priority settings
1760 */
1761 function wpsc_get_ticket_priorities(is_humbargar = false) {
1762 if (is_humbargar) {
1763 wpsc_toggle_humbargar();
1764 }
1765
1766 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
1767 jQuery(
1768 ".wpsc-setting-nav.ticket-priorities, .wpsc-humbargar-menu-item.ticket-priorities"
1769 ).addClass("active");
1770 jQuery(".wpsc-humbargar-title").html(
1771 supportcandy.humbargar_titles.ticket_priorities
1772 );
1773
1774 window.history.replaceState(
1775 {},
1776 null,
1777 "admin.php?page=wpsc-settings&section=ticket-priorities"
1778 );
1779 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
1780
1781 wpsc_scroll_top();
1782
1783 var data = { action: "wpsc_get_ticket_priorities" };
1784 jQuery.post(supportcandy.ajax_url, data, function (response) {
1785 jQuery(".wpsc-setting-body").html(response);
1786 wpsc_reset_responsive_style();
1787 });
1788 }
1789
1790 /**
1791 * Set add new priority
1792 */
1793 function wpsc_set_add_priority(el) {
1794 var form = jQuery(".wpsc-frm-add-priority")[0];
1795 var dataform = new FormData(form);
1796
1797 if (dataform.get("name").trim() == "") {
1798 alert(supportcandy.translations.req_fields_missing);
1799 return;
1800 }
1801
1802 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1803 jQuery(el).text(supportcandy.translations.please_wait);
1804
1805 jQuery
1806 .ajax({
1807 url: supportcandy.ajax_url,
1808 type: "POST",
1809 data: dataform,
1810 processData: false,
1811 contentType: false,
1812 })
1813 .done(function (res) {
1814 wpsc_close_modal();
1815 wpsc_get_ticket_priorities();
1816 });
1817 }
1818
1819 /**
1820 * Get edit priority modal
1821 */
1822 function wpsc_get_edit_priority(id, nonce) {
1823 wpsc_show_modal();
1824 var data = { action: "wpsc_get_edit_priority", id, _ajax_nonce: nonce };
1825 jQuery.post(supportcandy.ajax_url, data, function (response) {
1826 // Set to modal.
1827 jQuery(".wpsc-modal-header").text(response.title);
1828 jQuery(".wpsc-modal-body").html(response.body);
1829 jQuery(".wpsc-modal-footer").html(response.footer);
1830 // Display modal.
1831 wpsc_show_modal_inner_container();
1832 });
1833 }
1834
1835 /**
1836 * Update an priority
1837 */
1838 function wpsc_set_edit_priority(el) {
1839 var form = jQuery(".wpsc-frm-edit-priority")[0];
1840 var dataform = new FormData(form);
1841
1842 if (dataform.get("name").trim() == "") {
1843 alert(supportcandy.translations.req_fields_missing);
1844 return;
1845 }
1846
1847 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1848 jQuery(el).text(supportcandy.translations.please_wait);
1849
1850 jQuery
1851 .ajax({
1852 url: supportcandy.ajax_url,
1853 type: "POST",
1854 data: dataform,
1855 processData: false,
1856 contentType: false,
1857 })
1858 .done(function (res) {
1859 wpsc_close_modal();
1860 wpsc_get_ticket_priorities();
1861 });
1862 }
1863
1864 /**
1865 * Delete priority modal
1866 */
1867 function wpsc_get_delete_priority(id, nonce) {
1868 var flag = confirm(supportcandy.translations.confirm);
1869 if (!flag) {
1870 return;
1871 }
1872
1873 wpsc_show_modal();
1874 var data = { action: "wpsc_get_delete_priority", id, _ajax_nonce: nonce };
1875 jQuery.post(supportcandy.ajax_url, data, function (response) {
1876 // Set to modal.
1877 jQuery(".wpsc-modal-header").text(response.title);
1878 jQuery(".wpsc-modal-body").html(response.body);
1879 jQuery(".wpsc-modal-footer").html(response.footer);
1880 // Display modal.
1881 wpsc_show_modal_inner_container();
1882 });
1883 }
1884
1885 /**
1886 * Delete priority
1887 */
1888 function wpsc_set_delete_priority(el) {
1889 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1890 jQuery(el).text(supportcandy.translations.please_wait);
1891
1892 var form = jQuery(".wpsc-frm-delete-priority")[0];
1893 var dataform = new FormData(form);
1894 jQuery
1895 .ajax({
1896 url: supportcandy.ajax_url,
1897 type: "POST",
1898 data: dataform,
1899 processData: false,
1900 contentType: false,
1901 })
1902 .done(function (res) {
1903 wpsc_close_modal();
1904 wpsc_get_ticket_priorities();
1905 });
1906 }
1907
1908 /**
1909 * Get ticket form fields
1910 */
1911 function wpsc_get_tff(is_humbargar = false) {
1912 if (is_humbargar) {
1913 wpsc_toggle_humbargar();
1914 }
1915
1916 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
1917 jQuery(
1918 ".wpsc-setting-nav.ticket-form-fields, .wpsc-humbargar-menu-item.ticket-form-fields"
1919 ).addClass("active");
1920 jQuery(".wpsc-humbargar-title").html(
1921 supportcandy.humbargar_titles.ticket_form_fields
1922 );
1923
1924 window.history.replaceState(
1925 {},
1926 null,
1927 "admin.php?page=wpsc-ticket-form&section=ticket-form-fields"
1928 );
1929 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
1930
1931 wpsc_scroll_top();
1932
1933 var data = { action: "wpsc_get_tff" };
1934 jQuery.post(supportcandy.ajax_url, data, function (response) {
1935 jQuery(".wpsc-setting-body").html(response);
1936 wpsc_reset_responsive_style();
1937 });
1938 }
1939
1940 /**
1941 * Set add new ticket form field
1942 */
1943 function wpsc_set_add_new_tff(el) {
1944 if (!jQuery("#wpsc-select-ticket-form-field").val()) {
1945 alert(supportcandy.translations.req_fields_missing);
1946 return;
1947 }
1948
1949 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1950 jQuery(el).text(supportcandy.translations.please_wait);
1951
1952 var form = jQuery(".frm-add-new-ticket-form-field")[0];
1953 var dataform = new FormData(form);
1954
1955 dataform.append(
1956 "visibility",
1957 JSON.stringify(wpsc_get_condition_json("visibility"))
1958 );
1959
1960 jQuery
1961 .ajax({
1962 url: supportcandy.ajax_url,
1963 type: "POST",
1964 data: dataform,
1965 processData: false,
1966 contentType: false,
1967 })
1968 .done(function (res) {
1969 wpsc_close_modal();
1970 wpsc_get_tff();
1971 });
1972 }
1973
1974 /**
1975 * Get edit ticket form field modal
1976 */
1977 function wpsc_get_edit_tff(id, nonce) {
1978 wpsc_show_modal();
1979 var data = { action: "wpsc_get_edit_tff", id, _ajax_nonce: nonce };
1980 jQuery.post(supportcandy.ajax_url, data, function (response) {
1981 // Set to modal.
1982 jQuery(".wpsc-modal-header").text(response.title);
1983 jQuery(".wpsc-modal-body").html(response.body);
1984 jQuery(".wpsc-modal-footer").html(response.footer);
1985 // Display modal.
1986 wpsc_show_modal_inner_container();
1987 });
1988 }
1989
1990 /**
1991 * Update ticket form field
1992 */
1993 function wpsc_set_edit_tff(el) {
1994 jQuery(".wpsc-modal-footer button").attr("disabled", true);
1995 jQuery(el).text(supportcandy.translations.please_wait);
1996
1997 var form = jQuery(".frm-edit-ticket-form-field")[0];
1998 var dataform = new FormData(form);
1999
2000 dataform.append(
2001 "visibility",
2002 JSON.stringify(wpsc_get_condition_json("visibility"))
2003 );
2004
2005 jQuery
2006 .ajax({
2007 url: supportcandy.ajax_url,
2008 type: "POST",
2009 data: dataform,
2010 processData: false,
2011 contentType: false,
2012 })
2013 .done(function (res) {
2014 wpsc_close_modal();
2015 wpsc_get_tff();
2016 });
2017 }
2018
2019 /**
2020 * Delete ticket form field
2021 */
2022 function wpsc_delete_tff(id, nonce) {
2023 var flag = confirm(supportcandy.translations.confirm);
2024 if (!flag) {
2025 return;
2026 }
2027
2028 var data = { action: "wpsc_delete_tff", id, _ajax_nonce: nonce };
2029 jQuery.post(supportcandy.ajax_url, data, function (res) {
2030 wpsc_get_tff();
2031 });
2032 }
2033
2034 /**
2035 * Get ticket fields
2036 */
2037 function wpsc_get_ticket_fields(is_humbargar = false) {
2038 if (is_humbargar) {
2039 wpsc_toggle_humbargar();
2040 }
2041
2042 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2043 jQuery(
2044 ".wpsc-setting-nav.ticket-fields, .wpsc-humbargar-menu-item.ticket-fields"
2045 ).addClass("active");
2046 jQuery(".wpsc-humbargar-title").html(
2047 supportcandy.humbargar_titles.ticket_fields
2048 );
2049
2050 window.history.replaceState(
2051 {},
2052 null,
2053 "admin.php?page=wpsc-ticket-form&section=ticket-fields"
2054 );
2055 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2056
2057 wpsc_scroll_top();
2058
2059 var data = { action: "wpsc_get_ticket_fields" };
2060 jQuery.post(supportcandy.ajax_url, data, function (response) {
2061 jQuery(".wpsc-setting-body").html(response);
2062 wpsc_reset_responsive_style();
2063 });
2064 }
2065
2066 /**
2067 * Get customer fields
2068 */
2069 function wpsc_get_customer_fields(is_humbargar = false) {
2070 if (is_humbargar) {
2071 wpsc_toggle_humbargar();
2072 }
2073
2074 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2075 jQuery(
2076 ".wpsc-setting-nav.customer-fields, .wpsc-humbargar-menu-item.customer-fields"
2077 ).addClass("active");
2078 jQuery(".wpsc-humbargar-title").html(
2079 supportcandy.humbargar_titles.customer_fields
2080 );
2081
2082 window.history.replaceState(
2083 {},
2084 null,
2085 "admin.php?page=wpsc-ticket-form&section=customer-fields"
2086 );
2087 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2088
2089 wpsc_scroll_top();
2090
2091 var data = { action: "wpsc_get_customer_fields" };
2092 jQuery.post(supportcandy.ajax_url, data, function (response) {
2093 jQuery(".wpsc-setting-body").html(response);
2094 wpsc_reset_responsive_style();
2095 });
2096 }
2097
2098 /**
2099 * Get agent only fields
2100 */
2101 function wpsc_get_agent_only_fields(is_humbargar = false) {
2102 if (is_humbargar) {
2103 wpsc_toggle_humbargar();
2104 }
2105
2106 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2107 jQuery(
2108 ".wpsc-setting-nav.agent-only-fields, .wpsc-humbargar-menu-item.agent-only-fields"
2109 ).addClass("active");
2110 jQuery(".wpsc-humbargar-title").html(
2111 supportcandy.humbargar_titles.agent_only_fields
2112 );
2113
2114 window.history.replaceState(
2115 {},
2116 null,
2117 "admin.php?page=wpsc-ticket-form&section=agent-only-fields"
2118 );
2119 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2120
2121 wpsc_scroll_top();
2122
2123 var data = { action: "wpsc_get_agent_only_fields" };
2124 jQuery.post(supportcandy.ajax_url, data, function (response) {
2125 jQuery(".wpsc-setting-body").html(response);
2126 wpsc_reset_responsive_style();
2127 });
2128 }
2129
2130 /**
2131 * Get add new ticket field
2132 */
2133 function wpsc_get_add_new_custom_field(field, nonce) {
2134 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2135 var data = {
2136 action: "wpsc_get_add_new_custom_field",
2137 field,
2138 _ajax_nonce: nonce,
2139 };
2140 jQuery.post(supportcandy.ajax_url, data, function (response) {
2141 jQuery(".wpsc-setting-section-body").html(response);
2142 });
2143 }
2144
2145 /**
2146 * Get edit ticket field modal
2147 */
2148 function wpsc_get_edit_custom_field(id, nonce) {
2149 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2150 var data = {
2151 action: "wpsc_get_edit_custom_field",
2152 cf_id: id,
2153 _ajax_nonce: nonce,
2154 };
2155 jQuery.post(supportcandy.ajax_url, data, function (response) {
2156 jQuery(".wpsc-setting-section-body").html(response);
2157 });
2158 }
2159
2160 /**
2161 * Submit delete an ticket form field
2162 */
2163 function wpsc_delete_custom_field(id, nonce) {
2164 var flag = confirm(supportcandy.translations.confirm);
2165 if (!flag) {
2166 return;
2167 }
2168
2169 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2170
2171 var data = {
2172 action: "wpsc_delete_custom_field",
2173 cf_id: id,
2174 _ajax_nonce: nonce,
2175 };
2176 jQuery.post(supportcandy.ajax_url, data, function (res) {
2177 jQuery(".wpsc-setting-nav.active").trigger("click");
2178 });
2179 }
2180
2181 /**
2182 * Get agent ticket list settings
2183 */
2184 function wpsc_get_agent_tl_settings(is_humbargar = false) {
2185 if (is_humbargar) {
2186 wpsc_toggle_humbargar();
2187 }
2188
2189 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2190 jQuery(
2191 ".wpsc-setting-nav.agent-ticket-list, .wpsc-humbargar-menu-item.agent-ticket-list"
2192 ).addClass("active");
2193 jQuery(".wpsc-humbargar-title").html(
2194 supportcandy.humbargar_titles.agent_ticket_list
2195 );
2196
2197 if (supportcandy.current_section !== "agent-ticket-list") {
2198 supportcandy.current_section = "agent-ticket-list";
2199 supportcandy.current_tab = "list-items";
2200 }
2201
2202 window.history.replaceState(
2203 {},
2204 null,
2205 "admin.php?page=wpsc-ticket-list&section=" +
2206 supportcandy.current_section +
2207 "&tab=" +
2208 supportcandy.current_tab
2209 );
2210 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2211
2212 wpsc_scroll_top();
2213
2214 var data = {
2215 action: "wpsc_get_agent_tl_settings",
2216 tab: supportcandy.current_tab,
2217 };
2218 jQuery.post(supportcandy.ajax_url, data, function (response) {
2219 jQuery(".wpsc-setting-body").html(response);
2220 wpsc_reset_responsive_style();
2221 jQuery(
2222 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2223 ).trigger("click");
2224 });
2225 }
2226
2227 /**
2228 * Get customer ticket list
2229 */
2230 function wpsc_get_customer_tl_settings(is_humbargar = false) {
2231 if (is_humbargar) {
2232 wpsc_toggle_humbargar();
2233 }
2234
2235 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2236 jQuery(
2237 ".wpsc-setting-nav.customer-ticket-list, .wpsc-humbargar-menu-item.customer-ticket-list"
2238 ).addClass("active");
2239 jQuery(".wpsc-humbargar-title").html(
2240 supportcandy.humbargar_titles.customer_ticket_list
2241 );
2242
2243 if (supportcandy.current_section !== "customer-ticket-list") {
2244 supportcandy.current_section = "customer-ticket-list";
2245 supportcandy.current_tab = "list-items";
2246 }
2247
2248 window.history.replaceState(
2249 {},
2250 null,
2251 "admin.php?page=wpsc-ticket-list&section=" +
2252 supportcandy.current_section +
2253 "&tab=" +
2254 supportcandy.current_tab
2255 );
2256 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2257
2258 wpsc_scroll_top();
2259
2260 var data = {
2261 action: "wpsc_get_customer_tl_settings",
2262 tab: supportcandy.current_tab,
2263 };
2264 jQuery.post(supportcandy.ajax_url, data, function (response) {
2265 jQuery(".wpsc-setting-body").html(response);
2266 wpsc_reset_responsive_style();
2267 jQuery(
2268 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2269 ).trigger("click");
2270 });
2271 }
2272
2273 /**
2274 * Get ticket list more settings
2275 */
2276 function wpsc_get_tl_more_settigns(is_humbargar = false) {
2277 if (is_humbargar) {
2278 wpsc_toggle_humbargar();
2279 }
2280
2281 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
2282 jQuery(
2283 ".wpsc-setting-nav.more-settings, .wpsc-humbargar-menu-item.more-settings"
2284 ).addClass("active");
2285 jQuery(".wpsc-humbargar-title").html(
2286 supportcandy.humbargar_titles.more_settings
2287 );
2288
2289 if (supportcandy.current_section !== "more-settings") {
2290 supportcandy.current_section = "more-settings";
2291 supportcandy.current_tab = "agent-view";
2292 }
2293
2294 window.history.replaceState(
2295 {},
2296 null,
2297 "admin.php?page=wpsc-ticket-list&section=more-settings"
2298 );
2299 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
2300
2301 wpsc_scroll_top();
2302
2303 var data = { action: "wpsc_get_tl_more_settigns" };
2304 jQuery.post(supportcandy.ajax_url, data, function (response) {
2305 jQuery(".wpsc-setting-body").html(response);
2306 wpsc_reset_responsive_style();
2307 jQuery(
2308 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2309 ).trigger("click");
2310 });
2311 }
2312
2313 /**
2314 * Get agent ticket list items
2315 */
2316 function wpsc_get_agent_tl_items() {
2317 supportcandy.current_tab = "list-items";
2318 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2319 jQuery(
2320 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2321 ).addClass("active");
2322
2323 window.history.replaceState(
2324 {},
2325 null,
2326 "admin.php?page=wpsc-ticket-list&section=" +
2327 supportcandy.current_section +
2328 "&tab=" +
2329 supportcandy.current_tab
2330 );
2331 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2332
2333 wpsc_scroll_top();
2334
2335 var data = { action: "wpsc_get_agent_tl_items" };
2336 jQuery.post(supportcandy.ajax_url, data, function (response) {
2337 jQuery(".wpsc-setting-section-body").html(response);
2338 wpsc_reset_responsive_style();
2339 });
2340 }
2341
2342 /**
2343 * Set add new agent list items
2344 */
2345 function wpsc_set_add_agent_tl_item(el) {
2346 var form = jQuery(".frm-add-agent-tl-items")[0];
2347 var dataform = new FormData(form);
2348
2349 var cf_id = dataform.getAll("cf_id[]");
2350 if (!cf_id.length) {
2351 alert(supportcandy.translations.req_fields_missing);
2352 return;
2353 }
2354
2355 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2356 jQuery(el).text(supportcandy.translations.please_wait);
2357
2358 jQuery
2359 .ajax({
2360 url: supportcandy.ajax_url,
2361 type: "POST",
2362 data: dataform,
2363 processData: false,
2364 contentType: false,
2365 })
2366 .done(function (res) {
2367 wpsc_close_modal();
2368 wpsc_get_agent_tl_items();
2369 });
2370 }
2371
2372 /**
2373 * Set delete agent ticket list item
2374 */
2375 function wpsc_delete_agent_tl_item(slug, nonce) {
2376 if (confirm(supportcandy.translations.confirm)) {
2377 var data = {
2378 action: "wpsc_delete_agent_tl_item",
2379 slug: slug,
2380 _ajax_nonce: nonce,
2381 };
2382
2383 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2384 jQuery(slug).text(supportcandy.translations.please_wait);
2385 jQuery.post(supportcandy.ajax_url, data, function (res) {
2386 wpsc_get_agent_tl_items();
2387 });
2388 } else {
2389 return false;
2390 }
2391 }
2392
2393 /**
2394 * Get agent filter items
2395 */
2396 function wpsc_get_agent_filter_items() {
2397 supportcandy.current_tab = "filter-items";
2398 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2399 jQuery(
2400 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2401 ).addClass("active");
2402
2403 window.history.replaceState(
2404 {},
2405 null,
2406 "admin.php?page=wpsc-ticket-list&section=" +
2407 supportcandy.current_section +
2408 "&tab=" +
2409 supportcandy.current_tab
2410 );
2411 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2412
2413 wpsc_scroll_top();
2414
2415 var data = { action: "wpsc_get_agent_filter_items" };
2416 jQuery.post(supportcandy.ajax_url, data, function (response) {
2417 jQuery(".wpsc-setting-section-body").html(response);
2418 wpsc_reset_responsive_style();
2419 });
2420 }
2421
2422 /**
2423 * Set add new agent list items
2424 */
2425 function wpsc_set_add_atl_filter_item(el) {
2426 var form = jQuery(".frm-add-agent-tl-filter-items")[0];
2427 var dataform = new FormData(form);
2428
2429 var cf_id = dataform.getAll("agent-tl-filter-id[]");
2430 if (!cf_id.length) {
2431 alert(supportcandy.translations.req_fields_missing);
2432 return;
2433 }
2434
2435 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2436 jQuery(el).text(supportcandy.translations.please_wait);
2437 jQuery
2438 .ajax({
2439 url: supportcandy.ajax_url,
2440 type: "POST",
2441 data: dataform,
2442 processData: false,
2443 contentType: false,
2444 })
2445 .done(function (res) {
2446 wpsc_close_modal();
2447 wpsc_get_agent_filter_items();
2448 });
2449 }
2450
2451 /**
2452 * Get delete agent ticket list item
2453 *
2454 * @param {*} slug
2455 */
2456 function wpsc_delete_atl_filter_item(slug, nonce) {
2457 if (confirm(supportcandy.translations.confirm)) {
2458 var data = {
2459 action: "wpsc_delete_atl_filter_item",
2460 slug: slug,
2461 _ajax_nonce: nonce,
2462 };
2463 jQuery.post(supportcandy.ajax_url, data, function (res) {
2464 wpsc_get_agent_filter_items();
2465 });
2466 }
2467 }
2468
2469 /**
2470 * Get agent default filters
2471 */
2472 function wpsc_get_atl_default_filters() {
2473 supportcandy.current_tab = "default-filters";
2474 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2475 jQuery(
2476 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2477 ).addClass("active");
2478
2479 window.history.replaceState(
2480 {},
2481 null,
2482 "admin.php?page=wpsc-ticket-list&section=" +
2483 supportcandy.current_section +
2484 "&tab=" +
2485 supportcandy.current_tab
2486 );
2487 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2488
2489 wpsc_scroll_top();
2490
2491 var data = { action: "wpsc_get_atl_default_filters" };
2492 jQuery.post(supportcandy.ajax_url, data, function (response) {
2493 jQuery(".wpsc-setting-section-body").html(response);
2494 wpsc_reset_responsive_style();
2495 });
2496 }
2497
2498 /**
2499 * Add agent default filter
2500 */
2501 function wpsc_get_add_atl_default_filter() {
2502 wpsc_show_modal();
2503 var data = { action: "wpsc_get_add_atl_default_filter" };
2504 jQuery.post(supportcandy.ajax_url, data, function (response) {
2505 jQuery(".wpsc-modal-header").text(response.title);
2506 jQuery(".wpsc-modal-body").html(response.body);
2507 jQuery(".wpsc-modal-footer").html(response.footer);
2508 jQuery(".wpsc-form-filter-container").append(
2509 jQuery(".wpsc-form-filter-snippet").html()
2510 );
2511 jQuery(".wpsc-form-filter-container select").selectWoo();
2512 wpsc_show_modal_inner_container();
2513 });
2514 }
2515
2516 /**
2517 * Set add agent default filters
2518 */
2519 function wpsc_set_add_atl_default_filter(el) {
2520 var label = jQuery("#wpsc-atl-df-label").val().trim();
2521 if (!label) {
2522 alert(supportcandy.translations.req_fields_missing);
2523 return;
2524 }
2525
2526 var filters = wpsc_get_condition_json("default_filters");
2527 if (
2528 filters.length === 0 ||
2529 (filters.length === 1 && filters[0].length === 0)
2530 ) {
2531 alert(supportcandy.translations.req_fields_missing);
2532 return;
2533 }
2534
2535 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2536 jQuery(el).text(supportcandy.translations.please_wait);
2537
2538 var form = jQuery(".wpsc-frm-add-atl-default-filter")[0];
2539 var dataform = new FormData(form);
2540 dataform.append("filters", JSON.stringify(filters));
2541
2542 jQuery
2543 .ajax({
2544 url: supportcandy.ajax_url,
2545 type: "POST",
2546 data: dataform,
2547 processData: false,
2548 contentType: false,
2549 })
2550 .done(function (res) {
2551 wpsc_close_modal();
2552 wpsc_get_atl_default_filters();
2553 });
2554 }
2555
2556 /**
2557 * Get edit agent defualt filter
2558 */
2559 function wpsc_get_edit_atl_default_filter(slug, nonce) {
2560 wpsc_show_modal();
2561 var data = {
2562 action: "wpsc_get_edit_atl_default_filter",
2563 slug,
2564 _ajax_nonce: nonce,
2565 };
2566 jQuery.post(supportcandy.ajax_url, data, function (response) {
2567 jQuery(".wpsc-modal-header").text(response.title);
2568 jQuery(".wpsc-modal-body").html(response.body);
2569 jQuery(".wpsc-modal-footer").html(response.footer);
2570 wpsc_show_modal_inner_container();
2571 });
2572 }
2573
2574 /**
2575 * Set edit agent default filter
2576 */
2577 function wpsc_set_edit_atl_default_filter(el, flag) {
2578 var label = jQuery("#wpsc-atl-df-label").val().trim();
2579 if (!label) {
2580 alert(supportcandy.translations.req_fields_missing);
2581 return;
2582 }
2583
2584 var form = jQuery(".wpsc-frm-edit-atl-default-filter")[0];
2585 var dataform = new FormData(form);
2586
2587 if (flag) {
2588 var filters = wpsc_get_condition_json("default_filters");
2589 if (
2590 filters.length === 0 ||
2591 (filters.length === 1 && filters[0].length === 0)
2592 ) {
2593 alert(supportcandy.translations.req_fields_missing);
2594 return;
2595 }
2596 dataform.append("filters", JSON.stringify(filters));
2597 }
2598
2599 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2600 jQuery(el).text(supportcandy.translations.please_wait);
2601
2602 jQuery
2603 .ajax({
2604 url: supportcandy.ajax_url,
2605 type: "POST",
2606 data: dataform,
2607 processData: false,
2608 contentType: false,
2609 })
2610 .done(function (res) {
2611 wpsc_close_modal();
2612 wpsc_get_atl_default_filters();
2613 });
2614 }
2615
2616 /**
2617 * Delete agent default filter
2618 */
2619 function wpsc_delete_atl_default_filter(slug, nonce) {
2620 var flag = confirm(supportcandy.translations.confirm);
2621 if (!flag) {
2622 return;
2623 }
2624
2625 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2626
2627 var data = {
2628 action: "wpsc_delete_atl_default_filter",
2629 slug,
2630 _ajax_nonce: nonce,
2631 };
2632 jQuery.post(supportcandy.ajax_url, data, function (response) {
2633 wpsc_get_atl_default_filters();
2634 });
2635 }
2636
2637 /**
2638 * Get customer ticket list items
2639 */
2640 function wpsc_get_customer_tl_items() {
2641 supportcandy.current_tab = "list-items";
2642 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2643 jQuery(
2644 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2645 ).addClass("active");
2646
2647 window.history.replaceState(
2648 {},
2649 null,
2650 "admin.php?page=wpsc-ticket-list&section=" +
2651 supportcandy.current_section +
2652 "&tab=" +
2653 supportcandy.current_tab
2654 );
2655 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2656
2657 wpsc_scroll_top();
2658
2659 var data = { action: "wpsc_get_customer_tl_items" };
2660 jQuery.post(supportcandy.ajax_url, data, function (response) {
2661 jQuery(".wpsc-setting-section-body").html(response);
2662 wpsc_reset_responsive_style();
2663 });
2664 }
2665
2666 /**
2667 * Get customer default filters
2668 */
2669 function wpsc_get_ctl_default_filters() {
2670 supportcandy.current_tab = "default-filters";
2671 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2672 jQuery(
2673 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2674 ).addClass("active");
2675
2676 window.history.replaceState(
2677 {},
2678 null,
2679 "admin.php?page=wpsc-ticket-list&section=" +
2680 supportcandy.current_section +
2681 "&tab=" +
2682 supportcandy.current_tab
2683 );
2684 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2685
2686 wpsc_scroll_top();
2687
2688 var data = { action: "wpsc_get_ctl_default_filters" };
2689 jQuery.post(supportcandy.ajax_url, data, function (response) {
2690 jQuery(".wpsc-setting-section-body").html(response);
2691 wpsc_reset_responsive_style();
2692 });
2693 }
2694
2695 /**
2696 * Add customer default filter
2697 */
2698 function wpsc_get_add_ctl_default_filter() {
2699 wpsc_show_modal();
2700 var data = { action: "wpsc_get_add_ctl_default_filter" };
2701 jQuery.post(supportcandy.ajax_url, data, function (response) {
2702 jQuery(".wpsc-modal-header").text(response.title);
2703 jQuery(".wpsc-modal-body").html(response.body);
2704 jQuery(".wpsc-modal-footer").html(response.footer);
2705 jQuery(".wpsc-form-filter-container").append(
2706 jQuery(".wpsc-form-filter-snippet").html()
2707 );
2708 jQuery(".wpsc-form-filter-container select").selectWoo();
2709 wpsc_show_modal_inner_container();
2710 });
2711 }
2712
2713 /**
2714 * Set add customer default filters
2715 */
2716 function wpsc_set_add_ctl_default_filter(el) {
2717 var label = jQuery("#wpsc-ctl-df-label").val().trim();
2718 if (!label) {
2719 alert(supportcandy.translations.req_fields_missing);
2720 return;
2721 }
2722
2723 var filters = wpsc_get_condition_json("default_filters");
2724 if (
2725 filters.length === 0 ||
2726 (filters.length === 1 && filters[0].length === 0)
2727 ) {
2728 alert(supportcandy.translations.req_fields_missing);
2729 return;
2730 }
2731
2732 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2733 jQuery(el).text(supportcandy.translations.please_wait);
2734
2735 var form = jQuery(".wpsc-frm-add-ctl-default-filter")[0];
2736 var dataform = new FormData(form);
2737 dataform.append("filters", JSON.stringify(filters));
2738
2739 jQuery
2740 .ajax({
2741 url: supportcandy.ajax_url,
2742 type: "POST",
2743 data: dataform,
2744 processData: false,
2745 contentType: false,
2746 })
2747 .done(function (res) {
2748 wpsc_close_modal();
2749 wpsc_get_ctl_default_filters();
2750 });
2751 }
2752
2753 /**
2754 * Get edit customer defualt filter
2755 */
2756 function wpsc_get_edit_ctl_default_filter(slug, nonce) {
2757 wpsc_show_modal();
2758 var data = {
2759 action: "wpsc_get_edit_ctl_default_filter",
2760 slug,
2761 _ajax_nonce: nonce,
2762 };
2763 jQuery.post(supportcandy.ajax_url, data, function (response) {
2764 jQuery(".wpsc-modal-header").text(response.title);
2765 jQuery(".wpsc-modal-body").html(response.body);
2766 jQuery(".wpsc-modal-footer").html(response.footer);
2767 wpsc_show_modal_inner_container();
2768 });
2769 }
2770
2771 /**
2772 * Set edit customer default filter
2773 */
2774 function wpsc_set_edit_ctl_default_filter(el, flag) {
2775 var label = jQuery("#wpsc-ctl-df-label").val().trim();
2776 if (!label) {
2777 alert(supportcandy.translations.req_fields_missing);
2778 return;
2779 }
2780
2781 var form = jQuery(".wpsc-frm-edit-ctl-default-filter")[0];
2782 var dataform = new FormData(form);
2783
2784 if (flag) {
2785 var filters = wpsc_get_condition_json("default_filters");
2786 if (
2787 filters.length === 0 ||
2788 (filters.length === 1 && filters[0].length === 0)
2789 ) {
2790 alert(supportcandy.translations.req_fields_missing);
2791 return;
2792 }
2793 dataform.append("filters", JSON.stringify(filters));
2794 }
2795
2796 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2797 jQuery(el).text(supportcandy.translations.please_wait);
2798
2799 jQuery
2800 .ajax({
2801 url: supportcandy.ajax_url,
2802 type: "POST",
2803 data: dataform,
2804 processData: false,
2805 contentType: false,
2806 })
2807 .done(function (res) {
2808 wpsc_close_modal();
2809 wpsc_get_ctl_default_filters();
2810 });
2811 }
2812
2813 /**
2814 * Delete customer default filter
2815 */
2816 function wpsc_delete_ctl_default_filter(slug, nonce) {
2817 var flag = confirm(supportcandy.translations.confirm);
2818 if (!flag) {
2819 return;
2820 }
2821
2822 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2823
2824 var data = {
2825 action: "wpsc_delete_ctl_default_filter",
2826 slug,
2827 _ajax_nonce: nonce,
2828 };
2829 jQuery.post(supportcandy.ajax_url, data, function (response) {
2830 wpsc_get_ctl_default_filters();
2831 });
2832 }
2833
2834 /**
2835 * Set add new customer list items
2836 */
2837 function wpsc_set_add_customer_tl_item(el) {
2838 var form = jQuery(".frm-add-customer-tl-items")[0];
2839 var dataform = new FormData(form);
2840
2841 var cf_id = dataform.getAll("cf_id[]");
2842 if (!cf_id.length) {
2843 alert(supportcandy.translations.req_fields_missing);
2844 return;
2845 }
2846
2847 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2848 jQuery(el).text(supportcandy.translations.please_wait);
2849 jQuery
2850 .ajax({
2851 url: supportcandy.ajax_url,
2852 type: "POST",
2853 data: dataform,
2854 processData: false,
2855 contentType: false,
2856 })
2857 .done(function (res) {
2858 wpsc_close_modal();
2859 wpsc_get_customer_tl_items();
2860 });
2861 }
2862
2863 /**
2864 * Set delete customer ticket list item
2865 */
2866 function wpsc_delete_customer_tl_item(slug, nonce) {
2867 if (confirm(supportcandy.translations.confirm)) {
2868 var data = {
2869 action: "wpsc_delete_customer_tl_item",
2870 slug: slug,
2871 _ajax_nonce: nonce,
2872 };
2873
2874 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2875 jQuery(slug).text(supportcandy.translations.please_wait);
2876 jQuery.post(supportcandy.ajax_url, data, function (res) {
2877 wpsc_get_customer_tl_items();
2878 });
2879 } else {
2880 return false;
2881 }
2882 }
2883
2884 /**
2885 * Get customer filter items
2886 */
2887 function wpsc_get_customer_filter_items() {
2888 supportcandy.current_tab = "filter-items";
2889 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2890 jQuery(
2891 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2892 ).addClass("active");
2893
2894 window.history.replaceState(
2895 {},
2896 null,
2897 "admin.php?page=wpsc-ticket-list&section=" +
2898 supportcandy.current_section +
2899 "&tab=" +
2900 supportcandy.current_tab
2901 );
2902 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2903
2904 wpsc_scroll_top();
2905
2906 var data = { action: "wpsc_get_customer_filter_items" };
2907 jQuery.post(supportcandy.ajax_url, data, function (response) {
2908 jQuery(".wpsc-setting-section-body").html(response);
2909 wpsc_reset_responsive_style();
2910 });
2911 }
2912
2913 /**
2914 * Get add customer ticket list filter items modal UI
2915 */
2916 function wpsc_get_add_ctl_filter_item() {
2917 wpsc_show_modal();
2918 var data = { action: "wpsc_get_add_ctl_filter_item" };
2919 jQuery.post(supportcandy.ajax_url, data, function (response) {
2920 // Set to modal.
2921 jQuery(".wpsc-modal-header").text(response.title);
2922 jQuery(".wpsc-modal-body").html(response.body);
2923 jQuery(".wpsc-modal-footer").html(response.footer);
2924 // Display modal.
2925 wpsc_show_modal_inner_container();
2926 });
2927 }
2928
2929 /**
2930 * Set add new customer list items
2931 */
2932 function wpsc_set_add_ctl_filter_item(el) {
2933 var form = jQuery(".frm-add-customer-tl-filter-items")[0];
2934 var dataform = new FormData(form);
2935
2936 var cf_id = dataform.getAll("customer-tl-filter-id[]");
2937 if (!cf_id.length) {
2938 alert(supportcandy.translations.req_fields_missing);
2939 return;
2940 }
2941
2942 jQuery(".wpsc-modal-footer button").attr("disabled", true);
2943 jQuery(el).text(supportcandy.translations.please_wait);
2944 jQuery
2945 .ajax({
2946 url: supportcandy.ajax_url,
2947 type: "POST",
2948 data: dataform,
2949 processData: false,
2950 contentType: false,
2951 })
2952 .done(function (res) {
2953 wpsc_close_modal();
2954 wpsc_get_customer_filter_items();
2955 });
2956 }
2957
2958 /**
2959 * Get delete customer ticket list item
2960 *
2961 * @param {*} slug
2962 */
2963 function wpsc_delete_ctl_filter_item(slug, nonce) {
2964 if (confirm(supportcandy.translations.confirm)) {
2965 var data = {
2966 action: "wpsc_delete_ctl_filter_item",
2967 slug: slug,
2968 _ajax_nonce: nonce,
2969 };
2970 jQuery.post(supportcandy.ajax_url, data, function (res) {
2971 wpsc_get_customer_filter_items();
2972 });
2973 }
2974 }
2975
2976 /**
2977 * Get Thank You Page Settings
2978 */
2979 function wpsc_get_gs_thankyou() {
2980 supportcandy.current_tab = "thank-you-page";
2981 jQuery(".wpsc-setting-tab-container button").removeClass("active");
2982 jQuery(
2983 ".wpsc-setting-tab-container button." + supportcandy.current_tab
2984 ).addClass("active");
2985
2986 window.history.replaceState(
2987 {},
2988 null,
2989 "admin.php?page=wpsc-settings&section=" +
2990 supportcandy.current_section +
2991 "&tab=" +
2992 supportcandy.current_tab
2993 );
2994 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
2995
2996 wpsc_scroll_top();
2997
2998 var data = { action: "wpsc_get_gs_thankyou" };
2999 jQuery.post(supportcandy.ajax_url, data, function (response) {
3000 jQuery(".wpsc-setting-section-body").html(response);
3001 wpsc_reset_responsive_style();
3002 });
3003 }
3004
3005 /**
3006 * Reset Thankyou page settings
3007 */
3008 function wpsc_reset_gs_thankyou(el, nonce) {
3009 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3010 jQuery(el).text(supportcandy.translations.please_wait);
3011 var data = { action: "wpsc_reset_gs_thankyou", _ajax_nonce: nonce };
3012 jQuery.post(supportcandy.ajax_url, data, function (response) {
3013 wpsc_get_gs_thankyou();
3014 });
3015 }
3016
3017 /**
3018 * Set Thankyou Page Settings
3019 */
3020 function wpsc_set_gs_thankyou(el) {
3021 var form = jQuery(".wpsc-frm-gs-thankyoupage")[0];
3022 var dataform = new FormData(form);
3023
3024 var is_tinymce =
3025 typeof tinyMCE !== "undefined" &&
3026 tinyMCE.get("wpsc-html-agent") &&
3027 !tinyMCE.get("wpsc-html-agent").isHidden();
3028 var description = is_tinymce
3029 ? tinyMCE.get("wpsc-html-agent").getContent().trim()
3030 : jQuery("#wpsc-html-agent").val();
3031 dataform.append("html-agent", description);
3032
3033 var is_tinymce =
3034 typeof tinyMCE !== "undefined" &&
3035 tinyMCE.get("wpsc-html-customer") &&
3036 !tinyMCE.get("wpsc-html-customer").isHidden();
3037 description = is_tinymce
3038 ? tinyMCE.get("wpsc-html-customer").getContent().trim()
3039 : jQuery("#wpsc-html-customer").val();
3040 dataform.append("html-customer", description);
3041
3042 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3043 jQuery(el).text(supportcandy.translations.please_wait);
3044 jQuery
3045 .ajax({
3046 url: supportcandy.ajax_url,
3047 type: "POST",
3048 data: dataform,
3049 processData: false,
3050 contentType: false,
3051 })
3052 .done(function (res) {
3053 wpsc_get_gs_thankyou();
3054 });
3055 }
3056
3057 /**
3058 * File attachment settings
3059 */
3060 function wpsc_get_gs_file_attachments() {
3061 supportcandy.current_tab = "file-attachments";
3062 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3063 jQuery(
3064 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3065 ).addClass("active");
3066
3067 window.history.replaceState(
3068 {},
3069 null,
3070 "admin.php?page=wpsc-settings&section=" +
3071 supportcandy.current_section +
3072 "&tab=" +
3073 supportcandy.current_tab
3074 );
3075 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3076
3077 wpsc_scroll_top();
3078
3079 var data = { action: "wpsc_get_gs_file_attachments" };
3080 jQuery.post(supportcandy.ajax_url, data, function (response) {
3081 jQuery(".wpsc-setting-section-body").html(response);
3082 wpsc_reset_responsive_style();
3083 });
3084 }
3085
3086 /**
3087 * Save page settings
3088 */
3089 function wpsc_set_gs_file_attachments(el) {
3090 var form = jQuery(".wpsc-frm-gs-fa")[0];
3091 var dataform = new FormData(form);
3092 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3093 jQuery(el).text(supportcandy.translations.please_wait);
3094 jQuery
3095 .ajax({
3096 url: supportcandy.ajax_url,
3097 type: "POST",
3098 data: dataform,
3099 processData: false,
3100 contentType: false,
3101 })
3102 .done(function (res) {
3103 wpsc_get_gs_file_attachments();
3104 });
3105 }
3106
3107 /**
3108 * Reset file attachments
3109 */
3110 function wpsc_reset_gs_file_attachments(el, nonce) {
3111 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3112 jQuery(el).text(supportcandy.translations.please_wait);
3113 var data = { action: "wpsc_reset_gs_file_attachments", _ajax_nonce: nonce };
3114 jQuery.post(supportcandy.ajax_url, data, function (response) {
3115 wpsc_get_gs_file_attachments();
3116 });
3117 }
3118
3119 /**
3120 * Get email notifications general setting
3121 */
3122 function wpsc_get_en_general_setting(is_humbargar = false) {
3123 if (is_humbargar) {
3124 wpsc_toggle_humbargar();
3125 }
3126
3127 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
3128 jQuery(
3129 ".wpsc-setting-nav.general-settings, .wpsc-humbargar-menu-item.general-settings"
3130 ).addClass("active");
3131 jQuery(".wpsc-humbargar-title").html(
3132 supportcandy.humbargar_titles.general_settings
3133 );
3134
3135 window.history.replaceState(
3136 {},
3137 null,
3138 "admin.php?page=wpsc-email-notifications&section=general-settings"
3139 );
3140 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
3141
3142 wpsc_scroll_top();
3143
3144 var data = { action: "wpsc_get_en_general_setting" };
3145 jQuery.post(supportcandy.ajax_url, data, function (response) {
3146 jQuery(".wpsc-setting-body").html(response);
3147 wpsc_reset_responsive_style();
3148 });
3149 }
3150
3151 /**
3152 * Save email notification general settings
3153 */
3154 function wpsc_set_en_general(el) {
3155 var form = jQuery(".wpsc-frm-en-general")[0];
3156 var dataform = new FormData(form);
3157 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3158 jQuery(el).text(supportcandy.translations.please_wait);
3159 jQuery
3160 .ajax({
3161 url: supportcandy.ajax_url,
3162 type: "POST",
3163 data: dataform,
3164 processData: false,
3165 contentType: false,
3166 })
3167 .done(function (res) {
3168 wpsc_get_en_general_setting();
3169 });
3170 }
3171
3172 /**
3173 * Reset email notification general settings
3174 */
3175 function wpsc_reset_en_general(el, nonce) {
3176 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3177 jQuery(el).text(supportcandy.translations.please_wait);
3178 var data = { action: "wpsc_reset_en_general", _ajax_nonce: nonce };
3179 jQuery.post(supportcandy.ajax_url, data, function (response) {
3180 wpsc_get_en_general_setting();
3181 });
3182 }
3183
3184 /**
3185 * Get ticket notifications setting
3186 */
3187 function wpsc_get_ticket_notifications(is_humbargar = false) {
3188 if (is_humbargar) {
3189 wpsc_toggle_humbargar();
3190 }
3191
3192 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
3193 jQuery(
3194 ".wpsc-setting-nav.ticket-notifications, .wpsc-humbargar-menu-item.ticket-notifications"
3195 ).addClass("active");
3196 jQuery(".wpsc-humbargar-title").html(
3197 supportcandy.humbargar_titles.ticket_notifications
3198 );
3199
3200 window.history.replaceState(
3201 {},
3202 null,
3203 "admin.php?page=wpsc-email-notifications&section=ticket-notifications"
3204 );
3205 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
3206
3207 wpsc_scroll_top();
3208
3209 var data = { action: "wpsc_get_ticket_notifications" };
3210 jQuery.post(supportcandy.ajax_url, data, function (response) {
3211 jQuery(".wpsc-setting-body").html(response);
3212 wpsc_reset_responsive_style();
3213 });
3214 }
3215
3216 /**
3217 * Set add ticket notification
3218 */
3219 function wpsc_en_set_add_ticket_notification(el) {
3220 var title = jQuery(el)
3221 .closest(".modal")
3222 .find("input[name=title]")
3223 .val()
3224 .trim();
3225 if (!title) {
3226 alert(supportcandy.translations.req_fields_missing);
3227 return;
3228 }
3229
3230 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3231 jQuery(el).text(supportcandy.translations.please_wait);
3232
3233 var form = jQuery(".wpsc-frm-add-en")[0];
3234 var dataform = new FormData(form);
3235 jQuery
3236 .ajax({
3237 url: supportcandy.ajax_url,
3238 type: "POST",
3239 data: dataform,
3240 processData: false,
3241 contentType: false,
3242 })
3243 .done(function (response) {
3244 wpsc_close_modal();
3245 wpsc_en_get_edit_ticket_notification(response.index, response.nonce);
3246 });
3247 }
3248
3249 /**
3250 * Get edit email notification
3251 *
3252 * @param {int} id
3253 */
3254 function wpsc_en_get_edit_ticket_notification(template_id, nonce) {
3255 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3256 var data = {
3257 action: "wpsc_en_get_edit_ticket_notification",
3258 template_id,
3259 _ajax_nonce: nonce,
3260 };
3261 jQuery.post(supportcandy.ajax_url, data, function (res) {
3262 jQuery(".wpsc-setting-section-body").html(res);
3263 });
3264 }
3265
3266 /**
3267 * Set edit email notification
3268 */
3269 function wpsc_en_set_edit_ticket_notification() {
3270 var form = jQuery(".wpsc-frm-edit-en")[0];
3271 var dataform = new FormData(form);
3272
3273 var title = dataform.get("title").trim();
3274 if (!title) {
3275 alert(supportcandy.translations.req_fields_missing);
3276 return;
3277 }
3278
3279 var subject = dataform.get("subject").trim();
3280 if (!subject) {
3281 alert(supportcandy.translations.req_fields_missing);
3282 return;
3283 }
3284
3285 var is_tinymce =
3286 typeof tinyMCE != "undefined" &&
3287 tinyMCE.activeEditor &&
3288 !tinyMCE.activeEditor.isHidden();
3289 var body = is_tinymce
3290 ? tinyMCE.get("wpsc-en-body").getContent().trim()
3291 : dataform.get("body").trim();
3292 dataform.append("body", body);
3293
3294 if (!body) {
3295 alert(supportcandy.translations.req_fields_missing);
3296 return;
3297 }
3298
3299 // to.
3300 var toGeneral = dataform.getAll("to[general-recipients][]");
3301 var toRoles = dataform.getAll("to[agent-roles][]");
3302 var toCustom = dataform.get("to[custom]").trim();
3303 if (!(toGeneral.length || toRoles.length || toCustom)) {
3304 alert(supportcandy.translations.req_fields_missing);
3305 return;
3306 }
3307
3308 dataform.append(
3309 "conditions",
3310 JSON.stringify(wpsc_get_condition_json("conditions"))
3311 );
3312
3313 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3314 jQuery
3315 .ajax({
3316 url: supportcandy.ajax_url,
3317 type: "POST",
3318 data: dataform,
3319 processData: false,
3320 contentType: false,
3321 })
3322 .done(function (res) {
3323 wpsc_get_ticket_notifications();
3324 });
3325 }
3326
3327 /**
3328 * Get clone ticket notification
3329 *
3330 * @param {INT} template_id
3331 */
3332 function wpsc_en_get_clone_ticket_notification(template_id, nonce) {
3333 wpsc_show_modal();
3334 var data = {
3335 action: "wpsc_en_get_clone_ticket_notification",
3336 template_id,
3337 _ajax_nonce: nonce,
3338 };
3339
3340 jQuery.post(supportcandy.ajax_url, data, function (response) {
3341 jQuery(".wpsc-modal-header").text(response.title);
3342 jQuery(".wpsc-modal-body").html(response.body);
3343 jQuery(".wpsc-modal-footer").html(response.footer);
3344
3345 wpsc_show_modal_inner_container();
3346 });
3347 }
3348
3349 /**
3350 * Set clone ticket notification
3351 */
3352 function wpsc_en_set_clone_ticket_notification(el) {
3353 var form = jQuery(".wpsc-en-add-clone")[0];
3354 var dataform = new FormData(form);
3355
3356 if (dataform.get("title").trim() == "") {
3357 alert(supportcandy.translations.req_fields_missing);
3358 return;
3359 }
3360
3361 jQuery(el).text(supportcandy.translations.please_wait);
3362 jQuery
3363 .ajax({
3364 url: supportcandy.ajax_url,
3365 type: "POST",
3366 data: dataform,
3367 processData: false,
3368 contentType: false,
3369 })
3370 .done(function (response) {
3371 wpsc_close_modal();
3372 wpsc_en_get_edit_ticket_notification(response.index, response.nonce);
3373 });
3374 }
3375
3376 /**
3377 * Disable ticket notification
3378 */
3379 function wpsc_en_enable_disable_template(template_id, status, nonce) {
3380 var data = {
3381 action: "wpsc_en_enable_disable_template",
3382 template_id,
3383 status,
3384 _ajax_nonce: nonce,
3385 };
3386
3387 jQuery.post(supportcandy.ajax_url, data, function (response) {
3388 wpsc_get_ticket_notifications();
3389 });
3390 }
3391
3392 /**
3393 * Delete email notification
3394 *
3395 * @param {int} template_id
3396 */
3397 function wpsc_en_delete_ticket_notification(template_id, nonce) {
3398 var flag = confirm(supportcandy.translations.confirm);
3399 if (!flag) {
3400 return;
3401 }
3402
3403 var data = {
3404 action: "wpsc_en_delete_ticket_notification",
3405 template_id,
3406 _ajax_nonce: nonce,
3407 };
3408 jQuery.post(supportcandy.ajax_url, data, function (res) {
3409 wpsc_get_ticket_notifications();
3410 });
3411 }
3412
3413 /**
3414 * Get miscellaneous settings
3415 *
3416 * @param {*} is_humbargar
3417 */
3418 function wpsc_get_miscellaneous_settings(is_humbargar = false) {
3419 if (is_humbargar) {
3420 wpsc_toggle_humbargar();
3421 }
3422
3423 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
3424 jQuery(
3425 ".wpsc-setting-nav.miscellaneous-settings, .wpsc-humbargar-menu-item.miscellaneous-settings"
3426 ).addClass("active");
3427 jQuery(".wpsc-humbargar-title").html(
3428 supportcandy.humbargar_titles.miscellaneous_settings
3429 );
3430
3431 if (supportcandy.current_section !== "miscellaneous-settings") {
3432 supportcandy.current_section = "miscellaneous-settings";
3433 supportcandy.current_tab = "term-and-conditions";
3434 }
3435
3436 window.history.replaceState(
3437 {},
3438 null,
3439 "admin.php?page=wpsc-settings&section=miscellaneous-settings"
3440 );
3441 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
3442
3443 wpsc_scroll_top();
3444
3445 var data = { action: "wpsc_get_miscellaneous_settings" };
3446 jQuery.post(supportcandy.ajax_url, data, function (response) {
3447 jQuery(".wpsc-setting-body").html(response);
3448 wpsc_reset_responsive_style();
3449 jQuery(
3450 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3451 ).trigger("click");
3452 });
3453 }
3454
3455 /**
3456 * Get ticket widget
3457 */
3458 function wpsc_get_ticket_widget(is_humbargar) {
3459 if (is_humbargar) {
3460 wpsc_toggle_humbargar();
3461 }
3462
3463 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
3464 jQuery(
3465 ".wpsc-setting-nav.ticket-widgets, .wpsc-humbargar-menu-item.ticket-widgets"
3466 ).addClass("active");
3467 jQuery(".wpsc-humbargar-title").html(
3468 supportcandy.humbargar_titles.ticket_widget
3469 );
3470
3471 window.history.replaceState(
3472 {},
3473 null,
3474 "admin.php?page=wpsc-settings&section=ticket-widgets"
3475 );
3476 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
3477
3478 wpsc_scroll_top();
3479
3480 var data = { action: "wpsc_get_ticket_widget" };
3481 jQuery.post(supportcandy.ajax_url, data, function (response) {
3482 jQuery(".wpsc-setting-body").html(response);
3483 wpsc_reset_responsive_style();
3484 });
3485 }
3486
3487 /**
3488 * Get Terms and conditions settings
3489 */
3490 function wpsc_get_ms_term_and_conditions() {
3491 supportcandy.current_tab = "term-and-conditions";
3492 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3493 jQuery(
3494 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3495 ).addClass("active");
3496
3497 window.history.replaceState(
3498 {},
3499 null,
3500 "admin.php?page=wpsc-settings&section=" +
3501 supportcandy.current_section +
3502 "&tab=" +
3503 supportcandy.current_tab
3504 );
3505 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3506
3507 wpsc_scroll_top();
3508 var data = { action: "wpsc_get_ms_term_and_conditions" };
3509 jQuery.post(supportcandy.ajax_url, data, function (response) {
3510 jQuery(".wpsc-setting-section-body").html(response);
3511 wpsc_reset_responsive_style();
3512 });
3513 }
3514
3515 /**
3516 * Get agent view settings
3517 */
3518 function wpsc_tl_ms_get_agent_view() {
3519 supportcandy.current_tab = "agent-view";
3520 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3521 jQuery(
3522 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3523 ).addClass("active");
3524
3525 window.history.replaceState(
3526 {},
3527 null,
3528 "admin.php?page=wpsc-ticket-list&section=" +
3529 supportcandy.current_section +
3530 "&tab=" +
3531 supportcandy.current_tab
3532 );
3533 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3534
3535 wpsc_scroll_top();
3536
3537 var data = { action: "wpsc_tl_ms_get_agent_view" };
3538 jQuery.post(supportcandy.ajax_url, data, function (response) {
3539 jQuery(".wpsc-setting-section-body").html(response);
3540 wpsc_reset_responsive_style();
3541 });
3542 }
3543
3544 /**
3545 * Save terms and conditions
3546 *
3547 * @param {*} el
3548 */
3549 function wpsc_set_ms_term_and_conditions(el) {
3550 var form = jQuery(".wpsc-frm-ms-tandc")[0];
3551 var dataform = new FormData(form);
3552 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3553 var is_tinymce_ct =
3554 typeof tinyMCE != "undefined" &&
3555 tinyMCE.get("tandc-text") &&
3556 !tinyMCE.get("tandc-text").isHidden();
3557
3558 if (is_tinymce_ct) {
3559 var description = tinyMCE.get("tandc-text").getContent().trim();
3560 } else {
3561 var description = jQuery("#tandc-text").val();
3562 }
3563 dataform.append("tandc-text", description);
3564
3565 var is_tinymce_reg =
3566 typeof tinyMCE != "undefined" &&
3567 tinyMCE.get("tandc-text-reg-user") &&
3568 !tinyMCE.get("tandc-text-reg-user").isHidden();
3569
3570 if (is_tinymce_reg) {
3571 var description = tinyMCE.get("tandc-text-reg-user").getContent().trim();
3572 } else {
3573 var description = jQuery("#tandc-text-reg-user").val();
3574 }
3575 dataform.append("tandc-text-reg-user", description);
3576
3577 jQuery(el).text(supportcandy.translations.please_wait);
3578 jQuery
3579 .ajax({
3580 url: supportcandy.ajax_url,
3581 type: "POST",
3582 data: dataform,
3583 processData: false,
3584 contentType: false,
3585 })
3586 .done(function (res) {
3587 wpsc_get_ms_term_and_conditions();
3588 });
3589 }
3590
3591 /**
3592 * Sort ticket widget
3593 */
3594 function wpsc_set_tw_load_order(slugs, nonce) {
3595 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3596 var data = { action: "wpsc_set_tw_load_order", slugs, _ajax_nonce: nonce };
3597 jQuery.post(supportcandy.ajax_url, data, function (res) {
3598 wpsc_get_ticket_widget();
3599 });
3600 }
3601
3602 /**
3603 * Get edit Agent Collision widget
3604 */
3605 function wpsc_get_tw_agent_collision() {
3606
3607 wpsc_show_modal();
3608 var data = { action: 'wpsc_get_tw_agent_collision' };
3609 jQuery.post(
3610 supportcandy.ajax_url,
3611 data,
3612 function (response) {
3613
3614 // Set to modal.
3615 jQuery( '.wpsc-modal-header' ).text( response.title );
3616 jQuery( '.wpsc-modal-body' ).html( response.body );
3617 jQuery( '.wpsc-modal-footer' ).html( response.footer );
3618 // Display modal.
3619 wpsc_show_modal_inner_container();
3620 }
3621 );
3622 }
3623
3624 /**
3625 * Set edit Agent Collision widget
3626 */
3627 function wpsc_set_tw_agent_collision(el) {
3628 var form = jQuery( '.wpsc-frm-edit-ac' )[0];
3629 var dataform = new FormData( form );
3630
3631 if (dataform.get( 'label' ).trim() == '') {
3632 alert( supportcandy.translations.req_fields_missing );
3633 return;
3634 }
3635
3636 jQuery( '.wpsc-modal-footer button' ).attr( 'disabled', true );
3637 jQuery( el ).text( supportcandy.translations.please_wait );
3638
3639 jQuery.ajax(
3640 {
3641 url: supportcandy.ajax_url,
3642 type: 'POST',
3643 data: dataform,
3644 processData: false,
3645 contentType: false
3646 }
3647 ).done(
3648 function (res) {
3649 wpsc_close_modal();
3650 wpsc_get_ticket_widget();
3651 }
3652 );
3653 }
3654
3655 /**
3656 * Ticket widget status
3657 */
3658 function wpsc_get_tw_ticket_status() {
3659 wpsc_show_modal();
3660 var data = { action: "wpsc_get_tw_ticket_status" };
3661 jQuery.post(supportcandy.ajax_url, data, function (response) {
3662 // Set to modal.
3663 jQuery(".wpsc-modal-header").text(response.title);
3664 jQuery(".wpsc-modal-body").html(response.body);
3665 jQuery(".wpsc-modal-footer").html(response.footer);
3666 // Display modal.
3667 wpsc_show_modal_inner_container();
3668 });
3669 }
3670
3671 /**
3672 * Set ticket widget status
3673 */
3674 function wpsc_set_tw_ticket_status(el) {
3675 var form = jQuery(".wpsc-frm-edit-ticket-status")[0];
3676 var dataform = new FormData(form);
3677
3678 if (dataform.get("label").trim() == "") {
3679 alert(supportcandy.translations.req_fields_missing);
3680 return;
3681 }
3682
3683 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3684 jQuery(el).text(supportcandy.translations.please_wait);
3685
3686 jQuery
3687 .ajax({
3688 url: supportcandy.ajax_url,
3689 type: "POST",
3690 data: dataform,
3691 processData: false,
3692 contentType: false,
3693 })
3694 .done(function (res) {
3695 wpsc_close_modal();
3696 wpsc_get_ticket_widget();
3697 });
3698 }
3699
3700 /**
3701 * Set agent view settings
3702 *
3703 * @param {*} el
3704 */
3705 function wpsc_tl_ms_set_agent_view(el) {
3706 var form = jQuery(".wpsc-frm-tl-ms-agent-view")[0];
3707 var dataform = new FormData(form);
3708 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3709 jQuery(el).text(supportcandy.translations.please_wait);
3710 jQuery
3711 .ajax({
3712 url: supportcandy.ajax_url,
3713 type: "POST",
3714 data: dataform,
3715 processData: false,
3716 contentType: false,
3717 })
3718 .done(function (res) {
3719 wpsc_tl_ms_get_agent_view();
3720 });
3721 }
3722
3723 /**
3724 * Reset terms and conditions
3725 *
3726 * @param {*} el
3727 */
3728 function wpsc_reset_ms_term_and_conditions(el, nonce) {
3729 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3730 jQuery(el).text(supportcandy.translations.please_wait);
3731 var data = {
3732 action: "wpsc_reset_ms_term_and_conditions",
3733 _ajax_nonce: nonce,
3734 };
3735 jQuery.post(supportcandy.ajax_url, data, function (response) {
3736 wpsc_get_ms_term_and_conditions();
3737 });
3738 }
3739
3740 /**
3741 * Get ticket widget raised by
3742 */
3743 function wpsc_get_tw_raised_by() {
3744 wpsc_show_modal();
3745 var data = { action: "wpsc_get_tw_raised_by" };
3746 jQuery.post(supportcandy.ajax_url, data, function (response) {
3747 // Set to modal.
3748 jQuery(".wpsc-modal-header").text(response.title);
3749 jQuery(".wpsc-modal-body").html(response.body);
3750 jQuery(".wpsc-modal-footer").html(response.footer);
3751 // Display modal.
3752 wpsc_show_modal_inner_container();
3753 });
3754 }
3755
3756 /**
3757 * Reset agent view settings
3758 *
3759 * @param {*} el
3760 */
3761 function wpsc_tl_ms_reset_agent_view(el, nonce) {
3762 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3763 jQuery(el).text(supportcandy.translations.please_wait);
3764 var data = { action: "wpsc_tl_ms_reset_agent_view", _ajax_nonce: nonce };
3765 jQuery.post(supportcandy.ajax_url, data, function (response) {
3766 wpsc_tl_ms_get_agent_view();
3767 });
3768 }
3769
3770 /**
3771 * Get reCaptcha settings
3772 */
3773 function wpsc_get_ms_recaptcha() {
3774 supportcandy.current_tab = "recaptcha";
3775 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3776 jQuery(
3777 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3778 ).addClass("active");
3779
3780 window.history.replaceState(
3781 {},
3782 null,
3783 "admin.php?page=wpsc-settings&section=" +
3784 supportcandy.current_section +
3785 "&tab=" +
3786 supportcandy.current_tab
3787 );
3788 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3789
3790 wpsc_scroll_top();
3791
3792 var data = { action: "wpsc_get_ms_recaptcha" };
3793 jQuery.post(supportcandy.ajax_url, data, function (response) {
3794 jQuery(".wpsc-setting-section-body").html(response);
3795 wpsc_reset_responsive_style();
3796 });
3797 }
3798
3799 /**
3800 * Set ticket widget raised by
3801 */
3802 function wpsc_set_tw_raised_by(el) {
3803 var form = jQuery(".wpsc-frm-edit-ticket-raised-by")[0];
3804 var dataform = new FormData(form);
3805
3806 if (dataform.get("label").trim() == "") {
3807 alert(supportcandy.translations.req_fields_missing);
3808 return;
3809 }
3810
3811 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3812 jQuery(el).text(supportcandy.translations.please_wait);
3813
3814 jQuery
3815 .ajax({
3816 url: supportcandy.ajax_url,
3817 type: "POST",
3818 data: dataform,
3819 processData: false,
3820 contentType: false,
3821 })
3822 .done(function (res) {
3823 wpsc_close_modal();
3824 wpsc_get_ticket_widget();
3825 });
3826 }
3827
3828 /**
3829 * Get customer view settings
3830 */
3831 function wpsc_tl_ms_get_customer_view() {
3832 supportcandy.current_tab = "customer-view";
3833 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3834 jQuery(
3835 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3836 ).addClass("active");
3837
3838 window.history.replaceState(
3839 {},
3840 null,
3841 "admin.php?page=wpsc-ticket-list&section=" +
3842 supportcandy.current_section +
3843 "&tab=" +
3844 supportcandy.current_tab
3845 );
3846 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3847
3848 wpsc_scroll_top();
3849
3850 var data = { action: "wpsc_tl_ms_get_customer_view" };
3851 jQuery.post(supportcandy.ajax_url, data, function (response) {
3852 jQuery(".wpsc-setting-section-body").html(response);
3853 wpsc_reset_responsive_style();
3854 });
3855 }
3856
3857 /**
3858 * Save reCaptcha
3859 *
3860 * @param {*} el
3861 */
3862 function wpsc_set_ms_recaptcha(el) {
3863 var form = jQuery(".wpsc-frm-ms-recaptcha")[0];
3864 var dataform = new FormData(form);
3865 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3866 jQuery(el).text(supportcandy.translations.please_wait);
3867 jQuery
3868 .ajax({
3869 url: supportcandy.ajax_url,
3870 type: "POST",
3871 data: dataform,
3872 processData: false,
3873 contentType: false,
3874 })
3875 .done(function (res) {
3876 wpsc_get_ms_recaptcha();
3877 });
3878 }
3879
3880 /**
3881 * Get ticket widget ticket info
3882 */
3883 function wpsc_get_tw_ticket_info() {
3884 wpsc_show_modal();
3885 var data = { action: "wpsc_get_tw_ticket_info" };
3886 jQuery.post(supportcandy.ajax_url, data, function (response) {
3887 // Set to modal.
3888 jQuery(".wpsc-modal-header").text(response.title);
3889 jQuery(".wpsc-modal-body").html(response.body);
3890 jQuery(".wpsc-modal-footer").html(response.footer);
3891 // Display modal.
3892 wpsc_show_modal_inner_container();
3893 });
3894 }
3895
3896 /**
3897 * Add new option snippet
3898 */
3899 function wpsc_get_add_new_option() {
3900 jQuery(".wpsc-options-container").append(jQuery(".wpsc-add-option").html());
3901 jQuery(".wpsc-options-container")
3902 .children()
3903 .last()
3904 .find(".wpsc-add-option-container input:first")
3905 .focus();
3906 }
3907
3908 /**
3909 * Add new option for custom field
3910 */
3911 function wpsc_add_new_option(el, nonce) {
3912 var submitBtn = jQuery(el);
3913 var inputField = jQuery(el).parent().find("input").first();
3914
3915 var name = inputField.val().trim();
3916 if (!name) {
3917 return;
3918 }
3919
3920 submitBtn.attr("disabled", true);
3921 inputField.attr("disabled", true);
3922 submitBtn.html(supportcandy.inline_loader);
3923
3924 var data = { action: "wpsc_add_new_option", name, _ajax_nonce: nonce };
3925 jQuery.post(supportcandy.ajax_url, data, function (response) {
3926 submitBtn
3927 .closest(".wpsc-option-item")
3928 .find(".wpsc-option-listing-container .text")
3929 .text(response.name);
3930 submitBtn
3931 .closest(".wpsc-option-item")
3932 .append(
3933 '<input type="hidden" class="option_id" name="options[]" value="' +
3934 response.id +
3935 '">'
3936 );
3937 submitBtn.parent().hide();
3938 submitBtn.closest(".content").find(".wpsc-option-listing-container").show();
3939 wpsc_change_def_val_option_single();
3940 });
3941 }
3942
3943 /**
3944 * Set ticket widget ticket info
3945 */
3946 function wpsc_set_tw_ticket_info(el) {
3947 var form = jQuery(".wpsc-frm-edit-ticket-info")[0];
3948 var dataform = new FormData(form);
3949
3950 if (dataform.get("label").trim() == "") {
3951 alert(supportcandy.translations.req_fields_missing);
3952 return;
3953 }
3954
3955 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3956 jQuery(el).text(supportcandy.translations.please_wait);
3957
3958 jQuery
3959 .ajax({
3960 url: supportcandy.ajax_url,
3961 type: "POST",
3962 data: dataform,
3963 processData: false,
3964 contentType: false,
3965 })
3966 .done(function (res) {
3967 wpsc_close_modal();
3968 wpsc_get_ticket_widget();
3969 });
3970 }
3971
3972 /**
3973 * Reset reCaptcha
3974 *
3975 * @param {*} el
3976 */
3977 function wpsc_reset_ms_recaptcha(el, nonce) {
3978 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3979 jQuery(el).text(supportcandy.translations.please_wait);
3980 var data = { action: "wpsc_reset_ms_recaptcha", _ajax_nonce: nonce };
3981 jQuery.post(supportcandy.ajax_url, data, function (response) {
3982 wpsc_get_ms_recaptcha();
3983 });
3984 }
3985
3986 /**
3987 * Set customer view settings
3988 *
3989 * @param {*} el
3990 */
3991 function wpsc_tl_ms_set_customer_view(el) {
3992 var form = jQuery(".wpsc-frm-tl-ms-customer-view")[0];
3993 var dataform = new FormData(form);
3994 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3995 jQuery(el).text(supportcandy.translations.please_wait);
3996 jQuery
3997 .ajax({
3998 url: supportcandy.ajax_url,
3999 type: "POST",
4000 data: dataform,
4001 processData: false,
4002 contentType: false,
4003 })
4004 .done(function (res) {
4005 wpsc_tl_ms_get_customer_view();
4006 });
4007 }
4008
4009 /**
4010 * Get ticket widget agents
4011 */
4012 function wpsc_get_tw_agents() {
4013 wpsc_show_modal();
4014 var data = { action: "wpsc_get_tw_agents" };
4015 jQuery.post(supportcandy.ajax_url, data, function (response) {
4016 // Set to modal.
4017 jQuery(".wpsc-modal-header").text(response.title);
4018 jQuery(".wpsc-modal-body").html(response.body);
4019 jQuery(".wpsc-modal-footer").html(response.footer);
4020 // Display modal.
4021 wpsc_show_modal_inner_container();
4022 });
4023 }
4024
4025 /**
4026 * Reset customer view settings
4027 *
4028 * @param {*} el
4029 */
4030 function wpsc_tl_ms_reset_customer_view(el, nonce) {
4031 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4032 jQuery(el).text(supportcandy.translations.please_wait);
4033 var data = { action: "wpsc_tl_ms_reset_customer_view", _ajax_nonce: nonce };
4034 jQuery.post(supportcandy.ajax_url, data, function (response) {
4035 wpsc_tl_ms_get_customer_view();
4036 });
4037 }
4038
4039 /**
4040 * Set ticket widget agents
4041 */
4042 function wpsc_set_tw_agents(el) {
4043 var form = jQuery(".wpsc-frm-edit-agents")[0];
4044 var dataform = new FormData(form);
4045
4046 if (dataform.get("label").trim() == "") {
4047 alert(supportcandy.translations.req_fields_missing);
4048 return;
4049 }
4050
4051 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4052 jQuery(el).text(supportcandy.translations.please_wait);
4053
4054 jQuery
4055 .ajax({
4056 url: supportcandy.ajax_url,
4057 type: "POST",
4058 data: dataform,
4059 processData: false,
4060 contentType: false,
4061 })
4062 .done(function (res) {
4063 wpsc_close_modal();
4064 wpsc_get_ticket_widget();
4065 });
4066 }
4067
4068 /**
4069 * Get ticket widget ticket fields
4070 */
4071 function wpsc_get_tw_ticket_fields() {
4072 wpsc_show_modal();
4073 var data = { action: "wpsc_get_tw_ticket_fields" };
4074 jQuery.post(supportcandy.ajax_url, data, function (response) {
4075 // Set to modal.
4076 jQuery(".wpsc-modal-header").text(response.title);
4077 jQuery(".wpsc-modal-body").html(response.body);
4078 jQuery(".wpsc-modal-footer").html(response.footer);
4079 // Display modal.
4080 wpsc_show_modal_inner_container();
4081 });
4082 }
4083
4084 /**
4085 * Load edit option view
4086 */
4087 function wpsc_edit_option(el) {
4088 var editBtn = jQuery(el);
4089 var text = editBtn
4090 .closest(".wpsc-option-listing-container")
4091 .find(".text")
4092 .text();
4093 editBtn.closest(".content").find(".edit-option-text").val(text);
4094 editBtn.closest(".wpsc-option-listing-container").hide();
4095 editBtn.closest(".content").find(".wpsc-edit-option-container").show();
4096 }
4097
4098 /**
4099 * Update option
4100 */
4101 function wpsc_set_edit_option(el, nonce) {
4102 var submitBtn = jQuery(el);
4103 var inputField = jQuery(el).parent().find("input").first();
4104
4105 var option_id = submitBtn
4106 .closest(".wpsc-option-item")
4107 .find(".option_id")
4108 .val()
4109 .trim();
4110 if (!option_id) {
4111 return;
4112 }
4113
4114 var name = inputField.val().trim();
4115 if (!name) {
4116 return;
4117 }
4118
4119 submitBtn.attr("disabled", true);
4120 inputField.attr("disabled", true);
4121
4122 var submitHtml = submitBtn.html();
4123 submitBtn.html(supportcandy.inline_loader);
4124
4125 var data = {
4126 action: "wpsc_set_edit_option",
4127 id: option_id,
4128 name,
4129 _ajax_nonce: nonce,
4130 };
4131 jQuery.post(supportcandy.ajax_url, data, function (response) {
4132 submitBtn
4133 .closest(".wpsc-option-item")
4134 .find(".wpsc-option-listing-container .text")
4135 .text(response.name);
4136 submitBtn.attr("disabled", false);
4137 inputField.attr("disabled", false);
4138 submitBtn.html(submitHtml);
4139 submitBtn.parent().hide();
4140 submitBtn.closest(".content").find(".wpsc-option-listing-container").show();
4141 wpsc_change_def_val_option_single();
4142 });
4143 }
4144
4145 /**
4146 * Set ticket widget ticket fields
4147 */
4148 function wpsc_set_tw_ticket_fields(el) {
4149 var form = jQuery(".wpsc-frm-edit-ticket-fields")[0];
4150 var dataform = new FormData(form);
4151
4152 if (dataform.get("label").trim() == "") {
4153 alert(supportcandy.translations.req_fields_missing);
4154 return;
4155 }
4156
4157 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4158 jQuery(el).text(supportcandy.translations.please_wait);
4159
4160 jQuery
4161 .ajax({
4162 url: supportcandy.ajax_url,
4163 type: "POST",
4164 data: dataform,
4165 processData: false,
4166 contentType: false,
4167 })
4168 .done(function (res) {
4169 wpsc_close_modal();
4170 wpsc_get_ticket_widget();
4171 });
4172 }
4173
4174 /**
4175 * Get gdpr settings
4176 */
4177 function wpsc_get_ms_gdpr() {
4178 supportcandy.current_tab = "gdpr";
4179 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4180 jQuery(
4181 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4182 ).addClass("active");
4183
4184 window.history.replaceState(
4185 {},
4186 null,
4187 "admin.php?page=wpsc-settings&section=" +
4188 supportcandy.current_section +
4189 "&tab=" +
4190 supportcandy.current_tab
4191 );
4192 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4193
4194 wpsc_scroll_top();
4195
4196 var data = { action: "wpsc_get_ms_gdpr" };
4197 jQuery.post(supportcandy.ajax_url, data, function (response) {
4198 jQuery(".wpsc-setting-section-body").html(response);
4199 wpsc_reset_responsive_style();
4200 });
4201 }
4202
4203 /**
4204 * Get advanced settings of tl more settings
4205 */
4206 function wpsc_tl_ms_get_advanced() {
4207 supportcandy.current_tab = "advanced";
4208 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4209 jQuery(
4210 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4211 ).addClass("active");
4212
4213 window.history.replaceState(
4214 {},
4215 null,
4216 "admin.php?page=wpsc-ticket-list&section=" +
4217 supportcandy.current_section +
4218 "&tab=" +
4219 supportcandy.current_tab
4220 );
4221 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4222
4223 wpsc_scroll_top();
4224
4225 var data = { action: "wpsc_tl_ms_get_advanced" };
4226 jQuery.post(supportcandy.ajax_url, data, function (response) {
4227 jQuery(".wpsc-setting-section-body").html(response);
4228 wpsc_reset_responsive_style();
4229 });
4230 }
4231
4232 /**
4233 * Save gdpr
4234 *
4235 * @param {*} el
4236 */
4237 function wpsc_set_ms_gdpr(el) {
4238 var form = jQuery(".wpsc-frm-ms-gdpr")[0];
4239 var dataform = new FormData(form);
4240 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4241 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4242 var is_tinymce_ct =
4243 typeof tinyMCE != "undefined" &&
4244 tinyMCE.get("gdpr-text") &&
4245 !tinyMCE.get("gdpr-text").isHidden();
4246
4247 if (is_tinymce_ct) {
4248 var description = tinyMCE.get("gdpr-text").getContent().trim();
4249 } else {
4250 var description = jQuery("#gdpr-text").val();
4251 }
4252 dataform.append("gdpr-text", description);
4253
4254 var is_tinymce_reg =
4255 typeof tinyMCE != "undefined" &&
4256 tinyMCE.get("gdpr-text-reg-user") &&
4257 !tinyMCE.get("gdpr-text-reg-user").isHidden();
4258
4259 if (is_tinymce_reg) {
4260 var description = tinyMCE.get("gdpr-text-reg-user").getContent().trim();
4261 } else {
4262 var description = jQuery("#gdpr-text-reg-user").val();
4263 }
4264 dataform.append("gdpr-text-reg-user", description);
4265
4266 jQuery(el).text(supportcandy.translations.please_wait);
4267 jQuery
4268 .ajax({
4269 url: supportcandy.ajax_url,
4270 type: "POST",
4271 data: dataform,
4272 processData: false,
4273 contentType: false,
4274 })
4275 .done(function (res) {
4276 wpsc_get_ms_gdpr();
4277 });
4278 }
4279
4280 /**
4281 * Set advanced settings of tl more settings
4282 *
4283 * @param {*} el
4284 */
4285 function wpsc_tl_ms_set_advanced(el) {
4286 var form = jQuery(".wpsc-frm-advanced-settings")[0];
4287 var dataform = new FormData(form);
4288 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4289 jQuery(el).text(supportcandy.translations.please_wait);
4290 jQuery
4291 .ajax({
4292 url: supportcandy.ajax_url,
4293 type: "POST",
4294 data: dataform,
4295 processData: false,
4296 contentType: false,
4297 })
4298 .done(function (res) {
4299 wpsc_tl_ms_get_advanced();
4300 });
4301 }
4302
4303 /**
4304 * Get ticket widget agentOnly fields
4305 */
4306 function wpsc_get_tw_agentonly_fields() {
4307 wpsc_show_modal();
4308 var data = { action: "wpsc_get_tw_agentonly_fields" };
4309 jQuery.post(supportcandy.ajax_url, data, function (response) {
4310 // Set to modal.
4311 jQuery(".wpsc-modal-header").text(response.title);
4312 jQuery(".wpsc-modal-body").html(response.body);
4313 jQuery(".wpsc-modal-footer").html(response.footer);
4314 // Display modal.
4315 wpsc_show_modal_inner_container();
4316 });
4317 }
4318
4319 /**
4320 * Reset gdpr
4321 *
4322 * @param {*} el
4323 */
4324 function wpsc_reset_ms_gdpr(el, nonce) {
4325 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4326 jQuery(el).text(supportcandy.translations.please_wait);
4327 var data = { action: "wpsc_reset_ms_gdpr", _ajax_nonce: nonce };
4328 jQuery.post(supportcandy.ajax_url, data, function (response) {
4329 wpsc_get_ms_gdpr();
4330 });
4331 }
4332
4333 /**
4334 * Reset advanced settings of tl more settings
4335 *
4336 * @param {*} el
4337 */
4338 function wpsc_tl_ms_reset_advanced(el, nonce) {
4339 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4340 jQuery(el).text(supportcandy.translations.please_wait);
4341 var data = { action: "wpsc_tl_ms_reset_advanced", _ajax_nonce: nonce };
4342 jQuery.post(supportcandy.ajax_url, data, function (response) {
4343 wpsc_tl_ms_get_advanced();
4344 });
4345 }
4346
4347 /**
4348 * Get advanced miscellaneous settings
4349 */
4350 function wpsc_get_ms_advanced() {
4351 supportcandy.current_tab = "advanced";
4352 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4353 jQuery(
4354 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4355 ).addClass("active");
4356
4357 window.history.replaceState(
4358 {},
4359 null,
4360 "admin.php?page=wpsc-settings&section=" +
4361 supportcandy.current_section +
4362 "&tab=" +
4363 supportcandy.current_tab
4364 );
4365 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4366
4367 wpsc_scroll_top();
4368
4369 var data = { action: "wpsc_get_ms_advanced" };
4370 jQuery.post(supportcandy.ajax_url, data, function (response) {
4371 jQuery(".wpsc-setting-section-body").html(response);
4372 wpsc_reset_responsive_style();
4373 });
4374 }
4375
4376 /**
4377 * Set ticket widget agentOnly fields
4378 */
4379 function wpsc_set_tw_agentonly_fields(el) {
4380 var form = jQuery(".wpsc-frm-edit-agentonly-fields")[0];
4381 var dataform = new FormData(form);
4382
4383 if (dataform.get("label").trim() == "") {
4384 alert(supportcandy.translations.req_fields_missing);
4385 return;
4386 }
4387
4388 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4389 jQuery(el).text(supportcandy.translations.please_wait);
4390
4391 jQuery
4392 .ajax({
4393 url: supportcandy.ajax_url,
4394 type: "POST",
4395 data: dataform,
4396 processData: false,
4397 contentType: false,
4398 })
4399 .done(function (res) {
4400 wpsc_close_modal();
4401 wpsc_get_ticket_widget();
4402 });
4403 }
4404
4405 /**
4406 * Get ticket widget additional recipients
4407 */
4408 function wpsc_get_tw_additional_recipients() {
4409 wpsc_show_modal();
4410 var data = { action: "wpsc_get_tw_additional_recipients" };
4411 jQuery.post(supportcandy.ajax_url, data, function (response) {
4412 // Set to modal.
4413 jQuery(".wpsc-modal-header").text(response.title);
4414 jQuery(".wpsc-modal-body").html(response.body);
4415 jQuery(".wpsc-modal-footer").html(response.footer);
4416 // Display modal.
4417 wpsc_show_modal_inner_container();
4418 });
4419 }
4420
4421 /**
4422 * Save advanced miscellaneous settings
4423 *
4424 * @param {*} el
4425 */
4426 function wpsc_set_ms_advanced(el) {
4427 var form = jQuery(".wpsc-frm-ms-advanced")[0];
4428 var dataform = new FormData(form);
4429 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4430 jQuery(el).text(supportcandy.translations.please_wait);
4431 jQuery
4432 .ajax({
4433 url: supportcandy.ajax_url,
4434 type: "POST",
4435 data: dataform,
4436 processData: false,
4437 contentType: false,
4438 })
4439 .done(function (res) {
4440 wpsc_get_ms_advanced();
4441 });
4442 }
4443
4444 /**
4445 * Set ticket widget additional recipients
4446 */
4447 function wpsc_set_tw_additional_recipients(el) {
4448 var form = jQuery(".wpsc-frm-edit-additional-recipients")[0];
4449 var dataform = new FormData(form);
4450
4451 if (dataform.get("label").trim() == "") {
4452 alert(supportcandy.translations.req_fields_missing);
4453 return;
4454 }
4455
4456 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4457 jQuery(el).text(supportcandy.translations.please_wait);
4458
4459 jQuery
4460 .ajax({
4461 url: supportcandy.ajax_url,
4462 type: "POST",
4463 data: dataform,
4464 processData: false,
4465 contentType: false,
4466 })
4467 .done(function (res) {
4468 wpsc_close_modal();
4469 wpsc_get_ticket_widget();
4470 });
4471 }
4472
4473 /**
4474 * Reset advanced miscellaneous settings
4475 *
4476 * @param {*} el
4477 */
4478 function wpsc_reset_ms_advanced(el, nonce) {
4479 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4480 jQuery(el).text(supportcandy.translations.please_wait);
4481 var data = { action: "wpsc_reset_ms_advanced", _ajax_nonce: nonce };
4482 jQuery.post(supportcandy.ajax_url, data, function (response) {
4483 wpsc_get_ms_advanced();
4484 });
4485 }
4486
4487 /**
4488 * Cancel edit
4489 */
4490 function wpsc_edit_option_cancel(el) {
4491 var cancelBtn = jQuery(el);
4492 cancelBtn.closest(".wpsc-edit-option-container").hide();
4493 cancelBtn.closest(".content").find(".wpsc-option-listing-container").show();
4494 }
4495
4496 /**
4497 * Remove an item
4498 */
4499 function wpsc_remove_option_item(el) {
4500 jQuery(el).closest(".wpsc-option-item").remove();
4501 wpsc_change_def_val_option_single();
4502 }
4503
4504 /**
4505 * Change default value options
4506 */
4507 function wpsc_change_def_val_option_single() {
4508 var options = [];
4509 jQuery(".wpsc-options-container .option_id").each(function (index, el) {
4510 var key = jQuery(el).val().trim();
4511 var value = jQuery(el)
4512 .closest(".wpsc-option-item")
4513 .find(".wpsc-option-listing-container .text")
4514 .text();
4515 options.push({ key, value });
4516 });
4517 var optionStr = '<option value=""></option>';
4518 jQuery(options).each(function (index, el) {
4519 optionStr += '<option value="' + el.key + '">' + el.value + "</option>";
4520 });
4521
4522 var fieldType = jQuery("#wpsc-select-ticket-field").val();
4523
4524 var optionSingleTypes = ["cf_single_select", "cf_radio_button"];
4525 if (jQuery.inArray(fieldType, optionSingleTypes) != -1) {
4526 jQuery("#wpsc-default-val-option-single").html(optionStr);
4527 jQuery("#wpsc-default-val-option-single").selectWoo();
4528 }
4529
4530 var optionMultiTypes = ["cf_multi_select", "cf_checkbox"];
4531 if (jQuery.inArray(fieldType, optionMultiTypes) != -1) {
4532 var preValue = jQuery("#wpsc-default-val-option-multi").val();
4533
4534 jQuery("#wpsc-default-val-option-multi").html(optionStr);
4535 jQuery("#wpsc-default-val-option-multi").selectWoo();
4536
4537 if (preValue) {
4538 jQuery("#wpsc-default-val-option-multi").val(preValue);
4539 jQuery("#wpsc-default-val-option-multi").trigger("change");
4540 }
4541 }
4542 }
4543
4544 /**
4545 * Get rich text settings
4546 */
4547 function wpsc_get_rich_text_editor(is_humbargar = false) {
4548 if (is_humbargar) {
4549 wpsc_toggle_humbargar();
4550 }
4551
4552 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4553 jQuery(
4554 ".wpsc-setting-nav.rich-text-editor, .wpsc-humbargar-menu-item.rich-text-editor"
4555 ).addClass("active");
4556 jQuery(".wpsc-humbargar-title").html(
4557 supportcandy.humbargar_titles.rich_text_editor
4558 );
4559
4560 if (supportcandy.current_section !== "rich-text-editor") {
4561 supportcandy.current_section = "rich-text-editor";
4562 supportcandy.current_tab = "agent";
4563 }
4564
4565 window.history.replaceState(
4566 {},
4567 null,
4568 "admin.php?page=wpsc-settings&section=" +
4569 supportcandy.current_section +
4570 "&tab=" +
4571 supportcandy.current_tab
4572 );
4573 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4574
4575 wpsc_scroll_top();
4576
4577 var data = {
4578 action: "wpsc_get_rich_text_editor",
4579 tab: supportcandy.current_tab,
4580 };
4581 jQuery.post(supportcandy.ajax_url, data, function (response) {
4582 jQuery(".wpsc-setting-body").html(response);
4583 wpsc_reset_responsive_style();
4584 jQuery(
4585 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4586 ).trigger("click");
4587 });
4588 }
4589
4590 /**
4591 * Load agent tab ui
4592 */
4593 function wpsc_get_te_agent() {
4594 supportcandy.current_tab = "agent";
4595 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4596 jQuery(
4597 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4598 ).addClass("active");
4599
4600 window.history.replaceState(
4601 {},
4602 null,
4603 "admin.php?page=wpsc-settings&section=" +
4604 supportcandy.current_section +
4605 "&tab=" +
4606 supportcandy.current_tab
4607 );
4608 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4609
4610 wpsc_scroll_top();
4611
4612 const data = { action: "wpsc_get_te_agent" };
4613 jQuery.post(supportcandy.ajax_url, data, function (response) {
4614 jQuery(".wpsc-setting-section-body").html(response);
4615 wpsc_reset_responsive_style();
4616 });
4617 }
4618
4619 /**
4620 * Save agent settings
4621 */
4622 function wpsc_set_te_agent(el) {
4623 const form = jQuery(".wpsc-frm-te-agent")[0];
4624 const dataform = new FormData(form);
4625 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4626 jQuery(el).text(supportcandy.translations.please_wait);
4627 jQuery
4628 .ajax({
4629 url: supportcandy.ajax_url,
4630 type: "POST",
4631 data: dataform,
4632 processData: false,
4633 contentType: false,
4634 })
4635 .done(function (res) {
4636 wpsc_get_te_agent();
4637 });
4638 }
4639
4640 /**
4641 * Reset agent settings
4642 */
4643 function wpsc_reset_te_agent(el, nonce) {
4644 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4645 jQuery(el).text(supportcandy.translations.please_wait);
4646 const data = { action: "wpsc_reset_te_agent", _ajax_nonce: nonce };
4647 jQuery.post(supportcandy.ajax_url, data, function (response) {
4648 wpsc_get_te_agent();
4649 });
4650 }
4651
4652 /**
4653 * Load registered user tab ui
4654 */
4655 function wpsc_get_te_registered_user() {
4656 supportcandy.current_tab = "registered-user";
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&section=" +
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_registered_user" };
4675 jQuery.post(supportcandy.ajax_url, data, function (response) {
4676 jQuery(".wpsc-setting-section-body").html(response);
4677 wpsc_reset_responsive_style();
4678 });
4679 }
4680
4681 /**
4682 * Save registered user settings
4683 */
4684 function wpsc_set_te_registered_user(el) {
4685 const form = jQuery(".wpsc-frm-te-registered-user")[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_registered_user();
4699 });
4700 }
4701
4702 /**
4703 * Reset registered user settings
4704 */
4705 function wpsc_reset_te_registered_user(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_registered_user", _ajax_nonce: nonce };
4709 jQuery.post(supportcandy.ajax_url, data, function (response) {
4710 wpsc_get_te_registered_user();
4711 });
4712 }
4713
4714 /**
4715 * Load guest user tab ui
4716 */
4717 function wpsc_get_te_guest_user() {
4718 supportcandy.current_tab = "guest-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&section=" +
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_guest_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 guest user settings
4745 */
4746 function wpsc_set_te_guest_user(el) {
4747 const form = jQuery(".wpsc-frm-te-guest-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_guest_user();
4761 });
4762 }
4763
4764 /**
4765 * Reset guest user settings
4766 */
4767 function wpsc_reset_te_guest_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_guest_user", _ajax_nonce: nonce };
4771 jQuery.post(supportcandy.ajax_url, data, function (response) {
4772 wpsc_get_te_guest_user();
4773 });
4774 }
4775
4776 /**
4777 * Load advanced tab ui
4778 */
4779 function wpsc_get_te_advanced() {
4780 supportcandy.current_tab = "advanced";
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&section=" +
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_advanced" };
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 advanced settings
4807 */
4808 function wpsc_set_te_advanced(el) {
4809 const form = jQuery(".wpsc-frm-te-advanced")[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_advanced();
4823 });
4824 }
4825
4826 /**
4827 * Reset advanced settings
4828 */
4829 function wpsc_reset_te_advanced(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_advanced", _ajax_nonce: nonce };
4833 jQuery.post(supportcandy.ajax_url, data, function (response) {
4834 wpsc_get_te_advanced();
4835 });
4836 }
4837
4838 /**
4839 * Get agent working hrs settings
4840 */
4841 function wpsc_get_agents_working_hrs(is_humbargar = false) {
4842 if (is_humbargar) {
4843 wpsc_toggle_humbargar();
4844 }
4845
4846 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4847 jQuery(
4848 ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs"
4849 ).addClass("active");
4850 jQuery(".wpsc-humbargar-title").html(
4851 supportcandy.humbargar_titles.working_hrs
4852 );
4853
4854 window.history.replaceState(
4855 {},
4856 null,
4857 "admin.php?page=wpsc-support-agents&section=working-hrs"
4858 );
4859 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4860
4861 wpsc_scroll_top();
4862
4863 var data = { action: "wpsc_get_agents_working_hrs" };
4864 jQuery.post(supportcandy.ajax_url, data, function (response) {
4865 jQuery(".wpsc-setting-body").html(response);
4866 wpsc_reset_responsive_style();
4867 wpsc_get_agents_wh_hrs();
4868 });
4869 }
4870
4871 /**
4872 * Get working hrs of given agent id
4873 */
4874 function wpsc_get_agents_wh_hrs() {
4875 jQuery("button.tab.exceptions").removeClass("active");
4876 jQuery("button.tab.working-hrs").addClass("active");
4877 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4878 var data = {
4879 action: "wpsc_get_agents_wh_hrs",
4880 agent_id: supportcandy.temp.agent_id,
4881 _ajax_nonce: supportcandy.nonce,
4882 };
4883 jQuery.post(supportcandy.ajax_url, data, function (response) {
4884 jQuery(".wpsc-setting-section-body").html(response);
4885 });
4886 }
4887
4888 /**
4889 * Get agent working hrs exceptions
4890 */
4891 function wpsc_get_agents_wh_exceptions() {
4892 jQuery("button.tab.working-hrs").removeClass("active");
4893 jQuery("button.tab.exceptions").addClass("active");
4894 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4895 var data = {
4896 action: "wpsc_get_agents_wh_exceptions",
4897 agent_id: supportcandy.temp.agent_id,
4898 _ajax_nonce: supportcandy.nonce,
4899 };
4900 jQuery.post(supportcandy.ajax_url, data, function (response) {
4901 jQuery(".wpsc-setting-section-body").html(response);
4902 });
4903 }
4904
4905 /**
4906 * Get agent working hrs settings
4907 */
4908 function wpsc_get_agent_working_hrs(is_humbargar = false) {
4909 if (is_humbargar) {
4910 wpsc_toggle_humbargar();
4911 }
4912
4913 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4914 jQuery(
4915 ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs"
4916 ).addClass("active");
4917 jQuery(".wpsc-humbargar-title").html(
4918 supportcandy.humbargar_titles.working_hrs
4919 );
4920
4921 window.history.replaceState(
4922 {},
4923 null,
4924 "admin.php?page=wpsc-support-agents&section=working-hrs"
4925 );
4926 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4927
4928 wpsc_scroll_top();
4929
4930 var data = { action: "wpsc_get_agent_working_hrs" };
4931 jQuery.post(supportcandy.ajax_url, data, function (response) {
4932 jQuery(".wpsc-setting-body").html(response);
4933 wpsc_reset_responsive_style();
4934 window.location.reload();
4935 });
4936 }
4937
4938 /**
4939 * Get all agent leaves
4940 */
4941 function wpsc_get_agent_leaves(is_humbargar = false) {
4942 if (is_humbargar) {
4943 wpsc_toggle_humbargar();
4944 }
4945
4946 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4947 jQuery(".wpsc-setting-nav.leaves, .wpsc-humbargar-menu-item.leaves").addClass(
4948 "active"
4949 );
4950 jQuery(".wpsc-humbargar-title").html(supportcandy.humbargar_titles.leaves);
4951
4952 window.history.replaceState(
4953 {},
4954 null,
4955 "admin.php?page=wpsc-support-agents&section=leaves"
4956 );
4957 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4958
4959 wpsc_scroll_top();
4960
4961 var data = { action: "wpsc_get_agent_leaves" };
4962 jQuery.post(supportcandy.ajax_url, data, function (response) {
4963 jQuery(".wpsc-setting-body").html(response);
4964 wpsc_reset_responsive_style();
4965 });
4966 }
4967
4968 /**
4969 * Get add agent leaves
4970 */
4971 function wpsc_get_add_agent_leaves(dateSelected, _ajax_nonce) {
4972 supportcandy.temp.dateSelected = dateSelected;
4973 wpsc_show_modal();
4974 var data = {
4975 action: "wpsc_get_add_agent_leaves",
4976 dateSelected,
4977 _ajax_nonce,
4978 };
4979 jQuery.post(supportcandy.ajax_url, data, function (response) {
4980 // Set to modal.
4981 jQuery(".wpsc-modal-header").text(response.title);
4982 jQuery(".wpsc-modal-body").html(response.body);
4983 jQuery(".wpsc-modal-footer").html(response.footer);
4984 // Display modal.
4985 wpsc_show_modal_inner_container();
4986 });
4987 }
4988
4989 /**
4990 * Set add agent leaves
4991 */
4992 function wpsc_set_add_agent_leaves(el) {
4993 const form = jQuery(".wpsc-frm-agent-holiday-actions")[0];
4994 const dataform = new FormData(form);
4995
4996 var agents = dataform.getAll("agents[]");
4997 if (!agents.length) {
4998 alert(supportcandy.translations.req_fields_missing);
4999 return;
5000 }
5001
5002 dataform.append("dateSelected", supportcandy.temp.dateSelected);
5003 jQuery(el).text(supportcandy.translations.please_wait);
5004 jQuery
5005 .ajax({
5006 url: supportcandy.ajax_url,
5007 type: "POST",
5008 data: dataform,
5009 processData: false,
5010 contentType: false,
5011 })
5012 .done(function (response) {
5013 calendar.refetchEvents();
5014 wpsc_close_modal();
5015 });
5016 }
5017
5018 /**
5019 * Delete agent leave
5020 */
5021 function wpsc_delete_agent_leave(id, nonce) {
5022 var flag = confirm(supportcandy.translations.deleteLeaveConfirmation);
5023 if (!flag) {
5024 return;
5025 }
5026
5027 var data = {
5028 action: "wpsc_delete_agent_leave",
5029 holidayId: id,
5030 _ajax_nonce: nonce,
5031 };
5032 jQuery.post(supportcandy.ajax_url, data, function (response) {
5033 calendar.refetchEvents();
5034 });
5035 }
5036
5037 /**
5038 * User registration otp email template
5039 */
5040 function wpsc_get_en_user_reg_otp(is_humbargar = false) {
5041 if (is_humbargar) {
5042 wpsc_toggle_humbargar();
5043 }
5044
5045 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5046 jQuery(
5047 ".wpsc-setting-nav.registration-otp, .wpsc-humbargar-menu-item.registration-otp"
5048 ).addClass("active");
5049 jQuery(".wpsc-humbargar-title").html(
5050 supportcandy.humbargar_titles.registration_otp
5051 );
5052
5053 window.history.replaceState(
5054 {},
5055 null,
5056 "admin.php?page=wpsc-email-notifications&section=registration-otp"
5057 );
5058 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5059
5060 wpsc_scroll_top();
5061
5062 var data = { action: "wpsc_get_en_user_reg_otp" };
5063 jQuery.post(supportcandy.ajax_url, data, function (response) {
5064 jQuery(".wpsc-setting-body").html(response);
5065 wpsc_reset_responsive_style();
5066 });
5067 }
5068
5069 /**
5070 * Set user registration otp email template
5071 */
5072 function wpsc_set_en_user_reg_otp(el) {
5073 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5074 jQuery(el).text(supportcandy.translations.please_wait);
5075 var form = jQuery(".wpsc-frm-en-user-reg-otp")[0];
5076 var dataform = new FormData(form);
5077 if (dataform.get("editor") == "html") {
5078 dataform.append("body", tinyMCE.get("wpsc-en-body").getContent());
5079 }
5080 jQuery
5081 .ajax({
5082 url: supportcandy.ajax_url,
5083 type: "POST",
5084 data: dataform,
5085 processData: false,
5086 contentType: false,
5087 })
5088 .done(function (res) {
5089 wpsc_get_en_user_reg_otp();
5090 });
5091 }
5092
5093 /**
5094 * Reset user registration otp email template
5095 */
5096 function wpsc_reset_en_user_reg_otp(el, nonce) {
5097 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5098 jQuery(el).text(supportcandy.translations.please_wait);
5099 const data = { action: "wpsc_reset_en_user_reg_otp", _ajax_nonce: nonce };
5100 jQuery.post(supportcandy.ajax_url, data, function (response) {
5101 wpsc_get_en_user_reg_otp();
5102 });
5103 }
5104
5105 /**
5106 * Get guest login otp email template
5107 *
5108 * @param {boolean} is_humbargar
5109 */
5110 function wpsc_get_en_guest_login_otp(is_humbargar = false) {
5111 if (is_humbargar) {
5112 wpsc_toggle_humbargar();
5113 }
5114
5115 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5116 jQuery(
5117 ".wpsc-setting-nav.guest-login-otp, .wpsc-humbargar-menu-item.guest-login-otp"
5118 ).addClass("active");
5119 jQuery(".wpsc-humbargar-title").html(
5120 supportcandy.humbargar_titles.registration_otp
5121 );
5122
5123 window.history.replaceState(
5124 {},
5125 null,
5126 "admin.php?page=wpsc-email-notifications&section=guest-login-otp"
5127 );
5128 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5129
5130 wpsc_scroll_top();
5131
5132 var data = { action: "wpsc_get_en_guest_login_otp" };
5133 jQuery.post(supportcandy.ajax_url, data, function (response) {
5134 jQuery(".wpsc-setting-body").html(response);
5135 wpsc_reset_responsive_style();
5136 });
5137 }
5138
5139 /**
5140 * Set guest login otp email template
5141 */
5142 function wpsc_set_en_guest_login_otp(el) {
5143 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5144 jQuery(el).text(supportcandy.translations.please_wait);
5145 var form = jQuery(".wpsc-frm-en-guest-login-otp")[0];
5146 var dataform = new FormData(form);
5147 if (dataform.get("editor") == "html") {
5148 dataform.append("body", tinyMCE.get("wpsc-en-body").getContent());
5149 }
5150 jQuery
5151 .ajax({
5152 url: supportcandy.ajax_url,
5153 type: "POST",
5154 data: dataform,
5155 processData: false,
5156 contentType: false,
5157 })
5158 .done(function (res) {
5159 wpsc_get_en_guest_login_otp();
5160 });
5161 }
5162
5163 /**
5164 * Reset guest login otp email template
5165 */
5166 function wpsc_reset_en_guest_login_otp(el, nonce) {
5167 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5168 jQuery(el).text(supportcandy.translations.please_wait);
5169 const data = { action: "wpsc_reset_en_guest_login_otp", _ajax_nonce: nonce };
5170 jQuery.post(supportcandy.ajax_url, data, function (response) {
5171 wpsc_get_en_guest_login_otp();
5172 });
5173 }
5174
5175 /**
5176 * Get ticket widget biographical info
5177 */
5178 function wpsc_get_tw_biographical_info() {
5179 wpsc_show_modal();
5180 var data = { action: "wpsc_get_tw_biographical_info" };
5181 jQuery.post(supportcandy.ajax_url, data, function (response) {
5182 // Set to modal.
5183 jQuery(".wpsc-modal-header").text(response.title);
5184 jQuery(".wpsc-modal-body").html(response.body);
5185 jQuery(".wpsc-modal-footer").html(response.footer);
5186 // Display modal.
5187 wpsc_show_modal_inner_container();
5188 });
5189 }
5190
5191 /**
5192 * Set ticket widget biographical info
5193 */
5194 function wpsc_set_tw_biographical_info(el) {
5195 var form = jQuery(".wpsc-frm-edit-biographical-info")[0];
5196 var dataform = new FormData(form);
5197
5198 if (dataform.get("label").trim() == "") {
5199 alert(supportcandy.translations.req_fields_missing);
5200 return;
5201 }
5202
5203 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5204 jQuery(el).text(supportcandy.translations.please_wait);
5205
5206 jQuery
5207 .ajax({
5208 url: supportcandy.ajax_url,
5209 type: "POST",
5210 data: dataform,
5211 processData: false,
5212 contentType: false,
5213 })
5214 .done(function (res) {
5215 wpsc_close_modal();
5216 wpsc_get_ticket_widget();
5217 });
5218 }
5219
5220 /**
5221 * Get edit agent ticket list items
5222 */
5223 function wpsc_get_edit_agent_tl_item(slug, _ajax_nonce) {
5224 wpsc_show_modal();
5225 var data = { action: "wpsc_get_edit_agent_tl_item", slug, _ajax_nonce };
5226 jQuery.post(supportcandy.ajax_url, data, function (response) {
5227 // Set to modal.
5228 jQuery(".wpsc-modal-header").text(response.title);
5229 jQuery(".wpsc-modal-body").html(response.body);
5230 jQuery(".wpsc-modal-footer").html(response.footer);
5231 // Display modal.
5232 wpsc_show_modal_inner_container();
5233 });
5234 }
5235
5236 /**
5237 * Set edit agent ticket list items
5238 */
5239 function wpsc_set_edit_agent_tl_item(el) {
5240 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5241 jQuery(el).text(supportcandy.translations.please_wait);
5242
5243 var form = jQuery(".frm-edit-agent-tl-items")[0];
5244 var dataform = new FormData(form);
5245 jQuery
5246 .ajax({
5247 url: supportcandy.ajax_url,
5248 type: "POST",
5249 data: dataform,
5250 processData: false,
5251 contentType: false,
5252 })
5253 .done(function (res) {
5254 wpsc_close_modal();
5255 wpsc_get_agent_tl_items();
5256 });
5257 }
5258
5259 /**
5260 * Get edit agent filter list items
5261 */
5262 function wpsc_get_edit_agent_filter_item(slug, _ajax_nonce) {
5263 wpsc_show_modal();
5264 var data = { action: "wpsc_get_edit_agent_filter_item", slug, _ajax_nonce };
5265 jQuery.post(supportcandy.ajax_url, data, function (response) {
5266 // Set to modal.
5267 jQuery(".wpsc-modal-header").text(response.title);
5268 jQuery(".wpsc-modal-body").html(response.body);
5269 jQuery(".wpsc-modal-footer").html(response.footer);
5270 // Display modal.
5271 wpsc_show_modal_inner_container();
5272 });
5273 }
5274
5275 /**
5276 * Set edit agent filter list items
5277 */
5278 function wpsc_set_edit_agent_filter_item(el) {
5279 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5280 jQuery(el).text(supportcandy.translations.please_wait);
5281
5282 var form = jQuery(".frm-edit-agent-fl-items")[0];
5283 var dataform = new FormData(form);
5284 jQuery
5285 .ajax({
5286 url: supportcandy.ajax_url,
5287 type: "POST",
5288 data: dataform,
5289 processData: false,
5290 contentType: false,
5291 })
5292 .done(function (res) {
5293 wpsc_close_modal();
5294 wpsc_get_agent_filter_items();
5295 });
5296 }
5297
5298 /**
5299 * Get edit company working hrs exception
5300 */
5301 function wpsc_get_edit_wh_exception(exception_id, _ajax_nonce) {
5302 wpsc_show_modal();
5303 var data = {
5304 action: "wpsc_get_edit_wh_exception",
5305 exception_id,
5306 _ajax_nonce,
5307 };
5308 jQuery.post(supportcandy.ajax_url, data, function (response) {
5309 // Set to modal.
5310 jQuery(".wpsc-modal-header").text(response.title);
5311 jQuery(".wpsc-modal-body").html(response.body);
5312 jQuery(".wpsc-modal-footer").html(response.footer);
5313 // Display modal.
5314 wpsc_show_modal_inner_container();
5315 });
5316 }
5317
5318 /**
5319 * Delete company working hrs exception
5320 */
5321 function wpsc_delete_wh_exception(exception_id, _ajax_nonce) {
5322 var flag = confirm(supportcandy.translations.confirm);
5323 if (!flag) {
5324 return;
5325 }
5326 var data = { action: "wpsc_delete_wh_exception", exception_id, _ajax_nonce };
5327 jQuery.post(supportcandy.ajax_url, data, function (res) {
5328 wpsc_get_wh_exceptions();
5329 });
5330 }
5331
5332 /**
5333 * Get edit customer ticket list items
5334 */
5335 function wpsc_get_edit_customer_tl_item(slug, _ajax_nonce) {
5336 wpsc_show_modal();
5337 var data = { action: "wpsc_get_edit_customer_tl_item", slug, _ajax_nonce };
5338 jQuery.post(supportcandy.ajax_url, data, function (response) {
5339 // Set to modal.
5340 jQuery(".wpsc-modal-header").text(response.title);
5341 jQuery(".wpsc-modal-body").html(response.body);
5342 jQuery(".wpsc-modal-footer").html(response.footer);
5343 // Display modal.
5344 wpsc_show_modal_inner_container();
5345 });
5346 }
5347
5348 /**
5349 * Set edit customer ticket list items
5350 */
5351 function wpsc_set_edit_customer_tl_item(el) {
5352 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5353 jQuery(el).text(supportcandy.translations.please_wait);
5354
5355 var form = jQuery(".frm-edit-customer-tl-items")[0];
5356 var dataform = new FormData(form);
5357 jQuery
5358 .ajax({
5359 url: supportcandy.ajax_url,
5360 type: "POST",
5361 data: dataform,
5362 processData: false,
5363 contentType: false,
5364 })
5365 .done(function (res) {
5366 wpsc_close_modal();
5367 wpsc_get_customer_tl_items();
5368 });
5369 }
5370
5371 /**
5372 * Get edit coustomer ticket filter items
5373 */
5374 function wpsc_get_edit_ctl_filter_item(slug, _ajax_nonce) {
5375 wpsc_show_modal();
5376 var data = { action: "wpsc_get_edit_ctl_filter_item", slug, _ajax_nonce };
5377 jQuery.post(supportcandy.ajax_url, data, function (response) {
5378 // Set to modal.
5379 jQuery(".wpsc-modal-header").text(response.title);
5380 jQuery(".wpsc-modal-body").html(response.body);
5381 jQuery(".wpsc-modal-footer").html(response.footer);
5382 // Display modal.
5383 wpsc_show_modal_inner_container();
5384 });
5385 }
5386
5387 /**
5388 * Set edit coustomer ticket filter items
5389 */
5390 function wpsc_set_edit_ctl_filter_item(el) {
5391 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5392 jQuery(el).text(supportcandy.translations.please_wait);
5393
5394 var form = jQuery(".frm-edit-customer-fl-items")[0];
5395 var dataform = new FormData(form);
5396 jQuery
5397 .ajax({
5398 url: supportcandy.ajax_url,
5399 type: "POST",
5400 data: dataform,
5401 processData: false,
5402 contentType: false,
5403 })
5404 .done(function (res) {
5405 wpsc_close_modal();
5406 wpsc_get_customer_filter_items();
5407 });
5408 }
5409
5410 /**
5411 * Get ticket tag settings
5412 */
5413 function wpsc_get_ticket_tags() {
5414 supportcandy.current_tab = "ticket-tags-list";
5415 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5416 jQuery(
5417 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5418 ).addClass("active");
5419
5420 window.history.replaceState(
5421 {},
5422 null,
5423 "admin.php?page=wpsc-settings&section=" +
5424 supportcandy.current_section +
5425 "&tab=" +
5426 supportcandy.current_tab
5427 );
5428 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5429
5430 wpsc_scroll_top();
5431
5432 var data = { action: "wpsc_get_ticket_tags" };
5433 jQuery.post(supportcandy.ajax_url, data, function (response) {
5434 jQuery(".wpsc-setting-section-body").html(response);
5435 wpsc_reset_responsive_style();
5436 });
5437 }
5438
5439 /**
5440 * Set add ticket tag
5441 */
5442 function wpsc_set_add_ticket_tags(el) {
5443 var form = jQuery(".wpsc-frm-add-ms-ticket-tags")[0];
5444 var dataform = new FormData(form);
5445
5446 if (!dataform.get("name")) {
5447 alert(supportcandy.translations.req_fields_missing);
5448 return;
5449 }
5450
5451 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5452 jQuery(el).text(supportcandy.translations.please_wait);
5453
5454 jQuery
5455 .ajax({
5456 url: supportcandy.ajax_url,
5457 type: "POST",
5458 data: dataform,
5459 processData: false,
5460 contentType: false,
5461 })
5462 .done(function (res) {
5463 wpsc_close_modal();
5464 wpsc_get_ticket_tags();
5465 });
5466 }
5467
5468 /**
5469 * Update tag
5470 */
5471 function wpsc_get_edit_ticket_tags(id, nonce) {
5472 wpsc_show_modal();
5473 var data = { action: "wpsc_get_edit_ticket_tags", id, _ajax_nonce: nonce };
5474 jQuery.post(supportcandy.ajax_url, data, function (res) {
5475 // Set to modal.
5476 jQuery(".wpsc-modal-header").text(res.title);
5477 jQuery(".wpsc-modal-body").html(res.body);
5478 jQuery(".wpsc-modal-footer").html(res.footer);
5479 // Display modal.
5480 wpsc_show_modal_inner_container();
5481 });
5482 }
5483
5484 function wpsc_set_edit_ticket_tags(el) {
5485 var form = jQuery(".wpsc-frm-edit-ticket-tag")[0];
5486 var dataform = new FormData(form);
5487
5488 if (!dataform.get("name")) {
5489 alert(supportcandy.translations.req_fields_missing);
5490 return;
5491 }
5492 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5493 jQuery(el).text(supportcandy.translations.please_wait);
5494
5495 jQuery
5496 .ajax({
5497 url: supportcandy.ajax_url,
5498 type: "POST",
5499 data: dataform,
5500 processData: false,
5501 contentType: false,
5502 })
5503 .done(function (res) {
5504 wpsc_close_modal();
5505 wpsc_get_ticket_tags();
5506 });
5507 }
5508
5509 /**
5510 * Delete ticket tag modal
5511 */
5512 function wpsc_set_delete_ticket_tags(id, nonce) {
5513 var flag = confirm(supportcandy.translations.confirm);
5514 if (!flag) {
5515 return;
5516 }
5517
5518 var data = { action: "wpsc_set_delete_ticket_tags", id, _ajax_nonce: nonce };
5519 jQuery.post(supportcandy.ajax_url, data, function (response) {
5520 wpsc_get_ticket_tags();
5521 });
5522 }
5523
5524 /**
5525 * Get ticket widget ticket tags
5526 */
5527 function wpsc_get_tw_ticket_tags() {
5528 wpsc_show_modal();
5529 var data = { action: "wpsc_get_tw_ticket_tags" };
5530 jQuery.post(supportcandy.ajax_url, data, function (response) {
5531 // Set to modal.
5532 jQuery(".wpsc-modal-header").text(response.title);
5533 jQuery(".wpsc-modal-body").html(response.body);
5534 jQuery(".wpsc-modal-footer").html(response.footer);
5535 // Display modal.
5536 wpsc_show_modal_inner_container();
5537 });
5538 }
5539
5540 /**
5541 * Set ticket widget ticket tags
5542 */
5543 function wpsc_set_tw_ticket_tags(el) {
5544 var form = jQuery(".wpsc-frm-edit-tags")[0];
5545 var dataform = new FormData(form);
5546
5547 if (dataform.get("label").trim() == "") {
5548 alert(supportcandy.translations.req_fields_missing);
5549 return;
5550 }
5551
5552 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5553 jQuery(el).text(supportcandy.translations.please_wait);
5554
5555 jQuery
5556 .ajax({
5557 url: supportcandy.ajax_url,
5558 type: "POST",
5559 data: dataform,
5560 processData: false,
5561 contentType: false,
5562 })
5563 .done(function (res) {
5564 wpsc_close_modal();
5565 wpsc_get_ticket_widget();
5566 });
5567 }
5568
5569 /**
5570 * Get ticket tags modal UI
5571 */
5572 function wpsc_it_get_edit_ticket_tags(ticket_id, nonce) {
5573 wpsc_show_modal();
5574 var data = {
5575 action: "wpsc_it_get_edit_ticket_tags",
5576 ticket_id,
5577 _ajax_nonce: nonce,
5578 };
5579 jQuery.post(supportcandy.ajax_url, data, function (response) {
5580 jQuery(".wpsc-modal-header").text(response.title);
5581 jQuery(".wpsc-modal-body").html(response.body);
5582 jQuery(".wpsc-modal-footer").html(response.footer);
5583 wpsc_show_modal_inner_container();
5584 });
5585 }
5586
5587 /**
5588 * Get appearence settings
5589 */
5590 function wpsc_get_ticket_tags_settings(is_humbargar = false) {
5591 if (is_humbargar) {
5592 wpsc_toggle_humbargar();
5593 }
5594
5595 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5596 jQuery(
5597 ".wpsc-setting-nav.ticket-tags, .wpsc-humbargar-menu-item.ticket-tags"
5598 ).addClass("active");
5599 jQuery(".wpsc-humbargar-title").html(
5600 supportcandy.humbargar_titles.tickettags
5601 );
5602
5603 if (supportcandy.current_section !== "ticket-tags") {
5604 supportcandy.current_section = "ticket-tags";
5605 supportcandy.current_tab = "general";
5606 }
5607
5608 window.history.replaceState(
5609 {},
5610 null,
5611 "admin.php?page=wpsc-settings&section=" +
5612 supportcandy.current_section +
5613 "&tab=" +
5614 supportcandy.current_tab
5615 );
5616 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5617
5618 wpsc_scroll_top();
5619
5620 var data = {
5621 action: "wpsc_get_ticket_tags_settings",
5622 tab: supportcandy.current_tab,
5623 };
5624 jQuery.post(supportcandy.ajax_url, data, function (response) {
5625 jQuery(".wpsc-setting-body").html(response);
5626 wpsc_reset_responsive_style();
5627 jQuery(
5628 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5629 ).trigger("click");
5630 });
5631 }
5632
5633 /**
5634 * Get general appearence settings
5635 */
5636 function wpsc_ticket_tags_get_general_settings() {
5637 supportcandy.current_tab = "general";
5638 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5639 jQuery(
5640 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5641 ).addClass("active");
5642
5643 window.history.replaceState(
5644 {},
5645 null,
5646 "admin.php?page=wpsc-settings&section=" +
5647 supportcandy.current_section +
5648 "&tab=" +
5649 supportcandy.current_tab
5650 );
5651 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5652
5653 wpsc_scroll_top();
5654 var data = { action: "wpsc_ticket_tags_get_general_settings" };
5655 jQuery.post(supportcandy.ajax_url, data, function (response) {
5656 jQuery(".wpsc-setting-section-body").html(response);
5657 wpsc_reset_responsive_style();
5658 });
5659 }
5660
5661 /**
5662 * Set general settings
5663 */
5664 function wpsc_ticket_tags_set_general_settings(el) {
5665 var form = jQuery(".wpsc-ticket-tags-general-settings")[0];
5666 var dataform = new FormData(form);
5667 jQuery(el).text(supportcandy.translations.please_wait);
5668 jQuery
5669 .ajax({
5670 url: supportcandy.ajax_url,
5671 type: "POST",
5672 data: dataform,
5673 processData: false,
5674 contentType: false,
5675 })
5676 .done(function (res) {
5677 wpsc_ticket_tags_get_general_settings();
5678 });
5679 }
5680
5681 /**
5682 * Reset general settings
5683 */
5684 function wpsc_ticket_tags_reset_general_settings(el, nonce) {
5685 jQuery(el).text(supportcandy.translations.please_wait);
5686 var data = {
5687 action: "wpsc_ticket_tags_reset_general_settings",
5688 _ajax_nonce: nonce,
5689 };
5690 jQuery.post(supportcandy.ajax_url, data, function (response) {
5691 wpsc_ticket_tags_get_general_settings();
5692 });
5693 }
5694
5695 /**
5696 * Get dashboard settings
5697 */
5698 function wpsc_get_dashboard_settings(is_humbargar = false) {
5699 if (is_humbargar) {
5700 wpsc_toggle_humbargar();
5701 }
5702
5703 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5704 jQuery(
5705 ".wpsc-setting-nav.dashboard-settings, .wpsc-humbargar-menu-item.dashboard-settings"
5706 ).addClass("active");
5707 jQuery(".wpsc-humbargar-title").html(
5708 supportcandy.humbargar_titles.tickettags
5709 );
5710
5711 if (supportcandy.current_section !== "dashboard-settings") {
5712 supportcandy.current_section = "dashboard-settings";
5713 supportcandy.current_tab = "dashboard-general";
5714 }
5715
5716 window.history.replaceState(
5717 {},
5718 null,
5719 "admin.php?page=wpsc-settings&section=" +
5720 supportcandy.current_section +
5721 "&tab=" +
5722 supportcandy.current_tab
5723 );
5724 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5725
5726 wpsc_scroll_top();
5727
5728 var data = {
5729 action: "wpsc_get_dashboard_settings",
5730 tab: supportcandy.current_tab,
5731 };
5732 jQuery.post(supportcandy.ajax_url, data, function (response) {
5733 jQuery(".wpsc-setting-body").html(response);
5734 wpsc_reset_responsive_style();
5735 jQuery(
5736 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5737 ).trigger("click");
5738 });
5739 }
5740
5741 /**
5742 * Get dashboard cards settings
5743 */
5744 function wpsc_get_dashboard_cards_settings() {
5745 supportcandy.current_tab = "dashboard-cards";
5746 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5747 jQuery(
5748 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5749 ).addClass("active");
5750
5751 window.history.replaceState(
5752 {},
5753 null,
5754 "admin.php?page=wpsc-settings&section=" +
5755 supportcandy.current_section +
5756 "&tab=" +
5757 supportcandy.current_tab
5758 );
5759 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5760
5761 wpsc_scroll_top();
5762 var data = { action: "wpsc_get_dashboard_cards_settings" };
5763 jQuery.post(supportcandy.ajax_url, data, function (response) {
5764 jQuery(".wpsc-setting-section-body").html(response);
5765 wpsc_reset_responsive_style();
5766 });
5767 }
5768
5769 /**
5770 * Sort dashboard cards
5771 */
5772 function wpsc_set_dashboard_card_load_order(slugs, nonce) {
5773 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5774 var data = {
5775 action: "wpsc_set_dashboard_card_load_order",
5776 slugs,
5777 _ajax_nonce: nonce,
5778 };
5779 jQuery.post(supportcandy.ajax_url, data, function (res) {
5780 wpsc_get_dashboard_cards_settings();
5781 });
5782 }
5783
5784 /**
5785 * Get dashboard widgets settings
5786 */
5787 function wpsc_get_dashboard_widgets_settings() {
5788 supportcandy.current_tab = "dashboard-widgets";
5789 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5790 jQuery(
5791 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5792 ).addClass("active");
5793
5794 window.history.replaceState(
5795 {},
5796 null,
5797 "admin.php?page=wpsc-settings&section=" +
5798 supportcandy.current_section +
5799 "&tab=" +
5800 supportcandy.current_tab
5801 );
5802 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5803
5804 wpsc_scroll_top();
5805 var data = { action: "wpsc_get_dashboard_widgets_settings" };
5806 jQuery.post(supportcandy.ajax_url, data, function (response) {
5807 jQuery(".wpsc-setting-section-body").html(response);
5808 wpsc_reset_responsive_style();
5809 });
5810 }
5811
5812 /**
5813 * Get dashboard widgets settings
5814 */
5815 function wpsc_get_dashboard_general_settings() {
5816 supportcandy.current_tab = "dashboard-general";
5817 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5818 jQuery(
5819 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5820 ).addClass("active");
5821
5822 window.history.replaceState(
5823 {},
5824 null,
5825 "admin.php?page=wpsc-settings&section=" +
5826 supportcandy.current_section +
5827 "&tab=" +
5828 supportcandy.current_tab
5829 );
5830 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5831
5832 wpsc_scroll_top();
5833 var data = { action: "wpsc_get_dashboard_general_settings" };
5834 jQuery.post(supportcandy.ajax_url, data, function (response) {
5835 jQuery(".wpsc-setting-section-body").html(response);
5836 wpsc_reset_responsive_style();
5837 });
5838 }
5839
5840 /**
5841 * Save dashboard general settings
5842 *
5843 * @param {*} el
5844 */
5845 function wpsc_set_dashboard_general_settings(el) {
5846 var form = jQuery(".wpsc-frm-db-gs")[0];
5847 var dataform = new FormData(form);
5848 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5849 jQuery(el).text(supportcandy.translations.please_wait);
5850 jQuery
5851 .ajax({
5852 url: supportcandy.ajax_url,
5853 type: "POST",
5854 data: dataform,
5855 processData: false,
5856 contentType: false,
5857 })
5858 .done(function (res) {
5859 wpsc_get_dashboard_general_settings();
5860 });
5861 }
5862
5863 /**
5864 * Reset dashboard general settings
5865 *
5866 * @param {*} el
5867 */
5868 function wpsc_reset_dashboard_general_settings(el, nonce) {
5869 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5870 jQuery(el).text(supportcandy.translations.please_wait);
5871 var data = {
5872 action: "wpsc_reset_dashboard_general_settings",
5873 _ajax_nonce: nonce,
5874 };
5875 jQuery.post(supportcandy.ajax_url, data, function (response) {
5876 wpsc_get_dashboard_general_settings();
5877 });
5878 }
5879
5880 /**
5881 * Add new dashboard widget
5882 */
5883 function wpsc_get_new_dashboard_widget(nonce) {
5884 wpsc_show_modal();
5885 var data = { action: "wpsc_get_new_dashboard_widget", _ajax_nonce: nonce };
5886 jQuery.post(supportcandy.ajax_url, data, function (response) {
5887 // Set to modal.
5888 jQuery(".wpsc-modal-header").text(response.title);
5889 jQuery(".wpsc-modal-body").html(response.body);
5890 jQuery(".wpsc-modal-footer").html(response.footer);
5891 // Display modal.
5892 wpsc_show_modal_inner_container();
5893 });
5894 }
5895
5896 /**
5897 * Set new dashboard widget
5898 */
5899 function wpsc_set_new_dashboard_widget(el) {
5900 var form = jQuery(".wpsc-add-new-dashboard-widget")[0];
5901 var dataform = new FormData(form);
5902 jQuery(el).text(supportcandy.translations.please_wait);
5903 jQuery
5904 .ajax({
5905 url: supportcandy.ajax_url,
5906 type: "POST",
5907 data: dataform,
5908 processData: false,
5909 contentType: false,
5910 })
5911 .done(function (res) {
5912 wpsc_close_modal();
5913 wpsc_get_dashboard_settings();
5914 });
5915 }
5916
5917 /**
5918 * Delete dashboard widget
5919 */
5920 function wpsc_delete_dashboard_widget(slug, nonce) {
5921 var flag = confirm(supportcandy.translations.confirm);
5922 if (!flag) {
5923 return;
5924 }
5925
5926 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5927 var data = {
5928 action: "wpsc_delete_dashboard_widget",
5929 slug,
5930 _ajax_nonce: nonce,
5931 };
5932 jQuery.post(supportcandy.ajax_url, data, function (response) {
5933 wpsc_get_dashboard_settings();
5934 });
5935 }
5936
5937 /**
5938 * Sort dashboard widgets
5939 */
5940 function wpsc_set_dashboard_widget_load_order(slugs, nonce) {
5941 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5942 var data = {
5943 action: "wpsc_set_dashboard_widget_load_order",
5944 slugs,
5945 _ajax_nonce: nonce,
5946 };
5947 jQuery.post(supportcandy.ajax_url, data, function (res) {
5948 wpsc_get_dashboard_widgets_settings();
5949 });
5950 }
5951
5952 /**
5953 * Edit bashboard widget
5954 */
5955 function wpsc_get_edit_dashboard_card_widget(type, slug, nonce) {
5956 wpsc_show_modal();
5957 var data = {
5958 action: "wpsc_get_edit_dashboard_card_widget",
5959 type,
5960 slug,
5961 _ajax_nonce: nonce,
5962 };
5963 jQuery.post(supportcandy.ajax_url, data, function (response) {
5964 // Set to modal.
5965 jQuery(".wpsc-modal-header").text(response.title);
5966 jQuery(".wpsc-modal-body").html(response.body);
5967 jQuery(".wpsc-modal-footer").html(response.footer);
5968 // Display modal.
5969 wpsc_show_modal_inner_container();
5970 });
5971 }
5972
5973 /**
5974 * Set edit bashboard widget
5975 */
5976 function wpsc_set_edit_dashboard_card_widget(el) {
5977 var form = jQuery(".wpsc-frm-edit-dashboard-cards-widgets")[0];
5978 var dataform = new FormData(form);
5979
5980 if (dataform.get("label").trim() == "") {
5981 alert(supportcandy.translations.req_fields_missing);
5982 return;
5983 }
5984
5985 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5986 jQuery(el).text(supportcandy.translations.please_wait);
5987
5988 jQuery
5989 .ajax({
5990 url: supportcandy.ajax_url,
5991 type: "POST",
5992 data: dataform,
5993 processData: false,
5994 contentType: false,
5995 })
5996 .done(function (res) {
5997 wpsc_close_modal();
5998 wpsc_get_dashboard_settings();
5999 });
6000 }
6001
6002 /**
6003 * Get appearence dashboard
6004 */
6005 function wpsc_get_ap_dashboard() {
6006 supportcandy.current_tab = "dashboard";
6007 jQuery(".wpsc-setting-tab-container button").removeClass("active");
6008 jQuery(
6009 ".wpsc-setting-tab-container button." + supportcandy.current_tab
6010 ).addClass("active");
6011
6012 window.history.replaceState(
6013 {},
6014 null,
6015 "admin.php?page=wpsc-settings&section=" +
6016 supportcandy.current_section +
6017 "&tab=" +
6018 supportcandy.current_tab
6019 );
6020 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
6021
6022 wpsc_scroll_top();
6023 var data = { action: "wpsc_get_ap_dashboard" };
6024 jQuery.post(supportcandy.ajax_url, data, function (response) {
6025 jQuery(".wpsc-setting-section-body").html(response);
6026 wpsc_reset_responsive_style();
6027 });
6028 }
6029
6030 /**
6031 * Set appearence dashboard
6032 */
6033 function wpsc_set_ap_dashboard(el) {
6034 var form = jQuery(".wpsc-frm-ap-dash")[0];
6035 var dataform = new FormData(form);
6036 jQuery(el).text(supportcandy.translations.please_wait);
6037 jQuery
6038 .ajax({
6039 url: supportcandy.ajax_url,
6040 type: "POST",
6041 data: dataform,
6042 processData: false,
6043 contentType: false,
6044 })
6045 .done(function (res) {
6046 wpsc_get_ap_dashboard();
6047 });
6048 }
6049
6050 /**
6051 * Reset appearence dashboard
6052 */
6053 function wpsc_reset_ap_dashboard(el, nonce) {
6054 jQuery(el).text(supportcandy.translations.please_wait);
6055 var data = { action: "wpsc_reset_ap_dashboard", _ajax_nonce: nonce };
6056 jQuery.post(supportcandy.ajax_url, data, function (res) {
6057 wpsc_get_ap_dashboard();
6058 });
6059 }
6060
6061 /**
6062 * Get customer profile
6063 *
6064 * @param {int} id
6065 */
6066 function wpsc_view_customer_detailed_info(customer_id, nonce) {
6067 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
6068 var data = {
6069 action: "wpsc_view_customer_detailed_info",
6070 customer_id,
6071 _ajax_nonce: nonce,
6072 };
6073 jQuery.post(supportcandy.ajax_url, data, function (res) {
6074 jQuery(".wpsc-setting-section-body").html(res);
6075 });
6076 }
6077
6078 function wpsc_update_live_agents() {
6079
6080 if (!supportcandy.ticketListIsIndividual) {
6081 return;
6082 }
6083 agent_id = jQuery("#wpsc-current-agent").val();
6084 if (!agent_id) {
6085 return;
6086 }
6087 if (typeof supportcandy.agent_collision === "undefined" || !supportcandy.agent_collision) {
6088 return;
6089 }
6090
6091 ticket_id = jQuery("#wpsc-current-ticket").val();
6092 var data = { action: 'wpsc_check_live_agents', agent_id, ticket_id, operation: 'leave', _ajax_nonce: supportcandy.nonce };
6093 jQuery.post(
6094 supportcandy.ajax_url,
6095 data,
6096 function (response) {
6097 }
6098 );
6099 }
6100
6101 /**
6102 * Get ticket list
6103 */
6104 function wpsc_get_archive_ticket_list(is_humbargar = false) {
6105
6106 supportcandy.current_section = "archive-ticket-list";
6107 if (is_humbargar) {
6108 wpsc_toggle_humbargar();
6109 }
6110
6111 var id = supportcandy.current_archived_ticket_id;
6112 if (id) {
6113 delete supportcandy.current_archived_ticket_id;
6114 wpsc_get_individual_archive_ticket(id);
6115 return;
6116 }
6117
6118 // set flag to differenciate between ticket list and individual ticket.
6119 supportcandy.ticketListIsIndividual = false;
6120
6121 jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active");
6122 jQuery(
6123 ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list"
6124 ).addClass("active");
6125 jQuery(".wpsc-humbargar-title").html(
6126 supportcandy.humbargar_titles.archived_ticket_list
6127 );
6128
6129 window.history.replaceState(
6130 {},
6131 null,
6132 "admin.php?page=wpsc-archive-tickets&section=archive-ticket-list"
6133 );
6134 jQuery(".wpsc-body").html(supportcandy.loader_html);
6135
6136 wpsc_scroll_top();
6137
6138 var data = {
6139 action: "wpsc_get_archive_ticket_list",
6140 _ajax_nonce: supportcandy.nonce,
6141 is_frontend: supportcandy.is_frontend,
6142 };
6143 jQuery.post(supportcandy.ajax_url, data, function (response) {
6144 jQuery(".wpsc-body").html(response);
6145 wpsc_reset_responsive_style();
6146 });
6147 wpsc_delete_auto_draft();
6148 }
6149
6150 /**
6151 * Get individual ticket
6152 */
6153 function wpsc_get_individual_archive_ticket(id) {
6154 jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active");
6155 jQuery(
6156 ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list"
6157 ).addClass("active");
6158 jQuery(".wpsc-humbargar-title").html(
6159 supportcandy.humbargar_titles.archived_ticket_list
6160 );
6161
6162 window.history.replaceState(
6163 {},
6164 null,
6165 "admin.php?page=wpsc-archive-tickets&section=archive-ticket-list&id=" + id
6166 );
6167 jQuery(".wpsc-body").html(supportcandy.loader_html);
6168
6169 wpsc_scroll_top();
6170
6171 // set flag to differenciate between ticket list and individual ticket.
6172 supportcandy.ticketListIsIndividual = true;
6173
6174 var data = {
6175 action: "wpsc_get_individual_archive_ticket",
6176 ticket_id: id,
6177 };
6178 jQuery.post(supportcandy.ajax_url, data, function (response) {
6179 jQuery(".wpsc-body").html(response);
6180 wpsc_reset_responsive_style();
6181 });
6182 }