Merge pull request #53 from cheapy-ispp/develop

Develop
This commit is contained in:
Antonio Vidal 2021-04-03 12:09:53 +02:00 committed by GitHub
commit 7015e3b211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 1735 additions and 526 deletions

133
readme.md
View file

@ -1,133 +0,0 @@
# Spring PetClinic Sample Application [![Build Status](https://travis-ci.org/spring-projects/spring-petclinic.png?branch=main)](https://travis-ci.org/spring-projects/spring-petclinic/)
## Understanding the Spring Petclinic application with a few diagrams
<a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>
## Running petclinic locally
Petclinic is a [Spring Boot](https://spring.io/guides/gs/spring-boot) application built using [Maven](https://spring.io/guides/gs/maven/). You can build a jar file and run it from the command line:
```
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
./mvnw package
java -jar target/*.jar
```
You can then access petclinic here: http://localhost:8080/
<img width="1042" alt="petclinic-screenshot" src="https://cloud.githubusercontent.com/assets/838318/19727082/2aee6d6c-9b8e-11e6-81fe-e889a5ddfded.png">
Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):
```
./mvnw spring-boot:run
```
## In case you find a bug/suggested improvement for Spring Petclinic
Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues
## Database configuration
In its default configuration, Petclinic uses an in-memory database (H2) which
gets populated at startup with data. The h2 console is automatically exposed at `http://localhost:8080/h2-console`
and it is possible to inspect the content of the database using the `jdbc:h2:mem:testdb` url.
A similar setup is provided for MySql in case a persistent database configuration is needed. Note that whenever the database type is changed, the app needs to be run with a different profile: `spring.profiles.active=mysql` for MySql.
You could start MySql locally with whatever installer works for your OS, or with docker:
```
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
```
Further documentation is provided [here](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt).
## Working with Petclinic in your IDE
### Prerequisites
The following items should be installed in your system:
* Java 8 or newer.
* git command line tool (https://help.github.com/articles/set-up-git)
* Your preferred IDE
* Eclipse with the m2e plugin. Note: when m2e is available, there is an m2 icon in `Help -> About` dialog. If m2e is
not there, just follow the install process here: https://www.eclipse.org/m2e/
* [Spring Tools Suite](https://spring.io/tools) (STS)
* IntelliJ IDEA
* [VS Code](https://code.visualstudio.com)
### Steps:
1) On the command line
```
git clone https://github.com/spring-projects/spring-petclinic.git
```
2) Inside Eclipse or STS
```
File -> Import -> Maven -> Existing Maven project
```
Then either build on the command line `./mvnw generate-resources` or using the Eclipse launcher (right click on project and `Run As -> Maven install`) to generate the css. Run the application main method by right clicking on it and choosing `Run As -> Java Application`.
3) Inside IntelliJ IDEA
In the main menu, choose `File -> Open` and select the Petclinic [pom.xml](pom.xml). Click on the `Open` button.
CSS files are generated from the Maven build. You can either build them on the command line `./mvnw generate-resources` or right click on the `spring-petclinic` project then `Maven -> Generates sources and Update Folders`.
A run configuration named `PetClinicApplication` should have been created for you if you're using a recent Ultimate version. Otherwise, run the application by right clicking on the `PetClinicApplication` main class and choosing `Run 'PetClinicApplication'`.
4) Navigate to Petclinic
Visit [http://localhost:8080](http://localhost:8080) in your browser.
## Looking for something in particular?
|Spring Boot Configuration | Class or Java property files |
|--------------------------|---|
|The Main Class | [PetClinicApplication](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java) |
|Properties Files | [application.properties](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources) |
|Caching | [CacheConfiguration](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java) |
## Interesting Spring Petclinic branches and forks
The Spring Petclinic "main" branch in the [spring-projects](https://github.com/spring-projects/spring-petclinic)
GitHub org is the "canonical" implementation, currently based on Spring Boot and Thymeleaf. There are
[quite a few forks](https://spring-petclinic.github.io/docs/forks.html) in a special GitHub org
[spring-petclinic](https://github.com/spring-petclinic). If you have a special interest in a different technology stack
that could be used to implement the Pet Clinic then please join the community there.
## Interaction with other open source projects
One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found some bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days.
Here is a list of them:
| Name | Issue |
|------|-------|
| Spring JDBC: simplify usage of NamedParameterJdbcTemplate | [SPR-10256](https://jira.springsource.org/browse/SPR-10256) and [SPR-10257](https://jira.springsource.org/browse/SPR-10257) |
| Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility |[HV-790](https://hibernate.atlassian.net/browse/HV-790) and [HV-792](https://hibernate.atlassian.net/browse/HV-792) |
| Spring Data: provide more flexibility when working with JPQL queries | [DATAJPA-292](https://jira.springsource.org/browse/DATAJPA-292) |
# Contributing
The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests.
For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <https://editorconfig.org>. If you have not previously done so, please fill out and submit the [Contributor License Agreement](https://cla.pivotal.io/sign/spring).
# License
The Spring PetClinic sample application is released under version 2.0 of the [Apache License](https://www.apache.org/licenses/LICENSE-2.0).
[spring-petclinic]: https://github.com/spring-projects/spring-petclinic
[spring-framework-petclinic]: https://github.com/spring-petclinic/spring-framework-petclinic
[spring-petclinic-angularjs]: https://github.com/spring-petclinic/spring-petclinic-angularjs
[javaconfig branch]: https://github.com/spring-petclinic/spring-framework-petclinic/tree/javaconfig
[spring-petclinic-angular]: https://github.com/spring-petclinic/spring-petclinic-angular
[spring-petclinic-microservices]: https://github.com/spring-petclinic/spring-petclinic-microservices
[spring-petclinic-reactjs]: https://github.com/spring-petclinic/spring-petclinic-reactjs
[spring-petclinic-graphql]: https://github.com/spring-petclinic/spring-petclinic-graphql
[spring-petclinic-kotlin]: https://github.com/spring-petclinic/spring-petclinic-kotlin
[spring-petclinic-rest]: https://github.com/spring-petclinic/spring-petclinic-rest

View file

@ -37,24 +37,28 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/users/new").permitAll()
.antMatchers("/login/**").anonymous()
.antMatchers("/logout").permitAll()
.antMatchers("/logout").authenticated()
.antMatchers("/usuarios/new").permitAll()
.antMatchers("/admin/**").hasAnyAuthority("admin")
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
.antMatchers("/offers/**/edit").hasAnyAuthority("admin", "client")
.antMatchers("/offers/**/new").hasAnyAuthority("admin", "client")
.antMatchers("/offers/**/activate").hasAnyAuthority("admin","client")
.antMatchers("/clients/new").permitAll()
.antMatchers("/offers/**").permitAll()
.antMatchers("/clients/new").permitAll()
.antMatchers("/offers").permitAll()
.antMatchers("/offersCreate").hasAuthority("client")
.antMatchers("/reviews/**").authenticated()
.and().formLogin()
.loginPage("/login").permitAll()
.loginPage("/login")
.failureUrl("/login?error")
.and().logout().logoutSuccessUrl("/login");
.and().logout().logoutSuccessUrl("/");
// Configuración para que funcione la consola de administración
// de la BD H2 (deshabilitar las cabeceras de protección contra
@ -69,7 +73,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public void configure(final AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(this.dataSource)
//[login de admin,owner y vet] .usersByUsernameQuery("select username,password,enabled " + "from users " + "where username = ?")
.usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?")
.usersByUsernameQuery("select username, password, enabled from users where username=?").authoritiesByUsernameQuery("select username, authority " + "from authorities " + "where username = ?")
.passwordEncoder(this.passwordEncoder());
}

View file

@ -17,10 +17,11 @@ 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;
import org.hibernate.validator.constraints.Range;
@Entity
@Table(name = "food_offers")
public class FoodOffer extends Offer {
@ -28,11 +29,11 @@ public class FoodOffer extends Offer {
private static final long serialVersionUID = 1L;
//Plato específico
@NotBlank
@NotBlank(message = "Debe rellenar la comida a ofertar")
private String food;
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento que proporciona")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discount;
public String getFood() {

View file

@ -6,6 +6,8 @@ import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
@Entity
@Table(name = "nu_offers")
public class NuOffer extends Offer {
@ -13,31 +15,31 @@ public class NuOffer extends Offer {
//Oferta por numero de comensales
private static final long serialVersionUID = 1L;
@NotNull
@NotNull(message = "Debe rellenar el tiempo del rango oro")
@Min(1)
private Integer gold;
@Column(name = "discount_gold")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango oro")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountGold;
@NotNull
@NotNull(message = "Debe rellenar el tiempo del rango plata")
@Min(1)
private Integer silver;
@Column(name = "discount_silver")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango plata")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountSilver;
@NotNull
@NotNull(message = "Debe rellenar el tiempo del rango bronce")
@Min(1)
private Integer bronze;
@Column(name = "discount_bronze")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango bronce")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountBronze;
public Integer getGold() {

View file

@ -35,13 +35,13 @@ public class Offer extends BaseEntity {
// Clase padre
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
@NotNull
@Future
@NotNull(message = "Debe introducir una fecha de inicio")
@Future(message = "La fecha debe debe ser futura")
private LocalDateTime start;
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
@NotNull
@Future
@NotNull(message = "Debe introducir una fecha de fin")
@Future(message = "La fecha debe debe ser futura")
private LocalDateTime end;
private String code;

View file

@ -0,0 +1,56 @@
package org.springframework.cheapy.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;
import com.sun.istack.NotNull;
@Entity
@Table(name = "review")
public class Review extends BaseEntity{
private static final long serialVersionUID = 1L;
@NotBlank(message = "Debe rellenar la valoración de Cheapy")
@Column(length=16777215)
private String opinion;
@NotNull
@Range(min = 1, max = 5)
private Integer stars;
@ManyToOne
@JoinColumn(name = "username", referencedColumnName = "username")
private User escritor;
public User getEscritor() {
return escritor;
}
public void setEscritor(User escritor) {
this.escritor = escritor;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
public Integer getStars() {
return stars;
}
public void setStars(Integer stars) {
this.stars = stars;
}
}

View file

@ -6,6 +6,8 @@ import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
@Entity
@Table(name = "speed_offers")
public class SpeedOffer extends Offer {
@ -13,31 +15,31 @@ public class SpeedOffer extends Offer {
// Ofertar por rapidez comiendo
private static final long serialVersionUID = 1L;
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el tiempo del rango oro")
@Min(1)
private Integer gold;
@Column(name = "discount_gold")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango oro")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountGold;
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el tiempo del rango plata")
@Min(1)
private Integer silver;
@Column(name = "discount_silver")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango plata")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountSilver;
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el tiempo del rango bronce")
@Min(1)
private Integer bronze;
@Column(name = "discount_bronze")
@NotNull
@Min(0)
@NotNull(message = "Debe rellenar el descuento del rango bronce")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discountBronze;
public Integer getGold() {

View file

@ -6,6 +6,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
@Entity
@ -17,14 +18,15 @@ public class TimeOffer extends Offer {
// Oferta por franja horaria
@DateTimeFormat(pattern = "HH:mm")
@NotNull
@NotNull(message = "Debe introducir una hora de inicio")
private LocalTime init;
@DateTimeFormat(pattern = "HH:mm")
@NotNull
@NotNull(message = "Debe introducir una hora de fin")
private LocalTime finish;
@NotNull
@NotNull(message = "Debe rellenar el descuento")
@Range(min = 0, max = 100, message = "El descuento debe estar entre 0 y 100 %")
private Integer discount;
public LocalTime getInit() {

View file

@ -0,0 +1,22 @@
package org.springframework.cheapy.repository;
import java.util.List;
import org.springframework.cheapy.model.Review;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
public interface ReviewRepository extends Repository<Review, Integer> {
@Query("SELECT r FROM Review r")
@Transactional(readOnly = true)
List<Review> findAllReviews();
void save(Review review);
@Query("SELECT r FROM Review r WHERE id =:id")
@Transactional(readOnly = true)
Review findReviewById(@Param("id") Integer id);
}

View file

@ -0,0 +1,15 @@
package org.springframework.cheapy.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.cheapy.model.User;
import org.springframework.cheapy.model.Usuario;
public interface UserRepository extends CrudRepository<Usuario, String> {
@Query("SELECT u FROM User u WHERE username =:username")
@Transactional(readOnly = true)
User findByUsername(String username);
}

View file

@ -1,11 +0,0 @@
package org.springframework.cheapy.repository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.cheapy.model.Usuario;
public interface UsuarioRepository extends CrudRepository<Usuario, String> {
//Usuario findByUsername(String currentPrincipalName);
}

View file

@ -26,12 +26,6 @@ import org.springframework.cheapy.repository.AuthoritiesRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Mostly used as a facade for all Petclinic controllers Also a placeholder
* for @Transactional and @Cacheable annotations
*
* @author Michael Isvy
*/
@Service
public class AuthoritiesService {
/*

View file

@ -35,6 +35,11 @@ public class NuOfferService {
this.nuOfferRepository.save(nuOffer);
}
@Transactional
public void saveUpdateNuOffer(final NuOffer nuOfferNew, final NuOffer nuOfferOld) throws DataAccessException {
this.nuOfferRepository.save(nuOfferNew);
}
public List<NuOffer> findActiveNuOffer() {
return this.nuOfferRepository.findActiveNuOffer(StatusOffer.active);
}

View file

@ -0,0 +1,40 @@
package org.springframework.cheapy.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.Review;
import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.repository.ReviewRepository;
import org.springframework.cheapy.repository.TimeOfferRepository;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class ReviewService {
private ReviewRepository reviewRepository;
@Autowired
public ReviewService(final ReviewRepository reviewRepository) {
this.reviewRepository = reviewRepository;
}
@Transactional
public Review findReviewById(final int id) {
return this.reviewRepository.findReviewById(id);
}
@Transactional
public List<Review> findAllReviews() {
return this.reviewRepository.findAllReviews();
}
@Transactional
public void saveReview(final Review Review) throws DataAccessException {
this.reviewRepository.save(Review);
}
}

View file

@ -0,0 +1,29 @@
package org.springframework.cheapy.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.User;
import org.springframework.cheapy.repository.UserRepository;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class UserService {
private UserRepository userRepository;
@Autowired
public UserService(final UserRepository userRepository) {
this.userRepository = userRepository;
}
@Transactional
public User getCurrentUser() throws DataAccessException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String username = authentication.getName();
return this.userRepository.findByUsername(username);
}
}

View file

@ -4,8 +4,10 @@ package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.FoodOffer;
import org.springframework.cheapy.model.StatusOffer;
@ -31,6 +33,33 @@ public class FoodOfferController {
this.clientService = clientService;
}
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;
}
private boolean checkOffer(final FoodOffer session, final FoodOffer offer) {
boolean res = false;
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
res = true;
}
return res;
}
private boolean checkDates(final FoodOffer foodOffer) {
boolean res = false;
if(foodOffer.getEnd().isAfter(foodOffer.getStart())) {
res = true;
}
return res;
}
@GetMapping("/offers/food/new")
public String initCreationForm(Map<String, Object> model) {
@ -44,6 +73,10 @@ public class FoodOfferController {
if (result.hasErrors()) {
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(foodOffer)) {
//Poner aqui mensaje de error
return VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
}
Client client = this.clientService.getCurrentClient();
foodOffer.setClient(client);
foodOffer.setStatus(StatusOffer.hidden);
@ -51,7 +84,7 @@ public class FoodOfferController {
return "redirect:/offers/food/" + foodOffer.getId();
}
}
@GetMapping(value = "/offers/food/{foodOfferId}/activate")
public String activateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, ModelMap modelMap) {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
@ -63,7 +96,7 @@ public class FoodOfferController {
} else {
modelMap.addAttribute("message", "You don't have access to this food offer");
}
return "redirect:/offers/food/"+foodOfferId;
return "redirect:/offers/food/" + foodOfferId;
}
@ -73,31 +106,53 @@ public class FoodOfferController {
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
model.put("foodOffer", foodOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/food/foodOffersShow";
}
@GetMapping(value = "/offers/food/{foodOfferId}/edit")
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model) {
public String updateFoodOffer(@PathVariable("foodOfferId") final int foodOfferId, final ModelMap model,
HttpServletRequest request) {
if (!this.checkIdentity(foodOfferId)) {
return "error";
}
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(foodOfferId);
if (foodOffer.getStatus().equals(StatusOffer.inactive)) {
return "error";
}
model.addAttribute("foodOffer", foodOffer);
request.getSession().setAttribute("idFood", foodOfferId);
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) {
final ModelMap model, HttpServletRequest request) {
if (!this.checkIdentity(foodOfferEdit.getId())) {
return "error";
}
Integer id = (Integer) request.getSession().getAttribute("idFood");
FoodOffer foodOffer = this.foodOfferService.findFoodOfferById(id);
if (!this.checkOffer(foodOffer, foodOfferEdit)) {
return "error";
}
if (result.hasErrors()) {
model.addAttribute("foodOffer", foodOfferEdit);
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(foodOfferEdit)) {
//Poner aqui mensaje de error
return FoodOfferController.VIEWS_FOOD_OFFER_CREATE_OR_UPDATE_FORM;
}
BeanUtils.copyProperties(this.foodOfferService.findFoodOfferById(foodOfferEdit.getId()), foodOfferEdit,
"start", "end", "food", "discount");
this.foodOfferService.saveFoodOffer(foodOfferEdit);
return "redirect:/offers/food/" + foodOfferEdit.getId();
}
@ -106,15 +161,21 @@ public class FoodOfferController {
@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";
return "offers/food/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);
@ -122,7 +183,7 @@ public class FoodOfferController {
this.foodOfferService.saveFoodOffer(foodOffer);
return "redirect:/offers";
return "redirect:/myOffers";
}
}

View file

@ -4,15 +4,18 @@ import java.security.Principal;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.StatusOffer;
import org.springframework.beans.BeanUtils;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.FoodOffer;
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.annotation.GetMapping;
@ -31,6 +34,50 @@ public class NuOfferController {
this.nuOfferService = nuOfferService;
this.clientService = clientService;
}
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;
}
private boolean checkOffer(final NuOffer session, final NuOffer offer) {
boolean res = false;
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
res = true;
}
return res;
}
private boolean checkDates(final NuOffer nuOffer) {
boolean res = false;
if(nuOffer.getEnd().isAfter(nuOffer.getStart())) {
res = true;
}
return res;
}
private boolean checkConditions(final NuOffer NuOffer) {
boolean res = false;
if(NuOffer.getGold() > NuOffer.getSilver() && NuOffer.getSilver() > NuOffer.getBronze()) {
res = true;
}
return res;
}
private boolean checkDiscounts(final NuOffer NuOffer) {
boolean res = false;
if(NuOffer.getDiscountGold() > NuOffer.getDiscountSilver() && NuOffer.getDiscountSilver() > NuOffer.getDiscountBronze()) {
res = true;
}
return res;
}
@GetMapping("/offers/nu/new")
public String initCreationForm(Map<String, Object> model) {
@ -44,6 +91,18 @@ public class NuOfferController {
if (result.hasErrors()) {
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkConditions(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkDiscounts(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
nuOffer.setStatus(StatusOffer.hidden);
Client client = this.clientService.getCurrentClient();
@ -51,11 +110,11 @@ public class NuOfferController {
nuOffer.setClient(client);
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) {
Client client = this.clientService.getCurrentClient();
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
@ -63,11 +122,11 @@ public class NuOfferController {
nuOffer.setStatus(StatusOffer.active);
nuOffer.setCode("NU-" + nuOfferId);
this.nuOfferService.saveNuOffer(nuOffer);
} else {
modelMap.addAttribute("message", "You don't have access to this number offer");
}
return "redirect:/offers/nu/"+ nuOffer.getId();
return "redirect:/offers/nu/" + nuOffer.getId();
}
@ -82,22 +141,53 @@ public class NuOfferController {
}
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model,
HttpServletRequest request) {
if (!this.checkIdentity(nuOfferId)) {
return "error";
}
NuOffer nuOffer = this.nuOfferService.findNuOfferById(nuOfferId);
if (nuOffer.getStatus().equals(StatusOffer.inactive)) {
return "error";
}
model.addAttribute("nuOffer", nuOffer);
request.getSession().setAttribute("idNu", nuOfferId);
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) {
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model,
HttpServletRequest request) {
if (!this.checkIdentity(nuOfferEdit.getId())) {
return "error";
}
Integer id = (Integer) request.getSession().getAttribute("idNu");
NuOffer nuOffer = this.nuOfferService.findNuOfferById(id);
if (!this.checkOffer(nuOffer, nuOfferEdit)) {
return "error";
}
if (result.hasErrors()) {
model.addAttribute("nuOffer", nuOfferEdit);
return NuOfferController.VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkConditions(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkDiscounts(nuOffer)) {
//Poner aqui mensaje de error
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
BeanUtils.copyProperties(this.nuOfferService.findNuOfferById(nuOfferEdit.getId()), nuOfferEdit, "start",
"end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
this.nuOfferService.saveNuOffer(nuOfferEdit);
return "redirect:/offers/nu/" + nuOfferEdit.getId();
}
@ -107,21 +197,27 @@ public class NuOfferController {
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";
return "offers/nu/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";
return "redirect:/myOffers";
}

View file

@ -13,16 +13,19 @@ import org.springframework.cheapy.service.FoodOfferService;
import org.springframework.cheapy.service.NuOfferService;
import org.springframework.cheapy.service.SpeedOfferService;
import org.springframework.cheapy.service.TimeOfferService;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class OfertaController {
private final ClientService clientService;
private final FoodOfferService foodOfferService;
private final NuOfferService nuOfferService;
private final NuOfferService nuOfferService;
private final SpeedOfferService speedOfferService;
private final TimeOfferService timeOfferService;
@ -42,40 +45,49 @@ public class OfertaController {
List<NuOffer> nuOfferLs=this.nuOfferService.findActiveNuOffer();
List<SpeedOffer> speedOfferLs=this.speedOfferService.findActiveSpeedOffer();
List<TimeOffer> timeOfferLs=this.timeOfferService.findActiveTimeOffer();
model.put("foodOfferLs", foodOfferLs);
model.put("nuOfferLs", nuOfferLs);
model.put("speedOfferLs", speedOfferLs);
model.put("timeOfferLs", timeOfferLs);
//Se añade formateador de fecha al modelo
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/offersList";
}
@GetMapping("/myOffers")
public String processMyOffersForm( Map<String, Object> model) {
int actual = this.clientService.getCurrentClient().getId();
List<FoodOffer> foodOfferLs = this.foodOfferService.findFoodOfferByUserId(actual);
List<NuOffer> nuOfferLs = this.nuOfferService.findNuOfferByUserId(actual);
List<SpeedOffer> speedOfferLs = this.speedOfferService.findSpeedOfferByUserId(actual);
List<TimeOffer> timeOfferLs = this.timeOfferService.findTimeOfferByUserId(actual);
model.put("foodOfferLs", foodOfferLs);
model.put("nuOfferLs", nuOfferLs);
model.put("speedOfferLs", speedOfferLs);
model.put("timeOfferLs", timeOfferLs);
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/myOffersList";
}
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/myOffersList";
}
@GetMapping("/offersCreate")
public String createOffers() {
return "offers/offersCreate";
}
// @GetMapping("/owners/{ownerId}/edit")
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
// Owner owner = this.ownerService.findOwnerById(ownerId);
@ -99,10 +111,10 @@ public class OfertaController {
// public ModelAndView showOwner(@PathVariable("ownerId") int ownerId) {
// ModelAndView mav = new ModelAndView("owners/ownerDetails");
// Owner owner = this.ownerService.findOwnerById(ownerId);
//
//
// mav.addObject(owner);
// return mav;
// }
}

View file

@ -0,0 +1,115 @@
package org.springframework.cheapy.web;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.cheapy.model.Review;
import org.springframework.cheapy.model.User;
import org.springframework.cheapy.service.ReviewService;
import org.springframework.cheapy.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class ReviewController {
private static final String VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM = "reviews/createOrUpdateReviewForm";
private final ReviewService reviewService;
private final UserService userService;
public ReviewController(final ReviewService reviewService, final UserService userService) {
this.reviewService = reviewService;
this.userService = userService;
}
private boolean checkIdentity(final int reviewId) {
boolean res = false;
User user = this.userService.getCurrentUser();
Review review = this.reviewService.findReviewById(reviewId);
User reviewsAuthor = review.getEscritor();
if (user.equals(reviewsAuthor)) {
res = true;
}
return res;
}
@GetMapping("/reviews")
public String processFindForm( Map<String, Object> model) {
List<Review> reviewsLs=this.reviewService.findAllReviews();
model.put("reviewsLs", reviewsLs);
return "reviews/reviewsList";
}
@GetMapping("/reviews/new")
public String initCreationForm(Map<String, Object> model) {
Review review = new Review();
model.put("review", review);
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
}
@PostMapping("/reviews/new")
public String processCreationForm(@Valid Review review, BindingResult result) {
if (result.hasErrors()) {
return VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
} else {
User escritor = this.userService.getCurrentUser();
review.setEscritor(escritor);
this.reviewService.saveReview(review);
return "redirect:/reviews/" + review.getId();
}
}
@GetMapping("/reviews/{reviewId}")
public String processShowForm(@PathVariable("reviewId") int reviewId, Map<String, Object> model) {
Review review = this.reviewService.findReviewById(reviewId);
model.put("review", review);
return "reviews/reviewsShow";
}
@GetMapping(value = "/reviews/{reviewId}/edit")
public String updateReview(@PathVariable("reviewId") final int reviewId, final ModelMap model) {
if (!this.checkIdentity(reviewId)) {
return "error";
}
Review review = this.reviewService.findReviewById(reviewId);
model.addAttribute("review", review);
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
}
@PostMapping(value = "/reviews/{reviewId}/edit")
public String updateReview(@Valid final Review reviewEdit, final BindingResult result, final ModelMap model) {
if (!this.checkIdentity(reviewEdit.getId())) {
return "error";
}
if (result.hasErrors()) {
model.addAttribute("review", reviewEdit);
return ReviewController.VIEWS_REVIEWS_CREATE_OR_UPDATE_FORM;
} else {
User escritor = this.userService.getCurrentUser();
reviewEdit.setEscritor(escritor);
this.reviewService.saveReview(reviewEdit);
return "redirect:/reviews/" + reviewEdit.getId();
}
}
}

View file

@ -3,11 +3,14 @@ package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.StatusOffer;
import org.springframework.beans.BeanUtils;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.FoodOffer;
import org.springframework.cheapy.service.ClientService;
import org.springframework.cheapy.service.SpeedOfferService;
import org.springframework.stereotype.Controller;
@ -30,6 +33,49 @@ public class SpeedOfferController {
this.clientService = clientService;
}
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;
}
private boolean checkOffer(final SpeedOffer session, final SpeedOffer offer) {
boolean res = false;
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
res = true;
}
return res;
}
private boolean checkDates(final SpeedOffer speedOffer) {
boolean res = false;
if(speedOffer.getEnd().isAfter(speedOffer.getStart())) {
res = true;
}
return res;
}
private boolean checkConditions(final SpeedOffer speedOffer) {
boolean res = false;
if(speedOffer.getGold() < speedOffer.getSilver() && speedOffer.getSilver() < speedOffer.getBronze()) {
res = true;
}
return res;
}
private boolean checkDiscounts(final SpeedOffer speedOffer) {
boolean res = false;
if(speedOffer.getDiscountGold() > speedOffer.getDiscountSilver() && speedOffer.getDiscountSilver() > speedOffer.getDiscountBronze()) {
res = true;
}
return res;
}
@GetMapping("/offers/speed/new")
public String initCreationForm(Map<String, Object> model) {
@ -43,6 +89,18 @@ public class SpeedOfferController {
if (result.hasErrors()) {
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkConditions(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkDiscounts(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
Client client = this.clientService.getCurrentClient();
speedOffer.setClient(client);
speedOffer.setStatus(StatusOffer.hidden);
@ -51,7 +109,6 @@ public class SpeedOfferController {
}
}
@GetMapping(value = "/offers/speed/{speedOfferId}/activate")
public String activateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, ModelMap modelMap) {
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
@ -77,21 +134,53 @@ public class SpeedOfferController {
}
@GetMapping(value = "/offers/speed/{speedOfferId}/edit")
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model) {
public String updateSpeedOffer(@PathVariable("speedOfferId") final int speedOfferId, final ModelMap model, HttpServletRequest request) {
if (!this.checkIdentity(speedOfferId)) {
return "error";
}
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(speedOfferId);
if (speedOffer.getStatus().equals(StatusOffer.inactive)) {
return "error";
}
model.addAttribute("speedOffer", speedOffer);
request.getSession().setAttribute("idSpeed", speedOfferId);
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) {
public String updateSpeedOffer(@Valid final SpeedOffer speedOfferEdit, final BindingResult result,
final ModelMap model, HttpServletRequest request) {
if (!this.checkIdentity(speedOfferEdit.getId())) {
return "error";
}
Integer id = (Integer) request.getSession().getAttribute("idSpeed");
SpeedOffer speedOffer = this.speedOfferService.findSpeedOfferById(id);
if (!this.checkOffer(speedOffer, speedOfferEdit)) {
return "error";
}
if (result.hasErrors()) {
model.addAttribute("speedOffer", speedOfferEdit);
return SpeedOfferController.VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkConditions(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkDiscounts(speedOffer)) {
//Poner aqui mensaje de error
return VIEWS_SPEED_OFFER_CREATE_OR_UPDATE_FORM;
}
BeanUtils.copyProperties(this.speedOfferService.findSpeedOfferById(speedOfferEdit.getId()), speedOfferEdit,
"start", "end", "gold", "discount_gold", "silver", "discount_silver", "bronze", "discount_bronze");
this.speedOfferService.saveSpeedOffer(speedOfferEdit);
return "redirect:/offers/speed/" + speedOfferEdit.getId();
}
@ -101,15 +190,21 @@ public class SpeedOfferController {
@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";
return "offers/speed/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);
@ -117,7 +212,7 @@ public class SpeedOfferController {
this.speedOfferService.saveSpeedOffer(speedOffer);
return "redirect:/offers";
return "redirect:/myOffers";
}
}

View file

@ -1,12 +1,14 @@
package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.FoodOffer;
import org.springframework.cheapy.model.StatusOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.ClientService;
@ -21,7 +23,6 @@ import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class TimeOfferController {
private static final String VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM = "offers/time/createOrUpdateTimeOfferForm";
private final TimeOfferService timeOfferService;
private final ClientService clientService;
@ -31,6 +32,42 @@ public class TimeOfferController {
this.clientService = clientService;
}
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;
}
private boolean checkOffer(final TimeOffer session, final TimeOffer offer) {
boolean res = false;
if (session.getId() == offer.getId() && session.getStatus() == offer.getStatus()
&& (session.getCode() == null ? offer.getCode() == "" : session.getCode().equals(offer.getCode())) && !(session.getStatus().equals(StatusOffer.inactive))) {
res = true;
}
return res;
}
private boolean checkDates(final TimeOffer timeOffer) {
boolean res = false;
if(timeOffer.getEnd().isAfter(timeOffer.getStart())) {
res = true;
}
return res;
}
private boolean checkTimes(final TimeOffer timeOffer) {
boolean res = false;
if(timeOffer.getFinish().isAfter(timeOffer.getInit())) {
res = true;
}
return res;
}
@GetMapping("/offers/time/new")
public String initCreationForm(Map<String, Object> model) {
TimeOffer timeOffer = new TimeOffer();
@ -43,6 +80,16 @@ public class TimeOfferController {
if (result.hasErrors()) {
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(timeOffer)) {
//Poner aqui mensaje de error
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkTimes(timeOffer)) {
//Poner aqui mensaje de error
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
}
timeOffer.setStatus(StatusOffer.hidden);
Client client = this.clientService.getCurrentClient();
@ -54,7 +101,7 @@ public class TimeOfferController {
}
}
@GetMapping(value ="/offers/time/{timeOfferId}/activate")
@GetMapping(value = "/offers/time/{timeOfferId}/activate")
public String activateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap modelMap) {
Client client = this.clientService.getCurrentClient();
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
@ -63,13 +110,11 @@ public class TimeOfferController {
timeOffer.setCode("TI-" + timeOfferId);
this.timeOfferService.saveTimeOffer(timeOffer);
} else {
modelMap.addAttribute("message", "You don't have access to this time offer");
}
return "redirect:/offers/time/" + timeOffer.getId();
}
@GetMapping("/offers/time/{timeOfferId}")
@ -80,29 +125,56 @@ public class TimeOfferController {
model.put("timeOffer", timeOffer);
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/time/timeOffersShow";
}
@GetMapping(value = "/offers/time/{timeOfferId}/edit")
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model) {
public String updateTimeOffer(@PathVariable("timeOfferId") final int timeOfferId, final ModelMap model,
HttpServletRequest request) {
if (!this.checkIdentity(timeOfferId)) {
return "error";
}
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(timeOfferId);
if (timeOffer.getStatus().equals(StatusOffer.inactive)) {
return "error";
}
model.addAttribute("timeOffer", timeOffer);
request.getSession().setAttribute("idTime", timeOfferId);
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) {
public String updateTimeOffer(@Valid final TimeOffer timeOfferEdit, final BindingResult result,
final ModelMap model, HttpServletRequest request) {
if (!this.checkIdentity(timeOfferEdit.getId())) {
return "error";
}
Integer id = (Integer) request.getSession().getAttribute("idTime");
TimeOffer timeOffer = this.timeOfferService.findTimeOfferById(id);
if (!this.checkOffer(timeOffer, timeOfferEdit)) {
return "error";
}
if (result.hasErrors()) {
model.addAttribute("timeOffer", timeOfferEdit);
return TimeOfferController.VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
} else {
if(!this.checkDates(timeOffer)) {
//Poner aqui mensaje de error
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
}
if(!this.checkTimes(timeOffer)) {
//Poner aqui mensaje de error
return VIEWS_TIME_OFFER_CREATE_OR_UPDATE_FORM;
}
BeanUtils.copyProperties(this.timeOfferService.findTimeOfferById(timeOfferEdit.getId()), timeOfferEdit,
"start", "end", "init", "finish", "discount");
this.timeOfferService.saveTimeOffer(timeOfferEdit);
return "redirect:/offers/time/" + timeOfferEdit.getId();
}
@ -112,15 +184,21 @@ public class TimeOfferController {
@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";
return "offers/time/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);
@ -128,8 +206,7 @@ public class TimeOfferController {
this.timeOfferService.saveTimeOffer(timeOffer);
return "redirect:/offers";
return "redirect:/myOffers";
}

View file

@ -56,7 +56,7 @@
.table-filter {
background-color: @spring-brown;
padding: 9px 12px;
padding: 5px 12px;
}
.nav > li > a {
@ -240,20 +240,81 @@ img.img-responsive{
background-color: rgb(40, 140, 215);
}
.btn-home{
display: table;
margin: 0 auto;
}
.btn-create button {
background-color: rgb(40, 140, 215);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
width: 70%;
display: block;
}
.btn-create button:not(:last-child) {
border-bottom: none;
}
.btn-create button:hover {
background-color: rgb(0, 64, 128)
}
.btn-create-max button {
padding: 20px;
margin-left:auto;
margin-right: auto;
margin-bottom: 20px;
}
.btn-mod{
display: table;
margin: 0 auto;
float:left;
}
.btn-mod button {
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
display: block;
}
.btn-mod button:not(:last-child) {
border-bottom: none;
}
.btn-mod button:hover {
background-color: rgb(40, 140, 215);
}
#foodOfferTable th {
width: 25%;
text-align: center;
}
#nuOfferTable th {
width: 33%;
width: 25%;
text-align: center;
}
#speedOfferTable th {
width: 33%;
width: 25%;
text-align: center;
}
#timeOfferTable th {
width: 33%;
width: 25%;
text-align: center;
}
.btn-detalles button {
@ -278,7 +339,52 @@ img.img-responsive{
.btn-return{
display: table;
margin: 0 auto;
width: 100%;
float:left;
}
.btns-edit{
display: table;
margin: 0 auto;
float:right;
}
.btns-edit button{
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
}
.btns-edit button:not(:last-child) {
border-bottom: none;
}
.btns-edit button:hover {
background-color: rgb(40, 140, 215);
}
.btns-delete{
display: table;
margin: 0 auto;
float:left;
}
.btns-delete button{
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
}
.btns-delete button:not(:last-child) {
border-bottom: none;
}
.btns-delete button:hover {
background-color: rgb(40, 140, 215);
}
.btn-return button {
@ -288,32 +394,50 @@ img.img-responsive{
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;
text-align: center;
}
#nuOfferTable td{
vertical-align:middle;
text-align: center;
}
#speedOfferTable td{
vertical-align:middle;
text-align: center;
}
#timeOfferTable td{
vertical-align:middle;
text-align: center;
}
#nuOffer-table th{
text-align: center;
}
#nuOffer-table td{
text-align: center;
}
#speedOffer-table th{
text-align: center;
}
#speedOffer-table td{
text-align: center;
}
#nuOffer-table tr:nth-child(3){
@ -364,6 +488,13 @@ img.img-responsive{
background-color: rgb(204, 128, 51);
}
#vacio {
text-align:center;
font-size: 120%;
padding:10px;
color: rgb(29, 142, 226);
}
.alert-success {
.alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text);
}

View file

@ -16,7 +16,7 @@ spring.jpa.properties.javax.persistence.schema-generation.drop-script-source=dro
# Internationalization
spring.messages.basename=messages/messages
spring.messages.encoding=UTF-8
# Views
spring.mvc.view.prefix: /WEB-INF/jsp/
@ -33,4 +33,4 @@ logging.level.org.springframework=INFO
# logging.level.org.springframework.context.annotation=TRACE
# Maximum time static resources should be cached
spring.resources.cache.cachecontrol.max-age=12h
spring.resources.cache.cachecontrol.max-age=12h

View file

@ -1,3 +1,5 @@
__^__ __^__
( ___ )------------------------------------( ___ )
| / | | \ |
@ -5,5 +7,4 @@
|___| |___|
(_____)------------------------------------(_____)
:: Built with Spring Boot :: ${spring-boot.version}
-- Built with Spring Boot -- (${spring-boot.version})

View file

@ -11,8 +11,8 @@ 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 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 users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE );
INSERT INTO authorities VALUES ('david','client');
@ -32,8 +32,18 @@ INSERT INTO usuarios VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690
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', 'inactive', 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, status, client_id, food, discount) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'FO-1', 'inactive', 1, 'macarrones', 15);
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'FO-2', 'active', 1, 'macarrones con tomate', 10);
INSERT INTO food_offers(start, end, code, status, client_id, food, discount) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden', 1, 'macarrones con queso', 5);
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'T-1', 'inactive', 1, '12:00:00', '13:00:00', 5);
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'T-2', 'active', 1, '12:00:00', '13:00:00', 10);
INSERT INTO time_offers(start, end, code, status, client_id, init, finish, discount) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden', 1, '12:00:00', '13:00:00', 15);
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-14 12:00:00', '2021-08-15 12:00:00', 'SP-1', 'inactive',1,5,25,10,15,15,10);
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'SP-2', 'active',1,5,25,10,15,15,10);
INSERT INTO speed_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden',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-08-14 12:00:00', '2021-08-15 12:00:00', 'NU-1', 'inactive',1,15,25,10,15,5,10);
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-15 12:00:00', '2021-08-16 12:00:00', 'NU-2', 'active',1,15,25,10,15,5,10);
INSERT INTO nu_offers(start, end, code, status, client_id, gold, discount_gold, silver, discount_silver, bronze, discount_bronze) VALUES ('2021-08-16 12:00:00', '2021-08-17 12:00:00', null, 'hidden',1,15,25,10,15,5,10);

View file

@ -1,11 +1,16 @@
welcome=Bienvenido a
new=Nueva
deleteOffer=Eliminar Oferta
cancel=Cancelar
deleteOfferMessage=Confirme que quiere eliminar su oferta
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
createOffers=Crear Ofertas
foodOffers=Ofertas por plato específico
foodOffer=Oferta por plato específico
nuOffers=Ofertas por número de comensales
nuOffer=Oferta por número de comensales
speedOffers=Ofertas por tiempo empleado en comer
speedOffer=Oferta por tiempo empleado en comer
timeOffers=Ofertas por franja horaria
timeOffer=Oferta por franja horaria
food=Plato
@ -18,17 +23,28 @@ silverGoal=Meta plata
silverDiscount=Descuento plata
bronzeGoal=Meta bronce
bronzeDiscount=Descuento bronce
startDate=Fecha inicio
startDate=Fecha de inicio
offerBeginning=Inicio de la oferta
endDate=Fecha fin
endDate=Fecha de fin
offerEnding=Fin de la oferta
details=Detalles
offerCode=Codigo de la oferta
offerCode=Código de la oferta
return=Volver
required=Es requeridOfertas por franja horariao
required=Es requerido
notFound=No ha sido encontrado
duplicate=Ya se encuentra en uso
nonNumeric=Sólo debe contener numeros
nonNumeric=Solo debe contener números
duplicateFormSubmission=No se permite el envío de formularios duplicados
typeMismatch.date=Fecha invalida
typeMismatch.birthDate=Fecha invalida
typeMismatch.date=Fecha inválida
typeMismatch.birthDate=Fecha inválida
review= Reseña
reviews= Reseñas
stars= Estrellas
opinion= Opinión
user = Nombre de usuario
createFoodOffers= Crear ofertas por plato específico
createNuOffers= Crear ofertas por número de comensales
createSpeedOffers= Crear ofertas por rapidez comiendo
createTimeOffers= Crear ofertas por franja horaria
init= Inicio del intervalo
finish= Fin del intervalo

View file

@ -4,8 +4,7 @@
<cheapy:layout pageName="error">
<h2 style="text-align:center">Algo malo ha pasado...</h2>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>Algo malo ha pasado...</em></h2>
<spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/>
<img class="img-responsive" src="${cheapyImage}"/>

View file

@ -1,6 +1,8 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ 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="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
@ -275,27 +277,29 @@
<div class="wrapper fadeInDown">
<div id="formContent">
<!-- Tabs Titles -->
<!-- Icon -->
<div class="fadeIn first">
<img src="/resources/images/Logo Cheapy.png" id="icon" />
<c:if test= "${not empty param}" >
<p class="text-danger"> El usuario y/o la contraseña son incorrectos </p>
</c:if>
</div>
<div th:if="${param.error}">
<p class="text-danger"> Invalid username or password</p>
</div>
<!-- Login Form -->
<form class='form-signin' action="/login" method='POST'>
<input type="text" id="username" class="fadeIn second" name="username" placeholder="username" required autofocus>
<input type="password" id="password" class="fadeIn third" name="password" placeholder="password" required>
<input type="text" id="username" class="fadeIn second" name="username" placeholder="Usuario" required autofocus>
<input type="password" id="password" class="fadeIn third" name="password" placeholder="Contraseña" required>
<sec:csrfInput />
<input type="submit" class="fadeIn fourth" value="Login">
<input type="submit" class="fadeIn fourth" value="Iniciar sesión">
</form>
<!-- Remind Passowrd -->
<!-- Remind Passowrd
<div id="formFooter">
<a class="underlineHover" href="#">Forgot Password?</a>
<a class="underlineHover" href="#">¿Olvidó su contraseña?</a>
</div>
-->
</div>
</div>

View file

@ -4,33 +4,53 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<petclinic:layout pageName="foodOffers">
<h2>
<c:if test="${foodOffer['new']}">New </c:if> FoodOffer
<cheapy:layout pageName="foodOffers">
<h2 style="text-align:center;padding:5px">
<c:if test="${foodOffer['new']}"><fmt:message key="new"/> </c:if> <fmt:message key="foodOffer"/>
</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"/>
<cheapy:inputField label="Fecha de Inicio" placeholder="dd/MM/yyyy HH:mm" name="start"/>
<cheapy:inputField label="Fecha de Fin" placeholder="dd/MM/yyyy HH:mm" name="end"/>
<cheapy:inputField label="Plato" placeholder="Ej. Macarrones" name="food"/>
<cheapy:inputField label="Descuento" placeholder="Ej. 50" name="discount"/>
</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">Crear oferta</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit">Modificar</button>
</c:otherwise>
</c:choose>
<div class="btn-mod">
<c:choose>
<c:when test="${foodOffer['new']}">
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Crear oferta</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Modificar</button>
</c:otherwise>
</c:choose>
</div>
</div>
</div>
</form:form>
</petclinic:layout>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -2,22 +2,36 @@
<%@ 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="cheapy" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<petclinic:layout pageName="foodOffer">
<cheapy:layout pageName="foodOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></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>
<input type="hidden" name="food" value="${foodOffer.food}" />
<input type="hidden" name="discount" value="${foodOffer.discount}" />
<div class="btns-edit">
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Dar de baja</button>
</div>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</jsp:body>
</petclinic:layout>
</cheapy:layout>

View file

@ -4,11 +4,11 @@
<%@ 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="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="foodOffer">
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffer"/></h2>
@ -29,7 +29,7 @@
</tr>
<tr>
<th><fmt:message key="discount"/></th>
<td><c:out value="${foodOffer.discount}"/></td>
<td><c:out value="${foodOffer.discount}%"/> </td>
</tr>
<tr>
@ -38,21 +38,46 @@
</tr>
</thead>
</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="{foodOfferId}/edit" var="editUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<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>
<div class="btn-menu">
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btns-edit">
<spring:url value="{foodOfferId}/edit" var="editUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Editar oferta</button>
<c:if test="${foodOffer.status eq 'hidden' }">
<spring:url value="{foodOfferId}/activate" var="activateUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(activateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Activar oferta</button>
</c:if>
<c:if test="${foodOffer.status eq 'active' }">
<spring:url value="{foodOfferId}/disable" var="deactivateUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(deactivateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Desactivar oferta</button>
</c:if>
</div>
</sec:authorize>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -6,9 +6,12 @@
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="myOffers">
<cheapy:layout pageName="ofertasM">
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
<c:if test="${empty foodOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty foodOfferLs }">
<table id="foodOfferTable" class="table table-striped">
<thead>
<tr>
@ -16,7 +19,9 @@
<th><fmt:message key="food"/></th>
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th> </th>
<th> <spring:url value="/offers/food/new" var="newFoodUrl">
</spring:url>
<!-- <a href="${fn:escapeXml(newFoodUrl)}" class="btn btn-default">Nueva oferta</a></th>-->
</tr>
</thead>
<tbody>
@ -46,16 +51,21 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
<c:if test="${empty nuOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty nuOfferLs }">
<table id="nuOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th> </th>
<th> <spring:url value="/offers/nu/new" var="newNuUrl">
</spring:url>
<!-- <a href="${fn:escapeXml(newNuUrl)}" class="btn btn-default">Nueva oferta</a></th>-->
</tr>
</thead>
@ -83,15 +93,22 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
<c:if test="${empty foodOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty speedOfferLs }">
<table id="speedOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th> </th>
<th> <spring:url value="/offers/speed/new" var="newSpeedUrl">
</spring:url>
<!-- <a href="${fn:escapeXml(newSpeedUrl)}" class="btn btn-default">Nueva oferta</a></th>-->
</tr>
</thead>
@ -120,15 +137,22 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
<c:if test="${empty timeOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty timeOfferLs }">
<table id="timeOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th> </th>
<th><spring:url value="/offers/time/new" var="newTimeUrl">
</spring:url>
<!--<a href="${fn:escapeXml(newTimeUrl)}" class="btn btn-default">Nueva oferta</a> </th>-->
</tr>
</thead>
<tbody>
@ -155,4 +179,5 @@
</c:forEach>
</tbody>
</table>
</c:if>
</cheapy:layout>

View file

@ -4,39 +4,58 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<petclinic:layout pageName="NumOffers">
<h2>
<c:if test="${nuOffer['new']}">New </c:if> NuOffer
<cheapy:layout pageName="NumOffers">
<h2 style="text-align:center;padding:5px">
<c:if test="${nuOffer['new']}"><fmt:message key="new"/> </c:if> <fmt:message key="nuOffer"/>
</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"/>
<cheapy:inputField label="Fecha de Inicio" placeholder="dd/MM/yyyy HH:mm" name="start"/>
<cheapy:inputField label="Fecha de Fin" placeholder="dd/MM/yyyy HH:mm" name="end"/>
<petclinic:inputField label="Oro" name="gold"/>
<petclinic:inputField label="descuento de oro" name="discountGold"/>
<petclinic:inputField label="Plata" name="silver"/>
<petclinic:inputField label="Descuento de plata" name="discountSilver"/>
<petclinic:inputField label="Bronce" name="bronze"/>
<petclinic:inputField label="Descuento de bronce" name="discountBronze"/>
<cheapy:inputField label="Número de comensales (nivel Oro)" placeholder="XX (Ej. 6)" name="gold"/>
<cheapy:inputField label="Descuento de nivel oro" placeholder="XX% (Ej. 30)" name="discountGold"/>
<cheapy:inputField label="Número de comensales (nivel Plata)" placeholder="XX (Ej. 4)" name="silver"/>
<cheapy:inputField label="Descuento de plata" placeholder="XX% (Ej. 15)" name="discountSilver"/>
<cheapy:inputField label="Número de comensales (nivel Bronce)" placeholder="XX (Ej. 2)" name="bronze"/>
<cheapy:inputField label="Descuento de bronce" placeholder="XX% (Ej. 5)" name="discountBronze"/>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<c:choose>
<c:when test="${nuOffer['new']}">
<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 class="btn-mod">
<c:choose>
<c:when test="${nuOffer['new']}">
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Crear oferta</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Modificar</button>
</c:otherwise>
</c:choose>
</div>
</div>
</div>
</form:form>
</petclinic:layout>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -2,26 +2,40 @@
<%@ 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="cheapy" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<petclinic:layout pageName="nuOffer">
<cheapy:layout pageName="nuOfferDisable">
<jsp:body>
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></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}" />
<input type="hidden" name="gold" value="${nuOffer.gold}" />
<input type="hidden" name="discountGold" value="${nuOffer.discountGold}" />
<input type="hidden" name="silver" value="${nuOffer.silver}" />
<input type="hidden" name="discountSilver" value="${nuOffer.discountSilver}" />
<input type="hidden" name="bronze" value="${nuOffer.bronze}" />
<input type="hidden" name="discountBronze" value="${nuOffer.discountBronze}" />
<button class="btn btn-default" type="submit">Dar de baja</button>
<div class="btns-edit">
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Dar de baja</button>
</div>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</jsp:body>
</petclinic:layout>
</cheapy:layout>

View file

@ -4,12 +4,14 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="nuOffer">
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffer"/></h2>
<h2 style="text-align: center; padding: 5px">
<fmt:message key="nuOffer" />
</h2>
<table class="table table-striped" id="nuOffer-table">
<tr>
@ -22,48 +24,72 @@
</tr>
<tr>
<th><fmt:message key="goldGoal"/></th>
<td><c:out value="${nuOffer.gold}"/></td>
<td><c:out value="${nuOffer.gold} comensales" /></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${nuOffer.discountGold}"/></td>
<td><c:out value="${nuOffer.discountGold}%"/></td>
</tr>
<tr>
<th><fmt:message key="silverGoal"/></th>
<td><c:out value="${nuOffer.silver}"/></td>
<td><c:out value="${nuOffer.silver} comensales"/></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${nuOffer.discountSilver}"/></td>
<td><c:out value="${nuOffer.discountSilver}%"/></td>
</tr>
<tr>
<th>Meta bronce</th>
<td><c:out value="${nuOffer.bronze}"/></td>
<td><c:out value="${nuOffer.bronze} comensales"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount"/></th>
<td><c:out value="${nuOffer.discountBronze}"/></td>
<td><c:out value="${nuOffer.discountBronze}%"/></td>
</tr>
<tr>
<th><fmt:message key="offerCode"/></th>
<td><c:out value="${nuOffer.code}"/></td>
</tr>
</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="{nuOfferId}/edit" var="editUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<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>
<div class="btn-menu">
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btns-edit">
<spring:url value="{nuOfferId}/edit" var="editUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Editar oferta</button>
<c:if test="${nuOffer.status eq 'hidden' }">
<spring:url value="{nuOfferId}/activate" var="activateUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(activateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Activar oferta</button>
</c:if>
<c:if test="${nuOffer.status eq 'active' }">
<spring:url value="{nuOfferId}/disable" var="deactivateUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(deactivateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Desactivar oferta</button>
</c:if>
</div>
</sec:authorize>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -0,0 +1,46 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ 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" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="crearOfertas">
<div class="btn-create-max">
<div class="btn-create">
<button type="button" role="link" onclick="window.location='/offers/food/new'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createFoodOffers"/> </button>
</div>
<div class="btn-create">
<button type="button" role="link" onclick="window.location='/offers/nu/new'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createNuOffers"/> </button>
</div>
<div class="btn-create">
<button type="button" role="link" onclick="window.location='/offers/speed/new'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createSpeedOffers"/> </button>
</div>
<div class="btn-create">
<button type="button" role="link" onclick="window.location='/offers/time/new'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createTimeOffers"/> </button>
</div>
</div>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -8,12 +8,16 @@
<cheapy:layout pageName="ofertas">
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffers"/></h2>
<c:if test="${empty foodOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty foodOfferLs }">
<table id="foodOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="food"/></th>
<th><fmt:message key="discount"/></th>
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th> </th>
@ -25,6 +29,9 @@
<td>
<c:out value="${foodOffer.food}"/>
</td>
<td>
<c:out value="${foodOffer.discount}%"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
</td>
@ -46,15 +53,20 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="nuOffers"/></h2>
<c:if test="${empty nuOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty nuOfferLs }">
<table id="nuOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="goldGoal"/></th>
<th><fmt:message key="goldDiscount"/></th>
<th> </th>
</tr>
@ -69,6 +81,12 @@
<td>
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
</td>
<td>
<c:out value="${nuOffer.gold} comensales"/>
</td>
<td>
<c:out value="${nuOffer.discountGold}%"/>
</td>
<td>
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
@ -83,14 +101,21 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
<c:if test="${empty speedOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty speedOfferLs }">
<table id="speedOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="goldGoal"/></th>
<th><fmt:message key="goldDiscount"/></th>
<th> </th>
</tr>
@ -105,6 +130,12 @@
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
</td>
<td>
<c:out value="${speedOffer.gold} minutos"/>
</td>
<td>
<c:out value="${speedOffer.discountGold}%"/>
</td>
<td>
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
@ -120,14 +151,21 @@
</c:forEach>
</tbody>
</table>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
<c:if test="${empty timeOfferLs }">
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty timeOfferLs }">
<table id="timeOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="init"/></th>
<th><fmt:message key="finish"/></th>
<th> </th>
</tr>
</thead>
@ -141,6 +179,13 @@
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
</td>
<td>
<c:out value="${timeOffer.init}h"/>
</td>
<td>
<c:out value="${timeOffer.finish}h"/>
</td>
<td>
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
@ -155,4 +200,16 @@
</c:forEach>
</tbody>
</table>
</c:if>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -4,37 +4,56 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<petclinic:layout pageName="speedOffers">
<h2>
<c:if test="${speedOffer['new']}">New </c:if> SpeedOffer
<cheapy:layout pageName="speedOffers">
<h2 style="text-align:center;padding:5px">
<c:if test="${speedOffer['new']}"><fmt:message key="new"/> </c:if> <fmt:message key="speedOffer"/>
</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"/>
<petclinic:inputField label="Gold Discount" name="discountGold"/>
<petclinic:inputField label="Silver" name="silver"/>
<petclinic:inputField label="Silver Discount" name="discountSilver"/>
<petclinic:inputField label="Bronze" name="bronze"/>
<petclinic:inputField label="Bronze Discount" name="discountBronze"/>
<cheapy:inputField label="Fecha de Inicio" placeholder="dd/MM/yyyy HH:mm" name="start"/>
<cheapy:inputField label="Fecha de Fin" placeholder="dd/MM/yyyy HH:mm" name="end"/>
<cheapy:inputField label="Tiempo para comer (nivel Oro)" placeholder="XX minutos (Ej. 5)" name="gold"/>
<cheapy:inputField label="Descuento nivel Oro" placeholder="XX% (Ej. 35)" name="discountGold"/>
<cheapy:inputField label="Tiempo para comer (nivel Plata)" placeholder="XX minutos (Ej. 10)" name="silver"/>
<cheapy:inputField label="Descuento nivel Plata" placeholder="XX% (Ej. 15)" name="discountSilver"/>
<cheapy:inputField label="Tiempo para comer (nivel Bronce)" placeholder="XX minutos (Ej. 20)" name="bronze"/>
<cheapy:inputField label="Descuento nivel Bronce" placeholder="XX% (Ej. 5)" name="discountBronze"/>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<c:choose>
<c:when test="${speedOffer['new']}">
<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 class="btn-mod">
<c:choose>
<c:when test="${speedOffer['new']}">
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Crear oferta</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Modificar</button>
</c:otherwise>
</c:choose>
</div>
</div>
</div>
</form:form>
</petclinic:layout>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -2,26 +2,41 @@
<%@ 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="cheapy" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<petclinic:layout pageName="speedOffer">
<cheapy:layout pageName="speedOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere dar de baja su offer? </h2>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></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>
<input type="hidden" name="gold" value="${speedOffer.gold}" />
<input type="hidden" name="discountGold" value="${speedOffer.discountGold}" />
<input type="hidden" name="silver" value="${speedOffer.silver}" />
<input type="hidden" name="discountSilver" value="${speedOffer.discountSilver}" />
<input type="hidden" name="bronze" value="${speedOffer.bronze}" />
<input type="hidden" name="discountBronze" value="${speedOffer.discountBronze}" />
<div class="btns-edit">
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Dar de baja</button>
</div>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</jsp:body>
</petclinic:layout>
</cheapy:layout>

View file

@ -4,12 +4,14 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="speedOffer">
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffer"/></h2>
<h2 style="text-align: center; padding: 5px">
<fmt:message key="speedOffer" />
</h2>
<table class="table table-striped" id="speedOffer-table">
<tr>
@ -22,48 +24,74 @@
</tr>
<tr>
<th><fmt:message key="goldGoal"/></th>
<td><c:out value="${speedOffer.gold}"/></td>
<td><c:out value="${speedOffer.gold} minutos"/></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${speedOffer.discountGold}"/></td>
<td><c:out value="${speedOffer.discountGold}%"/></td>
</tr>
<tr>
<th><fmt:message key="silverGoal"/></th>
<td><c:out value="${speedOffer.silver}"/></td>
<td><c:out value="${speedOffer.silver} minutos"/></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${speedOffer.discountSilver}"/></td>
<td><c:out value="${speedOffer.discountSilver}%"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeGoal"/></th>
<td><c:out value="${speedOffer.bronze}"/></td>
<td><c:out value="${speedOffer.bronze} minutos"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount"/></th>
<td><c:out value="${speedOffer.discountBronze}"/></td>
<td><c:out value="${speedOffer.discountBronze}%"/></td>
</tr>
<tr>
<th><fmt:message key="offerCode"/></th>
<td><c:out value="${speedOffer.code}"/></td>
</tr>
</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="{speedOfferId}/edit" var="editUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<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>
<div class="btn-menu">
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btns-edit">
<spring:url value="{speedOfferId}/edit" var="editUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Editar oferta</button>
<c:if test="${speedOffer.status eq 'hidden' }">
<spring:url value="{speedOfferId}/activate" var="activateUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(activateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Activar oferta</button>
</c:if>
<c:if test="${speedOffer.status eq 'active' }">
<spring:url value="{speedOfferId}/disable" var="deactivateUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(deactivateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Desactivar oferta</button>
</c:if>
</div>
</sec:authorize>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -4,37 +4,56 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<petclinic:layout pageName="TimeOffers">
<h2>
<c:if test="${timeOffer['new']}">New </c:if> TimeOffer
<cheapy:layout pageName="TimeOffers">
<h2 style="text-align:center;padding:5px">
<c:if test="${timeOffer['new']}"><fmt:message key="new"/> </c:if> <fmt:message key="timeOffer"/>
</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"/>
<petclinic:inputField label="Hora de inicio" name="init"/>
<petclinic:inputField label="Hora de final" name="finish"/>
<petclinic:inputField label="Descuento" name="discount"/>
<cheapy:inputField label="Fecha de inicio" placeholder="dd/MM/yyyy HH:mm" name="start"/>
<cheapy:inputField label="Fecha de fin" placeholder="dd/MM/yyyy HH:mm" name="end"/>
<cheapy:inputField label="Hora de inicio" placeholder="HH:mm" name="init"/>
<cheapy:inputField label="Hora de final" placeholder="HH:mm" name="finish"/>
<cheapy:inputField label="Descuento" placeholder="XX% (Ej.15)" name="discount"/>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<c:choose>
<c:when test="${timeOffer['new']}">
<button class="btn btn-default" type="submit">Add Offer</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit">Update Offer</button>
</c:otherwise>
</c:choose>
<div class="btn-mod">
<c:choose>
<c:when test="${timeOffer['new']}">
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Crear oferta</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-floppy-save" aria-hidden="true" style="padding: 5px"> </span>
Modificar</button>
</c:otherwise>
</c:choose>
</div>
</div>
</div>
</form:form>
</petclinic:layout>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -2,23 +2,37 @@
<%@ 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="cheapy" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<petclinic:layout pageName="foodOffer">
<cheapy:layout pageName="timeOffer">
<jsp:body>
<h2> ¿Esta seguro de que quiere eliminar su oferta? </h2>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 30px; color: rgb(0, 64, 128); padding:30px"><em>¿Está seguro de que quiere eliminar su oferta?</em></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}" />
<form:form modelAttribute="timeOffer" class="form-horizontal">
<input type="hidden" name="init" value="${timeOffer.init}" />
<input type="hidden" name="finish" value="${timeOffer.finish}" />
<input type="hidden" name="discount" value="${timeOffer.discount}" />
<button class="btn btn-default" type="submit">Eliminar Oferta</button>
<div class="btns-edit">
<button type="submit" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Dar de baja</button>
</div>
</form:form>
<a class="btn btn-default" href='<spring:url value="/offers" htmlEscape="true"/>'>Volver</a>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<script>
function goBack() {
window.history.back()
}
</script>
</jsp:body>
</petclinic:layout>
</cheapy:layout>

View file

@ -4,6 +4,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="timeOffer">
@ -11,7 +12,7 @@
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffer"/></h2>
<table class="table table-striped">
<table id="timeOfferTable" class="table table-striped">
<thead>
<tr>
<th><fmt:message key="offerBeginning"/></th>
@ -21,9 +22,17 @@
<th><fmt:message key="offerEnding"/></th>
<td><c:out value="${localDateTimeFormat.format(timeOffer.end)}"/></td>
</tr>
<tr>
<th><fmt:message key="init"/></th>
<td><c:out value="${timeOffer.init}h"/></td>
</tr>
<tr>
<th><fmt:message key="finish"/></th>
<td><c:out value="${timeOffer.finish}h"/></td>
</tr>
<tr>
<th><fmt:message key="discount"/></th>
<td><c:out value="${timeOffer.discount}"/></td>
<td><c:out value="${timeOffer.discount}%"/></td>
</tr>
<tr>
<th><fmt:message key="offerCode"/></th>
@ -32,20 +41,47 @@
</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-menu">
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btns-edit">
<spring:url value="{timeOfferId}/edit" var="editUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Editar oferta</button>
<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>
<c:if test="${timeOffer.status eq 'hidden' }">
<spring:url value="{timeOfferId}/activate" var="activateUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(activateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Activar oferta</button>
</c:if>
<c:if test="${timeOffer.status eq 'active' }">
<spring:url value="{timeOfferId}/disable" var="deactivateUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(deactivateUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-trash" aria-hidden="true" style="padding: 5px"> </span>
Desactivar oferta</button>
</c:if>
</div>
</sec:authorize>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -0,0 +1,32 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<cheapy:layout pageName="reviewsN">
<h2>
<c:if test="${review['new']}">Nueva </c:if> Reseña
</h2>
<form:form modelAttribute="review" class="form-horizontal" id="add-review-form">
<div class="form-group has-feedback">
<form:hidden path="id"/>
<cheapy:textAreaField label="Opinión" name="opinion"/>
<cheapy:inputField label="Estrellas" name="stars"/>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<c:choose>
<c:when test="${review['new']}">
<button class="btn btn-default" type="submit">Crear Reseña</button>
</c:when>
<c:otherwise>
<button class="btn btn-default" type="submit">Modificar Reseña</button>
</c:otherwise>
</c:choose>
</div>
</div>
</form:form>
</cheapy:layout>

View file

@ -0,0 +1,59 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ 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" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="reviews">
<h2 style="text-align:center;padding:5px"><fmt:message key="reviews"/></h2>
<table id="reviewTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="user"/></th>
<th><fmt:message key="stars"/></th>
<th><fmt:message key="opinion"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:choose>
<c:when test="${fn:length(reviewsLs) == 0}">
<tr><td colspan="4"><em><c:out value="No se ha realizado ninguna valoración por el momento."/></em></td></tr>
</c:when>
<c:otherwise>
<c:forEach items="${reviewsLs}" var="review">
<tr>
<!-- <td> -->
<%-- <c:out value="nombre por definir"/> <!-- ${review.usuario.nombre},${review.usuario.apellidos} --> --%>
<!-- </td> -->
<td>
<c:out value="${review.escritor.username}"/>
</td>
<td>
<c:out value="${review.stars}"/>
</td>
<td>
<c:out value="${review.opinion}"/>
</td>
<td>
<spring:url value="/reviews/{reviewId}" var="reviewUrl">
<spring:param name="reviewId" value="${review.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewUrl)}'" 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>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
</table>
</cheapy:layout>

View file

@ -0,0 +1,51 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<cheapy:layout pageName="review">
<h2 style="text-align:center;padding:5px"><fmt:message key="review"/></h2>
<table class="table table-striped" id="review-table">
<tr>
<th><fmt:message key="stars"/></th>
<td><c:out value="${review.stars}"/></td>
</tr>
<tr>
<th><fmt:message key="opinion"/></th>
<td><c:out value="${review.opinion}"/></td>
</tr>
</table>
<div class="btn-return">
<button type="button" role="link" onclick="goBack()" 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>
<sec:authentication var="principal" property="principal" />
<div class="btns-edit">
<c:if test="${ principal.username eq review.escritor.username }">
<spring:url value="{reviewId}/edit" var="editUrl">
<spring:param name="reviewId" value="${review.id}"/>
</spring:url>
<button type="button" role="link" onclick="window.location='${fn:escapeXml(editUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Editar opinión</button>
</c:if>
</div>
<script>
function goBack() {
window.history.back()
}
</script>
</cheapy:layout>

View file

@ -1,11 +1,14 @@
<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ 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" %>
<link href='https://fonts.googleapis.com/css?family=Lobster' rel='stylesheet'>
<!-- %@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %-->
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<cheapy:layout pageName="home">
<cheapy:layout pageName="home">
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 60px; color: rgb(0, 64, 128); padding:30px"><fmt:message key="welcome"/></h2>
<div class="row">
<div class="col-md-12">
@ -14,10 +17,19 @@
<img class="img-responsive" src="${cheapyImage}"/>
</div>
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="listOffers"/> </button>
</div>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/offersCreate'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createOffers"/> </button>
</div>
</sec:authorize>
</div>
</div>
</cheapy:layout>

View file

@ -14,7 +14,7 @@ Cheapy :: a Spring Framework demonstration
<spring:url value="/resources/images/faviconChikito.png" var="favicon"/>
<link rel="shortcut icon" type="image/x-icon" href="${favicon}">
<title>Cheapy : eat fast, eat cheapy</title>
<title>Cheapy: Eat fast, eat cheapy</title>
<%-- CSS generated from LESS --%>
<spring:url value="/resources/css/cheapy.css" var="cheapyCss"/>

View file

@ -5,15 +5,17 @@
description="Name of corresponding property in bean object" %>
<%@ attribute name="label" required="true" rtexprvalue="true"
description="Label appears in red color if input is considered as invalid after submission" %>
<%@ attribute name="placeholder" required="false" rtexprvalue="true"
description="Placeholder para los campos en los input fields" %>
<spring:bind path="${name}">
<c:set var="cssGroup" value="form-group ${status.error ? 'has-error' : '' }"/>
<c:set var="valid" value="${not status.error and not empty status.actualValue}"/>
<div class="${cssGroup}">
<label class="col-sm-2 control-label">${label}</label>
<div class="col-sm-10">
<form:input class="form-control" path="${name}"/>
<form:input class="form-control" placeholder="${placeholder }" path="${name}"/>
<c:if test="${valid}">
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
</c:if>

View file

@ -28,14 +28,13 @@
<span>Inicio</span>
</cheapy:menuItem>
<cheapy:menuItem active="${name eq 'ofertas'}" url="/offers"
title="ofertas">
<cheapy:menuItem active="${name eq 'ofertas'}" url="/offers" title="ofertas">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
<span>Ver ofertas</span>
</cheapy:menuItem>
<sec:authorize access="hasAnyAuthority('client')">
<cheapy:menuItem active="${name eq 'ofertas'}" url="/myOffers" title="misOfertas">
<cheapy:menuItem active="${name eq 'ofertasM'}" url="/myOffers" title="misOfertas">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true"></span>
<span>Mis ofertas</span>
</cheapy:menuItem>
@ -44,22 +43,29 @@
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
title="contactanos">
<span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>
<span>Contáctanos</span>
<span>Cont�ctanos</span>
</cheapy:menuItem>
-->
<sec:authorize access="isAuthenticated()">
<cheapy:menuItem active="${name eq 'reviews'}" url="/reviews" title="opiniones">
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
<span>Reseñas</span>
</cheapy:menuItem>
<cheapy:menuItem active="${name eq 'reviewsN'}" url="/reviews/new" title="valóranos">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
<span>Valóranos</span>
</cheapy:menuItem>
</sec:authorize>
</ul>
<ul class="nav navbar-nav navbar-right">
<sec:authorize access="!isAuthenticated()">
<li><a href="<c:url value="/login" />">Login</a></li>
<li><a href="<c:url value="/login" />">Iniciar sesión</a></li>
<!--<li><a href="<c:url value="/users/new" />">Register</a></li>-->
</sec:authorize>
<sec:authorize access="isAuthenticated()">
<li class="dropdown"><a href="#" class="dropdown-toggle"
data-toggle="dropdown"> <span class="glyphicon glyphicon-user"></span> 
data-toggle="dropdown"> <span class="glyphicon glyphicon-user"></span>
<strong><sec:authentication property="name" /></strong> <span
class="glyphicon glyphicon-chevron-down"></span>
</a>
@ -104,8 +110,5 @@
</sec:authorize>
</ul>
</div>
</div>
</nav>

View file

@ -0,0 +1,28 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ attribute name="name" required="true" rtexprvalue="true"
description="Name of corresponding property in bean object" %>
<%@ attribute name="label" required="true" rtexprvalue="true"
description="Label appears in red color if input is considered as invalid after submission" %>
<%@ attribute name="placeholder" required="false" rtexprvalue="true"
description="Example for input field" %>
<spring:bind path="${name}">
<c:set var="cssGroup" value="form-group ${status.error ? 'has-error' : '' }"/>
<c:set var="valid" value="${not status.error and not empty status.actualValue}"/>
<div class="${cssGroup}">
<label class="col-sm-2 control-label">${label}</label>
<div class="col-sm-10">
<form:textarea class="form-control" rows = "5" cols = "30" path="${name}"/>
<c:if test="${valid}">
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
</c:if>
<c:if test="${status.error}">
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
<span class="help-inline">${status.errorMessage}</span>
</c:if>
</div>
</div>
</spring:bind>