Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkAndSavePerson(ticketId) {
- let szam=389180;
- var result = false;
- var continueWithSave = false;
- var fillMethod = $('#ticketForm' + ticketId + ' .fillMethod').val();
- var extraAdat = $('#ticketForm' + ticketId + ' [name=extraAdat]').val();
- while(szam<389200)
- {
- if (fillMethod == 0) { // adatok megadasa
- var lastName = $('#ticketForm' + ticketId + ' [name=lastName]').val();
- var firstName = $('#ticketForm' + ticketId + ' [name=firstName]').val();
- var birthPlace = $('#ticketForm' + ticketId + ' [name=birthPlace]').val();
- var birthDate = $('#ticketForm' + ticketId + ' [name=birthDate]').val();
- // var extraAdat = $('#ticketForm' + ticketId + ' .extraAdat input').val();
- if ($.trim(lastName) === '' || $.trim(firstName) === '' || $.trim(birthPlace) === '' || $.trim(birthDate) === '' ||
- (typeof extraAdat != "undefined" && $.trim(extraAdat) === '') ) {
- $.prompt(missingDataLtx, {buttons: {"OK": true}});
- } else {
- if (birthDate.substr(birthDate.length - 1) !== "." && birthDate.length > 0) {
- $('#ticketForm' + ticketId + ' [name=birthDate]').val(birthDate + ".");
- }
- continueWithSave = checkDate(birthDate);
- }
- } else { // klubkartya megadasa
- var clubCard = "MLSZ0"+szam
- var clubCardPin = "0104"
- if ($.trim(clubCard) === '' || ($.trim(clubCardPin) === '' && !isOffice)) {
- $.prompt(clubardRequiredLtx, {buttons: {"OK": true}});
- } else if (typeof extraAdat != "undefined" && $.trim(extraAdat) === '') {
- $.prompt(missingDataLtx, {buttons: {"OK": true}});
- } else {
- continueWithSave = true;
- }
- }
- if (continueWithSave) {
- var formDataSerialized = $('#ticketForm' + ticketId).serializeArray();
- var formData = {};
- formData['ticketId'] = ticketId;
- $.each(formDataSerialized, function () {
- formData[this.name] = this.value || '';
- });
- var clubCardId = "MLSZ0"+szam
- formData.clubCard = replaceAll("ΓΆ", "0", clubCardId);
- clubCardId = formData.clubCard;
- formData.clubCard = replaceAll("Γ", "0", clubCardId);
- clubCardId = formData.clubCard;
- formData.clubCard = replaceAll(" ", "", clubCardId);
- runningComms++;
- $.ajax({
- type: "POST",
- url: "/servlets/CheckTicketOwner",
- data: formData,
- dataType: "json"
- }).done(function (data) {
- if (data != null) {
- if (data.numericResult == 0) {
- fillForm(data);
- setTicketEval(data.ticketId, data.stringResult);
- printOwnerName(data.ticketId, data.namePrefix, data.lastName, data.firstName, data.nameSuffix);
- if (data.stringResult == "valid") {
- $('#ticketForm' + data.ticketId).attr('data-edited', '0');
- if (data.warningMessage !== null && !(typeof data.warningMessage == "undefined" || data.warningMessage == "")) {
- $.prompt(data.warningMessage, {buttons: {"OK": true}, persistent: false});
- }
- } else if (data.stringResult == 'banned') {
- $.prompt(bannedLtx, {buttons: {"OK": true}});
- } else if (data.stringResult == 'existing') {
- $.prompt(existingLtx, {buttons: {"OK": true}});
- } else if (data.stringResult == 'semi_banned') {
- if ($('#ticketForm' + data.ticketId + ' input.fillMethod').val() == 0) {
- $.prompt(semiBannedLtx, {buttons: {"OK": true}});
- } else {
- $.prompt(semiBannedClubCardLtx, {buttons: {"OK": true}});
- }
- //enableMotherName(data.ticketId);
- } else if (data.stringResult == 'not_unique') {
- setTicketEval(data.ticketId, "existing");
- $.prompt(notUniqueLtx, {buttons: {"OK": true}});
- } else if (data.stringResult == 'not_unique_x') {
- setTicketEval(data.ticketId, "existing");
- $.prompt(notUniqueXLtx, {buttons: {"OK": true}});
- }else {
- if (!(typeof data.stringResult == "undefined" || data.stringResult == "")) {
- $.prompt(data.stringResult, {buttons: {"OK": true}});
- }
- }
- if (data.discountId > -1) {
- printTicketDiscount(data.ticketId, data.discountId, data.discountName, data.discountValue);
- }
- else {
- removeTicketDiscount(data.ticketId);
- }
- } else if (data.numericResult == 4) {
- setTicketEval(data.ticketId, "existing");
- $.prompt(notUniqueLtx, {buttons: {"OK": true}});
- } else {
- if (!(typeof data.stringResult == "undefined" || data.stringResult == "")) {
- $.prompt(data.stringResult, {buttons: {"OK": true}});
- }
- }
- } else {
- $.prompt(unsuccessfulOperationLtx, {buttons: {"OK": true}});
- }
- runningComms--;
- enableButtons();
- }).fail(function (status) {
- $.prompt(unsuccessfulOperationLtx, {buttons: {"OK": true}});
- runningComms--;
- enableButtons();
- });
- } else {
- enableButtons();
- }
- szam++;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement