From 809cd4bf3cc3d93bd78e258878bc1d769378421e Mon Sep 17 00:00:00 2001 From: alberto Date: Wed, 8 May 2013 15:23:20 +0200 Subject: [PATCH] Add changes for bookings and structure - add new credit card entity for booking - add mobile phone in structure details - add notes for booking - remove required phone in guest details --- sql/locanda.sql | 38 +++++++ src/action/BookingAction.java | 27 ++++- src/global_en.properties | 12 +++ src/global_es.properties | 12 +++ src/global_it.properties | 12 +++ src/model/Booking.java | 9 ++ src/model/CreditCard.java | 98 +++++++++++++++++++ .../mybatis/mappers/CreditCardMapper.java | 27 +++++ .../mybatis/mappers/CreditCardMapper.xml | 52 ++++++++++ src/service/BookingServiceImpl.java | 29 +++++- src/service/CreditCardService.java | 17 ++++ src/service/CreditCardServiceImpl.java | 52 ++++++++++ webroot/WEB-INF/jsp/contents/booking_form.jsp | 57 ++++++++++- .../WEB-INF/jsp/templates/guest.mustache.jsp | 4 +- webroot/js/controllers/booking_controller.js | 4 + webroot/js/helpers/common.js | 2 +- 16 files changed, 439 insertions(+), 13 deletions(-) create mode 100644 src/model/CreditCard.java create mode 100644 src/persistence/mybatis/mappers/CreditCardMapper.java create mode 100644 src/persistence/mybatis/mappers/CreditCardMapper.xml create mode 100644 src/service/CreditCardService.java create mode 100644 src/service/CreditCardServiceImpl.java diff --git a/sql/locanda.sql b/sql/locanda.sql index 1bb323c4..b2c5fa2c 100644 --- a/sql/locanda.sql +++ b/sql/locanda.sql @@ -1029,4 +1029,42 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +-- +-- Table structure for table `creditCard` +-- + +DROP TABLE IF EXISTS `creditCard`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `creditCard` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cardType` varchar(45) DEFAULT NULL, + `cardNumber` varchar(45) DEFAULT NULL, + `expMonth` tinyint(4) DEFAULT NULL, + `expYear` smallint(6) DEFAULT NULL, + `firstName` varchar(255) DEFAULT NULL, + `lastName` varchar(255) DEFAULT NULL, + `securityCode` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `creditCard` +-- + +LOCK TABLES `creditCard` WRITE; +/*!40000 ALTER TABLE `creditCard` DISABLE KEYS */; +/*!40000 ALTER TABLE `creditCard` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + -- Dump completed on 2013-04-18 16:38:58 diff --git a/src/action/BookingAction.java b/src/action/BookingAction.java index 71628c93..760d045d 100644 --- a/src/action/BookingAction.java +++ b/src/action/BookingAction.java @@ -23,6 +23,7 @@ import org.apache.commons.lang.time.DateUtils; import model.Adjustment; +import model.CreditCard; import model.ExtraItem; import model.Booking; import model.Extra; @@ -49,6 +50,7 @@ import service.BookingService; import service.ConventionService; +import service.CreditCardService; import service.ExtraService; import service.GroupLeaderService; import service.GuestService; @@ -99,6 +101,9 @@ public class BookingAction extends ActionSupport implements SessionAware,UserAwa private GroupLeaderService groupLeaderService = null; @Autowired private HousedService housedService = null; + @Autowired + private CreditCardService creditCardService = null; + private static Logger logger = Logger.getLogger(Logger.class); @Actions({ @@ -393,6 +398,7 @@ public String saveUpdateBooking(){ Guest booker = null; Booking booking = null; Convention convention = null; + CreditCard creditCard = null; if(!this.checkBookingDates(this.getIdStructure())){ return ERROR; @@ -429,9 +435,12 @@ public String saveUpdateBooking(){ booking.setId_room(this.getBooking().getRoom().getId()); - convention = booking.getConvention(); + convention = this.getBooking().getConvention(); booking.setId_convention(convention.getId()); booking.setNotes(this.getBooking().getNotes()); + creditCard = this.getBooking().getCreditCard(); + booking.setCreditCard(creditCard); + logger.info("****** carta di credito " + creditCard.getCardType()); booking.setStatus(this.getBooking().getStatus()); booking.setId_structure(this.getIdStructure()); @@ -456,6 +465,7 @@ public String goAddNewBookingFromPlanner() { Integer numNights = 0; Double roomSubtotal = 0.0; Booking booking = null; + CreditCard creditCard = new CreditCard(); booking = new Booking(); this.getSession().put("booking", booking); @@ -470,6 +480,8 @@ public String goAddNewBookingFromPlanner() { defaultConvention = this.getConventionService().findConventionsByIdStructure(this.getIdStructure()).get(0); booking.setConvention(defaultConvention); + booking.setCreditCard(creditCard); + roomSubtotal = this.getBookingService().calculateRoomSubtotalForBooking(this.getIdStructure(),booking); booking.setRoomSubtotal(roomSubtotal); @@ -493,12 +505,15 @@ public String goAddNewBookingFromPlanner() { public String goAddNewBooking() { Convention defaultConvention = null; Booking booking = null; + CreditCard creditCard = new CreditCard(); booking = new Booking(); this.getSession().put("booking", booking); defaultConvention = this.getConventionService().findConventionsByIdStructure(this.getIdStructure()).get(0); booking.setConvention(defaultConvention); + booking.setCreditCard(creditCard); + this.setBooking(booking); this.setRooms(this.getRoomService().findRoomsByIdStructure(this.getIdStructure())); @@ -569,7 +584,7 @@ public String goUpdateBooking() { paymentsSubtotal = this.getBooking().calculatePaymentsSubtotal(); this.setPaymentsSubtotal(paymentsSubtotal); - + this.updateListNumGuests(booking); return SUCCESS; } @@ -1014,6 +1029,14 @@ public void setHousedService(HousedService housedService) { this.housedService = housedService; } + public CreditCardService getCreditCardService() { + return creditCardService; + } + + public void setCreditCardService(CreditCardService creditCardService) { + this.creditCardService = creditCardService; + } + public String getDateStart() { return dateStart; } diff --git a/src/global_en.properties b/src/global_en.properties index ce9f1184..8bbcdc57 100644 --- a/src/global_en.properties +++ b/src/global_en.properties @@ -145,6 +145,16 @@ createAccountSuccess = Account created successfully createAccountSuccessMessage = Congratulation! Your account has been created successfully. Now you are able to log in to locanda by using the following data +creditCard = Credit Card + +creditCardNumber = Card number + +creditCardType = Card Type + +creditCardExpirationDate = Expiration Date + +creditCardSecurityCode = Security Code + customer = Customer customizeLayout = Customize Layout @@ -357,6 +367,8 @@ mobile = Mobile monday = Monday +month = Month + name = Name new = New diff --git a/src/global_es.properties b/src/global_es.properties index 78af3259..f0b730d0 100644 --- a/src/global_es.properties +++ b/src/global_es.properties @@ -131,6 +131,16 @@ createAccountSuccess = Cuenta creada correctamente createAccountSuccessMessage = Felicidades! Tu cuenta ha sido creada. Puede acceder al sistema utilizando estos datos: +creditCard = Tarjeta de crédito + +creditCardNumber = Número de tarjeta + +creditCardType = Tipo de tarjeta + +creditCardExpirationDate = Fecha de vencimiento + +creditCardSecurityCode = Código de Seguridad + customer = Cliente customizeLayout = Personaliza tu distribuci\u00F3n @@ -319,6 +329,8 @@ mobile = Mobile monday = Lunes +month = Mes + name = Nombre new = Nuevo diff --git a/src/global_it.properties b/src/global_it.properties index 572310c2..bf8d25db 100644 --- a/src/global_it.properties +++ b/src/global_it.properties @@ -147,6 +147,16 @@ createAccountSuccess = Account creato con successo createAccountSuccessMessage = Complimenti! Account creato con successo. Ora puoi accedere al sistema utilizzando le seguenti credenziali: +creditCard = Carta di credito + +creditCardNumber = Numero Carta + +creditCardType = Tipo Carta + +creditCardExpirationDate = Data Scadenza + +creditCardSecurityCode = CVV + customer = Cliente customizeLayout = Personalizza il Layout @@ -359,6 +369,8 @@ mobile = Cellulare monday = Luned\u00EC +month = Mese + name = Nome new = Nuova diff --git a/src/model/Booking.java b/src/model/Booking.java index b9800ccd..31cc82da 100644 --- a/src/model/Booking.java +++ b/src/model/Booking.java @@ -45,6 +45,7 @@ public class Booking implements Serializable{ private List guests = null; private Convention convention = null; private List extraItems; + private CreditCard creditCard = null; private Integer id_structure = null; private Integer id_convention = null; private Integer id_room = null; @@ -344,6 +345,14 @@ public Convention getConvention() { public void setConvention(Convention convention) { this.convention = convention; } + public CreditCard getCreditCard() { + return creditCard; + } + + public void setCreditCard(CreditCard creditCard) { + this.creditCard = creditCard; + } + public List getExtraItems() { return extraItems; } diff --git a/src/model/CreditCard.java b/src/model/CreditCard.java new file mode 100644 index 00000000..806f777e --- /dev/null +++ b/src/model/CreditCard.java @@ -0,0 +1,98 @@ +package model; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +public class CreditCard implements Serializable { + private Integer id; + private String cardType; + private String cardNumber; + private Integer expMonth; + private Integer expYear; + private String securityCode; + private String firstName; + private String lastName; + private Integer id_booking; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CreditCard other = (CreditCard) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public String getCardType() { + return cardType; + } + public void setCardType(String cardType) { + this.cardType = cardType; + } + public String getCardNumber() { + return cardNumber; + } + public void setCardNumber(String cardNumber) { + this.cardNumber = cardNumber; + } + public Integer getExpMonth() { + return expMonth; + } + public void setExpMonth(Integer expMonth) { + this.expMonth = expMonth; + } + public Integer getExpYear() { + return expYear; + } + public void setExpYear(Integer expYear) { + this.expYear = expYear; + } + public String getSecurityCode() { + return securityCode; + } + public void setSecurityCode(String securityCode) { + this.securityCode = securityCode; + } + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + public Integer getId_booking() { + return id_booking; + } + public void setId_booking(Integer id_booking) { + this.id_booking = id_booking; + } + +} diff --git a/src/persistence/mybatis/mappers/CreditCardMapper.java b/src/persistence/mybatis/mappers/CreditCardMapper.java new file mode 100644 index 00000000..49ac9fc5 --- /dev/null +++ b/src/persistence/mybatis/mappers/CreditCardMapper.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * + * Copyright 2013 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package persistence.mybatis.mappers; + +import model.CreditCard; + +public interface CreditCardMapper { + public CreditCard findCreditCardById(Integer id); + public CreditCard findCreditCardByIdBooking(Integer id_booking); + public Integer updateCreditCard(CreditCard creditCard); + public Integer insertCreditCard(CreditCard creditCard); + public Integer deleteCreditCard(Integer id); + public Integer deleteCreditCardByIdBooking(Integer id_booking); +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/CreditCardMapper.xml b/src/persistence/mybatis/mappers/CreditCardMapper.xml new file mode 100644 index 00000000..017b0475 --- /dev/null +++ b/src/persistence/mybatis/mappers/CreditCardMapper.xml @@ -0,0 +1,52 @@ + + + + + + + + + + SELECT id,cardType,cardNumber,expMonth,expYear,securityCode,firstName,lastName,id_booking FROM creditCard + + + + + + + + UPDATE creditCard set + cardType= #{cardType},cardNumber= #{cardNumber},expMonth= #{expMonth},expYear= #{expYear},securityCode= #{securityCode},firstName= #{firstName},lastName= #{lastName},id_booking= #{id_booking} + WHERE id = #{id} + + + + insert into creditCard(cardType,cardNumber,expMonth,expYear,securityCode,firstName,lastName,id_booking) values(#{cardType},#{cardNumber},#{expMonth},#{expYear},#{securityCode},#{firstName},#{lastName},#{id_booking}) + + + + DELETE from creditCard where id = #{id} + + + + DELETE from creditCard where id_booking = #{id_booking} + + diff --git a/src/service/BookingServiceImpl.java b/src/service/BookingServiceImpl.java index b775f35f..74765b26 100644 --- a/src/service/BookingServiceImpl.java +++ b/src/service/BookingServiceImpl.java @@ -22,6 +22,7 @@ import model.Adjustment; import model.Booker; import model.Booking; +import model.CreditCard; import model.ExtraItem; import model.Guest; import model.Housed; @@ -73,6 +74,8 @@ public class BookingServiceImpl implements BookingService { private GroupLeaderService groupLeaderService = null; @Autowired private HousedExportService housedExportService = null; + @Autowired + private CreditCardService creditCardService = null; public Booking findBookingById(Integer id){ Booking booking = null; @@ -82,6 +85,7 @@ public Booking findBookingById(Integer id){ List adjustments = null; List payments = null; Convention convention = null; + CreditCard creditCard = null; Room room = null; booking = this.getBookingMapper().findBookingById(id); @@ -105,6 +109,9 @@ public Booking findBookingById(Integer id){ convention = this.getConventionService().findConventionById(booking.getId_convention()); booking.setConvention(convention); + + creditCard = this.getCreditCardService().findCreditCardByIdBooking(id); + booking.setCreditCard(creditCard); } return booking; @@ -227,6 +234,7 @@ public Integer countBookingsByIdSeason(Integer id_season) { public Integer saveUpdateBooking(Booking booking) { Integer ret = 0; Guest oldBooker = null; + CreditCard creditCard = null; //System.out.println("saveupdatebooking"); ret = this.getBookingMapper().updateBooking(booking); @@ -252,7 +260,14 @@ public Integer saveUpdateBooking(Booking booking) { for(Payment payment: booking.getPayments()){ payment.setId_booking(booking.getId()); this.getPaymentService().insertPayment(payment); - } + } + + creditCard = booking.getCreditCard(); + this.getCreditCardService().deleteCreditCardByIdBooking(booking.getId()); + if(creditCard != null){ + creditCard.setId_booking(booking.getId()); + this.getCreditCardService().insertCreditCard(creditCard); + } /* oldBooker = this.getGuestService().findGuestById(booking.getBooker().getId()); @@ -273,9 +288,7 @@ public Integer saveUpdateBooking(Booking booking) { //L'update viene gestito in REST per cui non è necessario fare l'update in questo metodo della action Integer id_guest = booking.getBooker().getId(); Integer id_booking = booking.getId(); - this.getBookerService().insert(id_guest, id_booking); - - + this.getBookerService().insert(id_guest, id_booking); } return ret; } @@ -445,4 +458,12 @@ public HousedExportService getHousedExportService() { public void setHousedExportService(HousedExportService housedExportService) { this.housedExportService = housedExportService; } + + public CreditCardService getCreditCardService() { + return creditCardService; + } + + public void setCreditCardService(CreditCardService creditCardService) { + this.creditCardService = creditCardService; + } } \ No newline at end of file diff --git a/src/service/CreditCardService.java b/src/service/CreditCardService.java new file mode 100644 index 00000000..373ae30b --- /dev/null +++ b/src/service/CreditCardService.java @@ -0,0 +1,17 @@ +package service; + +import model.CreditCard; +import model.listini.Convention; + +import org.springframework.transaction.annotation.Transactional; + +@Transactional +public interface CreditCardService { + public Integer insertCreditCard(CreditCard creditCard); + public Integer updateCreditCard(CreditCard creditCard); + public Integer deleteCreditCard(Integer id); + public Integer deleteCreditCardByIdBooking(Integer id); + public CreditCard findCreditCardById(Integer id); + public CreditCard findCreditCardByIdBooking(Integer id_booking); +} + diff --git a/src/service/CreditCardServiceImpl.java b/src/service/CreditCardServiceImpl.java new file mode 100644 index 00000000..be34892e --- /dev/null +++ b/src/service/CreditCardServiceImpl.java @@ -0,0 +1,52 @@ +package service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import persistence.mybatis.mappers.CreditCardMapper; +import model.CreditCard; + +@Service +public class CreditCardServiceImpl implements CreditCardService { + @Autowired + private CreditCardMapper creditCardMapper = null; + + @Override + public Integer insertCreditCard(CreditCard creditCard) { + return this.getCreditCardMapper().insertCreditCard(creditCard); + } + + @Override + public Integer updateCreditCard(CreditCard creditCard) { + return this.getCreditCardMapper().updateCreditCard(creditCard); + } + + @Override + public Integer deleteCreditCard(Integer id) { + return this.getCreditCardMapper().deleteCreditCard(id); + } + + @Override + public Integer deleteCreditCardByIdBooking(Integer id_booking) { + return this.getCreditCardMapper().deleteCreditCardByIdBooking(id_booking); + } + + public CreditCardMapper getCreditCardMapper() { + return creditCardMapper; + } + + public void setCreditCardMapper(CreditCardMapper creditCardMapper) { + this.creditCardMapper = creditCardMapper; + } + + @Override + public CreditCard findCreditCardById(Integer id) { + return this.getCreditCardMapper().findCreditCardById(id); + } + + @Override + public CreditCard findCreditCardByIdBooking(Integer id_booking) { + return this.getCreditCardMapper().findCreditCardByIdBooking(id_booking); + } + +} diff --git a/webroot/WEB-INF/jsp/contents/booking_form.jsp b/webroot/WEB-INF/jsp/contents/booking_form.jsp index e0c9b337..952c9442 100755 --- a/webroot/WEB-INF/jsp/contents/booking_form.jsp +++ b/webroot/WEB-INF/jsp/contents/booking_form.jsp @@ -237,11 +237,11 @@ width:80%; -
+

-
- -
+
+ +
@@ -321,6 +321,55 @@ width:80%;
Balance Due:
" />
--> +
+

+
+ +
+ "/> +
:
+
" class="digits"/>
+
+
+ +
+
+
:
+
:" class="validPricePositive" min="" max=""/>
+
+
+
+
:" />
+
" />
+
+
+
diff --git a/webroot/WEB-INF/jsp/templates/guest.mustache.jsp b/webroot/WEB-INF/jsp/templates/guest.mustache.jsp index 38835cb5..447460fe 100755 --- a/webroot/WEB-INF/jsp/templates/guest.mustache.jsp +++ b/webroot/WEB-INF/jsp/templates/guest.mustache.jsp @@ -82,8 +82,8 @@
- - + +
diff --git a/webroot/js/controllers/booking_controller.js b/webroot/js/controllers/booking_controller.js index baf8604d..f4c2c3dc 100644 --- a/webroot/js/controllers/booking_controller.js +++ b/webroot/js/controllers/booking_controller.js @@ -217,6 +217,10 @@ $(function () { } }); }); + + // creditcard setting + $('input[name="booking.creditCard.expYear"]').attr("min",new Date().getFullYear()).attr("max",new Date().getFullYear() + 100); + //update of dateOut changing num of nights. $("select[name='numNights']").change(function () { $('input[name="booking.dateIn"]').rules("add", { diff --git a/webroot/js/helpers/common.js b/webroot/js/helpers/common.js index 8dc1c281..52895fe5 100644 --- a/webroot/js/helpers/common.js +++ b/webroot/js/helpers/common.js @@ -143,7 +143,7 @@ $(document).ready(function () { animated: 'bounceslide', autoHeight: false }); - $("#accordion2,#accordion3").accordion({ + $("#accordion2,#accordion3,#accordion4").accordion({ collapsible: true, active: true, animated: 'bounceslide',