Add discount and prodCode to list and detail
This commit is contained in:
parent
da71ada2b8
commit
bdd9dba626
10 changed files with 214 additions and 21 deletions
Binary file not shown.
Binary file not shown.
|
@ -33,10 +33,10 @@
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="Remise">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
<select name="code_remise" id="dc">
|
<select name="discountCode" id="discountCode">
|
||||||
<c:forEach items="${code}" var="dc">
|
<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>
|
</c:forEach>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
@ -92,7 +92,6 @@
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${type == 'purchase'}">
|
<c:when test="${type == 'purchase'}">
|
||||||
<p>result: ${result}</p>
|
|
||||||
<p>
|
<p>
|
||||||
<label for="orderNum">Order number</label>
|
<label for="orderNum">Order number</label>
|
||||||
<input type="number" name="orderNum" value="${result.orderNum}" id="orderNum" />
|
<input type="number" name="orderNum" value="${result.orderNum}" id="orderNum" />
|
||||||
|
@ -123,7 +122,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="salesDate">Sales date</label>
|
<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>
|
||||||
<p>
|
<p>
|
||||||
<label for="shippingDate">Shipping date</label>
|
<label for="shippingDate">Shipping date</label>
|
||||||
|
@ -134,6 +133,34 @@
|
||||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</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>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
<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}" />
|
<input type=submit value="${v}" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${type}"/>
|
<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" />
|
<input type=submit value="Détail" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="Remise">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
<select name="code_remise" id="dc">
|
<select name="discountCode" id="discountCode">
|
||||||
<c:forEach items="${code}" var="dc">
|
<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>
|
</c:forEach>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
@ -133,6 +133,34 @@
|
||||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</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>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
<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}" />
|
<input type=submit value="${v}" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${type}"/>
|
<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" />
|
<input type=submit value="Détail" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
|
|
@ -180,6 +180,27 @@ public class MagasinHelper {
|
||||||
return resultat;
|
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(){
|
public List getProductCodes(){
|
||||||
List <ProductCode> resultat=null;
|
List <ProductCode> resultat=null;
|
||||||
Transaction tx=null;
|
Transaction tx=null;
|
||||||
|
@ -201,7 +222,29 @@ public class MagasinHelper {
|
||||||
return resultat;
|
return resultat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getDiscountCode(){
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getDiscountCodesColums(){
|
||||||
List resultat=null;
|
List resultat=null;
|
||||||
Transaction tx=null;
|
Transaction tx=null;
|
||||||
try{
|
try{
|
||||||
|
@ -210,7 +253,7 @@ List resultat=null;
|
||||||
session.flush();
|
session.flush();
|
||||||
|
|
||||||
tx=session.beginTransaction();
|
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();
|
resultat=q.list();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
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(){
|
public List getMicroMarket(){
|
||||||
List <MicroMarket> resultat=null;
|
List <MicroMarket> resultat=null;
|
||||||
Transaction tx=null;
|
Transaction tx=null;
|
||||||
|
|
|
@ -84,6 +84,14 @@ public class BddController extends MultiActionController {
|
||||||
put("productId", "product");
|
put("productId", "product");
|
||||||
}});
|
}});
|
||||||
break;
|
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:
|
default:
|
||||||
mv.addObject("error", "Type not found");
|
mv.addObject("error", "Type not found");
|
||||||
}
|
}
|
||||||
|
@ -97,7 +105,7 @@ public class BddController extends MultiActionController {
|
||||||
ModelAndView mv = new ModelAndView("form_inscription");
|
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("discount",new MagasinHelper().getDiscountCodesColums());
|
||||||
mv.addObject("code",new MagasinHelper().getZipCode());
|
mv.addObject("code",new MagasinHelper().getZipCode());
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +120,7 @@ public class BddController extends MultiActionController {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "customer":
|
case "customer":
|
||||||
mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num"))));
|
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());
|
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
|
||||||
break;
|
break;
|
||||||
case "product":
|
case "product":
|
||||||
|
@ -125,6 +133,13 @@ public class BddController extends MultiActionController {
|
||||||
mv.addObject("customers", new MagasinHelper().getClients());
|
mv.addObject("customers", new MagasinHelper().getClients());
|
||||||
mv.addObject("products", new MagasinHelper().getProducts());
|
mv.addObject("products", new MagasinHelper().getProducts());
|
||||||
break;
|
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:
|
default:
|
||||||
mv.addObject("error", "Type not found");
|
mv.addObject("error", "Type not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="Remise">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
<select name="code_remise" id="dc">
|
<select name="discountCode" id="discountCode">
|
||||||
<c:forEach items="${code}" var="dc">
|
<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>
|
</c:forEach>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
@ -133,6 +133,34 @@
|
||||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</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>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
|
<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}" />
|
<input type=submit value="${v}" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<TD>
|
<TD>
|
||||||
<form name="Detail" action="detail.htm" method="POST">
|
<form name="Detail" action="detail.htm" method="POST">
|
||||||
<input hidden type="text" name="type" value="${type}"/>
|
<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" />
|
<input type=submit value="Détail" />
|
||||||
</form>
|
</form>
|
||||||
</TD>
|
</TD>
|
||||||
|
|
Reference in a new issue