KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > order_manager > struts > OrderForm


1 package com.dotmarketing.portlets.order_manager.struts;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Calendar JavaDoc;
5 import java.util.Date JavaDoc;
6 import java.util.List JavaDoc;
7
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9
10 import org.apache.commons.validator.CreditCardValidator;
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 import com.liferay.portal.util.Constants;
20
21
22 public class OrderForm extends ValidatorForm {
23
24     private static final long serialVersionUID = 1L;
25     private long inode; //identifier
26
private long userInode; //persistent
27
private String JavaDoc userId;
28     private int orderStatus; //persistent
29
private int paymentStatus; //persistent
30
private java.util.Date JavaDoc datePosted; //persistent
31
private java.util.Date JavaDoc lastModDate; //persistent
32
private String JavaDoc billingAddressType; //persistent
33
private String JavaDoc billingAddress1; //persistent
34
private String JavaDoc billingAddress2; //persistent
35
private String JavaDoc billingCity; //persistent
36
private String JavaDoc billingState; //persistent
37
private String JavaDoc billingStateOtherCountryText;
38     private String JavaDoc billingZip; //persistent
39
private String JavaDoc billingCountry; //persistent
40
private String JavaDoc billingPhone; //persistent
41
private String JavaDoc billingFax; //persistent
42
private String JavaDoc billingContactName; //persistent
43
private String JavaDoc billingContactPhone; //persistent
44
private String JavaDoc billingContactEmail; //persistent
45
private String JavaDoc shippingAddressType; //persistent
46
private String JavaDoc shippingAddress1; //persistent
47
private String JavaDoc shippingAddress2; //persistent
48
private String JavaDoc shippingLabel; //persistent
49
private String JavaDoc shippingCity; //persistent
50
private String JavaDoc shippingState; //persistent
51
private String JavaDoc shippingStateOtherCountryText;
52     private String JavaDoc shippingZip; //persistent
53
private String JavaDoc shippingCountry; //persistent
54
private String JavaDoc shippingPhone; //persistent
55
private String JavaDoc shippingFax; //persistent
56
private String JavaDoc paymentType; //persistent
57
private String JavaDoc nameOnCard; //persistent
58
private String JavaDoc cardType; //persistent
59
private String JavaDoc cardNumber; //persistent
60
private int cardExpMonth; //persistent
61
private int cardExpYear; //persistent
62
private String JavaDoc cardVerificationValue; //persistent
63
private float orderSubTotal; //persistent
64
private float orderDiscount; //persistent
65
private float orderSubTotalDiscount; //persistent
66
private float orderShipping; //persistent
67
private int orderShipType; //persistent
68
private float orderTax; //persistent
69
private String JavaDoc taxExemptNumber; //persistent
70
private String JavaDoc discountCodes; //persistent
71
private float orderTotal; //persistent
72
private float orderTotalPaid; //persistent
73
private float orderTotalDue; //persistent
74
private String JavaDoc invoiceNumber; //persistent
75
private java.util.Date JavaDoc invoiceDate; //persistent
76
private String JavaDoc checkNumber; //persistent
77
private String JavaDoc checkBankName; //persistent
78
private String JavaDoc poNumber; //persistent
79
private String JavaDoc trackingNumber; //persistent
80
private boolean isShippingZero;
81     private String JavaDoc contactName;
82     private String JavaDoc contactEmail;
83     private String JavaDoc contactSystem;
84     private String JavaDoc contactFacility;
85     private boolean modified_QB; // persistent
86
private boolean modified_FH; // persistent
87
private String JavaDoc backendUser; //persistent
88
private String JavaDoc backendUserName;
89     //new
90
private String JavaDoc homeAddress1;
91     private String JavaDoc homeAddress2;
92     private String JavaDoc homeLabel;
93     private String JavaDoc homeCity;
94     private String JavaDoc homeState;
95     private String JavaDoc homeStateOtherCountryText;
96     private String JavaDoc homeZip;
97     private String JavaDoc homeCountry;
98     private String JavaDoc homePhone;
99     private String JavaDoc homeFax;
100     private String JavaDoc homeContactName;
101     private String JavaDoc homeContactPhone;
102     private String JavaDoc homeContactEmail;
103     
104     private String JavaDoc workAddress1;
105     private String JavaDoc workAddress2;
106     private String JavaDoc workLabel;
107     private String JavaDoc workCity;
108     private String JavaDoc workState;
109     private String JavaDoc workStateOtherCountryText;
110     private String JavaDoc workZip;
111     private String JavaDoc workCountry;
112     private String JavaDoc workPhone;
113     private String JavaDoc workFax;
114     private String JavaDoc workContactName;
115     private String JavaDoc workContactPhone;
116     private String JavaDoc workContactEmail;
117     
118     private List JavaDoc<OrderItemForm> orderItemList = new ArrayList JavaDoc<OrderItemForm> ();
119
120     public boolean isCreditCardPayment() {
121         String JavaDoc creditCarType = Config.getStringProperty("ECOM_CREDIT_CARD");
122         return creditCarType.equals(paymentType.trim());
123     }
124     
125     
126     
127     public OrderForm() {
128         paymentType = "";
129         cardExpMonth = -1;
130         cardExpYear = -1;
131         this.modified_QB = true;
132         this.modified_FH = true;
133     }
134
135     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
136         if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.ADD)) {
137             return super.validate(mapping, request);
138         }
139         return null;
140     }
141     
142     
143     public long getInode() {
144         return this.inode;
145     }
146
147     public void setInode(long inode) {
148         this.inode = inode;
149     }
150     public long getUserInode() {
151         return this.userInode;
152     }
153
154     public void setUserInode(long userInode) {
155         this.userInode = userInode;
156     }
157     public int getOrderStatus() {
158         return this.orderStatus;
159     }
160
161     public void setOrderStatus(int orderStatus) {
162         this.orderStatus = orderStatus;
163     }
164     public int getPaymentStatus() {
165         return this.paymentStatus;
166     }
167
168     public void setPaymentStatus(int paymentStatus) {
169         this.paymentStatus = paymentStatus;
170     }
171     public java.util.Date JavaDoc getDatePosted() {
172         return this.datePosted;
173     }
174
175     public void setDatePosted(java.util.Date JavaDoc datePosted) {
176         this.datePosted = datePosted;
177     }
178     public java.util.Date JavaDoc getLastModDate() {
179         return this.lastModDate;
180     }
181
182     public void setLastModDate(java.util.Date JavaDoc lastModDate) {
183         this.lastModDate = lastModDate;
184     }
185     public String JavaDoc getBillingAddress1() {
186         return this.billingAddress1;
187     }
188
189     public void setBillingAddress1(String JavaDoc billingAddress1) {
190         this.billingAddress1 = billingAddress1;
191     }
192     public String JavaDoc getBillingAddress2() {
193         return this.billingAddress2;
194     }
195
196     public void setBillingAddress2(String JavaDoc billingAddress2) {
197         this.billingAddress2 = billingAddress2;
198     }
199     public String JavaDoc getBillingCity() {
200         return this.billingCity;
201     }
202
203     public void setBillingCity(String JavaDoc billingCity) {
204         this.billingCity = billingCity;
205     }
206     public String JavaDoc getBillingState() {
207         if (billingState != null)
208             return this.billingState.trim();
209         else
210             return null;
211     }
212
213     public void setBillingState(String JavaDoc billingState) {
214         this.billingState = billingState;
215     }
216     public String JavaDoc getBillingZip() {
217         return this.billingZip;
218     }
219
220     public void setBillingZip(String JavaDoc billingZip) {
221         this.billingZip = billingZip;
222     }
223     public String JavaDoc getBillingCountry() {
224         return this.billingCountry;
225     }
226
227     public void setBillingCountry(String JavaDoc billingCountry) {
228         this.billingCountry = billingCountry;
229     }
230     public String JavaDoc getBillingPhone() {
231         return this.billingPhone;
232     }
233
234     public void setBillingPhone(String JavaDoc billingPhone) {
235         this.billingPhone = billingPhone;
236     }
237     public String JavaDoc getBillingFax() {
238         return this.billingFax;
239     }
240
241     public void setBillingFax(String JavaDoc billingFax) {
242         this.billingFax = billingFax;
243     }
244     public String JavaDoc getBillingContactName() {
245         return this.billingContactName;
246     }
247
248     public void setBillingContactName(String JavaDoc billingContactName) {
249         this.billingContactName = billingContactName;
250     }
251     public String JavaDoc getBillingContactPhone() {
252         return this.billingContactPhone;
253     }
254
255     public void setBillingContactPhone(String JavaDoc billingContactPhone) {
256         this.billingContactPhone = billingContactPhone;
257     }
258     public String JavaDoc getBillingContactEmail() {
259         return this.billingContactEmail;
260     }
261
262     public void setBillingContactEmail(String JavaDoc billingContactEmail) {
263         this.billingContactEmail = billingContactEmail;
264     }
265     public String JavaDoc getShippingAddress1() {
266         return this.shippingAddress1;
267     }
268
269     public void setShippingAddress1(String JavaDoc shippingAddress1) {
270         this.shippingAddress1 = shippingAddress1;
271     }
272     public String JavaDoc getShippingAddress2() {
273         return this.shippingAddress2;
274     }
275
276     public void setShippingAddress2(String JavaDoc shippingAddress2) {
277         this.shippingAddress2 = shippingAddress2;
278     }
279     public String JavaDoc getShippingCity() {
280         return this.shippingCity;
281     }
282
283     public void setShippingCity(String JavaDoc shippingCity) {
284         this.shippingCity = shippingCity;
285     }
286     public String JavaDoc getShippingState() {
287         if (this.shippingState != null)
288             return this.shippingState.trim();
289         else
290             return "";
291     }
292
293     public void setShippingState(String JavaDoc shippingState) {
294         this.shippingState = shippingState;
295     }
296     public String JavaDoc getShippingZip() {
297         return this.shippingZip;
298     }
299
300     public void setShippingZip(String JavaDoc shippingZip) {
301         this.shippingZip = shippingZip;
302     }
303     public String JavaDoc getShippingCountry() {
304         return this.shippingCountry;
305     }
306
307     public void setShippingCountry(String JavaDoc shippingCountry) {
308         this.shippingCountry = shippingCountry;
309     }
310     public String JavaDoc getShippingPhone() {
311         return this.shippingPhone;
312     }
313
314     public void setShippingPhone(String JavaDoc shippingPhone) {
315         this.shippingPhone = shippingPhone;
316     }
317     public String JavaDoc getShippingFax() {
318         return this.shippingFax;
319     }
320
321     public void setShippingFax(String JavaDoc shippingFax) {
322         this.shippingFax = shippingFax;
323     }
324     public String JavaDoc getPaymentType() {
325         return this.paymentType;
326     }
327
328     public void setPaymentType(String JavaDoc paymentType) {
329         this.paymentType = paymentType.trim();
330     }
331     public String JavaDoc getNameOnCard() {
332         return this.nameOnCard;
333     }
334
335     public void setNameOnCard(String JavaDoc nameOnCard) {
336         this.nameOnCard = nameOnCard;
337     }
338     public String JavaDoc getCardType() {
339         return this.cardType;
340     }
341
342     public void setCardType(String JavaDoc cardType) {
343         this.cardType = cardType;
344     }
345     public String JavaDoc getCardNumber() {
346         return this.cardNumber;
347     }
348
349     public void setCardNumber(String JavaDoc cardNumber) {
350         this.cardNumber = cardNumber;
351     }
352     public int getCardExpMonth() {
353         return this.cardExpMonth;
354     }
355
356     public void setCardExpMonth(int cardExpMonth) {
357         this.cardExpMonth = cardExpMonth;
358     }
359     public int getCardExpYear() {
360         return this.cardExpYear;
361     }
362
363     public void setCardExpYear(int cardExpYear) {
364         this.cardExpYear = cardExpYear;
365     }
366     public String JavaDoc getCardVerificationValue() {
367         return this.cardVerificationValue;
368     }
369
370     public void setCardVerificationValue(String JavaDoc cardVerificationValue) {
371         this.cardVerificationValue = cardVerificationValue;
372     }
373     public float getOrderSubTotal() {
374         return this.orderSubTotal;
375     }
376
377     public void setOrderSubTotal(float orderSubTotal) {
378         this.orderSubTotal = orderSubTotal;
379     }
380     public float getOrderShipping() {
381         return this.orderShipping;
382     }
383
384     public void setOrderShipping(float orderShipping) {
385         this.orderShipping = orderShipping;
386     }
387     public int getOrderShipType() {
388         return this.orderShipType;
389     }
390
391     public void setOrderShipType(int orderShipType) {
392         this.orderShipType = orderShipType;
393     }
394     public float getOrderTax() {
395         return this.orderTax;
396     }
397
398     public void setOrderTax(float orderTax) {
399         this.orderTax = orderTax;
400     }
401     public String JavaDoc getDiscountCodes() {
402         return this.discountCodes;
403     }
404
405     public void setDiscountCodes(String JavaDoc discountCodes) {
406         this.discountCodes = discountCodes;
407     }
408     public float getOrderTotal() {
409         return this.orderTotal;
410     }
411
412     public void setOrderTotal(float orderTotal) {
413         this.orderTotal = orderTotal;
414     }
415     public float getOrderTotalPaid() {
416         return this.orderTotalPaid;
417     }
418
419     public void setOrderTotalPaid(float orderTotalPaid) {
420         this.orderTotalPaid = orderTotalPaid;
421     }
422     public float getOrderTotalDue() {
423         return this.orderTotalDue;
424     }
425
426     public void setOrderTotalDue(float orderTotalDue) {
427         this.orderTotalDue = orderTotalDue;
428     }
429     public String JavaDoc getInvoiceNumber() {
430         return this.invoiceNumber;
431     }
432
433     public void setInvoiceNumber(String JavaDoc invoiceNumber) {
434         this.invoiceNumber = invoiceNumber;
435     }
436     public java.util.Date JavaDoc getInvoiceDate() {
437         return this.invoiceDate;
438     }
439
440     public void setInvoiceDate(java.util.Date JavaDoc invoiceDate) {
441         this.invoiceDate = invoiceDate;
442     }
443     public String JavaDoc getCheckNumber() {
444         return this.checkNumber;
445     }
446
447     public void setCheckNumber(String JavaDoc checkNumber) {
448         this.checkNumber = checkNumber;
449     }
450     public String JavaDoc getCheckBankName() {
451         return this.checkBankName;
452     }
453
454     public void setCheckBankName(String JavaDoc checkBankName) {
455         this.checkBankName = checkBankName;
456     }
457     public String JavaDoc getPoNumber() {
458         return this.poNumber;
459     }
460
461     public void setPoNumber(String JavaDoc poNumber) {
462         this.poNumber = poNumber;
463     }
464     
465     public ActionErrors validate()
466     {
467         ActionErrors ae = new ActionErrors();
468         //Billing Address
469
if(!UtilMethods.isSet(billingAddressType))
470         {
471             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Address"));
472         }
473         if(!UtilMethods.isSet(billingAddress1))
474         {
475             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Address Street 1"));
476         }
477         if(!UtilMethods.isSet(billingCity))
478         {
479             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing City"));
480         }
481         if(!UtilMethods.isSet(billingCountry))
482         {
483             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Country"));
484         }
485         if(!UtilMethods.isSet(billingState))
486         {
487             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing State"));
488         }
489         else
490         {
491             if(UtilMethods.isSet(billingCountry)){
492                 if ((billingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (billingState.equals("otherCountry")))
493                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
494                 else{
495                     if (!(billingState.equals("otherCountry")))
496                         if (billingState.length() != 2)
497                         {
498                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Billing State","2"));
499                         }
500                 }
501             }
502         }
503         
504         if(!UtilMethods.isSet(billingZip))
505         {
506             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Zip"));
507         }
508         //Shpping Address
509
if(!UtilMethods.isSet(shippingAddress1))
510         {
511             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shippig Address Street 1"));
512         }
513         if(!UtilMethods.isSet(shippingCity))
514         {
515             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping City"));
516         }
517         if(!UtilMethods.isSet(shippingState))
518         {
519             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping State"));
520         }
521         else
522         {
523             if(UtilMethods.isSet(shippingCountry)){
524                 if ((shippingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (shippingState.equals("otherCountry")))
525                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
526                 else{
527                     if (!(shippingState.equals("otherCountry")))
528                         if (shippingState.length() != 2)
529                         {
530                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Shipping State","2"));
531                         }
532                 }
533             }
534         }
535         
536         if(!UtilMethods.isSet(shippingZip))
537         {
538             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Zip"));
539         }
540         if(!UtilMethods.isSet(shippingPhone))
541         {
542             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Phone"));
543         }
544         if(!UtilMethods.isSet(shippingAddressType))
545         {
546             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Address"));
547         }
548         //Payment Type
549
if (paymentType.equals("cc"))
550         {
551             if(!UtilMethods.isSet(nameOnCard))
552             {
553                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Name On Card"));
554             }
555             if(!UtilMethods.isSet(cardNumber))
556             {
557                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Number"));
558             }
559             else
560             {
561                 CreditCardValidator cardValidator = new CreditCardValidator ();
562                 if (cardType.equals("vs")) {
563                     cardValidator = new CreditCardValidator (CreditCardValidator.VISA);
564                 } else if (cardType.equals("mc")) {
565                     cardValidator = new CreditCardValidator (CreditCardValidator.MASTERCARD);
566                 } else if (cardType.equals("dc")) {
567                     cardValidator = new CreditCardValidator (CreditCardValidator.DISCOVER);
568                 } else if (cardType.equals("ae")) {
569                     cardValidator = new CreditCardValidator (CreditCardValidator.AMEX);
570                 }
571                 if (!cardNumber.equals("5111111111111111") && !cardNumber.equals("4111111111111111") && !cardValidator.isValid(cardNumber))
572                 {
573                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.invalid.credit.card.number"));
574                 }
575             }
576             /*if(!UtilMethods.isSet(cardVerificationValue))
577             {
578                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Verification Value"));
579             }
580             else
581             {
582                 if(cardVerificationValue.length() < 3 || cardVerificationValue.length() > 4)
583                 {
584                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.form.length","Card Verification Value","3 or 4"));
585                 }
586                 if(!UtilMethods.isInt(cardVerificationValue))
587                 {
588                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.form.format","Card Verification Value"));
589                 }
590             }*/

591             Date JavaDoc now = new Date JavaDoc();
592             Calendar JavaDoc calendar = Calendar.getInstance();
593             calendar.setTime(now);
594             if ((cardExpYear < calendar.get(Calendar.YEAR)) ||
595                ((cardExpYear == calendar.get(Calendar.YEAR)) && (cardExpMonth < calendar.get(Calendar.MONTH))))
596             {
597                 ae.add(Globals.ERROR_KEY, new ActionMessage("error.invalid.credit.card.expiration"));
598             }
599         }
600         else if (paymentType.equals("ch"))
601         {
602             /*if(!UtilMethods.isSet(checkNumber))
603             {
604                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Number"));
605             }
606             if(!UtilMethods.isSet(checkBankName))
607             {
608                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Bank Name"));
609             }*/

610         }
611         else if (paymentType.equals("po"))
612         {
613             /*if(!UtilMethods.isSet(poNumber))
614             {
615                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","PO Number"));
616             }*/

617         }
618         ///Contact Info
619
if(UtilMethods.isSet(billingAddressType) && billingAddressType.equals("Work"))
620         {
621             if(!UtilMethods.isSet(billingContactName))
622             {
623                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Contact Person Name"));
624             }
625             if(!UtilMethods.isSet(billingContactPhone))
626             {
627                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Phone"));
628             }
629             if(!UtilMethods.isSet(billingContactEmail))
630             {
631                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Email"));
632             }
633         }
634         return ae;
635     }
636
637     public String JavaDoc getBillingAddressType() {
638         return billingAddressType;
639     }
640
641     public void setBillingAddressType(String JavaDoc billingAddressType) {
642         this.billingAddressType = billingAddressType;
643     }
644
645     public String JavaDoc getShippingAddressType() {
646         return shippingAddressType;
647     }
648
649     public void setShippingAddressType(String JavaDoc shippingAddressType) {
650         this.shippingAddressType = shippingAddressType;
651     }
652
653     public float getOrderDiscount() {
654         return orderDiscount;
655     }
656
657     public void setOrderDiscount(float orderDiscount) {
658         this.orderDiscount = orderDiscount;
659     }
660
661     public float getOrderSubTotalDiscount() {
662         return orderSubTotalDiscount;
663     }
664
665     public void setOrderSubTotalDiscount(float orderSubTotalDiscount) {
666         this.orderSubTotalDiscount = orderSubTotalDiscount;
667     }
668
669     public List JavaDoc<OrderItemForm> getOrderItemList() {
670         return orderItemList;
671     }
672
673     public void setOrderItemList(List JavaDoc<OrderItemForm> orderItemList) {
674         this.orderItemList = orderItemList;
675     }
676
677     public String JavaDoc getTrackingNumber() {
678         return trackingNumber;
679     }
680
681     public void setTrackingNumber(String JavaDoc trackingNumber) {
682         this.trackingNumber = trackingNumber;
683     }
684
685     public String JavaDoc getTaxExemptNumber() {
686         return taxExemptNumber;
687     }
688
689     public void setTaxExemptNumber(String JavaDoc taxExemptNumber) {
690         this.taxExemptNumber = taxExemptNumber;
691     }
692     
693     public ActionErrors validateBackEnd()
694     {
695         ActionErrors ae = new ActionErrors();
696         //Billing Address
697
if(!UtilMethods.isSet(billingAddress1))
698         {
699             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Address Street 1"));
700         }
701         if(!UtilMethods.isSet(billingCity))
702         {
703             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing City"));
704         }
705         if(!UtilMethods.isSet(billingState))
706         {
707             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing State"));
708         }
709         else
710         {
711             if(UtilMethods.isSet(billingCountry)){
712                 if ((billingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (billingState.equals("otherCountry")))
713                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
714                 else{
715                     if (!(billingState.equals("otherCountry")))
716                         if (billingState.length() != 2)
717                         {
718                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Billing State","2"));
719                         }
720                 }
721             }
722         }
723         
724         if(!UtilMethods.isSet(billingZip))
725         {
726             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Zip"));
727         }
728         
729         if(!UtilMethods.isSet(billingPhone))
730         {
731             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Phone"));
732         }
733         //Shpping Address
734
if(!UtilMethods.isSet(shippingAddress1))
735         {
736             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shippig Address Street 1"));
737         }
738         if(!UtilMethods.isSet(shippingCity))
739         {
740             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping City"));
741         }
742         if(!UtilMethods.isSet(shippingState))
743         {
744             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping State"));
745         }
746         else
747         {
748             if(UtilMethods.isSet(shippingCountry)){
749                 if ((shippingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (shippingState.equals("otherCountry")))
750                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
751                 else{
752                     if (!(shippingState.equals("otherCountry")))
753                         if (shippingState.length() != 2)
754                         {
755                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Shipping State","2"));
756                         }
757                 }
758             }
759         }
760         
761         if(!UtilMethods.isSet(shippingZip))
762         {
763             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Zip"));
764         }
765         if(!UtilMethods.isSet(shippingPhone))
766         {
767             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Phone"));
768         }
769         //Payment Type
770
if (paymentType.equals("cc"))
771         {
772             if(!UtilMethods.isSet(nameOnCard))
773             {
774                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Name On Card"));
775             }
776             if(!UtilMethods.isSet(cardNumber))
777             {
778                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Number"));
779             }
780             else
781             {
782                 CreditCardValidator cardValidator = new CreditCardValidator ();
783                 if (cardType.equals("vs")) {
784                     cardValidator = new CreditCardValidator (CreditCardValidator.VISA);
785                 } else if (cardType.equals("mc")) {
786                     cardValidator = new CreditCardValidator (CreditCardValidator.MASTERCARD);
787                 } else if (cardType.equals("dc")) {
788                     cardValidator = new CreditCardValidator (CreditCardValidator.DISCOVER);
789                 } else if (cardType.equals("ae")) {
790                     cardValidator = new CreditCardValidator (CreditCardValidator.AMEX);
791                 }
792                 if (!cardNumber.equals("5111111111111111") && !cardNumber.equals("4111111111111111") && !cardValidator.isValid(cardNumber))
793                 {
794                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.invalid.credit.card.number"));
795                 }
796             }
797             /*if(!UtilMethods.isSet(cardVerificationValue))
798             {
799                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Verification Value"));
800             }
801             else
802             {
803                 if(cardVerificationValue.length() < 3 || cardVerificationValue.length() > 4)
804                 {
805                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.form.length","Card Verification Value","3 or 4"));
806                 }
807                 if(!UtilMethods.isInt(cardVerificationValue))
808                 {
809                     ae.add(Globals.ERROR_KEY, new ActionMessage("error.form.format","Card Verification Value"));
810                 }
811             }*/

812             Date JavaDoc now = new Date JavaDoc();
813             Calendar JavaDoc calendar = Calendar.getInstance();
814             calendar.setTime(now);
815             if ((cardExpYear < calendar.get(Calendar.YEAR)) ||
816                ((cardExpYear == calendar.get(Calendar.YEAR)) && (cardExpMonth < calendar.get(Calendar.MONTH))))
817             {
818                 ae.add(Globals.ERROR_KEY, new ActionMessage("error.invalid.credit.card.expiration"));
819             }
820         }
821         else if (paymentType.equals("ch"))
822         {
823             /*if(!UtilMethods.isSet(checkNumber))
824             {
825                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Number"));
826             }
827             if(!UtilMethods.isSet(checkBankName))
828             {
829                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Bank Name"));
830             }*/

831         }
832         else if (paymentType.equals("po"))
833         {
834             /*if(!UtilMethods.isSet(poNumber))
835             {
836                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","PO Number"));
837             }*/

838         }
839         return ae;
840     }
841     
842     public ActionErrors validateBackEndEdit()
843     {
844         ActionErrors ae = new ActionErrors();
845         //Billing Address
846
if(!UtilMethods.isSet(billingAddress1))
847         {
848             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Address Street 1"));
849         }
850         if(!UtilMethods.isSet(billingCity))
851         {
852             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing City"));
853         }
854         if(!UtilMethods.isSet(billingState))
855         {
856             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing State"));
857         }
858         else
859         {
860             if(UtilMethods.isSet(billingCountry)){
861                 if ((billingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (billingState.equals("otherCountry")))
862                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
863                 else{
864                     if (!(billingState.equals("otherCountry")))
865                         if (billingState.length() != 2)
866                         {
867                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Billing State","2"));
868                         }
869                 }
870             }
871         }
872         
873         if(!UtilMethods.isSet(billingZip))
874         {
875             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Zip"));
876         }
877         /*
878         if(!UtilMethods.isSet(billingPhone))
879         {
880             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Billing Phone"));
881         }
882         */

883         //Shpping Address
884
if(!UtilMethods.isSet(shippingAddress1))
885         {
886             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shippig Address Street 1"));
887         }
888         if(!UtilMethods.isSet(shippingCity))
889         {
890             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping City"));
891         }
892         if(!UtilMethods.isSet(shippingState))
893         {
894             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping State"));
895         }
896         else
897         {
898             if(UtilMethods.isSet(shippingCountry)){
899                 if ((shippingCountry.equals(Config.getStringProperty("DEFAULT_COUNTRY_CODE")))&& (shippingState.equals("otherCountry")))
900                     ae.add(Globals.ERROR_KEY,new ActionMessage("error.invalid.state.US"));
901                 else{
902                     if (!(shippingState.equals("otherCountry")))
903                         if (shippingState.length() != 2)
904                         {
905                             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.length","Shipping State","2"));
906                         }
907                 }
908             }
909         }
910         
911         if(!UtilMethods.isSet(shippingZip))
912         {
913             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Zip"));
914         }
915         /*
916         if(!UtilMethods.isSet(shippingPhone))
917         {
918             ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Shipping Phone"));
919         }
920         */

921         //Payment Type
922
if (paymentType.equals("cc"))
923         {
924             /*if(!UtilMethods.isSet(nameOnCard))
925             {
926                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Name On Card"));
927             }
928             if(!UtilMethods.isSet(cardNumber))
929             {
930                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Number"));
931             }
932             if(!UtilMethods.isSet(cardVerificationValue))
933             {
934                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Card Verification Value"));
935             }
936             Date now = new Date();
937             Calendar calendar = Calendar.getInstance();
938             calendar.setTime(now);
939             if ((cardExpYear < calendar.get(Calendar.YEAR)) ||
940                ((cardExpYear == calendar.get(Calendar.YEAR)) && (cardExpMonth < calendar.get(Calendar.MONTH))))
941             {
942                 ae.add(Globals.ERROR_KEY, new ActionMessage("error.invalid.credit.card.expiration"));
943             }*/

944         }
945         else if (paymentType.equals("ch"))
946         {
947             /*if(!UtilMethods.isSet(checkNumber))
948             {
949                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Number"));
950             }
951             if(!UtilMethods.isSet(checkBankName))
952             {
953                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","Check Bank Name"));
954             }*/

955         }
956         else if (paymentType.equals("po"))
957         {
958             /*if(!UtilMethods.isSet(poNumber))
959             {
960                 ae.add(Globals.ERROR_KEY,new ActionMessage("error.form.mandatory","PO Number"));
961             }*/

962         }
963         return ae;
964     }
965
966
967     public boolean getIsShippingZero() {
968         return isShippingZero;
969     }
970
971     public void setIsShippingZero(boolean isShippingZero) {
972         this.isShippingZero = isShippingZero;
973     }
974     
975     /**
976      * @param contactName
977      * The contact name to set.
978      */

979     public void setContactName(String JavaDoc contactName) {
980         this.contactName = contactName;
981     }
982
983     
984     /**
985      * @return Returns the contact name.
986      */

987     public String JavaDoc getContactName() {
988         return contactName;
989     }
990     
991     /**
992      * @param contactEmail
993      * The contact email to set.
994      */

995     public void setContactEmail(String JavaDoc contactEmail) {
996         this.contactEmail = contactEmail;
997     }
998
999     
1000    /**
1001     * @return Returns the contact email.
1002     */

1003    public String JavaDoc getContactEmail() {
1004        return contactEmail;
1005    }
1006    
1007    /**
1008     * @param contactSystem
1009     * The contact system to set.
1010     */

1011    public void setContactSystem(String JavaDoc contactSystem) {
1012        this.contactSystem = contactSystem;
1013    }
1014
1015    
1016    /**
1017     * @return Returns the contact system.
1018     */

1019    public String JavaDoc getContactSystem() {
1020        return contactSystem;
1021    }
1022
1023    /**
1024     * @param contactFacility
1025     * The contact facility to set.
1026     */

1027    public void setContactFacility(String JavaDoc contactFacility) {
1028        this.contactFacility = contactFacility;
1029    }
1030
1031    
1032    /**
1033     * @return Returns the contact facility.
1034     */

1035    public String JavaDoc getContactFacility() {
1036        return contactFacility;
1037    }
1038    
1039    /**
1040     * @return Returns the modified_FH.
1041     */

1042    public boolean isModified_FH() {
1043        return modified_FH;
1044    }
1045
1046    /**
1047     * @param modified_FH
1048     * The modified_FH to set.
1049     */

1050    public void setModified_FH(boolean modified_FH) {
1051        this.modified_FH = modified_FH;
1052    }
1053    
1054    /**
1055     * @return Returns the modified_QB.
1056     */

1057    public boolean isModified_QB() {
1058        return modified_QB;
1059    }
1060
1061    /**
1062     * @param modified_QB
1063     * The modified_QB to set.
1064     */

1065    public void setModified_QB(boolean modified_QB) {
1066        this.modified_QB = modified_QB;
1067    }
1068
1069
1070
1071    public String JavaDoc getBillingStateOtherCountryText() {
1072        return billingStateOtherCountryText;
1073    }
1074
1075
1076
1077    public void setBillingStateOtherCountryText(String JavaDoc billingStateText) {
1078        this.billingStateOtherCountryText = billingStateText;
1079    }
1080
1081
1082
1083    public String JavaDoc getShippingStateOtherCountryText() {
1084        return shippingStateOtherCountryText;
1085    }
1086
1087
1088
1089    public void setShippingStateOtherCountryText(String JavaDoc shippingStateText) {
1090        this.shippingStateOtherCountryText = shippingStateText;
1091    }
1092
1093
1094
1095    /**
1096     * @return Returns the userId.
1097     */

1098    public String JavaDoc getUserId() {
1099        return userId;
1100    }
1101
1102
1103
1104    /**
1105     * @param userId The userId to set.
1106     */

1107    public void setUserId(String JavaDoc userId) {
1108        this.userId = userId;
1109    }
1110
1111
1112
1113    public String JavaDoc getBackendUser() {
1114        return backendUser;
1115    }
1116
1117
1118
1119    public void setBackendUser(String JavaDoc backendUser) {
1120        this.backendUser = backendUser;
1121    }
1122
1123
1124
1125    public String JavaDoc getBackendUserName() {
1126        return backendUserName;
1127    }
1128
1129
1130
1131    public void setBackendUserName(String JavaDoc backendUserName) {
1132        this.backendUserName = backendUserName;
1133    }
1134
1135
1136
1137    public String JavaDoc getShippingLabel() {
1138        return shippingLabel;
1139    }
1140
1141
1142
1143    public void setShippingLabel(String JavaDoc shippingLabel) {
1144        this.shippingLabel = shippingLabel;
1145    }
1146
1147
1148
1149    public String JavaDoc getHomeAddress1() {
1150        return homeAddress1;
1151    }
1152
1153
1154
1155    public void setHomeAddress1(String JavaDoc homeAddress1) {
1156        this.homeAddress1 = homeAddress1;
1157    }
1158
1159
1160
1161    public String JavaDoc getHomeAddress2() {
1162        return homeAddress2;
1163    }
1164
1165
1166
1167    public void setHomeAddress2(String JavaDoc homeAddress2) {
1168        this.homeAddress2 = homeAddress2;
1169    }
1170
1171
1172
1173    public String JavaDoc getHomeCity() {
1174        return homeCity;
1175    }
1176
1177
1178
1179    public void setHomeCity(String JavaDoc homeCity) {
1180        this.homeCity = homeCity;
1181    }
1182
1183
1184
1185    public String JavaDoc getHomeCountry() {
1186        return homeCountry;
1187    }
1188
1189
1190
1191    public void setHomeCountry(String JavaDoc homeCountry) {
1192        this.homeCountry = homeCountry;
1193    }
1194
1195
1196
1197    public String JavaDoc getHomeFax() {
1198        return homeFax;
1199    }
1200
1201
1202
1203    public void setHomeFax(String JavaDoc homeFax) {
1204        this.homeFax = homeFax;
1205    }
1206
1207
1208
1209    public String JavaDoc getHomeLabel() {
1210        return homeLabel;
1211    }
1212
1213
1214
1215    public void setHomeLabel(String JavaDoc homeLabel) {
1216        this.homeLabel = homeLabel;
1217    }
1218
1219
1220
1221    public String JavaDoc getHomePhone() {
1222        return homePhone;
1223    }
1224
1225
1226
1227    public void setHomePhone(String JavaDoc homePhone) {
1228        this.homePhone = homePhone;
1229    }
1230
1231
1232
1233    public String JavaDoc getHomeState() {
1234        return homeState;
1235    }
1236
1237
1238
1239    public void setHomeState(String JavaDoc homeState) {
1240        this.homeState = homeState;
1241    }
1242
1243
1244
1245    public String JavaDoc getHomeStateOtherCountryText() {
1246        return homeStateOtherCountryText;
1247    }
1248
1249
1250
1251    public void setHomeStateOtherCountryText(String JavaDoc homeStateOtherCountryText) {
1252        this.homeStateOtherCountryText = homeStateOtherCountryText;
1253    }
1254
1255
1256
1257    public String JavaDoc getHomeZip() {
1258        return homeZip;
1259    }
1260
1261
1262
1263    public void setHomeZip(String JavaDoc homeZip) {
1264        this.homeZip = homeZip;
1265    }
1266
1267
1268
1269    public String JavaDoc getWorkAddress1() {
1270        return workAddress1;
1271    }
1272
1273
1274
1275    public void setWorkAddress1(String JavaDoc workAddress1) {
1276        this.workAddress1 = workAddress1;
1277    }
1278
1279
1280
1281    public String JavaDoc getWorkAddress2() {
1282        return workAddress2;
1283    }
1284
1285
1286
1287    public void setWorkAddress2(String JavaDoc workAddress2) {
1288        this.workAddress2 = workAddress2;
1289    }
1290
1291
1292
1293    public String JavaDoc getWorkCity() {
1294        return workCity;
1295    }
1296
1297
1298
1299    public void setWorkCity(String JavaDoc workCity) {
1300        this.workCity = workCity;
1301    }
1302
1303
1304
1305    public String JavaDoc getWorkCountry() {
1306        return workCountry;
1307    }
1308
1309
1310
1311    public void setWorkCountry(String JavaDoc workCountry) {
1312        this.workCountry = workCountry;
1313    }
1314
1315
1316
1317    public String JavaDoc getWorkFax() {
1318        return workFax;
1319    }
1320
1321
1322
1323    public void setWorkFax(String JavaDoc workFax) {
1324        this.workFax = workFax;
1325    }
1326
1327
1328
1329    public String JavaDoc getWorkLabel() {
1330        return workLabel;
1331    }
1332
1333
1334
1335    public void setWorkLabel(String JavaDoc workLabel) {
1336        this.workLabel = workLabel;
1337    }
1338
1339
1340
1341    public String JavaDoc getWorkPhone() {
1342        return workPhone;
1343    }
1344
1345
1346
1347    public void setWorkPhone(String JavaDoc workPhone) {
1348        this.workPhone = workPhone;
1349    }
1350
1351
1352
1353    public String JavaDoc getWorkState() {
1354        return workState;
1355    }
1356
1357
1358
1359    public void setWorkState(String JavaDoc workState) {
1360        this.workState = workState;
1361    }
1362
1363
1364
1365    public String JavaDoc getWorkStateOtherCountryText() {
1366        return workStateOtherCountryText;
1367    }
1368
1369
1370
1371    public void setWorkStateOtherCountryText(String JavaDoc workStateOtherCountryText) {
1372        this.workStateOtherCountryText = workStateOtherCountryText;
1373    }
1374
1375
1376
1377    public String JavaDoc getWorkZip() {
1378        return workZip;
1379    }
1380
1381
1382
1383    public void setWorkZip(String JavaDoc workZip) {
1384        this.workZip = workZip;
1385    }
1386
1387
1388
1389    public String JavaDoc getHomeContactEmail() {
1390        return homeContactEmail;
1391    }
1392
1393
1394
1395    public void setHomeContactEmail(String JavaDoc homeContactEmail) {
1396        this.homeContactEmail = homeContactEmail;
1397    }
1398
1399
1400
1401    public String JavaDoc getHomeContactName() {
1402        return homeContactName;
1403    }
1404
1405
1406
1407    public void setHomeContactName(String JavaDoc homeContactName) {
1408        this.homeContactName = homeContactName;
1409    }
1410
1411
1412
1413    public String JavaDoc getHomeContactPhone() {
1414        return homeContactPhone;
1415    }
1416
1417
1418
1419    public void setHomeContactPhone(String JavaDoc homeContactPhone) {
1420        this.homeContactPhone = homeContactPhone;
1421    }
1422
1423
1424
1425    public String JavaDoc getWorkContactEmail() {
1426        return workContactEmail;
1427    }
1428
1429
1430
1431    public void setWorkContactEmail(String JavaDoc workContactEmail) {
1432        this.workContactEmail = workContactEmail;
1433    }
1434
1435
1436
1437    public String JavaDoc getWorkContactName() {
1438        return workContactName;
1439    }
1440
1441
1442
1443    public void setWorkContactName(String JavaDoc workContactName) {
1444        this.workContactName = workContactName;
1445    }
1446
1447
1448
1449    public String JavaDoc getWorkContactPhone() {
1450        return workContactPhone;
1451    }
1452
1453
1454
1455    public void setWorkContactPhone(String JavaDoc workContactPhone) {
1456        this.workContactPhone = workContactPhone;
1457    }
1458    
1459    
1460}
1461
Popular Tags