Agregada funcion Ver Historial de Compras del Usuario
Arreglo de Errores
This commit is contained in:
parent
4a164fd1a1
commit
8c060382f0
File diff suppressed because it is too large
Load Diff
65
src/controller/clientControllers/transactionsHistory.java
Normal file
65
src/controller/clientControllers/transactionsHistory.java
Normal file
@ -0,0 +1,65 @@
|
||||
package controller.clientControllers;
|
||||
|
||||
import controller.usersManagement.users.UsersControllerView;
|
||||
import model.User;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class transactionsHistory extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
//Se usa para revisar si hay una sesion activa
|
||||
HttpSession sesion= request.getSession();
|
||||
|
||||
//Intenta hallar una sesion activa
|
||||
try{
|
||||
User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
||||
|
||||
request.setAttribute("User",user);
|
||||
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
|
||||
|
||||
ArrayList<String> lista = crearArrayList(user.getTransactionList());
|
||||
request.setAttribute("transactionList",lista);
|
||||
|
||||
sesion.setAttribute("serverResponse","!");
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/ClientViews/transactionsHistory.jsp");
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
}
|
||||
//Si no la encuentra, redirige a la pagina inicial.
|
||||
catch (Exception e){
|
||||
System.err.println("Error catched. " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
private ArrayList<String> crearArrayList(String datos){
|
||||
ArrayList<String> lista = new ArrayList<>();
|
||||
|
||||
do
|
||||
{
|
||||
lista.add(datos.substring(0,datos.indexOf(",")));
|
||||
datos = datos.substring(datos.indexOf(",")+1);
|
||||
}
|
||||
while (datos.length() > 2);
|
||||
|
||||
return lista;
|
||||
}
|
||||
|
||||
}
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
|
||||
public class IncomeReport extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
package controller.financesManagement.transactions;
|
||||
|
||||
import controller.PMF;
|
||||
import controller.resourcesManagement.services.ServicesControllerView;
|
||||
import controller.usersManagement.users.UsersControllerView;
|
||||
import model.Service;
|
||||
import model.Transaction;
|
||||
import model.User;
|
||||
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TransactionsControllerAdd extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
String action = request.getParameter("action");
|
||||
|
||||
//Para evitar errores, si no hay ninguna accion, se establece a vacio.
|
||||
if (action == null)
|
||||
action = "";
|
||||
|
||||
if (action.equals("userAddTransaction")){
|
||||
|
||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||
|
||||
String userId = request.getSession().getAttribute("userID").toString();
|
||||
Service service = ServicesControllerView.getService(request.getParameter("serviceKey").toString());
|
||||
|
||||
Transaction transaction = new Transaction(userId,service.getKey(),service.getPrice() + "");
|
||||
User user = pm.getObjectById(User.class, request.getSession().getAttribute("userID").toString());
|
||||
|
||||
pm.makePersistent(transaction);
|
||||
|
||||
user.addTransaction(transaction.getKey());
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"¡Listo! Tu transacción se completó.\"}");
|
||||
|
||||
pm.close();
|
||||
}
|
||||
|
||||
try{
|
||||
response.sendRedirect("/");
|
||||
}
|
||||
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
||||
catch (IllegalStateException e){
|
||||
System.err.println("IllegalStateException: There was a double redirect.");
|
||||
}
|
||||
|
||||
} catch (NullPointerException e){
|
||||
System.err.println("Error NPE ->");
|
||||
e.printStackTrace();
|
||||
response.sendRedirect("/");
|
||||
}
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package controller.financesManagement.transactions;
|
||||
|
||||
import controller.usersManagement.users.UsersControllerView;
|
||||
import model.User;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
import static controller.financesManagement.transactions.TransactionsControllerView.getAllTransactions;
|
||||
|
||||
public class TransactionsControllerIndex extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
//Se usa para revisar si hay una sesion activa
|
||||
HttpSession sesion= request.getSession();
|
||||
|
||||
//Intenta hallar una sesion activa
|
||||
try{
|
||||
User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
||||
|
||||
request.setAttribute("User",user);
|
||||
request.setAttribute("transactionsList",getAllTransactions());
|
||||
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
|
||||
sesion.setAttribute("serverResponse","!");
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Transactions/index.jsp");
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
}
|
||||
//Si no la encuentra, redirige a la pagina inicial.
|
||||
catch (Exception e){
|
||||
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package controller.financesManagement.transactions;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
import controller.PMF;
|
||||
import model.Transaction;
|
||||
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class TransactionsControllerView extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static List<Transaction> getAllTransactions (){
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
List<Transaction> transactions = (List<Transaction>) pm.newQuery("select from " + Transaction.class.getName()).execute();
|
||||
pm.close();
|
||||
return transactions;
|
||||
}
|
||||
|
||||
public static Transaction getTransaction(String key){
|
||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||
|
||||
Key k = KeyFactory.stringToKey(key);
|
||||
Transaction service = pm.getObjectById(Transaction.class,k);
|
||||
|
||||
pm.close();
|
||||
return service;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package controller;
|
||||
|
||||
import controller.resourcesManagement.services.ServicesControllerView;
|
||||
import controller.usersManagement.access.AccessControllerView;
|
||||
import controller.usersManagement.users.UsersControllerView;
|
||||
import model.User;
|
||||
|
||||
@ -14,6 +16,7 @@ import java.io.IOException;
|
||||
public class index extends HttpServlet {
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
HttpSession sesion= request.getSession();
|
||||
|
||||
@ -29,9 +32,10 @@ public class index extends HttpServlet {
|
||||
|
||||
if (loggedUser != null){
|
||||
|
||||
request.setAttribute("hasAccess",AccessControllerView.checkPermission(sesion.getAttribute("userID").toString(),"/e/"));
|
||||
request.setAttribute("User",loggedUser);
|
||||
request.setAttribute("isUserLogged",true);
|
||||
request.setAttribute("serverResponse","You are logged in.");
|
||||
request.setAttribute("servicesList",ServicesControllerView.getAllServices());
|
||||
request.setAttribute("serverResponse",request.getSession().getAttribute("serverResponse"));
|
||||
request.getSession().setAttribute("serverResponse","!");
|
||||
|
||||
|
@ -21,6 +21,7 @@ import model.Employee;
|
||||
@SuppressWarnings("serial")
|
||||
public class EmployeesControllerAdd extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class EmployeesControllerDelete extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -16,6 +16,7 @@ import static controller.resourcesManagement.employees.EmployeesControllerView.g
|
||||
public class EmployeesControllerIndex extends HttpServlet {
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -20,6 +20,7 @@ public class EmployeesControllerView extends HttpServlet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.io.IOException;
|
||||
|
||||
public class MaterialsControllerAdd extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.io.IOException;
|
||||
|
||||
public class MaterialsControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -16,6 +16,7 @@ import static controller.resourcesManagement.materials.MaterialsControllerView.g
|
||||
|
||||
public class MaterialsControllerIndex extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
|
||||
public class MaterialsControllerView extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
|
@ -21,6 +21,7 @@ import model.Service;
|
||||
@SuppressWarnings("serial")
|
||||
public class ServicesControllerAdd extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -43,10 +44,10 @@ public class ServicesControllerAdd extends HttpServlet {
|
||||
|
||||
Service service = new Service (name, price, description,userCreatorKey);
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Servicio creado con éxito.\"}");
|
||||
|
||||
pm.makePersistent(service);
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Servicio creado con éxito.\"}");
|
||||
|
||||
|
||||
} else if (action.equals("update")){
|
||||
|
||||
@ -73,7 +74,7 @@ public class ServicesControllerAdd extends HttpServlet {
|
||||
|
||||
pm.close();
|
||||
try{
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/e/services");
|
||||
}
|
||||
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
||||
catch (IllegalStateException e){
|
||||
@ -83,12 +84,12 @@ public class ServicesControllerAdd extends HttpServlet {
|
||||
} else {
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para crear un Servicio.\"}");
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/e/services");
|
||||
|
||||
}
|
||||
|
||||
} catch (NullPointerException e){
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/");
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class ServicesControllerDelete extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -38,16 +39,16 @@ public class ServicesControllerDelete extends HttpServlet {
|
||||
|
||||
pm.close();
|
||||
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/e/services");
|
||||
|
||||
} else {
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Servicio.\"}");
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/e/services");
|
||||
}
|
||||
|
||||
|
||||
} catch (NullPointerException e){
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/");
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@ import static controller.resourcesManagement.services.ServicesControllerView.get
|
||||
public class ServicesControllerIndex extends HttpServlet {
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -20,6 +20,7 @@ public class ServicesControllerView extends HttpServlet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -73,11 +74,11 @@ public class ServicesControllerView extends HttpServlet {
|
||||
|
||||
} else {
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver/editar un Servicio.\"}");
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/e/services");
|
||||
}
|
||||
|
||||
} catch (NullPointerException e){
|
||||
response.sendRedirect("/services");
|
||||
response.sendRedirect("/");
|
||||
}
|
||||
|
||||
}
|
||||
@ -87,14 +88,14 @@ public class ServicesControllerView extends HttpServlet {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static List<Service> getAllServices(){
|
||||
public static List<Service> getAllServices(){
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
List<Service> services = (List<Service>) pm.newQuery("select from " + Service.class.getName()).execute();
|
||||
pm.close();
|
||||
return services;
|
||||
}
|
||||
|
||||
private static Service getService(String key){
|
||||
public static Service getService(String key){
|
||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||
|
||||
Key k = KeyFactory.stringToKey(key);
|
||||
|
@ -24,6 +24,7 @@ public class AccessControllerAdd extends HttpServlet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -12,6 +12,7 @@ import controller.PMF;
|
||||
@SuppressWarnings("serial")
|
||||
public class AccessControllerDelete extends HttpServlet {
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -22,6 +22,7 @@ public class AccessControllerEdit extends HttpServlet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -20,6 +20,7 @@ public class AccessControllerIndex extends HttpServlet {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -24,6 +24,8 @@ import java.util.List;
|
||||
public class AccessControllerView extends HttpServlet {
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
// create the persistence manager instance
|
||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
|
||||
public class index extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class ResourcesControllerAdd extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class ResourcesControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class ResourcesControllerIndex extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||
@SuppressWarnings("serial")
|
||||
public class ResourcesControllerView extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||
|
@ -28,6 +28,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerAdd extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
@ -49,7 +50,7 @@ public class RolesControllerAdd extends HttpServlet {
|
||||
Boolean status = Boolean.parseBoolean(request.getParameter("roleStatus"));
|
||||
|
||||
createRole(name,status,pm);
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role created successfully.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol creado con éxito.\"}");
|
||||
|
||||
break;
|
||||
|
||||
@ -69,7 +70,7 @@ public class RolesControllerAdd extends HttpServlet {
|
||||
role1.setName(request.getParameter("roleName"));
|
||||
role1.setStatus(Boolean.parseBoolean(request.getParameter("roleStatus")));
|
||||
//role1.setImgUrl(userImg);
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role editado con éxito.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol editado con éxito.\"}");
|
||||
|
||||
break;
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
|
||||
@ -27,7 +28,7 @@ public class RolesControllerDelete extends HttpServlet {
|
||||
Key k = KeyFactory.stringToKey(request.getParameter("key"));
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(Role.class, k));
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role deleted successfully.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol eliminado con éxito.\"}");
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
System.err.println("Exception catched -> " + e.getMessage());
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerIndex extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||
|
@ -15,26 +15,10 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* RolesControllerView
|
||||
*
|
||||
* Permite ver los Roles
|
||||
*
|
||||
* Metodos importantes:
|
||||
*
|
||||
* public static getAllRoles()
|
||||
* Devuelve un List<Role> con todos los roles que existen.
|
||||
*
|
||||
* public static getRoleKey(String key)
|
||||
* Devuelve un Rol dada una key.
|
||||
* La key se obtiene usando el metodo getKey() de un objeto Role
|
||||
*
|
||||
* */
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerView extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try {
|
||||
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||
public class UsersControllerAdd extends HttpServlet {
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -71,7 +72,7 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
if (roleList.size() > 0){
|
||||
userRole = roleList.get(0).getKey();
|
||||
} else {
|
||||
userRole = RolesControllerAdd.createRole(userRole,true,pm);
|
||||
userRole = RolesControllerAdd.createRole("Cliente",true,pm);
|
||||
}
|
||||
|
||||
createUser(userID, userEmail, userName, userImg, userRole, pm);
|
||||
@ -104,7 +105,7 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
//Si lo que se quiere es Crear (proviene del formulario)
|
||||
case "create":
|
||||
createUser(userID, userEmail, userName, userImg, userRole, pm);
|
||||
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"User created successfully.\"}";
|
||||
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"Usuario creado con éxito.\"}";
|
||||
break;
|
||||
|
||||
//Si lo que se quiere es actualizar un Usuario
|
||||
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
@SuppressWarnings("serial")
|
||||
public class UsersControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -25,7 +26,7 @@ public class UsersControllerDelete extends HttpServlet {
|
||||
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(User.class, userID));
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"User deleted sucessfully.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Usuario eliminado con éxito.\"}");
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
System.err.println("Exception catched -> " + e.getMessage());
|
||||
}
|
||||
@ -36,7 +37,7 @@ public class UsersControllerDelete extends HttpServlet {
|
||||
|
||||
} else {
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to delete a user.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Usuario.\"}");
|
||||
response.sendRedirect("/e/users");
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UsersControllerIndex extends HttpServlet {
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
//Se usa para revisar si hay una sesion activa
|
||||
@ -33,7 +33,7 @@ public class UsersControllerIndex extends HttpServlet {
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
} else {
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /users.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/users.\"}");
|
||||
response.sendRedirect("/e/");
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ import java.util.List;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UsersControllerView extends HttpServlet {
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
try{
|
||||
|
||||
@ -77,7 +77,7 @@ public class UsersControllerView extends HttpServlet {
|
||||
|
||||
} else {
|
||||
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to edit/view a user.\"}");
|
||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver/editar un usuario.\"}");
|
||||
response.sendRedirect("/e/users");
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ import javax.jdo.annotations.*;
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@PersistenceCapable(identityType=IdentityType.APPLICATION)
|
||||
public class Material {
|
||||
|
||||
@ -25,11 +29,17 @@ public class Material {
|
||||
@Persistent
|
||||
private int amount;
|
||||
|
||||
@Persistent
|
||||
private String createDate;
|
||||
|
||||
public Material(String name, int price, int quantity, String unity) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
this.amount = quantity;
|
||||
this.unity = unity;
|
||||
|
||||
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
|
||||
this.createDate = df.format(Calendar.getInstance().getTime());
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
@ -65,4 +75,8 @@ public class Material {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
}
|
||||
public String getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
62
src/model/Transaction.java
Normal file
62
src/model/Transaction.java
Normal file
@ -0,0 +1,62 @@
|
||||
package model;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
import controller.resourcesManagement.services.ServicesControllerView;
|
||||
|
||||
import javax.jdo.annotations.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
@PersistenceCapable(identityType = IdentityType.APPLICATION)
|
||||
public class Transaction {
|
||||
|
||||
@PrimaryKey
|
||||
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
|
||||
private Key key;
|
||||
|
||||
@Persistent
|
||||
private String userID;
|
||||
|
||||
@Persistent
|
||||
private String serviceKey;
|
||||
|
||||
@Persistent
|
||||
private String servicePrice;
|
||||
|
||||
@Persistent
|
||||
private String createDate;
|
||||
|
||||
public Transaction(String userID, String serviceKey, String servicePrice) {
|
||||
this.userID = userID;
|
||||
this.serviceKey = serviceKey;
|
||||
this.servicePrice = servicePrice;
|
||||
|
||||
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
|
||||
this.createDate = df.format(Calendar.getInstance().getTime());
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return KeyFactory.keyToString(key);
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
public String getServiceKey() {
|
||||
return serviceKey;
|
||||
}
|
||||
public String getServiceName(){
|
||||
return ServicesControllerView.getService(serviceKey).getName();
|
||||
}
|
||||
|
||||
public String getServicePrice() {
|
||||
return servicePrice;
|
||||
}
|
||||
|
||||
public String getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import javax.jdo.annotations.IdentityType;
|
||||
import javax.jdo.annotations.PersistenceCapable;
|
||||
import javax.jdo.annotations.Persistent;
|
||||
import javax.jdo.annotations.PrimaryKey;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@PersistenceCapable(identityType = IdentityType.APPLICATION)
|
||||
public class User {
|
||||
@ -32,6 +33,10 @@ public class User {
|
||||
@Persistent
|
||||
private String roleKey;
|
||||
|
||||
//Lista de Strings con Keys de las transacciones del usuario -> trans,trans,trans,
|
||||
@Persistent
|
||||
private String transactionList;
|
||||
|
||||
//Constructor
|
||||
public User(String id, String name, String imgUrl, String email ,String role){
|
||||
this.id = id;
|
||||
@ -39,9 +44,9 @@ public class User {
|
||||
this.imgUrl = imgUrl;
|
||||
this.email = email;
|
||||
this.roleKey = role;
|
||||
transactionList = "";
|
||||
}
|
||||
|
||||
|
||||
//Getters y Setters
|
||||
public String getId() {
|
||||
return id;
|
||||
@ -85,6 +90,14 @@ public class User {
|
||||
this.roleKey = roleKey;
|
||||
}
|
||||
|
||||
public String getTransactionList() {
|
||||
return transactionList;
|
||||
}
|
||||
public void addTransaction(String transactionKey){
|
||||
transactionList = transactionKey + "," + transactionList;
|
||||
}
|
||||
|
||||
|
||||
//To String
|
||||
@Override
|
||||
public String toString() {
|
||||
|
190
war/WEB-INF/View/ClientViews/transactionsHistory.jsp
Normal file
190
war/WEB-INF/View/ClientViews/transactionsHistory.jsp
Normal file
@ -0,0 +1,190 @@
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="java.util.ArrayList" %>
|
||||
<%@ page import="model.Transaction" %>
|
||||
<%@ page import="controller.financesManagement.transactions.TransactionsControllerView" %>
|
||||
<% User usuario = (User) request.getAttribute("User");
|
||||
String serverResponse = (String) request.getAttribute("serverResponse");
|
||||
ArrayList<String> transactionList = (ArrayList<String>) request.getAttribute("transactionList");
|
||||
if (serverResponse == null) serverResponse = "!";
|
||||
%>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Historial - Hotel Service</title>
|
||||
|
||||
<!--<link type="text/css" rel="stylesheet" href="./css/Diseno.css">-->
|
||||
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="../css/Elements.css?v=2">
|
||||
|
||||
<script src="../js/GlobalJs.js" async defer></script>
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<style>
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink hide-on-small-only" href="/" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
|
||||
|
||||
<span id="nombreUsuario" style="min-width: 80px;">
|
||||
<%= usuario.getName()%>
|
||||
</span>
|
||||
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute;
|
||||
width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('../e/users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||
<li>
|
||||
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank">
|
||||
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg">
|
||||
<title id="simpleicons-github-icon">
|
||||
GitHub icon
|
||||
</title>
|
||||
<path fill="white" d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12">
|
||||
</path>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="whiteLink" href="#">Historial de Compras</a></li>
|
||||
<li>|</li>
|
||||
</ul>
|
||||
|
||||
<!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
|
||||
<div id="dropdownContent">
|
||||
<a onclick="postRedirect('./roles')">Roles</a>
|
||||
<a href="#" style="background-color: lightgray">Users</a>
|
||||
<a onclick="postRedirect('./resources')">Resources</a>
|
||||
<a onclick="postRedirect('./access')">Access</a>
|
||||
</div>-->
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Historial de compras</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<%if (!serverResponse.equals("!")){ %>
|
||||
|
||||
<div id="serverResponse">
|
||||
<div style="margin: 10px"></div>
|
||||
</div>
|
||||
<script>
|
||||
var respDiv = document.getElementById("serverResponse");
|
||||
|
||||
var responseData = JSON.parse('<%=serverResponse%>');
|
||||
|
||||
respDiv.style.backgroundColor = responseData["color"];
|
||||
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
|
||||
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "500px";
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "0";
|
||||
},1500);
|
||||
},300);
|
||||
|
||||
</script>
|
||||
|
||||
<% } %>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
Mi Historial<br />
|
||||
<br />
|
||||
|
||||
<table class="striped responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Servicio</td>
|
||||
<td>Precio</td>
|
||||
<td>Fecha de compra</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="tableBody">
|
||||
|
||||
<% for (String key: transactionList) {
|
||||
Transaction transaction = TransactionsControllerView.getTransaction(key);
|
||||
%>
|
||||
|
||||
<tr>
|
||||
<td><%=transaction.getServiceName()%></td>
|
||||
<td><%=transaction.getServicePrice()%></td>
|
||||
<td><%=transaction.getCreateDate()%></td>
|
||||
</tr>
|
||||
|
||||
<% } %>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -90,7 +90,7 @@
|
||||
</div>
|
||||
<div class="nav-content" style="background-color: #3949a3">
|
||||
<ul class="tabs tabs-transparent">
|
||||
<li class="tab active"><a class="active" href="#">Totales</a></li>
|
||||
<li class="tab active"><a class="active" href="#">Finanzas</a></li>
|
||||
<li class="tab"><a href="./trans">Transacciones</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -115,10 +115,12 @@
|
||||
respDiv.style.backgroundColor = responseData["color"];
|
||||
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
|
||||
|
||||
respDiv.style.maxHeight = "500px";
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "0";
|
||||
},1500);
|
||||
respDiv.style.maxHeight = "500px";
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "0";
|
||||
},1500);
|
||||
},50);
|
||||
|
||||
</script>
|
||||
|
||||
@ -128,9 +130,7 @@
|
||||
|
||||
Incompleto. Faltan datos acerca de:<br />
|
||||
<ol>
|
||||
<li>Ingresos mediante Clientes</li>
|
||||
<li>Egresos mediante pagos a Empleados</li>
|
||||
<li>Egresos mediante compra de recursos (comida, implementos, etc.)</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
|
@ -104,12 +104,12 @@
|
||||
Nombre del Material:<br />
|
||||
<input name="Name" placeholder="Nombre" required><br />
|
||||
|
||||
Cantidad:<br />
|
||||
<input name="Amount" placeholder="Cantidad" type="number" min="0" required><br />
|
||||
|
||||
Precio por unidad:<br />
|
||||
<input name="Price" placeholder="Precio" type="number" required min="0" step="0.1"><br />
|
||||
|
||||
Cantidad:<br />
|
||||
<input name="Amount" placeholder="Cantidad" type="number" min="0" required><br />
|
||||
|
||||
Unidad (ejm. Kg, Litros):<br />
|
||||
<input name="Unity" placeholder="Unidad" required><br />
|
||||
|
||||
|
@ -143,6 +143,8 @@
|
||||
<td>Precio Unitario</td>
|
||||
<td>Cantidad</td>
|
||||
<td>Unidad</td>
|
||||
<td>Fecha de Creación</td>
|
||||
<td>Acciones</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -154,6 +156,7 @@
|
||||
<td><%= material.getPrice() %></td>
|
||||
<td><%= material.getAmount() %></td>
|
||||
<td><%= material.getUnity() %></td>
|
||||
<td><%= material.getCreateDate() %></td>
|
||||
<td>
|
||||
<a class="postLink" onclick="postRedirect('./materials/view',{action:'viewRedirect',materialKey:'<%=material.getKey()%>'})">View</a>
|
||||
| <a class="postLink" onclick="postRedirect('./materials/view',{action:'editRedirect',materialKey:'<%=material.getKey()%>'})">Edit</a>
|
||||
|
161
war/WEB-INF/View/Transactions/index.jsp
Normal file
161
war/WEB-INF/View/Transactions/index.jsp
Normal file
@ -0,0 +1,161 @@
|
||||
<%@ page import="model.Resource" %>
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="model.Transaction" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Jose
|
||||
Date: 07/06/2018
|
||||
Time: 16:39
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<% User usuario = (User) request.getAttribute("User");
|
||||
List<Transaction> transitionList = (List<Transaction>) request.getAttribute("transactionsList");
|
||||
String serverResponse = (String) request.getAttribute("serverResponse");
|
||||
if (serverResponse == null) serverResponse = "!";
|
||||
%>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>Transacciones - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../../css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../css/Elements.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<script src="../../js/GlobalJs.js" async defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="nav-extended" style="background-color: #3f51b5">
|
||||
<div class="nav-wrapper" style="max-height: 64px">
|
||||
<a class="whiteLink hide-on-small-only" href="/" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
Empleados
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
|
||||
|
||||
<span id="nombreUsuario" style="min-width: 80px;">
|
||||
<%= usuario.getName()%>
|
||||
</span>
|
||||
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute;
|
||||
width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||
<li style="max-height: 62px">
|
||||
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
|
||||
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg">
|
||||
<title id="simpleicons-github-icon">
|
||||
GitHub icon
|
||||
</title>
|
||||
<path fill="white" d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12">
|
||||
</path>
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="whiteLink" href="./">Inicio</a></li>
|
||||
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
|
||||
<li><a class="whiteLink" href="./services">Administración de recursos</a></li>
|
||||
<li class="active"><a class="whiteLink active" href="#">Reportes de Ingresos</a></li>
|
||||
<li>|</li>
|
||||
</ul>
|
||||
|
||||
<!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
|
||||
<div id="dropdownContent">
|
||||
<a href="#" onclick="postRedirect('./roles')">Roles</a>
|
||||
<a href="#" style="background-color: lightgray">Users</a>
|
||||
<a onclick="postRedirect('./resources')">Resources</a>
|
||||
<a onclick="postRedirect('./access')">Access</a>
|
||||
</div>-->
|
||||
|
||||
</div>
|
||||
<div class="nav-content" style="background-color: #3949a3">
|
||||
<ul class="tabs tabs-transparent">
|
||||
<li class="tab"><a href="./reports">Finanzas</a></li>
|
||||
<li class="tab active"><a class="active" href="#">Transacciones</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Transacciones</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<%if (!serverResponse.equals("!")){ %>
|
||||
|
||||
<div id="serverResponse">
|
||||
<div style="margin: 10px"></div>
|
||||
</div>
|
||||
<script>
|
||||
var respDiv = document.getElementById("serverResponse");
|
||||
|
||||
var responseData = JSON.parse('<%=serverResponse%>');
|
||||
|
||||
respDiv.style.backgroundColor = responseData["color"];
|
||||
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
|
||||
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "500px";
|
||||
setTimeout(function () {
|
||||
respDiv.style.maxHeight = "0";
|
||||
},1500);
|
||||
},50);
|
||||
|
||||
</script>
|
||||
|
||||
<% } %>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<table class="striped responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID del Usuario</td>
|
||||
<td>Servicio</td>
|
||||
<td>Costo</td>
|
||||
<td>Fecha de facturación</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<% for (Transaction transaction: transitionList) {%>
|
||||
|
||||
<tr>
|
||||
<td><%=transaction.getUserID()%></td>
|
||||
<td><%=transaction.getServiceName()%></td>
|
||||
<td><%=transaction.getServicePrice()%></td>
|
||||
<td><%=transaction.getCreateDate()%></td>
|
||||
</tr>
|
||||
|
||||
<% } %>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -170,7 +170,8 @@
|
||||
<span style="font-size: x-large">Reportes de Ingresos</span><br />
|
||||
<br />
|
||||
<div>
|
||||
<a href="./reports">Total</a><br/>
|
||||
<a href="./reports">Finanzas</a><br/>
|
||||
<a href="./trans">Transacciones</a><br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col l3 m3 s4 right-align">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>lab08-20173373</application>
|
||||
<version>2</version>
|
||||
<application>hotel-service-210413</application>
|
||||
<version>1</version>
|
||||
<sessions-enabled>true</sessions-enabled>
|
||||
|
||||
<!--
|
||||
|
Binary file not shown.
@ -294,14 +294,50 @@
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>usersManagmentServlet</servlet-name>
|
||||
<servlet-name>UsersManagmentServlet</servlet-name>
|
||||
<servlet-class>controller.usersManagement.index</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>usersManagmentServlet</servlet-name>
|
||||
<servlet-name>UsersManagmentServlet</servlet-name>
|
||||
<url-pattern>/e/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>TransactionsControllerIndex</servlet-name>
|
||||
<servlet-class>controller.financesManagement.transactions.TransactionsControllerIndex</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>TransactionsControllerIndex</servlet-name>
|
||||
<url-pattern>/e/trans</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>TransactionsControllerAdd</servlet-name>
|
||||
<servlet-class>controller.financesManagement.transactions.TransactionsControllerAdd</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>TransactionsControllerAdd</servlet-name>
|
||||
<url-pattern>/e/trans/add</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>TransactionsControllerView</servlet-name>
|
||||
<servlet-class>controller.financesManagement.transactions.TransactionsControllerView</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>TransactionsControllerView</servlet-name>
|
||||
<url-pattern>/e/trans/view</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>transactionsHistory</servlet-name>
|
||||
<servlet-class>controller.clientControllers.transactionsHistory</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>transactionsHistory</servlet-name>
|
||||
<url-pattern>/me/history</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Controlador para gestionar el comportamiento del menu de inicio -->
|
||||
<servlet>
|
||||
<servlet-name>index</servlet-name>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="model.Service" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<% boolean isUserLogged;
|
||||
try {
|
||||
isUserLogged = Boolean.parseBoolean(request.getAttribute("isUserLogged").toString());
|
||||
@ -8,6 +10,7 @@
|
||||
}
|
||||
User usuario = (User) request.getAttribute("User");
|
||||
String serverResponse = (String) request.getAttribute("serverResponse");
|
||||
List<Service> serviceList = (List<Service>) request.getAttribute("servicesList");
|
||||
if (serverResponse == null) serverResponse = "!";
|
||||
%>
|
||||
|
||||
@ -74,7 +77,7 @@
|
||||
<div class="container">
|
||||
|
||||
<div style="font-size: x-large">
|
||||
<span id="mainText">¡Bienvenido! Inicia Sesión para empezar.</span>
|
||||
<span id="mainText">Bienvenido! Inicia Sesion para empezar.</span>
|
||||
<br />
|
||||
<br />
|
||||
<div id="mainDiv" class="transition" style="max-height: 400px">
|
||||
@ -138,8 +141,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
@ -150,7 +151,7 @@
|
||||
|
||||
var profile = googleUser.getBasicProfile();
|
||||
|
||||
document.getElementById("mainText").innerText = "Logged In. Redirecting...";
|
||||
document.getElementById("mainText").innerText = "Iniciaste sesion, te estamos redirigiendo...";
|
||||
|
||||
document.getElementById("mainHeader").style.maxHeight = "0";
|
||||
document.getElementById("mainHeader").style.padding = "0";
|
||||
@ -167,6 +168,7 @@
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<% } else { %>
|
||||
|
||||
<nav style="background-color: #67c9b3">
|
||||
@ -186,7 +188,7 @@
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./e/users/view',{action:'closeSession'})">Cerrar Sesión</a>
|
||||
<a style="color: black" onclick="postRedirect('./e/users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
@ -208,20 +210,10 @@
|
||||
</svg>
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./roles')">Mis Servicios</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./users')">Recibos y Facturas</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./users')">Historial</a></li>
|
||||
<li><a class="whiteLink" href="./me/history">Historial de Compras</a></li>
|
||||
<li>|</li>
|
||||
</ul>
|
||||
|
||||
<!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
|
||||
<div id="dropdownContent">
|
||||
<a onclick="postRedirect('./roles')">Roles</a>
|
||||
<a href="#" style="background-color: lightgray">Users</a>
|
||||
<a onclick="postRedirect('./resources')">Resources</a>
|
||||
<a onclick="postRedirect('./access')">Access</a>
|
||||
</div>-->
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@ -259,21 +251,43 @@
|
||||
|
||||
<div style="font-size: x-large">
|
||||
Bienvenido <%=usuario.getName()%>.<br />
|
||||
<br />
|
||||
Algunos datos:<br />
|
||||
<div class="row">
|
||||
<div class="col l9 m9 s8">
|
||||
Tu nombre: <%=usuario.getName()%><br />
|
||||
Tu correo electrónico: <%=usuario.getEmail()%><br />
|
||||
Tu Rol: <%=usuario.getRoleName()%>
|
||||
|
||||
<% if (Boolean.parseBoolean(request.getAttribute("hasAccess").toString())){ %>
|
||||
<div style="margin: 20px 0;border-radius: 2px; box-shadow: 2px 2px lightgray; background-color: #3f51b5; padding: 10px;
|
||||
color: white; cursor: pointer" onclick="window.location.href = ('/e/')">
|
||||
<i class="material-icons left" style="font-size: 2.5rem">how_to_reg</i>
|
||||
Ir al Area de Empleados
|
||||
</div>
|
||||
<div class="col l3 m3 s4">
|
||||
<img src="<%=usuario.getImgUrl()%>">
|
||||
<% } %>
|
||||
|
||||
<div class="card" style="padding: 10px">
|
||||
<span style="font-family: 'Product Sans',Roboto, serif; font-size: xx-large">Contrata un Servicio:</span>
|
||||
<div>
|
||||
<% for (Service service: serviceList) {%>
|
||||
|
||||
<div class="row" style="padding: 0 25px">
|
||||
<%=service.getName()%>
|
||||
<br />
|
||||
<div class="col l8 m8" style="font-size: large">
|
||||
<%=service.getDescription()%>
|
||||
</div>
|
||||
<div class="col l4 m4">
|
||||
<%=service.getPrice()%> S/.
|
||||
<a class="waves-effect waves-light btn whiteLink" style="background-color: #64c2ad"
|
||||
onclick="postRedirect('./e/trans/add',{'action':'userAddTransaction','serviceKey':'<%=service.getKey()%>'})">
|
||||
<i class="material-icons left">add_shopping_cart</i>
|
||||
Comprar
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<a class="waves-effect waves-light btn whiteLink indigo darken-1" href="./e/"><i class="material-icons left">how_to_reg</i>Empleados</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user