Author: jacopoc
Date: Fri Mar 23 00:53:39 2007 New Revision: 521616 URL: http://svn.apache.org/viewvc?view=rev&rev=521616 Log: 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 Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java?view=diff&rev=521616&r1=521615&r2=521616 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java Fri Mar 23 00:53:39 2007 @@ -147,21 +147,25 @@ 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)) { Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?view=diff&rev=521616&r1=521615&r2=521616 ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Fri Mar 23 00:53:39 2007 @@ -499,6 +499,12 @@ location="org.ofbiz.order.order.OrderServices" invoke="massChangeApproved" auth="true"> <implements service="massOrderChangeInterface"/> </service> + <service name="massPrintOrders" engine="java" transaction-timeout="300" + location="org.ofbiz.order.order.OrderServices" invoke="massPrintOrders" auth="true"> + <implements service="massOrderChangeInterface"/> + <attribute name="screenLocation" type="String" mode="IN" optional="false"/> + <attribute name="printerName" type="String" mode="IN" optional="true"/> + </service> <service name="getNextOrderId" engine="simple" location="org/ofbiz/order/order/OrderServices.xml" invoke="getNextOrderId"> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=521616&r1=521615&r2=521616 ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Fri Mar 23 00:53:39 2007 @@ -3623,6 +3623,38 @@ 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(); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?view=diff&rev=521616&r1=521615&r2=521616 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Fri Mar 23 00:53:39 2007 @@ -143,6 +143,12 @@ <response name="success" type="request-redirect" value="findorders"/> <response name="error" type="request-redirect" value="findorders"/> </request-map> + <request-map uri="massPrintOrders"> + <security https="true" auth="true"/> + <event type="service" path="" invoke="massPrintOrders"/> + <response name="success" type="request-redirect" value="findorders"/> + <response name="error" type="request-redirect" value="findorders"/> + </request-map> <!-- Order Manager Task List Requests --> <request-map uri="acceptassignment"> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl?view=diff&rev=521616&r1=521615&r2=521616 ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl Fri Mar 23 00:53:39 2007 @@ -399,10 +399,12 @@ <div> </div> <div align="right" class="tabletext"> <input type="hidden" name="orderIdList" value=""/> + <input type="hidden" name="screenLocation" value="component://order/widget/ordermgr/OrderPrintForms.xml#OrderPDF"/> <select name="serviceName" class="selectBox" onchange="javascript:setServiceName(this);"> <option value="javascript:void();"> </option> <option value="<@ofbizUrl>massApproveOrders?hideFields=${requestParameters.hideFields?default("N")}${paramList}</@ofbizUrl>">${uiLabelMap.OrderApproveOrder}</option> <option value="<@ofbizUrl>massPickOrders?hideFields=${requestParameters.hideFields?default("N")}${paramList}</@ofbizUrl>">${uiLabelMap.OrderPickOrders}</option> + <option value="<@ofbizUrl>massPrintOrders?hideFields=${requestParameters.hideFields?default('N')}${paramList}</@ofbizUrl>">${uiLabelMap.CommonPrint}</option> </select> <a href="javascript:runAction();" class="buttontext">${uiLabelMap.OrderRunAction}</a> </div> |
Free forum by Nabble | Edit this page |