Avances validadores

This commit is contained in:
Javier 2021-03-31 19:21:26 +02:00
parent ce0ee43e79
commit ba3aa68598
8 changed files with 341 additions and 280 deletions

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
@ -25,6 +26,7 @@ public class TimeOffer extends Offer {
private LocalTime finish;
@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

@ -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

@ -15,7 +15,9 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@ -32,13 +34,18 @@ public class NuOfferController {
this.clientService = clientService;
}
// @InitBinder
// public void setAllowedFields(WebDataBinder dataBinder) {
// dataBinder.setDisallowedFields("id");
// }
@GetMapping("/offers/nu/new")
public String initCreationForm(Map<String, Object> model) {
NuOffer nuOffer = new NuOffer();
model.put("nuOffer", nuOffer);
return VIEWS_NU_OFFER_CREATE_OR_UPDATE_FORM;
}
private boolean checkIdentity(final int nuOfferId) {
boolean res = false;
Client client = this.clientService.getCurrentClient();
@ -62,11 +69,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);
@ -74,11 +81,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();
}
@ -94,7 +101,7 @@ public class NuOfferController {
@GetMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final ModelMap model) {
if (!this.checkIdentity(nuOfferId)) {
return "error";
}
@ -106,7 +113,7 @@ public class NuOfferController {
@PostMapping(value = "/offers/nu/{nuOfferId}/edit")
public String updateNuOffer(@Valid final NuOffer nuOfferEdit, final BindingResult result, final ModelMap model) {
if (!this.checkIdentity(nuOfferEdit.getId())) {
return "error";
}
@ -122,7 +129,8 @@ public class NuOfferController {
}
@GetMapping(value = "/offers/nu/{nuOfferId}/disable")
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
public String disableNuOffer(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal,
final ModelMap model) {
if (!this.checkIdentity(nuOfferId)) {
return "error";
@ -134,12 +142,13 @@ public class NuOfferController {
}
@PostMapping(value = "/offers/nu/{nuOfferId}/disable")
public String disableNuOfferForm(@PathVariable("nuOfferId") final int nuOfferId, final Principal principal, final ModelMap model) {
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);

View file

@ -1,63 +1,73 @@
<%@ 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'>
<%@ 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'>
<cheapy:layout pageName="foodOffer">
<h2 style="text-align:center;padding:5px"><fmt:message key="foodOffer"/></h2>
<h2 style="text-align: center; padding: 5px">
<fmt:message key="foodOffer" />
</h2>
<table class="table table-striped" id="foodOfferTable">
<thead>
<tr>
<th><fmt:message key="offerBeginning"/></th>
<td><c:out value="${localDateTimeFormat.format(foodOffer.start)}"/></td>
</tr>
<tr>
<th><fmt:message key="offerEnding"/></th>
<td><c:out value="${localDateTimeFormat.format(foodOffer.end)}"/></td>
</tr>
<tr>
<th><fmt:message key="foodInOffer"/></th>
<td><c:out value="${foodOffer.food}"/></td>
</tr>
<tr>
<th><fmt:message key="discount"/></th>
<td><c:out value="${foodOffer.discount} %"/></td>
</tr>
<table class="table table-striped" id="foodOfferTable">
<thead>
<tr>
<th><fmt:message key="offerBeginning" /></th>
<td><c:out
value="${localDateTimeFormat.format(foodOffer.start)}" /></td>
</tr>
<tr>
<th><fmt:message key="offerEnding" /></th>
<td><c:out value="${localDateTimeFormat.format(foodOffer.end)}" /></td>
</tr>
<tr>
<th><fmt:message key="foodInOffer" /></th>
<td><c:out value="${foodOffer.food}" /></td>
</tr>
<tr>
<th><fmt:message key="discount" /></th>
<td><c:out value="${foodOffer.discount} %" /></td>
</tr>
<tr>
<th><fmt:message key="offerCode" /></th>
<td><c:out value="${foodOffer.code}" /></td>
</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>
<tr>
<th><fmt:message key="offerCode"/></th>
<td><c:out value="${foodOffer.code}"/></td>
</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>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
</cheapy:layout>

View file

@ -1,42 +1,48 @@
<%@ 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" %>
<%@ 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="NumOffers">
<h2>
<c:if test="${nuOffer['new']}">Nueva </c:if> Oferta por número de comensales
</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"/>
<cheapy:inputField label="Fecha de inicio" placeholder="15/06/2021 14:00" name="start"/>
<cheapy:inputField label="Fecha de fin" placeholder="15/06/2021 16:00" name="end"/>
<cheapy:inputField label="Oro" name="gold"/>
<cheapy:inputField label="Descuento de oro" name="discountGold"/>
<cheapy:inputField label="Plata" name="silver"/>
<cheapy:inputField label="Descuento de plata" name="discountSilver"/>
<cheapy:inputField label="Bronce" name="bronze"/>
<cheapy:inputField label="Descuento de bronce" name="discountBronze"/>
<h2>
<c:if test="${nuOffer['new']}">Nueva </c:if>
Oferta por número de comensales
</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" />
</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>
</div>
</form:form>
<cheapy:inputField label="Fecha de inicio"
placeholder="15/06/2021 14:00" name="start" />
<cheapy:inputField label="Fecha de fin"
placeholder="15/06/2021 16:00" name="end" />
<cheapy:inputField label="Oro" name="gold" />
<cheapy:inputField label="Descuento de oro" name="discountGold" />
<cheapy:inputField label="Plata" name="silver" />
<cheapy:inputField label="Descuento de plata" name="discountSilver" />
<cheapy:inputField label="Bronce" name="bronze" />
<cheapy:inputField label="Descuento de bronce" 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>
</div>
</form:form>
</cheapy:layout>

View file

@ -1,74 +1,83 @@
<%@ 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'>
<%@ 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="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>
<th><fmt:message key="offerBeginning"/></th>
<td><c:out value="${localDateTimeFormat.format(nuOffer.start)}"/></td>
</tr>
<tr>
<th><fmt:message key="offerEnding"/></th>
<td><c:out value="${localDateTimeFormat.format(nuOffer.end)}"/></td>
</tr>
<tr>
<th><fmt:message key="goldGoal"/></th>
<td><c:out value="${nuOffer.gold}"/></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${nuOffer.discountGold} %"/></td>
</tr>
<tr>
<th><fmt:message key="silverGoal"/></th>
<td><c:out value="${nuOffer.silver}"/></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${nuOffer.discountSilver} %"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeGoal"/></th>
<td><c:out value="${nuOffer.bronze}"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount"/></th>
<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>
<table class="table table-striped" id="nuOffer-table">
<tr>
<th><fmt:message key="offerBeginning" /></th>
<td><c:out value="${localDateTimeFormat.format(nuOffer.start)}" /></td>
</tr>
<tr>
<th><fmt:message key="offerEnding" /></th>
<td><c:out value="${localDateTimeFormat.format(nuOffer.end)}" /></td>
</tr>
<tr>
<th><fmt:message key="goldGoal" /></th>
<td><c:out value="${nuOffer.gold}" /></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount" /></th>
<td><c:out value="${nuOffer.discountGold} %" /></td>
</tr>
<tr>
<th><fmt:message key="silverGoal" /></th>
<td><c:out value="${nuOffer.silver}" /></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount" /></th>
<td><c:out value="${nuOffer.discountSilver} %" /></td>
</tr>
<tr>
<th><fmt:message key="bronzeGoal" /></th>
<td><c:out value="${nuOffer.bronze}" /></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount" /></th>
<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>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
</cheapy:layout>

View file

@ -1,74 +1,84 @@
<%@ 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'>
<%@ 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="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>
<th><fmt:message key="offerBeginning"/></th>
<td><c:out value="${localDateTimeFormat.format(speedOffer.start)}"/></td>
</tr>
<tr>
<th><fmt:message key="offerEnding"/></th>
<td><c:out value="${localDateTimeFormat.format(speedOffer.end)}"/></td>
</tr>
<tr>
<th><fmt:message key="goldGoal"/></th>
<td><c:out value="${speedOffer.gold}"/></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount"/></th>
<td><c:out value="${speedOffer.discountGold} %"/></td>
</tr>
<tr>
<th><fmt:message key="silverGoal"/></th>
<td><c:out value="${speedOffer.silver}"/></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount"/></th>
<td><c:out value="${speedOffer.discountSilver} %"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeGoal"/></th>
<td><c:out value="${speedOffer.bronze}"/></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount"/></th>
<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>
<table class="table table-striped" id="speedOffer-table">
<tr>
<th><fmt:message key="offerBeginning" /></th>
<td><c:out
value="${localDateTimeFormat.format(speedOffer.start)}" /></td>
</tr>
<tr>
<th><fmt:message key="offerEnding" /></th>
<td><c:out value="${localDateTimeFormat.format(speedOffer.end)}" /></td>
</tr>
<tr>
<th><fmt:message key="goldGoal" /></th>
<td><c:out value="${speedOffer.gold}" /></td>
</tr>
<tr>
<th><fmt:message key="goldDiscount" /></th>
<td><c:out value="${speedOffer.discountGold} %" /></td>
</tr>
<tr>
<th><fmt:message key="silverGoal" /></th>
<td><c:out value="${speedOffer.silver}" /></td>
</tr>
<tr>
<th><fmt:message key="silverDiscount" /></th>
<td><c:out value="${speedOffer.discountSilver} %" /></td>
</tr>
<tr>
<th><fmt:message key="bronzeGoal" /></th>
<td><c:out value="${speedOffer.bronze}" /></td>
</tr>
<tr>
<th><fmt:message key="bronzeDiscount" /></th>
<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>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
</cheapy:layout>

View file

@ -1,56 +1,66 @@
<%@ 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'>
<%@ 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="timeOffer">
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffer"/></h2>
<h2 style="text-align: center; padding: 5px">
<fmt:message key="timeOffer" />
</h2>
<table class="table table-striped">
<thead>
<tr>
<th><fmt:message key="offerBeginning"/></th>
<td><c:out value="${localDateTimeFormat.format(timeOffer.start)}"/></td>
</tr>
<tr>
<th><fmt:message key="offerEnding"/></th>
<td><c:out value="${localDateTimeFormat.format(timeOffer.end)}"/></td>
</tr>
<tr>
<th><fmt:message key="discount"/></th>
<td><c:out value="${timeOffer.discount} %"/></td>
</tr>
<tr>
<th><fmt:message key="offerCode"/></th>
<td><c:out value="${timeOffer.code}"/></td>
</tr>
</thead>
</table>
<table class="table table-striped">
<thead>
<tr>
<th><fmt:message key="offerBeginning" /></th>
<td><c:out
value="${localDateTimeFormat.format(timeOffer.start)}" /></td>
</tr>
<tr>
<th><fmt:message key="offerEnding" /></th>
<td><c:out value="${localDateTimeFormat.format(timeOffer.end)}" /></td>
</tr>
<tr>
<th><fmt:message key="discount" /></th>
<td><c:out value="${timeOffer.discount} %" /></td>
</tr>
<tr>
<th><fmt:message key="offerCode" /></th>
<td><c:out value="${timeOffer.code}" /></td>
</tr>
</thead>
</table>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<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>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('client')">
<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>
</sec:authorize>
<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>
<div class="btn-return">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-arrow-left" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="return"/> </button>
</div>
</cheapy:layout>