1 5 package com.dotmarketing.portlets.order_manager.action; 6 7 import java.util.ArrayList ; 8 import java.util.Date ; 9 import java.util.HashMap ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 13 import javax.portlet.ActionRequest; 14 import javax.portlet.ActionResponse; 15 import javax.portlet.PortletConfig; 16 import javax.portlet.PortletRequest; 17 import javax.portlet.PortletResponse; 18 import javax.portlet.RenderRequest; 19 import javax.portlet.RenderResponse; 20 import javax.portlet.WindowState; 21 import javax.servlet.ServletOutputStream ; 22 import javax.servlet.http.HttpServletResponse ; 23 import javax.servlet.http.HttpSession ; 24 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 29 import com.dotmarketing.beans.UserProxy; 30 import com.dotmarketing.cms.factories.PublicUserFactory; 31 import com.dotmarketing.db.DbConnectionFactory; 32 import com.dotmarketing.db.DotHibernate; 33 import com.dotmarketing.factories.InodeFactory; 34 import com.dotmarketing.factories.UserProxyFactory; 35 import com.dotmarketing.util.Config; 36 import com.dotmarketing.util.UtilMethods; 37 import com.dotmarketing.util.WebKeys; 38 import com.liferay.portal.ejb.UserLocalManagerUtil; 39 import com.liferay.portal.model.User; 40 import com.liferay.portal.struts.PortletAction; 41 import com.liferay.portal.util.Constants; 42 import com.liferay.portlet.ActionRequestImpl; 43 import com.liferay.portlet.ActionResponseImpl; 44 import com.liferay.portlet.RenderRequestImpl; 45 import com.dotmarketing.portlets.discountcode.model.DiscountCode; 46 import com.dotmarketing.portlets.order_manager.factories.OrderFactory; 47 import com.dotmarketing.portlets.order_manager.factories.OrderItemFactory; 48 import com.dotmarketing.portlets.order_manager.model.Order; 49 import com.dotmarketing.portlets.order_manager.model.OrderItem; 50 import com.dotmarketing.portlets.order_manager.struts.ViewOrdersForm; 51 import com.dotmarketing.portlets.organization.factories.OrganizationFactory; 52 import com.dotmarketing.portlets.organization.model.Organization; 53 import com.dotmarketing.portlets.product.factories.ProductFormatFactory; 54 import com.dotmarketing.portlets.product.factories.ProductFactory; 55 import com.dotmarketing.portlets.product.model.ProductFormat; 56 import com.dotmarketing.portlets.product.model.Product; 57 import com.dotmarketing.util.*; 58 62 public class ViewOrdersAction extends PortletAction { 63 public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, 64 RenderResponse res) throws Exception { 65 String cmd = req.getParameter(Constants.CMD); 66 if (cmd != null){ 67 if (com.liferay.portal.util.Constants.DELETE.equals(cmd)) { 68 _removeOrder(form, req, res); 69 cmd = com.liferay.portal.util.Constants.SEARCH; 70 } 71 } 72 if (req.getWindowState().equals(WindowState.NORMAL)) { 73 _viewTodaysOrders(mapping, form, config, req, res); 74 return mapping.findForward("portlet.ext.order_manager.view"); 75 } else { 76 _viewOrders(mapping, form, config, req, res); 77 _getOrderStatus(req); 78 _getOrderPaymentStatus(req); 79 return mapping.findForward("portlet.ext.order_manager.view_orders"); 80 } 81 } 82 83 public void processAction( 84 ActionMapping mapping, ActionForm form, PortletConfig config, 85 ActionRequest req, ActionResponse res) 86 throws Exception { 87 88 String cmd = req.getParameter(Constants.CMD); 89 90 if(cmd != null && cmd.equals("exportExcel")){ 91 _exportExcel(req, res,config,form); 92 setForward(req,"portlet.ext.order_manager.view_orders"); 93 } 94 95 if(cmd != null && cmd.equals("exportQB")){ 96 _exportQB(req, res,config,form); 97 setForward(req,"portlet.ext.order_manager.view_orders"); 98 } 99 100 } 101 102 103 private void _viewTodaysOrders(ActionMapping mapping, ActionForm form, PortletConfig config, PortletRequest req, 104 PortletResponse res) throws Exception { 105 106 HttpSession session = ((RenderRequestImpl)req).getHttpServletRequest().getSession(); 107 String filter = " shipping_country = '" + Config.getStringProperty("DEFAULT_COUNTRY_CODE") + "' and payment_status in ("+Config.getStringProperty("ECOM_PAY_INVOICED")+","+Config.getStringProperty("ECOM_PAY_PAID")+") and (invoice_number is NULL or invoice_number = '')"; 108 List orders = OrderFactory.getTodaysOrders(filter); 109 req.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 110 session.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 111 112 } 113 114 private void _getOrderStatus(PortletRequest req) { 115 116 List <HashMap > finalStatus = new ArrayList <HashMap >(); 118 String [] statusesArray = com.dotmarketing.util.Config.getStringArrayProperty("ECOM_ORDER_STATUSES"); 119 for (int i=0;i<statusesArray.length;i++) { 120 String status = statusesArray[i]; 121 HashMap <String ,String > hs = new HashMap <String ,String >(); 122 hs.put("optionName", Config.getStringProperty(status + "_FN")); 123 hs.put("optionValue", Config.getStringProperty(status)); 124 finalStatus.add(hs); 125 } 126 req.setAttribute("orderStatusList", finalStatus.iterator()); 127 128 129 } 130 131 private void _getOrderPaymentStatus(PortletRequest req) { 132 133 List <HashMap > finalPaymentStatus = new ArrayList <HashMap >(); 135 String [] statusesArray = com.dotmarketing.util.Config.getStringArrayProperty("ECOM_PAY_STATUSES"); 136 for (int i=0;i<statusesArray.length;i++) { 137 String status = statusesArray[i]; 138 HashMap <String ,String > hs = new HashMap <String ,String >(); 139 hs.put("optionName", Config.getStringProperty(status + "_FN")); 140 hs.put("optionValue", Config.getStringProperty(status)); 141 finalPaymentStatus.add(hs); 142 } 143 req.setAttribute("paymentStatusList", finalPaymentStatus.iterator()); 144 } 145 146 private void _viewOrders(ActionMapping mapping, ActionForm form, PortletConfig config, PortletRequest req, 147 PortletResponse res) throws Exception { 148 149 HttpSession session = ((RenderRequestImpl)req).getHttpServletRequest().getSession(); 150 151 ViewOrdersForm vForm = (ViewOrdersForm) form; 152 153 long orderInode = vForm.getOrderInode(); 154 String systemInode = vForm.getSystem(); 155 String firstName = vForm.getFirstName(); 156 String lastName = vForm.getLastName(); 157 String email = vForm.getEmail(); 158 String facilityInode = vForm.getFacility(); 159 String facilityTitle = vForm.getFacilityTitle(); 160 String invoiceNumber = vForm.getInvoiceNumber(); 161 162 if (!UtilMethods.isSet(facilityTitle)) 163 { 164 facilityInode = "0"; 165 } 166 int[] orderStatusArray = vForm.getOrderStatusArray(); 169 int[] paymentStatusArray = vForm.getOrderStatusArray(); 170 Date startDate = vForm.getStartDate(); 171 Date endDate = vForm.getEndDate(); 172 173 List systems = OrganizationFactory.getAllSystems(); 175 Iterator systemsIter = systems.iterator(); 176 req.setAttribute("systems", systemsIter); 177 178 List facilities = new ArrayList (); 180 if (UtilMethods.isSet(systemInode)) { 181 Organization parentSystem = OrganizationFactory.getOrganization(systemInode); 182 facilities = OrganizationFactory.getChildrenOrganizations(parentSystem,"title"); 183 } 184 Iterator facilitiesIter = facilities.iterator(); 185 req.setAttribute("facilities", facilitiesIter); 186 187 long facilityInodeLong = (UtilMethods.isSet(facilityInode)) ? Long.parseLong(facilityInode) : 0; 188 long systemInodeLong = (UtilMethods.isSet(systemInode)) ? Long.parseLong(systemInode) : 0; 189 190 191 if (UtilMethods.isSet(invoiceNumber) || UtilMethods.isSet(firstName) || UtilMethods.isSet(lastName) || UtilMethods.isSet(email) 193 || facilityInodeLong > 0 || systemInodeLong > 0 194 || paymentStatusArray != null || orderStatusArray != null || orderInode > 0 || UtilMethods.isSet(startDate) || UtilMethods.isSet(endDate)) { 195 196 List orders = OrderFactory.getFilteredOrders(vForm); 198 199 if (UtilMethods.isSet(firstName) || UtilMethods.isSet(lastName) || UtilMethods.isSet(email) || facilityInodeLong > 0 || systemInodeLong > 0) { 201 202 List <Order> resultOrders = new ArrayList <Order>(); 203 Iterator ordersIter = orders.iterator(); 204 205 while (ordersIter.hasNext()) { 206 Order order = (Order) ordersIter.next(); 207 UserProxy userProxy = UserProxyFactory.getUserProxy(order.getUserInode()); 208 209 String userId = userProxy.getUserId(); 210 if (userId != null){ 211 String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId(); 212 User user = UserLocalManagerUtil.getUserById(companyId, userId); 213 214 if (user != null && (user.getFirstName() != null && ((user.getFirstName().toUpperCase().startsWith(firstName.toUpperCase()) || !UtilMethods.isSet(firstName))) 215 && (user.getEmailAddress() != null && (user.getEmailAddress().toUpperCase().startsWith(email.toUpperCase()) || !UtilMethods.isSet(email))) 216 && (user.getLastName() != null && (user.getLastName().toUpperCase().startsWith(lastName.toUpperCase()) || !UtilMethods.isSet(lastName))))) { 217 218 if (facilityInodeLong > 0) { 219 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 221 if (organization.getInode() == facilityInodeLong) { 222 resultOrders.add(order); 223 } 224 } 225 else { 226 if (systemInodeLong > 0) { 228 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 229 Organization parentSystem = OrganizationFactory.getParentOrganization(organization); 230 if (parentSystem.getInode() == systemInodeLong) { 231 resultOrders.add(order); 232 } 233 } 234 else { 235 if (UtilMethods.isSet(facilityTitle)) { 238 Organization organization = (Organization) InodeFactory.getParentOfClass(userProxy, Organization.class); 239 if (organization.getTitle().contains(facilityTitle)) { 240 resultOrders.add(order); 241 } 242 } 243 else { 244 resultOrders.add(order); 246 } 247 } 248 } 249 } 250 }} 251 req.setAttribute(WebKeys.ORDER_MGR_VIEW, resultOrders); 253 session.setAttribute(WebKeys.ORDER_MGR_VIEW, resultOrders); 254 } else { 255 req.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 257 session.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 258 } 259 } else { 260 261 List orders = OrderFactory.getTodaysOrders(vForm.isOrderOutsideUS()); 263 req.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 264 session.setAttribute(WebKeys.ORDER_MGR_VIEW, orders); 265 } 266 } 267 268 269 @SuppressWarnings ("unchecked") 270 private void _exportQB(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 271 272 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 273 ActionResponseImpl resImpl = (ActionResponseImpl)res; 274 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 275 276 String condtition = " payment_status in ("+Config.getStringProperty("ECOM_PAY_INVOICED")+","+Config.getStringProperty("ECOM_PAY_PAID")+") and (invoice_number is NULL or invoice_number = '' or modified_QB = " + DbConnectionFactory.getDBTrue() + ")"; 278 List <Order> orders = (List <Order>) OrderFactory.getOrdersByCondition(condtition); 279 280 httpRes.setContentType("application/octet-stream"); 281 httpRes.setHeader("Content-Disposition", "attachment; filename=\"quickbooks_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 282 283 ServletOutputStream out = httpRes.getOutputStream(); 284 try { 285 286 if(orders != null && orders.size() > 0) { 287 288 out.print("Web OrderID,First Name,Last Name,Company,Email,Phone,ShipType,Payment Type,Card Type/Check Bank,Card/Check Number,Card ExpMonth,"); 289 out.print("Card ExpYear,Name,Bill Address1,Bill Address2,Bill City,Bill State,Bill Zip,Bill Country,Ship Name,"); 290 out.print("Ship Address1,Ship Address2,Ship City,Ship State,Ship Zip,Ship Country,ItemID, Price,Quantity, Shipping"); 291 out.print("\r\n"); 292 293 Iterator ordersIter = orders.iterator(); 294 295 while (ordersIter.hasNext()) { 296 Order order = (Order) ordersIter.next(); 297 if(order.getUserInode() == 0) 298 continue; 299 UserProxy orderUser = UserProxyFactory.getUserProxy(order.getUserInode()); 300 User user = PublicUserFactory.getUserByUserId(orderUser.getUserId()); 301 302 String orgName = ""; 303 if (orderUser.getInode()>0) { 304 Organization organization = (Organization) InodeFactory.getParentOfClass(orderUser,Organization.class); 305 if ((organization != null) && (organization.getInode() > 0)){ 306 if (organization.getTitle()!=null) { 307 orgName = organization.getTitle().trim(); 308 }else{ 309 orgName = "No Facility"; 310 } 311 } 312 else 313 orgName = user.getFirstName() + " " + user.getLastName(); 314 } 315 316 317 List <OrderItem> items = OrderItemFactory.getOrderItemsByOrderId(order.getInode()); 318 Iterator itemsIter = items.iterator(); 319 String paymentType = ""; 320 float itemPrice = 0; 321 List <DiscountCode> discounts = UtilMethods.getDiscountsByOrder(order); 322 while(itemsIter.hasNext()){ 323 324 OrderItem item = (OrderItem) itemsIter.next(); 325 326 out.print("\"" +order.getInode()+"\","); 327 out.print((user.getFirstName() == null ? "," : "\"" + user.getFirstName() + "\",")); 328 out.print((user.getLastName() == null ? "," : "\"" + user.getLastName() + "\",")); 329 out.print("\"" +orgName + "\","); 330 out.print((user.getEmailAddress() == null ? "," : "\"" + user.getEmailAddress() + "\",")); 331 out.print((order.getBillingContactPhone() == null ? "," : "\"" + order.getBillingContactPhone() + "\",")); 332 333 334 out.print("\"" + UtilMethods.getShippingTypeName(order.getOrderShipType())+"\","); 335 336 337 paymentType = order.getPaymentType().trim(); 338 out.print("\"" + UtilMethods.getPaymentTypeName(Integer.parseInt(paymentType)) +"\","); 339 if (paymentType.equalsIgnoreCase("1")){ 340 out.print((order.getCardType() == null ? "," : "\"" + order.getCardType() + "\",")); 341 out.print((order.getCardNumber() == null ? "," : "\"" + order.getCardNumber() + "\",")); 342 out.print((order.getCardExpMonth() == 0 ? "," : "\"" + UtilMethods.getMonthName(order.getCardExpMonth()) + "\",")); 343 out.print((order.getCardExpYear() == 0 ? "," :"\"" + order.getCardExpYear() + "\",")); 344 out.print((order.getNameOnCard() == null ? "," : "\"" + order.getNameOnCard() + "\",")); 345 } 346 else if(paymentType.equalsIgnoreCase("2")){ 347 out.print((order.getCheckBankName() == null ? "," : "\"" + order.getCheckBankName() + "\",")); 348 out.print((order.getCheckNumber() == null ? "," : "\"" + order.getCheckNumber() + "\",")); 349 out.print("\"\","); 350 out.print("\"\","); 351 out.print("\"\","); 352 } 353 else 354 { 355 out.print("\"\","); 356 out.print("\"\","); 357 out.print("\"\","); 358 out.print("\"\","); 359 out.print("\"\","); 360 } 361 362 363 out.print((order.getBillingAddress1() == null ? "," : "\"" + order.getBillingAddress1() + "\",")); 364 out.print((order.getBillingAddress2() == null ? "," : "\"" + order.getBillingAddress2() + "\",")); 365 out.print((order.getBillingCity() == null ? "," : "\"" + order.getBillingCity() + "\",")); 366 out.print((order.getBillingState() == null ? "," : "\"" + order.getBillingState() + "\",")); 367 out.print((order.getBillingZip() == null ? "," : "\"" + order.getBillingZip() + "\",")); 368 out.print((order.getBillingCountry() == null ? "," : "\"" + order.getBillingCountry() + "\",")); 369 370 371 out.print( "\""+user.getFullName()+"\"," ); 372 out.print((order.getShippingAddress1() == null ? "," : "\"" + order.getShippingAddress1() + "\",")); 373 out.print((order.getShippingAddress2() == null ? "," : "\"" + order.getShippingAddress2() + "\",")); 374 out.print((order.getShippingCity() == null ? "," : "\"" + order.getShippingCity() + "\",")); 375 out.print((order.getShippingState() == null ? "," : "\"" + order.getShippingState() + "\",")); 376 out.print((order.getShippingZip() == null ? "," : "\"" + order.getShippingZip() + "\",")); 377 out.print((order.getShippingCountry() == null ? "," : "\"" + order.getShippingCountry() + "\",")); 378 379 380 ProductFormat productFormat = (ProductFormat) ProductFormatFactory.getProductFormat(item.getProductInode()); 382 out.print("\"" +productFormat.getItemNum()+ "\","); 383 itemPrice = UtilMethods.getItemPriceWithDiscount(item,discounts); 384 out.print("\"$ " +itemPrice+ "\","); 385 out.print("\"" +item.getItemQty()+ "\","); 386 out.print("\"$ " +order.getOrderShipping()+ "\","); 387 out.print("\r\n"); 388 } 389 } 390 }else { 391 out.print("There are no Orders to show"); 392 out.print("\r\n"); 393 } 394 out.flush(); 395 out.close(); 396 DotHibernate.closeSession(); 397 }catch(Exception p){ 398 399 out.print("There are no Orders to show"); 400 out.print("\r\n"); 401 out.flush(); 402 out.close(); 403 DotHibernate.closeSession(); 404 405 } 406 } 407 408 @SuppressWarnings ("unchecked") 409 private void _exportExcel(ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form) throws Exception { 410 411 HttpSession session = ((ActionRequestImpl)req).getHttpServletRequest().getSession(); 412 413 ActionResponseImpl resImpl = (ActionResponseImpl)res; 414 HttpServletResponse httpRes = resImpl.getHttpServletResponse(); 415 416 List <Order> orders = (List <Order>) session.getAttribute(WebKeys.ORDER_MGR_VIEW); 417 418 httpRes.setContentType("application/octet-stream"); 419 httpRes.setHeader("Content-Disposition", "attachment; filename=\"orders_" + UtilMethods.dateToHTMLDate(new Date (),"M_d_yyyy") +".csv\""); 420 421 ServletOutputStream out = httpRes.getOutputStream(); 422 try { 423 424 if(orders != null && orders.size() > 0) { 425 426 out.print("Invoice,Order Number,Invoice Date,Order Date,First name,Last name,Company,Email,Phone,"); 427 out.print("Shiptype,Newponumber,Bill Address1,Bill Address2,Bill City,Bill State,Bill Zip,Bill Country,"); 428 out.print("ShipAddress1,ShipAddress2,ShipCity,ShipState,ShipZip,ShipCountry,ItemId,Price, Discount Codes, Product Name,Quantity,"); 429 out.print("ShipAmt,TaxExempt,FL Tax"); 430 out.print("\r\n"); 431 432 Iterator ordersIter = orders.iterator(); 433 434 while (ordersIter.hasNext()) { 435 Order order = (Order) ordersIter.next(); 436 if(order.getUserInode() == 0) 437 continue; 438 if (order.getOrderStatus() == 4) 439 continue; 440 UserProxy orderUser = UserProxyFactory.getUserProxy(order.getUserInode()); 441 User user = PublicUserFactory.getUserByUserId(orderUser.getUserId()); 442 443 String orgName = ""; 444 if (orderUser.getInode()>0) { 445 Organization organization = (Organization) InodeFactory.getParentOfClass(orderUser,Organization.class); 446 if (organization.getTitle()!=null) { 447 orgName = organization.getTitle().trim(); 448 }else{ 449 orgName = "No Facility"; 450 } 451 } 452 453 List <OrderItem> items = OrderItemFactory.getOrderItemsByOrderId(order.getInode()); 454 Iterator itemsIter = items.iterator(); 455 float itemPrice = 0; 456 List <DiscountCode> discounts = UtilMethods.getDiscountsByOrder(order); 457 458 while(itemsIter.hasNext()){ 459 460 OrderItem item = (OrderItem) itemsIter.next(); 461 462 out.print((order.getInvoiceNumber() == null ? "," : "\"" + order.getInvoiceNumber() + "\",")); 463 out.print("\"" +order.getInode()+"\","); 464 out.print("\"" +UtilMethods.dateToHTMLDate(order.getInvoiceDate())+"\","); 465 out.print("\"" +UtilMethods.dateToHTMLDate(order.getDatePosted())+"\","); 466 out.print((user.getFirstName() == null ? "," : "\"" + user.getFirstName() + "\",")); 467 out.print((user.getLastName() == null ? "," : "\"" + user.getLastName() + "\",")); 468 out.print("\"" +orgName + "\","); 469 out.print((user.getEmailAddress() == null ? "," : "\"" + user.getEmailAddress() + "\",")); 470 out.print((order.getBillingContactPhone() == null ? "," : "\"" + order.getBillingContactPhone() + "\",")); 471 472 out.print("\""+ UtilMethods.getShippingTypeName(order.getOrderShipType())+"\","); 473 out.print((order.getPoNumber() == null ? "," : "\"" +order.getPoNumber()+"\",")); 474 475 476 out.print((order.getBillingAddress1() == null ? "," : "\"" + order.getBillingAddress1() + "\",")); 477 out.print((order.getBillingAddress2() == null ? "," : "\"" + order.getBillingAddress2() + "\",")); 478 out.print((order.getBillingCity() == null ? "," : "\"" + order.getBillingCity() + "\",")); 479 out.print((order.getBillingState() == null ? "," : "\"" + order.getBillingState() + "\",")); 480 out.print((order.getBillingZip() == null ? "," : "\"" + order.getBillingZip() + "\",")); 481 out.print((order.getBillingCountry() == null ? "," : "\"" + order.getBillingCountry() + "\",")); 482 483 484 out.print((order.getShippingAddress1() == null ? "," : "\"" + order.getShippingAddress1() + "\",")); 485 out.print((order.getShippingAddress2() == null ? "," : "\"" + order.getShippingAddress2() + "\",")); 486 out.print((order.getShippingCity() == null ? "," : "\"" + order.getShippingCity() + "\",")); 487 out.print((order.getShippingState() == null ? "," : "\"" + order.getShippingState() + "\",")); 488 out.print((order.getShippingZip() == null ? "," : "\"" + order.getShippingZip() + "\",")); 489 out.print((order.getShippingCountry() == null ? "," : "\"" + order.getShippingCountry() + "\",")); 490 491 492 ProductFormat productFormat = (ProductFormat) ProductFormatFactory.getProductFormat(item.getProductInode()); 494 Product product = (Product) ProductFactory.getProduct(productFormat.getProductInode()); 495 out.print("\"" +productFormat.getItemNum()+ "\","); 496 497 itemPrice = UtilMethods.getItemPriceWithDiscount(item,discounts); 499 out.print("\"$ " +itemPrice+ "\","); 500 out.print("\"" + order.getDiscountCodes()+ "\","); 501 out.print("\"" + product.getTitle() + "(" + productFormat.getFormatName()+ ")\","); 502 out.print("\"" +item.getItemQty()+ "\","); 503 out.print("\"$ " +order.getOrderShipping()+ "\","); 504 out.print((order.getTaxExemptNumber() == null ? "," : "\"" +order.getTaxExemptNumber()+ "\",")); 505 out.print("\"$ " +order.getOrderTax()+ "\""); 506 out.print("\r\n"); 507 } 508 } 509 }else { 510 out.print("There are no Orders to show"); 511 out.print("\r\n"); 512 } 513 out.flush(); 514 out.close(); 515 DotHibernate.closeSession(); 516 }catch(Exception p){ 517 518 out.print("There are no Orders to show"); 519 out.print("\r\n"); 520 out.flush(); 521 out.close(); 522 DotHibernate.closeSession(); 523 524 } 525 } 526 private void _removeOrder(ActionForm form, RenderRequest request, RenderResponse response) 527 { 528 String orderInode = request.getParameter("inode"); 529 Order order = OrderFactory.getOrderById(orderInode); 530 531 List <OrderItem> orderItems = OrderItemFactory.getAllOrderItemsByParentOrder(order); 532 for(OrderItem orderItem : orderItems) 533 { 534 ProductFormat format = ProductFormatFactory.getProductFormat(orderItem.getProductInode()); 535 if (format.getInode() != 0){ 536 format.setInventoryQuantity(format.getInventoryQuantity() + orderItem.getItemQty()); 537 ProductFormatFactory.saveProductFormat(format); 538 } 539 OrderItemFactory.deleteOrderItem(orderItem); 540 } 541 OrderFactory.deleteOrder(order); 542 } 543 } 544 | Popular Tags |