1function Payment() 2{ 3 this.url = '/Ajax/Payment'; 4 this.detailLevelCollection = ['5', '6', '13', '49', '50', '54', '55', '56', '67', '90', '91', '138']; //CRS only ids: 49, 5, 67 5 this.negativeAllowed = ['5', '6', '13', '8', '45', '49', '54', '55', '56', '65', '67', '69', '71', '72', '73', '74', '75', '83', '90', '91', '102', '103']; 6 this.posPaymentType = ['1', '2', '3', '4']; 7 this.keepSign = ['13', '91']; 8 this.allowOverpayment = ['49', '90']; 9 10 this.displayPayment = function(systemID, keyID, displayType, fromWhere, modal) 11 { 12 $.post(this.url, 13 { 14 'action' : 'displayPayment', 15 'keyID' : keyID, 16 'systemID' : systemID, 17 'displayType' : displayType 18 }, 19 function(data) 20 { 21 var openModal = $('#paymentamount').length && $('#paymentForm').length ? $('#paymentForm').closest('.modal') : null; 22 23 if (typeof modal !== typeof undefined) { 24 openModal = modal; 25 } 26 27 var $m = mobileModalEdit(openModal, 'Apply Payment: ' + data.KEY_NBR + ' - ' + data.UNIT_ALL + '', data.OUTPUT, 28 { 29 "Cancel" :'', 30 "Save Payment": function() 31 { 32 payment.savePayment($m, systemID, keyID, "Save Payment", ( $('#sendEmailChkbox:checked').length ? 1 : 0 ), fromWhere); 33 }, 34 },'','large'); 35 }, 'json'); 36 }; 37 38 this.getAttendeeList = function(paymentType) 39 { 40 var idString = ''; 41 42 switch (paymentType) 43 { 44 case '82': 45 idString = 'lateFeeStringReverse'; 46 break; 47 case '83': 48 idString = 'earlyDiscountStringReverse'; 49 break; 50 case '84': 51 idString = 'lateFeeString'; 52 break; 53 case '85': 54 idString = 'earlyDiscountString'; 55 break; 56 } 57 58 var discountArray='', attendeeArray='', attendeeList=''; 59 discountArray = $('#' + idString).val().split('@'); 60 61 for (var i=0; i<discountArray.length; i++) 62 { 63 attendeeArray=discountArray[i].split('#'); 64 if ($('#payAmt' + attendeeArray[0]).length > 0 && parseFloat($('#payAmt' + attendeeArray[0]).val()) != 0) 65 { 66 attendeeList +=attendeeArray[0] + ", "; 67 } 68 } 69 70 if (attendeeList > '') 71 attendeeList = attendeeList.slice(0,-2); 72 73 return attendeeList; 74 75 }; 76 77 this.savePayment = function($m, systemID, keyID, btnName, sendEmail, fromWhere) 78 { 79 this.changeButtonStatus(btnName, 'disable'); 80 81 var paymenttype = $('#paymenttype').val(); 82 var paymentAmount = parseFloat($('#paymentamount').val()); 83 var payIds = ''; 84 //When on the payment screen there is another input with the name payIds under div attendeePayNowSection 85 if ($('#feeScheduleAreaPayment').find('input#payIds').length > 0) { 86 payIds = $('#feeScheduleAreaPayment input#payIds').val(); 87 } else { 88 payIds = $("#payIds").length > 0 && paymenttype != "60" ? $("#payIds").val() : ''; 89 } 90 91 var totalCollected = 0, 92 payAmt = 0, 93 customFee = 0, 94 refundPendingInfo = '', 95 payIdAmt = '', 96 serviceFee = 0, 97 changedPayIds = [], 98 refundValid = 1; 99 100 var useAttendeeList = ['82', '83', '84', '85']; 101 var attendeeList = useAttendeeList.indexOf( paymenttype ) > -1 ? payment.getAttendeeList(paymenttype) : ''; 102 103 var skipAdditionalFeeDetail = ['102', '103']; 104 if ( ( this.detailLevelCollection.indexOf( paymenttype ) > -1 && paymenttype != '13') 105 || ( paymenttype == 13 && skipAdditionalFeeDetail.indexOf($('#extraInfo13').val() ) == -1 ) ) 106 { 107 //itemPay itemKeyID 108 var keys = $('input[name = "itemKeyID[]"]'); 109 $('input[name = "itemPay[]"]').each(function(i) 110 { 111 if ($(this).val() != 0 && $(this).val() > '') 112 { 113 payIdAmt += $( keys[i] ).val() + ":" + $(this).val() + ":" + $(this).attr('data-bal') + ":" + $(this).attr('data-custom') + "@"; 114 totalCollected+= parseFloat($(this).val()); 115 if (paymenttype == 56) 116 { 117 changedPayIds.push([$('#extraInfo56').val(), $(this).val()]); 118 } 119 } 120 }); 121 122 var t=Math.round(totalCollected * 100) / 100; 123 totalCollected=t.toFixed(2); 124 } 125 else if (payIds > '' && paymenttype != 60 ) 126 { 127 var payIdsArray = payIds.split('@'), 128 regID = 0, 129 balanceDue = 0, 130 payAmt = 0, 131 customFee = 0; 132 for (var c=0; c< payIdsArray.length; c++) 133 { 134 regID = payIdsArray[c]; 135 balanceDue=encodeURIComponentCustom(document.getElementById("balanceDue"+regID).value); 136 //jlm 2020-09-22 not switching to use below so we don't get Na/na on the totalCollected payAmt=encodeURIComponentCustom(document.getElementById("payAmt"+regID).value); 137 138 if ($('#feeScheduleAreaPayment').find('input#payAmt' + regID).length > 0) { 139 payAmt = $('#feeScheduleAreaPayment input#payAmt' + regID).val() == '' ? 0 : $('#feeScheduleAreaPayment input#payAmt' + regID).val(); 140 } else { 141 payAmt = $("#payAmt" + regID).val() == '' ? 0 : $("#payAmt" + regID).val(); 142 } 143 144 if (document.getElementById("attendeeCustomFee"+regID)) customFee = encodeURIComponentCustom(document.getElementById("attendeeCustomFee"+regID).value); 145 else customFee=0; 146 payIdAmt += regID+":"+payAmt+":"+balanceDue+":"+customFee+"@"; 147 totalCollected+= parseFloat(payAmt); 148 } 149 var t=Math.round(totalCollected*100)/100; 150 totalCollected=t.toFixed(2); 151 } 152 else 153 totalCollected = paymentAmount; 154 155 if (paymenttype==53) 156 { 157 158 if ($('#BillingLName').val()=='' 159 || $('#BillingLName').val()=='' 160 || $('#BillingAddress').val()=='' 161 || $('#BillingCity').val()=='' 162 || $('#BillingZip').val()=='' 163 || $('#BillingEmail').val()=='' 164 || $('#BillingPhone').val()=='' 165 || $('#refundReason').val() == 0 166 || $('#refundType').val()==0) 167 { 168 refundValid=0; 169 } 170 } 171 172 var payments = Array.from($('input[name="payAmtUnused[]"]')).filter(function (e) { 173 return $(e).val() != 0 && $(e).val() > ''; 174 }).map(function (e) { 175 return [$(e).data('payid'), $(e).val()]; 176 });
177 178 if ($("#serviceFee").length) 179 { 180 var validServiceFeePayIds = ['1', '2', '3', '4']; 181 if (validServiceFeePayIds.indexOf( paymenttype) == -1 ) 182 { 183 $("#serviceFee").val(0); 184 } 185 } 186 187 var callApplyPayment = function() 188 { 189 190 $('#paymentForm :input').removeAttr('disabled'); 191 192 $.post(payment.url, $.param( 193 { 194 'action' : 'savePayment', 195 'systemID' : systemID, 196 'keyID' : keyID, 197 'attendeeList' : attendeeList, 198 'payIdAmt' : payIdAmt, 199 'payments' : payments, 200 'sendEmail' : sendEmail, 201 'serviceFee' : serviceFee, 202 'changedPayIds' : changedPayIds, 203 'refundValid' : refundValid 204 }) + "&" + $('#paymentForm :input').serialize() 205 + "&" + $('#extraDataCollection :input').serialize(), 206 function(data) 207 { 208 if(data.ERROR > '') 209 { 210 alert(data.ERROR); 211 payment.changeButtonStatus(btnName, 'enable'); 212 } 213 else if (systemID == 1 && fromWhere == 'EDIT') //jlm 2020-12-28 don't want to ask the add another question when coming from Cancel processing ... but both Apply Payment from within registration and cancel are 'fromWhere' = 'EDIT' 214 { 215 crsresedit.updatePaymentSummaryArea(keyID); 216 mobileModalClose($m); 217 } 218 else 219 { 220 $m = mobileModalEdit($m, 'Payment Added Successfully', 'Do you want to add another?', 221 { 222 'No Thanks' : '', 223 'Add Another' : function() 224 { 225 payment.displayPayment(systemID, keyID, 'FULL', fromWhere, $m); 226 } 227 }, 228 function() 229 { 230 if (systemID == 2) 231 { 232 if (fromWhere == 'editRegistration') { 233 ses.changeSummaryPage(keyID, 'admin', '2'); 234 } else if (fromWhere == 'postDates') { 235 $('#searchPostDateFrm').click(); 236 } else 237 displayRegistrationContent(orgKey, mdmUser_ID,saveEventInstanceID); //saveEventInstanceID is a global field filled when this section is displayed 238 } 239 else if (systemID == 6) 240 { 241 updateEventContentKeys('order'); 242 } 243 else 244 { 245 if (fromWhere == 'EDIT') 246 crsresedit.updatePaymentSummaryArea(keyID);//update finance panel 247 else if (fromWhere == 'SEARCH') 248 crsressearch.displayCRSSearchContent(); 249 } 250 }, 251 'small' 252 ); 253 } 254 }, 'json'); 255 }; 256 257 258 if($('#payeename').val() == '' || $('#paymenttype').val() == '' || $('#paymentamount').val() == '') 259 { 260 var missing = $('#payeename').val() == '' ? 'Payor Name<br />' : ''; 261 missing += $('#paymenttype').val() == '' ? 'Payment Type<br />' : ''; 262 missing += $('#paymentamount').val() == '' ? 'Payment Amount<br />' : ''; 263 264 custom_response_alert('Missing Information', missing + "<br /><b class=textBSABlue >Please enter missing information.</b>"); 265 this.changeButtonStatus(btnName, 'enable');; 266 } 267 else 268 { 269 if (this.validatePaymentTypeInput(totalCollected)) 270 { 271 var allowedOverage = ['1', '2', '3', '4', '81']; 272 273 if ( paymentAmount != parseFloat(totalCollected) ) 274 { 275 if ( paymentAmount < parseFloat(totalCollected) && paymenttype != 55 ) 276 { 277 custom_response_alert('Invalid Payment Amount', "Payment Allocations cannot be greater than the Payment Amount"); 278 } 279 else if (paymenttype == '53') 280 { 281 if ( parseFloat(paymentAmount) + parseFloat($("#totalUnusedCredit53").val()) > 0) 282 custom_response_alert('Invalid Payment Amount', "Payment amount is greater than the unallocated credit. Only unallocated credit can be moved to refund processing."); 283 else 284 callApplyPayment(); 285 } 286 else if (paymenttype == '55') 287 { 288 if ( parseFloat(totalCollected) + parseFloat($("#totalUnusedCredit53").val()) > parseFloat(paymentAmount)) 289 custom_response_alert('Additional Funds Needed', "Payment allocations + unused credit is less than payment amount being reversed. Use 'Reallocate Payment' to move money off participants so the transaction can then be reversed.
289<br><br>If there are not enough funds remaining on participants, contact Black Pug Software for assistance."); 290 else 291 callApplyPayment(); 292 } 293 else if (allowedOverage.indexOf( paymenttype ) > -1) 294 { 295 var overage = parseFloat(paymentAmount) - parseFloat(totalCollected); 296 $mm = mobileModal('Amount is over allocation', "\"Payment Amount\" is <u class=missingrequired>greater than</u> \"Paying Now\" total.<br><br><b>If you continue, the additional " + global.formatMoney(overage) + "<b> will be added to Unallocated Credit.", 297 { 298 'Cancel' : function() 299 { 300 payment.changeButtonStatus(btnName, 'enable'); 301 mobileModalClose($mm); 302 }, 303 'Continue' : function() 304 { 305 callApplyPayment(); 306 mobileModalClose($mm); 307 } 308 }); 309 } 310 else 311 { 312 custom_response_alert('Invalid Amount', "Payment Amount must equal amount being applied to participants"); 313 } 314 } 315 else if (paymenttype == 53 && $('#refundReason').val() == 0) { 316 custom_response_alert("Refund Reason", "<br />Refund Reason is required. Please select a reason for refunding the payment."); 317 } 318 else { 319 callApplyPayment(); 320 } 321 } 322 else 323 this.changeButtonStatus(btnName, 'enable'); 324 } 325 }; 326 327 this.selectPayment = function(selected, systemID) 328 { 329 var registrantRows = $('tr[name=registrantRow]'); 330 registrantRows.each(function() 331 { 332 var pay = $(this).find('input[name="payment'+selected.val()+'"]'); 333 var input = $(this).find('input[name="itemPay[]"]'); 334 335 if (selected.val() == '0') 336 { 337 $(this).hide(); 338 } else 339 { 340 $(this).show(); 341 } 342 343 if (pay.length > 0) 344 { 345 $(this).find('td[name="reallocateAmt"]').html('$'+pay.val()); 346 input.data('currentamt', pay.val()); 347 } else 348 { 349 $(this).find('td[name="reallocateAmt"]').html('$0'); 350 input.data('currentamt', '0'); 351 } 352 353 if(input.val() != '') 354 { 355 input.val(''); 356 payment.checkPayAmt(input, systemID); 357 } 358 }); 359 if (selected.val() == '0') 360 { 361 $('#warningRow').show(); 362 $('#unallocatedAmount').html('0.00'); 363 } else 364 { 365 $('#warningRow').hide(); 366 $('#unallocatedAmount').html($('option:selected', selected).data('unallocated')); 367 } 368 }; 369 370 this.showPayHistory = function(regId, attendeeId) 371 { 372 var postdata = 373 { 374 'action': 'showPayHistory', 375 'regId': regId, 376 'attendeeId': attendeeId 377 }; 378 $.post(payment.url, postdata, function(data) 379 { 380 $m = mobileModal('Payment History', data, 381 { 382 'Close': '' 383 }); 384 }); 385 }; 386 387 this.changeButtonStatus = function(btnName, action) 388 { 389 if (action == 'disable') 390 $(".ui-dialog-buttonpane button:contains('" + btnName + "')").attr("disabled", true).addClass("ui-state-disabled"); 391 else 392 $(".ui-dialog-buttonpane button:contains('" + btnName + "n')").removeAttr('disabled').removeClass( 'ui-state-disabled' ); 393 394 }; 395 396 this.validatePaymentTypeInput = function(totalCollected) 397 { 398 var paymentTypeID = $('#paymenttype').val(); 399 var paymentAmount = parseFloat($('#paymentamount').val()); 400 var msg = ''; 401 402 if (paymentTypeID == 0) 403 { 404 msg += "Please select a payment type<br>"; 405 } 406 407 var attendee = ''; //jlm 2018-02-04 is this 0 or blank??? 408 if (paymentTypeID == 50) 409 { 410 if ($("#attendeeTotalBalanceHidden" + attendee).length) 411 { 412 if (parseFloat($("#attendeeTotalBalanceHidden" + attendee).val()) < parseFloat(paymentAmount)) 413 msg += "The amount entered is greater than the attendee's total fee"; 414 } 415 } 416 if (paymentTypeID == 53 || paymentTypeID == 60 ) 417 { 418 if (paymentAmount * -1 < parseFloat($("#totalUnusedCredit53").val())) 419 { 420 msg += "Amount cannot be greater than " + global.formatMoney(parseFloat($("#totalUnusedCredit53").val()) * -1) + ", the unallocated credit amount."; 421 $('#paymentamount').val(parseFloat($("#totalUnusedCredit53").val()) * -1); 422 } 423 // else if ($('#refundReason').val() == 0 && paymentTypeID == 53) 424 // { 425 // msg += "Please select a reason for the refund. Additional refund reasons may be added under Accounting / Setup"; 426 // } 427 } 428 429 if (parseFloat(paymentAmount) <= 0 && payment.negativeAllowed.indexOf(paymentTypeID) == -1) 430 { 431 msg += "The amount you entered (" + paymentAmount + ") is less than or equal to zero. Please enter a positive value for this payment."; 432 if (paymentTypeID == 53 && $("#divAttendeeIDs").length > 0) { 433 msg += "<br><br>You may have to reallocate funds off a participant before issuing a refund. Select the Reallocate Payment type above to ensure no participants are overpaid."; 434 } 435 $('#paymentamount').val(0); 436 } 437
438 var validateAmt = ['45', '65', '69', '71', '72', '73', '74', '75', '81', '91']; 439 if (validateAmt.indexOf(paymentTypeID) != -1) 440 msg += this.validatePaymentAmt(paymentAmount, paymentTypeID, 1); 441 442 if ($('#extraInfo' + paymentTypeID).length) 443 { 444 var extraInfo = $.trim($('#extraInfo' + paymentTypeID).val()); 445 if (extraInfo == '0' || extraInfo == '') 446 msg += "All fields are required.<br>"; 447 } 448 449 if (payment.posPaymentType.indexOf(paymentTypeID) != -1 && $('#extraInfoPOS').length) 450 { 451 var extraInfo = $.trim($('#extraInfoPOS').val()); 452 if (extraInfo == '0' || extraInfo == '') 453 msg += "POS / Sellwise receipt number is required.<br>"; 454 } 455 456 //jlm 2019-05-21 was attempting this... not sure why used refundableTotal but didn't work in all situations... if(paymentTypeID == "56" && totalCollected > ( parseFloat($('#refundableTotal').val()) * -1 )) 457 if(paymentTypeID == "56") 458 { 459 if ( parseFloat(totalCollected) + parseFloat($("#totalUnusedCredit53").val()) > 0) 460 { 461 msg += "I'm sorry the total amount being reallocated is greater than the amount available. There is only " + global.formatMoney( parseFloat($("#totalUnusedCredit53").val()) * -1 ) + " available.<br />"; 462 } 463 else if (parseFloat(totalCollected) > ( parseFloat($('#refundableTotal').val()) * -1 )) 464 { 465 msg += "I'm sorry the total amount being reallocated is greater than the amount available. There is only " + global.formatMoney( parseFloat( $('#refundableTotal').val()) * -1 ) + " available.<br />"; 466 } 467 } 468 469 if (msg > '') 470 { 471 alert(msg); 472 return false; 473 } 474 475 return true; 476 477 }; 478 479 this.validatePaymentAmt = function(paymentAmount, paymentTypeID, rtnErrorMsg) 480 { 481 482 var extraInfoMaxAmt = 0, 483 paymentTypeStr = '', 484 originalPaymentAmount = paymentAmount; 485 486 if(paymentTypeID == "81") 487 { 488 var creditMaxArray = $('#extraInfo' + paymentTypeID).val().split(':'); 489 extraInfoMaxAmt = creditMaxArray[1]; 490 paymentTypeStr = 'credit'; 491 } else if ((paymentTypeID == 65 && $('#maxPay65').length > 0) || (paymentTypeID == 45 && $("#maxPay45").length > 0)) { 492 if (paymentAmount < 0) { 493 return ''; 494 } 495 496 extraInfoMaxAmt = paymentTypeID == 65 ? parseFloat($('#maxPay65').val()) : parseFloat($("#maxPay45").val()); 497 498 if (extraInfoMaxAmt < paymentAmount) { 499 $('#paymentamount').val(extraInfoMaxAmt); 500 var msg = 'The amount you entered is greater than the available amount of ' + (paymentTypeID == 65 ? 'per person fees' : 'booking fee') + '.' 501 if (rtnErrorMsg) { 502 return msg; 503 } else { 504 custom_response_alert('Invalid Amount', msg); 505 } 506 } 507 } 508 else if ($('#maxPay' + paymentTypeID).length) 509 { 510 if (paymentAmount > 0) //get out they are adding an amount so it's okay! 511 return ''; 512 513 514 paymentAmount = paymentAmount * -1; //need to make it possitive to compare to 'extra' info; if it's already a positive number and we make it a negative that's okay since it will mean they are adding a fee 515 extraInfoMaxAmt = parseFloat($('#maxPay' + paymentTypeID).val()); 516 517 if (parseFloat(extraInfoMaxAmt) < parseFloat(paymentAmount)) 518 $('#paymentamount').val(parseFloat(extraInfoMaxAmt) * -1); 519 520 paymentTypeStr = paymentTypeID == 65 ? 'per person' : 521 (paymentTypeID == 69 ? 'cleaning fee' : 522 (paymentTypeID == 71 ? 'utility fee' : 523 (paymentTypeID == 72 ? 'trading post taxable' : 524 (paymentTypeID == 73 ? 'trading post non-taxable' : 525 (paymentTypeID == 74 ? 'equipment rental' : 526 (paymentTypeID == 75 ? 'damages' : 527 (paymentTypeID == 91 ? 'cancellation/forfeit' : '' 528 (paymentTypeID == 102 ? 'shipping/handling' : '' 529 (paymentTypeID == 91 ? 'tax on sale of goods' : '' 530 )) ))))))); 531 532 } 533 534 if (parseFloat(extraInfoMaxAmt) < parseFloat(paymentAmount)) 535 { 536 if (rtnErrorMsg) 537 return "The amount you entered is " + (originalPaymentAmount < 0 ? "less" : "greater") + " than the available amount of " + paymentTypeStr + "."; 538 else 539 custom_response_alert('Invalid Amount', "The amount you entered is " + (originalPaymentAmount < 0 ? "less" : "greater") + " than the available amount of " + paymentTypeStr + "."); 540 } 541 else 542 { 543 if (rtnErrorMsg) 544 return ''; 545 else 546 return "Your payment of $" + global.formatMoney(paymentAmount) + " has been applied from " + paymentTypeStr + "."; 547 } 548 549 550 551 //EXTRA LOGIC THAT WE MAY OR MAY NOT NEED IS BELOW... RETURN IS GETTING US OUT OF HERE! 552 553 554 if(payTypeID == "91") //jlm 04-10-2014 adding logic so customer can add a forfeit to a reservation without using close-out processing which would require a reservation to be paid in full with an overage 555 { var newAmttmp=0; // prior to this could only reduce an existing cancellation fee 556 /* jlm 04-102-2014 557 if (parseFloat(newAmt)>0) { 558 newAmttmp=newAmt; 559 paidAmt=parseFloat(newAmt)*-1; 560 } else { 561 newAmttmp=parseFloat(newAmt) * -1; 562 } */ 563 if (parseFloat(newAmt)<0) { //Indicates we are reducing the cancellation fee -->
563 jlm (04-10-2014 - was originally a coded as above) 564 newAmttmp=newAmt; 565 paidAmt=parseFloat(newAmt)*-1; 566 var canFeeAmt = $('#canFeeAmt').val(); 567 if (parseFloat(canFeeAmt) >= parseFloat(paidAmt)) { //jlm 04-13-2014 changed from newAmttmp to paidAmt so... if the cancelFee >= amountBeingPaid 568 if (parseFloat(newAmt) > 0) 569 { 570 custom_response_alert('Invalid Cancel Fee', "Adjust Cancel fee (reduce) should be entered as a negative number."); 571 newAmt=parseFloat(newAmt)*-1; 572 $('#paymentamount').value=parseFloat(newAmt); 573 } 574 575 if (newAmttmp==canFeeAmt) 576 { 577 msg="Your cancellation fee has been removed"; 578 } 579 else 580 { 581 msg="Your Cancellation fee has been reduced by $"+global.formatMoney(newAmttmp); 582 } 583 } 584 else 585 { 586 custom_response_alert('Invalid Amount', "I'm sorry the amount you entered is greater than the original cancellation fee. Please adjust and try again"); 587 paidAmt=parseFloat(canFeeAmt)*-1; 588 validContinue=false; 589 } 590 } 591 else 592 { //Indicates we are adding a forfeit 593 msg="Forfeit fee of $"+global.formatMoney(newAmt)+" has been added to your registration."; 594 custom_response_alert('Warning', "Forfeit will be added to this registration."); 595 } 596 }else if(payTypeID == "53") 597 { 598 var totalUnusedCredit=parseFloat($("#totalUnusedCredit53").value); 599 if ((parseFloat(totalUnusedCredit)*-1) < parseFloat(newAmt)) 600 { 601 custom_response_alert('Invalid Amount', "I'm sorry the amount you entered is greater than the available amount of credit. Please adjust and try again"); 602 validContinue=false; 603 } 604 else 605 msg="$"+global.formatMoney(newAmt)+" has been moved to Refund processing."; 606 } 607 else if(payTypeID == "60") 608 { 609 var totalUnusedCredit=parseFloat($("#totalUnusedCredit53").value); 610 if (parseFloat(totalUnusedCredit) < parseFloat(newAmt)) 611 { 612 custom_response_alert('Invalid Amount', "I'm sorry the amount you entered is greater than the available amount of credit. Please adjust and try again"); 613 validContinue=false; 614 } 615 else 616 msg="$"+global.formatMoney(newAmt)+" has been moved to Credit. Please contact the office to use your credit."; 617 } 618 else if(payTypeID == "8" || payTypeID == "89" || payTypeID == "91") //If allowing negatives be sure to change in ses.js - checkPayAmt 619 { 620 if (parseFloat(newAmt) > 0) { 621 if(payTypeID == "8") 622 { 623 custom_response_alert('Invalid Amount', "Payment reversal should be entered as a negative number."); 624 } 625 else if(payTypeID == "89") 626 { 627 custom_response_alert('Invalid Amount', "Merchant EFT (reduce) should be entered as a negative number."); 628 } 629 newAmt=parseFloat(newAmt)*-1; 630 $('#paymentamount').value=parseFloat(newAmt); 631 validContinue=true; 632 } 633 amtAllowed = $('#refundableTotal').val(); 634 if (parseFloat(amtAllowed) <= parseFloat(newAmt)) { 635 // -72 <= -56 636 }else { 637 paidAmt=amtAllowed; 638 custom_response_alert('Amount > Paid Amount', "I'm sorry the amount you entered is greater than the amount actually paid. Please adjust and try again"); 639 validContinue=false; 640 } 641 }else if(payTypeID == "56") 642 { //adjust payment_detail - allowed on fee schedule rows 643 msg=''; 644 amtAllowed = $('#refundableTotal').val(); 645 if (parseFloat(amtAllowed) <= parseFloat(newAmt)) { 646 } 647 else 648 { 649 paidAmt=amtAllowed; 650 custom_response_alert('Amount > Paid Amount', "I'm sorry the amount you entered is greater than the amount actually paid. Please adjust and try again"); 651 validContinue=false; 652 } 653 } 654 else if(payTypeID == "83") 655 { //adjust early discount 656 var earlySelected = $('#removeEarly83').val(); 657 amtAllowed = earlySelected.split(":")[1]; 658 paidAmt=amtAllowed; 659 if (parseFloat(amtAllowed) >= parseFloat(newAmt)) { 660 msg=''; 661 } 662 else 663 { 664 custom_response_alert('Amount < Original Early Discount Amount', "I'm sorry the amount you entered is less than the original early discount. Please adjust and try again"); 665 validContinue=false; 666 } 667 } 668 else if(payTypeID == "82") 669 { //adjust early discount 670 var earlySelected = $('#removeLate82').val(); 671 amtAllowed = earlySelected.split(":")[1]; 672 paidAmt=amtAllowed; 673 if (parseFloat(amtAllowed) >= parseFloat(newAmt)) { 674 msg=''; 675 } 676 else 677 { 678 custom_response_alert('Amount < Original Late Fee', "I'm sorry the amount you entered is less than the original late fee. Please adjust and try again"); 679 validContinue=false; 680 } 681 } 682 }; 683 684 this.showExtraPaymentInfo =function(systemID, keyID) 685 { 686 var paymentTypeID = $('#paymenttype').val(); 687 var payIds=''; 688 689 if ($('#unusedCreditPaymentRow').length > 0) 690 $('#unusedCreditPaymentRow').hide(); 691 692 $('#extraDataCollection').html(''); 693 694 if ($('#paymentTypeDesc' + paymentTypeID).length) 695 { 696 $('#alertHelpMessageDIV').html($('#paymentTypeDesc' + paymentTypeID).html()); 697 $('#alertHelpMessageDIV').show(); 698 } 699 else 700 { 701 $('#alertHelpMessageDIV').hide(); 702 } 703 704 $('#payeename').val(''); 705 $('#paymentamount').val(''); 706 707 var useFeeSchedule = $("#feeScheduleApplies").length ? $("#feeScheduleApplies").val() : 0;
708//WHY??? $(".ui-dialog-buttonpane button:contains('Save Payment and Send Email Confirmation')").attr("disabled", true).addClass("ui-state-disabled"); 709 $("#payeename").removeAttr("disabled"); 710 $("#paymentamount").removeAttr("disabled"); 711 712 if ($("#extraInfoPOS").length) 713 $("#extraInfoPOS").removeAttr("disabled"); 714 715 if(useFeeSchedule > 0) 716 { 717 if ($('#feeScheduleAreaPayment').find('input#payIds').length > 0) { 718 payIds = $('#feeScheduleAreaPayment input#payIds').val(); 719 var payIdsArray = payIds.split('@'); 720 for (var c=0; c< payIdsArray.length; c++) 721 { 722 regID = payIdsArray[c]; 723 $('#feeScheduleAreaPayment input#payAmt' + regID).removeAttr("disabled"); 724 } 725 } else if ($("#payIds").length) { 726 payIds=$("#payIds").val(); 727 var payIdsArray = payIds.split('@'); 728 for (var c=0; c< payIdsArray.length; c++) 729 { 730 regID = payIdsArray[c]; 731 $("#payAmt"+regID).removeAttr("disabled"); 732 } 733 } 734 } 735 736 $('.hiddenPayTypeClass').hide(); //jlm 05-15-2016 hide all extraInfo stuff 737 $('#hiddenPayType' + paymentTypeID).show(); 738 739 if (payment.posPaymentType.indexOf(paymentTypeID) != -1 && $('#extraInfoPOS').length) 740 { 741 $('#hiddenPayTypePOS').show(); 742 743 if (paymentTypeID == '4' && $('#udaPending').length && $('#udaPending').val() == 1) 744 { 745 $("#extraInfoPOS").val('TBD - Pending'); 746 $("#extraInfoPOS").attr("disabled", "disabled"); 747 } 748 else 749 $("#extraInfoPOS").val(''); 750 } 751 752 if (paymentTypeID=="53") 753 { 754 payment.fillRefundFields(systemID, keyID, 'payment', 0); 755 756 if ($('#unusedCreditPaymentRow').length > 0) { 757 $('#unusedCreditPaymentRow').show(); 758 $("#paymentamount").attr("disabled", "disabled"); 759 this.changeUnusedCreditUseAmt(); 760 } 761 } 762 else if (paymentTypeID == "60") 763 { 764 if ($("#feeScheduleAreaPayment").length) 765 $('#feeScheduleAreaPayment').hide(); 766 } 767 else 768 { 769 if ($("#feeScheduleAreaPayment").length) 770 $('#feeScheduleAreaPayment').show(); 771 } 772 773 var fillPayeeNamepaymentType = ['5', '6', '45', '49', '50', '53', '54', '56', '60', '67', '65', '69', '71', '72', '73', '74', '75', '90', '91', '137']; 774 if (fillPayeeNamepaymentType.indexOf(paymentTypeID) > -1) 775 this.fillPayeeName('paymenttype'); 776 777// if (paymentTypeID == "1" || paymentTypeID == "2" || paymentTypeID == "3" || paymentTypeID == "4" || paymentTypeID == "50" || paymentTypeID == "89" || paymentTypeID == "6") 778// $(".ui-dialog-buttonpane button:contains('Save Payment and Send Email Confirmation')").removeAttr('disabled').removeClass( 'ui-state-disabled' ); 779 780 var dontSetTo0 = ['1', '2', '3', '4']; 781 if (systemID == 2 && dontSetTo0.indexOf(paymentTypeID) == -1) 782 { 783 this.setDetailLevelPayAmtTo0(); 784 } 785 786 var stringID = paymentTypeID == '84' ? 'lateFeeString' : 787 (paymentTypeID == '82' ? 'lateFeeStringReverse' : 788 (paymentTypeID == '83' ? 'earlyDiscountStringReverse' : 789 (paymentTypeID == '85' ? 'earlyDiscountString' : ''))) 790 791 if (stringID > '') 792 { 793 this.setAttendeeLevelPayAmt(stringID); 794 disableExtraPayIds(stringID); 795 } 796 797 if ( this.detailLevelCollection.indexOf(paymentTypeID) > -1 && systemID != 6) 798 this.fillDetailLevelPayAmt(systemID, keyID); 799 800 if ($("#serviceFee").length) 801 { 802 var validServiceFeePayIds = ['1', '2', '3', '4']; //change this in savePaymentSES also 803 if (validServiceFeePayIds.indexOf(paymentTypeID ) > -1) 804 { //show Service Fee / Payment area and disable paymentamount 805 $('.CRRow').show(); 806 $("#paymentamount").attr("disabled", "disabled"); 807 } 808 else 809 { 810 $('.CRRow').hide(); 811 $("#paymentamount").removeAttr('disabled'); 812 } 813 } 814 815 if (paymentTypeID == '56') 816 { 817 $('#unallocatedDisplay').show(); 818 } else 819 { 820 $('#unallocatedDisplay').hide(); 821 } 822 }; 823 824 this.setAttendeeLevelPayAmt = function(stringID) 825 { 826 var stringArray = $('#' + stringID).val().split('@'); 827 var paymentTotal=0; 828 for (var i = 0; i < stringArray.length; i++) 829 { 830 attendeeArray = stringArray[i].split('#'); 831// attendeeArray[1] = (parseFloat(attendeeArray[1])); 832 if ($('#payAmt' + attendeeArray[0]).length) 833 {
834 if (stringID != 'lateFeeStringReverse') { 835 var payAmt = parseFloat(attendeeArray[1]) > parseFloat($('#balanceDue' + attendeeArray[0]).val()) ? 0 : parseFloat(attendeeArray[1]); 836 $('#payAmt' + attendeeArray[0]).val(payAmt); 837 paymentTotal = paymentTotal + payAmt; 838 paymentTotal = Math.round(paymentTotal * 100) / 100; 839 } 840 if (parseFloat(attendeeArray[1]) == 0) 841 $("#payAmt" + attendeeArray[0]).attr("disabled", "disabled"); 842 } 843 } 844 845 paymentTotal = paymentTotal.toFixed(2); 846 847 if ($('#isPayingNow').length) 848 $('#isPayingNow').val(paymentTotal); 849 850 $("#payeename").val("(attendee name)"); 851 $("#paymentamount").val(paymentTotal); 852 853 $("#payeename").attr("disabled", "disabled"); 854 $("#paymentamount").attr("disabled", "disabled"); 855 856 857 }; 858 859 this.setDetailLevelPayAmtTo0 = function() 860 { 861 var payIds=''; 862 863 if ($('#feeScheduleAreaPayment').find('input#payIds').length > 0) { 864 payIds = $('#feeScheduleAreaPayment input#payIds').val(); 865 if (payIds > '') { 866 var payIdsArray = payIds.split('@'); 867 for (var c = 0; c < payIdsArray.length; c++) { 868 regID = payIdsArray[c]; 869 $('#feeScheduleAreaPayment input#payAmt' + regID).val(0); 870 } 871 872 if ($('#feeScheduleAreaPayment').find('input#isPayingNow').length) 873 $('#feeScheduleAreaPayment input#isPayingNow').val(0); 874 } 875 } else if ($("#payIds").length) { 876 payIds = $("#payIds").val(); 877 878 if (payIds > '') { 879 var payIdsArray = payIds.split('@'); 880 for (var c = 0; c < payIdsArray.length; c++) { 881 regID = payIdsArray[c]; 882 $("#payAmt" + regID).val(0); 883 } 884 885 if ($('#isPayingNow').length) 886 $('#isPayingNow').val(0); 887 } 888 } 889 }; 890 891 this.fillDetailLevelPayAmt = function(systemID, keyID) 892 { 893 $("#paymentamount").attr("disabled", "disabled"); 894 895 var extraDetail = $('#paymenttype').val() == '55' ? $('#extraInfo' + $('#paymenttype').val()).val().split(':')[0] : $('#extraInfo' + $('#paymenttype').val()).val(); 896 897 $.post(this.url, 898 { 899 'action' : 'fillDetailLevelPayAmt', 900 'keyID' : keyID, 901 'systemID' : systemID, 902 'paymentTypeID' : $('#paymenttype').val(), 903 'extraDetailID' : extraDetail 904 }, 905 function(data) 906 { 907 $('#extraDataCollection').html(data); 908 909 if ($('#feeScheduleAreaPayment').length ) 910 $('#feeScheduleAreaPayment').hide(); 911 912 }); 913 }; 914 915 this.checkPayAmt = function ($this, systemID) { 916 var currentAmt = parseFloat($this.data('currentamt')); 917 var newAmt = parseFloat($this.val()); 918 var balAmt = parseFloat($this.attr('data-bal')); 919 var paymentTypeID = $('#paymenttype').val(); 920 921 if (newAmt < 0 && payment.negativeAllowed.indexOf(paymentTypeID) == -1) 922 { 923 custom_response_alert('Invalid Amount', "Negative number is not allowed. Try reversing the transaction and entering the correct amount."); 924 $this.val(0); 925 } 926 else if (newAmt < 0 && (newAmt * -1) > currentAmt) 927 { 928 custom_response_alert('Invalid Amount', "Amount is being reduced by more than was originally applied."); 929 $this.val(currentAmt * -1); 930 } 931 else if (newAmt > 0 && newAmt > balAmt && this.keepSign.indexOf(paymentTypeID) == -1) 932 { 933 if (payment.allowOverpayment.indexOf(paymentTypeID) == -1 || systemID == '2') 934 { 935 custom_response_alert('Invalid Amount', "Amount being applied is greater than Balance Due."); 936 $this.val(balAmt); 937 } 938 else 939 { 940 custom_response_alert('Warning', "Amount being applied is greater than Balance Due.<br /><br /><b>This is a warning only, if you continue the reservation will be overpaid.</b>"); 941 } 942 } 943 944 var totalCollected = 0; 945 $('input[name = "itemPay[]"]').each(function(i) 946 { 947 if ($(this).val() != 0 && $(this).val() > '') 948 { 949 totalCollected += parseFloat($(this).val()); 950 } 951 }); 952 953 if (paymentTypeID == 56) 954 { 955 var unallocated = parseFloat($('option:selected', '#extraInfo56').data('unallocated')); 956 if (totalCollected > unallocated) 957 { 958 custom_response_alert('Invalid Amount', "Amount being applied is greater than the unallocated credit for this payment."); 959 $this.val($this.val()-(totalCollected-unallocated)); 960 totalCollected -= totalCollected-unallocated; 961 } 962 } 963 964 var t=Math.round(totalCollected * 100) / 100; 965 $('#paymentamount').val(t.toFixed(2)); 966 967 }; 968 969 970 this.extraInfoCheck = function(systemID, keyID) 971 { 972 if ( this.detailLevelCollection.indexOf( $("#paymenttype").val() ) > -1 ) 973 this.fillDetailLevelPayAmt(systemID, keyID); 974 975 if (systemID == 6 && $("#paymenttype").val() == 13 ) 976 this.fillPayeeName('extraInfo13'); 977 978 }; 979 980 this.fillPayeeName = function(thisID) 981 { 982 983 var optionText = $("#" + thisID + " option:selected").text(); 984 $("#payeename").val(optionText.split(" - ",1)); 985 $("#payeename").attr("disabled", "disabled"); 986 }; 987 988 989 this.fillPayeeName81 = function(thisID) 990 { 991 var optionText = $("#" + thisID + " option:selected").text(); 992 993 var creditMaxArray = optionText.split(':'); 994 var creditName = creditMaxArray[1] + " : " + creditMaxArray[2]; 995 996 $("#payeename").val(creditName); 997 $("#payeename").attr("disabled", "disabled"); 998 999 var thisAmt = creditMaxArray[0].replace('$',''); 1000 thisAmt = thisAmt.replace(',', ''); 1001 1002 $('#paymentamount').val(thisAmt).trigger("change"); 1003 }; 1004 1005 this.fillPayeeName55 = function(thisValue, thisID) 1006 { 1007 var splitArray = thisValue.split(':'); 1008 $("#paymentamount").val(splitArray[1]); 1009 $("#paymentamount").attr("disabled", "disabled"); 1010 1011 var split1 = $('#' + thisID + " :selected").text().split(':'); 1012 var dateStr = $.trim(split1[0]); 1013 var typeArr = $.trim(split1[1]).split(/\s{1}/); 1014 var typeStr = typeArr.splice((typeArr[1] == "" ? 2 : 1)).join(' ');; 1015 var nameStr = $.trim(split1[2]); 1016 1017 //jlm 2020-11-19 not sure why we have the type in here too... just changed to name only so its not so big! $('#payeename').val(typeStr + ': ' + nameStr); 1018 $('#payeename').val( (nameStr == "" ? typeStr : nameStr) ); 1019 $("#payeename").attr("disabled", "disabled"); 1020 1021 }; 1022 1023 this.editComment = function(paymentID, systemID) 1024 { 1025 editorToTextarea($('#payComment' + paymentID), 'Edit Comment', systemID, '', '', 1026 function(data) 1027 { 1028 $('#payComment' + paymentID).html(data); 1029 1030 $.post(payment.url, 1031 { 1032 'action' : 'saveEditComment', 1033 'paymentID' : paymentID, 1034 'systemID' : systemID, 1035 'payComment' : data 1036 },function(data) 1037 { 1038 if (jQuery.trim(data) > '') 1039 alert(data); 1040 }); 1041 }, true); 1042 1043/* 1044 1045 var newText = $('#payCommentEdit').val(); 1046 $('#payComment' + paymentID).html(newText); 1047 1048 $.post(this.url, 1049 { 1050 'action' : 'saveEditComment', 1051 'paymentID' : paymentID, 1052 'systemID' : systemID, 1053 'payComment' : newText 1054 },function(data) 1055 { 1056 if (jQuery.trim(data) > '') 1057 alert(data); 1058 else 1059 alert("Changes have been saved"); 1060 1061 });
1062 mobileModalClose(m); 1063 } 1064 },'',''); 1065 }); 1066 */ 1067 }; 1068 1069 this.changeUnusedCreditUseAmt = function() 1070 { 1071 var totalUnused = 0; 1072 $('input[name = "payAmtUnused[]"]').each(function(i) 1073 { 1074 if ($(this).val() != 0 && $(this).val() > '') 1075 { 1076 if (parseFloat($(this).data('max-amt')) < parseFloat($( this).val()) ) 1077 { 1078 alert("There is only $" + $( this).data('max-amt') + " available from this payment."); 1079 $( this).val($(this).data('max-amt')); 1080 } 1081 1082 totalUnused += parseFloat($(this).val()); 1083 } 1084 }); 1085 1086 $('#paymentamount').val(totalUnused); 1087 1088 payment.changeAmountFillEmail(totalUnused); 1089 }; 1090 1091 this.changeAmountFillEmail = function(newAmt) 1092 { 1093 var amtAllowed = 0, 1094 payTypeID = 0, 1095 msg = "Your payment of " + global.formatMoney(newAmt) + " has been processed.", 1096 paidAmt = 0; 1097 1098 var paymentAmt=$('#paymentamount'); 1099 1100 payTypeID = $('#paymenttype').val(); 1101 1102 var validContinue = this.validatePaymentTypeInput(paymentAmt); 1103 if (validContinue) 1104 { 1105 if ($('#extraInfo' + payTypeID).length && [2, 137].indexOf($('#paymenttype').val()) > -1) 1106 { 1107 var extraInfoName = $('#extraInfo' + payTypeID + ' option:selected').text(); 1108 if (extraInfoName.slice(-9)=="(PENDING)") 1109 extraInfoName = extraInfoName.slice(0,-10); 1110 1111 if ($('#extraInfo' + payTypeID).val() == "0") 1112 { 1113 custom_response_alert('Error', "Required informatin is missing"); 1114 validContinue = false; 1115 } 1116 else 1117 { 1118 msg = global.formatMoney(newAmt) + " of your " + extraInfoName + " has been processed."; 1119 } 1120 } 1121 else if (payTypeID == 60) 1122 { 1123 msg = global.formatMoney(newAmt) + " credit is being held for " + extraInfoName + "."; 1124 } 1125 } 1126 1127 if (validContinue) 1128 { 1129 $("#emailComment").val(msg); 1130 if ($("#payingNow0").length) 1131 { 1132 $("#payingNow0").val(newAmt); 1133 } 1134 } 1135 else if ($("#paymentamount")) 1136 { 1137 if ($('#extraInfoMaxAmt' + payTypeID).length) 1138 { 1139 $("#paymentamount").val($('#extraInfoMaxAmt' + payTypeID).val()); 1140 } 1141 1142// if(payTypeID == "56" || payTypeID == "83" || payTypeID == "8" || payTypeID == "89" || payTypeID == "82" || payTypeID == "91") 1143// { 1144// $("#paymentamount").value=paidAmt; 1145// } else { $("#paymentamount").value=''; } 1146 } 1147 }; 1148 1149 this.fillRefundFields = function(systemID, keyID, calledFrom, attendeeID) 1150 { 1151 1152 $.post(this.url, 1153 { 1154 'action' : 'fillRefundFields', 1155 'keyID' : keyID, 1156 'attendeeID' : attendeeID, 1157 'systemID' : systemID, 1158 'calledFrom' : calledFrom 1159 }, 1160 function(data) 1161 { 1162 $('#extraDataCollection').html(data); 1163 if ($('#feeScheduleAreaPayment').length ) 1164 $('#feeScheduleAreaPayment').hide(); 1165 1166 }); 1167 1168 1169 1170 }; 1171 1172 this.adjustMiscDebit = function($this) 1173 { 1174 var miscDebit = parseFloat( ( $this.val() == '' ? 0 : $this.val())); 1175 1176 if (parseFloat(miscDebit) > parseFloat($this.data('original'))) 1177 { 1178 custom_response_alert('Invalid Amount', 'Amount cannot be greater than original amount'); 1179 $this.val($this.data('original')); 1180 $('#MISCDEBITDiv').html( moneyFormat(0)); 1181 } 1182 else 1183 { 1184 $('#MISCDEBITDiv').html( moneyFormat(parseFloat($this.data('original')) - parseFloat(miscDebit))); 1185 } 1186 1187 }; 1188 1189 this.fillRefundFieldsAddr = function(thisValue, keyID, systemID) 1190 { 1191 1192 thisInfo = thisValue.split(':'); 1193 1194 $.post(this.url, 1195 { 1196 'action' : 'fillRefundFieldsAddr', 1197 'keyID' : keyID, 1198 'fromWhere' : thisInfo[0], 1199 'systemID' : systemID, 1200 'addressID' : thisInfo[1] 1201 }, 1202 function(data) 1203 { 1204 $('#BillingFName').val( data.FNAME ); 1205 $('#BillingLName').val( data.LNAME ); 1206 $('#BillingAddress').val( data.ADDR ); 1207 $('#BillingCity').val( data.CITY ); 1208 $('#stateList').val( data.STATEID ); 1209 $('#BillingZip').val( data.ZIP ); 1210 $('#BillingEmail').val( data.EMAIL ); 1211 $('#BillingPhone').val( data.PHONE ); 1212 1213 if ($('#payeename').length > 0) 1214 $('#payeename').val(data.FNAME + " " + data.LNAME); 1215 1216 }, 'json'); 1217 }; 1218 1219 this.viewTransaction = function(systemID, keyID, historyType, reload, keyNbr, calledFrom, $modal, $target) 1220 { 1221 var hasTarget = typeof $target !== typeof undefined ? 1 : 0; 1222 1223 $.post(this.url, 1224 { 1225 'action' : 'viewTransaction', 1226 'keyID' : keyID,
1227 'keyNbr' : keyNbr, 1228 'systemID' : systemID, 1229 'historyType' : historyType, 1230 'calledFrom' : calledFrom, 1231 'hasTarget' : hasTarget 1232 }, function(data) 1233 { 1234 if (hasTarget) 1235 { 1236 $target.replaceWith(data); 1237 } 1238 else 1239 { 1240 var args = [$modal, 'Transaction History (' + keyNbr + ')', data, 1241 { 1242 'Exit': function() 1243 { 1244 mobileModalClose(m); 1245 } 1246 }, '', 'large']; 1247 1248 if (typeof $modal !== typeof undefined) 1249 { 1250 var func = mobileModalEdit; 1251 } 1252 else 1253 { 1254 var func = mobileModal; 1255 args.shift(); 1256 } 1257 1258 var m = func.apply(this, args); 1259 } 1260 }); 1261 1262 }; 1263 1264 1265 this.toggleCheckNbr = function(ptType,thisID) 1266 { 1267 if (ptType == '2') //make sure check info is visible 1268 { 1269 $('#'+thisID+"DIV").show(); 1270 } 1271 else 1272 { 1273 $('#'+thisID+"DIV").hide(); 1274 } 1275 1276 }; 1277 1278 this.emailCheckinReceipt = function(keyID, systemID) 1279 { 1280 var data = "<div id=\"dialog-modal-generic\" class=\"dialog-modal-standard\"></div>"; 1281 data += "<br><br>Email receipt is sent to the " + ( systemID == 1 ? 'primary leader and billing ' : 'registration' ) + " contact.<br />To send to an additional person, enter their email address here:" + 1282 "<br /><input type=text id=additionalEmailAddress value=\"\" name=additionalEmailAddress class='form-control input-sm' >"; 1283 1284 var m = mobileModal('Send Email Receipt', data, 1285 { 1286 'Close' : '', 1287 "Send Email": function() 1288 { 1289 $.post(payment.url, $.param( 1290 { 1291 'action' : 'emailCheckinReceipt', 1292 'systemID' : systemID, 1293 'keyID' : keyID, 1294 'additionalEmailAddress' : $('#additionalEmailAddress').val() 1295 }), 1296 function(data) 1297 { 1298 if (data.ERROR > '') 1299 alert(data.ERROR); 1300 else 1301 { 1302 alert("Email has been sent to " + data.EMAIL); 1303 mobileModalClose(m); 1304 } 1305 1306 },'json'); 1307 } 1308 }, null); 1309 1310 }; 1311 1312 this.saveManualPaymentCashCheck = function(keyID, systemID, calledFrom, instPaymentID) 1313 { //processes both add and void cash/check payments paid at either Camp or Event 1314 1315 var alerttext='', requiredOK=true; 1316 1317 document.getElementById('checkNbr' + instPaymentID).value = jQuery.trim(document.getElementById('checkNbr' + instPaymentID).value); 1318 1319 if ($('#paymentType' + instPaymentID).val() == 2 && $.trim($('#checkNbr' + instPaymentID).val()) == '') 1320 { 1321 alerttext+=' Check Number'; 1322 } 1323 1324 var pName=encodeURIComponentCustom(document.getElementById("pName"+instPaymentID).value); 1325 if ($.trim($("#pName" + instPaymentID).val()) == '') 1326 { 1327 if (alerttext != '') alerttext+=', \n'; 1328 alerttext+=' Payor Name'; 1329 } 1330 1331 if ($.trim($("#paymentAmount" + instPaymentID).val()) == '' || parseFloat($.trim($("#paymentAmount" + instPaymentID).val())) == 0 ) 1332 { 1333 if (alerttext != '') alerttext+=', \n'; 1334 alerttext+=' Payment Amount'; 1335 } 1336 1337 if (alerttext == '') 1338 { 1339 $.post(payment.url, $.param( 1340 { 1341 'action' : 'saveManualPaymentCashCheck', 1342 'systemID' : systemID, 1343 'keyID' : keyID, 1344 'calledFrom' : calledFrom, 1345 'instPaymentID' : instPaymentID 1346 }) + "&" + $('#manualPaymentProcDiv :input').serialize(), 1347 function(data) 1348 { 1349 if (data.ERROR > '') 1350 alert(data.ERROR); 1351 else 1352 { 1353 var title = systemID == 2 ? 'Registration #' + data.RES_NBR : crsresrecon.buildReconcileModalTitle(data.RES_SDATE, data.RES_NBR, data.UNIT, data.BALANCE_DUE); 1354 mobileModalEdit($('#showPaymentSectionDIV').closest('.modal'), title); 1355 $("#showPaymentSectionDIV").html(data.OUTPUT); 1356 } 1357 1358 },'json'); 1359 } 1360 else 1361 { 1362 custom_response_alert('Error', 'You have not completed all required information, the following fields are missing: \n' + alerttext); 1363 $('#checkinPaymentBtn').attr('disabled', false); 1364 } 1365 }; 1366 1367 this.showManualPaymentProcessing = function(m, systemID, keyID, calledFrom) 1368 { 1369 $.post(payment.url, $.param( 1370 { 1371 'action' : 'showManualPaymentProcessing', 1372 'systemID' : systemID, 1373 'keyID' : keyID, 1374 'calledFrom' : calledFrom 1375 }), 1376 function(data) 1377 { 1378 if (data.ERROR > '') 1379 { 1380 alert(data.ERROR); 1381 } 1382 else 1383 { 1384 if (m == '') { 1385 m = null; 1386 } 1387 1388 if (systemID == 1) 1389 {
1390 var title = crsresrecon.buildReconcileModalTitle(data.RES_SDATE, data.RES_NBR, data.UNIT, data.BALANCE_DUE); 1391 var m1 = mobileModalEdit(m, title, "<div id=showPaymentSectionDIV >" + data.OUTPUT + "</div>", {}, function() { 1392 if (calledFrom == 'reconcile') { 1393 $('#reconcileDays').change(); 1394 } 1395 }, 'large'); 1396 } else if (systemID == 2) { 1397 var m1 = mobileModalEdit(m, 'Registration # ' + data.RES_NBR, "<div id=showPaymentSectionDIV >" + data.OUTPUT + "</div>", {}, function() { 1398 if (calledFrom == 'CHECKIN') { 1399 $('.submit').submit(); 1400 } 1401 }, 'large'); 1402 } 1403 } 1404 },'json'); 1405 }; 1406 1407 this.calcConvFeeAmt = function($this, conveniencePct) 1408 { 1409 var amt = parseFloat($this.val()); 1410 var convFeeAmt = parseFloat(amt * parseFloat(conveniencePct)).toFixed(2); 1411 var totalFee = parseFloat(amt + parseFloat(convFeeAmt)).toFixed(2); 1412 1413 $('#payAmt, #payTotal').val(amt); 1414 $('#' + $this.attr('id') + 'ConvFee').html("Convenience Fee: " + global.formatMoney(convFeeAmt) + "<br /><b>Total Payment:</b> " + global.formatMoney(totalFee)); 1415 1416 }; 1417 1418 this.manualCCPaymentProcessing = function($m, systemID, keyID, calledFrom, payBySwipe, showPolicies, includePaymentInfo) 1419 { 1420 1421 $('#usingCCSwipe').val(payBySwipe); 1422 1423 var overridePayNowAmt = $('#overridePayNowAmt').length > 0 ? $('#overridePayNowAmt').val() : 0; 1424 1425 if (parseFloat(overridePayNowAmt) > 0) 1426 { 1427 ccinput.systemCalledFrom = calledFrom; 1428 ccinput.manualCCPayment(systemID, keyID, 'admin', '', payBySwipe, showPolicies, includePaymentInfo); 1429 } 1430 else 1431 { 1432 custom_response_alert('Invalid Amount', "Payment amount must be greater than zero"); 1433 } 1434 }; 1435 1436 this.reloadPage = function() 1437 { 1438 window.location.reload(); 1439 }; 1440 1441 1442 this.payNowAmtSpreadIt = function(totalBalanceDue, calledFrom) 1443 { 1444 var totalUnusedCredit=0; 1445 var spreadAmt = $('#paymentamount').val(); 1446 var paymentTypeID = $('#paymenttype').val(); 1447 1448 if (document.getElementById("totalUnusedCredit")) totalUnusedCredit=parseFloat(document.getElementById("totalUnusedCredit").value) * -1; 1449 1450 var minDueNow = document.getElementById("actualMinDueNow").value; 1451 1452 var allowSpreadIt = ['1', '2', '3', '4', ]; 1453 if ( allowSpreadIt.indexOf(paymentTypeID) == -1 ) 1454 { 1455 custom_response_alert('Spread It Not Available', "Spread It is not allowed on this payment type"); 1456 } 1457 else if (spreadAmt == '') 1458 { 1459 custom_response_alert('Missing Amount', "Enter Payment Amount to spread it"); 1460 } 1461 else if ((parseFloat(totalUnusedCredit) > 0 && parseFloat(minDueNow) < parseFloat(totalUnusedCredit) && parseFloat(spreadAmt) > parseFloat(totalUnusedCredit)) && calledFrom != 'admin') 1462 { 1463 custom_response_alert('Use Credit', 'Please use credit prior to entering Spread It amount'); 1464 } 1465 else if ((calledFrom != 'admin') && ((parseFloat(spreadAmt) < parseFloat(minDueNow)) || spreadAmt=='')) 1466 { 1467 custom_response_alert('Amount < Minimum Due', "Spread It amount cannot be less than minimum due now"); 1468 } 1469 else if (parseFloat(spreadAmt) > parseFloat(totalBalanceDue) ) 1470 { 1471 if (calledFrom == 'admin' && parseFloat(totalUnusedCredit) > 0) 1472 { 1473 custom_response_alert('Amount > Balance Due', "Spread It amount cannot be greater than balance due minus unallocated credit"); 1474 } 1475 else 1476 { 1477 custom_response_alert('Amount > Balance Due', "Spread It amount cannot be greater than balance due"); 1478 } 1479 } 1480 else 1481 { //Goahead and spread it around! 1482 1483 var useBalanceDue = parseFloat(spreadAmt) == parseFloat(totalBalanceDue) ? 1 : 0; 1484 1485 var spreadItPer = totalBalanceDue ==0 ? 0 : (parseFloat(spreadAmt) / parseFloat(totalBalanceDue)); 1486 1487 var balanceDueAttendee = 0, totalPaying = 0, minDueNow = 0; 1488 1489 //these sections process the same but have different input sections 1490 if ($('#feeScheduleAreaPayment').find('input#payIds').length > 0) { 1491 var attendeeIds = $('#feeScheduleAreaPayment input#payIds').val().split('@'); 1492 var attendeeID = ''; 1493 for (var c=0; c < attendeeIds.length; c++) 1494 { 1495 //Loop through each attending 1496 attendeeID = attendeeIds[c]; 1497 1498 //balanceDueAttendee = parseFloat((parseFloat(document.getElementById("balanceDue"+attendeeID).value) * spreadItPer).toFixed(2)); 1499 //rounds to nearest 50 cents 1500 balanceDueAttendee = useBalanceDue ? $('#feeScheduleAreaPayment input#balanceDue' + attendeeID).val() 1501 : Math.round( ( (parseFloat($('#feeScheduleAreaPayment input#balanceDue' + attendeeID).val() ) * spreadItPer * 2) / 2)).toFixed(2); 1502 totalPaying += parseFloat(balanceDueAttendee); 1503 1504 if (parseFloat(totalPaying) > parseFloat(spreadAmt) || c == attendeeIds.length - 1) //on last attendee or amount used is > spreadit 1505 balanceDueAttendee = parseFloat((parseFloat(balanceDueAttendee) - (parseFloat(totalPaying) - parseFloat(spreadAmt).toFixed(2))).toFixed(2)); 1506 1507 if (balanceDueAttendee < 0 ) 1508 balanceDueAttendee = 0; 1509 1510 $('#feeScheduleAreaPayment input#payAmt' + attendeeID).val(balanceDueAttendee).change(); 1511 } 1512 } else { 1513 var attendeeIds = $("#payIds").val().split('@'); 1514 1515 var attendeeID = ''; 1516 for (var c=0; c < attendeeIds.length; c++) 1517 { 1518 //Loop through each attending 1519 attendeeID = attendeeIds[c]; 1520 1521 //balanceDueAttendee = parseFloat((parseFloat(document.getElementById("balanceDue"+attendeeID).value) * spreadItPer).toFixed(2)); 1522 //rounds to nearest 50 cents 1523 balanceDueAttendee = useBalanceDue ? $("#balanceDue" + attendeeID).val() : Math.round( ( (parseFloat($("#balanceDue" + attendeeID).val() ) * spreadItPer * 2) / 2)).toFixed(2); 1524 totalPaying += parseFloat(balanceDueAttendee); 1525 1526 if (parseFloat(totalPaying) > parseFloat(spreadAmt) || c == attendeeIds.length - 1) //on last attendee or amount used is > spreadit 1527 balanceDueAttendee = parseFloat((parseFloat(balanceDueAttendee) - (parseFloat(totalPaying) - parseFloat(spreadAmt).toFixed(2))).toFixed(2)); 1528 1529 if (balanceDueAttendee < 0 ) 1530 balanceDueAttendee = 0; 1531 1532 $("#payAmt" + attendeeID).val(balanceDueAttendee).change(); 1533 } 1534 } 1535 1536 } 1537 }; 1538} 1539 1540var payment = new Payment();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.