public static final String module = OrderLookupServices.class.getName();
public static Map<String, Object> findOrders(DispatchContext dctx, Map<String, ? extends Object> context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
Security security = dctx.getSecurity();
GenericValue userLogin = (GenericValue) context.get("userLogin");
Integer viewIndex = (Integer) context.get("viewIndex");
Integer viewSize = (Integer) context.get("viewSize");
String showAll = (String) context.get("showAll");
String useEntryDate = (String) context.get("useEntryDate");
if (showAll == null) {
showAll = "N";
}
// list of fields to select (initial list)
List<String> fieldsToSelect = FastList.newInstance();
fieldsToSelect.add("orderId");
fieldsToSelect.add("orderName");
fieldsToSelect.add("statusId");
fieldsToSelect.add("orderTypeId");
fieldsToSelect.add("orderDate");
fieldsToSelect.add("currencyUom");
fieldsToSelect.add("grandTotal");
fieldsToSelect.add("remainingSubTotal");
// sorting by order date newest first
List<String> orderBy = UtilMisc.toList("-orderDate", "-orderId");
// list to hold the parameters
List<String> paramList = FastList.newInstance();
// list of conditions
List<EntityCondition> conditions = FastList.newInstance();
// check security flag for purchase orders
boolean canViewPo = security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", userLogin);
if (!canViewPo) {
conditions.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.NOT_EQUAL, "PURCHASE_ORDER"));
}
// dynamic view entity