Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Search
Search


Forum Index » Templates

Post new topic   Reply to topic
Report to count pkgs shipped per service type
View previous topic :: View next topic  
Author Message
paulbishop



Joined: 23 Oct 2009
Posts: 10

PostPosted: Thu Feb 04, 2010 4:35 pm    Post subject: Report to count pkgs shipped per service type Reply with quote

I'm looking for a report that will out-put info as follows:
USPS Priority: 10
UPS Ground: 10
UPS 2nd Day Air: 5
All I can get is the total # of orders in the filter. (Using this example, it prints "25").

I tried altering the tracking number report, to no avail. I know I'm missing something really simple, but... Any help is greatly appreciated.
Thanks
_________________
Paul
V-LEDS.com
Back to top
View user's profile
Brandon



Joined: 14 Nov 2005
Posts: 704

PostPosted: Fri Feb 05, 2010 9:43 am    Post subject: Reply with quote

Try this. Its a quick hack of one our my more crazy templates so I hope I didn't break it.

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet[ <!ENTITY nl "&#xd;&#xa;"> <!ENTITY nbsp " "> ]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:import href="System\Common" />

<xsl:output method="html" encoding="utf-8" />

<sw:settings>
    <sw:email>
        <sw:store id="1">
            <sw:to>{//Order/Address[@type='bill']/Email}</sw:to>
            <sw:subject>{//Reference}</sw:subject>
        </sw:store>
    </sw:email>
    <sw:saving>
        <sw:filename>{//Reference}</sw:filename>
    </sw:saving>
    <sw:general>
        <sw:type>report</sw:type>
    </sw:general>
</sw:settings>

<xsl:key name="shipment_typeKey" match="Order/Shipment" use="ServiceUsed" />
<xsl:variable name="orders" select="//Order/Shipment[IsProcessed='true'][Voided=false()]/.." />

<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="//Store/StoreName" /><xsl:text> </xsl:text><xsl:value-of select="//Template/Name" /></title>

<style type="text/css">
body,
table {
    font-family: Tahoma;
    font-size: 8.5pt;
}
h1 {
    font-size: 130%;
    font-weight: 600;
    text-align: center;
    padding: 0;
    margin-bottom: 0.5em;
}
    h1 span {
        font-size: 85%;
        font-weight: 300;
    }
h2 {
    font-size: 105%;
    font-weight: 600;
    padding: 0;
    margin: 0 0 0.25em 0;
}
    h2 span {
        font-size: 90%;
        font-weight: 600;
    }
</style>
</head>
<body>

<h1><xsl:value-of select="//Template/Name" /><xsl:text> </xsl:text><span>(Generated <xsl:value-of select="sw:ToShortDate(//Generated)" />)</span></h1>

<div class="shipping-container">
    <h2>Summary of <xsl:value-of select="count($orders)" /> Orders and <xsl:value-of select="count($orders/Shipment[IsProcessed='true'][Voided=false()])" /> Shipments<br /></h2>
</div>

<xsl:for-each select="$orders/Shipment[generate-id() = generate-id(key('shipment_typeKey', ServiceUsed)[1])]">
    <xsl:variable name="shipmentGroup" select="key('shipment_typeKey', ServiceUsed)" />

    <xsl:variable name="count_shipments" select="count($shipmentGroup)" />

<div class="shipping-container">
    <xsl:value-of select="ServiceUsed" /><xsl:text>: </xsl:text><xsl:value-of select="$count_shipments" />
</div>
</xsl:for-each>

</body>
</html>

</xsl:template>
</xsl:stylesheet>


I did a quick preview and it looked right....
Back to top
View user's profile
paulbishop



Joined: 23 Oct 2009
Posts: 10

PostPosted: Fri Feb 05, 2010 12:23 pm    Post subject: Reply with quote

Brandon,
Thank You! I didn't know about the "shipment_typeKey", which is the solution here!
_________________
Paul
V-LEDS.com
Back to top
View user's profile
Brandon



Joined: 14 Nov 2005
Posts: 704

PostPosted: Fri Feb 05, 2010 12:33 pm    Post subject: Reply with quote

If you look towards the top of the template, we actually define shipment_typeKey as an XSL key. XSL keys are great shortcuts for grouping order, shipment or customer nodes for summary reports like these. One of the many unsung heroes of XSLT
Back to top
View user's profile
paulbishop



Joined: 23 Oct 2009
Posts: 10

PostPosted: Sat Feb 06, 2010 10:47 am    Post subject: Reply with quote

Brandon (or any other capable help Smile );
I see others have, in the past, asked for one more piece of this: Displaying the charges/costs by ServiceUsed. Once the shipments are broken out by carrier in this template Brandon supplied, can the charges/costs for the shipments by carrier be displayed?
All the codes I see have a total for all orders. So, can the display look like this?

CARRIER PIECES SHIP_REVENUE SHIP_EXPENSE SHIP_P&L
UPS Ground 3 34.00 20.00 14.00
USPS Priority 5 20.00 18.00 2.00

(all #s obviously made up, but I think the idea is clear?)

Thanks for the help
_________________
Paul
V-LEDS.com
Back to top
View user's profile
Brandon



Joined: 14 Nov 2005
Posts: 704

PostPosted: Mon Feb 08, 2010 9:20 am    Post subject: Reply with quote

Easily. Though you'd probably be looking for a plain text output so that you could import it into Excel or something, right? Here's a tab delimited:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet[ <!ENTITY nl "&#xd;&#xa;"> <!ENTITY nbsp " "> <!ENTITY tab " "> ]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:import href="System\Common" />

<xsl:output method="text" encoding="utf-8" />

<xsl:key name="shipment_typeKey" match="Order/Shipment" use="ServiceUsed" />
<xsl:variable name="orders" select="//Order/Shipment[IsProcessed='true'][Voided=false()]/.." />

<xsl:template match="/">

<xsl:text>CARRIER_SERVICE&tab;SHIPMENTS&tab;SHIP_REVENUE&tab;SHIP_EXPENSE&tab;SHIP_PL&nl;</xsl:text>
<xsl:for-each select="$orders/Shipment[generate-id() = generate-id(key('shipment_typeKey', ServiceUsed)[1])]">
    <xsl:variable name="shipmentGroup" select="key('shipment_typeKey', ServiceUsed)" />

    <xsl:variable name="count_shipments" select="count($shipmentGroup)" />
    <xsl:variable name="shipment_revenue" select="sum($shipmentGroup/../Charge[Type='SHIPPING']/Amount)" />
    <xsl:variable name="shipment_expense" select="sum($shipmentGroup/TotalCharges)" />

    <xsl:value-of select="ServiceUsed" /><xsl:text>&tab;</xsl:text>
    <xsl:value-of select="$count_shipments" /><xsl:text>&tab;</xsl:text>
    <xsl:value-of select="format-number($shipment_revenue, '#,##0.00')" /><xsl:text>&tab;</xsl:text>
    <xsl:value-of select="format-number($shipment_expense, '#,##0.00')" /><xsl:text>&tab;</xsl:text>
    <xsl:value-of select="format-number(($shipment_revenue - $shipment_expense), '#,##0.00')" /><xsl:text>&nl;</xsl:text>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>
Back to top
View user's profile
monstersgolf



Joined: 17 Dec 2009
Posts: 3

PostPosted: Wed Mar 03, 2010 7:34 am    Post subject: Reply with quote

Hi Brandon,

I tried using this code but didn't really get the any information. For some reason it only showed "CARRIER PIECES SHIP_REVENUE SHIP_EXPENSE SHIP_P&L" in the report but no information. I am very new in using templates so I could be doing something wrong. My steps were 1. Create New Template under Reports 2. Copy and Paste the code you provided 3. Highlight Multiple shipments in customer grid 4. Preview with new template. Let me know if I am missing something.
Back to top
View user's profile
Wes
Site Admin


Joined: 07 Oct 2002
Posts: 6745

PostPosted: Wed Mar 03, 2010 9:52 am    Post subject: Reply with quote

The following template may be helpful to you:

Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw">
<xsl:import href="System\Common" />

<xsl:output method="html" encoding="utf-8" />

<sw:settings>
    <sw:preview>
        <sw:filter>Shipped Orders</sw:filter>
        <sw:count>32</sw:count>
    </sw:preview>
    <sw:email>
        <sw:store id="1">
            <sw:to>{//Order/Address[@type='bill']/Email}</sw:to>
            <sw:subject>{//Reference}</sw:subject>
        </sw:store>
    </sw:email>
    <sw:saving>
        <sw:filename>{//Reference}</sw:filename>
    </sw:saving>
    <sw:general>
        <sw:type>report</sw:type>
    </sw:general>
</sw:settings>

<xsl:template match="/">
<html>

<head>
    <title>Interapptive ShipWorks Template</title>
   
    <!-- CSS -->
    <style>
        body, table, tr, td {font-family: Tahoma; font-size: 10pt;}
        span.example {color: blue; font-weight: bold;}
       
        #details tr.gridrow td
        {
           border-top: 1px solid darkgray;
           padding-top: 10px;
           padding-left: 10px;
           padding-right: 10px;
        }
    </style>
</head>

<body>
<font style="font-size:16pt; font-weight:bold;">Order Charge and Shipping Report</font><br />
<br />
Printed: <xsl:value-of select="sw:ToShortDate(//Generated)" /><br />
Filter Used: <xsl:value-of select="//ActiveFilter" /><br />
Orders Selected: <xsl:value-of select="count(//Order)" /><br />
Total Line Items: <xsl:value-of select="count(//Order/Item)" /><br />
Total Quantity of All Items: <xsl:value-of select="sum(//Order/Item/Quantity)" /><br />
<Br />

<b>For All <xsl:value-of select="count(//Order)" /> Orders Currently Selected:</b><br />

<table width="85%" cellspacing="0" id="details">

<tr class="gridrow">
<td>Total of all Orders<br />
(Includes Tax, Shipping, Insurance, Etc.):</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Order/Total), '#,##0.00')" /></td>
</tr>


<tr class="gridrow">
<td width="80%">Total of all Line Items:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Order/Item/Total), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total Shipping Charged to Customers:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Order/Charge[Type='SHIPPING']/Amount), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total Insurance Charged to Customers:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Order/Charge[Type='INSURANCE']/Amount), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total Sales Tax Charged to Customers:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Order/Charge[Type='TAX']/Amount), '#,##0.00')" /></td>
</tr>


<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true'])" />  Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='Custom'])" /> 'Custom' Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='Custom']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='DHL'])" /> DHL Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='DHL']/TotalCharges), '#,##0.00')" /></td>
</tr>



<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='FedEx'])" /> FedEx Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='FedEx']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='UPS OnLine Tools'])" /> UPS OnLine Tools Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='UPS OnLine Tools']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='WorldShip'])" /> UPS WorldShip Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='WorldShip']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='USPS Download'])" /> USPS Download Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='USPS Download']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='Endicia DAZzle'])" />Endicia DAZzle Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='Endicia DAZzle']/TotalCharges), '#,##0.00')" /></td>
</tr>

<tr class="gridrow">
<td>Total of All <xsl:value-of select="count(//Shipment[IsProcessed='true' and ShipmentType='Stamps.com'])" /> Stamps.com Shipments Processed:</td>
<td align="right">$<xsl:value-of select="format-number(sum(//Shipment[ShipmentType='Stamps.com']/TotalCharges), '#,##0.00')" /></td>
</tr>




</table>


</body>

</html>

</xsl:template>
</xsl:stylesheet>

_________________
Wes
Interapptive, Inc.
Back to top
View user's profile Visit poster's website
monstersgolf



Joined: 17 Dec 2009
Posts: 3

PostPosted: Wed Mar 03, 2010 1:21 pm    Post subject: Reply with quote

Works Perfect. Thanks Wes!!
Back to top
View user's profile
rjgolden



Joined: 20 Apr 2010
Posts: 1

PostPosted: Thu Jul 15, 2010 12:32 pm    Post subject: Convert to version 3.0? Reply with quote

monstersgolf wrote:
Works Perfect. Thanks Wes!!


Wes, is there an easy fix to get these templates to work in version 3.x? Thanks, RG
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index » Templates All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  

Powered by phpBB © 2001, 2002 phpBB Group