mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 07:45:49 +00:00
Merge branch 'develop' into 009-cambiarVistas
This commit is contained in:
commit
9ab1bf2ccf
27 changed files with 646 additions and 296 deletions
|
@ -36,7 +36,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
|
||||
.antMatchers("/users/new").permitAll()
|
||||
|
||||
.antMatchers("/nuOffers/**").hasAnyAuthority("admin","client")
|
||||
.antMatchers("/nuOffers/**").hasAnyAuthority("admin","cliente")
|
||||
.antMatchers("/timeOffers/**").hasAnyAuthority("admin","client")
|
||||
|
||||
.antMatchers("/login/**").anonymous()
|
||||
|
@ -49,7 +49,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
|
||||
|
||||
.antMatchers("/clients/new").permitAll()
|
||||
.antMatchers("/offers/**").permitAll()
|
||||
.antMatchers("/offers/**").hasAnyAuthority("admin", "cliente")
|
||||
|
||||
|
||||
.and().formLogin()
|
||||
.loginPage("/login").permitAll()
|
||||
|
|
|
@ -14,27 +14,29 @@ import javax.validation.constraints.NotEmpty;
|
|||
|
||||
@Entity
|
||||
@Table(name = "clients")
|
||||
public class Client extends BaseEntity{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Client extends BaseEntity {
|
||||
|
||||
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
|
||||
private String email;
|
||||
|
||||
|
||||
@NotEmpty
|
||||
private String address;
|
||||
|
||||
//@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotBlank
|
||||
private String init;
|
||||
// Hora de apertura del local
|
||||
@NotBlank
|
||||
private String init;
|
||||
|
||||
//@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotBlank
|
||||
private String finish;
|
||||
// Hora de cierre del local
|
||||
@NotBlank
|
||||
private String finish;
|
||||
|
||||
@NotEmpty
|
||||
@Digits(fraction = 0, integer = 10)
|
||||
|
@ -43,38 +45,45 @@ public class Client extends BaseEntity{
|
|||
@NotEmpty
|
||||
private String description;
|
||||
|
||||
// Codigo de activacion de cuenta
|
||||
@NotEmpty
|
||||
private String code;
|
||||
|
||||
@NotEmpty
|
||||
private String food;
|
||||
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "username", referencedColumnName = "username")
|
||||
private User usuar;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private Set<FoodOffer> foodOffers;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private Set<NuOffer> nuOffers;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private Set<SpeedOffer> speedOffers;
|
||||
|
||||
|
||||
@OneToMany
|
||||
private Set<TimeOffer> timeOffers;
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
@ -83,7 +92,6 @@ public class Client extends BaseEntity{
|
|||
this.address = address;
|
||||
}
|
||||
|
||||
|
||||
public String getInit() {
|
||||
return init;
|
||||
}
|
||||
|
@ -100,14 +108,6 @@ public class Client extends BaseEntity{
|
|||
this.finish = finish;
|
||||
}
|
||||
|
||||
public User getUsername() {
|
||||
return usuar;
|
||||
}
|
||||
|
||||
public void setUsername(User username) {
|
||||
this.usuar = username;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
|
@ -140,6 +140,14 @@ public class Client extends BaseEntity{
|
|||
this.food = food;
|
||||
}
|
||||
|
||||
public User getUsuar() {
|
||||
return usuar;
|
||||
}
|
||||
|
||||
public void setUsuar(User usuar) {
|
||||
this.usuar = usuar;
|
||||
}
|
||||
|
||||
public Set<FoodOffer> getFoodOffers() {
|
||||
return foodOffers;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.springframework.cheapy.model;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
@ -24,20 +25,15 @@ import javax.validation.constraints.NotNull;
|
|||
@Table(name = "food_offers")
|
||||
public class FoodOffer extends Offer {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//Plato específico
|
||||
@NotBlank
|
||||
private String food;
|
||||
|
||||
@NotBlank
|
||||
private String discount;
|
||||
|
||||
@NotNull
|
||||
private Integer units; // revisar
|
||||
@Min(0)
|
||||
private Integer discount;
|
||||
|
||||
public String getFood() {
|
||||
return food;
|
||||
|
@ -47,20 +43,12 @@ public class FoodOffer extends Offer {
|
|||
this.food = food;
|
||||
}
|
||||
|
||||
public String getDiscount() {
|
||||
public Integer getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(String discount) {
|
||||
public void setDiscount(Integer discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public Integer getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
public void setUnits(Integer units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,38 +3,42 @@ package org.springframework.cheapy.model;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "nu_offers")
|
||||
public class NuOffer extends Offer {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
//Oferta por numero de comensales
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@NotNull
|
||||
private Integer gold;
|
||||
@Min(1)
|
||||
private Integer gold;
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotBlank
|
||||
private String discountGold;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountGold;
|
||||
|
||||
@NotNull
|
||||
private Integer silver;
|
||||
@Min(1)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotBlank
|
||||
private String discountSilver;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountSilver;
|
||||
|
||||
@NotNull
|
||||
private Integer bronze;
|
||||
@Min(1)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotBlank
|
||||
private String discountBronze;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountBronze;
|
||||
|
||||
public Integer getGold() {
|
||||
return gold;
|
||||
|
@ -44,11 +48,11 @@ public class NuOffer extends Offer {
|
|||
this.gold = gold;
|
||||
}
|
||||
|
||||
public String getDiscountGold() {
|
||||
public Integer getDiscountGold() {
|
||||
return discountGold;
|
||||
}
|
||||
|
||||
public void setDiscountGold(String discountGold) {
|
||||
public void setDiscountGold(Integer discountGold) {
|
||||
this.discountGold = discountGold;
|
||||
}
|
||||
|
||||
|
@ -60,11 +64,11 @@ public class NuOffer extends Offer {
|
|||
this.silver = silver;
|
||||
}
|
||||
|
||||
public String getDiscountSilver() {
|
||||
public Integer getDiscountSilver() {
|
||||
return discountSilver;
|
||||
}
|
||||
|
||||
public void setDiscountSilver(String discountSilver) {
|
||||
public void setDiscountSilver(Integer discountSilver) {
|
||||
this.discountSilver = discountSilver;
|
||||
}
|
||||
|
||||
|
@ -76,12 +80,12 @@ public class NuOffer extends Offer {
|
|||
this.bronze = bronze;
|
||||
}
|
||||
|
||||
public String getDiscountBronze() {
|
||||
public Integer getDiscountBronze() {
|
||||
return discountBronze;
|
||||
}
|
||||
|
||||
public void setDiscountBronze(String discountBronze) {
|
||||
public void setDiscountBronze(Integer discountBronze) {
|
||||
this.discountBronze = discountBronze;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,11 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
|
||||
@MappedSuperclass
|
||||
public class Offer extends BaseEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//Clase padre
|
||||
// Clase padre
|
||||
|
||||
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||
@NotNull
|
||||
@Future
|
||||
|
@ -46,15 +44,13 @@ public class Offer extends BaseEntity {
|
|||
@Future
|
||||
private LocalDateTime end;
|
||||
|
||||
|
||||
private String code;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private StatusOffer type;
|
||||
|
||||
|
||||
private StatusOffer status;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="client_id")
|
||||
@JoinColumn(name = "client_id")
|
||||
private Client client;
|
||||
|
||||
public LocalDateTime getStart() {
|
||||
|
@ -81,14 +77,14 @@ public class Offer extends BaseEntity {
|
|||
this.code = code;
|
||||
}
|
||||
|
||||
public StatusOffer getType() {
|
||||
return type;
|
||||
public StatusOffer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setType(StatusOffer type) {
|
||||
this.type = type;
|
||||
public void setStatus(StatusOffer type) {
|
||||
this.status = type;
|
||||
}
|
||||
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -3,38 +3,42 @@ package org.springframework.cheapy.model;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Entity
|
||||
@Table(name = "speed_offers")
|
||||
public class SpeedOffer extends Offer {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// Ofertar por rapidez comiendo
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private Integer gold; // x minutos
|
||||
@Min(0)
|
||||
private Integer gold;
|
||||
|
||||
@Column(name = "discount_gold")
|
||||
@NotBlank
|
||||
private String discountGold;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountGold;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer silver;
|
||||
|
||||
@Column(name = "discount_silver")
|
||||
@NotBlank
|
||||
private String discountSilver;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountSilver;
|
||||
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer bronze;
|
||||
|
||||
@Column(name = "discount_bronze")
|
||||
@NotBlank
|
||||
private String discountBronze;
|
||||
@NotNull
|
||||
@Min(0)
|
||||
private Integer discountBronze;
|
||||
|
||||
public Integer getGold() {
|
||||
return gold;
|
||||
|
@ -44,11 +48,11 @@ public class SpeedOffer extends Offer {
|
|||
this.gold = gold;
|
||||
}
|
||||
|
||||
public String getDiscountGold() {
|
||||
public Integer getDiscountGold() {
|
||||
return discountGold;
|
||||
}
|
||||
|
||||
public void setDiscountGold(String discountGold) {
|
||||
public void setDiscountGold(Integer discountGold) {
|
||||
this.discountGold = discountGold;
|
||||
}
|
||||
|
||||
|
@ -60,11 +64,11 @@ public class SpeedOffer extends Offer {
|
|||
this.silver = silver;
|
||||
}
|
||||
|
||||
public String getDiscountSilver() {
|
||||
public Integer getDiscountSilver() {
|
||||
return discountSilver;
|
||||
}
|
||||
|
||||
public void setDiscountSilver(String discountSilver) {
|
||||
public void setDiscountSilver(Integer discountSilver) {
|
||||
this.discountSilver = discountSilver;
|
||||
}
|
||||
|
||||
|
@ -76,12 +80,12 @@ public class SpeedOffer extends Offer {
|
|||
this.bronze = bronze;
|
||||
}
|
||||
|
||||
public String getDiscountBronze() {
|
||||
public Integer getDiscountBronze() {
|
||||
return discountBronze;
|
||||
}
|
||||
|
||||
public void setDiscountBronze(String discountBronze) {
|
||||
public void setDiscountBronze(Integer discountBronze) {
|
||||
this.discountBronze = discountBronze;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.time.LocalTime;
|
|||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -12,13 +11,11 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
@Entity
|
||||
@Table(name = "time_offers")
|
||||
public class TimeOffer extends Offer {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//Oferta por franja horaria
|
||||
// Oferta por franja horaria
|
||||
|
||||
@DateTimeFormat(pattern = "HH:mm")
|
||||
@NotNull
|
||||
private LocalTime init;
|
||||
|
@ -27,8 +24,8 @@ public class TimeOffer extends Offer {
|
|||
@NotNull
|
||||
private LocalTime finish;
|
||||
|
||||
@NotBlank
|
||||
private String discount;
|
||||
@NotNull
|
||||
private Integer discount;
|
||||
|
||||
public LocalTime getInit() {
|
||||
return init;
|
||||
|
@ -46,11 +43,11 @@ public class TimeOffer extends Offer {
|
|||
this.finish = finish;
|
||||
}
|
||||
|
||||
public String getDiscount() {
|
||||
public Integer getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(String discount) {
|
||||
public void setDiscount(Integer discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ public interface ClientRepository extends CrudRepository<Client, String> {
|
|||
@Query("SELECT client FROM Client client WHERE username =:username")
|
||||
@Transactional(readOnly = true)
|
||||
Client findByUsername(String username);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,37 +1,36 @@
|
|||
package org.springframework.cheapy.service;
|
||||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.repository.NuOfferRepository;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class NuOfferService {
|
||||
private NuOfferRepository nuOfferRepository;
|
||||
|
||||
private NuOfferRepository nuOfferRepository;
|
||||
|
||||
@Autowired
|
||||
public NuOfferService(final NuOfferRepository nuOfferRepository) {
|
||||
this.nuOfferRepository = nuOfferRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public NuOffer findNuOfferById(final int id) {
|
||||
|
||||
return this.nuOfferRepository.findNuOfferById(id);
|
||||
}
|
||||
public List<NuOffer> findAllNuOffer() { //
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
|
||||
@Transactional
|
||||
public List<NuOffer> findAllNuOffer() {
|
||||
return this.nuOfferRepository.findAllNuOffer();
|
||||
}
|
||||
|
||||
|
||||
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException { //
|
||||
|
||||
@Transactional
|
||||
public void saveNuOffer(final NuOffer nuOffer) throws DataAccessException {
|
||||
this.nuOfferRepository.save(nuOffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
package org.springframework.cheapy.service;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.repository.SpeedOfferRepository;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class SpeedOfferService {
|
||||
|
@ -20,19 +20,18 @@ public class SpeedOfferService {
|
|||
this.speedOfferRepository = speedOfferRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SpeedOffer findSpeedOfferById(final int id) {
|
||||
return this.speedOfferRepository.findById(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<SpeedOffer> findAllSpeedOffer() { //
|
||||
return this.speedOfferRepository.findAllSpeedOffer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException {
|
||||
|
||||
@Transactional
|
||||
public void saveSpeedOffer(final SpeedOffer speedOffer) throws DataAccessException { //
|
||||
this.speedOfferRepository.save(speedOffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,7 @@ import org.springframework.cheapy.service.FoodOfferService;
|
|||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
@ -26,15 +24,20 @@ public class FoodOfferController {
|
|||
private final FoodOfferService foodOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
|
||||
public FoodOfferController(final FoodOfferService foodOfferService, final ClientService clientService) {
|
||||
this.foodOfferService = foodOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
private boolean checkIdentity(final int foodOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
Client clientOffer = foodOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/foodOffers/new")
|
||||
|
@ -48,40 +51,96 @@ public class FoodOfferController {
|
|||
public String processCreationForm(@Valid FoodOffer foodOffer, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
foodOffer.setClient(client);
|
||||
foodOffer.setType(StatusOffer.hidden);
|
||||
foodOffer.setStatus(StatusOffer.hidden);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
return "redirect:/foodOffers/" + foodOffer.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/foodOffers/{foodOfferId}/activate")
|
||||
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if(foodOffer.getClient().equals(client)) {
|
||||
foodOffer.setType(StatusOffer.active);
|
||||
foodOffer.setCode("FO-"+foodOfferId);
|
||||
if (foodOffer.getClient().equals(client)) {
|
||||
foodOffer.setStatus(StatusOffer.active);
|
||||
foodOffer.setCode("FO-" + foodOfferId);
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this food offer");
|
||||
}
|
||||
return "redirect:/foodOffers/";
|
||||
}
|
||||
|
||||
@GetMapping("/offers/food/{foodOfferId}")
|
||||
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);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "foodOffers/foodOffersShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
|
||||
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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 (!this.checkIdentity(foodOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(foodOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
|
||||
|
||||
foodOffer.setStatus(StatusOffer.inactive);
|
||||
|
||||
this.foodOfferService.saveFoodOffer(foodOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.security.Principal;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.NuOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.NuOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
||||
@Controller
|
||||
public class NuOfferController {
|
||||
|
||||
|
@ -28,17 +26,21 @@ public class NuOfferController {
|
|||
private final NuOfferService nuOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
|
||||
|
||||
public NuOfferController(final NuOfferService nuOfferService,ClientService clientService) {
|
||||
public NuOfferController(final NuOfferService nuOfferService, final ClientService clientService) {
|
||||
this.nuOfferService = nuOfferService;
|
||||
this.clientService = clientService;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
private boolean checkIdentity(final int nuOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
Client clientOffer = nuOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/nuOffers/new")
|
||||
|
@ -52,51 +54,98 @@ public class NuOfferController {
|
|||
public String processCreationForm(@Valid NuOffer nuOffer, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
else {
|
||||
nuOffer.setType(StatusOffer.hidden);
|
||||
|
||||
} else {
|
||||
nuOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
|
||||
nuOffer.setClient(client);
|
||||
|
||||
|
||||
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/nuOffers/" + nuOffer.getId();
|
||||
}
|
||||
}
|
||||
@GetMapping(value ="/nuOffers/{nuOfferId}/activate")
|
||||
|
||||
@GetMapping(value = "/nuOffers/{nuOfferId}/activate")
|
||||
public String activateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap modelMap) {
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
NuOffer nuOffer=this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if(nuOffer.getClient().equals(client)) {
|
||||
nuOffer.setType(StatusOffer.active);
|
||||
nuOffer.setCode("NU-"+nuOfferId);
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
if (nuOffer.getClient().equals(client)) {
|
||||
nuOffer.setStatus(StatusOffer.active);
|
||||
nuOffer.setCode("NU-" + nuOfferId);
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
|
||||
return "redirect:/nuOffers/" + nuOffer.getId();
|
||||
|
||||
return "redirect:/nuOffers/" + nuOffer.getId();
|
||||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this number offer");
|
||||
}
|
||||
return "redirect:/nuOffers/";
|
||||
|
||||
modelMap.addAttribute("message", "You don't have access to this number offer");
|
||||
}
|
||||
return "redirect:/nuOffers/";
|
||||
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
return "nuOffers/nuOffersShow";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
|
||||
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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 (!this.checkIdentity(nuOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(nuOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
|
||||
nuOffer.setStatus(StatusOffer.inactive);
|
||||
this.nuOfferService.saveNuOffer(nuOffer);
|
||||
return "redirect:/offers";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,37 +1,18 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.SpeedOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.SpeedOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
@ -47,10 +28,16 @@ public class SpeedOfferController {
|
|||
this.speedOfferService = speedOfferService;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
|
||||
private boolean checkIdentity(final int speedOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
Client clientOffer = speedOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/speedOffers/new")
|
||||
|
@ -64,38 +51,96 @@ public class SpeedOfferController {
|
|||
public String processCreationForm(@Valid SpeedOffer speedOffer, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
speedOffer.setClient(client);
|
||||
speedOffer.setType(StatusOffer.hidden);
|
||||
speedOffer.setStatus(StatusOffer.hidden);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
return "redirect:/speedOffers/" + speedOffer.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/speedOffers/{speedOfferId}/activate")
|
||||
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
if(speedOffer.getClient().equals(client)) {
|
||||
speedOffer.setType(StatusOffer.active);
|
||||
speedOffer.setCode("SP-"+speedOfferId);
|
||||
if (speedOffer.getClient().equals(client)) {
|
||||
speedOffer.setStatus(StatusOffer.active);
|
||||
speedOffer.setCode("SP-" + speedOfferId);
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this speed offer");
|
||||
}
|
||||
return "redirect:/speedOffers/";
|
||||
}
|
||||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
|
||||
@GetMapping("/offers/speed/{speedOfferId}")
|
||||
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);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
return "speedOffers/speedOffersShow";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
|
||||
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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 (!this.checkIdentity(speedOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(speedOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
|
||||
|
||||
speedOffer.setStatus(StatusOffer.inactive);
|
||||
|
||||
this.speedOfferService.saveSpeedOffer(speedOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,100 +1,156 @@
|
|||
package org.springframework.cheapy.web;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.cheapy.model.Client;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.model.StatusOffer;
|
||||
import org.springframework.cheapy.model.TimeOffer;
|
||||
import org.springframework.cheapy.service.ClientService;
|
||||
import org.springframework.cheapy.service.TimeOfferService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
||||
@Controller
|
||||
public class TimeOfferController {
|
||||
|
||||
private static final String VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM = "timeOffers/createOrUpdateTimeOfferForm";
|
||||
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "timeOffers/createOrUpdateTimeOfferForm";
|
||||
|
||||
private final TimeOfferService timeOfferService;
|
||||
private final ClientService clientService;
|
||||
|
||||
|
||||
|
||||
public TimeOfferController(final TimeOfferService timeOfferService,ClientService clientService) {
|
||||
public TimeOfferController(final TimeOfferService timeOfferService, ClientService clientService) {
|
||||
this.timeOfferService = timeOfferService;
|
||||
this.clientService = clientService;
|
||||
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void setAllowedFields(WebDataBinder dataBinder) {
|
||||
dataBinder.setDisallowedFields("id");
|
||||
}
|
||||
|
||||
private boolean checkIdentity(final int timeOfferId) {
|
||||
boolean res = false;
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
Client clientOffer = timeOffer.getClient();
|
||||
if (client.equals(clientOffer)) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/timeOffers/new")
|
||||
public String initCreationForm(Map<String, Object> model) {
|
||||
TimeOffer timeOffer = new TimeOffer();
|
||||
model.put("timeOffer", timeOffer);
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
|
||||
@PostMapping("/timeOffers/new")
|
||||
public String processCreationForm(@Valid TimeOffer timeOffer, BindingResult result) {
|
||||
if (result.hasErrors()) {
|
||||
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
}
|
||||
else {
|
||||
timeOffer.setType(StatusOffer.hidden);
|
||||
|
||||
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
|
||||
} else {
|
||||
timeOffer.setStatus(StatusOffer.hidden);
|
||||
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
|
||||
|
||||
timeOffer.setClient(client);
|
||||
|
||||
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
return "redirect:/TimeOffers/" + timeOffer.getId();
|
||||
}
|
||||
}
|
||||
@GetMapping(value ="/timeOffers/{timeOfferId}/activate")
|
||||
|
||||
@GetMapping(value = "/timeOffers/{timeOfferId}/activate")
|
||||
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
|
||||
Client client = this.clientService.getCurrentClient();
|
||||
TimeOffer timeOffer=this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if(timeOffer.getClient().equals(client)) {
|
||||
timeOffer.setType(StatusOffer.active);
|
||||
timeOffer.setCode("TI-"+timeOfferId);
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
if (timeOffer.getClient().equals(client)) {
|
||||
timeOffer.setStatus(StatusOffer.active);
|
||||
timeOffer.setCode("TI-" + timeOfferId);
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
|
||||
return "redirect:/timeOffers/" + timeOffer.getId();
|
||||
|
||||
return "redirect:/timeOffers/" + timeOffer.getId();
|
||||
} else {
|
||||
modelMap.addAttribute("message", "You don't have access to this time offer");
|
||||
}
|
||||
return "redirect:/timeOffers/";
|
||||
|
||||
modelMap.addAttribute("message", "You don't have access to this time offer");
|
||||
}
|
||||
return "redirect:/timeOffers/";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
|
||||
@GetMapping("/offers/time/{timeOfferId}")
|
||||
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);
|
||||
|
||||
//Se añade formateador de fecha al modelo
|
||||
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
|
||||
|
||||
|
||||
return "timeOffers/timeOffersShow";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
|
||||
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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 (!this.checkIdentity(timeOfferEdit.getId())) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (!this.checkIdentity(timeOfferId)) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
|
||||
|
||||
timeOffer.setStatus(StatusOffer.inactive);
|
||||
|
||||
this.timeOfferService.saveTimeOffer(timeOffer);
|
||||
|
||||
return "redirect:/offers";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,17 @@ INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '
|
|||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
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 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','cliente');
|
||||
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','cliente');
|
||||
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 users (dtype,username,password,enabled) VALUES ('user','lolo','lolo', TRUE );
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','lolo','lolo', TRUE );
|
||||
INSERT INTO authorities VALUES ('lolo','usuario');
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('user','pepe','pepe', TRUE );
|
||||
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','pepe','pepe', TRUE );
|
||||
INSERT INTO authorities VALUES ('pepe','usuario');
|
||||
|
||||
INSERT INTO usuarios VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','admin');
|
||||
|
@ -27,11 +27,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 (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 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 (1,'bar manoli','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 (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(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,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%' );
|
||||
|
|
|
@ -12,18 +12,23 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="foodOffer" class="form-horizontal" id="add-foodOffer-form">
|
||||
<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="End Date" name="end"/>
|
||||
<petclinic:inputField label="Food" name="food"/>
|
||||
<petclinic:inputField label="Discount" name="discount"/>
|
||||
<petclinic:inputField label="Units" name="units"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<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:otherwise>
|
||||
<button class="btn btn-default" type="submit">Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</div>
|
||||
|
|
23
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal file
23
src/main/webapp/WEB-INF/jsp/foodOffers/foodOffersDisable.jsp
Normal 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>
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
<cheapy:layout pageName="foodOffer">
|
||||
|
||||
|
||||
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffer"/></h2>
|
||||
|
||||
|
||||
|
||||
<table class="table table-striped" id="foodOfferTable">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -46,9 +48,14 @@
|
|||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:url value="{foodOfferId}/edit" var="editUrl">
|
||||
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
|
||||
</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>
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="nuOffer" class="form-horizontal" id="add-nuOffer-form">
|
||||
<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 fin" name="end"/>
|
||||
|
||||
|
@ -27,10 +30,10 @@
|
|||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<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:otherwise>
|
||||
<button class="btn btn-default" type="submit">Update Offer</button>
|
||||
<button class="btn btn-default" type="submit">Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
|
|
27
src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersDisable.jsp
Normal file
27
src/main/webapp/WEB-INF/jsp/nuOffers/nuOffersDisable.jsp
Normal 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>
|
|
@ -56,9 +56,14 @@
|
|||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:url value="{nuOfferId}/edit" var="editUrl">
|
||||
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
|
||||
</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>
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="speedOffer" class="form-horizontal" id="add-speedOffer-form">
|
||||
<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="End Date" name="end"/>
|
||||
<petclinic:inputField label="Gold" name="gold"/>
|
||||
|
@ -25,8 +28,11 @@
|
|||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<c:choose>
|
||||
<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:otherwise>
|
||||
<button class="btn btn-default" type="submit">Modificar</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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>
|
|
@ -56,9 +56,14 @@
|
|||
<fmt:message key="return"/> </button>
|
||||
</div>
|
||||
|
||||
<%-- <spring:url value="{ownerId}/edit" var="editUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:url value="{speedOfferId}/edit" var="editUrl">
|
||||
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
|
||||
</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>
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
</h2>
|
||||
<form:form modelAttribute="timeOffer" class="form-horizontal" id="add-timeOffer-form">
|
||||
<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 fin" name="end"/>
|
||||
|
||||
|
|
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal file
24
src/main/webapp/WEB-INF/jsp/timeOffers/timeOffersDisable.jsp
Normal 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>
|
|
@ -31,11 +31,21 @@
|
|||
</tr>
|
||||
</thead>
|
||||
</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>
|
||||
|
|
Loading…
Reference in a new issue