1 package com.dotmarketing.portlets.event_registrations.struts; 2 3 import java.util.ArrayList ; 4 import java.util.GregorianCalendar ; 5 import java.util.List ; 6 7 import javax.servlet.http.HttpServletRequest ; 8 9 import org.apache.commons.validator.CreditCardValidator; 10 import org.apache.commons.validator.EmailValidator; 11 import org.apache.struts.Globals; 12 import org.apache.struts.action.ActionErrors; 13 import org.apache.struts.action.ActionMapping; 14 import org.apache.struts.action.ActionMessage; 15 import org.apache.struts.validator.ValidatorForm; 16 17 import com.dotmarketing.util.Config; 18 import com.dotmarketing.util.UtilMethods; 19 20 public class WebEventRegistrationForm extends ValidatorForm { 21 22 private static final long serialVersionUID = 1L; 23 24 private long inode; 26 private long eventInode; 28 private long eventLocationInode; 30 private long userInode; 32 private String userId; 34 private int registrationStatus; 36 private java.util.Date datePosted; 38 private java.util.Date lastModDate; 40 private float totalPaid; 42 private float totalDue; 44 private float totalRegistration; 45 46 private int paymentType; 48 private String billingAddress1; 50 private String billingAddress2; 52 private String billingCity; 54 private String billingState; 56 private String billingStateOtherCountryText; 58 private String billingCountry; 60 private String billingZip; 62 private String billingContactName; 64 private String billingContactPhone; 66 private String billingContactEmail; 68 private String cardName; 70 private String cardType; 72 private String cardNumber; 74 private String cardExpMonth; 75 76 private String cardExpYear; 77 78 private String cardVerificationValue; 80 private String checkNumber; 82 private String checkBankName; 84 private String poNumber; 86 private String invoiceNumber; 88 private boolean badgePrinted; 90 private String howDidYouHear; 92 private String ceoName; 94 private String registrantFacility; 96 97 private long registrantFacilityInode; 98 99 private String registrantSystem; 100 101 private long registrantSystemInode; 102 103 private String registrantFirstName; 104 105 private String registrantLastName; 106 107 private String registrantEmail; 108 109 private List <WebEventAttendeeForm> eventAttendees = new ArrayList <WebEventAttendeeForm>(); 111 112 private String currentAttendeeFirstName; 114 private String currentAttendeeLastName; 116 private String currentAttendeeBadgeName; 118 private String currentAttendeeEmail; 120 private long currentAttendeeInode; 122 private String currentAttendeeLastEmail; 124 private String currentAttendeeLastFirstName; 126 private String currentAttendeeLastLastName; 128 private String currentAttendeeTitle; 130 private float currentAttendeePrice; 132 private boolean modified_QB; 134 public WebEventRegistrationForm() { 135 modified_QB = true; 136 } 137 138 public boolean isCreditCardPayment() { 139 return paymentType == Config.getIntProperty("EREG_CREDIT_CARD"); 140 } 141 public boolean isCheckPayment() { 142 return paymentType == Config.getIntProperty("EREG_CHECK"); 143 } 144 public boolean isPOPayment() { 145 return paymentType == Config.getIntProperty("EREG_PURCHASE_ORDER"); 146 } 147 148 public WebEventRegistrationForm(long eventInode, long eventLocationInode, 149 long userInode) { 150 this.eventInode = eventInode; 151 this.eventLocationInode = eventLocationInode; 152 this.userInode = userInode; 153 } 154 155 public ActionErrors validate(ActionMapping mapping, 156 HttpServletRequest request) { 157 ActionErrors errors = super.validate(mapping, request); 158 if (errors == null) 159 errors = new ActionErrors(); 160 161 if ((UtilMethods.isSet(request.getParameter("dispatch")) && request 163 .getParameter("dispatch").equals("editAttendee")) 164 || (UtilMethods.isSet(request.getParameter("dispatch")) && request 165 .getParameter("dispatch").equals("saveAttendee")) 166 || (UtilMethods.isSet(request.getParameter("cmd")) && request 167 .getParameter("cmd").equals("add_attendee"))) { 168 169 if (!UtilMethods.isSet(currentAttendeeEmail)) { 170 errors.add("currentAttendeeEmail", new ActionMessage( 171 "error.form.mandatory", "attendee email address")); 172 } else { 173 EmailValidator validator = EmailValidator.getInstance(); 174 if (!validator.isValid(currentAttendeeEmail)) { 175 errors.add(Globals.ERROR_KEY, new ActionMessage( 176 "error.form.format", "email")); 177 } 178 179 } 180 if (!UtilMethods.isSet(currentAttendeeFirstName)) { 181 errors.add("currentAttendeeFirstName", new ActionMessage( 182 "error.form.mandatory", "first name")); 183 } 184 if (!UtilMethods.isSet(currentAttendeeLastName)) { 185 errors.add("currentAttendeeLastName", new ActionMessage( 186 "error.form.mandatory", "last name")); 187 } 188 if (!UtilMethods.isSet(currentAttendeeTitle)) { 189 errors.add("currentAttendeeTitle", new ActionMessage( 190 "error.form.mandatory", "Title")); 191 } 192 } else if ((UtilMethods.isSet(request.getParameter("dispatch")) && request 193 .getParameter("dispatch").equals("toStep3")) 194 || (UtilMethods.isSet(request.getParameter("cmd")) && request 195 .getParameter("cmd").equals("step4"))) { 196 if (!UtilMethods.isSet(billingAddress1)) { 197 errors.add("billingAddress1", new ActionMessage( 198 "error.form.mandatory", "Street1")); 199 } 200 if (!UtilMethods.isSet(billingCity)) { 201 errors.add("billingCity", new ActionMessage( 202 "error.form.mandatory", "City")); 203 } 204 if (!UtilMethods.isSet(billingState)) { 205 errors.add("billingState", new ActionMessage( 206 "error.form.mandatory", "State")); 207 } 208 if (!UtilMethods.isSet(billingZip)) { 209 errors.add("billingZip", new ActionMessage( 210 "error.form.mandatory", "Zip")); 211 } 212 if (!UtilMethods.isSet(billingContactName)) { 213 errors.add("billingContactName", new ActionMessage( 214 "error.form.mandatory", 215 "Billing Contact´s Person Name")); 216 } 217 if (!UtilMethods.isSet(billingContactPhone)) { 218 errors.add("billingContactPhone", new ActionMessage( 219 "error.form.mandatory", "Phone")); 220 } 221 if (!UtilMethods.isSet(billingContactEmail)) { 222 errors.add("billingContactEmail", new ActionMessage( 223 "error.form.mandatory", "Email")); 224 } else { 225 226 EmailValidator validator = EmailValidator.getInstance(); 227 if (!validator.isValid(billingContactEmail)) { 228 errors.add(Globals.ERROR_KEY, new ActionMessage( 229 "error.form.format", "email")); 230 } 231 } 232 if (isCreditCardPayment()) { 233 if (!UtilMethods.isSet(cardName)) { 234 errors.add("cardName", new ActionMessage( 235 "error.form.mandatory", "Credit Card Name")); 236 } 237 if (!UtilMethods.isSet(cardNumber)) { 238 errors.add("cardNumber", new ActionMessage( 239 "error.form.mandatory", "Credit Card Number")); 240 } else { 241 if (!cardNumber.equals("4111-1111-1111-1111") 242 || cardNumber.equals("4111111111111111")) { 243 CreditCardValidator cardValidator = new CreditCardValidator(); 244 if (cardType.equals("Visa")) { 245 cardValidator = new CreditCardValidator( 246 CreditCardValidator.VISA); 247 } else if (cardType.equals("MasterCard")) { 248 cardValidator = new CreditCardValidator( 249 CreditCardValidator.MASTERCARD); 250 } else if (cardType.equals("Discover")) { 251 cardValidator = new CreditCardValidator( 252 CreditCardValidator.DISCOVER); 253 } else if (cardType.equals("American Express")) { 254 cardValidator = new CreditCardValidator( 255 CreditCardValidator.AMEX); 256 } 257 if (!cardValidator.isValid(cardNumber)) { 258 errors.add("cardNumber", new ActionMessage( 259 "error.invalid.credit.card.number")); 260 } 261 } 262 } 263 int month = Integer.parseInt(this.cardExpMonth) - 1; 264 int year = Integer.parseInt(cardExpYear); 265 GregorianCalendar cal = new GregorianCalendar (); 266 int currentMonth = cal.get(GregorianCalendar.MONTH); 267 int currentYear = cal.get(GregorianCalendar.YEAR); 268 if (year < currentYear 269 || (year == currentYear && month < currentMonth)) { 270 errors.add("cardExpMonth", new ActionMessage( 271 "error.invalid.credit.card.expiration")); 272 } 273 }else if (isPOPayment()){ 274 if (!UtilMethods.isSet(poNumber)) { 275 errors.add("poNumber", new ActionMessage( 276 "error.form.mandatory", "PO Number")); 277 } 278 } 279 } 280 return errors; 281 } 282 283 public long getEventInode() { 284 return this.eventInode; 285 } 286 287 public void setEventInode(long eventInode) { 288 this.eventInode = eventInode; 289 } 290 291 public long getEventLocationInode() { 292 return this.eventLocationInode; 293 } 294 295 public void setEventLocationInode(long eventLocationInode) { 296 this.eventLocationInode = eventLocationInode; 297 } 298 299 public long getUserInode() { 300 return this.userInode; 301 } 302 303 public void setUserInode(long userInode) { 304 this.userInode = userInode; 305 } 306 307 public java.util.Date getDatePosted() { 308 return this.datePosted; 309 } 310 311 public void setDatePosted(java.util.Date datePosted) { 312 this.datePosted = datePosted; 313 } 314 315 public java.util.Date getLastModDate() { 316 return this.lastModDate; 317 } 318 319 public void setLastModDate(java.util.Date lastModDate) { 320 this.lastModDate = lastModDate; 321 } 322 323 public float getTotalPaid() { 324 return this.totalPaid; 325 } 326 327 public void setTotalPaid(float totalPaid) { 328 this.totalPaid = totalPaid; 329 } 330 331 public float getTotalDue() { 332 return this.totalDue; 333 } 334 335 public void setTotalDue(float totalDue) { 336 this.totalDue = totalDue; 337 } 338 339 public String getBillingAddress1() { 340 return this.billingAddress1; 341 } 342 343 public void setBillingAddress1(String billingAddress1) { 344 this.billingAddress1 = billingAddress1; 345 } 346 347 public String getBillingAddress2() { 348 return this.billingAddress2; 349 } 350 351 public void setBillingAddress2(String billingAddress2) { 352 this.billingAddress2 = billingAddress2; 353 } 354 355 public String getBillingCity() { 356 return this.billingCity; 357 } 358 359 public void setBillingCity(String billingCity) { 360 this.billingCity = billingCity; 361 } 362 363 public String getBillingState() { 364 return this.billingState; 365 } 366 367 public void setBillingState(String billingState) { 368 this.billingState = billingState; 369 } 370 371 public String getBillingZip() { 372 return this.billingZip; 373 } 374 375 public void setBillingZip(String billingZip) { 376 this.billingZip = billingZip; 377 } 378 379 public String getBillingContactName() { 380 return this.billingContactName; 381 } 382 383 public void setBillingContactName(String billingContactName) { 384 this.billingContactName = billingContactName; 385 } 386 387 public String getBillingContactPhone() { 388 return this.billingContactPhone; 389 } 390 391 public void setBillingContactPhone(String billingContactPhone) { 392 this.billingContactPhone = billingContactPhone; 393 } 394 395 public String getBillingContactEmail() { 396 return this.billingContactEmail; 397 } 398 399 public void setBillingContactEmail(String billingContactEmail) { 400 this.billingContactEmail = billingContactEmail; 401 } 402 403 public String getCardName() { 404 return this.cardName; 405 } 406 407 public void setCardName(String cardName) { 408 this.cardName = cardName; 409 } 410 411 public String getCardType() { 412 return this.cardType; 413 } 414 415 public void setCardType(String cardType) { 416 this.cardType = cardType; 417 } 418 419 public String getCardNumber() { 420 return this.cardNumber; 421 } 422 423 public void setCardNumber(String cardNumber) { 424 this.cardNumber = cardNumber; 425 } 426 427 430 public String getCardExpMonth() { 431 return cardExpMonth; 432 } 433 434 438 public void setCardExpMonth(String cardExpMonth) { 439 this.cardExpMonth = cardExpMonth; 440 } 441 442 445 public String getCardExpYear() { 446 return cardExpYear; 447 } 448 449 453 public void setCardExpYear(String cardExpYear) { 454 this.cardExpYear = cardExpYear; 455 } 456 457 public String getCardVerificationValue() { 458 return this.cardVerificationValue; 459 } 460 461 public void setCardVerificationValue(String cardVerificationValue) { 462 this.cardVerificationValue = cardVerificationValue; 463 } 464 465 public String getCheckNumber() { 466 return this.checkNumber; 467 } 468 469 public void setCheckNumber(String checkNumber) { 470 this.checkNumber = checkNumber; 471 } 472 473 public String getCheckBankName() { 474 return this.checkBankName; 475 } 476 477 public void setCheckBankName(String checkBankName) { 478 this.checkBankName = checkBankName; 479 } 480 481 public String getPoNumber() { 482 return this.poNumber; 483 } 484 485 public void setPoNumber(String poNumber) { 486 this.poNumber = poNumber; 487 } 488 489 public String getInvoiceNumber() { 490 return this.invoiceNumber; 491 } 492 493 public void setInvoiceNumber(String invoiceNumber) { 494 this.invoiceNumber = invoiceNumber; 495 } 496 497 public String getHowDidYouHear() { 498 return this.howDidYouHear; 499 } 500 501 public void setHowDidYouHear(String howDidYouHear) { 502 this.howDidYouHear = howDidYouHear; 503 } 504 505 public String getCeoName() { 506 return this.ceoName; 507 } 508 509 public void setCeoName(String ceoName) { 510 this.ceoName = ceoName; 511 } 512 513 516 public boolean isBadgePrinted() { 517 return badgePrinted; 518 } 519 520 524 public void setBadgePrinted(boolean badgePrinted) { 525 this.badgePrinted = badgePrinted; 526 } 527 528 531 public long getInode() { 532 return inode; 533 } 534 535 539 public void setInode(long inode) { 540 this.inode = inode; 541 } 542 543 546 public float getTotalRegistration() { 547 return totalRegistration; 548 } 549 550 554 public void setTotalRegistration(float totalRegistration) { 555 this.totalRegistration = totalRegistration; 556 } 557 558 public List <WebEventAttendeeForm> getEventAttendees() { 559 return eventAttendees; 560 } 561 562 public void setEventAttendees(List <WebEventAttendeeForm> attendees) { 563 this.eventAttendees = attendees; 564 } 565 566 public String getCurrentAttendeeBadgeName() { 567 return currentAttendeeBadgeName; 568 } 569 570 public void setCurrentAttendeeBadgeName(String currentAttendeeBadgeName) { 571 this.currentAttendeeBadgeName = currentAttendeeBadgeName; 572 } 573 574 public String getCurrentAttendeeEmail() { 575 return currentAttendeeEmail; 576 } 577 578 public void setCurrentAttendeeEmail(String currentAttendeeEmail) { 579 this.currentAttendeeEmail = currentAttendeeEmail; 580 } 581 582 public String getCurrentAttendeeFirstName() { 583 return currentAttendeeFirstName; 584 } 585 586 public void setCurrentAttendeeFirstName(String currentAttendeeFirstName) { 587 this.currentAttendeeFirstName = currentAttendeeFirstName; 588 } 589 590 public String getCurrentAttendeeLastName() { 591 return currentAttendeeLastName; 592 } 593 594 public void setCurrentAttendeeLastName(String currentAttendeeLastName) { 595 this.currentAttendeeLastName = currentAttendeeLastName; 596 } 597 598 public String getCurrentAttendeeTitle() { 599 return currentAttendeeTitle; 600 } 601 602 public void setCurrentAttendeeTitle(String currentAttendeeTitle) { 603 this.currentAttendeeTitle = currentAttendeeTitle; 604 } 605 606 public void resetCurrentAttendee() { 607 setCurrentAttendeeBadgeName(""); 608 setCurrentAttendeeEmail(""); 609 setCurrentAttendeeFirstName(""); 610 setCurrentAttendeeLastName(""); 611 setCurrentAttendeeTitle(""); 612 } 613 614 public String getCurrentAttendeeLastEmail() { 615 return currentAttendeeLastEmail; 616 } 617 618 public void setCurrentAttendeeLastEmail(String currentAttendeeLastEmail) { 619 this.currentAttendeeLastEmail = currentAttendeeLastEmail; 620 } 621 622 625 public String getRegistrantEmail() { 626 return registrantEmail; 627 } 628 629 633 public void setRegistrantEmail(String registrantEmail) { 634 this.registrantEmail = registrantEmail; 635 } 636 637 640 public String getRegistrantFacility() { 641 return registrantFacility; 642 } 643 644 648 public void setRegistrantFacility(String registrantFacility) { 649 this.registrantFacility = registrantFacility; 650 } 651 652 655 public String getRegistrantFirstName() { 656 return registrantFirstName; 657 } 658 659 663 public void setRegistrantFirstName(String registrantFirstName) { 664 this.registrantFirstName = registrantFirstName; 665 } 666 667 670 public String getRegistrantLastName() { 671 return registrantLastName; 672 } 673 674 678 public void setRegistrantLastName(String registrantLastName) { 679 this.registrantLastName = registrantLastName; 680 } 681 682 685 public String getRegistrantSystem() { 686 return registrantSystem; 687 } 688 689 693 public void setRegistrantSystem(String registrantSystem) { 694 this.registrantSystem = registrantSystem; 695 } 696 697 public void resetAllForm() { 698 this.billingAddress1 = ""; 699 this.billingAddress2 = ""; 700 this.billingCity = ""; 701 this.billingContactEmail = ""; 702 this.billingContactName = ""; 703 this.billingContactPhone = ""; 704 this.billingState = ""; 705 this.billingZip = ""; 706 this.cardExpMonth = ""; 707 this.cardExpYear = ""; 708 this.cardName = ""; 709 this.cardNumber = ""; 710 this.cardType = ""; 711 this.cardVerificationValue = ""; 712 this.ceoName = ""; 713 this.checkBankName = ""; 714 this.checkNumber = ""; 715 this.currentAttendeeBadgeName = ""; 716 this.currentAttendeeEmail = ""; 717 this.currentAttendeeFirstName = ""; 718 this.currentAttendeeLastEmail = ""; 719 this.currentAttendeeLastName = ""; 720 this.currentAttendeeTitle = ""; 721 this.eventAttendees = new ArrayList <WebEventAttendeeForm>(); 722 this.eventInode = 0; 723 this.eventLocationInode = 0; 724 this.howDidYouHear = ""; 725 this.inode = 0; 726 this.invoiceNumber = ""; 727 this.paymentType = 0; 728 this.poNumber = ""; 729 this.registrantEmail = ""; 730 this.registrantFacility = ""; 731 this.registrantFirstName = ""; 732 this.registrantLastName = ""; 733 this.registrantSystem = ""; 734 this.registrationStatus = 0; 735 this.totalDue = 0; 736 this.totalPaid = 0; 737 this.totalRegistration = 0; 738 this.userInode = 0; 739 } 740 741 744 public int getPaymentType() { 745 return paymentType; 746 } 747 748 752 public void setPaymentType(int paymentType) { 753 this.paymentType = paymentType; 754 } 755 756 759 public int getRegistrationStatus() { 760 return registrationStatus; 761 } 762 763 767 public void setRegistrationStatus(int registrationStatus) { 768 this.registrationStatus = registrationStatus; 769 } 770 771 774 public long getRegistrantFacilityInode() { 775 return registrantFacilityInode; 776 } 777 778 782 public void setRegistrantFacilityInode(long registrantFacilityInode) { 783 this.registrantFacilityInode = registrantFacilityInode; 784 } 785 786 789 public long getRegistrantSystemInode() { 790 return registrantSystemInode; 791 } 792 793 797 public void setRegistrantSystemInode(long registrantSystemInode) { 798 this.registrantSystemInode = registrantSystemInode; 799 } 800 801 804 public float getCurrentAttendeePrice() { 805 return currentAttendeePrice; 806 } 807 808 812 public void setCurrentAttendeePrice(float currentAttendeePrice) { 813 this.currentAttendeePrice = currentAttendeePrice; 814 } 815 816 819 public long getCurrentAttendeeInode() { 820 return currentAttendeeInode; 821 } 822 823 827 public void setCurrentAttendeeInode(long currentAttendeeInode) { 828 this.currentAttendeeInode = currentAttendeeInode; 829 } 830 831 834 public String getUserId() { 835 return userId; 836 } 837 838 842 public void setUserId(String userId) { 843 this.userId = userId; 844 } 845 846 849 public boolean isModified_QB() { 850 return modified_QB; 851 } 852 853 857 public void setModified_QB(boolean modified_QB) { 858 this.modified_QB = modified_QB; 859 } 860 861 864 public String getCurrentAttendeeLastFirstName() { 865 return currentAttendeeLastFirstName; 866 } 867 868 871 public void setCurrentAttendeeLastFirstName(String currentAttendeeLastFirstName) { 872 this.currentAttendeeLastFirstName = currentAttendeeLastFirstName; 873 } 874 875 878 public String getCurrentAttendeeLastLastName() { 879 return currentAttendeeLastLastName; 880 } 881 882 885 public void setCurrentAttendeeLastLastName(String currentAttendeeLastLastName) { 886 this.currentAttendeeLastLastName = currentAttendeeLastLastName; 887 } 888 889 892 public String getBillingCountry() { 893 return billingCountry; 894 } 895 896 899 public void setBillingCountry(String billingCountry) { 900 this.billingCountry = billingCountry; 901 } 902 903 906 public String getBillingStateOtherCountryText() { 907 return billingStateOtherCountryText; 908 } 909 910 913 public void setBillingStateOtherCountryText(String billingStateOtherCountryText) { 914 this.billingStateOtherCountryText = billingStateOtherCountryText; 915 } 916 917 918 } 919 | Popular Tags |