1
0
Fork 0

Add discount and prodCode to list and detail

This commit is contained in:
Ethanell 2022-06-29 22:08:01 +02:00
parent da71ada2b8
commit bdd9dba626
10 changed files with 214 additions and 21 deletions

View file

@ -33,10 +33,10 @@
<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">
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
@ -92,7 +92,6 @@
</p>
</c:when>
<c:when test="${type == 'purchase'}">
<p>result: ${result}</p>
<p>
<label for="orderNum">Order number</label>
<input type="number" name="orderNum" value="${result.orderNum}" id="orderNum" />
@ -123,7 +122,7 @@
</p>
<p>
<label for="salesDate">Sales date</label>
<input type="number" name="salesDate" value="${result.salesDate}" id="salesDate" />
<input type="date" name="salesDate" value="${result.salesDate}" id="salesDate" />
</p>
<p>
<label for="shippingDate">Shipping date</label>
@ -134,6 +133,34 @@
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
</p>
</c:when>
<c:when test="${type == 'discount'}">
<p>
<label for="discountCode">Discount code</label>
<input type="text" name="discountCode" value="${result.discountCode}" id="discountCode" size="1" />
</p>
<p>
<label for="rate">Rate</label>
<input type="number" name="rate" value="${result.rate}" id="rate" />
</p>
</c:when>
<c:when test="${type == 'prodCode'}">
<p>
<label for="prodCode">Product Code</label>
<input type="text" name="prodCode" value="${result.prodCode}" id="prodCode" size="2" />
</p>
<p>
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="10" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />

View file

@ -35,7 +35,7 @@
<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 hidden name="num" value="${v}"/>
<input type=submit value="${v}" />
</form>
</TD>
@ -48,7 +48,7 @@
<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 hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" />
</form>
</TD>

View file

@ -33,10 +33,10 @@
<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">
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
@ -133,6 +133,34 @@
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
</p>
</c:when>
<c:when test="${type == 'discount'}">
<p>
<label for="discountCode">Discount code</label>
<input type="text" name="discountCode" value="${result.discountCode}" id="discountCode" size="1" />
</p>
<p>
<label for="rate">Rate</label>
<input type="number" name="rate" value="${result.rate}" id="rate" />
</p>
</c:when>
<c:when test="${type == 'prodCode'}">
<p>
<label for="prodCode">Product Code</label>
<input type="text" name="prodCode" value="${result.prodCode}" id="prodCode" size="2" />
</p>
<p>
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="10" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />

View file

@ -35,7 +35,7 @@
<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 hidden name="num" value="${v}"/>
<input type=submit value="${v}" />
</form>
</TD>
@ -48,7 +48,7 @@
<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 hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" />
</form>
</TD>

View file

@ -180,6 +180,27 @@ public class MagasinHelper {
return resultat;
}
public List getProductCodesColums(){
List <ProductCode> resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery("select p.prodCode, p.discountCode, p.description from ProductCode p");
resultat=q.list();
} catch (Exception e) {
e.printStackTrace();
} finally{
if (session.isOpen())session.close();
}
return resultat;
}
public List getProductCodes(){
List <ProductCode> resultat=null;
Transaction tx=null;
@ -200,8 +221,30 @@ public class MagasinHelper {
return resultat;
}
public ProductCode getProductCode(String id){
ProductCode resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery("from ProductCode p where p.prodCode = :_id");
q.setString("_id", id);
resultat=(ProductCode)q.list().iterator().next();
} catch (Exception e) {
e.printStackTrace();
} finally{
if (session.isOpen())session.close();
}
public List getDiscountCode(){
return resultat;
}
public List getDiscountCodesColums(){
List resultat=null;
Transaction tx=null;
try{
@ -210,7 +253,7 @@ List resultat=null;
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery("select a.discountCode from DiscountCode a");
Query q=session.createQuery("select dc.discountCode, dc.rate from DiscountCode dc");
resultat=q.list();
}
catch (Exception e) {
@ -225,6 +268,58 @@ List resultat=null;
}
public List getDiscountCodes(){
List resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())
session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery(" from DiscountCode dc");
resultat=q.list();
}
catch (Exception e) {
e.printStackTrace();
}
finally{
if (session.isOpen())session.close();
}
return resultat;
}
public DiscountCode getDiscountCode(char c){
DiscountCode resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())
session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery(" from DiscountCode dc where dc.discountCode = :_id");
q.setCharacter("_id", c);
resultat=(DiscountCode)q.list().iterator().next();
}
catch (Exception e) {
e.printStackTrace();
}
finally{
if (session.isOpen())session.close();
}
return resultat;
}
public List getMicroMarket(){
List <MicroMarket> resultat=null;
Transaction tx=null;

View file

@ -84,6 +84,14 @@ public class BddController extends MultiActionController {
put("productId", "product");
}});
break;
case "discount":
mv.addObject("results", new MagasinHelper().getDiscountCodesColums());
mv.addObject("colonnes", Arrays.asList("discountCode", "rate"));
break;
case "prodCode":
mv.addObject("results", new MagasinHelper().getProductCodesColums());
mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description"));
break;
default:
mv.addObject("error", "Type not found");
}
@ -97,7 +105,7 @@ public class BddController extends MultiActionController {
ModelAndView mv = new ModelAndView("form_inscription");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("discount",new MagasinHelper().getDiscountCode());
mv.addObject("discount",new MagasinHelper().getDiscountCodesColums());
mv.addObject("code",new MagasinHelper().getZipCode());
return mv;
}
@ -112,7 +120,7 @@ public class BddController extends MultiActionController {
switch (type) {
case "customer":
mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num"))));
mv.addObject("code",new MagasinHelper().getDiscountCode());
mv.addObject("code",new MagasinHelper().getDiscountCodes());
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
break;
case "product":
@ -125,6 +133,13 @@ public class BddController extends MultiActionController {
mv.addObject("customers", new MagasinHelper().getClients());
mv.addObject("products", new MagasinHelper().getProducts());
break;
case "discount":
mv.addObject("result", new MagasinHelper().getDiscountCode(request.getParameter("num").charAt(0)));
break;
case "prodCode":
mv.addObject("result", new MagasinHelper().getProductCode(request.getParameter("num")));
mv.addObject("code",new MagasinHelper().getDiscountCodes());
break;
default:
mv.addObject("error", "Type not found");
}

View file

@ -33,10 +33,10 @@
<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">
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
@ -133,6 +133,34 @@
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
</p>
</c:when>
<c:when test="${type == 'discount'}">
<p>
<label for="discountCode">Discount code</label>
<input type="text" name="discountCode" value="${result.discountCode}" id="discountCode" size="1" />
</p>
<p>
<label for="rate">Rate</label>
<input type="number" name="rate" value="${result.rate}" id="rate" />
</p>
</c:when>
<c:when test="${type == 'prodCode'}">
<p>
<label for="prodCode">Product Code</label>
<input type="text" name="prodCode" value="${result.prodCode}" id="prodCode" size="2" />
</p>
<p>
<label for="discountCode">Remise</label>
<select name="discountCode" id="discountCode">
<c:forEach items="${code}" var="dc">
<option <c:if test="${dc.discountCode==result.discountCode}"> selected </c:if> value="${dc.discountCode}}">${dc.discountCode} - ${dc.rate}%</option>
</c:forEach>
</select>
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="10" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />

View file

@ -35,7 +35,7 @@
<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 hidden name="num" value="${v}"/>
<input type=submit value="${v}" />
</form>
</TD>
@ -48,7 +48,7 @@
<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 hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" />
</form>
</TD>