1
0
Fork 0

Fix client purchases page

This commit is contained in:
Ethanell 2022-06-29 23:34:39 +02:00
parent 6d27564706
commit c5fcc072cc
7 changed files with 29 additions and 16 deletions

View file

@ -5,7 +5,7 @@
--%> --%>
<header> <header>
<nav style="display: flex; flex-direction: row; justify-content: space-between; align-content: center"> <nav style="display: flex; flex-direction: row; justify-content: space-between">
<div style="display: flex; flex-direction: row"> <div style="display: flex; flex-direction: row">
<p>Welcome ${user.login}</p> <p>Welcome ${user.login}</p>
<form name="form" method="POST"> <form name="form" method="POST">

View file

@ -10,7 +10,7 @@
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<H1>Achats du client n°<%=request.getParameter("numero")%></H1> <H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">

View file

@ -621,6 +621,28 @@ public void deleteProductCode(String _id) {
return resultat; return resultat;
} }
public List<PurchaseOrder> getPurchases(int id){
List<PurchaseOrder> resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery(" from PurchaseOrder po where po.customerId = :_id");
q.setInteger("_id", id);
resultat=q.list();
}
catch (Exception e) {
e.printStackTrace();
}
finally{
if (session.isOpen())session.close();
}
return resultat;
}
public int getMaxId(){ public int getMaxId(){
Transaction tx=null; Transaction tx=null;
int resultat=-1; int resultat=-1;

View file

@ -182,22 +182,13 @@ public class BddController extends MultiActionController {
MagasinHelper helper = new MagasinHelper(); MagasinHelper helper = new MagasinHelper();
return mv; return mv;
} }
public ModelAndView formfind(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
return new ModelAndView("recherche");
}
public ModelAndView achats(HttpServletRequest request, public ModelAndView achats(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request); sessionInit(request);
ModelAndView mv = new ModelAndView("achats");
mv.addObject("user",session.getAttribute("user"));
ModelAndView mv = new ModelAndView("achats"); mv.addObject("achats",new MagasinHelper().getPurchases(Integer.parseInt(request.getParameter("customerId"))));
mv.addObject("user",session.getAttribute("user"));
System.out.println("num "+Integer.parseInt(request.getParameter("numero")));
mv.addObject("achats",new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("numero"))));
return mv; return mv;
} }

View file

@ -10,7 +10,7 @@
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<H1>Achats du client n°<%=request.getParameter("numero")%></H1> <H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">