Author: hansbak
Date: Tue Oct 4 11:38:42 2011 New Revision: 1178759 URL: http://svn.apache.org/viewvc?rev=1178759&view=rev Log: add possibility to select on incoming shipments for return status Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy ofbiz/trunk/applications/product/webapp/facility/shipment/FindShipment.ftl Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy?rev=1178759&r1=1178758&r2=1178759&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy Tue Oct 4 11:38:42 2011 @@ -24,7 +24,11 @@ import org.ofbiz.entity.util.* import org.ofbiz.entity.condition.* import org.ofbiz.entity.transaction.* import org.ofbiz.base.util.* - +import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.entity.model.ModelViewEntity.ComplexAlias; +import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasField; +import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember; lookupFlag = parameters.lookupFlag; shipmentTypeId = parameters.shipmentTypeId; @@ -43,6 +47,10 @@ context.viewSize = viewSize; findShipmentExprs = [] as LinkedList; paramListBuffer = new StringBuffer(); +orderReturnValue = false; +if (UtilValidate.isNotEmpty(statusId) && statusId.startsWith("RETURN_")) { + orderReturnValue = true; +} if (parameters.shipmentId) { findShipmentExprs.add(EntityCondition.makeCondition("shipmentId", EntityOperator.EQUALS, parameters.shipmentId)); } @@ -82,7 +90,12 @@ if (minDate && minDate.length() > 8) { } paramListBuffer.append("&minDate="); paramListBuffer.append(minDate); - findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null))); + if (orderReturnValue) { + findShipmentExprs.add(EntityCondition.makeCondition("entryDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null))); + } else { + findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null))); + } + } if (maxDate && maxDate.length() > 8) { maxDate = maxDate.trim(); @@ -91,7 +104,12 @@ if (maxDate && maxDate.length() > 8) { } paramListBuffer.append("&maxDate="); paramListBuffer.append(maxDate); - findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null))); + if (orderReturnValue) { + findShipmentExprs.add(EntityCondition.makeCondition("entryDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null))); + } else { + findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null))); + } + } if ("Y".equals(lookupFlag)) { @@ -112,23 +130,57 @@ if ("Y".equals(lookupFlag)) { lowIndex = viewIndex * viewSize + 1; highIndex = (viewIndex + 1) * viewSize; findOpts.setMaxRows(highIndex); - // using list iterator - orli = delegator.find("Shipment", mainCond, null, null, orderBy, findOpts); - - shipmentListSize = orli.getResultsSizeAfterPartialList(); - if (highIndex > shipmentListSize) { - highIndex = shipmentListSize; + + if (!orderReturnValue) { + // using list iterator + orli = delegator.find("Shipment", mainCond, null, null, orderBy, findOpts); + + shipmentListSize = orli.getResultsSizeAfterPartialList(); + if (highIndex > shipmentListSize) { + highIndex = shipmentListSize; + } + + // get the partial list for this page + if (shipmentListSize > 0) { + shipmentList = orli.getPartialList(lowIndex, viewSize); + } else { + shipmentList = [] as ArrayList; + } + + // close the list iterator + orli.close(); } - - // get the partial list for this page - if (shipmentListSize > 0) { - shipmentList = orli.getPartialList(lowIndex, viewSize); - } else { - shipmentList = [] as ArrayList; + + if (orderReturnValue) { + OrderReturnViewEntity = new DynamicViewEntity(); + OrderReturnViewEntity.addMemberEntity("SM", "Shipment"); + OrderReturnViewEntity.addMemberEntity("RH", "ReturnHeader"); + OrderReturnViewEntity.addViewLink("SM", "RH", false, ModelKeyMap.makeKeyMapList("primaryReturnId", "returnId")); + OrderReturnViewEntity.addAlias("SM", "shipmentId"); + OrderReturnViewEntity.addAlias("SM", "shipmentTypeId"); + OrderReturnViewEntity.addAlias("SM", "primaryReturnId"); + OrderReturnViewEntity.addAlias("SM", "destinationFacilityId"); + OrderReturnViewEntity.addAlias("SM", "originFacilityId"); + OrderReturnViewEntity.addAlias("SM", "estimatedShipDate"); + OrderReturnViewEntity.addAlias("RH", "statusId"); + OrderReturnViewEntity.addAlias("RH", "returnId"); + OrderReturnViewEntity.addAlias("RH", "entryDate"); + + orderReturnIt = delegator.findListIteratorByCondition(OrderReturnViewEntity, mainCond, null, null, null, null); + shipmentListSize = orderReturnIt.getResultsSizeAfterPartialList(); + + if (highIndex > shipmentListSize) { + highIndex = shipmentListSize; + } + + // get the partial list for this page + if (shipmentListSize > 0) { + shipmentList = orderReturnIt.getPartialList(lowIndex, viewSize); + } else { + shipmentList = [] as ArrayList; + } + orderReturnIt.close(); } - - // close the list iterator - orli.close(); } catch (GenericEntityException e) { errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, module); @@ -144,7 +196,7 @@ if ("Y".equals(lookupFlag)) { // only commit the transaction if we started one... this will throw an exception if it fails TransactionUtil.commit(beganTransaction); } - + context.shipmentList = shipmentList; context.listSize = shipmentListSize; context.highIndex = highIndex; @@ -161,6 +213,9 @@ context.facilities = delegator.findList( context.shipmentStatuses = delegator.findList("StatusItem", EntityCondition.makeCondition([statusTypeId : 'SHIPMENT_STATUS']), null, ['sequenceId'], null, false); context.purchaseShipmentStatuses = delegator.findList("StatusItem", EntityCondition.makeCondition([statusTypeId : 'PURCH_SHIP_STATUS']), null, ['sequenceId'], null, false); +/// Get return status lists +context.returnStatuses = delegator.findList("StatusItem", EntityCondition.makeCondition([statusTypeId : 'ORDER_RETURN_STTS']), null, ['sequenceId'], null, false); + // create the fromDate for calendar fromCal = Calendar.getInstance(); fromCal.setTimeInMillis(System.currentTimeMillis()); @@ -184,4 +239,4 @@ toCal.set(Calendar.SECOND, toCal.getActu toCal.set(Calendar.MILLISECOND, toCal.getActualMaximum(Calendar.MILLISECOND)); toTs = new Timestamp(toCal.getTimeInMillis()); toStr = toTs.toString(); -context.thruDateStr = toStr; +context.thruDateStr = toStr; \ No newline at end of file Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/FindShipment.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/FindShipment.ftl?rev=1178759&r1=1178758&r2=1178759&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/shipment/FindShipment.ftl (original) +++ ofbiz/trunk/applications/product/webapp/facility/shipment/FindShipment.ftl Tue Oct 4 11:38:42 2011 @@ -116,6 +116,11 @@ function lookupShipments() { <#list purchaseShipmentStatuses as shipmentStatus> <option value="${shipmentStatus.statusId}">${shipmentStatus.get("description",locale)}</option> </#list> + <option value="">---</option> + <option value="">${uiLabelMap.ProductOrderReturnStatus}</option> + <#list returnStatuses as returnStatus> + <option value="${returnStatus.statusId}">${returnStatus.get("description",locale)}</option> + </#list> </select> </td> </tr> @@ -178,10 +183,10 @@ function lookupShipments() { <#if shipmentList?has_content> <#assign alt_row = false> <#list shipmentList as shipment> - <#assign originFacility = shipment.getRelatedOneCache("OriginFacility")?if_exists> - <#assign destinationFacility = shipment.getRelatedOneCache("DestinationFacility")?if_exists> - <#assign statusItem = shipment.getRelatedOneCache("StatusItem")?if_exists> - <#assign shipmentType = shipment.getRelatedOneCache("ShipmentType")?if_exists> + <#assign originFacility = delegator.findByPrimaryKeyCache("Facility", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", shipment.originFacilityId))?if_exists /> + <#assign destinationFacility = delegator.findByPrimaryKeyCache("Facility", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", shipment.destinationFacilityId))?if_exists /> + <#assign statusItem = delegator.findByPrimaryKeyCache("StatusItem", Static["org.ofbiz.base.util.UtilMisc"].toMap("statusId", shipment.statusId))?if_exists/> + <#assign shipmentType = delegator.findByPrimaryKeyCache("ShipmentType", Static["org.ofbiz.base.util.UtilMisc"].toMap("shipmentTypeId", shipment.shipmentTypeId))?if_exists/> <tr valign="middle"<#if alt_row> class="alternate-row"</#if>> <td><a href="<@ofbizUrl>ViewShipment?shipmentId=${shipment.shipmentId}</@ofbizUrl>" class="buttontext">${shipment.shipmentId}</a></td> <td>${(shipmentType.get("description",locale))?default(shipmentType.shipmentTypeId?default(""))}</td> |
Free forum by Nabble | Edit this page |