232 lines
6.9 KiB
JavaScript
232 lines
6.9 KiB
JavaScript
$(document).ready(function () {
|
|
$('.form-control-number').on('keydown', function (e) {
|
|
const allowedKeys = [
|
|
'Backspace', 'Tab', 'Escape', 'Enter', 'ArrowLeft', 'ArrowRight',
|
|
'ArrowUp', 'ArrowDown', 'Delete', 'Home', 'End'
|
|
];
|
|
|
|
if (allowedKeys.includes(e.key) || (e.key === 'a' && (e.ctrlKey || e.metaKey))) {
|
|
return;
|
|
}
|
|
|
|
if (!/^\d$/.test(e.key)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
var amount = parseFloat($("#Amount").val().replace(/٬/g, ''));
|
|
var amountRials = wordifyRials(amount);
|
|
var amountTomans = wordifyRialsInTomans(amount);
|
|
$('#amountRials').text(amountRials);
|
|
$('#amountTomans').text(amountTomans);
|
|
|
|
$('#Amount').keyup(function () {
|
|
var amount = $(this).val();
|
|
var amountRials = wordifyRials(amount);
|
|
var amountTomans = wordifyRialsInTomans(amount);
|
|
$('#amountRials').text(amountRials);
|
|
$('#amountTomans').text(amountTomans);
|
|
});
|
|
|
|
$(".form-control-currency").each(function () {
|
|
let element = $(this);
|
|
element.on('input', function () {
|
|
let value = convertPersianNumbersToEnglish(element.val());
|
|
element.val(value);
|
|
});
|
|
|
|
new Cleave(this, {
|
|
numeral: true,
|
|
numeralThousandsGroupStyle: 'thousand'
|
|
});
|
|
});
|
|
|
|
$(".form-control-date").each(function () {
|
|
let element = $(this);
|
|
element.on('input', function () {
|
|
let value = convertPersianNumbersToEnglish(element.val());
|
|
element.val(value);
|
|
});
|
|
|
|
new Cleave(this, {
|
|
date: true,
|
|
delimiter: '/',
|
|
datePattern: ['Y', 'm', 'd']
|
|
});
|
|
});
|
|
});
|
|
|
|
$(document).on('click', '.FineTitleSearch', function () {
|
|
searchResulTitle.html('');
|
|
let searchTextTitle = $(this).val();
|
|
|
|
$.ajax({
|
|
contentType: 'charset=utf-8',
|
|
dataType: 'json',
|
|
type: 'GET',
|
|
url: searchFineSubjectModal,
|
|
data: { "searchSubject": searchTextTitle },
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
success: function (response) {
|
|
if (response.list.length > 0) {
|
|
containerTitle.show();
|
|
$.each(response.list,
|
|
function (i, item) {
|
|
let li = `<li class="li-subject" onclick="selectItemTitle('${item.subject}');">${item.subject}</li>`;
|
|
searchResulTitle.append(li);
|
|
});
|
|
} else {
|
|
containerTitle.hide();
|
|
}
|
|
}
|
|
|
|
});
|
|
});
|
|
|
|
// نمایش عنوان دلبخواه
|
|
var containerTitle = $('#FineTitle');
|
|
var searchBoxTitle = $('.FineTitleSearch');
|
|
var searchResulTitle = $('.searchTitleResult');
|
|
var mixContainerAndSerchResultTitle = $('#FineTitle , .searchTitleResult');
|
|
|
|
containerTitle.hide();
|
|
var liListTitle;
|
|
var liPointerTitle;
|
|
var countTitle = 0;
|
|
|
|
//close search Employee when click on body
|
|
//$(document).on('click', function (event) {
|
|
// if (!$(event.target).closest(container).length) {
|
|
// containerTitle.hide();
|
|
// }
|
|
//});
|
|
|
|
$(document).on('keydown', function (event) {
|
|
if (event.keyCode === 9) {
|
|
$('#FineTitle').hide();
|
|
}
|
|
});
|
|
function searchSubjectFine() {
|
|
var input, filter, tbody, tr, i, td, containerResult;
|
|
input = document.getElementsByClassName("ModelTitle");
|
|
filter = input.value.toUpperCase();
|
|
tbody = document.getElementById("searchTitleResult");
|
|
tr = tbody.getElementsByClassName("li-subject");
|
|
|
|
var hasVisibleResults = false;
|
|
|
|
for (i = 0; i < tr.length; i++) {
|
|
td = tr[i];
|
|
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
|
|
tr[i].style.display = "";
|
|
hasVisibleResults = true;
|
|
} else {
|
|
tr[i].style.display = "none";
|
|
}
|
|
}
|
|
|
|
containerResult = document.getElementById("FineTitle");
|
|
if (hasVisibleResults) {
|
|
containerResult.style.display = "block";
|
|
} else {
|
|
containerResult.style.display = "none";
|
|
}
|
|
}
|
|
// نمایش عنوان دلبخواه
|
|
|
|
function fineSubjectModal() {
|
|
var goTo = `#showmodal=${fineSubjectModal}`;
|
|
window.location.href = goTo;
|
|
}
|
|
|
|
|
|
$('#createData').on('click', SaveDataAjax);
|
|
function SaveDataAjax() {
|
|
var loading = $('#createData .spinner-loading');
|
|
|
|
var Title = $('#Title ');
|
|
var Amount = $('#Amount ');
|
|
var FineDate = $('#FineDate');
|
|
|
|
if (!Title.val()) {
|
|
Title.addClass('errored');
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('لطفا عنوان را وارد نمائید');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
Title.removeClass('errored');
|
|
}, 3500);
|
|
return;
|
|
}
|
|
|
|
if (!Amount.val() || Amount.val() === "0") {
|
|
Amount.addClass('errored');
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('لطفا مبلغ را وارد نمائید');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
Amount.removeClass('errored');
|
|
}, 3500);
|
|
return;
|
|
}
|
|
|
|
if (!FineDate.val()) {
|
|
FineDate.addClass('errored');
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text('لطفا تاریخ را مشخص نمائید');
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
FineDate.removeClass('errored');
|
|
}, 3500);
|
|
return;
|
|
}
|
|
|
|
$('#createData').addClass('disable');
|
|
|
|
var data = $('#create-form').serialize();
|
|
$.ajax({
|
|
async: false,
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
url: saveEditFineAjax,
|
|
headers: { "RequestVerificationToken": antiForgeryToken },
|
|
data: data,
|
|
success: function (response) {
|
|
if (response.success) {
|
|
loading.show();
|
|
$('.alert-success-msg').show();
|
|
$('.alert-success-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-success-msg').hide();
|
|
$('.alert-success-msg p').text('');
|
|
}, 1500);
|
|
|
|
$('#fineListAjax').html('');
|
|
$('#PageIndex').val(0);
|
|
pageIndexJs = 0;
|
|
loadFineList();
|
|
|
|
loading.hide();
|
|
$('#MainModal').modal('hide');
|
|
} else {
|
|
$('.alert-msg').show();
|
|
$('.alert-msg p').text(response.message);
|
|
setTimeout(function () {
|
|
$('.alert-msg').hide();
|
|
$('.alert-msg p').text('');
|
|
}, 3500);
|
|
|
|
loading.hide();
|
|
$('#createData').removeClass('disable');
|
|
}
|
|
},
|
|
error: function (err) {
|
|
loading.hide();
|
|
$('#createData').removeClass('disable');
|
|
console.log(err);
|
|
}
|
|
});
|
|
} |