Merge branch 'develop' into 021-Ver-info-restaurante#70

This commit is contained in:
Pablo Franco Sánchez 2021-04-10 11:51:01 +02:00 committed by GitHub
commit 227d0d87a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 658 additions and 311 deletions

View file

@ -46,7 +46,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/usuarios/new").permitAll()
.antMatchers("/usuarios/**").hasAnyAuthority("usuario")
.antMatchers("/admin/**").hasAnyAuthority("admin")
.antMatchers("/administrators/**").hasAnyAuthority("admin")
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")

View file

@ -1,15 +1,29 @@
package org.springframework.cheapy.model;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name = "administrators")
public class Administrator extends User{
public class Administrator extends BaseEntity{
/**
*
*/
private static final long serialVersionUID = 1L;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "username", referencedColumnName = "username")
private User usuar;
public User getUsuar() {
return usuar;
}
public void setUsuar(User usuar) {
this.usuar = usuar;
}
}

View file

@ -1,6 +1,9 @@
package org.springframework.cheapy.repository;
import java.util.Optional;
import java.util.List;
import org.springframework.cheapy.model.Client;
import org.springframework.data.jpa.repository.Query;
@ -16,6 +19,12 @@ public interface ClientRepository extends CrudRepository<Client, String> {
Optional<Client> findById(Integer id);
// void save(Client client);
@Query("SELECT client FROM Client client")
@Transactional(readOnly = true)
List<Client> findAllClient();
}

View file

@ -1,5 +1,7 @@
package org.springframework.cheapy.repository;
import java.util.List;
import org.springframework.cheapy.model.Usuario;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
@ -11,6 +13,10 @@ public interface UsuarioRepository extends Repository<Usuario, String> {
@Transactional(readOnly = true)
Usuario findByUsername(String username);
@Query("SELECT usuario FROM Usuario usuario")
@Transactional(readOnly = true)
List<Usuario> findAllUsuario();
void save(Usuario usuario);
}

View file

@ -1,5 +1,7 @@
package org.springframework.cheapy.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.repository.ClientRepository;
@ -26,8 +28,16 @@ public class ClientService {
return this.clientRepository.findByUsername(username);
}
@Transactional
public Client findByUsername(String username) throws DataAccessException {
return this.clientRepository.findByUsername(username);
}
public void saveClient(final Client client) throws DataAccessException {
this.clientRepository.save(client);
}
@Transactional
public List<Client> findAllClient() throws DataAccessException {
return this.clientRepository.findAllClient();
}
}

View file

@ -1,6 +1,8 @@
package org.springframework.cheapy.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cheapy.model.Usuario;
import org.springframework.cheapy.repository.UsuarioRepository;
@ -27,6 +29,16 @@ public class UsuarioService {
String username = authentication.getName();
return this.usuarioRepository.findByUsername(username);
}
@Transactional
public Usuario findByUsername(String username) throws DataAccessException {
return this.usuarioRepository.findByUsername(username);
}
@Transactional
public List<Usuario> findAllUsuario() throws DataAccessException {
return this.usuarioRepository.findAllUsuario();
}
@Transactional
public void saveUsuario(final Usuario usuario) throws DataAccessException {

View file

@ -0,0 +1,92 @@
package org.springframework.cheapy.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.cheapy.model.Client;
import org.springframework.cheapy.model.Usuario;
import org.springframework.cheapy.service.ClientService;
import org.springframework.cheapy.service.UsuarioService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class AdministratorController {
private static final String VIEWS_USUARIO_CREATE_OR_UPDATE_FORM = "usuarios/createOrUpdateUsuarioForm";
private final UsuarioService usuarioService;
private final ClientService clientService;
public AdministratorController(final UsuarioService usuarioService, ClientService clientService) {
this.usuarioService = usuarioService;
this.clientService=clientService;
}
@GetMapping("/administrators/usuarios")
public String processFindUsuariosForm(Map<String, Object> model) {
List<Usuario> usuarioLs = this.usuarioService.findAllUsuario();
model.put("usuarioLs", usuarioLs);
return "usuarios/usuariosList";
}
@GetMapping("/administrators/clients")
public String processFindClientesForm(Map<String, Object> model) {
List<Client> clientLs = this.clientService.findAllClient();
model.put("clientLs", clientLs);
return "clients/clientsList";
}
@GetMapping("/administrators/usuarios/{username}")
public String processUsuarioShowForm(@PathVariable("username") String username, Map<String, Object> model) {
Usuario usuario = this.usuarioService.findByUsername(username);
model.put("usuario", usuario);
return "usuarios/usuariosShow";
}
@GetMapping("/administrators/clients/{username}")
public String processClientShowForm(@PathVariable("username") String username, Map<String, Object> model) {
Client client = this.clientService.findByUsername(username);
model.put("client", client);
return "clients/clientShow";
}
@GetMapping(value = "/administrators/usuarios/{username}/disable")
public String disableUsuario(@PathVariable("username") final String username, final ModelMap model) {
Usuario usuario = this.usuarioService.findByUsername(username);
model.put("usuario", usuario);
return "usuarios/usuariosDisable";
}
@PostMapping(value = "/administrators/usuarios/{username}/disable")
public String disableUsuarioForm(@PathVariable("username") final String username, final ModelMap model, final HttpServletRequest request) {
Usuario usuario = this.usuarioService.findByUsername(username);
usuario.getUsuar().setEnabled(false);
this.usuarioService.saveUsuario(usuario);
return "redirect:/administrators/usuarios";
}
@GetMapping(value = "/administrators/clients/{username}/disable")
public String disableClient(@PathVariable("username") final String username, final ModelMap model) {
Client client = this.clientService.findByUsername(username);
model.put("client", client);
return "clients/clientDisable";
}
@PostMapping(value = "/administrators/clients/{username}/disable")
public String disableClientForm(@PathVariable("username") final String username, final ModelMap model, final HttpServletRequest request) {
Client client = this.clientService.findByUsername(username);
client.getUsuar().setEnabled(false);
this.clientService.saveClient(client);
return "redirect:/administrators/clients";
}
}

View file

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class UsuarioController {
private static final String VIEWS_USUARIO_CREATE_OR_UPDATE_FORM = "usuarios/createOrUpdateUsuariosForm";
private static final String VIEWS_USUARIO_CREATE_OR_UPDATE_FORM = "usuarios/createOrUpdateUsuarioForm";
private final UsuarioService usuarioService;

View file

@ -216,9 +216,15 @@ img.img-responsive{
padding: 20px;
}
.btn-home{
display: table;
margin: 0 auto;
.btn-block {
display: block;
width: 25%;
}
.btn-home {
display: flex;
justify-content: center;
align-items: center;
}
.btn-home button {
@ -227,7 +233,6 @@ img.img-responsive{
color: white;
padding: 10px 24px;
cursor: pointer;
width: 100%;
display: block;
}
@ -240,9 +245,12 @@ img.img-responsive{
background-color: rgb(40, 140, 215);
}
.btn-home{
display: table;
margin: 0 auto;
.btn-home-max button {
padding: 20px;
margin-left:auto;
margin-right: auto;
margin-bottom: 20px;
}
.btn-create button {
@ -342,6 +350,13 @@ text-align: center;
float:left;
}
.btn-menu button {
margin-left:auto;
margin-right: auto;
margin-bottom: 20px;
margin-right: 20px;
}
.btns-edit{
display: table;
margin: 0 auto;
@ -356,10 +371,6 @@ text-align: center;
cursor: pointer;
}
.btns-edit button:not(:last-child) {
border-bottom: none;
}
.btns-edit button:hover {
background-color: rgb(40, 140, 215);
@ -518,6 +529,14 @@ text-align: center;
color: rgb(29, 142, 226);
}
.row-full{
width: 100vw;
position: relative;
margin-left: -50vw;
height: 100px;
left: 50%;
}
.alert-success {
.alert-variant(fade(@alert-success-bg, 70%); @alert-success-border; @alert-success-text);
}

View file

@ -38,4 +38,13 @@
margin-bottom: 30px;
}
.btn-home button {
background-color: rgb(0, 64, 128);
border: 1px solid rgb(0, 0, 160);
color: white;
padding: 10px 24px;
cursor: pointer;
width: 70%;
display: block;
}
}

View file

@ -1,19 +1,20 @@
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','admin','admin', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('admin','admin', TRUE );
INSERT INTO authorities VALUES ('admin','admin');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','manoli','manoli', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('manoli','manoli', TRUE );
INSERT INTO authorities VALUES ('manoli','client');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','david','david', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('david','david', TRUE );
INSERT INTO authorities VALUES ('david','client');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','paco','paco', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('paco','paco', TRUE );
INSERT INTO authorities VALUES ('paco','usuario');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','lolo','lolo', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('lolo','lolo', TRUE );
INSERT INTO authorities VALUES ('lolo','usuario');
INSERT INTO users (dtype,username,password,enabled) VALUES ('User','pepe','pepe', TRUE );
INSERT INTO users (username,password,enabled) VALUES ('pepe','pepe', TRUE );
INSERT INTO authorities VALUES ('pepe','usuario');
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (1, 'admin', 'admin', 'admin', 'C/admin', '000000000', 'admin@gmail.com','admin');
INSERT INTO administrators (id, username) VALUES (1, 'admin');
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (2, 'Paco', 'Naranjo', '21154416G', 'C/Esperanza', '666973647', 'Paco@gmail.com','paco');
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (3, 'Lolo', 'Lopez', '25486596L', 'C/Macarena', '690670547' ,'Lolo@gmail.com','lolo');
INSERT INTO usuarios (id, nombre, apellidos, dni, direccion, telefono, email, username) VALUES (4, 'Pepe', 'Lopez', '12456776V', 'C/Macarena', '690670547', 'Pepe@gmail.com','pepe');

View file

@ -67,11 +67,20 @@
<button type="button" role="link" onclick="window.location='${fn:escapeXml(disableUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true" style="padding: 5px"> </span>
Borrar cliente</button>
</div>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('admin')">
<sec:authentication var="principal" property="principal" />
<div class="btns-edit">
<spring:url value="/administrators/clients/{username}/disable" var="deactivateUrl">
<spring:param name="username" value="${client.usuar.username}"/>
</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 cliente</button>
</div>
</sec:authorize>
</div>

View file

@ -0,0 +1,55 @@
<%@ 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="clients">
<h2 style="text-align:center;padding:5px"><fmt:message key="clients"/></h2>
<c:if test="${empty clientLs }">
<p id="vacio" >No hay ningun Cliente.</p>
</c:if>
<c:if test="${not empty clientLs }">
<table id="clientTable" class="table table-striped">
<thead>
<tr>
<th><fmt:message key="nameClient"/></th>
<th><fmt:message key="username"/></th>
<th><fmt:message key="enabled"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${clientLs}" var="client">
<tr>
<td>
<c:out value="${client.name}"/>
</td>
<td>
<c:out value="${client.usuar.username}"/>
</td>
<td>
<c:out value="${client.usuar.enabled}"/>
</td>
<td>
<spring:url value="/administrators/clients/{username}" var="clientUrl">
<spring:param name="username" value="${client.usuar.username}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(clientUrl)}'" 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>
</c:if>
</cheapy:layout>

View file

@ -94,7 +94,7 @@
background-color: #56baed;
border: none;
color: white;
padding: 15px 80px;
padding: 15px;
text-align: center;
text-decoration: none;
display: inline-block;
@ -110,6 +110,7 @@
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
width: 60%;
}
input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover {
@ -143,6 +144,7 @@
transition: all 0.5s ease-in-out;
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
margin: 0 auto;
}
input[type=text]:focus {
@ -292,7 +294,9 @@
<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="Iniciar sesión">
<div style="text-align: center;">
<input type="submit" class="fadeIn fourth" value="Iniciar sesión">
</div>
</form>
<!-- Remind Passowrd

View file

@ -12,95 +12,99 @@
<p id="vacio" >No hay ninguna oferta por plato específico creada.</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="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="status"/></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>
<c:forEach items="${foodOfferLs}" var="foodOffer">
<tr>
<td>
<c:out value="${foodOffer.food}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
</td>
<td>
<c:out value="${foodOffer.status}"/>
</td>
<td>
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/></button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<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="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="status"/></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>
<c:forEach items="${foodOfferLs}" var="foodOffer">
<tr>
<td>
<c:out value="${foodOffer.food}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(foodOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(foodOffer.end)}"/>
</td>
<td>
<c:out value="${foodOffer.status}"/>
</td>
<td>
<spring:url value="/offers/food/{foodOfferId}" var="foodOfferUrl">
<spring:param name="foodOfferId" value="${foodOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(foodOfferUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/></button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</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 número de comensales creada.</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="status"/></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>
<tbody>
<c:forEach items="${nuOfferLs}" var="nuOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
</td>
<td>
<c:out value="${nuOffer.status}"/>
</td>
<td>
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<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="status"/></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>
<tbody>
<c:forEach items="${nuOfferLs}" var="nuOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(nuOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(nuOffer.end)}"/>
</td>
<td>
<c:out value="${nuOffer.status}"/>
</td>
<td>
<spring:url value="/offers/nu/{nuOfferId}" var="nuOfferUrl">
<spring:param name="nuOfferId" value="${nuOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(nuOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
@ -108,47 +112,49 @@
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer creada.</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="status"/></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>
<tbody>
<c:forEach items="${speedOfferLs}" var="speedOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
</td>
<td>
<c:out value="${speedOffer.status}"/>
</td>
<td>
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<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="status"/></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>
<tbody>
<c:forEach items="${speedOfferLs}" var="speedOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.end)}"/>
</td>
<td>
<c:out value="${speedOffer.status}"/>
</td>
<td>
<spring:url value="/offers/speed/{speedOfferId}" var="speedOfferUrl">
<spring:param name="speedOfferId" value="${speedOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
@ -156,44 +162,46 @@
<p id="vacio" >No hay ninguna oferta por franja horaria creada.</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="status"/></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>
<c:forEach items="${timeOfferLs}" var="timeOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
</td>
<td>
<c:out value="${timeOffer.status}"/>
</td>
<td>
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<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="status"/></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>
<c:forEach items="${timeOfferLs}" var="timeOffer">
<tr>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
</td>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.end)}"/>
</td>
<td>
<c:out value="${timeOffer.status}"/>
</td>
<td>
<spring:url value="/offers/time/{timeOfferId}" var="timeOfferUrl">
<spring:param name="timeOfferId" value="${timeOffer.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:if>
</cheapy:layout>

View file

@ -11,9 +11,11 @@
<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>
<p id="vacio" >No hay ninguna oferta por plato específico activa.</p>
</c:if>
<c:if test="${not empty foodOfferLs }">
<div class="table-responsive">
<table id="foodOfferTable" class="table table-striped">
<thead>
<tr>
@ -61,12 +63,16 @@
</c:forEach>
</tbody>
</table>
</div>
</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 número de comensales activa.</p>
<p id="vacio" >No hay ninguna oferta por número de comensales activa.</p>
</c:if>
<c:if test="${not empty nuOfferLs }">
<div class="table-responsive">
<table id="nuOfferTable" class="table table-striped">
<thead>
<tr>
@ -112,6 +118,8 @@
</c:forEach>
</tbody>
</table>
</div>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="speedOffers"/></h2>
@ -119,52 +127,56 @@
<p id="vacio" >No hay ninguna oferta por tiempo empleado en comer 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="name"/></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>
</thead>
<tbody>
<c:forEach items="${speedOfferLs}" var="speedOffer">
<tr>
<td>
<a href="/restaurant/${speedOffer.client.id}"><c:out value="${speedOffer.client.name}"/></a>
</td>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
</td>
<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}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<table id="speedOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="name"/></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>
</thead>
<tbody>
<c:forEach items="${speedOfferLs}" var="speedOffer">
<tr>
<td>
<a href="/restaurant/${speedOffer.client.id}"><c:out value="${speedOffer.client.name}"/></a>
</td>
<td>
<c:out value="${localDateTimeFormat.format(speedOffer.start)}"/>
</td>
<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}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(speedOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:if>
<h2 style="text-align:center;padding:5px"><fmt:message key="timeOffers"/></h2>
@ -172,51 +184,54 @@
<p id="vacio" >No hay ninguna oferta por franja horaria 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="name"/></th>
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="init"/></th>
<th><fmt:message key="finishOffer"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${timeOfferLs}" var="timeOffer">
<tr>
<td>
<a href="/restaurant/${timeOffer.client.id}"><c:out value="${timeOffer.client.name}"/></a>
</td>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
</td>
<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}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="table-responsive">
<table id="timeOfferTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="name"/></th>
<th><fmt:message key="startDate"/></th>
<th><fmt:message key="endDate"/></th>
<th><fmt:message key="init"/></th>
<th><fmt:message key="finishOffer"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${timeOfferLs}" var="timeOffer">
<tr>
<td>
<a href="/restaurant/${timeOffer.client.id}"><c:out value="${timeOffer.client.name}"/></a>
</td>
<td>
<c:out value="${localDateTimeFormat.format(timeOffer.start)}"/>
</td>
<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}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(timeOfferUrl)}'" class="btn-detalles" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/> </button>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:if>

View file

@ -0,0 +1,57 @@
<%@ 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="usuarios">
<h2 style="text-align:center;padding:5px"><fmt:message key="usuarios"/></h2>
<c:if test="${empty usuarioLs }">
<p id="vacio" >No hay ningun usuario.</p>
</c:if>
<c:if test="${not empty usuarioLs }">
<table id="usuarioTable" class="table table-striped">
<thead>
<tr>
<th><fmt:message key="nombre"/></th>
<th><fmt:message key="apellidos"/></th>
<th><fmt:message key="username"/></th>
<th><fmt:message key="enabled"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${usuarioLs}" var="usuario">
<tr>
<td>
<c:out value="${usuario.nombre}"/>
</td>
<td>
<c:out value="${usuario.apellidos}"/>
</td>
<td>
<c:out value="${usuario.usuar.username}"/>
</td>
<td>
<c:out value="${usuario.usuar.enabled}"/>
</td>
<td>
<spring:url value="/administrators/usuarios/{username}" var="usuarioUrl">
<spring:param name="username" value="${usuario.usuar.username}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(usuarioUrl)}'" 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>
</c:if>
</cheapy:layout>

View file

@ -56,6 +56,18 @@
Desactivar usuario</button>
</div>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('admin')">
<sec:authentication var="principal" property="principal" />
<div class="btns-edit">
<spring:url value="/administrators/usuarios/{username}/disable" var="deactivateUrl">
<spring:param name="username" value="${usuario.usuar.username}"/>
</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 usuario</button>
</div>
</sec:authorize>
</div>

View file

@ -9,38 +9,39 @@
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<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>
<h2 class="text-center" style="font-family: 'Lobster'; font-size: 300%; color: rgb(0, 64, 128); padding:30px"><fmt:message key="welcome"/></h2>
<div class="row">
<div class="col-md-12">
<div class="img-home">
<spring:url value="/resources/images/Logo Cheapy.png" htmlEscape="true" var="cheapyImage"/>
<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;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="listOffers"/> </button>
<div class="btn-home-max">
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/offers'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;" class="btn-block">
<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='/myOffers'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;" class="btn-block">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="myOffers"/> </button>
</div>
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/offersCreate'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;" class="btn-block">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="createOffers"/> </button>
</div>
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/clients/show'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="clientShow"/> </button>
</div>
</sec:authorize>
</div>
<sec:authorize access="hasAnyAuthority('client')">
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/myOffers'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="myOffers"/> </button>
</div>
<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>
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/clients/show'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
<span class="glyphicon glyphicon-cutlery" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="clientShow"/> </button>
</div>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('usuario')">
<div class="btn-home">
<button type="button" role="link" onclick="window.location='/usuarios/show'" style="font-family: 'Lobster'; font-size: 20px;margin:5px;">
@ -48,7 +49,7 @@
<fmt:message key="showUsuario"/> </button>
</div>
</sec:authorize>
</div>
</div>
</cheapy:layout>
</cheapy:layout>

View file

@ -39,6 +39,20 @@
<span>Mis ofertas</span>
</cheapy:menuItem>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('admin')">
<cheapy:menuItem active="${name eq 'clientes'}" url="/administrators/clients" title="clients">
<span class="glyphicon " aria-hidden="true"></span>
<span>Clientes</span>
</cheapy:menuItem>
</sec:authorize>
<sec:authorize access="hasAnyAuthority('admin')">
<cheapy:menuItem active="${name eq 'usuarios'}" url="/administrators/usuarios" title="usuarios">
<span class="glyphicon " aria-hidden="true"></span>
<span>Usuarios</span>
</cheapy:menuItem>
</sec:authorize>
<!--
<cheapy:menuItem active="${name eq 'contactanos'}" url="/contactanos"
title="contactanos">

View file

@ -2,7 +2,7 @@
<br/>
<br/>
<div class="container">
<div class="row-full">
<div class="row">
<div class="col-12 text-center"><img src="<spring:url value="/resources/images/eslogan.png" htmlEscape="true" />"
alt="Eat fast, eat cheapy"/></div>