steveosoule
3/30/2015 - 7:14 PM

Miva - Detailed Order Summary Batch Report

Miva - Detailed Order Summary Batch Report

<mvt:comment><!-- Development Helper Variables --></mvt:comment>
<mvt:assign name="g.debug" value="0"/>
<mvt:assign name="g.force_download" value="0"/>

<mvt:comment><!-- Make the output download as an attatchement (if desired) --></mvt:comment>
<mvt:if expr="g.force_download">
    <mvt:assign name="l.header" value="miva_output_header( 'Content-Disposition', 'attachment; filename=order-summary_' $ s.dyn_time_t $ '.xls' )" />
</mvt:if>

<mvt:comment><!-- Global Helper / File Format Variables --></mvt:comment>
<mvt:assign name="g.tab" value="asciichar(9)"/>
<mvt:assign name="g.delimiter" value="g.tab"/>
<mvt:assign name="g.newline" value="asciichar(10)"/>

<mvt:comment><!-- Prepare & output the File's Header --></mvt:comment>
<mvt:assign name="l.settings:admin_order:header_row" value="
    'Order Info'                            $ g.delimiter $
        'Order Number'                      $ g.delimiter $
        'Order Date-Time'                   $ g.delimiter $
        'Order Date'                        $ g.delimiter $
        'Order Time'                        $ g.delimiter $
        'Order Status'                      $ g.delimiter $
        'Subtotal'                          $ g.delimiter $
        'Shipping Method'                   $ g.delimiter $
        'Shipping Amount'                   $ g.delimiter $
        'Tax'                               $ g.delimiter $
        'Total'                             $ g.delimiter $
        'Discounts'                         $ g.delimiter $
    'Ship To'                               $ g.delimiter $
        'First Name'                        $ g.delimiter $
        'Last Name'                         $ g.delimiter $
        'Email'                             $ g.delimiter $
        'Phone'                             $ g.delimiter $
        'Address 1'                         $ g.delimiter $
        'Address 2'                         $ g.delimiter $
        'City'                              $ g.delimiter $
        'State'                             $ g.delimiter $
        'Zip Code'                          $ g.delimiter $
    'Bill To'                               $ g.delimiter $
        'First Name'                        $ g.delimiter $
        'Last Name'                         $ g.delimiter $
        'Email'                             $ g.delimiter $
        'Phone'                             $ g.delimiter $
        'Address 1'                         $ g.delimiter $
        'Address 2'                         $ g.delimiter $
        'City'                              $ g.delimiter $
        'State'                             $ g.delimiter $
        'Zip Code'                          $ g.delimiter $
    'Payment'                               $ g.delimiter $
        'Authorized'                        $ g.delimiter $
        'Captured'                          $ g.delimiter $
        'Refunded'                          $ g.delimiter $
        'Net Captured'                      $ g.delimiter $
        'Payment Type'                      $ g.delimiter $
        'Card Brand'                        $ g.delimiter $
        'Account Number'                    $ g.delimiter $
        'AVS Response'                      $ g.delimiter $
        'CVV2 Response'                     $ g.delimiter $
        'Order ID'                          $ g.delimiter $
        'Transaction Reference'             $ g.delimiter $
        'Status'                            $ g.delimiter $
        'Response Timestamp'                $ g.delimiter $
    'Product Info'                          $ g.delimiter $
        'Items code'                        $ g.delimiter $
        'Items sku'                         $ g.delimiter $
        'Product name'                      $ g.delimiter $
        'Quantity'                          $ g.delimiter $
        'Weight'                            $ g.delimiter $
        'Price/Each'                        $ g.delimiter $
        'Total'                             $ g.delimiter $
    'Shipment Tracking'                     $ g.delimiter $
        'Type'                              $ g.delimiter $
        'Number'                            $ g.delimiter $
        'Date'                              $ g.delimiter $
        'Time'                              $ g.newline
"/>
&mvt:admin_order:header_row;

<mvt:comment><!-- Loop over all the orders in this batch... --></mvt:comment>
<mvt:foreach iterator="order" array="admin_order:orders">

    <mvt:comment><!-- Format Date & Time --></mvt:comment>
        <mvt:assign name="g.timestamp" value="l.settings:order:orderdate" />
        <mvt:assign name="g.timezone_offset" value="'local'" />
        <mvt:assign name="g.timezone_offset" value="'-4'" />

        <mvt:assign name="l.settings:order:year" value="time_t_year( l.settings:order:orderdate, g.timezone_offset )" />
        <mvt:assign name="l.settings:order:month" value="padl(time_t_month( l.settings:order:orderdate, g.timezone_offset ), 2, 0)" />
        <mvt:assign name="l.settings:order:day" value="padl(time_t_dayofmonth( l.settings:order:orderdate, g.timezone_offset ), 2, 0)" />
        <mvt:assign name="l.settings:order:24hour" value="padl(time_t_hour( l.settings:order:orderdate, g.timezone_offset ), 2, 0)" />
        <mvt:assign name="l.settings:order:min" value="padl(time_t_min( l.settings:order:orderdate, g.timezone_offset ), 2, 0)" />
        <mvt:assign name="l.settings:order:sec" value="padl(time_t_sec( l.settings:order:orderdate, g.timezone_offset ), 2, 0)" />

        <mvt:assign name="l.settings:order:formatted_orderdate" value="l.settings:order:year $ '-' $ l.settings:order:month $ '-' $ l.settings:order:day" />
        <mvt:assign name="l.settings:order:formatted_ordertime" value="l.settings:order:24hour $ ':' $ l.settings:order:min $ ':' $ l.settings:order:sec" />
        <mvt:assign name="l.settings:order:formatted_orderdatetime" value="l.settings:order:formatted_orderdate $ ' ' $ l.settings:order:formatted_ordertime" />

    <mvt:comment><!-- Subtotal & Discount Amounts --></mvt:comment>
        <mvt:foreach iterator="group" array="order:groups">
            <mvt:assign name="l.settings:order:subtotal" value="l.settings:order:subtotal + l.settings:group:subtotal" />
            <mvt:foreach iterator="discount" array="group:discounts">
                <mvt:assign name="l.settings:order:discount" value="l.settings:order:discount + l.settings:discount:discount" />
            </mvt:foreach>
        </mvt:foreach>

    <mvt:comment><!-- Tax & Shipping Amounts --></mvt:comment>
        <mvt:foreach iterator="charge" array="order:charges">
            <mvt:if expr="l.settings:charge:type EQ 'TAX'">
                <mvt:assign name="l.settings:order:tax:amount" value="l.settings:charge:amount" />
            </mvt:if>
            <mvt:if expr="l.settings:charge:type EQ 'SHIPPING'">
                <mvt:assign name="l.settings:order:shipping:amount" value="l.settings:charge:amount" />
            </mvt:if>
        </mvt:foreach>

    <mvt:comment><!-- Loop over order items... --></mvt:comment>
        <mvt:foreach iterator="group" array="order:groups">
            <mvt:assign name="l.settings:group:row" value="
                'Order Info'                                            $ g.delimiter $
                    l.settings:order:id                                 $ g.delimiter $
                    l.settings:order:formatted_orderdatetime            $ g.delimiter $
                    l.settings:order:formatted_orderdate                $ g.delimiter $
                    l.settings:order:formatted_ordertime                $ g.delimiter $
                    l.settings:order:formatted_status                   $ g.delimiter $
                    l.settings:order:subtotal                           $ g.delimiter $
                    l.settings:order:ship_method                        $ g.delimiter $
                    l.settings:order:shipping:amount                    $ g.delimiter $
                    l.settings:order:tax:amount                         $ g.delimiter $
                    l.settings:order:total                              $ g.delimiter $
                    l.settings:order:discount                           $ g.delimiter $
                'Ship To'                                               $ g.delimiter $
                    l.settings:order:ship_fname                         $ g.delimiter $
                    l.settings:order:ship_lname                         $ g.delimiter $
                    l.settings:order:ship_email                         $ g.delimiter $
                    l.settings:order:ship_phone                         $ g.delimiter $
                    l.settings:order:ship_addr1                         $ g.delimiter $
                    l.settings:order:ship_addr2                         $ g.delimiter $
                    l.settings:order:ship_city                          $ g.delimiter $
                    l.settings:order:ship_state                         $ g.delimiter $
                    l.settings:order:ship_zip                           $ g.delimiter $
                'Bill To'                                               $ g.delimiter $
                    l.settings:order:bill_fname                         $ g.delimiter $
                    l.settings:order:bill_lname                         $ g.delimiter $
                    l.settings:order:bill_email                         $ g.delimiter $
                    l.settings:order:bill_phone                         $ g.delimiter $
                    l.settings:order:bill_addr1                         $ g.delimiter $
                    l.settings:order:bill_addr2                         $ g.delimiter $
                    l.settings:order:bill_city                          $ g.delimiter $
                    l.settings:order:bill_state                         $ g.delimiter $
                    l.settings:order:bill_zip                           $ g.delimiter $
                'Payment'                                               $ g.delimiter $
                    l.settings:order:total_auth                         $ g.delimiter $
                    l.settings:order:total_capt                         $ g.delimiter $
                    l.settings:order:total_rfnd                         $ g.delimiter $
                    l.settings:order:net_capt                           $ g.delimiter $
                    l.settings:order:payment:descrip                    $ g.delimiter $
                    l.settings:order:payment:field:cardbrand            $ g.delimiter $
                    l.settings:order:payment:field:accountnum           $ g.delimiter $
                    l.settings:order:payment:field:avsrespcode          $ g.delimiter $
                    l.settings:order:payment:field:cvv2respcode         $ g.delimiter $
                    l.settings:order:payment:field:orderid              $ g.delimiter $
                    l.settings:order:payment:field:txrefnum             $ g.delimiter $
                    l.settings:order:payment:field:statusmsg            $ g.delimiter $
                    l.settings:order:payment:field:resptime             $ g.delimiter $
                'Product Info'                                          $ g.delimiter $
                    l.settings:group:code                               $ g.delimiter $
                    l.settings:group:product:sku                        $ g.delimiter $
                    l.settings:group:name                               $ g.delimiter $
                    l.settings:group:quantity                           $ g.delimiter $
                    l.settings:group:weight                             $ g.delimiter $
                    l.settings:group:price                              $ g.delimiter $
                    l.settings:group:subtotal                           $ g.delimiter $
                'Shipment Tracking'                                     $ g.delimiter $
                    l.settings:group:shipment:tracktype                 $ g.delimiter $
                    l.settings:group:shipment:tracknum                  $ g.delimiter $
                    l.settings:group:shipment:formatted_ship_date       $ g.delimiter $
                    l.settings:group:shipment:formatted_ship_time       $ g.newline
            "/>
            &mvt:group:row;
        </mvt:foreach>

</mvt:foreach>

<mvt:comment><!-- Development helper to view all of the available data --></mvt:comment>
<mvt:if expr="g.debug">
    <mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:admin_order), ',', '<br>'))" />
</mvt:if>