Merge branch 'develop' into 011-pruebas-unitarias-publicar-ofertas-abel

# Conflicts:
#	src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java
#	src/main/java/org/springframework/cheapy/model/SpeedOffer.java
#	src/main/java/org/springframework/cheapy/web/FoodOfferController.java
#	src/main/java/org/springframework/cheapy/web/NuOfferController.java
#	src/main/java/org/springframework/cheapy/web/SpeedOfferController.java
#	src/main/java/org/springframework/cheapy/web/TimeOfferController.java
#	src/main/resources/db/mysql/data.sql
#	src/main/webapp/WEB-INF/jsp/offers/food/foodOffersDisable.jsp
#	src/main/webapp/WEB-INF/jsp/offers/nu/nuOffersDisable.jsp
#	src/main/webapp/WEB-INF/jsp/offers/speed/speedOffersDisable.jsp
#	src/main/webapp/WEB-INF/jsp/offers/time/timeOffersDisable.jsp
This commit is contained in:
abemorcardc 2021-03-28 17:18:45 +02:00
commit 3ccf48acfc
36 changed files with 856 additions and 336 deletions

View file

@ -36,14 +36,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll() .antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
.antMatchers("/users/new").permitAll() .antMatchers("/users/new").permitAll()
.antMatchers("/nuOffers/**").hasAnyAuthority("admin","client")
.antMatchers("/timeOffers/**").hasAnyAuthority("admin","client")
.antMatchers("/login/**").anonymous() .antMatchers("/login/**").anonymous()
.antMatchers("/logout").permitAll() .antMatchers("/logout").permitAll()
.antMatchers("/usuarios/new").permitAll() .antMatchers("/usuarios/new").permitAll()
.antMatchers("/admin/**").hasAnyAuthority("admin") .antMatchers("/admin/**").hasAnyAuthority("admin")
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin") .antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
.antMatchers("/offers/**/new").hasAnyAuthority("admin", "client") .antMatchers("/offers/**/new").hasAnyAuthority("admin", "client")
@ -52,6 +50,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/clients/new").permitAll() .antMatchers("/clients/new").permitAll()
.antMatchers("/offers/**").permitAll() .antMatchers("/offers/**").permitAll()
.and().formLogin() .and().formLogin()
.loginPage("/login").permitAll() .loginPage("/login").permitAll()
.failureUrl("/login?error") .failureUrl("/login?error")

View file

@ -14,27 +14,29 @@ import javax.validation.constraints.NotEmpty;
@Entity @Entity
@Table(name = "clients") @Table(name = "clients")
public class Client extends BaseEntity{ public class Client extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// (id, email, address, init, finish, telephone, description, code, food, usuar) // (id, name, email, address, init, finish, telephone, description, code, food,
// usuar)
@NotEmpty
private String name;
@NotEmpty @NotEmpty
private String email; private String email;
@NotEmpty @NotEmpty
private String address; private String address;
//@DateTimeFormat(pattern = "HH:mm") // Hora de apertura del local
@NotBlank @NotBlank
private String init; private String init;
//@DateTimeFormat(pattern = "HH:mm") // Hora de cierre del local
@NotBlank @NotBlank
private String finish; private String finish;
@NotEmpty @NotEmpty
@Digits(fraction = 0, integer = 10) @Digits(fraction = 0, integer = 10)
@ -43,38 +45,45 @@ public class Client extends BaseEntity{
@NotEmpty @NotEmpty
private String description; private String description;
// Codigo de activacion de cuenta
@NotEmpty @NotEmpty
private String code; private String code;
@NotEmpty @NotEmpty
private String food; private String food;
@OneToOne(cascade = CascadeType.ALL) @OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "username", referencedColumnName = "username") @JoinColumn(name = "username", referencedColumnName = "username")
private User usuar; private User usuar;
@OneToMany @OneToMany
private Set<FoodOffer> foodOffers; private Set<FoodOffer> foodOffers;
@OneToMany @OneToMany
private Set<NuOffer> nuOffers; private Set<NuOffer> nuOffers;
@OneToMany @OneToMany
private Set<SpeedOffer> speedOffers; private Set<SpeedOffer> speedOffers;
@OneToMany @OneToMany
private Set<TimeOffer> timeOffers; private Set<TimeOffer> timeOffers;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() { public String getEmail() {
return email; return email;
} }
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
public String getAddress() { public String getAddress() {
return address; return address;
} }
@ -83,7 +92,6 @@ public class Client extends BaseEntity{
this.address = address; this.address = address;
} }
public String getInit() { public String getInit() {
return init; return init;
} }
@ -100,14 +108,6 @@ public class Client extends BaseEntity{
this.finish = finish; this.finish = finish;
} }
public User getUsername() {
return usuar;
}
public void setUsername(User username) {
this.usuar = username;
}
public String getTelephone() { public String getTelephone() {
return telephone; return telephone;
} }
@ -140,6 +140,14 @@ public class Client extends BaseEntity{
this.food = food; this.food = food;
} }
public User getUsuar() {
return usuar;
}
public void setUsuar(User usuar) {
this.usuar = usuar;
}
public Set<FoodOffer> getFoodOffers() { public Set<FoodOffer> getFoodOffers() {
return foodOffers; return foodOffers;
} }

View file

@ -17,6 +17,7 @@ package org.springframework.cheapy.model;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -24,20 +25,15 @@ import javax.validation.constraints.NotNull;
@Table(name = "food_offers") @Table(name = "food_offers")
public class FoodOffer extends Offer { public class FoodOffer extends Offer {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
//Plato específico //Plato específico
@NotBlank @NotBlank
private String food; private String food;
@NotBlank
private String discount;
@NotNull @NotNull
private Integer units; // revisar @Min(0)
private Integer discount;
public String getFood() { public String getFood() {
return food; return food;
@ -47,20 +43,12 @@ public class FoodOffer extends Offer {
this.food = food; this.food = food;
} }
public String getDiscount() { public Integer getDiscount() {
return discount; return discount;
} }
public void setDiscount(String discount) { public void setDiscount(Integer discount) {
this.discount = discount; this.discount = discount;
} }
public Integer getUnits() {
return units;
}
public void setUnits(Integer units) {
this.units = units;
}
} }

View file

@ -3,38 +3,42 @@ package org.springframework.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "nu_offers") @Table(name = "nu_offers")
public class NuOffer extends Offer { public class NuOffer extends Offer {
/** //Oferta por numero de comensales
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@NotNull @NotNull
private Integer gold; @Min(1)
private Integer gold;
@Column(name = "discount_gold") @Column(name = "discount_gold")
@NotBlank @NotNull
private String discountGold; @Min(0)
private Integer discountGold;
@NotNull @NotNull
private Integer silver; @Min(1)
private Integer silver;
@Column(name = "discount_silver") @Column(name = "discount_silver")
@NotBlank @NotNull
private String discountSilver; @Min(0)
private Integer discountSilver;
@NotNull @NotNull
private Integer bronze; @Min(1)
private Integer bronze;
@Column(name = "discount_bronze") @Column(name = "discount_bronze")
@NotBlank @NotNull
private String discountBronze; @Min(0)
private Integer discountBronze;
public Integer getGold() { public Integer getGold() {
return gold; return gold;
@ -44,11 +48,11 @@ public class NuOffer extends Offer {
this.gold = gold; this.gold = gold;
} }
public String getDiscountGold() { public Integer getDiscountGold() {
return discountGold; return discountGold;
} }
public void setDiscountGold(String discountGold) { public void setDiscountGold(Integer discountGold) {
this.discountGold = discountGold; this.discountGold = discountGold;
} }
@ -60,11 +64,11 @@ public class NuOffer extends Offer {
this.silver = silver; this.silver = silver;
} }
public String getDiscountSilver() { public Integer getDiscountSilver() {
return discountSilver; return discountSilver;
} }
public void setDiscountSilver(String discountSilver) { public void setDiscountSilver(Integer discountSilver) {
this.discountSilver = discountSilver; this.discountSilver = discountSilver;
} }
@ -76,12 +80,12 @@ public class NuOffer extends Offer {
this.bronze = bronze; this.bronze = bronze;
} }
public String getDiscountBronze() { public Integer getDiscountBronze() {
return discountBronze; return discountBronze;
} }
public void setDiscountBronze(String discountBronze) { public void setDiscountBronze(Integer discountBronze) {
this.discountBronze = discountBronze; this.discountBronze = discountBronze;
} }
} }

View file

@ -32,7 +32,8 @@ public class Offer extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
//Clase padre // Clase padre
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm") @DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
@NotNull @NotNull
@Future @Future
@ -46,11 +47,10 @@ public class Offer extends BaseEntity {
private String code; private String code;
@Enumerated(value = EnumType.STRING) @Enumerated(value = EnumType.STRING)
private StatusOffer type; private StatusOffer status;
@ManyToOne @ManyToOne
@JoinColumn(name="client_id") @JoinColumn(name = "client_id")
private Client client; private Client client;
public LocalDateTime getStart() { public LocalDateTime getStart() {
@ -77,14 +77,14 @@ public class Offer extends BaseEntity {
this.code = code; this.code = code;
} }
public StatusOffer getType() { public StatusOffer getStatus() {
return type; return status;
} }
public void setType(StatusOffer type) { public void setStatus(StatusOffer type) {
this.type = type; this.status = type;
} }
public Client getClient() { public Client getClient() {
return client; return client;
} }

View file

@ -3,35 +3,42 @@ package org.springframework.cheapy.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Entity @Entity
@Table(name = "speed_offers") @Table(name = "speed_offers")
public class SpeedOffer extends Offer { public class SpeedOffer extends Offer {
// Ofertar por rapidez comiendo
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@NotNull @NotNull
private Integer gold; // x minutos @Min(0)
private Integer gold;
@Column(name = "discount_gold") @Column(name = "discount_gold")
@NotBlank @NotNull
private String discountGold; @Min(0)
private Integer discountGold;
@NotNull @NotNull
@Min(0)
private Integer silver; private Integer silver;
@Column(name = "discount_silver") @Column(name = "discount_silver")
@NotBlank @NotNull
private String discountSilver; @Min(0)
private Integer discountSilver;
@NotNull @NotNull
@Min(0)
private Integer bronze; private Integer bronze;
@Column(name = "discount_bronze") @Column(name = "discount_bronze")
@NotBlank @NotNull
private String discountBronze; @Min(0)
private Integer discountBronze;
public Integer getGold() { public Integer getGold() {
return gold; return gold;
@ -41,11 +48,11 @@ public class SpeedOffer extends Offer {
this.gold = gold; this.gold = gold;
} }
public String getDiscountGold() { public Integer getDiscountGold() {
return discountGold; return discountGold;
} }
public void setDiscountGold(String discountGold) { public void setDiscountGold(Integer discountGold) {
this.discountGold = discountGold; this.discountGold = discountGold;
} }
@ -57,11 +64,11 @@ public class SpeedOffer extends Offer {
this.silver = silver; this.silver = silver;
} }
public String getDiscountSilver() { public Integer getDiscountSilver() {
return discountSilver; return discountSilver;
} }
public void setDiscountSilver(String discountSilver) { public void setDiscountSilver(Integer discountSilver) {
this.discountSilver = discountSilver; this.discountSilver = discountSilver;
} }
@ -73,12 +80,12 @@ public class SpeedOffer extends Offer {
this.bronze = bronze; this.bronze = bronze;
} }
public String getDiscountBronze() { public Integer getDiscountBronze() {
return discountBronze; return discountBronze;
} }
public void setDiscountBronze(String discountBronze) { public void setDiscountBronze(Integer discountBronze) {
this.discountBronze = discountBronze; this.discountBronze = discountBronze;
} }
} }

View file

@ -4,7 +4,6 @@ import java.time.LocalTime;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -12,13 +11,11 @@ import org.springframework.format.annotation.DateTimeFormat;
@Entity @Entity
@Table(name = "time_offers") @Table(name = "time_offers")
public class TimeOffer extends Offer { public class TimeOffer extends Offer {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
//Oferta por franja horaria // Oferta por franja horaria
@DateTimeFormat(pattern = "HH:mm") @DateTimeFormat(pattern = "HH:mm")
@NotNull @NotNull
private LocalTime init; private LocalTime init;
@ -27,8 +24,8 @@ public class TimeOffer extends Offer {
@NotNull @NotNull
private LocalTime finish; private LocalTime finish;
@NotBlank @NotNull
private String discount; private Integer discount;
public LocalTime getInit() { public LocalTime getInit() {
return init; return init;
@ -46,11 +43,11 @@ public class TimeOffer extends Offer {
this.finish = finish; this.finish = finish;
} }
public String getDiscount() { public Integer getDiscount() {
return discount; return discount;
} }
public void setDiscount(String discount) { public void setDiscount(Integer discount) {
this.discount = discount; this.discount = discount;
} }

View file

@ -10,5 +10,5 @@ public interface ClientRepository extends CrudRepository<Client, String> {
@Query("SELECT client FROM Client client WHERE username =:username") @Query("SELECT client FROM Client client WHERE username =:username")
@Transactional(readOnly = true) @Transactional(readOnly = true)
Client findByUsername(String username); Client findByUsername(String username);
} }

View file

@ -1,37 +1,36 @@
package org.springframework.cheapy.service;
package org.springframework.cheapy.service;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.NuOffer; import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.repository.NuOfferRepository; import org.springframework.cheapy.repository.NuOfferRepository;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class NuOfferService { public class NuOfferService {
private NuOfferRepository nuOfferRepository;
private NuOfferRepository nuOfferRepository;
@Autowired @Autowired
public NuOfferService(final NuOfferRepository nuOfferRepository) { public NuOfferService(final NuOfferRepository nuOfferRepository) {
this.nuOfferRepository = nuOfferRepository; this.nuOfferRepository = nuOfferRepository;
} }
@Transactional
public NuOffer findNuOfferById(final int id) { public NuOffer findNuOfferById(final int id) {
return this.nuOfferRepository.findNuOfferById(id); return this.nuOfferRepository.findNuOfferById(id);
} }
public List<NuOffer> findAllNuOffer() { //
return this.nuOfferRepository.findAllNuOffer();
@Transactional
public List<NuOffer> findAllNuOffer() {
return this.nuOfferRepository.findAllNuOffer();
} }
@Transactional
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { // public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException {
this.nuOfferRepository.save(nuOffer); this.nuOfferRepository.save(nuOffer);
} }
} }

View file

@ -1,13 +1,13 @@
package org.springframework.cheapy.service; package org.springframework.cheapy.service;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.SpeedOffer; import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.repository.SpeedOfferRepository; import org.springframework.cheapy.repository.SpeedOfferRepository;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class SpeedOfferService { public class SpeedOfferService {
@ -20,19 +20,18 @@ public class SpeedOfferService {
this.speedOfferRepository = speedOfferRepository; this.speedOfferRepository = speedOfferRepository;
} }
@Transactional
public SpeedOffer findSpeedOfferById(final int id) { public SpeedOffer findSpeedOfferById(final int id) {
return this.speedOfferRepository.findById(id); return this.speedOfferRepository.findById(id);
} }
@Transactional
public List<SpeedOffer> findAllSpeedOffer() { // public List<SpeedOffer> findAllSpeedOffer() { //
return this.speedOfferRepository.findAllSpeedOffer(); return this.speedOfferRepository.findAllSpeedOffer();
} }
@Transactional
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
this.speedOfferRepository.save(speedOffer); this.speedOfferRepository.save(speedOffer);
} }
} }

View file

@ -1,6 +1,7 @@
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; import javax.validation.Valid;
@ -25,12 +26,12 @@ public class FoodOfferController {
private final FoodOfferService foodOfferService; private final FoodOfferService foodOfferService;
private final ClientService clientService; private final ClientService clientService;
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) { public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
this.foodOfferService = foodOfferService; this.foodOfferService = foodOfferService;
this.clientService = clientService; this.clientService = clientService;
} }
@GetMapping("/offers/food/new") @GetMapping("/offers/food/new")
public String initCreationForm(Map<String, Object> model) { public String initCreationForm(Map<String, Object> model) {
FoodOffer foodOffer = new FoodOffer(); FoodOffer foodOffer = new FoodOffer();
@ -42,11 +43,10 @@ public class FoodOfferController {
public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) { public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) {
if (result.hasErrors()) { if (result.hasErrors()) {
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM; return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
} } else {
else {
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
foodOffer.setClient(client); foodOffer.setClient(client);
foodOffer.setType(StatusOffer.hidden); foodOffer.setStatus(StatusOffer.hidden);
this.foodOfferService.saveFoodOffer(foodOffer); this.foodOfferService.saveFoodOffer(foodOffer);
return "redirect:/offers/food/" + foodOffer.getId(); return "redirect:/offers/food/" + foodOffer.getId();
} }
@ -56,9 +56,9 @@ public class FoodOfferController {
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) { public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId); FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
if(foodOffer.getClient().equals(client)) { if (foodOffer.getClient().equals(client)) {
foodOffer.setType(StatusOffer.active); foodOffer.setStatus(StatusOffer.active);
foodOffer.setCode("FO-"+foodOfferId); foodOffer.setCode("FO-" + foodOfferId);
this.foodOfferService.saveFoodOffer(foodOffer); this.foodOfferService.saveFoodOffer(foodOffer);
} else { } else {
modelMap.addAttribute("message", "You don't have access to this food offer"); modelMap.addAttribute("message", "You don't have access to this food offer");
@ -66,14 +66,63 @@ public class FoodOfferController {
return "redirect:/offers/food/"+foodOfferId; return "redirect:/offers/food/"+foodOfferId;
} }
@GetMapping("/offers/food/{foodOfferId}") @GetMapping("/offers/food/{foodOfferId}")
public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) { public String processShowForm(@PathVariable("foodOfferId") int foodOfferId, Map<String, Object> model) {
FoodOffer foodOffer=this.foodOfferService.findFoodOfferById(foodOfferId); FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
model.put("foodOffer", foodOffer); model.put("foodOffer", foodOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/food/foodOffersShow"; return "offers/food/foodOffersShow";
} }
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
model.addAttribute("foodOffer", foodOffer);
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
}
@PostMapping(value = "/offers/food/{foodOfferId}/edit")
public String updateFoodOffer(@Valid final FoodOffer foodOfferEdit, final BindingResult result,
final ModelMap model) {
if (result.hasErrors()) {
model.addAttribute("foodOffer", foodOfferEdit);
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
} else {
this.foodOfferService.saveFoodOffer(foodOfferEdit);
return "redirect:/offers/food/" + foodOfferEdit.getId();
}
}
@GetMapping(value = "/offers/food/{foodOfferId}/disable")
public String disableFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
model.put("foodOffer", foodOffer);
return "foodOffers/foodOffersDisable";
}
@PostMapping(value = "/offers/food/{foodOfferId}/disable")
public String disableFoodOfferForm(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
foodOffer.setStatus(StatusOffer.inactive);
this.foodOfferService.saveFoodOffer(foodOffer);
return "redirect:/offers";
}
} }

View file

@ -1,22 +1,24 @@
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.security.Principal;
import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.NuOffer; import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.service.ClientService; import org.springframework.cheapy.service.ClientService;
import org.springframework.cheapy.service.NuOfferService; import org.springframework.cheapy.service.NuOfferService;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@Controller @Controller
public class NuOfferController { public class NuOfferController {
@ -25,13 +27,9 @@ public class NuOfferController {
private final NuOfferService nuOfferService; private final NuOfferService nuOfferService;
private final ClientService clientService; private final ClientService clientService;
public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) {
public NuOfferController(final NuOfferService nuOfferService,ClientService clientService) {
this.nuOfferService = nuOfferService; this.nuOfferService = nuOfferService;
this.clientService = clientService; this.clientService = clientService;
}
@ -46,48 +44,86 @@ public class NuOfferController {
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) { public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
if (result.hasErrors()) { if (result.hasErrors()) {
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} } else {
else { nuOffer.setStatus(StatusOffer.hidden);
nuOffer.setType(StatusOffer.hidden);
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
nuOffer.setClient(client); nuOffer.setClient(client);
this.nuOfferService.saveNuOffer(nuOffer); this.nuOfferService.saveNuOffer(nuOffer);
return "redirect:/offers/nu/"+nuOffer.getId(); return "redirect:/offers/nu/"+nuOffer.getId();
} }
} }
@GetMapping(value ="/offers/nu/{nuOfferId}/activate") @GetMapping(value ="/offers/nu/{nuOfferId}/activate")
public String activateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap modelMap) { public String activateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap modelMap) {
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId); NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
if(nuOffer.getClient().equals(client)) { if (nuOffer.getClient().equals(client)) {
nuOffer.setType(StatusOffer.active); nuOffer.setStatus(StatusOffer.active);
nuOffer.setCode("NU-"+nuOfferId); nuOffer.setCode("NU-" + nuOfferId);
this.nuOfferService.saveNuOffer(nuOffer); this.nuOfferService.saveNuOffer(nuOffer);
} else { } else {
modelMap.addAttribute("message", "You don't have access to this number offer"); modelMap.addAttribute("message", "You don't have access to this number offer");
} }
return "redirect:/offers/nu/"+nuOffer.getId(); return "redirect:/nuOffers/"+ nuOffer.getId();
} }
@GetMapping("/offers/nu/{nuOfferId}")
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId); @GetMapping("/offers/nu/{nuOfferId}")
public String processShowForm(@PathVariable("nuOfferId") int nuOfferId, Map<String, Object> model) {
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
model.put("nuOffer", nuOffer); model.put("nuOffer", nuOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/nu/nuOffersShow"; return "offers/nu/nuOffersShow";
} }
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
model.addAttribute("nuOffer", nuOffer);
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model) {
if (result.hasErrors()) {
model.addAttribute("nuOffer", nuOfferEdit);
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} else {
this.nuOfferService.saveNuOffer(nuOfferEdit);
return "redirect:/offers/nu/" + nuOfferEdit.getId();
}
}
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
final ModelMap model) {
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
model.put("nuOffer", nuOffer);
return "nuOffers/nuOffersDisable";
}
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
final ModelMap model) {
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
nuOffer.setStatus(StatusOffer.inactive);
this.nuOfferService.saveNuOffer(nuOffer);
return "redirect:/offers";
}
} }

View file

@ -1,5 +1,6 @@
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -43,6 +44,9 @@ public class OfertaController {
model.put("speedOfferLs", speedOfferLs); model.put("speedOfferLs", speedOfferLs);
model.put("timeOfferLs", timeOfferLs); model.put("timeOfferLs", timeOfferLs);
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/offersList"; return "offers/offersList";
} }

View file

@ -1,28 +1,13 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.SpeedOffer; import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.StatusOffer; import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.service.ClientService; import org.springframework.cheapy.service.ClientService;
import org.springframework.cheapy.service.SpeedOfferService; import org.springframework.cheapy.service.SpeedOfferService;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -45,6 +30,7 @@ public class SpeedOfferController {
this.clientService = clientService; this.clientService = clientService;
} }
@GetMapping("/offers/speed/new") @GetMapping("/offers/speed/new")
public String initCreationForm(Map<String, Object> model) { public String initCreationForm(Map<String, Object> model) {
SpeedOffer speedOffer = new SpeedOffer(); SpeedOffer speedOffer = new SpeedOffer();
@ -56,35 +42,82 @@ public class SpeedOfferController {
public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) { public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) {
if (result.hasErrors()) { if (result.hasErrors()) {
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM; return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} } else {
else {
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
speedOffer.setClient(client); speedOffer.setClient(client);
speedOffer.setType(StatusOffer.hidden); speedOffer.setStatus(StatusOffer.hidden);
this.speedOfferService.saveSpeedOffer(speedOffer); this.speedOfferService.saveSpeedOffer(speedOffer);
return "redirect:/offers/speed/" + speedOffer.getId(); return "redirect:/offers/speed/" + speedOffer.getId();
} }
} }
@GetMapping(value = "/offers/speed/{speedOfferId}/activate") @GetMapping(value = "/offers/speed/{speedOfferId}/activate")
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) { public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId); SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
if(speedOffer.getClient().equals(client)) { if (speedOffer.getClient().equals(client)) {
speedOffer.setType(StatusOffer.active); speedOffer.setStatus(StatusOffer.active);
speedOffer.setCode("SP-"+speedOfferId); speedOffer.setCode("SP-" + speedOfferId);
this.speedOfferService.saveSpeedOffer(speedOffer); this.speedOfferService.saveSpeedOffer(speedOffer);
} else { } else {
modelMap.addAttribute("message", "You don't have access to this speed offer"); modelMap.addAttribute("message", "You don't have access to this speed offer");
} }
return "redirect:/offers/speed/" + speedOffer.getId(); return "redirect:/offers/speed/" + speedOffer.getId();
} }
@GetMapping("/offers/speed/{speedOfferId}") @GetMapping("/offers/speed/{speedOfferId}")
public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) { public String processShowForm(@PathVariable("speedOfferId") int speedOfferId, Map<String, Object> model) {
SpeedOffer speedOffer=this.speedOfferService.findSpeedOfferById(speedOfferId); SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
model.put("speedOffer", speedOffer); model.put("speedOffer", speedOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/speed/speedOffersShow"; return "offers/speed/speedOffersShow";
} }
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
model.addAttribute("speedOffer", speedOffer);
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
@PostMapping(value = "/offers/speed/{speedOfferId}/edit")
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result, final ModelMap model) {
if (result.hasErrors()) {
model.addAttribute("speedOffer", speedOfferEdit);
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} else {
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
return "redirect:/offers/speed/" + speedOfferEdit.getId();
}
}
@GetMapping(value = "/offers/speed/{speedOfferId}/disable")
public String disableSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
model.put("speedOffer", speedOffer);
return "speedOffers/speedOffersDisable";
}
@PostMapping(value = "/offers/speed/{speedOfferId}/disable")
public String disableSpeedOfferForm(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
speedOffer.setStatus(StatusOffer.inactive);
this.speedOfferService.saveSpeedOffer(speedOffer);
return "redirect:/offers";
}
} }

View file

@ -1,5 +1,7 @@
package org.springframework.cheapy.web; package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
import javax.validation.Valid; import javax.validation.Valid;
@ -16,75 +18,119 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@Controller @Controller
public class TimeOfferController { public class TimeOfferController {
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
private final TimeOfferService timeOfferService; private final TimeOfferService timeOfferService;
private final ClientService clientService; private final ClientService clientService;
public TimeOfferController(final TimeOfferService timeOfferService, ClientService clientService) {
public TimeOfferController(final TimeOfferService timeOfferService,ClientService clientService) {
this.timeOfferService = timeOfferService; this.timeOfferService = timeOfferService;
this.clientService = clientService; this.clientService = clientService;
}
@GetMapping("/offers/time/new") @GetMapping("/offers/time/new")
public String initCreationForm(Map<String, Object> model) { public String initCreationForm(Map<String, Object> model) {
TimeOffer timeOffer = new TimeOffer(); TimeOffer timeOffer = new TimeOffer();
model.put("timeOffer", timeOffer); model.put("timeOffer", timeOffer);
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
} }
@PostMapping("/offers/time/new") @PostMapping("/offers/time/new")
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) { public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
if (result.hasErrors()) { if (result.hasErrors()) {
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM; return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
} } else {
else { timeOffer.setStatus(StatusOffer.hidden);
timeOffer.setType(StatusOffer.hidden);
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
timeOffer.setClient(client); timeOffer.setClient(client);
this.timeOfferService.saveTimeOffer(timeOffer); this.timeOfferService.saveTimeOffer(timeOffer);
return "redirect:/offers/time/" + timeOffer.getId(); return "redirect:/offers/time/" + timeOffer.getId();
} }
} }
@GetMapping(value ="/offers/time/{timeOfferId}/activate") @GetMapping(value ="/offers/time/{timeOfferId}/activate")
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) { public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
Client client = this.clientService.getCurrentClient(); Client client = this.clientService.getCurrentClient();
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId); TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
if(timeOffer.getClient().equals(client)) { if (timeOffer.getClient().equals(client)) {
timeOffer.setType(StatusOffer.active); timeOffer.setStatus(StatusOffer.active);
timeOffer.setCode("TI-"+timeOfferId); timeOffer.setCode("TI-" + timeOfferId);
this.timeOfferService.saveTimeOffer(timeOffer); this.timeOfferService.saveTimeOffer(timeOffer);
} else { } else {
modelMap.addAttribute("message", "You don't have access to this time offer"); modelMap.addAttribute("message", "You don't have access to this time offer");
} }
return "redirect:/offers/time/" + timeOffer.getId(); return "redirect:/timeOffers/" + timeOffer.getId();
} }
@GetMapping("/offers/time/{timeOfferId}") @GetMapping("/offers/time/{timeOfferId}")
public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) { public String processShowForm(@PathVariable("timeOfferId") int timeOfferId, Map<String, Object> model) {
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId); TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
model.put("timeOffer", timeOffer); model.put("timeOffer", timeOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/time/timeOffersShow"; return "offers/time/timeOffersShow";
} }
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
model.addAttribute("timeOffer", timeOffer);
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
}
@PostMapping(value = "/offers/time/{timeOfferId}/edit")
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result, final ModelMap model) {
if (result.hasErrors()) {
model.addAttribute("timeOffer", timeOfferEdit);
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
} else {
this.timeOfferService.saveTimeOffer(timeOfferEdit);
return "redirect:/offers/time/" + timeOfferEdit.getId();
}
}
@GetMapping(value = "/offers/time/{timeOfferId}/disable")
public String disableTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
model.put("timeOffer", timeOffer);
return "timeOffers/timeOffersDisable";
}
@PostMapping(value = "/offers/time/{timeOfferId}/disable")
public String disableTimeOfferForm(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
timeOffer.setStatus(StatusOffer.inactive);
this.timeOfferService.saveTimeOffer(timeOffer);
return "redirect:/offers";
}
} }

View file

@ -47,10 +47,10 @@
@pagination-active-bg: @spring-brown; @pagination-active-bg: @spring-brown;
@pagination-active-border: @spring-blue; @pagination-active-border: @spring-blue;
@table-border-color: @spring-brown; @table-border-color: rgb(0, 64, 128);
.table > thead > tr > th { .table > thead > tr > th {
background-color: lighten(@spring-brown, 3%); background-color: rgb(40, 140, 215);
color: @spring-light-grey; color: @spring-light-grey;
} }
@ -237,7 +237,131 @@ img.img-responsive{
.btn-home button:hover { .btn-home button:hover {
background-color: rgb(0, 64, 128); background-color: rgb(40, 140, 215);
}
#foodOfferTable th {
width: 25%;
}
#nuOfferTable th {
width: 33%;
}
#speedOfferTable th {
width: 33%;
}
#timeOfferTable th {
width: 33%;
}
.btn-detalles button {
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
display: block;
float: right;
}
.btn-detalles button:not(:last-child) {
border-bottom: none;
}
.btn-detalles button:hover {
background-color: rgb(40, 140, 215);
}
.btn-return{
display: table;
margin: 0 auto;
width: 100%;
}
.btn-return button {
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
display: block;
left: 0%;
}
.btn-return button:not(:last-child) {
border-bottom: none;
}
.btn-return button:hover {
background-color: rgb(40, 140, 215);
}
#foodOfferTable td{
vertical-align:middle;
}
#nuOfferTable td{
vertical-align:middle;
}
#speedOfferTable td{
vertical-align:middle;
}
#timeOfferTable td{
vertical-align:middle;
}
#nuOffer-table tr:nth-child(3){
background-color: rgb(255, 215, 0);
}
#nuOffer-table tr:nth-child(4){
background-color: rgb(255, 215, 0);
}
#nuOffer-table tr:nth-child(5){
background-color: rgb(192, 192, 192);
}
#nuOffer-table tr:nth-child(6){
background-color: rgb(192, 192, 192);
}
#nuOffer-table tr:nth-child(7){
background-color: rgb(204, 128, 51);
}
#nuOffer-table tr:nth-child(8){
background-color: rgb(204, 128, 51);
}
#speedOffer-table tr:nth-child(3){
background-color: rgb(255, 215, 0);
}
#speedOffer-table tr:nth-child(4){
background-color: rgb(255, 215, 0);
}
#speedOffer-table tr:nth-child(5){
background-color: rgb(192, 192, 192);
}
#speedOffer-table tr:nth-child(6){
background-color: rgb(192, 192, 192);
}
#speedOffer-table tr:nth-child(7){
background-color: rgb(204, 128, 51);
}
#speedOffer-table tr:nth-child(8){
background-color: rgb(204, 128, 51);
} }
.alert-success { .alert-success {

View file

@ -12,9 +12,11 @@ INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Wa
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','admin','admin', TRUE ); INSERT INTO users (dtype,username,password,enabled) VALUES ('User','admin','admin', TRUE );
INSERT INTO authorities VALUES ('admin','admin'); INSERT INTO authorities VALUES ('admin','admin');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE ); INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE );
INSERT INTO authorities VALUES ('manoli','client'); INSERT INTO authorities VALUES ('manoli','client');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE ); INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE );
INSERT INTO authorities VALUES ('david','client'); INSERT INTO authorities VALUES ('david','client');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','paco','paco', TRUE ); INSERT INTO users (dtype,username,password,enabled) VALUES ('User','paco','paco', TRUE );
INSERT INTO authorities VALUES ('paco','usuario'); INSERT INTO authorities VALUES ('paco','usuario');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','lolo','lolo', TRUE ); INSERT INTO users (dtype,username,password,enabled) VALUES ('User','lolo','lolo', TRUE );
@ -27,11 +29,11 @@ INSERT INTO usuarios VALUES (2, 'Paco', 'Naranjo', '21154416G', 'C/Esperanza', '
INSERT INTO usuarios VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo'); INSERT INTO usuarios VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo');
INSERT INTO usuarios VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690670547', 'Pepe@gmail.com','pepe'); INSERT INTO usuarios VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690670547', 'Pepe@gmail.com','pepe');
INSERT INTO clients VALUES (1,'manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli'); INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (1,'bar manoli','manoli@gmail.com','C/Betis','10:00','22:00','608726190', 'description 1', 'code1', 'ESPAÑOLA','manoli');
INSERT INTO clients VALUES (2,'david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david'); INSERT INTO clients (id, name, email, address, init, finish, telephone, description, code, food, username) VALUES (2,'bar david','david@gmail.com','C/Sevilla','09:30','22:00','608726190', 'description 2', 'code2', 'americana','david');
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'active', 1, 'macarrones', 15);
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'T-1', 'active', 1, '12:00:00', '13:00:00', 10);
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active',1,5,25,10,15,15,10);
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'NU-1', 'active',1,15,25,10,15,5,10);
INSERT INTO food_offers(start, end, code, type, client_id, food, discount, units) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'FO-1', 'active', null, 'macarrones', '15%', 10);
INSERT INTO speed_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'SP-1', 'active', null, 5, '15%', 10, '10%', 15, '5%');
INSERT INTO time_offers(start, end, code, type, client_id, init, finish, discount) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null, '12:00:00', '13:00:00', '10%');
INSERT INTO speed_offers(id,start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES (3,'2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', 1,5,'25%',10,'15%',15,'10%' );
INSERT INTO nu_offers(start, end, code, type, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-06-15 12:00:00', '2021-06-16 12:00:00', 'jkhlljk', 'active', null,15,'25%',10,'15%',5,'10%' );

View file

@ -1,4 +1,6 @@
welcome=Welcome welcome=Welcome to
listOffers=List Offers
required=is required required=is required
notFound=has not been found notFound=has not been found
duplicate=is already in use duplicate=is already in use

View file

@ -1,8 +1,34 @@
welcome=Bienvenido a welcome=Bienvenido a
required=Es requerido listOffers=Ver Ofertas
foodOffers=Ofertas por plato especifico
foodOffer=Oferta por plato especifico
nuOffers=Ofertas por numero de comensales
nuOffer=Oferta por numero de comensales
speedOffers=Ofertas rapidez comiendo
speedOffer=Oferta por comer veloz
timeOffers=Ofertas por franja horaria
timeOffer=Oferta por franja horaria
food=Plato
foodInOffer=Plato en oferta
cuantity=Cantidad
discount=Descuento
goldGoal=Meta oro
goldDiscount=Descuento oro
silverGoal=Meta plata
silverDiscount=Descuento plata
bronzeGoal=Meta bronce
bronzeDiscount=Descuento bronce
startDate=Fecha inicio
offerBeginning=Inicio de la oferta
endDate=Fecha fin
offerEnding=Fin de la oferta
details=Detalles
offerCode=Codigo de la oferta
return=Volver
required=Es requeridOfertas por franja horariao
notFound=No ha sido encontrado notFound=No ha sido encontrado
duplicate=Ya se encuentra en uso duplicate=Ya se encuentra en uso
nonNumeric=Sólo debe contener numeros nonNumeric=Sólo debe contener numeros
duplicateFormSubmission=No se permite el envío de formularios duplicados duplicateFormSubmission=No se permite el envío de formularios duplicados
typeMismatch.date=Fecha invalida typeMismatch.date=Fecha invalida
typeMismatch.birthDate=Fecha invalida typeMismatch.birthDate=Fecha invalida

View file

@ -5,7 +5,7 @@
<cheapy:layout pageName="error"> <cheapy:layout pageName="error">
<h2>Algo malo ha pasado...</h2> <h2 style="text-align:center">Algo malo ha pasado...</h2>
<spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/> <spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/>
<img class="img-responsive" src="${cheapyImage}"/> <img class="img-responsive" src="${cheapyImage}"/>

View file

@ -12,18 +12,23 @@
</h2> </h2>
<form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form"> <form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<form:hidden path="id"/>
<form:hidden path="code"/>
<form:hidden path="status"/>
<petclinic:inputField label="Start Date" name="start"/> <petclinic:inputField label="Start Date" name="start"/>
<petclinic:inputField label="End Date" name="end"/> <petclinic:inputField label="End Date" name="end"/>
<petclinic:inputField label="Food" name="food"/> <petclinic:inputField label="Food" name="food"/>
<petclinic:inputField label="Discount" name="discount"/> <petclinic:inputField label="Discount" name="discount"/>
<petclinic:inputField label="Units" name="units"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<c:choose> <c:choose>
<c:when test="${foodOffer['new']}"> <c:when test="${foodOffer['new']}">
<button class="btn btn-default" type="submit">Add Food Offer</button> <button class="btn btn-default" type="submit">Crear oferta</button>
</c:when> </c:when>
<c:otherwise>
<button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise>
</c:choose> </c:choose>
</div> </div>
</div> </div>

View file

@ -0,0 +1,23 @@
<%@ page session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<petclinic:layout pageName="foodOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
<form:form modelAttribute="foodOffer" class="form-horizontal">
<input type="hidden" name="food" value="${food_offer.food}" />
<input type="hidden" name="discount" value="${food_offer.discount}" />
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
</jsp:body>
</petclinic:layout>

View file

@ -1,44 +1,58 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %> <%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="foodOffer"> <cheapy:layout pageName="foodOffer">
<h2>Oferta por plato específico</h2>
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffer"/></h2>
<table class="table table-striped">
<table class="table table-striped" id="foodOfferTable">
<thead>
<tr> <tr>
<th>Inicio de la oferta</th> <th><fmt:message key="offerBeginning"/></th>
<td><b><c:out value="${foodOffer.start}"/></b></td> <td><c:out value="${localDateTimeFormat.format(foodOffer.start)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Fin de la oferta</th> <th><fmt:message key="offerEnding"/></th>
<td><c:out value="${foodOffer.end}"/></td> <td><c:out value="${localDateTimeFormat.format(foodOffer.end)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Plato en oferta</th> <th><fmt:message key="foodInOffer"/></th>
<td><c:out value="${foodOffer.food}"/></td> <td><c:out value="${foodOffer.food}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento</th> <th><fmt:message key="discount"/></th>
<td><c:out value="${foodOffer.discount}"/></td> <td><c:out value="${foodOffer.discount}"/></td>
</tr> </tr>
<tr> <tr>
<th>Cantidad</th> <th><fmt:message key="offerCode"/></th>
<td><c:out value="${foodOffer.units}"/></td>
</tr>
<tr>
<th>Codigo de la oferta</th>
<td><c:out value="${foodOffer.code}"/></td> <td><c:out value="${foodOffer.code}"/></td>
</tr> </tr>
</thead>
</table> </table>
<div class="btn-return">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="return"/> </button>
</div>
<%-- <spring:url value="{ownerId}/edit" var="editUrl"> <spring:url value="{foodOfferId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%> <a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
<spring:url value="{foodOfferId}/disable" var="editUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
</cheapy:layout> </cheapy:layout>

View file

@ -12,6 +12,9 @@
</h2> </h2>
<form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form"> <form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<form:hidden path="id"/>
<form:hidden path="code"/>
<form:hidden path="status"/>
<petclinic:inputField label="Fecha de inicio" name="start"/> <petclinic:inputField label="Fecha de inicio" name="start"/>
<petclinic:inputField label="Fecha de fin" name="end"/> <petclinic:inputField label="Fecha de fin" name="end"/>
@ -27,10 +30,10 @@
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<c:choose> <c:choose>
<c:when test="${nuOffer['new']}"> <c:when test="${nuOffer['new']}">
<button class="btn btn-default" type="submit">Add Offer</button> <button class="btn btn-default" type="submit">Crear oferta</button>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<button class="btn btn-default" type="submit">Update Offer</button> <button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>

View file

@ -0,0 +1,27 @@
<%@ page session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<petclinic:layout pageName="nuOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
<form:form modelAttribute="nuOffer" class="form-horizontal">
<input type="hidden" name="gold" value="${nu_offer.gold}" />
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
<input type="hidden" name="silver" value="${nu_offer.silver}" />
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
<button class="btn btn-default" type="submit">Dar de baja</button>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
</jsp:body>
</petclinic:layout>

View file

@ -3,35 +3,37 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="nuOffer"> <cheapy:layout pageName="nuOffer">
<h2>Oferta por número de comensales</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="nuOffer"/></h2>
<table class="table table-striped"> <table class="table table-striped" id="nuOffer-table">
<tr> <tr>
<th>Inicio de la oferta</th> <th><fmt:message key="offerBeginning"/></th>
<td><b><c:out value="${nuOffer.start}"/></b></td> <td><c:out value="${localDateTimeFormat.format(nuOffer.start)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Fin de la oferta</th> <th><fmt:message key="offerEnding"/></th>
<td><c:out value="${nuOffer.end}"/></td> <td><c:out value="${localDateTimeFormat.format(nuOffer.end)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Meta oro</th> <th><fmt:message key="goldGoal"/></th>
<td><c:out value="${nuOffer.gold}"/></td> <td><c:out value="${nuOffer.gold}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento oro</th> <th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${nuOffer.discountGold}"/></td> <td><c:out value="${nuOffer.discountGold}"/></td>
</tr> </tr>
<tr> <tr>
<th>Meta plata</th> <th><fmt:message key="silverGoal"/></th>
<td><c:out value="${nuOffer.silver}"/></td> <td><c:out value="${nuOffer.silver}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento plata</th> <th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${nuOffer.discountSilver}"/></td> <td><c:out value="${nuOffer.discountSilver}"/></td>
</tr> </tr>
<tr> <tr>
@ -39,18 +41,29 @@
<td><c:out value="${nuOffer.bronze}"/></td> <td><c:out value="${nuOffer.bronze}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento bronce</th> <th><fmt:message key="bronzeDiscount"/></th>
<td><c:out value="${nuOffer.discountBronze}"/></td> <td><c:out value="${nuOffer.discountBronze}"/></td>
</tr> </tr>
<tr> <tr>
<th>Codigo de la oferta</th> <th><fmt:message key="offerCode"/></th>
<td><c:out value="${nuOffer.code}"/></td> <td><c:out value="${nuOffer.code}"/></td>
</tr> </tr>
</table> </table>
<div class="btn-return">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="return"/> </button>
</div>
<%-- <spring:url value="{ownerId}/edit" var="editUrl"> <spring:url value="{nuOfferId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%> <a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
<spring:url value="{nuOfferId}/disable" var="editUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
</cheapy:layout> </cheapy:layout>

View file

@ -4,17 +4,18 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="ofertas"> <cheapy:layout pageName="ofertas">
<h2>Ofertas por plato específico</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
<table id="foodOfferTable" class="table table-striped"> <table id="foodOfferTable" class="table table-striped">
<thead> <thead>
<tr> <tr>
<!-- <th style="width: 150px;">Restaurante</th> --> <!-- <th style="width: 150px;">Restaurante</th> -->
<th style="width: 150px;">Plato</th> <th><fmt:message key="food"/></th>
<th style="width: 150px;">Fecha inicio</th> <th><fmt:message key="startDate"/></th>
<th style="width: 200px;">Fecha fin</th> <th><fmt:message key="endDate"/></th>
<th> </th> <th> </th>
</tr> </tr>
</thead> </thead>
@ -25,16 +26,20 @@
<c:out value="${foodOffer.food}"/> <c:out value="${foodOffer.food}"/>
</td> </td>
<td> <td>
<c:out value="${foodOffer.start}"/> <c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
</td> </td>
<td> <td>
<c:out value="${foodOffer.end}"/> <c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
</td> </td>
<td> <td>
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl"> <spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/> <spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(foodOfferUrl)}"/>Enlace</a> <div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/></button>
</div>
</td> </td>
</tr> </tr>
@ -42,14 +47,14 @@
</tbody> </tbody>
</table> </table>
<h2>Ofertas por número de comensales</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
<table id="nuOfferTable" class="table table-striped"> <table id="nuOfferTable" class="table table-striped">
<thead> <thead>
<tr> <tr>
<!-- <th style="width: 150px;">Restaurante</th> --> <!-- <th style="width: 150px;">Restaurante</th> -->
<th style="width: 150px;">Fecha inicio</th> <th><fmt:message key="startDate"/></th>
<th style="width: 200px;">Fecha fin</th> <th><fmt:message key="endDate"/></th>
<th> </th> <th> </th>
</tr> </tr>
@ -59,29 +64,33 @@
<tr> <tr>
<td> <td>
<c:out value="${nuOffer.start}"/> <c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
</td> </td>
<td> <td>
<c:out value="${nuOffer.end}"/> <c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
</td> </td>
<td> <td>
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl"> <spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/> <spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(nuOfferUrl)}"/>Enlace</a> <div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>
</tbody> </tbody>
</table> </table>
<h2>Ofertas rapidez comiendo</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
<table id="speedOfferTable" class="table table-striped"> <table id="speedOfferTable" class="table table-striped">
<thead> <thead>
<tr> <tr>
<!-- <th style="width: 150px;">Restaurante</th> --> <!-- <th style="width: 150px;">Restaurante</th> -->
<th style="width: 150px;">Fecha inicio</th> <th><fmt:message key="startDate"/></th>
<th style="width: 200px;">Fecha fin</th> <th><fmt:message key="endDate"/></th>
<th> </th> <th> </th>
</tr> </tr>
@ -91,30 +100,34 @@
<tr> <tr>
<td> <td>
<c:out value="${speedOffer.start}"/> <c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
</td> </td>
<td> <td>
<c:out value="${speedOffer.end}"/> <c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
</td> </td>
<td> <td>
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl"> <spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/> <spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(speedOfferUrl)}"/>Enlace</a> <div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>
</tbody> </tbody>
</table> </table>
<h2>Ofertas por franja horaria</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
<table id="timeOfferTable" class="table table-striped"> <table id="timeOfferTable" class="table table-striped">
<thead> <thead>
<tr> <tr>
<!-- <th style="width: 150px;">Restaurante</th> --> <!-- <th style="width: 150px;">Restaurante</th> -->
<th style="width: 150px;">Fecha inicio</th> <th><fmt:message key="startDate"/></th>
<th style="width: 200px;">Fecha fin</th> <th><fmt:message key="endDate"/></th>
<th> </th> <th> </th>
</tr> </tr>
</thead> </thead>
@ -123,16 +136,20 @@
<tr> <tr>
<td> <td>
<c:out value="${timeOffer.start}"/> <c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
</td> </td>
<td> <td>
<c:out value="${timeOffer.end}"/> <c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
</td> </td>
<td> <td>
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl"> <spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/> <spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(timeOfferUrl)}"/>Enlace</a> <div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>

View file

@ -12,6 +12,9 @@
</h2> </h2>
<form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form"> <form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<form:hidden path="id"/>
<form:hidden path="code"/>
<form:hidden path="status"/>
<petclinic:inputField label="Start Date" name="start"/> <petclinic:inputField label="Start Date" name="start"/>
<petclinic:inputField label="End Date" name="end"/> <petclinic:inputField label="End Date" name="end"/>
<petclinic:inputField label="Gold" name="gold"/> <petclinic:inputField label="Gold" name="gold"/>
@ -25,8 +28,11 @@
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
<c:choose> <c:choose>
<c:when test="${speedOffer['new']}"> <c:when test="${speedOffer['new']}">
<button class="btn btn-default" type="submit">Add Speed Offer</button> <button class="btn btn-default" type="submit">Crear oferta</button>
</c:when> </c:when>
<c:otherwise>
<button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise>
</c:choose> </c:choose>
</div> </div>
</div> </div>

View file

@ -0,0 +1,27 @@
<%@ page session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<petclinic:layout pageName="speedOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
<form:form modelAttribute="speedOffer" class="form-horizontal">
<input type="hidden" name="gold" value="${nu_offer.gold}" />
<input type="hidden" name="discountGold" value="${nu_offer.discount_gold}" />
<input type="hidden" name="silver" value="${nu_offer.silver}" />
<input type="hidden" name="discountSilver" value="${nu_offer.discount_silver}" />
<input type="hidden" name="bronze" value="${nu_offer.bronze}" />
<input type="hidden" name="discountBronze" value="${nu_offer.discount_bronze}" />
<button class="btn btn-default" type="submit">Dar de baja</button>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
</jsp:body>
</petclinic:layout>

View file

@ -3,54 +3,67 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="speedOffer"> <cheapy:layout pageName="speedOffer">
<h2>Oferta por comer veloz</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="speedOffer"/></h2>
<table class="table table-striped"> <table class="table table-striped" id="speedOffer-table">
<tr> <tr>
<th>Inicio de la oferta</th> <th><fmt:message key="offerBeginning"/></th>
<td><b><c:out value="${speedOffer.start}"/></b></td> <td><c:out value="${localDateTimeFormat.format(speedOffer.start)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Fin de la oferta</th> <th><fmt:message key="offerEnding"/></th>
<td><c:out value="${speedOffer.end}"/></td> <td><c:out value="${localDateTimeFormat.format(speedOffer.end)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Meta oro</th> <th><fmt:message key="goldGoal"/></th>
<td><c:out value="${speedOffer.gold}"/></td> <td><c:out value="${speedOffer.gold}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento oro</th> <th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${speedOffer.discountGold}"/></td> <td><c:out value="${speedOffer.discountGold}"/></td>
</tr> </tr>
<tr> <tr>
<th>Meta plata</th> <th><fmt:message key="silverGoal"/></th>
<td><c:out value="${speedOffer.silver}"/></td> <td><c:out value="${speedOffer.silver}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento plata</th> <th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${speedOffer.discountSilver}"/></td> <td><c:out value="${speedOffer.discountSilver}"/></td>
</tr> </tr>
<tr> <tr>
<th>Meta bronce</th> <th><fmt:message key="bronzeGoal"/></th>
<td><c:out value="${speedOffer.bronze}"/></td> <td><c:out value="${speedOffer.bronze}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento bronce</th> <th><fmt:message key="bronzeDiscount"/></th>
<td><c:out value="${speedOffer.discountBronze}"/></td> <td><c:out value="${speedOffer.discountBronze}"/></td>
</tr> </tr>
<tr> <tr>
<th>Codigo de la oferta</th> <th><fmt:message key="offerCode"/></th>
<td><c:out value="${speedOffer.code}"/></td> <td><c:out value="${speedOffer.code}"/></td>
</tr> </tr>
</table> </table>
<div class="btn-return">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="return"/> </button>
</div>
<%-- <spring:url value="{ownerId}/edit" var="editUrl"> <spring:url value="{speedOfferId}/edit" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a> --%> <a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
<spring:url value="{speedOfferId}/disable" var="editUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
</cheapy:layout> </cheapy:layout>

View file

@ -12,6 +12,9 @@
</h2> </h2>
<form:form modelAttribute="timeOffer" class="form-horizontal" id="add-timeOffer-form"> <form:form modelAttribute="timeOffer" class="form-horizontal" id="add-timeOffer-form">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<form:hidden path="id"/>
<form:hidden path="code"/>
<form:hidden path="status"/>
<petclinic:inputField label="Fecha de inicio" name="start"/> <petclinic:inputField label="Fecha de inicio" name="start"/>
<petclinic:inputField label="Fecha de fin" name="end"/> <petclinic:inputField label="Fecha de fin" name="end"/>

View file

@ -0,0 +1,24 @@
<%@ page session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<petclinic:layout pageName="foodOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
<form:form modelAttribute="foodOffer" class="form-horizontal">
<input type="hidden" name="init" value="${time_offer.init}" />
<input type="hidden" name="finish" value="${time_offer.finish}" />
<input type="hidden" name="discount" value="${time_offer.discount}" />
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
</jsp:body>
</petclinic:layout>

View file

@ -3,29 +3,49 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="timeOffer"> <cheapy:layout pageName="timeOffer">
<h2>Oferta por franja horária</h2> <h2 style="text-align:center;padding:5px"><fmt:message key="timeOffer"/></h2>
<table class="table table-striped"> <table class="table table-striped">
<thead>
<tr> <tr>
<th>Inicio de la oferta</th> <th><fmt:message key="offerBeginning"/></th>
<td><b><c:out value="${timeOffer.start}"/></b></td> <td><c:out value="${localDateTimeFormat.format(timeOffer.start)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Fin de la oferta</th> <th><fmt:message key="offerEnding"/></th>
<td><c:out value="${timeOffer.end}"/></td> <td><c:out value="${localDateTimeFormat.format(timeOffer.end)}"/></td>
</tr> </tr>
<tr> <tr>
<th>Descuento</th> <th><fmt:message key="discount"/></th>
<td><c:out value="${timeOffer.discount}"/></td> <td><c:out value="${timeOffer.discount}"/></td>
</tr> </tr>
<tr> <tr>
<th>Codigo de la oferta</th> <th><fmt:message key="offerCode"/></th>
<td><c:out value="${timeOffer.code}"/></td> <td><c:out value="${timeOffer.code}"/></td>
</tr> </tr>
</thead>
</table> </table>
<spring:url value="{timeOfferId}/edit" var="editUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Editar oferta</a>
<spring:url value="{timeOfferId}/disable" var="editUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Desactivar oferta</a>
<div class="btn-return">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="return"/> </button>
</div>
</cheapy:layout> </cheapy:layout>

View file

@ -14,8 +14,9 @@
<img class="img-responsive" src="${cheapyImage}"/> <img class="img-responsive" src="${cheapyImage}"/>
</div> </div>
<div class="btn-home"> <div class="btn-home">
<a href="/offers"><button type="button" style="font-family: 'Lobster'; font-size: 20px;"> <button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="margin-right:8px"></span>Ver Ofertas</button></a> <span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="listOffers"/> </button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -34,12 +34,13 @@
<span>Ver ofertas</span> <span>Ver ofertas</span>
</cheapy:menuItem> </cheapy:menuItem>
<!--
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos" <cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
title="contactanos"> title="contactanos">
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span> <span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
<span>Contáctanos</span> <span>Contáctanos</span>
</cheapy:menuItem> </cheapy:menuItem>
-->
</ul> </ul>
@ -48,7 +49,7 @@
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<sec:authorize access="!isAuthenticated()"> <sec:authorize access="!isAuthenticated()">
<li><a href="<c:url value="/login" />">Login</a></li> <li><a href="<c:url value="/login" />">Login</a></li>
<li><a href="<c:url value="/users/new" />">Register</a></li> <!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
</sec:authorize> </sec:authorize>
<sec:authorize access="isAuthenticated()"> <sec:authorize access="isAuthenticated()">
<li class="dropdown"><a href="#" class="dropdown-toggle" <li class="dropdown"><a href="#" class="dropdown-toggle"
@ -59,10 +60,10 @@
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<div class="navbar-login"> <div class="navbar-login">
<div class="row"> <div class="row" >
<div class="col-lg-4"> <div class="col-lg-4" style="">
<p class="text-center"> <p class="text-center">
<span class="glyphicon glyphicon-user icon-size"></span> <span class="glyphicon glyphicon-user icon-size" ></span>
</p> </p>
</div> </div>
<div class="col-lg-8"> <div class="col-lg-8">
@ -71,7 +72,7 @@
</p> </p>
<form action="/logout" method=post> <form action="/logout" method=post>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<input type="submit" value="logout"> <input type="submit" value="logout" style="align-content:center;color:white;background-color:#004080;padding:10px; border:none; text-align:center">
</form> </form>
</div> </div>
</div> </div>

View file

@ -5,6 +5,6 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12 text-center"><img src="<spring:url value="/resources/images/eslogan.png" htmlEscape="true" />" <div class="col-12 text-center"><img src="<spring:url value="/resources/images/eslogan.png" htmlEscape="true" />"
alt="Sponsored by Pivotal"/></div> alt="Eat fast, eat cheapy"/></div>
</div> </div>
</div> </div>