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}