Registro de todas las ofertas
This commit is contained in:
Antonio Vidal 2021-04-13 15:56:41 +02:00 committed by GitHub
commit 7a6d824e9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 0 deletions

View file

@ -2,11 +2,14 @@
package org.springframework.cheapy.web;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.cheapy.model.FoodOffer;
import org.springframework.cheapy.model.NuOffer;
import org.springframework.cheapy.model.Offer;
import org.springframework.cheapy.model.SpeedOffer;
import org.springframework.cheapy.model.TimeOffer;
import org.springframework.cheapy.service.ClientService;
@ -123,7 +126,38 @@ public class OfertaController {
return "offers/offersCreate";
}
@GetMapping("/offersRecord")
public String processOffersRecordForm(final Map<String, Object> model) {
Pageable p = PageRequest.of(0, 3);
Map<Offer, String> datos = new HashMap<Offer, String>();
for(Offer of:this.foodOfferService.findAllFoodOffer(p)) {
datos.put(of, "food");
}
for(Offer of:this.nuOfferService.findAllNuOffer(p)) {
datos.put(of, "nu");
}
for(Offer of:this.speedOfferService.findAllSpeedOffer(p)) {
datos.put(of, "speed");
}
for(Offer of:this.timeOfferService.findAllTimeOffer(p)) {
datos.put(of, "time");
}
model.put("datos", datos);
//Se añade formateador de fecha al modelo
model.put("localDateTimeFormat", DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"));
return "offers/offersRecordList";
}
// @GetMapping("/owners/{ownerId}/edit")
// public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model model) {
// Owner owner = this.ownerService.findOwnerById(ownerId);

View file

@ -0,0 +1,74 @@
<%@ 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="ofertasM">
<h2 style="text-align:center;padding:5px">Registro de Ofertas</h2>
<c:if test="${empty datos }">
<p id="vacio" >No hay ninguna oferta creada.</p>
</c:if>
<c:if test="${not empty datos }">
<div class="table-responsive">
<table id="offerTable" class="table table-striped">
<thead>
<tr>
<th>Restaurante</th>
<th>Tipo de oferta</th>
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="status"/></th>
<th></th>
</tr>
</thead>
<tbody>
<c:forEach items="${datos}" var="datos">
<tr>
<td>
<c:out value="${datos.key.client.name}"/>
</td>
<td>
<c:if test="${datos.value == 'time'}">
<c:out value="Por franja horaria"/>
</c:if>
<c:if test="${datos.value == 'nu'}">
<c:out value="Por numero de comensales"/>
</c:if>
<c:if test="${datos.value == 'speed'}">
<c:out value="Por rapidez"/>
</c:if>
<c:if test="${datos.value == 'food'}">
<c:out value="Por plato especifico"/>
</c:if>
</td>
<td>
<c:out value="${localDateTimeFormat.format(datos.key.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(datos.key.end)}"/>
</td>
<td>
<c:out value="${datos.key.status}"/>
</td>
<td>
<spring:url value="/offers/${datos.value}/${datos.key.id}" var="offerUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(offerUrl)}'" 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>
</tbody>
</table>
</div>
</c:if>
</cheapy:layout>

View file

@ -53,6 +53,13 @@
<span>Usuarios</span>
</cheapy:menuItem>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('admin')">
<cheapy:menuItem active="${name eq 'registro'}" url="/offersRecord" title="offersRecord">
<span class="glyphicon " aria-hidden="true"></span>
<span>Registro de ofertas</span>
</cheapy:menuItem>
</sec:authorize>
<!--
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
title="contactanos">