Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Forked from tessguefen/example.xml
Created December 7, 2016 16:14
Show Gist options
  • Save steveosoule/17550aa343c1844f432b1773c9dcfada to your computer and use it in GitHub Desktop.
Save steveosoule/17550aa343c1844f432b1773c9dcfada to your computer and use it in GitHub Desktop.
Order report with dynamic headers (product codes).
<mvt:assign name="l.comma" value="asciichar('44')" />
<mvt:assign name="l.linebreak" value="asciichar('10')" />
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:foreach iterator="group" array="order:groups">
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
<mvt:if expr="miva_array_search( l.settings:products, 0, l.item, 'l.item:code EQ l.settings:group:code' )">
<mvt:assign name="l.item:quantity" value="l.item:quantity + l.settings:group:quantity" />
<mvt:assign name="l.item:subtotal" value="l.item:subtotal + l.settings:group:subtotal" />
<mvt:else>
<mvt:assign name="l.temp" value="NULL" />
<mvt:assign name="l.temp:code" value="l.settings:group:code" />
<mvt:assign name="l.temp:name" value="l.settings:group:name" />
<mvt:assign name="l.temp:subtotal" value="l.settings:group:subtotal" />
<mvt:assign name="l.temp:quantity" value="l.settings:group:quantity" />
<mvt:assign name="l.success" value="miva_array_insert( l.settings:products, l.temp, -1 )" />
</mvt:if>
<mvt:comment> <!-- Build Dynamic Array --> </mvt:comment>
</mvt:foreach>
</mvt:foreach>
<mvt:foreach iterator="order" array="admin_order:orders">
<mvt:assign name="l.row" value="l.row $ '<tr>' $ '<td>' $ l.settings:order:date $ '</td>' $ '<td>' $ l.settings:order:id $ '</td>'" />
<mvt:comment><mvt:assign name="l.row" value="l.row $ l.settings:order:date $ l.comma $ l.settings:order:id" /></mvt:comment>
<mvt:foreach iterator="product" array="products">
<mvt:if expr="miva_array_search( l.settings:order:groups, 0, l.group, 'l.group:code EQ l.settings:product:code' )">
<mvt:comment> <mvt:do file="g.Module_Store_Module_Currency" name="l.settings:product:formatted_subtotal" value="CurrencyModule_AddFormatting( g.Store:currncy_mod, l.settings:product:subtotal )" /></mvt:comment>
<mvt:comment><mvt:assign name="l.row" value="l.row $ l.comma $ l.settings:group:subtotal" /></mvt:comment>
<mvt:assign name="l.row" value="l.row $ '<td align=\"right\">' $ l.group:subtotal $ '</td>'" />
<mvt:else>
<mvt:comment><mvt:assign name="l.row" value="l.row $ l.comma $ '\' '" /></mvt:comment>
<mvt:assign name="l.row" value="l.row $ '<td align=\"right\">$0.00</td>'" />
</mvt:if>
</mvt:foreach>
<mvt:comment><mvt:assign name="l.row" value="l.row $ l.linebreak" /></mvt:comment>
<mvt:assign name="l.row" value="l.row $ '</tr>'" />
</mvt:foreach>
<mvt:assign name="l.header" value="'<tr><td>Order Date</td><td>Order</td>'" />
<mvt:foreach iterator="item" array="products">
<mvt:comment><mvt:assign name="l.header" value="l.header $ l.comma $ l.item:name" /></mvt:comment>
<mvt:assign name="l.header" value="l.header $ '<td>' $ l.settings:item:code $ '</td>'" />
<mvt:assign name="l.total_units" value="l.total_units $ '<td align=\"right\">' $ l.settings:item:quantity $ '</td>'" />
<mvt:assign name="l.total_dollars" value="l.total_dollars $ '<td align=\"right\">' $ l.settings:item:subtotal $ '</td>'" />
</mvt:foreach>
<table cellpadding="5" cellspacing="2" border="1">
<mvt:eval expr="l.header $ '</tr>' $ l.row" />
<tr>
<td colspan="2">Total Units</td>
<mvt:eval expr="l.total_units" />
</tr>
<tr>
<td colspan="2">Total Dollar Amounts</td>
<mvt:eval expr="l.total_dollars" />
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment