PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.1
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.4.1, at asset/js/admin.js

6,047 lines 154.9 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) {
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" };
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 * Ticket widget status
3604 */
3605 function wpsc_get_tw_ticket_status() {
3606 wpsc_show_modal();
3607 var data = { action: "wpsc_get_tw_ticket_status" };
3608 jQuery.post(supportcandy.ajax_url, data, function (response) {
3609 // Set to modal.
3610 jQuery(".wpsc-modal-header").text(response.title);
3611 jQuery(".wpsc-modal-body").html(response.body);
3612 jQuery(".wpsc-modal-footer").html(response.footer);
3613 // Display modal.
3614 wpsc_show_modal_inner_container();
3615 });
3616 }
3617
3618 /**
3619 * Set ticket widget status
3620 */
3621 function wpsc_set_tw_ticket_status(el) {
3622 var form = jQuery(".wpsc-frm-edit-ticket-status")[0];
3623 var dataform = new FormData(form);
3624
3625 if (dataform.get("label").trim() == "") {
3626 alert(supportcandy.translations.req_fields_missing);
3627 return;
3628 }
3629
3630 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3631 jQuery(el).text(supportcandy.translations.please_wait);
3632
3633 jQuery
3634 .ajax({
3635 url: supportcandy.ajax_url,
3636 type: "POST",
3637 data: dataform,
3638 processData: false,
3639 contentType: false,
3640 })
3641 .done(function (res) {
3642 wpsc_close_modal();
3643 wpsc_get_ticket_widget();
3644 });
3645 }
3646
3647 /**
3648 * Set agent view settings
3649 *
3650 * @param {*} el
3651 */
3652 function wpsc_tl_ms_set_agent_view(el) {
3653 var form = jQuery(".wpsc-frm-tl-ms-agent-view")[0];
3654 var dataform = new FormData(form);
3655 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3656 jQuery(el).text(supportcandy.translations.please_wait);
3657 jQuery
3658 .ajax({
3659 url: supportcandy.ajax_url,
3660 type: "POST",
3661 data: dataform,
3662 processData: false,
3663 contentType: false,
3664 })
3665 .done(function (res) {
3666 wpsc_tl_ms_get_agent_view();
3667 });
3668 }
3669
3670 /**
3671 * Reset terms and conditions
3672 *
3673 * @param {*} el
3674 */
3675 function wpsc_reset_ms_term_and_conditions(el, nonce) {
3676 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3677 jQuery(el).text(supportcandy.translations.please_wait);
3678 var data = {
3679 action: "wpsc_reset_ms_term_and_conditions",
3680 _ajax_nonce: nonce,
3681 };
3682 jQuery.post(supportcandy.ajax_url, data, function (response) {
3683 wpsc_get_ms_term_and_conditions();
3684 });
3685 }
3686
3687 /**
3688 * Get ticket widget raised by
3689 */
3690 function wpsc_get_tw_raised_by() {
3691 wpsc_show_modal();
3692 var data = { action: "wpsc_get_tw_raised_by" };
3693 jQuery.post(supportcandy.ajax_url, data, function (response) {
3694 // Set to modal.
3695 jQuery(".wpsc-modal-header").text(response.title);
3696 jQuery(".wpsc-modal-body").html(response.body);
3697 jQuery(".wpsc-modal-footer").html(response.footer);
3698 // Display modal.
3699 wpsc_show_modal_inner_container();
3700 });
3701 }
3702
3703 /**
3704 * Reset agent view settings
3705 *
3706 * @param {*} el
3707 */
3708 function wpsc_tl_ms_reset_agent_view(el, nonce) {
3709 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3710 jQuery(el).text(supportcandy.translations.please_wait);
3711 var data = { action: "wpsc_tl_ms_reset_agent_view", _ajax_nonce: nonce };
3712 jQuery.post(supportcandy.ajax_url, data, function (response) {
3713 wpsc_tl_ms_get_agent_view();
3714 });
3715 }
3716
3717 /**
3718 * Get reCaptcha settings
3719 */
3720 function wpsc_get_ms_recaptcha() {
3721 supportcandy.current_tab = "recaptcha";
3722 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3723 jQuery(
3724 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3725 ).addClass("active");
3726
3727 window.history.replaceState(
3728 {},
3729 null,
3730 "admin.php?page=wpsc-settings&section=" +
3731 supportcandy.current_section +
3732 "&tab=" +
3733 supportcandy.current_tab
3734 );
3735 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3736
3737 wpsc_scroll_top();
3738
3739 var data = { action: "wpsc_get_ms_recaptcha" };
3740 jQuery.post(supportcandy.ajax_url, data, function (response) {
3741 jQuery(".wpsc-setting-section-body").html(response);
3742 wpsc_reset_responsive_style();
3743 });
3744 }
3745
3746 /**
3747 * Set ticket widget raised by
3748 */
3749 function wpsc_set_tw_raised_by(el) {
3750 var form = jQuery(".wpsc-frm-edit-ticket-raised-by")[0];
3751 var dataform = new FormData(form);
3752
3753 if (dataform.get("label").trim() == "") {
3754 alert(supportcandy.translations.req_fields_missing);
3755 return;
3756 }
3757
3758 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3759 jQuery(el).text(supportcandy.translations.please_wait);
3760
3761 jQuery
3762 .ajax({
3763 url: supportcandy.ajax_url,
3764 type: "POST",
3765 data: dataform,
3766 processData: false,
3767 contentType: false,
3768 })
3769 .done(function (res) {
3770 wpsc_close_modal();
3771 wpsc_get_ticket_widget();
3772 });
3773 }
3774
3775 /**
3776 * Get customer view settings
3777 */
3778 function wpsc_tl_ms_get_customer_view() {
3779 supportcandy.current_tab = "customer-view";
3780 jQuery(".wpsc-setting-tab-container button").removeClass("active");
3781 jQuery(
3782 ".wpsc-setting-tab-container button." + supportcandy.current_tab
3783 ).addClass("active");
3784
3785 window.history.replaceState(
3786 {},
3787 null,
3788 "admin.php?page=wpsc-ticket-list&section=" +
3789 supportcandy.current_section +
3790 "&tab=" +
3791 supportcandy.current_tab
3792 );
3793 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
3794
3795 wpsc_scroll_top();
3796
3797 var data = { action: "wpsc_tl_ms_get_customer_view" };
3798 jQuery.post(supportcandy.ajax_url, data, function (response) {
3799 jQuery(".wpsc-setting-section-body").html(response);
3800 wpsc_reset_responsive_style();
3801 });
3802 }
3803
3804 /**
3805 * Save reCaptcha
3806 *
3807 * @param {*} el
3808 */
3809 function wpsc_set_ms_recaptcha(el) {
3810 var form = jQuery(".wpsc-frm-ms-recaptcha")[0];
3811 var dataform = new FormData(form);
3812 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3813 jQuery(el).text(supportcandy.translations.please_wait);
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_get_ms_recaptcha();
3824 });
3825 }
3826
3827 /**
3828 * Get ticket widget ticket info
3829 */
3830 function wpsc_get_tw_ticket_info() {
3831 wpsc_show_modal();
3832 var data = { action: "wpsc_get_tw_ticket_info" };
3833 jQuery.post(supportcandy.ajax_url, data, function (response) {
3834 // Set to modal.
3835 jQuery(".wpsc-modal-header").text(response.title);
3836 jQuery(".wpsc-modal-body").html(response.body);
3837 jQuery(".wpsc-modal-footer").html(response.footer);
3838 // Display modal.
3839 wpsc_show_modal_inner_container();
3840 });
3841 }
3842
3843 /**
3844 * Add new option snippet
3845 */
3846 function wpsc_get_add_new_option() {
3847 jQuery(".wpsc-options-container").append(jQuery(".wpsc-add-option").html());
3848 jQuery(".wpsc-options-container")
3849 .children()
3850 .last()
3851 .find(".wpsc-add-option-container input:first")
3852 .focus();
3853 }
3854
3855 /**
3856 * Add new option for custom field
3857 */
3858 function wpsc_add_new_option(el, nonce) {
3859 var submitBtn = jQuery(el);
3860 var inputField = jQuery(el).parent().find("input").first();
3861
3862 var name = inputField.val().trim();
3863 if (!name) {
3864 return;
3865 }
3866
3867 submitBtn.attr("disabled", true);
3868 inputField.attr("disabled", true);
3869 submitBtn.html(supportcandy.inline_loader);
3870
3871 var data = { action: "wpsc_add_new_option", name, _ajax_nonce: nonce };
3872 jQuery.post(supportcandy.ajax_url, data, function (response) {
3873 submitBtn
3874 .closest(".wpsc-option-item")
3875 .find(".wpsc-option-listing-container .text")
3876 .text(response.name);
3877 submitBtn
3878 .closest(".wpsc-option-item")
3879 .append(
3880 '<input type="hidden" class="option_id" name="options[]" value="' +
3881 response.id +
3882 '">'
3883 );
3884 submitBtn.parent().hide();
3885 submitBtn.closest(".content").find(".wpsc-option-listing-container").show();
3886 wpsc_change_def_val_option_single();
3887 });
3888 }
3889
3890 /**
3891 * Set ticket widget ticket info
3892 */
3893 function wpsc_set_tw_ticket_info(el) {
3894 var form = jQuery(".wpsc-frm-edit-ticket-info")[0];
3895 var dataform = new FormData(form);
3896
3897 if (dataform.get("label").trim() == "") {
3898 alert(supportcandy.translations.req_fields_missing);
3899 return;
3900 }
3901
3902 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3903 jQuery(el).text(supportcandy.translations.please_wait);
3904
3905 jQuery
3906 .ajax({
3907 url: supportcandy.ajax_url,
3908 type: "POST",
3909 data: dataform,
3910 processData: false,
3911 contentType: false,
3912 })
3913 .done(function (res) {
3914 wpsc_close_modal();
3915 wpsc_get_ticket_widget();
3916 });
3917 }
3918
3919 /**
3920 * Reset reCaptcha
3921 *
3922 * @param {*} el
3923 */
3924 function wpsc_reset_ms_recaptcha(el, nonce) {
3925 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3926 jQuery(el).text(supportcandy.translations.please_wait);
3927 var data = { action: "wpsc_reset_ms_recaptcha", _ajax_nonce: nonce };
3928 jQuery.post(supportcandy.ajax_url, data, function (response) {
3929 wpsc_get_ms_recaptcha();
3930 });
3931 }
3932
3933 /**
3934 * Set customer view settings
3935 *
3936 * @param {*} el
3937 */
3938 function wpsc_tl_ms_set_customer_view(el) {
3939 var form = jQuery(".wpsc-frm-tl-ms-customer-view")[0];
3940 var dataform = new FormData(form);
3941 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3942 jQuery(el).text(supportcandy.translations.please_wait);
3943 jQuery
3944 .ajax({
3945 url: supportcandy.ajax_url,
3946 type: "POST",
3947 data: dataform,
3948 processData: false,
3949 contentType: false,
3950 })
3951 .done(function (res) {
3952 wpsc_tl_ms_get_customer_view();
3953 });
3954 }
3955
3956 /**
3957 * Get ticket widget agents
3958 */
3959 function wpsc_get_tw_agents() {
3960 wpsc_show_modal();
3961 var data = { action: "wpsc_get_tw_agents" };
3962 jQuery.post(supportcandy.ajax_url, data, function (response) {
3963 // Set to modal.
3964 jQuery(".wpsc-modal-header").text(response.title);
3965 jQuery(".wpsc-modal-body").html(response.body);
3966 jQuery(".wpsc-modal-footer").html(response.footer);
3967 // Display modal.
3968 wpsc_show_modal_inner_container();
3969 });
3970 }
3971
3972 /**
3973 * Reset customer view settings
3974 *
3975 * @param {*} el
3976 */
3977 function wpsc_tl_ms_reset_customer_view(el, nonce) {
3978 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3979 jQuery(el).text(supportcandy.translations.please_wait);
3980 var data = { action: "wpsc_tl_ms_reset_customer_view", _ajax_nonce: nonce };
3981 jQuery.post(supportcandy.ajax_url, data, function (response) {
3982 wpsc_tl_ms_get_customer_view();
3983 });
3984 }
3985
3986 /**
3987 * Set ticket widget agents
3988 */
3989 function wpsc_set_tw_agents(el) {
3990 var form = jQuery(".wpsc-frm-edit-agents")[0];
3991 var dataform = new FormData(form);
3992
3993 if (dataform.get("label").trim() == "") {
3994 alert(supportcandy.translations.req_fields_missing);
3995 return;
3996 }
3997
3998 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3999 jQuery(el).text(supportcandy.translations.please_wait);
4000
4001 jQuery
4002 .ajax({
4003 url: supportcandy.ajax_url,
4004 type: "POST",
4005 data: dataform,
4006 processData: false,
4007 contentType: false,
4008 })
4009 .done(function (res) {
4010 wpsc_close_modal();
4011 wpsc_get_ticket_widget();
4012 });
4013 }
4014
4015 /**
4016 * Get ticket widget ticket fields
4017 */
4018 function wpsc_get_tw_ticket_fields() {
4019 wpsc_show_modal();
4020 var data = { action: "wpsc_get_tw_ticket_fields" };
4021 jQuery.post(supportcandy.ajax_url, data, function (response) {
4022 // Set to modal.
4023 jQuery(".wpsc-modal-header").text(response.title);
4024 jQuery(".wpsc-modal-body").html(response.body);
4025 jQuery(".wpsc-modal-footer").html(response.footer);
4026 // Display modal.
4027 wpsc_show_modal_inner_container();
4028 });
4029 }
4030
4031 /**
4032 * Load edit option view
4033 */
4034 function wpsc_edit_option(el) {
4035 var editBtn = jQuery(el);
4036 var text = editBtn
4037 .closest(".wpsc-option-listing-container")
4038 .find(".text")
4039 .text();
4040 editBtn.closest(".content").find(".edit-option-text").val(text);
4041 editBtn.closest(".wpsc-option-listing-container").hide();
4042 editBtn.closest(".content").find(".wpsc-edit-option-container").show();
4043 }
4044
4045 /**
4046 * Update option
4047 */
4048 function wpsc_set_edit_option(el, nonce) {
4049 var submitBtn = jQuery(el);
4050 var inputField = jQuery(el).parent().find("input").first();
4051
4052 var option_id = submitBtn
4053 .closest(".wpsc-option-item")
4054 .find(".option_id")
4055 .val()
4056 .trim();
4057 if (!option_id) {
4058 return;
4059 }
4060
4061 var name = inputField.val().trim();
4062 if (!name) {
4063 return;
4064 }
4065
4066 submitBtn.attr("disabled", true);
4067 inputField.attr("disabled", true);
4068
4069 var submitHtml = submitBtn.html();
4070 submitBtn.html(supportcandy.inline_loader);
4071
4072 var data = {
4073 action: "wpsc_set_edit_option",
4074 id: option_id,
4075 name,
4076 _ajax_nonce: nonce,
4077 };
4078 jQuery.post(supportcandy.ajax_url, data, function (response) {
4079 submitBtn
4080 .closest(".wpsc-option-item")
4081 .find(".wpsc-option-listing-container .text")
4082 .text(response.name);
4083 submitBtn.attr("disabled", false);
4084 inputField.attr("disabled", false);
4085 submitBtn.html(submitHtml);
4086 submitBtn.parent().hide();
4087 submitBtn.closest(".content").find(".wpsc-option-listing-container").show();
4088 wpsc_change_def_val_option_single();
4089 });
4090 }
4091
4092 /**
4093 * Set ticket widget ticket fields
4094 */
4095 function wpsc_set_tw_ticket_fields(el) {
4096 var form = jQuery(".wpsc-frm-edit-ticket-fields")[0];
4097 var dataform = new FormData(form);
4098
4099 if (dataform.get("label").trim() == "") {
4100 alert(supportcandy.translations.req_fields_missing);
4101 return;
4102 }
4103
4104 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4105 jQuery(el).text(supportcandy.translations.please_wait);
4106
4107 jQuery
4108 .ajax({
4109 url: supportcandy.ajax_url,
4110 type: "POST",
4111 data: dataform,
4112 processData: false,
4113 contentType: false,
4114 })
4115 .done(function (res) {
4116 wpsc_close_modal();
4117 wpsc_get_ticket_widget();
4118 });
4119 }
4120
4121 /**
4122 * Get gdpr settings
4123 */
4124 function wpsc_get_ms_gdpr() {
4125 supportcandy.current_tab = "gdpr";
4126 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4127 jQuery(
4128 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4129 ).addClass("active");
4130
4131 window.history.replaceState(
4132 {},
4133 null,
4134 "admin.php?page=wpsc-settings&section=" +
4135 supportcandy.current_section +
4136 "&tab=" +
4137 supportcandy.current_tab
4138 );
4139 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4140
4141 wpsc_scroll_top();
4142
4143 var data = { action: "wpsc_get_ms_gdpr" };
4144 jQuery.post(supportcandy.ajax_url, data, function (response) {
4145 jQuery(".wpsc-setting-section-body").html(response);
4146 wpsc_reset_responsive_style();
4147 });
4148 }
4149
4150 /**
4151 * Get advanced settings of tl more settings
4152 */
4153 function wpsc_tl_ms_get_advanced() {
4154 supportcandy.current_tab = "advanced";
4155 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4156 jQuery(
4157 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4158 ).addClass("active");
4159
4160 window.history.replaceState(
4161 {},
4162 null,
4163 "admin.php?page=wpsc-ticket-list&section=" +
4164 supportcandy.current_section +
4165 "&tab=" +
4166 supportcandy.current_tab
4167 );
4168 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4169
4170 wpsc_scroll_top();
4171
4172 var data = { action: "wpsc_tl_ms_get_advanced" };
4173 jQuery.post(supportcandy.ajax_url, data, function (response) {
4174 jQuery(".wpsc-setting-section-body").html(response);
4175 wpsc_reset_responsive_style();
4176 });
4177 }
4178
4179 /**
4180 * Save gdpr
4181 *
4182 * @param {*} el
4183 */
4184 function wpsc_set_ms_gdpr(el) {
4185 var form = jQuery(".wpsc-frm-ms-gdpr")[0];
4186 var dataform = new FormData(form);
4187 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4188 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4189 var is_tinymce_ct =
4190 typeof tinyMCE != "undefined" &&
4191 tinyMCE.get("gdpr-text") &&
4192 !tinyMCE.get("gdpr-text").isHidden();
4193
4194 if (is_tinymce_ct) {
4195 var description = tinyMCE.get("gdpr-text").getContent().trim();
4196 } else {
4197 var description = jQuery("#gdpr-text").val();
4198 }
4199 dataform.append("gdpr-text", description);
4200
4201 var is_tinymce_reg =
4202 typeof tinyMCE != "undefined" &&
4203 tinyMCE.get("gdpr-text-reg-user") &&
4204 !tinyMCE.get("gdpr-text-reg-user").isHidden();
4205
4206 if (is_tinymce_reg) {
4207 var description = tinyMCE.get("gdpr-text-reg-user").getContent().trim();
4208 } else {
4209 var description = jQuery("#gdpr-text-reg-user").val();
4210 }
4211 dataform.append("gdpr-text-reg-user", description);
4212
4213 jQuery(el).text(supportcandy.translations.please_wait);
4214 jQuery
4215 .ajax({
4216 url: supportcandy.ajax_url,
4217 type: "POST",
4218 data: dataform,
4219 processData: false,
4220 contentType: false,
4221 })
4222 .done(function (res) {
4223 wpsc_get_ms_gdpr();
4224 });
4225 }
4226
4227 /**
4228 * Set advanced settings of tl more settings
4229 *
4230 * @param {*} el
4231 */
4232 function wpsc_tl_ms_set_advanced(el) {
4233 var form = jQuery(".wpsc-frm-advanced-settings")[0];
4234 var dataform = new FormData(form);
4235 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4236 jQuery(el).text(supportcandy.translations.please_wait);
4237 jQuery
4238 .ajax({
4239 url: supportcandy.ajax_url,
4240 type: "POST",
4241 data: dataform,
4242 processData: false,
4243 contentType: false,
4244 })
4245 .done(function (res) {
4246 wpsc_tl_ms_get_advanced();
4247 });
4248 }
4249
4250 /**
4251 * Get ticket widget agentOnly fields
4252 */
4253 function wpsc_get_tw_agentonly_fields() {
4254 wpsc_show_modal();
4255 var data = { action: "wpsc_get_tw_agentonly_fields" };
4256 jQuery.post(supportcandy.ajax_url, data, function (response) {
4257 // Set to modal.
4258 jQuery(".wpsc-modal-header").text(response.title);
4259 jQuery(".wpsc-modal-body").html(response.body);
4260 jQuery(".wpsc-modal-footer").html(response.footer);
4261 // Display modal.
4262 wpsc_show_modal_inner_container();
4263 });
4264 }
4265
4266 /**
4267 * Reset gdpr
4268 *
4269 * @param {*} el
4270 */
4271 function wpsc_reset_ms_gdpr(el, nonce) {
4272 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4273 jQuery(el).text(supportcandy.translations.please_wait);
4274 var data = { action: "wpsc_reset_ms_gdpr", _ajax_nonce: nonce };
4275 jQuery.post(supportcandy.ajax_url, data, function (response) {
4276 wpsc_get_ms_gdpr();
4277 });
4278 }
4279
4280 /**
4281 * Reset advanced settings of tl more settings
4282 *
4283 * @param {*} el
4284 */
4285 function wpsc_tl_ms_reset_advanced(el, nonce) {
4286 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4287 jQuery(el).text(supportcandy.translations.please_wait);
4288 var data = { action: "wpsc_tl_ms_reset_advanced", _ajax_nonce: nonce };
4289 jQuery.post(supportcandy.ajax_url, data, function (response) {
4290 wpsc_tl_ms_get_advanced();
4291 });
4292 }
4293
4294 /**
4295 * Get advanced miscellaneous settings
4296 */
4297 function wpsc_get_ms_advanced() {
4298 supportcandy.current_tab = "advanced";
4299 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4300 jQuery(
4301 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4302 ).addClass("active");
4303
4304 window.history.replaceState(
4305 {},
4306 null,
4307 "admin.php?page=wpsc-settings&section=" +
4308 supportcandy.current_section +
4309 "&tab=" +
4310 supportcandy.current_tab
4311 );
4312 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4313
4314 wpsc_scroll_top();
4315
4316 var data = { action: "wpsc_get_ms_advanced" };
4317 jQuery.post(supportcandy.ajax_url, data, function (response) {
4318 jQuery(".wpsc-setting-section-body").html(response);
4319 wpsc_reset_responsive_style();
4320 });
4321 }
4322
4323 /**
4324 * Set ticket widget agentOnly fields
4325 */
4326 function wpsc_set_tw_agentonly_fields(el) {
4327 var form = jQuery(".wpsc-frm-edit-agentonly-fields")[0];
4328 var dataform = new FormData(form);
4329
4330 if (dataform.get("label").trim() == "") {
4331 alert(supportcandy.translations.req_fields_missing);
4332 return;
4333 }
4334
4335 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4336 jQuery(el).text(supportcandy.translations.please_wait);
4337
4338 jQuery
4339 .ajax({
4340 url: supportcandy.ajax_url,
4341 type: "POST",
4342 data: dataform,
4343 processData: false,
4344 contentType: false,
4345 })
4346 .done(function (res) {
4347 wpsc_close_modal();
4348 wpsc_get_ticket_widget();
4349 });
4350 }
4351
4352 /**
4353 * Get ticket widget additional recipients
4354 */
4355 function wpsc_get_tw_additional_recipients() {
4356 wpsc_show_modal();
4357 var data = { action: "wpsc_get_tw_additional_recipients" };
4358 jQuery.post(supportcandy.ajax_url, data, function (response) {
4359 // Set to modal.
4360 jQuery(".wpsc-modal-header").text(response.title);
4361 jQuery(".wpsc-modal-body").html(response.body);
4362 jQuery(".wpsc-modal-footer").html(response.footer);
4363 // Display modal.
4364 wpsc_show_modal_inner_container();
4365 });
4366 }
4367
4368 /**
4369 * Save advanced miscellaneous settings
4370 *
4371 * @param {*} el
4372 */
4373 function wpsc_set_ms_advanced(el) {
4374 var form = jQuery(".wpsc-frm-ms-advanced")[0];
4375 var dataform = new FormData(form);
4376 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4377 jQuery(el).text(supportcandy.translations.please_wait);
4378 jQuery
4379 .ajax({
4380 url: supportcandy.ajax_url,
4381 type: "POST",
4382 data: dataform,
4383 processData: false,
4384 contentType: false,
4385 })
4386 .done(function (res) {
4387 wpsc_get_ms_advanced();
4388 });
4389 }
4390
4391 /**
4392 * Set ticket widget additional recipients
4393 */
4394 function wpsc_set_tw_additional_recipients(el) {
4395 var form = jQuery(".wpsc-frm-edit-additional-recipients")[0];
4396 var dataform = new FormData(form);
4397
4398 if (dataform.get("label").trim() == "") {
4399 alert(supportcandy.translations.req_fields_missing);
4400 return;
4401 }
4402
4403 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4404 jQuery(el).text(supportcandy.translations.please_wait);
4405
4406 jQuery
4407 .ajax({
4408 url: supportcandy.ajax_url,
4409 type: "POST",
4410 data: dataform,
4411 processData: false,
4412 contentType: false,
4413 })
4414 .done(function (res) {
4415 wpsc_close_modal();
4416 wpsc_get_ticket_widget();
4417 });
4418 }
4419
4420 /**
4421 * Reset advanced miscellaneous settings
4422 *
4423 * @param {*} el
4424 */
4425 function wpsc_reset_ms_advanced(el, nonce) {
4426 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4427 jQuery(el).text(supportcandy.translations.please_wait);
4428 var data = { action: "wpsc_reset_ms_advanced", _ajax_nonce: nonce };
4429 jQuery.post(supportcandy.ajax_url, data, function (response) {
4430 wpsc_get_ms_advanced();
4431 });
4432 }
4433
4434 /**
4435 * Cancel edit
4436 */
4437 function wpsc_edit_option_cancel(el) {
4438 var cancelBtn = jQuery(el);
4439 cancelBtn.closest(".wpsc-edit-option-container").hide();
4440 cancelBtn.closest(".content").find(".wpsc-option-listing-container").show();
4441 }
4442
4443 /**
4444 * Remove an item
4445 */
4446 function wpsc_remove_option_item(el) {
4447 jQuery(el).closest(".wpsc-option-item").remove();
4448 wpsc_change_def_val_option_single();
4449 }
4450
4451 /**
4452 * Change default value options
4453 */
4454 function wpsc_change_def_val_option_single() {
4455 var options = [];
4456 jQuery(".wpsc-options-container .option_id").each(function (index, el) {
4457 var key = jQuery(el).val().trim();
4458 var value = jQuery(el)
4459 .closest(".wpsc-option-item")
4460 .find(".wpsc-option-listing-container .text")
4461 .text();
4462 options.push({ key, value });
4463 });
4464 var optionStr = '<option value=""></option>';
4465 jQuery(options).each(function (index, el) {
4466 optionStr += '<option value="' + el.key + '">' + el.value + "</option>";
4467 });
4468
4469 var fieldType = jQuery("#wpsc-select-ticket-field").val();
4470
4471 var optionSingleTypes = ["cf_single_select", "cf_radio_button"];
4472 if (jQuery.inArray(fieldType, optionSingleTypes) != -1) {
4473 jQuery("#wpsc-default-val-option-single").html(optionStr);
4474 jQuery("#wpsc-default-val-option-single").selectWoo();
4475 }
4476
4477 var optionMultiTypes = ["cf_multi_select", "cf_checkbox"];
4478 if (jQuery.inArray(fieldType, optionMultiTypes) != -1) {
4479 var preValue = jQuery("#wpsc-default-val-option-multi").val();
4480
4481 jQuery("#wpsc-default-val-option-multi").html(optionStr);
4482 jQuery("#wpsc-default-val-option-multi").selectWoo();
4483
4484 if (preValue) {
4485 jQuery("#wpsc-default-val-option-multi").val(preValue);
4486 jQuery("#wpsc-default-val-option-multi").trigger("change");
4487 }
4488 }
4489 }
4490
4491 /**
4492 * Get rich text settings
4493 */
4494 function wpsc_get_rich_text_editor(is_humbargar = false) {
4495 if (is_humbargar) {
4496 wpsc_toggle_humbargar();
4497 }
4498
4499 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4500 jQuery(
4501 ".wpsc-setting-nav.rich-text-editor, .wpsc-humbargar-menu-item.rich-text-editor"
4502 ).addClass("active");
4503 jQuery(".wpsc-humbargar-title").html(
4504 supportcandy.humbargar_titles.rich_text_editor
4505 );
4506
4507 if (supportcandy.current_section !== "rich-text-editor") {
4508 supportcandy.current_section = "rich-text-editor";
4509 supportcandy.current_tab = "agent";
4510 }
4511
4512 window.history.replaceState(
4513 {},
4514 null,
4515 "admin.php?page=wpsc-settings&section=" +
4516 supportcandy.current_section +
4517 "&tab=" +
4518 supportcandy.current_tab
4519 );
4520 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4521
4522 wpsc_scroll_top();
4523
4524 var data = {
4525 action: "wpsc_get_rich_text_editor",
4526 tab: supportcandy.current_tab,
4527 };
4528 jQuery.post(supportcandy.ajax_url, data, function (response) {
4529 jQuery(".wpsc-setting-body").html(response);
4530 wpsc_reset_responsive_style();
4531 jQuery(
4532 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4533 ).trigger("click");
4534 });
4535 }
4536
4537 /**
4538 * Load agent tab ui
4539 */
4540 function wpsc_get_te_agent() {
4541 supportcandy.current_tab = "agent";
4542 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4543 jQuery(
4544 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4545 ).addClass("active");
4546
4547 window.history.replaceState(
4548 {},
4549 null,
4550 "admin.php?page=wpsc-settings&section=" +
4551 supportcandy.current_section +
4552 "&tab=" +
4553 supportcandy.current_tab
4554 );
4555 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4556
4557 wpsc_scroll_top();
4558
4559 const data = { action: "wpsc_get_te_agent" };
4560 jQuery.post(supportcandy.ajax_url, data, function (response) {
4561 jQuery(".wpsc-setting-section-body").html(response);
4562 wpsc_reset_responsive_style();
4563 });
4564 }
4565
4566 /**
4567 * Save agent settings
4568 */
4569 function wpsc_set_te_agent(el) {
4570 const form = jQuery(".wpsc-frm-te-agent")[0];
4571 const dataform = new FormData(form);
4572 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4573 jQuery(el).text(supportcandy.translations.please_wait);
4574 jQuery
4575 .ajax({
4576 url: supportcandy.ajax_url,
4577 type: "POST",
4578 data: dataform,
4579 processData: false,
4580 contentType: false,
4581 })
4582 .done(function (res) {
4583 wpsc_get_te_agent();
4584 });
4585 }
4586
4587 /**
4588 * Reset agent settings
4589 */
4590 function wpsc_reset_te_agent(el, nonce) {
4591 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4592 jQuery(el).text(supportcandy.translations.please_wait);
4593 const data = { action: "wpsc_reset_te_agent", _ajax_nonce: nonce };
4594 jQuery.post(supportcandy.ajax_url, data, function (response) {
4595 wpsc_get_te_agent();
4596 });
4597 }
4598
4599 /**
4600 * Load registered user tab ui
4601 */
4602 function wpsc_get_te_registered_user() {
4603 supportcandy.current_tab = "registered-user";
4604 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4605 jQuery(
4606 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4607 ).addClass("active");
4608
4609 window.history.replaceState(
4610 {},
4611 null,
4612 "admin.php?page=wpsc-settings&section=" +
4613 supportcandy.current_section +
4614 "&tab=" +
4615 supportcandy.current_tab
4616 );
4617 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4618
4619 wpsc_scroll_top();
4620
4621 const data = { action: "wpsc_get_te_registered_user" };
4622 jQuery.post(supportcandy.ajax_url, data, function (response) {
4623 jQuery(".wpsc-setting-section-body").html(response);
4624 wpsc_reset_responsive_style();
4625 });
4626 }
4627
4628 /**
4629 * Save registered user settings
4630 */
4631 function wpsc_set_te_registered_user(el) {
4632 const form = jQuery(".wpsc-frm-te-registered-user")[0];
4633 const dataform = new FormData(form);
4634 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4635 jQuery(el).text(supportcandy.translations.please_wait);
4636 jQuery
4637 .ajax({
4638 url: supportcandy.ajax_url,
4639 type: "POST",
4640 data: dataform,
4641 processData: false,
4642 contentType: false,
4643 })
4644 .done(function (res) {
4645 wpsc_get_te_registered_user();
4646 });
4647 }
4648
4649 /**
4650 * Reset registered user settings
4651 */
4652 function wpsc_reset_te_registered_user(el, nonce) {
4653 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4654 jQuery(el).text(supportcandy.translations.please_wait);
4655 const data = { action: "wpsc_reset_te_registered_user", _ajax_nonce: nonce };
4656 jQuery.post(supportcandy.ajax_url, data, function (response) {
4657 wpsc_get_te_registered_user();
4658 });
4659 }
4660
4661 /**
4662 * Load guest user tab ui
4663 */
4664 function wpsc_get_te_guest_user() {
4665 supportcandy.current_tab = "guest-user";
4666 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4667 jQuery(
4668 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4669 ).addClass("active");
4670
4671 window.history.replaceState(
4672 {},
4673 null,
4674 "admin.php?page=wpsc-settings&section=" +
4675 supportcandy.current_section +
4676 "&tab=" +
4677 supportcandy.current_tab
4678 );
4679 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4680
4681 wpsc_scroll_top();
4682
4683 const data = { action: "wpsc_get_te_guest_user" };
4684 jQuery.post(supportcandy.ajax_url, data, function (response) {
4685 jQuery(".wpsc-setting-section-body").html(response);
4686 wpsc_reset_responsive_style();
4687 });
4688 }
4689
4690 /**
4691 * Save guest user settings
4692 */
4693 function wpsc_set_te_guest_user(el) {
4694 const form = jQuery(".wpsc-frm-te-guest-user")[0];
4695 const dataform = new FormData(form);
4696 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4697 jQuery(el).text(supportcandy.translations.please_wait);
4698 jQuery
4699 .ajax({
4700 url: supportcandy.ajax_url,
4701 type: "POST",
4702 data: dataform,
4703 processData: false,
4704 contentType: false,
4705 })
4706 .done(function (res) {
4707 wpsc_get_te_guest_user();
4708 });
4709 }
4710
4711 /**
4712 * Reset guest user settings
4713 */
4714 function wpsc_reset_te_guest_user(el, nonce) {
4715 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4716 jQuery(el).text(supportcandy.translations.please_wait);
4717 const data = { action: "wpsc_reset_te_guest_user", _ajax_nonce: nonce };
4718 jQuery.post(supportcandy.ajax_url, data, function (response) {
4719 wpsc_get_te_guest_user();
4720 });
4721 }
4722
4723 /**
4724 * Load advanced tab ui
4725 */
4726 function wpsc_get_te_advanced() {
4727 supportcandy.current_tab = "advanced";
4728 jQuery(".wpsc-setting-tab-container button").removeClass("active");
4729 jQuery(
4730 ".wpsc-setting-tab-container button." + supportcandy.current_tab
4731 ).addClass("active");
4732
4733 window.history.replaceState(
4734 {},
4735 null,
4736 "admin.php?page=wpsc-settings&section=" +
4737 supportcandy.current_section +
4738 "&tab=" +
4739 supportcandy.current_tab
4740 );
4741 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4742
4743 wpsc_scroll_top();
4744
4745 const data = { action: "wpsc_get_te_advanced" };
4746 jQuery.post(supportcandy.ajax_url, data, function (response) {
4747 jQuery(".wpsc-setting-section-body").html(response);
4748 wpsc_reset_responsive_style();
4749 });
4750 }
4751
4752 /**
4753 * Save advanced settings
4754 */
4755 function wpsc_set_te_advanced(el) {
4756 const form = jQuery(".wpsc-frm-te-advanced")[0];
4757 const dataform = new FormData(form);
4758 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4759 jQuery(el).text(supportcandy.translations.please_wait);
4760 jQuery
4761 .ajax({
4762 url: supportcandy.ajax_url,
4763 type: "POST",
4764 data: dataform,
4765 processData: false,
4766 contentType: false,
4767 })
4768 .done(function (res) {
4769 wpsc_get_te_advanced();
4770 });
4771 }
4772
4773 /**
4774 * Reset advanced settings
4775 */
4776 function wpsc_reset_te_advanced(el, nonce) {
4777 jQuery(".wpsc-modal-footer button").attr("disabled", true);
4778 jQuery(el).text(supportcandy.translations.please_wait);
4779 const data = { action: "wpsc_reset_te_advanced", _ajax_nonce: nonce };
4780 jQuery.post(supportcandy.ajax_url, data, function (response) {
4781 wpsc_get_te_advanced();
4782 });
4783 }
4784
4785 /**
4786 * Get agent working hrs settings
4787 */
4788 function wpsc_get_agents_working_hrs(is_humbargar = false) {
4789 if (is_humbargar) {
4790 wpsc_toggle_humbargar();
4791 }
4792
4793 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4794 jQuery(
4795 ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs"
4796 ).addClass("active");
4797 jQuery(".wpsc-humbargar-title").html(
4798 supportcandy.humbargar_titles.working_hrs
4799 );
4800
4801 window.history.replaceState(
4802 {},
4803 null,
4804 "admin.php?page=wpsc-support-agents&section=working-hrs"
4805 );
4806 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4807
4808 wpsc_scroll_top();
4809
4810 var data = { action: "wpsc_get_agents_working_hrs" };
4811 jQuery.post(supportcandy.ajax_url, data, function (response) {
4812 jQuery(".wpsc-setting-body").html(response);
4813 wpsc_reset_responsive_style();
4814 wpsc_get_agents_wh_hrs();
4815 });
4816 }
4817
4818 /**
4819 * Get working hrs of given agent id
4820 */
4821 function wpsc_get_agents_wh_hrs() {
4822 jQuery("button.tab.exceptions").removeClass("active");
4823 jQuery("button.tab.working-hrs").addClass("active");
4824 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4825 var data = {
4826 action: "wpsc_get_agents_wh_hrs",
4827 agent_id: supportcandy.temp.agent_id,
4828 _ajax_nonce: supportcandy.nonce,
4829 };
4830 jQuery.post(supportcandy.ajax_url, data, function (response) {
4831 jQuery(".wpsc-setting-section-body").html(response);
4832 });
4833 }
4834
4835 /**
4836 * Get agent working hrs exceptions
4837 */
4838 function wpsc_get_agents_wh_exceptions() {
4839 jQuery("button.tab.working-hrs").removeClass("active");
4840 jQuery("button.tab.exceptions").addClass("active");
4841 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
4842 var data = {
4843 action: "wpsc_get_agents_wh_exceptions",
4844 agent_id: supportcandy.temp.agent_id,
4845 _ajax_nonce: supportcandy.nonce,
4846 };
4847 jQuery.post(supportcandy.ajax_url, data, function (response) {
4848 jQuery(".wpsc-setting-section-body").html(response);
4849 });
4850 }
4851
4852 /**
4853 * Get agent working hrs settings
4854 */
4855 function wpsc_get_agent_working_hrs(is_humbargar = false) {
4856 if (is_humbargar) {
4857 wpsc_toggle_humbargar();
4858 }
4859
4860 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4861 jQuery(
4862 ".wpsc-setting-nav.working-hrs, .wpsc-humbargar-menu-item.working-hrs"
4863 ).addClass("active");
4864 jQuery(".wpsc-humbargar-title").html(
4865 supportcandy.humbargar_titles.working_hrs
4866 );
4867
4868 window.history.replaceState(
4869 {},
4870 null,
4871 "admin.php?page=wpsc-support-agents&section=working-hrs"
4872 );
4873 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4874
4875 wpsc_scroll_top();
4876
4877 var data = { action: "wpsc_get_agent_working_hrs" };
4878 jQuery.post(supportcandy.ajax_url, data, function (response) {
4879 jQuery(".wpsc-setting-body").html(response);
4880 wpsc_reset_responsive_style();
4881 window.location.reload();
4882 });
4883 }
4884
4885 /**
4886 * Get all agent leaves
4887 */
4888 function wpsc_get_agent_leaves(is_humbargar = false) {
4889 if (is_humbargar) {
4890 wpsc_toggle_humbargar();
4891 }
4892
4893 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4894 jQuery(".wpsc-setting-nav.leaves, .wpsc-humbargar-menu-item.leaves").addClass(
4895 "active"
4896 );
4897 jQuery(".wpsc-humbargar-title").html(supportcandy.humbargar_titles.leaves);
4898
4899 window.history.replaceState(
4900 {},
4901 null,
4902 "admin.php?page=wpsc-support-agents&section=leaves"
4903 );
4904 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
4905
4906 wpsc_scroll_top();
4907
4908 var data = { action: "wpsc_get_agent_leaves" };
4909 jQuery.post(supportcandy.ajax_url, data, function (response) {
4910 jQuery(".wpsc-setting-body").html(response);
4911 wpsc_reset_responsive_style();
4912 });
4913 }
4914
4915 /**
4916 * Get add agent leaves
4917 */
4918 function wpsc_get_add_agent_leaves(dateSelected, _ajax_nonce) {
4919 supportcandy.temp.dateSelected = dateSelected;
4920 wpsc_show_modal();
4921 var data = {
4922 action: "wpsc_get_add_agent_leaves",
4923 dateSelected,
4924 _ajax_nonce,
4925 };
4926 jQuery.post(supportcandy.ajax_url, data, function (response) {
4927 // Set to modal.
4928 jQuery(".wpsc-modal-header").text(response.title);
4929 jQuery(".wpsc-modal-body").html(response.body);
4930 jQuery(".wpsc-modal-footer").html(response.footer);
4931 // Display modal.
4932 wpsc_show_modal_inner_container();
4933 });
4934 }
4935
4936 /**
4937 * Set add agent leaves
4938 */
4939 function wpsc_set_add_agent_leaves(el) {
4940 const form = jQuery(".wpsc-frm-agent-holiday-actions")[0];
4941 const dataform = new FormData(form);
4942
4943 var agents = dataform.getAll("agents[]");
4944 if (!agents.length) {
4945 alert(supportcandy.translations.req_fields_missing);
4946 return;
4947 }
4948
4949 dataform.append("dateSelected", supportcandy.temp.dateSelected);
4950 jQuery(el).text(supportcandy.translations.please_wait);
4951 jQuery
4952 .ajax({
4953 url: supportcandy.ajax_url,
4954 type: "POST",
4955 data: dataform,
4956 processData: false,
4957 contentType: false,
4958 })
4959 .done(function (response) {
4960 calendar.refetchEvents();
4961 wpsc_close_modal();
4962 });
4963 }
4964
4965 /**
4966 * Delete agent leave
4967 */
4968 function wpsc_delete_agent_leave(id, nonce) {
4969 var flag = confirm(supportcandy.translations.deleteLeaveConfirmation);
4970 if (!flag) {
4971 return;
4972 }
4973
4974 var data = {
4975 action: "wpsc_delete_agent_leave",
4976 holidayId: id,
4977 _ajax_nonce: nonce,
4978 };
4979 jQuery.post(supportcandy.ajax_url, data, function (response) {
4980 calendar.refetchEvents();
4981 });
4982 }
4983
4984 /**
4985 * User registration otp email template
4986 */
4987 function wpsc_get_en_user_reg_otp(is_humbargar = false) {
4988 if (is_humbargar) {
4989 wpsc_toggle_humbargar();
4990 }
4991
4992 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
4993 jQuery(
4994 ".wpsc-setting-nav.registration-otp, .wpsc-humbargar-menu-item.registration-otp"
4995 ).addClass("active");
4996 jQuery(".wpsc-humbargar-title").html(
4997 supportcandy.humbargar_titles.registration_otp
4998 );
4999
5000 window.history.replaceState(
5001 {},
5002 null,
5003 "admin.php?page=wpsc-email-notifications&section=registration-otp"
5004 );
5005 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5006
5007 wpsc_scroll_top();
5008
5009 var data = { action: "wpsc_get_en_user_reg_otp" };
5010 jQuery.post(supportcandy.ajax_url, data, function (response) {
5011 jQuery(".wpsc-setting-body").html(response);
5012 wpsc_reset_responsive_style();
5013 });
5014 }
5015
5016 /**
5017 * Set user registration otp email template
5018 */
5019 function wpsc_set_en_user_reg_otp(el) {
5020 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5021 jQuery(el).text(supportcandy.translations.please_wait);
5022 var form = jQuery(".wpsc-frm-en-user-reg-otp")[0];
5023 var dataform = new FormData(form);
5024 if (dataform.get("editor") == "html") {
5025 dataform.append("body", tinyMCE.get("wpsc-en-body").getContent());
5026 }
5027 jQuery
5028 .ajax({
5029 url: supportcandy.ajax_url,
5030 type: "POST",
5031 data: dataform,
5032 processData: false,
5033 contentType: false,
5034 })
5035 .done(function (res) {
5036 wpsc_get_en_user_reg_otp();
5037 });
5038 }
5039
5040 /**
5041 * Reset user registration otp email template
5042 */
5043 function wpsc_reset_en_user_reg_otp(el, nonce) {
5044 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5045 jQuery(el).text(supportcandy.translations.please_wait);
5046 const data = { action: "wpsc_reset_en_user_reg_otp", _ajax_nonce: nonce };
5047 jQuery.post(supportcandy.ajax_url, data, function (response) {
5048 wpsc_get_en_user_reg_otp();
5049 });
5050 }
5051
5052 /**
5053 * Get guest login otp email template
5054 *
5055 * @param {boolean} is_humbargar
5056 */
5057 function wpsc_get_en_guest_login_otp(is_humbargar = false) {
5058 if (is_humbargar) {
5059 wpsc_toggle_humbargar();
5060 }
5061
5062 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5063 jQuery(
5064 ".wpsc-setting-nav.guest-login-otp, .wpsc-humbargar-menu-item.guest-login-otp"
5065 ).addClass("active");
5066 jQuery(".wpsc-humbargar-title").html(
5067 supportcandy.humbargar_titles.registration_otp
5068 );
5069
5070 window.history.replaceState(
5071 {},
5072 null,
5073 "admin.php?page=wpsc-email-notifications&section=guest-login-otp"
5074 );
5075 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5076
5077 wpsc_scroll_top();
5078
5079 var data = { action: "wpsc_get_en_guest_login_otp" };
5080 jQuery.post(supportcandy.ajax_url, data, function (response) {
5081 jQuery(".wpsc-setting-body").html(response);
5082 wpsc_reset_responsive_style();
5083 });
5084 }
5085
5086 /**
5087 * Set guest login otp email template
5088 */
5089 function wpsc_set_en_guest_login_otp(el) {
5090 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5091 jQuery(el).text(supportcandy.translations.please_wait);
5092 var form = jQuery(".wpsc-frm-en-guest-login-otp")[0];
5093 var dataform = new FormData(form);
5094 if (dataform.get("editor") == "html") {
5095 dataform.append("body", tinyMCE.get("wpsc-en-body").getContent());
5096 }
5097 jQuery
5098 .ajax({
5099 url: supportcandy.ajax_url,
5100 type: "POST",
5101 data: dataform,
5102 processData: false,
5103 contentType: false,
5104 })
5105 .done(function (res) {
5106 wpsc_get_en_guest_login_otp();
5107 });
5108 }
5109
5110 /**
5111 * Reset guest login otp email template
5112 */
5113 function wpsc_reset_en_guest_login_otp(el, nonce) {
5114 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5115 jQuery(el).text(supportcandy.translations.please_wait);
5116 const data = { action: "wpsc_reset_en_guest_login_otp", _ajax_nonce: nonce };
5117 jQuery.post(supportcandy.ajax_url, data, function (response) {
5118 wpsc_get_en_guest_login_otp();
5119 });
5120 }
5121
5122 /**
5123 * Get ticket widget biographical info
5124 */
5125 function wpsc_get_tw_biographical_info() {
5126 wpsc_show_modal();
5127 var data = { action: "wpsc_get_tw_biographical_info" };
5128 jQuery.post(supportcandy.ajax_url, data, function (response) {
5129 // Set to modal.
5130 jQuery(".wpsc-modal-header").text(response.title);
5131 jQuery(".wpsc-modal-body").html(response.body);
5132 jQuery(".wpsc-modal-footer").html(response.footer);
5133 // Display modal.
5134 wpsc_show_modal_inner_container();
5135 });
5136 }
5137
5138 /**
5139 * Set ticket widget biographical info
5140 */
5141 function wpsc_set_tw_biographical_info(el) {
5142 var form = jQuery(".wpsc-frm-edit-biographical-info")[0];
5143 var dataform = new FormData(form);
5144
5145 if (dataform.get("label").trim() == "") {
5146 alert(supportcandy.translations.req_fields_missing);
5147 return;
5148 }
5149
5150 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5151 jQuery(el).text(supportcandy.translations.please_wait);
5152
5153 jQuery
5154 .ajax({
5155 url: supportcandy.ajax_url,
5156 type: "POST",
5157 data: dataform,
5158 processData: false,
5159 contentType: false,
5160 })
5161 .done(function (res) {
5162 wpsc_close_modal();
5163 wpsc_get_ticket_widget();
5164 });
5165 }
5166
5167 /**
5168 * Get edit agent ticket list items
5169 */
5170 function wpsc_get_edit_agent_tl_item(slug, _ajax_nonce) {
5171 wpsc_show_modal();
5172 var data = { action: "wpsc_get_edit_agent_tl_item", slug, _ajax_nonce };
5173 jQuery.post(supportcandy.ajax_url, data, function (response) {
5174 // Set to modal.
5175 jQuery(".wpsc-modal-header").text(response.title);
5176 jQuery(".wpsc-modal-body").html(response.body);
5177 jQuery(".wpsc-modal-footer").html(response.footer);
5178 // Display modal.
5179 wpsc_show_modal_inner_container();
5180 });
5181 }
5182
5183 /**
5184 * Set edit agent ticket list items
5185 */
5186 function wpsc_set_edit_agent_tl_item(el) {
5187 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5188 jQuery(el).text(supportcandy.translations.please_wait);
5189
5190 var form = jQuery(".frm-edit-agent-tl-items")[0];
5191 var dataform = new FormData(form);
5192 jQuery
5193 .ajax({
5194 url: supportcandy.ajax_url,
5195 type: "POST",
5196 data: dataform,
5197 processData: false,
5198 contentType: false,
5199 })
5200 .done(function (res) {
5201 wpsc_close_modal();
5202 wpsc_get_agent_tl_items();
5203 });
5204 }
5205
5206 /**
5207 * Get edit agent filter list items
5208 */
5209 function wpsc_get_edit_agent_filter_item(slug, _ajax_nonce) {
5210 wpsc_show_modal();
5211 var data = { action: "wpsc_get_edit_agent_filter_item", slug, _ajax_nonce };
5212 jQuery.post(supportcandy.ajax_url, data, function (response) {
5213 // Set to modal.
5214 jQuery(".wpsc-modal-header").text(response.title);
5215 jQuery(".wpsc-modal-body").html(response.body);
5216 jQuery(".wpsc-modal-footer").html(response.footer);
5217 // Display modal.
5218 wpsc_show_modal_inner_container();
5219 });
5220 }
5221
5222 /**
5223 * Set edit agent filter list items
5224 */
5225 function wpsc_set_edit_agent_filter_item(el) {
5226 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5227 jQuery(el).text(supportcandy.translations.please_wait);
5228
5229 var form = jQuery(".frm-edit-agent-fl-items")[0];
5230 var dataform = new FormData(form);
5231 jQuery
5232 .ajax({
5233 url: supportcandy.ajax_url,
5234 type: "POST",
5235 data: dataform,
5236 processData: false,
5237 contentType: false,
5238 })
5239 .done(function (res) {
5240 wpsc_close_modal();
5241 wpsc_get_agent_filter_items();
5242 });
5243 }
5244
5245 /**
5246 * Get edit company working hrs exception
5247 */
5248 function wpsc_get_edit_wh_exception(exception_id, _ajax_nonce) {
5249 wpsc_show_modal();
5250 var data = {
5251 action: "wpsc_get_edit_wh_exception",
5252 exception_id,
5253 _ajax_nonce,
5254 };
5255 jQuery.post(supportcandy.ajax_url, data, function (response) {
5256 // Set to modal.
5257 jQuery(".wpsc-modal-header").text(response.title);
5258 jQuery(".wpsc-modal-body").html(response.body);
5259 jQuery(".wpsc-modal-footer").html(response.footer);
5260 // Display modal.
5261 wpsc_show_modal_inner_container();
5262 });
5263 }
5264
5265 /**
5266 * Delete company working hrs exception
5267 */
5268 function wpsc_delete_wh_exception(exception_id, _ajax_nonce) {
5269 var flag = confirm(supportcandy.translations.confirm);
5270 if (!flag) {
5271 return;
5272 }
5273 var data = { action: "wpsc_delete_wh_exception", exception_id, _ajax_nonce };
5274 jQuery.post(supportcandy.ajax_url, data, function (res) {
5275 wpsc_get_wh_exceptions();
5276 });
5277 }
5278
5279 /**
5280 * Get edit customer ticket list items
5281 */
5282 function wpsc_get_edit_customer_tl_item(slug, _ajax_nonce) {
5283 wpsc_show_modal();
5284 var data = { action: "wpsc_get_edit_customer_tl_item", slug, _ajax_nonce };
5285 jQuery.post(supportcandy.ajax_url, data, function (response) {
5286 // Set to modal.
5287 jQuery(".wpsc-modal-header").text(response.title);
5288 jQuery(".wpsc-modal-body").html(response.body);
5289 jQuery(".wpsc-modal-footer").html(response.footer);
5290 // Display modal.
5291 wpsc_show_modal_inner_container();
5292 });
5293 }
5294
5295 /**
5296 * Set edit customer ticket list items
5297 */
5298 function wpsc_set_edit_customer_tl_item(el) {
5299 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5300 jQuery(el).text(supportcandy.translations.please_wait);
5301
5302 var form = jQuery(".frm-edit-customer-tl-items")[0];
5303 var dataform = new FormData(form);
5304 jQuery
5305 .ajax({
5306 url: supportcandy.ajax_url,
5307 type: "POST",
5308 data: dataform,
5309 processData: false,
5310 contentType: false,
5311 })
5312 .done(function (res) {
5313 wpsc_close_modal();
5314 wpsc_get_customer_tl_items();
5315 });
5316 }
5317
5318 /**
5319 * Get edit coustomer ticket filter items
5320 */
5321 function wpsc_get_edit_ctl_filter_item(slug, _ajax_nonce) {
5322 wpsc_show_modal();
5323 var data = { action: "wpsc_get_edit_ctl_filter_item", slug, _ajax_nonce };
5324 jQuery.post(supportcandy.ajax_url, data, function (response) {
5325 // Set to modal.
5326 jQuery(".wpsc-modal-header").text(response.title);
5327 jQuery(".wpsc-modal-body").html(response.body);
5328 jQuery(".wpsc-modal-footer").html(response.footer);
5329 // Display modal.
5330 wpsc_show_modal_inner_container();
5331 });
5332 }
5333
5334 /**
5335 * Set edit coustomer ticket filter items
5336 */
5337 function wpsc_set_edit_ctl_filter_item(el) {
5338 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5339 jQuery(el).text(supportcandy.translations.please_wait);
5340
5341 var form = jQuery(".frm-edit-customer-fl-items")[0];
5342 var dataform = new FormData(form);
5343 jQuery
5344 .ajax({
5345 url: supportcandy.ajax_url,
5346 type: "POST",
5347 data: dataform,
5348 processData: false,
5349 contentType: false,
5350 })
5351 .done(function (res) {
5352 wpsc_close_modal();
5353 wpsc_get_customer_filter_items();
5354 });
5355 }
5356
5357 /**
5358 * Get ticket tag settings
5359 */
5360 function wpsc_get_ticket_tags() {
5361 supportcandy.current_tab = "ticket-tags-list";
5362 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5363 jQuery(
5364 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5365 ).addClass("active");
5366
5367 window.history.replaceState(
5368 {},
5369 null,
5370 "admin.php?page=wpsc-settings&section=" +
5371 supportcandy.current_section +
5372 "&tab=" +
5373 supportcandy.current_tab
5374 );
5375 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5376
5377 wpsc_scroll_top();
5378
5379 var data = { action: "wpsc_get_ticket_tags" };
5380 jQuery.post(supportcandy.ajax_url, data, function (response) {
5381 jQuery(".wpsc-setting-section-body").html(response);
5382 wpsc_reset_responsive_style();
5383 });
5384 }
5385
5386 /**
5387 * Set add ticket tag
5388 */
5389 function wpsc_set_add_ticket_tags(el) {
5390 var form = jQuery(".wpsc-frm-add-ms-ticket-tags")[0];
5391 var dataform = new FormData(form);
5392
5393 if (!dataform.get("name")) {
5394 alert(supportcandy.translations.req_fields_missing);
5395 return;
5396 }
5397
5398 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5399 jQuery(el).text(supportcandy.translations.please_wait);
5400
5401 jQuery
5402 .ajax({
5403 url: supportcandy.ajax_url,
5404 type: "POST",
5405 data: dataform,
5406 processData: false,
5407 contentType: false,
5408 })
5409 .done(function (res) {
5410 wpsc_close_modal();
5411 wpsc_get_ticket_tags();
5412 });
5413 }
5414
5415 /**
5416 * Update tag
5417 */
5418 function wpsc_get_edit_ticket_tags(id, nonce) {
5419 wpsc_show_modal();
5420 var data = { action: "wpsc_get_edit_ticket_tags", id, _ajax_nonce: nonce };
5421 jQuery.post(supportcandy.ajax_url, data, function (res) {
5422 // Set to modal.
5423 jQuery(".wpsc-modal-header").text(res.title);
5424 jQuery(".wpsc-modal-body").html(res.body);
5425 jQuery(".wpsc-modal-footer").html(res.footer);
5426 // Display modal.
5427 wpsc_show_modal_inner_container();
5428 });
5429 }
5430
5431 function wpsc_set_edit_ticket_tags(el) {
5432 var form = jQuery(".wpsc-frm-edit-ticket-tag")[0];
5433 var dataform = new FormData(form);
5434
5435 if (!dataform.get("name")) {
5436 alert(supportcandy.translations.req_fields_missing);
5437 return;
5438 }
5439 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5440 jQuery(el).text(supportcandy.translations.please_wait);
5441
5442 jQuery
5443 .ajax({
5444 url: supportcandy.ajax_url,
5445 type: "POST",
5446 data: dataform,
5447 processData: false,
5448 contentType: false,
5449 })
5450 .done(function (res) {
5451 wpsc_close_modal();
5452 wpsc_get_ticket_tags();
5453 });
5454 }
5455
5456 /**
5457 * Delete ticket tag modal
5458 */
5459 function wpsc_set_delete_ticket_tags(id, nonce) {
5460 var flag = confirm(supportcandy.translations.confirm);
5461 if (!flag) {
5462 return;
5463 }
5464
5465 var data = { action: "wpsc_set_delete_ticket_tags", id, _ajax_nonce: nonce };
5466 jQuery.post(supportcandy.ajax_url, data, function (response) {
5467 wpsc_get_ticket_tags();
5468 });
5469 }
5470
5471 /**
5472 * Get ticket widget ticket tags
5473 */
5474 function wpsc_get_tw_ticket_tags() {
5475 wpsc_show_modal();
5476 var data = { action: "wpsc_get_tw_ticket_tags" };
5477 jQuery.post(supportcandy.ajax_url, data, function (response) {
5478 // Set to modal.
5479 jQuery(".wpsc-modal-header").text(response.title);
5480 jQuery(".wpsc-modal-body").html(response.body);
5481 jQuery(".wpsc-modal-footer").html(response.footer);
5482 // Display modal.
5483 wpsc_show_modal_inner_container();
5484 });
5485 }
5486
5487 /**
5488 * Set ticket widget ticket tags
5489 */
5490 function wpsc_set_tw_ticket_tags(el) {
5491 var form = jQuery(".wpsc-frm-edit-tags")[0];
5492 var dataform = new FormData(form);
5493
5494 if (dataform.get("label").trim() == "") {
5495 alert(supportcandy.translations.req_fields_missing);
5496 return;
5497 }
5498
5499 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5500 jQuery(el).text(supportcandy.translations.please_wait);
5501
5502 jQuery
5503 .ajax({
5504 url: supportcandy.ajax_url,
5505 type: "POST",
5506 data: dataform,
5507 processData: false,
5508 contentType: false,
5509 })
5510 .done(function (res) {
5511 wpsc_close_modal();
5512 wpsc_get_ticket_widget();
5513 });
5514 }
5515
5516 /**
5517 * Get ticket tags modal UI
5518 */
5519 function wpsc_it_get_edit_ticket_tags(ticket_id, nonce) {
5520 wpsc_show_modal();
5521 var data = {
5522 action: "wpsc_it_get_edit_ticket_tags",
5523 ticket_id,
5524 _ajax_nonce: nonce,
5525 };
5526 jQuery.post(supportcandy.ajax_url, data, function (response) {
5527 jQuery(".wpsc-modal-header").text(response.title);
5528 jQuery(".wpsc-modal-body").html(response.body);
5529 jQuery(".wpsc-modal-footer").html(response.footer);
5530 wpsc_show_modal_inner_container();
5531 });
5532 }
5533
5534 /**
5535 * Get appearence settings
5536 */
5537 function wpsc_get_ticket_tags_settings(is_humbargar = false) {
5538 if (is_humbargar) {
5539 wpsc_toggle_humbargar();
5540 }
5541
5542 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5543 jQuery(
5544 ".wpsc-setting-nav.ticket-tags, .wpsc-humbargar-menu-item.ticket-tags"
5545 ).addClass("active");
5546 jQuery(".wpsc-humbargar-title").html(
5547 supportcandy.humbargar_titles.tickettags
5548 );
5549
5550 if (supportcandy.current_section !== "ticket-tags") {
5551 supportcandy.current_section = "ticket-tags";
5552 supportcandy.current_tab = "general";
5553 }
5554
5555 window.history.replaceState(
5556 {},
5557 null,
5558 "admin.php?page=wpsc-settings&section=" +
5559 supportcandy.current_section +
5560 "&tab=" +
5561 supportcandy.current_tab
5562 );
5563 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5564
5565 wpsc_scroll_top();
5566
5567 var data = {
5568 action: "wpsc_get_ticket_tags_settings",
5569 tab: supportcandy.current_tab,
5570 };
5571 jQuery.post(supportcandy.ajax_url, data, function (response) {
5572 jQuery(".wpsc-setting-body").html(response);
5573 wpsc_reset_responsive_style();
5574 jQuery(
5575 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5576 ).trigger("click");
5577 });
5578 }
5579
5580 /**
5581 * Get general appearence settings
5582 */
5583 function wpsc_ticket_tags_get_general_settings() {
5584 supportcandy.current_tab = "general";
5585 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5586 jQuery(
5587 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5588 ).addClass("active");
5589
5590 window.history.replaceState(
5591 {},
5592 null,
5593 "admin.php?page=wpsc-settings&section=" +
5594 supportcandy.current_section +
5595 "&tab=" +
5596 supportcandy.current_tab
5597 );
5598 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5599
5600 wpsc_scroll_top();
5601 var data = { action: "wpsc_ticket_tags_get_general_settings" };
5602 jQuery.post(supportcandy.ajax_url, data, function (response) {
5603 jQuery(".wpsc-setting-section-body").html(response);
5604 wpsc_reset_responsive_style();
5605 });
5606 }
5607
5608 /**
5609 * Set general settings
5610 */
5611 function wpsc_ticket_tags_set_general_settings(el) {
5612 var form = jQuery(".wpsc-ticket-tags-general-settings")[0];
5613 var dataform = new FormData(form);
5614 jQuery(el).text(supportcandy.translations.please_wait);
5615 jQuery
5616 .ajax({
5617 url: supportcandy.ajax_url,
5618 type: "POST",
5619 data: dataform,
5620 processData: false,
5621 contentType: false,
5622 })
5623 .done(function (res) {
5624 wpsc_ticket_tags_get_general_settings();
5625 });
5626 }
5627
5628 /**
5629 * Reset general settings
5630 */
5631 function wpsc_ticket_tags_reset_general_settings(el, nonce) {
5632 jQuery(el).text(supportcandy.translations.please_wait);
5633 var data = {
5634 action: "wpsc_ticket_tags_reset_general_settings",
5635 _ajax_nonce: nonce,
5636 };
5637 jQuery.post(supportcandy.ajax_url, data, function (response) {
5638 wpsc_ticket_tags_get_general_settings();
5639 });
5640 }
5641
5642 /**
5643 * Get dashboard settings
5644 */
5645 function wpsc_get_dashboard_settings(is_humbargar = false) {
5646 if (is_humbargar) {
5647 wpsc_toggle_humbargar();
5648 }
5649
5650 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
5651 jQuery(
5652 ".wpsc-setting-nav.dashboard-settings, .wpsc-humbargar-menu-item.dashboard-settings"
5653 ).addClass("active");
5654 jQuery(".wpsc-humbargar-title").html(
5655 supportcandy.humbargar_titles.tickettags
5656 );
5657
5658 if (supportcandy.current_section !== "dashboard-settings") {
5659 supportcandy.current_section = "dashboard-settings";
5660 supportcandy.current_tab = "dashboard-general";
5661 }
5662
5663 window.history.replaceState(
5664 {},
5665 null,
5666 "admin.php?page=wpsc-settings&section=" +
5667 supportcandy.current_section +
5668 "&tab=" +
5669 supportcandy.current_tab
5670 );
5671 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
5672
5673 wpsc_scroll_top();
5674
5675 var data = {
5676 action: "wpsc_get_dashboard_settings",
5677 tab: supportcandy.current_tab,
5678 };
5679 jQuery.post(supportcandy.ajax_url, data, function (response) {
5680 jQuery(".wpsc-setting-body").html(response);
5681 wpsc_reset_responsive_style();
5682 jQuery(
5683 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5684 ).trigger("click");
5685 });
5686 }
5687
5688 /**
5689 * Get dashboard cards settings
5690 */
5691 function wpsc_get_dashboard_cards_settings() {
5692 supportcandy.current_tab = "dashboard-cards";
5693 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5694 jQuery(
5695 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5696 ).addClass("active");
5697
5698 window.history.replaceState(
5699 {},
5700 null,
5701 "admin.php?page=wpsc-settings&section=" +
5702 supportcandy.current_section +
5703 "&tab=" +
5704 supportcandy.current_tab
5705 );
5706 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5707
5708 wpsc_scroll_top();
5709 var data = { action: "wpsc_get_dashboard_cards_settings" };
5710 jQuery.post(supportcandy.ajax_url, data, function (response) {
5711 jQuery(".wpsc-setting-section-body").html(response);
5712 wpsc_reset_responsive_style();
5713 });
5714 }
5715
5716 /**
5717 * Sort dashboard cards
5718 */
5719 function wpsc_set_dashboard_card_load_order(slugs, nonce) {
5720 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5721 var data = {
5722 action: "wpsc_set_dashboard_card_load_order",
5723 slugs,
5724 _ajax_nonce: nonce,
5725 };
5726 jQuery.post(supportcandy.ajax_url, data, function (res) {
5727 wpsc_get_dashboard_cards_settings();
5728 });
5729 }
5730
5731 /**
5732 * Get dashboard widgets settings
5733 */
5734 function wpsc_get_dashboard_widgets_settings() {
5735 supportcandy.current_tab = "dashboard-widgets";
5736 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5737 jQuery(
5738 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5739 ).addClass("active");
5740
5741 window.history.replaceState(
5742 {},
5743 null,
5744 "admin.php?page=wpsc-settings&section=" +
5745 supportcandy.current_section +
5746 "&tab=" +
5747 supportcandy.current_tab
5748 );
5749 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5750
5751 wpsc_scroll_top();
5752 var data = { action: "wpsc_get_dashboard_widgets_settings" };
5753 jQuery.post(supportcandy.ajax_url, data, function (response) {
5754 jQuery(".wpsc-setting-section-body").html(response);
5755 wpsc_reset_responsive_style();
5756 });
5757 }
5758
5759 /**
5760 * Get dashboard widgets settings
5761 */
5762 function wpsc_get_dashboard_general_settings() {
5763 supportcandy.current_tab = "dashboard-general";
5764 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5765 jQuery(
5766 ".wpsc-setting-tab-container button." + supportcandy.current_tab
5767 ).addClass("active");
5768
5769 window.history.replaceState(
5770 {},
5771 null,
5772 "admin.php?page=wpsc-settings&section=" +
5773 supportcandy.current_section +
5774 "&tab=" +
5775 supportcandy.current_tab
5776 );
5777 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5778
5779 wpsc_scroll_top();
5780 var data = { action: "wpsc_get_dashboard_general_settings" };
5781 jQuery.post(supportcandy.ajax_url, data, function (response) {
5782 jQuery(".wpsc-setting-section-body").html(response);
5783 wpsc_reset_responsive_style();
5784 });
5785 }
5786
5787 /**
5788 * Save dashboard general settings
5789 *
5790 * @param {*} el
5791 */
5792 function wpsc_set_dashboard_general_settings(el) {
5793 var form = jQuery(".wpsc-frm-db-gs")[0];
5794 var dataform = new FormData(form);
5795 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5796 jQuery(el).text(supportcandy.translations.please_wait);
5797 jQuery
5798 .ajax({
5799 url: supportcandy.ajax_url,
5800 type: "POST",
5801 data: dataform,
5802 processData: false,
5803 contentType: false,
5804 })
5805 .done(function (res) {
5806 wpsc_get_dashboard_general_settings();
5807 });
5808 }
5809
5810 /**
5811 * Reset dashboard general settings
5812 *
5813 * @param {*} el
5814 */
5815 function wpsc_reset_dashboard_general_settings(el, nonce) {
5816 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5817 jQuery(el).text(supportcandy.translations.please_wait);
5818 var data = {
5819 action: "wpsc_reset_dashboard_general_settings",
5820 _ajax_nonce: nonce,
5821 };
5822 jQuery.post(supportcandy.ajax_url, data, function (response) {
5823 wpsc_get_dashboard_general_settings();
5824 });
5825 }
5826
5827 /**
5828 * Add new dashboard widget
5829 */
5830 function wpsc_get_new_dashboard_widget(nonce) {
5831 wpsc_show_modal();
5832 var data = { action: "wpsc_get_new_dashboard_widget", _ajax_nonce: nonce };
5833 jQuery.post(supportcandy.ajax_url, data, function (response) {
5834 // Set to modal.
5835 jQuery(".wpsc-modal-header").text(response.title);
5836 jQuery(".wpsc-modal-body").html(response.body);
5837 jQuery(".wpsc-modal-footer").html(response.footer);
5838 // Display modal.
5839 wpsc_show_modal_inner_container();
5840 });
5841 }
5842
5843 /**
5844 * Set new dashboard widget
5845 */
5846 function wpsc_set_new_dashboard_widget(el) {
5847 var form = jQuery(".wpsc-add-new-dashboard-widget")[0];
5848 var dataform = new FormData(form);
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_close_modal();
5860 wpsc_get_dashboard_settings();
5861 });
5862 }
5863
5864 /**
5865 * Delete dashboard widget
5866 */
5867 function wpsc_delete_dashboard_widget(slug, nonce) {
5868 var flag = confirm(supportcandy.translations.confirm);
5869 if (!flag) {
5870 return;
5871 }
5872
5873 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5874 var data = {
5875 action: "wpsc_delete_dashboard_widget",
5876 slug,
5877 _ajax_nonce: nonce,
5878 };
5879 jQuery.post(supportcandy.ajax_url, data, function (response) {
5880 wpsc_get_dashboard_settings();
5881 });
5882 }
5883
5884 /**
5885 * Sort dashboard widgets
5886 */
5887 function wpsc_set_dashboard_widget_load_order(slugs, nonce) {
5888 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5889 var data = {
5890 action: "wpsc_set_dashboard_widget_load_order",
5891 slugs,
5892 _ajax_nonce: nonce,
5893 };
5894 jQuery.post(supportcandy.ajax_url, data, function (res) {
5895 wpsc_get_dashboard_widgets_settings();
5896 });
5897 }
5898
5899 /**
5900 * Edit bashboard widget
5901 */
5902 function wpsc_get_edit_dashboard_card_widget(type, slug, nonce) {
5903 wpsc_show_modal();
5904 var data = {
5905 action: "wpsc_get_edit_dashboard_card_widget",
5906 type,
5907 slug,
5908 _ajax_nonce: nonce,
5909 };
5910 jQuery.post(supportcandy.ajax_url, data, function (response) {
5911 // Set to modal.
5912 jQuery(".wpsc-modal-header").text(response.title);
5913 jQuery(".wpsc-modal-body").html(response.body);
5914 jQuery(".wpsc-modal-footer").html(response.footer);
5915 // Display modal.
5916 wpsc_show_modal_inner_container();
5917 });
5918 }
5919
5920 /**
5921 * Set edit bashboard widget
5922 */
5923 function wpsc_set_edit_dashboard_card_widget(el) {
5924 var form = jQuery(".wpsc-frm-edit-dashboard-cards-widgets")[0];
5925 var dataform = new FormData(form);
5926
5927 if (dataform.get("label").trim() == "") {
5928 alert(supportcandy.translations.req_fields_missing);
5929 return;
5930 }
5931
5932 jQuery(".wpsc-modal-footer button").attr("disabled", true);
5933 jQuery(el).text(supportcandy.translations.please_wait);
5934
5935 jQuery
5936 .ajax({
5937 url: supportcandy.ajax_url,
5938 type: "POST",
5939 data: dataform,
5940 processData: false,
5941 contentType: false,
5942 })
5943 .done(function (res) {
5944 wpsc_close_modal();
5945 wpsc_get_dashboard_settings();
5946 });
5947 }
5948
5949 /**
5950 * Get appearence dashboard
5951 */
5952 function wpsc_get_ap_dashboard() {
5953 supportcandy.current_tab = "dashboard";
5954 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5955 jQuery(
5956 ".wpsc-setting-tab-container button." + supportcandy.current_tabs
5957 ).addClass("active");
5958
5959 window.history.replaceState(
5960 {},
5961 null,
5962 "admin.php?page=wpsc-settings&section=" +
5963 supportcandy.current_section +
5964 "&tab=" +
5965 supportcandy.current_tab
5966 );
5967 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
5968
5969 wpsc_scroll_top();
5970 var data = { action: "wpsc_get_ap_dashboard" };
5971 jQuery.post(supportcandy.ajax_url, data, function (response) {
5972 jQuery(".wpsc-setting-section-body").html(response);
5973 wpsc_reset_responsive_style();
5974 });
5975 }
5976
5977 /**
5978 * Set appearence dashboard
5979 */
5980 function wpsc_set_ap_dashboard(el) {
5981 var form = jQuery(".wpsc-frm-ap-dash")[0];
5982 var dataform = new FormData(form);
5983 jQuery(el).text(supportcandy.translations.please_wait);
5984 jQuery
5985 .ajax({
5986 url: supportcandy.ajax_url,
5987 type: "POST",
5988 data: dataform,
5989 processData: false,
5990 contentType: false,
5991 })
5992 .done(function (res) {
5993 wpsc_get_ap_dashboard();
5994 });
5995 }
5996
5997 /**
5998 * Reset appearence dashboard
5999 */
6000 function wpsc_reset_ap_dashboard(el, nonce) {
6001 jQuery(el).text(supportcandy.translations.please_wait);
6002 var data = { action: "wpsc_reset_ap_dashboard", _ajax_nonce: nonce };
6003 jQuery.post(supportcandy.ajax_url, data, function (res) {
6004 wpsc_get_ap_dashboard();
6005 });
6006 }
6007
6008 /**
6009 * Get customer profile
6010 *
6011 * @param {int} id
6012 */
6013 function wpsc_view_customer_detailed_info(customer_id, nonce) {
6014 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
6015 var data = {
6016 action: "wpsc_view_customer_detailed_info",
6017 customer_id,
6018 _ajax_nonce: nonce,
6019 };
6020 jQuery.post(supportcandy.ajax_url, data, function (res) {
6021 jQuery(".wpsc-setting-section-body").html(res);
6022 });
6023 }
6024
6025 function wpsc_update_live_agents() {
6026
6027 if (!supportcandy.ticketListIsIndividual) {
6028 return;
6029 }
6030 agent_id = jQuery("#wpsc-current-agent").val();
6031 if (!agent_id) {
6032 return;
6033 }
6034 if (typeof supportcandy.agent_collision === "undefined" || !supportcandy.agent_collision) {
6035 return;
6036 }
6037
6038 ticket_id = jQuery("#wpsc-current-ticket").val();
6039 var data = { action: 'wpsc_check_live_agents', agent_id, ticket_id, operation: 'leave', _ajax_nonce: supportcandy.nonce };
6040 jQuery.post(
6041 supportcandy.ajax_url,
6042 data,
6043 function (response) {
6044 }
6045 );
6046 }
6047