Add purchase to detail
This commit is contained in:
parent
c3975ab084
commit
da71ada2b8
8 changed files with 264 additions and 26 deletions
Binary file not shown.
Binary file not shown.
|
@ -56,11 +56,19 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
<select name="manufacturerId" id="manufacturerId">
|
||||
<c:forEach items="${manufacturers}" var="manufacturer">
|
||||
<option <c:if test="${manufacturer.manufacturerId == result.manufacturerId}">selected </c:if>value="${manufacturer.manufacturerId}">${manufacturer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
<select name="productCode" id="productCode">
|
||||
<c:forEach items="${productCodes}" var="productCode">
|
||||
<option <c:if test="${productCode.prodCode == result.productCode}">selected </c:if>value="${productCode.prodCode}">${productCode.prodCode} - ${productCode.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
|
@ -76,13 +84,56 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
<input type="checkbox" name="available" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="available" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</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" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="customerId">Customer</label>
|
||||
<select name="customerId" id="customerId">
|
||||
<c:forEach items="${customers}" var="customer">
|
||||
<option <c:if test="${customer.customerId == result.customerId}">selected </c:if>value="${customer.customerId}">${customer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productId">Product</label>
|
||||
<select name="productId" id="productId">
|
||||
<c:forEach items="${products}" var="product">
|
||||
<option <c:if test="${product.productId == result.productId}">selected </c:if>value="${product.productId}">${product.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantity">Quantity</label>
|
||||
<input type="number" name="quantity" value="${result.quantity}" id="quantity" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingCost">Shipping cost</label>
|
||||
<input type="number" name="shippingCost" value="${result.shippingCost}" id="shippingCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="salesDate">Sales date</label>
|
||||
<input type="number" name="salesDate" value="${result.salesDate}" id="salesDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingDate">Shipping date</label>
|
||||
<input type="date" name="shippingDate" value="${result.shippingDate}" id="shippingDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="freightCompany">Freight company</label>
|
||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
|
|
|
@ -56,11 +56,19 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
<select name="manufacturerId" id="manufacturerId">
|
||||
<c:forEach items="${manufacturers}" var="manufacturer">
|
||||
<option <c:if test="${manufacturer.manufacturerId == result.manufacturerId}">selected </c:if>value="${manufacturer.manufacturerId}">${manufacturer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
<select name="productCode" id="productCode">
|
||||
<c:forEach items="${productCodes}" var="productCode">
|
||||
<option <c:if test="${productCode.prodCode == result.productCode}">selected </c:if>value="${productCode.prodCode}">${productCode.prodCode} - ${productCode.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
|
@ -76,13 +84,55 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
<input type="checkbox" name="available" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="available" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</p>
|
||||
</c:when>
|
||||
<c:when test="${type == 'purchase'}">
|
||||
<p>
|
||||
<label for="orderNum">Order number</label>
|
||||
<input type="number" name="orderNum" value="${result.orderNum}" id="orderNum" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="customerId">Customer</label>
|
||||
<select name="customerId" id="customerId">
|
||||
<c:forEach items="${customers}" var="customer">
|
||||
<option <c:if test="${customer.customerId == result.customerId}">selected </c:if>value="${customer.customerId}">${customer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productId">Product</label>
|
||||
<select name="productId" id="productId">
|
||||
<c:forEach items="${products}" var="product">
|
||||
<option <c:if test="${product.productId == result.productId}">selected </c:if>value="${product.productId}">${product.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantity">Quantity</label>
|
||||
<input type="number" name="quantity" value="${result.quantity}" id="quantity" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingCost">Shipping cost</label>
|
||||
<input type="number" name="shippingCost" value="${result.shippingCost}" id="shippingCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="salesDate">Sales date</label>
|
||||
<input type="date" name="salesDate" value="${result.salesDate}" id="salesDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingDate">Shipping date</label>
|
||||
<input type="date" name="shippingDate" value="${result.shippingDate}" id="shippingDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="freightCompany">Freight company</label>
|
||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
<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>
|
||||
<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/detail.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>
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MagasinHelper {
|
|||
this.session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
|
||||
public List getProducts(){
|
||||
public List getProductsColums(){
|
||||
List <Product> resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
|
@ -46,6 +46,27 @@ public class MagasinHelper {
|
|||
return resultat;
|
||||
}
|
||||
|
||||
public List<Product> getProducts(){
|
||||
List<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");
|
||||
resultat=q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public Product getProduct(int id){
|
||||
Product resultat=null;
|
||||
Transaction tx=null;
|
||||
|
@ -68,7 +89,7 @@ public class MagasinHelper {
|
|||
return resultat;
|
||||
}
|
||||
|
||||
public List getClients(){
|
||||
public List getClientsColums(){
|
||||
List <Customer> resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
|
@ -91,6 +112,30 @@ public class MagasinHelper {
|
|||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List<Customer> getClients(){
|
||||
List<Customer> resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery("from Customer c");
|
||||
resultat=q.list();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List getClients(String name){
|
||||
List resultat=null;
|
||||
Transaction tx=null;
|
||||
|
@ -113,6 +158,48 @@ public class MagasinHelper {
|
|||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List getManufacturers(){
|
||||
List <Manufacturer> resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery("from Manufacturer m");
|
||||
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;
|
||||
try{
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
session.flush();
|
||||
|
||||
tx=session.beginTransaction();
|
||||
Query q=session.createQuery("from ProductCode p");
|
||||
resultat=q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List getDiscountCode(){
|
||||
List resultat=null;
|
||||
|
@ -274,7 +361,7 @@ public void deleteCustomer (int _id) {
|
|||
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> getPurchase(){
|
||||
public List getPurchaseColums(){
|
||||
List resultat=null;
|
||||
Transaction tx=null;
|
||||
try{
|
||||
|
@ -282,7 +369,7 @@ public void deleteCustomer (int _id) {
|
|||
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");
|
||||
Query q=session.createQuery("select po.orderNum, 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) {
|
||||
|
@ -295,17 +382,17 @@ public void deleteCustomer (int _id) {
|
|||
return resultat;
|
||||
}
|
||||
|
||||
public List<PurchaseOrder> getPurchase(int id){
|
||||
List resultat=null;
|
||||
public PurchaseOrder getPurchase(int id){
|
||||
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 a where a.customerId=:_id");
|
||||
Query q=session.createQuery(" from PurchaseOrder p where p.orderNum = :_id");
|
||||
q.setInteger("_id", id);
|
||||
resultat=(List<PurchaseOrder>)q.list();
|
||||
resultat=(PurchaseOrder)q.list().iterator().next();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -69,16 +69,16 @@ public class BddController extends MultiActionController {
|
|||
|
||||
switch (type) {
|
||||
case "customer":
|
||||
mv.addObject("results", new MagasinHelper().getClients());
|
||||
mv.addObject("results", new MagasinHelper().getClientsColums());
|
||||
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
|
||||
break;
|
||||
case "product":
|
||||
mv.addObject("results", new MagasinHelper().getProducts());
|
||||
mv.addObject("results", new MagasinHelper().getProductsColums());
|
||||
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("results", new MagasinHelper().getPurchaseColums());
|
||||
mv.addObject("colonnes", Arrays.asList("orderNum", "customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
|
||||
mv.addObject("relation", new HashMap<String, String>() {{
|
||||
put("customerId", "customer");
|
||||
put("productId", "product");
|
||||
|
@ -112,17 +112,18 @@ public class BddController extends MultiActionController {
|
|||
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"));
|
||||
mv.addObject("manufacturers", new MagasinHelper().getManufacturers());
|
||||
mv.addObject("productCodes", new MagasinHelper().getProductCodes());
|
||||
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"));
|
||||
mv.addObject("customers", new MagasinHelper().getClients());
|
||||
mv.addObject("products", new MagasinHelper().getProducts());
|
||||
break;
|
||||
default:
|
||||
mv.addObject("error", "Type not found");
|
||||
|
|
|
@ -56,11 +56,19 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="manufacturerId">Manufacturer</label>
|
||||
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
|
||||
<select name="manufacturerId" id="manufacturerId">
|
||||
<c:forEach items="${manufacturers}" var="manufacturer">
|
||||
<option <c:if test="${manufacturer.manufacturerId == result.manufacturerId}">selected </c:if>value="${manufacturer.manufacturerId}">${manufacturer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productCode">Product Code</label>
|
||||
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
|
||||
<select name="productCode" id="productCode">
|
||||
<c:forEach items="${productCodes}" var="productCode">
|
||||
<option <c:if test="${productCode.prodCode == result.productCode}">selected </c:if>value="${productCode.prodCode}">${productCode.prodCode} - ${productCode.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="purchaseCost">Purchase cost</label>
|
||||
|
@ -76,13 +84,55 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="markup">Available</label>
|
||||
<input type="text" name="available" value="${result.available}" id="available" size="5" />
|
||||
<input type="checkbox" name="available" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="available" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="description">Description</label>
|
||||
<input type="text" name="description" value="${result.description}" id="description" size="50" />
|
||||
</p>
|
||||
</c:when>
|
||||
<c:when test="${type == 'purchase'}">
|
||||
<p>
|
||||
<label for="orderNum">Order number</label>
|
||||
<input type="number" name="orderNum" value="${result.orderNum}" id="orderNum" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="customerId">Customer</label>
|
||||
<select name="customerId" id="customerId">
|
||||
<c:forEach items="${customers}" var="customer">
|
||||
<option <c:if test="${customer.customerId == result.customerId}">selected </c:if>value="${customer.customerId}">${customer.name}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="productId">Product</label>
|
||||
<select name="productId" id="productId">
|
||||
<c:forEach items="${products}" var="product">
|
||||
<option <c:if test="${product.productId == result.productId}">selected </c:if>value="${product.productId}">${product.description}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="quantity">Quantity</label>
|
||||
<input type="number" name="quantity" value="${result.quantity}" id="quantity" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingCost">Shipping cost</label>
|
||||
<input type="number" name="shippingCost" value="${result.shippingCost}" id="shippingCost" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="salesDate">Sales date</label>
|
||||
<input type="date" name="salesDate" value="${result.salesDate}" id="salesDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="shippingDate">Shipping date</label>
|
||||
<input type="date" name="shippingDate" value="${result.shippingDate}" id="shippingDate" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="freightCompany">Freight company</label>
|
||||
<input type="text" name="freightCompany" value="${result.freightCompany}" id="freightCompany" />
|
||||
</p>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
|
||||
<input hidden type="text" name="type" value="${type}" />
|
||||
|
|
Reference in a new issue