svn commit: r518682 - in /ofbiz/trunk/applications/product: webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh webapp/facility/shipment/PackingSlip.fo.ftl widget/facility/ShipmentScreens.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r518682 - in /ofbiz/trunk/applications/product: webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh webapp/facility/shipment/PackingSlip.fo.ftl widget/facility/ShipmentScreens.xml

sichen
Author: sichen
Date: Thu Mar 15 09:31:50 2007
New Revision: 518682

URL: http://svn.apache.org/viewvc?view=rev&rev=518682
Log:
Improve the packing slip PDF so that it's organized as one page per package.  It could use a little more work on the flow of the header and gift message.  Perhaps the gift message and other such data should be on a page of its own?

Added:
    ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh
Modified:
    ofbiz/trunk/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl
    ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml

Added: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh?view=auto&rev=518682
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh (added)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh Thu Mar 15 09:31:50 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// This script gets shipment items grouped by package for use in the packing slip PDF or any screens that require by-package layout
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+import org.ofbiz.base.util.UtilMisc;
+
+// Since this script is run after ViewShipment, we will re-use the shipment in the context
+shipment = context.get("shipment");
+if (shipment == null) return;
+
+// get the packages related to this shipment in order of packages
+orderBy = UtilMisc.toList("shipmentPackageSeqId");
+shipmentPackages = shipment.getRelated("ShipmentPackage", orderBy);
+
+// first we scan the shipment items and count the quantity of each product that is being shipped
+quantityShippedByProduct = FastMap.newInstance();
+shipmentItems = shipment.getRelated("ShipmentItem");
+for (iter = shipmentItems.iterator(); iter.hasNext(); ) {
+    shipmentItem = iter.next();
+    productId = shipmentItem.get("productId");
+
+    shipped = quantityShippedByProduct.get(productId);
+    if (shipped == null) shipped = new Double(0);
+    shipped += shipmentItem.getDouble("quantity").doubleValue();
+    quantityShippedByProduct.put(productId, shipped);
+}
+
+// next scan the order items (via issuances) to count the quantity of each product requested
+quantityRequestedByProduct = FastMap.newInstance();
+issuances = shipment.getRelated("ItemIssuance");
+for (iter = issuances.iterator(); iter.hasNext(); ) {
+    issuance = iter.next();
+    orderItem = issuance.getRelatedOne("OrderItem");
+    productId = orderItem.get("productId");
+
+    requested = quantityRequestedByProduct.get(productId);
+    if (requested == null) requested = new Double(0);
+    cancelQuantity = orderItem.getDouble("cancelQuantity");
+    quantity = orderItem.getDouble("quantity");
+    requested += quantity.doubleValue() - (cancelQuantity != null ? cancelQuantity.doubleValue() : 0);
+    quantityRequestedByProduct.put(productId, requested);
+}
+
+// for each package, we want to list the quantities and details of each product
+packages = FastList.newInstance(); // note we assume that the package number is simply the index + 1 of this list
+for (iter = shipmentPackages.iterator(); iter.hasNext(); ) {
+    shipmentPackage = iter.next();
+    contents = shipmentPackage.getRelated("ShipmentPackageContent", UtilMisc.toList("shipmentItemSeqId"));
+
+    // each line is one logical Product and the quantities associated with it
+    lines = FastList.newInstance();
+    for (citer = contents.iterator(); citer.hasNext(); ) {
+        content = citer.next();
+        shipmentItem = content.getRelatedOne("ShipmentItem");
+        product = shipmentItem.getRelatedOne("Product");
+
+        line = FastMap.newInstance();
+        line.put("product", product);
+        line.put("quantityInPackage", content.get("quantity"));
+        line.put("quantityShipped", quantityShippedByProduct.get(product.get("productId")));
+        line.put("quantityRequested", quantityRequestedByProduct.get(product.get("productId")));
+        lines.add(line);
+    }
+    packages.add(lines);
+}
+context.put("packages", packages);

Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl?view=diff&rev=518682&r1=518681&r2=518682
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/PackingSlip.fo.ftl Thu Mar 15 09:31:50 2007
@@ -31,7 +31,6 @@
 </fo:layout-master-set>
 
     <#if hasPermission>
-        <#assign rowColor = "white">
         <#assign shipGroup = shipment.getRelatedOne("PrimaryOrderItemShipGroup")?if_exists>
         <#assign carrier = (shipGroup.carrierPartyId)?default("N/A")>
         <fo:page-sequence master-reference="main">
@@ -51,7 +50,10 @@
             </fo:block>
             <fo:block><fo:leader/></fo:block>
 
-            <fo:block font-size="14pt">${uiLabelMap.ProductShipmentId} #${shipmentId}</fo:block>
+
+            <#list packages as package>
+
+            <fo:block font-size="14pt">${uiLabelMap.ProductShipmentId} #${shipmentId} / Package ${package_index + 1}</fo:block>
             <fo:block font-size="12pt">${uiLabelMap.ProductOrderId} #${shipment.primaryOrderId?default("N/A")} / ${shipment.primaryShipGroupSeqId?default("N/A")}</fo:block>
             <fo:block><fo:leader/></fo:block>
 
@@ -110,47 +112,51 @@
             <fo:block space-after.optimum="10pt" font-size="10pt">
             <fo:table>
                 <fo:table-column column-width="250pt"/>
-                <fo:table-column column-width="100pt"/>
-                <fo:table-column column-width="100pt"/>
+                <fo:table-column column-width="67pt"/>
+                <fo:table-column column-width="67pt"/>
+                <fo:table-column column-width="67pt"/>
                 <fo:table-header>
                     <fo:table-row font-weight="bold">
                         <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>${uiLabelMap.ProductProduct}</fo:block></fo:table-cell>
-                        <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>${uiLabelMap.ProductQuantityRequested}</fo:block></fo:table-cell>
-                        <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>${uiLabelMap.ProductQuantityShipped}</fo:block></fo:table-cell>
+                        <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>Requested</fo:block></fo:table-cell>
+                        <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>In this Package</fo:block></fo:table-cell>
+                        <fo:table-cell padding="2pt" background-color="#D4D0C8"><fo:block>Total Shipped</fo:block></fo:table-cell>
                     </fo:table-row>
                 </fo:table-header>
                 <fo:table-body>
-                    <#list shipmentItemDatas as shipmentItem>
-                        <#assign itemIssuances = shipmentItem.itemIssuances>
-                        <#list itemIssuances as issue>
-                            <#assign orderItem = issue.getRelatedOne("OrderItem")>
-                            <#assign product = shipmentItem.product>
+                    <#list package as line>
+                            <#if ((line_index % 2) == 0)>
+                                <#assign rowColor = "white">
+                            <#else>
+                                <#assign rowColor = "#CCCCCC">
+                            </#if>
+
                             <fo:table-row>
                                 <fo:table-cell padding="2pt" background-color="${rowColor}">
-                                    <#if product?has_content>
-                                        <fo:block>${product.internalName?default("Internal Name Not Set!")} [${product.productId}]</fo:block>
+                                    <#if line.product?has_content>
+                                        <fo:block>${line.product.internalName?default("Internal Name Not Set!")} [${line.product.productId}]</fo:block>
                                     <#else/>
-                                        <fo:block>&nbsp;</fo:block>
+                                        <fo:block>${line.getClass().getName()}&nbsp;</fo:block>
                                     </#if>
                                 </fo:table-cell>
                                 <fo:table-cell padding="2pt" background-color="${rowColor}">
-                                    <fo:block>${orderItem.quantity}</fo:block>
+                                    <fo:block>${line.quantityRequested?default(0)}</fo:block>
                                 </fo:table-cell>
                                 <fo:table-cell padding="2pt" background-color="${rowColor}">
-                                    <fo:block>${issue.quantity}</fo:block>
+                                    <fo:block>${line.quantityInPackage?default(0)}</fo:block>
+                                </fo:table-cell>
+                                <fo:table-cell padding="2pt" background-color="${rowColor}">
+                                    <fo:block>${line.quantityShipped?default(0)}</fo:block>
                                 </fo:table-cell>
                             </fo:table-row>
-                            <#-- toggle the row color -->
-                            <#if rowColor == "white">
-                                <#assign rowColor = "#CCCCCC">
-                            <#else>
-                                <#assign rowColor = "white">
-                            </#if>
-                        </#list>
                     </#list>
                 </fo:table-body>
             </fo:table>
             </fo:block>
+
+            <#if package_has_next><fo:block break-before="page"/></#if>
+            </#list> <#-- packages -->
+
             <fo:block space-after.optimum="10pt" font-size="10pt">
             <fo:table>
                 <fo:table-column column-width="450pt"/>

Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml?view=diff&rev=518682&r1=518681&r2=518682
==============================================================================
--- ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml (original)
+++ ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Thu Mar 15 09:31:50 2007
@@ -275,7 +275,7 @@
 
                 <set field="shipmentId" from-field="parameters.shipmentId"/>
                 <script location="component://product/webapp/facility/WEB-INF/actions/shipment/ViewShipment.bsh"/>
-                <script location="component://product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh"/>
+                <script location="component://product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh"/>
             </actions>
             <widgets>
                 <platform-specific>