EngineGP/template/js/sections/services/crmp.js
Sergei Solovev b59003e559 Reformat code
This update contains code reformatting to meet PHP standards.
2023-11-12 21:12:42 +03:00

64 lines
2.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$('#crmp').ajaxForm({
dataType: 'json',
success: function (data) {
$.each(data, function (i, val) {
if (i == 'e')
bootbox.dialog('<h3 class="red">Ошибка</h3>' + val,
[{
"label": "Продолжить",
}]
);
if (i == 's')
location.href = home + 'servers/id/' + data['id'];
});
loading(0);
}
});
function change_data(data) {
$.getJSON('services/section/crmp/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/get/' + data, function (arr) {
$.each(arr, function (id, val) {
$('#' + id).html(val);
});
upd_price();
promo();
});
}
function upd_price() {
$.getJSON('services/section/crmp/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/get/price', function (arr) {
$.each(arr, function (id, val) {
$('#' + id).html(val);
});
promo();
});
}
function promo() {
if ($('#promo').val() == '') {
$('#promo_tr').css('display', 'none');
$('#sum_info').css('text-decoration', 'none');
return false;
}
$.getJSON('services/section/crmp/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/cod/' + $('#promo').val() + '/get/promo', function (arr) {
$('#promo_tr').css('display', 'table-row');
if (arr['e'] != undefined) {
$('#promo_info').html(arr['e']);
$('#sum_info').css('text-decoration', 'none');
} else {
if (arr['discount'] == 1) {
$('#sum_info').css('text-decoration', 'line-through');
$('#promo_info').html('Цена с учетом промо-кода: ' + arr['sum'] + ' ' + arr['cur']);
} else {
$('#sum_info').css('text-decoration', 'none');
$('#promo_info').html('Подарочные дни: ' + arr['days']);
}
}
});
}