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
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -499,6 +499,12 @@ under the License.
|
||||
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">
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -143,6 +143,12 @@ under the License.
|
||||
<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">
|
||||
|
||||
@@ -399,10 +399,12 @@ document.lookuporder.orderId.focus();
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user