From fda2cdde199256f89e25069bbcbd05aec189e8a8 Mon Sep 17 00:00:00 2001 From: Jacopo Cappellato Date: Fri, 23 Mar 2007 07:53:39 +0000 Subject: [PATCH] There is now a 'print' option in the select box in the header of the find order list. By selecting it and submitting the form all the orders with the checkbox set will be submitted as async jobs: the user can monitor the status of the print jobs (one per order) in the WorkEffort->Submitted Jobs screen (the status will move from Pending to Running to Finished). The system will render one postscript stream for each order (out of the screen definition) and send it to the first printer (that can handle postscript streams) that the server's JVM can locate. OFBIZ-824 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@521616 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/content/print/PrintServices.java | 26 ++++++++------- applications/order/servicedef/services.xml | 6 ++++ .../org/ofbiz/order/order/OrderServices.java | 32 +++++++++++++++++++ .../webapp/ordermgr/WEB-INF/controller.xml | 6 ++++ .../webapp/ordermgr/order/findOrders.ftl | 2 ++ 5 files changed, 61 insertions(+), 11 deletions(-) diff --git a/applications/content/src/org/ofbiz/content/print/PrintServices.java b/applications/content/src/org/ofbiz/content/print/PrintServices.java index f266dfa0d6..be32024de1 100644 --- a/applications/content/src/org/ofbiz/content/print/PrintServices.java +++ b/applications/content/src/org/ofbiz/content/print/PrintServices.java @@ -147,21 +147,25 @@ public class PrintServices { Doc myDoc = new SimpleDoc(bais, psInFormat, null); PrintServiceAttributeSet psaset = new HashPrintServiceAttributeSet(); - URI printerUri = new URI(printerName); - PrinterURI printerUriObj = new PrinterURI(printerUri); - psaset.add(printerUriObj); + if (UtilValidate.isNotEmpty(printerName)) { + URI printerUri = new URI(printerName); + PrinterURI printerUriObj = new PrinterURI(printerUri); + psaset.add(printerUriObj); + } //PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, psaset); // TODO: selecting the printer by URI seems to not work PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, null); PrintService printer = null; if (services.length > 0) { - String sPrinterName = null; - for (int i = 0; i < services.length; i++) { - PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class); - sPrinterName = ((PrinterName)attr).getValue(); - if (sPrinterName.toLowerCase().indexOf(printerName.toLowerCase()) >= 0) { - printer = services[i]; - Debug.logInfo("Printer with name [" + sPrinterName +"] selected", module); - break; + if (UtilValidate.isNotEmpty(printerName)) { + String sPrinterName = null; + for (int i = 0; i < services.length; i++) { + PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class); + sPrinterName = ((PrinterName)attr).getValue(); + if (sPrinterName.toLowerCase().indexOf(printerName.toLowerCase()) >= 0) { + printer = services[i]; + Debug.logInfo("Printer with name [" + sPrinterName +"] selected", module); + break; + } } } if (UtilValidate.isEmpty(printer)) { diff --git a/applications/order/servicedef/services.xml b/applications/order/servicedef/services.xml index c13de612f1..709a8f67e2 100644 --- a/applications/order/servicedef/services.xml +++ b/applications/order/servicedef/services.xml @@ -499,6 +499,12 @@ under the License. location="org.ofbiz.order.order.OrderServices" invoke="massChangeApproved" auth="true"> + + + + + diff --git a/applications/order/src/org/ofbiz/order/order/OrderServices.java b/applications/order/src/org/ofbiz/order/order/OrderServices.java index 4ec8c43815..00430ac1e7 100644 --- a/applications/order/src/org/ofbiz/order/order/OrderServices.java +++ b/applications/order/src/org/ofbiz/order/order/OrderServices.java @@ -3623,6 +3623,38 @@ public class OrderServices { return ServiceUtil.returnSuccess(); } + public static Map massPrintOrders(DispatchContext dctx, Map context) { + LocalDispatcher dispatcher = dctx.getDispatcher(); + GenericValue userLogin = (GenericValue) context.get("userLogin"); + String screenLocation = (String) context.get("screenLocation"); + String printerName = (String) context.get("printerName"); + + // make the list per facility + List orderIds = (List) context.get("orderIdList"); + Iterator i = orderIds.iterator(); + while (i.hasNext()) { + String orderId = (String) i.next(); + if (UtilValidate.isEmpty(orderId)) { + continue; + } + Map ctx = FastMap.newInstance(); + ctx.put("userLogin", userLogin); + ctx.put("screenLocation", screenLocation); + //ctx.put("contentType", "application/postscript"); + if (UtilValidate.isNotEmpty(printerName)) { + ctx.put("printerName", printerName); + } + ctx.put("screenContext", UtilMisc.toMap("orderId", orderId)); + + try { + dispatcher.runAsync("sendPrintFromScreen", ctx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + } + } + return ServiceUtil.returnSuccess(); + } + public static Map checkCreateDropShipPurchaseOrders(DispatchContext ctx, Map context) { GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); diff --git a/applications/order/webapp/ordermgr/WEB-INF/controller.xml b/applications/order/webapp/ordermgr/WEB-INF/controller.xml index f9885fcaf0..b3e0404df0 100644 --- a/applications/order/webapp/ordermgr/WEB-INF/controller.xml +++ b/applications/order/webapp/ordermgr/WEB-INF/controller.xml @@ -143,6 +143,12 @@ under the License. + + + + + + diff --git a/applications/order/webapp/ordermgr/order/findOrders.ftl b/applications/order/webapp/ordermgr/order/findOrders.ftl index 963a76a3e0..ed2d70978b 100644 --- a/applications/order/webapp/ordermgr/order/findOrders.ftl +++ b/applications/order/webapp/ordermgr/order/findOrders.ftl @@ -399,10 +399,12 @@ document.lookuporder.orderId.focus();
 
+ ${uiLabelMap.OrderRunAction}