Add product and purchase list
Start of the detail
This commit is contained in:
parent
63feda15b0
commit
c3975ab084
12 changed files with 473 additions and 264 deletions
Binary file not shown.
BIN
build/web/WEB-INF/classes/controller/BddController$1.class
Normal file
BIN
build/web/WEB-INF/classes/controller/BddController$1.class
Normal file
Binary file not shown.
Binary file not shown.
|
@ -9,47 +9,89 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<form name="detail" method="POST">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${client.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${client.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<c:choose>
|
||||
<c:when test="${type == 'customer'}">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
</c:when>
|
||||
<c:when test="${type == 'product'}">
|
||||
<p>
|
||||
<label for="productId">ID</label>
|
||||
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantityOnHand">Quantity on hand</label>
|
||||
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Markup</label>
|
||||
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
<c:if test="${type == 'customer'}">
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
</c:if>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,42 +15,47 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<table border="1" cellpadding="10">
|
||||
|
||||
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" >
|
||||
<TD>${v}
|
||||
</TD>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input type=hidden name="type" value="${type}"/>
|
||||
<input type=hidden name="num" value="${list[row.index][0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
<c:choose>
|
||||
<c:when test="${error != null}">
|
||||
<h1>${error}</h1>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<table border="1" cellpadding="10">
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
</TD>
|
||||
</TR>
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" varStatus="vStatus" >
|
||||
<c:choose>
|
||||
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
||||
<input hidden type="number" name="num" value="${v}"/>
|
||||
<input type=submit value="${v}" />
|
||||
</form>
|
||||
</TD>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<TD>${v}</TD>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${type}"/>
|
||||
<input hidden type="number" name="num" value="${values[0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
</TD>
|
||||
</TR>
|
||||
</c:forEach>
|
||||
<%-- <c:forEach items="${liste}" var="client">
|
||||
<TR>
|
||||
<TD>${client.customerId}</TD>
|
||||
<TD>${client.discountCode}</TD>
|
||||
<TD>${client.zip}</TD>
|
||||
<TD>${client.name}</TD>
|
||||
</TR>
|
||||
</c:forEach> --%>
|
||||
|
||||
</table>
|
||||
|
||||
</table>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -9,47 +9,89 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<form name="detail" method="POST">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${client.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${client.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<c:choose>
|
||||
<c:when test="${type == 'customer'}">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
</c:when>
|
||||
<c:when test="${type == 'product'}">
|
||||
<p>
|
||||
<label for="productId">ID</label>
|
||||
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantityOnHand">Quantity on hand</label>
|
||||
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Markup</label>
|
||||
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
<c:if test="${type == 'customer'}">
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
</c:if>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,42 +15,47 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<table border="1" cellpadding="10">
|
||||
|
||||
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" >
|
||||
<TD>${v}
|
||||
</TD>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input type=hidden name="type" value="${type}"/>
|
||||
<input type=hidden name="num" value="${list[row.index][0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
<c:choose>
|
||||
<c:when test="${error != null}">
|
||||
<h1>${error}</h1>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<table border="1" cellpadding="10">
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
</TD>
|
||||
</TR>
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" varStatus="vStatus" >
|
||||
<c:choose>
|
||||
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
||||
<input hidden type="number" name="num" value="${v}"/>
|
||||
<input type=submit value="${v}" />
|
||||
</form>
|
||||
</TD>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<TD>${v}</TD>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${type}"/>
|
||||
<input hidden type="number" name="num" value="${values[0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
</TD>
|
||||
</TR>
|
||||
</c:forEach>
|
||||
<%-- <c:forEach items="${liste}" var="client">
|
||||
<TR>
|
||||
<TD>${client.customerId}</TD>
|
||||
<TD>${client.discountCode}</TD>
|
||||
<TD>${client.zip}</TD>
|
||||
<TD>${client.name}</TD>
|
||||
</TR>
|
||||
</c:forEach> --%>
|
||||
|
||||
</table>
|
||||
|
||||
</table>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
<group>
|
||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/Product.hbm.xml</file>
|
||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/web/WEB-INF/jsp/menu.jsp</file>
|
||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/web/WEB-INF/jsp/resultat.jsp</file>
|
||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/controller/BddController.java</file>
|
||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/MagasinHelper.java</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -46,6 +46,28 @@ public class MagasinHelper {
|
|||
return resultat;
|
||||
}
|
||||
|
||||
public Product getProduct(int id){
|
||||
Product resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery("from Product p where p.productId = :_id");
|
||||
q.setInteger("_id", id);
|
||||
resultat=(Product)q.list().iterator().next();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List getClients(){
|
||||
List <Customer> resultat=null;
|
||||
Transaction tx=null;
|
||||
|
@ -227,29 +249,7 @@ public Customer getClient(int id){
|
|||
|
||||
return client;
|
||||
}
|
||||
public Customer getClient(String name){
|
||||
|
||||
|
||||
Customer client=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery(" from Customer a where a.customerId =:_name");
|
||||
q.setString("_name", name);
|
||||
client=(Customer)q.list().iterator().next();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("erreur"+e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
public void deleteCustomer (int _id) {
|
||||
|
||||
Transaction tx=null;
|
||||
|
@ -273,7 +273,29 @@ public void deleteCustomer (int _id) {
|
|||
}
|
||||
|
||||
}
|
||||
public List<PurchaseOrder> getAchats(int id){
|
||||
|
||||
public List<PurchaseOrder> getPurchase(){
|
||||
List resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery("select po.customerId, po.productId, po.quantity, po.shippingCost, po.salesDate, po.shippingDate, po.freightCompany from PurchaseOrder po");
|
||||
resultat=(List<PurchaseOrder>)q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> getPurchase(int id){
|
||||
List resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
|
|
|
@ -29,26 +29,29 @@ public class BddController extends MultiActionController {
|
|||
private User utilisateur;
|
||||
private HttpSession session;
|
||||
public BddController() {}
|
||||
|
||||
private void sessionInit(HttpServletRequest request) {
|
||||
if (login == null)
|
||||
login=request.getUserPrincipal().getName();
|
||||
if (utilisateur == null)
|
||||
utilisateur =new User(login);
|
||||
|
||||
if (session == null) {
|
||||
session=request.getSession();
|
||||
session.setAttribute("user", utilisateur);
|
||||
}
|
||||
}
|
||||
|
||||
public ModelAndView menu(HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
|
||||
login=request.getUserPrincipal().getName();
|
||||
|
||||
//pwd=request.getParameter("password");
|
||||
|
||||
utilisateur =new User(login);
|
||||
|
||||
session=request.getSession();
|
||||
session.setAttribute("user", utilisateur);
|
||||
sessionInit(request);
|
||||
System.out.println ("nbuser="+User.getCompteur());
|
||||
return new ModelAndView("menu").addObject("user",utilisateur);
|
||||
|
||||
}
|
||||
public ModelAndView logout(HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
|
||||
|
||||
sessionInit(request);
|
||||
request.getSession().invalidate();
|
||||
|
||||
|
||||
|
@ -58,46 +61,78 @@ public class BddController extends MultiActionController {
|
|||
|
||||
public ModelAndView list(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
|
||||
sessionInit(request);
|
||||
String type = request.getParameter("type");
|
||||
ModelAndView mv = new ModelAndView("resultat");
|
||||
|
||||
mv.addObject("user",session.getAttribute("user"));
|
||||
mv.addObject("type", type);
|
||||
|
||||
switch (type) {
|
||||
case "customer":
|
||||
mv.addObject("results", new MagasinHelper().getClients());
|
||||
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
|
||||
break;
|
||||
case "product":
|
||||
mv.addObject("results", new MagasinHelper().getProducts());
|
||||
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
|
||||
break;
|
||||
case "purchase":
|
||||
mv.addObject("results", new MagasinHelper().getPurchase());
|
||||
mv.addObject("colonnes", Arrays.asList("customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
|
||||
mv.addObject("relation", new HashMap<String, String>() {{
|
||||
put("customerId", "customer");
|
||||
put("productId", "product");
|
||||
}});
|
||||
break;
|
||||
default:
|
||||
mv.addObject("error", "Type not found");
|
||||
}
|
||||
|
||||
return mv;
|
||||
}
|
||||
public ModelAndView add(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
|
||||
sessionInit(request);
|
||||
|
||||
ModelAndView mv = new ModelAndView("form_inscription");
|
||||
|
||||
mv.addObject("user",session.getAttribute("user"));
|
||||
mv.addObject("user",session.getAttribute("user"));
|
||||
mv.addObject("discount",new MagasinHelper().getDiscountCode());
|
||||
mv.addObject("code",new MagasinHelper().getZipCode());
|
||||
return mv;
|
||||
}
|
||||
public ModelAndView detail(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
String type = request.getParameter("type");
|
||||
ModelAndView mv = new ModelAndView("detail");
|
||||
mv.addObject("user",session.getAttribute("user"));
|
||||
mv.addObject("code",new MagasinHelper().getDiscountCode());
|
||||
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
|
||||
mv.addObject("client",new MagasinHelper().getClient(request.getParameter("num")));
|
||||
mv.addObject("type", type);
|
||||
|
||||
switch (type) {
|
||||
case "customer":
|
||||
mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num"))));
|
||||
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
|
||||
mv.addObject("code",new MagasinHelper().getDiscountCode());
|
||||
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
|
||||
break;
|
||||
case "product":
|
||||
mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num"))));
|
||||
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
|
||||
break;
|
||||
case "purchase":
|
||||
mv.addObject("result", new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("num"))));
|
||||
mv.addObject("colonnes", Arrays.asList("customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
|
||||
break;
|
||||
default:
|
||||
mv.addObject("error", "Type not found");
|
||||
}
|
||||
|
||||
return mv;
|
||||
}
|
||||
public ModelAndView find(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
|
||||
sessionInit(request);
|
||||
|
||||
ModelAndView mv ;
|
||||
MagasinHelper requeteur = new MagasinHelper();
|
||||
|
@ -117,10 +152,12 @@ public class BddController extends MultiActionController {
|
|||
}
|
||||
public ModelAndView formfind(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
return new ModelAndView("recherche");
|
||||
}
|
||||
public ModelAndView achats(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
|
||||
|
||||
ModelAndView mv = new ModelAndView("achats");
|
||||
|
@ -128,12 +165,13 @@ public class BddController extends MultiActionController {
|
|||
mv.addObject("user",session.getAttribute("user"));
|
||||
System.out.println("num "+Integer.parseInt(request.getParameter("numero")));
|
||||
|
||||
mv.addObject("achats",new MagasinHelper().getAchats(Integer.parseInt(request.getParameter("numero"))));
|
||||
mv.addObject("achats",new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("numero"))));
|
||||
return mv;
|
||||
}
|
||||
|
||||
public ModelAndView save(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
String param1 = request.getParameter("nom");
|
||||
String param2 = request.getParameter("adresse");
|
||||
String param3 = request.getParameter("telephone");
|
||||
|
@ -146,6 +184,7 @@ public class BddController extends MultiActionController {
|
|||
}
|
||||
public ModelAndView delete(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
|
||||
new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("numero")));
|
||||
return new ModelAndView("confirm").addObject("confirm","suppression effectuée");
|
||||
|
@ -153,6 +192,7 @@ public class BddController extends MultiActionController {
|
|||
}
|
||||
public ModelAndView update(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
String param1 = request.getParameter("numero");
|
||||
String param2 = request.getParameter("code_remise");
|
||||
String param3 = request.getParameter("nom");
|
||||
|
|
|
@ -9,47 +9,89 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<form name="detail" method="POST">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${client.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${client.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<c:choose>
|
||||
<c:when test="${type == 'customer'}">
|
||||
<p>
|
||||
<label for="numero">Numero</label>
|
||||
<input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="nom">Nom</label>
|
||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="adresse">Adresse</label>
|
||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="telephone">Téléphone</label>
|
||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="email">E-mail</label>
|
||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="Remise">Remise</label>
|
||||
<select name="code_remise" id="dc">
|
||||
<c:forEach items="${code}" var="dc">
|
||||
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="cp">Code Postal</label>
|
||||
<select name="CP" id="cp">
|
||||
<c:forEach items="${cpostaux}" var="cp">
|
||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
</c:when>
|
||||
<c:when test="${type == 'product'}">
|
||||
<p>
|
||||
<label for="productId">ID</label>
|
||||
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantityOnHand">Quantity on hand</label>
|
||||
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Markup</label>
|
||||
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
<c:if test="${type == 'customer'}">
|
||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||
</c:if>
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,42 +15,47 @@
|
|||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
|
||||
|
||||
<table border="1" cellpadding="10">
|
||||
|
||||
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" >
|
||||
<TD>${v}
|
||||
</TD>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input type=hidden name="type" value="${type}"/>
|
||||
<input type=hidden name="num" value="${list[row.index][0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
<c:choose>
|
||||
<c:when test="${error != null}">
|
||||
<h1>${error}</h1>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<table border="1" cellpadding="10">
|
||||
<TR>
|
||||
<c:forEach items="${colonnes}" var="col">
|
||||
<TD>${col}</TD>
|
||||
</c:forEach>
|
||||
</TR>
|
||||
|
||||
</TD>
|
||||
</TR>
|
||||
<c:forEach items="${results}" var="values" varStatus="row" >
|
||||
<TR>
|
||||
<c:forEach items="${values}" var="v" varStatus="vStatus" >
|
||||
<c:choose>
|
||||
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
||||
<input hidden type="number" name="num" value="${v}"/>
|
||||
<input type=submit value="${v}" />
|
||||
</form>
|
||||
</TD>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<TD>${v}</TD>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</c:forEach>
|
||||
<TD>
|
||||
<form name="Detail" action="detail.htm" method="POST">
|
||||
<input hidden type="text" name="type" value="${type}"/>
|
||||
<input hidden type="number" name="num" value="${values[0]}"/>
|
||||
<input type=submit value="Détail" />
|
||||
</form>
|
||||
</TD>
|
||||
</TR>
|
||||
</c:forEach>
|
||||
<%-- <c:forEach items="${liste}" var="client">
|
||||
<TR>
|
||||
<TD>${client.customerId}</TD>
|
||||
<TD>${client.discountCode}</TD>
|
||||
<TD>${client.zip}</TD>
|
||||
<TD>${client.name}</TD>
|
||||
</TR>
|
||||
</c:forEach> --%>
|
||||
|
||||
</table>
|
||||
|
||||
</table>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Reference in a new issue