Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.88 KB | None | 0 0
  1. function checkAndSavePerson(ticketId) {
  2.     let szam=389180;
  3.  
  4.     var result = false;
  5.  
  6.     var continueWithSave = false;
  7.     var fillMethod = $('#ticketForm' + ticketId + ' .fillMethod').val();
  8.  
  9.     var extraAdat = $('#ticketForm' + ticketId + ' [name=extraAdat]').val();
  10.    
  11.     while(szam<389200)
  12.     {
  13.     if (fillMethod == 0) { // adatok megadasa
  14.         var lastName = $('#ticketForm' + ticketId + ' [name=lastName]').val();
  15.         var firstName = $('#ticketForm' + ticketId + ' [name=firstName]').val();
  16.         var birthPlace = $('#ticketForm' + ticketId + ' [name=birthPlace]').val();
  17.         var birthDate = $('#ticketForm' + ticketId + ' [name=birthDate]').val();
  18. //        var extraAdat = $('#ticketForm' + ticketId + ' .extraAdat input').val();
  19.  
  20.  
  21.         if ($.trim(lastName) === '' || $.trim(firstName) === '' || $.trim(birthPlace) === '' || $.trim(birthDate) === '' ||
  22.                 (typeof extraAdat != "undefined" && $.trim(extraAdat) === '') ) {
  23.             $.prompt(missingDataLtx, {buttons: {"OK": true}});
  24.         } else {
  25.             if (birthDate.substr(birthDate.length - 1) !== "." && birthDate.length > 0) {
  26.                 $('#ticketForm' + ticketId + ' [name=birthDate]').val(birthDate + ".");
  27.             }
  28.             continueWithSave = checkDate(birthDate);
  29.         }
  30.     } else { // klubkartya megadasa
  31.         var clubCard = "MLSZ0"+szam
  32.         var clubCardPin = "0104"
  33.         if ($.trim(clubCard) === '' || ($.trim(clubCardPin) === '' && !isOffice)) {
  34.             $.prompt(clubardRequiredLtx, {buttons: {"OK": true}});
  35.         } else if (typeof extraAdat != "undefined" && $.trim(extraAdat) === '') {
  36.             $.prompt(missingDataLtx, {buttons: {"OK": true}});
  37.         } else {
  38.             continueWithSave = true;
  39.         }
  40.     }
  41.  
  42.     if (continueWithSave) {
  43.         var formDataSerialized = $('#ticketForm' + ticketId).serializeArray();
  44.         var formData = {};
  45.  
  46.         formData['ticketId'] = ticketId;
  47.         $.each(formDataSerialized, function () {
  48.             formData[this.name] = this.value || '';
  49.         });
  50.  
  51.         var clubCardId = "MLSZ0"+szam
  52.         formData.clubCard = replaceAll("ΓΆ", "0", clubCardId);
  53.         clubCardId = formData.clubCard;
  54.         formData.clubCard = replaceAll("Γ–", "0", clubCardId);
  55.         clubCardId = formData.clubCard;
  56.         formData.clubCard = replaceAll(" ", "", clubCardId);
  57.  
  58.         runningComms++;
  59.         $.ajax({
  60.             type: "POST",
  61.             url: "/servlets/CheckTicketOwner",
  62.             data: formData,
  63.             dataType: "json"
  64.         }).done(function (data) {
  65.             if (data != null) {
  66.                 if (data.numericResult == 0) {
  67.                     fillForm(data);
  68.                     setTicketEval(data.ticketId, data.stringResult);
  69.                     printOwnerName(data.ticketId, data.namePrefix, data.lastName, data.firstName, data.nameSuffix);
  70.  
  71.                     if (data.stringResult == "valid") {
  72.                         $('#ticketForm' + data.ticketId).attr('data-edited', '0');
  73.                         if (data.warningMessage !== null && !(typeof data.warningMessage == "undefined" || data.warningMessage == "")) {
  74.                             $.prompt(data.warningMessage, {buttons: {"OK": true}, persistent: false});
  75.                         }                        
  76.                     } else if (data.stringResult == 'banned') {
  77.                         $.prompt(bannedLtx, {buttons: {"OK": true}});
  78.                     } else if (data.stringResult == 'existing') {
  79.                         $.prompt(existingLtx, {buttons: {"OK": true}});
  80.                     } else if (data.stringResult == 'semi_banned') {
  81.                         if ($('#ticketForm' + data.ticketId + ' input.fillMethod').val() == 0) {
  82.                             $.prompt(semiBannedLtx, {buttons: {"OK": true}});
  83.                         } else {
  84.                             $.prompt(semiBannedClubCardLtx, {buttons: {"OK": true}});
  85.                         }
  86.                         //enableMotherName(data.ticketId);
  87.                     } else if (data.stringResult == 'not_unique') {
  88.                         setTicketEval(data.ticketId, "existing");
  89.                         $.prompt(notUniqueLtx, {buttons: {"OK": true}});
  90.                     } else if (data.stringResult == 'not_unique_x') {
  91.                         setTicketEval(data.ticketId, "existing");
  92.                         $.prompt(notUniqueXLtx, {buttons: {"OK": true}});
  93.                     }else {
  94.                         if (!(typeof data.stringResult == "undefined" || data.stringResult == "")) {
  95.                             $.prompt(data.stringResult, {buttons: {"OK": true}});
  96.                         }
  97.                     }
  98.  
  99.                     if (data.discountId > -1) {
  100.                         printTicketDiscount(data.ticketId, data.discountId, data.discountName, data.discountValue);
  101.                     }
  102.                     else {
  103.                         removeTicketDiscount(data.ticketId);
  104.                     }
  105.                 } else if (data.numericResult == 4) {
  106.                     setTicketEval(data.ticketId, "existing");
  107.                     $.prompt(notUniqueLtx, {buttons: {"OK": true}});
  108.                 } else {
  109.                     if (!(typeof data.stringResult == "undefined" || data.stringResult == "")) {
  110.                         $.prompt(data.stringResult, {buttons: {"OK": true}});
  111.                     }
  112.                 }
  113.             } else {
  114.                 $.prompt(unsuccessfulOperationLtx, {buttons: {"OK": true}});
  115.             }                    
  116.             runningComms--;
  117.             enableButtons();
  118.         }).fail(function (status) {
  119.             $.prompt(unsuccessfulOperationLtx, {buttons: {"OK": true}});
  120.             runningComms--;
  121.             enableButtons();
  122.         });
  123.     } else {
  124.         enableButtons();
  125.     }
  126.             szam++;
  127.     }
  128.    
  129.     return result;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement