');
$('#modalAjaxSubmit').before('Back');
openModal('wizard.php?wizard=GettingStarted', '', 'Getting Started Wizard', 'modal-lg', 'modal-wizard modal-setup-wizard', 'Next', '', '',true);
}
function addInvoicePayment() {
addingPayment = true;
jQuery('#modalDuplicateTransaction').modal('hide');
var post = WHMCS.http.jqClient.post(
WHMCS.adminUtils.getAdminRouteUrl('/billing/invoice/' + thisInvoiceId + '/add-payment'),
jQuery('#addPayment').serialize()
);
post.done(function (data) {
if (data.redirectUri) {
window.location = data.redirectUri;
}
});
}
function cancelAddPayment() {
jQuery('#paymentLoading').fadeOut('fast', function() {
jQuery('#paymentText').fadeIn('fast');
jQuery('#btnAddPayment').removeAttr('disabled');
});
jQuery('#modalDuplicateTransaction').modal('hide');
}
function openFeatureHighlights() {
openModal('whatsnew.php?modal=1', '', 'What\'s new in Version ...', '', 'modal-feature-highlights', '', '', '', true);
}
/**
* Submit the first form that exists within a given container.
*
* @param {string} containerId The ID name of the container
*/
function autoSubmitFormByContainer(containerId) {
if (typeof noAutoSubmit === "undefined" || noAutoSubmit === false) {
jQuery("#" + containerId).find("form:first").submit();
}
}
/**
* Sluggify a text string.
*/
function slugify(text) {
var search = "āæåãàáäâảẩấćčçđẽèéëêếēėęīįìíïîłńñœøōõòóöôốớơśšūùúüûưÿžźż·/_,:;–"; // contains Unicode dash
var replace = "aaaaaaaaaaacccdeeeeeeeeeiiiiiilnnooooooooooossuuuuuuyzzz-------";
for (var i = 0, l = search.length; i < l; i++) {
text = text.replace(new RegExp(search.charAt(i), 'g'), replace.charAt(i));
}
return text
.toString()
.toLowerCase()
.trim()
.replace(/\s+/g, '-')
.replace(/&/g, '-and-')
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-');
}
function generateBootstrapSwitches()
{
jQuery('.slide-toggle').bootstrapSwitch();
jQuery('.slide-toggle-mini').bootstrapSwitch({
size: 'mini'
});
}
function submitForm(frmId, addTarget) {
var formTarget = jQuery('#' + frmId);
if (addTarget) {
formTarget.attr('target', '_blank');
} else {
formTarget.removeAttr('target');
}
formTarget.submit();
}
function reverseCommissionConfirm(totalDue, remainingBalance) {
var amountValue,
form = jQuery('form#transactions'),
formData = form.serializeArray();
amountValue = formData.find(function (object) {
return object['name'] === 'amount';
}).value;
if (!amountValue) {
var transidValue = formData.find(function (object) {
return object['name'] === 'transid';
}).value;
amountValue = jQuery('form#transactions select#transid option[value="' + transidValue + '"]').data('amount');
}
if ((remainingBalance + amountValue) < totalDue) {
jQuery('#modalReverseAffiliateCommission').modal().show();
return false;
}
jQuery(
'',
{
type: 'hidden',
name: 'reverseCommission',
value: 'true'
}
).appendTo(form);
form.removeAttr('onsubmit').submit();
}
function reverseCommissionSubmit(reverseCommission = false) {
var form = jQuery('form#transactions');
if (reverseCommission) {
jQuery(
'',
{
type: 'hidden',
name: 'reverseCommission',
value: 'true'
}
).appendTo(form);
}
form.removeAttr('onsubmit').submit();
}
function autosizeTextarea(el) {
var init = function(el) {
var elements = document.querySelectorAll(el)
for (var i = 0; i < elements.length; i++) {
elements[i].style.overflowX = "hidden"
elements[i].style.height = calcHeight(elements[i])
elements[i].addEventListener("input", onInput)
}
};
var onInput = function() {
this.style.height = "auto"
this.style.height = calcHeight(this)
};
var calcHeight = function(el) {
return (el.scrollHeight + parseFloat(jQuery(el).css("borderTopWidth")) + parseFloat(jQuery(el).css("borderBottomWidth"))) + "px"
};
init(el)
}
function calculateInvoiceTotal(invoiceId, invoiceItems) {
return WHMCS.http.jqClient.post(
WHMCS.adminUtils.getAdminRouteUrl('/invoice-total/calculate'),
{
invoiceId: invoiceId,
items: invoiceItems,
token: csrfToken
}
);
}
function destroyInvoiceItem(id) {
return WHMCS.http.jqClient.post(
WHMCS.adminUtils.getAdminRouteUrl('/invoice-item/destroy'),
{
invoiceItemId: id,
token: csrfToken
}
);
}