at path:ROOT / clients / assets / js / Admin.js
run:R W Run
DIR
2026-04-08 19:41:33
R W Run
DIR
2026-04-08 19:29:28
R W Run
38.7 KB
2026-04-08 19:26:24
R W Run
1.49 KB
2026-04-08 19:26:23
R W Run
4.72 KB
2026-04-08 19:26:25
R W Run
3.02 KB
2026-04-08 19:26:25
R W Run
10.78 KB
2026-04-08 19:26:25
R W Run
7.35 KB
2026-04-08 19:26:23
R W Run
11.6 KB
2026-04-08 19:26:22
R W Run
10.43 KB
2026-04-08 19:26:24
R W Run
26.35 KB
2026-04-08 19:26:25
R W Run
12.68 KB
2026-04-08 19:26:24
R W Run
1.94 KB
2026-04-08 19:26:24
R W Run
7.14 KB
2026-04-08 19:26:24
R W Run
1.16 KB
2026-04-08 19:26:24
R W Run
4.77 KB
2026-04-08 19:26:22
R W Run
3.56 KB
2026-04-08 19:26:24
R W Run
5.43 KB
2026-04-08 19:26:23
R W Run
4.04 KB
2026-04-08 19:26:23
R W Run
11.09 KB
2026-04-08 19:26:23
R W Run
10.93 KB
2026-04-08 19:26:25
R W Run
8.78 KB
2026-04-08 19:26:23
R W Run
3.09 KB
2026-04-08 19:26:22
R W Run
38.75 KB
2026-04-08 19:26:24
R W Run
4.62 KB
2026-04-08 19:26:24
R W Run
1.9 KB
2026-04-08 19:26:24
R W Run
23.06 KB
2026-04-08 19:26:23
R W Run
6.79 KB
2026-04-08 19:26:22
R W Run
72.3 KB
2026-04-08 19:26:24
R W Run
42 By
2026-04-08 19:26:23
R W Run
69.61 KB
2026-04-08 19:26:23
R W Run
35.35 KB
2026-04-08 19:26:22
R W Run
425.48 KB
2026-04-08 19:26:25
R W Run
77.13 KB
2026-04-08 19:26:24
R W Run
1.42 KB
2026-04-08 19:26:22
R W Run
20.26 KB
2026-04-08 19:26:25
R W Run
94.89 KB
2026-04-08 19:26:24
R W Run
22.42 KB
2026-04-08 19:26:24
R W Run
18.09 KB
2026-04-08 19:26:23
R W Run
4.6 KB
2026-04-08 19:26:23
R W Run
3.56 KB
2026-04-08 19:26:24
R W Run
16.76 KB
2026-04-08 19:26:24
R W Run
5.18 KB
2026-04-08 19:26:23
R W Run
31.03 KB
2026-04-08 19:26:25
R W Run
96.29 KB
2026-04-08 19:26:25
R W Run
41.33 KB
2026-04-08 19:26:22
R W Run
2.76 KB
2026-04-08 19:26:25
R W Run
error_log
📄Admin.js
1jQuery(document).ready(function() {
2 jQuery('[data-toggle="tooltip"]').tooltip();
3 jQuery('[data-toggle="popover"]').popover();
4 jQuery('.inline-editable').editable({
5 mode: 'inline',
6 params: function(params) {
7 params.action = 'savefield';
8 params.token = csrfToken;
9 return params;
10 }
11 });
12
13 generateBootstrapSwitches();
14
15 jQuery('select.form-control.enhanced').select2({
16 theme: 'bootstrap'
17 });
18
19 jQuery('body').on('click', '.copy-to-clipboard', WHMCS.ui.clipboard.copy);
20
21 jQuery(".credit-card-type li a").click(function() {
22 jQuery("#selectedCard").html(jQuery(this).html());
23 jQuery("#cctype").val(jQuery('span.type', this).html());
24 });
25
26 jQuery('.paging-dropdown li a,.page-selector').click(function() {
27 if (jQuery(this).parent().hasClass('disabled')) {
28 return false;
29 }
30 var form = jQuery('#frmRecordsFound');
31 jQuery("#currentPage").html(jQuery(this).data('page'));
32 form.find('input[name="page"]')
33 .val(jQuery(this).data('page')).end();
34 form.submit();
35 return false;
36 });
37
38 jQuery(".no-results a").click(function(e) {
39 e.preventDefault();
40 jQuery('#checkboxShowHidden').bootstrapSwitch('state', false);
41 });
42
43 jQuery('body').on('click', 'a.autoLinked', function (e) {
44 e.preventDefault();
45 if (jQuery(this).hasClass('disabled')) {
46 return false;
47 }
48
49 var child = window.open();
50 child.opener = null;
51 child.location = $(this).attr('href');
52 });
53
54 jQuery('#divModuleSettings').on('click', '.icon-refresh', function() {
55 fetchModuleSettings(jQuery(this).data('product-id'), 'simple');
56 processAddonDisplay();
57 });
58
59 jQuery('#mode-switch').click(function() {
60 fetchModuleSettings(jQuery(this).data('product-id'), jQuery(this).attr('data-mode'));
61 });
62
63 $('body').on('click', '.modal-wizard .modal-submit', function() {
64 var modal = $('#modalAjax');
65 modal.find('.loader').show();
66 modal.find('.modal-submit').prop('disabled', true);
67
68 $('.modal-wizard .wizard-step:hidden :input').attr('disabled', true);
69
70 var form = document.forms.namedItem('frmWizardContent'),
71 oData = new FormData(form),
72 currentStep = $('.modal-wizard .wizard-step:visible').data('step-number'),
73 ccGatewayFormSubmitted = $('#ccGatewayFormSubmitted').val(),
74 enomFormSubmitted = $('#enomFormSubmitted').val(),
75 oReq = new XMLHttpRequest();
76
77 if ((ccGatewayFormSubmitted && currentStep == 3) || (enomFormSubmitted && currentStep == 5)) {
78 wizardStepTransition(false, true);
79 fadeoutLoaderAndAllowSubmission(modal);
80 } else {
81
82 oReq.open('POST', $('#frmWizardContent').attr('action'), true);
83
84 oReq.send(oData);
85 oReq.onload = function () {
86 if (oReq.status == 200) {
87 try {
88 var data = JSON.parse(oReq.responseText),
89 doNotShow = $('#btnWizardDoNotShow');
90 if (doNotShow.is(':visible')) {
91 doNotShow.fadeOut('slow', function () {
92 $('#btnWizardSkip').hide().removeClass('hidden').fadeIn('slow');
93 });
94 }
95
96 if (data.success) {
97 if (data.sslData) {
98 var sslData = data.sslData;
99 if (sslData.approverEmails) {
100 for (i = 0; i < sslData.approverEmails.length; i++) {
101 var email = sslData.approverEmails[i];
102 $('.modal-wizard .cert-approver-emails')
103 .append('<label class="radio-inline">' +
104 '<input type="radio" name="approver_email" value="' + email + '"> '
105 + email + '</label><br>');
106 }
107 }
108 if (sslData.approvalMethods) {
109 for (i = 0; i < sslData.approvalMethods.length; i++) {
110 $("label[for='" + sslData.approvalMethods[i] + "Method']")
111 .removeClass('hidden').show();
112 }
113 }
114 } else if (data.authData) {
115 var authData = data.authData;
116 if (authData.method == 'emailauth') {
117 $('.modal-wizard .cert-email-auth').removeClass('hidden');
118 $('.modal-wizard .cert-email-auth-emailapprover').val(authData.email);
119 } else if (authData.method == 'fileauth') {
120 $('.modal-wizard .cert-file-auth').removeClass('hidden');
121 $('.modal-wizard .cert-file-auth-filename')
122 .val('http://<domain>/' + authData.path + '/' + authData.name);
123 $('.modal-wizard .cert-file-auth-contents').val(authData.contents);
124 } else if (authData.method == 'dnsauth') {
125 $('.modal-wizard .cert-dns-auth').removeClass('hidden');
126 $('.modal-wizard .cert-dns-auth-contents').val(authData.value);
127 $('.modal-wizard .cert-dns-auth-host').val(authData.host);
128 $('.modal-wizard .cert-dns-auth-type').val(authData.type);
129 }
130 }
131
132 if (data.refreshMc) {
133 $('#btnMcServiceRefresh').click();
134 }
135 wizardStepTransition(data.skipNextStep, false);
136 } else {
137 wizardError(data.error);
138 }
139 } catch (err) {
140 wizardError('An error occurred while communicating with the server. Please try again.');
141 } finally {
142 fadeoutLoaderAndAllowSubmission(modal);
143 }
144 } else {
145 alert('An error occurred while communicating with the server. Please try again.');
146 modal.find('.loader').fadeOut();
147 }
148 };
149 }
150 }).on('click', '#btnWizardSkip', function(e) {
151 e.preventDefault();
152 var currentStep = $('#inputWizardStep').val(),
153 skipTwo = false;
154
155 if (currentStep === '2' || currentStep === '4') {
156 skipTwo = true;
157 }
158 wizardStepTransition(skipTwo, true);
159 }).on('click', '#btnWizardBack', function(e) {
160 e.preventDefault();
161 wizardStepBackTransition();
162 }).on('click', '#btnWizardDoNotShow', function(e) {
163 e.preventDefault();
164 WHMCS.http.jqClient.post('wizard.php', 'dismiss=true', function() {
165 //Success or no, still hide now
166 $('#modalAjax').modal('hide');
167 });
168 });
169
170 $('#modalAjax').on('hidden.bs.modal', function (e) {
171 if ($('#modalAjax').hasClass('modal-wizard')) {
172 $('#btnWizardSkip').remove();
173 $('#btnWizardBack').remove();
174 $('#btnWizardDoNotShow').remove();
175 }
176 });
177
178 $('#prodsall').click(function () {
179 var checkboxes = $('.checkprods');
180 checkboxes.filter(':visible').prop('checked', $(this).prop('checked')).end();
181 if ($(this).prop('checked')) {
182 checkboxes.filter(':hidden').prop('checked', !$(this).prop('checked')).end();
183 }
184 });
185 $('#addonsall').click(function () {
186 var checkboxes = $('.checkaddons');
187 checkboxes.filter(':visible').prop('checked', $(this).prop('checked')).end();
188 if ($(this).prop('checked')) {
189 checkboxes.filter(':hidden').prop('checked', !$(this).prop('checked')).end();
190 }
191 });
192 $('#domainsall').click(function () {
193 var checkboxes = $('.checkdomains');
194 checkboxes.filter(':visible').prop('checked', $(this).prop('checked')).end();
195 if ($(this).prop('checked')) {
196 checkboxes.filter(':hidden').prop('checked', !$(this).prop('checked')).end();
197 }
198 });
199
200 jQuery('#addPayment').submit(function (e) {
201 e.preventDefault();
202 addingPayment = false;
203 jQuery('#btnAddPayment').attr('disabled', 'disabled');
204 jQuery('#paymentText').hide();
205 jQuery('#paymentLoading').removeClass('hidden').show();
206
207 var postData = jQuery(this).serialize().replace('action=edit', 'action=checkTransactionId'),
208 post = WHMCS.http.jqClient.post(
209 'invoices.php',
210 postData + '&ajax=1'
211 );
212
213 post.done(function (data) {
214 if (data.unique == false) {
215 jQuery('#modalDuplicateTransaction').modal('show');
216 } else {
217 addInvoicePayment();
218 }
219 });
220 });
221
222 $('#modalDuplicateTransaction').on('hidden.bs.modal', function () {
223 if (addingPayment === false) {
224 jQuery('#paymentLoading').hide('fast', function() {
225 jQuery('#paymentText').show('fast');
226 jQuery('#btnAddPayment').removeAttr('disabled');
227 });
228 }
229 });
230
231 jQuery(document).on('click', '.feature-highlights-content .btn-action-1, .feature-highlights-content .btn-action-2', function() {
232 var linkId = jQuery(this).data('link'),
233 linkTitle = jQuery(this).data('link-title');
234
235 WHMCS.http.jqClient.post(
236 'whatsnew.php',
237 {
238 action: "link-click",
239 linkId: linkId,
240 linkTitle: linkTitle,
241 token: csrfToken
242 }
243 );
244 });
245
246 /**
247 * Admin Tagging
248 */
249 if (typeof mentionsFormat !== "undefined") {
250 jQuery('#replynote[name="message"],#note[name="note"]').atwho({
251 at: "@",
252 displayTpl: "<li class=\"mention-list\">${gravatar} ${username} - ${name} (${email})</li>",
253 insertTpl: mentionsFormat,
254 data: WHMCS.adminUtils.getAdminRouteUrl('/mentions'),
255 limit: 5
256 });
257 }
258
259 jQuery('.search-bar .search-icon').click(function(e) {
260 jQuery('.search-bar').find('input:first').focus();
261 });
262 jQuery('.btn-search-advanced').click(function(e) {
263 jQuery(this).closest('.search-bar').find('.advanced-search-options').slideToggle('fast');
264 });
265
266 // DataTable data-driven auto object registration
267 WHMCS.ui.dataTable.register();
268
269 // Bootstrap Confirmation popup auto object registration
270 WHMCS.ui.confirmation.register();
271
272 var mcProductPromos = jQuery("#mcConfigureProductPromos");
273
274 if (mcProductPromos.length) {
275 var itemCount = mcProductPromos.find('.item').length;
276 mcProductPromos.owlCarousel({
277 loop: true,
278 margin: 10,
279 responsiveClass: true,
280 responsive: {
281 0: {
282 items: 1
283 },
284 850: {
285 items: (itemCount < 2 ? itemCount : 2)
286 },
287 1250: {
288 items: (itemCount < 3 ? itemCount : 3)
289 },
290 1650: {
291 items: (itemCount < 4 ? itemCount : 4)
292 }
293 }
294 });
295
296 jQuery('#dismissPromos').on('click', function() {
297 mcProductPromos.slideUp('fast');
298 jQuery(this).hide();
299 WHMCS.http.jqClient.post(
300 WHMCS.adminUtils.getAdminRouteUrl('/dismiss-marketconnect-promo'),
301 {
302 token: csrfToken
303 },
304 function (data) {
305 //do nothing
306 }
307 );
308 });
309 }
310
311 jQuery(document).on('submit', '#frmCreditCardDeleteDetails', function(e) {
312 e.preventDefault();
313 jQuery('#modalAjax .modal-submit').prop("disabled", true);
314 jQuery('#modalAjax .loader').show();
315 $('#remoteFailureDetails').slideUp();
316 WHMCS.http.jqClient.post(
317 jQuery(this).attr('action'),
318 jQuery(this).serialize(),
319 function(data) {
320 if (!data.error) {
321 updateAjaxModal(data);
322 } else {
323 $('#remoteFailureDetails')
324 .find('.alert').html(data.errorMsg)
325 .end()
326 .slideDown();
327
328 jQuery('#modalAjax .loader').fadeOut();
329 }
330 },
331 'json'
332 ).fail(function() {
333 jQuery('#modalAjax .modal-body').html('An error occurred while communicating with the server. Please try again.');
334 jQuery('#modalAjax .loader').fadeOut();
335 });
336 });
337
338 if (jQuery('.captcha-type').length) {
339 jQuery(document).on('change', '.captcha-type', function() {
340 var settings = jQuery('.recaptchasetts');
341 if (jQuery(this).val() === '') {
342 settings.hide();
343 } else {
344 settings.show();
345 }
346 });
347 }
348
349 if (jQuery('#frmClientSearch').length) {
350 jQuery(document).on('change', '.status', function() {
351 jQuery('#status').val(jQuery(this).val());
352 });
353 }
354
355 jQuery('.ssl-state.ssl-sync').each(function () {
356 var self = jQuery(this);
357 WHMCS.http.jqClient.post(
358 WHMCS.adminUtils.getAdminRouteUrl('/domains/ssl-check'),
359 {
360 'domain': self.data('domain'),
361 'userid': self.data('user-id'),
362 'token': csrfToken
363 },
364 function (data) {
365 self.replaceWith('<img src="' + data.image + '" data-toggle="tooltip" title="' + data.tooltip + '" class="' + data.class + '">');
366 jQuery('[data-toggle="tooltip"]').tooltip();
367 }
368 );
369 });
370
371 (function ($) {
372 $.fn.setInputError = function(error) {
373 this.parents('.form-group').addClass('has-error').find('.field-error-msg').text(error);
374 return this;
375 };
376 })(jQuery);
377
378 (function ($) {
379 $.fn.showInputError = function () {
380 this.parents(".form-group").addClass("has-error").find(".field-error-msg").show();
381 return this;
382 };
383 })(jQuery);
384
385 // Admin datatable row expand functionality
386 jQuery('.datatable .view-detail').click(function(e) {
387 e.preventDefault();
388 $currentRow = jQuery(this).closest('tr');
389 var loader = '<i class="fa fa-spinner fa-spin"></i> Loading...';
390 if (jQuery(this).hasClass('expanded')) {
391 $currentRow.next('tr.detail-row').hide();
392 jQuery(this).removeClass('expanded').find('i').removeClass('fa-minus').addClass('fa-plus');
393 } else {
394 var colCount = $currentRow.find('td').length;
395 if (jQuery(this).hasClass('data-loaded')) {
396 $currentRow.next('tr.detail-row').show();
397 } else {
398 var $newRow = $currentRow.after('<tr class="detail-row"><td colspan="' + colCount + '">' + loader + '</td></tr>');
399 WHMCS.http.jqClient.jsonGet({
400 url: jQuery(this).attr('href'),
401 success: function(response) {
402 $currentRow.next('tr.detail-row').remove();
403 $currentRow.after('<tr class="detail-row"><td colspan="' + colCount + '">' + response.output + '</td></tr>');
404 }
405 });
406 }
407 jQuery(this).find('i').addClass('fa-minus').removeClass('fa-plus');
408 jQuery(this).addClass('expanded').addClass('data-loaded');
409 }
410 });
411 jQuery(document).on('change', '.toggle-display', function() {
412 var showElement = jQuery(this).data('show'),
413 element = jQuery('.' + showElement);
414 jQuery(document).find('div.toggleable').hide();
415 if (element.hasClass('hidden')) {
416 element.removeClass('hidden');
417 }
418 element.show();
419 });
420
421 jQuery(document).on('click', 'button.disable-submit', function(e) {
422 var button = jQuery(this),
423 form = button.closest('form');
424
425 button.prepend('<i class="fas fa-spinner fa-spin"></i> ')
426 .addClass('disabled')
427 .prop('disabled', true);
428
429 form.submit();
430 });
431
432 /**
433 * Resend verification email button handler.
434 */
435 jQuery('#btnResendVerificationEmail').click(function() {
436 var button = $(this);
437 button.prop('disabled', true).html('<i class="fa fa-spinner fa-spin fa-fw"></i> ' + button.html());
438 WHMCS.http.jqClient.jsonPost(
439 {
440 url: window.location.href,
441 data: {
442 token: csrfToken,
443 action: 'resendVerificationEmail',
444 userid: button.data('clientid')
445 },
446 success: function(data) {
447 if (data.success) {
448 button.html(button.data('successmsg'));
449 } else {
450 button.html(button.data('errormsg'));
451 }
452 }
453 }
454 );
455 });
456
457 if (typeof Selectize !== 'undefined') {
458 Selectize.define('whmcs_no_results', function (options) {
459 var self = this;
460 this.search = (function () {
461 var original = self.search;
462
463 return function () {
464 var results = original.apply(this, arguments);
465
466 var isActualItem = function (item) {
467 // item.id may be 'client' - this is an actual item
468 return isNaN(item.id) || item.id > 0;
469 };
470
471 var actualItems = results.items.filter(function (item) {
472 return isActualItem(item);
473 });
474
475 var noResultsItems = results.items.filter(function (item) {
476 return !isActualItem(item);
477 });
478
479 if (actualItems.length > 0) {
480 results.items = actualItems;
481 } else if (noResultsItems.length > 0) {
482 results.items = [noResultsItems[0]];
483 }
484
485 return results;
486 };
487 })();
488 });
489 }
490
491 jQuery('.addon-type[name="atype"]').on('change', function() {
492 fetchModuleSettings(jQuery(this).closest('td').data('addon-id'));
493 processAddonDisplay();
494 });
495
496 jQuery(document).on('change', '.module-action-control', function() {
497 var actionActor = $(this).data('actor');
498 var params = jQuery('.module-action-param-row[data-action-type="' + actionActor + '"]');
499
500 if (parseInt($(this).val())) {
501 params.show();
502 } else {
503 params.hide();
504 }
505 });
506
507 jQuery(document).on('click', '.btn-create-module-action-custom-field', function() {
508 var self = this;
509 var productId = jQuery(self).data('product-id');
510
511 jQuery(self).attr('disabled', 'disabled');
512
513 WHMCS.http.jqClient.jsonPost({
514 url: 'configproducts.php',
515 data: {
516 action: 'create-module-action-custom-field',
517 id: productId,
518 token: csrfToken,
519 field_name: jQuery(self).data('field-name'),
520 field_type: jQuery(self).data('field-type')
521 },
522 success: function (data) {
523 var btnSave = jQuery('#btnSaveProduct');
524
525 if (jQuery(btnSave).attr('disabled')) {
526 jQuery.growl.notice(
527 {
528 title: '',
529 message: data.successMsg
530 }
531 );
532 } else {
533 jQuery(btnSave).trigger('click');
534 }
535 },
536 error: function (data) {
537 jQuery(self).removeAttr('disabled');
538
539 jQuery.growl.warning(
540 {
541 title: '',
542 message: data
543 }
544 );
545 }
546 });
547 });
548
549 jQuery.each(jQuery('table.table-themed.data-driven'), function () {
550 var self = $(this),
551 table = self.DataTable();
552 table.on('preXhr.dt', function (e, settings, data) {
553 var d = document.createElement('div');
554 jQuery(d).css({
555 'background-color': '#fff',
556 'opacity': '0.5',
557 'position': 'absolute',
558 'top': self.offset().top,
559 'left': self.offset().left,
560 'width': self.width() + 2,
561 'height': self.height() + 2,
562 'line-height': self.height() + 'px',
563 'font-size': 40 + 'px',
564 'text-align': 'center',
565 'color': '#000',
566 'border-radius': self.css('border-radius'),
567 'zIndex': 100
568 })
569 .attr('id', self.attr('id') + 'overlay')
570 .html('<strong><i class="fas fa-spinner fa-pulse"></i></strong>');
571 self.before(d);
572 data.token = csrfToken;
573 });
574 table.on('xhr.dt', function ( e, settings, info, xhr ) {
575 jQuery('#' + self.attr('id') + 'overlay').remove();
576 self.removeClass('text-muted');
577 });
578 });
579});
580
581var addingPayment = false,
582 loadedModuleConfiguration = false,
583 addonSupportsFeatures = false;
584
585function updateServerGroups(requiredModule) {
586 var optionServerTypes = '';
587 var doShowOption = false;
588
589 $('#inputServerGroup').find('option:not([value=0])').each(function() {
590 optionServerTypes = $(this).attr('data-server-types');
591
592 if (requiredModule && optionServerTypes) {
593 doShowOption = (optionServerTypes.indexOf(',' + requiredModule + ',') > -1);
594 } else {
595 doShowOption = true;
596 }
597
598 if (doShowOption) {
599 $(this).attr('disabled', false);
600 } else {
601 $(this).attr('disabled', true);
602
603 if ($(this).is(':selected')) {
604 $('#inputServerGroup').val('0');
605 }
606 }
607 });
608}
609
610function processAddonDisplay()
611{
612 var element = jQuery('input[name="atype"]:checked');
613 if (!loadedModuleConfiguration) {
614 setTimeout(processAddonDisplay, 100);
615 return;
616 }
617 var packageList = jQuery('#associatedPackages'),
618 typeAndGroupRows = jQuery('#rowProductType,#rowServerGroup');
619 packageList.find('option').prop('disabled', false);
620 if (addonSupportsFeatures) {
621 jQuery('#addonProvisioningType').find('div.radio').each(function() {
622 $(this).removeClass('radio-disabled').find('input').prop('disabled', false);
623 });
624 }
625 if (element.val() === 'feature') {
626 packageList.find('option[data-server-module!="' + $('#inputModule').val() + '"]')
627 .prop('checked', false)
628 .prop('disabled', true);
629 typeAndGroupRows.find('select').addClass('disabled').prop('disabled', true);
630 } else {
631 packageList.find('option').prop('disabled', false);
632 typeAndGroupRows.find('select').removeClass('disabled').prop('disabled', false)
633 .find('option[value="notAvailable"]').remove();
634 }
635 packageList.bootstrapDualListbox('refresh', true);
636}
637
638function fetchModuleSettings(productId, mode) {
639 var gotValidResponse = false;
640 var dataResponse = '';
641 var switchLink = $('#mode-switch');
642 var module = $('#inputModule').val();
643 var addonProvisioningType = jQuery('#addonProvisioningType');
644
645 if (module === "") {
646 $('#divModuleSettings').html('');
647 $('#noModuleSelectedRow').removeClass('hidden');
648 $('#tblModuleAutomationSettings').find('input[type=radio]').attr('disabled', true);
649 if (addonProvisioningType.length) {
650 jQuery('input[name="atype"]').first().prop('checked', true);
651 addonProvisioningType.find('div.radio').each(function(index) {
652 $(this).addClass('radio-disabled').find('input').prop('disabled', true);
653 });
654 }
655 return;
656 }
657
658 loadedModuleConfiguration = false;
659 mode = mode || 'simple';
660 if (mode !== 'simple' && mode !== 'advanced') {
661 mode = 'simple';
662 }
663 requestedMode = mode;
664 $('#divModuleSettings').addClass('module-settings-loading');
665 $('#tblModuleAutomationSettings').addClass('module-settings-loading');
666 $('#tblMetricSettings').addClass('module-settings-loading');
667 $('#serverReturnedError').addClass('hidden');
668 $('#moduleSettingsLoader').removeClass('hidden').show();
669 switchLink.attr('data-product-id', productId);
670 WHMCS.http.jqClient.post(window.location.pathname, {
671 'action': 'module-settings',
672 'module': module,
673 'servergroup': $('#inputServerGroup').val(),
674 'id': productId,
675 'type': $('#selectType').val(),
676 'atype': $('input[name="atype"]:checked').val(),
677 'mode': mode
678 },
679 function(data) {
680 gotValidResponse = true;
681 $('#divModuleSettings').removeClass('module-settings-loading');
682 $('#tblModuleAutomationSettings').removeClass('module-settings-loading');
683 $('#tblMetricSettings').removeClass('module-settings-loading');
684 $('#divModuleSettings').html('');
685 switchLink.parent('div .module-settings-mode').addClass('hidden');
686 if (module && data.error) {
687 $('#serverReturnedErrorText').html(data.error);
688 $('#serverReturnedError').removeClass('hidden');
689 }
690 if (module && data.content) {
691 $('#noModuleSelectedRow').addClass('hidden');
692 $('#divModuleSettings').html(data.content);
693 $('#tblModuleAutomationSettings').find('input[type=radio]').removeAttr('disabled');
694 if (data.mode === 'simple') {
695 switchLink.attr('data-mode', 'advanced').find('span').addClass('hidden').parent().find('.text-advanced').removeClass('hidden');
696 switchLink.parent('div .module-settings-mode').removeClass('hidden');
697 } else {
698 if (data.mode === 'advanced' && requestedMode === 'advanced') {
699 switchLink.attr('data-mode', 'simple').find('span').addClass('hidden').parent().find('.text-simple').removeClass('hidden');
700 switchLink.parent('div .module-settings-mode').removeClass('hidden');
701 } else {
702 switchLink.parent('div .module-settings-mode').addClass('hidden');
703 }
704 }
705 if (data.metrics) {
706 $('#metricsConfig').html(data.metrics).show();
707 $('#tblMetricSettings').removeClass('hidden').show();
708 $('.metric-toggle').bootstrapSwitch({
709 size: 'mini',
710 onColor: 'success'
711 }).on('switchChange.bootstrapSwitch', function(event, state) {
712 WHMCS.http.jqClient.post($(this).data('url'), 'action=toggle-metric&id=' + $('#inputProductId').val() + '&module=' + module + '&metric=' + $(this).data('metric') + '&token=' + csrfToken + '&enable=' + state);
713 });
714 } else {
715 $('#tblMetricSettings').hide();
716 }
717 if (addonProvisioningType.length) {
718 var packageList = jQuery('#associatedPackages'),
719 selectElements = jQuery('#selectType,#inputServerGroup'),
720 notAvailableOptions = selectElements.find('option[value="notAvailable"]');
721 if (typeof data.supportsFeatures !== 'undefined') {
722 addonSupportsFeatures = data.supportsFeatures;
723 addonProvisioningType.find('div.radio').each(function() {
724 $(this).removeClass('radio-disabled').find('input').prop('disabled', false);
725 });
726 }
727 if (!addonSupportsFeatures) {
728 jQuery('input[name="atype"]').first().prop('checked', true);
729 addonProvisioningType.find('div.radio').each(function() {
730 $(this).addClass('radio-disabled').find('input').prop('disabled', true);
731 });
732 packageList.find('option').prop('disabled', false);
733 selectElements.removeClass('disabled').prop('disabled', false);
734 notAvailableOptions.remove();
735 } else {
736 packageList.find('option').prop('disabled', true);
737 if (jQuery('input[name="atype"]:checked').val() === 'feature') {
738 selectElements.addClass('disabled').prop('disabled', true);
739 if (!notAvailableOptions.length) {
740 selectElements.prepend(
741 $('<option>').val('notAvailable')
742 .text(data.languageStrings['notAvailableForStyle'])
743 .attr('selected', 'selected')
744 );
745 }
746 }
747 }
748 packageList.bootstrapDualListbox('refresh', true);
749 }
750 } else {
751 $('#noModuleSelectedRow').removeClass('hidden');
752 $('#tblModuleAutomationSettings').find('input[type=radio]').attr('disabled', true);
753 }
754 }, "json")
755 .always(function() {
756 $('#moduleSettingsLoader').fadeOut();
757 jQuery('[data-toggle="tooltip"]').tooltip();
758 updateServerGroups(gotValidResponse ? module : '');
759
760 if (!gotValidResponse) {
761 // non json response, likely session expired
762 }
763 loadedModuleConfiguration = true;
764 });
765 return dataResponse;
766}
767
768function wizardCall(action, request, handler) {
769 var requestString = 'wizard=' + $('input[name="wizard"]').val()
770 + '&step=' + $('input[name="step"]').val()
771 + '&token=' + $('input[name="token"]').val()
772 + '&action=' + action
773 + '&' + request;
774
775 WHMCS.http.jqClient.post('wizard.php', requestString, handler);
776}
777
778function wizardError(errorMsg) {
779 WHMCS.ui.effects.errorShake($('.modal-wizard .wizard-step:visible .info-alert:first')
780 .html(errorMsg).removeClass('hidden').addClass('alert-danger'));
781}
782
783function wizardStepTransition(skipNextStep, skip) {
784 var currentStepNumber = $('.modal-wizard .wizard-step:visible').data('step-number');
785 if (skipNextStep) {
786 increment = 2;
787 } else {
788 increment = 1;
789 }
790 var lastStep = $('.modal-wizard .wizard-step:visible');
791 var nextStepNumber = currentStepNumber + increment;
792 if ($('#wizardStep' + nextStepNumber).length) {
793 $('#wizardStep' + currentStepNumber).fadeOut('', function() {
794 var newClass = 'completed';
795 if (skip) {
796 newClass = 'skipped';
797 $('#wizardStepLabel' + currentStepNumber + ' i').removeClass('fa-check-circle').addClass('fa-minus-circle');
798 } else {
799 lastStep.find('.signup-frm').hide();
800 lastStep.find('.signup-frm-success').removeClass('hidden');
801
802 if (currentStepNumber == 3) {
803 lastStep.find('.signup-frm-success')
804 .append('<input type="hidden" id="ccGatewayFormSubmitted" name="ccGatewayFormSubmitted" value="1" />');
805 } else if (currentStepNumber == 5) {
806 lastStep.find('.signup-frm-success')
807 .append('<input type="hidden" id="enomFormSubmitted" name="enomFormSubmitted" value="1" />');
808 }
809
810 }
811
812 if (nextStepNumber > 0) {
813 // Show the BACK button.
814 if (!$('#btnWizardBack').is(':visible')) {
815 $('#btnWizardBack').hide().removeClass('hidden').fadeIn('slow');
816 }
817 } else {
818 $('#btnWizardBack').fadeOut('slow');
819 $('#btnWizardDoNotShow').fadeIn('slow');
820 $('#btnWizardSkip').fadeOut('slow');
821 }
822 $('#wizardStepLabel' + currentStepNumber).removeClass('current').addClass(newClass);
823 $('.modal-wizard .wizard-step:visible :input').attr('disabled', true);
824 $('#wizardStep' + nextStepNumber + ' :input').removeAttr('disabled');
825 $('#wizardStep' + nextStepNumber).fadeIn();
826 $('#inputWizardStep').val(nextStepNumber);
827 $('#wizardStepLabel' + nextStepNumber).addClass('current');
828 });
829 if (!$('#wizardStep' + (nextStepNumber + 1)).length) {
830 $('#btnWizardSkip').fadeOut('slow');
831 $('#btnWizardBack').fadeOut('slow');
832 $('.modal-submit').html('Finish');
833 }
834 } else {
835 // end of steps
836 $('#modalAjax').modal('hide');
837 }
838}
839
840function wizardStepBackTransition() {
841 var currentStepNumber = $('.modal-wizard .wizard-step:visible').data('step-number');
842 var previousStepNumber = parseInt(currentStepNumber) - 1;
843
844 $('#wizardStep' + currentStepNumber).fadeOut('', function() {
845 if (previousStepNumber < 1) {
846 $('#btnWizardBack').fadeOut('slow');
847 $('#btnWizardDoNotShow').fadeIn('slow');
848 $('#btnWizardSkip').addClass('hidden');
849 }
850
851 $('.modal-wizard .wizard-step:visible :input').attr('disabled', true);
852 $('#wizardStep' + previousStepNumber + ' :input').removeAttr('disabled');
853 $('#wizardStep' + previousStepNumber).fadeIn();
854 $('#inputWizardStep').val(previousStepNumber);
855 $('#wizardStepLabel' + previousStepNumber).addClass('current');
856 $('#wizardStepLabel' + currentStepNumber).removeClass('current');
857 });
858}
859
860function fadeoutLoaderAndAllowSubmission(modal) {
861 modal.find('.loader').fadeOut();
862 modal.find('.modal-submit').removeProp('disabled');
863}
864
865function openSetupWizard() {
866 $('#modalFooterLeft').html('<a href="#" id="btnWizardSkip" class="btn btn-link pull-left hidden">Skip Step</a>' +
867 '<a href="#" id="btnWizardDoNotShow" class="btn btn-link pull-left">Do not show this again</a>' +
868 '</div>');
869 $('#modalAjaxSubmit').before('<a href="#" id="btnWizardBack" class="btn btn-default hidden">Back</a>');
870 openModal('wizard.php?wizard=GettingStarted', '', 'Getting Started Wizard', 'modal-lg', 'modal-wizard modal-setup-wizard', 'Next', '', '',true);
871}
872
873function addInvoicePayment() {
874 addingPayment = true;
875 jQuery('#modalDuplicateTransaction').modal('hide');
876 WHMCS.http.jqClient.post(
877 'invoices.php',
878 jQuery('#addPayment').serialize() + '&ajax=1',
879 function (data) {
880 if (data.redirectUri) {
881 window.location = data.redirectUri;
882 }
883 }
884 );
885}
886
887function cancelAddPayment() {
888 jQuery('#paymentLoading').fadeOut('fast', function() {
889 jQuery('#paymentText').fadeIn('fast');
890 jQuery('#btnAddPayment').removeAttr('disabled');
891 });
892 jQuery('#modalDuplicateTransaction').modal('hide');
893}
894
895function openFeatureHighlights() {
896 openModal('whatsnew.php?modal=1', '', 'What\'s new in Version ...', '', 'modal-feature-highlights', '', '', '', true);
897}
898
899/**
900 * Submit the first form that exists within a given container.
901 *
902 * @param {string} containerId The ID name of the container
903 */
904function autoSubmitFormByContainer(containerId) {
905 if (typeof noAutoSubmit === "undefined" || noAutoSubmit === false) {
906 jQuery("#" + containerId).find("form:first").submit();
907 }
908}
909
910/**
911 * Sluggify a text string.
912 */
913function slugify(text) {
914 var search = "āæåãàáäâảẩấćčçđẽèéëêếēėęīįìíïîłńñœøōõòóöôốớơśšūùúüûưÿžźż·/_,:;–"; // contains Unicode dash
915 var replace = "aaaaaaaaaaacccdeeeeeeeeeiiiiiilnnooooooooooossuuuuuuyzzz-------";
916
917 for (var i = 0, l = search.length; i < l; i++) {
918 text = text.replace(new RegExp(search.charAt(i), 'g'), replace.charAt(i));
919 }
920
921 return text
922 .toString()
923 .toLowerCase()
924 .trim()
925 .replace(/\s+/g, '-')
926 .replace(/&/g, '-and-')
927 .replace(/[^\w\-]+/g, '')
928 .replace(/\-\-+/g, '-');
929}
930
931function generateBootstrapSwitches()
932{
933 jQuery('.slide-toggle').bootstrapSwitch();
934 jQuery('.slide-toggle-mini').bootstrapSwitch({
935 size: 'mini'
936 });
937}
938
939function submitForm(frmId, addTarget) {
940 var formTarget = jQuery('#' + frmId);
941 if (addTarget) {
942 formTarget.attr('target', '_blank');
943 } else {
944 formTarget.removeAttr('target');
945 }
946 formTarget.submit();
947}
948
949function reverseCommissionConfirm(totalDue, remainingBalance) {
950 var amountValue,
951 form = jQuery('form#transactions'),
952 formData = form.serializeArray();
953
954 amountValue = formData.find(function (object) {
955 return object['name'] === 'amount';
956 }).value;
957 if (!amountValue) {
958 var transidValue = formData.find(function (object) {
959 return object['name'] === 'transid';
960 }).value;
961 amountValue = jQuery('form#transactions select#transid option[value="' + transidValue + '"]').data('amount');
962 }
963 if ((remainingBalance + amountValue) < totalDue) {
964 jQuery('#modalReverseAffiliateCommission').modal().show();
965 return false;
966 }
967 jQuery(
968 '<input>',
969 {
970 type: 'hidden',
971 name: 'reverseCommission',
972 value: 'true'
973 }
974 ).appendTo(form);
975 form.removeAttr('onsubmit').submit();
976}
977
978function reverseCommissionSubmit(reverseCommission = false) {
979 var form = jQuery('form#transactions');
980
981 if (reverseCommission) {
982 jQuery(
983 '<input>',
984 {
985 type: 'hidden',
986 name: 'reverseCommission',
987 value: 'true'
988 }
989 ).appendTo(form);
990 }
991 form.removeAttr('onsubmit').submit();
992}
993
994function autosizeTextarea(el) {
995 var init = function(el) {
996 var elements = document.querySelectorAll(el)
997 for (var i = 0; i < elements.length; i++) {
998 elements[i].style.overflowX = "hidden"
999 elements[i].style.height = calcHeight(elements[i])
1000 elements[i].addEventListener("input", onInput)
1001 }
1002 };
1003
1004 var onInput = function() {
1005 this.style.height = "auto"
1006 this.style.height = calcHeight(this)
1007 };
1008
1009 var calcHeight = function(el) {
1010 return (el.scrollHeight + parseFloat(jQuery(el).css("borderTopWidth")) + parseFloat(jQuery(el).css("borderBottomWidth"))) + "px"
1011 };
1012
1013 init(el)
1014}
1015