Author: mor
Date: Wed May 20 11:17:20 2009 New Revision: 776662 URL: http://svn.apache.org/viewvc?rev=776662&view=rev Log: Added new filters on find order page. This filter is about finding orders ship to a country. This work along with the option "Include Only" and "Do Not Include". With the former option system will display only orders that are ship to the selected country and with latter it will display only order that are not shipped to the selected country. Patch from Amit Sharma, part of OFBIZ-2477 (https://issues.apache.org/jira/browse/OFBIZ-2477). Thanks Pranay for testing. Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml ofbiz/trunk/applications/order/servicedef/services.xml ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.xml?rev=776662&r1=776661&r2=776662&view=diff ============================================================================== --- ofbiz/trunk/applications/order/config/OrderUiLabels.xml (original) +++ ofbiz/trunk/applications/order/config/OrderUiLabels.xml Wed May 20 11:17:20 2009 @@ -10228,5 +10228,14 @@ <value xml:lang="th">à¸à¸·à¹à¸à¹à¸à¸£à¹à¸à¸</value> <value xml:lang="zh">项ç®å称</value> </property> + <property key="OrderOnlyInclude"> + <value xml:lang="en">Only Include</value> + </property> + <property key="OrderDoNotInclude"> + <value xml:lang="en">Do Not Include</value> + </property> + <property key="OrderShipToCountry"> + <value xml:lang="en">Ship to Country</value> + </property> </resource> Modified: ofbiz/trunk/applications/order/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=776662&r1=776661&r2=776662&view=diff ============================================================================== --- ofbiz/trunk/applications/order/servicedef/services.xml (original) +++ ofbiz/trunk/applications/order/servicedef/services.xml Wed May 20 11:17:20 2009 @@ -818,6 +818,10 @@ <attribute name="paramList" type="String" mode="OUT" optional="false"/> <attribute name="orderList" type="List" mode="OUT" optional="false"/> <attribute name="orderListSize" type="Integer" mode="OUT" optional="false"/> + + <!-- ship to country fields --> + <attribute name="country" type="String" mode="INOUT" optional="true"/> + <attribute name="includeCountry" type="String" mode="INOUT" optional="true"/> </service> <service name="checkOrderIsOnBackOrder" engine="simple" auth="false" Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java?rev=776662&r1=776661&r2=776662&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java Wed May 20 11:17:20 2009 @@ -29,6 +29,7 @@ import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.security.Security; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -466,6 +467,54 @@ } } + //Get all orders according to specific ship to country with "Only Include" or "Do not Include". + String country = (String) context.get("country"); + String includeCountry = (String) context.get("includeCountry"); + if (UtilValidate.isNotEmpty(country) && UtilValidate.isNotEmpty(includeCountry)) { + paramList.add("country=" + country); + paramList.add("includeCountry=" + includeCountry); + boolean hasRecord = false; + List orExprs = FastList.newInstance(); + EntityCondition condition = null; + List<GenericValue> postalAddresses = null; + List<GenericValue> orderContactMechs = null; + try { + EntityConditionList andExprs = null; + condition = EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "SHIPPING_LOCATION"); + orderContactMechs = delegator.findList("OrderContactMech", condition, null, null, null, false); + if (UtilValidate.isNotEmpty(orderContactMechs)) { + for (GenericValue orderContactMech : orderContactMechs) { + if ("Y".equals(includeCountry)) { + andExprs = EntityCondition.makeCondition( UtilMisc.toList( + EntityCondition.makeCondition("contactMechId", orderContactMech.get("contactMechId")), + EntityCondition.makeCondition("countryGeoId", EntityOperator.EQUALS, country) + ), EntityOperator.AND); + } + else { + andExprs = EntityCondition.makeCondition( UtilMisc.toList( + EntityCondition.makeCondition("contactMechId", orderContactMech.get("contactMechId")), + EntityCondition.makeCondition("countryGeoId", EntityOperator.NOT_EQUAL, country) + ), EntityOperator.AND); + } + postalAddresses = delegator.findList("PostalAddress", andExprs, null, null, null, false); + if (UtilValidate.isNotEmpty(postalAddresses)) { + GenericValue postalAddress = EntityUtil.getFirst(postalAddresses); + if (UtilValidate.isNotEmpty(postalAddress)) { + orExprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderContactMech.get("orderId"))); + hasRecord = true; + } + } + } + } + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + EntityCondition shipCountryFilter = EntityCondition.makeCondition(orExprs, EntityOperator.OR); + if (hasRecord) { + conditions.add(shipCountryFilter); + } + } + // set distinct on so we only get one row per order EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); 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?rev=776662&r1=776661&r2=776662&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/order/findOrders.ftl Wed May 20 11:17:20 2009 @@ -375,6 +375,19 @@ </table> </td> </tr> + <tr> + <td width='25%' align='right' class='label'>${uiLabelMap.OrderShipToCountry}</td> + <td width='5%'> </td> + <td align='left'> + <select name="country"> + ${screens.render("component://common/widget/CommonScreens.xml#countries")} + </select> + <select name="includeCountry"> + <option value="Y">${uiLabelMap.OrderOnlyInclude}</option> + <option value="N">${uiLabelMap.OrderDoNotInclude}</option> + </select> + </td> + </tr> <tr><td colspan="3"><hr/></td></tr> <tr> <td width='25%' align='right'> </td> |
Free forum by Nabble | Edit this page |